content
stringlengths
7
1.05M
''' Created on Aug 4, 2012 @author: vinnie ''' class Rotor(object): def __init__(self, symbols, permutation): ''' ''' self.states = [] self.inverse_states = [] self.n_symbols = len(symbols) for i in range(self.n_symbols): self.states.append({sy...
class BasePexelError(Exception): pass class EndpointNotExists(BasePexelError): def __init__(self, end_point, _enum) -> None: options = _enum.__members__.keys() self.message = f'Endpoint "{end_point}" not exists. Valid endpoints: {", ".join(options)}' super().__init__(self.message) c...
"""Containers for DL CONTROL file MC move type descriptions Moves are part of the DL CONTROL file input. Each type of move gets a class here. The classification of the available Move types is as follows: Move MCMove AtomMove MoleculeMove ... [others, some of which are untested in regression tests] Vo...
class Person(object): type = '人类' # 类属性 def __init__(self, name, age): self.name = name self.age = age # 对象 p 是通过 Person 类创建出来的 p = Person('zs', 18) # Person类存在哪个地方 # 只要创建了一个实例对象,这个实例对象就有自己的name和age属性 # 对象属性,每个实例对象都单独保存的属性 # 每个实例对象之间的属性没有关联,互不影响 # 获取类属性:可以通过类对象和实例对象获取 print(Person.type) pr...
#https://www.acmicpc.net/problem/1712 a, b, b2 = map(int, input().split()) if b >= b2: print(-1) else: bx = b2 - b count = a // bx + 1 print(count)
grade_1 = [9.5,8.5,6.45,21] grade_1_sum = sum(grade_1) print(grade_1_sum) grade_1_len = len(grade_1) print(grade_1_len) grade_avg = grade_1_sum/grade_1_len print(grade_avg) # create Function def mean(myList): the_mean = sum(myList) / len(myList) return the_mean print(mean([10,1,1,10])) def mean_1(value)...
if 0: pass if 1: pass else: pass if 2: pass elif 3: pass if 4: pass elif 5: pass else: 1
print("Halo") print("This is my program in vscode ") name = input("what your name : ") if name == "Hero": print("Wow your name {} ? , my name is Hero too, nice to meet you ! ".format(name)) else: print("Halo {} , nice to meet you friend".format(name)) age = input("how old are you : ") if age == "21": ...
def foo(numbers, path, index, cur_val, target): if index == len(numbers): return cur_val, path # No point in continuation if cur_val > target: return -1, "" sol_1 = foo(numbers, path+"1", index+1, cur_val+numbers[index], target) # Found the solution. Do not continue. if sol_1[0] == target: ...
# general_sync_utils # similar to music_sync_utils but more general class NameEqualityMixin(): def __eq__(self, other): if isinstance(other, str): return self.name == other return self.name == other.name def __ne__(self, other): return not self.__eq__(other) def __ha...
LABEL_TRASH = -1 LABEL_NOISE = -2 LABEL_ALIEN = -9 LABEL_UNCLASSIFIED = -10 LABEL_NO_WAVEFORM = -11 to_name = { -1: 'Trash', -2 : 'Noise', -9: 'Alien', -10: 'Unclassified', -11: 'No waveforms', }
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( a , b , c ) : if ( a + b <= c ) or ( a + c <= b ) or ( b + c <= a ) : return False else : r...
infile=open("proverbs.txt","r") for line in infile: line=line.rstrip() word_list=line.split() #공백 단어분리 for word in word_list: print(word); infile.close()
# Enter your code here. Read input from STDIN. Print output to STDOUT rd,rm,ry=map(int,input().split()) ed,em,ey=map(int,input().split()) if ry<ey: print("0") elif ry<=ey: if rm<=em: if rd<=ed: print("0") else: print(15*(rd-ed)) else: print(500*(rm-em)) else: ...
# card.py # Implements the Card object. class Card: """ A Card of any type. """ def __init__(self, title, desc, color, holder, is_equip, use): self.title = title self.desc = desc self.color = color self.holder = holder self.is_equipment = is_equip self....
# -*- coding:utf-8 -*- def time_(time_delta): result = "" if time_delta < 60: temp = int(((time_delta / 3600) * 3600) % 60) result = '%s秒前' % temp elif time_delta < 3600: temp = int(((time_delta / 3600) * 3600) / 60) result = '%s分钟前' % temp elif time_delta < 24 * 60 * 60:...
n1 = float(input('Informe a primeira nota do Aluno: ')) n2 = float(input('informe a segunda nota: ')) m = (n1 + n2) / 2 print('Sua media foi de {}'.format(m))
class BaseAnalyzer(object): def __init__(self, base_node): self.base_node = base_node def analyze(self): raise NotImplementedError()
## Exercício 60 do livro Python 3 - Conceitos e Aplicações - Uma Abordagem Didática """ Escreva um programa que leia um número inteiro Q e exiba na tela os Q primeiros termos da sequência de Fibonacci, utilizando uma função recursiva para determinar o elemento da sequência a ser exibido.""" print("Os dez primeiros te...
class Solution: def minPathSum(self, grid: List[List[int]]) -> int: m, n = len(grid), len(grid[0]) dp = grid[0][:] for i in range(1, n): dp[i] += dp[i-1] for i in range(1, m): for j in range(n): if j > 0: dp[j] = grid[i][j] ...
"""simd float32vec""" def get_data(): return [1.9, 1.8, 1.7, 0.6, 0.99,0.88,0.77,0.66] def main(): ## the translator knows this is a float32vec because there are more than 4 elements x = y = z = w = 22/7 a = numpy.array( [1.1, 1.2, 1.3, 0.4, x,y,z,w], dtype=numpy.float32 ) ## in this case the translator is not s...
def repetition(a,b): count=0; for i in range(len(a)): if(a[i]==b): count=count+1 return count
n = int(input()) xy = [map(int, input().split()) for _ in range(n)] x, y = [list(i) for i in zip(*xy)] count = 0 buf = 0 for xi, yi in zip(x, y): if xi == yi: buf += 1 else: if buf > count: count = buf buf = 0 if buf > count: count = buf if count >= 3: print('Yes')...
""" Definitions of fixtures used in acceptance mixed tests. """ __author__ = "Michal Stanisz" __copyright__ = "Copyright (C) 2017 ACK CYFRONET AGH" __license__ = "This software is released under the MIT license cited in " \ "LICENSE.txt" pytest_plugins = "tests.gui.gui_conf"
""" Represents tests defined in the draft_kings.output.schema module. Most tests center around serializing / deserializing output objects using the marshmallow library """
# # PySNMP MIB module Sentry4-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Sentry4-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:14:39 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, 0...
# 374. 猜数字大小 # # 20200810 # huao # 二分 # The guess API is already defined for you. # @param num, your guess # @return -1 if my number is lower, 1 if my number is higher, otherwise return 0 def guess(num: int) -> int: pass class Solution: def guessNumber(self, n: int) -> int: begin = 1 end = n ...
DEBUG = True ALLOWED_HOSTS = ['*'] SECRET_KEY = 'secret' SOCIAL_AUTH_TWITTER_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxx' SOCIAL_AUTH_TWITTER_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' SOCIAL_AUTH_ORCID_KEY = '' SOCIAL_AUTH_ORCID_SECRET = ''
# reverse generator def reverse(data): current = len(data) while current >= 1: current -= 1 yield data[current] for c in reverse("string"): print(c) for i in reverse([1, 2, 3]): print(i) # reverse iterator class Reverse(object): def __init__(self, data): self.data = d...
salario = float(input('Qual o salário atual?')) aumento = float(input('Qual o valor do aumento em porcento?')) total = (salario*aumento)/100 print('o valor final é de R${}'.format(total+salario))
### Model data class catboost_model(object): float_features_index = [ 0, 1, 2, 4, 5, 6, 8, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 24, 27, 28, 31, 33, 35, 37, 38, 39, 46, 47, 48, ] float_feature_count = 50 cat_feature_count = 0 binary_feature_count = 29 tree_count = 40 float_feature...
# Based on: https://articles.leetcode.com/longest-palindromic-substring-part-ii/ def _process(s): alt_chars = ['$', '#'] for char in s: alt_chars.extend([char, '#']) alt_chars += ['@'] return alt_chars def _run_manacher(alt_chars): palin_table = [0] * len(alt_chars) center, right...
def get_majority_element(a, left, right): a.sort() if left == right: return -1 if left + 1 == right: return a[left] #write your code here mid = left + (right-left)//2 k=0 for i in range(len(a)): if a[i]==a[mid]: k+=1 if k > right/2 : return k return -1 n =...
n1 = int(input('Digite o começo de uma PA: ')) n2 = int(input('Agora digite a razão de uma PA: ')) contador = 0 while contador < 10: print(f'{n1 + (contador * n2)}', end=', ') contador += 1 print('Acabou')
def main(): points = [] with open("input.txt") as input_file: for wire in input_file: wire = [(x[0], int(x[1:])) for x in wire.split(",")] x, y = 0, 0 cost = 0 points_local = [(x, y, cost)] for direction, value in wire: if di...
class APIException(Exception): def __init__(self, message): super().__init__(message) self.message = message class UserException(Exception): def __init__(self, message): super().__init__(message) self.message = message
# Implemente um algoritmo em Python que receba a matricula, nome, teste e prova de um aluno e que calcule e exiba a matricula, nome, média e qual o seu conceito conforme discriminado abaixo: # Conceito A - media superior ou igual a 9 # Conceito B - media superior ou igual a 7 e inferior a 9 # Conceito C - ...
class MyClass(object): def set_val(self,val): self.val = val def get_val(self): return self.val a = MyClass() b = MyClass() a.set_val(10) b.set_val(100) print(a.get_val()) print(b.get_val())
""" @Pedro Santana Abreu (https://linktr.ee/pedrosantanaabreu) @Icev (https://somosicev.com) PT-BR: Desenvolva um programa para efetuar o cálculo da quantidade de litros de combustível gasta em uma viagem, considerando um automóvel que faz 12 Km/l. Para obter o cálculo, o usuário deve fornecer o tempo gasto (variável ...
""" Спортсмен поставил перед собой задачу пробежать в общей сложности Х километров. В первый день спортсмен пробежал Y километров, а затем он каждый день увеличивал пробег на 10% от предыдущего значения. Определите номер дня в который спортсмен достигнет своей цели. Оформите решение в виде программы, которая на вход пр...
# ======================== # Information # ======================== # Direct Link: https://www.hackerrank.com/challenges/security-key-spaces/problem # Difficulty: Easy # Max Score: 10 # Language: Python # ======================== # Solution # ======================== num = (input()) e = int(input()) p...
def reverse(S, start, stop): """Reverse elements in emplicit slice S[start:stop].""" if start < stop - 1: S[start], S[stop-1] = S[stop - 1], S[start] reverse(S, start+1, stop - 1) def reverse_iterative(S): """Reverse elements in S using tail recursion""" start,stop = 0,len...
def palindrome_num(): num = int(input("Enter a number:")) temp = num rev = 0 while(num>0): dig = num%10 rev = rev*10+dig num = num//10 if(temp == rev): print("The number is palindrome!") else: print("Not a palindrome!") palindrome_num()
# Not necessary. Just wanted to separate program from credentials def apikey(): return 'apikey' def stomp_username(): return 'stomp user' def stomp_password(): return 'stomp pass'
''' # Functional composition # • Lego is a popular toy because it’s so versatile # • Similar to how Lego pieces can be combined, in functional programming it’s common to combine functions def f(number): return number * 2 def g(number): return number + 1 x = 2 # print(f(2)) # detta ger --> 4 # print(g(2)) # detta g...
""" https://leetcode.com/problems/add-strings/ Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. Note: The length of both num1 and num2 is < 5100. Both num1 and num2 contains only digits 0-9. Both num1 and num2 does not contain any leading zero. You must not use any...
# Lists always stay in the same order, so you can get # information out very easily. List indexes act very similar # to string indexs intList = [1, 2, 3, 4, 5] # Get the first item print(intList[0]) # Get the last item print(intList[-1]) # Alternatively: print(intList[len(intList) - 1]) # Get the 2nd to 4th items ...
cars = 100 space_in_car = 4 drivers = 30 passengers = 90 cars_not_driven = cars - drivers cars_driven = drivers carpool_capacity = cars_driven * space_in_car average_passengers_per_car = passengers / cars_driven print("Cars: ", cars) print(drivers) print(cars_not_driven) print(carpool_capacity) print(passengers) print...
class Config(object): # Measuration Parameters TOTAL_TICKS = 80 PRECISION = 1 INITIAL_TIMESTAMP = 1 # Acceleration Parameters MINIMIZE_CHECKING = True GENERATE_STATE = False LOGGING_NETWORK = False # SPEC Parameters SLOTS_PER_EPOCH = 8 # System Parameters NUM_VALIDATO...
_base_ = [ '../_base_/models/mask_rcnn_se_r50_fpn.py', '../_base_/datasets/coco_instance.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py' ] model = dict( pretrained='checkpoints/se_resnext101_64x4d-f9926f93.pth', backbone=dict(block='SEResNeXtBottleneck', layers=[3, 4, 23, 3...
class Solution: def reverseVowels(self, s: str) -> str: vowels = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'} s = list(s) left = 0 right = len(s) - 1 while left < right: if s[left] not in vowels: left += 1 elif s[right] not in vow...
#!/usr/bin/env python3 # https://sites.google.com/site/ev3python/learn_ev3_python/using-sensors/sensor-modes speedReading=0 # Color Sensor Readings # COL-REFLECT COL-AMBIENT COL-COLOR RGB-RAW colorSensor_mode_default = "COL-COLOR" colorSensor_mode_lt = colorSensor_mode_default colorSensor_mode_rt = colorSensor_mo...
"""Message types to register.""" PROTOCOL_URI = "https://didcomm.org/issue-credential/1.1" PROTOCOL_PACKAGE = "aries_cloudagent.protocols.issue_credential.v1_1" CREDENTIAL_ISSUE = f"{PROTOCOL_URI}/issue-credential" CREDENTIAL_REQUEST = f"{PROTOCOL_URI}/request-credential" MESSAGE_TYPES = { CREDENTIAL_ISSUE: (f"{...
class Player: def getTime(self): pass def playWavFile(self, file): pass def wavWasPlayed(self): pass def resetWav(self): pass
def countSetBits(num): binary = bin(num) setBits = [ones for ones in binary[2:] if ones == '1'] return len(setBits) if __name__ == "__main__": n = int(input()) for i in range(n+1): print(countSetBits(i), end =' ')
'simple demo of using map to create instances of objects' class Dog: def __init__(self, name): self.name = name def bark(self): print("Woof! %s is barking!" % self.name) dogs = list(map(Dog, ['rex', 'rover', 'ranger']))
#!/usr/bin/python3 max_integer = __import__('6-max_integer').max_integer print(max_integer([1, 2, 3, 4])) print(max_integer([1, 3, 4, 2]))
try: # Check if the basestring type if available, this will fail in python3 basestring except NameError: basestring = str class ControlFileParams: generalParams = "GeneralParams" spawningBlockname = "SpawningParams" simulationBlockname = "SimulationParams" clusteringBlockname = "clustering...
num = int(input()) if num == 0: print("zero") elif num == 1: print("one") elif num == 2: print("two") elif num == 3: print("three") elif num == 4: print("four") elif num == 5: print("five") elif num == 6: print("six") elif num == 7: print("seven") elif num == 8: print("eight") elif ...
# -*- coding:utf-8 -*- """ Description: Exceptions Usage: from AntShares.Exceptions import * """ class WorkIdError(Exception): """Work Id Error""" def __init__(self, info): super(Exception, self).__init__(info) self.error_code = 0x0002 class OutputError(Exception): """Output Error...
#aula 7 14-11-2019 #Dicionarios lista = [] dicionario = { 'Nome': 'Antonio' , 'Sobrenome' : 'Gastaldi' } print(dicionario) print(dicionario['Sobrenome']) nome = 'Antônio' lista_notas = [10,20,50,70] media = sum(lista_notas)/ len(lista_notas) situacao = 'Reprovado' if media >= 7 : situacao = 'Aprovado' diciona...
# Crie um progrmaa que leia dois numeros e mostra a soma entre eles n1 = int(input('Digite o primeiro numero: ')) n2 = int(input('Digite o segundo numero: ')) s = n1 + n2 print('A soma de \033[31m{}\033[m e \033[34m{}\033[m eh de \033[32m{}\033[m ' .format(n1, n2, s))
# TODO(dan): Sort out how this displays in tracebacks, it's terrible class ValidationError(Exception): def __init__(self, errors, exc=None): self.errors = errors self.exc = exc self._str = str(exc) if exc is not None else '' + ', '.join( [str(e) for e in errors]) def __str_...
# # PySNMP MIB module SONUS-NTP-SERVICES-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SONUS-NTP-SERVICES-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:02:02 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (d...
JSVIZ1='''<script type="text/javascript"> function go() { var zoomCanvas = document.getElementById('canvas'); origZoomChart = new Scribl(zoomCanvas, 100); //origZoomChart.scale.min = 0; // origZoomChart.scale.max = 12000; ''' JSVIZ2=''' origZoomChart.scrollable =...
"""Default constants used in this library. Exponential Coulomb interaction. v(x) = amplitude * exp(-abs(x) * kappa) See also ext_potentials.exp_hydrogenic. Further details in: Thomas E Baker, E Miles Stoudenmire, Lucas O Wagner, Kieron Burke, and Steven R White. One-dimensional mimicking of electronic structure:...
def catalan_rec(n): if n <= 1: return 1 res = 0 for i in range(n): res += catalan_rec(i) * catalan_rec(n-i-1) return res def catalan_rec_td(n, arr): if n <= 1: return 1 if arr[n] > 0: return arr[n] res = 0 for i in range(n): res += catalan_rec_td(i, arr) * catalan_rec_td(n-i-1,...
''' Exercício Python 63: Escreva um programa que leia um número N inteiro qualquer e mostre na tela os N primeiros elementos de uma Sequência de Fibonacci. Exemplo: 0 – 1 – 1 – 2 – 3 – 5 – 8 ''' print('------------------------------') print('Sequencia de Fibonacci') print('------------------------------') n = int(in...
# %% P = {"task.variable_a": "value-used-during-interactive-development"} # %% tags=["parameters"] # ---- During automated runs parameters will be injected in this cell --- # %% # ----------------------------------------------------------------------- # %% # Example comment print(1 + 12 + 123) # %% print(f"""variable_a...
class Solution: def isValidSerialization(self, preorder: str) -> bool: return self.isValidSerializationStack(preorder) ''' Initial, Almost-Optimal, Split Iteration Look at the question closely. If i give you a subset from start, will you be able to tell me easily if ...
""" Shell Sort Approach: Divide and Conquer Complexity: O(n2) """ def sort_shell(input_arr): print("""""""""""""""""""""""""") print("input " + str(input_arr)) print("""""""""""""""""""""""""") print("""""""""""""""""""""""""") print("result " + str(input_arr)) print(""""""""""""""""""""""""...
#!/usr/bin/env python3 # Day 22: Binary Tree Zigzag Level Order Traversal # # Given a binary tree, return the zigzag level order traversal of its nodes' # values. (ie, from left to right, then right to left for the next level and # alternate between). # Definition for a binary tree node. class TreeNode: def __ini...
""" 数字 n 代表生成括号的对数,请你设计一个函数,用于能够生成所有可能的并且 有效的 括号组合。   示例: 输入:n = 3 输出:[ "((()))", "(()())", "(())()", "()(())", "()()()" ] 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/generate-parentheses 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 """
def minion_game(string): length = len(string) the_vowel = "AEIOU" kevin = 0 stuart = 0 for i in range(length): if string[i] in the_vowel: kevin = kevin + length - i else: stuart = stuart + length - i if kevin > stuart: print ("Kevin %d" % kevi...
class PatchExtractor: def __init__(self, img, patch_size, stride): self.img = img self.size = patch_size self.stride = stride def extract_patches(self): wp, hp = self.shape() return [self.extract_patch((w, h)) for h in range(hp) for w in range(wp)] def...
class OnegramException(Exception): pass # TODO [romeira]: Login exceptions {06/03/18 23:07} class AuthException(OnegramException): pass class AuthFailed(AuthException): pass class AuthUserError(AuthException): pass class NotSupportedError(OnegramException): pass class RequestFailed(OnegramExcep...
# _version.py # Simon Hulse # simon.hulse@chem.ox.ac.uk # Last Edited: Tue 10 May 2022 10:24:50 BST __version__ = "0.0.6"
#1. 如果有两个字符串"hello" 和 “world”,生成一个列表,列表中元素["hw", "eo", "lr"] str1 = "hello" str2 = "world" l = [] for i in range(len(str1)): l.append(str1[i]+str2[i]) print(l)
def fact(n): if n == 0: return(1) return(n*fact(n-1)) def ncr(n, r): return(fact(n)/(fact(r)*fact(n-r))) million = 1000000 n = 0 a = 0 comp = 0 for n in range(100, 0, -1): for r in range(a, n): if ncr(n,r) > million: comp += n-2*r + 1 a = r-1 break ...
#!/usr/bin/env python # # Copyright 2019 DFKI GmbH. # # 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, merg...
# # Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # 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 right...
""" Examples: >>> square(1) 1 >>> square(2) 4 >>> square(3) 9 >>> spam = Spam() >>> spam.eggs() 42 """ def square(x): """ Examples: >>> square(1) 1 >>> square(2) 4 >>> square(3) 9 """ return x * x class Spam(object): """ Examples: >>> spam = Spam() >>> s...
""" Random Starry Sky """ newPage(300, 300) fill(0) rect(0, 0, 300, 300) for i in range (200): dia = random() * 3 fill(random()) oval(random()*300, random()*300, dia, dia) """ Aufgabe: - Platziere ein paar zufällig farbige Planeten am Nachthimmel - Was passiert, wenn du Zeile 13 z...
'''' def multiplica(a,b): return a*b print(multiplica(4,5)) def troca(x,y): aux = x x=y y=aux x=10 y=20 troca(x,y) print("X=",x,"e y =",y) ''' def total_caracteres (x,y,z): return (len(x)+len(y)+len(z))
#!/usr/bin/env python3 def encode(message): encoded_message = "" i = 0 while (i <= len(message) - 1): count = 1 ch = message[i] j = i while (j < len(message) - 1): if (message[j] == message[j + 1]): count = count + 1 j = j + 1 ...
'''from math import trunc num = float(input('Digite um número para mostrar sua porção: ')) print('a porção do seu número é: {}'.format(trunc(num)))''' num = float(input('Digite um numero para se tornar uma integral zozinha: ')) print('o número flutuante {}, se tornou um número integral {:.0f}'.format(num, int(num)))
class MainClass: class_number = 20 class_string = 'Hello, world' def get_local_number(self): return 14 def get_lass_number(self): return MainClass.class_number def get_class_string(self): return MainClass.class_string
# # @lc app=leetcode id=135 lang=python3 # # [135] Candy # # https://leetcode.com/problems/candy/description/ # # algorithms # Hard (30.87%) # Likes: 815 # Dislikes: 154 # Total Accepted: 125.7K # Total Submissions: 406.8K # Testcase Example: '[1,0,2]' # # There are N children standing in a line. Each child is a...
friendly_names = { "fim_s01e01": "Season 1, Episode 1", "fim_s01e02": "Season 1, Episode 2", "fim_s01e03": "Season 1, Episode 3", "fim_s01e04": "Season 1, Episode 4", "fim_s01e05": "Season 1, Episode 5", "fim_s01e06": "Season 1, Episode 6", "fim_s01e07": "Season 1, Episode 7", "fim_s01e0...
#Aula02 #operadores aritmetricos print(5+8) print(10-5) print(5*3) print(17/3) print(2**3) #calculando a parte inteira da divisão print(5//2) print(5%2)
class Solution(object): def removeElement(self, nums, val): """ :type nums: List[int] :type val: int :rtype: int """ # Simple brute force # while val in nums: # nums.remove(val) # return (len(nums)) # Trying a 2 pointer approac...
class SpotUrls: token='85392160' CFID='459565' venice_morning_good='https://camrewinds.cdn-surfline.com/live/wc-venicebeachclose.stream.20191103T162900647.mp4' venice_static='https://camrewinds.cdn-surfline.com/live/wc-venicebeachclose.stream.20191027T235900139.mp4' lookup={'breakwater': 'http://ww...
s = input() n = len(s) formulas = s.split('+') ans = 0 for f in formulas: for i in range(len(f)): if f[i] == '0': break if i == len(f) - 1: ans += 1 print(ans)
x = int(input('Qual tabuada multiplicar: ')) print('-' * 15) print('{} x {:2} = {}'.format(x, 1, (x*1))) print('{} x {:2} = {}'.format(x, 2, (x*2))) print('{} x {:2} = {}'.format(x, 3, (x*3))) print('{} x {:2} = {}'.format(x, 4, (x*4))) print('{} x {:2} = {}'.format(x, 5, (x*5))) print('{} x {:2} = {}'.format(x, 6, (x*...
def FibonacciSearch(arr, key): fib2 = 0 fib1 = 1 fib = fib1 + fib2 while (fib < len(arr)): fib2 = fib1 fib1 = fib fib = fib1 + fib2 index = -1 while (fib > 1): i = min(index + fib2, (len(arr)-1)) if (arr[i] < key): fib = fib1 fib1 =...
# from fluprodia import FluidPropertyDiagram def test_main(): pass
""" Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct. Example 1: Input: [1,2,3,1] Output: true Example 2: Input: [1,2,3,4] Output: false Example 3: Inpu...
# -*- coding: utf-8 -*- """ Copyright (c) 2010-2014 Jennifer Ennis, William Tisäter. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any la...
a=0 pg=[[]] # input the number of chapters # input the maximum number of problems per page x,y=map(int,input().split(' ')) # input the number of problems in each chapter l=list(map(int,input().split(' '))) for i in l: k = [[] for _ in range(100)] for j in range(i): k[j//y].append(j+1) for i in k: ...
male = [ 'David', 'Maximilian', 'Lukas', 'Tobias', 'Paul', 'Elias', 'Jakob', 'Jonas', 'Alexander', 'Felix', 'Leon', 'Simon', 'Sebastian', 'Julian', 'Fabian', 'Florian', 'Noah', 'Moritz', 'Samuel', 'Raphael', 'Luca', 'Leo', 'Dani...