content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
def gcdEuclidian(a, b): while a != b: if a > b: a = a - b elif a < b: b = b - a return a def gcdEuclidianMod(a, b): while a > 0: a = a % b b = b - a return b def scm(a, b): return a * b / gcdEuclidianMod(a, b) print(gcdEuclidi...
def gcd_euclidian(a, b): while a != b: if a > b: a = a - b elif a < b: b = b - a return a def gcd_euclidian_mod(a, b): while a > 0: a = a % b b = b - a return b def scm(a, b): return a * b / gcd_euclidian_mod(a, b) print(gcd_euclidian(12, 20)...
valores = list() for cont in range(0, 5): valores.append(int(input('digite um valor: '))) print(valores) for c, v in enumerate(valores): print(f'na posicao {c} encontrei o valor {v} ')
valores = list() for cont in range(0, 5): valores.append(int(input('digite um valor: '))) print(valores) for (c, v) in enumerate(valores): print(f'na posicao {c} encontrei o valor {v} ')
# TODO: this must be the admissible categories only permodel, not just the categories # but maybe i can add the count/size for each category and the threshold for each model category_list = [ 'tituli_honorarii', 'tituli_operum', 'tituli_sacri', 'tituli_sepulcrales', 'carmina', 'defixiones', 'diplo...
category_list = ['tituli_honorarii', 'tituli_operum', 'tituli_sacri', 'tituli_sepulcrales', 'carmina', 'defixiones', 'diplomata_militaria', 'miliaria', 'inscriptiones_christianae', 'leges', 'senatus_consulta', 'sigilla_impressa', 'termini', 'tesserae_nummulariae', 'signacula', 'signacula_medicorum', 'litterae_erasae', ...
# # @lc app=leetcode id=1049 lang=python3 # # [1049] Last Stone Weight II # # @lc code=start class Solution: ''' dp[stone + i] = max(dp[stone + i], dp[i] + stone) ''' def lastStoneWeightII(self, stones: List[int]) -> int: s = sum(stones) m = s // 2 dp = [0 for _ in range(m + 1)...
class Solution: """ dp[stone + i] = max(dp[stone + i], dp[i] + stone) """ def last_stone_weight_ii(self, stones: List[int]) -> int: s = sum(stones) m = s // 2 dp = [0 for _ in range(m + 1)] for stone in stones: for i in range(m + 1, -1, -1): i...
fir = int(input("Insert your first number\n")) sec = int(input("Insert your second number\n")) thir = int(input("Insert your third number\n")) if fir > sec and fir > thir: print("The greather number is:\n") print(fir) elif sec > fir and sec > thir: print("The greather number is:\n") print(sec) elif t...
fir = int(input('Insert your first number\n')) sec = int(input('Insert your second number\n')) thir = int(input('Insert your third number\n')) if fir > sec and fir > thir: print('The greather number is:\n') print(fir) elif sec > fir and sec > thir: print('The greather number is:\n') print(sec) elif thir...
# Functions are defined by using the "def" keyword. def say_hi(name, age): print("Hello " + name + ", your age is " + age + "!") say_hi("Mike", "35") # Functions like "say_hi" can even receive an integer if it is properly converted. def say_hi(name, age): print("Hello " + name + ", your age is " + str(age) ...
def say_hi(name, age): print('Hello ' + name + ', your age is ' + age + '!') say_hi('Mike', '35') def say_hi(name, age): print('Hello ' + name + ', your age is ' + str(age) + '!') say_hi('Steve', 70)
channels = [] def reset_channels(a, b, c, main_win): channels.clear() if main_win.v_channel_1_on.get(): channels.append(0) if main_win.v_channel_2_on.get(): channels.append(1) if main_win.v_channel_3_on.get(): channels.append(2) if main_win.v_channel_4_on.get(): ch...
channels = [] def reset_channels(a, b, c, main_win): channels.clear() if main_win.v_channel_1_on.get(): channels.append(0) if main_win.v_channel_2_on.get(): channels.append(1) if main_win.v_channel_3_on.get(): channels.append(2) if main_win.v_channel_4_on.get(): chan...
FIRST_THOUSAND_OR_SO_USER_AGENTS = [ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36", "Mozilla/5.0 (Macintosh; Intel Mac...
first_thousand_or_so_user_agents = ['Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36', 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6...
DATABASE = 'flaskr.db' DEBUG = True ENV = 'development' SECRET_KEY = 'flaskr' USERNAME = 'admin' PASSWORD = 'admin'
database = 'flaskr.db' debug = True env = 'development' secret_key = 'flaskr' username = 'admin' password = 'admin'
def main(): even_numbers = 0 odd_numbers = 0 while True: number = float(input(f"Number {even_numbers + odd_numbers + 1}: ")) if number == 0: break if number % 2 == 0: even_numbers += 1 else: odd_numbers += 1 print(f"Numeros pares {even_...
def main(): even_numbers = 0 odd_numbers = 0 while True: number = float(input(f'Number {even_numbers + odd_numbers + 1}: ')) if number == 0: break if number % 2 == 0: even_numbers += 1 else: odd_numbers += 1 print(f'Numeros pares {even_...
is_running = False running_message = '' class MyState: is_check_available = False is_work_space = False is_train_tsv = False is_train = False is_analyse = False is_warning = False is_hot = False my_state = MyState()
is_running = False running_message = '' class Mystate: is_check_available = False is_work_space = False is_train_tsv = False is_train = False is_analyse = False is_warning = False is_hot = False my_state = my_state()
# The natural approach would be to do initialization in the object # constructor: class counter: def __init__(self): self.count = 0 def next(self): self.count += 1 return self.count # But Python offer a terse and efficient alternative: class counter: count = 0 def next(self)...
class Counter: def __init__(self): self.count = 0 def next(self): self.count += 1 return self.count class Counter: count = 0 def next(self): self.count += 1 return self.count
# This program reads in a students percentage mark # and prints out the corresponding grade #Modified to deal with rounding x = float (input ("Enter the percentage: ")) if x < 40: print("Fail") elif x <= 49.5: print("Pass") elif x <= 59.5: print("Merit 2") elif x <= 69.5: print("Merit 1") else: p...
x = float(input('Enter the percentage: ')) if x < 40: print('Fail') elif x <= 49.5: print('Pass') elif x <= 59.5: print('Merit 2') elif x <= 69.5: print('Merit 1') else: print('Distinction') x = float(input('Enter the percentage: ')) if x < 40: print('Fail') elif x < 49.6: print('Pass') elif...
# SOLVER SETTING # --------------- # define solver setting # number of finite difference points along the reactor length [zNo] # number of orthogonal collocation points inside the catalyst particle [rNo] # S1 # heterogenous model # S2 # homogenous dynamic model for plug-flow reactors # timesNo: in each loop (time) ...
diff_setting = {'BD': -1, 'CD': 0, 'FD': 1} solver_setting = {'N1': {'zNo': 100}, 'N2': {'zNo': 20, 'rNo': 5, 'tNo': 5, 'timesNo': 5}, 'S1': {'zNo': 20, 'rNo': 5}, 'S2': {'tNo': 10, 'zNo': 100, 'rNo': 7, 'timesNo': 5}, 'S3': {'timesNo': 25}, 'M9': {'zNo': 30, 'rNo': 1, 'zMesh': {'zNoNo': [15, 10], 'DoLeSe': 30, 'MeReDe...
def testEqual(actual,expected,places=5): ''' Does the actual value equal the expected value? For floats, places indicates how many places, right of the decimal, must be correct ''' if isinstance(expected,float): if abs(actual-expected) < 10**(-places): print('\tPass') ...
def test_equal(actual, expected, places=5): """ Does the actual value equal the expected value? For floats, places indicates how many places, right of the decimal, must be correct """ if isinstance(expected, float): if abs(actual - expected) < 10 ** (-places): print('\tPass') ...
class DataObj: def __init__(self): self.datasets = { "lincslevel2": { "name": "LINCS Level 2", "description": "This is **LINCS Level 2** data.\n\n\nIt was ~~released~~ on December 31st, 2015", "numMetaTypes": 12, "numGenes": 978, ...
class Dataobj: def __init__(self): self.datasets = {'lincslevel2': {'name': 'LINCS Level 2', 'description': 'This is **LINCS Level 2** data.\n\n\nIt was ~~released~~ on December 31st, 2015', 'numMetaTypes': 12, 'numGenes': 978, 'numSamples': 112634, 'uploadDate': 1464695717279}} self.meta = {'lincs...
# d1 = {'chave1': 'valor da chave 1','chave2': 'valor da chave 2'} # d1 = dict(chave1='valor da chave 1', chave2='valor da chave 2') # d1['chave3'] = 'valor da chave 3' # # print(d1) d1 = { 'str': 'valor', 123: 'outro valor', (1,3,2,4): 'tupla' } # print(d1[(1,3,2,4)]) # d1['chavenaoexiste'] = 'agora exi...
d1 = {'str': 'valor', 123: 'outro valor', (1, 3, 2, 4): 'tupla'} d1 = {1: 2, 3: 4, 5: 6} d2 = {'a': 'b', 'c': 'd'} d1.update(d2) print(d1)
def test_facts(napalm_connect): napalm_facts = napalm_connect.get_facts() assert isinstance(napalm_facts, type({})) assert napalm_facts["uptime"] > 0 assert napalm_facts["vendor"].lower() == "cisco" assert "15.4(2)T1" in napalm_facts["os_version"] assert napalm_facts["serial_number"] == "FTX1512...
def test_facts(napalm_connect): napalm_facts = napalm_connect.get_facts() assert isinstance(napalm_facts, type({})) assert napalm_facts['uptime'] > 0 assert napalm_facts['vendor'].lower() == 'cisco' assert '15.4(2)T1' in napalm_facts['os_version'] assert napalm_facts['serial_number'] == 'FTX1512...
class Solution: def checkInclusion(self, s1: str, s2: str) -> bool: if len(s2) < len(s1): return False mp = dict() for i in range(len(s1)): if s1[i] not in mp.keys(): mp[s1[i]] = 0 mp[s1[i]] += 1 mp2 = dict() for i in ran...
class Solution: def check_inclusion(self, s1: str, s2: str) -> bool: if len(s2) < len(s1): return False mp = dict() for i in range(len(s1)): if s1[i] not in mp.keys(): mp[s1[i]] = 0 mp[s1[i]] += 1 mp2 = dict() for i in rang...
class Gender: F = 0 # Female M = 1 # Male BOTH = 2 # Female and Male UNKNOWN = 3 # Unknown
class Gender: f = 0 m = 1 both = 2 unknown = 3
class Node: # Constructor to create a new node def __init__(self, data): self.data = data self.next = None class ListaCircularEncadeada: # Constructor to create a empty circular linked list def __init__(self): self.head = None modifiedWord = "" # Function to inse...
class Node: def __init__(self, data): self.data = data self.next = None class Listacircularencadeada: def __init__(self): self.head = None modified_word = '' def inserir_elemento(self, data): modified_word = data if data.istitle(): modified_word = ...
# ====================================================================== # Medicine for Rudolph # Advent of Code 2015 Day 19 -- Eric Wastl -- https://adventofcode.com # # Python implementation by Dr. Dean Earl Wright III # ====================================================================== # =====================...
"""A solver for the Advent of Code 2015 Day 19 puzzle""" upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' terminals = ['Rn', 'Ar', 'Y', 'Y'] class Medicine(object): """Object for Medicine for Rudolph""" def __init__(self, text=None, part2=False): self.part2 = part2 self.text = text self.transforma...
actions = { "buy": 0, "sell": 1 } order_types = { "limited": 0, "stop_limited": 1, "market_order": 2, "stop_loss": 3 } time_types = { "day": 1, "permanent": 3 } product_types = { "all": None, "shares": 1, "bonds": 2, "futures": 7, "options": 8, "invest_funds": ...
actions = {'buy': 0, 'sell': 1} order_types = {'limited': 0, 'stop_limited': 1, 'market_order': 2, 'stop_loss': 3} time_types = {'day': 1, 'permanent': 3} product_types = {'all': None, 'shares': 1, 'bonds': 2, 'futures': 7, 'options': 8, 'invest_funds': 13, 'leverage_products': 14, 'etfs': 131, 'cfds': 535, 'warrants':...
#!/usr/bin/env python print(True and not False) #print(True and not false) print(True or True and False) print(not True or not False) print(True and not 0) print(52 < 52.3) print(1 + 53 < 52.3) print(4 != 4.0)
print(True and (not False)) print(True or (True and False)) print(not True or not False) print(True and (not 0)) print(52 < 52.3) print(1 + 53 < 52.3) print(4 != 4.0)
class EmptyCell: def __init__(self, id, x): self.id = id self.x = x def vertices(self): return None def face_vertices(self): return None def neighbors(self): return None
class Emptycell: def __init__(self, id, x): self.id = id self.x = x def vertices(self): return None def face_vertices(self): return None def neighbors(self): return None
class BaseItem: def __init__(self, identifier): self.__identifier = identifier def get_id(self): return self.__identifier def set_id(self, identifier): self.__identifier = identifier class Entity(BaseItem): def __init__(self, identifier, lane...
class Baseitem: def __init__(self, identifier): self.__identifier = identifier def get_id(self): return self.__identifier def set_id(self, identifier): self.__identifier = identifier class Entity(BaseItem): def __init__(self, identifier, lane, distance, acceleration, length,...
makers=['acura', 'alfa romeo', 'aston martin', 'audi', 'bentley', 'bmw', 'buick', 'cadillac', 'chevrolet', 'chrysler', 'datsun', 'dodge', 'ferrari', 'fiat', 'ford', 'geely', 'general motors', 'geo', 'gmc', 'harley', 'honda', 'hummer', 'hyundai', 'infiniti', 'isuzu', 'jaguar', 'jeep', 'kawasaki', 'kia', 'ktm', 'laforza'...
makers = ['acura', 'alfa romeo', 'aston martin', 'audi', 'bentley', 'bmw', 'buick', 'cadillac', 'chevrolet', 'chrysler', 'datsun', 'dodge', 'ferrari', 'fiat', 'ford', 'geely', 'general motors', 'geo', 'gmc', 'harley', 'honda', 'hummer', 'hyundai', 'infiniti', 'isuzu', 'jaguar', 'jeep', 'kawasaki', 'kia', 'ktm', 'laforz...
# -*- coding: utf-8 -*- # Scrapy settings for downloader project # # For simplicity, this file contains only settings considered important or # commonly used. You can find more settings consulting the documentation: # # https://doc.scrapy.org/en/latest/topics/settings.html # https://doc.scrapy.org/en/latest/to...
bot_name = 'downloader' spider_modules = ['downloader.spiders'] newspider_module = 'downloader.spiders' splash_url = 'http://0.0.0.0:8050/' user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36' robotstxt_obey = False concurrent_requests = 1 dupefilter_d...
class Solution: def maxPower(self, s: str) -> int: counter = 0 result = 0 prev = "" for c in s: if c == prev: counter += 1 else: prev = c counter = 1 result = max(result, counter) return resul...
class Solution: def max_power(self, s: str) -> int: counter = 0 result = 0 prev = '' for c in s: if c == prev: counter += 1 else: prev = c counter = 1 result = max(result, counter) return res...
def getInput(): f = open("advent/2021/input/6.txt", "r") data = f.read() return [int(x) for x in data.split(',')] data = getInput() fish = [] day = [] total = 0 for d in data: fish = [[d]] fish.append([d]) for n in range(256): for f in fish[n]: if f == 0: ...
def get_input(): f = open('advent/2021/input/6.txt', 'r') data = f.read() return [int(x) for x in data.split(',')] data = get_input() fish = [] day = [] total = 0 for d in data: fish = [[d]] fish.append([d]) for n in range(256): for f in fish[n]: if f == 0: ne...
ACTION_OK = 'Ok' ACTION_ALARM = 'Alarm' ACTION_INSUFFICIENT_DATA = 'InsufficientData' ACTIONS_NONE = () ACTIONS_OK_ALARM = (ACTION_OK, ACTION_ALARM) ACTIONS_ALL = (ACTION_OK, ACTION_ALARM, ACTION_INSUFFICIENT_DATA)
action_ok = 'Ok' action_alarm = 'Alarm' action_insufficient_data = 'InsufficientData' actions_none = () actions_ok_alarm = (ACTION_OK, ACTION_ALARM) actions_all = (ACTION_OK, ACTION_ALARM, ACTION_INSUFFICIENT_DATA)
pkgname = "file" pkgver = "5.41" pkgrel = 0 build_style = "gnu_configure" configure_args = [ "--enable-static", "--disable-libseccomp", "--disable-bzlib", "--disable-xzlib" ] hostmakedepends = ["pkgconf"] makedepends = ["zlib-devel"] pkgdesc = "File type identification utility" maintainer = "q66 <q66@chimera-li...
pkgname = 'file' pkgver = '5.41' pkgrel = 0 build_style = 'gnu_configure' configure_args = ['--enable-static', '--disable-libseccomp', '--disable-bzlib', '--disable-xzlib'] hostmakedepends = ['pkgconf'] makedepends = ['zlib-devel'] pkgdesc = 'File type identification utility' maintainer = 'q66 <q66@chimera-linux.org>' ...
#!/usr/bin/python3 with open('input.txt') as f: input = f.read().splitlines() earliest = int(input[0]) services = list(map(int, [x for x in input[1].split(',') if x != 'x'])) closest = 0 bus = None for service in services: n = ((earliest // service) + 1) * service if closest == 0 or n < closest: closest =...
with open('input.txt') as f: input = f.read().splitlines() earliest = int(input[0]) services = list(map(int, [x for x in input[1].split(',') if x != 'x'])) closest = 0 bus = None for service in services: n = (earliest // service + 1) * service if closest == 0 or n < closest: closest = n bus ...
ch=input("enter a string = ") vowel=0 consonent=0 special=0 digit=0 for i in range (len(ch)): if(ch[i] in 'aeiou'): vowel=vowel+1 elif(ch[i]>='a' and ch[i]<='z'): consonent+=1 elif(ch[i]>='0' and ch[i]<='9'): digit+=1 else: special+=1 print("vowel count = ",vowel) print("...
ch = input('enter a string = ') vowel = 0 consonent = 0 special = 0 digit = 0 for i in range(len(ch)): if ch[i] in 'aeiou': vowel = vowel + 1 elif ch[i] >= 'a' and ch[i] <= 'z': consonent += 1 elif ch[i] >= '0' and ch[i] <= '9': digit += 1 else: special += 1 print('vowel ...
def printOutputForTesting(neuronIndex, timeAndRefrac, dendObj): print( 'neuronIndex',neuronIndex,'time',timeAndRefrac.time) print( 'dendObj.dirac',dendObj[0].dirac,dendObj[1].dirac,dendObj[2].dirac,dendObj[3].dirac) print( 'dendObj.v',dendObj[0].v,dendObj[1].v,dendObj[2].v,dendObj[3].v) print( 'sum(dendObj[neuronIn...
def print_output_for_testing(neuronIndex, timeAndRefrac, dendObj): print('neuronIndex', neuronIndex, 'time', timeAndRefrac.time) print('dendObj.dirac', dendObj[0].dirac, dendObj[1].dirac, dendObj[2].dirac, dendObj[3].dirac) print('dendObj.v', dendObj[0].v, dendObj[1].v, dendObj[2].v, dendObj[3].v) print...
ACCESS_LEVELS = [ (0, "internal"), (1, "candidate"), (2, "external"), ]
access_levels = [(0, 'internal'), (1, 'candidate'), (2, 'external')]
SQLALCHEMY_ECHO = True SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://msn_mmais:msn123@localhost/msntooldb_dev' SQLALCHEMY_TRACK_MODIFICATIONS = False SQLALCHEMY_ENCODING = "utf8" SQLALCHEMY_POOL_TIMEOUT = 15 SQLALCHEMY_POOL_RECYCLE = 2
sqlalchemy_echo = True sqlalchemy_database_uri = 'mysql+pymysql://msn_mmais:msn123@localhost/msntooldb_dev' sqlalchemy_track_modifications = False sqlalchemy_encoding = 'utf8' sqlalchemy_pool_timeout = 15 sqlalchemy_pool_recycle = 2
def can_build(env, platform): return True def configure(env): pass def get_doc_classes(): return [ "WorldGeneratorPropData", "Planet", "Building", "Biome", "WorldGenerator", ] def get_doc_path(): return "doc_classes"
def can_build(env, platform): return True def configure(env): pass def get_doc_classes(): return ['WorldGeneratorPropData', 'Planet', 'Building', 'Biome', 'WorldGenerator'] def get_doc_path(): return 'doc_classes'
def count_subsets(nums, sum): n = len(nums) dp = [[-1 for x in range(sum + 1)] for y in range(n)] # populate the sum = 0 columns, as we will always have an empty set for zero sum for i in range(0, n): dp[i][0] = 1 # with only one number, we can form a subset only when the required sum is e...
def count_subsets(nums, sum): n = len(nums) dp = [[-1 for x in range(sum + 1)] for y in range(n)] for i in range(0, n): dp[i][0] = 1 for s in range(1, sum + 1): dp[0][s] = 1 if nums[0] == s else 0 for i in range(1, n): for s in range(1, sum + 1): count_by_excludin...
class TheaterInformationQueryParameterBuilder: ROTTEN_TOMATOES_CODE = "RTO" @staticmethod def build(query): parameters = { "date": query.date.strftime("%Y%m%d"), "deviceType": TheaterInformationQueryParameterBuilder.ROTTEN_TOMATOES_CODE, "fullMovieInfo": query.re...
class Theaterinformationqueryparameterbuilder: rotten_tomatoes_code = 'RTO' @staticmethod def build(query): parameters = {'date': query.date.strftime('%Y%m%d'), 'deviceType': TheaterInformationQueryParameterBuilder.ROTTEN_TOMATOES_CODE, 'fullMovieInfo': query.return_complete_movie_info, 'limit': qu...
n = int(input('Fibonacci numero: ')) i = 0 n3 = 1 n1 = -1 n2 = 1 while i < n: i = i + 1 n3 = n2 + n1 n1 = n2 n2 = n3 print('{}'. format(n3), end="-> ") print('FIM')
n = int(input('Fibonacci numero: ')) i = 0 n3 = 1 n1 = -1 n2 = 1 while i < n: i = i + 1 n3 = n2 + n1 n1 = n2 n2 = n3 print('{}'.format(n3), end='-> ') print('FIM')
def main(): print('TATER NUMBER ONE') if __name__ == '__main__': main()
def main(): print('TATER NUMBER ONE') if __name__ == '__main__': main()
#!/usr/bin/env python3 class Track: class State: STOPPED = 0 PLAYING = 1 PAUSED = 2 def __init__(self, dictionary=None): self.path = None self.offset = 0 self.length = 0 self.index = 0 self.title = None self.artist = None self.al...
class Track: class State: stopped = 0 playing = 1 paused = 2 def __init__(self, dictionary=None): self.path = None self.offset = 0 self.length = 0 self.index = 0 self.title = None self.artist = None self.album = None self....
def genFib(): f1 = 0 f2 = 1 yield 0 yield 1 while True: next = f1 + f2 yield next f1 = f2 f2 = next fib = genFib() n = int(input('How many fibonacci numbers would you like? - ')) for i in range(n): print(fib.__next__())
def gen_fib(): f1 = 0 f2 = 1 yield 0 yield 1 while True: next = f1 + f2 yield next f1 = f2 f2 = next fib = gen_fib() n = int(input('How many fibonacci numbers would you like? - ')) for i in range(n): print(fib.__next__())
def sort_matrix(mat, size): ''' Takes input as unsorted matrix. Creates a 1-d list of len size*size and values 0. Sorts this list using python .sort() method. Then assigns these values to the original matrix. Parameters: unsorted matrix mat size of matrix Retu...
def sort_matrix(mat, size): """ Takes input as unsorted matrix. Creates a 1-d list of len size*size and values 0. Sorts this list using python .sort() method. Then assigns these values to the original matrix. Parameters: unsorted matrix mat size of matrix Retu...
# Map and Lambda Function # Problem Link: https://www.hackerrank.com/challenges/map-and-lambda-expression/problem # Complete the lambda function below. cube = lambda x: x ** 3 # Complete the definition below. def fibonacci(n): fibo = [0, 1] for i in range(1, n): fibo.append(fibo[i] + fibo[i - 1]) ...
cube = lambda x: x ** 3 def fibonacci(n): fibo = [0, 1] for i in range(1, n): fibo.append(fibo[i] + fibo[i - 1]) return fibo[0:n] if __name__ == '__main__': n = int(input()) print(list(map(cube, fibonacci(n))))
def json_internal_to_internal( start, end): '''kibana 24hour json''' es_request_query = { "query": { "bool": { "must": [ { "match_all": {} }, { "bool": { "should": [ { "term": { ...
def json_internal_to_internal(start, end): """kibana 24hour json""" es_request_query = {'query': {'bool': {'must': [{'match_all': {}}, {'bool': {'should': [{'term': {'destination_ip': '192.168.0.0/16'}}, {'term': {'destination_ip': '10.0.0.0/8'}}, {'term': {'destination_ip': '172.16.0.0/12'}}]}}, {'bool': {'sho...
class Solution: def plusOne(self, digits: List[int]) -> List[int]: carry = False for index in range(len(digits) - 1, -1, -1): digit = digits[index] if digit == 9: digits[index] = 0 carry = True else: digits[inde...
class Solution: def plus_one(self, digits: List[int]) -> List[int]: carry = False for index in range(len(digits) - 1, -1, -1): digit = digits[index] if digit == 9: digits[index] = 0 carry = True else: digits[index] ...
def process(hive_context, date): print('Processing foo') print(hive_context, date) def compute(hive_context, date): print('Computing foo') print(hive_context, date)
def process(hive_context, date): print('Processing foo') print(hive_context, date) def compute(hive_context, date): print('Computing foo') print(hive_context, date)
for i in range(5): if i == 3: continue # Skip the rest of the code inside loop for current i value print(i) for x in range(10): if x % 2 == 0: continue # Skip print(x) for this loop print(x)
for i in range(5): if i == 3: continue print(i) for x in range(10): if x % 2 == 0: continue print(x)
i=0 l=[] element=input('Enter the elements enter end to stop: ') while(element != 'end'): l.append(int(element)) i=i+1 element=input('Enter the elements enter end to stop: ') print('Your input') for item in l: print(item) d=l for k in range(0,len(l)): for j in range(k,len(l)): if(l[k]>=l[j]): l[k],l[j]=l[j...
i = 0 l = [] element = input('Enter the elements enter end to stop: ') while element != 'end': l.append(int(element)) i = i + 1 element = input('Enter the elements enter end to stop: ') print('Your input') for item in l: print(item) d = l for k in range(0, len(l)): for j in range(k, len(l)): ...
#!/usr/bin/env python3 # Day 21: Dungeon Game # # The demons had captured the princess (P) and imprisoned her in the # bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid # out in a 2D grid. Our valiant knight (K) was initially positioned in the # top-left room and must fight his way through the...
class Solution: def calculate_minimum_hp(self, dungeon: [[int]]) -> int: height = len(dungeon) width = len(dungeon[0]) required = [[0 for y in x] for x in dungeon] for row in range(height - 1, -1, -1): for column in range(width - 1, -1, -1): if row == hei...
class Hero: def __init__(self, name, health, armor): self.name = name self.__health = health self.__armor = armor # self.info = "name {} : \n\tHealth : {}".format(self.name, self.__health) @property def info(self): return "name {} : \n\tHealth : {}".format(...
class Hero: def __init__(self, name, health, armor): self.name = name self.__health = health self.__armor = armor @property def info(self): return 'name {} : \n\tHealth : {}'.format(self.name, self.__health) @property def armor(self): pass @armor.gette...
retrieve = [ {"scenario":"Patient Exists","patient":"9000000009", "response":{"address":[{"extension":[{"extension":[{"url":"type","valueCoding":{"code":"PAF","system":"https://fhir.nhs.uk/R4/CodeSystem/UKCore-AddressKeyType"}},{"url":"value","valueString":"12345678"}],"url":"https://fhir.nhs.uk/R4/StructureDefinit...
retrieve = [{'scenario': 'Patient Exists', 'patient': '9000000009', 'response': {'address': [{'extension': [{'extension': [{'url': 'type', 'valueCoding': {'code': 'PAF', 'system': 'https://fhir.nhs.uk/R4/CodeSystem/UKCore-AddressKeyType'}}, {'url': 'value', 'valueString': '12345678'}], 'url': 'https://fhir.nhs.uk/R4/St...
class Solution: def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float: nums = self.mergeSortedLists(nums1, nums2) print(nums) n = len(nums) if n % 2: return nums[n//2] return 0.5 * ( nums[n//2-1] + nums[n//2] ) def mergeSortedLists...
class Solution: def find_median_sorted_arrays(self, nums1: List[int], nums2: List[int]) -> float: nums = self.mergeSortedLists(nums1, nums2) print(nums) n = len(nums) if n % 2: return nums[n // 2] return 0.5 * (nums[n // 2 - 1] + nums[n // 2]) def merge_sort...
#1019 segundos = int(input()) horas, resto = divmod(segundos, 3600) minutos, segundos = divmod(resto, 60) print("{}:{}:{}".format(horas, minutos, segundos))
segundos = int(input()) (horas, resto) = divmod(segundos, 3600) (minutos, segundos) = divmod(resto, 60) print('{}:{}:{}'.format(horas, minutos, segundos))
def is_zero_heavy(n): s = str(n) le = len(s) return s.count('0') > le / 2.0 def test_is_zero_heavy(): assert is_zero_heavy(1050006) is True assert is_zero_heavy(105006) is False assert is_zero_heavy(1) is False if __name__ == '__main__': c = 0 # for x in range(1, 101): for x in...
def is_zero_heavy(n): s = str(n) le = len(s) return s.count('0') > le / 2.0 def test_is_zero_heavy(): assert is_zero_heavy(1050006) is True assert is_zero_heavy(105006) is False assert is_zero_heavy(1) is False if __name__ == '__main__': c = 0 for x in range(1, 18163107): if is_...
class Command(): def __init__(self, args): self.args = args print('Welcome Here') def execute(self): print("Executing...")
class Command: def __init__(self, args): self.args = args print('Welcome Here') def execute(self): print('Executing...')
s = 'This is a string.' type(s) x = 42 type(x) '300' + 'cc' 300 + 400 # '300' + 400 int('300') + 400 y = 2.5 z = 2.5 id(y) id(z) x = 42 x.imagx x.__class__
s = 'This is a string.' type(s) x = 42 type(x) '300' + 'cc' 300 + 400 int('300') + 400 y = 2.5 z = 2.5 id(y) id(z) x = 42 x.imagx x.__class__
# # PySNMP MIB module JCImSeries-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/JCImSeries-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:47:31 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, constraints_intersection, value_size_constraint, single_value_constraint, value_range_constraint) ...
class Parser: def __init__(self, CodeWriter_instance, input_file_obj, current_vm_file_name): self.c = CodeWriter_instance setattr(self.c, 'vm_file_name', current_vm_file_name) self.constructor(input_file_obj) def constructor(self, file_obj): for line i...
class Parser: def __init__(self, CodeWriter_instance, input_file_obj, current_vm_file_name): self.c = CodeWriter_instance setattr(self.c, 'vm_file_name', current_vm_file_name) self.constructor(input_file_obj) def constructor(self, file_obj): for line in file_obj: co...
class GridPoint: #Line: 1, Declaring a class def __init__(self, x, y): self.x = x self.y = y #Line: 4 def __add__(self, other): # Equivalent of + operator return GridPoint(self.x + other.x, self.y + other.y) def __str__(self): #Line: 12, returns the attributes when the object ...
class Gridpoint: def __init__(self, x, y): self.x = x self.y = y def __add__(self, other): return grid_point(self.x + other.x, self.y + other.y) def __str__(self): string = str(self.x) string = string + ', ' + str(self.y) return string point1 = grid_point(3...
class Path(object): @staticmethod def db_root_dir(dataset): if dataset == 'sceneflow': return '/store/Datasets/flow/SceneFlow/' elif dataset == 'kitti15': return 'store/Datasets/flow/kitti2015/training/' elif dataset == 'kitti12': return 'store/Dataset...
class Path(object): @staticmethod def db_root_dir(dataset): if dataset == 'sceneflow': return '/store/Datasets/flow/SceneFlow/' elif dataset == 'kitti15': return 'store/Datasets/flow/kitti2015/training/' elif dataset == 'kitti12': return 'store/Datase...
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. load("//antlir/bzl:shape.bzl", "shape") load("//antlir/bzl:target.shape.bzl", "target_t") affiliations_t = shape.shape( faction = str, ...
load('//antlir/bzl:shape.bzl', 'shape') load('//antlir/bzl:target.shape.bzl', 'target_t') affiliations_t = shape.shape(faction=str) color_t = shape.enum('red', 'green', 'blue') lightsaber_t = shape.shape(color=color_t, target=shape.field(target_t, optional=True)) weapon_t = shape.union(lightsaber_t, str) callsign_t = s...
# Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def mergeTwoLists(self, l1: Optional[ListNode], l2: Optional[ListNode]) -> Optional[ListNode]: ar1 = [] ar2 = [] while l1: ...
class Listnode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def merge_two_lists(self, l1: Optional[ListNode], l2: Optional[ListNode]) -> Optional[ListNode]: ar1 = [] ar2 = [] while l1: ar1.append(l1.val) ...
class Building(object): def __init__(self, name, level, position): self.name = name self.level = level self.position = position
class Building(object): def __init__(self, name, level, position): self.name = name self.level = level self.position = position
class AnimeNotFound(Exception): def __init__(self, name: str, url_attempt: str) -> None: msg = f"{name} not found\nTried {url_attempt}" super().__init__(msg) class CloudflareError(Exception): def __init__(self) -> None: msg = "Could not get cloudflare credentials" super().__ini...
class Animenotfound(Exception): def __init__(self, name: str, url_attempt: str) -> None: msg = f'{name} not found\nTried {url_attempt}' super().__init__(msg) class Cloudflareerror(Exception): def __init__(self) -> None: msg = 'Could not get cloudflare credentials' super().__in...
class Report: revenues: float gross_Income: float operating_Income: float profit_Before_Tax: float profit_to_Equity_Holders: float earnings_Per_Share: float number_of_shares: float dividend: float intangible_assets: float tangible_assets: float financial_assets: float non...
class Report: revenues: float gross__income: float operating__income: float profit__before__tax: float profit_to__equity__holders: float earnings__per__share: float number_of_shares: float dividend: float intangible_assets: float tangible_assets: float financial_assets: float...
ANCHOR_FILE_DOENLOAD_BTN_ID = 'download_source_anchor' ANCHOR_GENERATED_UTC_CLASS = 'anchor-generated_at' ANCHOR_FILE_NAME = 'configuration_anchor_{0}_internal_{1}.xml' ANCHOR_HASH_CLASS = 'anchor-hash' TRUSTED_ANCHORS_TAB_CSS = 'a[href="#trusted_anchors_tab"]'
anchor_file_doenload_btn_id = 'download_source_anchor' anchor_generated_utc_class = 'anchor-generated_at' anchor_file_name = 'configuration_anchor_{0}_internal_{1}.xml' anchor_hash_class = 'anchor-hash' trusted_anchors_tab_css = 'a[href="#trusted_anchors_tab"]'
key = 'RWSANSOL5' mode = 'rpns-k' rpns_rates = [5, 10, 15, 20, 25, 32, 40, 50, 60, 70, 80, 90, 100] methods = ['SANSOL', 'SANSOLF', 'SANSOLcorr', 'SANSOLFcorr', 'RWSANSOL', 'RWSANSOLF', 'RWSANSOLcorr', 'RWSANSOLFcorr'] with open('../../results/rpns.csv', 'r') as f: lines = f.readlines() def get_result_array(metho...
key = 'RWSANSOL5' mode = 'rpns-k' rpns_rates = [5, 10, 15, 20, 25, 32, 40, 50, 60, 70, 80, 90, 100] methods = ['SANSOL', 'SANSOLF', 'SANSOLcorr', 'SANSOLFcorr', 'RWSANSOL', 'RWSANSOLF', 'RWSANSOLcorr', 'RWSANSOLFcorr'] with open('../../results/rpns.csv', 'r') as f: lines = f.readlines() def get_result_array(method...
# https://www.hackerrank.com/challenges/array-left-rotation/ def rotate(arr, rotations): r = rotations % len(arr) return arr[r:] + arr[:r] _, rotations = [int(i) for i in input().strip().split()] arr = input().strip().split() print(' '.join(rotate(arr, rotations)))
def rotate(arr, rotations): r = rotations % len(arr) return arr[r:] + arr[:r] (_, rotations) = [int(i) for i in input().strip().split()] arr = input().strip().split() print(' '.join(rotate(arr, rotations)))
#-*- coding:utf-8 -*- # # This file is part of MoCGF - a code generation framework # 20141114 Joerg Raedler jraedler@udk-berlin.de # # the data dictionary read from the api is the first argument, # other arguments may be introduced later... def filter01(d, systemCfg, generatorCfg, logger): logger.info('Hello, th...
def filter01(d, systemCfg, generatorCfg, logger): logger.info('Hello, this is the filter running from module: %s', __file__)
class Node: def __init__(self, key, val, pre=None, nex=None, freq=0): self.pre = pre self.nex = nex self.freq = freq self.val = val self.key = key def insert(self, nex): nex.pre = self nex.nex = self.nex self.nex.pre = nex self.nex = nex ...
class Node: def __init__(self, key, val, pre=None, nex=None, freq=0): self.pre = pre self.nex = nex self.freq = freq self.val = val self.key = key def insert(self, nex): nex.pre = self nex.nex = self.nex self.nex.pre = nex self.nex = nex ...
class Event: def __init__(self, type='GenericEvent', data=None): self.type = type if data is None: self.data = {} else: self.data = data def __repr__(self): return ''.join(['Event<', self.type, '> ', str(self.data)])
class Event: def __init__(self, type='GenericEvent', data=None): self.type = type if data is None: self.data = {} else: self.data = data def __repr__(self): return ''.join(['Event<', self.type, '> ', str(self.data)])
class Estudiante : def __init__(self, edad) : self.edad = edad def getEdad(self) : return self.edad def setEdad(self, edad) : self.edad = edad def testFunc (n) : if ((n / 10) + 3) % 5 == 0 : print('Cumple la condicion') else : print('NO Cumple la condicion') ...
class Estudiante: def __init__(self, edad): self.edad = edad def get_edad(self): return self.edad def set_edad(self, edad): self.edad = edad def test_func(n): if (n / 10 + 3) % 5 == 0: print('Cumple la condicion') else: print('NO Cumple la condicion') test...
for k in range(3, 21, 3): if k%5==0: continue print(k) ''' output 3 6 9 12 18 '''
for k in range(3, 21, 3): if k % 5 == 0: continue print(k) ' output\n3\n6\n9\n12\n18\n'
def in2cm(inches): return inches * 2.54 def mToKm(miles): return miles * 1.60934 if __name__=="__main__": for i in range(1,11): print(i, " inches is ", in2cm(i), " centimeters")
def in2cm(inches): return inches * 2.54 def m_to_km(miles): return miles * 1.60934 if __name__ == '__main__': for i in range(1, 11): print(i, ' inches is ', in2cm(i), ' centimeters')
rad = 50 cx = 500/2 cy = 500/2 l = 350 a = PI/4 w = 1 c = 0 r = 0 g = 10 b = 150 class myline(): def render(self, cx, cy, a): x1 = cx - cos(a)*l/2 y1 = cy + sin(a)*l/2 x2 = cx + cos(a)*l/2 y2 = cy - sin(a)*l/2 self.x1 = x1 self.x2 = x2 self.y1 = y1 ...
rad = 50 cx = 500 / 2 cy = 500 / 2 l = 350 a = PI / 4 w = 1 c = 0 r = 0 g = 10 b = 150 class Myline: def render(self, cx, cy, a): x1 = cx - cos(a) * l / 2 y1 = cy + sin(a) * l / 2 x2 = cx + cos(a) * l / 2 y2 = cy - sin(a) * l / 2 self.x1 = x1 self.x2 = x2 se...
############################################################################ # # Copyright (C) 2016 The Qt Company Ltd. # Contact: https://www.qt.io/licensing/ # # This file is part of Qt Creator. # # Commercial License Usage # Licensees holding valid commercial Qt licenses may use this file in # accordance with the co...
source('../../shared/qtcreator.py') def check_type_and_properties(typePropertiesDetails): for (q_type, props, detail) in typePropertiesDetails: if qType == 'QPushButton': (ws_button_frame, ws_button_label) = get_welcome_screen_side_bar_button(props) test.verify(all((wsButtonFrame, w...
# PCA for MNIST with 3 dimensional output conf = { 'function':'PCA', 'n_components':3, 'copy':False, 'whiten':False, 'svd_solver':'auto', 'tol':.0, 'iterated_power':'auto', 'random_state':None }
conf = {'function': 'PCA', 'n_components': 3, 'copy': False, 'whiten': False, 'svd_solver': 'auto', 'tol': 0.0, 'iterated_power': 'auto', 'random_state': None}
REGISTERED_WAV_PROCESSORS = {} def register_wav_processors(name): def _f(cls): REGISTERED_WAV_PROCESSORS[name] = cls return cls return _f def get_wav_processor_cls(name): return REGISTERED_WAV_PROCESSORS.get(name, None) class BaseWavProcessor: @property def name(self): ...
registered_wav_processors = {} def register_wav_processors(name): def _f(cls): REGISTERED_WAV_PROCESSORS[name] = cls return cls return _f def get_wav_processor_cls(name): return REGISTERED_WAV_PROCESSORS.get(name, None) class Basewavprocessor: @property def name(self): r...
callback_classes = [ ['ns3::ObjectBase *', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['void', 'ns3::Ptr<ns3::Socket>', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empt...
callback_classes = [['ns3::ObjectBase *', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['void', 'ns3::Ptr<ns3::Socket>', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['bo...
load(":import_external.bzl", import_external = "import_external") def dependencies(): import_external( name = "io_argonaut_argonaut_2_12", artifact = "io.argonaut:argonaut_2.12:6.2.5", artifact_sha256 = "a89474477cb3abd6473e48c4e7af3722743993a2c203272499c6e2cc79c012a3", srcjar_sha25...
load(':import_external.bzl', import_external='import_external') def dependencies(): import_external(name='io_argonaut_argonaut_2_12', artifact='io.argonaut:argonaut_2.12:6.2.5', artifact_sha256='a89474477cb3abd6473e48c4e7af3722743993a2c203272499c6e2cc79c012a3', srcjar_sha256='8328a4dbf49c1f2b96589995a05e89cac6a16d...
class ChatParseException(Exception): ''' Base exception thrown by the parser ''' pass class ResponseContextError(ChatParseException): ''' Thrown when chat data is invalid. ''' pass class NoContents(ChatParseException): ''' Thrown when ContinuationContents is missing in JSON. ...
class Chatparseexception(Exception): """ Base exception thrown by the parser """ pass class Responsecontexterror(ChatParseException): """ Thrown when chat data is invalid. """ pass class Nocontents(ChatParseException): """ Thrown when ContinuationContents is missing in JSON. ...
with open("./data/qrels.robust2004.txt") as f: f
with open('./data/qrels.robust2004.txt') as f: f
class Solution: def removeDuplicates(self, nums: List[int]) -> int: if len(nums) == 0: return 0 elif len(nums) == 1: return 1 i = 0 # slow pointer for j in range(1, len(nums)): # fast pointer if nums[i] != nums[j]: i = i ...
class Solution: def remove_duplicates(self, nums: List[int]) -> int: if len(nums) == 0: return 0 elif len(nums) == 1: return 1 i = 0 for j in range(1, len(nums)): if nums[i] != nums[j]: i = i + 1 nums[i] = nums[j] ...
vl=input().split() A=float(vl[0]) B=float(vl[1]) C=float(vl[2]) if B>A: aux=B;B=A;A=aux if C>A: aux=C;C=A;A=aux if C>B: aux=C;C=B;B=aux if C>A: aux=C;C=A;A=aux if B>A: aux=B;B=A;A=aux if C>B: aux=C;C=B;B=aux print("%.1f %.1f %.1f" %(A,B,C)) if A>=(B+C): print("NAO FORMA...
vl = input().split() a = float(vl[0]) b = float(vl[1]) c = float(vl[2]) if B > A: aux = B b = A a = aux if C > A: aux = C c = A a = aux if C > B: aux = C c = B b = aux if C > A: aux = C c = A a = aux if B > A: aux = B b = A a = aux if C > B: aux = C c ...
# While Loops : i = 1 while i<11: print(i) i += 1 print() # For Loops : #Looping through lists: greetings = ["Hello","World","!!!"] for x in greetings: #Loops through elements of the list. print(x) print() #Looping through a string: for x in "hello": #Loops through characters in...
i = 1 while i < 11: print(i) i += 1 print() greetings = ['Hello', 'World', '!!!'] for x in greetings: print(x) print() for x in 'hello': print(x) print() for x in range(6): print(x) print() for x in range(1, 6): print(x) print() for x in range(0, 20, 2): print(x) print() input('Press Enter k...
CAP_EXEMPT = [ '', 'and', 'as', 'as if', 'as long as', 'at', 'but', 'by', 'even if', 'for', 'from', 'if', 'if only', 'in', 'into', 'like', 'near', 'now that', 'nor', 'of', 'off', 'on', 'on top of', 'once', 'onto', 'or', 'out of', 'over', 'past', 'so', 'so that', 'than', 'that', 'till', 'to', 'up', 'upon', 'with', 'w...
cap_exempt = ['', 'and', 'as', 'as if', 'as long as', 'at', 'but', 'by', 'even if', 'for', 'from', 'if', 'if only', 'in', 'into', 'like', 'near', 'now that', 'nor', 'of', 'off', 'on', 'on top of', 'once', 'onto', 'or', 'out of', 'over', 'past', 'so', 'so that', 'than', 'that', 'till', 'to', 'up', 'upon', 'with', 'when'...
class TestResult(object): def __init__(self, name, statistic, pvalue, dof=None, expected=None): self.name = name self.statistic = statistic self.pvalue = pvalue self.dof = dof self.expected = expected
class Testresult(object): def __init__(self, name, statistic, pvalue, dof=None, expected=None): self.name = name self.statistic = statistic self.pvalue = pvalue self.dof = dof self.expected = expected
file_name = input("Enter file name: ") fh = open(file_name) for line in fh: print(line.strip().upper())
file_name = input('Enter file name: ') fh = open(file_name) for line in fh: print(line.strip().upper())
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def reverseList(self, head: ListNode) -> ListNode: self.prev = None self.curr = head while (self.curr != None): self.nextTemp = ...
class Solution: def reverse_list(self, head: ListNode) -> ListNode: self.prev = None self.curr = head while self.curr != None: self.nextTemp = self.curr.next self.curr.next = self.prev self.prev = self.curr self.curr = self.nextTemp re...
__all__ = ["fit_temperature", "massmod_writeout", "plotting", "set_prof_data", "density_models", "mass_models", "fit_density", "posterior_mcmc", "gen"]
__all__ = ['fit_temperature', 'massmod_writeout', 'plotting', 'set_prof_data', 'density_models', 'mass_models', 'fit_density', 'posterior_mcmc', 'gen']
class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: i=0 l=[] while(i<len(nums)): if target-nums[i] in nums: l.append(i) l.append(nums.index(target-nums[i])) i+=1 l=list(set(l)) return l
class Solution: def two_sum(self, nums: List[int], target: int) -> List[int]: i = 0 l = [] while i < len(nums): if target - nums[i] in nums: l.append(i) l.append(nums.index(target - nums[i])) i += 1 l = list(set(l)) ret...
GOOD_GEO_DATA = [ {'latitude': 0.25, 'longitude': 0.15}, ] BAD_GEO_DATA = [ {'latitude': '0.25', 'longitude': '0.15'}, ] GOOD_ADDRESS_DATA = [ { 'street-address': '1234 Made-Up Lane', 'extended-address': 'Department of Software Testing', 'locality': 'San Francisco', 'region': 'CA', 'post...
good_geo_data = [{'latitude': 0.25, 'longitude': 0.15}] bad_geo_data = [{'latitude': '0.25', 'longitude': '0.15'}] good_address_data = [{'street-address': '1234 Made-Up Lane', 'extended-address': 'Department of Software Testing', 'locality': 'San Francisco', 'region': 'CA', 'postal-code': '94108', 'country-name': 'USA'...
# I am adding two numbers a=7 b=23 print(a+b)
a = 7 b = 23 print(a + b)
expected_output = { "lisp_id": { 0: { "instance_id": { 1031: { "eid": { "aabb.cc00.c900/48" : { "host_address" : ["192.168.3.2","2001:192:168:3::2","FE80::A8BB:CCFF:FE00:C900"] ...
expected_output = {'lisp_id': {0: {'instance_id': {1031: {'eid': {'aabb.cc00.c900/48': {'host_address': ['192.168.3.2', '2001:192:168:3::2', 'FE80::A8BB:CCFF:FE00:C900']}, 'aabb.cc00.ca00/48': {'host_address': ['192.168.3.3', '2001:192:168:3::3', 'FE80::A8BB:CCFF:FE00:CA00']}}}}}}}
class Solution: def myPow(self, x: float, n: int) -> float: def calculate(x, n): if(n == 0 or x == 1): return 1.0 res = 1.0 res = res * calculate(x, n//2) res = res * res if(n % 2 == 1): res = res * x ...
class Solution: def my_pow(self, x: float, n: int) -> float: def calculate(x, n): if n == 0 or x == 1: return 1.0 res = 1.0 res = res * calculate(x, n // 2) res = res * res if n % 2 == 1: res = res * x ...
def totalStudents(students): return(len(students.keys())) students = { "Peter": {"age": 10, "address": "Lisbon"}, "Isabel": {"age": 11, "address": "Sesimbra"}, "Anna": {"age": 9, "address": "Lisbon"}, "dhruv": {"age": 10, "address": "Keet"} } print(totalStudents(students))
def total_students(students): return len(students.keys()) students = {'Peter': {'age': 10, 'address': 'Lisbon'}, 'Isabel': {'age': 11, 'address': 'Sesimbra'}, 'Anna': {'age': 9, 'address': 'Lisbon'}, 'dhruv': {'age': 10, 'address': 'Keet'}} print(total_students(students))
''' Write a Python function to return all unique values in a dictionary. The values should be returned in a list. Input Data: input_dict = {'Box1':'Apple', 'Box2':'Mango', 'Box3':'Orange', 'Box4':'Apple', 'Box5':'Orange', 'Box6':'Orange','Box7':'Strawberry','Box8':'Apple'} Expected outcome = ['Mango', 'Orange', 'Str...
""" Write a Python function to return all unique values in a dictionary. The values should be returned in a list. Input Data: input_dict = {'Box1':'Apple', 'Box2':'Mango', 'Box3':'Orange', 'Box4':'Apple', 'Box5':'Orange', 'Box6':'Orange','Box7':'Strawberry','Box8':'Apple'} Expected outcome = ['Mango', 'Orange', 'Str...