content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
"Twilio backend for the RapidSMS project." __version__ = '1.0.1'
"""Twilio backend for the RapidSMS project.""" __version__ = '1.0.1'
class Trie(object): '''The main Trie object.''' def __init__(self, words): '''Takes the text given and creates a Trie.''' self.root = Node(None, '') self.words = words self.build(words) def build(self, text): '''Encapsulates all of the preprocessing build logic.''' ...
class Trie(object): """The main Trie object.""" def __init__(self, words): """Takes the text given and creates a Trie.""" self.root = node(None, '') self.words = words self.build(words) def build(self, text): """Encapsulates all of the preprocessing build logic.""" ...
a,b=map(int,input().split()) c,d=map(int,input().split()) e,f=map(int,input().split()) if (a-c)*(d-f)==(b-d)*(c-e): print('WHERE IS MY CHICKEN?') else: print('WINNER WINNER CHICKEN DINNER!')
(a, b) = map(int, input().split()) (c, d) = map(int, input().split()) (e, f) = map(int, input().split()) if (a - c) * (d - f) == (b - d) * (c - e): print('WHERE IS MY CHICKEN?') else: print('WINNER WINNER CHICKEN DINNER!')
def info(): name = input("Enter Your Name : ") fname = input("Enter Your Father Name : ") mname = input("Enter Your Mother Name : ") while True: try: age = int(input("\033[0m Enter your age: ")) break except Exception as e: print("\033[31m invalid age\nplease try again ") cont...
def info(): name = input('Enter Your Name : ') fname = input('Enter Your Father Name : ') mname = input('Enter Your Mother Name : ') while True: try: age = int(input('\x1b[0m Enter your age: ')) break except Exception as e: print('\x1b[31m invalid age\...
# Personal Greeter # Demonstrates getting user input name = input("Hi. What's your name? ") print(name) print("Hi,", name) input("\n\nPress the enter key to exit.")
name = input("Hi. What's your name? ") print(name) print('Hi,', name) input('\n\nPress the enter key to exit.')
def plusOne(arr): result = int("".join([str(each) for each in arr])) + 1 result = str(result) return list(result) # if want = result[-1] = digits[-1] + 1: # l = digits[-1] # digits.pop() # l = l + 1 # digits.append(l) # return digits if __name__ == "__main__":...
def plus_one(arr): result = int(''.join([str(each) for each in arr])) + 1 result = str(result) return list(result) if __name__ == '__main__': arr = [1, 2, 4, 5, 6] print(plus_one(arr))
def approve_new_user(sender, instance, created, *args, **kwarg): if created: instance.is_staff = True instance.is_superuser = True instance.save()
def approve_new_user(sender, instance, created, *args, **kwarg): if created: instance.is_staff = True instance.is_superuser = True instance.save()
def pylist_to_listnode(self, pylist, link_count): if len(pylist) > 1: ret = precompiled.listnode.ListNode(pylist.pop()) ret.next = self.pylist_to_listnode(pylist, link_count) return ret else: return precompiled.listnode.ListNode(pylist.pop(), None) def XXX(self, l1: ListNode, l2...
def pylist_to_listnode(self, pylist, link_count): if len(pylist) > 1: ret = precompiled.listnode.ListNode(pylist.pop()) ret.next = self.pylist_to_listnode(pylist, link_count) return ret else: return precompiled.listnode.ListNode(pylist.pop(), None) def xxx(self, l1: ListNode, l2...
def fill_tile(n): if n == 0 or n == 1 or n == 2: return 1 return fill_tile(n-1) + fill_tile(n-2) + fill_tile(n-3) print(fill_tile(8))
def fill_tile(n): if n == 0 or n == 1 or n == 2: return 1 return fill_tile(n - 1) + fill_tile(n - 2) + fill_tile(n - 3) print(fill_tile(8))
#Following are the operators supported # + Addition # - Subration # * Multiplication # / Division # % Modulus # // Integer Division # ** Exponential # #If any of operand is float the result is float print(3+2) #prints 5 print(3-2) #prints 1 print(3*2) #prints 6 print(2.5+2) #Prints 4.5 (float) #In division resu...
print(3 + 2) print(3 - 2) print(3 * 2) print(2.5 + 2) print(10 / 2) print(5 % 2) print(14.75 % 4) print(3.5 ** 2) print(3 ** 3) print(10.5 // 2) print(-5 // 2) print('2' + '3') print('abc' + str(2 + 3)) print(3 * 'Hello') print(3 * True) e = 2 + 3j f = 4 - 6j print(e + f) print(e * f) print(e - f)
num = 0 total = 0 while True: number = input("Enter a number: ") if number == "done": break try: numb = float(number) except: print("invalid input") continue num = num + 1 total = total + numb print(int(total), num, total/num)
num = 0 total = 0 while True: number = input('Enter a number: ') if number == 'done': break try: numb = float(number) except: print('invalid input') continue num = num + 1 total = total + numb print(int(total), num, total / num)
child_network_params = { "learning_rate": 3e-5, "max_epochs": 100, "beta": 1e-3, "batch_size": 20 } controller_params = { "max_layers": 3, "components_per_layer": 4, 'beta': 1e-4, 'max_episodes': 2000, "num_children_per_episode": 10 }
child_network_params = {'learning_rate': 3e-05, 'max_epochs': 100, 'beta': 0.001, 'batch_size': 20} controller_params = {'max_layers': 3, 'components_per_layer': 4, 'beta': 0.0001, 'max_episodes': 2000, 'num_children_per_episode': 10}
# WAP that takes some text and returns a list of all characters # in the text which are not vowels, sorted in alphabetical order. # You can either enter the text from the keyboard or # initialize a string variable with the string # soln get the set and subtract the set from the vowels set # text = set(input().lower()...
for i in set(input().upper()) - frozenset('AEIOU'): print(i)
SEED = 1 TOPIC_POKEMONS = 'pokemons' TOPIC_USERS = 'users' GROUP_DASHBOARD = 'dashboard' GROUP_LOGIN_CHECKER = 'checker' DATA = 'data/pokemon.csv' COORDINATES = { 'GAUSS_LAT_MADRID': {'mu': 40.45, 'sigma': 0.2}, 'GAUSS_LON_MADRID': {'mu': -3.60, 'sigma': 0.4}, 'GAUSS_LAT_SEGOVIA': {'mu': 40.95, 'sigma': ...
seed = 1 topic_pokemons = 'pokemons' topic_users = 'users' group_dashboard = 'dashboard' group_login_checker = 'checker' data = 'data/pokemon.csv' coordinates = {'GAUSS_LAT_MADRID': {'mu': 40.45, 'sigma': 0.2}, 'GAUSS_LON_MADRID': {'mu': -3.6, 'sigma': 0.4}, 'GAUSS_LAT_SEGOVIA': {'mu': 40.95, 'sigma': 0.1}, 'GAUSS_LON_...
def factorial(n): if n == 1: return n else: return n*factorial(n-1) number = int(input("Enter a number: ")) if number < 0: print("Sorry, factorial does not exist for negative numbers") elif number == 0: print("The factorial of 0 is 1") els...
def factorial(n): if n == 1: return n else: return n * factorial(n - 1) number = int(input('Enter a number: ')) if number < 0: print('Sorry, factorial does not exist for negative numbers') elif number == 0: print('The factorial of 0 is 1') else: print('The factorial of', number, 'is'...
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"nothing_here": "00_core.ipynb", "expand_hyphen": "notation.ipynb", "del_dot": "notation.ipynb", "del_zero": "notation.ipynb", "get_unique": "notation.ipynb", "exp...
__all__ = ['index', 'modules', 'custom_doc_links', 'git_url'] index = {'nothing_here': '00_core.ipynb', 'expand_hyphen': 'notation.ipynb', 'del_dot': 'notation.ipynb', 'del_zero': 'notation.ipynb', 'get_unique': 'notation.ipynb', 'expand_star': 'notation.ipynb', 'expand_colon': 'notation.ipynb', 'expand_regex': 'notati...
def cumulative(list_of_numbers): cumulative_sum = 0 new_list = [] for i in list_of_numbers: cumulative_sum += i new_list.append(cumulative_sum) return new_list list = [1,2,3,4,5,6,7,8,9] print(cumulative(list))
def cumulative(list_of_numbers): cumulative_sum = 0 new_list = [] for i in list_of_numbers: cumulative_sum += i new_list.append(cumulative_sum) return new_list list = [1, 2, 3, 4, 5, 6, 7, 8, 9] print(cumulative(list))
PACKAGES = { "ctypes": ["0.17.1", ["ctypes.foreign"]], "ctypes-foreign": ["0.4.0"], # WARNING: requires libffi-dev } opam = struct( version = "2.0", switches = { "mina-0.1.0": struct( default = True, compiler = "4.07.1", packages = PACKAGES ), ...
packages = {'ctypes': ['0.17.1', ['ctypes.foreign']], 'ctypes-foreign': ['0.4.0']} opam = struct(version='2.0', switches={'mina-0.1.0': struct(default=True, compiler='4.07.1', packages=PACKAGES), '4.07.1': struct(compiler='4.07.1', packages=PACKAGES)})
labels={} def lex(filecontents): filecontents=list(filecontents) tokens=[] #Implementations left# #Stack keywords #Rotate #16 bit operations #JUMP operations keywords=["STA","MVI","MOV","LDA","ADD","ADC","ADI","ACI","SUB","SUI","SBB","SBI","INR","DCR","CMP", "CPI","ANA","ANI","XRA","XRI","ORA","OR...
labels = {} def lex(filecontents): filecontents = list(filecontents) tokens = [] keywords = ['STA', 'MVI', 'MOV', 'LDA', 'ADD', 'ADC', 'ADI', 'ACI', 'SUB', 'SUI', 'SBB', 'SBI', 'INR', 'DCR', 'CMP', 'CPI', 'ANA', 'ANI', 'XRA', 'XRI', 'ORA', 'ORI', 'JMP', 'JNZ', 'JZ', 'JC', 'JNC'] next_state = {'STA': 1,...
_base_ = './cascade_rcnn_r101_fpn_1x.py' model = dict( pretrained='open-mmlab://msra/hrnetv2_w40', backbone=dict( _delete_=True, type='HRNet', extra=dict( stage1=dict( num_modules=1, num_branches=1, block='BOTTLENECK', ...
_base_ = './cascade_rcnn_r101_fpn_1x.py' model = dict(pretrained='open-mmlab://msra/hrnetv2_w40', backbone=dict(_delete_=True, type='HRNet', extra=dict(stage1=dict(num_modules=1, num_branches=1, block='BOTTLENECK', num_blocks=(4,), num_channels=(64,)), stage2=dict(num_modules=1, num_branches=2, block='BASIC', num_block...
def collectUntil(enoughGold): while hero.gold < enoughGold: item = hero.findNearestItem() if item: hero.moveXY(item.pos.x, item.pos.y) collectUntil(25) hero.buildXY("decoy", 40, 52) hero.moveXY(20, 52) collectUntil(50) hero.buildXY("decoy", 68, 22) hero.buildXY("decoy", 3...
def collect_until(enoughGold): while hero.gold < enoughGold: item = hero.findNearestItem() if item: hero.moveXY(item.pos.x, item.pos.y) collect_until(25) hero.buildXY('decoy', 40, 52) hero.moveXY(20, 52) collect_until(50) hero.buildXY('decoy', 68, 22) hero.buildXY('decoy', 30, 20)
def howmanyfingersdoihave(): ear.pauseListening() sleep(1) fullspeed() i01.moveHead(49,74) i01.moveArm("left",75,83,79,24) i01.moveArm("right",65,82,71,24) i01.moveHand("left",74,140,150,157,168,92) i01.moveHand("right",89,80,98,120,114,0) sleep(2) i01.moveHand("right",...
def howmanyfingersdoihave(): ear.pauseListening() sleep(1) fullspeed() i01.moveHead(49, 74) i01.moveArm('left', 75, 83, 79, 24) i01.moveArm('right', 65, 82, 71, 24) i01.moveHand('left', 74, 140, 150, 157, 168, 92) i01.moveHand('right', 89, 80, 98, 120, 114, 0) sleep(2) i01.moveHa...
create_favorite_query = ''' mutation {{ createFavorite ( title: "{title}", description: "{description}", category: "{category}", ranking: {ranking} ) {{ message errors favorite {{ id title }} }} }} ''' update_favorite_query = ''' mutation {{ updateFavorite ( id: ...
create_favorite_query = '\nmutation {{\n createFavorite (\n title: "{title}",\n description: "{description}",\n category: "{category}",\n ranking: {ranking}\n ) {{\n message\n errors\n favorite {{\n id\n title\n }}\n }}\n}}\n' update_favorite_query = '\nmutation {{\n updateFavorite...
# calculator print(1+2) print(3) print(10%2) print(11%2)
print(1 + 2) print(3) print(10 % 2) print(11 % 2)
# This script is used to format multiple en-ro translation datasets into the following format: # {english sequence}{TAB character}{romanian sequence} # \\\\\\\\\\\\\\\\\\\\\\\\\\\\\ # corpus # \\\\\\\\\\\\\\\\\\\\\\\\\\\\\ # import xml.etree.ElementTree as ET # # DATASET_CORPUS = "S:\\datasets\\eng-ron_corp...
dataset_path = 'S:\\processed\\dataset_all.txt' with open(DATASET_PATH, encoding='utf-8') as file: for (i, line) in enumerate(file): if line.count('\t') != 1: raise value_error(f'Only one TAB character must be in a single line.({i + 1})')
___assertEqual(float(False), 0.0) ___assertIsNot(float(False), False) ___assertEqual(float(True), 1.0) ___assertIsNot(float(True), True)
___assert_equal(float(False), 0.0) ___assert_is_not(float(False), False) ___assert_equal(float(True), 1.0) ___assert_is_not(float(True), True)
expected_output = { "aal5VccEntry": {"3": {}, "4": {}, "5": {}}, "aarpEntry": {"1": {}, "2": {}, "3": {}}, "adslAtucChanConfFastMaxTxRate": {}, "adslAtucChanConfFastMinTxRate": {}, "adslAtucChanConfInterleaveMaxTxRate": {}, "adslAtucChanConfInterleaveMinTxRate": {}, "adslAtucChanConfMaxInter...
expected_output = {'aal5VccEntry': {'3': {}, '4': {}, '5': {}}, 'aarpEntry': {'1': {}, '2': {}, '3': {}}, 'adslAtucChanConfFastMaxTxRate': {}, 'adslAtucChanConfFastMinTxRate': {}, 'adslAtucChanConfInterleaveMaxTxRate': {}, 'adslAtucChanConfInterleaveMinTxRate': {}, 'adslAtucChanConfMaxInterleaveDelay': {}, 'adslAtucCha...
def int_input(msg): inp = raw_input(msg) try: inp = int(inp) if inp <= 0: print("Please enter a non-negative number") return int_input(msg) else: return inp except: print("Please enter a valid non-decimal number") return int_input(msg) def run(): global starting_hand ...
def int_input(msg): inp = raw_input(msg) try: inp = int(inp) if inp <= 0: print('Please enter a non-negative number') return int_input(msg) else: return inp except: print('Please enter a valid non-decimal number') return int_input(m...
class Solution: # @param triangle, a list of lists of integers # @return an integer def minimumTotal(self, triangle): n = len(triangle) dp = triangle[-1] for i in xrange(n-2, -1, -1): for j in xrange(i+1): dp[j] = triangle[i][j] + min(dp[j], dp[j+1]) ...
class Solution: def minimum_total(self, triangle): n = len(triangle) dp = triangle[-1] for i in xrange(n - 2, -1, -1): for j in xrange(i + 1): dp[j] = triangle[i][j] + min(dp[j], dp[j + 1]) return dp[0]
class Node: def __init__(self, value): self.value = value self.left = None self.right = None def insert(root, node): if root is None: root = node return root if node.value < root.value: root.left = insert(root.left, node) else: root.right = inser...
class Node: def __init__(self, value): self.value = value self.left = None self.right = None def insert(root, node): if root is None: root = node return root if node.value < root.value: root.left = insert(root.left, node) else: root.right = inser...
class Solution: # @return an integer def reverse(self, x): int_max = 2147483647 limit = int_max/10 if x > 0: sig = 1 elif x < 0: sig = -1 x = -x else: return x y = 0 while x: if y > limit: ...
class Solution: def reverse(self, x): int_max = 2147483647 limit = int_max / 10 if x > 0: sig = 1 elif x < 0: sig = -1 x = -x else: return x y = 0 while x: if y > limit: return 0 ...
def print_headers(): headers = [ "V_energyF_Electricity_001,", "V_Costs_Transport_USGC-NEA_NaturalGas_001,", "V_Costs_MediumPressureSteam_001,", "V_Costs_CoolingWater_001,", "V_massF_BiodieselOutput_001,", "V_Costs_Transport_SG-SC_Methanol_001,", "V_Price_Storage_NaturalGas_001,", "V_Price_CoolingWater_001,...
def print_headers(): headers = ['V_energyF_Electricity_001,', 'V_Costs_Transport_USGC-NEA_NaturalGas_001,', 'V_Costs_MediumPressureSteam_001,', 'V_Costs_CoolingWater_001,', 'V_massF_BiodieselOutput_001,', 'V_Costs_Transport_SG-SC_Methanol_001,', 'V_Price_Storage_NaturalGas_001,', 'V_Price_CoolingWater_001,', 'V_Pri...
first_day = 500 #accounts deleted pair_user = 50 #hrn odd_user = 40 #hrn profit = 500 #hrn pair_users = 250 * pair_user #hrn odd_users = 250 * odd_user #hrn total_loss_of_deleted_users = pair_users + odd_users total_loss = profit - total_loss_of_deleted_users print("total loss:" ,total_loss)
first_day = 500 pair_user = 50 odd_user = 40 profit = 500 pair_users = 250 * pair_user odd_users = 250 * odd_user total_loss_of_deleted_users = pair_users + odd_users total_loss = profit - total_loss_of_deleted_users print('total loss:', total_loss)
i = 3 shit_indicator = 0 simple_nums = [2] while len(simple_nums) < 10001: for k in range(2, i): if i % k == 0: shit_indicator = 1 break if shit_indicator == 1: pass else: simple_nums.append(i) i += 1 shit_indicator = 0 print(simple_nums[...
i = 3 shit_indicator = 0 simple_nums = [2] while len(simple_nums) < 10001: for k in range(2, i): if i % k == 0: shit_indicator = 1 break if shit_indicator == 1: pass else: simple_nums.append(i) i += 1 shit_indicator = 0 print(simple_nums[-1])
OPTIONS = { 'start': '2018-01' # start of the planning horizon , 'num_period': 90 # size of the planning horizon # simulation params: , 'simulation': { 'num_resources': 15 # this depends on the number of tasks actually , 'num_parallel_tasks': 1 # number of parallel missions ,...
options = {'start': '2018-01', 'num_period': 90, 'simulation': {'num_resources': 15, 'num_parallel_tasks': 1, 'maint_duration': 6, 'max_used_time': 1000, 'max_elapsed_time': 60, 'elapsed_time_size': 15, 'min_usage_period': 0, 'perc_capacity': 0.15, 'min_avail_percent': 0.1, 'min_avail_value': 1, 'min_hours_perc': 0.5, ...
class Solution: def XXX(self, digits: List[int]) -> List[int]: ans = collections.deque() c = 1 for n in reversed(digits): c, t = divmod(n + c, 10) ans.appendleft(t) if c > 0: ans.appendleft(c) return list(ans)
class Solution: def xxx(self, digits: List[int]) -> List[int]: ans = collections.deque() c = 1 for n in reversed(digits): (c, t) = divmod(n + c, 10) ans.appendleft(t) if c > 0: ans.appendleft(c) return list(ans)
n = int(input()) values = [int(input()) for _ in range(n)] for value in values: msg = 'ODD ' if value % 2 == 0: msg = 'EVEN ' if value < 0: msg = msg + 'NEGATIVE' elif value > 0: msg = msg + 'POSITIVE' else: msg = 'NULL' print(msg)
n = int(input()) values = [int(input()) for _ in range(n)] for value in values: msg = 'ODD ' if value % 2 == 0: msg = 'EVEN ' if value < 0: msg = msg + 'NEGATIVE' elif value > 0: msg = msg + 'POSITIVE' else: msg = 'NULL' print(msg)
# # PySNMP MIB module DOCS-SUBMGT3-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DOCS-SUBMGT3-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:45:55 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar ...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, value_range_constraint, constraints_union, constraints_intersection, single_value_constraint) ...
''' Kattis - beatspread Very easy math problem. Time: O(1), Space: O(1) ''' num_tc = int(input()) for i in range(num_tc): a, b = map(int, input().split()) l = (a+b)//2 s = (a-b)//2 if (a+b)%2 == 1 or s < 0: print(f"impossible") else: print(f"{l} {s}")
""" Kattis - beatspread Very easy math problem. Time: O(1), Space: O(1) """ num_tc = int(input()) for i in range(num_tc): (a, b) = map(int, input().split()) l = (a + b) // 2 s = (a - b) // 2 if (a + b) % 2 == 1 or s < 0: print(f'impossible') else: print(f'{l} {s}')
class Node: '''each node represents a different dog or cat object They each have a name, a type (cat or dog), and a reference to the next animal in the shelter queue ''' def __init__(self, animal_type, next_node=None): self.animal_type = animal_type self.next = next_node class Inva...
class Node: """each node represents a different dog or cat object They each have a name, a type (cat or dog), and a reference to the next animal in the shelter queue """ def __init__(self, animal_type, next_node=None): self.animal_type = animal_type self.next = next_node class Inva...
target_x = range(211, 233) target_y = range(-124, -68) # part 1 and 2 x_hits = [] infinite_x_hits = [] for vx in range(1, target_x.stop): pos = 0 i = 0 while pos < target_x.stop and vx > i: pos += vx - i i += 1 if pos in target_x: x_hits.append((vx, i)) if vx == i a...
target_x = range(211, 233) target_y = range(-124, -68) x_hits = [] infinite_x_hits = [] for vx in range(1, target_x.stop): pos = 0 i = 0 while pos < target_x.stop and vx > i: pos += vx - i i += 1 if pos in target_x: x_hits.append((vx, i)) if vx == i and pos in target_...
n = 0 factor = 20 while True: n = n + factor is_divisible = True for i in range(1, factor + 1): if n % i != 0: is_divisible = False break if (is_divisible): break print(n)
n = 0 factor = 20 while True: n = n + factor is_divisible = True for i in range(1, factor + 1): if n % i != 0: is_divisible = False break if is_divisible: break print(n)
line = input().split(" ") n = int(line[0]) # nodes m = int(line[1]) # edges graph = {} def find_lowest_cost_node(costs, processed): lowest_cost_node = None lowest_cost = float("inf") for node, cost in costs.items(): if cost < lowest_cost and node not in processed: lowest_cost_node = ...
line = input().split(' ') n = int(line[0]) m = int(line[1]) graph = {} def find_lowest_cost_node(costs, processed): lowest_cost_node = None lowest_cost = float('inf') for (node, cost) in costs.items(): if cost < lowest_cost and node not in processed: lowest_cost_node = node ...
class Solution: # @param {string} s # @return {integer} def lengthOfLongestSubstring(self, s): n = len(s) if n <=1: return n start = 0 max_count = 1 c_dict = {s[0]:0} for p in range(1,n): sub = s[start:p] c = s[p] ...
class Solution: def length_of_longest_substring(self, s): n = len(s) if n <= 1: return n start = 0 max_count = 1 c_dict = {s[0]: 0} for p in range(1, n): sub = s[start:p] c = s[p] if c in sub: start = c_...
broj = -1 while broj != 0: print("Trenutni broj je " + str(broj)) broj = int(intpu("Unesite novi broj: ")) print("Kraj")
broj = -1 while broj != 0: print('Trenutni broj je ' + str(broj)) broj = int(intpu('Unesite novi broj: ')) print('Kraj')
name="Ashwin" def student(): print("Name",name) #accessing in def also student() if name[0]=="A": #accessing in global print("Starts from A") x = 300 def myfunc(): global x x = 200 print(x) myfunc() print(x)
name = 'Ashwin' def student(): print('Name', name) student() if name[0] == 'A': print('Starts from A') x = 300 def myfunc(): global x x = 200 print(x) myfunc() print(x)
# GENERATED VERSION FILE # TIME: Fri Sep 11 18:59:53 2020 __version__ = '0.3.0+038435e' short_version = '0.3.0'
__version__ = '0.3.0+038435e' short_version = '0.3.0'
def quick_sort(nums: list) -> list: if len(nums) <= 1: return nums mid = nums[0] return quick_sort([i for i in nums if i < mid]) + [mid] + quick_sort([i for i in nums if i > mid])
def quick_sort(nums: list) -> list: if len(nums) <= 1: return nums mid = nums[0] return quick_sort([i for i in nums if i < mid]) + [mid] + quick_sort([i for i in nums if i > mid])
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def deleteDuplicates(self, head: ListNode) -> ListNode: dummy = ListNode(None) dummy.next = head p = dummy while p.next: ...
class Solution: def delete_duplicates(self, head: ListNode) -> ListNode: dummy = list_node(None) dummy.next = head p = dummy while p.next: cur = p.next nxt = cur.next while nxt and cur.val == nxt.val: cur = cur.next ...
# -*- coding: utf-8 -*- ftx = { 'apiKey':"your_api_key_here" , 'secret':"your_api_secret_here", }
ftx = {'apiKey': 'your_api_key_here', 'secret': 'your_api_secret_here'}
# The location of the extracted scilab_for_xcos_on_cloud. This can be either # relative to SendLog.py or an absolute path. SCILAB_DIR = '../scilab_for_xcos_on_cloud' # The location to keep the flask session data on server. FLASKSESSIONDIR = '/tmp/flask-sessiondir' # The location to keep the session data on server. SE...
scilab_dir = '../scilab_for_xcos_on_cloud' flasksessiondir = '/tmp/flask-sessiondir' sessiondir = '/tmp/sessiondir' xcossourcedir = '' http_server_host = '127.0.0.1' http_server_port = 8001 db_host = '127.0.0.1' db_user = 'scilab' db_pass = '' db_name = 'scilab' db_port = 3306 query_category = "SELECT DISTINCT(loc.id),...
class ApiError(Exception): pass class WrongToken(ApiError): pass class PermissionError(ApiError): pass
class Apierror(Exception): pass class Wrongtoken(ApiError): pass class Permissionerror(ApiError): pass
def solve(A): T = [None]*len(A) prev = [None]*len( A) for i in range(len(A)): T[i] = 1 prev[i] = -1 for j in range(i): if A[j] < A[i] and T[i] < T[j]+1: T[i] = T[j]+1 return max(T[i] for i in range(len(A))) if __name__ == '_...
def solve(A): t = [None] * len(A) prev = [None] * len(A) for i in range(len(A)): T[i] = 1 prev[i] = -1 for j in range(i): if A[j] < A[i] and T[i] < T[j] + 1: T[i] = T[j] + 1 return max((T[i] for i in range(len(A)))) if __name__ == '__main__': a = [...
while True: numero= int(input("Escribir un numero= ")) if numero%2 == 0: print("El numero es par") else: print("El numero es impar")
while True: numero = int(input('Escribir un numero= ')) if numero % 2 == 0: print('El numero es par') else: print('El numero es impar')
# Natural Language Toolkit: code_search_documents def raw(file): contents = open(file).read() contents = re.sub(r'<.*?>', ' ', contents) contents = re.sub('\s+', ' ', contents) return contents def snippet(doc, term): text = ' '*30 + raw(doc) + ' '*30 pos = text.index(term) return text[pos-...
def raw(file): contents = open(file).read() contents = re.sub('<.*?>', ' ', contents) contents = re.sub('\\s+', ' ', contents) return contents def snippet(doc, term): text = ' ' * 30 + raw(doc) + ' ' * 30 pos = text.index(term) return text[pos - 30:pos + 30] print('Building Index...') files...
class Solution: def diffWaysToCompute(self, input: str) -> [int]: end = [] op = {'+': lambda x, y: x + y, '-': lambda x, y: x - y, '*': lambda x, y: x * y} for i in range(len(input)): if input[i] in op.keys(): for left in self.diffWays...
class Solution: def diff_ways_to_compute(self, input: str) -> [int]: end = [] op = {'+': lambda x, y: x + y, '-': lambda x, y: x - y, '*': lambda x, y: x * y} for i in range(len(input)): if input[i] in op.keys(): for left in self.diffWaysToCompute(input[:i]): ...
#PLOTS ################################################## #if(plot_opacity == True): # p_plot = np.linspace(2.0,6.0,21) # a_plot = np.logspace(np.log10(0.001),np.log10(10.),21) # # EXT_plot = EXT(a_plot,p_plot) # ALB_plot = ALB(a_plot,p_plot) # # plt.close() # fig = plt.figure() # ax = fig.ad...
if plot_sky == True: plt.close() (fig, ax) = plt.subplots(nrows=2, ncols=2, figsize=(15, 12)) fig.subplots_adjust(hspace=0.15, wspace=0.1) plt.suptitle('$\\lambda = %.2f \\ \\mathrm{cm}; \\ i = %.1f \\ \\mathrm{deg}$' % (wl, inc * 180.0 / np.pi)) if intensity_log == True: im = ax[0][0].imsho...
# Copyright 2017 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. DEPS = [ 'chromium', 'chromium_android', 'recipe_engine/json', ] def RunSteps(api): api.chromium.set_config('chromium') api.chromium_androi...
deps = ['chromium', 'chromium_android', 'recipe_engine/json'] def run_steps(api): api.chromium.set_config('chromium') api.chromium_android.set_config('main_builder', BUILD_CONFIG='Release') api.chromium_android.run_java_unit_test_suite('test_suite', json_results_file=api.json.output()) def gen_tests(api):...
def solveQuestion(value): n = -1 total = 0 while total < value: n += 1 total = 4*n*n - 4*n + 1 n = n - 1 minSpiralVal = 4*n*n - 4*n + 1 difference = value - minSpiralVal # if difference is more than n - 1 if difference < n: return n + difference elif d...
def solve_question(value): n = -1 total = 0 while total < value: n += 1 total = 4 * n * n - 4 * n + 1 n = n - 1 min_spiral_val = 4 * n * n - 4 * n + 1 difference = value - minSpiralVal if difference < n: return n + difference elif difference == n: return n...
input = "()()(()()()(()()((()((()))((()((((()()((((()))()((((())(((((((()(((((((((()(((())(()()(()((()()(()(())(()((((()((()()()((((())((((((()(()(((()())(()((((()))())(())(()(()()))))))))((((((((((((()())()())())(())))(((()()()((((()(((()(()(()()(()(()()(()(((((((())(())(())())))((()())()((((()()((()))(((()()()())))((...
input = '()()(()()()(()()((()((()))((()((((()()((((()))()((((())(((((((()(((((((((()(((())(()()(()((()()(()(())(()((((()((()()()((((())((((((()(()(((()())(()((((()))())(())(()(()()))))))))((((((((((((()())()())())(())))(((()()()((((()(((()(()(()()(()(()()(()(((((((())(())(())())))((()())()((((()()((()))(((()()()())))((...
class COLORS: header = "\033[4m" red = "\033[31m" green = "\033[32m" blue = "\033[34m" normal = "\033[0m" def format_verse(reference, text) -> str: return "{blue}{reference}{normal} \n{verse}\n".format( blue=COLORS.blue, reference=reference, normal=COLORS.normal, verse=text ...
class Colors: header = '\x1b[4m' red = '\x1b[31m' green = '\x1b[32m' blue = '\x1b[34m' normal = '\x1b[0m' def format_verse(reference, text) -> str: return '{blue}{reference}{normal} \n{verse}\n'.format(blue=COLORS.blue, reference=reference, normal=COLORS.normal, verse=text) def format_referenc...
class Solution: # @param A : list of integers # @return an integer def solve(self, A): s = set(A) if len(s) == len(A): return -1 for i in A: if A.count(i) > 1: return i else: return -1
class Solution: def solve(self, A): s = set(A) if len(s) == len(A): return -1 for i in A: if A.count(i) > 1: return i else: return -1
# Environment variables ENV_PROJECT_PATH = "PROJECT_PATH" ENV_FLOW_PATH = "FLOW_PATH" ENV_SCRIPT_PATH = "SCRIPT_PATH" ENV_PLATFORM_SCRIPT_PATH = "PLATFORM_SCRIPT_PATH" # Contexts CTX_EXEC = "exec"
env_project_path = 'PROJECT_PATH' env_flow_path = 'FLOW_PATH' env_script_path = 'SCRIPT_PATH' env_platform_script_path = 'PLATFORM_SCRIPT_PATH' ctx_exec = 'exec'
N, W, H = map(int, input().split()) row, col = [0] * (H + 1), [0] * (W + 1) for _ in range(N): x, y, w = map(int, input().split()) row[max(0, y - w)] += 1 row[min(H, y + w)] -= 1 col[max(0, x - w)] += 1 col[min(W, x + w)] -= 1 for i in range(H): row[i + 1] += row[i] for i in range(W): col[i ...
(n, w, h) = map(int, input().split()) (row, col) = ([0] * (H + 1), [0] * (W + 1)) for _ in range(N): (x, y, w) = map(int, input().split()) row[max(0, y - w)] += 1 row[min(H, y + w)] -= 1 col[max(0, x - w)] += 1 col[min(W, x + w)] -= 1 for i in range(H): row[i + 1] += row[i] for i in range(W): ...
# Calculates a^b def power(a, b): if b == 0: return 1 b -= 1 return a*power(a, b) x = int(input()) y = int(input()) print(power(x, y))
def power(a, b): if b == 0: return 1 b -= 1 return a * power(a, b) x = int(input()) y = int(input()) print(power(x, y))
''' Program Description: Calculate factorial of a given number ''' def calculate_factorial(n): if n == 0: return 1 if n < 0: raise ValueError fact = 1 for x in range(1,n+1): fact *= x return fact print('N = ', end='') try: result = calculate_factorial(int(input())) print('Output =', result) except Val...
""" Program Description: Calculate factorial of a given number """ def calculate_factorial(n): if n == 0: return 1 if n < 0: raise ValueError fact = 1 for x in range(1, n + 1): fact *= x return fact print('N = ', end='') try: result = calculate_factorial(int(input())) ...
class A: def __init__(self): print('base class constructor ') class B(A): def __init__(self): super().__init__() print('child class constructor ') b1=B()
class A: def __init__(self): print('base class constructor ') class B(A): def __init__(self): super().__init__() print('child class constructor ') b1 = b()
#Incomplete ordering class PartOrdered(object): def __eq__(self, other): return self is other def __ne__(self, other): return self is not other def __hash__(self): return id(self) def __lt__(self, other): return False #Don't blame a sub-class for super-class's sins. ...
class Partordered(object): def __eq__(self, other): return self is other def __ne__(self, other): return self is not other def __hash__(self): return id(self) def __lt__(self, other): return False class Derivedpartordered(PartOrdered): pass
config = { "coinbase":{ "Key": "", "Secret": "" }, "twilio":{ "Key": "", "Secret": "", "from": "+12223334444", "to_list": ["+12223334444"], }, "bittrex":{ "Key" : "", "Secret" : "" } }
config = {'coinbase': {'Key': '', 'Secret': ''}, 'twilio': {'Key': '', 'Secret': '', 'from': '+12223334444', 'to_list': ['+12223334444']}, 'bittrex': {'Key': '', 'Secret': ''}}
def getNthFib(n): if(n==1): return 0 elif (n==2): return 1 else: return getNthFib(n-1) + getNthFib(n-2) #End of getNthFib if __name__ == '__main__': print(getNthFib(6))#5 print(getNthFib(7))#8 print(getNthFib(1))#0 print(getNthFib(11))#55 print(getNthFib(18))#15...
def get_nth_fib(n): if n == 1: return 0 elif n == 2: return 1 else: return get_nth_fib(n - 1) + get_nth_fib(n - 2) if __name__ == '__main__': print(get_nth_fib(6)) print(get_nth_fib(7)) print(get_nth_fib(1)) print(get_nth_fib(11)) print(get_nth_fib(18))
class BadMessageError(Exception): # A bad message is broken in some way that will never be accepted by # the endpoing and as such should be rejected (it will still be logged # and stored so no data is lost) pass class RetryableError(Exception): # A retryable error is apparently transient and may b...
class Badmessageerror(Exception): pass class Retryableerror(Exception): pass class Decrypterror(Exception): pass
#! /usr/bin/python # Samples Python/PYgames # Print 'Hi' 10 times for i in range(10): print("Hi") for i in range(5): print("Hello") print ("There") for i in range(5): print("Hello") print("There") for i in range(10): print(i) for i in range(1, 11): print(i) for i in range(10, 0, -1): p...
for i in range(10): print('Hi') for i in range(5): print('Hello') print('There') for i in range(5): print('Hello') print('There') for i in range(10): print(i) for i in range(1, 11): print(i) for i in range(10, 0, -1): print(i) for i in [2, 6, 4, 2, 6, 7, 4]: print(i) for i in range(3): ...
def draw_z(size, position, target): if size == 1: return (position == target, 1) base_r, base_c = position half_size = size // 2 counter = 0 matched = False if (target[0] >= (base_r + size)) or (target[1] >= (base_c + size)): counter = size ** 2 return (matched, counter...
def draw_z(size, position, target): if size == 1: return (position == target, 1) (base_r, base_c) = position half_size = size // 2 counter = 0 matched = False if target[0] >= base_r + size or target[1] >= base_c + size: counter = size ** 2 return (matched, counter) fo...
# # @lc app=leetcode.cn id=174 lang=python3 # # [174] dungeon-game # None # @lc code=end
None
class Solution: def maxNumEdgesToRemove(self, n: int, edges: List[List[int]]) -> int: answer=0 aliceVisited=[0]*(n+1) bobVisited=[0]*(n+1) aliceSet={} aliceSetNum=1 bobSet={} bobSetNum=1 # Return False if this edge can be deleted. Applies to...
class Solution: def max_num_edges_to_remove(self, n: int, edges: List[List[int]]) -> int: answer = 0 alice_visited = [0] * (n + 1) bob_visited = [0] * (n + 1) alice_set = {} alice_set_num = 1 bob_set = {} bob_set_num = 1 def add_edge(edge) -> bool: ...
def fibonum(num): if num == 1: return 1 elif num == 2: return 1 else: return fibonum(num - 1) + fibonum(num - 2)
def fibonum(num): if num == 1: return 1 elif num == 2: return 1 else: return fibonum(num - 1) + fibonum(num - 2)
age = int(input('What your age?: ')) if age <= 2: print('Is a baby!') elif age <= 4: print('You are a children!') elif age <= 13: print('You are a kid!') elif age <= 20: print('You are a teenager!') elif age <= 65: print('You are a adult!') else: print('You are a old!')
age = int(input('What your age?: ')) if age <= 2: print('Is a baby!') elif age <= 4: print('You are a children!') elif age <= 13: print('You are a kid!') elif age <= 20: print('You are a teenager!') elif age <= 65: print('You are a adult!') else: print('You are a old!')
class Student(): def __init__(self): self._name = 'John' self._age = 18 self._grades = [9.5, 5.75, 10] s1 = Student() # Verify if s1 has the attribute 'name': print(hasattr(s1, 'name')) # Sets a new attribute 'average': setattr(s1, "average", sum(s1._grades) / 3) # Gets t...
class Student: def __init__(self): self._name = 'John' self._age = 18 self._grades = [9.5, 5.75, 10] s1 = student() print(hasattr(s1, 'name')) setattr(s1, 'average', sum(s1._grades) / 3) print(f"{getattr(s1, 'average'):4.2f}") delattr(s1, 'age')
class Solution: ''' 1. char_freq count and updates the char frequent of current window and updates accordingly as the window moves forward. so it dosen't need to delete the elements when the count become 0. 2. window length - window max_count > windown length - global max_count > k. If window length - most...
class Solution: """ 1. char_freq count and updates the char frequent of current window and updates accordingly as the window moves forward. so it dosen't need to delete the elements when the count become 0. 2. window length - window max_count > windown length - global max_count > k. If window length - most_...
'''https://leetcode.com/problems/binary-search/''' class Solution: def search(self, nums: List[int], target: int) -> int: l, h = 0, len(nums)-1 while l<=h: m = (l+h)//2 if nums[m]==target: return m elif nums[m]>target: h = m-1 ...
"""https://leetcode.com/problems/binary-search/""" class Solution: def search(self, nums: List[int], target: int) -> int: (l, h) = (0, len(nums) - 1) while l <= h: m = (l + h) // 2 if nums[m] == target: return m elif nums[m] > target: ...
def bubblesort(array): length = len(array)-1 for i in range(length,0,-1): for j in range(i): if array[j] > array[j+1]: array[j],array[j+1]=array[j+1],array[j]
def bubblesort(array): length = len(array) - 1 for i in range(length, 0, -1): for j in range(i): if array[j] > array[j + 1]: (array[j], array[j + 1]) = (array[j + 1], array[j])
# Time complexity: O(n^2) # Approach: Fix one and then based on that loop over other numbers. class Solution: def threeSum(self, nums: List[int]) -> List[List[int]]: n = len(nums) if n < 3: return [] nums = sorted(nums) ans = [] for k in range(n): tar...
class Solution: def three_sum(self, nums: List[int]) -> List[List[int]]: n = len(nums) if n < 3: return [] nums = sorted(nums) ans = [] for k in range(n): target = -nums[k] (i, j) = (k + 1, n - 1) while i < j: s...
Friend1 = {"First_name": "Anita", "Last_name": "Sanchez", "Age": 21, "City": "Saltillo"} Friend2 = {"First_name": "Andrea", "Last_name": "De la Fuente", "Age": 21, "City": "Monclova"} Friend3 = {"First_name": "Jorge", "Last_name": "Sanchez", "Age":20, "City": "Saltillo"} amigos = [Friend1, Friend2, Friend3] for i in ...
friend1 = {'First_name': 'Anita', 'Last_name': 'Sanchez', 'Age': 21, 'City': 'Saltillo'} friend2 = {'First_name': 'Andrea', 'Last_name': 'De la Fuente', 'Age': 21, 'City': 'Monclova'} friend3 = {'First_name': 'Jorge', 'Last_name': 'Sanchez', 'Age': 20, 'City': 'Saltillo'} amigos = [Friend1, Friend2, Friend3] for i in r...
# -*- coding: utf-8 -*- # Aufgaben 6, 7, 20, 21, 24, 30, 34, 39, 38, 41, 43 Bis Dienstag # ----------------- # 41 list in nested loop # ----------------- words = ['attribution', 'confabulation', 'elocution', 'sequoia', 'tenacious', 'unidirectional'] s = sorted(set([''.join([c for c in w if c in 'aeiou']) fo...
words = ['attribution', 'confabulation', 'elocution', 'sequoia', 'tenacious', 'unidirectional'] s = sorted(set([''.join([c for c in w if c in 'aeiou']) for w in words])) print('My result: ', sorted(s)) print('Solution: ', ['aiuio', 'eaiou', 'eouio', 'euoia', 'oauaio', 'uiieioa'])
def main(): ref = "lunes,martes,miercoles,juevez,viernes,sabado,domindo".split(",") day = int(input("Day: ")) - 1 print(ref[day]) if __name__ == '__main__': main()
def main(): ref = 'lunes,martes,miercoles,juevez,viernes,sabado,domindo'.split(',') day = int(input('Day: ')) - 1 print(ref[day]) if __name__ == '__main__': main()
file = open('data/day1.txt', 'r') values = [] for line in file.readlines(): values.append(int(line)) counter = 0 i = 3 while i < len(values): if values[i-3] < values [i]: counter = counter + 1 i = i + 1 print(counter)
file = open('data/day1.txt', 'r') values = [] for line in file.readlines(): values.append(int(line)) counter = 0 i = 3 while i < len(values): if values[i - 3] < values[i]: counter = counter + 1 i = i + 1 print(counter)
fun = lambda s : True if len(s) > 5 else False print(fun("sidd")) print(fun("sidddha")) names = ['alka','sidd','lala'] for pos,name in enumerate(names): print(f"{pos} ===> {name}") string = "lala" for pos,name in enumerate(names): if(name == string): print(f"{pos} ===> {name}")
fun = lambda s: True if len(s) > 5 else False print(fun('sidd')) print(fun('sidddha')) names = ['alka', 'sidd', 'lala'] for (pos, name) in enumerate(names): print(f'{pos} ===> {name}') string = 'lala' for (pos, name) in enumerate(names): if name == string: print(f'{pos} ===> {name}')
class BinarySearchTree(): def __init__(self): self.root = None def insert(self, data): if self.root: return self.root.insert(data) else: self.root = Node(data) return True def find(self, data): if self.root: return self.root....
class Binarysearchtree: def __init__(self): self.root = None def insert(self, data): if self.root: return self.root.insert(data) else: self.root = node(data) return True def find(self, data): if self.root: return self.root.fi...
# An example of function calling another def func_a(): print('A') # func_b() calls system function print() def func_b(): print('B') # func_ab() calls func_a() and func_b() def func_ab(): func_a() func_b() print('Done!') # Main calls func_ab() def main(): func_ab() # Call main() function....
def func_a(): print('A') def func_b(): print('B') def func_ab(): func_a() func_b() print('Done!') def main(): func_ab() main()
#Problema 9 res = 0 for a in range(1, 500): for b in range(1, 500): for c in range(1, 500): if (a < b < c) and (a ** 2 + b ** 2 == c ** 2): if a + b + c == 1000: res = a*b*c print(res)
res = 0 for a in range(1, 500): for b in range(1, 500): for c in range(1, 500): if a < b < c and a ** 2 + b ** 2 == c ** 2: if a + b + c == 1000: res = a * b * c print(res)
# Rule for building verilator simulations. # # Copyright 2019 Erik Gilling # # Heavily informed from the rules_foreign_cc package at: # https://github.com/bazelbuild/rules_foreign_cc/ # Since verilator uses make to build its output it shares some actions with # @rules_foreign_cc. load("@rules_foreign_cc//tools/build...
load('@rules_foreign_cc//tools/build_defs:cc_toolchain_util.bzl', 'get_env_vars') load('@rules_foreign_cc//tools/build_defs:shell_script_helper.bzl', 'os_name') def _verilator_sim_impl(ctx): v_files = ctx.attr._verilator_toolchain.files.to_list() verilator_dir = [f for f in v_files if f.path.endswith('copy_ver...
class Node(object): def __init__(self, data): self.data = data self.left = None self.right = None @staticmethod def pre_order(root, nodes): if not root: return nodes.append(root.data) Node.pre_order(root.left, nodes) Node.pre_order(root....
class Node(object): def __init__(self, data): self.data = data self.left = None self.right = None @staticmethod def pre_order(root, nodes): if not root: return nodes.append(root.data) Node.pre_order(root.left, nodes) Node.pre_order(root.r...
class Node(): def __init__(self, data=None,next_node=None): self.data = data self.next_node = next_node def __str__(self): return self.data def get_next(self): return self.next_node def set_new_next(self, new_next): self.next_node = new_next class LinkedList(): def __init_...
class Node: def __init__(self, data=None, next_node=None): self.data = data self.next_node = next_node def __str__(self): return self.data def get_next(self): return self.next_node def set_new_next(self, new_next): self.next_node = new_next class Linkedlist: ...
valid_sequence_dict = { "P1": "complete protein", "F1": "protein fragment", \ "DL": "linear DNA", "DC": "circular DNA", "RL": "linear RNA", \ "RC":"circular RNA", "N3": "transfer RNA", "N1": "other" }
valid_sequence_dict = {'P1': 'complete protein', 'F1': 'protein fragment', 'DL': 'linear DNA', 'DC': 'circular DNA', 'RL': 'linear RNA', 'RC': 'circular RNA', 'N3': 'transfer RNA', 'N1': 'other'}
f = open("test.txt") print(f.read())
f = open('test.txt') print(f.read())
def fibonacci(N :int)->int: if N==1 or N==2: return 1 else : return fibonacci(N-1)+fibonacci(N-2) def main(): # input N = int(input()) # compute # output print(fibonacci(N)) if __name__ == '__main__': main()
def fibonacci(N: int) -> int: if N == 1 or N == 2: return 1 else: return fibonacci(N - 1) + fibonacci(N - 2) def main(): n = int(input()) print(fibonacci(N)) if __name__ == '__main__': main()
class ConnectedSIPMessage(object): def __init__(self, a_sip_transport_connection, a_sip_message): self.connection = a_sip_transport_connection self.sip_message = a_sip_message @property def raw_string(self): if self.sip_message: return self.sip_message.raw_string ...
class Connectedsipmessage(object): def __init__(self, a_sip_transport_connection, a_sip_message): self.connection = a_sip_transport_connection self.sip_message = a_sip_message @property def raw_string(self): if self.sip_message: return self.sip_message.raw_string ...
# Change to API-tokens CONSUMER_KEY='[TWITTER CONSUMER KEY]' CONSUMER_SECRET='[TWITTER CONSUMER SECRET]' # Change to proper username/password ADMIN_NAME='admin' ADMIN_PW='1234' # Change to proper secrete key e.g. `python3 -c 'import os; print(os.urandom(16))'` SECRET_KEY = b'1234'
consumer_key = '[TWITTER CONSUMER KEY]' consumer_secret = '[TWITTER CONSUMER SECRET]' admin_name = 'admin' admin_pw = '1234' secret_key = b'1234'
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def detectCycle(self, head: ListNode) -> ListNode: cs = head cf = head if head == None: return None if cf.next == None: ...
class Solution: def detect_cycle(self, head: ListNode) -> ListNode: cs = head cf = head if head == None: return None if cf.next == None: return None else: cf = cf.next while cf.next != None and cf != cs: cs = cs.next ...
def toh(disks, source, destination, helper) -> int: # Number of steps it will take to transfer the disks from one tower to another # Base Case if disks == 1: print("move disk {} from {} -> {}".format(disks, source, destination)) return 1 # only one step needed # Hypothesis steps_t...
def toh(disks, source, destination, helper) -> int: if disks == 1: print('move disk {} from {} -> {}'.format(disks, source, destination)) return 1 steps_to_move_remaining_disks__from_src_helper = toh(disks - 1, source, helper, destination) print('move last disk({}) from {} -> {}'.format(disk...