content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# -*- coding: utf-8 -*- ''' module used while testing mock hubs provided in 'testing'. ''' __contracts__ = ['testing'] def noparam(hub): pass def echo(hub, param): return param def signature_func(hub, param1, param2='default'): pass def attr_func(hub): pass attr_func.test = True attr_func._...
""" module used while testing mock hubs provided in 'testing'. """ __contracts__ = ['testing'] def noparam(hub): pass def echo(hub, param): return param def signature_func(hub, param1, param2='default'): pass def attr_func(hub): pass attr_func.test = True attr_func.__test__ = True async def async_e...
def add(first,second): """Adds two numbers""" return first + second if __name__ == "__main__": add(2,3)
def add(first, second): """Adds two numbers""" return first + second if __name__ == '__main__': add(2, 3)
code = "he.elk.set.to" decode = code.split("e") print(decode[-1])
code = 'he.elk.set.to' decode = code.split('e') print(decode[-1])
"""Infer read orientation from sample data.""" def infer(): """Main function coordinating the execution of all other functions. Should be imported/called from main app and return results to it. """ # implement me
"""Infer read orientation from sample data.""" def infer(): """Main function coordinating the execution of all other functions. Should be imported/called from main app and return results to it. """
# you can write to stdout for debugging purposes, e.g. # print("this is a debug message") def solution(M, A): hash = [0] * (M + 1) slices = 0 max_slices = 1000000000 head = 0 for tail in range(len(A)): while head < len(A) and ( not hash[A[head]]): hash[A[head]] = 1 s...
def solution(M, A): hash = [0] * (M + 1) slices = 0 max_slices = 1000000000 head = 0 for tail in range(len(A)): while head < len(A) and (not hash[A[head]]): hash[A[head]] = 1 slices += head - tail + 1 if slices > max_slices: return max_slic...
""" Author: Alberto Marci """ class DecimalToRoman: # convert number from 0 to 9 def __zero_to_nine(self, number): if number == '0': return '' if number == '1': return 'I' if number == '2': return 'II' if number == '3': ...
""" Author: Alberto Marci """ class Decimaltoroman: def __zero_to_nine(self, number): if number == '0': return '' if number == '1': return 'I' if number == '2': return 'II' if number == '3': return 'III' if number == '4': ...
class Solution: def gameOfLife(self, board): """ :type board: List[List[int]] :rtype: void Do not return anything, modify board in-place instead. """ if not board: return board last = copy.deepcopy(board) for i in range(len(board)): ...
class Solution: def game_of_life(self, board): """ :type board: List[List[int]] :rtype: void Do not return anything, modify board in-place instead. """ if not board: return board last = copy.deepcopy(board) for i in range(len(board)): ...
#less than operator print(4<10) # --- L1 print(10<4) # --- L2 print(4<4.0) # --- L3 print(4.0<4) # --- L4 print('python'<'Python') #--- L5 print('python'<'python') # --- L6 print('Python'<'python') #--- L7
print(4 < 10) print(10 < 4) print(4 < 4.0) print(4.0 < 4) print('python' < 'Python') print('python' < 'python') print('Python' < 'python')
DIGITS = "0123456789abcdef" def convert_base_stack(decimal_number, base): remainder_stack = [] while decimal_number > 0: remainder = decimal_number % base remainder_stack.append(remainder) decimal_number = decimal_number // base new_digits = [] while remainder_stack: ...
digits = '0123456789abcdef' def convert_base_stack(decimal_number, base): remainder_stack = [] while decimal_number > 0: remainder = decimal_number % base remainder_stack.append(remainder) decimal_number = decimal_number // base new_digits = [] while remainder_stack: new...
def add(a,b): return a+b def substract(a,b): return a * b ## Imagine I made a valid change def absolut(a,b): return np.abs(a,b)
def add(a, b): return a + b def substract(a, b): return a * b def absolut(a, b): return np.abs(a, b)
class Solution: def findRestaurant(self, list1, list2): mp1, mp2 = {x: i for i, x in enumerate(list1)}, {x: i for i, x in enumerate(list2)} ans = [10 ** 4, []] for k, v in mp1.items(): if k in mp2 and v + mp2[k] == ans[0]: ans[1].append(k) elif k in mp2 and v + mp2[k]...
class Solution: def find_restaurant(self, list1, list2): (mp1, mp2) = ({x: i for (i, x) in enumerate(list1)}, {x: i for (i, x) in enumerate(list2)}) ans = [10 ** 4, []] for (k, v) in mp1.items(): if k in mp2 and v + mp2[k] == ans[0]: ans[1].append(k) ...
# Solution 1 # O(n) time / O(n) space def branchSums(root): sums = [] calculateBranchSums(root, 0, sums) return sums def calculateBranchSums(node, runningSum, sums): if node is None: return sums newRunningSum = runningSum + node.value if node.left is None and node.right is None: ...
def branch_sums(root): sums = [] calculate_branch_sums(root, 0, sums) return sums def calculate_branch_sums(node, runningSum, sums): if node is None: return sums new_running_sum = runningSum + node.value if node.left is None and node.right is None: sums.append(newRunningSum) ...
class Context(dict): """docstring for _Context""" def __init__(self, name, parameters={}, lifespan=5): self.name = name self.parameters = parameters self.lifespan = lifespan # def __getattr__(self, param): # if param in ['name', 'parameters', 'lifespan']: # ...
class Context(dict): """docstring for _Context""" def __init__(self, name, parameters={}, lifespan=5): self.name = name self.parameters = parameters self.lifespan = lifespan def set(self, param_name, value): self.parameters[param_name] = value def get(self, param): ...
def minInsertions(s: str) -> int: dp = [[0] * len(s) for _ in range(len(s))] for left in range(len(s) - 1, -1, -1): for right in range(0, len(s)): if left >= right: continue if s[left] == s[right]: dp[left][right] = dp[left+1][right-1] ...
def min_insertions(s: str) -> int: dp = [[0] * len(s) for _ in range(len(s))] for left in range(len(s) - 1, -1, -1): for right in range(0, len(s)): if left >= right: continue if s[left] == s[right]: dp[left][right] = dp[left + 1][right - 1] ...
# -*- coding: UTF-8 -*- PROXYSOCKET = '' RETRY_TIMES = 5 HEADERS = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36', 'Accept': 'application/json,application/xml' } INPUT_FILE = 'dependencies/input.xlsx' API_DEBUG = True AP...
proxysocket = '' retry_times = 5 headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36', 'Accept': 'application/json,application/xml'} input_file = 'dependencies/input.xlsx' api_debug = True api_port = 5678 post_time = 60
N = int(input("")) for x in range(0, N): if N > 0: s = input("") s = s.split() #separar if s[0] == s[1]: print("empate") else: if s[0] == "tesoura": if s[1] == "papel" or s[1] =="lagarto": print("rajesh") ...
n = int(input('')) for x in range(0, N): if N > 0: s = input('') s = s.split() if s[0] == s[1]: print('empate') elif s[0] == 'tesoura': if s[1] == 'papel' or s[1] == 'lagarto': print('rajesh') elif s[1] == 'pedra' or s[1] == 'spock'...
def extract_organization_id_from_request_query(request): return request.query_params.get('organization') or request.query_params.get('organization_id') def extract_organization_id_from_request_data(request) -> (int, bool): """ Returns the organization id from the request.data and a bool indicating if the ...
def extract_organization_id_from_request_query(request): return request.query_params.get('organization') or request.query_params.get('organization_id') def extract_organization_id_from_request_data(request) -> (int, bool): """ Returns the organization id from the request.data and a bool indicating if the k...
"""Provides the repository macro to import rocksdb.""" load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def repo(): """Imports rocksdb.""" ROCKSDB_VERSION = "6.15.5" ROCKSDB_SHA256 = "d7b994e1eb4dff9dfefcd51a63f86630282e1927fc42a300b93c573c853aa5d0" http_archive( name = "...
"""Provides the repository macro to import rocksdb.""" load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') def repo(): """Imports rocksdb.""" rocksdb_version = '6.15.5' rocksdb_sha256 = 'd7b994e1eb4dff9dfefcd51a63f86630282e1927fc42a300b93c573c853aa5d0' http_archive(name='rocksdb', buil...
#=============================================================================== # Copyright 2020 Intel 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 # # http://www.apache.o...
load('@onedal//dev/bazel:utils.bzl', 'utils', 'paths') def _create_symlinks(repo_ctx, root, entries, substitutions={}): for entry in entries: entry_fmt = utils.substitude(entry, substitutions) src_entry_path = paths.join(root, entry_fmt) dst_entry_path = entry_fmt repo_ctx.symlink(s...
def intersects(line1, line2): def onSeg(p, q, r): if (q[0] <= max(p[0],r[0]) and q[0] >= min(p[0],r[0]) and q[0] <= max(p[1],r[1]) and q[1] >= min(p[1],r[1])): return True return False #0 -> colinear, 1 -> clockwise, 2 -> ccw def orientation(p,q,r): v...
def intersects(line1, line2): def on_seg(p, q, r): if q[0] <= max(p[0], r[0]) and q[0] >= min(p[0], r[0]) and (q[0] <= max(p[1], r[1])) and (q[1] >= min(p[1], r[1])): return True return False def orientation(p, q, r): val = (q[1] - p[1]) * (r[0] - q[0]) - (q[0] - p[0]) * (r...
# Q1 class Thing: pass example = Thing() print(Thing) print(example) # Q2 class Thing2: letters = 'abc' print(Thing2.letters) # Q3 class Thing3: def __init__(self): self.letters = 'xyz' thing3 = Thing3() print(thing3.letters) # Q4 class Element: def __init__(self, name, symbol, numb...
class Thing: pass example = thing() print(Thing) print(example) class Thing2: letters = 'abc' print(Thing2.letters) class Thing3: def __init__(self): self.letters = 'xyz' thing3 = thing3() print(thing3.letters) class Element: def __init__(self, name, symbol, number): self.name = nam...
j = 7 for i in range(1,(10),2): for jump in range(0,3): print("I={0} J={1}".format(i,j)) j = j - 1 j = 7
j = 7 for i in range(1, 10, 2): for jump in range(0, 3): print('I={0} J={1}'.format(i, j)) j = j - 1 j = 7
result = [ [0.6, 0.7], {'a': 'b'}, None, [ 'uu', 'ii', [None], [7, 8, 9, {}] ] ]
result = [[0.6, 0.7], {'a': 'b'}, None, ['uu', 'ii', [None], [7, 8, 9, {}]]]
def DependsOn(pack, deps): return And([ Implies(pack, dep) for dep in deps ]) def Conflict(p1, p2): return Or(Not(p1), Not(p2)) a, b, c, d, e, f, g, z = Bools('a b c d e f g z') solve(DependsOn(a, [b, c, z]), DependsOn(b, [d]), DependsOn(c, [Or(d, e), Or(f, g)]), Conflict(d, e), a, z)...
def depends_on(pack, deps): return and([implies(pack, dep) for dep in deps]) def conflict(p1, p2): return or(not(p1), not(p2)) (a, b, c, d, e, f, g, z) = bools('a b c d e f g z') solve(depends_on(a, [b, c, z]), depends_on(b, [d]), depends_on(c, [or(d, e), or(f, g)]), conflict(d, e), a, z)
# # PySNMP MIB module SW-LAYER2-PORT-MANAGEMENT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SW-LAYER2-PORT-MANAGEMENT-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:12:34 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python ve...
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, value_range_constraint, single_value_constraint, value_size_constraint, constraints_intersection) ...
class Queue: # Constructor to initiate queue def __init__(self, queue=None): if queue is None: queue = [] self.queue = queue # push to append an item into queue def push(self, value): self.queue.append(value) # front to return starting element from queue de...
class Queue: def __init__(self, queue=None): if queue is None: queue = [] self.queue = queue def push(self, value): self.queue.append(value) def front(self): if Queue.empty(self) is False: return self.queue[0] else: raise index_e...
class EnumType(object): # Internal data storage uses integer running from 0 to range_end # range_end is set to the number of possible values that the Enum can take on # External representation of Enum starts at 1 and goes to range_end + 1 def __init__(self, initial_value): self.set(initial_valu...
class Enumtype(object): def __init__(self, initial_value): self.set(initial_value) def load_json(self, json_struct): self.set(json_struct) def json_serializer(self): if self.value < 0: return None else: return type(self).possible_values[self.value] ...
# -*- coding: utf-8 -*- # class LineLoop(object): _ID = 0 dimension = 1 def __init__(self, lines): self.lines = lines self.id = 'll{}'.format(LineLoop._ID) LineLoop._ID += 1 self.code = '\n'.join([ '{} = newll;'.format(self.id), 'Line Loop({}) = {...
class Lineloop(object): _id = 0 dimension = 1 def __init__(self, lines): self.lines = lines self.id = 'll{}'.format(LineLoop._ID) LineLoop._ID += 1 self.code = '\n'.join(['{} = newll;'.format(self.id), 'Line Loop({}) = {{{}}};'.format(self.id, ', '.join([l.id for l in lines]...
# Binary search def binary_search(A: list, x: int): i = 0 j = len(A) while i < j: m = (i + j) // 2 if A[m] == x: return True elif A[m] > x: j = m else: i = m + 1 return False def recursive_binary_search(A: list, x: int, start: int, end: int): if end >= start: m = start...
def binary_search(A: list, x: int): i = 0 j = len(A) while i < j: m = (i + j) // 2 if A[m] == x: return True elif A[m] > x: j = m else: i = m + 1 return False def recursive_binary_search(A: list, x: int, start: int, end: int): if e...
class BaseDBDriver(): """ This will stub the most basic methods that a GraphDB driver must have. """ _connected = False _settings = {} def __init__(self, dbapi): self.dbapi = dbapi def _debug(self, *args): if self.debug: print ("[GraphDB #%x]:" % id(self)...
class Basedbdriver: """ This will stub the most basic methods that a GraphDB driver must have. """ _connected = False _settings = {} def __init__(self, dbapi): self.dbapi = dbapi def _debug(self, *args): if self.debug: print('[GraphDB #%x]:' % id(self), *args) ...
class Solution: def numberOfLines(self, widths: List[int], s: str) -> List[int]: s = list(s); lines = 1; line = 0 while s: if line + widths[ord(s[0])-97] > 100: lines += 1; line = 0 else: line += widths[ord(s.pop(0))-97] return [lines, ...
class Solution: def number_of_lines(self, widths: List[int], s: str) -> List[int]: s = list(s) lines = 1 line = 0 while s: if line + widths[ord(s[0]) - 97] > 100: lines += 1 line = 0 else: line += widths[ord(s.p...
Lakh = 100 * 1000 Crore = 100 * Lakh biggerNumbers = { 100 : "sau", 1000 : "hazaar", Lakh : "laakh", Crore : "karoD" }
lakh = 100 * 1000 crore = 100 * Lakh bigger_numbers = {100: 'sau', 1000: 'hazaar', Lakh: 'laakh', Crore: 'karoD'}
class Match: def __init__(self): self.date = "" self.round = "" self.tournament = "" self.home = "" self.score = "" self.away = "" self.channels = ""
class Match: def __init__(self): self.date = '' self.round = '' self.tournament = '' self.home = '' self.score = '' self.away = '' self.channels = ''
class Solution: def intToRoman(self, num): """ :type num: int :rtype: str """ res = "" while num: if num >= 1000: res += (num//1000) * 'M' num = num%1000 elif num >= 900: res += 'CM' ...
class Solution: def int_to_roman(self, num): """ :type num: int :rtype: str """ res = '' while num: if num >= 1000: res += num // 1000 * 'M' num = num % 1000 elif num >= 900: res += 'CM' ...
class Solution: def productExceptSelf(self, nums: List[int]) -> List[int]: prod = 1 prods = [1]*len(nums) for i in range(len(nums)): prods[i] = prod prod *= nums[i] prod = 1 for i in range(len(nums)-1, -1, -1): prods[i...
class Solution: def product_except_self(self, nums: List[int]) -> List[int]: prod = 1 prods = [1] * len(nums) for i in range(len(nums)): prods[i] = prod prod *= nums[i] prod = 1 for i in range(len(nums) - 1, -1, -1): prods[i] *= prod ...
def all_index(array, num): indx = [] for i in range(0,len(array)): for j in range(0,array[i].count(num)): if j == 0: indx.append([i, array[i].index(num)]) else: indx.append([i, array[i].index(num,indx[j-1][1]+1)]) return indx tic = [[1,1,0]...
def all_index(array, num): indx = [] for i in range(0, len(array)): for j in range(0, array[i].count(num)): if j == 0: indx.append([i, array[i].index(num)]) else: indx.append([i, array[i].index(num, indx[j - 1][1] + 1)]) return indx tic = [[1, ...
"""This problem was asked by Uber. You have N stones in a row, and would like to create from them a pyramid. This pyramid should be constructed such that the height of each stone increases by one until reaching the tallest stone, after which the heights decrease by one. In addition, the start and end stones of the p...
"""This problem was asked by Uber. You have N stones in a row, and would like to create from them a pyramid. This pyramid should be constructed such that the height of each stone increases by one until reaching the tallest stone, after which the heights decrease by one. In addition, the start and end stones of the p...
"""Constants for the xbox integration.""" DOMAIN = "xbox" OAUTH2_AUTHORIZE = "https://login.live.com/oauth20_authorize.srf" OAUTH2_TOKEN = "https://login.live.com/oauth20_token.srf" EVENT_NEW_FAVORITE = "xbox/new_favorite"
"""Constants for the xbox integration.""" domain = 'xbox' oauth2_authorize = 'https://login.live.com/oauth20_authorize.srf' oauth2_token = 'https://login.live.com/oauth20_token.srf' event_new_favorite = 'xbox/new_favorite'
def encrypt(message, key): encrypted_message = '' for char in message: if char.isalpha(): #ord() returns an integer representing the Unicode code point of the character unicode_num = ord(char) unicode_num += key if char.isupper(): ...
def encrypt(message, key): encrypted_message = '' for char in message: if char.isalpha(): unicode_num = ord(char) unicode_num += key if char.isupper(): if unicode_num > ord('Z'): unicode_num -= 26 elif unicode_num < ...
# In "and" operator if ONE is false the whole is false # in "or" operator if ONE is true the whole is true print("Welcome to the rollercoaster!") height = int(input("What is your height in cms? ")) bill = 0 if height >= 120: print("You can ride the rollercoaster") age = int(input("What is your age...
print('Welcome to the rollercoaster!') height = int(input('What is your height in cms? ')) bill = 0 if height >= 120: print('You can ride the rollercoaster') age = int(input('What is your age? ')) if age < 12: bill = 5 print('Child tickets are $5') elif age <= 18: bill = 7 ...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Problem 021 Divisible Sum Pairs Source : https://www.hackerrank.com/challenges/divisible-sum-pairs/problem """ _, d = map(int, input().split()) numbers = list(map(int, input().split())) nb = len(numbers) count = 0 for i in range(nb-1): for j in range(i+1, nb): ...
"""Problem 021 Divisible Sum Pairs Source : https://www.hackerrank.com/challenges/divisible-sum-pairs/problem """ (_, d) = map(int, input().split()) numbers = list(map(int, input().split())) nb = len(numbers) count = 0 for i in range(nb - 1): for j in range(i + 1, nb): count += (numbers[i] + numbers[j]) %...
class User: def __init__(self, username, name, email, bio, repositories): self.username = username self.name = name self.email = email self.bio = bio self.repositories = repositories def __str__(self): final = "Name: {} ({}):".format(self.name, self.username) ...
class User: def __init__(self, username, name, email, bio, repositories): self.username = username self.name = name self.email = email self.bio = bio self.repositories = repositories def __str__(self): final = 'Name: {} ({}):'.format(self.name, self.username) ...
#------------------------------------------------------------------------------- def checkUser( username, passwd ): return False #------------------------------------------------------------------------------- def checkIfUserAvailable( username ): return False #------------------------------------------------...
def check_user(username, passwd): return False def check_if_user_available(username): return False def get_user_email(username): return None def allow_password_change(username): return False def change_user_password(username, oldpass, newpass): return False
# using modified merge function def compute_union(arr1, arr2): union = [] index1 = 0 index2 = 0 while (index1 < len(arr1)) and (index2 < len(arr2)): if arr1[index1] < arr2[index2]: union.append(arr1[index1]) index1 += 1 elif arr1[index1] > arr2[index2]: ...
def compute_union(arr1, arr2): union = [] index1 = 0 index2 = 0 while index1 < len(arr1) and index2 < len(arr2): if arr1[index1] < arr2[index2]: union.append(arr1[index1]) index1 += 1 elif arr1[index1] > arr2[index2]: union.append(arr2[index2]) ...
levels = [ #{ # 'geometry': [ ' bbb ', # ' bbb ', # ' bbb ', # ' bbb ', # ' b ', # ' b ', # ' bbb ', # ...
levels = [{'geometry': [' ', ' ', ' bbb ', ' bbbb ', ' bbbb ', ' bbb ', ' bbb ', ' bbbb ', ' bbbb ', ' bebb ', ' bbbb ', ' bb ', ' ', ' ', ' '], 'start': {'x': 6, 'y': 3}, 'swatches': []}, {'geometry': [' bbbbb ', ' bbbbb ',...
while True: a, b, c = sorted(map(int, input().split())) if a == 0 and b == 0 and c == 0: break print("right" if a ** 2 + b ** 2 == c ** 2 else "wrong")
while True: (a, b, c) = sorted(map(int, input().split())) if a == 0 and b == 0 and (c == 0): break print('right' if a ** 2 + b ** 2 == c ** 2 else 'wrong')
# EASY # count each element in array and store in dict{} # loop through the array check if exist nums[i]+1 in dict{} class Solution: def findLHS(self, nums: List[int]) -> int: n = len(nums) appear = {} for i in range(n): appear[nums[i]] = appear.get(nums[i],0) + 1 ...
class Solution: def find_lhs(self, nums: List[int]) -> int: n = len(nums) appear = {} for i in range(n): appear[nums[i]] = appear.get(nums[i], 0) + 1 result = 0 for (k, v) in appear.items(): if k + 1 in appear: result = max(result, v +...
class Clock(): # Set initial Clock state def __init__(self, hours, minutes): timeDic = self.calculateMinutes(minutes) self.minutes = timeDic['minutes'] self.hours = self.calculateHour(hours + timeDic['hours']) self.time = self.generateTimeString() # Add minutes to the cl...
class Clock: def __init__(self, hours, minutes): time_dic = self.calculateMinutes(minutes) self.minutes = timeDic['minutes'] self.hours = self.calculateHour(hours + timeDic['hours']) self.time = self.generateTimeString() def add(self, numMinutes=0): time_dic = self.calc...
class Order: __slots__ = ( 'id', 'order_number', 'customer_name', 'shipping_name', 'order_date', 'order_details_url', 'subtotal', 'shipping_fee', 'tax', 'status', 'retail_bonus', 'order_type', 'customer_url', ...
class Order: __slots__ = ('id', 'order_number', 'customer_name', 'shipping_name', 'order_date', 'order_details_url', 'subtotal', 'shipping_fee', 'tax', 'status', 'retail_bonus', 'order_type', 'customer_url', 'customer_id', 'customer_contact', 'total', 'qv', 'hostess', 'party', 'ship_date', 'line_items', 'shipping_a...
''' Find the largest continuous sum ''' def largest_cont_sum(arr): if len(arr) == 0: return 0 cur_sum = arr[0] max_sum = arr[0] for item in arr[1:]: cur_sum = max(cur_sum+item, item) if cur_sum >= max_sum: max_sum = cur_sum return max_sum
""" Find the largest continuous sum """ def largest_cont_sum(arr): if len(arr) == 0: return 0 cur_sum = arr[0] max_sum = arr[0] for item in arr[1:]: cur_sum = max(cur_sum + item, item) if cur_sum >= max_sum: max_sum = cur_sum return max_sum
class Solution: def matrixReshape(self, mat: List[List[int]], newRows: int, newCols: int) -> List[List[int]]: rows = len(mat) cols = len(mat[0]) if rows * cols != newRows * newCols: return mat newMat = [[0] * newCols for _ in range(newRows)] for x in range(rows...
class Solution: def matrix_reshape(self, mat: List[List[int]], newRows: int, newCols: int) -> List[List[int]]: rows = len(mat) cols = len(mat[0]) if rows * cols != newRows * newCols: return mat new_mat = [[0] * newCols for _ in range(newRows)] for x in range(rows...
input = """ c num blocks = 1 c num vars = 180 c minblockids[0] = 1 c maxblockids[0] = 180 p cnf 180 765 43 -70 -94 0 80 70 -20 0 34 -89 37 0 -99 -140 153 0 -30 131 14 0 136 20 17 0 -125 -172 -114 0 19 -13 -126 0 127 -138 -142 0 -127 -84 79 0 -63 -13 50 0 -15 -118 17 0 6 65 -116 0 -30 -167 157 0 -156 -143 -12 0 38 -60 1...
input = '\nc num blocks = 1\nc num vars = 180\nc minblockids[0] = 1\nc maxblockids[0] = 180\np cnf 180 765\n43 -70 -94 0\n80 70 -20 0\n34 -89 37 0\n-99 -140 153 0\n-30 131 14 0\n136 20 17 0\n-125 -172 -114 0\n19 -13 -126 0\n127 -138 -142 0\n-127 -84 79 0\n-63 -13 50 0\n-15 -118 17 0\n6 65 -116 0\n-30 -167 157 0\n-156 -...
def multiplication_table(size): return [[ x * y for y in range(1, size + 1)] for x in range(1, size + 1)] print(multiplication_table(3)) # [[1,2,3],[2,4,6],[3,6,9]]
def multiplication_table(size): return [[x * y for y in range(1, size + 1)] for x in range(1, size + 1)] print(multiplication_table(3))
a=5 b=50 if a>=b: c=a-b else: c=a-b print(c)
a = 5 b = 50 if a >= b: c = a - b else: c = a - b print(c)
# -*- coding: utf-8 -*- # Put here your production specific settings ADMINS = [ ('Francesca Alberti', 'francydark91@gmail.com'), ] EMAIL_SUBJECT_PREFIX = '[ALBERTIFRA]'
admins = [('Francesca Alberti', 'francydark91@gmail.com')] email_subject_prefix = '[ALBERTIFRA]'
# autocord # package for simple automation with discord client # # m: error class ApiError(Exception): pass
class Apierror(Exception): pass
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 # For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt copy("src", "out_encodings") run(""" coverage run utf8.py coverage annotate utf8.py """, rundir="out_encodings") compare("out_encodings", "gold_encoding...
copy('src', 'out_encodings') run('\n coverage run utf8.py\n coverage annotate utf8.py\n ', rundir='out_encodings') compare('out_encodings', 'gold_encodings', '*,cover') clean('out_encodings')
""" 0604. Design Compressed String Iterator Design and implement a data structure for a compressed string iterator. The given compressed string will be in the form of each letter followed by a positive integer representing the number of this letter existing in the original uncompressed string. Implement the StringIter...
""" 0604. Design Compressed String Iterator Design and implement a data structure for a compressed string iterator. The given compressed string will be in the form of each letter followed by a positive integer representing the number of this letter existing in the original uncompressed string. Implement the StringIter...
class HarmonyConfig(object): def __init__(self, config): self.json = config def get_activities(self): return self._build_kv_menu('activity') def get_devices(self): return self._build_kv_menu('device') def _build_kv_menu(self, key): menu = {} for d in self.json[...
class Harmonyconfig(object): def __init__(self, config): self.json = config def get_activities(self): return self._build_kv_menu('activity') def get_devices(self): return self._build_kv_menu('device') def _build_kv_menu(self, key): menu = {} for d in self.json...
# Copyright 2018 Databricks, Inc. VERSION = "1.12.1.dev0"
version = '1.12.1.dev0'
#!/usr/bin/env python # # Copyright (c) 2018 10X Genomics, Inc. All rights reserved. # __MRO__ = """ stage CHOOSE_DIMENSION_REDUCTION( in bool chemistry_batch_correction, out bool disable_run_pca, out bool disable_correct_chemistry_batch, src py "stages/analyzer/choose_dimension_reduction", ) """ ...
__mro__ = '\nstage CHOOSE_DIMENSION_REDUCTION(\n in bool chemistry_batch_correction,\n out bool disable_run_pca,\n out bool disable_correct_chemistry_batch,\n src py "stages/analyzer/choose_dimension_reduction",\n)\n' def main(args, outs): if args.chemistry_batch_correction is None or args.chemistry...
'''https://leetcode.com/problems/longest-common-subsequence/ 1143. Longest Common Subsequence Medium 4663 55 Add to List Share Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0. A subsequence of a string is a new string generated f...
"""https://leetcode.com/problems/longest-common-subsequence/ 1143. Longest Common Subsequence Medium 4663 55 Add to List Share Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0. A subsequence of a string is a new string generated f...
# Copyright 2021 BenchSci Analytics Inc. # Copyright 2021 Nate Gay # # 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 a...
"""rules_kustomize""" load('//:kustomization.bzl', _kustomization='kustomization') load('//:kustomize_image.bzl', _kustomize_image='kustomize_image') kustomization = _kustomization kustomize_image = _kustomize_image
class Program: language = 'Python' def say_hello(): print(f'Hello from {Program.language}') p = Program() print(type(p)) print(p.__dict__) print(Program.__dict__) print(p.__class__) # BEST PRACTICES print(isinstance(p, Program))
class Program: language = 'Python' def say_hello(): print(f'Hello from {Program.language}') p = program() print(type(p)) print(p.__dict__) print(Program.__dict__) print(p.__class__) print(isinstance(p, Program))
def assert_status_with_message(status_code=200, response=None, message=None): """ Check to see if a message is contained within a response. :param status_code: Status code that defaults to 200 :type status_code: int :param response: Flask response :type response: str :param message: String...
def assert_status_with_message(status_code=200, response=None, message=None): """ Check to see if a message is contained within a response. :param status_code: Status code that defaults to 200 :type status_code: int :param response: Flask response :type response: str :param message: String...
class TreeLeaf( object ): """Base class for Tree Leaf objects. Supports a single parent. Cannot have children. """ def __init__( self ): """Creates a tree leaf object. """ super( TreeLeaf, self ).__init__() self._parent = None @pr...
class Treeleaf(object): """Base class for Tree Leaf objects. Supports a single parent. Cannot have children. """ def __init__(self): """Creates a tree leaf object. """ super(TreeLeaf, self).__init__() self._parent = None @property def parent(self): ...
def roman_to_int(s): s = s.upper() try: rom_val = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000} int_val = 0 for i in range(len(s)): if i > 0 and rom_val[s[i]] > rom_val[s[i - 1]]: int_val += rom_val[s[i]] - 2 * rom_val[s[i - 1]] ...
def roman_to_int(s): s = s.upper() try: rom_val = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000} int_val = 0 for i in range(len(s)): if i > 0 and rom_val[s[i]] > rom_val[s[i - 1]]: int_val += rom_val[s[i]] - 2 * rom_val[s[i - 1]] ...
#!/usr/bin/env python3 """ This module containes general-purpose chemical data (aka tables). Sources: 1. www.ccdc.cam.ac.uk/Lists/ResourceFileList/Elemental_Radii.xlsx, (access date: 13 Oct 2015) 2. C. W. Yong, 'DL_FIELD - A force field and model development tool for DL_POLY', R. Blake, Ed., CSE Fron...
""" This module containes general-purpose chemical data (aka tables). Sources: 1. www.ccdc.cam.ac.uk/Lists/ResourceFileList/Elemental_Radii.xlsx, (access date: 13 Oct 2015) 2. C. W. Yong, 'DL_FIELD - A force field and model development tool for DL_POLY', R. Blake, Ed., CSE Frontier, STFC Computationa...
class OuterClass(object): def outer_method(self): def nested_function(): class InnerClass(object): class InnermostClass(object): def innermost_method(self): print() InnerClass.InnermostClass().innermost_method() ...
class Outerclass(object): def outer_method(self): def nested_function(): class Innerclass(object): class Innermostclass(object): def innermost_method(self): print() InnerClass.InnermostClass().innermost_method() ...
# -*- coding: utf-8 -*- # # Copyright (c) 2015, ParaTools, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # (1) Redistributions of source code must retain the above copyright notice, # t...
"""TODO: FIXME: Docs TAU Commander core software architecture. TAU Commander follows the `Model-View-Controller (MVC)`_ architectural pattern. Packages in :py:mod:`taucmdr.model` define models and controllers. The `model` module declares the model attributes as a dictionary named `ATTRIBUTES` in the form:: <att...
# S-box Table # We have 8 different 4x16 matrices for each S box #It converts 48 bits to 32 bits # Each S box will get 6 bits and output will be 4 bits s_box = [ [[14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7], [0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8], [4, 1, 14, 8...
s_box = [[[14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7], [0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8], [4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0], [15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13]], [[15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10], [3, 13, 4, 7, 15, 2, 8, 14, ...
# Split target image into an MxN grid def splitImage(image, size): W, H = image.size[0], image.size[1] m, n = size w, h = int(W/n), int(H/m) imgs = [] for j in range(m): for i in range(n): # append cropped image imgs.append(image.crop((i*w, j*h, (i+1)*w, (j+1)*h...
def split_image(image, size): (w, h) = (image.size[0], image.size[1]) (m, n) = size (w, h) = (int(W / n), int(H / m)) imgs = [] for j in range(m): for i in range(n): imgs.append(image.crop((i * w, j * h, (i + 1) * w, (j + 1) * h))) return imgs
def is_vowel(s: str) -> bool: if len(s) == 0 or len(s) > 1: return False vowel = ["a", "e", "i", "o", "u"] for item in s: if item.lower() in vowel: return True return False
def is_vowel(s: str) -> bool: if len(s) == 0 or len(s) > 1: return False vowel = ['a', 'e', 'i', 'o', 'u'] for item in s: if item.lower() in vowel: return True return False
# content of test_sample.py def func(x): return x + 2 def test_answer(): assert func(3) == 5 def test_2(): assert func(10) == 12
def func(x): return x + 2 def test_answer(): assert func(3) == 5 def test_2(): assert func(10) == 12
''' Created on Aug 7, 2017 @author: duncan ''' class Subscriber(object): def __init__(self, subscriber_id, subscriber_email): self.subscriber_id = subscriber_id self.subscriber_email = subscriber_email class Site(object): def __init__(self, site_id, site_name): self.site_id...
""" Created on Aug 7, 2017 @author: duncan """ class Subscriber(object): def __init__(self, subscriber_id, subscriber_email): self.subscriber_id = subscriber_id self.subscriber_email = subscriber_email class Site(object): def __init__(self, site_id, site_name): self.site_id = site_i...
# 2. Use the function to compute the square of all numbers of a given list def squares(a): squared = a*a return squared li = [1, 2, 3, 4, 5] lisq=[] for el in li: sq = squares(el) lisq.append(sq) print(lisq)
def squares(a): squared = a * a return squared li = [1, 2, 3, 4, 5] lisq = [] for el in li: sq = squares(el) lisq.append(sq) print(lisq)
# coding: utf-8 __author__ = 'Keita Tomochika' __version__ = '0.0.1' __license__ = 'MIT'
__author__ = 'Keita Tomochika' __version__ = '0.0.1' __license__ = 'MIT'
name = "openjpeg" version = "2.3.1" authors = [ "Image and Signal Processing Group, UCL" ] description = \ """ OpenJPEG is an open-source JPEG 2000 codec written in C language. It has been developed in order to promote the use of JPEG 2000, a still-image compression standard from the Joint Photograph...
name = 'openjpeg' version = '2.3.1' authors = ['Image and Signal Processing Group, UCL'] description = '\n OpenJPEG is an open-source JPEG 2000 codec written in C language. It has been developed in order to promote the\n use of JPEG 2000, a still-image compression standard from the Joint Photographic Experts Grou...
# Subject - the one to be observed # Observers - the one monitoring or observing the subject for changes class Subject: def __init__(self): self.__observers = [] def register(self, observer): self.__observers.append(observer) def notifyAll(self, *args, **kwargs): for observer in ...
class Subject: def __init__(self): self.__observers = [] def register(self, observer): self.__observers.append(observer) def notify_all(self, *args, **kwargs): for observer in self.__observers: observer.notify(self, *args, **kwargs) class Observer1: def __init__(...
def galoisMult(a, b): ''' The parameter b will be either 1, 2 or 3. Multiplication by 3 is defined as multiplication by 2 then adding the original value. For example 3x6 is equivalent to 2x6+6. The multiplication by 2 is done with a left shift (a <<= 1) and dropping the MSB. If that bit had been a...
def galois_mult(a, b): """ The parameter b will be either 1, 2 or 3. Multiplication by 3 is defined as multiplication by 2 then adding the original value. For example 3x6 is equivalent to 2x6+6. The multiplication by 2 is done with a left shift (a <<= 1) and dropping the MSB. If that bit had been a ...
diff_counter = 0 A = input() B = input() for i in range(len(A)): if A[i] != B[i]: diff_counter += 1 if diff_counter > 1: print("LARRY IS DEAD!") elif diff_counter == 1: print("LARRY IS SAVED!") else: print("LARRY IS DEAD!")
diff_counter = 0 a = input() b = input() for i in range(len(A)): if A[i] != B[i]: diff_counter += 1 if diff_counter > 1: print('LARRY IS DEAD!') elif diff_counter == 1: print('LARRY IS SAVED!') else: print('LARRY IS DEAD!')
""" dir([object]) Without arguments, return the list of names in the current local scope. With an argument, attempt to return a list of valid attributes for that object. """ class A: name = "Derick" age = 30 class Shape: def __dir__(self): return ['area', 'location', 'shape',] def b(): c = 1 ...
""" dir([object]) Without arguments, return the list of names in the current local scope. With an argument, attempt to return a list of valid attributes for that object. """ class A: name = 'Derick' age = 30 class Shape: def __dir__(self): return ['area', 'location', 'shape'] def b(): c = 1 ...
class Method: CHAR = 'char' WORD = 'word' SPECTROGRAM = 'spectrogram' AUDIO = 'audio' FLOW = 'flow' @staticmethod def getall(): return [Method.CHAR, Method.WORD, Method.AUDIO, Method.SPECTROGRAM, Method.FLOW]
class Method: char = 'char' word = 'word' spectrogram = 'spectrogram' audio = 'audio' flow = 'flow' @staticmethod def getall(): return [Method.CHAR, Method.WORD, Method.AUDIO, Method.SPECTROGRAM, Method.FLOW]
#!/usr/bin/env/python inp = open('top-1m.csv', 'r') out = open('top-1m__.csv', 'a+') out.write('"domain_id,"domain_name"') id = '' domain = '' while True: line = inp.readline() if len(line) > 0: cPos = line.find(',') id = line[:cPos] domain = line[cPos+1:] domain = '"'+dom...
inp = open('top-1m.csv', 'r') out = open('top-1m__.csv', 'a+') out.write('"domain_id,"domain_name"') id = '' domain = '' while True: line = inp.readline() if len(line) > 0: c_pos = line.find(',') id = line[:cPos] domain = line[cPos + 1:] domain = '"' + domain.rstrip() + '"' ...
TINY_TEST = False if TINY_TEST: MIN_BOUND = -2 MAX_BOUND = 2 else: MIN_BOUND = -200 MAX_BOUND = 200 WIDTH = (MAX_BOUND - MIN_BOUND) + 3 M = [["."] * WIDTH for i in range(WIDTH)] def setMap(p, v): x, y = p M[y - MIN_BOUND + 1][x - MIN_BOUND + 1] = v def getMap(p): x, y = p return M[...
tiny_test = False if TINY_TEST: min_bound = -2 max_bound = 2 else: min_bound = -200 max_bound = 200 width = MAX_BOUND - MIN_BOUND + 3 m = [['.'] * WIDTH for i in range(WIDTH)] def set_map(p, v): (x, y) = p M[y - MIN_BOUND + 1][x - MIN_BOUND + 1] = v def get_map(p): (x, y) = p return M[...
def even_numbers(func): def wrapper(nums): numbers = func(nums) return [num for num in numbers if num % 2 == 0] return wrapper @even_numbers def get_numbers(numbers): return numbers print(get_numbers([1, 2, 3, 4, 5]))
def even_numbers(func): def wrapper(nums): numbers = func(nums) return [num for num in numbers if num % 2 == 0] return wrapper @even_numbers def get_numbers(numbers): return numbers print(get_numbers([1, 2, 3, 4, 5]))
SEASONS = { 1: { "TITLE" : "Destiny 2", "EXPANSION" : "Destiny 2", "ACTIVE" : False, "YEAR" : "1", "START" : '2017-09-06 17:00:00', "END" : '2017-12-05 17:00:00', }, 2: { "TITLE" : "Curse of Osiris", "EXPANSION" : "Destiny 2", ...
seasons = {1: {'TITLE': 'Destiny 2', 'EXPANSION': 'Destiny 2', 'ACTIVE': False, 'YEAR': '1', 'START': '2017-09-06 17:00:00', 'END': '2017-12-05 17:00:00'}, 2: {'TITLE': 'Curse of Osiris', 'EXPANSION': 'Destiny 2', 'ACTIVE': False, 'YEAR': '1', 'START': '2017-12-05 17:00:01', 'END': '2018-05-08 17:00:00'}, 3: {'TITLE': ...
#Day 6 : Lets Review for i in range(int(input())): char = input() print("".join(char[::2]),"".join(char[1::2]))
for i in range(int(input())): char = input() print(''.join(char[::2]), ''.join(char[1::2]))
# Copyright 2017 Therp BV, ACSONE SA/NV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Client side message boxes", "version": "13.0.1.0.0", "author": "Therp BV, " "ACSONE SA/NV, " "Odoo Community Association (OCA)", "license": "AGPL-3", "category": "Hidden/Dependency", ...
{'name': 'Client side message boxes', 'version': '13.0.1.0.0', 'author': 'Therp BV, ACSONE SA/NV, Odoo Community Association (OCA)', 'license': 'AGPL-3', 'category': 'Hidden/Dependency', 'summary': 'Show a message box to users', 'depends': ['web'], 'data': ['views/templates.xml'], 'qweb': ['static/src/xml/web_ir_action...
def linked_sort(a,b,kf=''): mapped = sorted([(i,j) for i,j in zip(a,b)], key=kf or standard) bsr=[j for i,j in mapped] a.sort(key=(kf or standard)) b.sort(key=lambda x: bsr.index(x)) return a standard = lambda x: str(x)
def linked_sort(a, b, kf=''): mapped = sorted([(i, j) for (i, j) in zip(a, b)], key=kf or standard) bsr = [j for (i, j) in mapped] a.sort(key=kf or standard) b.sort(key=lambda x: bsr.index(x)) return a standard = lambda x: str(x)
def findDecision(obj): #obj[0]: Coupon, obj[1]: Education # {"feature": "Education", "instances": 34, "metric_value": 0.9597, "depth": 1} if obj[1]>1: # {"feature": "Coupon", "instances": 19, "metric_value": 0.998, "depth": 2} if obj[0]<=3: return 'True' elif obj[0]>3: return 'False' else: return 'False...
def find_decision(obj): if obj[1] > 1: if obj[0] <= 3: return 'True' elif obj[0] > 3: return 'False' else: return 'False' elif obj[1] <= 1: if obj[0] > 2: return 'True' elif obj[0] <= 2: return 'False' el...
one = ['1'] two = ['3'] three = ['9'] a = '1' b = '3' c = '9' v = [0,0,0] for i in range(1000): v[0] = int(a) v[1] = int(b) v[2] = int(c) for i in range(len(a)) : v[0] += int(a[i]) for i in range(len(b)) : v[1] += int(b[i]) for i in range(len(a)) : v[2] += int(c[i]) one.app...
one = ['1'] two = ['3'] three = ['9'] a = '1' b = '3' c = '9' v = [0, 0, 0] for i in range(1000): v[0] = int(a) v[1] = int(b) v[2] = int(c) for i in range(len(a)): v[0] += int(a[i]) for i in range(len(b)): v[1] += int(b[i]) for i in range(len(a)): v[2] += int(c[i]) on...
class MovieTrackingCamera: distortion_model = None division_k1 = None division_k2 = None focal_length = None focal_length_pixels = None k1 = None k2 = None k3 = None pixel_aspect = None principal = None sensor_width = None units = None
class Movietrackingcamera: distortion_model = None division_k1 = None division_k2 = None focal_length = None focal_length_pixels = None k1 = None k2 = None k3 = None pixel_aspect = None principal = None sensor_width = None units = None
print("digite um numero para consultar seu intervalo") x = int(input()) if 0 <= x <= 25: print('Intervalo [0,25]') if 25 < x <= 50: print('Intervalo (25,50]') if 50 < x <= 75: print('Intervalo (50,75]') if 75 < x <= 100: print('Intervalo (75,100]') else: print('Fora de intervalo')
print('digite um numero para consultar seu intervalo') x = int(input()) if 0 <= x <= 25: print('Intervalo [0,25]') if 25 < x <= 50: print('Intervalo (25,50]') if 50 < x <= 75: print('Intervalo (50,75]') if 75 < x <= 100: print('Intervalo (75,100]') else: print('Fora de intervalo')
""" Implement pow(x, n), which calculates x raised to the power n (i.e., xn). source - https://leetcode.com/problems/powx-n """ """ Time Complexity - O(Logn) Space Complexity - 1 """ # Faster class Solution: def myPow(self, x: float, n: int) -> float: return pow(x, n) """ Time Complexity - O(Logn) Space...
""" Implement pow(x, n), which calculates x raised to the power n (i.e., xn). source - https://leetcode.com/problems/powx-n """ '\nTime Complexity - O(Logn)\nSpace Complexity - 1\n' class Solution: def my_pow(self, x: float, n: int) -> float: return pow(x, n) '\nTime Complexity - O(Logn)\nSpace Complexit...
""" Shape Vertices. How to iterate over the vertices of a shape. When loading an obj or SVG, getVertexCount() will typically return 0 since all the vertices are in the child shapes. You should iterate through the children and then iterate through their vertices. """ def setup(): size(640, 360) # Load the sha...
""" Shape Vertices. How to iterate over the vertices of a shape. When loading an obj or SVG, getVertexCount() will typically return 0 since all the vertices are in the child shapes. You should iterate through the children and then iterate through their vertices. """ def setup(): size(640, 360) global uk u...
class HttpRequest(): def __init__(self, scope, body, receive, metadata=None, application=None): self._application = application self._scope = scope self._body = body self._cookies = None self._receive = receive self._subdomain, self._headers = metadata ...
class Httprequest: def __init__(self, scope, body, receive, metadata=None, application=None): self._application = application self._scope = scope self._body = body self._cookies = None self._receive = receive (self._subdomain, self._headers) = metadata self._...
""" Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. Example 1: Input: nums = [2,7,11,15], t...
""" Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. Example 1: Input: nums = [2,7,11,15], t...
# This dict is built through the metaclass applied to ExternalProvider. # It is intentionally empty here, and should remain empty. PROVIDER_LOOKUP = dict() def get_service(name): """Given a service name, return the provider class""" return PROVIDER_LOOKUP[name]()
provider_lookup = dict() def get_service(name): """Given a service name, return the provider class""" return PROVIDER_LOOKUP[name]()
dbodydict = dict() # dtitle, dbody fdbody = open("sample_alldoc_fake_body.dict") while 1: line = fdbody.readline() if not line: break tks = line.strip().split(' ') dbodydict[tks[0]]=tks[1] fclean = open("sample_valid_cqexp.cleaned") fexp = open("sample_valid_cqbody.cleaned",'w') while 1: ...
dbodydict = dict() fdbody = open('sample_alldoc_fake_body.dict') while 1: line = fdbody.readline() if not line: break tks = line.strip().split(' ') dbodydict[tks[0]] = tks[1] fclean = open('sample_valid_cqexp.cleaned') fexp = open('sample_valid_cqbody.cleaned', 'w') while 1: line = fclean.re...