content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
test = {
'name': 'Question',
'points': 1,
'suites': [
{
'cases': [
{
'code': r"""
>>> int(sum(train.PredGenderAge13))
351
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> int(sum(test.PredG... | test = {'name': 'Question', 'points': 1, 'suites': [{'cases': [{'code': '\n >>> int(sum(train.PredGenderAge13))\n 351\n ', 'hidden': False, 'locked': False}, {'code': '\n >>> int(sum(test.PredGenderAge13))\n 165\n ', 'hidden': False, 'locked': False}, {'code': '\n ... |
friends = ["Rolf", "Charlie", "Anna", "Bob", "Jen"]
print(friends[2:4])
print(friends[2:])
print(friends[:4])
print(friends[:])
print(friends[-3:])
print(friends[:-2])
print(friends[-3:-1])
# You can slice with tuples and strings as well.
# More advanced content in our slices blog posts!
# https://blog.tecladocode... | friends = ['Rolf', 'Charlie', 'Anna', 'Bob', 'Jen']
print(friends[2:4])
print(friends[2:])
print(friends[:4])
print(friends[:])
print(friends[-3:])
print(friends[:-2])
print(friends[-3:-1]) |
def search(it,name,**kwargs):
'''Search an iterable `it` for name `name`. This is commonly used to search the columns of Pandas DataFrames.
Toggle case-sensitivity with `case` (default=False).
Toggle removing underscores with `remove_us` (default=False).'''
#Initial setup
it_names_orig = list(it)... | def search(it, name, **kwargs):
"""Search an iterable `it` for name `name`. This is commonly used to search the columns of Pandas DataFrames.
Toggle case-sensitivity with `case` (default=False).
Toggle removing underscores with `remove_us` (default=False)."""
it_names_orig = list(it)
try:
it... |
def is_madvah_array(array):
"""Check if array matches condition required for a Madvah Array.
The Madvah Array has the following property:
a[0] = a[1] + a[2] = a[3] + a[4] + a[5] = a[6] + a[7] + a[8] + a[9] = ...
Parameters
----------
array : list(int)
List of integers.
Returns
... | def is_madvah_array(array):
"""Check if array matches condition required for a Madvah Array.
The Madvah Array has the following property:
a[0] = a[1] + a[2] = a[3] + a[4] + a[5] = a[6] + a[7] + a[8] + a[9] = ...
Parameters
----------
array : list(int)
List of integers.
Returns
... |
"""
Search in a row wise and column wise sorted matrix
Problem Description
Given a matrix of integers A of size N x M and an integer B.
In the given matrix every row and column is sorted in increasing order. Find and return the position of B in the matrix in the given form:
If A[i][j] = B then return (i * 1009 + j)
If... | """
Search in a row wise and column wise sorted matrix
Problem Description
Given a matrix of integers A of size N x M and an integer B.
In the given matrix every row and column is sorted in increasing order. Find and return the position of B in the matrix in the given form:
If A[i][j] = B then return (i * 1009 + j)
If... |
n = int(input())
for i in range(1, n + 1):
digits_sum = 0
for digits in str(i):
digits_sum += int(digits)
is_special = digits_sum in [5, 7, 11]
print(f"{i} -> {is_special}")
| n = int(input())
for i in range(1, n + 1):
digits_sum = 0
for digits in str(i):
digits_sum += int(digits)
is_special = digits_sum in [5, 7, 11]
print(f'{i} -> {is_special}') |
# one list using
# the other list
def sort_list(list1, list2):
zipped_pairs = zip(list2, list1)
z = [x for _, x in sorted(zipped_pairs)]
return z
# driver code
x = ["a", "b", "c", "d", "e", "f", "g", "h", "i"]
y = [0, 1, 1, 0, 1, 2, 2, 0, 1]
print(sort_list(x, y))
x = ["g", "e", "e", "k", "s", "f",... | def sort_list(list1, list2):
zipped_pairs = zip(list2, list1)
z = [x for (_, x) in sorted(zipped_pairs)]
return z
x = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']
y = [0, 1, 1, 0, 1, 2, 2, 0, 1]
print(sort_list(x, y))
x = ['g', 'e', 'e', 'k', 's', 'f', 'o', 'r', 'g', 'e', 'e', 'k', 's']
y = [0, 1, 1, 0, 1,... |
employee_one_capacity = int(input())
employee_two_capacity = int(input())
employee_three_capacity = int(input())
total_people_count = int(input())
total_people_per_hour = employee_one_capacity + employee_two_capacity + employee_three_capacity
BREAK = 1
total_time = 0
while total_people_count > 0:
total_... | employee_one_capacity = int(input())
employee_two_capacity = int(input())
employee_three_capacity = int(input())
total_people_count = int(input())
total_people_per_hour = employee_one_capacity + employee_two_capacity + employee_three_capacity
break = 1
total_time = 0
while total_people_count > 0:
total_people_count... |
class Solution(object):
def isIsomorphic(self, s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
char_map, target = {}, set()
for c1, c2 in zip(s, t):
if c1 in char_map:
if char_map[c1] != c2:
return False
... | class Solution(object):
def is_isomorphic(self, s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
(char_map, target) = ({}, set())
for (c1, c2) in zip(s, t):
if c1 in char_map:
if char_map[c1] != c2:
return ... |
class Solution:
def longestPath(self, parent: List[int], s: str) -> int:
n = len(parent)
ans = 0
graph = [[] for _ in range(n)]
for i in range(1, n):
graph[parent[i]].append(i)
def longestPathDownFrom(u: int) -> int:
nonlocal ans
max1 = 0
max2 = 0
for v in graph[u]... | class Solution:
def longest_path(self, parent: List[int], s: str) -> int:
n = len(parent)
ans = 0
graph = [[] for _ in range(n)]
for i in range(1, n):
graph[parent[i]].append(i)
def longest_path_down_from(u: int) -> int:
nonlocal ans
max1... |
{
'includes': [ '../common.gyp' ],
'targets': [
{
'target_name': 'libpng',
'type': 'static_library',
'include_dirs': [
'.',
'../zlib'
],
'sources': [
'png.c',
'pngerror.c',
'pngget.c',
'pngmem.c',
'pngpread.c',
'pngrea... | {'includes': ['../common.gyp'], 'targets': [{'target_name': 'libpng', 'type': 'static_library', 'include_dirs': ['.', '../zlib'], 'sources': ['png.c', 'pngerror.c', 'pngget.c', 'pngmem.c', 'pngpread.c', 'pngread.c', 'pngrio.c', 'pngrtran.c', 'pngrutil.c', 'pngset.c', 'pngtest.c', 'pngtrans.c', 'pngwio.c', 'pngwrite.c',... |
#
# $Id: __init__.py 778 2011-08-16 07:24:09Z hat $
#
"""
Susyna
======
Python package for SUpervisor SYnthesis for Nondeterministic Automata (SUSYNA).
@todo: Write down what exists in the package and how to use it.
"""
version = "0.4.4"
installed = True
| """
Susyna
======
Python package for SUpervisor SYnthesis for Nondeterministic Automata (SUSYNA).
@todo: Write down what exists in the package and how to use it.
"""
version = '0.4.4'
installed = True |
"""Utility macros for buildpacks."""
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
def buildpack(name, executables, descriptor = "buildpack.toml", srcs = None, extension = "tgz", strip_prefix = ".", visibility = None):
"""Macro to create a single buildpack as a tgz or tar archive.
The result ... | """Utility macros for buildpacks."""
load('@bazel_tools//tools/build_defs/pkg:pkg.bzl', 'pkg_tar')
def buildpack(name, executables, descriptor='buildpack.toml', srcs=None, extension='tgz', strip_prefix='.', visibility=None):
"""Macro to create a single buildpack as a tgz or tar archive.
The result is a tar or... |
def passcode_derivation(file):
text_file = open(file, "r")
lines = text_file.read().split()
b0 = []
b1 = []
b2 = []
b3 = []
b4 = []
b5 = []
b6 = []
b7 = []
b8 = []
b9 = []
for line in lines:
num_list = b0
num_str = "0"
if ... | def passcode_derivation(file):
text_file = open(file, 'r')
lines = text_file.read().split()
b0 = []
b1 = []
b2 = []
b3 = []
b4 = []
b5 = []
b6 = []
b7 = []
b8 = []
b9 = []
for line in lines:
num_list = b0
num_str = '0'
if line[2] == num_str:
... |
"""Top-level package for Python Boilerplate."""
__author__ = """Lars Claussen"""
__email__ = 'claussen.lars@nelen-schuurmans.nl'
__version__ = '0.1.0'
| """Top-level package for Python Boilerplate."""
__author__ = 'Lars Claussen'
__email__ = 'claussen.lars@nelen-schuurmans.nl'
__version__ = '0.1.0' |
# -*- coding:utf-8 -*-
#https://leetcode.com/problems/container-with-most-water/description/
class Solution(object):
def maxArea(self, height):
"""
:type height: List[int]
:rtype: int
"""
l, r = 0, len(height) - 1
ret = 0
while l < r:
if... | class Solution(object):
def max_area(self, height):
"""
:type height: List[int]
:rtype: int
"""
(l, r) = (0, len(height) - 1)
ret = 0
while l < r:
if height[l] < height[r]:
ret = max(ret, height[l] * (r - l))
l += 1... |
INPUT = 303
def spinlock(step):
"""
>>> spinlock(3)
638
"""
max_value = 2017
cycle_buffer = [0]
position = 0
for value in range(1, max_value + 1):
position = (position + step) % len(cycle_buffer) + 1
cycle_buffer.insert(position, value)
position = (position + 1) ... | input = 303
def spinlock(step):
"""
>>> spinlock(3)
638
"""
max_value = 2017
cycle_buffer = [0]
position = 0
for value in range(1, max_value + 1):
position = (position + step) % len(cycle_buffer) + 1
cycle_buffer.insert(position, value)
position = (position + 1) % le... |
def pentagon():
ps = set()
i = 1
while True:
i += 1
s = (3*i*i-i)/2
for Pj in ps:
if s-Pj in ps and s-2*Pj in ps:
return s-2*Pj
ps.add(s)
print('result:'+str(pentagon()))
| def pentagon():
ps = set()
i = 1
while True:
i += 1
s = (3 * i * i - i) / 2
for pj in ps:
if s - Pj in ps and s - 2 * Pj in ps:
return s - 2 * Pj
ps.add(s)
print('result:' + str(pentagon())) |
# AUTOGENERATED BY NBDEV! DO NOT EDIT!
__all__ = ["index", "modules", "custom_doc_links", "git_url"]
index = {"GenVars": "00_basics.ipynb",
"CommonCauses": "00_basics.ipynb",
"Instruments": "00_basics.ipynb",
"EffectModifiers": "00_basics.ipynb",
"Treatments": "00_basics.ipynb",
... | __all__ = ['index', 'modules', 'custom_doc_links', 'git_url']
index = {'GenVars': '00_basics.ipynb', 'CommonCauses': '00_basics.ipynb', 'Instruments': '00_basics.ipynb', 'EffectModifiers': '00_basics.ipynb', 'Treatments': '00_basics.ipynb', 'initialize': '00_basics.ipynb', 'generate': '00_basics.ipynb', 'get_obs': '00_... |
def check(line):
return max(line) - min(line)
def aoc(data):
return sum([check([int(x) for x in line.split()]) for line in data.split("\n")])
| def check(line):
return max(line) - min(line)
def aoc(data):
return sum([check([int(x) for x in line.split()]) for line in data.split('\n')]) |
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 26 10:42:52 2021
@author: Easin
"""
in1 = input()
in1 = int(in1)
in2 = input().split()
count = 0
for val in range(len(in2)):
count += int(in2[val])
total = count/in1
print(total) | """
Created on Mon Jul 26 10:42:52 2021
@author: Easin
"""
in1 = input()
in1 = int(in1)
in2 = input().split()
count = 0
for val in range(len(in2)):
count += int(in2[val])
total = count / in1
print(total) |
# -*- coding: utf-8 -*-
"""
ytelapi
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
"""
class AudioDirectionEnum(object):
"""Implementation of the 'AudioDirection' enum.
The direction the audio effect should be placed on. If IN, the effects
will occu... | """
ytelapi
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
"""
class Audiodirectionenum(object):
"""Implementation of the 'AudioDirection' enum.
The direction the audio effect should be placed on. If IN, the effects
will occur on the incoming audio stream. If OUT,... |
class Fileformat(object):
def __init__(self, filepath, **kwargs):
self.filepath = filepath
self.kwargs = kwargs
self.reader = self.load_reader()
self.fieldnames = self.load_fields()
self.meta = self.load_meta()
def __len__(self):
return len(self.reader)
... | class Fileformat(object):
def __init__(self, filepath, **kwargs):
self.filepath = filepath
self.kwargs = kwargs
self.reader = self.load_reader()
self.fieldnames = self.load_fields()
self.meta = self.load_meta()
def __len__(self):
return len(self.reader)
def... |
# -*- coding: utf-8 -*-
"""
This is a Django_ integration of Select2_.
The app includes Select2 driven Django Widgets and Form Fields.
.. _Django: https://www.djangoproject.com/
.. _Select2: http://ivaynberg.github.com/select2/
"""
__version__ = "5.4.2"
| """
This is a Django_ integration of Select2_.
The app includes Select2 driven Django Widgets and Form Fields.
.. _Django: https://www.djangoproject.com/
.. _Select2: http://ivaynberg.github.com/select2/
"""
__version__ = '5.4.2' |
#!/usr/bin/env python3
def fill(ls, capacity, config=None):
if capacity == 0:
return [config]
if not ls or capacity < 0:
return []
if config is None:
config = []
return fill(ls[:-1], capacity, config) + fill(ls[:-1], capacity-ls[-1], config+[ls[-1]])
def main():
try:
... | def fill(ls, capacity, config=None):
if capacity == 0:
return [config]
if not ls or capacity < 0:
return []
if config is None:
config = []
return fill(ls[:-1], capacity, config) + fill(ls[:-1], capacity - ls[-1], config + [ls[-1]])
def main():
try:
capacity = 150
... |
def iea37_names():
return [('P', 'probability'),
('TI', 'turbulence_intensity'),
('wd', 'wind_direction'),
('ws', 'wind_speed'),
('Sector_frequency', 'sector_probability'),
('Weibull_A', 'weibull_a'),
('Weibull_k', 'weibull_k')]
| def iea37_names():
return [('P', 'probability'), ('TI', 'turbulence_intensity'), ('wd', 'wind_direction'), ('ws', 'wind_speed'), ('Sector_frequency', 'sector_probability'), ('Weibull_A', 'weibull_a'), ('Weibull_k', 'weibull_k')] |
# -*- coding: utf-8 -*-
# @Time: 2020/3/4 11:55
# @Author: GraceKoo
# @File: 61_rotate-list.py
# @Desc:https://leetcode-cn.com/problems/rotate-list/
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def rotateRight(self,... | class Listnode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def rotate_right(self, head: ListNode, k: int) -> ListNode:
if not head or head.next:
return head
length_of_nodes = 1
old_tail = head
while old_tail.next:
... |
'''
A pivot table is just a DataFrame with sorted indexes, so the techniques you have learned already can be used to subset them. In particular, the .loc[] + slicing combination is often helpful.
pandas is loaded as pd. temp_by_country_city_vs_year is available.
'''
# Subset for Egypt to India
temp_by_country_city_vs_... | """
A pivot table is just a DataFrame with sorted indexes, so the techniques you have learned already can be used to subset them. In particular, the .loc[] + slicing combination is often helpful.
pandas is loaded as pd. temp_by_country_city_vs_year is available.
"""
temp_by_country_city_vs_year.loc['Egypt':'India']
te... |
class Model:
def __init__(self):
self.capacity = 0.0
self.i_flow = 0.0
self.SoC = 0.0
def step(self, value):
self.SoC += (self.i_flow - 75) / self.capacity
self.SoC = max(0, min(self.SoC, 1))
| class Model:
def __init__(self):
self.capacity = 0.0
self.i_flow = 0.0
self.SoC = 0.0
def step(self, value):
self.SoC += (self.i_flow - 75) / self.capacity
self.SoC = max(0, min(self.SoC, 1)) |
class Person:
# A class that has the person's data
def __init__(self):
# The initialization function of the class
self.name = ""
self.tel = ""
self.addr = ""
self.descr = ""
pass
| class Person:
def __init__(self):
self.name = ''
self.tel = ''
self.addr = ''
self.descr = ''
pass |
# COLUMNS
ASIGNATURA_COLUMNS = ["id_asignatura", "nombre"]
# TABLES
ASIGNATURA_TABLE = "asignatura"
# WHERE COLUMNS
| asignatura_columns = ['id_asignatura', 'nombre']
asignatura_table = 'asignatura' |
class ChannelHead:
def __init__(self):
pass
def pack_moves(self, moves):
pass # return (binary channel pattern string, remaining moves)
def can_move_simul(move1, move2): # both arguments are 4-tuples, (tips, ml, source, dest)
tips, mls, sources, dests = zip(move1, move2)
... | class Channelhead:
def __init__(self):
pass
def pack_moves(self, moves):
pass
def can_move_simul(move1, move2):
(tips, mls, sources, dests) = zip(move1, move2)
move_components = zip(sources, tips, dests)
xy_deltas = (None, None, None)
for (i, (pos1, pos2)) ... |
class CategoryType(Enum, IComparable, IFormattable, IConvertible):
"""
The type of category.
enum CategoryType,values: AnalyticalModel (5),Annotation (2),Internal (4),Invalid (0),Model (1)
"""
def __eq__(self, *args):
""" x.__eq__(y) <==> x==yx.__eq__(y) <==> x==yx.__eq__(y) <==> x==y ... | class Categorytype(Enum, IComparable, IFormattable, IConvertible):
"""
The type of category.
enum CategoryType,values: AnalyticalModel (5),Annotation (2),Internal (4),Invalid (0),Model (1)
"""
def __eq__(self, *args):
""" x.__eq__(y) <==> x==yx.__eq__(y) <==> x==yx.__eq__(y) <==> x==y """
... |
def encodeRepeatingKeyXor(s, key):
keySize = len(s)
mask = expandToLength(key,keySize)
xor = [ ord(x) ^ ord(y) for x, y in zip(s, mask) ]
b16_xor_tokens = map(lambda x: hex(x), xor)
return ''.join(map(lambda x: x[2:].zfill(2), b16_xor_tokens))
def expandToLength(s, length):
return (s * ... | def encode_repeating_key_xor(s, key):
key_size = len(s)
mask = expand_to_length(key, keySize)
xor = [ord(x) ^ ord(y) for (x, y) in zip(s, mask)]
b16_xor_tokens = map(lambda x: hex(x), xor)
return ''.join(map(lambda x: x[2:].zfill(2), b16_xor_tokens))
def expand_to_length(s, length):
return (s *... |
# run_game = True
# car_running = False
# while run_game == True:
# #UI = user input
# UI = (input('>'))
# if UI == 'start':
# car_running = True
# print('Car started... Ready to go!')
# elif UI == 'quit':
# run_game = False
# break
# elif UI == 'stop':
# ... | command = ''
started = False
while True:
command = input('>').lower()
if command == 'start':
if started:
print('Car is already started!')
else:
started = True
print('Car started...')
elif command == 'stop':
if not started:
print('Car is... |
def even_numbers(function):
def wrapper(numbers):
result = function(numbers)
return [num for num in result if num % 2 == 0]
return wrapper
@even_numbers
def get_numbers(numbers):
return numbers
print(get_numbers([1, 2, 3, 4, 5]))
| def even_numbers(function):
def wrapper(numbers):
result = function(numbers)
return [num for num in result if num % 2 == 0]
return wrapper
@even_numbers
def get_numbers(numbers):
return numbers
print(get_numbers([1, 2, 3, 4, 5])) |
#####################################################################################
# #
# Script to start client application #
# ... | def start_application(name):
app_manager = AdminControl.queryNames('node=DefaultNode01,type=ApplicationManager,process=server1,*')
AdminControl.invoke(appManager, 'startApplication', name)
start_application(sys.argv[0]) |
"""
Demonstrates different exception handling examples
"""
#This function accepts an argument that the function divides by
#100. It returns the result of that division.
def divide100(valueIn) :
if valueIn < 0 :
#Raises an exception if the argument was negative.
raise Exception("Negative number supplied to d... | """
Demonstrates different exception handling examples
"""
def divide100(valueIn):
if valueIn < 0:
raise exception('Negative number supplied to divide100 function.')
else:
return 100 / valueIn
line = input('Enter a number: ')
while line.lower() != 'exit':
try:
result = divide100(int... |
if __name__ == '__main__':
n = int(input())
i = 0
while n > i:
print(i*i)
i+=1
| if __name__ == '__main__':
n = int(input())
i = 0
while n > i:
print(i * i)
i += 1 |
def tobits(s):
result = []
for c in s:
bits = bin(ord(c))[2:]
bits = '00000000'[len(bits):] + bits
result.extend([int(b) for b in bits])
return result
def frombits(bits):
chars = []
for b in range(len(bits) // 8):
byte = bits[b*8:(b+1)*8]
chars.append(chr(int... | def tobits(s):
result = []
for c in s:
bits = bin(ord(c))[2:]
bits = '00000000'[len(bits):] + bits
result.extend([int(b) for b in bits])
return result
def frombits(bits):
chars = []
for b in range(len(bits) // 8):
byte = bits[b * 8:(b + 1) * 8]
chars.append(c... |
password_reset_spec = {
'type': 'object',
'required': ['email'],
'properties': {
'email': {
'description': 'Email address registered for user requesting reset.',
'type': 'string',
},
},
}
| password_reset_spec = {'type': 'object', 'required': ['email'], 'properties': {'email': {'description': 'Email address registered for user requesting reset.', 'type': 'string'}}} |
'''
Basic hash table to practice working through hash table logic...
'''
class HashTable():
def __init__(self):
CURRENT_SIZE = 10
self.table_size = CURRENT_SIZE
# self.table = [0] * self.table_size
# TODO: make this more dynamic .. check for collisions instead of filling every slo... | """
Basic hash table to practice working through hash table logic...
"""
class Hashtable:
def __init__(self):
current_size = 10
self.table_size = CURRENT_SIZE
self.table = [single_linked_list() for x in range(CURRENT_SIZE)]
def insert(self, input_str):
self.table[self.__simple... |
class InvalidExpression(Exception):
pass
class WriterNotSupportingGroupedBatch(Exception):
pass
class ConfigurationError(ValueError):
"Configuration provided isn't valid."
class InvalidDateRangeError(ValueError):
"Empty or impossible date range"
class UnsupportedCompressionFormat(ValueError):
... | class Invalidexpression(Exception):
pass
class Writernotsupportinggroupedbatch(Exception):
pass
class Configurationerror(ValueError):
"""Configuration provided isn't valid."""
class Invaliddaterangeerror(ValueError):
"""Empty or impossible date range"""
class Unsupportedcompressionformat(ValueError)... |
# https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/
#
# algorithms
# Medium (49.47%)
# Total Accepted: 34,319
# Total Submissions: 69,379
# beats 100.0% of python submissions
class Solution(object):
def maxProfit(self, prices, fee):
"""
:type prices: List[int]
... | class Solution(object):
def max_profit(self, prices, fee):
"""
:type prices: List[int]
:type fee: int
:rtype: int
"""
length = len(prices)
if length < 2:
return 0
res = 0
buy = prices[0]
for n in prices:
if n < ... |
# keeps asking for numbers until count numbers have been entered.
# Prints the average value.
# Notice that we use an integer to keep track of how many numbers,
# but floating point numbers for the input of each number
sum = 0.0
print("This program will take several numbers then average them.")
count = int(input("How... | sum = 0.0
print('This program will take several numbers then average them.')
count = int(input('How many numbers would you like to average: '))
current_count = 0
while current_count < count:
current_count = current_count + 1
print('Number', current_count)
number = float(input('Enter a number: '))
sum = ... |
CREATE_TODO = [{
'field_name': 'bucketName',
'type': str,
}, {
'field_name': 'name',
'type': str,
}, {
'field_name': 'done',
'type': bool,
}, {
'field_name': 'bucketId',
'type': int,
'required': False,
'blank': (True,)
}]
UPDATE_TODO = [{
'field_name': 'name',
'type': st... | create_todo = [{'field_name': 'bucketName', 'type': str}, {'field_name': 'name', 'type': str}, {'field_name': 'done', 'type': bool}, {'field_name': 'bucketId', 'type': int, 'required': False, 'blank': (True,)}]
update_todo = [{'field_name': 'name', 'type': str}, {'field_name': 'done', 'type': bool, 'required': False}, ... |
#13) Large sum
#Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.
nums = """
37107287533902102798797998220837590246510135740250
...
53503534226472524250874054075591789781264330331690
""".replace('\n', ' ').strip().split(' ')
# Solution
str(sum([int(x) for x in nums]))[:10]
| nums = '\n37107287533902102798797998220837590246510135740250\n...\n53503534226472524250874054075591789781264330331690\n'.replace('\n', ' ').strip().split(' ')
str(sum([int(x) for x in nums]))[:10] |
class DrawAction:
PEN_UP = 1
PEN_DOWN = 2
PEN_MOVE = 3
def __init__(self, t, x=0, y=0):
self.t = t
self.x = x
self.y = y
| class Drawaction:
pen_up = 1
pen_down = 2
pen_move = 3
def __init__(self, t, x=0, y=0):
self.t = t
self.x = x
self.y = y |
# Basic operations
print(2+1)
print(3*4)
print(3/2)
# Modulo or "Mod" operator
print(7 % 4)
print(50 % 5)
# Power
print(2 ** 3) | print(2 + 1)
print(3 * 4)
print(3 / 2)
print(7 % 4)
print(50 % 5)
print(2 ** 3) |
"""Main entry point for the game."""
def main():
"""Main entry point for the game.
Raises:
NotImplementedError: Placeholder for now
"""
raise NotImplementedError # Placeholder
if __name__ == "main":
main()
| """Main entry point for the game."""
def main():
"""Main entry point for the game.
Raises:
NotImplementedError: Placeholder for now
"""
raise NotImplementedError
if __name__ == 'main':
main() |
http_archive(
name = "io_bazel_rules_rust",
sha256 = "615639cfd5459fec4b8a5751112be808ab25ba647c4c1953d29bb554ef865da7",
strip_prefix = "rules_rust-0.0.6",
urls = [
"http://bazel-mirror.storage.googleapis.com/github.com/bazelbuild/rules_rust/archive/0.0.6.tar.gz",
"https://github.com/baz... | http_archive(name='io_bazel_rules_rust', sha256='615639cfd5459fec4b8a5751112be808ab25ba647c4c1953d29bb554ef865da7', strip_prefix='rules_rust-0.0.6', urls=['http://bazel-mirror.storage.googleapis.com/github.com/bazelbuild/rules_rust/archive/0.0.6.tar.gz', 'https://github.com/bazelbuild/rules_rust/archive/0.0.6.tar.gz'])... |
with open("input.txt", "r") as f:
data = f.read()
binary = ""
for char in data:
_bin = bin(int(char, 16))[2:]
binary += "0" * (4 - len(_bin)) + _bin
result = 0
def go(packet):
version = int(packet[:3], 2)
typeID = int(packet[3:6], 2)
if typeID == 4:
totalPacketLength, representation = 6... | with open('input.txt', 'r') as f:
data = f.read()
binary = ''
for char in data:
_bin = bin(int(char, 16))[2:]
binary += '0' * (4 - len(_bin)) + _bin
result = 0
def go(packet):
version = int(packet[:3], 2)
type_id = int(packet[3:6], 2)
if typeID == 4:
(total_packet_length, representation... |
# -*- coding: utf-8 -*-
"""
Created on Fri Nov 13 17:09 2020
Introduction to Computation and Programming Using Python. John V. Guttag, 2016, 2nd ed
Book Chapter 4 Finger Exercises
Using method str.in write a function that takes two strings and returns
True if either is contained inside the other, False othewise
@autho... | """
Created on Fri Nov 13 17:09 2020
Introduction to Computation and Programming Using Python. John V. Guttag, 2016, 2nd ed
Book Chapter 4 Finger Exercises
Using method str.in write a function that takes two strings and returns
True if either is contained inside the other, False othewise
@author: Atanas Kozarev - gith... |
# The storage class for creating binary tree nodes
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
# Implementation of the Binary Search Tree
class BinarySearchTree:
# Creates an initially empty BST
def __init__(self):
self._root = No... | class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
class Binarysearchtree:
def __init__(self):
self._root = None
self._size = 0
def __len__(self):
return self._size
def insert_node(self, new_node):
if sel... |
class AdlQuantile:
def __init__(self):
self.symbol = ""
self.adlQuantile = ""
@staticmethod
def json_parse(json_wrapper):
result = AdlQuantile()
result.symbol = json_wrapper.get_string("symbol")
result.adlQuantile = json_wrapper.get_string("adlQuantile")
ret... | class Adlquantile:
def __init__(self):
self.symbol = ''
self.adlQuantile = ''
@staticmethod
def json_parse(json_wrapper):
result = adl_quantile()
result.symbol = json_wrapper.get_string('symbol')
result.adlQuantile = json_wrapper.get_string('adlQuantile')
re... |
"""
0080. Remove Duplicates from Sorted Array II
Medium
Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length.
Do not allocate extra space for another array; you must do this by modifying the input array in-place with O(1) extra memory.
Clarif... | """
0080. Remove Duplicates from Sorted Array II
Medium
Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length.
Do not allocate extra space for another array; you must do this by modifying the input array in-place with O(1) extra memory.
Clarif... |
'''
Write a program that reads from the console 3 real numbers b1, b2 and h
and calculates the face of trapezoid with bases b1 and b2 and height h.
The trapezoidal face formula is (b1 + b2) * h / 2.
'''
a = float(input())
b = float(input())
h = float(input())
area = (a + b) * h / 2
print(area)
| """
Write a program that reads from the console 3 real numbers b1, b2 and h
and calculates the face of trapezoid with bases b1 and b2 and height h.
The trapezoidal face formula is (b1 + b2) * h / 2.
"""
a = float(input())
b = float(input())
h = float(input())
area = (a + b) * h / 2
print(area) |
"""
Leetcode #151
"""
class Solution:
def reverseWords(self, s: str) -> str:
if not s:
return ""
res = []
j = len(s)
for i in range(len(s)-1,-1,-1):
# trim the trailing space
if s[i] == " ":
j = i
# if we encoun... | """
Leetcode #151
"""
class Solution:
def reverse_words(self, s: str) -> str:
if not s:
return ''
res = []
j = len(s)
for i in range(len(s) - 1, -1, -1):
if s[i] == ' ':
j = i
elif i == 0 or s[i - 1] == ' ':
re... |
# --==[ Settings ]==--
# General
font = 'SauceCodePro Nerd Font Medium'
wallpaper = '~/wallpapers/wp2.png'
# Weather
location = {'Mexico': 'Mexico'}
city = 'Mexico City, MX'
# Hardware [/sys/class]
net = 'wlp2s0'
backlight = 'radeon_bl0'
# Color Schemes
colorscheme = 'gruvbox_material'
| font = 'SauceCodePro Nerd Font Medium'
wallpaper = '~/wallpapers/wp2.png'
location = {'Mexico': 'Mexico'}
city = 'Mexico City, MX'
net = 'wlp2s0'
backlight = 'radeon_bl0'
colorscheme = 'gruvbox_material' |
"""
PASSENGERS
"""
numPassengers = 4114
passenger_arriving = (
(7, 11, 9, 4, 3, 0, 7, 12, 6, 2, 4, 0), # 0
(12, 8, 9, 4, 2, 0, 7, 11, 10, 5, 1, 0), # 1
(6, 14, 4, 8, 1, 0, 8, 13, 8, 6, 1, 0), # 2
(0, 14, 12, 1, 5, 0, 10, 7, 5, 6, 6, 0), # 3
(3, 8, 14, 5, 1, 0, 8, 16, 9, 4, 0, 0), # 4
(4, 13, 7, 7, 2, 0, 9... | """
PASSENGERS
"""
num_passengers = 4114
passenger_arriving = ((7, 11, 9, 4, 3, 0, 7, 12, 6, 2, 4, 0), (12, 8, 9, 4, 2, 0, 7, 11, 10, 5, 1, 0), (6, 14, 4, 8, 1, 0, 8, 13, 8, 6, 1, 0), (0, 14, 12, 1, 5, 0, 10, 7, 5, 6, 6, 0), (3, 8, 14, 5, 1, 0, 8, 16, 9, 4, 0, 0), (4, 13, 7, 7, 2, 0, 9, 10, 3, 7, 2, 0), (3, 9, 6, 5, 1,... |
errorcodes ={
"OK":"",
"ERR_SERVO_MAX": "Servo maximum limit hit",
"ERR_SERVO_MIN": "Servo minimum limit hit",
"ERR_SERVO_INVALIDVALUE": "You shall submit integer or name of position using variable 'value'",
"ERR_SERVO_INVALIDSERVO": "Servo name not exists in servo database",
"ERR_TRACK_INVALID"... | errorcodes = {'OK': '', 'ERR_SERVO_MAX': 'Servo maximum limit hit', 'ERR_SERVO_MIN': 'Servo minimum limit hit', 'ERR_SERVO_INVALIDVALUE': "You shall submit integer or name of position using variable 'value'", 'ERR_SERVO_INVALIDSERVO': 'Servo name not exists in servo database', 'ERR_TRACK_INVALID': 'Track name not exist... |
def writeText(data, filename):
file = open(filename, mode = 'w')
file.write(data)
return
writeText('Hello, world.', 'c:\\users\\chharri\\documents\\hello.txt') | def write_text(data, filename):
file = open(filename, mode='w')
file.write(data)
return
write_text('Hello, world.', 'c:\\users\\chharri\\documents\\hello.txt') |
__all__ = []
__all__.extend([
'SymOptError',
'IncompatibleSolverError'
])
class SymOptError(Exception):
pass
class IncompatibleSolverError(SymOptError):
pass
| __all__ = []
__all__.extend(['SymOptError', 'IncompatibleSolverError'])
class Symopterror(Exception):
pass
class Incompatiblesolvererror(SymOptError):
pass |
class BayesNet:
def __init__(self, ldep=None): # Why not ldep={}? See footnote 1.
if not ldep:
ldep = {}
self.dependencies = ldep
# Os dados estao num dicionario (var,dependencies)
# em que as dependencias de cada variavel
# estao num dicionario (mothers,prob);
# "mothe... | class Bayesnet:
def __init__(self, ldep=None):
if not ldep:
ldep = {}
self.dependencies = ldep
def add(self, var, mothers, prob):
self.dependencies.setdefault(var, {})[frozenset(mothers)] = prob
def joint_prob(self, conjunction):
prob = 1.0
for (var, va... |
# Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.
# You may return the answer in any order.
# Example 1:
# Input: n = 4, k = 2
# Output:
# [
# [2,4],
# [3,4],
# [2,3],
# [1,2],
# [1,3],
# [1,4],
# ]
# Example 2:
# Input: n = 1, k = 1
# Output: [[1]]
# Constra... | class Solution:
def combine(self, n: int, k: int):
lst = [i for i in range(1, n + 1)]
return Solution.combLst(self, lst, k)
def comb_lst(self, lst, k):
if k == 1:
return [[i] for i in lst]
result = []
for i in range(len(lst) - 1):
l = Solution.co... |
# simeple.for.py
for number in [0, 1, 2, 3, 4]:
print(number)
for number in range(5):
print(number)
| for number in [0, 1, 2, 3, 4]:
print(number)
for number in range(5):
print(number) |
class DboException(Exception):
"""Base class for venus database access objects"""
pass
class DboTransactionError(DboException):
"""Transaction error for venus database access objects."""
pass
| class Dboexception(Exception):
"""Base class for venus database access objects"""
pass
class Dbotransactionerror(DboException):
"""Transaction error for venus database access objects."""
pass |
#!/usr/bin/env python
# -*- coding: utf-8 -*- #
AUTHOR = "Ryan Cheley"
SITENAME = "RyanCheley.com"
SITESUBTITLE = "My Place on the Internet"
SITEURL = ""
PATH = "content"
PLUGINS = [
"pelican.plugins.series",
"pelican.plugins.simple_footnotes",
"pelican.plugins.pelican_to_sqlite",
]
THEME = "rc_custom"
... | author = 'Ryan Cheley'
sitename = 'RyanCheley.com'
sitesubtitle = 'My Place on the Internet'
siteurl = ''
path = 'content'
plugins = ['pelican.plugins.series', 'pelican.plugins.simple_footnotes', 'pelican.plugins.pelican_to_sqlite']
theme = 'rc_custom'
timezone = 'America/Los_Angeles'
default_lang = 'en'
feed_all_atom ... |
class Solution:
def numMagicSquaresInside(self, grid: List[List[int]]) -> int:
def isMagic(a,b,c,d,e,f,g,h,i):
return (sorted([a,b,c,d,e,f,g,h,i]) == list(range(1, 10)) and
(a+b+c == d+e+f == g+h+i == a+d+g ==
b+e+h == c+f+i == a+e+i == c+e+g == 15))
... | class Solution:
def num_magic_squares_inside(self, grid: List[List[int]]) -> int:
def is_magic(a, b, c, d, e, f, g, h, i):
return sorted([a, b, c, d, e, f, g, h, i]) == list(range(1, 10)) and a + b + c == d + e + f == g + h + i == a + d + g == b + e + h == c + f + i == a + e + i == c + e + g =... |
class Evaluator():
def __init__(self, dataLayer):
""" Constructor of the class Evaluator
Args:
dataLayer (dataLayer): Instance of DataLayer, used to get the relevant and antirelevant counts and
to check if a passed ratings is relevant or antireleva... | class Evaluator:
def __init__(self, dataLayer):
""" Constructor of the class Evaluator
Args:
dataLayer (dataLayer): Instance of DataLayer, used to get the relevant and antirelevant counts and
to check if a passed ratings is relevant or antirelevant r... |
def firstUniqChar(self, s: str):
count = {}
for i in s:
if i in count:
count[i] += 1
else:
count[i] = 1
for i in range(len(s)):
if count[s[i]] == 1:
return i
return -1
| def first_uniq_char(self, s: str):
count = {}
for i in s:
if i in count:
count[i] += 1
else:
count[i] = 1
for i in range(len(s)):
if count[s[i]] == 1:
return i
return -1 |
#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-... | allocated = 'allocated'
available = 'available'
deleted = 'deleted' |
help_text = {
"TRACTS": """
Can vary in size but averages 4,000 people. Designed to remain relatively
stable across decades to allow statistical comparisons. Boundaries defined
by local officials using Census Bureau rules.
""",
"PLACES": """
1. What most people call cities or towns. A locality incorpor... | help_text = {'TRACTS': '\nCan vary in size but averages 4,000 people. Designed to remain relatively\nstable across decades to allow statistical comparisons. Boundaries defined\nby local officials using Census Bureau rules.\n ', 'PLACES': '\n1. What most people call cities or towns. A locality incorporated under\nsta... |
# (C) Copyright 2020 ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmenta... | class Docstring:
def __init__(self):
pass
def __call__(self, func):
return func |
class Solution:
def rob(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
far = near = 0
for elem in nums:
far, near = near, max(far + elem, near)
return near
| class Solution:
def rob(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
far = near = 0
for elem in nums:
(far, near) = (near, max(far + elem, near))
return near |
class Solution(object):
def getSum(self, a, b):
"""
:type a: int
:type b: int
:rtype: int
"""
list_a = [a, b]
sumofab = sum(list_a)
return sumofab
| class Solution(object):
def get_sum(self, a, b):
"""
:type a: int
:type b: int
:rtype: int
"""
list_a = [a, b]
sumofab = sum(list_a)
return sumofab |
#!/usr/bin/env python
#-*- coding: utf-8 -*-
__author__ = 'Stefan Jansen'
def recursive_dfs(G, s, S=None):
if S is None: S = set() # Initialize the history
S.add(s) # We've visited s
for u in G[s]: # Explore neighbors
if u in S: continue # Al... | __author__ = 'Stefan Jansen'
def recursive_dfs(G, s, S=None):
if S is None:
s = set()
S.add(s)
for u in G[s]:
if u in S:
continue
recursive_dfs(G, u, S)
def iterative_dfs(G, s):
(s, q) = (set(), [])
Q.append(s)
while Q:
u = Q.pop()
if u in S:... |
def chooseBest(pset, maxWeight, getVal, getWeight):
bestVal = 0.0
bestSet = None
for items in pset:
itemsVal = 0.0
itemsWeight = 0.0
for item in items:
itemsVal += getVal(item)
itemsWeight += getWeight(item)
if itemsWeight <= maxWeight and... | def choose_best(pset, maxWeight, getVal, getWeight):
best_val = 0.0
best_set = None
for items in pset:
items_val = 0.0
items_weight = 0.0
for item in items:
items_val += get_val(item)
items_weight += get_weight(item)
if itemsWeight <= maxWeight and... |
class Solution(object):
def decodeString(self, s):
"""
:type s: str
:rtype: str
"""
stack = []
for c in s:
if c == ']':
curr = ''
while stack and stack[-1] != '[':
curr = stack.pop() + curr
... | class Solution(object):
def decode_string(self, s):
"""
:type s: str
:rtype: str
"""
stack = []
for c in s:
if c == ']':
curr = ''
while stack and stack[-1] != '[':
curr = stack.pop() + curr
... |
# Location of the ref data.
reference_data_path = '/p/cscratch/acme/data/obs_for_acme_diags/'
# Name of the ref obs data, used to find the climo files.
ref_name = 'ceres_ebaf_toa_v2.8'
# Location of the test data.
test_data_path = '/p/cscratch/acme/data/obs_for_acme_diags/'
# Name of the test obs data, used to find th... | reference_data_path = '/p/cscratch/acme/data/obs_for_acme_diags/'
ref_name = 'ceres_ebaf_toa_v2.8'
test_data_path = '/p/cscratch/acme/data/obs_for_acme_diags/'
test_name = 'ceres_ebaf_toa_v4.0'
results_dir = 'obs_vs_obs'
sets = ['lat_lon']
seasons = ['ANN']
backend = 'mpl' |
s = str(input())
if s[-1] != "s":
s += "s"
else:
s += "es"
print(s) | s = str(input())
if s[-1] != 's':
s += 's'
else:
s += 'es'
print(s) |
#
# A generic merge-sort program.
#
# USAGE:
# Let "ptr" be a pointer to some structure which is at the head of
# a null-terminated list. Then to sort the list call:
#
# ptr = msort(ptr,&(ptr->next),cmpfnc);
#
# In the above, "cmpfnc" is a pointer to a function which compares
# two instances of the structure and r... | def merge(a, b, cmp, next):
if a is None:
head = b
elif b is None:
head = a
else:
if cmp(a, b) <= 0:
ptr = a
a = getattr(a, next)
else:
ptr = b
b = getattr(b, next)
head = ptr
while a and b:
if cmp(a,... |
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 26 21:46:18 2018
@author: Xingyuan Gu, Peter Law
"""
#coding:utf-8
def read_file():
f=open('C:/Users/dell/.spyder-py3/WordTesting.txt',encoding='ISO-8859-1')
readline=f.readlines()
word=[]
for line in readline:
line=line.replace(',','').replace('-',''... | """
Created on Fri Oct 26 21:46:18 2018
@author: Xingyuan Gu, Peter Law
"""
def read_file():
f = open('C:/Users/dell/.spyder-py3/WordTesting.txt', encoding='ISO-8859-1')
readline = f.readlines()
word = []
for line in readline:
line = line.replace(',', '').replace('-', '').replace('&', '').repl... |
n, m = map(int, input().split())
arr = list(map(int, input().split()))[:n]
flag = True
for i in range(n-1):
if arr[i+1]-arr[i] > m:
flag = False
if flag and ((42195-arr[len(arr)-1]) <= m):
print("S")
else:
print("N") | (n, m) = map(int, input().split())
arr = list(map(int, input().split()))[:n]
flag = True
for i in range(n - 1):
if arr[i + 1] - arr[i] > m:
flag = False
if flag and 42195 - arr[len(arr) - 1] <= m:
print('S')
else:
print('N') |
class Solution:
def isValid(self, s: str) -> bool:
stack: list[str] = []
for char in s:
if char in '([{':
stack.append(char)
continue
if char == ')':
if len(stack) < 1 or stack[-1] != '(':
return False
... | class Solution:
def is_valid(self, s: str) -> bool:
stack: list[str] = []
for char in s:
if char in '([{':
stack.append(char)
continue
if char == ')':
if len(stack) < 1 or stack[-1] != '(':
return False
... |
N, x = map(int, input().split())
if x == 1 or x == 2 * N - 1:
print("No")
exit()
print("Yes")
if N == 2:
print(1)
print(2)
print(3)
exit()
ans = [-1] * (2 * N - 1)
if x == 2:
ans[N - 2:N + 2] = [3, 2, 1, 4]
tmp = 5
for i in range(2 * N - 1):
if ans[i] != -1:
con... | (n, x) = map(int, input().split())
if x == 1 or x == 2 * N - 1:
print('No')
exit()
print('Yes')
if N == 2:
print(1)
print(2)
print(3)
exit()
ans = [-1] * (2 * N - 1)
if x == 2:
ans[N - 2:N + 2] = [3, 2, 1, 4]
tmp = 5
for i in range(2 * N - 1):
if ans[i] != -1:
con... |
def heatmap_values(data, heat_column_name, row_name, column_name):
results = []
rows = data[row_name].unique()
columns = data[column_name].unique()
for i_idx, i in enumerate(rows):
results.append([])
for j in columns:
results[i_idx].append(data[(data[row_name] == i) & ... | def heatmap_values(data, heat_column_name, row_name, column_name):
results = []
rows = data[row_name].unique()
columns = data[column_name].unique()
for (i_idx, i) in enumerate(rows):
results.append([])
for j in columns:
results[i_idx].append(data[(data[row_name] == i) & (data... |
n, m = map(int,input().split())
data = []
temp = [[0] * m for _ in range(n)]
for _ in range(n):
data.append(list(map(int,input().split())))
dx = [0,1,0,-1]
dy = [1,0,-1,0]
result = 0
def virus(x,y) :
for i in range(4) :
nx = x + dx[i]
ny = y + dy[i]
if 0 <= nx < n and 0 <= ny < m :
... | (n, m) = map(int, input().split())
data = []
temp = [[0] * m for _ in range(n)]
for _ in range(n):
data.append(list(map(int, input().split())))
dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
result = 0
def virus(x, y):
for i in range(4):
nx = x + dx[i]
ny = y + dy[i]
if 0 <= nx < n and 0 <= ny <... |
TIME_DENSITY=0.1
AVG_TIME=1.0
AVG_TRASH=0.9
GARBAGECAN_SIZE=5
TEMP_CAN_SIZE=0
GARBAGETRUCK_SIZE=15
TIME_STDDEV=0.2
TRASH_STDDEV=0.1
TRUCK_INITIAL=7
TRUCK_CYCLE=24
TRUCK_DELAY=0.01
simulation_time=48
VERBOSE=False
SIMULATION_MODE="VIRTUAL_TIME"
RANDOM_SEED=4 | time_density = 0.1
avg_time = 1.0
avg_trash = 0.9
garbagecan_size = 5
temp_can_size = 0
garbagetruck_size = 15
time_stddev = 0.2
trash_stddev = 0.1
truck_initial = 7
truck_cycle = 24
truck_delay = 0.01
simulation_time = 48
verbose = False
simulation_mode = 'VIRTUAL_TIME'
random_seed = 4 |
XK_Arabic_comma = 0x5ac
XK_Arabic_semicolon = 0x5bb
XK_Arabic_question_mark = 0x5bf
XK_Arabic_hamza = 0x5c1
XK_Arabic_maddaonalef = 0x5c2
XK_Arabic_hamzaonalef = 0x5c3
XK_Arabic_hamzaonwaw = 0x5c4
XK_Arabic_hamzaunderalef = 0x5c5
XK_Arabic_hamzaonyeh = 0x5c6
XK_Arabic_alef = 0x5c7
XK_Arabic_beh = 0x5c8
XK_Ar... | xk__arabic_comma = 1452
xk__arabic_semicolon = 1467
xk__arabic_question_mark = 1471
xk__arabic_hamza = 1473
xk__arabic_maddaonalef = 1474
xk__arabic_hamzaonalef = 1475
xk__arabic_hamzaonwaw = 1476
xk__arabic_hamzaunderalef = 1477
xk__arabic_hamzaonyeh = 1478
xk__arabic_alef = 1479
xk__arabic_beh = 1480
xk__arabic_tehma... |
alien_0 = {'Color':'Green', 'Pontos':5}
alien_1 = {'Color':'Yellow', 'Pontos':10}
alien_2 = {'Color':'Blue', 'Pontos':15}
aliens = [alien_0,alien_1,alien_2]
for alien in aliens:
print(alien) | alien_0 = {'Color': 'Green', 'Pontos': 5}
alien_1 = {'Color': 'Yellow', 'Pontos': 10}
alien_2 = {'Color': 'Blue', 'Pontos': 15}
aliens = [alien_0, alien_1, alien_2]
for alien in aliens:
print(alien) |
class JustMethods(object):
def test1(self):
assert 2 == 2
def test2(self):
assert 1 == 1
def test3(self):
assert 3 == 3
class MostlyMethods(object):
test = 1
def before_class_hook(self):
pass
def after_class_hook(self):
pass
def before_method_ho... | class Justmethods(object):
def test1(self):
assert 2 == 2
def test2(self):
assert 1 == 1
def test3(self):
assert 3 == 3
class Mostlymethods(object):
test = 1
def before_class_hook(self):
pass
def after_class_hook(self):
pass
def before_method_ho... |
PointConfig={
"version": "v1",
"config": {
"visState": {
"filters": [],
"layers": [
{
"id": "c20ju4",
"type": "point",
"config": {
"dataId": "data_2",
"label": "data_2",
"color": [
253,
... | point_config = {'version': 'v1', 'config': {'visState': {'filters': [], 'layers': [{'id': 'c20ju4', 'type': 'point', 'config': {'dataId': 'data_2', 'label': 'data_2', 'color': [253, 121, 0], 'columns': {'lat': 'Latitude', 'lng': 'Longitude', 'altitude': None}, 'isVisible': True, 'visConfig': {'radius': 10, 'fixedRadius... |
class Actor:
def __init__(self, name, age, *movies):
self.name = name
self.age = age
self.movies = movies
def addAge(self, age):
self.age = self.age + age
# making Object 1
p1 = Actor("Shahrukh Khan", 60, "Koala", "DDLJ", "Kuch kuch hota hain", "Kabhi Khushi Kabhi Gum")
# m... | class Actor:
def __init__(self, name, age, *movies):
self.name = name
self.age = age
self.movies = movies
def add_age(self, age):
self.age = self.age + age
p1 = actor('Shahrukh Khan', 60, 'Koala', 'DDLJ', 'Kuch kuch hota hain', 'Kabhi Khushi Kabhi Gum')
p2 = actor('Salman Khan'... |
#!/usr/bin/env python
"""
Write a program to sort a stack.
This is O(N^2).
"""
def built_in_sort(stack):
stack.sort()
return stack
def custom_sort(stack):
"""Custom version of list sort. This should never be used."""
new_stack = []
while len(stack):
temp = stack.pop()
while len... | """
Write a program to sort a stack.
This is O(N^2).
"""
def built_in_sort(stack):
stack.sort()
return stack
def custom_sort(stack):
"""Custom version of list sort. This should never be used."""
new_stack = []
while len(stack):
temp = stack.pop()
while len(new_stack) and new_stack... |
#Constants used in SimMod modules
TEMP_0 = 10. #Mean Earth surface temp (degrees C)
C_TO_CO2 = 3.67
PGC_TO_MOL = 1e15/12.
MOLES_IN_ATMOSPHERE = 1.8 * 10.**20.
GRAMS_PER_MOLE_CO2 = 44.01
GRAMS_PER_MOLE_CH4 = 16.04
GRAMS_PER_MOLE_N2O = 44.01
CO2_PER_TON_CH4 = 1.5 #Tons CO2 produced when ton CH4 deca... | temp_0 = 10.0
c_to_co2 = 3.67
pgc_to_mol = 1000000000000000.0 / 12.0
moles_in_atmosphere = 1.8 * 10.0 ** 20.0
grams_per_mole_co2 = 44.01
grams_per_mole_ch4 = 16.04
grams_per_mole_n2_o = 44.01
co2_per_ton_ch4 = 1.5
ch4_efold = 10.0
n2_o_efold = 114.0
co2_ppm_1750 = 277.01467
ch4_ppb_1750 = 721.89411
n2_o_ppb_1750 = 272.... |
counter = int(input())
left_sum = 0
right_sum = 0
for index in range (0,2*counter):
num = int(input())
if index<counter:
left_sum += num
else:
right_sum += num
if left_sum == right_sum:
print(f"Yes, sum = {left_sum}")
else:
print(f"No, diff = {abs(left_sum-right_sum)}")
| counter = int(input())
left_sum = 0
right_sum = 0
for index in range(0, 2 * counter):
num = int(input())
if index < counter:
left_sum += num
else:
right_sum += num
if left_sum == right_sum:
print(f'Yes, sum = {left_sum}')
else:
print(f'No, diff = {abs(left_sum - right_sum)}') |
settings = {}
settings['username'] = ""
settings['client_id'] = ""
settings['client_secret'] = ""
settings['redirect_uri'] = ""
| settings = {}
settings['username'] = ''
settings['client_id'] = ''
settings['client_secret'] = ''
settings['redirect_uri'] = '' |
__all__ = ["VERSION"]
_MAJOR = "0"
_MINOR = "2"
_PATCH = "0.post1"
VERSION = f"{_MAJOR}.{_MINOR}.{_PATCH}"
| __all__ = ['VERSION']
_major = '0'
_minor = '2'
_patch = '0.post1'
version = f'{_MAJOR}.{_MINOR}.{_PATCH}' |
# https://leetcode.com/problems/most-stones-removed-with-same-row-or-column/
class Solution(object):
def colorStones(self, stones, stone, colors, color):
colors[stone] = color
for i in range(len(stones)):
if colors[i] != -1: continue
if stones[i][0] == stones[stone][0] or s... | class Solution(object):
def color_stones(self, stones, stone, colors, color):
colors[stone] = color
for i in range(len(stones)):
if colors[i] != -1:
continue
if stones[i][0] == stones[stone][0] or stones[i][1] == stones[stone][1]:
self.colorSt... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.