content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
def extended_gcd(a, b): if a == 0: return (b, 0, 1) g, y, x = extended_gcd(b % a, a) return (g, x - (b // a) * y, y) def modinv(a, m): g, x, y = extended_gcd(a % m, m) if g != 1: raise Exception('Element has no inverse') return x % m
def extended_gcd(a, b): if a == 0: return (b, 0, 1) (g, y, x) = extended_gcd(b % a, a) return (g, x - b // a * y, y) def modinv(a, m): (g, x, y) = extended_gcd(a % m, m) if g != 1: raise exception('Element has no inverse') return x % m
def balanced(text: str): stack = [] is_balanced = True for i in range(len(text)): if text[i] in "{[(": stack.append(i) elif text[i] in ")]}" and len(stack) > 0: start_ind = stack.pop() if text[start_ind] == "{": if text[i] != "}": ...
def balanced(text: str): stack = [] is_balanced = True for i in range(len(text)): if text[i] in '{[(': stack.append(i) elif text[i] in ')]}' and len(stack) > 0: start_ind = stack.pop() if text[start_ind] == '{': if text[i] != '}': ...
def round_scores(student_scores): ''' :param student_scores: list of student exam scores as float or int. :return: list of student scores *rounded* to nearest integer value. ''' rounded = [] while student_scores: rounded.append(round(student_scores.pop())) return rounded def count...
def round_scores(student_scores): """ :param student_scores: list of student exam scores as float or int. :return: list of student scores *rounded* to nearest integer value. """ rounded = [] while student_scores: rounded.append(round(student_scores.pop())) return rounded def count_f...
def is_prime(n): if n % 2 == 0: return n == 2 d = 3 while d * d <= n and n % d != 0: d += 2 return d * d > n def main(): n = int(input("Input the number from 0 to 1000: ")) print(is_prime(n)) if __name__ == '__main__': main()
def is_prime(n): if n % 2 == 0: return n == 2 d = 3 while d * d <= n and n % d != 0: d += 2 return d * d > n def main(): n = int(input('Input the number from 0 to 1000: ')) print(is_prime(n)) if __name__ == '__main__': main()
class Node: def __init__(self, value = 0): self.value = value self.next = None def findList(first, second): if not first and not second: return True if not first or not second: return False ptr1 = first ptr2 = second while ptr2: ptr2 = second ...
class Node: def __init__(self, value=0): self.value = value self.next = None def find_list(first, second): if not first and (not second): return True if not first or not second: return False ptr1 = first ptr2 = second while ptr2: ptr2 = second wh...
def sequencia(): s = 0 for i in range(1, 101): s += 1/i print(f'{s:.2f}') sequencia()
def sequencia(): s = 0 for i in range(1, 101): s += 1 / i print(f'{s:.2f}') sequencia()
def main_menu(): print("Please select an option from the following:") print(" [1] Customer") #add to db print(" [2] Order")# add to db print(" [3] Complete Order") print(" [4] Cancel Order") print(" [5] Exit") def sign_up_menu(): print("Please select an option from the foll...
def main_menu(): print('Please select an option from the following:') print(' [1] Customer') print(' [2] Order') print(' [3] Complete Order') print(' [4] Cancel Order') print(' [5] Exit') def sign_up_menu(): print('Please select an option from the following:') print(' ...
x = float(input('x = ')) if x > 1: y = 3 * x - 5 elif x >= -1: y = x + 2 else: y = 5 * x + 3 print('f(%.2f) = %.2f' % (x, y)) print(range(10))
x = float(input('x = ')) if x > 1: y = 3 * x - 5 elif x >= -1: y = x + 2 else: y = 5 * x + 3 print('f(%.2f) = %.2f' % (x, y)) print(range(10))
def selectionsort(arr): N = len(arr) for i in range(N): minimum = i for j in range(1, N): if arr[j] < arr[minimum]: minimum = j arr[minimum], arr[i] = arr[i], arr[minimum] return arr if __name__ == "__main__": arr = [0, 4, 5, 6, 7, 8, 2, 1, 5, 3, 9] ...
def selectionsort(arr): n = len(arr) for i in range(N): minimum = i for j in range(1, N): if arr[j] < arr[minimum]: minimum = j (arr[minimum], arr[i]) = (arr[i], arr[minimum]) return arr if __name__ == '__main__': arr = [0, 4, 5, 6, 7, 8, 2, 1, 5, 3, 9...
class Person: def __init__(self, name, age): self.x__name = name self.age = age def info(self): return f'Name: {self.x__name}, Age: {self.age}' def __generate_key(self, key): if key.startswith('x__'): return f'x__Person{key}' return key def __setatt...
class Person: def __init__(self, name, age): self.x__name = name self.age = age def info(self): return f'Name: {self.x__name}, Age: {self.age}' def __generate_key(self, key): if key.startswith('x__'): return f'x__Person{key}' return key def __setat...
useragents = [ "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.1 Safari/537.36", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like G...
useragents = ['Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.1 Safari/537.36', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/...
def exists(env): return True def generate(env): env.Replace(MODE='test')
def exists(env): return True def generate(env): env.Replace(MODE='test')
class Solution: def XXX(self, x: int) -> int: s = str(x) s = "-" + s.replace("-","")[::-1] if "-" in s else s[::-1] return (int(s) if int(s)<2**31-1 and int(s)>-2**31 else 0)
class Solution: def xxx(self, x: int) -> int: s = str(x) s = '-' + s.replace('-', '')[::-1] if '-' in s else s[::-1] return int(s) if int(s) < 2 ** 31 - 1 and int(s) > -2 ** 31 else 0
# invert a binary tree def reverse(root): if not root: return root.left, root.right = root.right, root.left if root.left: reverse(root.left) if root.right: reverse(root.right)
def reverse(root): if not root: return (root.left, root.right) = (root.right, root.left) if root.left: reverse(root.left) if root.right: reverse(root.right)
for _ in range(int(input())): n = int(input()) l = list(map(int, input().split(' '))) ans = 0 for i in range(n): ans += (i + 1) * (n - i) if l[i] == 0: ans += (i + 1) * (n - i) print(ans)
for _ in range(int(input())): n = int(input()) l = list(map(int, input().split(' '))) ans = 0 for i in range(n): ans += (i + 1) * (n - i) if l[i] == 0: ans += (i + 1) * (n - i) print(ans)
#-*- coding:utf-8 -*- age = [3, 2, 30, 1, 16, 18, 19, 20, 22, 25] name = ['lizi', 'liudehua', 'linjunjie', 'zhoujielun', 'zhangsan', 'bigmom', 'kaiduo', 'luffe'] print(age) print(sorted(age)) print(age) age.sort() print(age) age.append(33) print(age) age.insert(2, 65) print(age) age.pop() print(age) _del = age.pop() pr...
age = [3, 2, 30, 1, 16, 18, 19, 20, 22, 25] name = ['lizi', 'liudehua', 'linjunjie', 'zhoujielun', 'zhangsan', 'bigmom', 'kaiduo', 'luffe'] print(age) print(sorted(age)) print(age) age.sort() print(age) age.append(33) print(age) age.insert(2, 65) print(age) age.pop() print(age) _del = age.pop() print(_del) print(age) d...
class DatabaseService: def __init__(self): #TODO: mongo pass
class Databaseservice: def __init__(self): pass
class OddNumberException(Exception): def __init__(self,*args): self.args = args class EvenNumberException(Exception): def __init__(self,*args): self.args = args try: n = int(input("Enter a Number to check whether he number is odd or even : ")) if n % 2 == 0: raise EvenNumberExc...
class Oddnumberexception(Exception): def __init__(self, *args): self.args = args class Evennumberexception(Exception): def __init__(self, *args): self.args = args try: n = int(input('Enter a Number to check whether he number is odd or even : ')) if n % 2 == 0: raise even_numbe...
def filter_db_queryset_by_id(db_queryset, rqst_id, list_of_ids): if isinstance(rqst_id, str) and rqst_id.lower() == "all": db_queryset = db_queryset.order_by("id") else: db_queryset = db_queryset.filter(id__in=list_of_ids).order_by("id") return db_queryset
def filter_db_queryset_by_id(db_queryset, rqst_id, list_of_ids): if isinstance(rqst_id, str) and rqst_id.lower() == 'all': db_queryset = db_queryset.order_by('id') else: db_queryset = db_queryset.filter(id__in=list_of_ids).order_by('id') return db_queryset
class Dij: # matrix of roads road = [[]] # infinity infinit = 9999 # array of costs D = [] # array of selected nodes S = [] # array of fathers T = [] # number of nodes nodes = -1 # output output = [] def __init__(self, start): self.readGraph() ...
class Dij: road = [[]] infinit = 9999 d = [] s = [] t = [] nodes = -1 output = [] def __init__(self, start): self.readGraph() self.r = start r = self.r self.S[r] = 1 for j in range(1, self.nodes + 1): self.D[j] = self.road[r][j] ...
n, k = (int(x) for x in input().split()) arr = [int(x) for x in input().split()] new_arr = list() i = 0 while i != n - k + 1: new_arr.append(max(arr[i:i+k])) i += 1 print(*new_arr)
(n, k) = (int(x) for x in input().split()) arr = [int(x) for x in input().split()] new_arr = list() i = 0 while i != n - k + 1: new_arr.append(max(arr[i:i + k])) i += 1 print(*new_arr)
# # PySNMP MIB module Nortel-Magellan-Passport-SoftwareMIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Nortel-Magellan-Passport-SoftwareMIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:18:50 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # U...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, single_value_constraint, value_size_constraint, constraints_intersection, value_range_constraint) ...
expression = input() parentheses_indices = [] for i in range(len(expression)): if expression[i] == '(': parentheses_indices.append(i) elif expression[i] == ')': opening_index = parentheses_indices.pop() closing_index = i searched_set = expression[opening_index:closing_index + 1...
expression = input() parentheses_indices = [] for i in range(len(expression)): if expression[i] == '(': parentheses_indices.append(i) elif expression[i] == ')': opening_index = parentheses_indices.pop() closing_index = i searched_set = expression[opening_index:closing_index + 1] ...
name = "Optimizer Parameters" description = None args_and_kwargs = ( (("--iterations",), { "help":"Number of gradient steps to take.", "type":int, "default":10000, }), (("--learning-rate",), { "help":"Adam learning rate. The default is 0.001", "type":float, ...
name = 'Optimizer Parameters' description = None args_and_kwargs = ((('--iterations',), {'help': 'Number of gradient steps to take.', 'type': int, 'default': 10000}), (('--learning-rate',), {'help': 'Adam learning rate. The default is 0.001', 'type': float, 'default': 0.001}), (('--beta-1',), {'help': 'Adam beta_1 para...
# File: M (Python 2.4) class Mappable: def __init__(self): pass def getMapNode(self): pass class MappableArea(Mappable): def getMapName(self): return '' def getZoomLevels(self): return ((100, 200, 300), 1) def getFootprintNode(self): ...
class Mappable: def __init__(self): pass def get_map_node(self): pass class Mappablearea(Mappable): def get_map_name(self): return '' def get_zoom_levels(self): return ((100, 200, 300), 1) def get_footprint_node(self): pass def get_shop_nodes(self):...
#!/usr/bin/env python S_PC = ord("p") S_A = ord("A") S_X = ord("X") S_Y = ord("Y") S_SP = ord("S") S_IND_X = 0x1D9 S_IND_Y = 0x1DF S_Z_X = 0x209 S_Z_Y = 0x20F S_Z = 0x200 S_ABS_X = 0x809 S_ABS_Y = 0x80F S_ABS = 0x800 S_HASH = ord("#") S_XXX = 0xFFFF S_NONE = 0x0000
s_pc = ord('p') s_a = ord('A') s_x = ord('X') s_y = ord('Y') s_sp = ord('S') s_ind_x = 473 s_ind_y = 479 s_z_x = 521 s_z_y = 527 s_z = 512 s_abs_x = 2057 s_abs_y = 2063 s_abs = 2048 s_hash = ord('#') s_xxx = 65535 s_none = 0
N = float(input()) if N >= 0 and N <= 25: print('Intervalo [0,25]') elif N > 25 and N <= 50: print('Intervalo (25,50]') elif N > 50 and N <= 75: print('Intervalo (50,75]') elif N > 75 and N <= 100: print('Intervalo (75,100]') else: print('Fora de intervalo')
n = float(input()) if N >= 0 and N <= 25: print('Intervalo [0,25]') elif N > 25 and N <= 50: print('Intervalo (25,50]') elif N > 50 and N <= 75: print('Intervalo (50,75]') elif N > 75 and N <= 100: print('Intervalo (75,100]') else: print('Fora de intervalo')
# Write a function called delete_starting_evens() that has a parameter named lst. # The function should remove elements from the front of lst until the front of the list is not even. The function should then return lst. # For example if lst started as [4, 8, 10, 11, 12, 15], then delete_starting_evens(lst) should retur...
def delete_starting_evens(lst): while len(lst) > 0 and lst[0] % 2 == 0: lst = lst[1:] return lst print(delete_starting_evens([4, 8, 10, 11, 12, 15]))
db_config = { 'host':'', #typically localhost if running this locally 'port':'', #typically 3306 if running a standard MySQl engine 'user':'', #mysql user with full privileges on the DB 'pass':'', #password of the mysql user 'db':''} #database in which all tables will be stored (must be already created)
db_config = {'host': '', 'port': '', 'user': '', 'pass': '', 'db': ''}
squares = [1, 4, 9, 16, 25] print(squares) # [1, 4, 9, 16, 25] print(squares[0]) # 1 print(squares[-1]) # 25 cubes = [1, 8, 27, 65, 125] cubes[3] = 64 print(cubes) # [1, 8, 27, 64, 125] cubes.append(216) cubes.append(7 ** 3) print(cubes) # [1, 8, 27, 64, 125, 216, 343] print(8 in cubes) # True print(None in c...
squares = [1, 4, 9, 16, 25] print(squares) print(squares[0]) print(squares[-1]) cubes = [1, 8, 27, 65, 125] cubes[3] = 64 print(cubes) cubes.append(216) cubes.append(7 ** 3) print(cubes) print(8 in cubes) print(None in cubes) a = [1, 2, 3] print(a) a[1] = [1, 2, 3] print(a) a[1][1] = [1, 2, 3] print(a) a[1][1][1] = 5 p...
REPOSITORY_LOCATIONS = dict( bazel_gazelle = dict( sha256 = "be9296bfd64882e3c08e3283c58fcb461fa6dd3c171764fcc4cf322f60615a9b", urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/0.18.1/bazel-gazelle-0.18.1.tar.gz"], ), bazel_skylib = dict( sha256 = "2ef429f5d7ce7...
repository_locations = dict(bazel_gazelle=dict(sha256='be9296bfd64882e3c08e3283c58fcb461fa6dd3c171764fcc4cf322f60615a9b', urls=['https://github.com/bazelbuild/bazel-gazelle/releases/download/0.18.1/bazel-gazelle-0.18.1.tar.gz']), bazel_skylib=dict(sha256='2ef429f5d7ce7111263289644d233707dba35e39696377ebab8b0bc701f7818e...
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def swapPairs(self, head): return nodeSwap(head) def nodeSwap(head): if head and head.next is None: return head count = 1 ...
class Solution: def swap_pairs(self, head): return node_swap(head) def node_swap(head): if head and head.next is None: return head count = 1 prev = None current = head new_head = None while current.next is not None: if count % 2 == 0: if newHead is None:...
# Strings normal_string = 'you will see a \t tab' print(normal_string) raw_string = r"you won't see a \t tab" print(raw_string) content = ['Joe', 26] format_string = f"His name's {content[0]} and he's {content[1]}." print(format_string) # Numbers # to be continued..
normal_string = 'you will see a \t tab' print(normal_string) raw_string = "you won't see a \\t tab" print(raw_string) content = ['Joe', 26] format_string = f"His name's {content[0]} and he's {content[1]}." print(format_string)
# static qstrs, should be sorted # extracted from micropython/py/makeqstrdata.py static_qstr_list = [ "", "__dir__", # Put __dir__ after empty qstr for builtin dir() to work "\n", " ", "*", "/", "<module>", "_", "__call__", "__class__", "__delitem__", "__enter__", "_...
static_qstr_list = ['', '__dir__', '\n', ' ', '*', '/', '<module>', '_', '__call__', '__class__', '__delitem__', '__enter__', '__exit__', '__getattr__', '__getitem__', '__hash__', '__init__', '__int__', '__iter__', '__len__', '__main__', '__module__', '__name__', '__new__', '__next__', '__qualname__', '__repr__', '__se...
# To raise an exception, you can use the 'raise' keyword. # Note that you can only raise an object of the Exception class or its subclasses. # Exception is an inbuilt class in python. # To raise subclasses of Exception(custom Exception) we have to create our own custom Class. # We can also pass message along with exc...
class Employee: def __init__(self, salary): self.salary_lower_limit = 100 self.salary_upper_limit = 200 self.salary = salary class Humanresource: def pay_salary(self, employee): if employee.salary < employee.salary_lower_limit: raise low_salary_exception(employee) ...
# CANDY REPLENISHING ROBOT n,t = [int(a) for a in input().strip().split()] Ar = [int(a) for a in input().strip().split()] i = 0 c = n count = 0 while t: #print(c) if c<5: count += (n-c) c += (n-c) #print(count) c -= Ar[i] t -= 1 i += 1 print(count)
(n, t) = [int(a) for a in input().strip().split()] ar = [int(a) for a in input().strip().split()] i = 0 c = n count = 0 while t: if c < 5: count += n - c c += n - c c -= Ar[i] t -= 1 i += 1 print(count)
class Benchmark(): def __init__(self): super().__init__() #Domain should be a list of lists where each list yields the minimum and maximum value for one of the variables. pass def calculate(self, x_var, y_var): pass def clip_to_domain(self, x_var, y_var): if...
class Benchmark: def __init__(self): super().__init__() pass def calculate(self, x_var, y_var): pass def clip_to_domain(self, x_var, y_var): if x_var < self.domain[0][0]: x_var = tf.Variable(self.domain[0][0]) if x_var > self.domain[0][1]: x...
# # PySNMP MIB module HUAWEI-L3VPN-EXT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-L3VPN-EXT-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:45:58 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (defau...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_range_constraint, value_size_constraint, single_value_constraint, constraints_union) ...
class Subscriber: def __init__(self, name): self.name = name def update(self, message): print(f'{self.name} got message {message}')
class Subscriber: def __init__(self, name): self.name = name def update(self, message): print(f'{self.name} got message {message}')
class Point: def __init__(self,x,y,types,ide) -> None: self.x = x self.y = y self.type = types self.id = ide def getID(self): return self.id def getX(self): return self.x def getY(self): return self.y def getType(self): ret...
class Point: def __init__(self, x, y, types, ide) -> None: self.x = x self.y = y self.type = types self.id = ide def get_id(self): return self.id def get_x(self): return self.x def get_y(self): return self.y def get_type(self): ret...
#!/usr/bin/env python3 # ## Code: def get_kth_prime(n:int)->int: # By Trial and Error, find the uppper bound of the state space max_n = 9*10**6 # Declare a list of bool values of size max_n is_prime = [True]*max_n # We already know that 0 and 1 are not prime is_prime[0], is_prime[1] = Fal...
def get_kth_prime(n: int) -> int: max_n = 9 * 10 ** 6 is_prime = [True] * max_n (is_prime[0], is_prime[1]) = (False, False) i = 2 while i * i < max_n: if is_prime[i]: for j in range(i * i, max_n, i): is_prime[j] = False i += 1 prime_t = [] for i in...
x = int(input()) d = [0] * 1000001 for i in range(2,x+1): d[i] = d[i-1] + 1 if i%2 == 0: d[i] = min(d[i], d[i//2] + 1) if i%3 == 0: d[i] = min(d[i], d[i//3] + 1) print(d[x])
x = int(input()) d = [0] * 1000001 for i in range(2, x + 1): d[i] = d[i - 1] + 1 if i % 2 == 0: d[i] = min(d[i], d[i // 2] + 1) if i % 3 == 0: d[i] = min(d[i], d[i // 3] + 1) print(d[x])
class PipelineException(Exception): pass class CredentialsException(Exception): pass
class Pipelineexception(Exception): pass class Credentialsexception(Exception): pass
num = int(input("enter somthing")) base = int(input("enter a base")) b = bin(num)[2:] o = oct(num)[2:] h = hex(num)[2:] print(b,o,h) x = num lst = [] while x >0: lst.append(int(x%base)) xmod = x%base x = (x-xmod)/base lst.reverse() print(lst) x = 0 for i in range(len(lst)): if lst[i] != 0: x +=...
num = int(input('enter somthing')) base = int(input('enter a base')) b = bin(num)[2:] o = oct(num)[2:] h = hex(num)[2:] print(b, o, h) x = num lst = [] while x > 0: lst.append(int(x % base)) xmod = x % base x = (x - xmod) / base lst.reverse() print(lst) x = 0 for i in range(len(lst)): if lst[i] != 0: ...
def findSeatId(line : str) -> int: row = findPosition(line[0:7], "F", "B") column = findPosition(line[7:], "L", "R") return (row << 3) + column def findPosition(line : str, goLow: str, goHigh:str) -> int: pos = 0 stride = 1 << (len(line) - 1) for c in line: if c == goHigh: ...
def find_seat_id(line: str) -> int: row = find_position(line[0:7], 'F', 'B') column = find_position(line[7:], 'L', 'R') return (row << 3) + column def find_position(line: str, goLow: str, goHigh: str) -> int: pos = 0 stride = 1 << len(line) - 1 for c in line: if c == goHigh: ...
class Intersection(): def __init__(self,t,object): self.t = t self.object = object class Intersections(list): def __init__(self,i): self += i def hit(self): hit = None pos = list(filter(lambda x: x.t >= 0,self)) if len(pos): hit = min(pos,ke...
class Intersection: def __init__(self, t, object): self.t = t self.object = object class Intersections(list): def __init__(self, i): self += i def hit(self): hit = None pos = list(filter(lambda x: x.t >= 0, self)) if len(pos): hit = min(pos, ke...
class Config: SECRET_KEY = '86cbed706b49dd1750b080f06d030a23' SQLALCHEMY_DATABASE_URI = 'sqlite:///database.db' SQLALCHEMY_TRACK_MODIFICATIONS =False SESSION_COOKIE_SECURE = True REMEMBER_COOKIE_SECURE = True MAIL_SERVER = 'smtp@google.com' MAIL_PASSWORD = '' MAIL_USERNAME = ''...
class Config: secret_key = '86cbed706b49dd1750b080f06d030a23' sqlalchemy_database_uri = 'sqlite:///database.db' sqlalchemy_track_modifications = False session_cookie_secure = True remember_cookie_secure = True mail_server = 'smtp@google.com' mail_password = '' mail_username = '' mail...
# This tests long ints for 32-bit machine a = 0x1ffffffff b = 0x100000000 print(a) print(b) print(a + b) print(a - b) print(b - a) # overflows long long implementation #print(a * b) print(a // b) print(a % b) print(a & b) print(a | b) print(a ^ b) print(a << 3) print(a >> 1) a += b print(a) a -= 123456 print(a) a *= ...
a = 8589934591 b = 4294967296 print(a) print(b) print(a + b) print(a - b) print(b - a) print(a // b) print(a % b) print(a & b) print(a | b) print(a ^ b) print(a << 3) print(a >> 1) a += b print(a) a -= 123456 print(a) a *= 257 print(a) a //= 257 print(a) a %= b print(a) a ^= b print(a) a |= b print(a) a &= b print(a) a...
# # PySNMP MIB module CTIF-EXT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CTIF-EXT-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:44:24 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,...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_range_constraint, constraints_union, value_size_constraint, single_value_constraint) ...
def egcd(a, b): x,y, u,v = 0,1, 1,0 while a != 0: q, r = b//a, b%a m, n = x-u*q, y-v*q b,a, x,y, u,v = a,r, u,v, m,n gcd = b return gcd, x, y def modinv(a, m): gcd, x, y = egcd(a, m) if gcd != 1: return None # modular inverse does not exist else: return x % m def affine...
def egcd(a, b): (x, y, u, v) = (0, 1, 1, 0) while a != 0: (q, r) = (b // a, b % a) (m, n) = (x - u * q, y - v * q) (b, a, x, y, u, v) = (a, r, u, v, m, n) gcd = b return (gcd, x, y) def modinv(a, m): (gcd, x, y) = egcd(a, m) if gcd != 1: return None else: ...
# RestDF Default settings PORT: int = 8000 HOST: str = 'localhost' DEBUG: bool = False
port: int = 8000 host: str = 'localhost' debug: bool = False
def reindent(s, numSpaces, prefix=None): _prefix = "\n" if prefix: _prefix+=prefix if not isinstance(s,str): s=str(s) _str = _prefix.join((numSpaces * " ") + i for i in s.splitlines()) return _str def format_columns(data, columns=4, max_rows=4): max_len = max( list(map( len...
def reindent(s, numSpaces, prefix=None): _prefix = '\n' if prefix: _prefix += prefix if not isinstance(s, str): s = str(s) _str = _prefix.join((numSpaces * ' ' + i for i in s.splitlines())) return _str def format_columns(data, columns=4, max_rows=4): max_len = max(list(map(len, ...
class User: ''' class that generates a new instance of a password user __init__ method that helps us to define properitis for our objet Args: ''' user_list = [] #Empty user list def __init__(self,name,password): self.name=name self.password=password ...
class User: """ class that generates a new instance of a password user __init__ method that helps us to define properitis for our objet Args: """ user_list = [] def __init__(self, name, password): self.name = name self.password = password def save_user(self): ...
# # PySNMP MIB module ALCATEL-IND1-MLD-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ALCATEL-IND1-MLD-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:18:33 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (defau...
(softent_ind1_mld,) = mibBuilder.importSymbols('ALCATEL-IND1-BASE', 'softentIND1Mld') (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, single_...
class Solution: def minimumTime(self, s: str) -> int: n = len(s) ans = n left = 0 # min time to remove illegal cars so far for i, c in enumerate(s): left = min(left + (ord(c) - ord('0')) * 2, i + 1) ans = min(ans, left + n - 1 - i) return ans
class Solution: def minimum_time(self, s: str) -> int: n = len(s) ans = n left = 0 for (i, c) in enumerate(s): left = min(left + (ord(c) - ord('0')) * 2, i + 1) ans = min(ans, left + n - 1 - i) return ans
SCREEN_HEIGHT, SCREEN_WIDTH = 600, 600 # Controls UP = 0, -1 DOWN = 0, 1 LEFT = -1, 0 RIGHT = 1, 0 # Window grid GRID_SIZE = 20 GRID_WIDTH = SCREEN_WIDTH / GRID_SIZE GRID_HEIGHT = SCREEN_HEIGHT / GRID_SIZE
(screen_height, screen_width) = (600, 600) up = (0, -1) down = (0, 1) left = (-1, 0) right = (1, 0) grid_size = 20 grid_width = SCREEN_WIDTH / GRID_SIZE grid_height = SCREEN_HEIGHT / GRID_SIZE
st = input("pls enter student details: ") student_db = {} while(st != "end"): ind = st.find(' ') student_db[st[:ind]] = st[ind + 1:] st = input("pls enter student details: ") roll = input("psl enter roll no : ") while(roll != 'X'): print(stude...
st = input('pls enter student details: ') student_db = {} while st != 'end': ind = st.find(' ') student_db[st[:ind]] = st[ind + 1:] st = input('pls enter student details: ') roll = input('psl enter roll no : ') while roll != 'X': print(student_db[roll]) roll = input('psl enter roll no : ')
def max_end3(nums): if nums[0] > nums[-1]: return nums[0:1]*3 return nums[-1:]*3
def max_end3(nums): if nums[0] > nums[-1]: return nums[0:1] * 3 return nums[-1:] * 3
#!/usr/bin/env python3 # -*- coding: utf-8 -*- name = "rqmts" __version__ = "1.0.0"
name = 'rqmts' __version__ = '1.0.0'
# FIXME: Stub class PreprocessorInfoChannel(object): def addLineForTokenNumber(self, line, toknum): pass
class Preprocessorinfochannel(object): def add_line_for_token_number(self, line, toknum): pass
assert easy_cxx_is_root @brutal.rule(caching='memory', traced=1) def c_compiler(): cc = brutal.env('CC', []) if cc: return cc NERSC_HOST = brutal.env('NERSC_HOST', None) if NERSC_HOST: return ['cc'] return ['gcc'] @brutal.rule(caching='memory', traced=1) def cxx_compiler(): cxx = brutal.env('CXX', [...
assert easy_cxx_is_root @brutal.rule(caching='memory', traced=1) def c_compiler(): cc = brutal.env('CC', []) if cc: return cc nersc_host = brutal.env('NERSC_HOST', None) if NERSC_HOST: return ['cc'] return ['gcc'] @brutal.rule(caching='memory', traced=1) def cxx_compiler(): cxx...
def word_flipper(str): if len(str) == 0: return str #split strings into words, as words are separated by spaces so words = str.split(" ") new_str = "" for i in range(len(words)): words[i] = words[i][::-1] return " ".join(words) # Test Cases print ("Pass" if ('retaw' == word_fl...
def word_flipper(str): if len(str) == 0: return str words = str.split(' ') new_str = '' for i in range(len(words)): words[i] = words[i][::-1] return ' '.join(words) print('Pass' if 'retaw' == word_flipper('water') else 'Fail') print('Pass' if 'sihT si na elpmaxe' == word_flipper('Thi...
def merge_sort(arr): if len(arr) <= 1: return mid = len(arr)//2 left = arr[:mid] right = arr[mid:] merge_sort(left) merge_sort(right) merge_lists(left, right, arr) def merge_lists(a,b,arr): len_a = len(a) len_b = len(b) i = j = k = 0 while i < len_a and j < len...
def merge_sort(arr): if len(arr) <= 1: return mid = len(arr) // 2 left = arr[:mid] right = arr[mid:] merge_sort(left) merge_sort(right) merge_lists(left, right, arr) def merge_lists(a, b, arr): len_a = len(a) len_b = len(b) i = j = k = 0 while i < len_a and j < len_b...
# FLOW011 for i in range(int(input())): salary=int(input()) if salary<1500: print(2*salary) else: print(1.98*salary + 500)
for i in range(int(input())): salary = int(input()) if salary < 1500: print(2 * salary) else: print(1.98 * salary + 500)
#encoding:utf-8 subreddit = 'bikinimoe' t_channel = '@BikiniMoe' def send_post(submission, r2t): return r2t.send_simple(submission)
subreddit = 'bikinimoe' t_channel = '@BikiniMoe' def send_post(submission, r2t): return r2t.send_simple(submission)
simType='sim_file' symProps = [ {'set': 'memory', 'RBs': [{'higher_order': False, 'pred_name': 'non_exist', 'P': 'non_exist', 'object_name': 'bar_0.703780466095', 'pred_sem': [], 'object_sem': [['X', 1, 'X', 'nil', 'state'], ['X_0.790476190476', 1, 'X', 0.79047619047619044, 'value'], ['Y', 1, 'Y', 'nil', 'state'], ['Y_...
sim_type = 'sim_file' sym_props = [{'set': 'memory', 'RBs': [{'higher_order': False, 'pred_name': 'non_exist', 'P': 'non_exist', 'object_name': 'bar_0.703780466095', 'pred_sem': [], 'object_sem': [['X', 1, 'X', 'nil', 'state'], ['X_0.790476190476', 1, 'X', 0.7904761904761904, 'value'], ['Y', 1, 'Y', 'nil', 'state'], ['...
# Given the mapping a = 1, b = 2, ... z = 26, and an encoded message, count the # number of ways it can be decoded. # For example, the message '111' would give 3, since it could be decoded as # 'aaa', 'ka', and 'ak'. # You can assume that the messages are decodable. For example, '001' is not # allowed. ALPHA...
alphabet = [chr(i) for i in range(97, 123)] def decode_number(nums): codes = [] def helper(nums, message): if not nums: codes.append(message) for i in range(1, len(nums) + 1): code = int(nums[:i]) if code == 0 or code > 26: break ...
N = int(input()) c = 0 for i in range(0, N // 5 + 1): for j in range(0, N // 4 + 1): five, four = 5 * i, 4 * j if five + four == N: c += 1 print(c)
n = int(input()) c = 0 for i in range(0, N // 5 + 1): for j in range(0, N // 4 + 1): (five, four) = (5 * i, 4 * j) if five + four == N: c += 1 print(c)
num1 = 10 num2 = 14 num3 = 12 if (num1 >= num2) and (num1 >= num3): largest = num1 elif (num2 >= num1) and (num2 >= num3): largest = num2 else: largest = num3 print("The largest number between",num1,",",num2,"and",num3,"is",largest)
num1 = 10 num2 = 14 num3 = 12 if num1 >= num2 and num1 >= num3: largest = num1 elif num2 >= num1 and num2 >= num3: largest = num2 else: largest = num3 print('The largest number between', num1, ',', num2, 'and', num3, 'is', largest)
day = int(input()) even = int(input()) end = int(input()) plan_a = round(max(0, day - 100) * 0.25 + even * 0.15 + end * 0.2, 2) plan_b = round(max(0, day - 250) * 0.45 + even * 0.35 + end * 0.25, 2) print('Plan A costs {:2}'.format(plan_a)) print('Plan B costs {:2}'.format(plan_b)) if plan_a < plan_b: print('Plan ...
day = int(input()) even = int(input()) end = int(input()) plan_a = round(max(0, day - 100) * 0.25 + even * 0.15 + end * 0.2, 2) plan_b = round(max(0, day - 250) * 0.45 + even * 0.35 + end * 0.25, 2) print('Plan A costs {:2}'.format(plan_a)) print('Plan B costs {:2}'.format(plan_b)) if plan_a < plan_b: print('Plan A...
#Check if the number entered is special '''a=int(input("Enter a number: ")) b=a fact=1 s=0 while a!=0: d=a%10#5;4;1 print(a,d) for i in range(1,d+1): fact*=i s+=fact#120;144;145 fact=1 a=a//10 if s==b: print("The given number, ", b,"is a special number") else: print("The given nu...
"""a=int(input("Enter a number: ")) b=a fact=1 s=0 while a!=0: d=a%10#5;4;1 print(a,d) for i in range(1,d+1): fact*=i s+=fact#120;144;145 fact=1 a=a//10 if s==b: print("The given number, ", b,"is a special number") else: print("The given number, ", b,"is not a special number")"""...
# MAXIMISE GCD def gcd(a,b): if a%b==0: return(b) if b%a==0: return(a) if a==b: return(a) if a>b: return gcd(a%b,b) if b>a: return gcd(a,b%a) n = int(input()) Arr = list(map(int, input().strip().split())) x = Arr[n-1] mx = 1 j = 0 for i ...
def gcd(a, b): if a % b == 0: return b if b % a == 0: return a if a == b: return a if a > b: return gcd(a % b, b) if b > a: return gcd(a, b % a) n = int(input()) arr = list(map(int, input().strip().split())) x = Arr[n - 1] mx = 1 j = 0 for i in range(n - 1, -1...
## ## # File auto-generated against equivalent DynamicSerialize Java class class NewAdaptivePlotRequest(object): def __init__(self): self.fileContents = None self.fileName = None self.bundleName = None self.description = None def getFileContents(self): return self.fil...
class Newadaptiveplotrequest(object): def __init__(self): self.fileContents = None self.fileName = None self.bundleName = None self.description = None def get_file_contents(self): return self.fileContents def set_file_contents(self, fileContents): self.file...
load("@rules_scala_annex//rules:external.bzl", "scala_maven_import_external") load("//repos:rules.bzl", "overlaid_github_repository") def singularity_scala_repositories(): com_chuusai_shapeless_repository() com_github_mpilquist_simulacrum_repository() eu_timepit_refined_repository() io_circe_circe_repo...
load('@rules_scala_annex//rules:external.bzl', 'scala_maven_import_external') load('//repos:rules.bzl', 'overlaid_github_repository') def singularity_scala_repositories(): com_chuusai_shapeless_repository() com_github_mpilquist_simulacrum_repository() eu_timepit_refined_repository() io_circe_circe_repo...
cipher = '11b90d6311b90ff90ce610c4123b10c40ce60dfa123610610ce60d450d000ce61061106110c4098515340d4512361534098509270e5d09850e58123610c9' pubkey = [99, 1235, 865, 990, 5, 1443, 895, 1477] flag = "" for i in range(0, len(cipher), 4): c = int(cipher[i:i+4], 16) for m in range(0x100): test = 0 for p...
cipher = '11b90d6311b90ff90ce610c4123b10c40ce60dfa123610610ce60d450d000ce61061106110c4098515340d4512361534098509270e5d09850e58123610c9' pubkey = [99, 1235, 865, 990, 5, 1443, 895, 1477] flag = '' for i in range(0, len(cipher), 4): c = int(cipher[i:i + 4], 16) for m in range(256): test = 0 for p ...
#coding:utf-8 ''' filename:vowel_counts.py chap:4 subject:9 conditions:chap3_35 string solution:count a,e,i,o,u ''' text = '''You raise me up,so I can stand on mountains You raise me up to walk on stromy seas I am strong when I am on your shoulders You raise me up to more than I can be''' v...
""" filename:vowel_counts.py chap:4 subject:9 conditions:chap3_35 string solution:count a,e,i,o,u """ text = 'You raise me up,so I can stand on mountains\nYou raise me up to walk on stromy seas\nI am strong when I am on your shoulders\nYou raise me up to more than I can be' vowels = ('a', 'e', ...
# reading ocntents from file # fp=open('file.txt') fp=open('file.txt','r') # by default it opens in read mode text=fp.read() print(text)
fp = open('file.txt', 'r') text = fp.read() print(text)
class Entry(object): def __init__(self): self.name = '' self.parent = '' self.created = 0 self.lastUpdate = 0 self.lastAccess = 0 def create(self): pass def delete(self): pass def getFullPath(self): if not self.parent: return...
class Entry(object): def __init__(self): self.name = '' self.parent = '' self.created = 0 self.lastUpdate = 0 self.lastAccess = 0 def create(self): pass def delete(self): pass def get_full_path(self): if not self.parent: ret...
class HashMap: def __init__(self): self.bucket = {} def put(self, key: int, value: int) -> None: self.bucket[key] = value def get(self, key: int) -> int: if key in self.bucket: return self.bucket[key] return -1 def remove(self, key: int) -> None: i...
class Hashmap: def __init__(self): self.bucket = {} def put(self, key: int, value: int) -> None: self.bucket[key] = value def get(self, key: int) -> int: if key in self.bucket: return self.bucket[key] return -1 def remove(self, key: int) -> None: i...
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
default_rules = list() default_rules.append('event["eventName"] == "ConsoleLogin" ' + 'and event["additionalEventData.MFAUsed"] != "Yes" ' + 'and "assumed-role/AWSReservedSSO" not in event.get("userIdentity.arn", "")') default_rules.append('event.get("errorCode", "") == "UnauthorizedOperation"') default_rules.append('e...
class DisjointSet: def __init__(self, elements): self.parent = [0] * elements self.size = [0] * elements def make_set(self, value): self.parent[value] = value self.size[value] = 1 def find(self, value): while self.parent[value] != value: value = self.pa...
class Disjointset: def __init__(self, elements): self.parent = [0] * elements self.size = [0] * elements def make_set(self, value): self.parent[value] = value self.size[value] = 1 def find(self, value): while self.parent[value] != value: value = self.pa...
def factor(num1: float, num2: float): if num1 % num2 == 0: return f"{num2} is a factor of {num1}" else: return f"{num2} is not a factor of {num1}" num1 = int(input("Enter a number: ")) num2 = int(input("Enter a number: ")) print(factor(num1, num2))
def factor(num1: float, num2: float): if num1 % num2 == 0: return f'{num2} is a factor of {num1}' else: return f'{num2} is not a factor of {num1}' num1 = int(input('Enter a number: ')) num2 = int(input('Enter a number: ')) print(factor(num1, num2))
n = input() cnt = 0 for i in n: if 'A' <= i <= 'C': cnt += 3 elif 'D' <= i <= 'F': cnt += 4 elif 'G' <= i <= 'I': cnt += 5 elif 'J' <= i <= 'L': cnt += 6 elif 'M' <= i <= 'O': cnt += 7 elif 'P' <= i <= 'S': cnt += 8 elif 'T' <= i <= 'V': ...
n = input() cnt = 0 for i in n: if 'A' <= i <= 'C': cnt += 3 elif 'D' <= i <= 'F': cnt += 4 elif 'G' <= i <= 'I': cnt += 5 elif 'J' <= i <= 'L': cnt += 6 elif 'M' <= i <= 'O': cnt += 7 elif 'P' <= i <= 'S': cnt += 8 elif 'T' <= i <= 'V': ...
class ClosestDistanceInfo: def __init__(self, first, second, neighbours): self.mFirst = first self.mSecond = second self.mNeighbours = neighbours
class Closestdistanceinfo: def __init__(self, first, second, neighbours): self.mFirst = first self.mSecond = second self.mNeighbours = neighbours
# -*- coding: utf-8 -*- { 'actualizada': ['actualizadas'], 'eliminada': ['eliminadas'], 'fila': ['filas'], 'seleccionado': ['seleccionados'], }
{'actualizada': ['actualizadas'], 'eliminada': ['eliminadas'], 'fila': ['filas'], 'seleccionado': ['seleccionados']}
class node(object): def __init__(self, data): self.data = data self.next = None def get_data(self): return self.data def set_next(self, next): self.next = next def get_next(self): return self.next def has_next(self): return self.next...
class Node(object): def __init__(self, data): self.data = data self.next = None def get_data(self): return self.data def set_next(self, next): self.next = next def get_next(self): return self.next def has_next(self): return self.next != None clas...
# Longest common sub sequence: def find_length_lcs(a1, a2): N = len(a1) dp = [[0 for i in range(N + 1)] for j in range(N + 1)] for i in range(1, N + 1): for j in range(1, N + 1): if a1[i - 1] == a2[j - 1]: dp[i][j] = 1 + dp[i - 1][j - 1] else: ...
def find_length_lcs(a1, a2): n = len(a1) dp = [[0 for i in range(N + 1)] for j in range(N + 1)] for i in range(1, N + 1): for j in range(1, N + 1): if a1[i - 1] == a2[j - 1]: dp[i][j] = 1 + dp[i - 1][j - 1] else: dp[i][j] = max(dp[i - 1][j], dp...
entries = [ { 'env-title': 'atari-alien', 'env-variant': 'No-op start', 'score': 5778, 'stddev': 2189, }, { 'env-title': 'atari-amidar', 'env-variant': 'No-op start', 'score': 3537, 'stddev': 521, }, { 'env-title': 'atari-assaul...
entries = [{'env-title': 'atari-alien', 'env-variant': 'No-op start', 'score': 5778, 'stddev': 2189}, {'env-title': 'atari-amidar', 'env-variant': 'No-op start', 'score': 3537, 'stddev': 521}, {'env-title': 'atari-assault', 'env-variant': 'No-op start', 'score': 11231, 'stddev': 503}, {'env-title': 'atari-asterix', 'en...
class CacheData: def __init__(self, cache=None, root=None,hit=None,full=None): self.cache = cache self.root = root self.hit = hit self.full = full
class Cachedata: def __init__(self, cache=None, root=None, hit=None, full=None): self.cache = cache self.root = root self.hit = hit self.full = full
## # This software was developed and / or modified by Raytheon Company, # pursuant to Contract DG133W-05-CQ-1067 with the US Government. # # U.S. EXPORT CONTROLLED TECHNICAL DATA # This software product contains export-restricted data whose # export/transfer/disclosure is restricted by U.S. law. Dissemination # to ...
verdir = '/data/verify' editareas = 'EditAreas.dat' percent_color = 'Warm To Cold' griddays = 200 statdays = 500 obsmodels = ['Obs', 'RFCQPE'] verconfig = {} VERCONFIG['T'] = (0, 0, 3, (1, 3, 5, 7, 10), 0.5, 20, 'BV_Change1', 'T') VERCONFIG['MaxT'] = (0, 0, 0, (1, 3, 5, 7, 10), 0.5, 20, 'BV_Change1', 'MaxT') VERCONFIG[...
validators = { "departure location": [[45, 609], [616, 954]], "departure station": [[32, 194], [211, 972]], "departure platform": [[35, 732], [744, 970]], "departure track": [[40, 626], [651, 952]], "departure date": [[44, 170], [184, 962]], "departure time": [[49, 528], [538, 954]], "arriva...
validators = {'departure location': [[45, 609], [616, 954]], 'departure station': [[32, 194], [211, 972]], 'departure platform': [[35, 732], [744, 970]], 'departure track': [[40, 626], [651, 952]], 'departure date': [[44, 170], [184, 962]], 'departure time': [[49, 528], [538, 954]], 'arrival location': [[36, 448], [464...
class Solution: def recoverTree(self, root: Optional[TreeNode]) -> None: def swap(x: Optional[TreeNode], y: Optional[TreeNode]) -> None: temp = x.val x.val = y.val y.val = temp def inorder(root: Optional[TreeNode]) -> None: if not root: return inorder(root.left) ...
class Solution: def recover_tree(self, root: Optional[TreeNode]) -> None: def swap(x: Optional[TreeNode], y: Optional[TreeNode]) -> None: temp = x.val x.val = y.val y.val = temp def inorder(root: Optional[TreeNode]) -> None: if not root: ...
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. class VersionUpdateItem: def __init__(self, id, new_version): self.id = id self.new_version = new_version def __str__(self): return '[id: {}; new_version: {}]'.format(self.id, self.new_versio...
class Versionupdateitem: def __init__(self, id, new_version): self.id = id self.new_version = new_version def __str__(self): return '[id: {}; new_version: {}]'.format(self.id, self.new_version)
class Solution: def minimumTotal(self, triangle: List[List[int]]) -> int: arr = [0x7fffffff] * len(triangle) arr[0] = triangle[0][0] for i in range(1, len(triangle)): arr[i] = arr[i - 1] + triangle[i][i] for j in range(i - 1, 0, -1): arr[j] = min(arr[j...
class Solution: def minimum_total(self, triangle: List[List[int]]) -> int: arr = [2147483647] * len(triangle) arr[0] = triangle[0][0] for i in range(1, len(triangle)): arr[i] = arr[i - 1] + triangle[i][i] for j in range(i - 1, 0, -1): arr[j] = min(arr...
prn_out = { 1: [2, 6], 2: [3, 7], 3: [4, 8], 4: [6, 9], 5: [1, 9], 6: [2, 10], 7: [1, 8], 8: [2, 9], 9: [3, 10], 10: [2, 3], 11: [3, 4], 12: [5, 6], 13: [6, 7], 14: [7, 8], 15: [8, 9], 16: [9, 10], 17: [1, 4], 18: [2, 5], 19: [3, 6], ...
prn_out = {1: [2, 6], 2: [3, 7], 3: [4, 8], 4: [6, 9], 5: [1, 9], 6: [2, 10], 7: [1, 8], 8: [2, 9], 9: [3, 10], 10: [2, 3], 11: [3, 4], 12: [5, 6], 13: [6, 7], 14: [7, 8], 15: [8, 9], 16: [9, 10], 17: [1, 4], 18: [2, 5], 19: [3, 6], 20: [4, 7], 21: [5, 8], 22: [6, 9], 23: [1, 3], 24: [4, 6], 25: [5, 7], 26: [6, 8], 27:...
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") def berty_go_repositories(): # utils maybe( git_repository, name = "bazel_skylib", re...
load('@bazel_tools//tools/build_defs/repo:git.bzl', 'git_repository') load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') load('@bazel_tools//tools/build_defs/repo:utils.bzl', 'maybe') def berty_go_repositories(): maybe(git_repository, name='bazel_skylib', remote='https://github.com/bazelbuild/baz...
y: Tuple[int, ...] x: Tuple[int] z: Tuple[Union[int, str]] for ([y, (x, (z))]) in \ undefined(): pass
y: Tuple[int, ...] x: Tuple[int] z: Tuple[Union[int, str]] for [y, (x, z)] in undefined(): pass
class Solution: def findLadders(self, beginWord: str, endWord: str, wordList: List[str]) -> List[List[str]]: words = set(wordList) if endWord not in words: return [] frontier = collections.deque([(beginWord)]) mn_cost = math.inf costs = {w : math.inf for w in word...
class Solution: def find_ladders(self, beginWord: str, endWord: str, wordList: List[str]) -> List[List[str]]: words = set(wordList) if endWord not in words: return [] frontier = collections.deque([beginWord]) mn_cost = math.inf costs = {w: math.inf for w in words...
if __name__ == '__main__': stlist = [] marks = set() lower_name = [] for _ in range(int(input())): name = input() score = float(input()) stlist.append([name, score]) marks.add(score) # Increasing order sec = sorted(marks)[1] # print(sec) for name, scor...
if __name__ == '__main__': stlist = [] marks = set() lower_name = [] for _ in range(int(input())): name = input() score = float(input()) stlist.append([name, score]) marks.add(score) sec = sorted(marks)[1] for (name, score) in stlist: if score == sec: ...
#printing fibonacci number until 'n' using python n=int(input("enter the value of 'n': ")) a=0 b=1 sum=0 count=1 print("fibonacci:",end = " ") while(count<=n): print(sum,end=" ") count +=1 a=b b=sum sum=a+b
n = int(input("enter the value of 'n': ")) a = 0 b = 1 sum = 0 count = 1 print('fibonacci:', end=' ') while count <= n: print(sum, end=' ') count += 1 a = b b = sum sum = a + b