content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# generated from genmsg/cmake/pkg-genmsg.context.in messages_str = "/home/cherif/OMCRI4CP/T-quad/ROS_WS/src/tquad/msg/LineSensor.msg" services_str = "" pkg_name = "tquad" dependencies_str = "std_msgs" langs = "gencpp;geneus;genlisp;gennodejs;genpy" dep_include_paths_str = "tquad;/home/cherif/OMCRI4CP/T-quad/ROS_WS/src...
messages_str = '/home/cherif/OMCRI4CP/T-quad/ROS_WS/src/tquad/msg/LineSensor.msg' services_str = '' pkg_name = 'tquad' dependencies_str = 'std_msgs' langs = 'gencpp;geneus;genlisp;gennodejs;genpy' dep_include_paths_str = 'tquad;/home/cherif/OMCRI4CP/T-quad/ROS_WS/src/tquad/msg;std_msgs;/opt/ros/kinetic/share/std_msgs/c...
start = int(input('what do you want the starting element to be?\n'.title())) current = [start,0] size = int(input('how many terms do you want\n'.title())) for i in range(0,size - 2): out = 0 l = len(current) last = current[-1] for i in range(l - 2,-1,-1): if current[i] == las...
start = int(input('what do you want the starting element to be?\n'.title())) current = [start, 0] size = int(input('how many terms do you want\n'.title())) for i in range(0, size - 2): out = 0 l = len(current) last = current[-1] for i in range(l - 2, -1, -1): if current[i] == last: o...
def read_state(file_name): MAX_SIZE = 20 data = [] with open(file_name) as f: score_matrix = [] h, w = map(int, f.readline().split()) for i in range(h): array = list(map(int, f.readline().split())) while(len(array) < MAX_SIZE): ...
def read_state(file_name): max_size = 20 data = [] with open(file_name) as f: score_matrix = [] (h, w) = map(int, f.readline().split()) for i in range(h): array = list(map(int, f.readline().split())) while len(array) < MAX_SIZE: array.append(0)...
def main(path): return\ path.endswith( ".h") or\ path.endswith(".hpp") or\ \ path.endswith( ".c") or\ path.endswith( ".cc") or\ path.endswith(".cpp") or\ path.endswith(".cxx")
def main(path): return path.endswith('.h') or path.endswith('.hpp') or path.endswith('.c') or path.endswith('.cc') or path.endswith('.cpp') or path.endswith('.cxx')
{ "targets": [{ "target_name": "node_xslt", "sources": [ "node_xslt.cc" ], "cflags": ["<!(xml2-config --cflags)", "-fexceptions -w"], "cflags_cc": ["<!(xml2-config --cflags)", "-fexceptions -w"], "xcode_settings": { "OTHER_CFLAGS": ["<!(xml2-config --cflags)", "-f...
{'targets': [{'target_name': 'node_xslt', 'sources': ['node_xslt.cc'], 'cflags': ['<!(xml2-config --cflags)', '-fexceptions -w'], 'cflags_cc': ['<!(xml2-config --cflags)', '-fexceptions -w'], 'xcode_settings': {'OTHER_CFLAGS': ['<!(xml2-config --cflags)', '-fexceptions']}, 'libraries': ['-lxml2', '-lxslt', '-lexslt'], ...
# # PySNMP MIB module DC-MGMD-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DC-MGMD-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:27:34 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 0...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_range_constraint, value_size_constraint, single_value_constraint, constraints_union) ...
# -*- coding: utf-8 -*- user_agents = [ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36 Edg/94.0.992.38", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.3", "Mozilla/5.0 (Wi...
user_agents = ['Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36 Edg/94.0.992.38', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.3', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit...
def merge_sort(a): if len(a) < 2: return a l = a[0:len(a)//2] r = a[len(a)//2:] return merge(merge_sort(l), merge_sort(r)) def merge(a, b): out = [] i = 0 j = 0 while i < len(a) or j < len(b): if i >= len(a): out.append(b[j]) j += 1 elif ...
def merge_sort(a): if len(a) < 2: return a l = a[0:len(a) // 2] r = a[len(a) // 2:] return merge(merge_sort(l), merge_sort(r)) def merge(a, b): out = [] i = 0 j = 0 while i < len(a) or j < len(b): if i >= len(a): out.append(b[j]) j += 1 el...
M = 26 N = (M%10*10) + (M//10 + M%10) print(N) print((1%10*10) + (1//10+1%10))
m = 26 n = M % 10 * 10 + (M // 10 + M % 10) print(N) print(1 % 10 * 10 + (1 // 10 + 1 % 10))
def F(n): if n<=2: return 1 else: return F(n-1)+F(n-2) #print(F(7))
def f(n): if n <= 2: return 1 else: return f(n - 1) + f(n - 2)
read_int = lambda: int(input()) def solve(N, P): P = P.replace('S', 'T') P = P.replace('E', 'S') P = P.replace('T', 'E') return P T = read_int() for i in range(1, T + 1): N, P = read_int(), input() answer = solve(N, P) print('Case #{}: {}'.format(i, answer))
read_int = lambda : int(input()) def solve(N, P): p = P.replace('S', 'T') p = P.replace('E', 'S') p = P.replace('T', 'E') return P t = read_int() for i in range(1, T + 1): (n, p) = (read_int(), input()) answer = solve(N, P) print('Case #{}: {}'.format(i, answer))
class Solution: def findClosestElements(self, arr: List[int], k: int, x: int) -> List[int]: diff = [] for i in range(len(arr)): diff.append((abs(arr[i] - x), i)) diff = sorted(diff, reverse=True) ans = [] for i in range(k): a...
class Solution: def find_closest_elements(self, arr: List[int], k: int, x: int) -> List[int]: diff = [] for i in range(len(arr)): diff.append((abs(arr[i] - x), i)) diff = sorted(diff, reverse=True) ans = [] for i in range(k): ans.append(arr[diff.pop()...
#Variable String and f-strings first_name = "nemuel" last_name = "palomo" full_name = f"{first_name} {last_name}" print(full_name) print(f"Hello, {full_name.title()}!") message = f"Hello, {full_name.title()}!" print(message) print("Python") print("\tPython") print("") print("Languages:\nPython\nC...
first_name = 'nemuel' last_name = 'palomo' full_name = f'{first_name} {last_name}' print(full_name) print(f'Hello, {full_name.title()}!') message = f'Hello, {full_name.title()}!' print(message) print('Python') print('\tPython') print('') print('Languages:\nPython\nC\nJavascript') print('') print('Language:\n\tPython:\n...
def printEvent(event): print('MessageName:', event.MessageName) print('Message:',event.Message) print('Time:', event.Time) print('Window:',event.Window) print('WindowName:',event.WindowName) print('Ascii:', event.Ascii, chr(event.Ascii)) print('Key:', event.Key) print( 'KeyID:', event.KeyID) print( ...
def print_event(event): print('MessageName:', event.MessageName) print('Message:', event.Message) print('Time:', event.Time) print('Window:', event.Window) print('WindowName:', event.WindowName) print('Ascii:', event.Ascii, chr(event.Ascii)) print('Key:', event.Key) print('KeyID:', event...
print ("H") print ("e") print ("l") print ("l") print ("o") print ("W") print ("o") print ("r") print ("l") print ("d")
print('H') print('e') print('l') print('l') print('o') print('W') print('o') print('r') print('l') print('d')
class Solution: def containsDuplicate(self, nums) -> bool: d = {} # store the elements which already exist for elem in nums: if elem in d: return True else: d[elem] = 1 return False print(Solution().containsDuplicate([0]))
class Solution: def contains_duplicate(self, nums) -> bool: d = {} for elem in nums: if elem in d: return True else: d[elem] = 1 return False print(solution().containsDuplicate([0]))
# # PySNMP MIB module HP-ICF-PRIVATEVLAN-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HP-ICF-PRIVATEVLAN-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:35:06 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (d...
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_size_constraint, constraints_union, value_range_constraint, constraints_intersection) ...
targetX = [143,177] targetY = [-106,-71] # targetX = [20,30] # targetY = [-10,-5] def step(X,Y,vX,vY): X = X + vX Y = Y + vY vY = vY - 1 if (vX > 0): vX = vX - 1 elif (vX < 0): vX = vX + 1 return [X,Y,vX,vY] hits = [] for vx in range(max(targetX)+1): for vy in range(-max(m...
target_x = [143, 177] target_y = [-106, -71] def step(X, Y, vX, vY): x = X + vX y = Y + vY v_y = vY - 1 if vX > 0: v_x = vX - 1 elif vX < 0: v_x = vX + 1 return [X, Y, vX, vY] hits = [] for vx in range(max(targetX) + 1): for vy in range(-max(max(targetY), abs(min(targetY))) ...
# yapf:disable log_config = dict( interval=1, hooks=[ dict(type='StatisticTextLoggerHook', by_epoch=True, interval=1), #dict(type='TensorboardLoggerHook') ]) # yapf:enable seed = None deterministic = False gpu_ids = [0] dist_params = dict(backend='nccl') log_level = 'INFO' load_from = None resum...
log_config = dict(interval=1, hooks=[dict(type='StatisticTextLoggerHook', by_epoch=True, interval=1)]) seed = None deterministic = False gpu_ids = [0] dist_params = dict(backend='nccl') log_level = 'INFO' load_from = None resume_from = None workflow = [('train', 1)] cudnn_benchmark = False work_dir = '/root/public02/ma...
bases = { "binary": 2, "octal": 8, "decimal": 10, "hex": 16, "hexadecimal": 16 } default = 10 def verify_base(x): try: return int(x) except: if x in bases: return bases[x] else: return default def decimal_value(x): if(x >= '0'...
bases = {'binary': 2, 'octal': 8, 'decimal': 10, 'hex': 16, 'hexadecimal': 16} default = 10 def verify_base(x): try: return int(x) except: if x in bases: return bases[x] else: return default def decimal_value(x): if x >= '0' and x <= '9': return int(...
def insertion_sort(lista): fim = len(lista) for i in range(fim - 1): posicao_do_minimo = i for j in range(i + 1, fim): if lista[j] < lista[posicao_do_minimo]: posicao_do_minimo = j lista[i], lista[posicao_do_minimo] = lista[posicao_do_minimo], ...
def insertion_sort(lista): fim = len(lista) for i in range(fim - 1): posicao_do_minimo = i for j in range(i + 1, fim): if lista[j] < lista[posicao_do_minimo]: posicao_do_minimo = j (lista[i], lista[posicao_do_minimo]) = (lista[posicao_do_minimo], lista[i]) ...
piv_limit = 0.20 def drive_from_vector(x, y): left_premix = 0.0 right_premix = 0.0 pivot_speed = 0.0 pivot_scale = 0.0 if y >= 0: if x >= 0: left_premix = 1.0 right_premix = 1.0 - x else: left_premix = 1.0 + x right_pr...
piv_limit = 0.2 def drive_from_vector(x, y): left_premix = 0.0 right_premix = 0.0 pivot_speed = 0.0 pivot_scale = 0.0 if y >= 0: if x >= 0: left_premix = 1.0 right_premix = 1.0 - x else: left_premix = 1.0 + x right_premix = 1.0 eli...
def process(thisGlyph): thisGlyph.beginUndo() for layer in thisGlyph.layers: for path in layer.paths: path.addNodesAtExtremes() thisGlyph.endUndo()
def process(thisGlyph): thisGlyph.beginUndo() for layer in thisGlyph.layers: for path in layer.paths: path.addNodesAtExtremes() thisGlyph.endUndo()
class Solution: def twoSum(self, numbers: List[int], target: int) -> List[int]: i,j=0,len(numbers)-1 while i<j: m=i+(j-i)//2 if numbers[i]+numbers[j]==target: return [i+1,j+1] elif numbers[i]+numbers[m]>target: j=m-1 eli...
class Solution: def two_sum(self, numbers: List[int], target: int) -> List[int]: (i, j) = (0, len(numbers) - 1) while i < j: m = i + (j - i) // 2 if numbers[i] + numbers[j] == target: return [i + 1, j + 1] elif numbers[i] + numbers[m] > target: ...
def _first_upper(v): if len(v) > 0: return v[0].upper() + v[1:] else: return v def to_upper_camelcase(v): return ''.join(_first_upper(part) for part in v.split('_')) def to_camelcase(v): parts = v.split('_') return parts[0] + ''.join(_first_upper(part) for part in parts[1:])
def _first_upper(v): if len(v) > 0: return v[0].upper() + v[1:] else: return v def to_upper_camelcase(v): return ''.join((_first_upper(part) for part in v.split('_'))) def to_camelcase(v): parts = v.split('_') return parts[0] + ''.join((_first_upper(part) for part in parts[1:]))
# 5. Person Info # Write a function called get_info that receives a name, an age, and a town, and returns a string in the format: # "This is {name} from {town} and he is {age} years old". Use dictionary unpacking when testing your function. # Submit only the function in the judge system. def get_info(**kwargs): re...
def get_info(**kwargs): return f"This is {kwargs.get('name')} from {kwargs.get('town')} and he is {kwargs.get('age')} years old" print(get_info(**{'name': 'George', 'town': 'Sofia', 'age': 20}))
def replace_names(fio, line): new_line = line for x, y in zip(['orgsurname', 'orgname', 'orgpatronymic', 'orgcity'], [0, 1, 2, 3]): new_line = new_line.replace(x, fio[y]) return new_line def names_gen(file): names_list = [] with open(file, 'r', encoding='utf-8') as f: for line in f...
def replace_names(fio, line): new_line = line for (x, y) in zip(['orgsurname', 'orgname', 'orgpatronymic', 'orgcity'], [0, 1, 2, 3]): new_line = new_line.replace(x, fio[y]) return new_line def names_gen(file): names_list = [] with open(file, 'r', encoding='utf-8') as f: for line in ...
def median(median_list): try: median_list.sort() mid = len(median_list) // 2 res = (median_list[mid] + median_list[~mid]) / 2 return res except (IndexError) or (ValueError): # Index Error : throws exception if the list is empty # Value Error : throws exception if ...
def median(median_list): try: median_list.sort() mid = len(median_list) // 2 res = (median_list[mid] + median_list[~mid]) / 2 return res except IndexError or ValueError: return None
AWS_ACCESS_KEY_ID='' AWS_SECRET_ACCESS_KEY='' AWS_DEFAULT_REGION='' AWS_DEFAULT_OUTPUT='json' SLACK_ACCESS_TOKEN='' SLACK_CHANNEL='' SQS_QUEUE_URL='' AWS_REGION=AWS_DEFAULT_REGION
aws_access_key_id = '' aws_secret_access_key = '' aws_default_region = '' aws_default_output = 'json' slack_access_token = '' slack_channel = '' sqs_queue_url = '' aws_region = AWS_DEFAULT_REGION
while True: n=int(input()) if(n==2002): print("Acesso Permitido") break else: print("Senha Invalida")
while True: n = int(input()) if n == 2002: print('Acesso Permitido') break else: print('Senha Invalida')
#!/usr/bin/python class Test (): def start (self): print('yea') def trigger_hook (self, name, args): print(args)
class Test: def start(self): print('yea') def trigger_hook(self, name, args): print(args)
''' Created on Jun 26, 2013 @author: Mantas Stankevicius @contact: mantas.stankevicius@cern.ch http://cmsdoxy.web.cern.ch/cmsdoxy/dataformats/ @responsible: ''' json = { "full": { "title": "RecoTracker collections (in RECO and AOD)", "data": [ { "ins...
""" Created on Jun 26, 2013 @author: Mantas Stankevicius @contact: mantas.stankevicius@cern.ch http://cmsdoxy.web.cern.ch/cmsdoxy/dataformats/ @responsible: """ json = {'full': {'title': 'RecoTracker collections (in RECO and AOD)', 'data': [{'instance': 'dedxHarmonic2', 'container': '*'...
#!/usr/bin/env python # encoding: utf-8 # HTTP Status Codes OK = 200 CREATED = 201 ACCEPTED = 202 NO_CONTENT = 204 BAD_REQUEST = 400 UNAUTHORIZED = 401 FORBIDDEN = 403 NOT_FOUND = 404 METHOD_NOT_ALLOWED = 405 APPLICATION_ERROR = 500 METHOD_NOT_IMPLEMENTED = 501 class HttpError(Exception): status = APPLICATION...
ok = 200 created = 201 accepted = 202 no_content = 204 bad_request = 400 unauthorized = 401 forbidden = 403 not_found = 404 method_not_allowed = 405 application_error = 500 method_not_implemented = 501 class Httperror(Exception): status = APPLICATION_ERROR msg = 'Application Error' def __init__(self, msg=...
def main() -> None: N, X = map(int, input().split()) assert 1 <= N <= 100 assert 1 <= X <= 10**6 for _ in range(N): A_i, C_i = map(int, input().split()) assert 1 <= A_i <= 10**6 assert 1 <= C_i <= 10**6 if __name__ == '__main__': main()
def main() -> None: (n, x) = map(int, input().split()) assert 1 <= N <= 100 assert 1 <= X <= 10 ** 6 for _ in range(N): (a_i, c_i) = map(int, input().split()) assert 1 <= A_i <= 10 ** 6 assert 1 <= C_i <= 10 ** 6 if __name__ == '__main__': main()
a = [1, 2, 3] b = [4, 5, 6] c = a+b print(c)
a = [1, 2, 3] b = [4, 5, 6] c = a + b print(c)
''' LeetCode Stack Q.921 Minimum Add to Make Parentheses Valid ''' def minAddToMakeValid(S): stack = [] ans = 0 for i in S: if i == '(': stack.append(i) else: if stack: stack.pop(-1) else: ans += 1 ans += len(stack...
""" LeetCode Stack Q.921 Minimum Add to Make Parentheses Valid """ def min_add_to_make_valid(S): stack = [] ans = 0 for i in S: if i == '(': stack.append(i) elif stack: stack.pop(-1) else: ans += 1 ans += len(stack) return ans if __name...
costs = { "character": { # (amount, tier) 0: {'xp': 0, 'mora': 0, 'element_1': (0, 0), 'element_2': 0, 'local': 0, 'common': (0, 0)}, # lvl 1, asc 0 1: {'xp': 120175, 'mora': 0, 'element_1': (0, 0), 'element_2': 0, 'local': 0, 'common': (0, 0)}, # lvl 20, asc 0 2: {'xp': 578325, 'mora': 20000, 'element_1': (1...
costs = {'character': {0: {'xp': 0, 'mora': 0, 'element_1': (0, 0), 'element_2': 0, 'local': 0, 'common': (0, 0)}, 1: {'xp': 120175, 'mora': 0, 'element_1': (0, 0), 'element_2': 0, 'local': 0, 'common': (0, 0)}, 2: {'xp': 578325, 'mora': 20000, 'element_1': (1, 0), 'element_2': 0, 'local': 3, 'common': (3, 0)}, 3: {'xp...
#input firstNumber = int(input()) secondNumber = int(input()) #output print(firstNumber+secondNumber) print(firstNumber-secondNumber) print(firstNumber*secondNumber)
first_number = int(input()) second_number = int(input()) print(firstNumber + secondNumber) print(firstNumber - secondNumber) print(firstNumber * secondNumber)
# divide function def partition(arr,low,high): i = ( low-1 ) pivot = arr[high] # pivot element for j in range(low , high): # If current element is smaller if arr[j] <= pivot: # increment i = i+1 arr[i],arr[j] = arr[j],arr[i] arr[i+1],arr[high] = arr[high],arr...
def partition(arr, low, high): i = low - 1 pivot = arr[high] for j in range(low, high): if arr[j] <= pivot: i = i + 1 (arr[i], arr[j]) = (arr[j], arr[i]) (arr[i + 1], arr[high]) = (arr[high], arr[i + 1]) return i + 1 def quick_sort(arr, low, high): if low < high:...
#!/usr/bin/env python3 # "slicing" gets values between two indexes # a list my_list = [2,4,6,8,10] # slice it, getting only values between the 1st and 3rd index using [int:int] print(my_list[1:3])
my_list = [2, 4, 6, 8, 10] print(my_list[1:3])
def test_basic(client, flask_file_request_args): res = client.post('/image', **flask_file_request_args) assert res.status_code == 201 assert res.get_json()['success'][0] == 'foobar.jpg' def test_no_file(client): res = client.post('/image') assert res.status_code == 400 assert res.get_json()['e...
def test_basic(client, flask_file_request_args): res = client.post('/image', **flask_file_request_args) assert res.status_code == 201 assert res.get_json()['success'][0] == 'foobar.jpg' def test_no_file(client): res = client.post('/image') assert res.status_code == 400 assert res.get_json()['er...
def count_bits(n): n_bin = bin(n) for i in range(len(n_bin)): count = n_bin.count('1') return count
def count_bits(n): n_bin = bin(n) for i in range(len(n_bin)): count = n_bin.count('1') return count
class Pessoa: def __init__(self,*filhos, nome = None, idade=36): self.idade = idade self.nome = nome self.filhos = list(filhos) def cumprimentar(self): return 'ola mundo' if __name__ == '__main__': leonardo = Pessoa(nome = 'Leonardo') vera = Pessoa(leonardo, nome = ...
class Pessoa: def __init__(self, *filhos, nome=None, idade=36): self.idade = idade self.nome = nome self.filhos = list(filhos) def cumprimentar(self): return 'ola mundo' if __name__ == '__main__': leonardo = pessoa(nome='Leonardo') vera = pessoa(leonardo, nome='Vera') ...
#!/usr/bin/env python3 class ShoppingCenter: def __init__(self, capital, shops:list): if shops == []: raise Warning("No shops") self._capital = capital self.__shops = shops self.__debtors = [] def collect_rent_and_loan(self, rent): for shop in self.__shops:...
class Shoppingcenter: def __init__(self, capital, shops: list): if shops == []: raise warning('No shops') self._capital = capital self.__shops = shops self.__debtors = [] def collect_rent_and_loan(self, rent): for shop in self.__shops: self._capi...
{ "targets": [ { "target_name": "addon", "sources": [ "src/harfbuzz.cc", ], "include_dirs": ["<!(node -e \"require('nan')\")", "/usr/local/include/freetype2", "/usr/local/include/harfbuzz"], "libraries": [ "-lfreetype", "-lharfbuzz" ] } ] }
{'targets': [{'target_name': 'addon', 'sources': ['src/harfbuzz.cc'], 'include_dirs': ['<!(node -e "require(\'nan\')")', '/usr/local/include/freetype2', '/usr/local/include/harfbuzz'], 'libraries': ['-lfreetype', '-lharfbuzz']}]}
class DjangoShardingException(Exception): pass class ShardedModelInitializationException(DjangoShardingException): pass class InvalidMigrationException(DjangoShardingException): pass class InvalidShowMigrationsException(DjangoShardingException): pass class NonExistentDatabaseException(DjangoShar...
class Djangoshardingexception(Exception): pass class Shardedmodelinitializationexception(DjangoShardingException): pass class Invalidmigrationexception(DjangoShardingException): pass class Invalidshowmigrationsexception(DjangoShardingException): pass class Nonexistentdatabaseexception(DjangoSharding...
def join(sep, items): res = '' if len(items) > 0: res = str(items[0]) items = items[1:] while len(items) > 0: res = res + sep + str(items[0]) items = items[1:] return res
def join(sep, items): res = '' if len(items) > 0: res = str(items[0]) items = items[1:] while len(items) > 0: res = res + sep + str(items[0]) items = items[1:] return res
class Solution: def calculate(self, s: str) -> int: stack = [] pre_op = '+' num = 0 for i, each in enumerate(s): if each.isdigit(): num = 10 * num + int(each) if i == len(s) - 1 or each in '+-*': if pre_op == '+': ...
class Solution: def calculate(self, s: str) -> int: stack = [] pre_op = '+' num = 0 for (i, each) in enumerate(s): if each.isdigit(): num = 10 * num + int(each) if i == len(s) - 1 or each in '+-*': if pre_op == '+': ...
'''4. Write a Python program to count the number occurrence of a specific character in a string.''' def count_character(string, char): return string.count(char) print(count_character("Stackoverflow", 'o')) print(count_character("Hash", 's'))
"""4. Write a Python program to count the number occurrence of a specific character in a string.""" def count_character(string, char): return string.count(char) print(count_character('Stackoverflow', 'o')) print(count_character('Hash', 's'))
totalGold = 0 while True: coin = hero.findNearestItem() if coin: hero.moveXY(coin.pos.x, coin.pos.y) totalGold += coin.value if totalGold >= 25: break hero.moveXY(58, 33) hero.say(totalGold)
total_gold = 0 while True: coin = hero.findNearestItem() if coin: hero.moveXY(coin.pos.x, coin.pos.y) total_gold += coin.value if totalGold >= 25: break hero.moveXY(58, 33) hero.say(totalGold)
''' @author: l4zyc0d3r People who are happy makes other happy. I am gonna finish it slowly but definitely.cdt ''' def failfunc(s): F= [0 for _ in s] i,j = 1, 0 while i<len(s): if s[i] ==s[j]: j+=1 F[i] = j i+=1 else: if j == 0: F[i],i = 0, i+1 else: j = F[j-1] return F def find(F,H, N): i,j...
""" @author: l4zyc0d3r People who are happy makes other happy. I am gonna finish it slowly but definitely.cdt """ def failfunc(s): f = [0 for _ in s] (i, j) = (1, 0) while i < len(s): if s[i] == s[j]: j += 1 F[i] = j i += 1 elif j == 0: (F[i]...
''' https://leetcode.com/contest/weekly-contest-151/problems/dinner-plate-stacks/ Implementation: Using Fenwick tree with binary search for push op Better way would be to use Heap instead of keep track of left most index for push op Both Pop ops take O(1) at Average ''' class DinnerPlates: def __init__(self, capa...
""" https://leetcode.com/contest/weekly-contest-151/problems/dinner-plate-stacks/ Implementation: Using Fenwick tree with binary search for push op Better way would be to use Heap instead of keep track of left most index for push op Both Pop ops take O(1) at Average """ class Dinnerplates: def __init__(self, cap...
SCREEN_WIDTH = 640 SCREEN_HEIGHT = 480 LEFT = 'left' RIGHT = 'right' # Define some colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) RED = (255, 0, 0) # valid parsers PARSERS = ('apache', 'postgresql', 'mysql')
screen_width = 640 screen_height = 480 left = 'left' right = 'right' black = (0, 0, 0) white = (255, 255, 255) red = (255, 0, 0) parsers = ('apache', 'postgresql', 'mysql')
class FollowTrackConstraint: camera = None clip = None depth_object = None frame_method = None object = None track = None use_3d_position = None use_active_clip = None use_undistorted_position = None
class Followtrackconstraint: camera = None clip = None depth_object = None frame_method = None object = None track = None use_3d_position = None use_active_clip = None use_undistorted_position = None
def bin_to_decimal(binary: list[int]): decimal = 0 i = 0 for d in reversed(binary): if i == 0: decimal += d else: decimal += d * 2**i i += 1 return decimal def parse_report(diagnostic_report): return [[int(c) for c in d] for d in diagnostic_report]
def bin_to_decimal(binary: list[int]): decimal = 0 i = 0 for d in reversed(binary): if i == 0: decimal += d else: decimal += d * 2 ** i i += 1 return decimal def parse_report(diagnostic_report): return [[int(c) for c in d] for d in diagnostic_report]
class person: totalObjects=0 def __init__(self): person.totalObjects=person.totalObjects+1 #@classmethod def showcount(self): print("Total objects: ",self.totalObjects) class greeting: @staticmethod def greet(): print("Hello!") greeting.greet()
class Person: total_objects = 0 def __init__(self): person.totalObjects = person.totalObjects + 1 def showcount(self): print('Total objects: ', self.totalObjects) class Greeting: @staticmethod def greet(): print('Hello!') greeting.greet()
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = 'CYX' configs = { 'debug': True, 'server':{ 'host': '127.0.0.1', 'port': 9000 }, 'qshield':{ 'jars': 'opaque_2.11-0.1.jar', 'app_name': 'qshield', 'master': 'spark://spark:7077' } }
__author__ = 'CYX' configs = {'debug': True, 'server': {'host': '127.0.0.1', 'port': 9000}, 'qshield': {'jars': 'opaque_2.11-0.1.jar', 'app_name': 'qshield', 'master': 'spark://spark:7077'}}
async def get_userid(message): if not 'from_user' in dir(message): return None if not 'id' in dir(message.from_user): return None return message.from_user.id async def get_text(message): if 'text' in dir(message): if len(message.text) > 0: return message.text if ...
async def get_userid(message): if not 'from_user' in dir(message): return None if not 'id' in dir(message.from_user): return None return message.from_user.id async def get_text(message): if 'text' in dir(message): if len(message.text) > 0: return message.text if ...
value = float(input('What the house value: ')) salary = float(input('What is your salary: ')) years = int(input('How many years you will pay: ')) installment = value / (years * 12) limit = salary * 0.3 print('To pay a house of R$ {:.2f} in {} years'.format(value, years), end=', ') print('the installment is R$ {:.2f}.'....
value = float(input('What the house value: ')) salary = float(input('What is your salary: ')) years = int(input('How many years you will pay: ')) installment = value / (years * 12) limit = salary * 0.3 print('To pay a house of R$ {:.2f} in {} years'.format(value, years), end=', ') print('the installment is R$ {:.2f}.'....
n=4 for i in range(1,2*n): print("0",end="") print() for i in range(1,n): for left in range(1,n-i+1): print("0",end="") for space in range(1,2*i): print(" ",end="") for right in range(1, n - i + 1): print("0", end="") print()
n = 4 for i in range(1, 2 * n): print('0', end='') print() for i in range(1, n): for left in range(1, n - i + 1): print('0', end='') for space in range(1, 2 * i): print(' ', end='') for right in range(1, n - i + 1): print('0', end='') print()
passwords = open("input.txt", "r").read().split("\n") correct = 0 for passw in passwords: if (len(passw.split()) == len(set(passw.split()))) & (len(passw.split()) > 1): correct = correct + 1 print(correct)
passwords = open('input.txt', 'r').read().split('\n') correct = 0 for passw in passwords: if (len(passw.split()) == len(set(passw.split()))) & (len(passw.split()) > 1): correct = correct + 1 print(correct)
class PlasticColumn(object): __slots__ = ('_parent', '_column') def __init__(self, parentClass, columnName): # anchor to the parent class to ensure runtime modifications are considered self._parent = parentClass self._column = columnName def dereference(self, selector):...
class Plasticcolumn(object): __slots__ = ('_parent', '_column') def __init__(self, parentClass, columnName): self._parent = parentClass self._column = columnName def dereference(self, selector): if isinstance(selector, PlasticColumn): return selector.fqn else: ...
class BST: # Checks if a binary tree is a binary search tree. # root - node with `left`, `right` and `value` properties class TreeNode: def __init__(self, value, left_child=None, right_child=None): self.value = value self.left = left_child self.right = right_chi...
class Bst: class Treenode: def __init__(self, value, left_child=None, right_child=None): self.value = value self.left = left_child self.right = right_child @staticmethod def create_node(values, index): if index >= len(values) or values[index...
'''256 color terminal handling ALL_COLORS is a dict mapping color indexes to the ANSI escape code. ALL_COLORS is essentially a "palette". Note that ALL_COLORS is a dict that (mostly) uses integers as the keys. Yeah, that is weird. In theory, the keys could also be other identifiers, although that isn't used much at t...
"""256 color terminal handling ALL_COLORS is a dict mapping color indexes to the ANSI escape code. ALL_COLORS is essentially a "palette". Note that ALL_COLORS is a dict that (mostly) uses integers as the keys. Yeah, that is weird. In theory, the keys could also be other identifiers, although that isn't used much at t...
def setup(): size(1000,1000) background(0) def draw(): stroke(random(200,250)) strokeWeight(random(1,5)) point(random(0,width),random(0,height)) #saveFrame("####.png")
def setup(): size(1000, 1000) background(0) def draw(): stroke(random(200, 250)) stroke_weight(random(1, 5)) point(random(0, width), random(0, height))
[[1, 2, 3]] [[1, 2, 3], [1, 3, 2]] [[1, 2, 3], [1, 3, 2], [2, 1, 3]] [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1]] [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 2, 1]] [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 2, 1], [3, 1, 2]] [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 2, 1], [3, 1, 2]] [[1, 2, 3]] [[...
[[1, 2, 3]] [[1, 2, 3], [1, 3, 2]] [[1, 2, 3], [1, 3, 2], [2, 1, 3]] [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1]] [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 2, 1]] [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 2, 1], [3, 1, 2]] [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 2, 1], [3, 1, 2]] [[1, 2, 3]] [[1,...
#!/usr/bin/python # -*- coding: utf-8 -*- class Api: def __init__(self, core): print('install core %s on %s' % (core, self)) self.__core = core def config(self): pass def get_db_connection(self): return self.__core.get_db_connection() def register_to_input(self, f...
class Api: def __init__(self, core): print('install core %s on %s' % (core, self)) self.__core = core def config(self): pass def get_db_connection(self): return self.__core.get_db_connection() def register_to_input(self, f): self.__core.register_to_input(f) ...
def square_return(num): return num ** 2 def square_print(num): print("The square of num is ", num ** 2) # print the result of number1 + number2 def add1(number1, number2): return number1 + number2 print("hello") # add2 will return nothing. def add2(number1, number2): print(number1 + number2)
def square_return(num): return num ** 2 def square_print(num): print('The square of num is ', num ** 2) def add1(number1, number2): return number1 + number2 print('hello') def add2(number1, number2): print(number1 + number2)
def bubble_sort(given_list): for i in range(0, len(given_list)): for j in range(0, len(given_list) - (i + 1)): # start of for loop to compare and interchange elements if given_list[j] > given_list[j + 1]: # Compare and if previous element is getter than next element. given_lis...
def bubble_sort(given_list): for i in range(0, len(given_list)): for j in range(0, len(given_list) - (i + 1)): if given_list[j] > given_list[j + 1]: (given_list[j + 1], given_list[j]) = (given_list[j], given_list[j + 1]) def main(): given_list = list(map(int, input('Enter El...
dict = {} dict['Hot']=['balmy','summery','tropical','boiling'] dict['Cold']=['chilly','cool','freezing','icy'] dict['Happy']=['contented','content','cheerful','cheery'] dict['Sad']=['unhappy','sorrowful','dejected','regretful'] print("Welcome to the thesaurus") print("These are the current words in the thesauru...
dict = {} dict['Hot'] = ['balmy', 'summery', 'tropical', 'boiling'] dict['Cold'] = ['chilly', 'cool', 'freezing', 'icy'] dict['Happy'] = ['contented', 'content', 'cheerful', 'cheery'] dict['Sad'] = ['unhappy', 'sorrowful', 'dejected', 'regretful'] print('Welcome to the thesaurus') print('These are the current words in ...
''' Created on 1.12.2016 @author: Darren '''''' Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer of each row is greater than the last integer of the previous row. ...
""" Created on 1.12.2016 @author: Darren Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer of each row is greater than the last integer of the previous row. For exa...
############################################### # # # Created by Youssef Sully # # Beginner python # # Dictionary 4 # # # ################################...
dict_info_1 = {'first_name': 'Youssef', 'last_name': 'Sully', 'age': 33, 'courses': ['Telecom theory', 'Informatics']} print('\n{} {} {}\n'.format('-' * 9, 'Dictionary output', '-' * 9)) print('My first name is {} '.format(dict_info_1['first_name'])) print('My last name is {} '.format(dict_info_1['last_name'])) print('...
''' Created on Jan 1, 2019 @author: Shawn ''' def PatternXorAssert(x, y, z, L): command = "" command += "ASSERT(BVXOR({0} & {1} & {2}, BVXOR({0}, BVXOR({1}, {2}))) = 0bin{3});\n".format( x, y, z, "0" * L ) return command def Return_Sum_String(input_list...
""" Created on Jan 1, 2019 @author: Shawn """ def pattern_xor_assert(x, y, z, L): command = '' command += 'ASSERT(BVXOR({0} & {1} & {2}, BVXOR({0}, BVXOR({1}, {2}))) = 0bin{3});\n'.format(x, y, z, '0' * L) return command def return__sum__string(input_list, vec_len, var_len=1): l = len(input_list) ...
#Given a non-negative integer, return an array / a list of the individual digits in order. def largest(n,xs): xss = sorted(xs, reverse=True) return sorted(xss[:n]) #Alternate Solution def largest(n,xs): return sorted(xs)[-n:];
def largest(n, xs): xss = sorted(xs, reverse=True) return sorted(xss[:n]) def largest(n, xs): return sorted(xs)[-n:]
# https://www.geeksforgeeks.org/inorder-successor-in-binary-search-tree/ class TreeNode: def __init__(self, data, left=None, right=None): self.data = data self.left = left self.right = right def inorder_traversal_recursive(self, root): if not root: return ...
class Treenode: def __init__(self, data, left=None, right=None): self.data = data self.left = left self.right = right def inorder_traversal_recursive(self, root): if not root: return self.inorder_traversal_recursive(root.left) print(root.data, end=' ...
# A list of all the ranks ranks = [ "AVN CADET", "BRIG GEN", "ENGR SEA", "ENGR YEO", "1ST SGT", "ENGR CK", "ENGR OS", "MAJ GEN", "COLONEL", "1ST LT", "2ND LT", "GY SGT", "LT COL", "LT GEN", "TECH 1", "TECH 2", "TECH 3", "TECH 4", "TECH 5", ...
ranks = ['AVN CADET', 'BRIG GEN', 'ENGR SEA', 'ENGR YEO', '1ST SGT', 'ENGR CK', 'ENGR OS', 'MAJ GEN', 'COLONEL', '1ST LT', '2ND LT', 'GY SGT', 'LT COL', 'LT GEN', 'TECH 1', 'TECH 2', 'TECH 3', 'TECH 4', 'TECH 5', 'TECH 6', '1STSGT', 'MAJGEN', 'MGYSGT', 'MPCOCG', 'SGTMAJ', 'SSMB1C', 'SSMB2C', 'M SGT', 'S SGT', 'T SGT', ...
class Solution: def decompressRLElist(self, nums: List[int]) -> List[int]: n = len(nums) ans = [] for i in range(n, 2): print([nums[i + 1]] * nums[i]) ans.extend([nums[i + 1]] * nums[i]) print(ans) return ans
class Solution: def decompress_rl_elist(self, nums: List[int]) -> List[int]: n = len(nums) ans = [] for i in range(n, 2): print([nums[i + 1]] * nums[i]) ans.extend([nums[i + 1]] * nums[i]) print(ans) return ans
n = int(input()) c = 0 for _ in range(n): if int(input()) ==1: c+=1 if c>n//2: print("Junhee is cute!") else : print("Junhee is not cute!")
n = int(input()) c = 0 for _ in range(n): if int(input()) == 1: c += 1 if c > n // 2: print('Junhee is cute!') else: print('Junhee is not cute!')
__author__ = "Prahlad Yeri" __email__ = "prahladyeri@yahoo.com" __copyright__ = "(c) 2019 Prahlad Yeri" __license__ = "MIT" __version__ = "1.0.7" __title__ = "github activity reminder cron" __description__ = ''
__author__ = 'Prahlad Yeri' __email__ = 'prahladyeri@yahoo.com' __copyright__ = '(c) 2019 Prahlad Yeri' __license__ = 'MIT' __version__ = '1.0.7' __title__ = 'github activity reminder cron' __description__ = ''
#! /usr/bin/env python3 def isSum(data, number) : return any(True for i in range(len(data)) if number - data[i] in data[i + 1:]) with open("input", "r") as fd : numbers = [int(x) for x in fd.read().split('\n')] for i in range(25, len(numbers)) : if not isSum(numbers[i - 25:i], numbers[i]) : print...
def is_sum(data, number): return any((True for i in range(len(data)) if number - data[i] in data[i + 1:])) with open('input', 'r') as fd: numbers = [int(x) for x in fd.read().split('\n')] for i in range(25, len(numbers)): if not is_sum(numbers[i - 25:i], numbers[i]): print(numbers[i]) break
class notes: def __init__(self): notes = list() self.notes = notes def append(self, Time, Type, X, Y, Direction): global notes self.notes.append('{"_time":' + str(Time) + ',"_lineIndex":' + str(X) + ',"_lineLayer":' + str(Y) + ',"_type":' + str(Type) + ',"_cutDirection":...
class Notes: def __init__(self): notes = list() self.notes = notes def append(self, Time, Type, X, Y, Direction): global notes self.notes.append('{"_time":' + str(Time) + ',"_lineIndex":' + str(X) + ',"_lineLayer":' + str(Y) + ',"_type":' + str(Type) + ',"_cutDirection":' + str...
MAX_ITEMS = 100 class StackType: def __init__(self): self.info = [] def is_empty(self): return len(self.info)==0 def is_full(self): return len(self.info)==MAX_ITEMS def push(self, item): if not self.is_full(): self.info.append(item) ...
max_items = 100 class Stacktype: def __init__(self): self.info = [] def is_empty(self): return len(self.info) == 0 def is_full(self): return len(self.info) == MAX_ITEMS def push(self, item): if not self.is_full(): self.info.append(item) else: ...
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'test.db', } } INSTALLED_APPS = [ 'django.contrib.sessions', 'bootstrap_ui', ] ROOT_URLCONF = 'tests.urls' SECRET_KEY = 'test-key' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemp...
databases = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'test.db'}} installed_apps = ['django.contrib.sessions', 'bootstrap_ui'] root_urlconf = 'tests.urls' secret_key = 'test-key' templates = [{'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': ['tests/templates'], 'APP_DIRS': True}...
NAME = 'bitcoin.py' ORIGINAL_AUTHORS = [ 'Gabriele Ron' ] ABOUT = ''' Checks the current price for Bitcoin through the Legacy Coin Market Cap API TODO: Update API to new Coin Market Cap API ''' COMMANDS = ''' >>> .btc returns current value of bitcoin ''' WEBSITE = 'https://Macr0Nerd.github.io'
name = 'bitcoin.py' original_authors = ['Gabriele Ron'] about = '\nChecks the current price for Bitcoin through the Legacy Coin Market Cap API\nTODO: Update API to new Coin Market Cap API\n' commands = '\n>>> .btc\nreturns current value of bitcoin\n' website = 'https://Macr0Nerd.github.io'
class Obstacle: def __init__(self, s, offset): self.type = s if self.type == 1: self.y = 280 - 85 width = 80 elif self.type == 2: self.y = 280 - 90 width = 65 elif self.type == 3: self.y =...
class Obstacle: def __init__(self, s, offset): self.type = s if self.type == 1: self.y = 280 - 85 width = 80 elif self.type == 2: self.y = 280 - 90 width = 65 elif self.type == 3: self.y = 280 - 100 width = 45 ...
_PFULL_STR = 'pfull' _RADEARTH = 6370997. LON_STR = 'lon' LAT_STR = 'lat' PHALF_STR = 'phalf' PFULL_STR = 'pfull'
_pfull_str = 'pfull' _radearth = 6370997.0 lon_str = 'lon' lat_str = 'lat' phalf_str = 'phalf' pfull_str = 'pfull'
class Address(object): def __init__(self): self.street = None self.number = None self.complement = None self.zip_code = None self.city = None self.state = None self.country = None
class Address(object): def __init__(self): self.street = None self.number = None self.complement = None self.zip_code = None self.city = None self.state = None self.country = None
# Checking a condition on a lit # Initialize the list we want to test test_list = ['no', 'yesss', 'tooshort', 'arg', 'nop', 'nope'] # Initialize the result list result_list = [] #[] empty list # Start iteration on the test_list for item in test_list: # item is conventional. Use what you like. # Check the item i...
test_list = ['no', 'yesss', 'tooshort', 'arg', 'nop', 'nope'] result_list = [] for item in test_list: if len(item) > 3: result_list.append(item) print(result_list)
#! /usr/bin/python3 # -*- coding: utf-8 -*- #================================================================================= # author: Chancerel Codjovi (aka codrelphi) # date: 2019-09-16 # source: https://www.hackerrank.com/challenges/python-print/problem #============================================================...
if __name__ == '__main__': n = int(input().strip()) for i in range(1, n + 1): print(i, end='')
class Add(Binary): __slots__ = ['left', 'right'] def eval(self, env: dict): return self.left.eval(env) + self.right.eval(env)
class Add(Binary): __slots__ = ['left', 'right'] def eval(self, env: dict): return self.left.eval(env) + self.right.eval(env)
def is_palindrome(s): def to_chars(s): s = s.lower() ans = '' for c in s: if c in 'abcdefghijklmnopqrstuvwxyz': ans += c return ans def is_pal(s): if len(s) <= 1: return True else: return s[0] == s[-1] and is_...
def is_palindrome(s): def to_chars(s): s = s.lower() ans = '' for c in s: if c in 'abcdefghijklmnopqrstuvwxyz': ans += c return ans def is_pal(s): if len(s) <= 1: return True else: return s[0] == s[-1] and is_p...
''' Question: Write a program that computes the value of a+aa+aaa+aaaa with a given digit as the value of a. Suppose the following input is supplied to the program: 9 Then, the output should be: 11106 ''' a = input() print(sum(int(i*a) for i in range(1, 5)))
""" Question: Write a program that computes the value of a+aa+aaa+aaaa with a given digit as the value of a. Suppose the following input is supplied to the program: 9 Then, the output should be: 11106 """ a = input() print(sum((int(i * a) for i in range(1, 5))))
class BatchStatus: newCount = 0 completed = 0 total = 0 inProgress = 0 def __init__(self,new_count,in_progress,completed,total): self.completed = completed self.newCount = new_count self.inProgress = in_progress self.total = total def get_completed(self): ...
class Batchstatus: new_count = 0 completed = 0 total = 0 in_progress = 0 def __init__(self, new_count, in_progress, completed, total): self.completed = completed self.newCount = new_count self.inProgress = in_progress self.total = total def get_completed(self): ...
{ "targets" : [ { "dependencies": [ "zlib.gyp:zlib" ], "target_name" : "libpng", "type" : "static_library", "include_dirs": [ "../src/configs", "../modules/lpng" ], "sources" :...
{'targets': [{'dependencies': ['zlib.gyp:zlib'], 'target_name': 'libpng', 'type': 'static_library', 'include_dirs': ['../src/configs', '../modules/lpng'], 'sources': ['../modules/lpng/png.c', '../modules/lpng/pngerror.c', '../modules/lpng/pngget.c', '../modules/lpng/pngmem.c', '../modules/lpng/pngpread.c', '../modules/...
class Carro: def __init__(self, motor, direcao): self.motor = motor self.direcao = direcao def calc_vel(self): return self.motor.velocidade def acelerar(self): self.motor.acelerar() def frear(self): self.motor.frear() def sentido(self): return self.di...
class Carro: def __init__(self, motor, direcao): self.motor = motor self.direcao = direcao def calc_vel(self): return self.motor.velocidade def acelerar(self): self.motor.acelerar() def frear(self): self.motor.frear() def sentido(self): return sel...
#Eoin Lees #Create a program to subtract one number from another #Input reads in a string so we need to convert it into an int so # we can preform mathematical operations x = int(input("Enter first number: ")) y = int(input("Enter Second number: ")) z = x - y print("{} minus {} is {}".format(x, y, z))
x = int(input('Enter first number: ')) y = int(input('Enter Second number: ')) z = x - y print('{} minus {} is {}'.format(x, y, z))
def go(n: int): d = [None]*(n+1) d[1] = 0 for i in range(2, n+1): d[i] = d[i-1] + 1 if i % 2 == 0 and d[i] > d[i//2] + 1: d[i] = d[i//2] + 1 if i % 3 == 0 and d[i] > d[i//3] + 1: d[i] = d[i//3] + 1 return d[n] def test_go(): assert go(2) == 1 ass...
def go(n: int): d = [None] * (n + 1) d[1] = 0 for i in range(2, n + 1): d[i] = d[i - 1] + 1 if i % 2 == 0 and d[i] > d[i // 2] + 1: d[i] = d[i // 2] + 1 if i % 3 == 0 and d[i] > d[i // 3] + 1: d[i] = d[i // 3] + 1 return d[n] def test_go(): assert go(...
class CardException(Exception): def __init__(self, message): self.message = message class CardNotFoundException(CardException): pass class TokenizationFailedException(CardException): pass class RepeatedCardException(CardException): pass
class Cardexception(Exception): def __init__(self, message): self.message = message class Cardnotfoundexception(CardException): pass class Tokenizationfailedexception(CardException): pass class Repeatedcardexception(CardException): pass
class ModularChessException(Exception): pass class InvalidMoveException(ModularChessException): pass class InvalidPositionError(ModularChessException, IndexError): pass class InvalidArgumentsError(ModularChessException, ValueError): pass class TimerError(ModularChessException): pass class ...
class Modularchessexception(Exception): pass class Invalidmoveexception(ModularChessException): pass class Invalidpositionerror(ModularChessException, IndexError): pass class Invalidargumentserror(ModularChessException, ValueError): pass class Timererror(ModularChessException): pass class Inval...
def sort(seq): L = len(seq) for i in range(L): for n in range(1, L - i): if seq[n] < seq[n - 1]: seq[n - 1], seq[n] = seq[n], seq[n - 1] return seq
def sort(seq): l = len(seq) for i in range(L): for n in range(1, L - i): if seq[n] < seq[n - 1]: (seq[n - 1], seq[n]) = (seq[n], seq[n - 1]) return seq