content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
arr=[1,3,6,5,4,8,7,0] isSorted=False temp=0 while(not isSorted): isSorted=True for i in range(1,len(arr)-1): for j in range(len(arr)-i-1): if arr[i]>arr[i+1]: temp=arr[i] arr[i]=arr[i+1] arr[i+1]=temp print(arr)
arr = [1, 3, 6, 5, 4, 8, 7, 0] is_sorted = False temp = 0 while not isSorted: is_sorted = True for i in range(1, len(arr) - 1): for j in range(len(arr) - i - 1): if arr[i] > arr[i + 1]: temp = arr[i] arr[i] = arr[i + 1] arr[i + 1] = temp print(...
a=[2,4,6,8] b=[1,2,3,4] result=[] '''for i in a: if i in b: result.append(i)''' result=[i for i in a if i in b] print(result)
a = [2, 4, 6, 8] b = [1, 2, 3, 4] result = [] 'for i in a:\n if i in b:\n result.append(i)' result = [i for i in a if i in b] print(result)
#!/usr/bin/env python # -*- coding: utf-8 -*- MEMORY_SIZE = 64 DISPLAY_SIZE = 8 class VirtualMachine: def execute(program, heap = [], debug = False): labels = {} memory = [] display = [] buf = [] sp = 0 pc = 0 for pc in range(len(program)): t = ...
memory_size = 64 display_size = 8 class Virtualmachine: def execute(program, heap=[], debug=False): labels = {} memory = [] display = [] buf = [] sp = 0 pc = 0 for pc in range(len(program)): t = program[pc] if t[0] == 'lbl': ...
def ApodEclipseImage(): return "https://apod.nasa.gov/apod/image/1709/BT5643s.jpg" def ApodEclipsePage(): return "https://apod.nasa.gov/apod/ap170901.html" def ContentTypeToExtensions(): return { "image/jpeg": ".jpg", "image/jpg": ".jpg", "image/png": ".png" }
def apod_eclipse_image(): return 'https://apod.nasa.gov/apod/image/1709/BT5643s.jpg' def apod_eclipse_page(): return 'https://apod.nasa.gov/apod/ap170901.html' def content_type_to_extensions(): return {'image/jpeg': '.jpg', 'image/jpg': '.jpg', 'image/png': '.png'}
# table.py def print_table(objects, colnames): ''' Make a nicely formatted table showing attributes from a list of objects ''' for colname in colnames: print('{:>10s}'.format(colname), end=' ') print() for obj in objects: for colname in colnames: print('{:>10s}'.form...
def print_table(objects, colnames): """ Make a nicely formatted table showing attributes from a list of objects """ for colname in colnames: print('{:>10s}'.format(colname), end=' ') print() for obj in objects: for colname in colnames: print('{:>10s}'.format(str(getat...
loop = 0 loop2 = 0 howToMove = 5 side1 = 4 side2 = 6 printing = "" player = [" :}{: ", ":-/==\-:"] lazer = " || " noLazer = " " gap = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" lazer1 = [False, False, False, False, False, False, False, False, False, False, ...
loop = 0 loop2 = 0 how_to_move = 5 side1 = 4 side2 = 6 printing = '' player = [' :}{: ', ':-/==\\-:'] lazer = ' || ' no_lazer = ' ' gap = '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' lazer1 = [False, False, False, False, False, False, False, False, False, False, ...
class radixConvert(object): def __init__(self): return None def hexValuGet(self, srcNum=''): return int(srcNum, 16) def decValueGet(self, srcNum=''): return int(srcNum) def binValueGet(self, srcNum=''): return int(srcNum, 2) def hex2Dec(self, srcNum=''): ...
class Radixconvert(object): def __init__(self): return None def hex_valu_get(self, srcNum=''): return int(srcNum, 16) def dec_value_get(self, srcNum=''): return int(srcNum) def bin_value_get(self, srcNum=''): return int(srcNum, 2) def hex2_dec(self, srcNum=''): ...
def generateKey(string, key): key = list(key) if len(string) == len(key): return (key) else: for i in range(len(string) - len(key)): key.append(key[i % len(key)]) return ("".join(key)) def cipher_text(string, key): cipher_text = [] for i in ra...
def generate_key(string, key): key = list(key) if len(string) == len(key): return key else: for i in range(len(string) - len(key)): key.append(key[i % len(key)]) return ''.join(key) def cipher_text(string, key): cipher_text = [] for i in range(len(string)): x...
m = 998244353 N = int(input()) print(pow(6, N // 2, m))
m = 998244353 n = int(input()) print(pow(6, N // 2, m))
str.capitalize() str.lower() str.upper() word = 'banana' type(word)
str.capitalize() str.lower() str.upper() word = 'banana' type(word)
def get_serach_terms(file): ''' Bulk Loads a spreadsheet like datasource with search terms to pass to scraping engine ''' pass def get_file(file, destination): ''' Downloads a file from a specifed URL and saves to some location ''' pass def bulk_export(dfs): ''' Export...
def get_serach_terms(file): """ Bulk Loads a spreadsheet like datasource with search terms to pass to scraping engine """ pass def get_file(file, destination): """ Downloads a file from a specifed URL and saves to some location """ pass def bulk_export(dfs): """ Export...
#! /root/anaconda3/bin/python def a_line(a, b): def arg_y(y): return a * x + b return arg_y line1 = a_line(3, 5) line2 = a_line(5, 10) print(line1(10)) print(line1(20)) def a_line(a, b): return lambda x: a * x + b line1 = a_line(3, 5) line2 = a_line(5, 10) print(line1(10)) print(line1(20))
def a_line(a, b): def arg_y(y): return a * x + b return arg_y line1 = a_line(3, 5) line2 = a_line(5, 10) print(line1(10)) print(line1(20)) def a_line(a, b): return lambda x: a * x + b line1 = a_line(3, 5) line2 = a_line(5, 10) print(line1(10)) print(line1(20))
token="homme" token_stem = stemmer.stem(token) columns = ["CBOW", "skip-gram", "online"] df_ = [] msw_cbow = model_cbow.wv.most_similar([token_stem]) df_.append([msw_cbow[k][0] for k in range(10)]) msw_sg = model_sg.wv.most_similar([token_stem]) df_.append([msw_sg[k][0] for k in range(10)]) msw_online = model_online.w...
token = 'homme' token_stem = stemmer.stem(token) columns = ['CBOW', 'skip-gram', 'online'] df_ = [] msw_cbow = model_cbow.wv.most_similar([token_stem]) df_.append([msw_cbow[k][0] for k in range(10)]) msw_sg = model_sg.wv.most_similar([token_stem]) df_.append([msw_sg[k][0] for k in range(10)]) msw_online = model_online....
str = input("Enter strings: ") def pangram(str): test= "abcdefghijklmnopqrstuvwxyz" for char in test: if char not in str.lower(): return False return True if pangram (str)== True: print("Pangram exists") else: print("Pangram doesn't exists")
str = input('Enter strings: ') def pangram(str): test = 'abcdefghijklmnopqrstuvwxyz' for char in test: if char not in str.lower(): return False return True if pangram(str) == True: print('Pangram exists') else: print("Pangram doesn't exists")
mydict = dict() myset = set() mylist = [1,1,1,2,2,3,4,5,6,6,7] mylist = list(set(mylist)) print(mylist)
mydict = dict() myset = set() mylist = [1, 1, 1, 2, 2, 3, 4, 5, 6, 6, 7] mylist = list(set(mylist)) print(mylist)
# Strange Counter # https://www.hackerrank.com/challenges/strange-code/problem n = int(input()) max_score = 10e12 a, b = 1, 3 t_v_l = [] r = 0 while b < max_score: t_v_l.append((a, b,)) a += b b *= 2 for i in range(len(t_v_l)): if(t_v_l[i][0] <= n): r = t_v_l[i][1] - (n - t_v_l[i][0]) print...
n = int(input()) max_score = 10000000000000.0 (a, b) = (1, 3) t_v_l = [] r = 0 while b < max_score: t_v_l.append((a, b)) a += b b *= 2 for i in range(len(t_v_l)): if t_v_l[i][0] <= n: r = t_v_l[i][1] - (n - t_v_l[i][0]) print(r)
num = int(input()) for i in range(num): name = input().split(' ') name[0] = 'god' print(''.join(name))
num = int(input()) for i in range(num): name = input().split(' ') name[0] = 'god' print(''.join(name))
# COUNT ONES IN BINARY REPRESENTATION OF INTEGER EDABIT SOLUTION: # creating a function to solve the problem. def count_ones(num): # creating a variable to keep track of the count of number 1's. count = 0 # creating a variable to hold the binary representation of 'num'. bin_rep = bin(num) ...
def count_ones(num): count = 0 bin_rep = bin(num) for i in str(bin_rep): if bin_rep.count(i) == '1': count += 1 return count
def pooling(proto_layer, layer_infos, edges_info): for key, layer_info in layer_infos.items(): if layer_info['name'] == proto_layer.name: cur_layer_info = layer_info break # proto for edge in edges_info: if edge['to-layer'] == cur_layer_info['id']: top_name = layer_infos[i...
def pooling(proto_layer, layer_infos, edges_info): for (key, layer_info) in layer_infos.items(): if layer_info['name'] == proto_layer.name: cur_layer_info = layer_info break for edge in edges_info: if edge['to-layer'] == cur_layer_info['id']: top_name = layer_...
def checkout_time(customers, registers): tills = {} if registers == 1: return sum(customers) if len(customers) <= registers: return max(customers) for i in range(1, registers+1): tills[i] = customers[i] for j in range(registers, len(customers)): next_open = min(tills, key=tills.get) tills[next_open] += c...
def checkout_time(customers, registers): tills = {} if registers == 1: return sum(customers) if len(customers) <= registers: return max(customers) for i in range(1, registers + 1): tills[i] = customers[i] for j in range(registers, len(customers)): next_open = min(till...
class Solution: def findPairs(self, nums: List[int], k: int) -> int: nums.sort() x=0 l=0 r=l+1 while r<len(nums) and l<len(nums): if nums[r]-nums[l]<k or l==r: r=r+1 elif nums[r]-nums[l]==k: x=x+1 #print(...
class Solution: def find_pairs(self, nums: List[int], k: int) -> int: nums.sort() x = 0 l = 0 r = l + 1 while r < len(nums) and l < len(nums): if nums[r] - nums[l] < k or l == r: r = r + 1 elif nums[r] - nums[l] == k: x...
thing = 0 while thing < 20: print("I like turtles!") thing = thing + 1
thing = 0 while thing < 20: print('I like turtles!') thing = thing + 1
# ======================================================================== # sprites.py # # Description: Sprites for the 8x8 LED matrix on the Sense HAT. # # Author: Jim Ing # Date: 2020-02-22 # ======================================================================== class Sprites: def __init__(self): # Ba...
class Sprites: def __init__(self): w = (255, 255, 255) r = (255, 0, 0) g = (0, 255, 0) b = (0, 0, 255) c = (0, 255, 255) m = (255, 0, 255) y = (255, 255, 0) k = (0, 0, 0) self.blank = [K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K...
#!/usr/bin/python3 #File to save variable mute = '/home/volumio/bladelius/var/mute' vol = '/home/volumio/bladelius/var/vol' theinput = '/home/volumio/bladelius/var/input' power = '/home/volumio/bladelius/var/stat' #Volume volume = 0 #Power state power_state = 0
mute = '/home/volumio/bladelius/var/mute' vol = '/home/volumio/bladelius/var/vol' theinput = '/home/volumio/bladelius/var/input' power = '/home/volumio/bladelius/var/stat' volume = 0 power_state = 0
#!/usr/bin/env python class hashablyUniqueObject: # Typically you do not hash mutable objects. This hash value, however, # is independent of the state of this object. def __hash__(self): return id(self) # We also override the rich comparison operators to be consistent with # the uniqueness...
class Hashablyuniqueobject: def __hash__(self): return id(self) def __lt__(self, other): return NotImplemented def __le__(self, other): return NotImplemented def __eq__(self, other): return NotImplemented def __ne__(self, other): return NotImplemented ...
def sum_double(n, m): sum = (n+m) if n == m: return 2 * sum else: return sum result = sum_double(1, 2) print(result) result = sum_double(3, 2) print(result) result = sum_double(2, 2) print(result)
def sum_double(n, m): sum = n + m if n == m: return 2 * sum else: return sum result = sum_double(1, 2) print(result) result = sum_double(3, 2) print(result) result = sum_double(2, 2) print(result)
def reValuation(num): if (num >= 0 and num <= 9): return chr(num + ord('0')) else: return chr(num - 10 + ord('A')) def convert(res, base, inputNum): index = 0 while (inputNum > 0): res+= reValuation(inputNum % base) inputNum = int(inputNum / base) # Reverse the result res = res[::-1] return re...
def re_valuation(num): if num >= 0 and num <= 9: return chr(num + ord('0')) else: return chr(num - 10 + ord('A')) def convert(res, base, inputNum): index = 0 while inputNum > 0: res += re_valuation(inputNum % base) input_num = int(inputNum / base) res = res[::-1] ...
# # PySNMP MIB module AT-LOOPPROTECT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AT-LOOPPROTECT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:14:21 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, ...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, value_range_constraint, value_size_constraint, constraints_intersection, single_value_constraint) ...
consumer_key = "" consumer_secret = "" access_token = "" access_token_secret = "" # Change the following, if you have a different receipt printer # These values work for my ZD-5890K printer_vendor = 0x0416 printer_device = 0x5011
consumer_key = '' consumer_secret = '' access_token = '' access_token_secret = '' printer_vendor = 1046 printer_device = 20497
class Solution: def get_captures(self, board, r, c): result = 0 for i, j in [[1, 0], [0, 1], [-1, 0], [0, -1]]: y, x = r + i, c + j while 0 <= x < 8 and 0 <= y < 8: if board[y][x] == 'p': result += 1 if board[y][x] != '.': ...
class Solution: def get_captures(self, board, r, c): result = 0 for (i, j) in [[1, 0], [0, 1], [-1, 0], [0, -1]]: (y, x) = (r + i, c + j) while 0 <= x < 8 and 0 <= y < 8: if board[y][x] == 'p': result += 1 if board[y][x] !=...
def greet(name): while True: print('i hate you markerbot')
def greet(name): while True: print('i hate you markerbot')
#The script generates an error. Please add the appropriate code that adds variables a and b without an error. #A: The script generates an error saying that an integer object cannot convert to string implicitly. #Please try to convert the integer to a string explicitly then or the string to an integer. a = "1" b = 2...
a = '1' b = 2 print(a + b)
n = 400 print("%d %d" % (n, n-1)) for i in range(1, 400): print("%d %d" % (i, i +1)) print("%d %d" % (n, n*(n-1)//2)) for i in range(1, 400): for j in range(i + 1, 401): print("%d %d" % (i, j)) print("0 0")
n = 400 print('%d %d' % (n, n - 1)) for i in range(1, 400): print('%d %d' % (i, i + 1)) print('%d %d' % (n, n * (n - 1) // 2)) for i in range(1, 400): for j in range(i + 1, 401): print('%d %d' % (i, j)) print('0 0')
class Solution: def fib(self, n: int) -> int: if n == 0: return 0 elif n in [1, 2]: return 1 fib = [1, 1, 2] for i in range(3, n + 1): fib[(i - 1) % 3] = fib[i % 3] + fib[(i + 1) % 3] return fib[(i - 1) % 3]
class Solution: def fib(self, n: int) -> int: if n == 0: return 0 elif n in [1, 2]: return 1 fib = [1, 1, 2] for i in range(3, n + 1): fib[(i - 1) % 3] = fib[i % 3] + fib[(i + 1) % 3] return fib[(i - 1) % 3]
# # PySNMP MIB module HUAWEI-BRAS-QOS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-BRAS-QOS-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:31:22 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, constraints_intersection, single_value_constraint, constraints_union, value_range_constraint) ...
# Link to problem statement: https://www.hackerrank.com/challenges/quicksort1/problem def quick_sort(m, ar): if m < 2: print(ar[0]) else: p = ar[0] less = [] more = [] for item in ar[1:]: if item < p: less.append(item) else: ...
def quick_sort(m, ar): if m < 2: print(ar[0]) else: p = ar[0] less = [] more = [] for item in ar[1:]: if item < p: less.append(item) else: more.append(item) final = less + [p] + more print(' '.join([s...
class Solution: def longestConsecutive(self, nums: List[int]) -> int: longestStreak, numSet = 0, set(nums) for num in numSet: if num - 1 not in numSet: currentNum, currentStreak = num, 1 while currentNum + 1 in numSet: currentNum, curre...
class Solution: def longest_consecutive(self, nums: List[int]) -> int: (longest_streak, num_set) = (0, set(nums)) for num in numSet: if num - 1 not in numSet: (current_num, current_streak) = (num, 1) while currentNum + 1 in numSet: (cu...
BLACKLIST = [ 'null', 'kill yourself', 'fist me daddy', "don't flex", 'go die', 'fuck', 'fucker', 'dick', 'dickwad', 'asshole', 'asswipe', 'cum', 'cumming', 'cumwad', 'nigga', 'niggas', 'nigger', 'niggers', 'k k k', 'kk k', 'k kk', ...
blacklist = ['null', 'kill yourself', 'fist me daddy', "don't flex", 'go die', 'fuck', 'fucker', 'dick', 'dickwad', 'asshole', 'asswipe', 'cum', 'cumming', 'cumwad', 'nigga', 'niggas', 'nigger', 'niggers', 'k k k', 'kk k', 'k kk', 'harder daddy', 'harder dad', 'shh :i tt', 'sf u k k', 'sf u kk', 'sf u cee k', 'sf u k',...
# rename file to secrets.py token = "YOUR DISCORD BOT TOKEN HERE" # I recommend creating a sperate account specifically for the bot login = "YOUR E621 USERNAME" api_key = "YOUR E621 API KEY"
token = 'YOUR DISCORD BOT TOKEN HERE' login = 'YOUR E621 USERNAME' api_key = 'YOUR E621 API KEY'
# http://www.pythonchallenge.com/pc/def/0.html def main(): return 2**38 if __name__ == "__main__": print(main()) # http://www.pythonchallenge.com/pc/def/274877906944.html
def main(): return 2 ** 38 if __name__ == '__main__': print(main())
# GENERATED VERSION FILE # TIME: Tue Nov 23 22:36:16 2021 __version__ = '2.1.0+2cfaa8e' short_version = '2.1.0' version_info = (2, 1, 0)
__version__ = '2.1.0+2cfaa8e' short_version = '2.1.0' version_info = (2, 1, 0)
if __name__ == "__main__": gettext.install("myapp") # replace with the appropriate catalog name myapp = wx.PySimpleApp() appframe = MyAppFrame(None, wx.ID_ANY, "") myapp.SetTopWindow(appframe) appframe.Show() myapp.MainLoop()
if __name__ == '__main__': gettext.install('myapp') myapp = wx.PySimpleApp() appframe = my_app_frame(None, wx.ID_ANY, '') myapp.SetTopWindow(appframe) appframe.Show() myapp.MainLoop()
points = [] outter = None def setup(): global outter size(600, 600) for _ in range(20): points.append(PVector(random(50, width - 50), random(50, height - 50))) points.sort(key=lambda x: x.x) outter = JarvisMarch(points) print(outter) def draw(): background(51) ...
points = [] outter = None def setup(): global outter size(600, 600) for _ in range(20): points.append(p_vector(random(50, width - 50), random(50, height - 50))) points.sort(key=lambda x: x.x) outter = jarvis_march(points) print(outter) def draw(): background(51) stroke(255) ...
def get_slices_from_dataset_offset(offset, input_shape, output_shape=None): if output_shape is None: output_slice = None elif max(output_shape) == 0: output_slice = None else: borders = tuple([(in_ - out_) / 2 for (in_, out_) in zip(input_shape, output_shape)]) output_slice =...
def get_slices_from_dataset_offset(offset, input_shape, output_shape=None): if output_shape is None: output_slice = None elif max(output_shape) == 0: output_slice = None else: borders = tuple([(in_ - out_) / 2 for (in_, out_) in zip(input_shape, output_shape)]) output_slice =...
# Make Range my_list = [n for n in range(5)] # Check Iter my_iter = iter(my_list) # Print Data print(my_iter) print(next(my_iter)) print(next(my_iter)) print(next(my_iter)) print(next(my_iter)) print(next(my_iter)) print(next(my_iter)) print(next(my_iter))
my_list = [n for n in range(5)] my_iter = iter(my_list) print(my_iter) print(next(my_iter)) print(next(my_iter)) print(next(my_iter)) print(next(my_iter)) print(next(my_iter)) print(next(my_iter)) print(next(my_iter))
def print_32bit_hex_array(hex_array): for i in range (0, len(hex_array), 4): print ("[8][{0:>4}] [32][{1:>4}]: {2:02X} {3:02X} {4:02X} {5:02X}".format(i, (i / 4), hex_array[i], hex_array[i + 1], hex_array[i + 2], hex_array[i + 3]))
def print_32bit_hex_array(hex_array): for i in range(0, len(hex_array), 4): print('[8][{0:>4}] [32][{1:>4}]: {2:02X} {3:02X} {4:02X} {5:02X}'.format(i, i / 4, hex_array[i], hex_array[i + 1], hex_array[i + 2], hex_array[i + 3]))
def E(number_string): def strtolist(value): i = 0 list = [] while i < len(str(value)): list.append(value[i]) i = i + 1 return list def listtostr(list): string = '' i = 0 while i < len(list): string = string + list[i] ...
def e(number_string): def strtolist(value): i = 0 list = [] while i < len(str(value)): list.append(value[i]) i = i + 1 return list def listtostr(list): string = '' i = 0 while i < len(list): string = string + list[i] ...
## Create the hashing function which insert a key into tables...!!!! class myhash: def __init__ (self, b): ## b = size of m declare while create the object of class... self.bucket = b self.table = [[] for i in range(b)] def insert (self, x): ## x = key values ...
class Myhash: def __init__(self, b): self.bucket = b self.table = [[] for i in range(b)] def insert(self, x): i = x % self.bucket self.table[i].append(x) def delete(self, x): i = x % self.bucket if x in self.table[i]: self.table[i].remove(x) ...
class ElectricityReadingRepository: def __init__(self): self.meter_associated_readings = {} def store(self, smart_meter_id, readings): if smart_meter_id in self.meter_associated_readings: existing_list_of_readings = self.meter_associated_readings.get(smart_meter_id) self...
class Electricityreadingrepository: def __init__(self): self.meter_associated_readings = {} def store(self, smart_meter_id, readings): if smart_meter_id in self.meter_associated_readings: existing_list_of_readings = self.meter_associated_readings.get(smart_meter_id) sel...
def noExistBook(book_nm): return 'book : ' + book_nm + ' does not exist' def noExistInst(inst_nm): return 'instrument : ' + inst_nm + ' does not exist' def noInstrumentExistInBook(inst_nm, book_nm): return inst_nm + ' does not exist in book : ' + book_nm def instrumentExistInBook(inst_nm, book_nm): ...
def no_exist_book(book_nm): return 'book : ' + book_nm + ' does not exist' def no_exist_inst(inst_nm): return 'instrument : ' + inst_nm + ' does not exist' def no_instrument_exist_in_book(inst_nm, book_nm): return inst_nm + ' does not exist in book : ' + book_nm def instrument_exist_in_book(inst_nm, book...
''' Write a program that takes two arrays representing integers, and retums an integer representing their product. ''' def multiply(x, y): # Time: O(xy) sign = -1 if (x[0] < 0) ^ (y[0] < 0) else 1 x[0], y[0] = abs(x[0]), abs(y[0]) result = [0] * (len(x) + len(y)) for i in reversed(range(len(x))): ...
""" Write a program that takes two arrays representing integers, and retums an integer representing their product. """ def multiply(x, y): sign = -1 if (x[0] < 0) ^ (y[0] < 0) else 1 (x[0], y[0]) = (abs(x[0]), abs(y[0])) result = [0] * (len(x) + len(y)) for i in reversed(range(len(x))): for j i...
arr = [list(map(int, input().split())) for _ in range(10)] x = 1 y = 1 while 1: arr[x][y] = 9 if arr[x][y + 1] != 1: y += 1 elif arr[x + 1][y] != 1: x += 1 else: break if arr[x][y] == 2: break arr[x][y] = 9 for i in range(10): for j in range(10): print(arr[i][j], end='' if j == 9 else ' ') prin...
arr = [list(map(int, input().split())) for _ in range(10)] x = 1 y = 1 while 1: arr[x][y] = 9 if arr[x][y + 1] != 1: y += 1 elif arr[x + 1][y] != 1: x += 1 else: break if arr[x][y] == 2: break arr[x][y] = 9 for i in range(10): for j in range(10): print(arr...
def planify_array(array: list[str]): result = [] for elem in array: if type(elem) is list: planify_array(elem) if type(elem) is str: result.append(elem) else: result.extend(elem) return result def card_bill_add_details_from_card_statement(card_bi...
def planify_array(array: list[str]): result = [] for elem in array: if type(elem) is list: planify_array(elem) if type(elem) is str: result.append(elem) else: result.extend(elem) return result def card_bill_add_details_from_card_statement(card_bil...
class BinaryTreesOnAParticleSet(object): def __init__(self, particles_set, name_of_firstchild_attribute, name_of_secondchild_attribute): self.particles_set = particles_set self.name_of_firstchild_attribute = name_of_firstchild_attribute self.name_of_secondchild_attribute = name_of_secondch...
class Binarytreesonaparticleset(object): def __init__(self, particles_set, name_of_firstchild_attribute, name_of_secondchild_attribute): self.particles_set = particles_set self.name_of_firstchild_attribute = name_of_firstchild_attribute self.name_of_secondchild_attribute = name_of_secondchi...
# https://www.acmicpc.net/problem/1987 def dfs(x, y, depth): res[0] = max(res[0], depth) for diff_x, diff_y in zip(dx, dy): next_x = x + diff_x next_y = y + diff_y if not (0 <= next_x < C and 0 <= next_y < R): continue next_value = grid[next_y][next_x] if v...
def dfs(x, y, depth): res[0] = max(res[0], depth) for (diff_x, diff_y) in zip(dx, dy): next_x = x + diff_x next_y = y + diff_y if not (0 <= next_x < C and 0 <= next_y < R): continue next_value = grid[next_y][next_x] if visited[next_value]: continue...
DB_IP='pgsql' DB_PORT='5432' DB_ID='postgres' DB_PW='' BIND_ADDR="0.0.0.0" DEBUG=False
db_ip = 'pgsql' db_port = '5432' db_id = 'postgres' db_pw = '' bind_addr = '0.0.0.0' debug = False
#print ("Paket internet jaringan 4g, Mau ?") #print ("1. Mau\n2.Internet&BB\3. Nelp&SMS\n") #a = input("") #print ("kamu memilih {}".format(a)) #if a=="1": # print("paket 4g hanya dengan Rp 1.000.000") #elif a=="2": # print("paket internet Rp 5.000.000 plus cowok ganteng") #else : #print ("anda salah pilih,...
a = 3 b = 5 c = a * b print(c)
keys = { 'up': 'w', 'down': 's', 'left': 'a', 'right': 'd', 'done': '1' }
keys = {'up': 'w', 'down': 's', 'left': 'a', 'right': 'd', 'done': '1'}
# # PySNMP MIB module CISCO-APPLICATION-ACCELERATION-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-APPLICATION-ACCELERATION-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:50:14 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, single_value_constraint, value_size_constraint, constraints_union, constraints_intersection) ...
# Write your solution here def sum_of_positives(my_list): sum = 0 for item in my_list: if item > 0: sum += item return sum if __name__ == "__main__": my_list = [1, -2, 3, -4, 5] result = sum_of_positives(my_list) print("The result is", result)
def sum_of_positives(my_list): sum = 0 for item in my_list: if item > 0: sum += item return sum if __name__ == '__main__': my_list = [1, -2, 3, -4, 5] result = sum_of_positives(my_list) print('The result is', result)
# This file contains UW specific values on the server side to be localized. # It's really just here to make creation of the messages file easier. # Space Types _('server_alcove') _('server_cafe') _('server_classroom') _('server_computer_lab') _('server_lounge') _('server_open') _('server_outdoor') _('server_studio') _...
_('server_alcove') _('server_cafe') _('server_classroom') _('server_computer_lab') _('server_lounge') _('server_open') _('server_outdoor') _('server_studio') _('server_study_area') _('server_study_room')
# noinspection PyUnusedLocal # skus = unicode string def checkout(skus): ''' Input: string of goods to checkout. Example: 'ABCADAZ' Output: total checkout value (attention to special offers) ''' price_rules = Constant.PRICE_RULES price_rules.sort(key = lambda x:x[0], reverse = True) ...
def checkout(skus): """ Input: string of goods to checkout. Example: 'ABCADAZ' Output: total checkout value (attention to special offers) """ price_rules = Constant.PRICE_RULES price_rules.sort(key=lambda x: x[0], reverse=True) offer_rules = Constant.OFFER_RULES offer_rules.sort(key=lamb...
class Config: def __init__(self, slots=None): self.slots = slots or [None] * 8 def slots(self): return self.slots def slot_for(self, ingredient): for index, slot in enumerate(self.slots): if slot.lower() in ingredient.lower() or ingredient.lower() in slot.lower(): ...
class Config: def __init__(self, slots=None): self.slots = slots or [None] * 8 def slots(self): return self.slots def slot_for(self, ingredient): for (index, slot) in enumerate(self.slots): if slot.lower() in ingredient.lower() or ingredient.lower() in slot.lower(): ...
# Done by Carlos Amaral (2020/09/22) tuple_variable = (3, 5, 7, 3, 2, 5, 2, 7, 3, 3) total = 0 for value in tuple_variable: total = total + value print("The total of the values in the tuple is: ", total)
tuple_variable = (3, 5, 7, 3, 2, 5, 2, 7, 3, 3) total = 0 for value in tuple_variable: total = total + value print('The total of the values in the tuple is: ', total)
def meshHeight(name, x, z): pass
def mesh_height(name, x, z): pass
def recursive_group(records): root = {} for record in records: node = root for value in record: node = node.setdefault(value, {}) return root
def recursive_group(records): root = {} for record in records: node = root for value in record: node = node.setdefault(value, {}) return root
class Node(object): pass class Registry(object): pass
class Node(object): pass class Registry(object): pass
ip = '141.58.x.x' port = 5672 username = 'admin' password = 'admin' host = '/'
ip = '141.58.x.x' port = 5672 username = 'admin' password = 'admin' host = '/'
schoolClass = {} while True: name = input("Enter the student's name (or type exit to stop): ") if name == 'exit': break score = int(input("Enter the student's score (0-10): ")) if name in schoolClass: schoolClass[name] += (score,) else: schoolClass[name] = (score,) for na...
school_class = {} while True: name = input("Enter the student's name (or type exit to stop): ") if name == 'exit': break score = int(input("Enter the student's score (0-10): ")) if name in schoolClass: schoolClass[name] += (score,) else: schoolClass[name] = (score,) for name ...
class JSONMergeError(Exception): def __init__(self, message, value=None, strategy_name=None): self.message = message self.value = value self.strategy_name = strategy_name def __str__(self): r = self.message try: ref = self.value.ref except: ref = None if ref is not None: r = "%s: %s" % (r, r...
class Jsonmergeerror(Exception): def __init__(self, message, value=None, strategy_name=None): self.message = message self.value = value self.strategy_name = strategy_name def __str__(self): r = self.message try: ref = self.value.ref except: ...
# PYHTON CONDICIONAIS (IF) if 5 > 2: print('BACKUP Funciona') else: print('Algo esta errado') if 5 == 5: print('Testando BACKUP')
if 5 > 2: print('BACKUP Funciona') else: print('Algo esta errado') if 5 == 5: print('Testando BACKUP')
#!/usr/bin/env python class ComputerSim(object): def __init__(self): self.latency = 1 self.cpu = 1 def set_latency(self, val): self.latency = val def set_cpu(self, val): self.cpu = val
class Computersim(object): def __init__(self): self.latency = 1 self.cpu = 1 def set_latency(self, val): self.latency = val def set_cpu(self, val): self.cpu = val
s1, s2, s3 = map(str, input().split()) s1 = list(map(str, s1)) s2 = list(map(str, s2)) s3 = list(map(str, s3)) print(s1[0].upper() + s2[0].upper() + s3[0].upper())
(s1, s2, s3) = map(str, input().split()) s1 = list(map(str, s1)) s2 = list(map(str, s2)) s3 = list(map(str, s3)) print(s1[0].upper() + s2[0].upper() + s3[0].upper())
def gen_nums(): n = 0 while n < 20: yield n n += 1 for num in gen_nums(): print(num)
def gen_nums(): n = 0 while n < 20: yield n n += 1 for num in gen_nums(): print(num)
num = int(input('digite um nr de 0 a 9999: ')) if num < 10: x = str('0'+'0'+'0'+str(num)) print(f'UNIDADE: {x[3]}') print(f'DEZENA: {x[2]}') print(f'CENTENA: {x[1]}') print(f'MILHAR: {x[0]}') elif num < 100: x = str('0' + '0' + str(num)) print(f'UNIDADE: {x[3]}') print(f'DEZENA...
num = int(input('digite um nr de 0 a 9999: ')) if num < 10: x = str('0' + '0' + '0' + str(num)) print(f'UNIDADE: {x[3]}') print(f'DEZENA: {x[2]}') print(f'CENTENA: {x[1]}') print(f'MILHAR: {x[0]}') elif num < 100: x = str('0' + '0' + str(num)) print(f'UNIDADE: {x[3]}') print(f'DEZENA: {x...
def simplegesture(name, point_list): '''A simple helper function to create and return a gesture''' g = Gesture() g.add_stroke(point_list) g.normalize() g.name = name return g class GestureBoard(FloatLayout): def on_touch_down(self, touch): '''Collect points in touch.ud''...
def simplegesture(name, point_list): """A simple helper function to create and return a gesture""" g = gesture() g.add_stroke(point_list) g.normalize() g.name = name return g class Gestureboard(FloatLayout): def on_touch_down(self, touch): """Collect points in touch.ud""" w...
def bar_function(debugger, args, result, dict): global UtilityModule print >>result, (UtilityModule.barutil_function("bar told me " + args)) return None def __lldb_init_module(debugger, session_dict): global UtilityModule UtilityModule = __import__("barutil") debugger.HandleCommand("command script add -f bar.ba...
def bar_function(debugger, args, result, dict): global UtilityModule (print >> result, UtilityModule.barutil_function('bar told me ' + args)) return None def __lldb_init_module(debugger, session_dict): global UtilityModule utility_module = __import__('barutil') debugger.HandleCommand('command s...
class Solution: def maxProfit(self, prices: List[int]) -> int: maxProfit, minCost = 0, float('inf') for price in prices: minCost = min(minCost, price) maxProfit = max(maxProfit, price - minCost) return maxProfit
class Solution: def max_profit(self, prices: List[int]) -> int: (max_profit, min_cost) = (0, float('inf')) for price in prices: min_cost = min(minCost, price) max_profit = max(maxProfit, price - minCost) return maxProfit
expected_output = { "interfaces": { "GigabitEthernet1/0/2": { "description": "test_of_parser", "switchport_trunk_vlans": "500,821,900-905", "switchport_mode": "trunk", "flow_monitor_input": "IPv4_NETFLOW", "ip_arp_inspection_trust": True, ...
expected_output = {'interfaces': {'GigabitEthernet1/0/2': {'description': 'test_of_parser', 'switchport_trunk_vlans': '500,821,900-905', 'switchport_mode': 'trunk', 'flow_monitor_input': 'IPv4_NETFLOW', 'ip_arp_inspection_trust': True, 'ip_arp_inspection_limit_rate': '100', 'load_interval': '30', 'power_inline': {'stat...
t = int(input().strip()) # no. of cases read in h = 1 while h<=t: # loop over case inputs # read in case inputs m, n = input().strip().split() rx, ry = input().strip().split() o = int(input()) s = list(input()) x = 0 y = 0 for i in s: # loop over instructions, calculate x and...
t = int(input().strip()) h = 1 while h <= t: (m, n) = input().strip().split() (rx, ry) = input().strip().split() o = int(input()) s = list(input()) x = 0 y = 0 for i in s: if i == 'L': x -= 1 elif i == 'R': x += 1 elif i == 'U': y +...
def add(x,y): return x + y def subtract(x,y): return x - y def multiply(x,y): return x * y def divide(x,y): if y != 0: return x/y else: return None
def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): return x * y def divide(x, y): if y != 0: return x / y else: return None
class BadToken(Exception): pass class TokenExpired(Exception): pass class Forbidden(Exception): pass
class Badtoken(Exception): pass class Tokenexpired(Exception): pass class Forbidden(Exception): pass
class Wheels: _midPos = False _leftPos = False _rightPos = False _curPos = False POS_MID = 1 POS_LEFT = 2 POS_RIGHT = 3 def __init__(self, midPos, leftPos, rightPos): self._midPos = midPos self._rightPos = rightPos self._leftPos = leftPos self._curPos = ...
class Wheels: _mid_pos = False _left_pos = False _right_pos = False _cur_pos = False pos_mid = 1 pos_left = 2 pos_right = 3 def __init__(self, midPos, leftPos, rightPos): self._midPos = midPos self._rightPos = rightPos self._leftPos = leftPos self._curPos...
class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def hasCycle(self, head): s = set() while(head != None): if id(head) not in s: s.add(id(head)) else: return True ...
class Listnode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def has_cycle(self, head): s = set() while head != None: if id(head) not in s: s.add(id(head)) else: return True ...
TPB_URL = "https://thepiratebay.org" KICKASS_URL = "http://kat.cr" EZTV_URL = "http://eztvapi.co.za/" NYAA_URL = "http://www.nyaa.se/" YTS_URL = "http://yts.ag" RARBG_URL = "https://rarbg.to" CPABSIEN_URL = "http://www.cpasbien.io/recherche/films/" T411_URL = "https://api.t411.me/" STRIKE_URL = "https://getstrike.net" ...
tpb_url = 'https://thepiratebay.org' kickass_url = 'http://kat.cr' eztv_url = 'http://eztvapi.co.za/' nyaa_url = 'http://www.nyaa.se/' yts_url = 'http://yts.ag' rarbg_url = 'https://rarbg.to' cpabsien_url = 'http://www.cpasbien.io/recherche/films/' t411_url = 'https://api.t411.me/' strike_url = 'https://getstrike.net' ...
class Env: @classmethod def load(cls): return cls() def __init__(self): self.rgroup = 'testrg' self.subscription = 'testapp' self.host = 'http://localhost:5000'
class Env: @classmethod def load(cls): return cls() def __init__(self): self.rgroup = 'testrg' self.subscription = 'testapp' self.host = 'http://localhost:5000'
def concatenation(firstString, secondString): answer = firstString + secondString return answer def findLength(string): return len(string)
def concatenation(firstString, secondString): answer = firstString + secondString return answer def find_length(string): return len(string)
#!/usr/bin/env python # coding=utf-8 __import__('pkg_resources').declare_namespace(__name__) __version__ = '0.0.1' __author__ = 'hk'
__import__('pkg_resources').declare_namespace(__name__) __version__ = '0.0.1' __author__ = 'hk'
class FusionObject: def __init__(self): self.detected = False self.fused = False self.distance = 0 self.velocity = 0 self.rect = [0, 0, 0, 0] def setDetection(self, detection): self.detected = detection return self def setDistance(self, distance): ...
class Fusionobject: def __init__(self): self.detected = False self.fused = False self.distance = 0 self.velocity = 0 self.rect = [0, 0, 0, 0] def set_detection(self, detection): self.detected = detection return self def set_distance(self, distance):...
class Solution: def lengthOfLIS(self, nums: 'List[int]') -> 'int': dp = [] for num in nums: left, right = 0, len(dp) - 1 while left <= right: mid = (left + right + 1) >> 1 if num < dp[mid]: right = mid - 1 el...
class Solution: def length_of_lis(self, nums: 'List[int]') -> 'int': dp = [] for num in nums: (left, right) = (0, len(dp) - 1) while left <= right: mid = left + right + 1 >> 1 if num < dp[mid]: right = mid - 1 ...
''' Copyright (c) 2020 Modul 9/HiFiBerry Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribu...
""" Copyright (c) 2020 Modul 9/HiFiBerry Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribu...
def bubbleSort(lis): for i in range(len(lis)-1, 0, -1): for j in range(i): if lis[j] > lis[j+1]: temp = lis[j] lis[j]= lis[j+1] lis[j+1]= temp print("Current_state : ", lis) if __name__=="__main__": lis = list(map(int, inpu...
def bubble_sort(lis): for i in range(len(lis) - 1, 0, -1): for j in range(i): if lis[j] > lis[j + 1]: temp = lis[j] lis[j] = lis[j + 1] lis[j + 1] = temp print('Current_state : ', lis) if __name__ == '__main__': lis = list(map(int, ...
expected_output = { "vrf": { "process1": { "address_family": { "ipv6": { "distance": 120, "interfaces": {"Gigabitethernet0/0/0": {}}, "maximum_paths": 1, "multicast_group": "FF02::9", ...
expected_output = {'vrf': {'process1': {'address_family': {'ipv6': {'distance': 120, 'interfaces': {'Gigabitethernet0/0/0': {}}, 'maximum_paths': 1, 'multicast_group': 'FF02::9', 'originate_default_route': {'enabled': True}, 'pid': 62, 'poison_reverse': False, 'port': 521, 'redistribute': {'bgp': {65001: {'route_policy...
# Databricks notebook source # MAGIC %md # MAGIC # MAGIC **Project:** ***CCU003-CKD*** # MAGIC # MAGIC **Description** This notebook creates validated CKD code list prepared during CaReMe UCL-AZ project # MAGIC # MAGIC **requierments** N/A # MAGIC # MAGIC **Author(s)** Muhammad Dashtban (aka. Ashkan) # MAGIC # MAG...
cols = ['id', 'stage', 'dia', 'dueto', 'term'] ckd_codelist = [('700379002', 3, 0, 0, 'chronic kidney disease stage 3b'), ('324121000000109', 1, 0, 0, 'chronic kidney disease stage 1 with proteinuria'), ('994401000006102', 1, 0, 0, 'chronic kidney disease stage 1'), ('431855005', 1, 0, 0, 'chronic kidney disease stage ...
rows = int(input()) for num in range(rows): for i in range(num): print(num, end="") print("")
rows = int(input()) for num in range(rows): for i in range(num): print(num, end='') print('')
# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. # # Use of this source code is governed by a BSD-style license # that can be found in the LICENSE file in the root of the source # tree. An additional intellectual property rights grant can be found # in the file PATENTS. All contributing project au...
{'includes': ['../../../../../common_settings.gypi'], 'targets': [{'target_name': 'NetEq', 'type': '<(library)', 'dependencies': ['../../../codecs/CNG/main/source/cng.gyp:CNG', '../../../../../common_audio/signal_processing_library/main/source/spl.gyp:spl'], 'defines': ['NETEQ_VOICEENGINE_CODECS', 'SCRATCH'], 'include_...
''' Interface Genie Ops Object Outputs for IOS. ''' class InterfaceOutput(object): ShowInterfaces = '''\ Vlan1 is up, line protocol is up Hardware is EtherSVI, address is 843d.c638.b9c0 (bia 843d.c638.b9c0) MTU 1500 bytes, BW 1000000 Kbit, DLY 10 usec, reliability 255/...
""" Interface Genie Ops Object Outputs for IOS. """ class Interfaceoutput(object): show_interfaces = ' Vlan1 is up, line protocol is up \n Hardware is EtherSVI, address is 843d.c638.b9c0 (bia 843d.c638.b9c0)\n MTU 1500 bytes, BW 1000000 Kbit, DLY 10 usec, \n reliability 255/25...
def findTokens(sc): _var="" _cond="" _exp_1="" _exp_2="" var=True cond=True exp_1=True exp_2=True _is_str=False str_var="" str_cond="" str_exp_1="" str_exp_2="" for i in sc: if i=='=': if var: var=False _var=s...
def find_tokens(sc): _var = '' _cond = '' _exp_1 = '' _exp_2 = '' var = True cond = True exp_1 = True exp_2 = True _is_str = False str_var = '' str_cond = '' str_exp_1 = '' str_exp_2 = '' for i in sc: if i == '=': if var: var = ...
# Code to instruct the computer to count up to 20 by twos and display output to the screen # The above text is commentary. The actual program starts below: # Input: number, an integer variable # Output: a vertical list of integers in the range specified in your range statement. print ("\n\n\nPython 3.0 Workbook\n...
print('\n\n\nPython 3.0 Workbook\nStudent Work Booklet\nStudent Activity 3.0b2\n\n') print('A program to count numbers up to 20 by twos and to display the output to the screen.') print('It uses the range statement so you can do it in just two lines.') print('You just need to add a third parameter to the range statement...
a = [] b = [] for m in range(101): a.append(300 - m*100) for n in range(101): b.append(a[n]+200) c = 0 for a in b: if a < 0: c+=1 print(c)
a = [] b = [] for m in range(101): a.append(300 - m * 100) for n in range(101): b.append(a[n] + 200) c = 0 for a in b: if a < 0: c += 1 print(c)