content
stringlengths
7
1.05M
# help.py # Metadata NAME = 'help' ENABLE = True PATTERN = '^!help\s*(?P<module_name>.*)$' USAGE = '''Usage: !help [<module_name> | all] Either list all the modules or provide the usage message for a particular module. ''' # Command async def help(bot, message, module_name=None): responses = [] if no...
k ,m= 0,0 while True: try: line = str(input()) except: break if line[0] == '+': m +=1 elif line[0] == '-': m -= 1 else: k += m*len(line[line.index(':')+1::]) print(k)
dataset_type = 'SIXrayDataset' data_root = 'datasets/sixray/' img_norm_cfg = dict( mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) albu_transforms = [ #dict(type='Equalize',mode='cv',by_channels=False) #dict(type='Blur') #dict(type='JpegCompression', quality_lower=10, qualit...
def solution(yourLeft, yourRight, friendsLeft, friendsRight): ''' EXPLANATION ------------------------------------------------------------------- Since all values are in question in this problem, I sort both arrays, and then compare the resultant arrays. -----------------------------------------...
# Filename:continue.py while True: s = input("Just input something:") if s != "quit": continue break
""" Board representation of No Dice Einstein. """ COLOR = { "red": 'R', "blue": 'B' } VALUE = { 1: '1', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6' } MOVE = { "U": "up", "D": "down", "L": "left", "R": "right", "X": "diagonal" } class Piece: def __init__(self, row, c...
''' 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。 ''' class Solution: def lengthOfLongestSubstring(self, s: str) -> int: if len(s) <= 1: return len(s) start = 0 maxLen = 0 end = 0 for end in range(len(s)): findIdx = self.instr(s, start, end) if findId...
# Python - 3.6.0 Test.assert_equals(fib(1), 0, 'fib(1) failed') Test.assert_equals(fib(2), 1, 'fib(2) failed') Test.assert_equals(fib(3), 1, 'fib(3) failed') Test.assert_equals(fib(4), 2, 'fib(4) failed') Test.assert_equals(fib(5), 3, 'fib(5) failed')
class Solution: def maxCoins(self, piles: List[int]) -> int: piles.sort() n = len(piles) i, j = 0, n - 1 ans = 0 while i < j: c = piles[j - 1] j -= 2 i += 1 ans += c return ans
# Motor control DRIVE = 0 STEER = 1 # Body WAIST = 2 HEAD_SWIVEL = 3 HEAD_TILT = 4 # Right arm RIGHT_SHOULDER = 5 RIGHT_FLAP = 6 RIGHT_ELBOW = 7 RIGHT_WRIST = 8 RIGHT_TWIST = 9 RIGHT_GRIP = 10 # Left arm LEFT_SHOULDER = 12 LEFT_FLAP = 13 LEFT_ELBOW = 14 LEFT_WRIST = 15 LEFT_TWIST = 16 LEFT_GRIP = 17
__author__ = 'katharine' __version_info__ = (1, 1, 1) __version__ = '.'.join(map(str, __version_info__))
# # @lc app=leetcode.cn id=121 lang=python3 # # [121] 买卖股票的最佳时机 # # https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock/description/ # # algorithms # Easy (54.27%) # Likes: 1077 # Dislikes: 0 # Total Accepted: 241.4K # Total Submissions: 442.5K # Testcase Example: '[7,1,5,3,6,4]' # # 给定一个数组,它的第 i 个元...
# Func20.py - Closure def Calc(): def sum(i,j): return i+j def sub(i,j): return i-j def mul(i,j): return i*j def div(i,j): return i/j def ans(x,a,b): if x =='덧셈': return sum(a,b) elif x =='뺄셈': return sub(a,b) elif x =='곱셈': return mul(a,b) elif x =='나눗셈': return div...
# This program will convert given temperatures to different measuring units print("\nWelcome to the Temperature Conversion App") temp_f = float(input("What is the temperature in Fahrenheit: ")) # Temperature Conversions temp_c = (5/9) * (temp_f - 32) temp_k = temp_c + 273.15 # Round Temperatures to 2 decimal places...
#bilmemkacv2/OPP(object-oriented-programing) class Account: def init (self,isim,numara,bakiye): self.isim = isim self.numara = numara self.bakiye = bakiye def hesapBilgileri(self): print('İsim: ',self.isim) print('Numara: ',self.numara) print('Bakiye: ',self.bakiy...
# Those are the field names of the cargo tables of leaguepedia # Tournament tournaments_fields = { "Name", "DateStart", "Date", "Region", "League", "Rulebook", "TournamentLevel", "IsQualifier", "IsPlayoffs", "IsOfficial", "OverviewPage", } # Game game_fields = { "GameId...
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def countPairs(self, root: TreeNode, distance: int) -> int: # Compute all values of pairs # ...
class Game(dict): def __init__(self, **kw): dict.__init__(self, kw) self.__dict__.update(kw) # Assigned via game.xml self.home_team= None self.away_team = None self.stadium = None # Assigned via ???? self.innings = [] # Assigned Via game_eve...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Sep 15 15:17:43 2020 @author: runner """ def my_addition(a, b): return a+b print('10+2=12 ?',my_addition(10,2))
class UnionFind: def __init__(self,n): self.par=[-1]*n self.siz=[1]*n #根を求める def root(self,x): if self.par[x] == -1: return x else: #経路圧縮 self.par[x]=self.root(self.par[x]) return self.par[x] #グループ判定(根が一致するかどうか) ...
###################################################### # schema schemaclipboard = None SCHEMA_WRITE_PREFERENCE_DEFAULTS = [ {"key":"addchild","display":"Add child","default":True}, {"key":"remove","display":"Remove","default":True}, {"key":"childsopened","display":"Childs opened","default":False}, {"k...
# encoding: utf-8 class DummyResponse(object): status_code = 250 class DummyBackend(object): def __init__(self, **kw): pass def sendmail(self, **kw): return DummyResponse()
class NetworkInfoEntry(object): def __init__(self): self.bytes = 0 self.packets = 0 self.error = 0 self.drop = 0 class NetworkLogEntry(object): def __init__(self): self.name = "" self.rx = NetworkInfoEntry() self.tx = NetworkInfoEntry() class DomainLo...
class Ball: def __init__(self, x0, y0, r0): self.x = x0 self.y = y0 self.r = r0 return def distance(self, x0, y0): return ((self.x-x0)**2. + (self.y-y0)**2.)**(0.5) def distance_from_origin(self): return self.distance(0,0) def __str__(self): out_str = "Radius = {}\n".forma...
# # PySNMP MIB module CABH-CDP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CABH-CDP-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:26:22 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,...
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None # 核心思路 # 因为没有BST的性质,所以这里只能常规遍历 # 遍历时候返回:确定p/q的数量 & LCA的结点 # 自底向上遍历,当某个结点的左、右子树已经找齐了,则把LCA结点返回;如果左右子树数量,加上当前节点(如果是pq之一) # 等于2,则说明当前节点就是LCA class Solut...
class Animal: def __init__(self,name,legs): self.name = name self.legs = legs class Bear(Animal): def __init__(self,name,legs=4,hibernate='yes'): self.name = name self.legs = legs self.hibernate = hibernate yogi = Bear('Yogi') print(yogi.name) print(yogi.legs) print(yo...
''' 05.Mixed Phones You will be given several phone entries, in the form of strings in format: {firstElement} : {secondElement} The first element is usually the person’s name, and the second one – his phone number. The phone number consists ONLY of digits, while the person’s name can consist of any ASCII characters. S...
# _*_ coding: utf-8 _*_ # !/usr/bin/env python3 """ Mictlantecuhtli: A Multi-Cloud Global Probe Mesh Creator. @author: Collisio-Adolebitque """ class CommandParser: def __init__(self, command_string=''): self.command = command_string def run(self): return self.command class Terraform: ...
class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ d = {} for i, n in enumerate(nums): if target-n in d: return [d[target-n], i + 1] else: ...
year = int(input("Enter year: ")) if year % 400 == 0: print('Entered year is a leap year.') elif year % 100 != 0 and year % 4 == 0: print('Entered year is a leap year.') else: print('Not a leap year.')
# -*- coding: utf-8 -*- # Copyright 2019 Cohesity Inc. class Type5Enum(object): """Implementation of the 'Type5' enum. Specifies the type of managed Object in a HyperFlex protection source like kServer. Examples of a HyperFlex types include 'kServer'. 'kServer' indicates HyperFlex server entity. ...
A= input('Digite a primeira nota:') B= input('Digite a segunda nota:') C= input('Digite a terceira nota:') D= input('Digite a quarta nota:') MA= (int(A)+int(B)+int(C)+int(D))/4 print ('A média aritmética é ',MA)
def test(): class MyInt(int): pass def f(x): """ :type x: MyInt """ i = MyInt(2) f(i)
# Description: Examples of a triple water pentagon. Zoom in on the selection. Edit by changing the residue number. # Source: placeHolder """ cmd.do('fetch ${1:lw9}, async=0; ') cmd.do('zoom resi ${2:313}; ') cmd.do('preset.technical(selection="all", mode=1);') """ cmd.do('fetch lw9, async=0; ') cmd.do('zoom resi 31...
""" checklist: - mock req - mock resp - two ravens: - urls.py - test js req - view.py - req_file.py - test js resp - test w/o TA2 - test w/ TA2 - add tests """
numb = int(input('Digite um número para saber se ele é primo: ')) cont = 0 lst = [] for p in range(1, numb + 1): if numb % p == 0: lst += [p] cont += 1 if cont == 2: print('É primo') else: print('Não é primo') print('E seus divisóres são \n {}'.format(lst))
class Component(object): """Base class for components""" NAME = "base_component" def __init__(self): self.host = None self.properties = {} def on_register(self, host): self.host = host def on_unregister(self): self.host = None def round_update(self): p...
class Solution: def nthUglyNumber(self, n: int, a: int, b: int, c: int) -> int: ab = (a * b) // math.gcd(a, b) ac = (a * c) // math.gcd(a, c) bc = (b * c) // math.gcd(b, c) abc = (ab * c) // math.gcd(ab, c) lo, hi = 1, 2 * 10 ** 9 while lo < hi: mid = (lo ...
# https://leetcode.com/problems/sum-of-root-to-leaf-binary-numbers # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def __init__(self): self.ans = 0...
class TimeInterval: def __init__(self, earliest, latest): self._earliest = earliest self._latest = latest @property def earliest(self): return self._earliest @property def latest(self): return self._latest
''' Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array. Example 1: Input: 2 Output: [0,1,1] Example 2: Input: 5 Output: [0,1,1,2,1,2] Follow up: It is very easy to come up with a solution with r...
# # This file contains the Python code from Program 12.2 of # "Data Structures and Algorithms # with Object-Oriented Design Patterns in Python" # by Bruno R. Preiss. # # Copyright (c) 2003 by Bruno R. Preiss, P.Eng. All rights reserved. # # http://www.brpreiss.com/books/opus7/programs/pgm12_02.txt # class SetAsArray(S...
#!/usr/bin/env python3 # makes the terminal know this is in python x = 9 #Set variables y = 3 #Arithmetic Operators print(x+y) # Addition print(x-y) # Subtraction print(x*y) # Multiplication print(x/y) # Division print(x%y) # Modulus (remainder) print(x**y) # Exponentiation ...
def convert(value, newType): try: return newType(value) except ValueError: return None
""" The probability that a machine produces a defective product is 1/3. What is the probability that the 1st defect is found during the 5th inspection? """ def geometric(n, p): return p * (1 - p) ** (n - 1) def sum_geometric(n, p): total = 0 for i in range(1, n): total += geometric(...
casa = int(input('Qual o valor da casa a ser comprada? ')) salario = int(input('Qual seu salário? ')) anos = int(input('Em quantos anos você deseja pagar essa casa? ')) mes = anos*12 mínima = salario * 30 / 100 prestação = casa / mes print('') print('Para pagar uma casa de R${:.2f}, a prestação mínima é de R${:.2f} rea...
class Node: def __init__(self,value=None): self.value = value self.next = None class CircularSinglyLinkedList: def __init__(self): self.head = None self.tail = None def __iter__(self): '''to iterate objects of this class with "in"-keyword''' node =...
class Solution: ans = 0 def findPathNum(self, i, j, grid: List[List[int]], curLen, pLen)->None: if(grid[i][j]==2): if(pLen-1==curLen): self.ans+=1 return elif (grid[i][j]==-1): return curLen+=1 grid[i][j]=-1 if(i-1>=0):...
class BoxDriveAPI(): host = None key = None secret = None access_token = None access_token_expiration = None def __init__(self, host, key, secret): # the function that is executed when # an instance of the class is created self.host = host self.key = key ...
""" Quiz: Create an HTML List Write some code, including a for loop, that iterates over a list of strings and creates a single string, html_str, which is an HTML list. For example, if the list is items = ['first string', 'second string'], printing html_str should output: <ul> <li>first string</li> <li>second string</l...
title = 'LOJA SUPER BARATÃO' ending = ' FIM DO PROGRAMA ' print('-' * 30) print(f'{title:^30}') print('-' * 30) soma = cont = menor = controlador = 0 mais_barato = '' while True: produto = str(input('Nome do Produto: ').strip()) preço = float(input('Preço: R$').strip()) res = ' ' while res not in 'SN': ...
print(not None) print(not False) print(not True) print(not 0) print(not 1) print(not -1) print(not ()) print(not (1,)) print(not []) print(not [1,]) print(not {}) print(not {1:1})
# A população de um pais #Cont cont = 0 # Pais A pA = 80000 cA = 80000 * 3.0 / 100 tA = pA + cA # Pais B pB = 200000 cB = 200000 * 1.5 / 100 tB = pB + cB while tA < tB: tA += tA tB += tB cont += 1 print ("Serão necessarios %d anos, para que a cidade A alcance a B em numero de habitantes" %cont)
tot = 0 b = int(input()) for i in range(b): a = list(map(float, input().split())) if(a[0]==1001): tot+=a[1]*1.5 elif(a[0]==1002): tot+=a[1]*2.5 elif(a[0]==1003): tot+=a[1]*3.5 elif(a[0]==1004): tot+=a[1]*4.5 elif(a[0]==1005): tot+=a[1]*5.5 print("%.2f" % (tot))
def division(a, b): if a == b: return 1 if a < b: return 0 quotient = 1 temp_number = b while temp_number + b <= a: quotient += 1 temp_number += b return quotient print(division(1200, 3))
index = [] def createIndex(): for file in ["..\data\subgraph\hop1", "..\data\subgraph\hop2", "..\data\subgraph\hop3"]: with open(file) as f: edges = [edge.rstrip() for edge in f] arr = [] for edge in edges: arr2 = [] arr3 = [] x = edge.split('...
def gaussJordan(A): n = len(A) x = [0]*n print(f'A :\n{A}') for i in range(n): if A[i][i] == 0: print('Ora iso mbagi 0 bos') break for j in range(i+1,n): rasio = A[j][i]/A[i][i] for k in range(n+1): A[j][k] -= r...
def grade(key, submission): if submission == 'b3_car3ful_0r_y0ur_l3ak_m1ght_l3ak': return True, "You're now an elite hacker..." else: return False, "Keep digging..."
def ZG_rprod(X,Y): if len(X.shape) < 2: X = X[:,None] n,m = X.shape if Y.shape[0] != n or len(Y.shape) != 1: print('rprod error') return None Y = Y[:,None] Z = np.multiply(X,np.matmul(Y,np.ones((1,m)))) return Z
possibles = { "A": "01000001", "B": "01000010", "C": "01000011", "D": "01000100", "E": "01000101", "F": "01000110", "G": "01000111", "H": "01001000", "I": "01001001", "J": "01001010", "K": "01001011", "L": "01001100", "M": "01001101", "N...
# Emulating the badge module # # The badge module is a C module with Python bindings # on the real badge, but for the emulator it's just a # plain python module. def nvs_get_u16(namespace, key, value): return value def eink_init(): "ok" def safe_mode(): return False
#import In.entity class Message(In.entity.Entity): '''Message Entity class. ''' room_id = None def __init__(self, data = None, items = None, **args): super().__init__(data, items, **args) @IN.register('Message', type = 'Entitier') class MessageEntitier(In.entity.EntityEntitier): '''Base Message Enti...
x = [ 0, 2, 5, 10] y = [ 0, 3, 5] def carresgrosselistedistance(x, y): xlist = list() ylist = list() grosse_liste = list() print(len(x), len(y)) for i in range(len(x)): try: xlist.append(x[i + 1] - x[i]) except IndexError: xlist.append(x[i]) for i in ra...
# -*- coding: utf-8 -*- """ Created on Mon Feb 24 16:24:05 2020 @author: mberutti """ class Data: """ Class for managing, storing, and broadcasting data transmitted from the camera. """ def __init__(self, data_path): self.data_path = data_path self.results = None ...
def capitals_first(string): words = string.split() st1 = [] st2 = [] for word in words: if word[0].isalpha(): if word[0].isupper(): st1.append(word) else: st2.append(word) return " ".join(st1 + st2)
# local usage only dbconfig = { 'host' : '172.29.0.2', 'port' : 3306, 'db' : 'routing', 'user' : 'dev', 'password' : 'admin', }
''' Author : kazi_amit_hasan Problem: Hello 2019,Problem A Solution: Just check that first input is present in next input or not ''' t= input() h = input() if t[0] in h or t[1] in h: print("YES") else: print("NO")
#!/usr/bin/py # Head ends here def pairs(a,k): # a is the list of numbers and k is the difference value count = 0 compls = {} for i in a: if i in compls: count += compls[i] compls[i + k] = compls[i + k] + 1 if i+k in compls else 1 compls[i - k] = compls[i - k] + 1 if ...
def main(): for i in range (1001, 3339): a = i b = a + 3330 c = b + 3330 flag = False flag2 = False for eachNum in str(a): if not (eachNum in str(b) or eachNum in str(c)): for eachOtherNum in str(b): if not eachOthe...
SUPPORT_PROTOCOL_VERSIONS = [3, 4] SUPPORT_PROTOCOLS = ["MQIsdp" ,"MQTT"] class TYPE(): R_0 = "\x00" CONNECT = "\01" CONNACK = "\x02" PUBLISH = "\x03" PUBACK = "\x04" PUBREC = "\x05" PUBREL = "\x06" PUBCOMP = "\x07" SUBSCRIBE = "\x08" SUBACK = "\x09" UNSUBSCRIBE = "\x0a" ...
class Solution: def diagonalSum(self, mat: List[List[int]]) -> int: total = 0 for i in range(len(mat)): total += mat[i][i] # elements from the primary diagonal total += mat[i][len(mat)-1-i] # secondary diagonal if len(mat) % 2 == 0: return total ...
"""Migration 001 Migration ID: 123 Revises: Created at: 01/01/2001 """ # Nomade migration identifiers migration_name = 'Migration 001' migration_date = '01/01/2001' curr_migration = '123' down_migration = '' def upgrade(): """Write your upgrade statements here.""" def downgrade(): """Write your downgrade ...
valorPorHora = float(input('Quanto voce ganha por hora: ')) horasTrabalhadas = float(input('Quantas horas voce trabalhou no mes: ')) salarioBruto = valorPorHora * horasTrabalhadas impostoRenda = salarioBruto * 0.11 inss = salarioBruto * 0.08 sindicato = salarioBruto * 0.05 salarioLiquido = salarioBruto - impostoRenda ...
def define_best_name(name1, name2): if len(name1) > len(name2): return name1 return name2 my_name = "Tom Thompsom" your_name = "Lauretius Maximus" the_best_name = define_best_name(my_name, your_name)
def resolve(): ''' code here Sを先頭 真ん中 お尻の三分割する 連結した場合を考えると以下の場合分け 先頭 お尻 真ん中×K (先頭₊お尻)×(K-1) 同じ文字が続いたらn//2個の文字変更が必要 以上で解けるた ''' S = input() K = int(input()) S_head = '' head = S[0] for s in S: if s == head: S_head += s else: br...
print("""\033[2;36m __ __ ____ _ _ \ \/ / | _ \ _ __ ___ (_) __| | \ /_____| | | | '__/ _ \| |/ _` | / \_____| |_| | | | (_) | | (_| | /_/\_\ |____/|_| \___/|_|\__,_|v0.1® """) db = {} print('Welcome!, I am X~Droid v0.1\nDesigned by Myth for data storage\n') while True: ...
BATCH_SIZE = 512 D_MODEL = 512 P_DROP = 0.1 D_FF = 2048 HEADS = 8 LAYERS = 6 LR = 1e-3 EPOCHS = 40
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def rotateRight(self, head: Optional[ListNode], k: int) -> Optional[ListNode]: if head is None: return head #Fin...
# Python - 3.4.3 fib = {0: 0, 1: 1} def fibonacci(n): if not n in fib: fib[n - 2] = fibonacci(n - 2) fib[n - 1] = fibonacci(n - 1) fib[n] = fib[n - 1] + fib[n - 2] return fib[n]
""" Contains custom exceptions """ class MissingSetting(Exception): """ When a setting is missing """ def __init__(self, setting_name): self.setting_name = setting_name super().__init__( f"Could not find setting '{self.setting_name}' in 'PAGE_SHARER' settings." )
# Try comparison operators in this quiz! This code calculates the # population densities of Rio de Janeiro and San Francisco. sf_population, sf_area = 864816, 231.89 rio_population, rio_area = 6453682, 486.5 san_francisco_pop_density = sf_population/sf_area rio_de_janeiro_pop_density = rio_population/rio_area # Writ...
""" The submodule that handles form processing. """ def process(**kwargs): """ Processes the form arguments and returns a message to display to the user. Keyword Arguments ----------------- The keyword arguments are of the form: { 'name': value } Where the name is t...
def create_matrix(rows): result = [] for _ in range(rows): row = [int(el) for el in input().split(", ")] result.append(row) return result def get_biggest_sum_elements(matrix, r, c): result = [matrix[r][c:c + 2], matrix[r + 1][c:c + 2]] return result def print_result(biggest_sum, bi...
# Unindo dicionários e listas '''Crie um program que leia NOME, SEXO e IDADE de VÁRIAS PESSOAS, guardando os dados de cada pessoa em um DICIONÁRIO e todos os dicionários em uma LISTA. No final, mostre: A) Quantas pessoas foram cadastradas B) A MÉDIA de idade do grupo C) Uma lista com todas as MULHERES D) Uma lista com ...
global v, foo v = 1 v = 2 print(v) def foo(): return 1 try: def foo(): return 2 except RuntimeError: print("RuntimeError1") print(foo()) def __main__(): pass
# Problem: https://www.hackerrank.com/challenges/list-comprehensions/problem if __name__ == '__main__': x = int(input()) y = int(input()) z = int(input()) n = int(input())
class Pessoa: tamanho_cpf = 11 p = Pessoa() print(p.tamanho_cpf) p.tamanho_cpf = 12 print(p.tamanho_cpf) print(Pessoa.tamanho_cpf)
__version__ = '1.8' __name__ = 'Zhihu Favorite' class Document: def __init__(self, meta, content): self.meta = meta self.content = content self.images = list() def convert2(self, converter, file): file.write(converter(self).tostring()) class DocBuilder: def __init__(self...
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def isValidBST(self, root): """ :type root: TreeNode :rtype: bool """ de...
class Player: def __init__(self, name: str, sprint: int, dribble: int, passing: int, shooting: int): self.__name = name self.__sprint = sprint self.__dribble = dribble self.__passing = passing self.__shooting = shooting @property def name(self): return self._...
def designerPdfViewer(h, word): word = list(word) height = 0 width = len(word) for x in word: current = h[ord(x)-97] if current > height: height = current return height * width
pkgname = "lame" pkgver = "3.100" pkgrel = 0 build_style = "gnu_configure" configure_args = ["--enable-nasm", "--enable-shared"] hostmakedepends = ["nasm"] makedepends = ["ncurses-devel"] pkgdesc = "Fast, high quality MP3 encoder" maintainer = "q66 <q66@chimera-linux.org>" license = "LGPL-2.1-or-later" url = "https://l...
# anagram! # remove each string that is an anagram of an earlier string, then return an ordered list of the remaining words # example: # input: ['code', 'doce', 'frame', 'edoc', 'framer'] # output: 'code', 'frame', 'framer' # input = ['poke', 'ekop', 'kope', 'peok'] # output = ['poke'] # start with a brute force algor...
class MagicList : def __init__(self): self.data = [0] def findMin(self): M = self.data smallest= min(M) return(smallest) def insert(self, E): M = self.data M.append(E) l=len(M) i= l-1 while (i//2 >= 1 and M[i//2] > M[i]): ...
class Node: def __init__(self, value): self.value = value self.next = None max_node = 1_000_000 nodes = {i: Node(i) for i in range(1, max_node + 1)} initial_arrangement = [1, 5, 6, 7, 9, 4, 8, 2, 3, 10] current = nodes[initial_arrangement[0]] for i in range(1, len(initial_arrangement)): prev ...
""" Main test configuration """ def pytest_addoption(parser): """Add extra CLI options for integration testing""" # TODO(RKM 2019-12-31) Update docs parser.addoption("--run-integration", action="store_true") parser.addoption("--docker-host", action="store") parser.addoption( "--integratio...
# Solution to Advent of Code 2020 day 5 # Read data with open("input.txt") as inFile: seats = inFile.read().split("\n") # Part 1 seatIDs = [] for seat in seats: row = int(seat[:7].replace("F", "0").replace("B", "1"), base=2) column = int(seat[7:].replace("L", "0").replace("R", "1"), base=2) seatIDs.ap...
def factorial(n): if 0 < n < 13: return n * factorial(n-1) elif n == 0: return 1 else: raise ValueError
# Name or IP of the machine running vocabulary pet server HOST = 'localhost' # Port Name of vocabulary pet server PORT = '8080' # Please fill into the brakets the root directory of vocabulary pet # Example: STATIC_PATH = '/home/user/vocabulary_pet/static' STATIC_PATH = '/<vocabulary_pet_directory>/static'