content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# Copyright (c) 2021 Hashz Software. class ArgNotFound: def __init__(self, arg): print("ArgNotFound: %s" % arg)
class Argnotfound: def __init__(self, arg): print('ArgNotFound: %s' % arg)
""" 213. House Robber II You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have security system connected and it ...
""" 213. House Robber II You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have security system connected and it ...
#These information comes from Twitter API #Create a Twitter Account and Get These Information from apps.twitter.com consumer_key = 'R1feyoEHAw2Lg32k4OKyyn01v' consumer_secret = 'KdxSi79P7PAjhmY4OYU2VfeKUcaUt4WmyJMb7Oew0nE1M7Ji5h' access_token = '145566333-KIndElco5MlHXPIGWeGkvjVXlMchLyQI2bMD8BJT' access_secret = 'iqf...
consumer_key = 'R1feyoEHAw2Lg32k4OKyyn01v' consumer_secret = 'KdxSi79P7PAjhmY4OYU2VfeKUcaUt4WmyJMb7Oew0nE1M7Ji5h' access_token = '145566333-KIndElco5MlHXPIGWeGkvjVXlMchLyQI2bMD8BJT' access_secret = 'iqfFlcM4clh6wCwDSLZaQqJttgstiIybUDOoB3uyzaZx8'
class lightswitch: is_on = False def Flip(self): #self refers to the instance of the object. needs to be included only when using class, to ensure that it is defined only within the class self.is_on = not self.is_on #field/attribute print(self.is_on) def FlipMany(self, number:...
class Lightswitch: is_on = False def flip(self): self.is_on = not self.is_on print(self.is_on) def flip_many(self, number: int): for i in range(number): self.Flip() living_room_light = lightswitch() bedroom_light = lightswitch() print('living_room_light:') living_room_l...
if __name__ == "__main__": TC = int(input()) for t in range(0,TC): N = int(input()) max_score = -1 tie = False win = 0 for n in range(0,N): T = [0] * 6 C = list(map(int, input().split())) for c in range(1,len(C)): T...
if __name__ == '__main__': tc = int(input()) for t in range(0, TC): n = int(input()) max_score = -1 tie = False win = 0 for n in range(0, N): t = [0] * 6 c = list(map(int, input().split())) for c in range(1, len(C)): T[C...
def value_at(poly_spec, x): num=1 total=0 for i,j in enumerate(poly_spec[::-1]): total+=j*num num=(num*(x-i))/(i+1) return round(total, 2)
def value_at(poly_spec, x): num = 1 total = 0 for (i, j) in enumerate(poly_spec[::-1]): total += j * num num = num * (x - i) / (i + 1) return round(total, 2)
class BaseGenerator: """Base class for generators. Generators should provide of synthesis measurements for a location. For performance reasons generation of data should be initialized by the :meth:`uwb.generator.BaseGenerator.gen`. and :meth:`uwb.generator.BaseGenerator.get_closest_position` should pro...
class Basegenerator: """Base class for generators. Generators should provide of synthesis measurements for a location. For performance reasons generation of data should be initialized by the :meth:`uwb.generator.BaseGenerator.gen`. and :meth:`uwb.generator.BaseGenerator.get_closest_position` should pro...
REV_CLASS_MAP = { 0: "rock", 1: "paper", 2: "scissors", 3: "none" } # 0_Rock 1_Paper 2_Scissors def mapper(val): return REV_CLASS_MAP[val] def calculate_winner(move1, move2): if move1 == move2: return "Tie" if move1 == "rock": if move2 == 2: ...
rev_class_map = {0: 'rock', 1: 'paper', 2: 'scissors', 3: 'none'} def mapper(val): return REV_CLASS_MAP[val] def calculate_winner(move1, move2): if move1 == move2: return 'Tie' if move1 == 'rock': if move2 == 2: return 'User' if move2 == 1: return 'Computer'...
class ArtistNotFound(Exception): pass class AlbumNotFound(Exception): pass
class Artistnotfound(Exception): pass class Albumnotfound(Exception): pass
standard = { 'rulebook_white': { 'name':'Rulebook White T', 'style': { 'color': '#666666', 'background': '#fff', 'border-color': '#000', }, }, 'rulebook_pink': { 'name':'Rulebook Pink', 'style': { 'color': '#ffffdd', ...
standard = {'rulebook_white': {'name': 'Rulebook White T', 'style': {'color': '#666666', 'background': '#fff', 'border-color': '#000'}}, 'rulebook_pink': {'name': 'Rulebook Pink', 'style': {'color': '#ffffdd', 'background': '#F25292', 'border-color': '#FE98C0'}}, 'rulebook_blue': {'name': 'Rulebook Blue', 'style': {'co...
def recurFibonaci(number): if number <= 1: return number else: return recurFibonaci(number - 1) + recurFibonaci(number - 2) numberTerms = 10 if numberTerms <= 0: print("enter positive integers") else: print("fibonaci sequence ") for i in range(numberTerms): print(recurFibon...
def recur_fibonaci(number): if number <= 1: return number else: return recur_fibonaci(number - 1) + recur_fibonaci(number - 2) number_terms = 10 if numberTerms <= 0: print('enter positive integers') else: print('fibonaci sequence ') for i in range(numberTerms): print(recur_fi...
cadena_ingresada = input("Ingrese la fecha actual en formato dd/mm/yyyy: "); separado = cadena_ingresada.split('/'); print(separado); print( f'Dia: {separado[0]}', '-', f'Mes: {separado[1]}', '-', f'Anio: {separado[2]}' ); c = cadena_ingresada; print( f'Dia: {c[0]}{c[1]}', '-', f'Mes: {c[3]}{c[...
cadena_ingresada = input('Ingrese la fecha actual en formato dd/mm/yyyy: ') separado = cadena_ingresada.split('/') print(separado) print(f'Dia: {separado[0]}', '-', f'Mes: {separado[1]}', '-', f'Anio: {separado[2]}') c = cadena_ingresada print(f'Dia: {c[0]}{c[1]}', '-', f'Mes: {c[3]}{c[4]}', '-', f'Anio: {c[6]}{c[7]}{c...
carros = [] carros.append("audi") carros.append("bmw") carros.append("subaru") carros.append("toyota") carros.append("chevrolet") carros.append("honda") # if elif else for carro in carros: if carro == "honda": print(carro.upper() + " !") elif carro == "BMW": print(carro.upper()) ...
carros = [] carros.append('audi') carros.append('bmw') carros.append('subaru') carros.append('toyota') carros.append('chevrolet') carros.append('honda') for carro in carros: if carro == 'honda': print(carro.upper() + ' !') elif carro == 'BMW': print(carro.upper()) elif carro == 'toyota': ...
# Digit factorials def factorial(n): if n == 0: return 1 return n*factorial(n-1) def digitized_factorial_sum(num): if num == 1 or num == 2: return False return sum([factorial(int(digit)) for digit in str(num)]) == num # Need bounds on the numbers to be checked if their sum of factoria...
def factorial(n): if n == 0: return 1 return n * factorial(n - 1) def digitized_factorial_sum(num): if num == 1 or num == 2: return False return sum([factorial(int(digit)) for digit in str(num)]) == num for i in range(int(1000000.0)): if digitized_factorial_sum(i): print('Th...
# Question 2 - Shouting! def main(): # You don't need to modify this function. name = input('Please enter your name: ') # The computer is pleased to see you! Shout out to the user shout_name = shout(name) print('This program is happy to see you, {}'.format(shout_name)) def shout(name): ...
def main(): name = input('Please enter your name: ') shout_name = shout(name) print('This program is happy to see you, {}'.format(shout_name)) def shout(name): pass if __name__ == '__main__': main()
#python3 # Compute the last digit of the sum of squares of Fibonacci numbers till Fn def fib_mod_sum(n): mod_seq = [0, 1] # mod is 10 -> pisano period is 60 pp = 60 fib_i = n % pp for _ in range(1, fib_i): mod_seq.append((mod_seq[-1] + mod_seq[-2])) fn_seq = mod_seq[:fib_i + 1] r...
def fib_mod_sum(n): mod_seq = [0, 1] pp = 60 fib_i = n % pp for _ in range(1, fib_i): mod_seq.append(mod_seq[-1] + mod_seq[-2]) fn_seq = mod_seq[:fib_i + 1] return sum([i ** 2 for i in fn_seq]) % 10 def main(): n = int(input()) print(fib_mod_sum(n)) if __name__ == '__main__': ...
__title__ = 'django-uuslug' __author__ = 'Val Neekman' __author_email__ = 'info@neekware.com' __description__ = "A Django slugify application that also handles Unicode" __url__ = 'https://github.com/un33k/django-uuslug' __license__ = 'MIT' __copyright__ = 'Copyright 2022 Val Neekman @ Neekware Inc.' __version__ = '2.0....
__title__ = 'django-uuslug' __author__ = 'Val Neekman' __author_email__ = 'info@neekware.com' __description__ = 'A Django slugify application that also handles Unicode' __url__ = 'https://github.com/un33k/django-uuslug' __license__ = 'MIT' __copyright__ = 'Copyright 2022 Val Neekman @ Neekware Inc.' __version__ = '2.0....
class Quadrado: def __init__(self, lado): self.lado = lado def perimetro(self): return 4 * self.lado def area(self): return self.lado * self.lado class Retangulo: def __init__(self, base, altura): self.base = base self.altura = altura def area(self): return self.base * self.altura ...
class Quadrado: def __init__(self, lado): self.lado = lado def perimetro(self): return 4 * self.lado def area(self): return self.lado * self.lado class Retangulo: def __init__(self, base, altura): self.base = base self.altura = altura def area(self): ...
# https://codeforces.com/problemset/problem/510/A n, m = input().split() whileloop_count = 1 dotline = 0 k = int(m)-1 while whileloop_count <= int(n): if whileloop_count % 2 != 0: print("#"*int(m)) elif whileloop_count % 2 == 0 and dotline % 2 == 0: print(("."*k+"#")) dotline += 1 el...
(n, m) = input().split() whileloop_count = 1 dotline = 0 k = int(m) - 1 while whileloop_count <= int(n): if whileloop_count % 2 != 0: print('#' * int(m)) elif whileloop_count % 2 == 0 and dotline % 2 == 0: print('.' * k + '#') dotline += 1 elif whileloop_count % 2 == 0 and dotline % ...
minha_lista = [1,2,3,4,5] sua_lista = [item ** 2 for item in minha_lista] print(minha_lista) print(sua_lista)
minha_lista = [1, 2, 3, 4, 5] sua_lista = [item ** 2 for item in minha_lista] print(minha_lista) print(sua_lista)
#!/usr/bin/python # -*- coding:utf-8 -*- class Cursor: def __init__(self, x=0, y=0): self.x = x self.y = y self.x_max = 5 self.y_max = 32 def up(self, buff): return Cursor(self.x - 1, self.y).clamp(buff) def down(self, buff): return Cursor(self.x + 1, self....
class Cursor: def __init__(self, x=0, y=0): self.x = x self.y = y self.x_max = 5 self.y_max = 32 def up(self, buff): return cursor(self.x - 1, self.y).clamp(buff) def down(self, buff): return cursor(self.x + 1, self.y).clamp(buff) def right(self, buff)...
# Fern Zapata # https://github.com/fernzi/dotfiles # Qtile Window Manager - User settings terminal = 'alacritty' launcher = 'rofi -show drun' switcher = 'rofi -show window' file_manager = 'pcmanfm-qt' wallpaper = '~/Pictures/Wallpapers/Other/Waves.png' applications = dict( messenger='discord', mixer='pavucontrol...
terminal = 'alacritty' launcher = 'rofi -show drun' switcher = 'rofi -show window' file_manager = 'pcmanfm-qt' wallpaper = '~/Pictures/Wallpapers/Other/Waves.png' applications = dict(messenger='discord', mixer='pavucontrol-qt', web_browser='qutebrowser') autostart = ['lxqt-policykit-agent', 'setxkbmap -option compose:r...
#--- # title: Zen Markdown Demo # author: Dr. P. B. Patel # date: CURRENT_DATE # output: # format: pdf #--- ## with sql # %%{sql} """SELECT * FROM stocks""" #``` # %%{run=true, echo=true, render=true} zen.to_latex() #``` # with custom con string # %%{sql, con_string=my_con_string, name=custom_df} """SELECT * ...
"""SELECT * FROM stocks""" zen.to_latex() 'SELECT * \nFROM stocks' custom_df.to_latex()
# -*- coding: utf-8 -*- """ Created on Mon Jan 04 2021 - 10:22 Introduction to Computation and Programming Using Python. John V. Guttag, 2016, 2nd ed A complimentary exercise from the book companion, the OCW video lecture series - Lecture 6 Song Lyrics parser https://ocw.mit.edu/courses/electrical-engineering-and-c...
""" Created on Mon Jan 04 2021 - 10:22 Introduction to Computation and Programming Using Python. John V. Guttag, 2016, 2nd ed A complimentary exercise from the book companion, the OCW video lecture series - Lecture 6 Song Lyrics parser https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-0001-i...
# http://www.geeksforgeeks.org/find-number-of-triangles-possible/ def number_of_triangles(input): input.sort() count = 0 for i in range(len(input)-2): k = i + 2 for j in range(i+1, len(input)): while k < len(input) and input[i] + input[j] > input[k]: k = k + 1 ...
def number_of_triangles(input): input.sort() count = 0 for i in range(len(input) - 2): k = i + 2 for j in range(i + 1, len(input)): while k < len(input) and input[i] + input[j] > input[k]: k = k + 1 count += k - j - 1 return count if __name__ == '_...
def primeCheck(n): # 0, 1, even numbers greater than 2 are NOT PRIME if n==1 or n==0 or (n % 2 == 0 and n > 2): return "Not prime" else: # Not prime if divisable by another number less # or equal to the square root of itself. # n**(1/2) returns square root of n ...
def prime_check(n): if n == 1 or n == 0 or (n % 2 == 0 and n > 2): return 'Not prime' else: for i in range(3, int(n ** (1 / 2)) + 1, 2): if n % i == 0: return 'Not prime' return 'Prime'
""" Utilities that are not kartothek-specific but are required to archive certain tasks. """ __all__ = ()
""" Utilities that are not kartothek-specific but are required to archive certain tasks. """ __all__ = ()
""" Conversion functions between fahrentheit and centrigrade This module shows off two functions for converting temperature back and forth between fahrenheit and centigrade. It also shows how to use variables to represent "constants", or values that we give a name in order to remember them better. Author: Walker M. ...
""" Conversion functions between fahrentheit and centrigrade This module shows off two functions for converting temperature back and forth between fahrenheit and centigrade. It also shows how to use variables to represent "constants", or values that we give a name in order to remember them better. Author: Walker M. ...
#!/usr/bin/env python # coding: utf-8 template = """<!DOCTYPE html> <html lang="en"> <head> <title>RoadScanner result</title> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> html { height: 100% } body { height: 100%; ...
template = '<!DOCTYPE html>\n<html lang="en">\n<head>\n <title>RoadScanner result</title>\n <meta charset="utf-8">\n <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />\n <style type="text/css">\n html { height: 100% }\n body { height: 100%; margin: 0; padding: 0 }\n ...
class Solution: def largestOverlap(self, img1: List[List[int]], img2: List[List[int]]) -> int: """Array. Running time: O(n^2 + AB) where is n is the length of img1, A is the number of 1s in img1 and B is the number of 1s in img2. """ n = len(img1) pimg1 = [] pimg2 = ...
class Solution: def largest_overlap(self, img1: List[List[int]], img2: List[List[int]]) -> int: """Array. Running time: O(n^2 + AB) where is n is the length of img1, A is the number of 1s in img1 and B is the number of 1s in img2. """ n = len(img1) pimg1 = [] pimg2 ...
class MWB: """MainWidgetBase""" def __init__(self, params): self.parent_node_instance = params def get_data(self): data = {} return data def set_data(self, data): pass def remove_event(self): pass class IWB: """InputWidgetBase""" def __init__(self...
class Mwb: """MainWidgetBase""" def __init__(self, params): self.parent_node_instance = params def get_data(self): data = {} return data def set_data(self, data): pass def remove_event(self): pass class Iwb: """InputWidgetBase""" def __init__(sel...
# GYP file to build unit tests. { 'includes': [ 'apptype_console.gypi', 'common.gypi', ], 'targets': [ { 'target_name': 'tests', 'type': 'executable', 'include_dirs' : [ '../src/core', '../src/gpu', ], 'sources': [ '../tests/AAClipTest.cpp', ...
{'includes': ['apptype_console.gypi', 'common.gypi'], 'targets': [{'target_name': 'tests', 'type': 'executable', 'include_dirs': ['../src/core', '../src/gpu'], 'sources': ['../tests/AAClipTest.cpp', '../tests/BitmapCopyTest.cpp', '../tests/BitmapGetColorTest.cpp', '../tests/BitSetTest.cpp', '../tests/BlitRowTest.cpp', ...
#!/usr/bin/env python # -*- coding:utf-8 -*- # author:joel # time:2018/8/14 15:36 def headerstool(p): """deal with the request headers""" with open(p + '_new.txt', 'w') as fw: with open(p, 'r') as fr: for line in fr.readlines(): if not line.endswith('\n'): ...
def headerstool(p): """deal with the request headers""" with open(p + '_new.txt', 'w') as fw: with open(p, 'r') as fr: for line in fr.readlines(): if not line.endswith('\n'): line = line + '\n' line_w = "'" + line.replace(': ', "': '").repl...
class UserAlreadyEnteredError(Exception): pass class NoUsersEnteredError(Exception): pass class WrongTimeFormatError(Exception): pass #custom error just for readability
class Useralreadyenterederror(Exception): pass class Nousersenterederror(Exception): pass class Wrongtimeformaterror(Exception): pass
''' Given an integer n, return the next bigger permutation of its digits. If n is already in its biggest permutation, rotate to the smallest permutation. case 1 n= 5342310 ans=5343012 case 2 n= 543321 ans= 123345 ''' n = 5342310 # case 1 # n = 543321 # case 2 a = list(map(int, str(n))) i = len(a)-...
""" Given an integer n, return the next bigger permutation of its digits. If n is already in its biggest permutation, rotate to the smallest permutation. case 1 n= 5342310 ans=5343012 case 2 n= 543321 ans= 123345 """ n = 5342310 a = list(map(int, str(n))) i = len(a) - 2 while a[i] >= a[i + 1]: i -= 1 if i ==...
# function test # test 1 def println ( str ) : print ( str ) return println ( "Hello World" ) # test 2 def printStu ( name, age ): print ("%s, %d" % (name, age)) return printStu (age = 19, name = "Inno") # test 3 def printInfo ( who, sex = 'male' ): print ("%s/%s" % (who, sex)) return printInfo (...
def println(str): print(str) return println('Hello World') def print_stu(name, age): print('%s, %d' % (name, age)) return print_stu(age=19, name='Inno') def print_info(who, sex='male'): print('%s/%s' % (who, sex)) return print_info('Inno') def count_sum(*var_arg): sum = 0 for i in var...
# # PySNMP MIB module HM2-PWRMGMT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HM2-PWRMGMT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:18:36 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, value_size_constraint, constraints_intersection, constraints_union) ...
""" Main.class javac Main.java . """ constant_pool = list() def is_class(magic_code): return magic_code == 'cafebabe' def read_constant_class(f, tag, index): name_index = int(f.read(2).hex(), 16) return { 'tag': tag, 'name_index': name_index, 'index': index, } def read_con...
""" Main.class javac Main.java . """ constant_pool = list() def is_class(magic_code): return magic_code == 'cafebabe' def read_constant_class(f, tag, index): name_index = int(f.read(2).hex(), 16) return {'tag': tag, 'name_index': name_index, 'index': index} def read_constant_ref(f, tag, index): clas...
''' Leetcode 7. Reverse Integer Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Note: The input is assumed to be a 32-bit signed integer. Your function should return 0 when the reversed integer overflows. ''' def reverse(p): """ :type x: int :rtype: int ...
""" Leetcode 7. Reverse Integer Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Note: The input is assumed to be a 32-bit signed integer. Your function should return 0 when the reversed integer overflows. """ def reverse(p): """ :type x: int :rtype: int "...
""" This package contains the sphinx extensions used by barak. The `numpydoc` module is derived from the documentation tools numpy and scipy use to parse docstrings in the numpy/scipy format. The other modules are dependencies for `numpydoc`. """
""" This package contains the sphinx extensions used by barak. The `numpydoc` module is derived from the documentation tools numpy and scipy use to parse docstrings in the numpy/scipy format. The other modules are dependencies for `numpydoc`. """
# key = DB quest string, value = quest timer in days quests = { 'AugmentationBlankGemAcquired': ('Aug Gem: Bellas', 6), 'BlankAugLuminanceTimer_0511': ('Aug Gem: Luminance', 14), 'PickedUpMarkerBoss10x': ('Aug Gem: Diemos', 6), 'SocietyMasterStipendCollectionTimer': ('Stipend - Society', 6), 'Stipen...
quests = {'AugmentationBlankGemAcquired': ('Aug Gem: Bellas', 6), 'BlankAugLuminanceTimer_0511': ('Aug Gem: Luminance', 14), 'PickedUpMarkerBoss10x': ('Aug Gem: Diemos', 6), 'SocietyMasterStipendCollectionTimer': ('Stipend - Society', 6), 'StipendTimer_0812': ('Stipend - General', 6)}
# Initialization of n*n grid def create_grid(): global n n = int(input("Enter grid size: ")) global grids grids = [] for i in range(0, n): grids.append([]) for i in range(0, n): for j in range(0, n): grids[i].append(j) grids[i][j] = - 1 grid_def()...
def create_grid(): global n n = int(input('Enter grid size: ')) global grids grids = [] for i in range(0, n): grids.append([]) for i in range(0, n): for j in range(0, n): grids[i].append(j) grids[i][j] = -1 grid_def() def grid_def(): grid = [] ...
''' By a length in meters you can check how it is in kilometer, hectometer decimeter, centimeter and millimeter ''' m = float(input('Type a length in meters: ')) km = m / 1000 hm = m / 100 dam = m / 10 dm = m * 10 cm = m * 100 mm = m * 1000 print('The value in kilometer is {:.3f}. \nThe value in hectometer is {:.2f}....
""" By a length in meters you can check how it is in kilometer, hectometer decimeter, centimeter and millimeter """ m = float(input('Type a length in meters: ')) km = m / 1000 hm = m / 100 dam = m / 10 dm = m * 10 cm = m * 100 mm = m * 1000 print('The value in kilometer is {:.3f}. \nThe value in hectometer is {:.2f}. ...
glob_cnt = {} def key_or_incr(word): if glob_cnt.has_key(word): glob_cnt[word]+=1 else: glob_cnt.update({word:1}) if __name__=='__main__': # Reads a paragraph of text para = open("para.txt","r") word_list = para.read().split(" ") # update the count entries for each word fo...
glob_cnt = {} def key_or_incr(word): if glob_cnt.has_key(word): glob_cnt[word] += 1 else: glob_cnt.update({word: 1}) if __name__ == '__main__': para = open('para.txt', 'r') word_list = para.read().split(' ') for word in word_list: key_or_incr(word.lower()) for (k, v) in ...
MODEL_EXTENSIONS = ( '.egg', '.bam', '.pz', '.obj', ) PANDA_3D_RUNTIME_PATH = r'C:\Panda3D-1.10.9-x64'
model_extensions = ('.egg', '.bam', '.pz', '.obj') panda_3_d_runtime_path = 'C:\\Panda3D-1.10.9-x64'
class Key: def __init__(self, m, e): self.modulus = m self.exponent = e def set_modulus(self, m): self.modulus = m def set_exponent(self, e): self.exponent = e def get_modulus(self): return self.modulus def get_exponent(self): return self.exponent
class Key: def __init__(self, m, e): self.modulus = m self.exponent = e def set_modulus(self, m): self.modulus = m def set_exponent(self, e): self.exponent = e def get_modulus(self): return self.modulus def get_exponent(self): return self.exponent
# 13. Write a program that asks the user to enter two strings of the same length. The program # should then check to see if the strings are of the same length. If they are not, the program # should print an appropriate message and exit. If they are of the same length, the program # should alternate the characters of th...
first_string = input('Enter a string: ') second_string = input('Enter another string: ') if len(first_string) != len(second_string): print('The strings are not the same length.') else: for i in range(len(first_string)): print(second_string[i] + first_string[i], end='')
#!/usr/bin/env python # table auto-generator for zling. # author: Zhang Li <zhangli10@baidu.com> kBucketItemSize = 4096 matchidx_blen = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7] + [8] * 1024 matchidx_code = [] matchidx_bits = [] matchidx_base = [] while len(matchidx_code) < kBucketItemSize: for bit...
k_bucket_item_size = 4096 matchidx_blen = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7] + [8] * 1024 matchidx_code = [] matchidx_bits = [] matchidx_base = [] while len(matchidx_code) < kBucketItemSize: for bits in range(2 ** matchidx_blen[len(matchidx_base)]): matchidx_code.append(len(matchidx_base...
# NOTE: the agent holds items as a list where # items[idx] is the number of items collected of type 'idx' # IMPORTANT: if the original item config is changed/reodered, this file will # likely have to be updated to reflect new item positions. def all_item_reward(ai_r=1): # awards +ai_r for every new item collected ...
def all_item_reward(ai_r=1): def reward_calc(prev_items, items): return (sum(items) - sum(prev_items)) * ai_r return reward_calc def r_jellybean(jb_r=1): def reward_calc(prev_items, items): jb_idx = 2 return (items[JB_IDX] - prev_items[JB_IDX]) * jb_r return reward_calc def r...
""" Given a positive integer n and you can do operations as follow: If n is even, replace n with n/2. If n is odd, you can replace n with either n + 1 or n - 1. What is the minimum number of replacements needed for n to become 1? Example 1: Input: 8 Output: 3 Explana...
""" Given a positive integer n and you can do operations as follow: If n is even, replace n with n/2. If n is odd, you can replace n with either n + 1 or n - 1. What is the minimum number of replacements needed for n to become 1? Example 1: Input: 8 Output: 3 Explana...
tuplas = (1,2,3,4,5,6,7,8,9,0) print(tuplas[0]) # seleccion invertida print(tuplas[-1]) # sub tuplas sub = tuplas[:9:2] print(sub) # no puede ser modificada, por lo que sub[1] = 30
tuplas = (1, 2, 3, 4, 5, 6, 7, 8, 9, 0) print(tuplas[0]) print(tuplas[-1]) sub = tuplas[:9:2] print(sub) sub[1] = 30
# Define a Python subroutine to colour atoms by B-factor, using predefined intervals def colour_consurf(selection="all"): # Colour other chains gray, while maintaining # oxygen in red, nitrogen in blue and hydrogen in white cmd.color("gray", selection) cmd.util.cnc() # These are constants mi...
def colour_consurf(selection='all'): cmd.color('gray', selection) cmd.util.cnc() minimum = 0.0 maximum = 9.0 n_colours = 9 colours = [[0.039215686, 0.490196078, 0.509803922], [0.294117647, 0.68627451, 0.745098039], [0.647058824, 0.862745098, 0.901960784], [0.843137255, 0.941176471, 0.941176471],...
""" Module: 'flowlib.units._makey' on M5 FlowUI v1.4.0-beta """ # MCU: (sysname='esp32', nodename='esp32', release='1.11.0', version='v1.11-284-g5d8e1c867 on 2019-08-30', machine='ESP32 module with ESP32') # Stubber: 1.3.1 MAKEY_I2C_ADDR = 81 class Makey: '' def _available(): pass def _updateValue...
""" Module: 'flowlib.units._makey' on M5 FlowUI v1.4.0-beta """ makey_i2_c_addr = 81 class Makey: """""" def _available(): pass def _update_value(): pass def deinit(): pass value = None value_all = None i2c_bus = None unit = None
fName = input("\nwhat is your first name? ").strip().capitalize() mName = input("\nwhat is your middle name? ").strip().capitalize() lName = input("\nwhat is your last name? ").strip().capitalize() print(f"\nHello World, My name is {fName:s} {mName:.1s} {lName:s}, Happy to see you.")
f_name = input('\nwhat is your first name? ').strip().capitalize() m_name = input('\nwhat is your middle name? ').strip().capitalize() l_name = input('\nwhat is your last name? ').strip().capitalize() print(f'\nHello World, My name is {fName:s} {mName:.1s} {lName:s}, Happy to see you.')
class Player: def __init__(self, amount): if amount < 1: print('You do not have money') self.amount = 100 self.hand_bet = None self.suit_bet = 0 self.amount_bet = 0 self.sinput = None self.binput = None self.badb_bet = 0 de...
class Player: def __init__(self, amount): if amount < 1: print('You do not have money') self.amount = 100 self.hand_bet = None self.suit_bet = 0 self.amount_bet = 0 self.sinput = None self.binput = None self.badb_bet = 0 def amount(se...
#!/usr/bin/env python # -*- coding: utf-8 -* ONION_ADDR = { "patient": "xwjtp3mj427zdp4tljiiivg2l5ijfvmt5lcsfaygtpp6cw254kykvpyd.onion" } # TODO: LOGGER = { "user": { "password": "", "rooms": [] # rooms are mapped to topics in mqtt } } LOGGER = { "!qKGqWURPTdcyFQHFjJ:casper.magi.sys":...
onion_addr = {'patient': 'xwjtp3mj427zdp4tljiiivg2l5ijfvmt5lcsfaygtpp6cw254kykvpyd.onion'} logger = {'user': {'password': '', 'rooms': []}} logger = {'!qKGqWURPTdcyFQHFjJ:casper.magi.sys': {'user': 'patient', 'password': 'MDTweSomWY'}}
host = 'localhost' user = 'dongeonguard' password = 'SuchWow' db = 'imagedongeon'
host = 'localhost' user = 'dongeonguard' password = 'SuchWow' db = 'imagedongeon'
def myfunction1(): x = 60 # This is local variable print("Welcome to Fucntions") print("x value from func1: ", x) myfunction2() return None def myfunction2(): print("Thank you!!") print("x value form fucn2:", x) return None x = 10 # This is global variable myfunction1() # Note : Priority is given to Local va...
def myfunction1(): x = 60 print('Welcome to Fucntions') print('x value from func1: ', x) myfunction2() return None def myfunction2(): print('Thank you!!') print('x value form fucn2:', x) return None x = 10 myfunction1() '\ndef myfunction1():\n\tx = 60 # This is local variable\n\tprint("...
frase = input('Digite a frase: ').strip() print(frase.lower().count('a')) print(frase.lower().find('a')) print(frase.lower().rfind('a'))
frase = input('Digite a frase: ').strip() print(frase.lower().count('a')) print(frase.lower().find('a')) print(frase.lower().rfind('a'))
''' @Date: 2019-12-22 20:33:28 @Author: ywyz @LastModifiedBy: ywyz @Github: https://github.com/ywyz @LastEditors : ywyz @LastEditTime : 2019-12-22 20:38:20 ''' strings = input("Enter the first 9 digits of an ISBN-10 as a string: ") temp = 1 total = 0 for i in strings: total += int(i) * temp temp += 1 total %=...
""" @Date: 2019-12-22 20:33:28 @Author: ywyz @LastModifiedBy: ywyz @Github: https://github.com/ywyz @LastEditors : ywyz @LastEditTime : 2019-12-22 20:38:20 """ strings = input('Enter the first 9 digits of an ISBN-10 as a string: ') temp = 1 total = 0 for i in strings: total += int(i) * temp temp += 1 total %= ...
""" This test package was created separately to see the behavior of retrieving the Override rules declared on a registry where @handle_urls is defined on another package. """
""" This test package was created separately to see the behavior of retrieving the Override rules declared on a registry where @handle_urls is defined on another package. """
def solution(num): answer = 0 while num != 1: if num % 2 == 0: num = int(num // 2) else: num = num * 3 + 1 answer += 1 if answer >= 500: return -1 return answer print(solution(626331))
def solution(num): answer = 0 while num != 1: if num % 2 == 0: num = int(num // 2) else: num = num * 3 + 1 answer += 1 if answer >= 500: return -1 return answer print(solution(626331))
class ListNode: def __init__(self, x): self.val = x self.next = None class CircularLinkedList: def __init__(self): self.head = None def insertAtHead(self, x): if self.head is None: self.head = ListNode(x) self.head.next = self.head el...
class Listnode: def __init__(self, x): self.val = x self.next = None class Circularlinkedlist: def __init__(self): self.head = None def insert_at_head(self, x): if self.head is None: self.head = list_node(x) self.head.next = self.head else:...
#T# opposite numbers are calculated with the minus - operator #T# create a number and find its opposite num1 = 5 num2 = -num1 # -5 num1 = -5 num2 = -num1 # 5
num1 = 5 num2 = -num1 num1 = -5 num2 = -num1
class Vector2D(object): def __init__(self, vec2d): """ Initialize your data structure here. :type vec2d: List[List[int]] [ [1,2], [10], [4,5,6] ] """ self.lists = vec2d self.curr_list = None self.curr_ele...
class Vector2D(object): def __init__(self, vec2d): """ Initialize your data structure here. :type vec2d: List[List[int]] [ [1,2], [10], [4,5,6] ] """ self.lists = vec2d self.curr_list = None self.curr_ele...
X = int(input()) while True: Z = int(input()) if Z > X: break count = 0 summ = 0 for i in range(X,Z+1): summ += i count += 1 if summ > Z: break print(count)
x = int(input()) while True: z = int(input()) if Z > X: break count = 0 summ = 0 for i in range(X, Z + 1): summ += i count += 1 if summ > Z: break print(count)
""" File contains the constants used by the sensor modules. """ # Power sensor INA219_PATH = "/sys/class/i2c-dev/i2c-0/device/i2c-dev/i2c-0/device/0-0040/hwmon/hwmon0/" INA219_CURRENT = "/sys/class/i2c-dev/i2c-0/device/i2c-dev/i2c-0/device/0-0040/hwmon/hwmon0/curr1_input" INA219_RESISTOR = "/sys/class/i2c-dev/i2c-0/de...
""" File contains the constants used by the sensor modules. """ ina219_path = '/sys/class/i2c-dev/i2c-0/device/i2c-dev/i2c-0/device/0-0040/hwmon/hwmon0/' ina219_current = '/sys/class/i2c-dev/i2c-0/device/i2c-dev/i2c-0/device/0-0040/hwmon/hwmon0/curr1_input' ina219_resistor = '/sys/class/i2c-dev/i2c-0/device/i2c-dev/i2c...
# Copyright (c) 2021, Omid Erfanmanesh, All rights reserved. class EncoderTypes: CUSTOM = 0 LABEL = 1 ORDINAL = 2 ONE_HOT = 3 BINARY = 4
class Encodertypes: custom = 0 label = 1 ordinal = 2 one_hot = 3 binary = 4
# 1 #1 1 #1 1 1 p = int(input("Ingrese un numero: ")) for n in range(1,p): print(" "*(p-1) + "1") if(p != 1): print(" 1 1 ")
p = int(input('Ingrese un numero: ')) for n in range(1, p): print(' ' * (p - 1) + '1') if p != 1: print(' 1 1 ')
# Copyright 2021 The Bazel Authors. All rights reserved. # # 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 applicable la...
"""apple_universal_binary Starlark tests.""" load(':rules/analysis_target_outputs_test.bzl', 'analysis_target_outputs_test') load(':rules/common_verification_tests.bzl', 'binary_contents_test') def apple_universal_binary_test_suite(name): """Test suite for apple_universal_binary. Args: name: the base na...
# first_list_example.py # # Illustrates two ways to iterate through a list (examine every # element in a list). # CSC 110 # Fall 2011 stuff = [7, 17, -4, 0.5] # create a list filled with integers print(stuff) # prints in "list" form (with square brackets and commas) # This loop visits every element of the list,...
stuff = [7, 17, -4, 0.5] print(stuff) for index in range(len(stuff)): print('Index', index, 'has value', stuff[index]) print() sq_sum = 0 for value in stuff: sq = value ** 2 print('The number', value, 'squared =', sq) sq_sum += sq print('The sum of the squares =', sqSum)
# other column settings -> http://bootstrap-table.wenzhixin.net.cn/documentation/#column-options columns_criar_eleicao = [ { "field": "pessoa", # which is the field's name of data key "title": "Pessoa", # display as the table header's name] "sortable":True }, { "field": "...
columns_criar_eleicao = [{'field': 'pessoa', 'title': 'Pessoa', 'sortable': True}, {'field': 'login', 'title': 'Login', 'sortable': True}, {'field': 'select', 'checkbox': True}] columns_abrir_eleicao = [{'field': 'eleicao', 'title': 'Titulo', 'sortable': True}, {'field': 'select', 'checkbox': True}] columns_fechar_elei...
class cell: def __init__(self, y, x, icon, cellnum, board): self.chricon = icon self.coords = [y, x] self.evopoints = 0 self.idnum = cellnum self.playable = False self.learnedmutations = { 'move' : False, 'sight' : False, ...
class Cell: def __init__(self, y, x, icon, cellnum, board): self.chricon = icon self.coords = [y, x] self.evopoints = 0 self.idnum = cellnum self.playable = False self.learnedmutations = {'move': False, 'sight': False, 'strike': True, 'wall': False, 'leap': True} ...
# # PySNMP MIB module A3COM-HUAWEI-ACL-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/A3COM-HUAWEI-ACL-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:03:47 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (defau...
(h3c_common,) = mibBuilder.importSymbols('A3COM-HUAWEI-OID-MIB', 'h3cCommon') (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, constraints_un...
# # PySNMP MIB module VMWARE-ESX-AGENTCAP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/VMWARE-ESX-AGENTCAP-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:34:50 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 ...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, single_value_constraint, constraints_intersection, value_size_constraint, constraints_union) ...
def test(seq, target_seq): scorer = CodonFreqScorer() scorer.set_codon_freqs_from_seq(target_seq) print(scorer.score(seq))
def test(seq, target_seq): scorer = codon_freq_scorer() scorer.set_codon_freqs_from_seq(target_seq) print(scorer.score(seq))
#!/usr/bin/env python3 class State(): def __init__(self, e, pos, dist=float('inf'), prev=None): self.e = e self.pos = pos self.dist = dist self.prev = prev # we need a good hash that is the same for all (g,m)-pair permutations # this hash will be used to index the dictiona...
class State: def __init__(self, e, pos, dist=float('inf'), prev=None): self.e = e self.pos = pos self.dist = dist self.prev = prev def __hash__(self): l = [] for i in range(int(len(self.pos) / 2)): l += [(self.pos[2 * i], self.pos[2 * i + 1])] ...
################ # 66. Plus One ################ class Solution: def plusOne(self, digits): """ :type digits: List[int] :rtype: List[int] """ digits = digits[::-1] last = 1 for i in range(len(digits)): digits[i], last = (digits[i] + last) % 10, int...
class Solution: def plus_one(self, digits): """ :type digits: List[int] :rtype: List[int] """ digits = digits[::-1] last = 1 for i in range(len(digits)): (digits[i], last) = ((digits[i] + last) % 10, int(digits[i] + last - 10 >= 0)) if...
def sum_numbers(numbers=None): if numbers == None: return sum(range(101)) else: return sum(numbers)
def sum_numbers(numbers=None): if numbers == None: return sum(range(101)) else: return sum(numbers)
"""A RESTful Wagtail enclosure""" __version__ = '0.2.2' default_app_config = 'wagtailnest.apps.WagtailnestConfig'
"""A RESTful Wagtail enclosure""" __version__ = '0.2.2' default_app_config = 'wagtailnest.apps.WagtailnestConfig'
class Task(): def __init__(self, target=None, args=[], kwargs={}): self.target = target self.args = args self.kwargs = kwargs def execute_task(self): return self.target(*self.args, **self.kwargs) class TaskManager(): def __init__(self, tasks): """Add tasks in r...
class Task: def __init__(self, target=None, args=[], kwargs={}): self.target = target self.args = args self.kwargs = kwargs def execute_task(self): return self.target(*self.args, **self.kwargs) class Taskmanager: def __init__(self, tasks): """Add tasks in reverse ...
COLUMNS = [ 'EventId', 'DER_mass_MMC', 'DER_mass_transverse_met_lep', 'DER_mass_vis', 'DER_pt_h', 'DER_deltaeta_jet_jet', 'DER_mass_jet_jet', 'DER_prodeta_jet_jet', 'DER_deltar_tau_lep', 'DER_pt_tot', 'DER_sum_pt', 'DER_pt_ratio_lep_tau', 'DER_met_phi_centrality', ...
columns = ['EventId', 'DER_mass_MMC', 'DER_mass_transverse_met_lep', 'DER_mass_vis', 'DER_pt_h', 'DER_deltaeta_jet_jet', 'DER_mass_jet_jet', 'DER_prodeta_jet_jet', 'DER_deltar_tau_lep', 'DER_pt_tot', 'DER_sum_pt', 'DER_pt_ratio_lep_tau', 'DER_met_phi_centrality', 'DER_lep_eta_centrality', 'PRI_tau_pt', 'PRI_tau_eta', '...
class MetadataError(Exception): pass class CopyError(RuntimeError): pass class _BaseZarrError(ValueError): _msg = "" def __init__(self, *args): super().__init__(self._msg.format(*args)) class ContainsGroupError(_BaseZarrError): _msg = "path {0!r} contains a group" def err_contains...
class Metadataerror(Exception): pass class Copyerror(RuntimeError): pass class _Basezarrerror(ValueError): _msg = '' def __init__(self, *args): super().__init__(self._msg.format(*args)) class Containsgrouperror(_BaseZarrError): _msg = 'path {0!r} contains a group' def err_contains_group...
class Solution: def longestStrChain(self, words: List[str]) -> int: dp = {} for word in sorted(words, key=len): dp[word] = max(dp.get(word[:i] + word[i + 1:], 0) + 1 for i in range(len(word))) return max(dp.values())
class Solution: def longest_str_chain(self, words: List[str]) -> int: dp = {} for word in sorted(words, key=len): dp[word] = max((dp.get(word[:i] + word[i + 1:], 0) + 1 for i in range(len(word)))) return max(dp.values())
# Integer Break class Solution: def integerBreak(self, n): dp = [0] * (max(7, n + 1)) dp[2] = 1 dp[3] = 2 dp[4] = 4 dp[5] = 6 dp[6] = 9 if n <= 6: return dp[n] mod = n % 3 if mod == 0: return dp[6] * 3 ** ((n - 6) // ...
class Solution: def integer_break(self, n): dp = [0] * max(7, n + 1) dp[2] = 1 dp[3] = 2 dp[4] = 4 dp[5] = 6 dp[6] = 9 if n <= 6: return dp[n] mod = n % 3 if mod == 0: return dp[6] * 3 ** ((n - 6) // 3) elif mod...
class ParseError(Exception): def __init__(self,mes:str="")->None: super().__init__() self.mes = mes def __str__(self)->str: return f"ParseError: {self.mes}" class Flag: def __init__(self,flag:str,options:int,second_flag:str=None,flag_symbol:str="-")->None: self.flag=flag ...
class Parseerror(Exception): def __init__(self, mes: str='') -> None: super().__init__() self.mes = mes def __str__(self) -> str: return f'ParseError: {self.mes}' class Flag: def __init__(self, flag: str, options: int, second_flag: str=None, flag_symbol: str='-') -> None: ...
RUNNING_NODE_CONFIG = { "pid": 58701, "version": "main", "network": "localnet" } LOG_PATH = "{}/forge/localnet/main/logs/2021-12-22-10:21:00.884707.txt" MNEMONIC_INFO = """ name: validator type: local address: pb14rclwq9xych9t0vqzdf7flw2dmhmqv3sxjjru8 pubkey: '{"@type":"/cosmos.crypto....
running_node_config = {'pid': 58701, 'version': 'main', 'network': 'localnet'} log_path = '{}/forge/localnet/main/logs/2021-12-22-10:21:00.884707.txt' mnemonic_info = '\nname: validator\n type: local\n address: pb14rclwq9xych9t0vqzdf7flw2dmhmqv3sxjjru8\n pubkey: \'{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"Ag...
# SPDX-License-Identifier: Apache-2.0 # Copyright Contributors to the OpenTimelineIO project VIEW_STYLESHEET = """ QMainWindow { background-color: rgb(27, 27, 27); } QScrollBar:horizontal { background: rgb(21, 21, 21); height: 15px; margin: 0px 20px 0 20px; } QScrollBar::handle:horizontal { backg...
view_stylesheet = '\nQMainWindow {\n background-color: rgb(27, 27, 27);\n}\n\nQScrollBar:horizontal {\n background: rgb(21, 21, 21);\n height: 15px;\n margin: 0px 20px 0 20px;\n}\n\nQScrollBar::handle:horizontal {\n background: rgb(255, 83, 112);\n min-width: 20px;\n}\n\nQScrollBar::add-line:horizonta...
''' u are given pointer to the root of the binary search tree and two values and . You need to return the lowest common ancestor (LCA) of and in the binary search tree. image In the diagram above, the lowest common ancestor of the nodes and is the node . Node is the lowest node which has nodes and as descendan...
""" u are given pointer to the root of the binary search tree and two values and . You need to return the lowest common ancestor (LCA) of and in the binary search tree. image In the diagram above, the lowest common ancestor of the nodes and is the node . Node is the lowest node which has nodes and as descendan...
# uncompyle6 version 3.7.4 # Python bytecode 3.7 (3394) # Decompiled from: Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)] # Embedded file name: T:\InGame\Gameplay\Scripts\Server\filters\demographics_filter_term_mixin.py # Compiled at: 2018-12-11 03:52:40 # Size of source mod 2*...
class Demographicsfiltertermmixin: def get_valid_world_ids(self): raise NotImplementedError
def main(): max_id = -1 with open("data.txt") as f: for line in f: line = line.strip() if len(line) == 0: continue if len(line) != 10: raise ValueError(f"unexpected line {line} in input file") max_id = max(max_id, int("".joi...
def main(): max_id = -1 with open('data.txt') as f: for line in f: line = line.strip() if len(line) == 0: continue if len(line) != 10: raise value_error(f'unexpected line {line} in input file') max_id = max(max_id, int(''.jo...
def format_composition(attribute, features): if attribute == 'key': return format_key(features) if attribute == 'tempo': return format_tempo(features) if attribute == 'signature': return format_signature(features) def format_signature(features): return str(features['time_signat...
def format_composition(attribute, features): if attribute == 'key': return format_key(features) if attribute == 'tempo': return format_tempo(features) if attribute == 'signature': return format_signature(features) def format_signature(features): return str(features['time_signatu...
def binary_search(arr, n): return _binary_search(sorted(arr), n, 0, len(arr) - 1) def _binary_search(arr, n, start, end): if start > end: return 0 mid = int((start + end) / 2) if n == arr[mid]: return 1 elif n < arr[mid]: return _binary_search(arr, n, start, mid - 1) else: return _binary_search(arr, n, ...
def binary_search(arr, n): return _binary_search(sorted(arr), n, 0, len(arr) - 1) def _binary_search(arr, n, start, end): if start > end: return 0 mid = int((start + end) / 2) if n == arr[mid]: return 1 elif n < arr[mid]: return _binary_search(arr, n, start, mid - 1) els...
# URI Online Judge 1178 X = float(input()) N = [X] print('N[{}] = {:.4f}'.format(0, N[0])) for i in range(1, 100): N.append(N[i-1]/2) print('N[{}] = {:.4f}'.format(i, N[i-1]/2))
x = float(input()) n = [X] print('N[{}] = {:.4f}'.format(0, N[0])) for i in range(1, 100): N.append(N[i - 1] / 2) print('N[{}] = {:.4f}'.format(i, N[i - 1] / 2))
# Global variables representing colors WHITE = (255, 255, 255) BLACK = (0, 0, 0) # Global variable used for sizing ICON_SIZE = 24
white = (255, 255, 255) black = (0, 0, 0) icon_size = 24
""" Given a non-empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the second middle node. Example 1: Input: [1,2,3,4,5] Output: Node 3 from this list (Serialization: [3,4,5]) The returned node has value 3. (The judge's serialization of this n...
""" Given a non-empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the second middle node. Example 1: Input: [1,2,3,4,5] Output: Node 3 from this list (Serialization: [3,4,5]) The returned node has value 3. (The judge's serialization of this n...
#LeetCode problem 112: Path Sum # 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 hasPathSum(self, root: TreeNode, sum: int) -> bool: if root is N...
class Solution: def has_path_sum(self, root: TreeNode, sum: int) -> bool: if root is None: return False if root.left is None and root.right is None: return root.val == sum res = [] self.isTrue(root, sum, res) print(res) if res.count(1) >= 1: ...
blacklisted_generators = [ 'latitude', 'geo_coordinate', 'longitude', 'time_delta', 'date_object', 'date_time', 'date_time_between', 'date_time_ad', 'date_time_this_decade', 'date_time_between_dates', 'time_object', 'date_time_this_year', 'date_time_this_century', ...
blacklisted_generators = ['latitude', 'geo_coordinate', 'longitude', 'time_delta', 'date_object', 'date_time', 'date_time_between', 'date_time_ad', 'date_time_this_decade', 'date_time_between_dates', 'time_object', 'date_time_this_year', 'date_time_this_century', 'date_time_this_month', 'sentences', 'words', 'paragraph...
class NoSolutionError(Exception): """Exception returned when a DnaOptimizationProblem aborts. This means that the constraints are found to be unsatisfiable. """ def __init__(self, message, problem, constraint=None, location=None): """Initialize.""" Exception.__init__(self, message) ...
class Nosolutionerror(Exception): """Exception returned when a DnaOptimizationProblem aborts. This means that the constraints are found to be unsatisfiable. """ def __init__(self, message, problem, constraint=None, location=None): """Initialize.""" Exception.__init__(self, message) ...
class Node: def __init__(self,data): self.data = data self.next = None class Solution: def display(self,head): current = head while current: print(current.data,end=' ') current = current.next def insert(self, head, data): if head is None: ...
class Node: def __init__(self, data): self.data = data self.next = None class Solution: def display(self, head): current = head while current: print(current.data, end=' ') current = current.next def insert(self, head, data): if head is None...