content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
class Solution: def findTheCity(self, n: int, edges: List[List[int]], distanceThreshold: int) -> int: """ 4 [[0,1,3],[1,2,1],[1,3,4],[2,3,1]] 4 5 [[0,1,2],[0,4,8],[1,2,3],[1,4,2],[2,3,1],[3,4,1]] 2 5 [[0,1,2],[0,4,8],[1,2,3],[1,4,2],[2,3,4],[3,...
class Solution: def find_the_city(self, n: int, edges: List[List[int]], distanceThreshold: int) -> int: """ 4 [[0,1,3],[1,2,1],[1,3,4],[2,3,1]] 4 5 [[0,1,2],[0,4,8],[1,2,3],[1,4,2],[2,3,1],[3,4,1]] 2 5 [[0,1,2],[0,4,8],[1,2,3],[1,4,2],[2,3,4],...
def spec(packet, config, transmitted_packet): if packet.device == config['wan device']: assert transmitted_packet.device == config['lan device'] else: assert transmitted_packet.device == config['wan device'] # assert transmitted_packet.data[:96] == packet.data[:96] # ignore MACs for now
def spec(packet, config, transmitted_packet): if packet.device == config['wan device']: assert transmitted_packet.device == config['lan device'] else: assert transmitted_packet.device == config['wan device']
class HashTable: def __init__(self, sz, stp): self.size = sz self.step = stp self.slots = [None] * self.size def hash_fun(self, value): result = 0 for pos in range(len(value)): sym = value[pos] result += ord(sym) * pos return result % self...
class Hashtable: def __init__(self, sz, stp): self.size = sz self.step = stp self.slots = [None] * self.size def hash_fun(self, value): result = 0 for pos in range(len(value)): sym = value[pos] result += ord(sym) * pos return result % sel...
n=int(input()) for i in range(n): s,k=input().split() k=int(k) s=s.replace('-','1').replace('+','0') s=int(s,2) ans=0 x=int('1'*k,2) while s: ss=len(bin(s))-2 if ss-k < 0: ans="IMPOSSIBLE" break s^=x<<(ss-k) ans+=1 print("Case #%d: %s"%(i+1,str(ans)))
n = int(input()) for i in range(n): (s, k) = input().split() k = int(k) s = s.replace('-', '1').replace('+', '0') s = int(s, 2) ans = 0 x = int('1' * k, 2) while s: ss = len(bin(s)) - 2 if ss - k < 0: ans = 'IMPOSSIBLE' break s ^= x << ss - k ...
# Python - 3.6.0 Test.describe('Basic Tests') Test.assert_equals(twice_as_old(36, 7), 22) Test.assert_equals(twice_as_old(55, 30), 5) Test.assert_equals(twice_as_old(42, 21), 0) Test.assert_equals(twice_as_old(22, 1), 20) Test.assert_equals(twice_as_old(29 ,0), 29)
Test.describe('Basic Tests') Test.assert_equals(twice_as_old(36, 7), 22) Test.assert_equals(twice_as_old(55, 30), 5) Test.assert_equals(twice_as_old(42, 21), 0) Test.assert_equals(twice_as_old(22, 1), 20) Test.assert_equals(twice_as_old(29, 0), 29)
x = [1, 2, 3] # Create the first list y = [4, 5, 6] # Create the second list t = (x, y) # Create the tuple from the lists print(t) # Print the tuple print(type(t)) # Display the type 'tuple' print(t[0]) # Display the first list print(t[0][1]) # Display the second element of the first list a, b = t # Assi...
x = [1, 2, 3] y = [4, 5, 6] t = (x, y) print(t) print(type(t)) print(t[0]) print(t[0][1]) (a, b) = t print(a) print(b) a[0] = 'sorry' print(a) print(x) c = ('Hello!',) print(type(c))
#!/usr/bin/env python3 #this progam will write Hello World! print("Hello World!")
print('Hello World!')
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def isValidBST(self, root: TreeNode) -> bool: nodes = [] self._isValidBST(root, nodes) ...
class Solution: def is_valid_bst(self, root: TreeNode) -> bool: nodes = [] self._isValidBST(root, nodes) return sorted(nodes) == nodes and len(nodes) == len(set(nodes)) def _is_valid_bst(self, root, nodes): if root: self._isValidBST(root.left, nodes) nod...
class Indexer: """An indexer class.""" def __init__(self, candidates, index=0): """Constructor. Args: candidates (Sequence): A candidates. """ self.candidates = candidates self.index = index @property def index(self): """int: A current index....
class Indexer: """An indexer class.""" def __init__(self, candidates, index=0): """Constructor. Args: candidates (Sequence): A candidates. """ self.candidates = candidates self.index = index @property def index(self): """int: A current index...
# Write a Python program to remove the first item from a specified list. color = ["Red", "Black", "Green", "White", "Orange"] print("Original Color: ", color) del color[0] print("After removing the first color: ", color) print()
color = ['Red', 'Black', 'Green', 'White', 'Orange'] print('Original Color: ', color) del color[0] print('After removing the first color: ', color) print()
# # PySNMP MIB module CISCO-LWAPP-DOT11-CLIENT-CCX-REPORTS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-LWAPP-DOT11-CLIENT-CCX-REPORTS-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:05:14 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davw...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, single_value_constraint, value_size_constraint, value_range_constraint, constraints_intersection) ...
# -*- coding: utf-8 -*- __author__ = 'willmcginnis' class SQLContext(object): def __init__(self, parkContext, sqlContext=None): pass @property def _ssql_ctx(self): """ NotImplemented :return: """ raise NotImplementedError def setConf(self, key, value...
__author__ = 'willmcginnis' class Sqlcontext(object): def __init__(self, parkContext, sqlContext=None): pass @property def _ssql_ctx(self): """ NotImplemented :return: """ raise NotImplementedError def set_conf(self, key, value): """ N...
def neighbor(neighbor_list,peer_state, **kwargs): if peer_state in neighbor_list: return 1 else: return 0
def neighbor(neighbor_list, peer_state, **kwargs): if peer_state in neighbor_list: return 1 else: return 0
"""https://open.kattis.com/problems/missingnumbers""" n = int(input()) nums = [] for _ in range(n): nums.append(int(input())) if len(nums) == nums[-1]: print("good job") else: for i in range(1, nums[-1] + 1): if i not in nums: print(i)
"""https://open.kattis.com/problems/missingnumbers""" n = int(input()) nums = [] for _ in range(n): nums.append(int(input())) if len(nums) == nums[-1]: print('good job') else: for i in range(1, nums[-1] + 1): if i not in nums: print(i)
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def findTilt(self, root: TreeNode) -> int: if root is None: return 0 # post order tree walk traversal ...
class Solution: def find_tilt(self, root: TreeNode) -> int: if root is None: return 0 sum = 0 def post_order_traver(node): nonlocal sum if node.left is None and node.right is None: return node.val left_sum = 0 if node.left is ...
# Tree Node class Node: def __init__(self, val): self.right = None self.data = val self.left = None class Solution: # The given root is the root of the Binary Tree # Return the root of the generated BST def binaryTreeToBST_Util(self, root): if root is None: ...
class Node: def __init__(self, val): self.right = None self.data = val self.left = None class Solution: def binary_tree_to_bst__util(self, root): if root is None: return self.binaryTreeToBST_Util(root.left) self.values.append(root.data) self...
#Defining function for Linear Search def Linear_Search(input_list, key): flag = 0 #Iterating each item in the list and comparing it with the key searching for for i in range(len(input_list)): if(input_list[i] == key): #If key matches with any of the list items flag = 1 ...
def linear__search(input_list, key): flag = 0 for i in range(len(input_list)): if input_list[i] == key: flag = 1 print('\nKey is found in the position: {}'.format(i)) if flag == 0: print('\nKey not found') input_list = [11, 12, 13, 14, 15, 16, 17, 18, 19] print('List ...
class Token(): def __init__(self, classe, lexema, tipo): self.classe = classe self.lexema = lexema self.tipo = tipo def __repr__(self) -> str: return 'classe: ' + self.classe + ', lexema: ' + self.lexema + ', tipo: ' + self.tipo
class Token: def __init__(self, classe, lexema, tipo): self.classe = classe self.lexema = lexema self.tipo = tipo def __repr__(self) -> str: return 'classe: ' + self.classe + ', lexema: ' + self.lexema + ', tipo: ' + self.tipo
def program(): intProgram = [ 1,12,2,3,1,1,2,3,1,3, 4,3,1,5,0,3,2,1,10,19, 1,6,19,23,1,10,23,27,2,27, 13,31,1,31,6,35,2,6,35,39, 1,39,5,43,1,6,43,47,2,6, 47,51,1,51,5,55,2,55,9,59, 1,6,59,63,1,9,63,67,1,67, 10,71,2,9,71,75,1,6,75,79, 1,5,79,83,2,83,10,87,1,87, 5,91,1,91,9,95,1,6,95,99, ...
def program(): int_program = [1, 12, 2, 3, 1, 1, 2, 3, 1, 3, 4, 3, 1, 5, 0, 3, 2, 1, 10, 19, 1, 6, 19, 23, 1, 10, 23, 27, 2, 27, 13, 31, 1, 31, 6, 35, 2, 6, 35, 39, 1, 39, 5, 43, 1, 6, 43, 47, 2, 6, 47, 51, 1, 51, 5, 55, 2, 55, 9, 59, 1, 6, 59, 63, 1, 9, 63, 67, 1, 67, 10, 71, 2, 9, 71, 75, 1, 6, 75, 79, 1, 5, 79, ...
class Solution: def minSubArrayLen(self, s: int, nums: List[int]) -> int: ans = float('inf') left = 0 sum_ = 0 for right, num in enumerate(nums): sum_ += num while left <= right and sum_ >= s: ans = min(ans, right - left + 1) ...
class Solution: def min_sub_array_len(self, s: int, nums: List[int]) -> int: ans = float('inf') left = 0 sum_ = 0 for (right, num) in enumerate(nums): sum_ += num while left <= right and sum_ >= s: ans = min(ans, right - left + 1) ...
class Solution: def res(self, a, b): count = 0 for i in range(1, len(a)): if a[i] != a[0] and b[i] != a[0]: return -1 elif a[i] != a[0]: a[i] = b[i] count += 1 return count def minDominoRotations(self, A: list, B: ...
class Solution: def res(self, a, b): count = 0 for i in range(1, len(a)): if a[i] != a[0] and b[i] != a[0]: return -1 elif a[i] != a[0]: a[i] = b[i] count += 1 return count def min_domino_rotations(self, A: list, B...
class DatastoreRouter(object): def db_for_read(self, model, **hints): """ Reads go to a randomly-chosen replica. """ return 'datastore' def db_for_write(self, model, **hints): """ Writes always go to primary. """ return 'primary'
class Datastorerouter(object): def db_for_read(self, model, **hints): """ Reads go to a randomly-chosen replica. """ return 'datastore' def db_for_write(self, model, **hints): """ Writes always go to primary. """ return 'primary'
# STP2019 - FALL # Observable class Publisher(object): subscribers = set() def register(self, user): self.subscribers.add(user) def unregister(self, user): self.subscribers.discard(user) def send_notifications(self, message): for user in self.subscribers: user.up...
class Publisher(object): subscribers = set() def register(self, user): self.subscribers.add(user) def unregister(self, user): self.subscribers.discard(user) def send_notifications(self, message): for user in self.subscribers: user.update(message) class Subscriber(...
""" __init__ for package code """ # pylint: disable=invalid-name name = 'lazynumpy' # pylint: enable=invalid-name
""" __init__ for package code """ name = 'lazynumpy'
def lee_entero(): while True: entrada = raw_input("Escribe un numero entero: ") try: entrada = int(entrada) return entrada except ValueError: print ("La entrada es incorrecta: escribe un numero entero")
def lee_entero(): while True: entrada = raw_input('Escribe un numero entero: ') try: entrada = int(entrada) return entrada except ValueError: print('La entrada es incorrecta: escribe un numero entero')
''' The __init__.py file makes Python treat directories containing it as modules. Furthermore, this is the first file to be loaded in a module, so you can use it to execute code that you want to run each time a module is loaded, or specify the submodules to be exported. '''
""" The __init__.py file makes Python treat directories containing it as modules. Furthermore, this is the first file to be loaded in a module, so you can use it to execute code that you want to run each time a module is loaded, or specify the submodules to be exported. """
class Exponentiation: @staticmethod def exponentiation(base, exponent): return base ** exponent
class Exponentiation: @staticmethod def exponentiation(base, exponent): return base ** exponent
class Board: def __init__(self, id) -> None: self.id = id self.parts = [] #note will be array of arrays [part object, qty used per board] self.flag = False #True if stock issue def AddPart(self, part, qty): self.parts.append([part, qty]) def IsMatch(self, testid)...
class Board: def __init__(self, id) -> None: self.id = id self.parts = [] self.flag = False def add_part(self, part, qty): self.parts.append([part, qty]) def is_match(self, testid): if self.id == testid: return True else: return Fals...
# hw01_05 print('3 + 4 =', end=' ') print(3 + 4) ''' 3 + 4 = 7 '''
print('3 + 4 =', end=' ') print(3 + 4) '\n\n3 + 4 = 7\n\n'
def list_to_list_two_tuples(values: list): """ Convert a list of values to a list of tuples with for each value twice that same value e.g. [1,2,3] ==> [(1,1),(2,2),(3,3)] Parameters ---------- values : list list of values to convert into tuples Returns ------- list ...
def list_to_list_two_tuples(values: list): """ Convert a list of values to a list of tuples with for each value twice that same value e.g. [1,2,3] ==> [(1,1),(2,2),(3,3)] Parameters ---------- values : list list of values to convert into tuples Returns ------- list ...
f = open('text1.txt') v = open('text2.txt') list1 = [] list2 = [] result = [] for line in f: list1.append(line) for line in v: list2.append(line) for i in range(len(list1)): if list1[i] != list2[i]: a = str(list1[i]) + '!=' + str(list2[i]) result.append(a) print(result)
f = open('text1.txt') v = open('text2.txt') list1 = [] list2 = [] result = [] for line in f: list1.append(line) for line in v: list2.append(line) for i in range(len(list1)): if list1[i] != list2[i]: a = str(list1[i]) + '!=' + str(list2[i]) result.append(a) print(result)
a = input("digite um numero em binario: ") for n in (len(a)): if n==1: x=1 b=x*len(a) print(b)
a = input('digite um numero em binario: ') for n in len(a): if n == 1: x = 1 b = x * len(a) print(b)
def find(arr,n,x): start=0 end=n-1 result=-1 res=-1 mid=start+(end-start)//2 while start<end: if arr[mid]==x: result=mid end=mid-1 elif arr[mid]>x: end=mid-1 else: start=mid+1 while start<end: if arr[mi...
def find(arr, n, x): start = 0 end = n - 1 result = -1 res = -1 mid = start + (end - start) // 2 while start < end: if arr[mid] == x: result = mid end = mid - 1 elif arr[mid] > x: end = mid - 1 else: start = mid + 1 whil...
"""Trivial test module for verifying that unit tests are running as expected.""" def test_health(): """ This health check test should pass no matter what. """ assert True
"""Trivial test module for verifying that unit tests are running as expected.""" def test_health(): """ This health check test should pass no matter what. """ assert True
class Solution: def minCostClimbingStairs(self, cost: List[int]) -> int: min_cost = { 0: 0, 1: 0, } n = len(cost) for i in range(2, n+1): min_cost[i] = min(min_cost[i-1] + cost[i-1], min_cost[i-2] + cost[i-2]) return min_cost[n]
class Solution: def min_cost_climbing_stairs(self, cost: List[int]) -> int: min_cost = {0: 0, 1: 0} n = len(cost) for i in range(2, n + 1): min_cost[i] = min(min_cost[i - 1] + cost[i - 1], min_cost[i - 2] + cost[i - 2]) return min_cost[n]
""" Basic Login Search - SOLUTION """ users = { 'person@email.com': 'PassWord', 'someone@email.com': 'p@$$w0rd', 'me@email.com': 'myPassword', 'anyone@email.com': 'p@ssw0rd', 'guy@email.com': 'pa$$word' # etc } # A user enters the below login info (email and password) for your app. Search your database of user ...
""" Basic Login Search - SOLUTION """ users = {'person@email.com': 'PassWord', 'someone@email.com': 'p@$$w0rd', 'me@email.com': 'myPassword', 'anyone@email.com': 'p@ssw0rd', 'guy@email.com': 'pa$$word'} current_user = {'me@email.com': 'myPassword'} name = list(current_user.keys()) name = name[0] pw = list(current_user....
CONFIG = { 'api_key': 'to be filled out', 'api_key_secret': 'to be filled out', 'access_token': 'to be filled out', 'access_token_secret': 'to be filled out', 'images_base_folder': 'to be filled out', 'images_backlog_folder': 'to be filled out', 'telegram_token': 'to be filled out', '...
config = {'api_key': 'to be filled out', 'api_key_secret': 'to be filled out', 'access_token': 'to be filled out', 'access_token_secret': 'to be filled out', 'images_base_folder': 'to be filled out', 'images_backlog_folder': 'to be filled out', 'telegram_token': 'to be filled out', 'admin_chat_id': 0, 'user_chat_id': 0...
""" TODO: first insert analytical greeks in bs.py & then 1. write TEST for Black prices and implieds PUT f = 101.0 x = 102.0 t = .5 r = .01 sigma_price = 0.2 price = black(-1, f, x, t, r=0, sigma_price) expected_price = 6.20451158097 from expected price get implied of...
""" TODO: first insert analytical greeks in bs.py & then 1. write TEST for Black prices and implieds PUT f = 101.0 x = 102.0 t = .5 r = .01 sigma_price = 0.2 price = black(-1, f, x, t, r=0, sigma_price) expected_price = 6.20451158097 from expected price get implied of...
def final_multipy(num: int) -> int: if num < 10: return num n = 1 for i in str(num): n *= int(i) return final_multipy(n) def final_multipy2(num: int) -> int: return num if num < 10 else final_multipy2(reduce(lambda x, y: x*y, [int(i) for i in str(num)]))
def final_multipy(num: int) -> int: if num < 10: return num n = 1 for i in str(num): n *= int(i) return final_multipy(n) def final_multipy2(num: int) -> int: return num if num < 10 else final_multipy2(reduce(lambda x, y: x * y, [int(i) for i in str(num)]))
# Copyright (c) Project Jupyter. # Distributed under the terms of the Modified BSD License. version_info = (0, 9, 0) __version__ = ".".join(map(str, version_info))
version_info = (0, 9, 0) __version__ = '.'.join(map(str, version_info))
# ========================= SymbolTable CLASS class SymbolTable(object): """ Symbol table for the CompilationEngine of the Jack compiler. """ def __init__(self): self._file_name = '' self._class_table = {} self._subroutine_table = {} self._static_count = 0 self._...
class Symboltable(object): """ Symbol table for the CompilationEngine of the Jack compiler. """ def __init__(self): self._file_name = '' self._class_table = {} self._subroutine_table = {} self._static_count = 0 self._field_count = 0 self._arg_count = 0 ...
def incorrectPasscodeAttempts(passcode, attempts): cnt = 0 for att in attempts: if att == passcode: cnt = 0 else: cnt += 1 if cnt >= 10: return True return False
def incorrect_passcode_attempts(passcode, attempts): cnt = 0 for att in attempts: if att == passcode: cnt = 0 else: cnt += 1 if cnt >= 10: return True return False
options = [ "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "CNY", "HKD", "NZD", "SEK", "KRW", "SGD", "NOK", "MXN", "INR", "RUB", "ZAR", "TRY", "BRL", ] opt2=[ "USD", "EUR", "JPY", "GBP", "A...
options = ['USD', 'EUR', 'JPY', 'GBP', 'AUD', 'CAD', 'CHF', 'CNY', 'HKD', 'NZD', 'SEK', 'KRW', 'SGD', 'NOK', 'MXN', 'INR', 'RUB', 'ZAR', 'TRY', 'BRL'] opt2 = ['USD', 'EUR', 'JPY', 'GBP', 'AUD', 'CAD', 'CHF', 'CNY', 'HKD', 'NZD', 'SEK', 'KRW', 'SGD', 'NOK', 'MXN', 'INR', 'RUB', 'ZAR', 'TRY', 'BRL']
#!/usr/bin/env python3 """ help.py This is a file to pull the help for all programs in bin. Each script must be added individually, some scripts use argparse, so -h is called, others do not, and so their __doc__ is printed. Based on spHelp written by Elena. 2020-06-08 DG Init, based on spHelp 2020-08-17 DG Adde...
""" help.py This is a file to pull the help for all programs in bin. Each script must be added individually, some scripts use argparse, so -h is called, others do not, and so their __doc__ is printed. Based on spHelp written by Elena. 2020-06-08 DG Init, based on spHelp 2020-08-17 DG Added XMID and WAVEMID 2020...
# noinspection PyShadowingBuiltins,PyUnusedLocal def compute(x, y): if all(0 <= n <= 100 for n in (x, y)): return x + y else: raise ValueError('Please provide two integer numbers')
def compute(x, y): if all((0 <= n <= 100 for n in (x, y))): return x + y else: raise value_error('Please provide two integer numbers')
# # PySNMP MIB module IPFIX-EXPORTER-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/IPFIX-EXPORTER-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:55:56 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, ...
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, constraints_intersection, value_range_constraint, value_size_constraint, single_value_constraint) ...
# Advent of Code 2020, Day 6 with open("../input06", "r") as infile: lines = infile.readlines() # check if a line is blank def blank(l): b = True for c in l: b = b and (c == ' ' or c == '\n') return b group = [] groups = [] for l in lines: if blank(l): groups.append(group) group = [] else: ...
with open('../input06', 'r') as infile: lines = infile.readlines() def blank(l): b = True for c in l: b = b and (c == ' ' or c == '\n') return b group = [] groups = [] for l in lines: if blank(l): groups.append(group) group = [] else: group.append(l[:-1]) groups....
class Products: def __init__(self, product_name, displayed_price, product_number): self.product_name = product_name self.displayed_price = displayed_price self.product_number = product_number
class Products: def __init__(self, product_name, displayed_price, product_number): self.product_name = product_name self.displayed_price = displayed_price self.product_number = product_number
def for_underscore(): for row in range(4): for col in range(6): if row==3 and col>0 and col<5 : print("*",end=" ") else: print(" ",end=" ") print() def while_underscore(): row=0 while row<4: col=0 while col<6...
def for_underscore(): for row in range(4): for col in range(6): if row == 3 and col > 0 and (col < 5): print('*', end=' ') else: print(' ', end=' ') print() def while_underscore(): row = 0 while row < 4: col = 0 while c...
""" __version__.py ~~~~~~~~~~~~~~ Metadata of the Module. """ __all__ = [ "__title__", "__description__", "__url__", "__version__", "__author__", "__license__", "__copyright__", ] __title__ = "sxcu" __description__ = "Python API wraper for sxcu.net" __url__ = "https://sxcu.syr...
""" __version__.py ~~~~~~~~~~~~~~ Metadata of the Module. """ __all__ = ['__title__', '__description__', '__url__', '__version__', '__author__', '__license__', '__copyright__'] __title__ = 'sxcu' __description__ = 'Python API wraper for sxcu.net' __url__ = 'https://sxcu.syrusdark.website' __version__ = '...
def asTemplate(f): def wrapped(*args, **props): def execute(): return f(*args, **props) return execute return wrapped def renderProps(**props): result = [f' {key}="{value}"' if isinstance(value, str) else f' {key}={str(value)}' for key, value in props.items()] retur...
def as_template(f): def wrapped(*args, **props): def execute(): return f(*args, **props) return execute return wrapped def render_props(**props): result = [f' {key}="{value}"' if isinstance(value, str) else f' {key}={str(value)}' for (key, value) in props.items()] return '...
def render_template(gadget): RN = "\r\n" p = Payload() p.header = "__METHOD__ __ENDPOINT__?cb=__RANDOM__ HTTP/__HTTP_VERSION__" + RN p.header += gadget + RN p.header += "Host: __HOST__" + RN p.header += "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/...
def render_template(gadget): rn = '\r\n' p = payload() p.header = '__METHOD__ __ENDPOINT__?cb=__RANDOM__ HTTP/__HTTP_VERSION__' + RN p.header += gadget + RN p.header += 'Host: __HOST__' + RN p.header += 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)...
class VmCustomParamsExtractor(object): def get_custom_param_value(self, custom_params, name): """Returns the value of the requested custom param :param custom_params: list[DeployDataHolder] array of VMCustomParams from the deployed app json :param name: (str) the name of the custom param t...
class Vmcustomparamsextractor(object): def get_custom_param_value(self, custom_params, name): """Returns the value of the requested custom param :param custom_params: list[DeployDataHolder] array of VMCustomParams from the deployed app json :param name: (str) the name of the custom param t...
# Count inversions in a sequence of numbers def count_inversion(sequence): if (len(sequence) < 1 or len(sequence) > 199): return "Error1" for element in sequence: if (element < -99 or element > 199): return "Error2" sequencel = list(sequence); count = 0; ...
def count_inversion(sequence): if len(sequence) < 1 or len(sequence) > 199: return 'Error1' for element in sequence: if element < -99 or element > 199: return 'Error2' sequencel = list(sequence) count = 0 fake = 0 for i in reversed(range(len(sequencel))): for ...
def grade(a): if a >= 90: print("A") else: if a >= 85: print("B+") else: if a >= 80: print("B") else: if a >= 75: print("C+") else: if a >= 70: print("C") else: if a >= 65: print("D+") ...
def grade(a): if a >= 90: print('A') elif a >= 85: print('B+') elif a >= 80: print('B') elif a >= 75: print('C+') elif a >= 70: print('C') elif a >= 65: print('D+') elif a >= 60: print('D') else: print('F') a = 'Error : Valu...
class DDH2Exception(Exception): def __init__(self, response): self.status_code = response.status_code self.text = response.text def __repr__(self): return 'DDH2Exception [{}]: {}'.format(self.status_code, self.text) def __str__(self): return self.text
class Ddh2Exception(Exception): def __init__(self, response): self.status_code = response.status_code self.text = response.text def __repr__(self): return 'DDH2Exception [{}]: {}'.format(self.status_code, self.text) def __str__(self): return self.text
class Queue: def __init__(self): self.array = [] self.length = 0 # adding the data to the end of the array def enqueue(self, data): self.array.append(data) self.length += 1 return # popping the data to the start of the array def dequeue(self): poped ...
class Queue: def __init__(self): self.array = [] self.length = 0 def enqueue(self, data): self.array.append(data) self.length += 1 return def dequeue(self): poped = self.array[0] self.array.pop(0) self.length -= 1 return poped d...
""" Module containing exceptions raised by the warden application """ class ActionNotAllowed(Exception): pass
""" Module containing exceptions raised by the warden application """ class Actionnotallowed(Exception): pass
def minimax(arr): arr.sort() max = 0 min = 0 for i in range(len(arr)): if i!=0: max += arr[i] if i!=4: min += arr[i] print(min,max) if __name__=="__main__": arr = list(map(int, input().rstrip().split())) minimax(arr)
def minimax(arr): arr.sort() max = 0 min = 0 for i in range(len(arr)): if i != 0: max += arr[i] if i != 4: min += arr[i] print(min, max) if __name__ == '__main__': arr = list(map(int, input().rstrip().split())) minimax(arr)
# You need to print the value from 0 to 100 # whenever the number divisible by 3, then it should print as "fuzz" # If the number is divisible 5, it should display as "buzz # If the number id divided by 15, the result should be "fuzz_buzz" # Simple method for i in range(101): if i % 15 == 0: print("fuzz_buz...
for i in range(101): if i % 15 == 0: print('fuzz_buzz') elif i % 5 == 0: print('buzz') elif i % 3 == 0: print('fizz') else: print(i) answer = ('fizz_buzz' if i % 15 == 0 else 'buzz' if i % 5 == 0 else 'fizz' if i % 3 == 0 else i for i in range(101))
#============================================================================== # # Copyright (c) 2019 Smells Like Donkey Software Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redist...
def decode_bid(bid): suit = bid[-1:] if suit in ('C', 'H', 'D', 'S', 'N'): bid = bid[:-1] else: suit = None return (bid, suit) def decode_card(card): if card[0] == '3': return (3, card[1]) if card[0] == '5': return (5, card[1]) if card[0] == '7': retu...
#!/usr/bin/env python3 def getMinimumCost(k, c): min_cost = 0 temp = 0 previous = 0 if k >= len(c): return sum(c) c = sorted(c) for x in reversed(c): if temp == k: temp = 0 previous += 1 min_cost += (previous + 1) * x temp += 1 ret...
def get_minimum_cost(k, c): min_cost = 0 temp = 0 previous = 0 if k >= len(c): return sum(c) c = sorted(c) for x in reversed(c): if temp == k: temp = 0 previous += 1 min_cost += (previous + 1) * x temp += 1 return min_cost print(get_min...
POSTGRES_URL="****" POSTGRES_USER="****" POSTGRES_PW="****" POSTGRES_DB="****"
postgres_url = '****' postgres_user = '****' postgres_pw = '****' postgres_db = '****'
# # PySNMP MIB module ASCEND-MIBATMIF-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ASCEND-MIBATMIF-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:26:28 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default...
(configuration,) = mibBuilder.importSymbols('ASCEND-MIB', 'configuration') (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_inters...
#!/usr/bin/env pypy n = int(input()) F = [1] * -~n for i in range(2, n + 1): for j in range(i, n + 1, i): F[j] += 1 print(sum(e * v for e, v in enumerate(F)))
n = int(input()) f = [1] * -~n for i in range(2, n + 1): for j in range(i, n + 1, i): F[j] += 1 print(sum((e * v for (e, v) in enumerate(F))))
# Large sum x = 371072875339021027987979982208375902465101357402504637693767749000971264812489697007805041701826053874324986199524741059474233309513058123726617309629919422133635741615725224305633018110724061549082502306758820753934617117198031042104751377806324667689261670696623633820136378418383684178734361726757281...
x = 3710728753390210279879799822083759024651013574025046376937677490009712648124896970078050417018260538743249861995247410594742333095130581237266173096299194221336357416157252243056330181107240615490825023067588207539346171171980310421047513778063246676892616706966236338201363784183836841787343617267572811287981284997...
# -*- coding: utf-8 -*- class GraphDSLSemantics(object): def digit(self, ast): return ast def symbol(self, ast): return ast def characters(self, ast): return ast def identifier(self, ast): return ast def string(self, ast): return ast[1] def natural(...
class Graphdslsemantics(object): def digit(self, ast): return ast def symbol(self, ast): return ast def characters(self, ast): return ast def identifier(self, ast): return ast def string(self, ast): return ast[1] def natural(self, ast): retur...
n = int(input()) nums = list(input()) sum = 0 for i in range(0, n): sum += int(nums[i]) print(sum)
n = int(input()) nums = list(input()) sum = 0 for i in range(0, n): sum += int(nums[i]) print(sum)
test_secret = "seB388LNHgxcuvAcg1pOV20_VR7uJWNGAznE0fOqKxg=".encode('ascii') test_data = { 'valid': '{"tx_id":"0f534ffc-9442-414c-b39f-a756b4adc6cb", "case_id":"0f534ffc-9442-414c-b39f-a756b4adc6cb","collection":' '{"exercise_sid":"hfjdskf"},"metadata":{"user_id":"789473423","ru_ref":"12345678901A"...
test_secret = 'seB388LNHgxcuvAcg1pOV20_VR7uJWNGAznE0fOqKxg='.encode('ascii') test_data = {'valid': '{"tx_id":"0f534ffc-9442-414c-b39f-a756b4adc6cb", "case_id":"0f534ffc-9442-414c-b39f-a756b4adc6cb","collection":{"exercise_sid":"hfjdskf"},"metadata":{"user_id":"789473423","ru_ref":"12345678901A"}}', 'invalid': '{"cats":...
''' Create a script that reads something and show the type and all informations about it. ''' something = input('Type something: ') print(f'The type of this value is \033[34m{type(something)}\033[m') print(f'Has only spaces? \033[34m{something.isspace()}\033[m') print(f'Is numeric? \033[34m{something.isnumeric()}\...
""" Create a script that reads something and show the type and all informations about it. """ something = input('Type something: ') print(f'The type of this value is \x1b[34m{type(something)}\x1b[m') print(f'Has only spaces? \x1b[34m{something.isspace()}\x1b[m') print(f'Is numeric? \x1b[34m{something.isnumeric()}\x...
# # This file contains the Python code from Program 8.12 of # "Data Structures and Algorithms # with Object-Oriented Design Patterns in Python" # by Bruno R. Preiss. # # Copyright (c) 2003 by Bruno R. Preiss, P.Eng. All rights reserved. # # http://www.brpreiss.com/books/opus7/programs/pgm08_12.txt # class ChainedScatt...
class Chainedscattertable(HashTable): def __init__(self, length): super(ChainedScatterTable, self).__init__() self._array = array(length) for i in xrange(len(self._array)): self._array[i] = self.Entry(None, self.NULL) def __len__(self): return len(self._array) ...
"""Use 2-dimansional arrays to create a playable tic tac toe""" class TicTacToe: """Management of a Tic-Tac-Toe game (does not do strategy)""" def __init__(self) -> None: "Starts a new game" self._board = [[" "] * 3 for j in range(3)] self._player = "X" def __str__(self) -> str: ...
"""Use 2-dimansional arrays to create a playable tic tac toe""" class Tictactoe: """Management of a Tic-Tac-Toe game (does not do strategy)""" def __init__(self) -> None: """Starts a new game""" self._board = [[' '] * 3 for j in range(3)] self._player = 'X' def __str__(self) -> st...
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None # inorder = [9,3,15,20,7] # postorder = [9,15,7,20,3] class Solution: def buildTree(self, inorder, postorder): """ :type inorder: List[int] ...
class Treenode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def build_tree(self, inorder, postorder): """ :type inorder: List[int] :type postorder: List[int] :rtype: TreeNode """ if len(postorde...
font = CurrentFont() min = 0 max = 0 for glyph in font: if glyph.bounds != None: if glyph.bounds[1] < min: min = glyph.bounds[1] if glyph.bounds[3] > max: max = glyph.bounds[3] print(min,max) font.info.openTypeOS2TypoAscender = font.info.ascender font.info.ope...
font = current_font() min = 0 max = 0 for glyph in font: if glyph.bounds != None: if glyph.bounds[1] < min: min = glyph.bounds[1] if glyph.bounds[3] > max: max = glyph.bounds[3] print(min, max) font.info.openTypeOS2TypoAscender = font.info.ascender font.info.openTypeOS2TypoDe...
class AtomicappBuilderException(Exception): def __init__(self, cause): super(AtomicappBuilderException, self).__init__(cause) self.cause = cause def to_str(self): ret = str(self.cause) if hasattr(self.cause, 'output'): ret += ' Subprocess output: {0}'.format(self.cau...
class Atomicappbuilderexception(Exception): def __init__(self, cause): super(AtomicappBuilderException, self).__init__(cause) self.cause = cause def to_str(self): ret = str(self.cause) if hasattr(self.cause, 'output'): ret += ' Subprocess output: {0}'.format(self.ca...
""" Here because random is also a builtin module. """ a = set
""" Here because random is also a builtin module. """ a = set
class Employee: #the self paremeter is a reference #to the current instance of the class - w3schools/python def __init__(self,name,age): self.name = name self.age = age def compute_wage(self,hours, rate): return hours * rate
class Employee: def __init__(self, name, age): self.name = name self.age = age def compute_wage(self, hours, rate): return hours * rate
value = float(input()) print('NOTAS:') for cell in [100, 50, 20, 10, 5, 2]: print('{} nota(s) de R$ {},00'.format(int(value/cell), cell)) value = value % cell print('MOEDAS:') for coin in [1, 0.5, 0.25, 0.10, 0.05, 0.01]: print('{} moeda(s) de R$ {:.2f}'.format(int(value/coin), coin).replace('.',',')) v...
value = float(input()) print('NOTAS:') for cell in [100, 50, 20, 10, 5, 2]: print('{} nota(s) de R$ {},00'.format(int(value / cell), cell)) value = value % cell print('MOEDAS:') for coin in [1, 0.5, 0.25, 0.1, 0.05, 0.01]: print('{} moeda(s) de R$ {:.2f}'.format(int(value / coin), coin).replace('.', ',')) ...
# ----------------------------------------------------------- # Copyright (c) 2021. Danil Smirnov # The football team recruits girls from 10 to 15 years old inclusive. # Write a program that asks for the age and gender of an applicant # using the gender designation m (for male) and f (for female) # to...
class Applicant: def __init__(self, name: str=None, age: int=None, gender: str=None): self.name = name self.age = age self.gender = gender self.can_join = self.check_membership(age, gender) def check_membership(self, age: int, gender: str) -> bool: return self.check_age...
""" padding.py """ def pkcs7(bs, block_size): """ An implementation of pkcs#7 padding. """ # Find the amount needed to pad to correct length. pad = block_size - len(bs)%block_size if pad == 0: pad = block_size # Pad with padding length and return. return bytearray(bs) + bytear...
""" padding.py """ def pkcs7(bs, block_size): """ An implementation of pkcs#7 padding. """ pad = block_size - len(bs) % block_size if pad == 0: pad = block_size return bytearray(bs) + bytearray([pad] * pad) def pkcs7_unpad(bs, block_size): """ An implementation of pkcs#7 unpadd...
text_list = list(input()) length_matrix = int(input()) matrix = [] player_position = [] for i in range(length_matrix): row = list(input()) matrix.append(row) for j in range(length_matrix): if row[j] == 'P': player_position = [i, j] directions = { 'up': (-1, 0), 'right': (0, 1), ...
text_list = list(input()) length_matrix = int(input()) matrix = [] player_position = [] for i in range(length_matrix): row = list(input()) matrix.append(row) for j in range(length_matrix): if row[j] == 'P': player_position = [i, j] directions = {'up': (-1, 0), 'right': (0, 1), 'down': (1...
class Layer(object): def __init__(self): self.input_shape = None self.x =None self.z = None def initialize(self,folder): pass def train(self, inputs, train=True): pass def forward(self, inputs): pass def backward(self,delta_in,arg)...
class Layer(object): def __init__(self): self.input_shape = None self.x = None self.z = None def initialize(self, folder): pass def train(self, inputs, train=True): pass def forward(self, inputs): pass def backward(self, delta_in, arg): pa...
""" DEV ~~~ .. data:: DEV Used to specify the development environment. PROD ~~~~ .. data:: PROD Used to specify the production environment. STAGING ~~~~~~~ .. data:: STAGING Used to specify the staging environment. TEST ~~~~ .. data:: TEST Used to specify the test environment. """ DEV = 'dev...
""" DEV ~~~ .. data:: DEV Used to specify the development environment. PROD ~~~~ .. data:: PROD Used to specify the production environment. STAGING ~~~~~~~ .. data:: STAGING Used to specify the staging environment. TEST ~~~~ .. data:: TEST Used to specify the test environment. """ dev = 'deve...
# https://www.hackerrank.com/challenges/three-month-preparation-kit-queue-using-two-stacks/problem class Queue: def __init__(self, s1=[], s2=[]): self.s1 = s1 self.s2 = s2 def isEmpty(self): if not self.s1 and not self.s2: return True return False def size(self): r...
class Queue: def __init__(self, s1=[], s2=[]): self.s1 = s1 self.s2 = s2 def is_empty(self): if not self.s1 and (not self.s2): return True return False def size(self): return len(self.s1) + len(self.s2) def enqueue(self, val): self.s1.appen...
# Copyright (C) 2018 Intel Corporation # # SPDX-License-Identifier: MIT default_app_config = 'cvat.apps.annotation.apps.AnnotationConfig'
default_app_config = 'cvat.apps.annotation.apps.AnnotationConfig'
"""MQTT Topics""" TOPIC_BUTTON_PROXY = "sensor/button/_proxy" # Hardware button states TOPIC_COFFEE_BUTTON = "sensor/button/coffee" TOPIC_WATER_BUTTON = "sensor/button/water" TOPIC_STEAM_BUTTON = "sensor/button/steam" TOPIC_RED_BUTTON = "sensor/button/red" TOPIC_BLUE_BUTTON = "sensor/button/blue" TOPIC_WHITE_BUTTON ...
"""MQTT Topics""" topic_button_proxy = 'sensor/button/_proxy' topic_coffee_button = 'sensor/button/coffee' topic_water_button = 'sensor/button/water' topic_steam_button = 'sensor/button/steam' topic_red_button = 'sensor/button/red' topic_blue_button = 'sensor/button/blue' topic_white_button = 'sensor/button/white' topi...
{ "targets": [ { "target_name": "irf", "sources": [ "irf/node.cpp", "irf/randomForest.h", "irf/randomForest.cpp", "irf/MurmurHash3.h", "irf/MurmurHash3.cpp" ], 'cflags': [ '<!@(pkg-config --cflags libsparsehash)' ], 'conditions': [ [ 'O...
{'targets': [{'target_name': 'irf', 'sources': ['irf/node.cpp', 'irf/randomForest.h', 'irf/randomForest.cpp', 'irf/MurmurHash3.h', 'irf/MurmurHash3.cpp'], 'cflags': ['<!@(pkg-config --cflags libsparsehash)'], 'conditions': [['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', {'cflags_cc!': ['-fno-rtti', ...
# SLICE list = ['start', 'second', 'third', 'fourth', 'fifth'] list_fra = list[2] print(list) print(list_fra) print(list[1:3]) print(list[-3:-1]) print(list[-3:]) print(list[:-3])
list = ['start', 'second', 'third', 'fourth', 'fifth'] list_fra = list[2] print(list) print(list_fra) print(list[1:3]) print(list[-3:-1]) print(list[-3:]) print(list[:-3])
class Solution: def helper(self, n: int, k: int, first: int, curr: list, output: list) -> None: if len(curr)==k: output.append(curr[:]) else: for i in range(first, n+1): curr.append(i) self.helper(n, k, i+1, curr, output) curr.p...
class Solution: def helper(self, n: int, k: int, first: int, curr: list, output: list) -> None: if len(curr) == k: output.append(curr[:]) else: for i in range(first, n + 1): curr.append(i) self.helper(n, k, i + 1, curr, output) ...
file1 = open('windows/contest.ppm','r') Lines = file1.readlines() count = 0 for line in Lines: a, b, c = line.split() count += 6 A = int(a) B = int(b) C = int(c) while A/10 >= 1 : count += 1 A /= 10 while B/10 >= 1 : count += 1 B /= 10 while ...
file1 = open('windows/contest.ppm', 'r') lines = file1.readlines() count = 0 for line in Lines: (a, b, c) = line.split() count += 6 a = int(a) b = int(b) c = int(c) while A / 10 >= 1: count += 1 a /= 10 while B / 10 >= 1: count += 1 b /= 10 while C / 10 >=...
MONGODB_SETTINGS = { 'db': 'rsframgia', 'collection': 'viblo_posts', 'host': 'mongodb+srv://nhomanhemcututu:chubichthuy@cluster0.vnbw3.mongodb.net/rsframgia?authSource=admin&replicaSet=atlas-mi89bw-shard-0&w=majority&readPreference=primary&appname=MongoDB%20Compass&retryWrites=true&ssl=true' } PATH_DICTIONA...
mongodb_settings = {'db': 'rsframgia', 'collection': 'viblo_posts', 'host': 'mongodb+srv://nhomanhemcututu:chubichthuy@cluster0.vnbw3.mongodb.net/rsframgia?authSource=admin&replicaSet=atlas-mi89bw-shard-0&w=majority&readPreference=primary&appname=MongoDB%20Compass&retryWrites=true&ssl=true'} path_dictionary = 'models/i...
# Anders Poirel # https://leetcode.com/problems/valid-parentheses # Runtime: 28 ms, faster than 71.23% of Python3 online submissions for Valid Parentheses. # Memory Usage: 12.8 MB, less than 100.00% of Python3 online submissions for Valid Parentheses. class Solution: def isValid(self, s: str) -> bool: st...
class Solution: def is_valid(self, s: str) -> bool: stack = [] for i in range(len(s)): if s[i] in ['{', '[', '(']: stack.append(s[i]) else: if len(stack) == 0: return False res = stack.pop() ...
#2. Suppose the cover price of a book is **$24.95, but bookstores get a **40% discount. Shipping costs **$3 for the # first copy and **75 cents for each additional copy. What is the total wholesale cost for **60 copies? cover_price = 24.95 bkstore_dis = cover_price - (cover_price * 40)/100 ship_cost = 3 #only for t...
cover_price = 24.95 bkstore_dis = cover_price - cover_price * 40 / 100 ship_cost = 3 ship_cost_normal = 0.75 copies = 60 ship_calc = ship_cost_normal * (copies - 1) + ship_cost books_purchase = bkstore_dis * copies whole_sale = books_purchase + ship_calc print('The total wholesale cost ${:.2f}'.format(whole_sale))
# # Author: Luke Hindman # Date: Mon Nov 6 16:13:43 MST 2017 # Description: Example of how to write to a file with Exception Handling # # Write a List of strings to a file # # Parameter # outputFile - A String with the name of the file to write to # dataList - A List of strings to write to the file # # Return ...
def write_list_to_file(outputFile, dataList): try: destination = open(outputFile, 'w') destination.writelines(dataList) destination.close() except IOError: print('Unable to write to output file' + outputFile) my_file = 'names.txt' name_list = ['Robin\n', 'Lily\n', 'Nora\n', 'Patr...
power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate...
power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate Leakage': 0.00662954, 'Peak Dynamic': 0.0, 'Runtime Dynamic': 0.0, 'Subthres...
# This file contains default error messages to be used. notFound = { "status": "error", "type": "404 Not found", "message": "Not found error" } serverError = { "status": "error", "type": "500 Server error", "message": "Unknown internal server error" } badRequest = { "status": "error", ...
not_found = {'status': 'error', 'type': '404 Not found', 'message': 'Not found error'} server_error = {'status': 'error', 'type': '500 Server error', 'message': 'Unknown internal server error'} bad_request = {'status': 'error', 'type': '400 Bad request', 'message': 'Bad request, please check your syntax and try again'}
# -*- coding: utf-8 -*- def main(): d = list(map(int, input().split())) j = list(map(int, input().split())) gold_amount = 0 for di, ji in zip(d, j): gold_amount += max(di, ji) print(gold_amount) if __name__ == '__main__': main()
def main(): d = list(map(int, input().split())) j = list(map(int, input().split())) gold_amount = 0 for (di, ji) in zip(d, j): gold_amount += max(di, ji) print(gold_amount) if __name__ == '__main__': main()
''' For Admins: This Template class is to help developers add additional cloud platforms to the software ''' ''' class [Platform_NAME](object): def __init__(self): ## For attributes use convention [NAME]_[FUNCTION]_[PARAM] ## The below attributes are strongly recomended to have within ...
""" For Admins: This Template class is to help developers add additional cloud platforms to the software """ "\nclass [Platform_NAME](object):\n def __init__(self):\n ## For attributes use convention [NAME]_[FUNCTION]_[PARAM]\n ## The below attributes are strongly recomended to have within new plat...
# https://leetcode.com/problems/determine-if-string-halves-are-alike/ def halves_are_alike(s): vowels = { 'a': True, 'e': True, 'i': True, 'o': True, 'u': True, 'A': True, 'E': True, 'I': True, 'O': True, 'U': True, } ...
def halves_are_alike(s): vowels = {'a': True, 'e': True, 'i': True, 'o': True, 'u': True, 'A': True, 'E': True, 'I': True, 'O': True, 'U': True} middle_index = len(s) // 2 (a, b) = (s[:middle_index], s[middle_index:]) (a_counter, b_counter) = (0, 0) for char in a: if char in vowels: ...
def hex_rgb(argument): """Convert the argument string to a tuple of integers. """ h = argument.lstrip("#") num_digits = len(h) if num_digits == 3: return ( int(h[0], 16), int(h[1], 16), int(h[2], 16), ) elif num_digits == 4: return ( ...
def hex_rgb(argument): """Convert the argument string to a tuple of integers. """ h = argument.lstrip('#') num_digits = len(h) if num_digits == 3: return (int(h[0], 16), int(h[1], 16), int(h[2], 16)) elif num_digits == 4: return (int(h[0], 16), int(h[1], 16), int(h[2], 16), int(h...