content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
"""Definition for create_release macro.""" load("//shlib/rules:execute_binary.bzl", "execute_binary") def create_release(name, workflow_name): """Declares an executable target that launches a Github Actions release workflow. This utility expects Github's CLI (`gh`) to be installed. Running this \ utility...
"""Definition for create_release macro.""" load('//shlib/rules:execute_binary.bzl', 'execute_binary') def create_release(name, workflow_name): """Declares an executable target that launches a Github Actions release workflow. This utility expects Github's CLI (`gh`) to be installed. Running this utility la...
# Time: O(n) # Space: O(h) # Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def bstToGst(self, root): """ :type root: TreeNode :rtype: Tre...
class Treenode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def bst_to_gst(self, root): """ :type root: TreeNode :rtype: TreeNode """ def bst_to_gst_helper(root, prev): if n...
#python 3.5.2 ''' This Python functions finds the maximum number in a list by compares each number to every other number on the list. ''' class MyMath(): def __init__(self, list): self.list = list def findMaxNo(self): max = self.list[0] for x in self.list: if x > max...
""" This Python functions finds the maximum number in a list by compares each number to every other number on the list. """ class Mymath: def __init__(self, list): self.list = list def find_max_no(self): max = self.list[0] for x in self.list: if x > max: m...
name, age = "Inshad", 18 username = "MohammedInshad" print ('Hello!') print("inshad: {}\n18 {}\nMohammedInshad: {}".format(name, age, username))
(name, age) = ('Inshad', 18) username = 'MohammedInshad' print('Hello!') print('inshad: {}\n18 {}\nMohammedInshad: {}'.format(name, age, username))
''' The MIT License (MIT) Copyright (c) 2016 WavyCloud Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, p...
""" The MIT License (MIT) Copyright (c) 2016 WavyCloud Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, p...
workers = 1 worker_class = 'gevent' bind = '0.0.0.0:5000' pidfile = '/tmp/gunicorn-csdh-api.pid' debug = True reload = True loglevel = 'info' errorlog = '/tmp/gunicorn_csdh_api_error.log' accesslog = '/tmp/gunicorn_csdh_api_access.log' daemon = False
workers = 1 worker_class = 'gevent' bind = '0.0.0.0:5000' pidfile = '/tmp/gunicorn-csdh-api.pid' debug = True reload = True loglevel = 'info' errorlog = '/tmp/gunicorn_csdh_api_error.log' accesslog = '/tmp/gunicorn_csdh_api_access.log' daemon = False
def sol(): a = input() b = input() for i in range(3): print( int(a) * int(b[2 - i]) ) print(int(a) * int(b)) if __name__ == "__main__": sol()
def sol(): a = input() b = input() for i in range(3): print(int(a) * int(b[2 - i])) print(int(a) * int(b)) if __name__ == '__main__': sol()
def main(): x = 10 if(x == 5): x = 1 else: x = 2 x = 3
def main(): x = 10 if x == 5: x = 1 else: x = 2 x = 3
class Phishing(object): @staticmethod def create_(): print("Haciendo phishing")
class Phishing(object): @staticmethod def create_(): print('Haciendo phishing')
n = int(input()) ondo = [list(map(float, input().split())) for _ in range(n)] soukei = {'mousyo': 0, 'manatsu': 1, 'natsu': 2, 'nettai': 3, 'huyu': 4, 'mafuyu': 5} s = [0]*6 for i, j in ondo: if i >= 35: s[soukei['mousyo']] += 1 if 30 <= i < 35: s[soukei['manatsu']] += 1 if 25 <= i...
n = int(input()) ondo = [list(map(float, input().split())) for _ in range(n)] soukei = {'mousyo': 0, 'manatsu': 1, 'natsu': 2, 'nettai': 3, 'huyu': 4, 'mafuyu': 5} s = [0] * 6 for (i, j) in ondo: if i >= 35: s[soukei['mousyo']] += 1 if 30 <= i < 35: s[soukei['manatsu']] += 1 if 25 <= i < 30:...
class Car(object): speed = 0 def __init__(self, vehicle_type=None,model='GM',name='General'): self.vehicle_type= vehicle_type self.model = model self.name=name if self.name in ['Porsche', 'Koenigsegg']: self.num_of_doors = 2 else: self.num_of_doors = 4 if self.vehicle_t...
class Car(object): speed = 0 def __init__(self, vehicle_type=None, model='GM', name='General'): self.vehicle_type = vehicle_type self.model = model self.name = name if self.name in ['Porsche', 'Koenigsegg']: self.num_of_doors = 2 else: self.num_of...
# Python Program To Find Square Of Elements In A List ''' Function Name : Square Of Elements In A List. Function Date : 8 Sep 2020 Function Author : Prasad Dangare Input : Integer Output : Integer ''' def square(x): return x*x # Let Us Take A List Of Numbers lst ...
""" Function Name : Square Of Elements In A List. Function Date : 8 Sep 2020 Function Author : Prasad Dangare Input : Integer Output : Integer """ def square(x): return x * x lst = [1, 2, 3, 4, 5] lst1 = list(map(square, lst)) print(lst1)
class Solution(object): def countAndSay(self, n): """ :type n: int :rtype: str """ if n == 1: return "1" prev = self.countAndSay(n-1) res = "" ct = 1 for i in range(len(prev)): if i == len(prev)-1 or prev[i] != prev[i+1...
class Solution(object): def count_and_say(self, n): """ :type n: int :rtype: str """ if n == 1: return '1' prev = self.countAndSay(n - 1) res = '' ct = 1 for i in range(len(prev)): if i == len(prev) - 1 or prev[i] != pr...
n=int(input()) while True: a=int(input()) if a is 0: break if a%n is 0: print("{} is a multiple of {}.".format(a,n)) else: print("{} is NOT a multiple of {}.".format(a,n))
n = int(input()) while True: a = int(input()) if a is 0: break if a % n is 0: print('{} is a multiple of {}.'.format(a, n)) else: print('{} is NOT a multiple of {}.'.format(a, n))
""" UB_ID : 50291708 Name : Md Moniruzzaman Monir """ class Rectangle: # constructor def __init__(self, x, y, width, height): self.x = x self.y = y self.width = width self.height = height # Return the sum of all pixels inside a rectangle for a specific int...
""" UB_ID : 50291708 Name : Md Moniruzzaman Monir """ class Rectangle: def __init__(self, x, y, width, height): self.x = x self.y = y self.width = width self.height = height def compute_sum(self, integralImg, scale, x, y): x = self.x y = self.y ...
n = int(input()) l = int(input()) for first in range(1, n): for second in range(1, n): for three in range(97, 97 + l): for four in range(97, 97 + l): for five in range(2, n + 1): three_chr = chr(three) four_chr = chr(four) ...
n = int(input()) l = int(input()) for first in range(1, n): for second in range(1, n): for three in range(97, 97 + l): for four in range(97, 97 + l): for five in range(2, n + 1): three_chr = chr(three) four_chr = chr(four) ...
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
"""some additional (math) types you may need, with instance checks""" __all__ = ['NaturalNumber', 'StrictNaturalNumber'] class NaturalNumberMeta(type): """metaclass""" def __instancecheck__(self, instance): return isinstance(instance, int) and instance >= 0 class StrictNaturalNumberMeta(type): ...
"""some additional (math) types you may need, with instance checks""" __all__ = ['NaturalNumber', 'StrictNaturalNumber'] class Naturalnumbermeta(type): """metaclass""" def __instancecheck__(self, instance): return isinstance(instance, int) and instance >= 0 class Strictnaturalnumbermeta(type): ""...
"""Exercise 1: Country Roads Remember to fill out all the TODO's, you can quickly scan for them by pressing CTRL/CMD + F """ class Car: """A class representing a car with details about how far it can travel""" def __init__(self, gas_tank_size, fuel, litres_per_kilometre): self.gas_tank_size = gas_tank...
"""Exercise 1: Country Roads Remember to fill out all the TODO's, you can quickly scan for them by pressing CTRL/CMD + F """ class Car: """A class representing a car with details about how far it can travel""" def __init__(self, gas_tank_size, fuel, litres_per_kilometre): self.gas_tank_size = gas_tan...
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...
sections = { # type descriptions / header blocks "public": { "name": "Public Routes", "desc": """\ <p>These routes <b>DO NOT</b> require user authentication (though some of them require a valid API key to use).</p> <p> When building an application, use these routes to construct dashboard type vi...
sections = {'public': {'name': 'Public Routes', 'desc': '<p>These routes <b>DO NOT</b> require user authentication (though some of them\nrequire a valid API key to use).</p>\n<p> When building an application, use these routes to construct\ndashboard type views and to look up game asset data that does not belong to any\...
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...
class Solution: def shiftingLetters(self, S: str, shifts: List[int]) -> str: """String. Running time: O(n) where n == len(shifts). """ orda = ord('a') n = len(shifts) suf = shifts suf[-1] %= 26 for i in range(n - 2, -1, -1): suf[i] = (suf[...
class Solution: def shifting_letters(self, S: str, shifts: List[int]) -> str: """String. Running time: O(n) where n == len(shifts). """ orda = ord('a') n = len(shifts) suf = shifts suf[-1] %= 26 for i in range(n - 2, -1, -1): suf[i] = (su...
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...
EXTERN_START = "\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n" EXTERN_STOP = "#ifdef __cplusplus\n}\n#endif\n\n" EXTERN_FIND1 = "extern \"C\" {\n" EXTERN_FIND2 = " *****************************************************************************/\n" # noqa def add_extern_c(source_file, source): """ Add 'Exte...
extern_start = '\n#ifdef __cplusplus\nextern "C" {\n#endif\n\n' extern_stop = '#ifdef __cplusplus\n}\n#endif\n\n' extern_find1 = 'extern "C" {\n' extern_find2 = ' *****************************************************************************/\n' def add_extern_c(source_file, source): """ Add 'Extern C' to a giv...
""" This is boin default hyper parameters. """ model_name = 'BoinAutoEncoder' lr = 0.001 max_view_num = 500 view_interval = 100 class encoder_hparams: model_name = 'BoinEncoder' nhid = 512 nlayers = 2 class decoder_hparams: model_name = 'BoinDecoder' nhid = 512 nlayers = 2
""" This is boin default hyper parameters. """ model_name = 'BoinAutoEncoder' lr = 0.001 max_view_num = 500 view_interval = 100 class Encoder_Hparams: model_name = 'BoinEncoder' nhid = 512 nlayers = 2 class Decoder_Hparams: model_name = 'BoinDecoder' nhid = 512 nlayers = 2
""" Matrix exercise """ class Matrix: """ Matrix class """ def __init__(self, matrix_string): """ Create a matrix """ self.rows = [] self.columns = [[] for i in range(len(matrix_string.split("\n")[0].split()))] for line in matrix_string.spli...
""" Matrix exercise """ class Matrix: """ Matrix class """ def __init__(self, matrix_string): """ Create a matrix """ self.rows = [] self.columns = [[] for i in range(len(matrix_string.split('\n')[0].split()))] for line in matrix_string.split...
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
""" w04 team assignment : Date.py day : int month : int year : int __init__() prompt() display() """ class Date: """ the date class """ def __init__(self, date_day=1, date_month=1, date_year=2000): # set up the class variables and assign default values self.day = date_day self.month ...
""" w04 team assignment : Date.py day : int month : int year : int __init__() prompt() display() """ class Date: """ the date class """ def __init__(self, date_day=1, date_month=1, date_year=2000): self.day = date_day self.month = date_month self.year = date_year def prompt(self)...
""" 1. Create a inheritance tree with the following structure 1. BaseCharacter 1. Non-Playable Character(NPC) 1. Friendly 2. Enemy 2. Playable Character(PC) 1. Archer 2. Green Lantern 3. Butcher 2. Add 'printName' function All characters ha...
""" 1. Create a inheritance tree with the following structure 1. BaseCharacter 1. Non-Playable Character(NPC) 1. Friendly 2. Enemy 2. Playable Character(PC) 1. Archer 2. Green Lantern 3. Butcher 2. Add 'printName' function All characters ha...
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] ...
"""Mappings. Mappings define how internal objects and their fields will be indexed. The provided record-v1.0.0.json file is an example of how to index records in Elasticsearch. """
"""Mappings. Mappings define how internal objects and their fields will be indexed. The provided record-v1.0.0.json file is an example of how to index records in Elasticsearch. """
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
"""Libpdf exceptions.""" class LibpdfException(Exception): """Generic libpdf exception class."""
"""Libpdf exceptions.""" class Libpdfexception(Exception): """Generic libpdf exception class."""
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 Solution(object): def minPatches(self, nums, n): """ :type nums: List[int] :type n: int :rtype: int """ i = 0 patches = 0 miss = 1 while miss <= n: if i < len(nums) and nums[i] <= miss: miss += nums...
class Solution(object): def min_patches(self, nums, n): """ :type nums: List[int] :type n: int :rtype: int """ i = 0 patches = 0 miss = 1 while miss <= n: if i < len(nums) and nums[i] <= miss: miss += nums[i] ...
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 RedisConnectionMock(object): """ Simple class to mock a dummy behaviour for Redis related functions """ def zscore(self, redis_prefix, day): pass def zincrby(self, redis_prefix, day, amount): pass
class Redisconnectionmock(object): """ Simple class to mock a dummy behaviour for Redis related functions """ def zscore(self, redis_prefix, day): pass def zincrby(self, redis_prefix, day, amount): pass
""" LC735 Asteroid Collision We are given an array asteroids of integers representing asteroids in a row. For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed. Find out the state of the a...
""" LC735 Asteroid Collision We are given an array asteroids of integers representing asteroids in a row. For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed. Find out the state of the a...
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...
class Solution(object): def longestWord(self, words): """ :type words: List[str] :rtype: str """ wset = set(words) res = "" for w in words: isIn = True for i in range(1, len(w)): #check if all subwords in if w[:i] not i...
class Solution(object): def longest_word(self, words): """ :type words: List[str] :rtype: str """ wset = set(words) res = '' for w in words: is_in = True for i in range(1, len(w)): if w[:i] not in wset: ...
#!/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...
#!/usr/bin/env python """actions.py Contains actions for interaction board state """
"""actions.py Contains actions for interaction board state """
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: ...
# https://leetcode.com/problems/integer-break/ #Given an integer n, break it into the sum of k positive integers, where k >= 2, and maximize the product of those integers. #Return the maximum product you can get. class Solution(object): def integerBreak(self, n): """ :type n: int :rtype: in...
class Solution(object): def integer_break(self, n): """ :type n: int :rtype: int """ if n == 2: return 1 if n == 3: return 2 if n == 4: return 4 if n == 5: return 6 if n == 6: return ...
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...
""" Some constants related to Cityscapes and SUN datasets """ # Taken from deeplabv3 trained on COCO CITYSCAPES_MEAN = [0.485, 0.456, 0.406] CITYSCAPES_STD = [0.229, 0.224, 0.225] # Mapping of IDs to labels # We follow https://github.com/mcordts/cityscapesScripts/blob/master/cityscapesscripts/helpers/labels.py # We m...
""" Some constants related to Cityscapes and SUN datasets """ cityscapes_mean = [0.485, 0.456, 0.406] cityscapes_std = [0.229, 0.224, 0.225] cityscapes_id_2_label = {0: 'void', 1: 'void', 2: 'void', 3: 'void', 4: 'void', 5: 'void', 6: 'void', 7: 'road', 8: 'sidewalk', 9: 'parking', 10: 'rail track', 11: 'building', 12:...
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) ...
""" Created on Wed Jan 26 23:57:01 2022 @author: G.A. """ ## PS1 Part A: House Hunting # Variables annual_salary = float(input("Enter your annual salary:")) portion_saved = float(input("Enter the percent of your salary to save, as a decimal:")) total_cost = float(input("Enter the cost of your dream home:")) portio...
""" Created on Wed Jan 26 23:57:01 2022 @author: G.A. """ annual_salary = float(input('Enter your annual salary:')) portion_saved = float(input('Enter the percent of your salary to save, as a decimal:')) total_cost = float(input('Enter the cost of your dream home:')) portion_down_payment = 0.25 r = 0.04 current_saving...
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'
"""Constants for Hive.""" ATTR_MODE = "mode" ATTR_TIME_PERIOD = "time_period" ATTR_ONOFF = "on_off" CONF_CODE = "2fa" CONFIG_ENTRY_VERSION = 1 DEFAULT_NAME = "Hive" DOMAIN = "hive" PLATFORMS = ["binary_sensor", "climate", "light", "sensor", "switch", "water_heater"] PLATFORM_LOOKUP = { "binary_sensor": "binary_sens...
"""Constants for Hive.""" attr_mode = 'mode' attr_time_period = 'time_period' attr_onoff = 'on_off' conf_code = '2fa' config_entry_version = 1 default_name = 'Hive' domain = 'hive' platforms = ['binary_sensor', 'climate', 'light', 'sensor', 'switch', 'water_heater'] platform_lookup = {'binary_sensor': 'binary_sensor', ...
# 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)