content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
a = 34 b = "Roots's" c = 'Root' d = '''ROOT"s''' print(a,b,c,d) print(type(a))
a = 34 b = "Roots's" c = 'Root' d = 'ROOT"s' print(a, b, c, d) print(type(a))
# --- default umap config ----- n_neighbors = 30 spread = 1.0 min_dist = 0.1 random_state = 42 verbose = False # --- default stochastic embedding config ----- # fraction of samples used as neighbors neighbor_frac = 0.7 # fraction of samples used as centroids centroid_frac = 0.7 smoothing_epochs = 0 smoothing_neighbors...
n_neighbors = 30 spread = 1.0 min_dist = 0.1 random_state = 42 verbose = False neighbor_frac = 0.7 centroid_frac = 0.7 smoothing_epochs = 0 smoothing_neighbors = None max_iter = 2000 a = 500 b = 1
input() count = [0]*100 for n in map(int, input().split()): count[n] += 1 print(" ".join(map(str, count)))
input() count = [0] * 100 for n in map(int, input().split()): count[n] += 1 print(' '.join(map(str, count)))
def check_guess(number, guess): ret = [] rnge = min(len(number),len(guess)) for i in range(0,rnge): if guess[i] == number[i]: ret.append('+') elif number.find(guess[i]) != -1: ret.append('*') else: ret.append('-') return ret
def check_guess(number, guess): ret = [] rnge = min(len(number), len(guess)) for i in range(0, rnge): if guess[i] == number[i]: ret.append('+') elif number.find(guess[i]) != -1: ret.append('*') else: ret.append('-') return ret
MODE_INDICATOR = 4 BITS_CHAR_COUNT_INDICATOR = lambda v: 8 if v <= 9 else 16 PAD1 = 0b11101100 PAD2 = 0b00010001 G15 = ( (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0)) G18 = ( (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 <<...
mode_indicator = 4 bits_char_count_indicator = lambda v: 8 if v <= 9 else 16 pad1 = 236 pad2 = 17 g15 = 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0 g18 = 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0 g15_mask = 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1 error_corr_level =...
def divisores(): n = int(input()) for i in range(1, n+1): if n % i == 0: print(i) divisores()
def divisores(): n = int(input()) for i in range(1, n + 1): if n % i == 0: print(i) divisores()
#palindrome n=int(input("Enter number:")) copy=n rev=0 while copy>0: rev=rev*10+copy%10 copy//=10 if rev==n: print("Palindrome") else: print("Not")
n = int(input('Enter number:')) copy = n rev = 0 while copy > 0: rev = rev * 10 + copy % 10 copy //= 10 if rev == n: print('Palindrome') else: print('Not')
if __name__ == '__main__': n = int(input()) student_marks = {} for _ in range(n): name, *line = input().split() scores = list(map(float, line)) student_marks[name] = scores query_name = input() def avg_list(li): average=sum(li)/len(li) avg_format="{:.2f}".format(average)...
if __name__ == '__main__': n = int(input()) student_marks = {} for _ in range(n): (name, *line) = input().split() scores = list(map(float, line)) student_marks[name] = scores query_name = input() def avg_list(li): average = sum(li) / len(li) avg_format = '{:.2f}'.format(...
log_tfid = Pipeline([ ("vectorizer", TfidfVectorizer(stop_words='english')), ("log_reg", LogisticRegression(solver='liblinear')) ]) len(text_train) len(text_test) log_tfid.fit(text_train, y_train) log_tfid.score(text_test, y_test) feature_names = log_tfid["vectorizer"].get_feature_names_out() log_reg_coefs...
log_tfid = pipeline([('vectorizer', tfidf_vectorizer(stop_words='english')), ('log_reg', logistic_regression(solver='liblinear'))]) len(text_train) len(text_test) log_tfid.fit(text_train, y_train) log_tfid.score(text_test, y_test) feature_names = log_tfid['vectorizer'].get_feature_names_out() log_reg_coefs = log_tfid['...
# https://codeforces.com/problemset/problem/1335/A t = int(input()) for _ in range(t): n = int(input()) if n % 2 == 0: result = int(n / 2 - 1) print(result) else: result = int(n // 2) print(result)
t = int(input()) for _ in range(t): n = int(input()) if n % 2 == 0: result = int(n / 2 - 1) print(result) else: result = int(n // 2) print(result)
#!/usr/bin/python3 def max_integer(my_list=[]): if len(my_list) == 0: return None m = my_list[0] for i in my_list: if i > m: m = i return m
def max_integer(my_list=[]): if len(my_list) == 0: return None m = my_list[0] for i in my_list: if i > m: m = i return m
for n in range(15, 23 + 1): # rn = (816 * n + 2880 * 1.05**(n - 1)) # rn = ((8 * n * 102) + ((120 * 24) * 1.05**(n - 1))) rn = ((8 * n * 102) + (((120 * 24) * (1 - 1.05**n)) / (1 - 1.05))) for n2 in range(15, 32 + 1): # rn2 = (1040 * n2 + (2842 * n2 + 42 * n2**2)) rn2 = ((65 * n2 * 16) +...
for n in range(15, 23 + 1): rn = 8 * n * 102 + 120 * 24 * (1 - 1.05 ** n) / (1 - 1.05) for n2 in range(15, 32 + 1): rn2 = 65 * n2 * 16 + 1 / 2 * n2 * (2 * (103 * 28) + (n2 - 1) * (28 * 3)) if abs(rn - rn2) <= 1000: print(n, n2, 'value', abs(rn - rn2))
tot18 = toth = totm20 = 0 while True: print('-' * 30) print('CADASTRE UM PESSOA') print('-' * 30) idade = int(input('Idade: ')) sexo = ' ' while sexo not in 'MF': sexo = str(input('Sexo: [M/F]')).strip().upper()[0] if sexo == 'M': toth = toth + 1 if idade >= 18: t...
tot18 = toth = totm20 = 0 while True: print('-' * 30) print('CADASTRE UM PESSOA') print('-' * 30) idade = int(input('Idade: ')) sexo = ' ' while sexo not in 'MF': sexo = str(input('Sexo: [M/F]')).strip().upper()[0] if sexo == 'M': toth = toth + 1 if idade >= 18: t...
#give a string character and filepath as input paramters to a function # and get occurences of that character as an output of that function def process(character, filepath): myfile = open(filepath) content = myfile.read() myfile.close() count = content.count(character) return count a = input("Ente...
def process(character, filepath): myfile = open(filepath) content = myfile.read() myfile.close() count = content.count(character) return count a = input('Enter Character') b = input('File name') print(process(a, b))
class MunHa: BLACK, WHITE = '@', 'o' # SETAR O VALOR DE INFINITO E DE -INFINITO INF, NINF = 100000, -100000 #IMPLEMENTAR def heuristic(self, board, move, color): other_color = self._change_color(color) table = [ [120, -20, 20, 5, 5, 20, -20, 120], [-20, -40,...
class Munha: (black, white) = ('@', 'o') (inf, ninf) = (100000, -100000) def heuristic(self, board, move, color): other_color = self._change_color(color) table = [[120, -20, 20, 5, 5, 20, -20, 120], [-20, -40, -5, -5, -5, -5, -40, -20], [20, -5, 15, 3, 3, 15, -5, 20], [5, -5, 3, 3, 3, 3, -5...
def make_list(): result = [] in_value = 0 while in_value >= 0: in_value = int(input("List Items: ")) if in_value >= 0: result += [in_value] return result def main(): col = make_list() print(col) '''Mking list from range object''' lst = list(range(0,1)) print(lst * 5)...
def make_list(): result = [] in_value = 0 while in_value >= 0: in_value = int(input('List Items: ')) if in_value >= 0: result += [in_value] return result def main(): col = make_list() print(col) 'Mking list from range object' lst = list(range(0, 1)) print(lst * 5) k ...
#!/usr/bin/env python # -*- coding: utf-8 -*- class User: id = None
class User: id = None
# 3. Capitals # Using a dictionary comprehension, write a program which receives country names on the first line, # separated by comma and space ", ", and their corresponding capital cities on the second line # (again separated by comma and space ", "). Print each country with their capital on a separate # line in the ...
countries = input().split(', ') capitals = input().split(', ') print('\n'.join([f'{key} -> {value}' for (key, value) in {countries[index]: capitals[index] for index in range(len(countries))}.items()]))
input_str = '' with open('input.txt') as f: input_str = f.read() raw_passports = input_str.split('\n\n') almost_not_raw = list(map(lambda x: x.replace('\n', ' '), raw_passports)) almost_not_raw = list(map(lambda x: x.split(' '), almost_not_raw)) done = [] for i in almost_not_raw: temp = list(filter(None, i)) to_ap...
input_str = '' with open('input.txt') as f: input_str = f.read() raw_passports = input_str.split('\n\n') almost_not_raw = list(map(lambda x: x.replace('\n', ' '), raw_passports)) almost_not_raw = list(map(lambda x: x.split(' '), almost_not_raw)) done = [] for i in almost_not_raw: temp = list(filter(None, i)) ...
a=int(input()) b=int(input()) t=a a=b b=t print("Swapped values are:",a,b)
a = int(input()) b = int(input()) t = a a = b b = t print('Swapped values are:', a, b)
while True: T = int(input('')) if T == 0: break else: for i in range(T): X = str(input('')) S = X.split() C = int(S[0]) A = float(S[1]) B = float(S[2]) D = (((A + B) / 2) * 5) * C print('Size #%d:' %(i+1)) ...
while True: t = int(input('')) if T == 0: break else: for i in range(T): x = str(input('')) s = X.split() c = int(S[0]) a = float(S[1]) b = float(S[2]) d = (A + B) / 2 * 5 * C print('Size #%d:' % (i + 1)) ...
OPERATORS = [ '==', '!=', '>=', '<=', '<', '>' ] BASE = { '112': { 'c': 'print', 'argvs':[], 'kwargs':{ 'end': '""' } }, '105': { 'c': 'input', 'argvs':[], 'kwargs':{} }, '99': { 'c': 'le...
operators = ['==', '!=', '>=', '<=', '<', '>'] base = {'112': {'c': 'print', 'argvs': [], 'kwargs': {'end': '""'}}, '105': {'c': 'input', 'argvs': [], 'kwargs': {}}, '99': {'c': 'len', 'argvs': [], 'kwargs': {}}} def get(code): for (c, v) in BASE.items(): if str(c) == str(code): return v re...
DATABASE_ENGINE = 'sqlite3' INSTALLED_APPS = [ 'ckeditor', ] CKEDITOR_MEDIA_PREFIX = '/media/' CKEDITOR_UPLOAD_PATH = '/tmp'
database_engine = 'sqlite3' installed_apps = ['ckeditor'] ckeditor_media_prefix = '/media/' ckeditor_upload_path = '/tmp'
x=9 y=3 #basic math operations print(x+y) print(x-y) print(x*y) print(x/y) print(x%y) #remainder print(x**y) #exponents x=9.191823 print(x//y) #floor division #assignments x=9 x+=3 #x = x + 3 print(x) x=9 x-=3 # x = x-3 print(x) x+=3 print(x) x/=3 print(x) x **=3 print(x) x = 9 y = 3 pri...
x = 9 y = 3 print(x + y) print(x - y) print(x * y) print(x / y) print(x % y) print(x ** y) x = 9.191823 print(x // y) x = 9 x += 3 print(x) x = 9 x -= 3 print(x) x += 3 print(x) x /= 3 print(x) x **= 3 print(x) x = 9 y = 3 print(x == y) print(x != y) print(x > y) print(x >= y) print(x <= y)
def to_lower(text): return text.str.lower() def remove_punctuation(text): pattern = "[" + string.punctuation + "]+" text = text.str.replace(pattern, " ", regex=True) text = text.str.replace("\n", " ", regex=False) return text def lemmatize_stopwords(s): # I combine lemmatization and stopword r...
def to_lower(text): return text.str.lower() def remove_punctuation(text): pattern = '[' + string.punctuation + ']+' text = text.str.replace(pattern, ' ', regex=True) text = text.str.replace('\n', ' ', regex=False) return text def lemmatize_stopwords(s): doc = nlp(s) lemma = [] for toke...
string=input('Enter string here: ') new_string=' ' for i in range(0,len(string)): #check for lower case character if string[i].islower(): #convert it into uppercase using upper() function new_string = new_string+string[i].upper() #checks for upper case character elif string[i].isupper(): #convert it...
string = input('Enter string here: ') new_string = ' ' for i in range(0, len(string)): if string[i].islower(): new_string = new_string + string[i].upper() elif string[i].isupper(): new_string = new_string + string[i].lower() else: new_string = new_string + string[i] print(f'String af...
''' Created on Sep 10, = 2012 @author: miips640 ''' MAX_PATH = 260 DRV_ERROR_CODES = 20001 DRV_SUCCESS = 20002 DRV_VXDNOTINSTALLED = 20003 DRV_ERROR_SCAN = 20004 DRV_ERROR_CHECK_SUM = 20005 DRV_ERROR_FILELOAD = 20006 DRV_UNKNOWN_FUNCTION = 20007 DRV_ERROR_VXD_INIT = 20008 DRV_ERROR_ADDRESS = 20009 DRV_ERROR_PAGELOCK...
""" Created on Sep 10, = 2012 @author: miips640 """ max_path = 260 drv_error_codes = 20001 drv_success = 20002 drv_vxdnotinstalled = 20003 drv_error_scan = 20004 drv_error_check_sum = 20005 drv_error_fileload = 20006 drv_unknown_function = 20007 drv_error_vxd_init = 20008 drv_error_address = 20009 drv_error_pagelock =...
class Firmware: def __init__(self, firmware_path: str, ipsw): self._ipsw = ipsw self._firmware_path = firmware_path self._manifest_data = self._ipsw.read(self.get_relative_path('manifest')) self._firmware_files = {} for filename in self._manifest_data.splitlines(): ...
class Firmware: def __init__(self, firmware_path: str, ipsw): self._ipsw = ipsw self._firmware_path = firmware_path self._manifest_data = self._ipsw.read(self.get_relative_path('manifest')) self._firmware_files = {} for filename in self._manifest_data.splitlines(): ...
class SettingsContainer: __writable__ = False dryrun = False def __enter__(self): self.__writable__ = True def __exit__(self, *args, **kwargs): self.__writable__ = False def __setattr__(self, key, value): if key != '__writable__': if not hasattr(self, key): ...
class Settingscontainer: __writable__ = False dryrun = False def __enter__(self): self.__writable__ = True def __exit__(self, *args, **kwargs): self.__writable__ = False def __setattr__(self, key, value): if key != '__writable__': if not hasattr(self, key): ...
#-*- coding: utf-8 -*- device_version = { "android": "2.2.7", "android_donate": "2.1.8", "ios": "1.6.0" } # Token duration in seconds token_duration = 3600 serect_key = "usapoijupojfa;dsj;lv;ldakjads;lfkjapoiuewqprjf" # HTTP Status Code ok = 200 no_content = 204
device_version = {'android': '2.2.7', 'android_donate': '2.1.8', 'ios': '1.6.0'} token_duration = 3600 serect_key = 'usapoijupojfa;dsj;lv;ldakjads;lfkjapoiuewqprjf' ok = 200 no_content = 204
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def maxPathSum(self, root: Optional[TreeNode]) -> int: self.maxPath = -inf def maxGain(node)...
class Solution: def max_path_sum(self, root: Optional[TreeNode]) -> int: self.maxPath = -inf def max_gain(node): if node is None: return 0 left = max(max_gain(node.left), 0) right = max(max_gain(node.right), 0) cur_path = node.val + l...
board = [ [0, 0, 0, 2, 6, 0, 7, 0, 1], [6, 8, 0, 0, 7, 0, 0, 9, 0], [1, 9, 0, 0, 0, 4, 5, 0, 0], [8, 2, 0, 1, 0, 0, 0, 4, 0], [0, 0, 4, 6, 0, 2, 9, 0, 0], [0, 5, 0, 0, 0, 3, 0, 2, 8], [0, 0, 9, 3, 0, 0, 0, 7, 4], [0, 4, 0, 0, 5, 0, 0, 3, 6], [7, 0, 3, 0, 1, 8, 0, 0, 0] ] def valida...
board = [[0, 0, 0, 2, 6, 0, 7, 0, 1], [6, 8, 0, 0, 7, 0, 0, 9, 0], [1, 9, 0, 0, 0, 4, 5, 0, 0], [8, 2, 0, 1, 0, 0, 0, 4, 0], [0, 0, 4, 6, 0, 2, 9, 0, 0], [0, 5, 0, 0, 0, 3, 0, 2, 8], [0, 0, 9, 3, 0, 0, 0, 7, 4], [0, 4, 0, 0, 5, 0, 0, 3, 6], [7, 0, 3, 0, 1, 8, 0, 0, 0]] def validate(board, y, x, value): for i in ra...
#!/usr/bin/python3.4 class ToDoList: def __init__(self): self.list = [] def addItem(self, task): self.list.append(task) def deleteItem(self, task): self.list.remove(task) def viewList(self): print("\n".join(self.list)) MyTodoList = ToDoList() MyTodoList.addItem('Take a shower'); MyTodoList.addItem('Go...
class Todolist: def __init__(self): self.list = [] def add_item(self, task): self.list.append(task) def delete_item(self, task): self.list.remove(task) def view_list(self): print('\n'.join(self.list)) my_todo_list = to_do_list() MyTodoList.addItem('Take a shower') MyT...
def execute(code): pc, step = 0, 0 while pc in range(0, len(code)): code[pc] += 1 pc += code[pc] - 1 step += 1 return step instructions = list(map(int,open("day5.txt").readlines())) # = 342669 #instructions = [0, 3 ,0, 1, -3] # = 5 print("Steps 'till exit:", execute(inst...
def execute(code): (pc, step) = (0, 0) while pc in range(0, len(code)): code[pc] += 1 pc += code[pc] - 1 step += 1 return step instructions = list(map(int, open('day5.txt').readlines())) print("Steps 'till exit:", execute(instructions))
# noinspection PyPep8Naming class classproperty(property): # noinspection PyMethodOverriding def __get__(self, obj, type_): return self.fget.__get__(None, type_)()
class Classproperty(property): def __get__(self, obj, type_): return self.fget.__get__(None, type_)()
class Cell: def __init__(self, content: str, normalized: str, candidates: list, is_lit_cell=False): self.content = content self.normalized = normalized self.is_lit_cell = is_lit_cell self._cands_entities = [ cand[1] for cand in candidates ] se...
class Cell: def __init__(self, content: str, normalized: str, candidates: list, is_lit_cell=False): self.content = content self.normalized = normalized self.is_lit_cell = is_lit_cell self._cands_entities = [cand[1] for cand in candidates] self._cands_labels = {} for ...
f = open('pg27780.txt', 'r') for line in f: line = line.strip() words = line.split(' ') for w in words: if(w.strip() != ''): print(w.strip())
f = open('pg27780.txt', 'r') for line in f: line = line.strip() words = line.split(' ') for w in words: if w.strip() != '': print(w.strip())
#!/usr/bin/env python # encoding: utf-8 ''' @author: Jason Lee @license: (C) Copyright @ Jason Lee @contact: jiansenll@163.com @file: jianzhi_offer_35.py @time: 2019/5/1 15:07 @desc: ''' class Solution: def FirstNotRepeatingChar(self, s): if not s: return -1 count = [0] * (ord(...
""" @author: Jason Lee @license: (C) Copyright @ Jason Lee @contact: jiansenll@163.com @file: jianzhi_offer_35.py @time: 2019/5/1 15:07 @desc: """ class Solution: def first_not_repeating_char(self, s): if not s: return -1 count = [0] * (ord('z') - ord('A') + 1) for val i...
#4 for row in range(10): for col in range(9): if col+row==6 or row==6 or (col==6): print("*",end=" ") else: print(" ",end=" ") print()
for row in range(10): for col in range(9): if col + row == 6 or row == 6 or col == 6: print('*', end=' ') else: print(' ', end=' ') print()
CACHE = {} @profile def leonardo(number): if number in (0, 1): return 1 if number not in CACHE: result = leonardo(number - 1) + leonardo(number - 2) + 1 CACHE[number] = result ret_value = CACHE[number] MAX_SIZE = 5 while len(CACHE) > MAX_SIZE: # Maximum size al...
cache = {} @profile def leonardo(number): if number in (0, 1): return 1 if number not in CACHE: result = leonardo(number - 1) + leonardo(number - 2) + 1 CACHE[number] = result ret_value = CACHE[number] max_size = 5 while len(CACHE) > MAX_SIZE: key = list(CACHE.keys()...
class Stack: def __init__(self): self.data = [] def __repr__(self): return(str(self.data)) def push(self, value): self.data.append(value) def pop(self): if len(self.data) == 0: return None else: return self.data.pop() def peek(self): if len(self.data) == 0: retur...
class Stack: def __init__(self): self.data = [] def __repr__(self): return str(self.data) def push(self, value): self.data.append(value) def pop(self): if len(self.data) == 0: return None else: return self.data.pop() def peek(self)...
def DivisiblePairCount(arr, n) : res = 0 for i in range(0, n): for j in range(i+1, n): if (arr[i] % arr[j] == 0 or arr[j] % arr[i] == 0): res+=1 return res if __name__=='__main__': arr = [int(item) for item in input("Enter the array items : ").split()] n = le...
def divisible_pair_count(arr, n): res = 0 for i in range(0, n): for j in range(i + 1, n): if arr[i] % arr[j] == 0 or arr[j] % arr[i] == 0: res += 1 return res if __name__ == '__main__': arr = [int(item) for item in input('Enter the array items : ').split()] n = le...
class Node: def __init__(self,data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def __str__(self): res = [] temp = self.head while temp: res.append(f"{temp.data}") temp = ...
class Node: def __init__(self, data): self.data = data self.next = None class Linkedlist: def __init__(self): self.head = None def __str__(self): res = [] temp = self.head while temp: res.append(f'{temp.data}') temp = temp.next ...
''' Design a logger system that receive stream of messages along with its timestamps, each message should be printed if and only if it is not printed in the last 10 seconds. Given a message and a timestamp (in seconds granularity), return true if the message should be printed in the given timestamp, otherwise returns ...
""" Design a logger system that receive stream of messages along with its timestamps, each message should be printed if and only if it is not printed in the last 10 seconds. Given a message and a timestamp (in seconds granularity), return true if the message should be printed in the given timestamp, otherwise returns ...
ranges = [] for line in open('input.txt', 'r'): ranges.append(list(map(int, line.split('-')))) ranges.sort() i = 0 while i < len(ranges) - 1: if ranges[i][1] >= ranges[i + 1][0] - 1: ranges[i][1] = max(ranges[i][1], ranges[i + 1][1]) ranges.pop(i + 1) else: i += 1 allowed = 4294967...
ranges = [] for line in open('input.txt', 'r'): ranges.append(list(map(int, line.split('-')))) ranges.sort() i = 0 while i < len(ranges) - 1: if ranges[i][1] >= ranges[i + 1][0] - 1: ranges[i][1] = max(ranges[i][1], ranges[i + 1][1]) ranges.pop(i + 1) else: i += 1 allowed = 429496729...
#!/usr/bin/env python2 def heal(connection, canal, auteur, cmds, canalobj, mogbot): user = mogbot.getUserManager().findUser(auteur) if user == False: connection.privmsg(canal, auteur + " je ne te trouve pas dans la base de donnees :( - erreur 500") return if user.battle != None: con...
def heal(connection, canal, auteur, cmds, canalobj, mogbot): user = mogbot.getUserManager().findUser(auteur) if user == False: connection.privmsg(canal, auteur + ' je ne te trouve pas dans la base de donnees :( - erreur 500') return if user.battle != None: connection.privmsg(canal, a...
s, t = input().strip().split(' ') s, t = [int(s), int(t)] a, b = input().strip().split(' ') a, b = [int(a), int(b)] m, n = input().strip().split(' ') m, n = [int(m), int(n)] apple_distances = [ int(apple_temp) for apple_temp in input().strip().split(' ') ] orange_distances = [ int(orange_temp) fo...
(s, t) = input().strip().split(' ') (s, t) = [int(s), int(t)] (a, b) = input().strip().split(' ') (a, b) = [int(a), int(b)] (m, n) = input().strip().split(' ') (m, n) = [int(m), int(n)] apple_distances = [int(apple_temp) for apple_temp in input().strip().split(' ')] orange_distances = [int(orange_temp) for orange_temp ...
def count_array(a, b, nestedlist): count = 0 for i in range(0, a): for j in range(0, b): if nestedlist[i][j] == 0: count += 1 return count
def count_array(a, b, nestedlist): count = 0 for i in range(0, a): for j in range(0, b): if nestedlist[i][j] == 0: count += 1 return count
_base_ = 'resnet50_8xb32-coslr_in1k.py' # Precise BN hook will update the bn stats, so this hook should be executed # before CheckpointHook, which has priority of 'NORMAL'. So set the # priority of PreciseBNHook to 'ABOVE_NORMAL' here. custom_hooks = [ dict( type='PreciseBNHook', num_samples=8192, ...
_base_ = 'resnet50_8xb32-coslr_in1k.py' custom_hooks = [dict(type='PreciseBNHook', num_samples=8192, interval=1, priority='ABOVE_NORMAL')]
''' Module providing functionality for tracer-kinetic model fitting in DCE-MRI ''' __all__ = ['data_io', 'dce_aif', 'dibem', 'tissue_concentration', 'tofts_model']
""" Module providing functionality for tracer-kinetic model fitting in DCE-MRI """ __all__ = ['data_io', 'dce_aif', 'dibem', 'tissue_concentration', 'tofts_model']
class Particle: def __init__(self, charge, boson, lepton, mass): self.charge = charge self.boson = boson self.lepton = lepton self.mass = mass
class Particle: def __init__(self, charge, boson, lepton, mass): self.charge = charge self.boson = boson self.lepton = lepton self.mass = mass
def op_add(arg1, arg2): return arg1 + arg2 def op_mult(arg1, arg2): return arg1 * arg2 def op_power(arg1, arg2): return arg1 ** arg2 def op_split(arg1, n_outs): return [arg1] * n_outs def op_negate(arg1, negate=True): if negate: return 0 else: return arg1
def op_add(arg1, arg2): return arg1 + arg2 def op_mult(arg1, arg2): return arg1 * arg2 def op_power(arg1, arg2): return arg1 ** arg2 def op_split(arg1, n_outs): return [arg1] * n_outs def op_negate(arg1, negate=True): if negate: return 0 else: return arg1
class CellularAutomata: ## configurable changeToDead = 3 changeToAlive = 1 def __init__(self, matrix, steps, alive, dead): self.matrix = matrix self.steps = steps self.alive = alive self.dead = dead self.height = len(matrix) self.width = len(matrix[0]) def checkBoundary(self, xPos, yPos): if xPos >...
class Cellularautomata: change_to_dead = 3 change_to_alive = 1 def __init__(self, matrix, steps, alive, dead): self.matrix = matrix self.steps = steps self.alive = alive self.dead = dead self.height = len(matrix) self.width = len(matrix[0]) def check_bou...
# First we should notice that sum(|a_i - a_j|) >= max(a) - min(a). # Left and right are equal if and only if a is sorted (in either order). # # When we sort an array, we are essentially doing a permutation (See # https://en.wikipedia.org/wiki/Permutation#Permutations_in_group_theory). # The permutation can be broken do...
def count_swaps(A): visited = [False] * len(A) def ring_gen(x): visited[x] = True i = x while A[i] != x: visited[A[i]] = True yield A[i] i = A[i] return sum((sum((1 for x in ring_gen(i))) for i in range(len(A)) if not visited[i])) n = int(input())...
DEFAULT_LOG_FILE = '/opt/logs/logs.txt' CHATBOT_LOG_FILE = '/opt/logs/chatbot-logs.txt' AGENT_CREDENTIALS_FILE = 'app/credentials/agent_credentials.json' DB_CREDENTIALS_FILE = 'app/credentials/db_credentials.json' API_KEYS_FILE = 'app/credentials/api_keys.json' DEFAULT_JOKES_FILE = 'app/database/default_jokes.txt' ENVI...
default_log_file = '/opt/logs/logs.txt' chatbot_log_file = '/opt/logs/chatbot-logs.txt' agent_credentials_file = 'app/credentials/agent_credentials.json' db_credentials_file = 'app/credentials/db_credentials.json' api_keys_file = 'app/credentials/api_keys.json' default_jokes_file = 'app/database/default_jokes.txt' envi...
# entrada de inteiros A = int(input()) B = int(input()) # soma SOMA = A + B print('SOMA = {}'.format(SOMA))
a = int(input()) b = int(input()) soma = A + B print('SOMA = {}'.format(SOMA))
def fetch_base_url(cfg=None): base_url = '' if cfg is not None and cfg.has_section('backend'): base_url = cfg.get('backend', 'base_url') if cfg.has_option('backend', 'base_url') else '' return base_url
def fetch_base_url(cfg=None): base_url = '' if cfg is not None and cfg.has_section('backend'): base_url = cfg.get('backend', 'base_url') if cfg.has_option('backend', 'base_url') else '' return base_url
bunga =["Angrek", "Mawar", "Melati", "Kamboja", "Teratai", "Lily", "Tulip", "Kertas", "Asoka", "Bougenville", "Kemuning "] print(bunga) print(bunga[0]) print(bunga[6:9]) bunga[0] = "Anggrek Ungu" bunga[1] = "Mawar Putih" print(bunga) KeteranganMawarPutih ={"Nama":"Mawar Putih"} print(KeteranganMawarPutih) pohon = ("Man...
bunga = ['Angrek', 'Mawar', 'Melati', 'Kamboja', 'Teratai', 'Lily', 'Tulip', 'Kertas', 'Asoka', 'Bougenville', 'Kemuning '] print(bunga) print(bunga[0]) print(bunga[6:9]) bunga[0] = 'Anggrek Ungu' bunga[1] = 'Mawar Putih' print(bunga) keterangan_mawar_putih = {'Nama': 'Mawar Putih'} print(KeteranganMawarPutih) pohon = ...
sam = [ { "name": "pigz", "params": { "cmd": "pigz", "cmparg": "-c -p {threads}", "decarg": "-c -d -p {threads}", "stdin": "{in}", "stdout": "{out}", "ext": "gz" } }, { "name": "pbzip2", "params": { "cmd": "pbzip2", "cmparg": "-c -p{threads}", "decarg": "-c -d -p{threads...
sam = [{'name': 'pigz', 'params': {'cmd': 'pigz', 'cmparg': '-c -p {threads}', 'decarg': '-c -d -p {threads}', 'stdin': '{in}', 'stdout': '{out}', 'ext': 'gz'}}, {'name': 'pbzip2', 'params': {'cmd': 'pbzip2', 'cmparg': '-c -p{threads}', 'decarg': '-c -d -p{threads}', 'stdin': '{in}', 'stdout': '{out}', 'ext': 'bz2'}}, ...
# Code it up # Create a program that adds 25 to the value of each character of a string that a user enters. This new string should be saved and output. def addASCIIValue(string, value): return ''.join([chr(ord(i)+value) for i in string]) def main(): string = input('Enter a string: ') value = int(input('Enter ...
def add_ascii_value(string, value): return ''.join([chr(ord(i) + value) for i in string]) def main(): string = input('Enter a string: ') value = int(input('Enter value to encrypt string: ')) encryption_type = input('Do you want to Encode or Decode the string? [E/D] ').upper() new_string = add_ascii...
class algebric: def __init__(self,number,algebric={}): if number==0 and (algebric): number=1 self.num=number self.al=algebric def __repr__(self): return str(self.num)+' '.join([a+"^"+str(self.al[a]) for a in self.al]) def ha(self): return bool(self.algebric) class calculator: def is_float(self,value): ...
class Algebric: def __init__(self, number, algebric={}): if number == 0 and algebric: number = 1 self.num = number self.al = algebric def __repr__(self): return str(self.num) + ' '.join([a + '^' + str(self.al[a]) for a in self.al]) def ha(self): return ...
dogs = ['husky', 'beagle', 'doberman', 'dachsund', 'collie', 'mutt'] cats = ['siamese', 'burmese', 'angora', 'maine coon', 'manx'] # Bad! for i in range(min(len(cats), len(dogs))): print("Would you like a {} or a {}".format(cats[i], dogs[i])) print("") # Good! for cat, dog in zip(cats, dogs): print("Would...
dogs = ['husky', 'beagle', 'doberman', 'dachsund', 'collie', 'mutt'] cats = ['siamese', 'burmese', 'angora', 'maine coon', 'manx'] for i in range(min(len(cats), len(dogs))): print('Would you like a {} or a {}'.format(cats[i], dogs[i])) print('') for (cat, dog) in zip(cats, dogs): print('Would you like a {} or a...
class ConfigObserver(object): def __init__(self): pass def alarm_added(self, alarm): raise NotImplemented("alarm_added is not implemented") def alarm_deleted(self, id): raise NotImplemented("alarm_deleted is not implemented") def alarm_changed(self, alarm): raise NotIm...
class Configobserver(object): def __init__(self): pass def alarm_added(self, alarm): raise not_implemented('alarm_added is not implemented') def alarm_deleted(self, id): raise not_implemented('alarm_deleted is not implemented') def alarm_changed(self, alarm): raise no...
# Concept No. 1: FUNCTIONS print("print is a function, functions do things. You know something is a function typically when you see ()") # Concept No. 2: VARIABLES myVariable = "Variables are simply containers which hold values" # Concept No. 3: LISTS myList = ["Lists", "are", "like", "variables", "but","contain", "...
print('print is a function, functions do things. You know something is a function typically when you see ()') my_variable = 'Variables are simply containers which hold values' my_list = ['Lists', 'are', 'like', 'variables', 'but', 'contain', 'many', 'values'] 'I am a string, a basic data type (human readable text used ...
{ "targets":[ { "target_name": "round", "sources": ["round.cc"] }, { "target_name": "setFactor", "sources": ["round.cc"] } ] }
{'targets': [{'target_name': 'round', 'sources': ['round.cc']}, {'target_name': 'setFactor', 'sources': ['round.cc']}]}
# this script surveys concept of container # Containers are any object that holds an arbitrary number of other objects. # Generally, containers provide a way to access the contained objects # and to iterate over them. listContainer1 = [1, 2, 3, 4] # list comprehension to create a list contrainer listContainer2 = [3...
list_container1 = [1, 2, 3, 4] list_container2 = [3, 4, 5, 6] set_container1 = set(listContainer1) set_container2 = set(listContainer2) set_union = setContainer1 | setContainer2 print() print(setUnion) print() tuple_container = (1, 'red', 2) print(tupleContainer) print() dict_container = {1: 'first', 2: 'second'} print...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def flip_equiv(self, root1: TreeNode, root2: TreeNode) -> bool: if root1 is None and root2 is None: return True elif root1 is not None and root2 is not Non...
class Treenode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def flip_equiv(self, root1: TreeNode, root2: TreeNode) -> bool: if root1 is None and root2 is None: return True elif root1 is not None and root2 is not No...
L = [] while True: s = input("please enter a word: ") if not s: break L.append(s) # set method # s = set(L) #set can directly remove the duplicates # print("The total number of types of words you entered is: ", len(s)) # for word in s: # print(word) # list method # L2 = [] # ...
l = [] while True: s = input('please enter a word: ') if not s: break L.append(s) s = set(L) for x in L: if x in s: print(x) s.discard(x)
#!/usr/bin/env python3 # https://codeforces.com/problemset/problem/1183/A def f(l,k): mi = min(l) mx = max(l) if mx-k>mi+k: return -1 return mi+k t = int(input()) for _ in range(t): n,k = list(map(int,input().split())) l = list(map(int,input().split())) print(f(l,k))
def f(l, k): mi = min(l) mx = max(l) if mx - k > mi + k: return -1 return mi + k t = int(input()) for _ in range(t): (n, k) = list(map(int, input().split())) l = list(map(int, input().split())) print(f(l, k))
class Pattern_Four: '''Pattern four K A T H M A N D U K A T H M A N D K A T H M A N K A T H M A K A T H K A T K A K ''' def __init__(self, strings='KATHMANDU'): if isinstance(strings, str): self.strings = strings ...
class Pattern_Four: """Pattern four K A T H M A N D U K A T H M A N D K A T H M A N K A T H M A K A T H K A T K A K """ def __init__(self, strings='KATHMANDU'): if isinstance(strings, str): self.strings = strings e...
#!/usr/bin/env python class P4Exception(Exception): pass class P4NoSuchFileError(P4Exception): pass
class P4Exception(Exception): pass class P4Nosuchfileerror(P4Exception): pass
# Study Drills 12 # 1. In Terminal, where you normally run python3.6 to run your scripts, type pydoc input. # Read what it says. If you're on Windows try python3.6 -m pydoc input instead. # 2. Get out of pydoc by typing q to quit. # 3. Look online for what the pydoc command does. # 4. Use pydoc to also read about ope...
age = input('How old are you? ') height = input('How tall are you? ') weight = input('How much do you weigh? ') print(f"So, you're {age} old, {height} tall and {weight} heavy.")
# generated from catkin/cmake/template/pkg.context.pc.in CATKIN_PACKAGE_PREFIX = "" PROJECT_PKG_CONFIG_INCLUDE_DIRS = "${prefix}/include".split(';') if "${prefix}/include" != "" else [] PROJECT_CATKIN_DEPENDS = "roscpp;std_msgs;message_runtime".replace(';', ' ') PKG_CONFIG_LIBRARIES_WITH_PREFIX = "-lpluto_camera_sense;...
catkin_package_prefix = '' project_pkg_config_include_dirs = '${prefix}/include'.split(';') if '${prefix}/include' != '' else [] project_catkin_depends = 'roscpp;std_msgs;message_runtime'.replace(';', ' ') pkg_config_libraries_with_prefix = '-lpluto_camera_sense;-limage_transport;-lcv_bridge'.split(';') if '-lpluto_cam...
def xor(x, s): print(x, 'xor', s, '=', x ^ s) def bxor(x, s): print(bin(x), 'xor', bin(s), '=', bin(x ^ s)) xor(4, 8) xor(4, 4) xor(255, 1) xor(255, 128) print() bxor(4, 8) bxor(4, 4) bxor(255, 1) bxor(255, 128)
def xor(x, s): print(x, 'xor', s, '=', x ^ s) def bxor(x, s): print(bin(x), 'xor', bin(s), '=', bin(x ^ s)) xor(4, 8) xor(4, 4) xor(255, 1) xor(255, 128) print() bxor(4, 8) bxor(4, 4) bxor(255, 1) bxor(255, 128)
def GraphObjectContainer_byindex(self, idx): for e in self: if e.index() == idx: return e raise IndexError("Container has no element with index %s." % idx) def advance_iterator(self): if not self.valid(): raise StopIteration() val = self.__deref__() self.__preinc__() ...
def graph_object_container_byindex(self, idx): for e in self: if e.index() == idx: return e raise index_error('Container has no element with index %s.' % idx) def advance_iterator(self): if not self.valid(): raise stop_iteration() val = self.__deref__() self.__preinc__()...
SECRET_KEY = "ChangeMe" DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'sideloader', 'USER': 'postgres', 'PASSWORD': '', 'HOST': 'localhost', 'PORT': '', } } MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddl...
secret_key = 'ChangeMe' databases = {'default': {'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'sideloader', 'USER': 'postgres', 'PASSWORD': '', 'HOST': 'localhost', 'PORT': ''}} middleware_classes = ('django.middleware.common.CommonMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware') i...
def test_func_1(): assert bool(1) def test_func_2(): assert not bool(0)
def test_func_1(): assert bool(1) def test_func_2(): assert not bool(0)
params={ 'enc_type': 'lstm', 'dec_type': 'lstm', 'nz': 32, 'ni': 128, 'enc_nh': 512, 'dec_nh': 512, 'dec_dropout_in': 0.5, 'dec_dropout_out': 0.5, 'batch_size': 32, 'epochs': 32, 'test_nepoch': 4, 'train_data': 'datasets/poetry_500k_sample_data/poetry_500k_sample.train.t...
params = {'enc_type': 'lstm', 'dec_type': 'lstm', 'nz': 32, 'ni': 128, 'enc_nh': 512, 'dec_nh': 512, 'dec_dropout_in': 0.5, 'dec_dropout_out': 0.5, 'batch_size': 32, 'epochs': 32, 'test_nepoch': 4, 'train_data': 'datasets/poetry_500k_sample_data/poetry_500k_sample.train.txt', 'val_data': 'datasets/poetry_500k_sample_da...
class Solution: def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool: num1 = "".join([str(ord(i)-97) for i in firstWord]) num2 = "".join([str(ord(i)-97) for i in secondWord]) num3 = "".join([str(ord(i)-97) for i in targetWord]) if int(num1) + int(num2) == i...
class Solution: def is_sum_equal(self, firstWord: str, secondWord: str, targetWord: str) -> bool: num1 = ''.join([str(ord(i) - 97) for i in firstWord]) num2 = ''.join([str(ord(i) - 97) for i in secondWord]) num3 = ''.join([str(ord(i) - 97) for i in targetWord]) if int(num1) + int(nu...
class Book: def __init__(self, title, author): self.title = title self.author = author self.page = 0 def turn_page(self, page): self.page = page class Library: def __init__(self, location): self.location = location self.books = [] def find_book(self, t...
class Book: def __init__(self, title, author): self.title = title self.author = author self.page = 0 def turn_page(self, page): self.page = page class Library: def __init__(self, location): self.location = location self.books = [] def find_book(self, ...
############################# # # Parameters # # Written by Daniele Michilli # ############################# DM_MIN = 2. #pc/cm3 SNR_MIN = 6.5 #DURATION_MAX = 0.049152 #s F_MIN = 119.43 #MHz F_MAX = F_MIN + 31.64 #MHz RES = 491.52e-6 #s DURATION = 3599.719 #s #Grouping ERR_FLOAT = 0.001 #Error on float num...
dm_min = 2.0 snr_min = 6.5 f_min = 119.43 f_max = F_MIN + 31.64 res = 0.00049152 duration = 3599.719 err_float = 0.001 steps_group = 20 durat_group = 0.03 sigma_toll = 4 sigma_toll_ib = 2 rfi_percent = 2 puls_lenght = 15 ds_offset = 100000 dm_step1 = 41.04 dm_step2 = 133.14
file = open('Advent-of-Code-2021\\Day 12\Day 12 input.txt','r') caves = [] pairs = [] for line in file: currpair = line.strip().split('-') if (currpair not in pairs): pairs.append(currpair) for p in currpair: if (p not in caves): caves.append(p) #Build dictionary cavedict...
file = open('Advent-of-Code-2021\\Day 12\\Day 12 input.txt', 'r') caves = [] pairs = [] for line in file: currpair = line.strip().split('-') if currpair not in pairs: pairs.append(currpair) for p in currpair: if p not in caves: caves.append(p) cavedict = {} for edge in pairs: ...
def a(z): print(z + z) a(0) a('e') a([0])
def a(z): print(z + z) a(0) a('e') a([0])
parser_result_set = { "assertSelectInWithNullParameter": { "parameters": (1, 'null'), "tables": [ {"name": "t_order"} ], "tokens": { "table_tokens": [ {"original_literals": "t_order", "begin_position": 14}, ]...
parser_result_set = {'assertSelectInWithNullParameter': {'parameters': (1, 'null'), 'tables': [{'name': 't_order'}], 'tokens': {'table_tokens': [{'original_literals': 't_order', 'begin_position': 14}]}, 'order_by_columns': [{'name': 'order_id', 'order_direction': 'ASC'}]}, 'assertSelectPaginationWithRowCount': {'parame...
# This method is called exhaustive numeration! # I am checking every possible value # that can be root of given x systematically # Kinda brute forcing def find_cube_root(x): if type(x) == str: return "Expected an integer! Cannot find cube root of an string!" for i in range(0, x): if i ** 3 == ...
def find_cube_root(x): if type(x) == str: return 'Expected an integer! Cannot find cube root of an string!' for i in range(0, x): if i ** 3 == x: return i return '{} is not a perfect cube'.format(x) x = 27 result = find_cube_root(x) print('Cube root of {} is {}'.format(x, result)...
# ---------------------------------------------------------------- # In OOPs there are two classes, struct and objects. # Every object has two characterstics 1) Attributes and 2) behaviour # i.e A parrot object will have # 1) name, age, color are the attributes # 2) singing and dancing will be the behaviour # -------...
class Parrot: species = 'bird' def __init__(self, name, age): self.name = name self.age = age def sing(self, song): print('{} is sing song named {}'.format(self.name, song)) def dance(self): print('{} is dancing'.format(self.name)) class Bird: def __init__(self):...
#!/usr/bin/env python3 class Solution: def kthFactor(self, n, k): for i in range(1,n+1): if n%i == 0: k -= 1 if k == 0: return i return -1 n, k = 1000, 3 n, k = 4, 4 n, k = 1, 1 n, k = 7, 2 n, k = 12, 3 sol = Solution() print(n, k, sol.kthFac...
class Solution: def kth_factor(self, n, k): for i in range(1, n + 1): if n % i == 0: k -= 1 if k == 0: return i return -1 (n, k) = (1000, 3) (n, k) = (4, 4) (n, k) = (1, 1) (n, k) = (7, 2) (n, k) = (12, 3) sol = solution() print(n, k, sol.kthF...
CONFIGURE = { "HOST": "0.0.0.0", "PORT": 12345, "GENERATE_MAX_X": -244.0, "GENERATE_MIN_X": -293.0, "GENERATE_MAX_Z": 65, "GENERATE_MIN_Z": 24, "GENERATE_Y": 0.5, "MAX_ENEMY_COUNT": 10000, "RANDOM_GENERATED_ENEMY_COUNT": [4, 7], "MAX_GENERABLE_ITEM": 10, "ENMEY_BULLET_DAM...
configure = {'HOST': '0.0.0.0', 'PORT': 12345, 'GENERATE_MAX_X': -244.0, 'GENERATE_MIN_X': -293.0, 'GENERATE_MAX_Z': 65, 'GENERATE_MIN_Z': 24, 'GENERATE_Y': 0.5, 'MAX_ENEMY_COUNT': 10000, 'RANDOM_GENERATED_ENEMY_COUNT': [4, 7], 'MAX_GENERABLE_ITEM': 10, 'ENMEY_BULLET_DAMAGE': 10, 'ENMEY_ATTACK_DAMAGE': 15, 'PLAYER_NORM...
WIDTH = 400 HEIGHT = 600 FPS = 30 TILE_SIZE = 10
width = 400 height = 600 fps = 30 tile_size = 10
# coding=utf-8 # List of modules to import when Celery starts. CELERY_IMPORTS = ("tasks",) BROKER_URL = 'amqp://' CELERY_RESULT_BACKEND = 'amqp://' # SENTRY_DSN = None OUTPUT_ROOT = "../temp"
celery_imports = ('tasks',) broker_url = 'amqp://' celery_result_backend = 'amqp://' output_root = '../temp'
def main(lines): commands = [line.split() for line in lines] commands = [(t[0], int(t[1])) for t in commands] depth = 0 aim = 0 position = 0 for command, value in commands: if command == 'down': aim += value elif command == 'up': aim -= value else...
def main(lines): commands = [line.split() for line in lines] commands = [(t[0], int(t[1])) for t in commands] depth = 0 aim = 0 position = 0 for (command, value) in commands: if command == 'down': aim += value elif command == 'up': aim -= value els...
class Fenwick: def __init__(self, n, l=[]): self.s = n self.d = [0] * (n + 1) for i, x in enumerate(l, 1): self.add(i, x) def sum(self, *i): if len(i) == 1: i = i[0] r = 0 while i >= 1: r ^= self.d[i] # ...
class Fenwick: def __init__(self, n, l=[]): self.s = n self.d = [0] * (n + 1) for (i, x) in enumerate(l, 1): self.add(i, x) def sum(self, *i): if len(i) == 1: i = i[0] r = 0 while i >= 1: r ^= self.d[i] ...
#Project Euler Question 45 #Triangular, pentagonal, and hexagonal def pentagon_number(x, step): if x == 1: return 1 else: n = step while True: n += 1 penn = int(((3 * n) - 1) * n / 2) if penn > x: return [penn_save, n -1] ...
def pentagon_number(x, step): if x == 1: return 1 else: n = step while True: n += 1 penn = int((3 * n - 1) * n / 2) if penn > x: return [penn_save, n - 1] elif penn == x: return [penn, n] else: ...
def say_hello(name): print(f'Hello {name}!') def say_goodbye(name): print(f'Goodbye {name}!') class Greeting: def __init__(self, name='World'): self.name = name def hello(self): say_hello(self.name) def goodbye(self): say_goodbye(self.name)
def say_hello(name): print(f'Hello {name}!') def say_goodbye(name): print(f'Goodbye {name}!') class Greeting: def __init__(self, name='World'): self.name = name def hello(self): say_hello(self.name) def goodbye(self): say_goodbye(self.name)
#: Dictionary to map Python and SQLite data types DATA_TYPES = {str: 'TEXT', int: 'INTEGER', float: 'REAL'} def attrs(obj): return dict(i for i in vars(obj).items() if i[0][0] != '_') def copy_attrs(obj, remove=None): if remove is None: remove = [] return dict(i for i in attrs(obj).items() if i[...
data_types = {str: 'TEXT', int: 'INTEGER', float: 'REAL'} def attrs(obj): return dict((i for i in vars(obj).items() if i[0][0] != '_')) def copy_attrs(obj, remove=None): if remove is None: remove = [] return dict((i for i in attrs(obj).items() if i[0] not in remove)) def render_column_definitions...
''' Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. Example: Input: [ ["1","0","1","0","0"], ["1","0","1","1","1"], ["1","1","1","1","1"], ["1","0","0","1","0"] ] Output: 6 ''' ''' Starting from first row, iterate each cell in the row and ...
""" Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. Example: Input: [ ["1","0","1","0","0"], ["1","0","1","1","1"], ["1","1","1","1","1"], ["1","0","0","1","0"] ] Output: 6 """ '\nStarting from first row, iterate each cell in the row and\nc...
def main(): N = int(input()) arr = [] for _ in range(N): (x, y, h) = [int(s) for s in input().split()] arr.append((x, y, h)) arr.sort(key=lambda x: x[2], reverse=True) max_h = arr[0][2] for i in range(max_h,0, -1): sub_ar = [(x, y) for x, y, h in arr if h == i] i...
def main(): n = int(input()) arr = [] for _ in range(N): (x, y, h) = [int(s) for s in input().split()] arr.append((x, y, h)) arr.sort(key=lambda x: x[2], reverse=True) max_h = arr[0][2] for i in range(max_h, 0, -1): sub_ar = [(x, y) for (x, y, h) in arr if h == i] ...
# # PySNMP MIB module Nortel-MsCarrier-MscPassport-UtpDpnTrunksMIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Nortel-MsCarrier-MscPassport-UtpDpnTrunksMIB # Produced by pysmi-0.3.4 at Wed May 1 14:31:33 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by u...
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, constraints_union, constraints_intersection, value_size_constraint) ...
test = int(input()) while(test != 0): n = input() l = [] count = 0 for word in n: l.append(word) l = list(map(int,l)) for i in l: try: if int(n)%i == 0: count += 1 except: continue print(count) test -= 1
test = int(input()) while test != 0: n = input() l = [] count = 0 for word in n: l.append(word) l = list(map(int, l)) for i in l: try: if int(n) % i == 0: count += 1 except: continue print(count) test -= 1
dataset_type = 'CocoDataset' img_norm_cfg = dict(mean=[123.675, 116.28, 103.53], std=[ 58.395, 57.12, 57.375], to_rgb=True) train_pipeline = [ dict(type='LoadImageFromFile', to_float32=True), dict(type='LoadAnnotations', with_bbox=True), dict( type='PhotoMetricDistortion', ...
dataset_type = 'CocoDataset' img_norm_cfg = dict(mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) train_pipeline = [dict(type='LoadImageFromFile', to_float32=True), dict(type='LoadAnnotations', with_bbox=True), dict(type='PhotoMetricDistortion', brightness_delta=32, contrast_range=(0.5, 1.5), s...