content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
days = input().split("|") energy = 100 coins = 100 bakery_is_closed = False for current_day in days: current_day = current_day.split("-") to_do = current_day[0] number = int(current_day[1]) if to_do == "rest": needed_energy = 100 - energy gained_energy = min(number, needed_energy) ...
days = input().split('|') energy = 100 coins = 100 bakery_is_closed = False for current_day in days: current_day = current_day.split('-') to_do = current_day[0] number = int(current_day[1]) if to_do == 'rest': needed_energy = 100 - energy gained_energy = min(number, needed_energy) ...
MODULE_NAME = 'Gigamon ThreatINSIGHT ConfTokenTest' INTEGRATION_NAME = 'Gigamon ThreatINSIGHT' GIGAMON_URL = 'https://portal.icebrg.io' CONFIDENCE = SEVERITY = ('High', 'Medium', 'Low') RELATIONS_TYPES = ( 'Connected_To', 'Sent_From', 'Sent_To', 'Resolved_To', 'Hosted_On', 'Queried_For', 'Downloaded_To', 'D...
module_name = 'Gigamon ThreatINSIGHT ConfTokenTest' integration_name = 'Gigamon ThreatINSIGHT' gigamon_url = 'https://portal.icebrg.io' confidence = severity = ('High', 'Medium', 'Low') relations_types = ('Connected_To', 'Sent_From', 'Sent_To', 'Resolved_To', 'Hosted_On', 'Queried_For', 'Downloaded_To', 'Downloaded_Fro...
def get_subindicator(metric): subindicators = metric.indicator.subindicators idx = metric.subindicator if metric.subindicator is not None else 0 return subindicators[idx] def get_sum(data, group=None, subindicator=None): if (group is not None and subindicator is not None): return sum([float(row...
def get_subindicator(metric): subindicators = metric.indicator.subindicators idx = metric.subindicator if metric.subindicator is not None else 0 return subindicators[idx] def get_sum(data, group=None, subindicator=None): if group is not None and subindicator is not None: return sum([float(row['...
# -*- coding: utf-8 -*- __all__ = ('__version__',) __version__ = '0.39.0+dev' def includeme(config): config.include('pyramid_services') # This must be included first so it can set up the model base class if # need be. config.include('memex.models') config.include('memex.links')
__all__ = ('__version__',) __version__ = '0.39.0+dev' def includeme(config): config.include('pyramid_services') config.include('memex.models') config.include('memex.links')
description = 'setup for the NICOS watchdog' group = 'special' # The entries in this list are dictionaries. Possible keys: # # 'setup' -- setup that must be loaded (default '' to mean all setups) # 'condition' -- condition for warning (a Python expression where cache keys # can be used: t_value stands for t/value e...
description = 'setup for the NICOS watchdog' group = 'special' watch_conditions = [dict(condition='LogSpace_status[0] == WARN', message='Disk space for log files becomes too low.', type='critical', gracetime=30), dict(condition='(sixfold_value == "closed" or nl4a_value == "closed") and reactorpower_value > 19', message...
class Point: def __init__(self, x, y): self.x = x self.y = y def __add__(self, other): return Point(self.x + other.x, self.y + other.y) def __sub__(self, other): return Point(self.x - other.x, self.y - other.y) def __mul__(self, other): return Point(self...
class Point: def __init__(self, x, y): self.x = x self.y = y def __add__(self, other): return point(self.x + other.x, self.y + other.y) def __sub__(self, other): return point(self.x - other.x, self.y - other.y) def __mul__(self, other): return point(self.x * o...
# Constants PROD = "product" LOCN = "location" PRLO = "product_location" PRMO = "product_movement" names = [PROD, LOCN, PRLO, PRMO] required_cols = { PROD: ("product_id", "product_name"), LOCN: ("location_id", "location_name"), PRLO: ("product_id", "location_id", "qty"), PRMO: ("movement_id", "transac...
prod = 'product' locn = 'location' prlo = 'product_location' prmo = 'product_movement' names = [PROD, LOCN, PRLO, PRMO] required_cols = {PROD: ('product_id', 'product_name'), LOCN: ('location_id', 'location_name'), PRLO: ('product_id', 'location_id', 'qty'), PRMO: ('movement_id', 'transaction_time', 'product_id', 'qty'...
def main(): n_gnomes_orig, n_gnomes_remain = [int(x) for x in input().split()] gnomes_remain = [] for _ in range(n_gnomes_remain): gnomes_remain.append(int(input())) gnomes_remain_tmp = set(gnomes_remain) missing_gnomes = [g for g in range(1, n_gnomes_orig + 1) if g not in gnomes_remain_tm...
def main(): (n_gnomes_orig, n_gnomes_remain) = [int(x) for x in input().split()] gnomes_remain = [] for _ in range(n_gnomes_remain): gnomes_remain.append(int(input())) gnomes_remain_tmp = set(gnomes_remain) missing_gnomes = [g for g in range(1, n_gnomes_orig + 1) if g not in gnomes_remain_tm...
print("*****************") print("Guessing game") print("*****************") secret_number = 43 attempts_total = 3 for attempt in range(1, attempts_total + 1): print("Attempt {} by {}".format(attempt, attempts_total)) user_number_str = input("Fill the number: ") print("Your number was: " + user_number_st...
print('*****************') print('Guessing game') print('*****************') secret_number = 43 attempts_total = 3 for attempt in range(1, attempts_total + 1): print('Attempt {} by {}'.format(attempt, attempts_total)) user_number_str = input('Fill the number: ') print('Your number was: ' + user_number_str) ...
[ [0.0, 1.3892930788974391, 0.8869425734660505, 1.402945620973322], [0.0, 0.1903540333363253, 0.30894158244285624, 0.3994739596013725], [0.0, 0.03761142927757482, 1.2682277741610029, 0.36476016345069556], [0.0, -1.187392798652706, -1.0206496663686406, -1.35111583891054], [0.0, -1.742783579889951, -2...
[[0.0, 1.3892930788974391, 0.8869425734660505, 1.402945620973322], [0.0, 0.1903540333363253, 0.30894158244285624, 0.3994739596013725], [0.0, 0.03761142927757482, 1.2682277741610029, 0.36476016345069556], [0.0, -1.187392798652706, -1.0206496663686406, -1.35111583891054], [0.0, -1.742783579889951, -2.425391682127969, -3....
_ = input() # number of test cases; we can ignore this since it has no significance temps = map(int, input().split()) # all the temps stored to a list with type int subercold = 0 # how many temps below 0 we got for i in temps: # for every temp we recorded if it's less than 0 add +1 to subercold if i < 0: ...
_ = input() temps = map(int, input().split()) subercold = 0 for i in temps: if i < 0: subercold += 1 print(subercold)
#!/usr/bin/python # -*- utf-8 -*- class Solution: # @param A, a list of integer # @return an integer def singleNumber(self, A): cache = {} for a in A: count = cache.get(a, 0) + 1 if count >= 3: cache.pop(a) else: cache[a] =...
class Solution: def single_number(self, A): cache = {} for a in A: count = cache.get(a, 0) + 1 if count >= 3: cache.pop(a) else: cache[a] = count return cache.popitem()[0] if __name__ == '__main__': print(solution().sin...
# Criando arquivo 1 com 10 linhas with open('arquivo1.txt', 'w') as arq1: for line in range(1, 11): arq1.write(f'Linha {line} do arquivo 1\n') # Criando arquivo 2 com 10 linhas with open('arquivo2.txt', 'w') as arq1: for line in range(1, 11): arq1.write(f'Linha {line} do arquivo 2\n') # Lendo ...
with open('arquivo1.txt', 'w') as arq1: for line in range(1, 11): arq1.write(f'Linha {line} do arquivo 1\n') with open('arquivo2.txt', 'w') as arq1: for line in range(1, 11): arq1.write(f'Linha {line} do arquivo 2\n') with open('arquivo1.txt', 'r') as arq1: with open('arquivo2.txt', 'r') as ...
# https://www.codewars.com/kata/5432fd1c913a65b28f000342/train/python ''' Instructions : Create a function that accepts dimensions, of Rows x Columns, as parameters in order to create a multiplication table sized according to the given dimensions. **The return value of the function must be an array, and the numbers m...
""" Instructions : Create a function that accepts dimensions, of Rows x Columns, as parameters in order to create a multiplication table sized according to the given dimensions. **The return value of the function must be an array, and the numbers must be Fixnums, NOT strings. Example: multiplication_table(3,3) ...
class Solution: def reorderedPowerOf2(self, N: int) -> bool: t=1 cands=set() while t<=1000000000: tt=sorted([ttt for ttt in str(t)]) cands.add(''.join(tt)) t*=2 print(cands) tt=sorted([ttt for ttt in str(N)]) print(tt) retur...
class Solution: def reordered_power_of2(self, N: int) -> bool: t = 1 cands = set() while t <= 1000000000: tt = sorted([ttt for ttt in str(t)]) cands.add(''.join(tt)) t *= 2 print(cands) tt = sorted([ttt for ttt in str(N)]) print(tt...
#Meaning of Life? answer = "42" n = 1 i = 0 while i < 1: x = input("What is the meaning of life? ") if x != answer: print("Incorrect.") n = n + 1 if x == answer: print("You got it in " + str(n) + " attempt(s)!") break
answer = '42' n = 1 i = 0 while i < 1: x = input('What is the meaning of life? ') if x != answer: print('Incorrect.') n = n + 1 if x == answer: print('You got it in ' + str(n) + ' attempt(s)!') break
#Create an empty set s = set() # Add elements to set s.add(1) s.add(2) s.add(3) s.add(4) s.add(3) s.remove(2) print(s) print(f"The set has {len(s)} elements.")
s = set() s.add(1) s.add(2) s.add(3) s.add(4) s.add(3) s.remove(2) print(s) print(f'The set has {len(s)} elements.')
# /* Kattis: acm # * # * Topic: others # * # * Level: easy # * # * Brief problem description: # * # * branching summation # * # * Solution Summary: # * # * basic arithmetic # * # * Used Resources: # * # * # * # * I hereby certify that I have produced the following solution myself # * using only t...
line = input() point = 0 penalty = 0 problems = dict() while line != '-1': try: line = line.split(' ') if line[2] == 'right': point += 1 penalty += int(line[0]) penalty += problems[line[1]] * 20 else: problems[line[1]] += 1 except KeyError:...
def jmp_simple(n): return 3 if n == 0 else 5 def jmp_short(n): if n == 0: n += 1 n += 1 n += 1 n += 1 n += 1 n += 1 n += 1 n += 1 n += 1 n += 1 n += 1 n += 1 n += 1 n += 1 n += 1 n +...
def jmp_simple(n): return 3 if n == 0 else 5 def jmp_short(n): if n == 0: n += 1 n += 1 n += 1 n += 1 n += 1 n += 1 n += 1 n += 1 n += 1 n += 1 n += 1 n += 1 n += 1 n += 1 n += 1 n +=...
class Solution: def minOperationsMaxProfit(self, customers: List[int], boardingCost: int, runningCost: int) -> int: run = maxRun = 0 profit = maxProfit = 0 wait = 0 i = 0 while wait > 0 or i < len(customers): if i < len(customers): wait += customer...
class Solution: def min_operations_max_profit(self, customers: List[int], boardingCost: int, runningCost: int) -> int: run = max_run = 0 profit = max_profit = 0 wait = 0 i = 0 while wait > 0 or i < len(customers): if i < len(customers): wait += cu...
# Method 1 def reverse(str): return str[::-1] # Method 2 ''' def reverse(string): result = "" for letter in xrange(len(string), 0, -1): result = result + string[letter-1] return result ''' if __name__=="__main__": print("Enter a String: ",end="") str = input() print("Reverse of '",...
def reverse(str): return str[::-1] '\ndef reverse(string):\n result = ""\n for letter in xrange(len(string), 0, -1):\n result = result + string[letter-1]\n return result\n' if __name__ == '__main__': print('Enter a String: ', end='') str = input() print("Reverse of '", str, "' is '", rev...
config = { # coinflex production api server 'rest_url': 'https://v2api.coinflex.com', 'rest_path': 'v2api.coinflex.com', # local data filename 'coinflex_data_filename': 'coinflex_data.json', # create an api key on coinflex.com and put it here 'api_key': "<your api key>", 'api_secret': "<your api secret>", #...
config = {'rest_url': 'https://v2api.coinflex.com', 'rest_path': 'v2api.coinflex.com', 'coinflex_data_filename': 'coinflex_data.json', 'api_key': '<your api key>', 'api_secret': '<your api secret>', 'assets': ['flexUSD'], 'markets': ['BCH-USD', 'DOGE-USD', 'BTC-USD'], 't_account_start': int(1609455600 * 1000), 'endpoin...
GUILD_ID = 391155528501559296 # ==== rewards ==== REWARDS_CHANNEL = 404753143172431873 DISCUSSION_CHANNEL = 556531902865997834 SCHEDULED_HOUR = 20 # 2000 GMT ROLES_TO_PING = [ 404055199054036993, # dm 631621534233919499, # planar dm # 405499372592168960 # trial dm ] # ==== onboarding ==== ROLLING_CHAN...
guild_id = 391155528501559296 rewards_channel = 404753143172431873 discussion_channel = 556531902865997834 scheduled_hour = 20 roles_to_ping = [404055199054036993, 631621534233919499] rolling_channel = 404368543740723200 roles_to_assign = ['Player'] onboarding_message = 'PLACEHOLDER' dm_quest_channel = 4040503674547732...
class Movie(): # Initialize instance of class Movie def __init__(self, movie_title, poster_image, trailer_youtube, movie_storyline, movie_rating): self.title = movie_title self.poster_image_url = poster_image self.trailer_youtube_url = trailer_youtube ...
class Movie: def __init__(self, movie_title, poster_image, trailer_youtube, movie_storyline, movie_rating): self.title = movie_title self.poster_image_url = poster_image self.trailer_youtube_url = trailer_youtube self.storyline = movie_storyline self.rating_image_url = movie...
class Mammal: mammal_population = 0 def __init__(self, name, age): self.name = name self.age = age Mammal.mammal_population += 1 class Dog(Mammal): dog_population = 0 def __init__(self, name, age, breed): super().__init__(name, age) self.breed = breed ...
class Mammal: mammal_population = 0 def __init__(self, name, age): self.name = name self.age = age Mammal.mammal_population += 1 class Dog(Mammal): dog_population = 0 def __init__(self, name, age, breed): super().__init__(name, age) self.breed = breed D...
""" =================== CanvasUserInterface =================== Unsupported - this is a beta feature in Canvas, and does not translate to the PPTX interface. """ class CanvasUserInterface(object): """ [NoInterfaceObject] interface CanvasUserInterface { void drawFocusIfNeeded(Element element); ...
""" =================== CanvasUserInterface =================== Unsupported - this is a beta feature in Canvas, and does not translate to the PPTX interface. """ class Canvasuserinterface(object): """ [NoInterfaceObject] interface CanvasUserInterface { void drawFocusIfNeeded(Element element); ...
""" Given two sorted linked lists, merge them together in ascending order and return a reference to the merged list """ class ListNode: def __init__(self, val=0, nextNode=None): self.val = val self.next = nextNode class MergeLinkedList: def printList(self, node: ListNode): while nod...
""" Given two sorted linked lists, merge them together in ascending order and return a reference to the merged list """ class Listnode: def __init__(self, val=0, nextNode=None): self.val = val self.next = nextNode class Mergelinkedlist: def print_list(self, node: ListNode): while no...
class WriteStreamClosedEventArgs(EventArgs): """ WriteStreamClosedEventArgs() """ def ZZZ(self): """hardcoded/mock instance of the class""" return WriteStreamClosedEventArgs() instance=ZZZ() """hardcoded/returns an instance of the class""" Error=property(lambda self: object(),lambda self,v: None,lambda ...
class Writestreamclosedeventargs(EventArgs): """ WriteStreamClosedEventArgs() """ def zzz(self): """hardcoded/mock instance of the class""" return write_stream_closed_event_args() instance = zzz() 'hardcoded/returns an instance of the class' error = property(lambda self: object(), l...
def apply_filters(sv_list, rmsk_track=None, segdup_track=None): for sv in sv_list: if sv.type == 'INS' or (sv.type == 'BND' and sv.bnd_ins > 0): sv.filters.add('INSERTION') def get_filter_string(sv, filter_criteria): intersection = set(sv.filters).intersection(set(filter_criteria)) if ...
def apply_filters(sv_list, rmsk_track=None, segdup_track=None): for sv in sv_list: if sv.type == 'INS' or (sv.type == 'BND' and sv.bnd_ins > 0): sv.filters.add('INSERTION') def get_filter_string(sv, filter_criteria): intersection = set(sv.filters).intersection(set(filter_criteria)) if l...
huge = 999999999 # nothing but the largest number during calculation, just for convenience cross_p = 0.8 # chromo cross probability random_mutate_p = 0.1 # chromo random mutate probability remove_mutate_p = 0.5 # remove the 'worst' route probability, opposite of it is direct restart probability inter_change_p = 0....
huge = 999999999 cross_p = 0.8 random_mutate_p = 0.1 remove_mutate_p = 0.5 inter_change_p = 0.8 combine_try_time = 10 insert_try_time = 10 remove_try_p = 0.7 restart_p = 0.01 starve_para = 0.25 feasible_generate_p = 0.2 perturb_generate_p = 0.2 center_id = 0 custom_number = 1000 station_number = 100 max_volume = 16 max...
brace = None db = None announcement = "" templateLoader = None templateEnv = None datadog = None datadogConfig = {}
brace = None db = None announcement = '' template_loader = None template_env = None datadog = None datadog_config = {}
""" Entrada Metros-->float-->mtrs Salida Pulgafas-->float-->pul Pie-->float-->pie """ mtrs=float(input("Digite los metros que quiera convertir: ")) pul=mtrs*39.37 pie=mtrs*3.281 print("Este valor en pies seria:", pie, "y en pulgadas es:",pul)
""" Entrada Metros-->float-->mtrs Salida Pulgafas-->float-->pul Pie-->float-->pie """ mtrs = float(input('Digite los metros que quiera convertir: ')) pul = mtrs * 39.37 pie = mtrs * 3.281 print('Este valor en pies seria:', pie, 'y en pulgadas es:', pul)
def countWays(n): a = 1 b = 2 c = 4 d = 0 if (n == 0 or n == 1 or n == 2): return n if (n == 3): return c for i in range(4, n + 1): d = c + b + a a = b b = c c = d return d n = 4 print(countWays(n))
def count_ways(n): a = 1 b = 2 c = 4 d = 0 if n == 0 or n == 1 or n == 2: return n if n == 3: return c for i in range(4, n + 1): d = c + b + a a = b b = c c = d return d n = 4 print(count_ways(n))
class Solution: def addNegabinary(self, arr1: 'List[int]', arr2: 'List[int]') -> 'List[int]': n = max(len(arr1), len(arr2)) res = [] for i in range(-1, -n - 1, -1): r = 0 if len(arr1) + i >= 0: r += arr1[i] if len(arr2) + i >= 0: ...
class Solution: def add_negabinary(self, arr1: 'List[int]', arr2: 'List[int]') -> 'List[int]': n = max(len(arr1), len(arr2)) res = [] for i in range(-1, -n - 1, -1): r = 0 if len(arr1) + i >= 0: r += arr1[i] if len(arr2) + i >= 0: ...
def logCommand(Command, Author, Date): Message = f"[{str(Date)}] {Author}: {Command}\n" with open('data/logs/commands.easy', 'a') as logFile: logFile.write(Message) logFile.close()
def log_command(Command, Author, Date): message = f'[{str(Date)}] {Author}: {Command}\n' with open('data/logs/commands.easy', 'a') as log_file: logFile.write(Message) logFile.close()
# https://atcoder.jp/contests/abc192/tasks/abc192_c N, K = map(int, input().split()) ans = N for _ in range(K): str_N = str(ans) g1 = int("".join(sorted(str_N, reverse=True))) g2 = int("".join(sorted(str_N))) ans = g1 - g2 print(ans)
(n, k) = map(int, input().split()) ans = N for _ in range(K): str_n = str(ans) g1 = int(''.join(sorted(str_N, reverse=True))) g2 = int(''.join(sorted(str_N))) ans = g1 - g2 print(ans)
# https://atcoder.jp/contests/abc002/tasks/abc002_3 ax, ay, bx, by, cx, cy = map(int, input().split()) ans = (ax * by + ay * cx + bx * cy - ay * bx - ax * cy - by * cx) * 0.5 print(abs(ans)) # ax ay 1 ax ay # bx by 1 bx by # cx cy 1 cx cy # ax * by + ay * cx + bx * cy - ay * bx - ax * cy - by * cx
(ax, ay, bx, by, cx, cy) = map(int, input().split()) ans = (ax * by + ay * cx + bx * cy - ay * bx - ax * cy - by * cx) * 0.5 print(abs(ans))
# separate file for keeping global constants # right now need for LOGDIR_ROOT because this value is used in backend.py # but is defined in backend.py descendants LOGDIR_ROOT = None
logdir_root = None
''' You can verify if a specified item is exists in a tuple using in keyword: ''' test=[] n=int(input('Enter size of tuple: ')) for i in range(n): data=input(f'Elements of tuple are: ') test.append(data) test=tuple(test) print(f'Elements of the tuple are: {test}') if "israel" in test: print('yes') else...
""" You can verify if a specified item is exists in a tuple using in keyword: """ test = [] n = int(input('Enter size of tuple: ')) for i in range(n): data = input(f'Elements of tuple are: ') test.append(data) test = tuple(test) print(f'Elements of the tuple are: {test}') if 'israel' in test: print('yes') ...
#Q row=0 while row<8: col =0 while col<8: if (col==1 and row==0)or (col==2 and row==0)or (col==3 and row==0)or (col==4 and row==1)or (col==4 and row==2)or (col==4 and row==3)or (col==5 and row==5)or (col==6 and row==6)or (col==1 and row==4)or (col==2 and row==4)or (col==3 and row==4)or (col==4 and ...
row = 0 while row < 8: col = 0 while col < 8: if col == 1 and row == 0 or (col == 2 and row == 0) or (col == 3 and row == 0) or (col == 4 and row == 1) or (col == 4 and row == 2) or (col == 4 and row == 3) or (col == 5 and row == 5) or (col == 6 and row == 6) or (col == 1 and row == 4) or (col == 2 and ...
""" What you will learn: - What is an if statement - How does this relate to boolean logic - Using if to check conditions - dealing with else - dealing with ifelse Okay, let's say your mom said "If you clean your room you can have a cookie" what is going on here. You have been given a statement: is room clean? Now if...
""" What you will learn: - What is an if statement - How does this relate to boolean logic - Using if to check conditions - dealing with else - dealing with ifelse Okay, let's say your mom said "If you clean your room you can have a cookie" what is going on here. You have been given a statement: is room clean? Now if...
# User defined functions # Example 1 def function_name(): print("my first user-defined function!") function_name() function_name() function_name() function_name() # Example 2 def welcome_msg(): print("Welcome to Python 101") welcome_msg() # Example 3 def welcome_msg(name): print(f"Welcome to Python 101,...
def function_name(): print('my first user-defined function!') function_name() function_name() function_name() function_name() def welcome_msg(): print('Welcome to Python 101') welcome_msg() def welcome_msg(name): print(f'Welcome to Python 101, {name}') welcome_msg('Casey') welcome_msg('Rico') welcome_msg(...
q=int(input("Enter large prime integer(q):")) a=int(input("Enter primitive root(a):")) xa=int(input("Enter Xa:")) ya=(a**xa)%q k=int(input("Enter the value of k:")) m=int(input("Enter Message:")) print("Public key (Ya):",ya) S1=(a**k)%q print("S1:",S1) i=1 while True: x=(k*i)%(q-1) if x==1: break els...
q = int(input('Enter large prime integer(q):')) a = int(input('Enter primitive root(a):')) xa = int(input('Enter Xa:')) ya = a ** xa % q k = int(input('Enter the value of k:')) m = int(input('Enter Message:')) print('Public key (Ya):', ya) s1 = a ** k % q print('S1:', S1) i = 1 while True: x = k * i % (q - 1) i...
s = "I'm a string." print(type(s)) yes = True #Bool true print(type(yes)) no = False #Bool false print(type(no)) #List - ordered and changeable alpha_list = ["a", "b", "c"] #list init print(type(alpha_list)) #tuple print(type(alpha_list[0])) #string alpha_list.append("d") #will add "d" to list print(al...
s = "I'm a string." print(type(s)) yes = True print(type(yes)) no = False print(type(no)) alpha_list = ['a', 'b', 'c'] print(type(alpha_list)) print(type(alpha_list[0])) alpha_list.append('d') print(alpha_list) alpha_tuple = ('a', 'b', 'c') print(type(alpha_tuple)) try: alpha_tuple[2] = 'd' except TypeError: pr...
class Grid: def __init__(self, row, col, gsize): self.row = row self.col = col self.gsize = gsize self.walls = {} # top, left, bottom, right def connections(self): my_list = [] for key, val in self.walls.items(): if val != None: ...
class Grid: def __init__(self, row, col, gsize): self.row = row self.col = col self.gsize = gsize self.walls = {} def connections(self): my_list = [] for (key, val) in self.walls.items(): if val != None: my_list.append(key) re...
# https://www.hackerrank.com/challenges/python-loops/problem n = int(input()) # 5 for i in range(n): print(i ** 2) # 0 # 1 # 4 # 9 # 16
n = int(input()) for i in range(n): print(i ** 2)
TRANSACTIONALSET_ADD = 0x1201 TRANSACTIONALSET_REMOVE = 0x1202 TRANSACTIONALSET_SIZE = 0x1203
transactionalset_add = 4609 transactionalset_remove = 4610 transactionalset_size = 4611
'''https://leetcode.com/problems/climbing-stairs/ 70. Climbing Stairs Easy 8813 261 Add to List Share You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Example 1: Input: n = 2 Output: 2 Explanation:...
"""https://leetcode.com/problems/climbing-stairs/ 70. Climbing Stairs Easy 8813 261 Add to List Share You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Example 1: Input: n = 2 Output: 2 Explanation:...
# Lec 2.6, slide 2 x = int(raw_input('Enter an integer: ')) if x%2 == 0: print('Even') else: print('Odd')
x = int(raw_input('Enter an integer: ')) if x % 2 == 0: print('Even') else: print('Odd')
board = [ [7,8,0,4,0,0,1,2,0], [6,0,0,0,7,5,0,0,9], [0,0,0,6,0,1,0,7,8], [0,0,7,0,4,0,2,6,0], [0,0,1,0,5,0,9,3,0], [9,0,4,0,6,0,0,0,5], [0,7,0,3,0,0,0,1,2], [1,2,0,0,0,7,4,0,0], [0,4,9,2,0,6,0,0,7] ] def print_board(board): for i in range(len(board)): if i % 3 == 0: ...
board = [[7, 8, 0, 4, 0, 0, 1, 2, 0], [6, 0, 0, 0, 7, 5, 0, 0, 9], [0, 0, 0, 6, 0, 1, 0, 7, 8], [0, 0, 7, 0, 4, 0, 2, 6, 0], [0, 0, 1, 0, 5, 0, 9, 3, 0], [9, 0, 4, 0, 6, 0, 0, 0, 5], [0, 7, 0, 3, 0, 0, 0, 1, 2], [1, 2, 0, 0, 0, 7, 4, 0, 0], [0, 4, 9, 2, 0, 6, 0, 0, 7]] def print_board(board): for i in range(len(bo...
II = lambda : int(input()) a1 = II() a2 = II() k1 = II() k2 = II() n = II() if(k1>k2): k1,k2 = k2,k1 a1,a2 = a2,a1 auxM = min(a1,n//k1) restM = n-auxM*k1 M = auxM+min(a2,restM//k2) if((k1-1)*a1+(k2-1)*a2>=n): m = 0 else: m = n-((k1-1)*a1+(k2-1)*a2) print(m,M)
ii = lambda : int(input()) a1 = ii() a2 = ii() k1 = ii() k2 = ii() n = ii() if k1 > k2: (k1, k2) = (k2, k1) (a1, a2) = (a2, a1) aux_m = min(a1, n // k1) rest_m = n - auxM * k1 m = auxM + min(a2, restM // k2) if (k1 - 1) * a1 + (k2 - 1) * a2 >= n: m = 0 else: m = n - ((k1 - 1) * a1 + (k2 - 1) * a2) print...
def buttons(ceiling): connections = ((1, 0), (0, 1), (0, -1), (-1, 0)) g = [[int(c) for c in line] for line in ceiling.strip().splitlines()] sizex, sizey = len(g), len(g[0]) visited = set() def is_new(x, y): return (x, y) not in visited and 0 <= x < sizex and 0 <= y < sizey and g[x][y] != 0...
def buttons(ceiling): connections = ((1, 0), (0, 1), (0, -1), (-1, 0)) g = [[int(c) for c in line] for line in ceiling.strip().splitlines()] (sizex, sizey) = (len(g), len(g[0])) visited = set() def is_new(x, y): return (x, y) not in visited and 0 <= x < sizex and (0 <= y < sizey) and (g[x][...
""" Definition of SegmentTreeNode: class SegmentTreeNode: def __init__(self, start, end): self.start, self.end = start, end self.left, self.right = None, None """ class Solution: """ @param: start: start value. @param: end: end value. @return: The root of Segment Tree....
""" Definition of SegmentTreeNode: class SegmentTreeNode: def __init__(self, start, end): self.start, self.end = start, end self.left, self.right = None, None """ class Solution: """ @param: start: start value. @param: end: end value. @return: The root of Segment Tree. """ ...
pkgname = "python-setuptools" version = "57.0.0" revision = 0 build_style = "python_module" hostmakedepends = ["python-devel"] depends = ["python"] short_desc = "Easily build and distribute Python packages" maintainer = "q66 <q66@chimera-linux.org>" license = "MIT" homepage = "https://github.com/pypa/setuptools" distfi...
pkgname = 'python-setuptools' version = '57.0.0' revision = 0 build_style = 'python_module' hostmakedepends = ['python-devel'] depends = ['python'] short_desc = 'Easily build and distribute Python packages' maintainer = 'q66 <q66@chimera-linux.org>' license = 'MIT' homepage = 'https://github.com/pypa/setuptools' distfi...
def main(): count = 0 sum_ = 0 while True: try: number = float(input(f"Number {count+1}: ")) count += 1 sum_ += number except ValueError: if not count: count = 1 break print(sum_) print(sum_ / count) if __n...
def main(): count = 0 sum_ = 0 while True: try: number = float(input(f'Number {count + 1}: ')) count += 1 sum_ += number except ValueError: if not count: count = 1 break print(sum_) print(sum_ / count) if __n...
# Released under the MIT License. See LICENSE for details. # # This file was automatically generated from "happy_thoughts.ma" # pylint: disable=all points = {} # noinspection PyDictCreation boxes = {} boxes['area_of_interest_bounds'] = (-1.045859963, 12.67722855, -5.401537075) + (0....
points = {} boxes = {} boxes['area_of_interest_bounds'] = (-1.045859963, 12.67722855, -5.401537075) + (0.0, 0.0, 0.0) + (34.46156851, 20.94044653, 0.6931564611) points['ffa_spawn1'] = (-9.295167711, 8.010664315, -5.44451005) + (1.555840357, 1.453808816, 0.1165648888) points['ffa_spawn2'] = (7.484707127, 8.172681752, -5...
class Node: def __init__(self, value, next=None): self.value = value self.next = next def __str__(self): current = self ret = '' while current: ret += str(current.value) current = current.next return ret # Time: O(n) # Space: O(1) def rot...
class Node: def __init__(self, value, next=None): self.value = value self.next = next def __str__(self): current = self ret = '' while current: ret += str(current.value) current = current.next return ret def rotate_list(list, k): len...
load( ":download.bzl", "TerraformBinaryInfo", "TerraformProviderInfo", ) TerraformModuleInfo = provider( "Provider for the terraform_module rule", fields={ "source_files": "depset of source Terraform files", "modules": "depset of modules", "providers": "depset of providers",...
load(':download.bzl', 'TerraformBinaryInfo', 'TerraformProviderInfo') terraform_module_info = provider('Provider for the terraform_module rule', fields={'source_files': 'depset of source Terraform files', 'modules': 'depset of modules', 'providers': 'depset of providers'}) def _terraform_module_impl(ctx): source_f...
# ## https://leetcode.com/problems/longest-palindromic-substring/ # # ## Cannot fully pass the performance test. # class Solution(object): def longestPalindrome(self, s): """ :type s: str :rtype: str """ if s is None: raise ValueError('Input must be a String.') if len(s) == 0 or len(s)...
class Solution(object): def longest_palindrome(self, s): """ :type s: str :rtype: str """ if s is None: raise value_error('Input must be a String.') if len(s) == 0 or len(s) == 1: return s if len(s) == 2: return s if s[0] == s[1] else ...
class ColorConstants(object): #QLineEdit colours QLE_GREEN = '#c4df9b' # green QLE_YELLOW = '#fff79a' # yellow QLE_RED = '#f6989d' # red #see http://cloford.com/resources/colours/500col.htm
class Colorconstants(object): qle_green = '#c4df9b' qle_yellow = '#fff79a' qle_red = '#f6989d'
class BaseServer: def __init__(self, app, **kwargs): """ Construct method """ self.kwargs = kwargs self.app = app def run_serve(self): raise NotImplementedError
class Baseserver: def __init__(self, app, **kwargs): """ Construct method """ self.kwargs = kwargs self.app = app def run_serve(self): raise NotImplementedError
#bmi calculator print("YOU ARE WELCOME TO BMI CALCULATOR BUILT BY IDRIS") print("") print(" PLEASE KINDLY ENTER YOUR VALUE IN KG FOR WEIGHT AND IN METERS FOR HEIGHT ") print("") w=float(input("please enter the value for weight in KG = ")) print("") h=float(input("please enter the value for height in METERS = ")) bmi=w/...
print('YOU ARE WELCOME TO BMI CALCULATOR BUILT BY IDRIS') print('') print(' PLEASE KINDLY ENTER YOUR VALUE IN KG FOR WEIGHT AND IN METERS FOR HEIGHT ') print('') w = float(input('please enter the value for weight in KG = ')) print('') h = float(input('please enter the value for height in METERS = ')) bmi = w / (h * h) ...
def mergesort(m): if len(m) == 1: return m mid = len(m) // 2 left = m[:mid] right = m[mid:] left = mergesort(left) right = mergesort(right) return merge(left, right) def merge(left, right): result = [] while len(left) > 0 or len(right) > 0: if len(left) > 0 and l...
def mergesort(m): if len(m) == 1: return m mid = len(m) // 2 left = m[:mid] right = m[mid:] left = mergesort(left) right = mergesort(right) return merge(left, right) def merge(left, right): result = [] while len(left) > 0 or len(right) > 0: if len(left) > 0 and len(r...
# One can use pretty unicode characters here ('\u25EF', '\u2A09'), if their terminal emulator supports it PLAYER_TOKENS = ('O', 'X') TOKEN_EMPTY = '-' VALID_TOKENS = PLAYER_TOKENS + tuple(TOKEN_EMPTY)
player_tokens = ('O', 'X') token_empty = '-' valid_tokens = PLAYER_TOKENS + tuple(TOKEN_EMPTY)
num = 253 total = 0 while(num != 0): rem = num % 10 total = total + rem num = num // 10 print("Sum of number's digit:", total)
num = 253 total = 0 while num != 0: rem = num % 10 total = total + rem num = num // 10 print("Sum of number's digit:", total)
def run_xnli(model): pass
def run_xnli(model): pass
# Challenge 2.3 # Favourite Team # ================= games = ["Manchester Utd v Liverpool", "Liverpool v Southampton", "Liverpool v Stoke", "Chelsea v Liverpool"]
games = ['Manchester Utd v Liverpool', 'Liverpool v Southampton', 'Liverpool v Stoke', 'Chelsea v Liverpool']
HOST = "Enter your host details" USERNAME ="Enter your username" PASSWORD="Enter your password" #PASSWORD="" PORT = 22 TIMEOUT = 10 PKEY = "Enter your key filename here" #Sample commands to execute(Add your commands here) COMMANDS = ['ls;mkdir sample']
host = 'Enter your host details' username = 'Enter your username' password = 'Enter your password' port = 22 timeout = 10 pkey = 'Enter your key filename here' commands = ['ls;mkdir sample']
# # PySNMP MIB module CISCO-WAN-ANNOUNCEMENT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-WAN-ANNOUNCEMENT-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:18:45 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version ...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_union, single_value_constraint, constraints_intersection, value_size_constraint) ...
a = input('Enter a: ') b = input('Enter b: ') if a > b: a = int(a) b = int(b) while a <= b: print(a) a += 1 else: a = int(a) b = int(b) while b <= a: print(b) b += 1
a = input('Enter a: ') b = input('Enter b: ') if a > b: a = int(a) b = int(b) while a <= b: print(a) a += 1 else: a = int(a) b = int(b) while b <= a: print(b) b += 1
def Insertion_Sort_Recursive(arr, p, q): if(p==q): return Insertion_Sort_Recursive(arr, p, q-1) last = arr[q] j = q-1 while(j>=0 and arr[j] > last): arr[j+1] = arr[j] j = j-1 arr[j+1] = last array = [3, 6, 1, 7, 8, 2, 5, 4, 0, 9] Insertion_Sort_Recursive(array, 0, len(array)-1) print(array)
def insertion__sort__recursive(arr, p, q): if p == q: return insertion__sort__recursive(arr, p, q - 1) last = arr[q] j = q - 1 while j >= 0 and arr[j] > last: arr[j + 1] = arr[j] j = j - 1 arr[j + 1] = last array = [3, 6, 1, 7, 8, 2, 5, 4, 0, 9] insertion__sort__recursive...
__all__ = ['XsecRecord'] class XsecRecord: """:class:`XsecRecord` implements the same-named ARTS datatype. Contains the reference cross section data at low pressure and the coefficients for the broadening formula. """ def __init__(self, species=None, coeffs=None, fmin=None, fmax=None, ...
__all__ = ['XsecRecord'] class Xsecrecord: """:class:`XsecRecord` implements the same-named ARTS datatype. Contains the reference cross section data at low pressure and the coefficients for the broadening formula. """ def __init__(self, species=None, coeffs=None, fmin=None, fmax=None, refpressure...
cells_conv_areas = [prop.convex_area for prop in properties] cells_orientation = [prop.orientation for prop in properties] print('Convex areas: {}'.format(cells_conv_areas)) print('Orientation: {}'.format(cells_orientation))
cells_conv_areas = [prop.convex_area for prop in properties] cells_orientation = [prop.orientation for prop in properties] print('Convex areas: {}'.format(cells_conv_areas)) print('Orientation: {}'.format(cells_orientation))
def part1(lines): x, y = 0, 0 for line in lines: movement, amount = line.split(' ') if movement == 'forward': x += int(amount) elif movement == 'down': y += int(amount) else: y -= int(amount) print(x * y) def part2(lines): x, y, aim =...
def part1(lines): (x, y) = (0, 0) for line in lines: (movement, amount) = line.split(' ') if movement == 'forward': x += int(amount) elif movement == 'down': y += int(amount) else: y -= int(amount) print(x * y) def part2(lines): (x, y,...
SUCCESS = 0 ERROR = 1 UNKNOWN_ERROR = 2 VIRTUALENV_NOT_FOUND = 3 PREVIOUS_BUILD_DIR_ERROR = 4 NO_MATCHES_FOUND = 23
success = 0 error = 1 unknown_error = 2 virtualenv_not_found = 3 previous_build_dir_error = 4 no_matches_found = 23
df_train = pd.get_dummies(df_train, columns=['Initial'], prefix='Initial') df_test = pd.get_dummies(df_test, columns=['Initial'], prefix='Initial') df_train.head() df_train = pd.get_dummies(df_train, columns=['Embarked'], prefix='Embarked') df_test = pd.get_dummies(df_test, columns=['Embarked'], prefix='Embarked')
df_train = pd.get_dummies(df_train, columns=['Initial'], prefix='Initial') df_test = pd.get_dummies(df_test, columns=['Initial'], prefix='Initial') df_train.head() df_train = pd.get_dummies(df_train, columns=['Embarked'], prefix='Embarked') df_test = pd.get_dummies(df_test, columns=['Embarked'], prefix='Embarked')
install_dependencies = ''' #!/bin/bash [COMMANDS] '''.strip()
install_dependencies = '\n#!/bin/bash\n\n[COMMANDS]\n'.strip()
MONGODB_DB = 'mongomail' MONGODB_HOST = 'localhost' MONGODB_PORT = 27017 MONGODB_USER = None MONGODB_PASSWORD = None MAIL_HOST = "0.0.0.0" MAIL_PORT = 8025 DEBUG = False
mongodb_db = 'mongomail' mongodb_host = 'localhost' mongodb_port = 27017 mongodb_user = None mongodb_password = None mail_host = '0.0.0.0' mail_port = 8025 debug = False
#import pprint class Node(): def __init__(self): self.name = None # node name self.data = None # data string self.attribute = None # attribute dictionary self.child = None # child node list self.parent = None # parent node self.is_contain = None # boolean, tag contai...
class Node: def __init__(self): self.name = None self.data = None self.attribute = None self.child = None self.parent = None self.is_contain = None self.open_tag_scope = None self.close_tag_scope = None self.data_scope = None self.is_t...
def read_each(): with open('input.txt') as fh: for line in fh.readlines(): policy, pwd = line.split(':') yield policy.strip(), pwd.strip() def validate(policy, pwd): rng, req_char = policy.split() pos1, pos2 = rng.split('-') pos1 = int(pos1)-1 pos2 = int(pos2)-1 ...
def read_each(): with open('input.txt') as fh: for line in fh.readlines(): (policy, pwd) = line.split(':') yield (policy.strip(), pwd.strip()) def validate(policy, pwd): (rng, req_char) = policy.split() (pos1, pos2) = rng.split('-') pos1 = int(pos1) - 1 pos2 = int(po...
# 34. Find First and Last Position of Element in Sorted Array # Runtime: 93 ms, faster than 27.31% of Python3 online submissions for Find First and Last Position of Element in Sorted Array. # Memory Usage: 15.6 MB, less than 12.09% of Python3 online submissions for Find First and Last Position of Element in Sorted Ar...
class Solution: def search_range(self, nums: list[int], target: int) -> list[int]: def find_left_bound() -> int: (begin, end) = (0, len(nums)) while begin < end: mid = begin + (end - begin) // 2 if nums[mid] == target: end = mid ...
''' In a array A of size 2N, there are N+1 unique elements, and exactly one of these elements is repeated N times. Return the element repeated N times. Example 1: Input: [1,2,3,3] Output: 3 Example 2: Input: [2,1,2,5,3,2] Output: 2 Example 3: Input: [5,1,5,2,5,3,5,4] Output: 5 Note: 4 <= A.length <= 10000 0...
""" In a array A of size 2N, there are N+1 unique elements, and exactly one of these elements is repeated N times. Return the element repeated N times. Example 1: Input: [1,2,3,3] Output: 3 Example 2: Input: [2,1,2,5,3,2] Output: 2 Example 3: Input: [5,1,5,2,5,3,5,4] Output: 5 Note: 4 <= A.length <= 10000 0...
QUALITY = 50 STOPSTREAM = -1 FRAMEMISS = -2 TRACKMISS = -3 COLLECT_TIMESTEP = 0.01 DEC_TIMESTEP = 0.01 DIST_TIMESTEP = 0.01 ENC_TIMESTEP = 0.01 PUB_TIMESTEP = 0.01 SUB_TIMESTEP = 0.01 REQ_TIMESTEP = 0.03 COLLECT_HWM = 3 DEC_HWM = 3 ENC_HWM = 3 DIST_HWM = 3 PUB_HWM = 3 SUB_HWM = 3 REQ_HWM = 3
quality = 50 stopstream = -1 framemiss = -2 trackmiss = -3 collect_timestep = 0.01 dec_timestep = 0.01 dist_timestep = 0.01 enc_timestep = 0.01 pub_timestep = 0.01 sub_timestep = 0.01 req_timestep = 0.03 collect_hwm = 3 dec_hwm = 3 enc_hwm = 3 dist_hwm = 3 pub_hwm = 3 sub_hwm = 3 req_hwm = 3
plotSize =1 # MARE for regressors, accuracy for classifiers lrCurve = 0
plot_size = 1 lr_curve = 0
# from functools import lru_cache class Solution: def climbStairs(self, n: int) -> int: if n == 1: return 1 prev = 1 cur = 2 for i in range(2, n): cur, prev = cur + prev, cur return cur
class Solution: def climb_stairs(self, n: int) -> int: if n == 1: return 1 prev = 1 cur = 2 for i in range(2, n): (cur, prev) = (cur + prev, cur) return cur
# # Copyright (c) 2017 Joy Diamond. All rights reserved. # if __name__ == '__main__': def gem(module_name): def execute(f): return f() return execute @gem('Ivory.Boot') def gem(): PythonSystem = __import__('sys') is_python_2 = PythonSystem.version_info.ma...
if __name__ == '__main__': def gem(module_name): def execute(f): return f() return execute @gem('Ivory.Boot') def gem(): python_system = __import__('sys') is_python_2 = PythonSystem.version_info.major is 2 is_python_3 = PythonSystem.version_info.major i...
class User: def __init__(self, id, name, birthday, description, genderId, prefectureId, imageName, hobby, favoriteType): self.id = id self.name = name self.birthday = birthday self.description = description self.genderId = genderId self.prefectureId = prefectureId ...
class User: def __init__(self, id, name, birthday, description, genderId, prefectureId, imageName, hobby, favoriteType): self.id = id self.name = name self.birthday = birthday self.description = description self.genderId = genderId self.prefectureId = prefectureId ...
# List of Basic configurations #Login Configs clientID='JL53WY5Cw2WK8g' clientSecret='fKqCZ44PIIFdqOjemTIKab0BfEs' agent='popularWordBot Script' username='popularWordBot' #Action Considerations #targetSub = ['testabot','australia'] #consider making this a list targetSub = ['brisbane','melbourne','austr...
client_id = 'JL53WY5Cw2WK8g' client_secret = 'fKqCZ44PIIFdqOjemTIKab0BfEs' agent = 'popularWordBot Script' username = 'popularWordBot' target_sub = ['brisbane', 'melbourne', 'australia', 'sydney', 'perth', 'tasmania', 'Adelaide'] limit = 25 clean_up = True
# -*- coding: utf-8 -*- """ Bombolone ~~~~~~~~~~~~~~~~~~~~~ Bombolone is a tasty Content Management System for Python based on Flask, MongoDB, AngularJS, Sass and Bootstrap. It's designed to be a simple, flexible toolset for projects of any size. :copyright: (c) 2014 by @zizzamia :license: BSD (See LICENSE for deta...
""" Bombolone ~~~~~~~~~~~~~~~~~~~~~ Bombolone is a tasty Content Management System for Python based on Flask, MongoDB, AngularJS, Sass and Bootstrap. It's designed to be a simple, flexible toolset for projects of any size. :copyright: (c) 2014 by @zizzamia :license: BSD (See LICENSE for details) """ __title__ = 'bo...
class RobustGridRouter(object): """ A router to control all database operations on models in the grid_core application. """ def db_for_read(self, model, **hints): """ Attempts to read grid_core models go to robust_grid. """ if model._meta.app_label == 'grid_core': ...
class Robustgridrouter(object): """ A router to control all database operations on models in the grid_core application. """ def db_for_read(self, model, **hints): """ Attempts to read grid_core models go to robust_grid. """ if model._meta.app_label == 'grid_core': ...
DATABASES = { 'default': { 'NAME': 'ietf_utf8', 'ENGINE': 'django.db.backends.mysql', 'USER': 'matheuspfitscher', 'PASSWORD': 'ietf', # Contact henrik@levkowetz.com to get the password 'HOST': '127.0.0.1' }, 'datatracker': { 'NAME': 'ietf_utf8', 'ENGI...
databases = {'default': {'NAME': 'ietf_utf8', 'ENGINE': 'django.db.backends.mysql', 'USER': 'matheuspfitscher', 'PASSWORD': 'ietf', 'HOST': '127.0.0.1'}, 'datatracker': {'NAME': 'ietf_utf8', 'ENGINE': 'django.db.backends.mysql', 'USER': 'matheuspfitscher', 'PASSWORD': 'ietf', 'HOST': '127.0.0.1'}} database_routers = ['...
#%% msg = "Hello world" print(msg) #%% msg2 = "Hello world" print(msg2) # %%
msg = 'Hello world' print(msg) msg2 = 'Hello world' print(msg2)
class Two_Dimensional_Matrix: def isValidSize(self): for i in range(1, self.m): if (self.n != len(self.matrix[i])): return False return True # def isValidType(self, expectedType=int): # for i in range(len(self.matrix)): # for j in rang...
class Two_Dimensional_Matrix: def is_valid_size(self): for i in range(1, self.m): if self.n != len(self.matrix[i]): return False return True def __init__(self, matrix): self.matrix = matrix self.n = len([row for row in matrix]) self.m = len([...
""" Make a program that reads tha name of a city from california, and returns: 1-if its starts or not with 'san'. 2-if its has of not san in any part of name. """ city = str(input('Enter a city of California:\n')).strip().title() city = city.split() print('Does this city name begin with San?\n','San' in city[0]) prin...
""" Make a program that reads tha name of a city from california, and returns: 1-if its starts or not with 'san'. 2-if its has of not san in any part of name. """ city = str(input('Enter a city of California:\n')).strip().title() city = city.split() print('Does this city name begin with San?\n', 'San' in city[0]) print...
class Solution: def XXX(self, height: [int]) -> int: area = 0 y = len(height)-1 x = 0 while x != y: a = min(height[y],height[x]) * abs(x-y) if a > area: area = a if height[x] < height[y]: x += 1 else: ...
class Solution: def xxx(self, height: [int]) -> int: area = 0 y = len(height) - 1 x = 0 while x != y: a = min(height[y], height[x]) * abs(x - y) if a > area: area = a if height[x] < height[y]: x += 1 els...
""" .. module:: dj-stripe.contrib. :synopsis: Extra modules not pertaining to core logic of dj-stripe. """
""" .. module:: dj-stripe.contrib. :synopsis: Extra modules not pertaining to core logic of dj-stripe. """
def insertion_sort_general(arr): if not arr: return arr size = len(arr) for i in range(size): for j in range(i + 1, size): while i < j: if arr[j] < arr[j - 1]: arr[j], arr[j - 1] = arr[j - 1], arr[j] j -= 1 return arr arr ...
def insertion_sort_general(arr): if not arr: return arr size = len(arr) for i in range(size): for j in range(i + 1, size): while i < j: if arr[j] < arr[j - 1]: (arr[j], arr[j - 1]) = (arr[j - 1], arr[j]) j -= 1 return arr ar...
phone_to_id = { "n": 0, "s": 1, "ER": 2, "iong": 3, "AE": 4, "HH": 5, "h": 6, "S": 7, "JH": 8, "AY": 9, "W": 10, "DH": 11, "SH": 12, "5": 13, "4": 14, "t": 15, "AA": 16, "c": 17, "EY": 18, "j": 19, "ian": 20, "x": 21, "uan": 22,...
phone_to_id = {'n': 0, 's': 1, 'ER': 2, 'iong': 3, 'AE': 4, 'HH': 5, 'h': 6, 'S': 7, 'JH': 8, 'AY': 9, 'W': 10, 'DH': 11, 'SH': 12, '5': 13, '4': 14, 't': 15, 'AA': 16, 'c': 17, 'EY': 18, 'j': 19, 'ian': 20, 'x': 21, 'uan': 22, 'ou': 23, 'T': 24, 'l': 25, 'UH': 26, '6': 27, 'D': 28, '#3': 29, 'e': 30, 'sh': 31, '#0': 3...
def double(val): return val + val print(double(3)) print(double(3.3)) print(double('3'))
def double(val): return val + val print(double(3)) print(double(3.3)) print(double('3'))
def prim(n, adj): total_weight = 0 selected, min_e = [False] * n, [[float('inf'), -1] for _ in range(n)] mst_edges = [] min_e[0][0] = 0 for i in range(n): v = -1 for j in range(n): if (not selected[j]) and ((v == -1) or (min_e[j][0] < min_e[v][0])): v =...
def prim(n, adj): total_weight = 0 (selected, min_e) = ([False] * n, [[float('inf'), -1] for _ in range(n)]) mst_edges = [] min_e[0][0] = 0 for i in range(n): v = -1 for j in range(n): if not selected[j] and (v == -1 or min_e[j][0] < min_e[v][0]): v = j ...