content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
class Solution: def trailingZeroes(self, n: int) -> int: l2 = [self.func(i, 2) for i in range(1, n+1) if i % 2 == 0] l5 = [self.func(i, 5) for i in range(1, n + 1) if i % 5 == 0] suml2 = sum(l2) suml5 = sum(l5) r = min(suml2, suml5) return r def func(self, n, i):...
class Solution: def trailing_zeroes(self, n: int) -> int: l2 = [self.func(i, 2) for i in range(1, n + 1) if i % 2 == 0] l5 = [self.func(i, 5) for i in range(1, n + 1) if i % 5 == 0] suml2 = sum(l2) suml5 = sum(l5) r = min(suml2, suml5) return r def func(self, n,...
# Here follows example input: fs = 48000 # Sample rate (Hz) base_freq = 100. # Base frequency (Hz) bpm = 120 # Beats per minute
fs = 48000 base_freq = 100.0 bpm = 120
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def verticalTraversal(self, root: 'TreeNode') -> 'List[List[int]]': queue = collections.deque([(root, 0, 0)]) d = collect...
class Solution: def vertical_traversal(self, root: 'TreeNode') -> 'List[List[int]]': queue = collections.deque([(root, 0, 0)]) d = collections.defaultdict(list) while queue: (node, x, y) = queue.popleft() d[x].append((y, node.val)) if node.left: ...
VALIGN_TOP = "top" VALIGN_CENTER = "center" VALIGN_BASELINE = "baseline" VALIGN_BOTTOM = "bottom" HALIGN_LEFT = "left" HALIGN_CENTER = "center" HALIGN_RIGHT = "right" PROPAGATE_UP = "up" PROPAGATE_DOWN = "down" NO_PROPAGATION = "local" NO_LOCAL_INVOKE = "nolocal" BOLD = "bold" NORMAL = "normal" SEMIBOLD = "semibold" LE...
valign_top = 'top' valign_center = 'center' valign_baseline = 'baseline' valign_bottom = 'bottom' halign_left = 'left' halign_center = 'center' halign_right = 'right' propagate_up = 'up' propagate_down = 'down' no_propagation = 'local' no_local_invoke = 'nolocal' bold = 'bold' normal = 'normal' semibold = 'semibold' le...
# hackerrank problem of problem solving # problem statement : Picking Numbers def pickingNumbers(arr) : left = 0 max_sum = 0;max_left = 0;max_right=0 for i in range(1, len(arr)) : if abs(arr[i] - arr[i-1]) > 1 : number = i - left if number > max_sum : ...
def picking_numbers(arr): left = 0 max_sum = 0 max_left = 0 max_right = 0 for i in range(1, len(arr)): if abs(arr[i] - arr[i - 1]) > 1: number = i - left if number > max_sum: max_sum = number max_left = left max_right = ...
st = input() sum = 0 for s in st: t = ord(s) if t >= ord('a'): sum += t - ord('a') + 1 else: sum += t - ord('A') + 27 ii = 2 for i in range(2, sum + 1): if sum % i == 0: ii = i break if ii == sum or sum == 1 : print('It is a prime word.') else : print('It is not a...
st = input() sum = 0 for s in st: t = ord(s) if t >= ord('a'): sum += t - ord('a') + 1 else: sum += t - ord('A') + 27 ii = 2 for i in range(2, sum + 1): if sum % i == 0: ii = i break if ii == sum or sum == 1: print('It is a prime word.') else: print('It is not a p...
mainstr="the quick brown fox jumped over the lazy dog. the dog slept over the verandah" newstr=mainstr.split(" ") i=0 a=" " while i<len(newstr): if newstr[i]=="over": a=a+"on"+" " else: a=a+newstr[i]+" " i+=1 print(a)
mainstr = 'the quick brown fox jumped over the lazy dog. the dog slept over the verandah' newstr = mainstr.split(' ') i = 0 a = ' ' while i < len(newstr): if newstr[i] == 'over': a = a + 'on' + ' ' else: a = a + newstr[i] + ' ' i += 1 print(a)
def chemelements(): periodic_elements = ["Ac","Al","Ag","Am","Ar","As","At","Au","B","Ba","Bh","Bi","Be", "Bk","Br","C","Ca","Cd","Ce","Cf","Cl","Cm","Co","Cr","Cs","Cu", "Db","Dy","Er","Es","Eu","F","Fe","Fm","Fr","Ga","Gd","Ge","H", "He","Hf","Hg","Ho...
def chemelements(): periodic_elements = ['Ac', 'Al', 'Ag', 'Am', 'Ar', 'As', 'At', 'Au', 'B', 'Ba', 'Bh', 'Bi', 'Be', 'Bk', 'Br', 'C', 'Ca', 'Cd', 'Ce', 'Cf', 'Cl', 'Cm', 'Co', 'Cr', 'Cs', 'Cu', 'Db', 'Dy', 'Er', 'Es', 'Eu', 'F', 'Fe', 'Fm', 'Fr', 'Ga', 'Gd', 'Ge', 'H', 'He', 'Hf', 'Hg', 'Ho', 'Hs', 'I', 'In', 'Ir'...
class Foo(): def g(self): pass class Bar(): def f(self): pass
class Foo: def g(self): pass class Bar: def f(self): pass
# # Copyright (C) [2020] Futurewei Technologies, Inc. # # FORCE-RISCV is 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-2.0 # # THIS SOFTWARE IS PRO...
new_registers = [{'target': 'system', 'register': 'vtype', 'size': 64, 'physical_register': 'vtype', 'index': '0xc21', 'fields': [{'field': 'VILL', 'shift': 63, 'size': 1}, {'field': 'RESERVED (WRITE 0)', 'shift': 8, 'size': 55}, {'field': 'VMA', 'shift': 7, 'size': 1}, {'field': 'VTA', 'shift': 6, 'size': 1}, {'field'...
''' There is a horizontal row of cubes. The length of each cube is given. You need to create a new vertical pile of cubes. The new pile should follow these directions: if cube_i is on top of cube_j then cube_j >= cube_i. When stacking the cubes, you can only pick up either the leftmost or the rightmost cube each ti...
""" There is a horizontal row of cubes. The length of each cube is given. You need to create a new vertical pile of cubes. The new pile should follow these directions: if cube_i is on top of cube_j then cube_j >= cube_i. When stacking the cubes, you can only pick up either the leftmost or the rightmost cube each ti...
#: Common folder in which the data file are related. DATA_ROOT_FOLDER = '/Users/mdartiailh/Labber/Data/2019/' #: Dictionary of parallel field, file path. DATA_PATHS = {400: '03/Data_0316/JS124S_BM002_390.hdf5', # 350: '03/Data_0317/JS124S_BM002_392.hdf5', # 300: '03/Data_0318/JS124S_BM002_3...
data_root_folder = '/Users/mdartiailh/Labber/Data/2019/' data_paths = {400: '03/Data_0316/JS124S_BM002_390.hdf5', 250: '03/Data_0318/JS124S_BM002_395.hdf5', 100: '03/Data_0321/JS124S_BM002_405.hdf5', -300: '04/Data_0430/JS124S_BM002_532.hdf5'} field_ranges = {400: (-0.008, -0.0055), 350: (None, -0.006), 300: (-0.00659,...
def poly_conversion_array(eq, var): poly = eq.split() coeffPower = [] i = 1 while i < len(poly): poly.insert(i, poly[i] + poly[i + 1]) poly.pop(i + 1) poly.pop(i + 1) i += 1 for j in poly: cp = j.split(var) if len(cp) == 1: cp.append(0) ...
def poly_conversion_array(eq, var): poly = eq.split() coeff_power = [] i = 1 while i < len(poly): poly.insert(i, poly[i] + poly[i + 1]) poly.pop(i + 1) poly.pop(i + 1) i += 1 for j in poly: cp = j.split(var) if len(cp) == 1: cp.append(0) ...
def selection(arr): for i in range(0, len(arr)): # Min idx starts always at the ith element min_idx = i # Look for any local minima going forward for j in range(i+1, len(arr)): # If we find one, set the min_idx to what we find if arr[j] < arr[mi...
def selection(arr): for i in range(0, len(arr)): min_idx = i for j in range(i + 1, len(arr)): if arr[j] < arr[min_idx]: min_idx = j (arr[i], arr[min_idx]) = (arr[min_idx], arr[i]) if __name__ == '__main__': arrs = [[4, 3, 3, 7, 6, -1, 10, 3, 8, 4], [10, 11, 9,...
# This file will store strings for the entire app # Error Strings space_in_first_name_error = 'First name may not contain spaces' space_in_last_name_error = 'Last name may not contain spaces' # Dashboard Strings my_projects = "My Projects" no_projects = "Looks like you don't have any projects yet. Select Add project,...
space_in_first_name_error = 'First name may not contain spaces' space_in_last_name_error = 'Last name may not contain spaces' my_projects = 'My Projects' no_projects = "Looks like you don't have any projects yet. Select Add project, or check back later." add_project_button = 'add project' join_code_prompt = 'Enter a jo...
show_in_list = True title = 'Detector Configuration' motor_names = ['collect.detector_configuration', 'xray_scope.setup', 'laser_scope.setup'] names = ['detectors', 'xray_scope_setup', 'laser_scope_setup', 'motor2'] motor_labels = ['Detectors', 'X-ray Scope Setup', 'Laser Scope Setup'] widths = [280, 170, 170] line0.xr...
show_in_list = True title = 'Detector Configuration' motor_names = ['collect.detector_configuration', 'xray_scope.setup', 'laser_scope.setup'] names = ['detectors', 'xray_scope_setup', 'laser_scope_setup', 'motor2'] motor_labels = ['Detectors', 'X-ray Scope Setup', 'Laser Scope Setup'] widths = [280, 170, 170] line0.xr...
# Setters for the results dictionary def set_error(name, message): global _error _error = {} _error = {"Hostname": name, "Message": message} return _error def new(): return { 'Hostname': None, 'IP': None, 'MD5': None, 'View':...
def set_error(name, message): global _error _error = {} _error = {'Hostname': name, 'Message': message} return _error def new(): return {'Hostname': None, 'IP': None, 'MD5': None, 'View': None, 'Results': []} def set_result(results, key, value): results[key] = value def set_ciphers(results, v...
def get_input(): with open("input.txt", "r") as file: return file.read() def quiz1(data): print(data.count("(") - data.count(")")) def quiz2(data): count = 0 for i, p in enumerate(data): if p == ("("): count += 1 if p == (")"): count -= 1 if c...
def get_input(): with open('input.txt', 'r') as file: return file.read() def quiz1(data): print(data.count('(') - data.count(')')) def quiz2(data): count = 0 for (i, p) in enumerate(data): if p == '(': count += 1 if p == ')': count -= 1 if count ...
user = "DB_USER" password = "DB_PASS" token = "API_TOKEN" valid_chats = []
user = 'DB_USER' password = 'DB_PASS' token = 'API_TOKEN' valid_chats = []
MASK = 0xffffffffffffffff BLOCK_LEN_INT64 = 8 BLOCK_LEN_BYTES = 8 * BLOCK_LEN_INT64 blake2b_IV = [ 0x6a09e667f3bcc908, 0xbb67ae8584caa73b, 0x3c6ef372fe94f82b, 0xa54ff53a5f1d36f1, 0x510e527fade682d1, 0x9b05688c2b3e6c1f, 0x1f83d9abfb41bd6b, 0x5be0cd19137e2179 ] def rotr(w, c): return (w >> c) | (w ...
mask = 18446744073709551615 block_len_int64 = 8 block_len_bytes = 8 * BLOCK_LEN_INT64 blake2b_iv = [7640891576956012808, 13503953896175478587, 4354685564936845355, 11912009170470909681, 5840696475078001361, 11170449401992604703, 2270897969802886507, 6620516959819538809] def rotr(w, c): return w >> c | w << 64 - c ...
# https://leetcode.com/problems/valid-parentheses/ class Solution: def isValid(self, s: str) -> bool: stack = [] for c in s: if c == ')': if len(stack) > 0 and stack[-1] == '(': stack.pop() else: return Fal...
class Solution: def is_valid(self, s: str) -> bool: stack = [] for c in s: if c == ')': if len(stack) > 0 and stack[-1] == '(': stack.pop() else: return False elif c == '}': if len(stack)...
def create_lkas(packer, enabled, frame, lat_active, apply_steer): values = { "LKA_MODE": 2, "LKA_ICON": 2 if enabled else 1, "TORQUE_REQUEST": apply_steer, "LKA_ASSIST": 1 if lat_active else 0, "STEER_REQ": 1 if lat_active else 0, "STEER_MODE": 0, "SET_ME_1": 0, "NEW_SIGNAL_1": 0, ...
def create_lkas(packer, enabled, frame, lat_active, apply_steer): values = {'LKA_MODE': 2, 'LKA_ICON': 2 if enabled else 1, 'TORQUE_REQUEST': apply_steer, 'LKA_ASSIST': 1 if lat_active else 0, 'STEER_REQ': 1 if lat_active else 0, 'STEER_MODE': 0, 'SET_ME_1': 0, 'NEW_SIGNAL_1': 0, 'NEW_SIGNAL_2': 0} return packe...
# https://leetcode-cn.com/problems/binary-search/ def binary_search(nums, target): if not nums: return -1 if nums[0] > target or nums[-1] < target: return -1 l, r = 0, len(nums) - 1 while l <= r: m = l + (r - l) // 2 if nums[m] == target: return m e...
def binary_search(nums, target): if not nums: return -1 if nums[0] > target or nums[-1] < target: return -1 (l, r) = (0, len(nums) - 1) while l <= r: m = l + (r - l) // 2 if nums[m] == target: return m elif nums[m] > target: r = m - 1 ...
def human_readable_size(size, decimal_places=2): for unit in ['B','KB','MB','GB','TB']: if size < 1024.0: break size /= 1024.0 return f"{size:.{decimal_places}f} {unit}"
def human_readable_size(size, decimal_places=2): for unit in ['B', 'KB', 'MB', 'GB', 'TB']: if size < 1024.0: break size /= 1024.0 return f'{size:.{decimal_places}f} {unit}'
def RemoveA(file1='Weird.txt',file2='WeirdButA.txt'): f=open(file2,'a') lst=open(file1,'r').readlines() f1=open(file1,'w') for x in lst: if 'a' in x or 'A' in x: f.write(x) else: f1.write(x) f.close() f1.close() print(open(file1,'r').read(),open(file2,...
def remove_a(file1='Weird.txt', file2='WeirdButA.txt'): f = open(file2, 'a') lst = open(file1, 'r').readlines() f1 = open(file1, 'w') for x in lst: if 'a' in x or 'A' in x: f.write(x) else: f1.write(x) f.close() f1.close() print(open(file1, 'r').read()...
wt0_16_4 = {'192.168.122.111': [8.3103, 8.0392, 7.6612, 7.6962, 7.5176, 7.5481, 7.5683, 7.5518, 7.8167, 7.7147, 7.6347, 7.5667, 7.5034, 7.9934, 7.9606, 7.9429, 7.9216, 7.8997, 7.8826, 8.0898, 8.037, 8.36, 8.3285, 8.4888, 8.4126, 8.3655, 8.2986, 8.258, 8.2224, 8.1874, 8.1354, 8.1046, 8.2392, 8.2046, 8.1844, 8.1706, 8.1...
wt0_16_4 = {'192.168.122.111': [8.3103, 8.0392, 7.6612, 7.6962, 7.5176, 7.5481, 7.5683, 7.5518, 7.8167, 7.7147, 7.6347, 7.5667, 7.5034, 7.9934, 7.9606, 7.9429, 7.9216, 7.8997, 7.8826, 8.0898, 8.037, 8.36, 8.3285, 8.4888, 8.4126, 8.3655, 8.2986, 8.258, 8.2224, 8.1874, 8.1354, 8.1046, 8.2392, 8.2046, 8.1844, 8.1706, 8.15...
a=[] for x in range(1,101): if x%3==0: a.append('Fizz') elif x%5==0: a.append('Buzz') elif x%3==0 and x%5==0: a.append("FizzBuzz") else: a.append(x) print(*a)
a = [] for x in range(1, 101): if x % 3 == 0: a.append('Fizz') elif x % 5 == 0: a.append('Buzz') elif x % 3 == 0 and x % 5 == 0: a.append('FizzBuzz') else: a.append(x) print(*a)
cube = lambda x: x ** 3 # complete the lambda function def fibonacci(n): # return a list of fibonacci numbers a = 0 b = 1 for i in range(n): yield a a, b = b, a + b def main(): n = int(input()) print(list(map(cube, fibonacci(n)))) if __name__ == '__main__': main()
cube = lambda x: x ** 3 def fibonacci(n): a = 0 b = 1 for i in range(n): yield a (a, b) = (b, a + b) def main(): n = int(input()) print(list(map(cube, fibonacci(n)))) if __name__ == '__main__': main()
# SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = ['*'] # TODO: to env TIME_ZONE = 'Europe/Helsinki' # TODO: to env FIRST_DAY_OF_WEEK = 1 MONTH_DAY_FORMAT = 'j F '
debug = True allowed_hosts = ['*'] time_zone = 'Europe/Helsinki' first_day_of_week = 1 month_day_format = 'j F '
# Random Comment x = 3 y = x + 2 y = y * 2 print(y)
x = 3 y = x + 2 y = y * 2 print(y)
# Anti Diagonals # https://www.interviewbit.com/problems/anti-diagonals/ # # Give a N*N square matrix, return an array of its anti-diagonals. Look at the example for more details. # # Example: # # Input: # # 1 2 3 # 4 5 6 # 7 8 9 # # Return the following : # # [ # [1], # [2, 4], # [3, 5, 7], # [6, 8], # [9] #...
class Solution: def diagonal(self, A): res = [list() for i in range(2 * len(A) - 1)] for i in range(len(A)): for j in range(len(A)): res[i + j].append(A[i][j]) return res if __name__ == '__main__': s = solution() print(s.diagonal([[1, 2, 3], [4, 5, 6], [7...
orders = ["daisy", "buttercup", "snapdragon", "gardenia", "lily"] # Create new orders here: new_orders = ["lilac", "iris"] orders_combined = orders + new_orders broken_prices = [5, 3, 4, 5, 4] + [4]
orders = ['daisy', 'buttercup', 'snapdragon', 'gardenia', 'lily'] new_orders = ['lilac', 'iris'] orders_combined = orders + new_orders broken_prices = [5, 3, 4, 5, 4] + [4]
# List Comprehension # adalah metode untuk menambahkan anggota dari suatu list melalui for loop # Syntax dari List Comprehension adalah # [expression for item in iterable] # Original List original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] print(f"Original : {original}") # Output = Original : [1, 2, 3, 4, 5, 6, 7...
original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] print(f'Original : {original}') original_dua = [value for value in range(5, 11)] print(f'Original Range : {original_dua}') exp_list = [item ** 2 for item in original] print(f'Exponent List : {exp_list}') genap = [item for item in original if item % 2 == 0] print(f'Genap : {gen...
class Solution: def sumBase(self, n: int, k: int) -> int: r = 0 while n>0: r += n%k n = n//k return r
class Solution: def sum_base(self, n: int, k: int) -> int: r = 0 while n > 0: r += n % k n = n // k return r
# Copyright 2021 Adobe. All rights reserved. # This file is licensed to you 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-2.0 # # Unless required by applicable la...
class Document: json_hint = {'dc_format': 'dc:format', 'location': 'cpf:location'} def __init__(self, file_format=None, location=None): self.dc_format = file_format self.location = location
# This file is used by build_autocachebreakers.py # Note: both outputs and breakers[n][1] are relative to this file's directory. targets = [ {"output": "js_minerva/cw/net/autocachebreakers.js", "breakers": [ ("cw.net.breaker_FlashConnector_swf", "minerva/compiled_client/FlashConnector.swf"), ]}, ]
targets = [{'output': 'js_minerva/cw/net/autocachebreakers.js', 'breakers': [('cw.net.breaker_FlashConnector_swf', 'minerva/compiled_client/FlashConnector.swf')]}]
# Python program to print connected # components in an undirected graph # https://www.geeksforgeeks.org/connected-components-in-an-undirected-graph/ class Graph: # init function to declare class variables def __init__(self, V): self.V = V self.adj = [[] for i in range(V)] def DFSUtil(self...
class Graph: def __init__(self, V): self.V = V self.adj = [[] for i in range(V)] def dfs_util(self, temp, v, visited): visited[v] = True temp.append(v) for i in self.adj[v]: if visited[i] == False: temp = self.DFSUtil(temp, i, visited) ...
# # PySNMP MIB module NBS-NTP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NBS-NTP-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:17:23 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, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, single_value_constraint, value_range_constraint, constraints_union, value_size_constraint) ...
## Some utils for plots clean_variable_names = { "age": "Age", "anosmia": "Anosmia", "cough": "Cough", "diarrhea": "Diarrhea", "fever": "Fever", "minor_severity_factor": "Number of minor severity factors", "risk_factor": "Number of risk factors", "sore_throat_aches": "Sore throat/aches"...
clean_variable_names = {'age': 'Age', 'anosmia': 'Anosmia', 'cough': 'Cough', 'diarrhea': 'Diarrhea', 'fever': 'Fever', 'minor_severity_factor': 'Number of minor severity factors', 'risk_factor': 'Number of risk factors', 'sore_throat_aches': 'Sore throat/aches'} legend_imp_name = {'SOBOL_TOTAL': 'Sobol Total-order', '...
# # PySNMP MIB module JUNIPER-WX-STATUS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/JUNIPER-WX-GLOBAL-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:01:32 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (def...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_intersection, value_size_constraint, single_value_constraint, constraints_union) ...
def ordinal(number): if number <= 0: return 'none' tmp = number % 100 if tmp >= 20: tmp = tmp % 10 if tmp == 1: return str(number) + 'st' elif tmp == 2: return str(number) + 'nd' elif tmp == 3: return str(number) + 'rd' else: return str(number)...
def ordinal(number): if number <= 0: return 'none' tmp = number % 100 if tmp >= 20: tmp = tmp % 10 if tmp == 1: return str(number) + 'st' elif tmp == 2: return str(number) + 'nd' elif tmp == 3: return str(number) + 'rd' else: return str(number)...
def load_parse_data(path: str) -> list: with open(path, mode='r', encoding="utf-8") as f: return list(map(int, f.read().split(','))) def school_by_age(data: list) -> list: school_by_age = [0] * 9 for age in data: school_by_age[age] += 1 return school_by_age def model_school_growth(sc...
def load_parse_data(path: str) -> list: with open(path, mode='r', encoding='utf-8') as f: return list(map(int, f.read().split(','))) def school_by_age(data: list) -> list: school_by_age = [0] * 9 for age in data: school_by_age[age] += 1 return school_by_age def model_school_growth(scho...
scores = [] for i in range(5): scores.append(sum([int(x) for x in input().split(" ")])) topscore = 0 for score in scores: if score > topscore: topscore = score index = scores.index(topscore) + 1 print(str(index) + " " + str(topscore))
scores = [] for i in range(5): scores.append(sum([int(x) for x in input().split(' ')])) topscore = 0 for score in scores: if score > topscore: topscore = score index = scores.index(topscore) + 1 print(str(index) + ' ' + str(topscore))
lines = [line.strip() for line in open("input.txt", 'r') if line.strip() != ""] tiles = [] # e - 0; se - 1; sw - 2; w - 3; nw - 4; ne - 5 directions = ((1, -1, 0), (0, -1, 1), (-1, 0, 1), (-1, 1, 0), (0, 1, -1), (1, 0, -1)) for line in lines: tile = [] while len(line) > 0: if line[0] =...
lines = [line.strip() for line in open('input.txt', 'r') if line.strip() != ''] tiles = [] directions = ((1, -1, 0), (0, -1, 1), (-1, 0, 1), (-1, 1, 0), (0, 1, -1), (1, 0, -1)) for line in lines: tile = [] while len(line) > 0: if line[0] == 's': tile.append(1 if line[1] == 'e' else 2) ...
# insert CR, insert line above keys(':setf vim\<CR>jw') keys('4\<C-Down>') keys('Ea') keys('\<CR>') keys('CARRYING OVER ') keys('\<Esc>A') keys('\<CR>') keys('CR at EOL') keys('\<Esc>k') keys('O') keys('above CR') keys('\<Esc>\<Esc>')
keys(':setf vim\\<CR>jw') keys('4\\<C-Down>') keys('Ea') keys('\\<CR>') keys('CARRYING OVER ') keys('\\<Esc>A') keys('\\<CR>') keys('CR at EOL') keys('\\<Esc>k') keys('O') keys('above CR') keys('\\<Esc>\\<Esc>')
# from AI_module import AI_module def receive_basic_iuput_data(Singal_Loss, Shock_Alert, Oxygen_Supply, Fever, Hypotension, Hypertension): # Recevie data from input module, then analyze it using some judge functions to generate boolean result # Boolean Parameters # If paramter returns True, means it shoul...
def receive_basic_iuput_data(Singal_Loss, Shock_Alert, Oxygen_Supply, Fever, Hypotension, Hypertension): basic_result = {'Signal_Loss': False, 'Shock_Alert': False, 'Oxygen_Supply': False, 'Fever': False, 'Hypotension': False, 'Hypertension': False} if Singal_Loss: BasicResult['Signal Loss'] = True ...
# # PySNMP MIB module CISCO-RADIUS-EXT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-RADIUS-EXT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:53:51 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (defau...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, constraints_intersection, single_value_constraint, value_size_constraint, value_range_constraint) ...
class Solution: def isValidSudoku(self, board: List[List[str]]) -> bool: for i in range(9): check_r = dict() check_c = dict() check_b = dict() print("_____") for j in range(9): print(check_r.keys(),check_c.keys(),check_b.keys()) ...
class Solution: def is_valid_sudoku(self, board: List[List[str]]) -> bool: for i in range(9): check_r = dict() check_c = dict() check_b = dict() print('_____') for j in range(9): print(check_r.keys(), check_c.keys(), check_b.keys()...
# http://codingbat.com/prob/p118366 def string_splosion(str): result = "" for i in range( len(str) ): result += str[:i+1] return result
def string_splosion(str): result = '' for i in range(len(str)): result += str[:i + 1] return result
# Python3 m, n = [int(i) for i in input().split()] if n <= 1: print(n) quit() lesser_n = (n+2) % 60 lesser_m = (m+1) % 60 def fibo(n): a, b = 0, 1 for i in range(2, n+1): c = a+b c = c % 10 b, a = c, b return (c-1) if lesser_n <= 1: a = lesser...
(m, n) = [int(i) for i in input().split()] if n <= 1: print(n) quit() lesser_n = (n + 2) % 60 lesser_m = (m + 1) % 60 def fibo(n): (a, b) = (0, 1) for i in range(2, n + 1): c = a + b c = c % 10 (b, a) = (c, b) return c - 1 if lesser_n <= 1: a = lesser_n - 1 else: a =...
links_file = open("link_queue.txt", "r") link_queue = links_file.readlines() go = [] count = 0 index = 0 while index < len(link_queue): if link_queue[index].find("interforo") == -1: go.append(link_queue[index]) del link_queue[index] else: index = index + 1 count = count + 1 ...
links_file = open('link_queue.txt', 'r') link_queue = links_file.readlines() go = [] count = 0 index = 0 while index < len(link_queue): if link_queue[index].find('interforo') == -1: go.append(link_queue[index]) del link_queue[index] else: index = index + 1 count = count + 1 print...
class Run(dict): attributes = ('nx', 'ny', 'nz', 'time', 'NbrOfCores', 'platform', 'configuration', 'repetitions', 'mpiargs', 'tag') def __init__(self, serie, data, **kwargs): super(Run, self).__init__(**kwargs) self.data = data self.parent = serie for x in Run.attributes: ...
class Run(dict): attributes = ('nx', 'ny', 'nz', 'time', 'NbrOfCores', 'platform', 'configuration', 'repetitions', 'mpiargs', 'tag') def __init__(self, serie, data, **kwargs): super(Run, self).__init__(**kwargs) self.data = data self.parent = serie for x in Run.attributes: ...
AVAILABLE_THEMES = [ ('suse', 'SUSE', 'themes/suse'), ('default', 'Default', 'themes/default'), ]
available_themes = [('suse', 'SUSE', 'themes/suse'), ('default', 'Default', 'themes/default')]
callback_classes = [ ['ns3::ObjectBase *', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['void', 'ns3::Ptr<const ns3::MobilityModel>', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty...
callback_classes = [['ns3::ObjectBase *', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['void', 'ns3::Ptr<const ns3::MobilityModel>', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::...
# Copyright 2020 https://www.globaletraining.com/ # Generator send method def simple_gen(start_number=10): i = start_number while True: x = (yield i * 2) if x: # check if used send() i += x else: i += 1 gen1 = simple_gen() print(gen1.__next__()) print...
def simple_gen(start_number=10): i = start_number while True: x = (yield (i * 2)) if x: i += x else: i += 1 gen1 = simple_gen() print(gen1.__next__()) print(gen1.send(10)) print(gen1.__next__()) print(gen1.send(20)) print(gen1.__next__()) print(gen1.__next__()) pr...
# g code generator for clay extrusions def gCodeLine(generation): def __init__(self, coordinates, z_val = True, extrusion_value = None, feed_value = None, absolute_relative = None): self.X = coordinates.X self.Y = coordinates.Y if z_val: self.Z = coordinates.Z class...
def g_code_line(generation): def __init__(self, coordinates, z_val=True, extrusion_value=None, feed_value=None, absolute_relative=None): self.X = coordinates.X self.Y = coordinates.Y if z_val: self.Z = coordinates.Z class Gcodesettings: def __init__(self): self.noz...
# Non-unicode strings are assumed to be CP437. We have an indexed table to # convert CP437 to unicode (index range 0-255 => unicode char) and a dict to # convert Unicode to CP437 (unicode char => CP437 char). These are used by the # fsuCP437_to_Unicode and fsUnicode_to_CP437 functions respectively. asUnicodeCharMapCP43...
as_unicode_char_map_cp437 = [isinstance(x, str) and str(x) or chr(x) for x in [0, 9786, 9787, 9829, 9830, 9827, 9824, 8226, 9688, 9675, 9689, 9794, 9792, 9834, 9835, 9788, 9658, 9668, 8597, 8252, 182, 167, 9644, 8616, 8593, 8595, 8594, 8592, 8735, 8596, 9650, 9660, ' ', '!', '"', '#', '$', '%', '&', "'", '(', ')', '*',...
monthConversions = { "Jan": "January", "Feb": "Februry", "Mar": "March", "Apr": "April", "May": "May", "Jun": "June", "Jul": "July", "Aug": "August", "Sep": "September", "Oct": "October", "Nov": "November", "Dec": "December", } print(monthConversions["Oct"]) print(monthC...
month_conversions = {'Jan': 'January', 'Feb': 'Februry', 'Mar': 'March', 'Apr': 'April', 'May': 'May', 'Jun': 'June', 'Jul': 'July', 'Aug': 'August', 'Sep': 'September', 'Oct': 'October', 'Nov': 'November', 'Dec': 'December'} print(monthConversions['Oct']) print(monthConversions.get('Dec')) for item in monthConversions...
a=[2,6,7,5,11,15] n=len(a) print("old array=",a) for i in range(n-1): if a[i]<=a[i+1]: continue t=a[i+1] j=i+1 while j>=1 and a[j-1]>t: a[j]=a[j-1] j=j-1 a[j]=t print("Sorted Array=",a)
a = [2, 6, 7, 5, 11, 15] n = len(a) print('old array=', a) for i in range(n - 1): if a[i] <= a[i + 1]: continue t = a[i + 1] j = i + 1 while j >= 1 and a[j - 1] > t: a[j] = a[j - 1] j = j - 1 a[j] = t print('Sorted Array=', a)
class MarkdownParser: def __init__(self, whitelist_filters=None): self._delimiter = '\n' self._single_delimiters = \ ('#', '*', '+', '~', '-', '|', '`', '\n') self._whitelist_filters = whitelist_filters or [str.isdigit] def encode(self, text): content_parts, conten...
class Markdownparser: def __init__(self, whitelist_filters=None): self._delimiter = '\n' self._single_delimiters = ('#', '*', '+', '~', '-', '|', '`', '\n') self._whitelist_filters = whitelist_filters or [str.isdigit] def encode(self, text): (content_parts, content_delimiters) ...
#!/usr/bin/python # -*- coding: utf-8 -*- INPUT_STREAMS = [ 'test.count_words_stream.CountWordsStream' ] REDUCERS = [ 'test.count_words_reducer.CountWordsReducer' ]
input_streams = ['test.count_words_stream.CountWordsStream'] reducers = ['test.count_words_reducer.CountWordsReducer']
''' This problem was asked by Facebook. There is an N by M matrix of zeroes. Given N and M, write a function to count the number of ways of starting at the top-left corner and getting to the bottom-right corner. You can only move right or down. For example, given a 2 by 2 matrix, you should return 2, since there are ...
""" This problem was asked by Facebook. There is an N by M matrix of zeroes. Given N and M, write a function to count the number of ways of starting at the top-left corner and getting to the bottom-right corner. You can only move right or down. For example, given a 2 by 2 matrix, you should return 2, since there are ...
# Testing Assertions # Given a sequence of a number of cars, # the function get_total_cars returns the total number of cars. # get_total_cars([1, 2, 3, 4]) # outputs: 10 # get_total_cars(['a', 'b', 'c']) # outputs: ValueError: invalid literal for int() with base 10: 'a' # Explain in words what the assertions in t...
def get_total(values): assert len(values) > 0 for element in values: assert int(element) values = [int(element) for element in values] total = sum(values) assert total > 0 return total
# Sal's Shipping # Eleni A. weight = 41.5 GS_FLAT = 20 GSP_FLAT = 125 # Basic Scale Shipping def basic_shipping(weight): if weight <= 2: cost = weight * 1.50 elif weight <= 6: cost = weight * 3 elif weight <=10: cost = weight * 4 else: cost = weight * 4.75 return cost # Ground Shipping def ...
weight = 41.5 gs_flat = 20 gsp_flat = 125 def basic_shipping(weight): if weight <= 2: cost = weight * 1.5 elif weight <= 6: cost = weight * 3 elif weight <= 10: cost = weight * 4 else: cost = weight * 4.75 return cost def ground_shipping(weight): cost = basic_sh...
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: 2017, Dag Wieers (@dagwieers) <dag@wieers.com> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by...
ansible_metadata = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} documentation = "\n---\nmodule: win_defrag\nversion_added: '2.4'\nshort_description: Consolidate fragmented files on local volumes\ndescription:\n- Locates and consolidates fragmented files on local volumes to improve sys...
def open_dev( ): ''' Opens the red light LEDR device :return: 1 on success, else 0 ''' def set(data): ''' Sets the red light LEDR device :param data: the integer data to write to LEDR. If data = 0 all lights will be turned off. If data = 0b1111111111 all lights will be turned on :retu...
def open_dev(): """ Opens the red light LEDR device :return: 1 on success, else 0 """ def set(data): """ Sets the red light LEDR device :param data: the integer data to write to LEDR. If data = 0 all lights will be turned off. If data = 0b1111111111 all lights will be turned on :retu...
del_items(0x801234F4) SetType(0x801234F4, "void GameOnlyTestRoutine__Fv()") del_items(0x801234FC) SetType(0x801234FC, "int vecleny__Fii(int a, int b)") del_items(0x80123520) SetType(0x80123520, "int veclenx__Fii(int a, int b)") del_items(0x8012354C) SetType(0x8012354C, "void GetDamageAmt__FiPiT1(int i, int *mind, int *...
del_items(2148676852) set_type(2148676852, 'void GameOnlyTestRoutine__Fv()') del_items(2148676860) set_type(2148676860, 'int vecleny__Fii(int a, int b)') del_items(2148676896) set_type(2148676896, 'int veclenx__Fii(int a, int b)') del_items(2148676940) set_type(2148676940, 'void GetDamageAmt__FiPiT1(int i, int *mind, i...
def simple(arry, target): # simple search arry = [i for i in range(20)] for i in arry: print("%d steps" % i) if i == target: print("Found %d" % i) break def binary_search(arry, target): # binary search l = 0 # left pointer r = len(arry) - 1 # right poi...
def simple(arry, target): arry = [i for i in range(20)] for i in arry: print('%d steps' % i) if i == target: print('Found %d' % i) break def binary_search(arry, target): l = 0 r = len(arry) - 1 step = 0 while l <= r: step += 1 mid = l + (r...
FreeMono9pt7bBitmaps = [ 0xAA, 0xA8, 0x0C, 0xED, 0x24, 0x92, 0x48, 0x24, 0x48, 0x91, 0x2F, 0xE4, 0x89, 0x7F, 0x28, 0x51, 0x22, 0x40, 0x08, 0x3E, 0x62, 0x40, 0x30, 0x0E, 0x01, 0x81, 0xC3, 0xBE, 0x08, 0x08, 0x71, 0x12, 0x23, 0x80, 0x23, 0xB8, 0x0E, 0x22, 0x44, 0x70, 0x38, 0x81, 0x02, 0x06, 0x1A, 0x65, 0x4...
free_mono9pt7b_bitmaps = [170, 168, 12, 237, 36, 146, 72, 36, 72, 145, 47, 228, 137, 127, 40, 81, 34, 64, 8, 62, 98, 64, 48, 14, 1, 129, 195, 190, 8, 8, 113, 18, 35, 128, 35, 184, 14, 34, 68, 112, 56, 129, 2, 6, 26, 101, 70, 200, 236, 233, 36, 90, 170, 169, 64, 169, 85, 90, 128, 16, 34, 75, 227, 5, 17, 0, 16, 32, 71, 2...
#!/usr/bin/python # -*- coding: utf-8 -*- ## # Current source: https://github.com/open-security/vulnpwn/ ## class FrameworkException(Exception): pass class OptionValidationError(FrameworkException): pass
class Frameworkexception(Exception): pass class Optionvalidationerror(FrameworkException): pass
def load(h): return ({'abbr': 'none', 'code': 0, 'title': 'not set'}, {'abbr': 96, 'code': 96, 'title': 'HIRLAM data', 'units': 'non-standard, deprecated'}, {'abbr': 98, 'code': 98, 'title': 'previously used to tag SMHI data th...
def load(h): return ({'abbr': 'none', 'code': 0, 'title': 'not set'}, {'abbr': 96, 'code': 96, 'title': 'HIRLAM data', 'units': 'non-standard, deprecated'}, {'abbr': 98, 'code': 98, 'title': 'previously used to tag SMHI data that is ECMWF compliant', 'units': 'deprecated'})
# Daniel Mc Callion # Computing the primes # My list of primes p = [] # Loop through all of the numbers we're # checking for primality for i in range (2,10000): # Assume that i is a prime is_prime = True # Look through all values j from 2 up # to but not including i # for j in range(2,i): for...
p = [] for i in range(2, 10000): is_prime = True for j in p: if i % j == 0: is_prime = False break if is_prime: p.append(i) print(p)
# Section 1: Comments and Print # A single line comment in python is indicated by a # at the beginning ''' This is a multiline comment ''' # A print function prints the code to the console, useful to learn and to debug print('This is a print') # a comment can also be added after a funcion declaration or variable dec...
""" This is a multiline comment """ print('This is a print') print('you can print multiple things separated by a comma', 'like this and python will add a space in between') var_1 = 5 var_2 = 'a' var_3 = 1.0 print('Hello World!') print('Hello', 'World!') print('Hello', end=' ') print('World!') print('var_1', var_1) p...
inputstr="SecondMostFrequentCharacterInTheString" safe=inputstr countar=[] count=0 for i in inputstr: if(i!='#'): countar.append(inputstr.count(i)) print(i,inputstr.count(i),end=", ") inputstr=inputstr.replace(i,'#') else: continue firstmax=max(countar) countar.remove...
inputstr = 'SecondMostFrequentCharacterInTheString' safe = inputstr countar = [] count = 0 for i in inputstr: if i != '#': countar.append(inputstr.count(i)) print(i, inputstr.count(i), end=', ') inputstr = inputstr.replace(i, '#') else: continue firstmax = max(countar) countar.re...
class Solution: def reverseBetween(self, head: ListNode, left: int, right: int) -> ListNode: # Base case scenario if left == right: return head node = ptr = ListNode() # Dummy node before actual linked list node.next = head # First traver...
class Solution: def reverse_between(self, head: ListNode, left: int, right: int) -> ListNode: if left == right: return head node = ptr = list_node() node.next = head for _ in range(1, left): ptr = ptr.next current_node = ptr.next while left < ...
codigo_set = set() codido_set_saiu = set() s = input() codigos = input().split(' ') for codigo in codigos: codigo_set.add(codigo) i = input() saidas = input().split(' ') A = 0 I = 0 R = 0 for saida in saidas: if saida in codigo_set: if saida in codido_set_saiu: R += 1 else: A += 1...
codigo_set = set() codido_set_saiu = set() s = input() codigos = input().split(' ') for codigo in codigos: codigo_set.add(codigo) i = input() saidas = input().split(' ') a = 0 i = 0 r = 0 for saida in saidas: if saida in codigo_set: if saida in codido_set_saiu: r += 1 else: ...
# Configuration file for the Sphinx documentation builder. project = 'pathlib2' copyright = '2012-2014 Antoine Pitrou and contributors; 2014-2021, Matthias C. M. Troffaes and contributors' author = 'Matthias C. M. Troffaes' # The full version, including alpha/beta/rc tags with open("../VERSION", "r") as version_file:...
project = 'pathlib2' copyright = '2012-2014 Antoine Pitrou and contributors; 2014-2021, Matthias C. M. Troffaes and contributors' author = 'Matthias C. M. Troffaes' with open('../VERSION', 'r') as version_file: release = version_file.read().strip() extensions = [] exclude_patterns = ['_build', 'Thumbs.db', '.DS_Sto...
# # PySNMP MIB module Dell-vlan-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Dell-vlan-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 18:43:15 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 201...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, constraints_intersection, single_value_constraint, value_range_constraint, constraints_union) ...
_base_ = [ '../_base_/models/mask_rcnn_r50_fpn.py', '../_base_/datasets/coco_instance.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py' ] model = dict( rpn_head=dict( anchor_generator=dict(type='LegacyAnchorGenerator', center_offset=0.5), bbox_coder=dict...
_base_ = ['../_base_/models/mask_rcnn_r50_fpn.py', '../_base_/datasets/coco_instance.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'] model = dict(rpn_head=dict(anchor_generator=dict(type='LegacyAnchorGenerator', center_offset=0.5), bbox_coder=dict(type='LegacyDeltaXYWHBBoxCoder'), loss_bbox=d...
#!/usr/bin/python # -*- coding: utf-8 -*- # Author: illuz <iilluzen[at]gmail.com> # File: AC_stack_dict_n.py # Create Date: 2015-03-04 19:47:43 # Usage: AC_stack_dict_n.py # Descripton: class Solution: # @return a boolean def isValid(self, s): mp = {')': '(', ']': '[', '}': '{'} ...
class Solution: def is_valid(self, s): mp = {')': '(', ']': '[', '}': '{'} stk = [] for ch in s: if ch in '([{': stk.append(ch) elif not stk or mp[ch] != stk.pop(): return False return not stk
f = open('sample-input.txt') o = open('sample-output.txt', 'w') t = int(f.readline().strip()) for i in xrange(1, t + 1): o.write("Case #{}: ".format(i)) n = int(f.readline().strip()) x = [int(j) for j in f.readline().strip().split()] y = [int(j) for j in f.readline().strip().split()] o.write("\n")
f = open('sample-input.txt') o = open('sample-output.txt', 'w') t = int(f.readline().strip()) for i in xrange(1, t + 1): o.write('Case #{}: '.format(i)) n = int(f.readline().strip()) x = [int(j) for j in f.readline().strip().split()] y = [int(j) for j in f.readline().strip().split()] o.write('\n')
class Users: def __init__(self, id, name, surname, password, email, changepass, read_comment, read_like): self.id = id self.name = name self.surname = surname self.password = password self.email = email self.changepass = changepass self.read_comment = read_co...
class Users: def __init__(self, id, name, surname, password, email, changepass, read_comment, read_like): self.id = id self.name = name self.surname = surname self.password = password self.email = email self.changepass = changepass self.read_comment = read_co...
M = int(input()) m1 = set(map(int, input().split())) N = int(input()) n1 = set(map(int, input().split())) output = list(m1.union(n1).difference(m1.intersection(n1))) output.sort() for i in output: print(i)
m = int(input()) m1 = set(map(int, input().split())) n = int(input()) n1 = set(map(int, input().split())) output = list(m1.union(n1).difference(m1.intersection(n1))) output.sort() for i in output: print(i)
## UVSError handling guidelines: # 1- don't use OOP exceptions, NEVER NEVER NEVER use inheritance in exceptions # i dont like exception X that inherits from Y and 2mrw is a G then suddenly catches an F blah blah # doing the above makes it harder not easier to figure out what the hell happened. # ju...
class Uvserror(Exception): pass
# This is an input class. Do not edit. class LinkedList: def __init__(self, value): self.value = value self.next = None def reverseLinkedList(head): # The trick of the problem is that we need to use three pointers, not two (which is the common pattern). # the first and third pointer act as a ...
class Linkedlist: def __init__(self, value): self.value = value self.next = None def reverse_linked_list(head): (p1, p2) = (None, head) while p2 is not None: p3 = p2.next p2.next = p1 p1 = p2 p2 = p3 return p1
# cycle.py def cycle(iterable): index = 0 length = len(iterable) while True: for index in range(length): yield index endless = cycle(range(0, 10)) for item in endless: print(item)
def cycle(iterable): index = 0 length = len(iterable) while True: for index in range(length): yield index endless = cycle(range(0, 10)) for item in endless: print(item)
def oddTuples(aTup): ''' aTup: a tuple returns: tuple, every other element of aTup. ''' # using tuple slicing method return aTup[0: :2]
def odd_tuples(aTup): """ aTup: a tuple returns: tuple, every other element of aTup. """ return aTup[0::2]
mylang='fr' family = 'wikipedia' usernames['wikipedia']['fr']=u'Arktest' console_encoding = 'utf-8'
mylang = 'fr' family = 'wikipedia' usernames['wikipedia']['fr'] = u'Arktest' console_encoding = 'utf-8'
''' @author: Pranshu Aggarwal @problem: https://hack.codingblocks.com/app/practice/1/285/problem Algorithm to Generate(arr, n): for row:=0 to n step by 1, for col:=0 to row + 1 step by 1, Set arr[row][col] = 1 if column is 0 or equals row Set arr[row][col] = (Sum of Diagonally Pre...
""" @author: Pranshu Aggarwal @problem: https://hack.codingblocks.com/app/practice/1/285/problem Algorithm to Generate(arr, n): for row:=0 to n step by 1, for col:=0 to row + 1 step by 1, Set arr[row][col] = 1 if column is 0 or equals row Set arr[row][col] = (Sum of Diagonally Pre...
#!/usr/bin/env python3 # https://codeforces.com/problemset/problem/1332/A def f(l): a,c = l p = 1 r = 0 while a>0 or c>0: r += p*((c%3-a%3)%3) p *= 3 c = c//3 a = a//3 return r l = list(map(int,input().split())) print(f(l))
def f(l): (a, c) = l p = 1 r = 0 while a > 0 or c > 0: r += p * ((c % 3 - a % 3) % 3) p *= 3 c = c // 3 a = a // 3 return r l = list(map(int, input().split())) print(f(l))
a = 0 b = 1 n = int(input()) for i in range(n): print(a,end=",") print(b,end=",") a = a+b b = b+a print("\b")
a = 0 b = 1 n = int(input()) for i in range(n): print(a, end=',') print(b, end=',') a = a + b b = b + a print('\x08')
DATASET_REGISTRY = {} def register_dataset(name: str): def register_dataset_func(func): DATASET_REGISTRY[name] = func() return register_dataset_func
dataset_registry = {} def register_dataset(name: str): def register_dataset_func(func): DATASET_REGISTRY[name] = func() return register_dataset_func
token = "bot_token" admins = [admin_id] api_id = 2040 api_hash = "b18441a1ff607e10a989891a5462e627"
token = 'bot_token' admins = [admin_id] api_id = 2040 api_hash = 'b18441a1ff607e10a989891a5462e627'
a = [3, 4, 5, 6] b = ['a', 'b', 'c', 'd'] def zipper(a,b): newZip = [] if len (a) == len(b): for i in range(len(a)): newZip.append([a[i], b[i]]) print (newZip) if len(a)!= len(b): print("lists do not match") zipper(a,b)
a = [3, 4, 5, 6] b = ['a', 'b', 'c', 'd'] def zipper(a, b): new_zip = [] if len(a) == len(b): for i in range(len(a)): newZip.append([a[i], b[i]]) print(newZip) if len(a) != len(b): print('lists do not match') zipper(a, b)
c = get_config() c.TerminalInteractiveShell.confirm_exit = False c.TerminalInteractiveShell.editing_mode = 'vi'
c = get_config() c.TerminalInteractiveShell.confirm_exit = False c.TerminalInteractiveShell.editing_mode = 'vi'
class Player: def __init__(self, socket, name, color, board): self.name = name self.board = board self.socket = socket self.lastMove = [] self.isTurn = False #self.color = color self.color = 'w' async def init(self): await self.board.addPlayer(se...
class Player: def __init__(self, socket, name, color, board): self.name = name self.board = board self.socket = socket self.lastMove = [] self.isTurn = False self.color = 'w' async def init(self): await self.board.addPlayer(self) def __str__(self): ...
# visit: https://imgur.com/a/oemBqyv count = 0 total = 0 # Handle any exceptions using try/except try: def main(): # Initialize variables count = 0 total = 0 # Opens the Section1.txt file. infile = open("Section1.txt", "r") # Reads the numbers in the file into a li...
count = 0 total = 0 try: def main(): count = 0 total = 0 infile = open('Section1.txt', 'r') num = infile.readlines() for num in infile: number = float(num) total = total + number count = count + 1 average = total / count ...
# PROBLEM LINK:- https://leetcode.com/problems/height-checker/ class Solution: def heightChecker(self, heights: List[int]) -> int: n = len(heights) expected = heights.copy() expected.sort() c = 0 for i in range(0,n): if heights[i] != expected[i]: ...
class Solution: def height_checker(self, heights: List[int]) -> int: n = len(heights) expected = heights.copy() expected.sort() c = 0 for i in range(0, n): if heights[i] != expected[i]: c += 1 return c
m = float(input('Informe os metros: ')) print(f'{m} metros equivale a: \n{m*0.001}km\n{m*0.01}hm\n{m*0.1:.1f}dam\n{m*10:.0f}dm\n{m*100:.0f}cm\n{m*1000:.0f}mm') #km, hm, dam, m, dm, cm, mm
m = float(input('Informe os metros: ')) print(f'{m} metros equivale a: \n{m * 0.001}km\n{m * 0.01}hm\n{m * 0.1:.1f}dam\n{m * 10:.0f}dm\n{m * 100:.0f}cm\n{m * 1000:.0f}mm')
__title__ = "feedler" __description__ = "A dead simple parser" __version__ = "0.0.2" __author__ = "Victor Natschke" __author_email__ = "vnatschke@gmail.com" __license__ = "MIT" __copyright__ = "Copyright 2020 Victor Natschke"
__title__ = 'feedler' __description__ = 'A dead simple parser' __version__ = '0.0.2' __author__ = 'Victor Natschke' __author_email__ = 'vnatschke@gmail.com' __license__ = 'MIT' __copyright__ = 'Copyright 2020 Victor Natschke'