content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
class Solution: def removeDuplicates(self, nums: List[int]) -> int: l = len(nums) if l == 1: return 1 index = 1 num = nums[0] for i in range(1, l): if nums[i] == num: continue num = nums[i]...
class Solution: def remove_duplicates(self, nums: List[int]) -> int: l = len(nums) if l == 1: return 1 index = 1 num = nums[0] for i in range(1, l): if nums[i] == num: continue num = nums[i] nums[index] = nums[i...
''' Define constraints (depends on your problem) https://stackoverflow.com/questions/42303470/scipy-optimize-inequality-constraint-which-side-of-the-inequality-is-considered [0.1268 0.467 0.5834 0.2103 -0.1268 -0.5425 -0.5096 0.0581] . The bounds are +/-30% of this. ''' t_base = [0.1268, 0.467, 0.5834, 0.2103, -0.1268...
""" Define constraints (depends on your problem) https://stackoverflow.com/questions/42303470/scipy-optimize-inequality-constraint-which-side-of-the-inequality-is-considered [0.1268 0.467 0.5834 0.2103 -0.1268 -0.5425 -0.5096 0.0581] . The bounds are +/-30% of this. """ t_base = [0.1268, 0.467, 0.5834, 0.2103, -0.1268,...
__key_mapping = { 'return' : 'enter', 'up_arrow' : 'up', 'down_arrow' : 'down', 'left_arrow' : 'left', 'right_arrow' : 'right', 'page_up' : 'pageup', 'page_down' : 'pagedown', } def translate_key(e): if len(e.key) > 0: return __key_mapping[e.key] if e.key in __key_mapping e...
__key_mapping = {'return': 'enter', 'up_arrow': 'up', 'down_arrow': 'down', 'left_arrow': 'left', 'right_arrow': 'right', 'page_up': 'pageup', 'page_down': 'pagedown'} def translate_key(e): if len(e.key) > 0: return __key_mapping[e.key] if e.key in __key_mapping else e.key elif e.char == '\x08': ...
""" sentry.pool.base ~~~~~~~~~~~~~~~~ :copyright: (c) 2010-2013 by the Sentry Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ class Pool(object): def __init__(self, keyspace): self.keyspace = keyspace self.queue = [] def put(self, item): self.queu...
""" sentry.pool.base ~~~~~~~~~~~~~~~~ :copyright: (c) 2010-2013 by the Sentry Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ class Pool(object): def __init__(self, keyspace): self.keyspace = keyspace self.queue = [] def put(self, item): self.queu...
class Solution: def wordPattern(self, pattern: str, str: str) -> bool: lst = str.split() combo = zip(pattern, lst) return len(set(pattern)) == len(set(lst)) == len(set(combo)) and len(pattern) == len(lst)
class Solution: def word_pattern(self, pattern: str, str: str) -> bool: lst = str.split() combo = zip(pattern, lst) return len(set(pattern)) == len(set(lst)) == len(set(combo)) and len(pattern) == len(lst)
soma_idade=0 media_Idade=0 maior_idade_homem=0 nome_velho='' tot_mulher_20=0 for i in range(0,4): nome=str(input('Nome: ')).strip() idade=int(input('Idade: ')) sexo=str(input('Sexo: ')).strip() soma_idade+=idade if i==1 and sexo in 'Mm': maior_idade_homem=idade nome_velho=nome el...
soma_idade = 0 media__idade = 0 maior_idade_homem = 0 nome_velho = '' tot_mulher_20 = 0 for i in range(0, 4): nome = str(input('Nome: ')).strip() idade = int(input('Idade: ')) sexo = str(input('Sexo: ')).strip() soma_idade += idade if i == 1 and sexo in 'Mm': maior_idade_homem = idade ...
# -*- coding: utf-8 -*- """ Created on Fri Jan 31 11:53:09 2020 @author: aboutet """ def street_pattern_before(es, infos, insert): return {} def street_pattern(es, infos, data, documents): to_send = [] for json in data: if "LINK_ID" in json.keys(): link_id = "LINK...
""" Created on Fri Jan 31 11:53:09 2020 @author: aboutet """ def street_pattern_before(es, infos, insert): return {} def street_pattern(es, infos, data, documents): to_send = [] for json in data: if 'LINK_ID' in json.keys(): link_id = 'LINK_ID' else: link_id = 'LIN...
"""The LinkedList code from before is provided below. Add three functions to the LinkedList. "get_position" returns the element at a certain position. The "insert" function will add an element to a particular spot in the list. "delete" will delete the first element with that particular value. Then, use "Test Run" and "...
"""The LinkedList code from before is provided below. Add three functions to the LinkedList. "get_position" returns the element at a certain position. The "insert" function will add an element to a particular spot in the list. "delete" will delete the first element with that particular value. Then, use "Test Run" and "...
# -*- coding: utf-8 -*- """Top-level package for Medzibrod.""" __author__ = """Michal Nalevanko""" __email__ = 'michal.nalevanko@gmail.com' __version__ = '0.1.0'
"""Top-level package for Medzibrod.""" __author__ = 'Michal Nalevanko' __email__ = 'michal.nalevanko@gmail.com' __version__ = '0.1.0'
# Copyright (c) 2020 Samplasion <samplasion@gmail.com> # # This software is released under the MIT License. # https://opensource.org/licenses/MIT TARGET = 2020 def main(): print("=============") print("= AoC Day 1 =") print("=============") print() with open("input.txt") as f: file = f.r...
target = 2020 def main(): print('=============') print('= AoC Day 1 =') print('=============') print() with open('input.txt') as f: file = f.read() numbers = sorted(list(map(int, file.split('\n')))) phase1(numbers) phase2(numbers) def phase1(numbers): min = 0 ...
SCHEMA = { # staff-and-student-information "all_students_count": "{short_code}PETALLC", "african_american_count": "{short_code}PETBLAC", "african_american_percent": "{short_code}PETBLAP", "american_indian_count": "{short_code}PETINDC", "american_indian_percent": "{short_code}PETINDP", "asian...
schema = {'all_students_count': '{short_code}PETALLC', 'african_american_count': '{short_code}PETBLAC', 'african_american_percent': '{short_code}PETBLAP', 'american_indian_count': '{short_code}PETINDC', 'american_indian_percent': '{short_code}PETINDP', 'asian_count': '{short_code}PETASIC', 'asian_percent': '{short_code...
# This problem was asked by Facebook. # Given an array of numbers representing the stock prices of a company in chronological # order and an integer k, return the maximum profit you can make from k buys and sells. # You must buy the stock before you can sell it, and you must sell the stock before you can buy it again...
def get_max_profit(arr, k): a = arr + [-1] current_min = a[0] current_max = a[0] ends = [] for i in range(1, len(a)): if a[i] > current_max: current_max = a[i] if a[i] < current_max and current_max != current_min: ends.append((current_min, current_max)) ...
def file_html(fname): fptr=open(fname,"r") to_send = "" for lines in fptr: to_send += lines; return to_send #file_html("myfile.html");
def file_html(fname): fptr = open(fname, 'r') to_send = '' for lines in fptr: to_send += lines return to_send
md = [0,0] facing = "E" def rotate(cw, val): idx = 4 + cw * int((val/90) % 4) mv = ['E','S','W','N'] c = mv.index(facing) return mv[(idx + c) % 4] def move(dr, val): global ew global ns global facing if dr == 'N': md[1] += val elif dr == 'S': md[1] -= val ...
md = [0, 0] facing = 'E' def rotate(cw, val): idx = 4 + cw * int(val / 90 % 4) mv = ['E', 'S', 'W', 'N'] c = mv.index(facing) return mv[(idx + c) % 4] def move(dr, val): global ew global ns global facing if dr == 'N': md[1] += val elif dr == 'S': md[1] -= val el...
for _ in range(int(input())): n,x = map(int,input().split()) l = list(map(int,input().split())) flag=2 if len(set(l)) == 1 and l[0] == x: flag=0 elif x in l or sum([i-x for i in l])==0: flag=1 if flag==0: print(0) elif flag==1: print(1) else: print...
for _ in range(int(input())): (n, x) = map(int, input().split()) l = list(map(int, input().split())) flag = 2 if len(set(l)) == 1 and l[0] == x: flag = 0 elif x in l or sum([i - x for i in l]) == 0: flag = 1 if flag == 0: print(0) elif flag == 1: print(1) ...
""" Take the block of text provided and strip off the whitespace at both ends. Split the text by newline (\n) using split. Loop through the lines and if the first character of each (stripped) line is lowercase, split the line into words and add the last word to the (given) results list, stripping the trailing dot (.)...
""" Take the block of text provided and strip off the whitespace at both ends. Split the text by newline ( ) using split. Loop through the lines and if the first character of each (stripped) line is lowercase, split the line into words and add the last word to the (given) results list, stripping the trailing dot (.) a...
""" domonic.constants.keyboard ==================================== """ class KeyCode(): A = '65' #: ALTERNATE = '18' #: B = '66' #: BACKQUOTE = '192' #: BACKSLASH = '220' #: BACKSPACE = '8' #: C = '67' #: CAPS_LOCK = '20' #: COMMA = '188' #: COMMAND = '15' ...
""" domonic.constants.keyboard ==================================== """ class Keycode: a = '65' alternate = '18' b = '66' backquote = '192' backslash = '220' backspace = '8' c = '67' caps_lock = '20' comma = '188' command = '15' control = '17' d = '68' delet...
#!/usr/bin/env python # configure these settings to change projector behavior server_mount_path = '//192.168.42.11/PiShare' # shared folder on other pi user_name = 'pi' # shared drive login user name user_password = 'raspberry' # shared drive login password client_mount_path = '/mnt/pishare' # where to find the shared...
server_mount_path = '//192.168.42.11/PiShare' user_name = 'pi' user_password = 'raspberry' client_mount_path = '/mnt/pishare' pics_folder = '/mnt/pishare/pics' waittime = 2 use_prime = True prime_slide = '/home/pi/photobooth/projector.png' prime_freq = 16 monitor_w = 800 monitor_h = 600 title = 'SlideShow'
class Solution: def boldWords(self, words, S): """ :type words: List[str] :type S: str :rtype: str """ m = len(S) flags = [False] * m for word in words: n = len(word) for i in range(m - n + 1): if S[i:i + n] == w...
class Solution: def bold_words(self, words, S): """ :type words: List[str] :type S: str :rtype: str """ m = len(S) flags = [False] * m for word in words: n = len(word) for i in range(m - n + 1): if S[i:i + n] ==...
data = ( 'E ', # 0x00 'Cheng ', # 0x01 'Xin ', # 0x02 'Ai ', # 0x03 'Lu ', # 0x04 'Zhui ', # 0x05 'Zhou ', # 0x06 'She ', # 0x07 'Pian ', # 0x08 'Kun ', # 0x09 'Tao ', # 0x0a 'Lai ', # 0x0b 'Zong ', # 0x0c 'Ke ', # 0x0d 'Qi ', # 0x0e 'Qi ', # 0x0f 'Yan ', # 0x10 'Fei '...
data = ('E ', 'Cheng ', 'Xin ', 'Ai ', 'Lu ', 'Zhui ', 'Zhou ', 'She ', 'Pian ', 'Kun ', 'Tao ', 'Lai ', 'Zong ', 'Ke ', 'Qi ', 'Qi ', 'Yan ', 'Fei ', 'Sao ', 'Yan ', 'Jie ', 'Yao ', 'Wu ', 'Pian ', 'Cong ', 'Pian ', 'Qian ', 'Fei ', 'Huang ', 'Jian ', 'Huo ', 'Yu ', 'Ti ', 'Quan ', 'Xia ', 'Zong ', 'Kui ', 'Rou ', 'Si...
"""Top-level package for ML Model Evaluation Toolkit.""" __author__ = """Nicolas Kaenzig""" __email__ = "nkaenzig@gmail.com" __version__ = "0.1.0"
"""Top-level package for ML Model Evaluation Toolkit.""" __author__ = 'Nicolas Kaenzig' __email__ = 'nkaenzig@gmail.com' __version__ = '0.1.0'
def remove_duplicated_keep_order(value_in_tuple): new_tuple = [] for i in value_in_tuple: if not (i in new_tuple): new_tuple.append(i) return new_tuple # return tuple(set(value_in_tuple))
def remove_duplicated_keep_order(value_in_tuple): new_tuple = [] for i in value_in_tuple: if not i in new_tuple: new_tuple.append(i) return new_tuple
# Licensed under a 3-clause BSD style license - see LICENSE.rst def get_package_data(): return { _ASTROPY_PACKAGE_NAME_ + '.tests': ['coveragerc', 'data/*.hdr'] # noqa }
def get_package_data(): return {_ASTROPY_PACKAGE_NAME_ + '.tests': ['coveragerc', 'data/*.hdr']}
exp.set('total_responses', 0) exp.set('total_correct', 0) exp.set('total_response_time', 0) exp.set('average_response_time', 'NA') exp.set('avg_rt', 'NA') exp.set('accuracy', 'NA') exp.set('acc', 'NA')
exp.set('total_responses', 0) exp.set('total_correct', 0) exp.set('total_response_time', 0) exp.set('average_response_time', 'NA') exp.set('avg_rt', 'NA') exp.set('accuracy', 'NA') exp.set('acc', 'NA')
def exception_test(assert_check_fn): try: def exception_wrapper(*arg, **kwarg): assert_check_fn(*arg, **kwarg) except Exception as e: pytest.failed(e)
def exception_test(assert_check_fn): try: def exception_wrapper(*arg, **kwarg): assert_check_fn(*arg, **kwarg) except Exception as e: pytest.failed(e)
""" Queries of issue queries """ def gql_issues(fragment): """ Return the GraphQL issues query """ return f''' query ($where: IssueWhere!, $first: PageSize!, $skip: Int!) {{ data: issues(where: $where, first: $first, skip: $skip) {{ {fragment} }} }} ''' GQL_ISSUES_COUNT = ''' query($where: I...
""" Queries of issue queries """ def gql_issues(fragment): """ Return the GraphQL issues query """ return f'\nquery ($where: IssueWhere!, $first: PageSize!, $skip: Int!) {{\n data: issues(where: $where, first: $first, skip: $skip) {{\n {fragment}\n }}\n}}\n' gql_issues_count = '\nquery($where: Iss...
""" @desc Prints informations about the candidate : his/her profile and messages sent @params candidate: instance of Candidate """ def show_candidate_informations(candidate): print("## CANDIDATE PROFILE ##", end="\n\n") print("Firstname: {}".format(candidate.firstname)) print("Lastname: {}".format(candid...
""" @desc Prints informations about the candidate : his/her profile and messages sent @params candidate: instance of Candidate """ def show_candidate_informations(candidate): print('## CANDIDATE PROFILE ##', end='\n\n') print('Firstname: {}'.format(candidate.firstname)) print('Lastname: {}'.format(candida...
class Korean: """Korean speaker""" def __init__(self): self.name = "Korean" def speak_korean(self): return "An-neyong?" class British: """English speaker""" def __init__(self): self.name = "British" #Note the different method name here! def speak_english(self): return "Hello!" clas...
class Korean: """Korean speaker""" def __init__(self): self.name = 'Korean' def speak_korean(self): return 'An-neyong?' class British: """English speaker""" def __init__(self): self.name = 'British' def speak_english(self): return 'Hello!' class Adapter: ...
def green(text): return f"\033[92m{text}\033[0m" def yellow(text): return f"\033[93m{text}\033[0m"
def green(text): return f'\x1b[92m{text}\x1b[0m' def yellow(text): return f'\x1b[93m{text}\x1b[0m'
MORSE_CODE_DICT = { 'A':'.-', 'B':'-...', 'C':'-.-.', 'D':'-..', 'E':'.', 'F':'..-.', 'G':'--.', 'H':'....', 'I':'..', 'J':'.---', 'K':'-.-', 'L':'.-..', 'M':'--', 'N':'-.', 'O':'---', 'P':'.--.', 'Q':'--.-', ...
morse_code_dict = {'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-', 'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-', 'Y': '-.--'...
# -*- coding: utf-8 -*- class MyClass: # The __init__ method doesn't return anything, so it gets return # type None just like any other method that doesn't return anything. def __init__(self) -> None: ... # For instance methods, omit `self`. def my_class_method(self, num: int, str1: str) -> str: ...
class Myclass: def __init__(self) -> None: ... def my_class_method(self, num: int, str1: str) -> str: return num * str1 x = my_class()
expected_output = { "bridge_group": { "D": { "bridge_domain": { "D-w": { "ac": { "num_ac": 1, "num_ac_up": 1 }, "id": 0, "pbb": { ...
expected_output = {'bridge_group': {'D': {'bridge_domain': {'D-w': {'ac': {'num_ac': 1, 'num_ac_up': 1}, 'id': 0, 'pbb': {'num_pbb': 0, 'num_pbb_up': 0}, 'pw': {'num_pw': 1, 'num_pw_up': 1}, 'state': 'up', 'vni': {'num_vni': 0, 'num_vni_up': 0}}}}, 'GO-LEAFS': {'bridge_domain': {'GO': {'ac': {'num_ac': 3, 'num_ac_up': ...
INPUT_TO_DWI_CONVERSION_EDGES = [("dwi_file", "in_file")] INPUT_TO_FMAP_CONVERSION_EDGES = [("fmap_file", "in_file")] LOCATE_ASSOCIATED_TO_COVERSION_EDGES = [ ("json_file", "json_import"), ("bvec_file", "in_bvec"), ("bval_file", "in_bval"), ] DWI_CONVERSION_TO_OUTPUT_EDGES = [("out_file", "dwi_file")] FMAP...
input_to_dwi_conversion_edges = [('dwi_file', 'in_file')] input_to_fmap_conversion_edges = [('fmap_file', 'in_file')] locate_associated_to_coversion_edges = [('json_file', 'json_import'), ('bvec_file', 'in_bvec'), ('bval_file', 'in_bval')] dwi_conversion_to_output_edges = [('out_file', 'dwi_file')] fmap_conversion_to_o...
almacen_api_config = { 'debug': { 'name': 'almacen_api', 'database': 'stage_01', 'debug': True, 'app': { 'DEBUG': True, 'UPLOAD_FOLDER': '/tmp', }, 'run': { # 'ssl_context': ('ssl/cert.pem', 'ssl/key.pem'), 'port': 8000, }, 'app_tokens': { 'TOKEN': { ...
almacen_api_config = {'debug': {'name': 'almacen_api', 'database': 'stage_01', 'debug': True, 'app': {'DEBUG': True, 'UPLOAD_FOLDER': '/tmp'}, 'run': {'port': 8000}, 'app_tokens': {'TOKEN': {'app': 'development', 'roles': ['super', 'tagger']}, 'TOKEN': {'app': 'longcat_api', 'roles': ['tagger']}}}, 'development': {'nam...
a=1 def change_integer(a): a = a+1 return a print (change_integer(a)) print (a) b=[1,2,3] def change_list(b): b[0]=b[0]+1 return b print (change_list(b)) print (b)
a = 1 def change_integer(a): a = a + 1 return a print(change_integer(a)) print(a) b = [1, 2, 3] def change_list(b): b[0] = b[0] + 1 return b print(change_list(b)) print(b)
number_1 = int(input()) number_2 = int(input()) if number_1 >= number_2: print(number_1) print(number_2) else: print(number_2) print(number_1)
number_1 = int(input()) number_2 = int(input()) if number_1 >= number_2: print(number_1) print(number_2) else: print(number_2) print(number_1)
#!/usr/bin/env python3 # CHECKED A = [[4.5, -1, -1, 1], [-1, 4.5, 1, -1], [-1, 2, 4.5, -1], [2, -1, -1, 4.5]] b = [1, -1, -1, 0] x = [0.25, 0.25, 0.25, 0.25] x_new = [0, 0, 0, 0] for k in range(2): for i in range(4): x_new[i] = b[i] for j in range(4): if j != i: x_new[...
a = [[4.5, -1, -1, 1], [-1, 4.5, 1, -1], [-1, 2, 4.5, -1], [2, -1, -1, 4.5]] b = [1, -1, -1, 0] x = [0.25, 0.25, 0.25, 0.25] x_new = [0, 0, 0, 0] for k in range(2): for i in range(4): x_new[i] = b[i] for j in range(4): if j != i: x_new[i] -= A[i][j] * x[j] x_new[i...
class Solution: # @param num : a list of integer # @return : a list of integer def nextPermutation(self, num): # write your code here # Version 1 bp = -1 for i in range(len(num) - 1): if (num[i] < num[i + 1]): bp = i if (bp == -1): ...
class Solution: def next_permutation(self, num): bp = -1 for i in range(len(num) - 1): if num[i] < num[i + 1]: bp = i if bp == -1: num.reverse() return num rest = num[bp:] local_max = None for i in rest: ...
X = int(input()) a_list = [] for s in range(1, 32): for i in range(2, 10): a = s ** i if a > 1000: break a_list.append(a) a2 = sorted(list(set(a_list)), reverse=True) for n in a2: if n <= X: print(n) break
x = int(input()) a_list = [] for s in range(1, 32): for i in range(2, 10): a = s ** i if a > 1000: break a_list.append(a) a2 = sorted(list(set(a_list)), reverse=True) for n in a2: if n <= X: print(n) break
def presentacion_inicial(): print("*"*20) print("Que accion desea realizar : ") print("1) Insertar Persona : ") print("2) Insertar Empleado : ") print("3) Consultar las personas : ") print("4) Consultar por empleados : ") return int(input("Opcion necesitas : "))
def presentacion_inicial(): print('*' * 20) print('Que accion desea realizar : ') print('1) Insertar Persona : ') print('2) Insertar Empleado : ') print('3) Consultar las personas : ') print('4) Consultar por empleados : ') return int(input('Opcion necesitas : '))
class SEHException(ExternalException): """ Represents structured exception handling (SEH) errors. SEHException() SEHException(message: str) SEHException(message: str,inner: Exception) """ def ZZZ(self): """hardcoded/mock instance of the class""" return SEHException() instance=ZZZ() """har...
class Sehexception(ExternalException): """ Represents structured exception handling (SEH) errors. SEHException() SEHException(message: str) SEHException(message: str,inner: Exception) """ def zzz(self): """hardcoded/mock instance of the class""" return seh_exception() instance = ...
# encoding: utf-8 # module Revit.References calls itself References # from RevitNodes,Version=1.2.1.3083,Culture=neutral,PublicKeyToken=null # by generator 1.145 # no doc # no imports # no functions # classes class RayBounce(object): # no doc @staticmethod def ByOriginDirection(origin, dire...
class Raybounce(object): @staticmethod def by_origin_direction(origin, direction, maxBounces, view): """ ByOriginDirection(origin: Point,direction: Vector,maxBounces: int,view: View3D) -> Dictionary[str,object] Returns positions and elements hit by ray bounce from the specified origin p...
load("@io_bazel_rules_docker//go:image.bzl", go_image_repositories="repositories") load("@io_bazel_rules_docker//container:container.bzl", container_repositories = "repositories") def initialize_rules_docker(): container_repositories() go_image_repositories() load("@distroless//package_manager:package_manager.bzl"...
load('@io_bazel_rules_docker//go:image.bzl', go_image_repositories='repositories') load('@io_bazel_rules_docker//container:container.bzl', container_repositories='repositories') def initialize_rules_docker(): container_repositories() go_image_repositories() load('@distroless//package_manager:package_manager.bz...
""" 1. Problem Summary / Clarifications / TDD: output("abcd", "abecd") = "e" 2. Inuition: xor operator 3. Tests: output("abcd", "abecd") = "e": The added character is in the middle of t output("abcd", "abcde") = "e": The added character is at the end of t ou...
""" 1. Problem Summary / Clarifications / TDD: output("abcd", "abecd") = "e" 2. Inuition: xor operator 3. Tests: output("abcd", "abecd") = "e": The added character is in the middle of t output("abcd", "abcde") = "e": The added character is at the end of t ou...
# urls.py # urls for dash app url_paths = { "index": '/', "home": '/home', "scatter": '/apps/scatter-test', "combo": '/apps/combo-test' }
url_paths = {'index': '/', 'home': '/home', 'scatter': '/apps/scatter-test', 'combo': '/apps/combo-test'}
scoreboard_display = [['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25'], ['51', '50', '49', '48', '47', '46', '45', '44', '43', '42', '41', '40', '39', '38', '37', '36', '35', '34', '33', '32', '31', '30', '29', '28', '27',...
scoreboard_display = [['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25'], ['51', '50', '49', '48', '47', '46', '45', '44', '43', '42', '41', '40', '39', '38', '37', '36', '35', '34', '33', '32', '31', '30', '29', '28', '27',...
# flake8: noqa # in legacy datasets we need to put our sample data within the data dir legacy_datasets = ["cmu_small_region.svs"] # Registry of datafiles that can be downloaded along with their SHA256 hashes # To generate the SHA256 hash, use the command # openssl sha256 filename registry = { "histolab/broken.svs...
legacy_datasets = ['cmu_small_region.svs'] registry = {'histolab/broken.svs': 'b1325916876afa17ad5e02d2e7298ee883e758ed25369470d85bc0990e928e11', 'histolab/kidney.png': '5c6dc1b9ae10a2865302d9c8eda360362ec47732cb3e9766c38ed90cb9f4c371', 'data/cmu_small_region.svs': 'ed92d5a9f2e86df67640d6f92ce3e231419ce127131697fbbce42...
print('=' * 15, '\033[1;35mAULA 18 - Listas[Part #2]\033[m', '=' * 15) # -------------------------------------------------------------------- dados = [] pessoas = [] galera = [['Miguel', 25], ['Berta', 59], ['Joaquim', 20]] # -------------------------------------------------------------------- dados.append('Joaquim') d...
print('=' * 15, '\x1b[1;35mAULA 18 - Listas[Part #2]\x1b[m', '=' * 15) dados = [] pessoas = [] galera = [['Miguel', 25], ['Berta', 59], ['Joaquim', 20]] dados.append('Joaquim') dados.append(20) dados.append('Fernando') dados.append(23) dados.append('Maria') dados.append(19) pessoas.append(dados[:]) print(galera[0][0]) ...
P, D = list(map(int, input().split(' '))) totA, totB = 0, 0 dis = [[0,0,0,0] for i in range(D)] for i in range(P): a, b, c = map(int, input().split(' ')) k = (b+c)//2 + 1 dis[a-1][0] += b dis[a-1][1] += c for i, (ta, tb, _, _) in enumerate(dis): k = (ta + tb)//2 + 1 if ta > tb: wA = ta-k wB ...
(p, d) = list(map(int, input().split(' '))) (tot_a, tot_b) = (0, 0) dis = [[0, 0, 0, 0] for i in range(D)] for i in range(P): (a, b, c) = map(int, input().split(' ')) k = (b + c) // 2 + 1 dis[a - 1][0] += b dis[a - 1][1] += c for (i, (ta, tb, _, _)) in enumerate(dis): k = (ta + tb) // 2 + 1 if t...
# -*- coding: utf-8 -*- def _data_from_bar(ax, bar_label): """Given a matplotlib Axes object and a bar label, returns (x,y,w,h) data underlying the bar plot. Args: ax: The Axes object the data will be extracted from. bar_label: The bar label from which you want to extract the data. R...
def _data_from_bar(ax, bar_label): """Given a matplotlib Axes object and a bar label, returns (x,y,w,h) data underlying the bar plot. Args: ax: The Axes object the data will be extracted from. bar_label: The bar label from which you want to extract the data. Returns: A list of ...
baklava_price = float(input()) muffin_price = float(input()) shtolen_kg = float(input()) candy_kg = float(input()) bisquits_kg = int(input()) shtolen_price = baklava_price + baklava_price * 0.6 candy_price = muffin_price + muffin_price * 0.8 busquits_price = 7.50 shtolen_sum = shtolen_kg * shtolen_price candy_sum = ca...
baklava_price = float(input()) muffin_price = float(input()) shtolen_kg = float(input()) candy_kg = float(input()) bisquits_kg = int(input()) shtolen_price = baklava_price + baklava_price * 0.6 candy_price = muffin_price + muffin_price * 0.8 busquits_price = 7.5 shtolen_sum = shtolen_kg * shtolen_price candy_sum = cand...
""" Generic utilities """ def any(seq): for i in seq: if i: return True return False
""" Generic utilities """ def any(seq): for i in seq: if i: return True return False
x=int(input('Enter the number to convert: ')) print('Select the convertion') print(''' [ 1 ] Binary [ 1 ] Octal [ 3 ] HexaDeicmal ''') y=int(input('1 - Binary 2 - Octal 3 - Hexadecimal')) if y==1: bin(x)[2:] print('{}'.format(x)) elif y==2: oct(x) print('{}'.format(x)) elif y==3: hex(x) print(...
x = int(input('Enter the number to convert: ')) print('Select the convertion') print(' \n[ 1 ] Binary\n[ 1 ] Octal\n[ 3 ] HexaDeicmal\n') y = int(input('1 - Binary 2 - Octal 3 - Hexadecimal')) if y == 1: bin(x)[2:] print('{}'.format(x)) elif y == 2: oct(x) print('{}'.format(x)) elif y == 3: hex(x) ...
# -*- coding: utf-8 -*- """ meetup.py ~~~~~~~~~ a mock for the Meetup APi client """ class MockMeetupGroup: def __init__(self, *args, **kwargs): self.name = "Mock Meetup Group" self.link = "https://www.meetup.com/MeetupGroup/" self.next_event = { "id": 0, ...
""" meetup.py ~~~~~~~~~ a mock for the Meetup APi client """ class Mockmeetupgroup: def __init__(self, *args, **kwargs): self.name = 'Mock Meetup Group' self.link = 'https://www.meetup.com/MeetupGroup/' self.next_event = {'id': 0, 'name': 'Monthly Meetup', 'venue': 'Galvanize',...
#!/usr/bin/python3 def safe_print_list_integers(my_list=[], x=0): i = 0 for index in range(x): try: print("{:d}".format(my_list[index]), end="") i += 1 except (ValueError, TypeError): pass print() return i
def safe_print_list_integers(my_list=[], x=0): i = 0 for index in range(x): try: print('{:d}'.format(my_list[index]), end='') i += 1 except (ValueError, TypeError): pass print() return i
N = int(input()) A, B = ( zip(*(map(int, input().split()) for _ in range(N))) if N else ((), ()) ) ans = len({(min(a, b), max(a, b)) for a, b in zip(A, B)}) print(ans)
n = int(input()) (a, b) = zip(*(map(int, input().split()) for _ in range(N))) if N else ((), ()) ans = len({(min(a, b), max(a, b)) for (a, b) in zip(A, B)}) print(ans)
URLS = [ "url1" ] STATUSPAGE_API_KEY = "" STATUSPAGE_PAGE_ID = "" STATUSPAGE_METRICS = { "url": "metric_id" } STATUSPAGE_COMPONENTS = { "url": "component_id" } PING_WEBHOOKS = [] STATUS_WEBHOOKS = [] ESCALATION_IDS = [] POLL_TIME = 60 OUTAGE_CHANGE_AFTER = 10 DRY_MODE = False DEGRADED_PERFORMANCE_TARGET_PIN...
urls = ['url1'] statuspage_api_key = '' statuspage_page_id = '' statuspage_metrics = {'url': 'metric_id'} statuspage_components = {'url': 'component_id'} ping_webhooks = [] status_webhooks = [] escalation_ids = [] poll_time = 60 outage_change_after = 10 dry_mode = False degraded_performance_target_ping = 500 timeout_pi...
{ 'application':{ 'type':'Application', 'name':'MulticolumnExample', 'backgrounds': [ { 'type':'Background', 'name':'bgMulticolumnExample', 'title':'Multicolumn Example PythonCard Application', 'size':( 620, 500 ), 'menubar': { 'type':'MenuBar', 'menus': ...
{'application': {'type': 'Application', 'name': 'MulticolumnExample', 'backgrounds': [{'type': 'Background', 'name': 'bgMulticolumnExample', 'title': 'Multicolumn Example PythonCard Application', 'size': (620, 500), 'menubar': {'type': 'MenuBar', 'menus': [{'type': 'Menu', 'name': 'menuFile', 'label': '&File', 'items':...
#!/usr/bin/env python3 """ Models that maps to Cloudformation functions. """ def replace_fn(node): """Iteratively replace all Fn/Ref in the node""" if isinstance(node, list): return [replace_fn(item) for item in node] if isinstance(node, dict): return {name: replace_fn(value) for name, val...
""" Models that maps to Cloudformation functions. """ def replace_fn(node): """Iteratively replace all Fn/Ref in the node""" if isinstance(node, list): return [replace_fn(item) for item in node] if isinstance(node, dict): return {name: replace_fn(value) for (name, value) in node.items()} ...
"""Rule and corresponding provider that joins a label pointing to a TreeArtifact with a path nested within that directory """ load("//lib:utils.bzl", _to_label = "to_label") DirectoryPathInfo = provider( doc = "Joins a label pointing to a TreeArtifact with a path nested within that directory.", fields = { ...
"""Rule and corresponding provider that joins a label pointing to a TreeArtifact with a path nested within that directory """ load('//lib:utils.bzl', _to_label='to_label') directory_path_info = provider(doc='Joins a label pointing to a TreeArtifact with a path nested within that directory.', fields={'directory': 'a Tre...
# Find algorithm that sorts the stack of size n in O(log(n)) time. It is allowed to use operations # provided only by the stack interface: push(), pop(), top(), isEmpty() and additional stacks. class Stack: def __init__(self): self.stack = [] def push(self, value): self.stack.append(value) ...
class Stack: def __init__(self): self.stack = [] def push(self, value): self.stack.append(value) def pop(self): return self.stack.pop() def top(self): return self.stack[-1] def is_empty(self): if self.stack == []: return True else: ...
N = int(input()) MAX, VAR, FIX = range(3) # latest=9 r=3 b=4 # max_variable_fixed_values = [ # 3 4 5 # 2 3 3 # 2 1 5 # 2 4 2 # 2 2 4 # 2 5 1 # ] def try_to_beat(latest_score, r, b, max_var_fixed): our_score = 0 while b > 0: if not r: return -1 best_c_max_b, best_max_b = ...
n = int(input()) (max, var, fix) = range(3) def try_to_beat(latest_score, r, b, max_var_fixed): our_score = 0 while b > 0: if not r: return -1 (best_c_max_b, best_max_b) = (0, 0) for (max_b, variable, fixed) in max_var_fixed: this_c_max = min(max_b, b, (latest_sc...
# # PySNMP MIB module CTRON-CHASSIS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CTRON-CHASSIS-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:44:24 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Ma...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_range_constraint, constraints_union, value_size_constraint, single_value_constraint) ...
class BaseDataset: def __init__(self, data=list()): self.data = data def __getitem__(self, idx): return self.data[idx] def __len__(self): return len(self.data)
class Basedataset: def __init__(self, data=list()): self.data = data def __getitem__(self, idx): return self.data[idx] def __len__(self): return len(self.data)
"""Calculators for different values. In order to approximate the emissions for a single kWh of produced energy, per power source we look at the following 2016 data sets. * Detailed EIA-923 emissions survey data (https://www.eia.gov/electricity/data/state/emission_annual.xls) * Net Generation by State by Type of Pr...
"""Calculators for different values. In order to approximate the emissions for a single kWh of produced energy, per power source we look at the following 2016 data sets. * Detailed EIA-923 emissions survey data (https://www.eia.gov/electricity/data/state/emission_annual.xls) * Net Generation by State by Type of Pr...
def test(): # Here we can either check objects created in the solution code, or the # string value of the solution, available as __solution__. A helper for # printing formatted messages is available as __msg__. See the testTemplate # in the meta.json for details. # If an assertion fails, the messag...
def test(): assert 'DecisionTreeClassifier' in __solution__, "Make sure you are specifying a 'DecisionTreeClassifier'." assert model.get_params()['random_state'] == 1, "Make sure you are settting the model's 'random_state' to 1." assert 'model.fit' in __solution__, "Make sure you are using the '.fit()' func...
"""EXCEPTIONS Exceptions used on the project """ __all__ = ("VigoBusAPIException", "StopNotExist", "StopNotFound") class VigoBusAPIException(Exception): """Base exception for the project custom exceptions""" pass class StopNotExist(VigoBusAPIException): """The Stop does not physically exist (as reporte...
"""EXCEPTIONS Exceptions used on the project """ __all__ = ('VigoBusAPIException', 'StopNotExist', 'StopNotFound') class Vigobusapiexception(Exception): """Base exception for the project custom exceptions""" pass class Stopnotexist(VigoBusAPIException): """The Stop does not physically exist (as reported b...
def foo(): ''' >>> from mod import CamelCase as CONST ''' pass
def foo(): """ >>> from mod import CamelCase as CONST """ pass
#! python3 ############################################################################### # Copyright (c) 2021, PulseRain Technology LLC # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License (LGPL) as # published by the Free Softw...
class Prbs: def reset(self, prbs_length, start_value): if prbs_length == 7: self.poly = 193 >> 1 elif prbs_length == 9: self.poly = 545 >> 1 elif prbs_length == 11: self.poly = 2561 >> 1 elif prbs_length == 15: self.poly = 49153 >> 1 ...
class AVLNode: def __init__(self, key): self.key = key self.parent = None self.left = None self.right = None self.balance = 0 def has_left(self): return self.left is not None def has_right(self): return self.right is not None def has_no_children(self): return not...
class Avlnode: def __init__(self, key): self.key = key self.parent = None self.left = None self.right = None self.balance = 0 def has_left(self): return self.left is not None def has_right(self): return self.right is not None def has_no_childre...
# Project Euler Problem 11 # Created on: 2012-06-14 # Created by: William McDonald # Return the minimum number that can be present in # a solution set of four numbers def getMin(cap, min): k = 99 * 99 * 99 for i in range(min, 99): if i * k > cap: return i def importGrid(): ...
def get_min(cap, min): k = 99 * 99 * 99 for i in range(min, 99): if i * k > cap: return i def import_grid(): f = open('problem11.txt') grid = [] for line in f: str = line lon = str.split(' ') i = 0 for n in lon: lon[i] = int(n) ...
def get_final_line( filepath: str ) -> str: with open(filepath) as fs_r: for line in fs_r: pass return line def get_final_line__readlines( filepath: str ) -> str: with open(filepath) as fs_r: return fs_r.readlines()[-1] def main(): filepath = 'file.txt' fi...
def get_final_line(filepath: str) -> str: with open(filepath) as fs_r: for line in fs_r: pass return line def get_final_line__readlines(filepath: str) -> str: with open(filepath) as fs_r: return fs_r.readlines()[-1] def main(): filepath = 'file.txt' final_line_conte...
price = float(input("Digite o preco do produto: ")) discount = (5/100) * price total = price - discount print("O valor com desconto eh: {:.2f}".format(total))
price = float(input('Digite o preco do produto: ')) discount = 5 / 100 * price total = price - discount print('O valor com desconto eh: {:.2f}'.format(total))
def soma(n1, n2): return n1 + n2 def subtracao(n1,n2): return n1 - n2 def multiplicacao(n1, n2): return n1 * n2 def divisao(n1, n2): return n1 / n2
def soma(n1, n2): return n1 + n2 def subtracao(n1, n2): return n1 - n2 def multiplicacao(n1, n2): return n1 * n2 def divisao(n1, n2): return n1 / n2
# noinspection PyUnusedLocal # skus = unicode string price_table = { 'A': {'Price': 50, 'Offers': ['3A', 130]}, 'B': {'Price': 30, 'Offers': ['2b', 45]}, 'C': {'Price': 20, 'Offers': []}, 'D': {'Price': 15, 'Offers': []} } def checkout(skus): if ((...
price_table = {'A': {'Price': 50, 'Offers': ['3A', 130]}, 'B': {'Price': 30, 'Offers': ['2b', 45]}, 'C': {'Price': 20, 'Offers': []}, 'D': {'Price': 15, 'Offers': []}} def checkout(skus): if skus.isalpha() and skus.isupper() or skus == '': order_dict = build_orders(skus) running_total = 0 f...
""" Add `Django Filebrowser`_ to your project so you can use a centralized interface to manage the uploaded files to be used with other components (`cms`_, `zinnia`_, etc.). The version used is a special version called *no grappelli* that can be used outside of the *django-grapelli* environment. Filebrowser manage fi...
""" Add `Django Filebrowser`_ to your project so you can use a centralized interface to manage the uploaded files to be used with other components (`cms`_, `zinnia`_, etc.). The version used is a special version called *no grappelli* that can be used outside of the *django-grapelli* environment. Filebrowser manage fi...
def first_non_consecutive(arr: list) -> int: ''' This function returns the first element of an array that is not consecutive. ''' if len(arr) < 2: return None non_consecutive = [] for i in range(len(arr) - 1): if arr[i+1] - arr[i] != 1: non_consecutive.append(arr[i+1]) if...
def first_non_consecutive(arr: list) -> int: """ This function returns the first element of an array that is not consecutive. """ if len(arr) < 2: return None non_consecutive = [] for i in range(len(arr) - 1): if arr[i + 1] - arr[i] != 1: non_consecutive.append(arr[i + 1]) ...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: Jared """ # LATTICE VARIATION lattice_mul = 20 #how many lattice variations to perform lattice_variation_percent = 10 keep_aspect = False # COMPOSITION VARIATION # upper limit to sim num lattice_comp_num = 500 #how many crystals to generate (random mixing) l...
""" @author: Jared """ lattice_mul = 20 lattice_variation_percent = 10 keep_aspect = False lattice_comp_num = 500 lattice_init = [11.7, 5.4, 11.7] fnum = 20 atomic_position_variation_percent = 3 resolution = [1, 1, 2] asite = ['Cs', 'Rb', 'K', 'Na'] bsite = ['Sn', 'Ge'] xsite = ['I', 'Cl', 'Br']
try: print('enter try statement') raise Exception() print('exit try statement') except Exception as inst: print(inst.__class__.__name__)
try: print('enter try statement') raise exception() print('exit try statement') except Exception as inst: print(inst.__class__.__name__)
def solution(M, A): # write your code in Python 3.6 seen = [0] * (M + 1) count = 0 i,j = 0,0 while(i < len(A) and j < len(A)): if seen[A[j]]: seen[A[i]] = 0 i += 1 else: seen[A[j]] = 1 count += j - i + 1 j += 1 if co...
def solution(M, A): seen = [0] * (M + 1) count = 0 (i, j) = (0, 0) while i < len(A) and j < len(A): if seen[A[j]]: seen[A[i]] = 0 i += 1 else: seen[A[j]] = 1 count += j - i + 1 j += 1 if count > 1000000000.0: ...
# Time: O(n) # Space: O(1) # 978 # A subarray A[i], A[i+1], ..., A[j] of A is said to be turbulent if and only if: # - For i <= k < j, A[k] > A[k+1] when k is odd, and A[k] < A[k+1] when k is even; # - OR, for i <= k < j, A[k] > A[k+1] when k is even, and A[k] < A[k+1] when k is odd. # That is, the subarray is turbu...
class Solution(object): def max_turbulence_size(self, A): """ :type A: List[int] :rtype: int """ ans = 1 start = 0 for i in xrange(1, len(A)): c = cmp(A[i - 1], A[i]) if c == 0: start = i elif i == len(A) - ...
class TitleItem: def __init__(self, title='', title_type='', genre='', directors='', actors='', run_time='', release_date='', cover_url=''): """ :param title: String. The title of the movie/tv show. :param title_type: String. Options: feature or tv_series. :param ge...
class Titleitem: def __init__(self, title='', title_type='', genre='', directors='', actors='', run_time='', release_date='', cover_url=''): """ :param title: String. The title of the movie/tv show. :param title_type: String. Options: feature or tv_series. :param genre: String. A li...
class Earth: """ Class used to represent Earth. Values are defined using EGM96 geopotential model. Constant naming convention is intentionally not used since the values defined here may be updated in the future by introducing other geopotential models """ mu = 3.986004415e5 #km^3/s^2 ...
class Earth: """ Class used to represent Earth. Values are defined using EGM96 geopotential model. Constant naming convention is intentionally not used since the values defined here may be updated in the future by introducing other geopotential models """ mu = 398600.4415 equatorial_r...
# # PySNMP MIB module Wellfleet-DS1-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Wellfleet-DS1-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:39:54 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Ma...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_intersection, constraints_union, single_value_constraint, value_size_constraint) ...
#import numpy as np """ #moving avg #Parameters array of ts value #Returns moving avg """ #def moving_average(series, n): # return np.average(series[-n:])
""" #moving avg #Parameters array of ts value #Returns moving avg """
# *args - arguments - it returns tuple # **kwargs - keyword arguments - it returns dictionary def myfunc(*args): print(args) myfunc(1,2,3,4,5,6,7,8,9,0) def myfunc1(**kwargs): print(kwargs) if 'fruit' in kwargs: print('my fruit of choice is {}'.format(kwargs['fruit'])) else: print('...
def myfunc(*args): print(args) myfunc(1, 2, 3, 4, 5, 6, 7, 8, 9, 0) def myfunc1(**kwargs): print(kwargs) if 'fruit' in kwargs: print('my fruit of choice is {}'.format(kwargs['fruit'])) else: print('I did not find any fruit here') myfunc1(fruit='apple', veggie='lettuce')
def test_get_topics(client): response = client.get("/topics/") contents = response.get_json() assert contents["status"] == "OK" assert type(contents["payload"]) is dict assert type(contents["payload"]["topics"]) is list assert type(contents["payload"]["subtopics"]) is dict assert response.s...
def test_get_topics(client): response = client.get('/topics/') contents = response.get_json() assert contents['status'] == 'OK' assert type(contents['payload']) is dict assert type(contents['payload']['topics']) is list assert type(contents['payload']['subtopics']) is dict assert response.st...
""" Find an efficient algorithm to find the smallest distance (measured in number of words) between any two given words in a string. For example, given words "hello", and "world" and a text content of "dog cat hello cat dog dog hello cat world", return 1 because there's only one word "cat" in between the two words. ""...
""" Find an efficient algorithm to find the smallest distance (measured in number of words) between any two given words in a string. For example, given words "hello", and "world" and a text content of "dog cat hello cat dog dog hello cat world", return 1 because there's only one word "cat" in between the two words. ""...
# https://practice.geeksforgeeks.org/problems/number-of-palindromic-paths-in-a-matrix0819/1# # at each node recursively call itself and at bottom,left cornet determine it its a palindrome class Solution: def rec(self, matrix, it, jt, ib, jb, cache): if it > ib or jt > jb: cache[(it, jt, ib, j...
class Solution: def rec(self, matrix, it, jt, ib, jb, cache): if it > ib or jt > jb: cache[it, jt, ib, jb] = 0 return 0 if matrix[it][jt] != matrix[ib][jb]: cache[it, jt, ib, jb] = 0 return 0 if abs(it - ib) + abs(jt - jb) < 2: cac...
# Numbers 0 to 10 print(list(range(0,11))) print() # Even numbers 0 to 10 print(list(range(0,11,2))) print() # Odd numbers 0 to 10 print(list(range(1,11,2))) print() # Numbers 20 to 10 print(list(range(20,9,-1))) print() # Numbers 45 to 75 divisable by 5 print(list(range(45, 76, 5)))
print(list(range(0, 11))) print() print(list(range(0, 11, 2))) print() print(list(range(1, 11, 2))) print() print(list(range(20, 9, -1))) print() print(list(range(45, 76, 5)))
# https://leetcode.com/problems/monotonic-array/description/ # # algorithms # Medium (42.6%) # Total Accepted: 4.8k # Total Submissions: 11.2k # beats 77.52% of python submissions class Solution(object): def largestOverlap(self, A, B): """ :type A: List[List[int]] :type B: List[List[int...
class Solution(object): def largest_overlap(self, A, B): """ :type A: List[List[int]] :type B: List[List[int]] :rtype: int """ length = len(A) (a_1_arr, b_1_arr) = ([], []) for i in xrange(length): for j in xrange(length): ...
term_mappings = { 'Cell': 'csvw:Cell', 'Column': 'csvw:Column', 'Datatype': 'csvw:Datatype', 'Dialect': 'csvw:Dialect', 'Direction': 'csvw:Direction', 'ForeignKey': 'csvw:ForeignKey', 'JSON': 'csvw:JSON', 'NCName': 'xsd:NCName', 'NMTOKEN': 'xsd:NMTOKEN', 'Name': 'xsd:Name', '...
term_mappings = {'Cell': 'csvw:Cell', 'Column': 'csvw:Column', 'Datatype': 'csvw:Datatype', 'Dialect': 'csvw:Dialect', 'Direction': 'csvw:Direction', 'ForeignKey': 'csvw:ForeignKey', 'JSON': 'csvw:JSON', 'NCName': 'xsd:NCName', 'NMTOKEN': 'xsd:NMTOKEN', 'Name': 'xsd:Name', 'NumericFormat': 'csvw:NumericFormat', 'QName'...
expected_number_of_transactions = [ 2650, 2543, 1395, 2751, 2398, 2827, 2737, 3084, 1998, 2997, 976, 1929, 3268, 1904, 1772, 776, 2553, 2547, 2581, 2226, 2307, 2812, 2618, 177, 1538, 1990, 2323, 2613, 2503, 2140, 2542, 2291, 2782, 1994, 2513, 2773, 1359, 1744, 868, 896, 2228, 2300, 2349, 2440, 2562, 2123,...
expected_number_of_transactions = [2650, 2543, 1395, 2751, 2398, 2827, 2737, 3084, 1998, 2997, 976, 1929, 3268, 1904, 1772, 776, 2553, 2547, 2581, 2226, 2307, 2812, 2618, 177, 1538, 1990, 2323, 2613, 2503, 2140, 2542, 2291, 2782, 1994, 2513, 2773, 1359, 1744, 868, 896, 2228, 2300, 2349, 2440, 2562, 2123, 3150, 2564, 15...
files_c=[ 'C/Threads.c', ] files_cpp=[ 'CPP/7zip/UI/P7ZIP/wxP7ZIP.cpp', 'CPP/Common/IntToString.cpp', 'CPP/Common/MyString.cpp', 'CPP/Common/MyVector.cpp', 'CPP/Common/StringConvert.cpp', 'CPP/Windows/FileDir.cpp', 'CPP/Windows/FileFind.cpp', 'CPP/Windows/FileIO.cpp', 'CPP/Windows/FileName.cpp', 'CPP/Commo...
files_c = ['C/Threads.c'] files_cpp = ['CPP/7zip/UI/P7ZIP/wxP7ZIP.cpp', 'CPP/Common/IntToString.cpp', 'CPP/Common/MyString.cpp', 'CPP/Common/MyVector.cpp', 'CPP/Common/StringConvert.cpp', 'CPP/Windows/FileDir.cpp', 'CPP/Windows/FileFind.cpp', 'CPP/Windows/FileIO.cpp', 'CPP/Windows/FileName.cpp', 'CPP/Common/MyWindows.c...
# Medium # https://leetcode.com/problems/spiral-matrix/ # Time Complexity: O(N) # Space Complexity: 0(1) class Solution: def spiralOrder(self, matrix: List[List[int]]) -> List[int]: return Solution.spiralsol(matrix, []) @staticmethod def spiralsol(matrix, res): m = len(matrix) i...
class Solution: def spiral_order(self, matrix: List[List[int]]) -> List[int]: return Solution.spiralsol(matrix, []) @staticmethod def spiralsol(matrix, res): m = len(matrix) if m == 0: return res n = len(matrix[0]) if n == 0: return res ...
# https://www.reddit.com/wiki/bottiquette omit /r/suicidewatch and /r/depression # note: lowercase for case insensitive match blacklist = [ # https://www.reddit.com/r/Bottiquette/wiki/robots_txt_json "anime", "asianamerican", "askhistorians", "askscience", "askreddit", "aww", "chicagosu...
blacklist = ['anime', 'asianamerican', 'askhistorians', 'askscience', 'askreddit', 'aww', 'chicagosuburbs', 'cosplay', 'cumberbitches', 'd3gf', 'deer', 'depression', 'depthhub', 'drinkingdollars', 'forwardsfromgrandma', 'geckos', 'giraffes', 'grindsmygears', 'indianfetish', 'me_irl', 'misc', 'movies', 'mixedbreeds', 'n...
load("//bazel/rules/cpp:object.bzl", "cpp_object") load("//bazel/rules/hcp:hcp.bzl", "hcp") load("//bazel/rules/hcp:hcp_hdrs_derive.bzl", "hcp_hdrs_derive") def string_tree_to_static_tree_parser(name): #the file names to use target_name = name + "_string_tree_parser_dat" in_file = name + ".dat" outfile...
load('//bazel/rules/cpp:object.bzl', 'cpp_object') load('//bazel/rules/hcp:hcp.bzl', 'hcp') load('//bazel/rules/hcp:hcp_hdrs_derive.bzl', 'hcp_hdrs_derive') def string_tree_to_static_tree_parser(name): target_name = name + '_string_tree_parser_dat' in_file = name + '.dat' outfile = name + '_string_tree_par...
class BaseServerException(Exception): def __init__(self, detail, status_code, message): super().__init__(message) self.detail = detail self.status_code = status_code class SearchFieldRequiered(BaseServerException): def __init__(self): super().__init__(detail='entity', status_co...
class Baseserverexception(Exception): def __init__(self, detail, status_code, message): super().__init__(message) self.detail = detail self.status_code = status_code class Searchfieldrequiered(BaseServerException): def __init__(self): super().__init__(detail='entity', status_c...
class Solution: def nextGreaterElement(self, n: int) -> int: s = list(str(n)) i = len(s) - 1 while i - 1 >= 0 and s[i - 1] >= s[i]: i -= 1 if i == 0: return -1 j = len(s) - 1 while s[j] <= s[i - 1]: j -= 1 s[i - 1], s[j] =...
class Solution: def next_greater_element(self, n: int) -> int: s = list(str(n)) i = len(s) - 1 while i - 1 >= 0 and s[i - 1] >= s[i]: i -= 1 if i == 0: return -1 j = len(s) - 1 while s[j] <= s[i - 1]: j -= 1 (s[i - 1], s[j]...
class MyrialCompileException(Exception): pass class MyrialUnexpectedEndOfFileException(MyrialCompileException): def __str__(self): return "Unexpected end-of-file" class MyrialParseException(MyrialCompileException): def __init__(self, token): self.token = token def __str__(self): ...
class Myrialcompileexception(Exception): pass class Myrialunexpectedendoffileexception(MyrialCompileException): def __str__(self): return 'Unexpected end-of-file' class Myrialparseexception(MyrialCompileException): def __init__(self, token): self.token = token def __str__(self): ...