content
stringlengths
7
1.05M
# # PySNMP MIB module ZYXEL-OAM-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ZYXEL-OAM-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:51:06 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 201...
def intro(task): title = f" ** {task} ** " print ("\n") print ("*" * len(title)) print (title) print ("*" * len(title)) print ("\n") intro("School") class Person: def __init__(self, firstname, lastname, age, phone, email=None): self.firstname = firstname self.lastname = las...
def foo(y): x=y return x bar = foo(7)
class Solution: def countPrimes(self, n: int) -> int: primes = [] for i in range(2, n): for prime in primes: if i % prime == 0: break else: primes.append(i) return len(primes)
""" N 1^2 + 2^2 + 3^2 + ... + N^2 """ N = int(input()) sum = 0 for i in range(1, N + 1): sum += i ** 2 print(sum)
#!/usr/bin/env python # -*- coding: utf-8 -*- # Used to simulate an enum with unique values class Enumeration(set): def __getattr__(self, name): if name in self: return name raise AttributeError def __setattr__(self, name, value): raise RuntimeError("Cannot override values"...
def fib(n, c={0:1, 1:1}): if n not in c: x = n // 2 c[n] = fib(x-1) * fib(n-x-1) + fib(x) * fib(n - x) return c[n] fib(10000000) # calculating it takes a few seconds, printing it takes eons
def build_and(left, right): return {'type':'and','left':left,'right':right} def build_or(left,right): return {'type':'or','left':left,'right':right} def build_atom(atom): return {'type':'atom','atom':atom} def equal(p0,p1): if p0['type'] == p1['type']: if p1['type'] == 'atom': ret...
self.con_win_size = 9 self.halfwin = con_win_size // 2 def load_data(self): for i in range(self.n_file): self.log("n." + str(i+1)) inp = np.load(os.path.join(self.data_path, os.listdir(self.data_path)[i])) full_x = np.pad(inp["imgs"], [(self.halfwin,self.halfwin), (0,0)], mode='constant'...
"""Serves as an interface for the two different console parsers (characterize and JUnit)""" class DefaultConsoleParser: # noinspection PyUnusedLocal def __init__(self, pipeline_name, pipeline_counter, stage_index, stage_name, job_name): self.console_log = None self.response = None self...
class TTRssException(Exception): pass class TTRssArgumentException(TTRssException): pass class TTRssConfigurationException(TTRssException): pass
# # Represents a vertex in a DAG # # Copyright (c) 2013 by Michael Luckeneder # class Vertex(object): """Represents a vertex in a DAG""" def __init__(self, name): """Initialize the vertex""" self.name = name def __str__(self): """Returns String representation of vertex""" ...
# [] O que São funçoes, condiçoes e Loops em Python? # [] if # [] elif # [] Loops # [] While numeros = (1,2,3,4,5,6,7,8,9,10) for i in numeros: print(numeros)
lista = ('carro','moto','trator','caminhao','coracao','ovo', 'mao','paralelepipedo','borboleta','onibus','Brasil','papai') for i in lista: print(f'\nA palavra {i}, possui as vogais: ',end='') for j in i: if j.lower() in 'aeiou': print(j, end=' ')
def find(n,m,index,cursor): if index == m: print(" ".join(map(str,foundlist))) return else: for i in range(cursor,n+1): if findnum[i] == True: continue else: findnum[i] = True foundlist[index] = cursor = i find(n,m,index+1,cursor) findnum[i] = False ...
#!/usr/bin/python3 """Create""" def text_indentation(text): """text indentation """ if type(text) is not str: raise TypeError("text must be a string") i = 0 while i < len(text): if text[i] not in [".", "?", ":"]: print(text[i], end='') else: print('{}\n'...
ONES = {0: '', 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine'} TEENS = {11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen'} TENS = {0: '', 1: 'ten', 2: 'twenty', 3: 'thirty', 4: 'for...
class Solution: def numDupDigitsAtMostN(self, N: int) -> int: list_n = list(map(int, str(N + 1))) res = 0 len_n = len(list_n) for i in range(1, len_n): res += 9 * self.get_cnt(9, i - 1) s = set() for i, x in enumerate(list_n): for y in range(...
# -*- coding: utf-8 -*- # @Time :2021/3/8 10:48 # @Author :Ma Liang # @Email :mal818@126.com # @File :gameuniterror.py.py class GameUnitError(Exception): """Custom exception class for the 'AbstractGameUnit' and its subclasses""" def __init__(self, message=''): super().__init__(message) ...
# # PySNMP MIB module HPN-ICF-COMMON-SYSTEM-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-COMMON-SYSTEM-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:37:40 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3....
## Recursion with memoization # Time: O(n^3) class Solution: def wordBreak(self, s: str, wordDict: List[str]) -> bool: @lru_cache def recur( s, word_dict, start ): if start == len(s): return True for end in range( start+1, len(s)+1 ): if s[star...
expected_output = { "active_translations": {"dynamic": 0, "extended": 0, "static": 0, "total": 0}, "cef_punted_pkts": 0, "cef_translated_pkts": 0, "dynamic_mappings": { "inside_source": { "id": { 1: { "access_list": "test-robot", ...
# Copyright (C) 2021 Clinton Garwood # MIT Open Source Initiative Approved License # while_true_clinton.py # CIS-135 Python # Assignment #9 # # # Lab 9 # Get while_yes and enter Loop # Initial Value received from input is a string value # print("While Looping Exercises") #while_yes = input("Yes or No? Input ...
class Glass: capacity = 250 def __init__(self): self.content = 0 def get_space_left(self): return self.capacity - self.content def fill(self, ml): """ Fills water in the glass If no space for ml, nothing is filled in the glass """ if sel...
engine.run_script('init-touchcursor') # https://github.com/autokey/autokey/issues/127 # Can't simulate multimedia keys #127 # xmodmap -pk | grep XF86AudioRaiseVolume # 123 0x1008ff13 (XF86AudioRaiseVolume) 0x0000 (NoSymbol) 0x1008ff13 (XF86AudioRaiseVolume) # keyboard.send_keys("<code123>") # ...
class Solution: def twoSum(self, nums: list[int], target: int) -> list[int]: l = len(nums) data = {} for i in range(l): xa = nums[i] if xa in data: return [data[xa], i] xb = target - xa data[xb] = i return [] de...
# First, we collect a url from users: url = input("Enter the URL you'd like to clean up:\n") remove_query_strings = input("Should we remove query strings (y/n/yes/no)?\n") if remove_query_strings == "y" or remove_query_strings == "yes": remove_query_strings = True else: remove_query_strings = False # Remove ...
envs = [ 'dm.acrobot.swingup', 'dm.cheetah.run', 'dm.finger.turn_hard', 'dm.walker.run', 'dm.quadruped.run', 'dm.quadruped.walk', 'dm.hopper.hop', ] times = [ 1e6, 1e6, 1e6, 1e6, 2e6, 2e6, 1e6 ] sigma = 0.001 f_dims = [1024, 512, 256, 128, 64] lr = '1e-4' count = 0 for i, env in enume...
# -*- coding: utf-8 -*- """ Created on Sat Apr 16 15:39:58 2022 @author: jced0001 """ class Bias: """ Nanonis Bias Module """ def __init__(self, nanonisTCP): self.nanonisTCP = nanonisTCP def Set(self, bias): """ Set the tip voltage bias Parameters bias...
def foo(): return "foo 1" def bar(): return "bar 1" if __name__ == "__main__": print(foo()) print(bar())
class Comparable(object): """ https://regebro.wordpress.com/2010/12/13/python-implementing-rich-comparison-the-correct-way/ """ def _compare(self, other, method): try: if type(other) is type(self): return method(self._cmpkey, other._cmpkey) return NotImplemen...
# Algoritmo para verificar si dos números son amigos: def dividers(x: int, y:int) -> bool: div_x = [i for i in range(1, x) if x % i == 0] div_y = [i for i in range(1, y) if y % i == 0] return sum(div_x) == y and sum(div_y) == x if __name__ == '__main__': nums = [None, None] for i in range(len(num...
def find_node_in_list(name, l): for i in l: if i.name == name: return i return False def remove_bag(string): string = string.replace('bags', '') if 'bags' in string else string string = string.replace('bag', '') if 'bag' in string else string return string.strip() class Link...
n = int(input()) ans = 0 for a in range(10 ** 5): if a ** 2 <= n: ans = a else: break print(ans)
# -*- coding: utf-8 -*- def data_kind(): # num, 数字 myNum = 123 print(myNum) # string, 字符串 myStr = 'hello world!' print(myStr) # list, 列表 myList = [1, 2, 34, 5, "hello"] print(myList) # tuple, 元组 myTuple = (1, 2, 3, 4, "jjjjasd", 'mg', [1, 2, 3]) print(myTuple) # set, ...
dict = { 'apples': 7, 'oranges': 12, 'grapes': 5 } # to get an item from a dictionary apples = dict.get('apples') # option 1 apples1 = dict['apples'] # option 2 print(apples1) # add items to the dict dict['banana'] = 4 print(dict) # remove items from the dict dict.popitem() # removes last item fro...
A, B = map(int, input().split()) while A != 0 and B != 0: X = set(map(int, input().split())) Y = set(map(int, input().split())) print(min(len(X-Y), len(Y-X))) A, B = map(int, input().split())
num_1 = int(input("Digite um número:")) num_2 = int(input("Digite outro número:")) soma = num_1+num_2 print("A soma entre {} e {} é {}.".format(num_1, num_2, soma))
# Copyright 2015 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. { 'targets': [ { 'target_name': 'array_data_model', 'dependencies': [ '../../compiled_resources2.gyp:cr', '../compiled_resou...
class MutualExclusionRule(object): """Mutual exclusion rules indicate that a group of directives probably aren't going to show up in the same date string. ('%H','%I') would be an example of mutually-exclusive directives. MutualExclusionRule objects that are elements in the format_rules attribute of ...
aluno = {} aluno['Nome'] = str(input('Nome: ')) aluno['Média'] = float(input(f'Média do(a) {aluno["Nome"]}: ')) aluno['Situação'] = ('Aprovado' if aluno['Média'] >= 7 else 'Reprovado') for k, v in aluno.items(): # Para cada chave e valor em aluno.items() print(f'{k}: {v}')
######################################## # QUESTION ######################################## # Create a function (or write a script in Shell) that takes an integer as an argument # and returns "Even" for even numbers or "Odd" for odd numbers. ################################### # SOLUTION ############################...
# -*- coding: utf-8 -*- """ Um posto está vendendo combustíveis com a seguinte tabela de descontos: Álcool: até 20 litros, desconto de 3%. acima de 20 litros, desconto de 5%. Gasolina: até 20 litros, desconto de 4%. acima de 20 litros, desconto de 6%. Escreva um algoritmo que leia o número de litros vendidos, o tipo de...
# -*- coding: utf-8 -*- VERSION_MAJOR = '0' VERSION_MINOR = '1' VERSION_PATCH = '1' VERSION_DEV = 'dev' def version(): dev = '' if VERSION_DEV: dev = '-' + VERSION_DEV return VERSION_MAJOR + '.' + VERSION_MINOR + '.' + VERSION_PATCH + dev
x = int(input('Digite o primeiro número inteiro: ')) y = int(input('Digite o segundo número inteiro: ')) z = int(input('Digite o terceiro número inteiro: ')) menor = x if y<x and y<z: menor = y if z<x and z<y: menor = z maior = x if y>x and y>z: maior = y if z>x and z>y: maior = z print('O menor número ...
# coding: utf-8 default_app_config = 'modernrpc.apps.ModernRpcConfig' __version__ = '0.11.1'
x = 0 if x < 2 : print('small') elif x < 10 : print('Medium') else : print('LARGE') print('All done')
CONTENT_OPERATIONS_RESOURCES_NAMESPACE = \ 'bclearer_boson_1_1_source.resources.content_universes' ADJUSTMENT_OPERATIONS_RESOURCES_NAMESPACE = \ 'bclearer_boson_1_1_source.resources.adjustment_universes'
class UserSource(object): """ Generalized UserSource to facilitate ldap sync """ def __init__(self, name, bases, org=None, filters=None, user_type=None, default_filter='(objectClass=*)', verbose=False): self.name = name.lower() self._bases = bases self...
# More About the print Function (Title) # Reading # Suppressing the Print Function's Ending Newline print('one') print('two') print('three') # To print space instead of newline character (new line of output) print('one', end=' ') print('two', end=' ') print('three') # To print nothing at the end of its output print...
d = float(input('Informe a distâcia de sua viagem: ')) print('Você vai fazer uma viagem de {:.2f} Km. '.format(d)) if d <= 200: print('É o preço de sua passagem será de R$ {:.2f}'.format(d * 0.50)) else: print('É o preço de sua passagem será de R$ {:.2f} '.format(d * 0.45))
# Copyright 2020 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. PYTHON_VERSION_COMPATIBILITY = "PY2+3" DEPS = [ 'provenance', 'recipe_engine/path', ] def RunSteps(api): api.provenance.generate( 'projects/PROJ...
class Solution: def romanToInt(self, s): """ :type s: str :rtype: int """ d = {} d['I'] = 1 d['IV'] = 4 d['V'] = 5 d['IX'] = 9 d['X'] = 10 d['XL'] = 40 d['L'] = 50 d['XC'] = 90 d['C'] = 100 d['CD'...
# # PySNMP MIB module BASIS-GENERIC-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/BASIS-GENERIC-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:34:35 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Ma...
# -*- coding: utf-8 -*- """ In this module will be defined all constanst about Beauty & Pics """ class project_constants(object): # contest status {{{ CONTEST_OPENING = "opening" CONTEST_ACTIVE = "active" CONTEST_CLOSED = "closed" # contest status }}} # contest types {{{ MAN_CONTEST = "man...
def sort_012(input_arr): """ Given an input array consisting on only 0, 1, and 2, sort the array in a single traversal. Time Complexity O(n) Space Complexity O(n) Where n is the array size. Args: input_arr(array): Array to be sorted Returns: sorted_arr(array): ...
class Solution: def XXX(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ temp = 0 for i in range(len(nums)): if temp: i -= temp if nums[i] == 0: nums.pop(i) nu...
suplemento = ('Whey Protein', 77.66, 'Creatina', 45.60, 'Multivitaminico', 27.90, 'Glutamina', 50.55, 'Pre=treino', 120.21, 'Melatonina', 91.65) print('-' * 30) print('Listagem de Preços') print('-' * 30) for pos in range(0, len(suplemento)): if pos % 2 == 0: print(f'{suplemento[pos]:.<30}', e...
""" #!/usr/bin/python #Author: Suraj Patil #Version: 2.0 #Date: 27th March 2014 input: 1. this is a dummy text 2. another dummy text 3. this is dummy 4. this is also dummy output: this is a dummy text another dummy text this is dummy this is also dummy """ f = open('text', 'r') f1= open('textModified', ...
class MinStack(object): def __init__(self): self.stack = [] def push(self, x): self.stack.append((x, min(self.getMin(), x))) def pop(self): self.stack.pop() def top(self): return self.stack[-1][0] def getMin(self): return self.stack[-1][1] if self.stack e...
graph = {"A": ["B", "C"], "B": ["D", "E"], "C": ["F"], "D": [], "E": ["F"], "F": []} visited = set() def dfs(visited, graph, node): if node not in visited: print(node) visited.add(node) for neighbour in graph[node]: dfs(visited, graph, neighbour) if __name__ == "__main__": ...
# Definition for an interval. # class Interval: # def __init__(self, s=0, e=0): # self.start = s # self.end = e class Solution: # @param intervals, a list of Intervals # @param newInterval, a Interval # @return a list of Interval def insert(self, intervals, newInterval): re...
class dotIFC2X3_Application_t(object): # no doc ApplicationFullName=None ApplicationIdentifier=None Version=None
class LaunchAPIException(Exception): def __init__(self, message, status_code): super(Exception, self).__init__(message) self.status_code = status_code class ClientException(LaunchAPIException): pass
def main(): OnFwd(OUT_AB, 80) TextOut(0, LCD_LINE1, 20) Wait(2000)
FreeMonoOblique9pt7bBitmaps = [ 0x11, 0x22, 0x24, 0x40, 0x00, 0xC0, 0xDE, 0xE5, 0x29, 0x00, 0x09, 0x05, 0x02, 0x82, 0x47, 0xF8, 0xA0, 0x51, 0xFE, 0x28, 0x14, 0x0A, 0x09, 0x00, 0x08, 0x1D, 0x23, 0x40, 0x70, 0x1C, 0x02, 0x82, 0x84, 0x78, 0x20, 0x20, 0x1C, 0x11, 0x08, 0x83, 0x80, 0x18, 0x71, 0xC0, 0x1C, 0x...
''' Даны два числа. Напиши программу, которая найдет их среднее арифметическое. На вход программе поступает два числа a и b, каждое из которых не превышает 10000. Программа должна вывести среднее арифметическое чисел a и b. Sample Input 1: 1 2 Sample Output 1: 1.5 Sample Input 2: 3.5 1.5 Sample Output 2: 2.5 ''' a...
#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of easy-drf. # https://github.com/talp101/easy-drf.git # Licensed under the MIT license: # http://www.opensource.org/licenses/MIT-license # Copyright (c) 2015, Tal Peretz <13@1500.co.il> __version__ = '0.1.2' # NOQA
print('-----------------字符串的替换与合并--------------') s='hello python' print(s.replace('python','Java')) #用Java替换 s1='hello python python' print(s1.replace('python','Java',2)) #设置最大替换次数 lst=['hello','java','python'] print('|'.join(lst)) #用|连接列表元素 print(''.join(lst)) #默认直接连接 t=('hello','java','python') #连接元组元素...
class Solution: # @param dictionary: a list of strings # @return: a list of strings def longestWords(self, dictionary): def word_len_list(dictionary): wd_list =[] for word in dictionary: wd_list.append(len(word)) return max(wd_list) def fi...
""" 帮帮Mike 描述 Mike is a lawyer with the gift of photographic memory. He is so good with it that he can tell you all the numbers on a sheet of paper by having a look at it without any mistake. Mike is also brilliant with subsets so he thought of giving a challenge based on his skill and knowledge to Rachael. Mike kno...
def normalize(s: str) -> str: """ Filter out '\n' and translate multiple ' ' into one ' ' :param s: String to normalize :return: normalized str """ s = list(filter(lambda x: x != '\n', s)) ret_s = "" i = 0 while i < len(s): ret_s += s[i] if s[i] == ' ': ...
@jit(nopython=True) def pressure_poisson(p, b, l2_target): I, J = b.shape iter_diff = l2_target + 1 n = 0 while iter_diff > l2_target and n <= 500: pn = p.copy() for i in range(1, I - 1): for j in range(1, J - 1): p[i, j] = (.25 * (pn[i, j + 1] + ...
''' The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. Each solution contains a distinct board configuration of the n-queens' placement, where 'Q' and '.' both indicate a que...
def findAllDuplicates(nums): d = dict() for i in nums: d[i] = d.get(i, 0) + 1 dup = list() print(d) for i in d: if d[i] == 2: dup.append(i) return dup nums = [4, 3, 2, 7, 8, 2, 3, 1] dup = findAllDuplicates(nums) print(dup)
##sq=lambda x:x**2 ##res=sq(5) ##print("square is:",res) ## ## ## ##add=lambda x,y,z:x+y+z ## ## ##print("sum is:",add(2,3,4)) ## ##l=[1,2,3,4,5] ##li=list(map(lambda x:x**3,l)) ##print(li) t=(1,2,3,4,5) def sum(x): return x+10 a=list(map(sum,t)) print(a)
def iterative(array, element, sort=False): """ Perform Binary Search by Iterative Method. :param array: Iterable of elements. :param element: element to search. :param sort: True will sort the array first then search. By default = False. :return: returns value of index of element (if found) else...
codigo = int(input('Informe o código, por favor')) if codigo == 1: salario = float(input('Informe o salário, por favor')) print('Escrituário') aumento = salario*(0.5) novo_salario = salario+aumento print('O Aumento foi de R$',aumento) print('Seu salário ajustado é de R$',novo_salario) if codigo...
class WordDistanceFinder: """ This class will be given a list of words (such as might be tokenized from a paragraph of text), and will provide a method that takes two words and returns the shortest distance (in words) between those two words in the provided text. :: finder = WordDistance...
# Title : TODO # Objective : TODO # Created by: Wenzurk # Created on: 2018/2/3 transportation = ['bicycle', 'motorcycle', 'car', 'airplane'] message = 'I would like to own a ' print(message + transportation[0] + ".") print(message + transportation[1] + ".") print(message + transportation[2] + ".") print(message + ...
def solution(x, y): x = int(x) y = int(y) numCycles = 0 while (x > 1 or y > 1): if (x == y or x < 1 or y < 1): return "impossible" elif (x > y): factor = int(x/y) numCycles+=factor if (y == 1): numCycles-=1 ...
valores = [1, 2, 3, 4, 5, 6, 7, 8, 9] pares = list(filter(lambda x : x % 2 == 0, valores)) impares = list(filter(lambda x : x % 2 != 0, valores)) print(pares) print(impares)
# -*- coding: utf-8 -*- """Library for components to support modularity.""" MESSAGE_CLASSES = {} SEGMENT_CLASSES = {}
cpf = '04045683941' novo_cpf = cpf[:-2]#selecionando os 9 primeiros e deixando os dois ultimos #040456839 reverso = 10 total = 0 for index in range(19): if index > 8: index -= 9 total += int(novo_cpf[index]) * reverso print(cpf [index], index), reverso reverso -= 1 if reverso < 2: ...
# -*- coding: utf-8 -*- """ Manifest App Information Some codes used in this project is collected from several open source projects, such as; Django: https://github.com/django/django django-rest-framework: https://github.com/encode/django-rest-framework django-rest-auth: https://github.com/Tivix/django-rest-auth djang...
# Angold4 20200620 4.1 def normal_max(S): Max = S[0] for i in S: if i > Max: Max = i return Max def find_max(S): """answer""" if len(S) == 1: return S[0] Max = S.pop() return max(Max, find_max(S)) if __name__ == "__main__": s = [1, 4, 4, 7, 3, 2, 20, 34, 9...
class StubSoundPlayer: def __init__(self): pass def play_once(self, filename): pass def set_music_volume(self, new_volume): pass def change_music(self): pass def play_sound_event(self, sound_event): pass def process_events(self, sound_event_list):...
t = int(input()) for i in range(t): n, m = input().split() n = int(n) m = int(m) print((n-1)*(m-1))
class Solution: def maximalSquare(self, matrix: List[List[str]]) -> int: if len(matrix)<1: return 0 dp=[[0 for i in range(len(matrix[0])+1)] for j in range(len(matrix)+1)] max1=0 for i in range(len(matrix)): for j in range(len(matrix[0])): if m...
# # Common constants # APP_NAME = 'autonom' DEFAULT_CONFIG_FILE = 'autonom.ini' DEFAULT_SESSMGR = 'ticket' # We do this to convert run-time errors into compile time errors CF_DEFAULT = 'DEFAULT' CF_LISTEN = 'listen' CF_PORT = 'port' CF_PROVIDERS = 'providers' CF_FIXED_IP_LIST = 'fixed_ip_list' CF_LOG = 'log' CF_LOG_...
class BudgetNotFound(Exception): pass class WrongPushException(Exception): def __init__(self, expected_delta, delta): self.expected_delta = expected_delta self.delta = delta string = 'tried to push a changed_entities with %d entities while we expected %d entities' @property def m...
#Source : https://leetcode.com/problems/insertion-sort-list/ #Author : Yuan Wang #Date : 2021-02-01 ''' ********************************************************************************** *Sort a linked list using insertion sort. * *Example1 : *Input: 4->2->1->3 *Output: 1->2->3->4 ***********************************...
class ScoreCache: def __init__(self): self.parent_cache = dict() self.child_cache = dict() self.joint_cache = dict() def print(self): print("____CACHE_____") print("parents->(parent_states,parent_states_counts)") print(self.parent_cache) print("child->child_states_counts") print(self.child...
Config = { 'game': { 'height': 640, 'width': 800, 'tile_width': 32 }, 'resources': { 'sprites': { 'player': "src/res/char.png" } } }
def find_binary_partitioned_seat(seat_range, input_text): for letter in input_text: difference = abs(seat_range[0] - seat_range[1]) // 2 if (letter == "F") or (letter == "L"): seat_range = [seat_range[0], seat_range[0] + difference] else: seat_range = [seat_range[1] -...
f = open('input.txt', 'r') row = f.read() data = row.split() result = 0 children = {0: 1} metadata = {} deep = 1 slot = 2 for i in data: i = int(i) if slot == 2 and children[deep - 1] > 0 and (deep not in metadata or metadata[deep] == 0): children[deep] = i children[deep - 1] -= 1 slot ...
class Event: def __init__(self, time): self.time = time def __lt__(self, other): return self.time < other.time def __le__(self, other): return self < other or self.time == other.time class InjectEvent(Event): def __init__(self, time, packet): super(InjectEvent, self).__init__(time) self.packet = packet...
problems = input().split(";") count = 0 for problem in problems: if "-" in problem: upper = problem.split("-")[1] lower = problem.split("-")[0] count += int(upper) - int(lower) + 1 else: count += 1 print(count)
# game states IN_PROGRESS = 0 PLAYER1 = 1 PLAYER2 = 2 DRAW = 3 GAME_STATES = {"IN_PROGRESS": IN_PROGRESS, "PLAYER1": PLAYER1, "PLAYER2": PLAYER2, "DRAW": DRAW}
# Do not edit. bazel-deps autogenerates this file from maven_deps.yaml. def declare_maven(hash): native.maven_jar( name = hash["name"], artifact = hash["artifact"], sha1 = hash["sha1"], repository = hash["repository"] ) native.bind( name = hash["bind"], actua...