content
stringlengths
7
1.05M
# VSPAX (Virtual Serial Port Active X ) OnRxChar = 1 OnDTR = 2 OnRTS = 3 OnRing = 4 OnOpenClose = 5 OnTimeouts = 6 OnLineControl = 7 OnHandflow = 8 OnSpecialChars = 9 OnBaudRate = 10 OnDCD = 11 OnEvent = 12 VSPort_ActiveX_ProgID = "VSPort.VSPortAx.1"
# -*- coding:utf-8 -*- # @Time : 2021/8/18 13:43 # @Author : Charon. __version_info__ = ('1', '2', '0') __version__ = '.'.join(__version_info__)
"""242 · Convert Binary Tree to Linked Lists by Depth""" """ Definition of TreeNode: class TreeNode: def __init__(self, val): this.val = val this.left, this.right = None, None Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None ...
# coding: utf-8 __author__ = 'damirazo <me@damirazo.ru>' class ConversionTypeEnum(object): u""" Перечисления доступных типов для конвертации при парсинге шаблона конфигурации """ STRING = 'string' INTEGER = 'integer' DECIMAL = 'decimal' BOOL = 'bool'
''' 중요! Python에서 문자열도 list내에서 정렬 가능! (list: string).sort() var.isalpha() 알파벳이면 True, 아니면 False seperator_string.join(iterable) iterable 객체를 편하게 string으로 만드는 함수 ''' data = input() nums = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'} strings = [] sum = 0 for i in range(len(data)): # 0 ~ N-1 if data[i] in nu...
#in_both (ch 8.9) #brupoon 2014 def in_both(word1, word2): """Prints all letters in word1 that appear in word2""" for letter in word1: if letter in word2: print(letter) if __name__ == '__main__': in_both("apple","orange")
class FilterIntegerRule(FilterNumericValueRule,IDisposable): """ A filter rule that operates on integer values in a Revit project. FilterIntegerRule(valueProvider: FilterableValueProvider,evaluator: FilterNumericRuleEvaluator,ruleValue: int) """ def Dispose(self): """ Dispose(self: FilterRule,A_0: b...
numero = int(input('Ingresa un numero positivo')) if numero <= 0: print('Le indicamos que el valor sea positivo') # print("El valor capturado es ", numero) print("I'm") print(f"El valor capturado es {numero} por tanto es correcto")
#DESGLOSE BILLETES Y MONEDAS #funciones def desglose (cantidad): """ int --> int OBJ: Desglose en billetes y monedas """ #500 num_500 = cantidad // 500 resto_500 = cantidad % 500 if num_500 > 0: print('Billetes de 500 € : ', num_500) #200 num_200 = resto_500 // 200 ...
class Switch: def __init__(self): self.cases = {} def case(self, case, function, parameters=None): self.cases[str(case)] = {"name": function, "parameters": parameters} def switch(self, case): if (func := self.cases.get(str(case))): name = func['name'] if fun...
#!/usr/bin/python # -*- encoding: utf-8; py-indent-offset: 4 -*- # +------------------------------------------------------------------+ # | ____ _ _ __ __ _ __ | # | / ___| |__ ___ ___| | __ | \/ | |/ / | # | | | | '_ \ / _ \/ __| |/ /...
# -*- encoding: utf-8 -*- """ __init__.py.py Created on 2018/7/11 13:25 Copyright (c) 2018/7/11, @author: 马家树(majstx@163.com) """
def shellSort(arr): gaps = [701, 301, 132, 57, 23, 10, 4, 1] #go through each gap for gap in gaps: #no point in going through a gap larger than the array if gap > len(arr): continue #perform insertion sort on the sublists created by the gap value for start in range(gap): #for every element in the c...
#!/usr/bin/env python3 def main(): for _ in range(int(input())): n, m = [int(n) for n in input().split()] ans = '<' if n < m else '>' if n > m else '=' print(ans) if __name__ == '__main__': main()
def sort(numbers): for i in range(len(numbers) - 1, 0, -1): for j in range(i): if numbers[j] > numbers[j + 1]: temp = numbers[j] numbers[j] = numbers[j + 1] numbers[j + 1] = temp
# 优先处理出来数组中的前缀和后缀 # 如果长度等于总长度那么长度就是 0 # 其他的话就是从前缀的前面取 或者从后缀的后面取 总数就是总长度 class Solution: def findLengthOfShortestSubarray(self, arr: List[int]) -> int: n = len(arr) x = -1 l1 = [] for a in arr: if a >= x: l1.append(a); x = a else: break l2 = [] ...
class Order: def __init__(self, orderId: int, orderDate, customerId: int, productId: int, unitsOrdered: int, remarks): self.orderId = orderId self.orderDate = orderDate self.customerId = customerId self.productId = productId self.unitsOrdered = unitsOrdered self.remar...
A,B = map(int,input().split()) change = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" input() num = list(map(int,input().split())) if num[0] != 0: change_num = "" for i in num: change_num += change[i] ten_num = int(change_num,A) rem = [] while ten_num: rem.append(ten_num%B) ten_n...
''' A programação orientada a objetos é um dos paradigmas de programação. Detalhes: . Os paradigmas que existem são: imperativo, funcional, lógico e orientado a objetos Como diz o nome, é uma forma de programar baseando-se em objetos. Deste modo temos quatro pilares fundamentais de OO: . Abstração: na hora de repre...
class Car(): def __init__(self, manufacturer, model, year): self.manufacturer = manufacturer self.model = model self.year = year self.odometer_reading = 0 def get_descriptive_name(self): long_name = f"{self.year} {self.manufacturer} {self.model}" return ...
PRACTICE = False with open("test.txt" if PRACTICE else "input.txt", "r") as f: content = f.read().strip() required_close_brackets = { x[0]: x[1] for x in ("()", "[]", "{}", "<>") } score_key = {")": 1, "]": 2, "}": 3, ">": 4} scores = [] for line in content.split("\n"): stack = [] for i, c in enumer...
# -*- coding: utf-8 -*- """ This package contains modules wrapping different functions to call the system's status. Some parts of this package are specific to Raspberry Pi and Raspbian, and are marked accordingly in their respective doc strings. """
def getSmallestElement(array): smallestElement = array[0] smallestIndex = 0 for i in range(1, len(array)): if array[i] < smallestElement: smallestElement = array[i] smallestIndex = i return smallestIndex def selectionSort(array): newArray = [] for i in range(len...
def menu(): c = 0 while c == 0: try: print("Bem-vindo ao jogo do NIM! Escolha:") print(" ") print("1 - para jogar uma partida isolada") c = int(input("2 - para jogar um campeonato ")) if c != 1 and c != 2: c = 0 except ValueError: c = 0 if c==1: print("\nVoce escolheu uma partida isolada...
S = input() K = int(input()) for i in range(len(S)): if S[i] == '1': K -= 1 if K == 0: print(S[i]) break else: print(S[i]) break
class BaseScraper: def __init__(self, url): self.url = url def scrape(self): return {}
teste = list() teste.append('Gustavo') teste.append(40) print(teste) galera = list() galera.append(teste[:]) print(galera) teste[0] = "Maria" teste[1] = 22 galera.append(teste) print(galera) turma = [['Joao', 19], ['Ana', 33], ['Maria', 45], ['Joaquim', 13]] print(turma) print(turma[0]) print(turma[0][0]) print(turma[...
""" DOCSTRING: Bu çok güzel bir modüldür :) """ print("Module added!") def sayHello(): print("merhabalar dünyalı :)")
username = driver.find_element_by_id('username') username.send_keys('username') password = driver.find_element_by_id('password') password.send_keys('password') login = driver.find_element_by_id('login') login.click() header = driver.find_element_by_id('header') assert 'logged in' in header.get_attribute('text') next = ...
nome = str(input('Digite seu nome: ')) if nome == 'Victor' or nome == 'Angela': print('Que nome bonito!') elif nome == 'Maria' or nome == 'Paulo' or nome == 'José': print('Seu nome é muito comum no Brasil') else: print('Seu nome é bem normal.') print('Tenha um bom dia {}'.format(nome))
{ "name" : "Foyer", "description" : "You're standing in the foyer of the building. You have stepped in here to escape a roaring thunderstorm which has left you soaked. You can see a doorway to the north.", "neighbors" : {"n" : 2} }
__author__ = 'Roman Morozov' def convert_list_in_str(list_in: list) -> str: # a sort_list: list = list_in[::-1] for i in sort_list: if sort_list[sort_list.index(i)].isdigit() is True and sort_list[sort_list.index(i)].startswith('"') is False: sort_list.insert(sort_list.index(i) + 1, '...
"""Top-level numpy-api-bench __init__.py. .. codeauthor:: Derek Huang <djh458@stern.nyu.edu> """ __version__ = "0.1.0"
def func(): outra_variavel = 'Denetrius' return outra_variavel def func2(arg): print(arg) var = func() func2(var)
"""constants.py Stores constants such as number of nodes NNODES etc.""" NNODES_ov_RLL10deg_CSne4 = 683 NNODES_outCSne8 = 386 NNODES_outCSne30 = 5402 NNODES_outRLL1deg = 64442 DATAVARS_outCSne30 = 2
# URI Online Judge 1164 N = int(input()) for i in range(N): sum = 0 entrada = int(input()) for j in range(1,entrada): if entrada%j==0: sum += j if entrada == sum: print("{} eh perfeito".format(entrada)) else: print("{} nao eh perfeito".format(entrada))
class Ponto: def __init__(self, x, y, z): self.x = x self.y = y self.z = z class Vetor: def __init__(self, x, y, z): self.x = x self.y = y self.z = z class Segmento: def __init__(self, p1, p2): self.p1 = p1 self.p2 = p2 class Reta: def _...
#base class class person: def dislay(self): print("Here the element of base class person...!!!! \n") #derived class_1 class employee(person): def printing(self): print("Here the element of first element of derived class.....!!!! \n") # derived class_2 class programmer(employee): def sh...
class ODLRemoveOpenflowFlow(object): def __init__(self, odl_client, logger): """ :param cloudshell.sdn.odl.client.ODLClient odl_client: :param logging.Logger logger: """ self._odl_client = odl_client self._logger = logger def execute_flow(self, node_id, table_id...
contador=0 somador=0 while contador< 5: contador = contador + 1 valor = float(input('digite o'+str(contador)+ 'valor:')) somador = somador + valor print ('soma = ', somador)
#!/usr/bin/python # encoding: utf-8 """ @author: Ian @file: main.py @time: 2019-06-19 15:42 """ if __name__ == '__main__': while True: print('please select: 1) data explore; 2) train; 3) test') a = input() if a == 'q': print(f'bye! {a}') break print(f'hi {a}'...
string = "Hello, World!" string2 = "- Hello to you!" string3 = string + '' + string2 count = len(string) print(f"Count symbols: {count}") print(string3) print((string + "")*3) string = "I aM a StrinG aNd i wAnt To Be pRinTed" print(string.upper()) print(string.lower()) print(string.capitalize()) print(string.title()) s...
# Control def double(a: int) -> int: return 2*a # Remove the brackets def double(a: int) -> (int): return 2*a # Some newline variations def double(a: int) -> ( int): return 2*a def double(a: int) -> (int ): return 2*a def double(a: int) -> ( int ): return 2*a # Don't lose the comments d...
# -*- coding: utf-8 -*- db_config = { 'user': 'root', 'password': 'root', 'host': 'localhost', 'db': 'bac_db' } bot_code = "INSERT:TELEGRAM-BOT-TOKEN- HERE"
# ==================================================================================================== # This file provides class with the necessary sub functions for the calculation of breakpoint distance # ==================================================================================================== class bp_a...
class IResponseCallback: def on_response(self, response): """handle the async response of the mqtt request :param response: :return: """ print('[async] receive {} successfully, code: {}'.format(response.get_class(), str(response.get_code()))) def on_failure(self, except...
test_cases = int(input().strip()) for t in range(1, test_cases + 1): n, m, k = tuple(map(int, input().strip().split())) persons = list(map(int, input().strip().split())) persons.sort() result = 1 cnt = 1 for p in persons: fish = (p // m) * k if fish - cnt < 0: result...
"""Color palette 'The New Defaults' from clrs.cc""" clrs = { "aqua": "#7FDBFF", "blue": "#0074D9", "navy": "#001F3F", "teal": "#39CCCC", "green": "#2ECC40", "olive": "#3D9970", "lime": "#01FF70", "yellow": "#FFDC00", "orange": "#FF851B", "red": "#FF4136", "fuchsia": "#F012BE"...
# https://leetcode.com/problems/minimum-number-of-frogs-croaking class Solution: def minNumberOfFrogs(self, croakOfFrogs: str) -> int: min_frog = 0 status = [0,0,0,0,0] cindex_dict = { "c": 0, "r": 1, "o": 2, "a": 3, "k": 4 ...
## Automatically adapted for numpy Apr 14, 2006 by convertcode.py class infodata: def __init__(self, filenm): self.breaks = 0 for line in open(filenm): if line.startswith(" Data file name"): self.basenm = line.split("=")[-1].strip() continue i...
cpal = [ 0.0000060916, 0.0000090829, 0.0000166305, 0.0000300004, 0.0000543398, 0.0000914975, 0.0001482915, 0.0001569609, 0.0001661808, 0.0002504709 ] qpal = [ 0.0171114387, 0.0179425966, 0.0118157289, 0.0111629430, 0.0099376996, 0.0104620373, 0.0122294195, 0.0105990863, 0.0102895846, 0.0119658362 ] cole = [ 0.0000812...
''' Copyright (c) The Dojo Foundation 2011. All Rights Reserved. Copyright (c) IBM Corporation 2008, 2011. All Rights Reserved. ''' def getServiceNameFromChannel(channel, pub): # Public channels are of form /bot/<NAME> # Private channels are of form /service/bot/<NAME>/(request|response) parts = channel.sp...
class ConfigError(Exception): def __init__(self, config_option, value): self.config_option = config_option self.value = value class UnhandledObjectError(Exception): def __init__(self, obj_type): self.obj_type = obj_type class UnimplementedOutcomeError(Exception): def __init__(sel...
''' Univesidade Federal de Pernambuco -- UFPE (http://www.ufpe.br) Centro de Informatica -- CIn (http://www.cin.ufpe.br) IF969 -- Algoritmos e Estruturas de Dados Autor: Saulo de Sousa Joseph Email: ssj2@cin.ufpe.br Data: 10/09/2019 Descricao: lista de monitoria Q1 Licenca: The MIT License (MIT) ''' ...
duration = int(input('Введите количество секунд: ')) seconds = duration % 60 minutes = duration // 60 % 60 hours = duration // 3600 % 24 days = duration // 86400 if (minutes == 0) and (hours == 0) and (days == 0): print('{} сек'.format(seconds)) elif (hours == 0) and (days == 0): print('{} мин, {} сек'.format...
#Filename : 9x9.py #author by: Thomas.Wu #use for print("------------------Use for to do 9x9----------------") for i in range(1, 10): for j in range(1, i+1): print('{}x{}={}\t'.format(j, i, i*j), end='') print() #V2 #use while print("------------------Use While to 9x9------------------") i = 1 while i...
# -*- coding: utf-8 -*- n = int(input()) for x in range(n): qtd_pessoas = int(input()) lista = [] for y in range(qtd_pessoas): lista.append(input()) if all(e == lista[0] for e in lista): print(lista[0]) else: print('ingles')
class Solution(object): def isAdditiveNumberInternal(self, num, l1, l2): n1 = num[:l1] n2 = num[l1:l1 + l2] if (len(n1) > 1 and n1[0] == '0') or (len(n2) > 1 and n2[0] == '0'): return False n1, n2 = int(n1), int(n2) cur = l1 + l2 while True: if...
# We can get a part of list by using slice. my_list = ["h", "e", "l", "l", "o", "!"] print(my_list[0:3]) # Returns 0 - 2nd index print(my_list[:]) # clone full list print(my_list[-1]) # Special way to get last element del my_list[2] # delete item from list. print(my_list)
def get_python_executables(): """ :return: Linux maya python executables :rtype: dict """ maya_pythons = {} return maya_pythons
# !/usr/bin/python # -*- coding:utf-8 -*- # *********************************************************************** # Author: Zhichang Fu # Created Time: 2018-08-25 11:04:06 # Function: # Exception module # *********************************************************************** class UnknownDB(Exception): """r...
#n! means n × (n − 1) × ... × 3 × 2 × 1 #For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800, #and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. #Find the sum of the digits in the number 100! def factorial(n): st = 1 for i in range(1, n+1): st *= i return st def na...
''' Given a string and a pattern, find out if the string contains any permutation of the pattern. Example: s="oidbcaf", pattern="abc", Output: True Time complexity: O(len(pattern) + len(s)) Space complexity: O(len(pattern)) ''' class Solution: def checkInclusion(self, pattern: str, s: str) -> bool: # re...
# Maximize Distance to Closest Person ''' You are given an array representing a row of seats where seats[i] = 1 represents a person sitting in the ith seat, and seats[i] = 0 represents that the ith seat is empty (0-indexed). There is at least one empty seat, and at least one person sitting. Alex wants to sit in the ...
#!/usr/local/bin/python3 INPUT = "597662997341859357902611157036208771903818242152098532077631945761286356313596828766120793552153504735776047215557289042266690216296378293233573125233893740967616776128472704996683708081711977654975119692404514948640287120457947767118622758534054654011813904187289966467945017396009280...
# -*- coding: utf-8 -*- class Message(): def __init__(self): self.dict = { # 正常 0 : '0', # 软件运行错误 'Error(0001)': 'Error(0001): 软件运行错误,请连续管理员!', # 文件数据错误 'Error(1000)': 'Error(1000): Seg文件读取错误,请检测Seg数据!', 'Error(1001)': 'Err...
OPERATION_VALIDATION_PLUGIN_PATH_VALUE = "operation_verification" AUCTION_REQ_VALIDATION_PLUGIN_PATH_VALUE = "auction_req_validation" AUCTION_REQ_PROCESSOR_PLUGIN_PATH_VALUE = "auction_req_processor" BANK_REQ_VALIDATION_PLUGIN_PATH_VALUE = "bank_req_validation" BANK_REQ_PROCESSOR_PLUGIN_PATH_VALUE = "bank_req_processor...
total = 0 totalRibbon = 0 f = open("input.txt") for line in f: temp = "" length = 0 width = 0 height = 0 for c in line: if c.isdigit(): temp += c else: if length == 0: length = int(temp) elif width == 0: width = int(temp) elif height == 0: height = int(temp) temp = "" area = ...
def rounding(*args): result = [] for el in args[0]: result.append(round(float(el))) return result print(rounding(input().split()))
class Unit(): KB = 1024 MB = 1024 * 1024 GB = 1024 * 1024 * 1024 TB = 1024 * 1024 * 1024 * 1024 SI = 1000 KiB = 1000 MiB = 1000 * 1000 GiB = 1000 * 1000 * 1000 TiB = 1000 * 1000 * 1000 * 1000 class DeviceKey(): """Zabbixのデバイスディスカバリに使うキー """ KEY = 'smartmontools.discovery...
Carless = Goalkeeper('Ben Carless', 68, 65, 66, 67) Kyriakides = Outfield_Player('Dan Kyriakides', 'DF', 63, 74, 67, 63, 66, 65) Cornick = Outfield_Player('Andrew Cornick', 'MF', 67, 66, 68, 63, 69, 65) Brignull = Outfield_Player('Liam Brignull', 'MF', 62, 69, 65, 69, 67, 65) Furlong = Outfield_Player('Gareth Furlo...
def playHand(hand, wordList, n): """ Allows the user to play the given hand, as follows: * The hand is displayed. * The user may input a word or a single period (the string ".") to indicate they're done playing * Invalid words are rejected, and a message is displayed asking the user to...
# # @lc app=leetcode id=735 lang=python3 # # [735] Asteroid Collision # # https://leetcode.com/problems/asteroid-collision/description/ # # algorithms # Medium (40.39%) # Likes: 882 # Dislikes: 100 # Total Accepted: 53.2K # Total Submissions: 131.6K # Testcase Example: '[5,10,-5]' # # # We are given an array as...
USER_ABS_ENDPOINT_NAME = '/user' REQ_USER_ID_KEY_NAME = 'id' RES_USER_ID_KEY_NAME = 'id' RES_USER_EMAIL_KEY_NAME = 'email' RES_USER_FIRST_NAME_KEY_NAME = 'first_name' RES_USER_LAST_NAME_KEY_NAME = 'last_name' RES_USER_PROFILE_PICTURE_URL_KEY_NAME = 'profile_image_url' RES_USER_GENDER_KEY_NAME = 'gender' ...
## -*- coding: utf-8 -*- nodo = { "nombre": "juan", "edad": 15 }
def binary_length(n): if n == 0: return 0 else: return 1 + binary_length(n / 256) def to_binary_array(n,L=None): if L is None: L = binary_length(n) if n == 0: return [] else: x = to_binary_array(n / 256) x.append(n % 256) return x def to_binary(n,L=None): return ''.join([ch...
def input_file_to_list(file_path): with open(file_path, 'r') as input_file: output = list(map(int, input_file.read().split(','))) return output def run_intcode_program(intcode_input): index = 0 while intcode_input[index] in [1, 2]: opcode, first_value, second_value, position = intcode_...
nota1 = float(input('Digite a primeira nota ')) nota2 = float(input('Digite a segunda nota ')) nota3 = float(input('Digite a terceira nota ')) nota4 = float(input('Digite a ultima nota ')) media = (nota1 + nota2 + nota3 + nota4) / 4 print('PARABENS!! A sua média é de: {}!'.format(media))
print(" ****** Bienvenido al Registro de Promedios por Materias Y Alumnos ****** ") print(" ") print ("*******************************************************") print(" ") k = input("Ingresar la cantidad deseada de nombres de alumnos y promedios que desea conseguir: \n") try: cant = int(k) except : print("L...
class BaseConfig(object): DEBUG = False TESTING = False SECRET_KEY = 'this-really-needs-to-be-changed' MONGO_USERNAME = 'username' MONGO_PASSWORD = 'password' MONGO_URI = f'mongodb://{MONGO_USERNAME}:{MONGO_PASSWORD}@localhost:27017/photoseleven' TOKEN_EXPIRATION_DAYS = 365 UPLOADS_DIR =...
""" Simple solution Step-1: Find the sum (s) of all the values in array[] Step-2: Replace every arra[i] with s/arra[i] """ def solution(input_list): product = 1 for i in input_list: product *= i for i in range(len(input_list)): input_list[i] = int(product / input_list[i]) if __n...
""" Given an infinite number of quarters (25 cents), dimes (10 cents), nickels (5 cents) and pennies (1 cent), write code to calculate the number of ways of representing n cents """
n = int(input()) i = 1 print(i, end=" ") while True: if i * 2 > n: break print(i * 2, end=" ") i *= 2
def sortByHeight(a): copy = a[:] while -1 in copy: copy.remove(-1) copy.sort() counter = 0 for number in range(len(a)): if a[number] != -1: a[number] = copy[counter] counter += 1 return a
def resolve(): ''' code here ''' N = int(input()) As = [int(item) for item in input().split()] memo = As[0] res = 0 for i in range(N-1): res += (memo * As[i+1])%(10**9 + 7) memo += As[i+1] print(res % (10**9 + 7)) if __name__ == "__main__": resolve()
# # PySNMP MIB module HPN-ICF-USER-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-USER-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:29:41 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar ...
DATE_STRING_FORMAT = '%Y-%m-%d' COLLOQUIAL_DATE_LOOKUP = ( 'Today', 'Tomorrow', ) WEEKDAY_LOOKUP = ( 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday', )
# # PySNMP MIB module ARMILLAIRE2000-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ARMILLAIRE2000-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:25:22 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, ...
""" Colorful dots. """ class Dot(): def __init__(self, s: str) -> None: self.s = s def __str__(self): return self.s BLACK = Dot("○") BLUE = Dot("\x1b[34m●\x1b[0m") GREEN = Dot("\x1b[32m●\x1b[0m") ORANGE = Dot("\x1b[33m●\x1b[0m") RED = Dot("\x1b[31m●\x1b[0m") WHITE = Dot("●")
class Equipe(): def getContext(self): return self.__contextEquipe(self) def __parceiros(self): parceiros = [ { "nome": "#TodosContraoCorona", "short": "todoscontraocorona", "url": "https://www.facebook.com/centrouniversitariode...
TRAIN_BEGIN = 'TRAIN_BEGIN' TRAIN_END = 'TRAIN_END' EPOCH_BEGIN = 'EPOCH_BEGIN' EPOCH_END = 'EPOCH_END' BATCH_BEGIN = 'BATCH_BEGIN' BATCH_END = 'BATCH_END'
"""An implementation of the Enigma Machine in Python. This is a toy project intending to implement the Enigma Machine as originally designed by Arthur Scherbius. Based on project: https://github.com/ZAdamMac/python-enigma Modyfication by Adam Jurkiewicz adam(at)abixedukacja.eu - 2020 Apache 2.0 License """ default_...
r""" Given a binary tree, return the tilt of the whole tree. The tilt of a tree node is defined as the absolute difference between the sum of all left subtree node values and the sum of all right subtree node values. Null node has tilt 0. The tilt of the whole tree is defined as the sum of all nodes' tilt. Example: ...
class Solution: def isPalindrome(self, x: int) -> bool: output = [] if x < 0: return False elif x == 0: return True i = 0 while x > 0: last_digit = x % 10 if i == 0 and last_digit == 0: return False i...
def counting_sort(x): N = len(x) M = max(x) + 1 a = [0] * M for v in x: a[v] += 1 res = [] for i in range(M): for j in range(a[i]): res.append(i) return res def counting_sort2(x): N = len(x) M = max(x) + 1 c = [0] * M for v in x: c[v] += ...
'''13. Faça um programa que receba quatro valores: I, A, B e C. Desses valores, I é inteiro e positivo, A, B e C são reais. Escreva os números A, B e C obedecendo à tabela a seguir. Suponha que o valor digitado para I seja sempre um valor válido, ou seja, 1, 2 ou 3, e que os números digitados sejam diferentes um do ou...
class Solution: def countSubstrings(self, s): dp = [[0] * len(s) for i in range(len(s))] res = 0 for r in range(len(s)): for l in range(r+1): if s[r] == s[l]: if r == l or r+1 == l or dp[l+1][r-1] == 1: dp[l][r] = 1 ...
# coding: utf-8 # # Copyright 2022 :Barry-Thomas-Paul: Moss # # Licensed under the Apache License, Version 2.0 (the "License") # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http: // www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
""" A module with a well-specified function Author: Walker M. White Date: February 14, 2019 """ def number_vowels(w): """ Returns: number of vowels in string w. Vowels are defined to be 'a','e','i','o', and 'u'. 'y' is a vowel if it is not at the start of the word. Repeated vowels are counte...
# projecteuler.net/problem=52 def main(): answer = PermutatedMul() print("Answer: {}".format(answer)) def PermutatedMul(): i = 1 muls = [2,3,4,5,6] while True: found = True i += 1 si = list(str(i)) ops = list(map(lambda x: x * i, muls)) for...