content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
def fractionSum(a, b): c = a[1] * b[1] d = a[0] * b[1] + b[0] * a[1] gcd = getGcd(c, d) return [d/gcd, c/gcd] def getGcd(a, b): while b: a, b = b, a % b return a
def fraction_sum(a, b): c = a[1] * b[1] d = a[0] * b[1] + b[0] * a[1] gcd = get_gcd(c, d) return [d / gcd, c / gcd] def get_gcd(a, b): while b: (a, b) = (b, a % b) return a
def tflm_kernel_friends(): return [] def tflm_audio_frontend_friends(): return [] def xtensa_fusion_f1_cpu(): return "F1_190305_swupgrade" def xtensa_hifi_3z_cpu(): return "HIFI_190304_swupgrade" def xtensa_hifi_5_cpu(): return "AE_HiFi5_LE5_AO_FP_XC"
def tflm_kernel_friends(): return [] def tflm_audio_frontend_friends(): return [] def xtensa_fusion_f1_cpu(): return 'F1_190305_swupgrade' def xtensa_hifi_3z_cpu(): return 'HIFI_190304_swupgrade' def xtensa_hifi_5_cpu(): return 'AE_HiFi5_LE5_AO_FP_XC'
''' Problem: Given a string, find the first un-repeated character in it. ''' def unrepeated(target): lookup = {} # Build a lookup table. for item in target: lookup.setdefault(item, 0) lookup[item] += 1 # Find the first non-repeated character. for item in target: if lookup...
""" Problem: Given a string, find the first un-repeated character in it. """ def unrepeated(target): lookup = {} for item in target: lookup.setdefault(item, 0) lookup[item] += 1 for item in target: if lookup[item] == 1: return item return None test = 'unrepeated unde...
EV_SYN = 0x00 EV_KEY = 0x01 EV_REL = 0x02 EV_ABS = 0x03 EV_MSC = 0x04 EV_SW = 0x05 EV_LED = 0x11 EV_SND = 0x12 EV_REP = 0x14 EV_FF = 0x15 EV_PWR = 0x16 EV_FF_STATUS = 0x17 SYN_REPORT = 0 SYN_CONFIG = 1 REL_X = 0x00 REL_Y = 0x01 REL_Z = 0x02 REL_RX = 0x03 REL_RY = 0x04 REL_RZ = 0x05 REL_HWHEEL = 0x06 REL_DIAL = 0x07 R...
ev_syn = 0 ev_key = 1 ev_rel = 2 ev_abs = 3 ev_msc = 4 ev_sw = 5 ev_led = 17 ev_snd = 18 ev_rep = 20 ev_ff = 21 ev_pwr = 22 ev_ff_status = 23 syn_report = 0 syn_config = 1 rel_x = 0 rel_y = 1 rel_z = 2 rel_rx = 3 rel_ry = 4 rel_rz = 5 rel_hwheel = 6 rel_dial = 7 rel_wheel = 8 rel_misc = 9 rel_max = 15 abs_x = 0 abs_y =...
GREEN = 24 RED = 26 BLUE = 22 WHITELIST = {"eb94294a", "044c4fd2222a80"} SPINTIME = 3 BLINKFRACTION = 3 #espeak ACCESSDENIED = "Access denied." SPEAKSPEED = 140 SPEAKPITCH = 50
green = 24 red = 26 blue = 22 whitelist = {'eb94294a', '044c4fd2222a80'} spintime = 3 blinkfraction = 3 accessdenied = 'Access denied.' speakspeed = 140 speakpitch = 50
# table definition table = { 'table_name' : 'ar_allocations', 'module_id' : 'ar', 'short_descr' : 'Ar allocation detail lines', 'long_descr' : 'Ar allocation detail lines', 'sub_types' : None, 'sub_trans' : None, 'sequence' : None, 'tree_params' : None, 'ro...
table = {'table_name': 'ar_allocations', 'module_id': 'ar', 'short_descr': 'Ar allocation detail lines', 'long_descr': 'Ar allocation detail lines', 'sub_types': None, 'sub_trans': None, 'sequence': None, 'tree_params': None, 'roll_params': None, 'indexes': [['ar_alloc_ndx', [['tran_row_id', False]], None, False]], 'le...
power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate...
power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate Leakage': 0.00662954, 'Peak Dynamic': 0.0, 'Runtime Dynamic': 0.0, 'Subthres...
# @desc Checking to see if a number is equal to another number def is_equal(x, y): return x == y def main(): print(is_equal(3, 5)) print(is_equal(5, 4)) print(is_equal(15, 15)) if __name__ == '__main__': main()
def is_equal(x, y): return x == y def main(): print(is_equal(3, 5)) print(is_equal(5, 4)) print(is_equal(15, 15)) if __name__ == '__main__': main()
s = "python3" r = "raja" sh = 'shobha' iv = 'Ivaan' ag = "34" python_course = True r_course = False number_of_sisters = None # print("Hi ", r.capitalize(), s.capitalize(), sh.upper()) # print(sh.isalpha()) # print(ag.isdigit()) # print("Hello, am {0}. Nice to meet you {1}.".format(r.capitalize(),sh.capitalize())) p...
s = 'python3' r = 'raja' sh = 'shobha' iv = 'Ivaan' ag = '34' python_course = True r_course = False number_of_sisters = None print(f'Hello, am {r}. Nice to meet you {sh} and {iv}. Learning Python.. Is that {python_course}?. Ivaan has {number_of_sisters} sisters.') if ag: print('Shobha is {ag} years old.') else: ...
# -*- coding: UTF-8 -*- ''' Base Service Module ''' class BaseService(): __repository = None def __init__(self): pass
""" Base Service Module """ class Baseservice: __repository = None def __init__(self): pass
# find the multiple missing numbers in an sorted array # input Array elements # find difference between currentArrayValue and value's index # while i < arrayLength # while difference < currentElementDifference (if missing elements are more than 1 at a time) # then print the missing number (difference + currentIn...
print('Enter the elements', end=' ') array = list(map(int, input().split())) difference = array[0] - 0 for i in range(len(array)): while difference < array[i] - i: print(f'Missing value is {i + difference}') difference += 1 diff = array[0] - 0 missing_values = list() for i in range(len(array)): ...
def format_log(info: str, exception=None, traceback: str=None, values: dict={}): log = ( f'INFO: {info}\n' f'------------\n' ) if exception is not None: log = log + ( f'EXCEPTION FOUNDED: \n' f'{repr(exception)}\n' f'------------\n' ) if traceback is not None: log = log + ( f'TRACEBACK: \n' ...
def format_log(info: str, exception=None, traceback: str=None, values: dict={}): log = f'INFO: {info}\n------------\n' if exception is not None: log = log + f'EXCEPTION FOUNDED: \n{repr(exception)}\n------------\n' if traceback is not None: log = log + f'TRACEBACK: \n{traceback}\n-----------...
nt_regex = { 'Matthew': '.*(M[a-z]*t[a-z]*)[\s\.](\d+):(\d+)[\s]*(.*)', 'Mark': '(M[a-z]*k[a-z]*)[\s\.](\d+):(\d+)[\s]*(.+)', 'Luke': '(L[a-z]*k[a-z]*)[\s\.](\d+):(\d+)[\s]*(.+)', 'John': '(^J[a-z]*n[a-z]*)[\s\.](\d+):(\d+)[\s]*(.+)', 'Acts': '(A[a-z]*c[a-z]*)[\s\.](\d+):(\d+)[\s]*(.+)', 'Romans...
nt_regex = {'Matthew': '.*(M[a-z]*t[a-z]*)[\\s\\.](\\d+):(\\d+)[\\s]*(.*)', 'Mark': '(M[a-z]*k[a-z]*)[\\s\\.](\\d+):(\\d+)[\\s]*(.+)', 'Luke': '(L[a-z]*k[a-z]*)[\\s\\.](\\d+):(\\d+)[\\s]*(.+)', 'John': '(^J[a-z]*n[a-z]*)[\\s\\.](\\d+):(\\d+)[\\s]*(.+)', 'Acts': '(A[a-z]*c[a-z]*)[\\s\\.](\\d+):(\\d+)[\\s]*(.+)', 'Romans...
def is_palindrome(word): if word.lower() == word[::-1].lower(): print('Your word is a palindrome.') else: print('Your word is not a palindrome.') def is_anagram(word1, word2): w1 = sorted(word1.lower().replace(' ', '')) w2 = sorted(word2.lower().replace(' ', '')) if w1 == w2: ...
def is_palindrome(word): if word.lower() == word[::-1].lower(): print('Your word is a palindrome.') else: print('Your word is not a palindrome.') def is_anagram(word1, word2): w1 = sorted(word1.lower().replace(' ', '')) w2 = sorted(word2.lower().replace(' ', '')) if w1 == w2: ...
# Produce a list of list using list comprehensions list1 = [1,2,3,4,5] x = [[i**2, i**3] for i in list1] print(x)
list1 = [1, 2, 3, 4, 5] x = [[i ** 2, i ** 3] for i in list1] print(x)
# if a + b + c = P then we need a + b > c with c hypotenuse # we can also say that a <= b # Then we also need a^2 + b^2 = c^2 # We can start at 501 since all less than 501 will have a multiple # less than 1000 def findTris(p): ''' Find potential triangle sides of perimeter p. yield (a,b,c) ''' maxC = ...
def find_tris(p): """ Find potential triangle sides of perimeter p. yield (a,b,c) """ max_c = p / 2 n = 0 for c in xrange(maxC, 1, -1): max_a = (p - c) / 2 for a in xrange(1, maxA + 1): b = p - c - a if a * a + b * b == c * c: n += 1 re...
class Solution: def permute(self, nums): if not nums or len(nums) == 0: return [] def doPermute(numsLeft, numsChoosen, results): if not numsLeft or len(numsLeft) == 0: results.append(numsChoosen) return for i in range(len(n...
class Solution: def permute(self, nums): if not nums or len(nums) == 0: return [] def do_permute(numsLeft, numsChoosen, results): if not numsLeft or len(numsLeft) == 0: results.append(numsChoosen) return for i in range(len(numsLef...
class User: def __init__(self, user_id: int, username: str): self.user_id = user_id self.username = username self.books = [] def info(self): return ', '.join(sorted(self.books)) def __str__(self): return f"{self.user_id}, {self.username}, {self.books}"
class User: def __init__(self, user_id: int, username: str): self.user_id = user_id self.username = username self.books = [] def info(self): return ', '.join(sorted(self.books)) def __str__(self): return f'{self.user_id}, {self.username}, {self.books}'
# Solution 1 # O(n^2) time / O(n^2) space def sameBsts(arrayOne, arrayTwo): if len(arrayOne) != len(arrayTwo): return False if len(arrayOne) == 0 and len(arrayTwo) == 0: return True if arrayOne[0] != arrayTwo[0]: return False leftOne = getSmaller(arrayOne) leftTwo = getSm...
def same_bsts(arrayOne, arrayTwo): if len(arrayOne) != len(arrayTwo): return False if len(arrayOne) == 0 and len(arrayTwo) == 0: return True if arrayOne[0] != arrayTwo[0]: return False left_one = get_smaller(arrayOne) left_two = get_smaller(arrayTwo) right_one = get_bigge...
class Bunch(dict): def __init__(self, *args, **kwargs): super(Bunch, self).__init__(*args, **kwargs) self.__dict__ = self
class Bunch(dict): def __init__(self, *args, **kwargs): super(Bunch, self).__init__(*args, **kwargs) self.__dict__ = self
class MetaData(): def save_data_source(self): pass
class Metadata: def save_data_source(self): pass
ROBOT_LISTENER_API_VERSION = 2 def get_listener_method(name): def listener_method(*args): if name in ['message', 'log_message']: msg = args[0] message = '%s: %s %s' % (name, msg['level'], msg['message']) else: message = name raise AssertionError(message) ...
robot_listener_api_version = 2 def get_listener_method(name): def listener_method(*args): if name in ['message', 'log_message']: msg = args[0] message = '%s: %s %s' % (name, msg['level'], msg['message']) else: message = name raise assertion_error(message...
# 2-Sum Binary Tree # https://www.interviewbit.com/problems/2sum-binary-tree/ # # Given a binary search tree T, where each node contains a positive integer, and an integer K, # you have to find whether or not there exist two different nodes A and B such that A.value + B.value = K. # # Return 1 to denote that two such n...
class Solution(object): def _find_target(self, A, B, dp): if not A: return False if B - A.val in dp: return True dp[A.val] = True return self._findTarget(A.left, B, dp) or self._findTarget(A.right, B, dp) def t2_sum(self, A, B): return int(self._...
# -*- python -*- # This software was produced by NIST, an agency of the U.S. government, # and by statute is not subject to copyright in the United States. # Recipients of this software assume all responsibilities associated # with its operation, modification and maintenance. However, to # facilitate maintenance we a...
dirname = 'IO' if not DIM_3: clib = 'oof2common' else: clib = 'oof3dcommon' if not NO_GUI: subdirs = ['GUI'] if not DIM_3: cfiles = ['bitoverlay.C'] swigfiles = ['bitoverlay.swg'] pyfiles = ['activeareamodmenu.py', 'automatic.py', 'binarydata.py', 'bitmapdisplay.py', 'bitoverlaydisplay.py', 'col...
class Solution: def reverseOnlyLetters(self, s: str) -> str: s=list(s) left=0 right=len(s)-1 def isChar(a): return (ord(a)>=ord('a') and ord(a)<=ord('z')) or (ord(a)>=ord('A') and ord(a)<=ord('Z')) while left<right: if isChar(s[left]) and isChar(s[righ...
class Solution: def reverse_only_letters(self, s: str) -> str: s = list(s) left = 0 right = len(s) - 1 def is_char(a): return ord(a) >= ord('a') and ord(a) <= ord('z') or (ord(a) >= ord('A') and ord(a) <= ord('Z')) while left < right: if is_char(s[le...
# Shift cipher def shift(plain, key): if plain.isalnum() == False: raise ValueError("Plaintext should be alphanumeric") ctext = "" for c in plain: if c.islower(): ctext += chr((ord(c) - ord('a') + key) % 26 + ord('a')) elif c.isupper(): ctext += chr(...
def shift(plain, key): if plain.isalnum() == False: raise value_error('Plaintext should be alphanumeric') ctext = '' for c in plain: if c.islower(): ctext += chr((ord(c) - ord('a') + key) % 26 + ord('a')) elif c.isupper(): ctext += chr((ord(c) - ord('A') + key...
p = [] i = 0 while i < 10: p.append(i) i += 1 p[2] = p[6] = p p[a] = p # Makes p Top
p = [] i = 0 while i < 10: p.append(i) i += 1 p[2] = p[6] = p p[a] = p
n=str(input("Enter the list ")) ls=list(n.split(" ")) le=len(ls) last=ls[le-1] print("Last color %s"%last) print("First color " +ls[0])
n = str(input('Enter the list ')) ls = list(n.split(' ')) le = len(ls) last = ls[le - 1] print('Last color %s' % last) print('First color ' + ls[0])
#Hay que crear una variable donde esta el objetivo, una lo que se va # suman y otra donde esta lo que queda por cambiar dinero=100 acumulado=0 resto=100 #Variable lista con billetes billetes=[[3,20],[5,10],[2,5]] #variable cambio cambio2=[[0,20],[0,10],[0,5]] cambio=cambio2.copy() #soluciones posibles solucion=((0,0,0...
dinero = 100 acumulado = 0 resto = 100 billetes = [[3, 20], [5, 10], [2, 5]] cambio2 = [[0, 20], [0, 10], [0, 5]] cambio = cambio2.copy() solucion = ((0, 0, 0), (0, 0, 0), (0, 0, 0)) i = 0 while resto > billetes[i][1] and billetes[i][1] > 0 and (resto > dinero): billetes[i][1] -= 1 cambio[i][1] += 1 acumula...
a = "test1" b = "test2" c = "test3" print(2**100)
a = 'test1' b = 'test2' c = 'test3' print(2 ** 100)
def fa_icon(name): ''' http://fontawesome.dashgame.com/ ''' return 'fa fa-%s'%name
def fa_icon(name): """ http://fontawesome.dashgame.com/ """ return 'fa fa-%s' % name
class Customer: def __init__(self,name): self.name=name def greet(self,arg=None): if arg==None: print("Hello!") else: print("Hello",arg,"!") def purchase(self,*items): count=len(items) print(self.name, "you have purchased", count,"item(s):") ...
class Customer: def __init__(self, name): self.name = name def greet(self, arg=None): if arg == None: print('Hello!') else: print('Hello', arg, '!') def purchase(self, *items): count = len(items) print(self.name, 'you have purchased', count,...
# Copyright 2010 Hakan Kjellerstrand hakank@bonetmail.com # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
rows = 20 row_rule_len = 6 row_rules = [[0, 0, 0, 1, 1, 4], [0, 0, 0, 0, 1, 6], [1, 1, 1, 1, 2, 3], [0, 0, 1, 1, 2, 3], [0, 0, 3, 1, 2, 3], [0, 0, 4, 5, 2, 2], [0, 0, 0, 7, 3, 2], [0, 0, 3, 5, 1, 2], [0, 0, 2, 2, 4, 1], [0, 0, 2, 2, 3, 4], [0, 0, 0, 2, 5, 2], [0, 0, 2, 1, 5, 1], [0, 0, 2, 2, 3, 1], [0, 0, 0, 6, 2, 2], ...
class Hashtable: def __init__(self): self.size = 11 self.slots = [None] * self.size self.data = [None] *self.size def put(self, key, data): hash_value = self.hash_function(key) if self.slots[hash_value] == None: self.slots[hash_value] = key ...
class Hashtable: def __init__(self): self.size = 11 self.slots = [None] * self.size self.data = [None] * self.size def put(self, key, data): hash_value = self.hash_function(key) if self.slots[hash_value] == None: self.slots[hash_value] = key self...
def setup(): size (300,300) background (100) smooth() noLoop() def draw (): strokeWeight(15) str(100) line (100,200, 200,100) line (200,200, 100,100)
def setup(): size(300, 300) background(100) smooth() no_loop() def draw(): stroke_weight(15) str(100) line(100, 200, 200, 100) line(200, 200, 100, 100)
name = 'pyopengl' version = '3.1.0' authors = [ 'Mike C. Fletcher <mcfletch@vrplumber.com>' ] description = \ ''' Standard OpenGL bindings for Python. ''' build_requires = [ 'setuptools' ] requires = [ 'python' ] variants = [ ['platform-linux', 'arch-x86_64', 'os-CentOS-7'] ] uuid = '...
name = 'pyopengl' version = '3.1.0' authors = ['Mike C. Fletcher <mcfletch@vrplumber.com>'] description = '\n Standard OpenGL bindings for Python.\n ' build_requires = ['setuptools'] requires = ['python'] variants = [['platform-linux', 'arch-x86_64', 'os-CentOS-7']] uuid = 'pyopengl' def commands(): env.PYTH...
n, m = map(int, input().split()) l = [*map(int, input().split())] for _ in range(m): l.sort() l[0], l[1] = l[0]+l[1], l[0]+l[1] print(sum(l))
(n, m) = map(int, input().split()) l = [*map(int, input().split())] for _ in range(m): l.sort() (l[0], l[1]) = (l[0] + l[1], l[0] + l[1]) print(sum(l))
def dictMerge(a, b): for key, value in b.items(): if isinstance(value, dict): if key in a: dictMerge(a[key], value) else: a[key] = dict(value) else: a[key] = value
def dict_merge(a, b): for (key, value) in b.items(): if isinstance(value, dict): if key in a: dict_merge(a[key], value) else: a[key] = dict(value) else: a[key] = value
class Calculator: def __init__(self,num1): self.num1 = num1 def __add__(self,num2): return self.num1 + num2.num1 def __mul__(self,num2): return self.num1 * num2.num1 def __len__(self,str): return len(self.str) def __str__(self): return ...
class Calculator: def __init__(self, num1): self.num1 = num1 def __add__(self, num2): return self.num1 + num2.num1 def __mul__(self, num2): return self.num1 * num2.num1 def __len__(self, str): return len(self.str) def __str__(self): return f'The Decimal N...
# Copyright 2020 Plezentek, Inc. All rights reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or...
sqlc_release = provider(doc='Contains information about the SQLC release used in the toolchain', fields={'goos': 'The host OS the release was built for.', 'goarch': 'The host architecture the release was built for.', 'root_file': 'The file at the base of the toolchain context', 'sqlc': 'The sqlc binary to execute', 've...
SCRABBLE_LETTER_VALUES = { "a": 1, "b": 3, "c": 3, "d": 2, "e": 1, "f": 4, "g": 2, "h": 4, "i": 1, "j": 8, "k": 5, "l": 1, "m": 3, "n": 1, "o": 1, "p": 3, "q": 10, "r": 1, "s": 1, "t": 1, "u": 1, "v": 4, "w": 4, "x": 8, ...
scrabble_letter_values = {'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j': 8, 'k': 5, 'l': 1, 'm': 3, 'n': 1, 'o': 1, 'p': 3, 'q': 10, 'r': 1, 's': 1, 't': 1, 'u': 1, 'v': 4, 'w': 4, 'x': 8, 'y': 4, 'z': 10} def get_word_score(word, n): word_lower = word.lower() word_len = len(wordL...
def trace(matrix): try: return sum(matrix[i][i] for i in range(max(len(matrix), len(matrix[0])))) except: return None
def trace(matrix): try: return sum((matrix[i][i] for i in range(max(len(matrix), len(matrix[0]))))) except: return None
oredict = [ "logWood", "plankWood", "slabWood", "stairWood", "stickWood", "treeSapling", "treeLeaves", "vine", "oreGold", "oreIron", "oreLapis", "oreDiamond", "oreRedstone", "oreEmerald", "oreQuartz", "oreCoal", "ingotIron", "ingotGold", "ingot...
oredict = ['logWood', 'plankWood', 'slabWood', 'stairWood', 'stickWood', 'treeSapling', 'treeLeaves', 'vine', 'oreGold', 'oreIron', 'oreLapis', 'oreDiamond', 'oreRedstone', 'oreEmerald', 'oreQuartz', 'oreCoal', 'ingotIron', 'ingotGold', 'ingotBrick', 'ingotBrickNether', 'nuggetGold', 'nuggetIron', 'gemDiamond', 'gemEme...
class Embed: def __init__(self, title=None, description=None, color=None, spoiler=False): self.title = title self.description = description self.color = color self.spoiler = spoiler self.field_data = None self.footer = None def add_field(self, name, value, inline...
class Embed: def __init__(self, title=None, description=None, color=None, spoiler=False): self.title = title self.description = description self.color = color self.spoiler = spoiler self.field_data = None self.footer = None def add_field(self, name, value, inlin...
#!/usr/bin/env python3 # create a list containing three items my_list = ["192.168.0.5", 5060, "UP"] # display first item print("The first item in the list (IP): " + my_list[0] ) # Below needs to be cast from an int to a str for printing print("The second item in the list (port): " + str(my_list[1]) ) # displaying the f...
my_list = ['192.168.0.5', 5060, 'UP'] print('The first item in the list (IP): ' + my_list[0]) print('The second item in the list (port): ' + str(my_list[1])) print('The third item in the list (state): ' + my_list[2]) iplist = [5060, '80', 55, '10.0.0.1', '10.20.30.1', 'ssh'] print(iplist[3:5])
load("@bazel_gazelle//:deps.bzl", "go_repository") def pprof_go_repositories(): go_repository( name = "com_github_chzyer_logex", importpath = "github.com/chzyer/logex", sum = "h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=", version = "v1.1.10", ) go_repository( nam...
load('@bazel_gazelle//:deps.bzl', 'go_repository') def pprof_go_repositories(): go_repository(name='com_github_chzyer_logex', importpath='github.com/chzyer/logex', sum='h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=', version='v1.1.10') go_repository(name='com_github_chzyer_readline', importpath='github.com/c...
#SIMPLE CLASS TO SHOW HOW TO WORK WITH PACKAGES (look "11_test_my_package.py") #Santiago Garcia Arango #One of the modules to show how to create a simple package in python. class hello: def __init__(self, name): self.name = name def say_hi_to_someone(self): sentence = "Hello, " + self.name...
class Hello: def __init__(self, name): self.name = name def say_hi_to_someone(self): sentence = 'Hello, ' + self.name + '!!!' return sentence
class TextCompressor: def longestRepeat(self, sourceText): l = len(sourceText) for i in xrange(l / 2, 0, -1): for j in xrange(0, l - i): if sourceText[j : i + j] in sourceText[i + j :]: return sourceText[j : i + j] return ""
class Textcompressor: def longest_repeat(self, sourceText): l = len(sourceText) for i in xrange(l / 2, 0, -1): for j in xrange(0, l - i): if sourceText[j:i + j] in sourceText[i + j:]: return sourceText[j:i + j] return ''
class Solution: def canIwin(self, maxint: int, desiredtotal: int) -> bool: if maxint * (maxint + 1) < desiredtotal: return False cache = dict() def dp(running_total, used): if used in cache: return cache[used] for k in range(maxint, 0, -1):...
class Solution: def can_iwin(self, maxint: int, desiredtotal: int) -> bool: if maxint * (maxint + 1) < desiredtotal: return False cache = dict() def dp(running_total, used): if used in cache: return cache[used] for k in range(maxint, 0, -...
class TreasureHunt: def __init__(self, table, user_clues=None): try: # check user_clues user_clues = [int(clue) for clue in user_clues] except (TypeError, ValueError, IndexError): print('Clue has wrong type, expect - <int>. Start default:') user_clues = None ...
class Treasurehunt: def __init__(self, table, user_clues=None): try: user_clues = [int(clue) for clue in user_clues] except (TypeError, ValueError, IndexError): print('Clue has wrong type, expect - <int>. Start default:') user_clues = None try: ...
#!/usr/bin/env python # # (c) Copyright Rosetta Commons Member Institutions. # (c) This file is part of the Rosetta software suite and is made available under license. # (c) The Rosetta software is developed by the contributing members of the Rosetta Commons. # (c) For more information, see http://www.rosettacommons.or...
current_directory = ''
def func(a, b, n, m): min_elem = max(a) max_elem = min(b) ans = [] for i in range(min_elem, max_elem+1): j = 0 while j < n and i%a[j] == 0: j += 1 if j == n: if i%a[j-1] == 0: k = 0 while k < m and b[k]%i == 0: k += 1 if k == m: if b[k-1]%i == 0: ans.append(i) retu...
def func(a, b, n, m): min_elem = max(a) max_elem = min(b) ans = [] for i in range(min_elem, max_elem + 1): j = 0 while j < n and i % a[j] == 0: j += 1 if j == n: if i % a[j - 1] == 0: k = 0 while k < m and b[k] % i == 0: ...
f = open('input.txt') triangles = [map(int,l.split()) for l in f.readlines()] possible = 0 for t in triangles: t.sort() if t[0] + t[1] > t[2]: possible += 1 print(possible)
f = open('input.txt') triangles = [map(int, l.split()) for l in f.readlines()] possible = 0 for t in triangles: t.sort() if t[0] + t[1] > t[2]: possible += 1 print(possible)
#!/usr/bin/python dist = int(input()) v_r = int(input()) v_c = int(input()) time_r = dist / v_r time_c = 50 / v_c if time_c > time_r: print("Meep Meep") else: print("Yum")
dist = int(input()) v_r = int(input()) v_c = int(input()) time_r = dist / v_r time_c = 50 / v_c if time_c > time_r: print('Meep Meep') else: print('Yum')
# Problem: Remove x from string def removeX(string): if len(string)==0: return string if string[0]=="x": return removeX(string[1:]) else: return string[0]+removeX(string[1:]) # Main string = input() print(removeX(string))
def remove_x(string): if len(string) == 0: return string if string[0] == 'x': return remove_x(string[1:]) else: return string[0] + remove_x(string[1:]) string = input() print(remove_x(string))
def add(num1,num2): c=num1+num2 return c a=int(input("ENTER num1 : ")) b=int(input("ENTER num1 : ")) print(add(a,b))
def add(num1, num2): c = num1 + num2 return c a = int(input('ENTER num1 : ')) b = int(input('ENTER num1 : ')) print(add(a, b))
# set per your own configs prefixs = [ '011XXXXX.', ] prefixs_mid_process = [] prefixs_post_process = [] # process ASTERISK-like regex pattern for a prefix # we are not expanding 'X' or '.' # this is because we don't support length based prefix matching # instead we utilize dr_rules longest-to-shortest prefix matching...
prefixs = ['011XXXXX.'] prefixs_mid_process = [] prefixs_post_process = [] def process_prefix(prefix): for i in range(len(prefix)): if prefix[i] == 'N': tmp = list(prefix) for j in range(2, 9 + 1): tmp[i] = str(j) prefixs_mid_process.append(''.join(tm...
#~ def product(x,y): #~ return x*y #~ op = product(2,3) #~ print(op) #~ def product(x,y): #~ print(x*y) #~ op = product(2,3) #~ print(op) def product(x,y): print("i am before return") return x*y print("i am after return") product(2,3)
def product(x, y): print('i am before return') return x * y print('i am after return') product(2, 3)
class Solution: def threeSum(self, nums: List[int]) -> List[List[int]]: # Solution: 2 pointer solution -> O(n*n) nums.sort() res = [] for i in range(len(nums)-2): if i > 0 and nums[i] == nums[i-1]: continue left, right = i+1, len(nums)-1 ...
class Solution: def three_sum(self, nums: List[int]) -> List[List[int]]: nums.sort() res = [] for i in range(len(nums) - 2): if i > 0 and nums[i] == nums[i - 1]: continue (left, right) = (i + 1, len(nums) - 1) while left < right: ...
l = int(input()) h = int(input()) t = str(input()) alphabet = [str(input()) for i in range(h)] for i in range(h): for char in t.lower(): if char >= 'a' and char <= 'z': x = ord(char) - ord('a') else: x = ord('z') - ord('a') + 1 print(alphabet[i][x*l : x*l+l], end='...
l = int(input()) h = int(input()) t = str(input()) alphabet = [str(input()) for i in range(h)] for i in range(h): for char in t.lower(): if char >= 'a' and char <= 'z': x = ord(char) - ord('a') else: x = ord('z') - ord('a') + 1 print(alphabet[i][x * l:x * l + l], end=...
def fahrenheit_converter(C): fahrenheit = C * 9 / 5 + 32 print(str(fahrenheit) + 'F') c2f = fahrenheit_converter(35) print(c2f)
def fahrenheit_converter(C): fahrenheit = C * 9 / 5 + 32 print(str(fahrenheit) + 'F') c2f = fahrenheit_converter(35) print(c2f)
n = int(input()) tr = [] for _ in range(n): tr.append(int(input())) front = rear = 1 front_max = tr[0] for i in range(1,len(tr)): if front_max < tr[i]: front += 1 front_max = tr[i] tr.reverse() rear_max = tr[0] for i in range(1,len(tr)): if rear_max < tr[i]: rear += 1 re...
n = int(input()) tr = [] for _ in range(n): tr.append(int(input())) front = rear = 1 front_max = tr[0] for i in range(1, len(tr)): if front_max < tr[i]: front += 1 front_max = tr[i] tr.reverse() rear_max = tr[0] for i in range(1, len(tr)): if rear_max < tr[i]: rear += 1 rear_...
f_name = '../results/result-1__rf_log.txt' f = open(f_name,"r") line_ext = list() for line in f: if 'Kappa : ' in line: kappa = 'KAPPA\t'+line.strip().split(' : ')[1] if 'Accuracy : ' in line and 'Balanced' not in line: accu = 'ACCURACY\t'+line.strip().split(' : ')[1] if 'Sensitivity : ' in...
f_name = '../results/result-1__rf_log.txt' f = open(f_name, 'r') line_ext = list() for line in f: if 'Kappa : ' in line: kappa = 'KAPPA\t' + line.strip().split(' : ')[1] if 'Accuracy : ' in line and 'Balanced' not in line: accu = 'ACCURACY\t' + line.strip().split(' : ')[1] if 'Sensitivity : ...
### stuff I don't need to make the cards def drawSquareGrid(dwg, widthInMillimeters): hLineGroup = dwg.add(dwg.g(id='hlines', stroke='green')) y = 0 while y < 100: hLineGroup.add(dwg.add(dwg.line( start = (0*mm, y*mm), end = (150*mm, y*mm)))) y += widthInMillimeters...
def draw_square_grid(dwg, widthInMillimeters): h_line_group = dwg.add(dwg.g(id='hlines', stroke='green')) y = 0 while y < 100: hLineGroup.add(dwg.add(dwg.line(start=(0 * mm, y * mm), end=(150 * mm, y * mm)))) y += widthInMillimeters v_line_group = dwg.add(dwg.g(id='vlines', stroke='blue'...
T = int(input()) for _ in range(T): n, k = map(int, input().split()) print((n ** k - 1) % 9 + 1)
t = int(input()) for _ in range(T): (n, k) = map(int, input().split()) print((n ** k - 1) % 9 + 1)
class maxheap: ''' implements max heap: ''' def __init__(self, maxsize): ''' initialize an empty max heap with a max size. ''' self.size = 0 self.maxsize = maxsize self.Heap = [0] * (self.maxsize + 1) self.root = 1 def parent(self, pos): ...
class Maxheap: """ implements max heap: """ def __init__(self, maxsize): """ initialize an empty max heap with a max size. """ self.size = 0 self.maxsize = maxsize self.Heap = [0] * (self.maxsize + 1) self.root = 1 def parent(self, pos):...
def closure(graph): n = len(graph) reachable = [[0 for _ in range(n)] for _ in range(n)] for i, v in enumerate(graph): for neighbor in v: reachable[i][neighbor] = 1 for k in range(n): for i in range(n): for j in range(n): reachable[i][...
def closure(graph): n = len(graph) reachable = [[0 for _ in range(n)] for _ in range(n)] for (i, v) in enumerate(graph): for neighbor in v: reachable[i][neighbor] = 1 for k in range(n): for i in range(n): for j in range(n): reachable[i][j] |= reach...
quant = int(input()) for c in range(quant): frase = input().split() for x in range(len(frase) - 1, 0, -1): for i in range(x): if len(frase[i]) < len(frase[i+1]): temp = frase[i] frase[i] = frase[i+1] frase[i+1] = temp resultado = ' '.join(f...
quant = int(input()) for c in range(quant): frase = input().split() for x in range(len(frase) - 1, 0, -1): for i in range(x): if len(frase[i]) < len(frase[i + 1]): temp = frase[i] frase[i] = frase[i + 1] frase[i + 1] = temp resultado = ' '....
class Solution: def twoSum(self, arr: List[int], target: int) -> List[int]: l = 0 r = len(arr) - 1 while l < r: total = arr[l] + arr[r] if total == target: return l + 1, r + 1 elif total < target: l += ...
class Solution: def two_sum(self, arr: List[int], target: int) -> List[int]: l = 0 r = len(arr) - 1 while l < r: total = arr[l] + arr[r] if total == target: return (l + 1, r + 1) elif total < target: l += 1 else...
'''' | cancer | Total symptom |No | Yes | no |99989 | 0 | 99989 yes |10 | 1 | 11 total |99999 | 1 | 100000 ''' def cal_bayes(prior_H, prob_E_given_H, prob_E): return prior_H * prob_E_given_H / prob_E if __name__ == '__main__': prior_H = 1 / 100000 # probability ...
"""' | cancer | Total symptom |No | Yes | no |99989 | 0 | 99989 yes |10 | 1 | 11 total |99999 | 1 | 100000 """ def cal_bayes(prior_H, prob_E_given_H, prob_E): return prior_H * prob_E_given_H / prob_E if __name__ == '__main__': prior_h = 1 / 100000 prob_not_h = 1...
METRICS_AGGREGATE_KEYS = [ 'sum', 'max', 'min' ] BUCKETS_AGGREGATE_KEYS = [ 'terms', 'date_histogram' ] BUCKETS_AGGREGATE_OPTIONALS = [ 'format', 'order', 'size', 'interval' ]
metrics_aggregate_keys = ['sum', 'max', 'min'] buckets_aggregate_keys = ['terms', 'date_histogram'] buckets_aggregate_optionals = ['format', 'order', 'size', 'interval']
def book_dto(book): try: if not book: return None return { 'id': str(book.pk), 'book_name': book.name, 'summary': book.summary if book.summary else "", 'author': book.author, 'book_genre': book.genre, 'barcode': book...
def book_dto(book): try: if not book: return None return {'id': str(book.pk), 'book_name': book.name, 'summary': book.summary if book.summary else '', 'author': book.author, 'book_genre': book.genre, 'barcode': book.barcode, 'created_at': str(book.created_at), 'created_by': book.created_...
count_dict, count, Last_item = {}, 0, None binario = str(bin(int(input()))) binary_list = [n for n in binario] for item in binary_list: if Last_item != item: Last_item = item count = 1 else: count += 1 if count > count_dict.get(item, 0): count_dict[item] = count print(coun...
(count_dict, count, last_item) = ({}, 0, None) binario = str(bin(int(input()))) binary_list = [n for n in binario] for item in binary_list: if Last_item != item: last_item = item count = 1 else: count += 1 if count > count_dict.get(item, 0): count_dict[item] = count print(cou...
class Sample(object): def func_0(self): return '0' def func_1(self, arg1): return arg1 def func_2(self, arg1, arg2): return arg1 + arg2 s = Sample() result = s.func_0() print(result) result = s.func_1('test1') print(result) result = s.func_2('test1', 'test2') print(result) fu...
class Sample(object): def func_0(self): return '0' def func_1(self, arg1): return arg1 def func_2(self, arg1, arg2): return arg1 + arg2 s = sample() result = s.func_0() print(result) result = s.func_1('test1') print(result) result = s.func_2('test1', 'test2') print(result) func = ...
# 647. Palindromic Substrings # Runtime: 128 ms, faster than 79.15% of Python3 online submissions for Palindromic Substrings. # Memory Usage: 14.1 MB, less than 85.33% of Python3 online submissions for Palindromic Substrings. class Solution: # Expand Around Possible Centers def countSubstrings(self, s: str)...
class Solution: def count_substrings(self, s: str) -> int: count = 0 def expand_around_center(left: int, right: int) -> None: nonlocal count while left >= 0 and right < len(s): if s[left] != s[right]: break else: ...
def test_submit_retrieve(client) -> None: headers = { 'Content-Type': 'text/plain' } urls = { 'https://www.wikipedia.org/': '48VIcsBN5UX', 'https://www.google.com/': '48VIcsBN5UY', 'https://www.stackoverflow.com/': '48VIcsBN5UZ', 'https://www.youtube.com/watch?v=dQw4...
def test_submit_retrieve(client) -> None: headers = {'Content-Type': 'text/plain'} urls = {'https://www.wikipedia.org/': '48VIcsBN5UX', 'https://www.google.com/': '48VIcsBN5UY', 'https://www.stackoverflow.com/': '48VIcsBN5UZ', 'https://www.youtube.com/watch?v=dQw4w9WgXcQ': '48VIcsBN5Ua'} for key in urls: ...
list1 = [ 9, 2, 8, 4, 0, 1, 34 ] # insert 45 at 5th index list1.insert(4, 45) print(list1) list2 = ['q', 'b', 'u', 'h', 'p'] # insert z at the front of the list list2.insert(0, 'z') print(list2)
list1 = [9, 2, 8, 4, 0, 1, 34] list1.insert(4, 45) print(list1) list2 = ['q', 'b', 'u', 'h', 'p'] list2.insert(0, 'z') print(list2)
# Implement regular expression matching with the following special characters: # . (period) which matches any single character # * (asterisk) which matches zero or more of the preceding element # That is, implement a function that takes in a string and a valid regular # expression and returns whether or not the string...
def check_regex(re, string): bool_mat = [[False] * (len(re) + 1) for i in range(len(string) + 1)] boolMat[0][0] = True for i in range(0, len(string) + 1): for j in range(1, len(re) + 1): if re[j - 1] == '*': boolMat[i][j] = boolMat[i][j - 2] or (i > 0 and j > 1 and (re[j ...
# # PySNMP MIB module SCA-FREXT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SCA-FREXT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:52:53 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 201...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_range_constraint, single_value_constraint, value_size_constraint, constraints_union) ...
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def allPossibleFBT(self, N: int) -> List[TreeNode]: if N % 2 == 0: return [] dp = [[] for i ...
class Solution: def all_possible_fbt(self, N: int) -> List[TreeNode]: if N % 2 == 0: return [] dp = [[] for i in range(N + 1)] dp[1] = [tree_node(0)] for i in range(3, N + 1, 2): for j in range(1, i, 2): k = i - j - 1 for l in ...
ALPHABET = 'abcdefghijklmnopqrstuvwxyz' t = int(input()) allResult = '' for k in range(t): input() string = input() result = 'a' while string.find(result) != -1: if result[len(result) - 1] != 'z': result = result[:-1] + ALPHABET[ord(result[-1]) - 96] else: if result[0] == ALPHABET[25]: temp = '' f...
alphabet = 'abcdefghijklmnopqrstuvwxyz' t = int(input()) all_result = '' for k in range(t): input() string = input() result = 'a' while string.find(result) != -1: if result[len(result) - 1] != 'z': result = result[:-1] + ALPHABET[ord(result[-1]) - 96] elif result[0] == ALPHAB...
# n = int(input()) # res = [[10 ** 9 for j in range(n)] for _ in range(n)] # res[0][0] = 0 # scores = [] # for _ in range(n): # scores.append(list(map(int, input().split()))) # direcs = [(0, 1), (0, -1), (-1, 0), (1, 0)] # d4_scores = [[[] for _ in range(n)] for _ in range(n)] # for i in range(n): # for j in range(n)...
(n, m, k) = list(map(int, input().split())) gifts = [] for _ in range(n): gifts.append(list(map(int, input().split()))) gifts.sort(key=lambda x: [x[2], x[0], x[1]]) res = 0 i = 0 while i < n: (p, w, _) = gifts[i] i += 1 if k >= p and m >= w: res += 1 k -= p m -= w print(res)
for v in graph.getVertices(): print(v.value.rank)
for v in graph.getVertices(): print(v.value.rank)
class Solution: def coinChange(self, coins: 'List[int]', amount: int) -> int: coins.sort(reverse=True) impossible = (amount + 1) * 2 dp = [impossible] * (amount + 1) dp[0] = 0 for current in range(amount + 1): for coin in coins: if curren...
class Solution: def coin_change(self, coins: 'List[int]', amount: int) -> int: coins.sort(reverse=True) impossible = (amount + 1) * 2 dp = [impossible] * (amount + 1) dp[0] = 0 for current in range(amount + 1): for coin in coins: if current + coin...
EXAMPLES1 = ( ('04-exemple1.txt', 4512), ) EXAMPLES2 = ( ('04-exemple1.txt', 1924), ) INPUT = '04.txt' def read_data(fn): with open(fn) as f: numbers = [int(s) for s in f.readline().strip().split(',')] boards = list() board = None for line in f: ...
examples1 = (('04-exemple1.txt', 4512),) examples2 = (('04-exemple1.txt', 1924),) input = '04.txt' def read_data(fn): with open(fn) as f: numbers = [int(s) for s in f.readline().strip().split(',')] boards = list() board = None for line in f: if not line.strip(): ...
#!/usr/bin/python # # AbstractPatching is the base patching class of all the linux distros # # Copyright 2014 Microsoft Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # htt...
class Configoptions(object): disabled = ['true', 'false'] stop = ['true', 'false'] reboot_after_patch = ['rebootifneed', 'auto', 'required', 'notrequired'] category = {'required': 'important', 'all': 'importantandrecommended'} oneoff = ['true', 'false'] interval_of_weeks = [str(i) for i in range...
# # PySNMP MIB module RBN-SMS1000-ENVMON-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RBN-SMS1000-ENVMON-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:53:21 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (d...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, constraints_union, value_size_constraint, constraints_intersection, value_range_constraint) ...
''' Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1->2 Output: false Example 2: Input: 1->2->2->1 Output: true ''' # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def isPalindro...
""" Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1->2 Output: false Example 2: Input: 1->2->2->1 Output: true """ class Solution: def is_palindrome(self, head: ListNode) -> bool: """ Find the middle of the linked list and reverse the half of the linked ...
with open("sample.txt", 'a') as jabber: for i in range(1,13): for j in range(1,13): print(f"{j:>2} times {i:2} is {i*j:<}", file=jabber) print("-"*20, file=jabber)
with open('sample.txt', 'a') as jabber: for i in range(1, 13): for j in range(1, 13): print(f'{j:>2} times {i:2} is {i * j:<}', file=jabber) print('-' * 20, file=jabber)
class SocketManager(object): def __init__(self): self.ws = set() def add_socket(self, ws): self.ws.add(ws) def remove_sockets(self, disconnected_ws): if not isinstance(disconnected_ws, set): disconnected_ws = {disconnected_ws, } self.ws -= disconnected_ws
class Socketmanager(object): def __init__(self): self.ws = set() def add_socket(self, ws): self.ws.add(ws) def remove_sockets(self, disconnected_ws): if not isinstance(disconnected_ws, set): disconnected_ws = {disconnected_ws} self.ws -= disconnected_ws
# This class handles exceptions. All exceptions raised will be passed through the API to the client class DebugException(Exception): exception_dict = { 101: "Don't be naughty, type something with meaning >.<", # "Invalid input, please check your sentence", 301: "Keyword not found in Database", ...
class Debugexception(Exception): exception_dict = {101: "Don't be naughty, type something with meaning >.<", 301: 'Keyword not found in Database', 302: 'Invalid Synonym Level. Level must be integer between 1 and 3', 303: 'No Synonym Link found', 304: 'Invalid base word', 305: 'Relationship already exists', 306: 'Re...
class MockFeeEstOne(): @property def status_code(self): return 200 def json(self): return {"fastestFee": 200, "halfHourFee": 200, "hourFee": 100} class TestDataOne(): @property def path(self): return 'tests/test_files' @property def pub_key_file_name(self): ...
class Mockfeeestone: @property def status_code(self): return 200 def json(self): return {'fastestFee': 200, 'halfHourFee': 200, 'hourFee': 100} class Testdataone: @property def path(self): return 'tests/test_files' @property def pub_key_file_name(self): r...
# <auto-generated> # This code was generated by the UnitCodeGenerator tool # # Changes to this file will be lost if the code is regenerated # </auto-generated> def to_milligrams(value): return value * 28349.5231 def to_grams(value): return value * 28.3495231 def to_kilograms(value): return value / 35.274 def to_...
def to_milligrams(value): return value * 28349.5231 def to_grams(value): return value * 28.3495231 def to_kilograms(value): return value / 35.274 def to_tonnes(value): return value * 2.83495231e-05 def to_pounds(value): return value * 0.0625 def to_stones(value): return value / 224.0 def t...
S1 = "Hello World" print("Length of the String is", len(S1)) # To find the length of a String List1 = ["Emon", "Bakkar", "Ehassan", "Anik", "Ahad", "Sibbir"] print("After join the list:", ", ".join(List1)) # To join the String S2 = "Hey this is Emon" List2 = S2.split() print("After Split the String:{}".format(List2...
s1 = 'Hello World' print('Length of the String is', len(S1)) list1 = ['Emon', 'Bakkar', 'Ehassan', 'Anik', 'Ahad', 'Sibbir'] print('After join the list:', ', '.join(List1)) s2 = 'Hey this is Emon' list2 = S2.split() print('After Split the String:{}'.format(List2)) s3 = 'Welcome to Python Programming' print('After repla...
list = ['iam vengeance'] list1 = [] for k in list: list1.append(k.title()) print(list1)
list = ['iam vengeance'] list1 = [] for k in list: list1.append(k.title()) print(list1)
def func_kwargs(**kwargs): print('kwargs: ', kwargs) print('type: ', type(kwargs)) func_kwargs(key1=1, key2=2, key3=3) # kwargs: {'key1': 1, 'key2': 2, 'key3': 3} # type: <class 'dict'> def func_kwargs_positional(arg1, arg2, **kwargs): print('arg1: ', arg1) print('arg2: ', arg2) print('kwargs: '...
def func_kwargs(**kwargs): print('kwargs: ', kwargs) print('type: ', type(kwargs)) func_kwargs(key1=1, key2=2, key3=3) def func_kwargs_positional(arg1, arg2, **kwargs): print('arg1: ', arg1) print('arg2: ', arg2) print('kwargs: ', kwargs) func_kwargs_positional(0, 1, key1=1) d = {'key1': 1, 'key2':...
class DestinyPyError(Exception): ... class APIError(DestinyPyError): ... class InvalidJSONResponse(APIError): ... class APIResponseError(APIError): def __init__(self, errorCode: int) -> None: super().__init__(f'API returned an error code {errorCode}') self.errorCode = errorCode c...
class Destinypyerror(Exception): ... class Apierror(DestinyPyError): ... class Invalidjsonresponse(APIError): ... class Apiresponseerror(APIError): def __init__(self, errorCode: int) -> None: super().__init__(f'API returned an error code {errorCode}') self.errorCode = errorCode clas...
# -*- coding: utf-8 -*- def fibonacci(ene): a = 0 b = 1 contador = 1 fibo = 0 while contador < ene: fibo = b + a a = b b = fibo contador += 1 return fibo print('fibonacci(5) = ' + str(fibonacci(5))) print('fibonacci(10) = ' + str(fibonacci(10))) print('fibonac...
def fibonacci(ene): a = 0 b = 1 contador = 1 fibo = 0 while contador < ene: fibo = b + a a = b b = fibo contador += 1 return fibo print('fibonacci(5) = ' + str(fibonacci(5))) print('fibonacci(10) = ' + str(fibonacci(10))) print('fibonacci(20) = ' + str(fibonacci(2...
# model settings _base_ = "swin_tiny_my_MM_supervised.py" model = dict(type="Recognizer3DJoint", backbone=dict(generative=True, discriminative=True), cls_head=dict(type='JointHead'))
_base_ = 'swin_tiny_my_MM_supervised.py' model = dict(type='Recognizer3DJoint', backbone=dict(generative=True, discriminative=True), cls_head=dict(type='JointHead'))
''' Given three arrays sorted in increasing order. Find the elements that are common in all three arrays. Input: A = {1, 5, 10, 20, 40, 80} B = {6, 7, 20, 80, 100} C = {3, 4, 15, 20, 30, 70, 80, 120} Output: [20, 80] Explanation: 20 and 80 are the only common elements in A, B and C. ''' def common_elements(arr1,ar...
""" Given three arrays sorted in increasing order. Find the elements that are common in all three arrays. Input: A = {1, 5, 10, 20, 40, 80} B = {6, 7, 20, 80, 100} C = {3, 4, 15, 20, 30, 70, 80, 120} Output: [20, 80] Explanation: 20 and 80 are the only common elements in A, B and C. """ def common_elements(arr1, a...