content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# Copyright (c) 2012 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. { 'targets': [ { 'target_name': 'duplicate_names', 'type': 'shared_library', 'dependencies': [ 'one/sub.gyp:one', ...
{'targets': [{'target_name': 'duplicate_names', 'type': 'shared_library', 'dependencies': ['one/sub.gyp:one', 'two/sub.gyp:two']}]}
class FinnHubAPI: TOKEN="yourTokenHere" # Get a FinHubb API from # https://finnhub.io/
class Finnhubapi: token = 'yourTokenHere'
B = BLOCK_SIZE = 30 SURFACE_WIDTH = 300 SURFACE_HEIGHT = 600 S = [['.....', '.....', '..00.', '.00..', '.....'], ['.....', '..0..', '..00.', '...0.', '.....' ]] Z = [['.....', '.....', '.00..', '..00.', '.....'], ['.....', ...
b = block_size = 30 surface_width = 300 surface_height = 600 s = [['.....', '.....', '..00.', '.00..', '.....'], ['.....', '..0..', '..00.', '...0.', '.....']] z = [['.....', '.....', '.00..', '..00.', '.....'], ['.....', '..,0.', '..00.', '..0..', '.....']] i = [['.....', '..0..', '..0..', '..0..', '.....'], ['.....',...
lista = ('Lapis', 1.5, 'caneta', 2.5, 'caderno', 16.90, 'mochila', 67.99, 'livro', 37.89) print('-'*40) print(f'{"LISTA ESCOLAR":^40}') print('-'*40) for c in range(0, len(lista)): if c % 2 == 0: print(f'{lista[c]:.<30}', end=' ') else: print(f'R$ {lista[c]:.2f}') print('-'*40)
lista = ('Lapis', 1.5, 'caneta', 2.5, 'caderno', 16.9, 'mochila', 67.99, 'livro', 37.89) print('-' * 40) print(f"{'LISTA ESCOLAR':^40}") print('-' * 40) for c in range(0, len(lista)): if c % 2 == 0: print(f'{lista[c]:.<30}', end=' ') else: print(f'R$ {lista[c]:.2f}') print('-' * 40)
class WindowDatas(): def __init__(self): self.previousWindow = None self.nextWindow = None self.finalWindow = None self.accountDATA = None self.actions= None self.show= True self.database = None
class Windowdatas: def __init__(self): self.previousWindow = None self.nextWindow = None self.finalWindow = None self.accountDATA = None self.actions = None self.show = True self.database = None
# Flask Config Variables to be Auto-Loaded config = { 'flask': { 'SECRET_KEY': b'!T3DxK;L1jJGYf$', # Please change. See Flask for requirements. 'TESTING': True, 'TEMPLATES_AUTO_RELOAD': True, 'SERVER_NAME': 'flask.mvc' }, 'templati...
config = {'flask': {'SECRET_KEY': b'!T3DxK;L1jJGYf$', 'TESTING': True, 'TEMPLATES_AUTO_RELOAD': True, 'SERVER_NAME': 'flask.mvc'}, 'templating': {'template_folder': 'application/views', 'static_folder': 'public/assets'}}
class FVTADD : def __init__(self): self.default = '' def runTest(self,self) : return TemplateTest.runTest(self) def tearDown(self,self) : return TemplateTest.tearDown(self) def setUp(self,self) : return TemplateTest.setUp(self) def chkSetUpCondition(self,self,fv,...
class Fvtadd: def __init__(self): self.default = '' def run_test(self, self): return TemplateTest.runTest(self) def tear_down(self, self): return TemplateTest.tearDown(self) def set_up(self, self): return TemplateTest.setUp(self) def chk_set_up_condition(self, se...
#Your task is to complete this function # function should strictly return a string else answer wont be printed def multiplyStrings(str1, str2): return str(int(str1) * int(str2))
def multiply_strings(str1, str2): return str(int(str1) * int(str2))
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # Prefixes CONSOLE_LOG_PREFIX = "LanguageWorkerConsoleLog" # Capabilities RAW_HTTP_BODY_BYTES = "RawHttpBodyBytes" TYPED_DATA_COLLECTION = "TypedDataCollection" RPC_HTTP_BODY_ONLY = "RpcHttpBodyOnly" RPC_HTTP_TRIGGER_METADAT...
console_log_prefix = 'LanguageWorkerConsoleLog' raw_http_body_bytes = 'RawHttpBodyBytes' typed_data_collection = 'TypedDataCollection' rpc_http_body_only = 'RpcHttpBodyOnly' rpc_http_trigger_metadata_removed = 'RpcHttpTriggerMetadataRemoved' pyazure_webhost_debug = 'PYAZURE_WEBHOST_DEBUG' python_rollback_cwd_path = 'PY...
n = int(input()) res = 0 for i in range(n): res += int((input().strip())[:25]) print(str(res)[:10])
n = int(input()) res = 0 for i in range(n): res += int(input().strip()[:25]) print(str(res)[:10])
class Solution: def numDecodings(self, s: str) -> int: if not s or s[0] == '0': return 0 dp = [1, 1] for i in range(2, len(s) + 1): if '10' < s[i - 2: i] <= '26' and s[i - 1] != '0': dp.append(dp[i - 1] + dp[i - 2]) elif s[i - 2: i] == '10' or s[i - 2:...
class Solution: def num_decodings(self, s: str) -> int: if not s or s[0] == '0': return 0 dp = [1, 1] for i in range(2, len(s) + 1): if '10' < s[i - 2:i] <= '26' and s[i - 1] != '0': dp.append(dp[i - 1] + dp[i - 2]) elif s[i - 2:i] == '10'...
print("Welcome to the birthday dictionary. We know the birthdays of:") birthdays = {"Albert Einstein": "03/14/1879", "Benjamin Franklin": "01/17/1706", "Ada Lovelace": "12/10/1815"} for person in birthdays: print(person) name = input("Who's birthday do you want to look up? ") if(name in birthdays): print(...
print('Welcome to the birthday dictionary. We know the birthdays of:') birthdays = {'Albert Einstein': '03/14/1879', 'Benjamin Franklin': '01/17/1706', 'Ada Lovelace': '12/10/1815'} for person in birthdays: print(person) name = input("Who's birthday do you want to look up? ") if name in birthdays: print(name + ...
JAVA_LANGUAGE_LEVEL = "1.8" KOTLIN_LANGUAGE_LEVEL = "1.3" KOTLINC_VERSION = "1.3.41" KOTLINC_ROOT = "https://github.com/JetBrains/kotlin/releases/download" KOTLINC_SHA = "c44ab6866895606e408b60934ebe45d4befcbc33ea0e4ea73c4b3b89ad770132" KOTLIN_RULES_VERSION = "legacy-modded-0_26_1-02" KOTLIN_RULES_SHA = "245d0bc1511048...
java_language_level = '1.8' kotlin_language_level = '1.3' kotlinc_version = '1.3.41' kotlinc_root = 'https://github.com/JetBrains/kotlin/releases/download' kotlinc_sha = 'c44ab6866895606e408b60934ebe45d4befcbc33ea0e4ea73c4b3b89ad770132' kotlin_rules_version = 'legacy-modded-0_26_1-02' kotlin_rules_sha = '245d0bc1511048...
"Listing of all e2e tests, used to set up their repositories in /WORKSPACE" ALL_E2E = [ "bazel_managed_deps", "fine_grained_symlinks", "jasmine", "karma", "karma_stack_trace", "karma_typescript", "less", "node_loader_no_preserve_symlinks", "node_loader_preserve_symlinks", "packag...
"""Listing of all e2e tests, used to set up their repositories in /WORKSPACE""" all_e2_e = ['bazel_managed_deps', 'fine_grained_symlinks', 'jasmine', 'karma', 'karma_stack_trace', 'karma_typescript', 'less', 'node_loader_no_preserve_symlinks', 'node_loader_preserve_symlinks', 'packages', 'stylus', 'symlinked_node_modul...
base_api = "https://myanimelist.net/" #Anime anime = base_api + "api/animelist/" search_anime = base_api + "api/anime/search.xml" add_anime = anime + "add/{}.xml" update_anime = anime + "update/{}.xml" delete_anime = anime + "delete/{}.xml" #Manga manga = base_api + "api/mangalist/" search_manga = base_api + "api/ma...
base_api = 'https://myanimelist.net/' anime = base_api + 'api/animelist/' search_anime = base_api + 'api/anime/search.xml' add_anime = anime + 'add/{}.xml' update_anime = anime + 'update/{}.xml' delete_anime = anime + 'delete/{}.xml' manga = base_api + 'api/mangalist/' search_manga = base_api + 'api/manga/search.xml' a...
{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "Untitled16.ipynb", "provenance": [], "collapsed_sections": [], "authorship_tag": "ABX9TyOm2YDBa+1KtqbwxKRFb+3Y", "include_colab_link": true }, "kernelspec": { "name": "python3", "display_n...
{'nbformat': 4, 'nbformat_minor': 0, 'metadata': {'colab': {'name': 'Untitled16.ipynb', 'provenance': [], 'collapsed_sections': [], 'authorship_tag': 'ABX9TyOm2YDBa+1KtqbwxKRFb+3Y', 'include_colab_link': true}, 'kernelspec': {'name': 'python3', 'display_name': 'Python 3'}}, 'cells': [{'cell_type': 'markdown', 'metadata...
#WAP to accept the following data in a dictionary: #Item_Name, CP, SP #Displaying #Item_Name, Profit or Loss #The program should continue as long as the user wishes to. itemInt = int(input("Enter number of items to be stored: ")) x = "y" shopping = dict() while x == "y" or x == "Y": Item_name = input("Enter...
item_int = int(input('Enter number of items to be stored: ')) x = 'y' shopping = dict() while x == 'y' or x == 'Y': item_name = input('Enter the Item Name: ') cp = int(input('Enter the Cost Price: ')) sp = int(input('Enter the Selling price: ')) shopping[Item_name] = [cp, sp, sp - cp] print('\n\nITE...
#carriers [ x ] # substrates [ x ] guanine_mods = {'G_to_m7G' : {'name' : '7-methylguanosine', 'input' : 'G', 'output' : 'm7G', 'machines' : {'RlmL_dim' : {'proteins' : {'b0948' : 'RlmKL'}, 'RNA_position_substrates' :{'rRNA' : {2...
guanine_mods = {'G_to_m7G': {'name': '7-methylguanosine', 'input': 'G', 'output': 'm7G', 'machines': {'RlmL_dim': {'proteins': {'b0948': 'RlmKL'}, 'RNA_position_substrates': {'rRNA': {2069: {'LSU/23S/prokaryotic': 1}}}, 'carriers': None}, 'enzyme_new_RmtB': {'proteins': {'bnum': 'RmtB'}, 'RNA_position_substrates': {'rR...
list1=[] limit=int(input('Enter the size of list')) for i in range(1,limit+1,1): items=input('Enter the items of list:') list1.append(items) for i in list1: print(i) del list1[0] print(list1)
list1 = [] limit = int(input('Enter the size of list')) for i in range(1, limit + 1, 1): items = input('Enter the items of list:') list1.append(items) for i in list1: print(i) del list1[0] print(list1)
def get_me(): print('hi') if __name__ == '__main__': # This is executed you run via terminal print('Running other_module.py...')
def get_me(): print('hi') if __name__ == '__main__': print('Running other_module.py...')
options = {0 : "zero", 1 : "sqr", 4 : "sqr", 9 : "sqr", 2 : "even", 3 : "prime", 5 : "prime", 7 : "prime", } def zero(): print ("You typed zero.\n") def sqr(): print ("n is a perfect square\n") def...
options = {0: 'zero', 1: 'sqr', 4: 'sqr', 9: 'sqr', 2: 'even', 3: 'prime', 5: 'prime', 7: 'prime'} def zero(): print('You typed zero.\n') def sqr(): print('n is a perfect square\n') def even(): print('n is an even number\n') def prime(): print('n is a prime number\n') num = int(input('Enter a number...
model_imp = DecisionTreeClassifier(random_state=22) model_imp.fit(X_Smote_train,Y_Smote_train) importance = model_imp.feature_importances_ for i,v in enumerate(importance): print('Feature: %0d, Score: %.5f' % (i,v)) plt.bar([x for x in range(len(importance))], importance) plt.show() np.where(importance>0.015) X_Smote...
model_imp = decision_tree_classifier(random_state=22) model_imp.fit(X_Smote_train, Y_Smote_train) importance = model_imp.feature_importances_ for (i, v) in enumerate(importance): print('Feature: %0d, Score: %.5f' % (i, v)) plt.bar([x for x in range(len(importance))], importance) plt.show() np.where(importance > 0.0...
n1 = int n2 = int n3 = int n4 = int n5 = int n6 = int n7 = int n8 = int n9 = int n = int(input("Digite un Numero: ")) n1 = n*1 n2 = n*2 n3 = n*3 n4 = n*4 n5 = n*5 n6 = n*6 n7 = n*7 n8 = n*8 n9 = n*9 n10 = n*10 print ("El calculo Uno es: ", n1) print ("El calculo dos es: ", n2) print ("El calculo tres es: "...
n1 = int n2 = int n3 = int n4 = int n5 = int n6 = int n7 = int n8 = int n9 = int n = int(input('Digite un Numero: ')) n1 = n * 1 n2 = n * 2 n3 = n * 3 n4 = n * 4 n5 = n * 5 n6 = n * 6 n7 = n * 7 n8 = n * 8 n9 = n * 9 n10 = n * 10 print('El calculo Uno es: ', n1) print('El calculo dos es: ', n2) print('El calculo ...
# QUICK SORT # BEST: O(nlogn) time, O(logn) space # AVERAGE: O(nlogn) time, O(logn) space # WORST: O(n^2) time, O(logn) space def quickSort(array): # Write your code here. partition(array, 0, len(array) - 1) return array def partition(array, low, high): if low < high: print("Inside partition") pivot =...
def quick_sort(array): partition(array, 0, len(array) - 1) return array def partition(array, low, high): if low < high: print('Inside partition') pivot = quick_sort_helper(array, low, high) print('low', low, 'high', high, 'pivot', pivot) partition(array, low, pivot - 1) ...
#!/usr/bin/python3 def list_division(my_list_1, my_list_2, list_length): "divides element by element 2 lists" i = result = 0 list = [] for i in range(list_length): try: result = (my_list_1[i] / my_list_2[i]) except TypeError: result = 0 print("wrong ty...
def list_division(my_list_1, my_list_2, list_length): """divides element by element 2 lists""" i = result = 0 list = [] for i in range(list_length): try: result = my_list_1[i] / my_list_2[i] except TypeError: result = 0 print('wrong type') exce...
print('How old are you?') #ask the age my_Age = input() # input age if int(my_Age) < 18: # age comparision print('You are not on age') elif int(my_Age) >= 18: print('You are on age') if int(my_Age) >= 100: print('You are a vampire or maybe inmortal') if int(my_Age) >= 500: ...
print('How old are you?') my__age = input() if int(my_Age) < 18: print('You are not on age') elif int(my_Age) >= 18: print('You are on age') if int(my_Age) >= 100: print('You are a vampire or maybe inmortal') if int(my_Age) >= 500: print('You are inmortal') while int(my_Age) < 18...
# https://github.com/tensorflow/tensorflow/issues/2169 # MAX Unpooling in tensorflow # Solution from fabianbormann: # Limitations: # 1. //, argmax run ONLY on GPUs. def unravel_argmax(argmax, shape): output_list = [] output_list.append(argmax // (shape[2] * shape[3])) output_list.append(argmax % (shape[2]...
def unravel_argmax(argmax, shape): output_list = [] output_list.append(argmax // (shape[2] * shape[3])) output_list.append(argmax % (shape[2] * shape[3]) // shape[3]) return tf.stack(output_list) def unpool_layer2x2(x, raveled_argmax, out_shape): argmax = unravel_argmax(raveled_argmax, tf.to_int64(...
#Task No. 02 print('3rd graph') graph_3 = {7:[11,8],2:[],3:[8,10],11:[2,9,10],5:[11],9:[],8:[9]} keys_3 = list(graph_3.keys()) ## ##for i in range(len(keys_3)): ## temp = graph_3.get(keys_3[i]) ## print(str(keys_3[i]) + ' is connected with ' + str(temp) + ' and has degree of ' + str(len(temp))) for i in graph_3:...
print('3rd graph') graph_3 = {7: [11, 8], 2: [], 3: [8, 10], 11: [2, 9, 10], 5: [11], 9: [], 8: [9]} keys_3 = list(graph_3.keys()) for i in graph_3: in = 0 for j in graph_3: if i in graph_3[j]: in = In + 1 print(i, ' is connected with ', str(graph_3[i]), ' and has out-degree ', str(len(g...
print('Hello World') name = input('Please enter your name: ') print('Welcome', name) input1 = int(input('Please enter a number: ')) input2 = int(input('Please enter another number: ')) value = input1 + input2 print(f'The result of {input1} + {input2} is', value) print('The type of the value is', type(value)) input_s...
print('Hello World') name = input('Please enter your name: ') print('Welcome', name) input1 = int(input('Please enter a number: ')) input2 = int(input('Please enter another number: ')) value = input1 + input2 print(f'The result of {input1} + {input2} is', value) print('The type of the value is', type(value)) input_stri...
class Solution: def maxProfit(self, prices, fee): N = len(prices) if N < 2: return 0 ans = 0 minimum = prices[0] for i in range(1, N): if prices[i] < minimum: minimum = prices[i] elif prices[i] > minimum + fee: ...
class Solution: def max_profit(self, prices, fee): n = len(prices) if N < 2: return 0 ans = 0 minimum = prices[0] for i in range(1, N): if prices[i] < minimum: minimum = prices[i] elif prices[i] > minimum + fee: ...
ARGUMENT_PROCESS_NAME = 'process_name' ARGUMENT_FLOW_NAME = 'flow_name' ARGUMENT_STEP_NAME = 'step_name' ARGUMENT_TIMEPERIOD = 'timeperiod' ARGUMENT_START_TIMEPERIOD = 'start_timeperiod' ARGUMENT_END_TIMEPERIOD = 'end_timeperiod' ARGUMENT_UNIT_OF_WORK_TYPE = 'unit_of_work_type' # whether the unit_of_work is TYPE_MA...
argument_process_name = 'process_name' argument_flow_name = 'flow_name' argument_step_name = 'step_name' argument_timeperiod = 'timeperiod' argument_start_timeperiod = 'start_timeperiod' argument_end_timeperiod = 'end_timeperiod' argument_unit_of_work_type = 'unit_of_work_type' argument_run_mode = 'run_mode' run_mode_r...
class Plot(object): def __init__(self): pass def __call__(self): pass
class Plot(object): def __init__(self): pass def __call__(self): pass
# # PySNMP MIB module EQLEXT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/EQLEXT-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:05:18 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:...
(eql_ext,) = mibBuilder.importSymbols('APENT-MIB', 'eqlExt') (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, single_value_constraint, const...
#Open file file = open('inputs\input4.txt') data = file.read().split('\n\n') file.close() #Clean input dataClean = [] for x in data: dataClean.append(x.split()) #Split with no argument splits on whitespace #Solution 1 reqFields = ['byr','iyr','eyr','hgt','hcl','ecl','pid'] valid = 0 for passport in dataClean:...
file = open('inputs\\input4.txt') data = file.read().split('\n\n') file.close() data_clean = [] for x in data: dataClean.append(x.split()) req_fields = ['byr', 'iyr', 'eyr', 'hgt', 'hcl', 'ecl', 'pid'] valid = 0 for passport in dataClean: reqs_met = 0 for field in passport: field = field.split(':') ...
def get_input(file): with open(file, 'rt', encoding='utf8') as f: lines = [line.strip() for line in f] p1_cars = get_player_cards(lines, 1) p2_cars = get_player_cards(lines, 2) return p1_cars, p2_cars def get_player_cards(lines, player): start = lines.index(f'Player {player}:') + 1 en...
def get_input(file): with open(file, 'rt', encoding='utf8') as f: lines = [line.strip() for line in f] p1_cars = get_player_cards(lines, 1) p2_cars = get_player_cards(lines, 2) return (p1_cars, p2_cars) def get_player_cards(lines, player): start = lines.index(f'Player {player}:') + 1 en...
__all__ = [ "int_to_bytes", "bytes_to_int", "bytes_to_hex", "hex_to_bytes" ] def bytes_to_hex(src: bytes, with0x: bool = True, max_length: int = None) -> str: if max_length is not None: assert len(src) <= max_length, f"input bytes length is too long ({len(src)} > {max_length})" res = s...
__all__ = ['int_to_bytes', 'bytes_to_int', 'bytes_to_hex', 'hex_to_bytes'] def bytes_to_hex(src: bytes, with0x: bool=True, max_length: int=None) -> str: if max_length is not None: assert len(src) <= max_length, f'input bytes length is too long ({len(src)} > {max_length})' res = src.hex() if max_len...
class Solution: def longestPalindrome(self, s: str) -> str: lst = [] for ch in s: lst.append('#') lst.append(ch) lst.append('#') S = ''.join(lst) def helper(S): mx = 0 n = len(S) P = [0] * n c = 0 ...
class Solution: def longest_palindrome(self, s: str) -> str: lst = [] for ch in s: lst.append('#') lst.append(ch) lst.append('#') s = ''.join(lst) def helper(S): mx = 0 n = len(S) p = [0] * n c = 0 ...
LOG_DIR = "/tmp/mylogdir" def write_message(filename, message): try: path = os.path.join(LOG_DIR, filename) with open(path, 'a') as writer: writer.write(message) except OSError as error: print('Unable to write log message to {}: {}'.format(path, error))
log_dir = '/tmp/mylogdir' def write_message(filename, message): try: path = os.path.join(LOG_DIR, filename) with open(path, 'a') as writer: writer.write(message) except OSError as error: print('Unable to write log message to {}: {}'.format(path, error))
#!/usr/bin/env python3 n1 = int(input("Enter 1st subject degree: ")) n2 = int(input("Enter 2nd subject degree: ")) n3 = int(input("Enter 3rd subject degree: ")) if n1 >= 50 and n2 >= 50 and n3 >= 50: print("Pass") else: print("Fail")
n1 = int(input('Enter 1st subject degree: ')) n2 = int(input('Enter 2nd subject degree: ')) n3 = int(input('Enter 3rd subject degree: ')) if n1 >= 50 and n2 >= 50 and (n3 >= 50): print('Pass') else: print('Fail')
# Python3 def bishopAndPawn(bishop, pawn): getPos = lambda s: ('abcdefgh'.index(s[0]), '12345678'.index(s[1])) bishopPos = getPos(bishop) pawnPos = getPos(pawn) return abs(bishopPos[0] - pawnPos[0]) == abs(bishopPos[1] - pawnPos[1])
def bishop_and_pawn(bishop, pawn): get_pos = lambda s: ('abcdefgh'.index(s[0]), '12345678'.index(s[1])) bishop_pos = get_pos(bishop) pawn_pos = get_pos(pawn) return abs(bishopPos[0] - pawnPos[0]) == abs(bishopPos[1] - pawnPos[1])
class Solution: # @param A : integer # @param B : integer # @return an integer def gcd(self,A, B): if(B==0): return A return self.gcd(B,A%B)
class Solution: def gcd(self, A, B): if B == 0: return A return self.gcd(B, A % B)
class Solution: # @param A : list of strings # @return a strings def longestCommonPrefix(self, A): A.sort() minLen = min(len(A[0]), len(A[len(A) - 1])) prefix = '' for i in range(minLen): if A[0][i] == A[len(A) - 1][i]: prefix += A[0][i] ...
class Solution: def longest_common_prefix(self, A): A.sort() min_len = min(len(A[0]), len(A[len(A) - 1])) prefix = '' for i in range(minLen): if A[0][i] == A[len(A) - 1][i]: prefix += A[0][i] else: break return str(pref...
k = int(input()) q = input() cut = [0] topset = set([q[0]]) for i in range(1, len(q)): if len(cut) == k: break if q[i] not in topset: cut.append(i) topset.add(q[i]) if len(cut) < k: print('NO') else: print('YES') for i in range(k-1): print(q[cut[i]:cut[i+1]])...
k = int(input()) q = input() cut = [0] topset = set([q[0]]) for i in range(1, len(q)): if len(cut) == k: break if q[i] not in topset: cut.append(i) topset.add(q[i]) if len(cut) < k: print('NO') else: print('YES') for i in range(k - 1): print(q[cut[i]:cut[i + 1]]) ...
def new(): return {} def to_map(raw_metadata): return {tuple(md['breadcrumb']): md['metadata'] for md in raw_metadata} def to_list(compiled_metadata): return [{'breadcrumb': k, 'metadata': v} for k, v in compiled_metadata.items()] def delete(compiled_metadata, breadcrumb, k): del compiled_metadata[br...
def new(): return {} def to_map(raw_metadata): return {tuple(md['breadcrumb']): md['metadata'] for md in raw_metadata} def to_list(compiled_metadata): return [{'breadcrumb': k, 'metadata': v} for (k, v) in compiled_metadata.items()] def delete(compiled_metadata, breadcrumb, k): del compiled_metadata[...
batch_sizes = [4, 16, 128] def get_iterations(starting_size, batch_size, compute_budget): compute_budget_without_starting_size = compute_budget - starting_size iterations_without_start = compute_budget_without_starting_size // batch_size if (iterations_without_start) == 0: raise Exception(f"Compu...
batch_sizes = [4, 16, 128] def get_iterations(starting_size, batch_size, compute_budget): compute_budget_without_starting_size = compute_budget - starting_size iterations_without_start = compute_budget_without_starting_size // batch_size if iterations_without_start == 0: raise exception(f'Compute b...
text = input("Text: ") letters = 0 for letter in text: if letter.isalpha(): letters += 1 # Assign words to 1 if user actually typed a word at the start but not a space words = 1 if (len(text) > 0 and text[0] != ' ') else 0 print(words) print(letters)
text = input('Text: ') letters = 0 for letter in text: if letter.isalpha(): letters += 1 words = 1 if len(text) > 0 and text[0] != ' ' else 0 print(words) print(letters)
class MonteCarlo(object): def __init__(self, board, **kwargs): # Takes an instance of a Board and optionally some keyword # arguments. Initializes the list of game states and the # statistics tables. milliseconds = kwargs.get('calculation_ms', 10) self.calculation_time_ms =...
class Montecarlo(object): def __init__(self, board, **kwargs): milliseconds = kwargs.get('calculation_ms', 10) self.calculation_time_ms = datatime.timedelta(milliseconds=milliseconds) self.max_moves = kwargs.get('max_moves', 10) self.board = board self.states = [] def u...
print("Welcome to Python") print("Welcome to Python") print("Welcome to Python") print("Welcome to Python") print("Welcome to Python")
print('Welcome to Python') print('Welcome to Python') print('Welcome to Python') print('Welcome to Python') print('Welcome to Python')
def test_win10(helpers): caps = {} caps['browserName'] = 'internet explorer' caps['platform'] = 'Windows 10' caps['version'] = '11' driver = helpers.start_driver(caps) helpers.validate_google(driver) def test_late_win7(helpers): caps = {} caps['browserName'] = 'internet explorer' c...
def test_win10(helpers): caps = {} caps['browserName'] = 'internet explorer' caps['platform'] = 'Windows 10' caps['version'] = '11' driver = helpers.start_driver(caps) helpers.validate_google(driver) def test_late_win7(helpers): caps = {} caps['browserName'] = 'internet explorer' ca...
#The provided code stub reads two integers from STDIN, a and b. Add code to print three lines where: #1.The first line contains the sum of the two numbers. #2.The second line contains the difference of the two numbers (first - second). #3.The third line contains the product of the two numbers. #code a=int(raw_input())...
a = int(raw_input()) b = int(raw_input()) print(a + b) print(a - b) print(a * b)
def main(): f = [line.rstrip("\n") for line in open("Data.txt")] map_ = [list(line) for line in f] info = [] for i in range(len(map_)): for j in range(len(map_[0])): if map_[i][j] == "v": info.append([i, j, "down", "left"]) map_[i][j] = "|" ...
def main(): f = [line.rstrip('\n') for line in open('Data.txt')] map_ = [list(line) for line in f] info = [] for i in range(len(map_)): for j in range(len(map_[0])): if map_[i][j] == 'v': info.append([i, j, 'down', 'left']) map_[i][j] = '|' ...
def escape_librtmp(value): if isinstance(value, bool): value = "1" if value else "0" if isinstance(value, int): value = str(value) # librtmp expects some characters to be escaped value = value.replace("\\", "\\5c") value = value.replace(" ", "\\20") value = value.replace('"', "\...
def escape_librtmp(value): if isinstance(value, bool): value = '1' if value else '0' if isinstance(value, int): value = str(value) value = value.replace('\\', '\\5c') value = value.replace(' ', '\\20') value = value.replace('"', '\\22') return value def stream_to_url(stream): ...
coordinates_E0E1E1 = ((125, 114), (126, 93), (126, 114), (126, 130), (126, 132), (127, 92), (127, 93), (127, 104), (127, 114), (127, 115), (127, 130), (128, 91), (128, 92), (128, 102), (128, 104), (128, 114), (128, 117), (128, 119), (128, 131), (128, 132), (129, 91), (129, 101), (129, 114), (129, 119), (129, 131), (1...
coordinates_e0_e1_e1 = ((125, 114), (126, 93), (126, 114), (126, 130), (126, 132), (127, 92), (127, 93), (127, 104), (127, 114), (127, 115), (127, 130), (128, 91), (128, 92), (128, 102), (128, 104), (128, 114), (128, 117), (128, 119), (128, 131), (128, 132), (129, 91), (129, 101), (129, 114), (129, 119), (129, 131), (1...
# Be sure to update these values if you decide to run this bot! APP_NAME = "Boston Snowbot" REPO_URL = "https://github.com/molly/snowbot" # Precipitation probability above which we will add snowfall to prediction PROBABILITY_THRESHOLD = 0 # Get these values from hitting this URL with your latitude and longitude: # h...
app_name = 'Boston Snowbot' repo_url = 'https://github.com/molly/snowbot' probability_threshold = 0 office = 'BOX' grid_x = 70 grid_y = 76 timezone = 'US/Eastern' enable_french_toast = True toast_gif_delay = 24 * 60 * 60 severe_toast_gif = 'https://t.co/Bs8UzBRswG'
# Given two lists of equal sizes, sum all the corresponding index elements and return a new list. # Lis1 = [1,2,3,4,5] List2=[6,7,8,9,0] # new list output = [7, 9, 11,13,5] def sum_index_elements(alist, blist): new_list = [] for a in range(len(alist)): new_list.append(alist[a]+blist[a]) return new_list t...
def sum_index_elements(alist, blist): new_list = [] for a in range(len(alist)): new_list.append(alist[a] + blist[a]) return new_list test_code = sum_index_elements([2, 3, 1, 4, 2], [1, 4, 2, 4, 2]) print(test_code)
class LinearCongruentialGenerator: mul = 1103515245 # a, 0 < a < m inc = 12345 # c, 0 <= c < m mod = 2 ** 31 # m, 0 < m def __init__(self, seed): self.seed_ = seed % self.mod # X[0], 0 <= X[0] < m def rand(self): # X[n + 1] = (a * X[n] + c) mod m self.seed_ = (s...
class Linearcongruentialgenerator: mul = 1103515245 inc = 12345 mod = 2 ** 31 def __init__(self, seed): self.seed_ = seed % self.mod def rand(self): self.seed_ = (self.seed_ * self.mul + self.inc) % self.mod return self.seed_
#Search in a 2D Matrix class Solution(object): def searchMatrix(self, matrix, target): if not len(matrix) or not len(matrix[0]): return False m, n = len(matrix) , len(matrix[0]) #Start adaptive search from left bottom corner x,y = m-1 , 0 ...
class Solution(object): def search_matrix(self, matrix, target): if not len(matrix) or not len(matrix[0]): return False (m, n) = (len(matrix), len(matrix[0])) (x, y) = (m - 1, 0) while True: if x < 0 or y >= n: break current = matr...
alphabet = [ "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", "z", ] direction = input("Type 'encode' to encrypt, type 'decode' to decrypt:...
alphabet = ['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', 'z'] direction = input("Type 'encode' to encrypt, type 'decode' to decrypt:\n") text = input('Type your message:\n').lower() shift = int(input('Type the shift number:\n')) def encryp...
class Solution: def checkInclusion(self, s1: str, s2: str) -> bool: w_size = len(s1) n = len(s2) if n<w_size: return False rem_counts = collections.defaultdict(int) for i in range(w_size): if rem_counts[s1[i]] == -1: ...
class Solution: def check_inclusion(self, s1: str, s2: str) -> bool: w_size = len(s1) n = len(s2) if n < w_size: return False rem_counts = collections.defaultdict(int) for i in range(w_size): if rem_counts[s1[i]] == -1: rem_counts.pop(...
class Product(object): def __init__(self, name, base_price): self.name = name self.base_price = base_price def get_price(self, item_quantities): return item_quantities[self.name] * self.base_price class DiscountedProduct(Product): def __init__(self, name, base_pric...
class Product(object): def __init__(self, name, base_price): self.name = name self.base_price = base_price def get_price(self, item_quantities): return item_quantities[self.name] * self.base_price class Discountedproduct(Product): def __init__(self, name, base_price, offers=()): ...
def lengthN(n, cache): count = 1 while n > 1: if len(cache) >= n: count = count + cache[n-1] break if n % 2: n = 3*n + 1 else: n /= 2 count += 1 cache[int(n)-1] = count return count, cache if __name__ == '__main__': n...
def length_n(n, cache): count = 1 while n > 1: if len(cache) >= n: count = count + cache[n - 1] break if n % 2: n = 3 * n + 1 else: n /= 2 count += 1 cache[int(n) - 1] = count return (count, cache) if __name__ == '__main__':...
class Solution: def permuteUnique(self, nums: List[int]) -> List[List[int]]: results = [] def Combination(permutation, counter): if len(permutation) == len(nums): results.append(list(permutation)) return for num in counter: if ...
class Solution: def permute_unique(self, nums: List[int]) -> List[List[int]]: results = [] def combination(permutation, counter): if len(permutation) == len(nums): results.append(list(permutation)) return for num in counter: i...
#using this for test values for config class TestConfig: host = "irc.rizon.net" port = 6667 nickname = "testNickName8462" username = "testUserName8462" hostname = "testHostName8462" servername = "testServerName8462" realname = "testRealName8462"
class Testconfig: host = 'irc.rizon.net' port = 6667 nickname = 'testNickName8462' username = 'testUserName8462' hostname = 'testHostName8462' servername = 'testServerName8462' realname = 'testRealName8462'
load("@rules_python//python:defs.bzl", "py_test") load("@bazel_skylib//rules:write_file.bzl", "write_file") # End to end "Shell" test that a breakpoint can resolve a location # Consider just allow running a breakpoint without crashing # It does the following # 1. Take the (compiled) application and boot up a sim match...
load('@rules_python//python:defs.bzl', 'py_test') load('@bazel_skylib//rules:write_file.bzl', 'write_file') def ios_lldb_breakpoint_po_test(name, application, set_cmd, variable, sdk, device, expected_value=None, lldbinit=None, **kwargs): test_spec = struct(variable_name=variable, substrs=['variable_result: ' + var...
phonebook = { "John" : 938477566, "Jack" : 938377264, "Jill" : 947662781 } # Add "Jake" to the phonebook with the phone number 938273443, and remove Jill from the phonebook phonebook["Jake"] = 938273443 del phonebook["Jill"] # testing code if "Jake" in phonebook: print("Jake is listed in the phonebook...
phonebook = {'John': 938477566, 'Jack': 938377264, 'Jill': 947662781} phonebook['Jake'] = 938273443 del phonebook['Jill'] if 'Jake' in phonebook: print('Jake is listed in the phonebook.') if 'Jill' not in phonebook: print('Jill is not listed in the phonebook.') for (name, number) in phonebook.items(): print...
#! /usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2019/3/9 2:37 PM # @Author : xiaoliji # @Email : yutian9527@gmail.com class ListNode: def __init__(self, x: int): self.val = x self.next = None def construct_linklist(nodes: 'iterable')-> 'LinkedList': vals = list(nodes) head...
class Listnode: def __init__(self, x: int): self.val = x self.next = None def construct_linklist(nodes: 'iterable') -> 'LinkedList': vals = list(nodes) head = list_node(0) h = head for val in vals: h.next = list_node(val) h = h.next return head.next def pretty_...
class Shape: @staticmethod #define a static method before initiating an instance def add_ally(x,y): x.append(y) return x def __init__(self, shape_type): self.shape_type=shape_type self.__allies=[] #initiate a private empty list in an instance @property def allies_public(self): #make it accessibl...
class Shape: @staticmethod def add_ally(x, y): x.append(y) return x def __init__(self, shape_type): self.shape_type = shape_type self.__allies = [] @property def allies_public(self): return self.__allies def __create_allies(self): return self.a...
def vogal(letra): if(letra=='a') or (letra=='A'): return True if (letra=='e') or (letra=='E'): return True if (letra=='i') or (letra=='I'): return True if (letra=='o') or (letra=='O'): return True if (letra=='u') or (letra=='U'): return True else: ...
def vogal(letra): if letra == 'a' or letra == 'A': return True if letra == 'e' or letra == 'E': return True if letra == 'i' or letra == 'I': return True if letra == 'o' or letra == 'O': return True if letra == 'u' or letra == 'U': return True else: ...
# 24. Swap Nodes in Pairs ''' Given a linked list, swap every two adjacent nodes and return its head. You may not modify the values in the list's nodes, only nodes itself may be changed. Input: 1->2->3->4, Output: 2->1->4->3. ''' class Solution: def swapPairs(self, head: ListNode) -> ListNode: current = h...
""" Given a linked list, swap every two adjacent nodes and return its head. You may not modify the values in the list's nodes, only nodes itself may be changed. Input: 1->2->3->4, Output: 2->1->4->3. """ class Solution: def swap_pairs(self, head: ListNode) -> ListNode: current = head while curren...
def encrypt_letter(msg, key): enc_id = (ord(msg) + ord(key)) % 1114112 return chr(enc_id) def decrypt_letter(msg, key): dec_id = (1114112 + ord(msg) - ord(key)) % 1114112 return chr(dec_id) def process_message(message, key, encrypt): returned_message = "" for i, letter in enumerate(message)...
def encrypt_letter(msg, key): enc_id = (ord(msg) + ord(key)) % 1114112 return chr(enc_id) def decrypt_letter(msg, key): dec_id = (1114112 + ord(msg) - ord(key)) % 1114112 return chr(dec_id) def process_message(message, key, encrypt): returned_message = '' for (i, letter) in enumerate(message):...
def pre_save_operation(instance): # If this is a new record, then someone has started it in the Admin using EITHER a legacy COVE ID # OR a PBSMM UUID. Depending on which, the retrieval endpoint is slightly different, so this sets # the appropriate URL to access. if instance.pk is None: if in...
def pre_save_operation(instance): if instance.pk is None: if instance.object_id and instance.object_id.strip(): url = __get_api_url('pbsmm', instance.object_id) elif instance.legacy_tp_media_id: url = __get_api_url('cove', str(instance.legacy_tp_media_id)) else: ...
t = int(input().strip()) result = 0 current_time, current_value = 1, 3 def get_next_interval_cycle(time, value): next_time = time + value next_value = value * 2 return next_time, next_value while True: new_time, new_value = get_next_interval_cycle( current_time, current_value ...
t = int(input().strip()) result = 0 (current_time, current_value) = (1, 3) def get_next_interval_cycle(time, value): next_time = time + value next_value = value * 2 return (next_time, next_value) while True: (new_time, new_value) = get_next_interval_cycle(current_time, current_value) if new_time > ...
def acmTeam(topic): maxtopic, maxteam = 0, 1 for i in range(n): for j in range(i+1, n): know = 0 for x in range(m): if topic[i][x] == '1' or topic[j][x] == '1': know += 1 if know > maxtopic: maxtopic = know ...
def acm_team(topic): (maxtopic, maxteam) = (0, 1) for i in range(n): for j in range(i + 1, n): know = 0 for x in range(m): if topic[i][x] == '1' or topic[j][x] == '1': know += 1 if know > maxtopic: maxtopic = know ...
def make_readable(seconds): if seconds >= 0 and seconds <= 359999: hrs = seconds // 3600 seconds %= 3600 mins = seconds // 60 seconds %= 60 secs = seconds hour = str('{:02d}'.format(hrs)) minute = str('{:02d}'.format(mins)) second = str('{:02d}'.format...
def make_readable(seconds): if seconds >= 0 and seconds <= 359999: hrs = seconds // 3600 seconds %= 3600 mins = seconds // 60 seconds %= 60 secs = seconds hour = str('{:02d}'.format(hrs)) minute = str('{:02d}'.format(mins)) second = str('{:02d}'.format...
epsilon_d_ = { "epsilon": ["float", "0.03", "0.01 ... 0.3"], } distribution_d_ = { "distribution": ["string", "normal", "normal, laplace, logistic, gumbel"], } n_neighbours_d_ = { "n_neighbours": ["int", "3", "1 ... 10"], } p_accept_d_ = { "p_accept": ["float", "0.1", "0.01 ... 0.3"], } repulsion_factor...
epsilon_d_ = {'epsilon': ['float', '0.03', '0.01 ... 0.3']} distribution_d_ = {'distribution': ['string', 'normal', 'normal, laplace, logistic, gumbel']} n_neighbours_d_ = {'n_neighbours': ['int', '3', '1 ... 10']} p_accept_d_ = {'p_accept': ['float', '0.1', '0.01 ... 0.3']} repulsion_factor_d = {'repulsion_factor': ['...
def fatorial(n): if n == 0: return 1 else: return n * fatorial(n - 1) while True: try: entrada = input() entrada = entrada.split() fat1 = fatorial(int(entrada[0])) fat2 = fatorial(int(entrada[1])) print(fat1 + fat2) except EOFErro...
def fatorial(n): if n == 0: return 1 else: return n * fatorial(n - 1) while True: try: entrada = input() entrada = entrada.split() fat1 = fatorial(int(entrada[0])) fat2 = fatorial(int(entrada[1])) print(fat1 + fat2) except EOFError: break
class TrieNode: def __init__(self): self.children = [None] * 26 self.end = False self.size = 0 class Trie: def __init__(self): self.root = self.getNode() def getNode(self): return TrieNode() def _charToIndex(self, ch): retu...
class Trienode: def __init__(self): self.children = [None] * 26 self.end = False self.size = 0 class Trie: def __init__(self): self.root = self.getNode() def get_node(self): return trie_node() def _char_to_index(self, ch): return ord(ch) - ord('a') ...
class Database: def __init__(self, row_counts): self.row_counts = row_counts self.max_row_count = max(row_counts) n_tables = len(row_counts) self.parents = list(range(n_tables)) def merge(self, src, dst): src_parent = self.get_parent(src) dst_parent = self.get_pa...
class Database: def __init__(self, row_counts): self.row_counts = row_counts self.max_row_count = max(row_counts) n_tables = len(row_counts) self.parents = list(range(n_tables)) def merge(self, src, dst): src_parent = self.get_parent(src) dst_parent = self.get_p...
# Find the Most Competitive Subsequence: https://leetcode.com/problems/find-the-most-competitive-subsequence/ # Given an integer array nums and a positive integer k, return the most competitive subsequence of nums of size k. # An array's subsequence is a resulting sequence obtained by erasing some (possibly zero) elem...
class Solution: def most_competitive(self, nums, k: int): stack = [] addition = len(nums) - k for num in nums: while addition > 0 and len(stack) > 0 and (stack[-1] > num): stack.pop() addition -= 1 stack.append(num) while len(s...
# Template 1. preorder DFS # O(N) / O(H) class Solution: def preorderTraversal(self, root: TreeNode) -> List[int]: arr = [] def preorder(node): if not node: return arr.append(node.val) preorder(node.left) preorder(node.right) pr...
class Solution: def preorder_traversal(self, root: TreeNode) -> List[int]: arr = [] def preorder(node): if not node: return arr.append(node.val) preorder(node.left) preorder(node.right) preorder(root) return arr class...
with open('artistsfollowed.txt') as af: with open('/app/tosearch.txt', 'w') as ts: for line in af: if 'name' in line: line = line.strip() line = line.replace('name: ', '') line = line.replace('\'', '') line = line.replace(',', '') ...
with open('artistsfollowed.txt') as af: with open('/app/tosearch.txt', 'w') as ts: for line in af: if 'name' in line: line = line.strip() line = line.replace('name: ', '') line = line.replace("'", '') line = line.replace(',', '') ...
'''a Python program to print out a set containing all the colors from color_list_1 which are not present in color_list_2''' def main(): color_list_1 = set(["White", "Black", "Red"]) color_list_2 = set(["Red", "Green"]) print("Original set elements:") print(color_list_1) print(color_list_2) pr...
"""a Python program to print out a set containing all the colors from color_list_1 which are not present in color_list_2""" def main(): color_list_1 = set(['White', 'Black', 'Red']) color_list_2 = set(['Red', 'Green']) print('Original set elements:') print(color_list_1) print(color_list_2) pri...
input = [ ('Mamma Mia', ['ABBA']), ('Ghost Rule', ['DECO*27', 'Hatsune Miku']), ('Animals', ['Martin Garrix']), ('Remember The Name', ['Ed Sheeran', 'Eminem', '50 Cent']), ('404 Not Found', []) ] def songTitle(song): artists = '' if len(song[1]) > 1: for artist in range(len(song[1]...
input = [('Mamma Mia', ['ABBA']), ('Ghost Rule', ['DECO*27', 'Hatsune Miku']), ('Animals', ['Martin Garrix']), ('Remember The Name', ['Ed Sheeran', 'Eminem', '50 Cent']), ('404 Not Found', [])] def song_title(song): artists = '' if len(song[1]) > 1: for artist in range(len(song[1])): artist...
class FluidAudioDriver(): ''' Represents the FluidSynth audio driver object as defined in audio.h. This class is inspired by the FluidAudioDriver object from pyfluidsynth by MostAwesomeDude. Member: audio_driver -- The FluidSynth audio driver object (fluid_audio_driver_t). handle -- The handle...
class Fluidaudiodriver: """ Represents the FluidSynth audio driver object as defined in audio.h. This class is inspired by the FluidAudioDriver object from pyfluidsynth by MostAwesomeDude. Member: audio_driver -- The FluidSynth audio driver object (fluid_audio_driver_t). handle -- The handle t...
class Writer: def __init__(self, outfile): self.outfile = outfile def writeHeader(self): pass def write(self, record): pass def writeFooter(self): pass
class Writer: def __init__(self, outfile): self.outfile = outfile def write_header(self): pass def write(self, record): pass def write_footer(self): pass
a='cdef' b='ab' print('a'/'b') a=8 b='ab' print('a'/'b')
a = 'cdef' b = 'ab' print('a' / 'b') a = 8 b = 'ab' print('a' / 'b')
## GroupID-8 (14114002_14114068) - Abhishek Jaisingh & Tarun Kumar ## Date: April 15, 2016 ## bitwise_manipulations.py - Bitwise Manipulation Functions for Travelling Salesman Problem def size(int_type): length = 0 count = 0 while (int_type): count += (int_type & 1) length += 1 int_type >...
def size(int_type): length = 0 count = 0 while int_type: count += int_type & 1 length += 1 int_type >>= 1 return count def length(int_type): length = 0 count = 0 while int_type: count += int_type & 1 length += 1 int_type >>= 1 return lengt...
print("To change the data type of data") int_data=int(input("Enter the integer data:")) dec_data=float(input("Enter the decimal data:")) int_str=str(int_data) print(int_str) dec_int=int(dec_data) print(dec_int) dec_str=str(dec_data)
print('To change the data type of data') int_data = int(input('Enter the integer data:')) dec_data = float(input('Enter the decimal data:')) int_str = str(int_data) print(int_str) dec_int = int(dec_data) print(dec_int) dec_str = str(dec_data)
@dataclass class Point: x: int y: int z: int position = property() @position.setter def position(self, new_value): if type(new_value) not in (list, tuple, set): raise TypeError elif len(new_value) != 3: raise ValueError else: self.x, ...
@dataclass class Point: x: int y: int z: int position = property() @position.setter def position(self, new_value): if type(new_value) not in (list, tuple, set): raise TypeError elif len(new_value) != 3: raise ValueError else: (self.x, ...
def get_sql_lite_conn_str(db_file: str): db_file_stripped = db_file.strip() if not db_file or not db_file_stripped: # db_file = '../db/meet_app.db' raise Exception("SQL lite DB file is not specified.") return 'sqlite:///' + db_file_stripped
def get_sql_lite_conn_str(db_file: str): db_file_stripped = db_file.strip() if not db_file or not db_file_stripped: raise exception('SQL lite DB file is not specified.') return 'sqlite:///' + db_file_stripped
# definitions used # constants DE = 'DE' # variables qhLen = None # number of rows of the quarter of an hour output vector (4 each hour) header = None zones = None dataImport = None dataExport = None sumImport = None sumExport = None data = None # output file names output_file_name = 'GenerationAndLoad.csv' # c...
de = 'DE' qh_len = None header = None zones = None data_import = None data_export = None sum_import = None sum_export = None data = None output_file_name = 'GenerationAndLoad.csv' countries_dict = {'AT': ['DE'], 'BE': ['FR', 'NL'], 'FR': ['BE', 'DE'], 'DE': ['AT', 'FR', 'NL'], 'NL': ['BE', 'DE']} psrtype_mappings = {'A...
class StructureObject: def __init__(self, name="", dir=""): self.name = name self.dir = dir def getName(self): return self.name def getDir(self): return self.dir def getType(self): return type(self)
class Structureobject: def __init__(self, name='', dir=''): self.name = name self.dir = dir def get_name(self): return self.name def get_dir(self): return self.dir def get_type(self): return type(self)
def dbl_linear(n): u = [1] def func(nums): global fin new_nums = [] for i in nums: new_nums.append(2 * i + 1) new_nums.append(3 * i + 1) u.extend(new_nums) if len(u) > n*12: fin = list(sorted(set(u))) else: ...
def dbl_linear(n): u = [1] def func(nums): global fin new_nums = [] for i in nums: new_nums.append(2 * i + 1) new_nums.append(3 * i + 1) u.extend(new_nums) if len(u) > n * 12: fin = list(sorted(set(u))) else: func(n...
def write(filename, content): with open(filename, 'w') as file_object: file_object.write(content) def appendWrite(filename, content): with open(filename, 'a') as file_object: file_object.write(content)
def write(filename, content): with open(filename, 'w') as file_object: file_object.write(content) def append_write(filename, content): with open(filename, 'a') as file_object: file_object.write(content)
# Copyright (c) 2021 Qianyun, Inc. All rights reserved. # smartx SMARTX_INSTANCE_STATE_STOPPED = 'stopped'
smartx_instance_state_stopped = 'stopped'
for i in range (6): for j in range (7): if (i==0 and j %3!=0) or (i==1 and j % 3==0) or (i-j==2) or (i+j==8): print("*",end=" ") else: print(end=" ") print()
for i in range(6): for j in range(7): if i == 0 and j % 3 != 0 or (i == 1 and j % 3 == 0) or i - j == 2 or (i + j == 8): print('*', end=' ') else: print(end=' ') print()
A, B, K = map(int, input().split()) if A >= K: A -= K print(A, B) else: A, B = 0, max(0, B - (K - A)) print(A, B)
(a, b, k) = map(int, input().split()) if A >= K: a -= K print(A, B) else: (a, b) = (0, max(0, B - (K - A))) print(A, B)
class Solution: def plusOne(self, digits: List[int]) -> List[int]: carry = 0 for i in range(len(digits) - 1, -1, -1): if i == len(digits) - 1: digits[i] += 1 else: digits[i] = digits[i] + carry if digits[i] == 10: di...
class Solution: def plus_one(self, digits: List[int]) -> List[int]: carry = 0 for i in range(len(digits) - 1, -1, -1): if i == len(digits) - 1: digits[i] += 1 else: digits[i] = digits[i] + carry if digits[i] == 10: ...
#!/usr/bin/env python3 charlimit = 450 def isChan(chan, checkprefix): if not chan: return False elif chan.startswith("#"): return True elif checkprefix and len(chan) >= 2 and not chan[0].isalnum() and chan[1] == "#": return True else: return False
charlimit = 450 def is_chan(chan, checkprefix): if not chan: return False elif chan.startswith('#'): return True elif checkprefix and len(chan) >= 2 and (not chan[0].isalnum()) and (chan[1] == '#'): return True else: return False
__title__ = 'MongoFlask' __description__ = 'A Python Flask library for connecting a MongoDB instance to a Flask application' __url__ = 'https://github.com/juanmanuel96/mongo-flask' __version_info__ = ('0', '1', '3') __version__ = '.'.join(__version_info__) __author__ = 'Juan Vazquez' __py_version__ = 3
__title__ = 'MongoFlask' __description__ = 'A Python Flask library for connecting a MongoDB instance to a Flask application' __url__ = 'https://github.com/juanmanuel96/mongo-flask' __version_info__ = ('0', '1', '3') __version__ = '.'.join(__version_info__) __author__ = 'Juan Vazquez' __py_version__ = 3