content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
USER_AGENTS = [ ( 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko)' ' Chrome/39.0.2171.95 Safari/537.36' ), ( 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)' ' Chrome/42.0.2311.135 Safari/537.36 Edge/12...
user_agents = ['Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246']
def main(): print("Hello World!") test() pozdrav() def test(): print("This is a test") def pozdrav(): print("Hello") if __name__ == '__main__': main()
def main(): print('Hello World!') test() pozdrav() def test(): print('This is a test') def pozdrav(): print('Hello') if __name__ == '__main__': main()
class Empty: def __init__(self, *args, **kwargs): pass def __repr__(self): return "Empty" def __str__(self): return "Empty"
class Empty: def __init__(self, *args, **kwargs): pass def __repr__(self): return 'Empty' def __str__(self): return 'Empty'
class SplitterCancelEventArgs(CancelEventArgs): """ Provides data for splitter events. SplitterCancelEventArgs(mouseCursorX: int,mouseCursorY: int,splitX: int,splitY: int) """ @staticmethod def __new__(self,mouseCursorX,mouseCursorY,splitX,splitY): """ __new__(cls: type,mouseCursorX: int,mouseCurs...
class Splittercanceleventargs(CancelEventArgs): """ Provides data for splitter events. SplitterCancelEventArgs(mouseCursorX: int,mouseCursorY: int,splitX: int,splitY: int) """ @staticmethod def __new__(self, mouseCursorX, mouseCursorY, splitX, splitY): """ __new__(cls: type,mouseCursorX: int...
# -*- coding: utf-8 -*- class drone: def __init__(self, location, maximum_load): self.location = location self.maximum_load = maximum_load productsOnBoard = list() self.state = 0 self.alarm = 0 self.isBusy = False def Load(self, warehouse, product): if...
class Drone: def __init__(self, location, maximum_load): self.location = location self.maximum_load = maximum_load products_on_board = list() self.state = 0 self.alarm = 0 self.isBusy = False def load(self, warehouse, product): if warehouse.take(product)...
class CTF: def __init__(self, channel_id, name, long_name): """ An object representation of an ongoing CTF. channel_id : The slack id for the associated channel name : The name of the CTF """ self.channel_id = channel_id self.name = name self.challen...
class Ctf: def __init__(self, channel_id, name, long_name): """ An object representation of an ongoing CTF. channel_id : The slack id for the associated channel name : The name of the CTF """ self.channel_id = channel_id self.name = name self.challeng...
# date: 09/07/2020 # Description: # Given a string, we want to remove 2 adjacent characters that are the same, # and repeat the process with the new string until we can no longer perform the operation. def remove_adjacent_dup(s): finished = False index = 0 while not finished: if s[index+1]=...
def remove_adjacent_dup(s): finished = False index = 0 while not finished: if s[index + 1] == s[index]: s = s.replace(s[index + 1], '') index = 0 else: index += 1 if index + 1 > len(s) - 1: finished = True return s print(remove_adja...
wtf = list(range(1000)) for i in range(len(wtf)): wtf[i] = 2 print(wtf)
wtf = list(range(1000)) for i in range(len(wtf)): wtf[i] = 2 print(wtf)
#!/usr/bin/env python3 ######################################################################## # # # Program purpose: Program to check the priority of the four # # operators (+, -, *, /) # # ...
__operators__ = '+-/*' __parenthesis__ = '()' __priority__ = {'+': 0, '-': 0, '*': 1, '/': 1} def test_higher_priority(operatorA, operatorB): return __priority__[operatorA] >= __priority__[operatorB] if __name__ == '__main__': print(test_higher_priority('*', '-')) print(test_higher_priority('+', '-')) ...
par = [] impar = [] cont = 0 im = 0 p = 0 while cont < 15: num = int(input()) if num % 2 == 0: par.append(num) p += 1 else: impar.append(num) im += 1 if p > 4: for i in range(5): print(f'par[{i}] = {par[i]}') par = [] p = 0 if im > ...
par = [] impar = [] cont = 0 im = 0 p = 0 while cont < 15: num = int(input()) if num % 2 == 0: par.append(num) p += 1 else: impar.append(num) im += 1 if p > 4: for i in range(5): print(f'par[{i}] = {par[i]}') par = [] p = 0 if im > ...
#================================================================================================== # python_scripts/set_state.py # modified from - https://community.home-assistant.io/t/how-to-manually-set-state-value-of-sensor/43975/37 #===============================================================================...
input_entity = data.get('entity_id') if inputEntity is None: logger.warning('===== entity_id is required if you want to set something.') else: input_state_object = hass.states.get(inputEntity) if inputStateObject is None and (not data.get('allow_create')): logger.warning('===== unknown entity_id: %s...
string1 = "Devops" string2 = "Project" joined_string = string1 +' '+ string2 ## Add space between two strings print(joined_string)
string1 = 'Devops' string2 = 'Project' joined_string = string1 + ' ' + string2 print(joined_string)
num = 2 ** 1000 num = list(str(num)) total = 0 for i in num: total += int(i) print(total)
num = 2 ** 1000 num = list(str(num)) total = 0 for i in num: total += int(i) print(total)
#desafio 25: procurando uma string dentro de outra // verifica se o nome tem SILVA nome = str(input('Digite seu nome completo: ')).strip().upper() print('^'*30) print(f'\33[34mSeu nome tem Silva? {"SILVA" in nome}\33[m') print('^'*30)
nome = str(input('Digite seu nome completo: ')).strip().upper() print('^' * 30) print(f"\x1b[34mSeu nome tem Silva? {'SILVA' in nome}\x1b[m") print('^' * 30)
# part one lines = open('input.txt', 'r').readlines() gammaRate = "" for pos in range(len(lines[0].strip())): oneCount = len([p for p in lines if p[pos] == "1"]) gammaRate += "1" if 2 * oneCount > len(lines) else "0" print(int(gammaRate, 2) * int(gammaRate.replace("1", "#").replace("0", "1").replace("#", "0"),...
lines = open('input.txt', 'r').readlines() gamma_rate = '' for pos in range(len(lines[0].strip())): one_count = len([p for p in lines if p[pos] == '1']) gamma_rate += '1' if 2 * oneCount > len(lines) else '0' print(int(gammaRate, 2) * int(gammaRate.replace('1', '#').replace('0', '1').replace('#', '0'), 2)) oxyg...
def network(): model = tf.keras.Sequential() model.add(kl.InputLayer(input_shape=(224, 224, 3))) # First conv block model.add(kl.Conv2D(filters=96, kernel_size=7, padding='same', strides=2)) model.add(tf.keras.layers.ReLU()) model.add(kl.MaxPooling2D(pool_size=(3, 3))) # Second conv block ...
def network(): model = tf.keras.Sequential() model.add(kl.InputLayer(input_shape=(224, 224, 3))) model.add(kl.Conv2D(filters=96, kernel_size=7, padding='same', strides=2)) model.add(tf.keras.layers.ReLU()) model.add(kl.MaxPooling2D(pool_size=(3, 3))) model.add(kl.Conv2D(filters=256, kernel_size=...
""" You are given a binary tree. Write a function that can return the inorder traversal of node values. Example: Input: 3 \ 1 / 5 Output: [3,5,1] """ # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left =...
""" You are given a binary tree. Write a function that can return the inorder traversal of node values. Example: Input: 3 1 / 5 Output: [3,5,1] """ class Treenode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right 'itera...
src = [] component = aos_component('osal', src) component.add_global_includes('mico/include', 'include') component.add_comp_deps("middleware/alink/cloud") if aos_global_config.arch == 'ARM968E-S': component.add_cflags('-marm') @pre_config('osal') def osal_pre(comp): osal = aos_global_config.get('osal', 'rhin...
src = [] component = aos_component('osal', src) component.add_global_includes('mico/include', 'include') component.add_comp_deps('middleware/alink/cloud') if aos_global_config.arch == 'ARM968E-S': component.add_cflags('-marm') @pre_config('osal') def osal_pre(comp): osal = aos_global_config.get('osal', 'rhino'...
# # PySNMP MIB module TRAPEZE-NETWORKS-BASIC-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TRAPEZE-NETWORKS-BASIC-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:27:11 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version ...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, value_size_constraint, constraints_intersection, constraints_union) ...
class TextVectorizationResponse: """ Stores the BOW-encodings and (padded or aggregated e.g. averaged) embeddings for text. """ def __init__(self, tokens_bow_encoded, tokens_aggregated_embedding, tokens_embeddings_padded): self.tokens_bow_encoded = tokens_bow_encoded self.tokens_aggrega...
class Textvectorizationresponse: """ Stores the BOW-encodings and (padded or aggregated e.g. averaged) embeddings for text. """ def __init__(self, tokens_bow_encoded, tokens_aggregated_embedding, tokens_embeddings_padded): self.tokens_bow_encoded = tokens_bow_encoded self.tokens_aggrega...
# date: 01/07/2020 # Description: # A Perfect Number is a positive integer # that is equal to the sum of all its # positive divisors except itself. class Solution(object): def checkPerfectNumber(self, num): if num <= 0: return False,[] divisors = [] for i in range(1,...
class Solution(object): def check_perfect_number(self, num): if num <= 0: return (False, []) divisors = [] for i in range(1, num): if num % i == 0: divisors.append(i) total = 0 for i in divisors: total += i if total...
# GCD def gcd(a, b): while(b != 0): t = a a = b b = t % b return a def main(): print(gcd(60, 96)) print(gcd(20, 8)) if __name__ == "__main__": main()
def gcd(a, b): while b != 0: t = a a = b b = t % b return a def main(): print(gcd(60, 96)) print(gcd(20, 8)) if __name__ == '__main__': main()
n=input() r=0 for i in range(1, 2**9+1): r+=(int(bin(i)[2:]) <= int(n)) print(r)
n = input() r = 0 for i in range(1, 2 ** 9 + 1): r += int(bin(i)[2:]) <= int(n) print(r)
def run(coro): try: coro.send(None) except StopIteration as e: return e.value async def coro(): print('coro') class AContextManager(): async def __aenter__(self): print('Entering') await coro() return self async def __aexit__(self, ty, val, tb): pri...
def run(coro): try: coro.send(None) except StopIteration as e: return e.value async def coro(): print('coro') class Acontextmanager: async def __aenter__(self): print('Entering') await coro() return self async def __aexit__(self, ty, val, tb): prin...
#!/usr/bin/env python with open("my_new_file.txt", "a") as f: f.write('something else\n')
with open('my_new_file.txt', 'a') as f: f.write('something else\n')
""" Created on Mar 2, 2012 @author: Alex Hansen """ parse_line = "13C - Pure In-phase Carbon CEST" description = """\ Analyzes 13C chemical exchange in the presence of 1H composite decoupling during the CEST block. This keeps the spin system purely in-phase throughout, and is calculated using the 6x6, single spin m...
""" Created on Mar 2, 2012 @author: Alex Hansen """ parse_line = '13C - Pure In-phase Carbon CEST' description = 'Analyzes 13C chemical exchange in the presence of 1H composite decoupling during\nthe CEST block. This keeps the spin system purely in-phase throughout, and is \ncalculated using the 6x6, single spin matri...
# Copyright Rein Halbersma 2018-2021. # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) # http://forum.stratego.com/topic/357378-strategy-question-findingavoiding-bombs-at-the-end-of-games/?p=432...
print('TODO: implement first move statistics')
class TreeNode: def __init__(self, data, left=None, right=None): self.data = data self.left = left self.right = right def __str__(self): fmt = 'TreeNode(data={}, left={}, right={})' return fmt.format(self.data, self.left, self.right) class BinarySearchTree: def _...
class Treenode: def __init__(self, data, left=None, right=None): self.data = data self.left = left self.right = right def __str__(self): fmt = 'TreeNode(data={}, left={}, right={})' return fmt.format(self.data, self.left, self.right) class Binarysearchtree: def __...
##CONFIG## ##Leave it for blank if you don't want to include data from that source #Ether addresses that you'd like to watch. Input them as a list if there're more than one address. #E.g.: addresses = ['0xad2a6d5890c06083c340d723053b4040a28580ef', '0x214d0bb2b260b22b1498977200c1a32bdb75131b'] addresses = [] #Get thi...
addresses = [] bittrex_apikey = '' bittrex_apisecret = b'' poloniex_apikey = '' poloniex_apisecret = b'' bitfinex_apikey = '' bitfinex_apisecret = b'' bigone_apikey = '' other_bl = {}
potential_list = [[1,1],[1,0],[-1,0],[0,-1],[-3,1]] print(potential_list) for item1,item2 in potential_list: if item2 <= 0: potential_list.remove([item1,item2]) for item1,item2 in potential_list: if item1 <= 0: potential_list.remove([item1,item2]) print(potential_list)
potential_list = [[1, 1], [1, 0], [-1, 0], [0, -1], [-3, 1]] print(potential_list) for (item1, item2) in potential_list: if item2 <= 0: potential_list.remove([item1, item2]) for (item1, item2) in potential_list: if item1 <= 0: potential_list.remove([item1, item2]) print(potential_list)
#!/usr/bin/env python # -*- coding: utf-8 -*- # File: __init__.py # ------------------- # Divine Oasis # Text Based RPG Game # By wsngamerz # ------------------- __author__ = "wsngamerz" __version__ = "0.0.1 ALPHA 1"
__author__ = 'wsngamerz' __version__ = '0.0.1 ALPHA 1'
# -*- coding:utf-8 -*- # https://leetcode.com/problems/minimum-window-substring/description/ class Solution(object): def minWindow(self, s, t): """ :type s: str :type t: str :rtype: str """ wi, wj = None, None ds, dt = {}, {} for c in t: d...
class Solution(object): def min_window(self, s, t): """ :type s: str :type t: str :rtype: str """ (wi, wj) = (None, None) (ds, dt) = ({}, {}) for c in t: (ds[c], dt[c]) = (0, dt.get(c, 0) + 1) (count, i) = (0, 0) for (j, c)...
print(1,2,3)
print(1, 2, 3)
geo, par, val,override = IN setPreviously = False try: tags = geo.Tags if tags.LookupTag(par) is None or override: tags.AddTag(par, val) except ValueError: setPreviously = True OUT = IN[0], setPreviously
(geo, par, val, override) = IN set_previously = False try: tags = geo.Tags if tags.LookupTag(par) is None or override: tags.AddTag(par, val) except ValueError: set_previously = True out = (IN[0], setPreviously)
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: # def bstFromPreorder(self, preorder): # if not preorder: # return None # preorder.sort() # root = self.generator(1, preorder) # return root...
class Treenode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def bst_from_preorder(self, preorder): if not preorder: return None inorder = sorted(preorder) def generator(preorder, inorder): if n...
def sum_mul(n, m): sumu = 0 if n > 0 and m > 0: for i in range(n, m): if (i % n == 0): sumu += i else: return 'INVALID' return sumu
def sum_mul(n, m): sumu = 0 if n > 0 and m > 0: for i in range(n, m): if i % n == 0: sumu += i else: return 'INVALID' return sumu
string = 'some text' print(string) print(id(string)) print('Run fuction, then print string and it\'s id again without using the function') def changeString(): string = 'changed' print(string) print(id(string)) changeString() print(string) print(id(string)) print('(Redeclaring function)') print('Run fuctio...
string = 'some text' print(string) print(id(string)) print("Run fuction, then print string and it's id again without using the function") def change_string(): string = 'changed' print(string) print(id(string)) change_string() print(string) print(id(string)) print('(Redeclaring function)') print("Run fuctio...
for letter in 'Python': if letter == 'h': pass print("This is Pass Block") print("Current letter", letter) print("Good Job")
for letter in 'Python': if letter == 'h': pass print('This is Pass Block') print('Current letter', letter) print('Good Job')
# https://leetcode.com/explore/challenge/card/august-leetcoding-challenge/551/week-3-august-15th-august-21st/3430/ ''' 13 / 13 test cases passed. Status: Accepted Runtime: 108 ms Memory Usage: 23.3 MB Your runtime beats 50.00 % of python3 submissions. Your memory usage beats 28.30 % of python3 submis...
""" 13 / 13 test cases passed. Status: Accepted Runtime: 108 ms Memory Usage: 23.3 MB Your runtime beats 50.00 % of python3 submissions. Your memory usage beats 28.30 % of python3 submissions. """ class Solution: def reorder_list(self, head: ListNode) -> None: """ Do not return ...
### building a more advance calculator with python num1 = float(input("Enter first number: ")) op = input("Enter operator: ") num2 = float(input("Enter second number: ")) if op == "+": print(num1 + num2) elif op == "-": print(num1 - num2) elif op == "*": print(num1 * num2) elif op == "/": ...
num1 = float(input('Enter first number: ')) op = input('Enter operator: ') num2 = float(input('Enter second number: ')) if op == '+': print(num1 + num2) elif op == '-': print(num1 - num2) elif op == '*': print(num1 * num2) elif op == '/': print(num1 / num2) else: print('invalid operation')
# link: https://leetcode.com/problems/find-all-the-lonely-nodes/ # find all lonely nodes # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution(object): d...
class Solution(object): def get_lonely_nodes(self, root): """ :type root: TreeNode :rtype: List[int] """ if not root.left and (not root.right): return [] result = [] return self.dfs(root, result) def dfs(self, root, result): if not ro...
print("FINDING ROOTS OF A QUADRATIC EQUATION\n\n") print("Any general quadratic equation will be of the form 'ax^2+bx+c=0', \ntherefore state values...") a=int(input("\tcoefficient of x^2, a= ")) b=int(input("\tcoefficient of x, b= ")) c=int(input("\tconstant, c= ")) x=(b**2)-4*a*c if(x==0): print("\nThe roo...
print('FINDING ROOTS OF A QUADRATIC EQUATION\n\n') print("Any general quadratic equation will be of the form 'ax^2+bx+c=0', \ntherefore state values...") a = int(input('\tcoefficient of x^2, a= ')) b = int(input('\tcoefficient of x, b= ')) c = int(input('\tconstant, c= ')) x = b ** 2 - 4 * a * c if x == 0: print('\...
dysk = set() with open( r"D:\_MACIEK_\python_proby\skany_fabianki\lista_P.txt", "r" ) as listadysk: for line in listadysk: dysk.add(line) with open( r"D:\_MACIEK_\python_proby\skany_fabianki\lista_dysk.txt", "r" ) as listaP: for line in listaP: if line not in dysk: with ope...
dysk = set() with open('D:\\_MACIEK_\\python_proby\\skany_fabianki\\lista_P.txt', 'r') as listadysk: for line in listadysk: dysk.add(line) with open('D:\\_MACIEK_\\python_proby\\skany_fabianki\\lista_dysk.txt', 'r') as lista_p: for line in listaP: if line not in dysk: with open('D:\\...
# initial configurations PORT=33000 HOST="0.0.0.0"
port = 33000 host = '0.0.0.0'
# # PySNMP MIB module NAI-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NAI-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:22:50 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)...
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_size_constraint, constraints_union, constraints_intersection, value_range_constraint) ...
# Checking if a binary tree is a perfect binary tree in Python class newNode: def __init__(self, k): self.key = k self.right = self.left = None # Calculate the depth def calculateDepth(node): d = 0 while node is not None: d += 1 node = node.left return ...
class Newnode: def __init__(self, k): self.key = k self.right = self.left = None def calculate_depth(node): d = 0 while node is not None: d += 1 node = node.left return d def is_perfect(root, d, level=0): if root is None: return True if root.left is Non...
def set_salestax(request, tax_type, tax_total): """ Stores the tax type and total in the session. """ request.session["tax_type"] = tax_type request.session["tax_total"] = tax_total
def set_salestax(request, tax_type, tax_total): """ Stores the tax type and total in the session. """ request.session['tax_type'] = tax_type request.session['tax_total'] = tax_total
# print("Please choose your option from the list below:") # print("1:\tLearn Python") # print("2:\tLearn Java") # print("3:\tGo swimming") # print("4:\tHave dinner") # print("5:\tGo to bed") # print("0:\tExit") choice = "-" while choice != "0": # while True: # choice = input() # if choice == "0": # bre...
choice = '-' while choice != '0': if choice in '12345': print('You chose {}'.format(choice)) else: print('Please choose your option from the list below:') print('1:\tLearn Python') print('2:\tLearn Java') print('3:\tGo swimming') print('4:\tHave dinner') p...
k = int(input()) chess = 'W' empty = '.' neighbour = [[0, -1], [0, 1], [1, 0], [-1, 0],[1,-1],[1,1],[-1,-1],[-1,1]] def dfs(r, c, area, visited): mianji = 1 visited[r][c] = 1 stack = [] stack.append([r, c]) while len(stack) != 0: x, y = stack.pop() for dx, dy in neighbour: ...
k = int(input()) chess = 'W' empty = '.' neighbour = [[0, -1], [0, 1], [1, 0], [-1, 0], [1, -1], [1, 1], [-1, -1], [-1, 1]] def dfs(r, c, area, visited): mianji = 1 visited[r][c] = 1 stack = [] stack.append([r, c]) while len(stack) != 0: (x, y) = stack.pop() for (dx, dy) in neighbou...
r_result_json = { 'result': [{ 'dst_is_ip': 'false', 'src_is_ip': 'true', 'dst_list': 'seclist:/Compute-587626604/mayurnath.gokare@oracle.com/paas/SOA/gc3ntagrogr605/lb/ora_otd_infraadmin', 'name': '/Compute-587626604/mayurnath.gokare@o...
r_result_json = {'result': [{'dst_is_ip': 'false', 'src_is_ip': 'true', 'dst_list': 'seclist:/Compute-587626604/mayurnath.gokare@oracle.com/paas/SOA/gc3ntagrogr605/lb/ora_otd_infraadmin', 'name': '/Compute-587626604/mayurnath.gokare@oracle.com/paas/SOA/gc3ntagrogr605/lb/sys_infra2otd_admin_ssh', 'src_list': 'seciplist:...
# SPDX-License-Identifier: MIT # Copyright (c) 2020 Akumatic # #https://adventofcode.com/2020/day/13 def readFile() -> tuple: with open(f"{__file__.rstrip('code.py')}input.txt", "r") as f: timestamp = int(f.readline().strip()) values = f.readline().strip().split(",") bus_ids = [{"value": in...
def read_file() -> tuple: with open(f"{__file__.rstrip('code.py')}input.txt", 'r') as f: timestamp = int(f.readline().strip()) values = f.readline().strip().split(',') bus_ids = [{'value': int(values[i]), 'index': i} for i in range(len(values)) if values[i] != 'x'] return (timestamp,...
class File: def __init__(self, code: str, name: str, ast): self.lines = code.splitlines() self.name = name self.ast = ast def line(self, number): return self.lines[number]
class File: def __init__(self, code: str, name: str, ast): self.lines = code.splitlines() self.name = name self.ast = ast def line(self, number): return self.lines[number]
""" Pharos.Model.laser._skeleton.py ================================== .. note:: **IMPORTANT** Whatever new function is implemented in a specific model, it should be first declared in the laserBase class. In this way the other models will have access to the method and the program will keep running...
""" Pharos.Model.laser._skeleton.py ================================== .. note:: **IMPORTANT** Whatever new function is implemented in a specific model, it should be first declared in the laserBase class. In this way the other models will have access to the method and the program will keep running ...
#!/usr/bin/env python3 def validate_iso8601(ts): """Check validity of a timestamp in ISO 8601 format.""" digits = [0, 1, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15, 17, 18, 20, 21, 22] try: assert len(ts) == 24 assert all([ts[i].isdigit() for i in digits]) assert int(ts[5:7]) <= 12 a...
def validate_iso8601(ts): """Check validity of a timestamp in ISO 8601 format.""" digits = [0, 1, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15, 17, 18, 20, 21, 22] try: assert len(ts) == 24 assert all([ts[i].isdigit() for i in digits]) assert int(ts[5:7]) <= 12 assert int(ts[8:10]) < 32 ...
class LogicStringUtil: @staticmethod def getBytes(string): return string.encode() @staticmethod def getByteLength(string): return len(string)
class Logicstringutil: @staticmethod def get_bytes(string): return string.encode() @staticmethod def get_byte_length(string): return len(string)
# MIT License # # Copyright (c) 2017 Changsung # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, pu...
class Basestrategy: """ class for strategy. write an algorithm in this class""" __signals = {} def __init__(self): pass def add_signals(self, key, signal): self.__signals[key] = signal signal.setStrategy(self) def get_signal(self, key): return self.__signals[key...
_a = request.application response.logo = A(B('KVASIR'), _class="brand") response.title = settings.title response.subtitle = settings.subtitle response.meta.author = '%s <%s>' % (settings.author, settings.author_email) response.meta.keywords = settings.keywords response.meta.description = settings.description response...
_a = request.application response.logo = a(b('KVASIR'), _class='brand') response.title = settings.title response.subtitle = settings.subtitle response.meta.author = '%s <%s>' % (settings.author, settings.author_email) response.meta.keywords = settings.keywords response.meta.description = settings.description response.m...
# -*- coding: utf_8 -*- __author__ = 'Yagg' class Bombing: def __init__(self, attackerName, defenderName, planetNum, planetName, population, industry, production, capitals, materials, colonists, attackStrength, status): self.attackerName = attackerName self.defenderName = defenderN...
__author__ = 'Yagg' class Bombing: def __init__(self, attackerName, defenderName, planetNum, planetName, population, industry, production, capitals, materials, colonists, attackStrength, status): self.attackerName = attackerName self.defenderName = defenderName self.planetNum = planetNum ...
def gcd(a, b): if b == 0: return a return gcd(b, a%b) for _ in range(int(input())): a, b = map(int, input().split()) print(gcd(a, b))
def gcd(a, b): if b == 0: return a return gcd(b, a % b) for _ in range(int(input())): (a, b) = map(int, input().split()) print(gcd(a, b))
''' Fixed arguments ''' def print_fib(a, b, c): print(a, b, c) print_fib(1, 1, 2) print_fib(1, 1, 2, 3) ''' Using *args ''' def print_fib(a, *args): print(a) print(args) print_fib(1, 1, 2, 3) print_fib(1) ''' Using **kwargs ''' def print_fib(a, **kwargs): print(a) print(kwargs) print_fib(1, s...
""" Fixed arguments """ def print_fib(a, b, c): print(a, b, c) print_fib(1, 1, 2) print_fib(1, 1, 2, 3) '\nUsing *args\n' def print_fib(a, *args): print(a) print(args) print_fib(1, 1, 2, 3) print_fib(1) '\nUsing **kwargs\n' def print_fib(a, **kwargs): print(a) print(kwargs) print_fib(1, se=1, th=...
s, t, n = map(int, input().split()) dList = input().split() bList = input().split() cList = input().split() Time = 0 for i in range(len(dList) - 1): Time += int(dList[i]) if Time % int(cList[i]) == 0: wait = abs(Time - int(cList[i])) - int(cList[i]) else: wait = abs(Time - int(cList[i])) ...
(s, t, n) = map(int, input().split()) d_list = input().split() b_list = input().split() c_list = input().split() time = 0 for i in range(len(dList) - 1): time += int(dList[i]) if Time % int(cList[i]) == 0: wait = abs(Time - int(cList[i])) - int(cList[i]) else: wait = abs(Time - int(cList[i])...
""" Pipeless / examples.py. MIT licensed. Basic functionality >>> from pipeless import pipeline >>> function, run, _ = pipeline(lambda item, e: None) >>> @function ... def up_one(_): return _+1 >>> list(run([0, 1, 3])) [1, 2, 4] >>> @function ... def twofer(_): ... yield _ ... yield _ >>> list(run([0, 1, 3])) ...
""" Pipeless / examples.py. MIT licensed. Basic functionality >>> from pipeless import pipeline >>> function, run, _ = pipeline(lambda item, e: None) >>> @function ... def up_one(_): return _+1 >>> list(run([0, 1, 3])) [1, 2, 4] >>> @function ... def twofer(_): ... yield _ ... yield _ >>> list(run([0, 1, 3])) ...
logic_registry = [] def logic(function): """A descriptor to tag a function as programmable logic, contianing migen commands.""" logic_registry.append(function) return function def is_logic(function): """Returns True if the given function was tagged using the ``@logic`` descriptor.""" return func...
logic_registry = [] def logic(function): """A descriptor to tag a function as programmable logic, contianing migen commands.""" logic_registry.append(function) return function def is_logic(function): """Returns True if the given function was tagged using the ``@logic`` descriptor.""" return functi...
n = int(input()) string = [] string = input().split(" ") string.sort() for i in range (0,n): print (string[i], end = " ")
n = int(input()) string = [] string = input().split(' ') string.sort() for i in range(0, n): print(string[i], end=' ')
class GlobalInfo: gui_thread = None main_window = None daemon_inst = None daemon_conn = None headless_plugin_manager = None
class Globalinfo: gui_thread = None main_window = None daemon_inst = None daemon_conn = None headless_plugin_manager = None
class MinimumBalanceAccount(BankAccount): def __init__(self, minimum_balance): BankAccount.__init__(self) self.minimum_balance = minimum_balance def withdraw(self, amount): if self.balance - amount < self.minimum_balance: print ('Sorry, minimum balance must be maintaine...
class Minimumbalanceaccount(BankAccount): def __init__(self, minimum_balance): BankAccount.__init__(self) self.minimum_balance = minimum_balance def withdraw(self, amount): if self.balance - amount < self.minimum_balance: print('Sorry, minimum balance must be maintained.') ...
class Solution: def divide(self, dividend: int, divisor: int) -> int: if (dividend == -2147483648 and divisor == -1): return 2147483647 ans = 1 nORp = 1 if (dividend > 0) == (divisor > 0) else -1 a , b = abs(dividend) , abs(divisor) if a < b : return 0 elif a == b: re...
class Solution: def divide(self, dividend: int, divisor: int) -> int: if dividend == -2147483648 and divisor == -1: return 2147483647 ans = 1 n_o_rp = 1 if (dividend > 0) == (divisor > 0) else -1 (a, b) = (abs(dividend), abs(divisor)) if a < b: return...
colors = ["red", "yellow", "green", "blue"] print(type(colors)) print(colors) numbers = (1,2,3) print(numbers) numbers_list = list(numbers) print(numbers_list) print(list("Fabio")) groceries = "eggs, milk, cheese" grocery_list = groceries.split(", ") print(grocery_list) numbers = list(range(1,10)) print(numbers) ...
colors = ['red', 'yellow', 'green', 'blue'] print(type(colors)) print(colors) numbers = (1, 2, 3) print(numbers) numbers_list = list(numbers) print(numbers_list) print(list('Fabio')) groceries = 'eggs, milk, cheese' grocery_list = groceries.split(', ') print(grocery_list) numbers = list(range(1, 10)) print(numbers) pri...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Meta data for appveyorpy.""" __version__ = '0.0.1' def add(a: int, b: int) -> int: """Add ``a`` and ``b``.""" return a + b
"""Meta data for appveyorpy.""" __version__ = '0.0.1' def add(a: int, b: int) -> int: """Add ``a`` and ``b``.""" return a + b
class Solution: def maxArea(self, height: List[int]) -> int: n = len(height) start, end = 0, n-1 maxArea = 0 while start < end: area = (end - start)*min(height[start], height[end]) if maxArea < area: maxArea = area if height[start] ...
class Solution: def max_area(self, height: List[int]) -> int: n = len(height) (start, end) = (0, n - 1) max_area = 0 while start < end: area = (end - start) * min(height[start], height[end]) if maxArea < area: max_area = area if he...
N = int(input()) A = int(input()) if N%500 <= A: print('Yes') else: print('No')
n = int(input()) a = int(input()) if N % 500 <= A: print('Yes') else: print('No')
# puzzle3b.py def get_rating(input_data, rating_type, num_len): def rating_type_compare(rating_type, count_0, count_1): if rating_type.upper() in ["OXYGEN", "O2"]: return (count_0 > count_1) elif rating_type.upper() in ["CO2"]: return (count_0 <= count_1) # Strategy: Fo...
def get_rating(input_data, rating_type, num_len): def rating_type_compare(rating_type, count_0, count_1): if rating_type.upper() in ['OXYGEN', 'O2']: return count_0 > count_1 elif rating_type.upper() in ['CO2']: return count_0 <= count_1 input_values = input_data for...
class ParticipantIdentifierTypeName(): AS_PROGRESSION_ID = 'AS_PROGRESSION_ID' BME_COVID_ID = 'BME_COVID_ID' CARDIOMET_ID = 'CARDIOMET_ID' CARMER_BREATH_ID = 'CARMER_BREATH_ID' EASY_AS_ID = 'EASY_AS_ID' EDEN_ID = 'EDEN_ID' EDIFY_ID = 'EDIFY_ID' ELASTIC_AS_ID = 'ELASTIC_AS_ID' EPIGENE...
class Participantidentifiertypename: as_progression_id = 'AS_PROGRESSION_ID' bme_covid_id = 'BME_COVID_ID' cardiomet_id = 'CARDIOMET_ID' carmer_breath_id = 'CARMER_BREATH_ID' easy_as_id = 'EASY_AS_ID' eden_id = 'EDEN_ID' edify_id = 'EDIFY_ID' elastic_as_id = 'ELASTIC_AS_ID' epigene1_...
def D2old(): n = int(input()) bricks = input().split() bricks = [int(x) for x in bricks] m = min(bricks) M = max(bricks) while(m!=M): for idx in range(n): if(bricks[idx] != m): continue m_count = 0 while( idx+m_count < n and bricks[idx+m_count]== m): bricks[idx+m_count] +=1 m_count+=1 ...
def d2old(): n = int(input()) bricks = input().split() bricks = [int(x) for x in bricks] m = min(bricks) m = max(bricks) while m != M: for idx in range(n): if bricks[idx] != m: continue m_count = 0 while idx + m_count < n and bricks[idx...
# -*- coding: utf-8 -*- """ Created on Sat Aug 17 13:18:39 2019 @author: solis https://opendata.aemet.es/centrodedescargas/inicio """ MYAPIKEY = 'facilitadoPorAEMET'
""" Created on Sat Aug 17 13:18:39 2019 @author: solis https://opendata.aemet.es/centrodedescargas/inicio """ myapikey = 'facilitadoPorAEMET'
class LoginError(Exception): """ An error occurred when logging in. """ pass class ParseError(Exception): """ An error occurred when trying to parse the message. """ pass class ParserNotFoundError(Exception): """ Parser for the given destto name was not registered with the ...
class Loginerror(Exception): """ An error occurred when logging in. """ pass class Parseerror(Exception): """ An error occurred when trying to parse the message. """ pass class Parsernotfounderror(Exception): """ Parser for the given destto name was not registered with the meta...
# Copyright (c) 2015, 2014 Computational Molecular Biology Group, Free University # Berlin, 14195 Berlin, Germany. # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: # # * Redistributions of source ...
""" Created on May 26, 2014 @author: marscher """ class Spectralwarning(RuntimeWarning): pass class Imaginaryeigenvaluewarning(SpectralWarning): pass class Precisionwarning(RuntimeWarning): """ This warning indicates that some operation in your code leads to a conversion of datatypes, which invo...
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: MIT-0 """ Stubs for testing organization.py """ describe_organization = { 'Organization': { 'Id': 'some_org_id', 'Arn': 'string', 'FeatureSet': 'ALL', 'MasterAccountArn': 'string', ...
""" Stubs for testing organization.py """ describe_organization = {'Organization': {'Id': 'some_org_id', 'Arn': 'string', 'FeatureSet': 'ALL', 'MasterAccountArn': 'string', 'MasterAccountId': 'some_master_account_id', 'MasterAccountEmail': 'string', 'AvailablePolicyTypes': [{'Type': 'SERVICE_CONTROL_POLICY', 'Status': ...
list = [] def list_(times): for x in range(times): number = int(input('Ingrese numero(s) a incluir ')) list.append(number) return list times = int(input('Cantidad de elementos?: ')) list = list_(times) print(list)
list = [] def list_(times): for x in range(times): number = int(input('Ingrese numero(s) a incluir ')) list.append(number) return list times = int(input('Cantidad de elementos?: ')) list = list_(times) print(list)
#Patterns to detect accommodation related queries pattern_details1 = { "LABEL" : "PICKUP_REG", "pattern" : [ { "TEXT" : { "REGEX" : "\bpickup\b|\bpick-up\b|\bdeliver*\b|\bgrab*\b" } } ] } pattern_details2 = { "LABEL" : "PICKUP_LEMM", "pattern" : [ { "TEXT" : { "REGEX" : "delive...
pattern_details1 = {'LABEL': 'PICKUP_REG', 'pattern': [{'TEXT': {'REGEX': '\x08pickup\x08|\x08pick-up\x08|\x08deliver*\x08|\x08grab*\x08'}}]} pattern_details2 = {'LABEL': 'PICKUP_LEMM', 'pattern': [{'TEXT': {'REGEX': 'deliver|pickup|pick-up|grab|drop'}}, {'OP': '*'}, {'TEXT': {'REGEX': '\x08grocer*\x08|\x08medicin*\x08...
#remove all the digits from given string inp="test1254ab995drgdc10108done" inp=inp.replace("0","") inp=inp.replace("1","") inp=inp.replace("2","") inp=inp.replace("3","") inp=inp.replace("4","") inp=inp.replace("5","") inp=inp.replace("6","") inp=inp.replace("7","") inp=inp.replace("8","") inp=inp.replace("9...
inp = 'test1254ab995drgdc10108done' inp = inp.replace('0', '') inp = inp.replace('1', '') inp = inp.replace('2', '') inp = inp.replace('3', '') inp = inp.replace('4', '') inp = inp.replace('5', '') inp = inp.replace('6', '') inp = inp.replace('7', '') inp = inp.replace('8', '') inp = inp.replace('9', '') print(inp)
n = int(input()) if n%2!=0: print("Weird") else: if (n>=2 and n<=5): print("Not Weird") elif (n>=6 and n<=20): print("Weird") elif(n>20): print("Not Weird")
n = int(input()) if n % 2 != 0: print('Weird') elif n >= 2 and n <= 5: print('Not Weird') elif n >= 6 and n <= 20: print('Weird') elif n > 20: print('Not Weird')
#!/usr/bin/env python """Temp GGBweb python formating functions""" __author__ = "Aaron Brooks" __copyright__ = "Copyright 2014, cMonkey2" __credits__ = ["Aaron Brooks"] __license__ = "GPL" __version__ = "0.0.1" __maintainer__ = "Aaron Brooks" __email__ = "brooksan@uw.edu" __status__ = "Development"
"""Temp GGBweb python formating functions""" __author__ = 'Aaron Brooks' __copyright__ = 'Copyright 2014, cMonkey2' __credits__ = ['Aaron Brooks'] __license__ = 'GPL' __version__ = '0.0.1' __maintainer__ = 'Aaron Brooks' __email__ = 'brooksan@uw.edu' __status__ = 'Development'
n = int(input()) d = len(str(n)) - 1 k = str(n) j = int(k[0]) count = 1 co = 0 for i9 in range(3, 8, 2): for i8 in range(3, 8, 2): for i7 in range(3, 8, 2): for i6 in range(3, 8, 2): for i5 in range(3, 8, 2): for i4 in range(3, 8, 2): f...
n = int(input()) d = len(str(n)) - 1 k = str(n) j = int(k[0]) count = 1 co = 0 for i9 in range(3, 8, 2): for i8 in range(3, 8, 2): for i7 in range(3, 8, 2): for i6 in range(3, 8, 2): for i5 in range(3, 8, 2): for i4 in range(3, 8, 2): f...
""" @author: David Lei @since: 21/08/2016 @modified: Common problem with many variations - minimum number of coins - how many ways can we give change - each coin only used once - each coin can be used as many times as you want etc """ """ Minimum number of coins variation Given coins of d...
""" @author: David Lei @since: 21/08/2016 @modified: Common problem with many variations - minimum number of coins - how many ways can we give change - each coin only used once - each coin can be used as many times as you want etc """ "\nMinimum number of coins variation\nGiven coins of di...
""" Test routes for routes for authorizing users, app/main/routes """ # pylint: disable=redefined-outer-name,unused-argument def test_index_route_to_login(client): """ Test redirect to login when go to index and not authorized """ response = client.get("/", follow_redirects=True) assert response.st...
""" Test routes for routes for authorizing users, app/main/routes """ def test_index_route_to_login(client): """ Test redirect to login when go to index and not authorized """ response = client.get('/', follow_redirects=True) assert response.status_code == 200 assert b'Please log in to access t...
# coding: utf-8 """ Heapsort implementation https://en.wikipedia.org/wiki/Heapsort Worst-case performance O(n * log(n)) Best-case performance O(n) Average performance O(n * log(n)) """ def heapsort(lst): """ Implementation of heap sort algorithm """ lenght = len(lst) heapstart = int(lenght / 2) - 1 ...
""" Heapsort implementation https://en.wikipedia.org/wiki/Heapsort Worst-case performance O(n * log(n)) Best-case performance O(n) Average performance O(n * log(n)) """ def heapsort(lst): """ Implementation of heap sort algorithm """ lenght = len(lst) heapstart = int(lenght / 2) - 1 for start in ra...
#!/usr/bin/python3 # -*- coding: utf-8 -*- # # Run inside python3 shell. # def gen_gray(n): """ A generator that yields the elements of a gray sequence (as lists) with `n` bits. """ k = 0 even = True seq = [False]*n while k < 2**n: yield seq if even: seq[n - 1] = not s...
def gen_gray(n): """ A generator that yields the elements of a gray sequence (as lists) with `n` bits. """ k = 0 even = True seq = [False] * n while k < 2 ** n: yield seq if even: seq[n - 1] = not seq[n - 1] else: tmp = n - 1 while not ...
def convert_and_sum_list_kwargs(usd_list, **kwargs): total = 0 for amount in usd_list: total += convert_usd_to_aud(amount, **kwargs) return total print(convert_and_sum_list_kwargs([1, 3], rate=0.8))
def convert_and_sum_list_kwargs(usd_list, **kwargs): total = 0 for amount in usd_list: total += convert_usd_to_aud(amount, **kwargs) return total print(convert_and_sum_list_kwargs([1, 3], rate=0.8))
class SimpleGraph: def __init__(self): self.edges = {} @property def nodes(self): return self.edges.keys() def neighbors(self, id): return self.edges[id] class DFS(object): ''' Implementation of recursive depth-first search algorithm Note for status 0=not visited, ...
class Simplegraph: def __init__(self): self.edges = {} @property def nodes(self): return self.edges.keys() def neighbors(self, id): return self.edges[id] class Dfs(object): """ Implementation of recursive depth-first search algorithm Note for status 0=not visited,...
#link: https://leetcode.com/problems/island-perimeter/submissions/ """ Go through every cell on the grid and whenever you are at cell 1 (land cell), look for surrounding (UP, RIGHT, DOWN, LEFT) cells. A land cell without any surrounding land cell will have a perimeter of 4. Subtract 1 for each surrounding land cell. ...
""" Go through every cell on the grid and whenever you are at cell 1 (land cell), look for surrounding (UP, RIGHT, DOWN, LEFT) cells. A land cell without any surrounding land cell will have a perimeter of 4. Subtract 1 for each surrounding land cell. """ class Solution(object): def island_perimeter(self, grid): ...
#check if it is a multiple subject def is_multiple_subject_linked_to_subject(subject): for child in subject.children: if child.dep_ == "conj": return True return False def is_multiple_subject_linked_to_predicate(predicate): #this case is for personal pronoun, and not only, but much more nsubj subjects = [] ...
def is_multiple_subject_linked_to_subject(subject): for child in subject.children: if child.dep_ == 'conj': return True return False def is_multiple_subject_linked_to_predicate(predicate): subjects = [] for child in predicate.children: if child.dep_ == 'nsubj': s...
def test_getitem_fetches_delayed_array_from_index(): """ spec['a'] """ def test_getitem_logical_indexing_fetches_result_from_param_file(): """ Ensure that `spec[spec['param1'] == 1]` fetches the correct delayed object from the param files """ def test_getitem_multidimensional_logical_index...
def test_getitem_fetches_delayed_array_from_index(): """ spec['a'] """ def test_getitem_logical_indexing_fetches_result_from_param_file(): """ Ensure that `spec[spec['param1'] == 1]` fetches the correct delayed object from the param files """ def test_getitem_multidimensional_logical_indexing_...
#!/usr/bin/env python NAME = 'Imperva SecureSphere' def is_waf(self): # thanks to Mathieu Dessus <mathieu.dessus(a)verizonbusiness.com> for this # might lead to false positives so please report back to sandro@enablesecurity.com for attack in self.attacks: r = attack(self) if r is None: ...
name = 'Imperva SecureSphere' def is_waf(self): for attack in self.attacks: r = attack(self) if r is None: return (response, responsebody) = r if response.version == 10: return True return False
class Node(object): def __init__(self, val, parent=None): self.val = val self.leftChild = None self.rightChild = None self.parent = parent def getLeftChild(self): return self.leftChild def getRightChild(self): return self.rightChild def getParent(self...
class Node(object): def __init__(self, val, parent=None): self.val = val self.leftChild = None self.rightChild = None self.parent = parent def get_left_child(self): return self.leftChild def get_right_child(self): return self.rightChild def get_parent(...
"""Tests suite for pCrunch.""" __author__ = ["Jake Nunemaker", "Nikhar Abbas"] __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "Jake Nunemaker" __email__ = "jake.nunemaker@nrel.gov"
"""Tests suite for pCrunch.""" __author__ = ['Jake Nunemaker', 'Nikhar Abbas'] __copyright__ = 'Copyright 2020, National Renewable Energy Laboratory' __maintainer__ = 'Jake Nunemaker' __email__ = 'jake.nunemaker@nrel.gov'
class FundNameException(BaseException): pass class FundOutFileNameException(BaseException): pass class FundNotFoundException(BaseException): pass class StockInformationMissingException(BaseException): pass class StockCandleInformatinMissingException(StockInformationMissingException): pass
class Fundnameexception(BaseException): pass class Fundoutfilenameexception(BaseException): pass class Fundnotfoundexception(BaseException): pass class Stockinformationmissingexception(BaseException): pass class Stockcandleinformatinmissingexception(StockInformationMissingException): pass
dp = {0:0,1:1,2:2} class Solution: def minDays(self, n: int) -> int: if n in dp: return dp[n] ans = 1 + min(n%2 + self.minDays((n-n%2)//2), n%3 + self.minDays((n-n%3)//3)) dp[n] = ans return ans
dp = {0: 0, 1: 1, 2: 2} class Solution: def min_days(self, n: int) -> int: if n in dp: return dp[n] ans = 1 + min(n % 2 + self.minDays((n - n % 2) // 2), n % 3 + self.minDays((n - n % 3) // 3)) dp[n] = ans return ans
class MinStack: def __init__(self): """ initialize your data structure here. """ self.stack = list() def push(self, x: int) -> None: cur_min = self.getMin() if x < cur_min: cur_min = x self.stack.append((x, cur_min)) def pop(sel...
class Minstack: def __init__(self): """ initialize your data structure here. """ self.stack = list() def push(self, x: int) -> None: cur_min = self.getMin() if x < cur_min: cur_min = x self.stack.append((x, cur_min)) def pop(self) -> Non...
class ImeContext(object): """ Contains static methods that interact directly with the IME API. """ @staticmethod def Disable(handle): """ Disable(handle: IntPtr) Disables the specified IME. handle: A pointer to the IME to disable. """ pass @staticmethod ...
class Imecontext(object): """ Contains static methods that interact directly with the IME API. """ @staticmethod def disable(handle): """ Disable(handle: IntPtr) Disables the specified IME. handle: A pointer to the IME to disable. """ pass @staticmethod def enable(h...