content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
m,n=map(int,input().split()) ip=[] for i in range(m): ip.append(list(map(int,input().split()))) ''' Traverse the rows once keeping track of all the rows and columns which should finally be set to 0. ''' rows=[0 for i in range(m)] columns=[0 for i in range(n)] for i in range(m): for j in range(n): if i...
(m, n) = map(int, input().split()) ip = [] for i in range(m): ip.append(list(map(int, input().split()))) '\nTraverse the rows once keeping track of all the rows\nand columns which should finally be set to 0.\n' rows = [0 for i in range(m)] columns = [0 for i in range(n)] for i in range(m): for j in range(n): ...
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. ### CONTROLS (non-tunable) ### # general TYPE_OF_RUN = evaluate # train, test, test_episodes, evaluate LOAD_MODEL_FROM = mlruns/0/eb021674da6d4662b5e360703c518476/artifacts/agent/data/model.pth SAVE_MODELS_TO = None # worker.py ENV = Battle...
type_of_run = evaluate load_model_from = mlruns / 0 / eb021674da6d4662b5e360703c518476 / artifacts / agent / data / model.pth save_models_to = None env = BattleshipEnv env_random_seed = 2 agent_random_seed = 1 reporting_interval = 1000 total_steps = 100000 anneal_lr = False num_episodes_to_test = 5 agent_net = APPROXBA...
''' This is the Entities module assigning unique features to an entity ''' class Entity: entity = None def id(self): pass def toString(self): line = '' for i in self.entity: line += str(self.entity[i]) + ', ' return line[:-2] + '\n' ''' user resource entity:...
""" This is the Entities module assigning unique features to an entity """ class Entity: entity = None def id(self): pass def to_string(self): line = '' for i in self.entity: line += str(self.entity[i]) + ', ' return line[:-2] + '\n' '\nuser resource entity: us...
{ "targets": [ { "target_name": "node-dotnet-bridge", "sources": [ "addon.cpp", "Proxy.cpp", "AsyncContext.cpp" ], "include_dirs": [ "<!(node -e \"require('nan')\")" ], ...
{'targets': [{'target_name': 'node-dotnet-bridge', 'sources': ['addon.cpp', 'Proxy.cpp', 'AsyncContext.cpp'], 'include_dirs': ['<!(node -e "require(\'nan\')")'], 'cflags': ['-Wall', '-std=c++14'], 'conditions': [['OS=="win"', {'defines': ['WINDOWS']}], ['OS=="linux"', {'defines': ['LINUX']}]]}]}
class FocusTimeManager: def __init__(self, client_class): self._client = client_class self.access_token = '' # --------------------------------------------------------------------------------------------------------------- # Focus Timer Methods def start(self): """Starts t...
class Focustimemanager: def __init__(self, client_class): self._client = client_class self.access_token = '' def start(self): """Starts the focus timer""" pass
BINARY_FNAME_TEMPLATE = "{version}-{platform}-{architecture}" ARCHIVE_FNAME_TEMPLATE = BINARY_FNAME_TEMPLATE + ".{ext}" CLOUD_STORAGE_URL = "http://cloud.raiden.network/"
binary_fname_template = '{version}-{platform}-{architecture}' archive_fname_template = BINARY_FNAME_TEMPLATE + '.{ext}' cloud_storage_url = 'http://cloud.raiden.network/'
# automatically generated by the FlatBuffers compiler, do not modify # namespace: proto class ResultType(object): Success = 0 Failed = 1
class Resulttype(object): success = 0 failed = 1
class Solution: def countStrings(self,n): a = 1 b = 1 for _ in range(n) : c = (a + b) % 1000000007 a, b = b, c return b # Driver code if __name__ == "__main__": tc=int(input()) while tc > 0: n=int(input()) ...
class Solution: def count_strings(self, n): a = 1 b = 1 for _ in range(n): c = (a + b) % 1000000007 (a, b) = (b, c) return b if __name__ == '__main__': tc = int(input()) while tc > 0: n = int(input()) ob = solution() ans = ob.c...
# HOMETASK 1 - UPPER AND LOWER CASES print("# HOMETASK 1 - UPPER AND LOWER CASES") p_phylosophy = "Beautiful is better than ugly \ Explicit is better than implicit \ Simple is better than complex \ Complex is better than complicated \ Readability counts" # Printing in upper cases print (p_phylosophy.upper()) p_phyloso...
print('# HOMETASK 1 - UPPER AND LOWER CASES') p_phylosophy = 'Beautiful is better than ugly Explicit is better than implicit Simple is better than complex Complex is better than complicated Readability counts' print(p_phylosophy.upper()) p_phylosophy_upper = p_phylosophy.upper() print(p_phylosophy_upper.isupper()) prin...
#!/usr/bin/env python # AUTO GENERATED FILE - PLEASE CHECK gen.py! # Instructions = [{'code': 0, 'cycles': 4, 'flagResult': {'carry': None, 'halfcarry': None, 'sub': None, 'zero': None}, 'hexCode': '00', 'instruction': 'NOP', 'name': 'NOP', 'simpleFlags': ['-', '-', '-', '-'], 'size': '1', 'templateDa...
instructions = [{'code': 0, 'cycles': 4, 'flagResult': {'carry': None, 'halfcarry': None, 'sub': None, 'zero': None}, 'hexCode': '00', 'instruction': 'NOP', 'name': 'NOP', 'simpleFlags': ['-', '-', '-', '-'], 'size': '1', 'templateData': {'args': [], 'name': 'NOP'}}, {'code': 1, 'cycles': 12, 'flagResult': {'carry': No...
# 99. Recover Binary Search Tree # Runtime: 64 ms, faster than 95.92% of Python3 online submissions for Recover Binary Search Tree. # Memory Usage: 14.6 MB, less than 57.01% of Python3 online submissions for Recover Binary Search Tree. # Definition for a binary tree node. # class TreeNode: # def __init__(self, ...
class Solution: def recover_tree(self, root: TreeNode) -> None: """ Do not return anything, modify root in-place instead. """ x = y = prev = None def find_swapped(root: TreeNode) -> None: nonlocal x, y, prev if root is None: return ...
TRIPPIFY_DB_USER = 'trippify' TRIPPIFY_DB_PASSWORD = 'trippify1234' TRIPPIFY_DB_DB = 'trippify' TRIPPIFY_DB_HOST = 'localhost' TRIPPIFY_DB_PORT = 5432 MAPS_GEO_CODING_API_KEY = 'AIzaSyBUl98DdV0U05pu7spTcP-RIB_qoCkNcYU' HERE_APP_ID = 'm7AG9dmM8HNO5ZnJWRVO' HERE_APP_CODE = '2mCmRml-o_e3-uZuD_Z62A' HERE_GEO_CODER_URL = ...
trippify_db_user = 'trippify' trippify_db_password = 'trippify1234' trippify_db_db = 'trippify' trippify_db_host = 'localhost' trippify_db_port = 5432 maps_geo_coding_api_key = 'AIzaSyBUl98DdV0U05pu7spTcP-RIB_qoCkNcYU' here_app_id = 'm7AG9dmM8HNO5ZnJWRVO' here_app_code = '2mCmRml-o_e3-uZuD_Z62A' here_geo_coder_url = 'h...
#for x in range(0,5): #print("Hello World",x) #def recursive(string, num): # if num == 5: # return # print(string,num) #recursive(string,num+1) #recursive("Hello World",0) #def listsum(numList): # sum = 0 # for i in numList: # sum = sum + i # return sum #print(listsum([1,2,5,9,7])) ...
def listsum(numList): if len(numList) == 1: return numList[0] else: return numList[0] + listsum(numList[1:]) print(listsum([1, 2, 5, 9, 7]))
class JsonResponser: """ Set json response Args: code (int): response code message (str): success or error message data (list||dict): response data errors(dict||None): errors if exists """ def __init__(self, data = None, code: int = 200, message: str =...
class Jsonresponser: """ Set json response Args: code (int): response code message (str): success or error message data (list||dict): response data errors(dict||None): errors if exists """ def __init__(self, data=None, code: int=200, message: str=None...
# Solution to problem 9 # Open the file moby-dick.txt for reading and mark as "f" with open('moby-dick.txt', 'r') as f: count = 0 # set counter to zero for line in f: # for every line in the file count+=1 # count +1 if count % 2 == 0: # if the remainder is 0 print(line) ...
with open('moby-dick.txt', 'r') as f: count = 0 for line in f: count += 1 if count % 2 == 0: print(line)
""" Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. """ class RequestBuilderBase(object): def __init__(self, request_url, client): """Initialize a request builder which returns a request when req...
""" Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. """ class Requestbuilderbase(object): def __init__(self, request_url, client): """Initialize a request builder which returns a request when requ...
#/usr/bin/env python3 def nth_prime(n): ans = 2 known = [] for _ in range(n): while not all(ans%x != 0 for x in known): ans += 1 known.append(ans) return ans if __name__ == "__main__": n = int(input("Which one? ")) print(nth_prime(n))
def nth_prime(n): ans = 2 known = [] for _ in range(n): while not all((ans % x != 0 for x in known)): ans += 1 known.append(ans) return ans if __name__ == '__main__': n = int(input('Which one? ')) print(nth_prime(n))
def factory(n): def current(): return n def counter(): return n + 1 return current, counter f_current, f_counter = factory(int(input()))
def factory(n): def current(): return n def counter(): return n + 1 return (current, counter) (f_current, f_counter) = factory(int(input()))
numbers = [ -9, +7, +5, -13, +6, +14, -5, -10, -10, -12, +2, +5, +2, -6, -12, +1, +13, +5, +3, -15, -12, +4, -11, +10, -5, -14, -6, +2, -9, -18, +8, -1, +12, +9, +5, -9, +14, +3, -4, -16, +14, +14, +13, -7, -19, +12, -9, +5, +21, -7, +19, -2, +14, +18, +17, +4, +11, -16, -5, -6, -7, -2, -1, -2, -1, +14, -17, +5, +13, +...
numbers = [-9, +7, +5, -13, +6, +14, -5, -10, -10, -12, +2, +5, +2, -6, -12, +1, +13, +5, +3, -15, -12, +4, -11, +10, -5, -14, -6, +2, -9, -18, +8, -1, +12, +9, +5, -9, +14, +3, -4, -16, +14, +14, +13, -7, -19, +12, -9, +5, +21, -7, +19, -2, +14, +18, +17, +4, +11, -16, -5, -6, -7, -2, -1, -2, -1, +14, -17, +5, +13, +8...
METRICS_LABELS = { 'precision': 'Precision', 'recall': 'Recall', 'fmeasure': 'F-measure', 'auc': 'AUC', 'mcc': 'MCC', } MODELS_LABELS = { 'DummyClassifier(strategy=\'most_frequent\')': 'BM', 'DummyClassifier(strategy=\'prior\')': 'BP', 'DummyClassifier(strategy=\'stratified\')': 'BS', ...
metrics_labels = {'precision': 'Precision', 'recall': 'Recall', 'fmeasure': 'F-measure', 'auc': 'AUC', 'mcc': 'MCC'} models_labels = {"DummyClassifier(strategy='most_frequent')": 'BM', "DummyClassifier(strategy='prior')": 'BP', "DummyClassifier(strategy='stratified')": 'BS', "DummyClassifier(strategy='uniform')": 'BU',...
class Goat: legs_number: int = 4 def __init__(self, height: int, weight: int, hungry: bool) -> None: self._height: int = height self._weight: int = weight self._hungry: bool = hungry def stats(self) -> str: return f"Goat has {self._height} height and {self._weight} weight!"...
class Goat: legs_number: int = 4 def __init__(self, height: int, weight: int, hungry: bool) -> None: self._height: int = height self._weight: int = weight self._hungry: bool = hungry def stats(self) -> str: return f'Goat has {self._height} height and {self._weight} weight!'...
colors = [ '\033[38;5;21m', # blue (cold) '\033[38;5;39m', '\033[38;5;50m', '\033[38;5;48m', '\033[38;5;46m', # green '\033[38;5;118m', '\033[38;5;190m', '\033[38;5;226m', # yellow '\033[38;5;220m', '\033[38;5;214m', # orange '\033[38;5;208m', '\033[38;5;202m', '\033[...
colors = ['\x1b[38;5;21m', '\x1b[38;5;39m', '\x1b[38;5;50m', '\x1b[38;5;48m', '\x1b[38;5;46m', '\x1b[38;5;118m', '\x1b[38;5;190m', '\x1b[38;5;226m', '\x1b[38;5;220m', '\x1b[38;5;214m', '\x1b[38;5;208m', '\x1b[38;5;202m', '\x1b[38;5;196m', '\x1b[38;5;203m', '\x1b[38;5;210m', '\x1b[38;5;217m', '\x1b[38;5;224m', '\x1b[38;...
""" tn3270.ebcdic ~~~~~~~~~~~~~ EBCDIC constants """ DUP = 0x1c FM = 0x1e
""" tn3270.ebcdic ~~~~~~~~~~~~~ EBCDIC constants """ dup = 28 fm = 30
name1_1_1_0_0_0_0 = None name1_1_1_0_0_0_1 = None name1_1_1_0_0_0_2 = None name1_1_1_0_0_0_3 = None name1_1_1_0_0_0_4 = None
name1_1_1_0_0_0_0 = None name1_1_1_0_0_0_1 = None name1_1_1_0_0_0_2 = None name1_1_1_0_0_0_3 = None name1_1_1_0_0_0_4 = None
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Copyright (C) 2017-2020 The Project X-Ray Authors. # # Use of this source code is governed by a ISC-style # license that can be found in the LICENSE file or at # https://opensource.org/licenses/ISC # # SPDX-License-Identifier: ISC class NodeModel(): """ Node looku...
class Nodemodel: """ Node lookup model Terminology: Wire - A segment of metal in a tile Node - A connected set of wires This class can provide a list of nodes, the wires in a node and the node that a wire belongs too. The name of node is always the name of one wire in the node. It ...
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. ### CONTROLS (non-tunable) ### # general TYPE_OF_RUN = train # train, test, test_episodes, render LOAD_MODEL_FROM = None SAVE_MODELS_TO = models/new_gru_flat_babyai.pth # worker.py ENV = BabyAI_Env ENV_RANDOM_SEED = randint # Use an intege...
type_of_run = train load_model_from = None save_models_to = models / new_gru_flat_babyai.pth env = BabyAI_Env env_random_seed = randint agent_random_seed = 1 reporting_interval = 10000 total_steps = 2000000 anneal_lr = False agent_net = GRU_Network babyai_env_level = BabyAI - GoToLocal - v0 use_success_rate = True succ...
""" You're organizing a group dating activity for cats, i.e. a meeting where an equal number of male and female cats get together. For each cat you calculate their nature value, an integer that describes the cat's spirit. When a male and a female cat with the same nature value see each other, they become connected and ...
""" You're organizing a group dating activity for cats, i.e. a meeting where an equal number of male and female cats get together. For each cat you calculate their nature value, an integer that describes the cat's spirit. When a male and a female cat with the same nature value see each other, they become connected and ...
#DictExample3.py print("---------------------------------------------------") student = {"name":"sumit","college":"stanford","grade":"1"} print("Student information :\n") print("Student Name : ",student['name']) print("College : ",student['college']) print("grade : ",student['grade']) print("--------------...
print('---------------------------------------------------') student = {'name': 'sumit', 'college': 'stanford', 'grade': '1'} print('Student information :\n') print('Student Name : ', student['name']) print('College : ', student['college']) print('grade : ', student['grade']) print('------------------------------------...
config = { 'username': 'demo', 'password': 'demo1', 'url': 'http://127.0.0.1:18800', 'upload_url': '/YouWillNeverGuess' }
config = {'username': 'demo', 'password': 'demo1', 'url': 'http://127.0.0.1:18800', 'upload_url': '/YouWillNeverGuess'}
class Settings: WLAN_HOST = '$sudo' WLAN_PASSWORD = 'HowNowBrownCow' MQTT_BROKER_HOST = '192.168.0.136' MQTT_BROKER_PORT = '1883' API_URL = 'http://192.168.0.136:5000/api'
class Settings: wlan_host = '$sudo' wlan_password = 'HowNowBrownCow' mqtt_broker_host = '192.168.0.136' mqtt_broker_port = '1883' api_url = 'http://192.168.0.136:5000/api'
def calculate_period(x): if x == 'weeks': return x * 7 elif x == 'month': return x * 30 else: return x def currentlyinfected(x): return x * 10 def currently_infected(x): return x * 50 def infectionbyrequestedattime(x,y): factor = calculate_period(x) // 3 return ...
def calculate_period(x): if x == 'weeks': return x * 7 elif x == 'month': return x * 30 else: return x def currentlyinfected(x): return x * 10 def currently_infected(x): return x * 50 def infectionbyrequestedattime(x, y): factor = calculate_period(x) // 3 return cu...
# pylint: disable=line-too-long, no-member def generator_name(identifier): # pylint: disable=unused-argument return 'Voice Activity Detection' def extract_secondary_identifier(properties): if 'voices_present' in properties: if properties['voices_present']: return 'present' return...
def generator_name(identifier): return 'Voice Activity Detection' def extract_secondary_identifier(properties): if 'voices_present' in properties: if properties['voices_present']: return 'present' return 'not-present' return 'unknown'
power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate...
power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate Leakage': 0.00662954, 'Peak Dynamic': 0.0, 'Runtime Dynamic': 0.0, 'Subthres...
def sol(): for i in range(int(input())): R, S = input().split() print("".join([i * int(R) for i in S])) if __name__ == "__main__": sol()
def sol(): for i in range(int(input())): (r, s) = input().split() print(''.join([i * int(R) for i in S])) if __name__ == '__main__': sol()
# 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 trimBST(self, root: TreeNode, L: int, R: int) -> TreeNode: if not root: return None if r...
class Solution: def trim_bst(self, root: TreeNode, L: int, R: int) -> TreeNode: if not root: return None if root.val < L: return self.trimBST(root.right, L, R) if root.val > R: return self.trimBST(root.left, L, R) root.left = self.trimBST(root.lef...
class CustomException(Exception): _message = '' def __init__(self, message): self._message = message # Call the base class constructor with the parameters it needs super().__init__(message)
class Customexception(Exception): _message = '' def __init__(self, message): self._message = message super().__init__(message)
# Time: O(4^n / n^(3/2)) ~= Catalan numbers # Space: O(n) # iterative solution class Solution(object): def generateParenthesis(self, n): """ :type n: int :rtype: List[str] """ result, curr = [], [] stk = [(1, (n, n))] while stk: step, args = stk....
class Solution(object): def generate_parenthesis(self, n): """ :type n: int :rtype: List[str] """ (result, curr) = ([], []) stk = [(1, (n, n))] while stk: (step, args) = stk.pop() if step == 1: (left, right) = args ...
__is_prod = False def set_production(is_prod): global __is_prod __is_prod = is_prod def is_production(): return __is_prod
__is_prod = False def set_production(is_prod): global __is_prod __is_prod = is_prod def is_production(): return __is_prod
def format(piece): if piece.label: txt_piece = '{0}\n\\label{{{1}}}'.format(str(piece),piece.label) return txt_piece else: return str(piece)
def format(piece): if piece.label: txt_piece = '{0}\n\\label{{{1}}}'.format(str(piece), piece.label) return txt_piece else: return str(piece)
expected_output = { "hsrp_common_process_state": "not running", "hsrp_ha_state": "capable", "hsrp_ipv4_process_state": "not running", "hsrp_ipv6_process_state": "not running", "hsrp_timer_wheel_state": "running", "mac_address_table": { 166: {"group": 10, "interface": "gi2/0/3", "mac_addr...
expected_output = {'hsrp_common_process_state': 'not running', 'hsrp_ha_state': 'capable', 'hsrp_ipv4_process_state': 'not running', 'hsrp_ipv6_process_state': 'not running', 'hsrp_timer_wheel_state': 'running', 'mac_address_table': {166: {'group': 10, 'interface': 'gi2/0/3', 'mac_address': '0000.0cff.b311'}, 169: {'gr...
# Copyright 2022 DeChainers # # 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 law or agreed to in writing, so...
class Invalidpluginexception(Exception): """Exception to be thrown when Plugin is not compliant""" pass class Unknownpluginformatexception(Exception): """Exception to be thrown when Plugin format not recognized or supported""" pass class Pluginnotfoundexception(Exception): """Exception to be throw...
class User: """ This is a class that will contain all the details of the user """ def __init__(self,login,password): """ This will create unique details for each instance of the User class """ self.login = login self.password = password def user_exists(self,p...
class User: """ This is a class that will contain all the details of the user """ def __init__(self, login, password): """ This will create unique details for each instance of the User class """ self.login = login self.password = password def user_exists(sel...
# 001_init.py def migrate(migrator, database, fake=False, **kwargs): """Write your migrations here.""" migrator.sql("""CREATE TABLE users ( id INTEGER PRIMARY KEY, created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, modified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, em...
def migrate(migrator, database, fake=False, **kwargs): """Write your migrations here.""" migrator.sql("CREATE TABLE users (\n\n id INTEGER PRIMARY KEY,\n\n created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n modified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\n email text UN...
######################################## # CS/CNS/EE 155 2017 # Problem Set 5 # # Author: Avishek Dutta # Description: Set 5 ######################################## class Utility: ''' Utility for the problem files. ''' def __init__(): pass @staticmethod def load_poem(): ...
class Utility: """ Utility for the problem files. """ def __init__(): pass @staticmethod def load_poem(): """ Loads the file 'shake_words.txt'. Returns: states: Sequnces of states, i.e. a list of lists. E...
def factorial(num): if num == 0: return 1 return num * factorial(num-1) print(factorial(int(input())))
def factorial(num): if num == 0: return 1 return num * factorial(num - 1) print(factorial(int(input())))
#! /usr/bin/python # create a list of float # creating list of single data types fam = [1.73, 1.68, 1.72, 1.89] print(fam) # creating list of different data types
fam = [1.73, 1.68, 1.72, 1.89] print(fam)
# flake8: noqa # Edit this file to override the default graphite settings, do not edit settings.py # Turn on debugging and restart apache if you ever see an "Internal Server Error" page # DEBUG = True # Set your local timezone (django will try to figure this out automatically) TIME_ZONE = 'Europe/Zurich' # Secret ke...
time_zone = 'Europe/Zurich' secret_key = '%%SECRET_KEY%%' url_prefix = '/graphite/'
description = """ Adds Django Debug Toolbar support to your project. For more information, visit: https://github.com/django-debug-toolbar/django-debug-toolbar/blob/master/README.rst """
description = '\nAdds Django Debug Toolbar support to your project.\n\nFor more information, visit:\nhttps://github.com/django-debug-toolbar/django-debug-toolbar/blob/master/README.rst\n'
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : table = [ 0 for i in range ( n + 1 ) ] table [ 0 ] = 1 for i in range ( 3 , n + 1 ) : tab...
def f_gold(n): table = [0 for i in range(n + 1)] table[0] = 1 for i in range(3, n + 1): table[i] += table[i - 3] for i in range(5, n + 1): table[i] += table[i - 5] for i in range(10, n + 1): table[i] += table[i - 10] return table[n] if __name__ == '__main__': param = ...
# # PySNMP MIB module HUAWEI-BGP-ACCOUNTING-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-BGP-ACCOUNTING-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:31:02 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3....
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_size_constraint, constraints_union, constraints_intersection, value_range_constraint) ...
class Solution: def intersection(self, nums1, nums2): return list(set(nums1) & set(nums2)) if __name__ == '__main__': print(Solution().intersection([4, 9, 5], [9, 4, 9, 8, 4])) # [9, 4]
class Solution: def intersection(self, nums1, nums2): return list(set(nums1) & set(nums2)) if __name__ == '__main__': print(solution().intersection([4, 9, 5], [9, 4, 9, 8, 4]))
class Solution: def hammingDistance(self, x, y): result = x^y return bin(result).count('1')
class Solution: def hamming_distance(self, x, y): result = x ^ y return bin(result).count('1')
# Time: O(n * iter), iter is the number of iterations # Space: O(1) # see reference: # - https://en.wikipedia.org/wiki/Geometric_median # - https://wikimedia.org/api/rest_v1/media/math/render/svg/b3fb215363358f12687100710caff0e86cd9d26b # Weiszfeld's algorithm class Solution(object): def getMinDistSum(self, posit...
class Solution(object): def get_min_dist_sum(self, positions): """ :type positions: List[List[int]] :rtype: float """ eps = 1e-06 def norm(p1, p2): return ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5 def geometry_median(positions, median...
# V1 : DEV # V2 # https://blog.csdn.net/fuxuemingzhu/article/details/80778651 # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def generateTrees(self, n): """ ...
class Solution(object): def generate_trees(self, n): """ :type n: int :rtype: List[TreeNode] """ if n == 0: return [] return self.generateTreesDFS(1, n) def generate_trees_dfs(self, left, right): if left > right: return [None] ...
trunk_capacity = float(input()) is_trunk_full = False number_of_baggage = 0 command = input() while command != 'End': current_luggage = float(command) trunk_capacity -= current_luggage number_of_baggage += 1 if number_of_baggage % 3 == 0: trunk_capacity -= current_luggage * 0.1 if trunk_ca...
trunk_capacity = float(input()) is_trunk_full = False number_of_baggage = 0 command = input() while command != 'End': current_luggage = float(command) trunk_capacity -= current_luggage number_of_baggage += 1 if number_of_baggage % 3 == 0: trunk_capacity -= current_luggage * 0.1 if trunk_capa...
name1 = input("Write your name: ").lower() name2 = input("Write other person's name: ").lower() joinedName = name1 + name2 def loveCounter(countParameter): count1 = 0 for i in countParameter: count1 += joinedName.count(i) return count1 trueCount = loveCounter("true") loveCount = loveCounter("lov...
name1 = input('Write your name: ').lower() name2 = input("Write other person's name: ").lower() joined_name = name1 + name2 def love_counter(countParameter): count1 = 0 for i in countParameter: count1 += joinedName.count(i) return count1 true_count = love_counter('true') love_count = love_counter('...
class PontiacError(Exception): """Base class for error conditions defined for this application""" pass class ConfigurationError(PontiacError): """Exception class to denote an error in application configuration""" pass class DataValidationError(PontiacError): """Exception class to denote an erro...
class Pontiacerror(Exception): """Base class for error conditions defined for this application""" pass class Configurationerror(PontiacError): """Exception class to denote an error in application configuration""" pass class Datavalidationerror(PontiacError): """Exception class to denote an error i...
n = int(input()) w = [(list(map(int, input().split()))) for i in range(n)]#x,y,h w.sort(key=lambda x:(x[2]),reverse=True) hcon1 = 0 hcon2 = 0 for cx in range(101): for cy in range(101): for i in range(n): if w[i][2] > 0: if i == 0: hcon1 = abs(w[i][0] - cx) +...
n = int(input()) w = [list(map(int, input().split())) for i in range(n)] w.sort(key=lambda x: x[2], reverse=True) hcon1 = 0 hcon2 = 0 for cx in range(101): for cy in range(101): for i in range(n): if w[i][2] > 0: if i == 0: hcon1 = abs(w[i][0] - cx) + abs(w[i]...
def add3(x, y=0, z=0): return x + y + z def mul3(x=1, y=1, z=1): return x * y * z def doubler_premier_kwds(votre, signature): # TODO: votre code pass
def add3(x, y=0, z=0): return x + y + z def mul3(x=1, y=1, z=1): return x * y * z def doubler_premier_kwds(votre, signature): pass
""" Problem: https://www.hackerrank.com/challenges/find-a-string/problem Max Score: 10 Difficulty: Easy Author: Ric Date: Nov 13, 2019 """ def count_substring(string, sub_string): occ = 0 lenth_A = len(string) lenth_B = len(sub_string) for i in range(lenth_A - lenth_B + 1): if string[i: i + le...
""" Problem: https://www.hackerrank.com/challenges/find-a-string/problem Max Score: 10 Difficulty: Easy Author: Ric Date: Nov 13, 2019 """ def count_substring(string, sub_string): occ = 0 lenth_a = len(string) lenth_b = len(sub_string) for i in range(lenth_A - lenth_B + 1): if string[i:i + len(...
name_list= ['Sharon','Mic','Josh','Hannah','Hansel'] height_list = [172,166,187,200,166] weight_list = [59.5,65.6,49.8,64.2,47.5] size_list = ['M','L','S','M','S']\ details_list = [['Sharon', 'F', 33], ['Mic', 'M', 24], ['Josh', 'M', 25 ], ['Hannah', 'F', 30], ['Hanzel', 'M', 26]] gender = [] age = [] bmi_list = [] b...
name_list = ['Sharon', 'Mic', 'Josh', 'Hannah', 'Hansel'] height_list = [172, 166, 187, 200, 166] weight_list = [59.5, 65.6, 49.8, 64.2, 47.5] size_list = ['M', 'L', 'S', 'M', 'S'] details_list = [['Sharon', 'F', 33], ['Mic', 'M', 24], ['Josh', 'M', 25], ['Hannah', 'F', 30], ['Hanzel', 'M', 26]] gender = [] age = [] bm...
def fib(n): if (n <= 2): return 1 else: return fib(n-1) + fib(n-2)
def fib(n): if n <= 2: return 1 else: return fib(n - 1) + fib(n - 2)
i, j, k = (int(x) for x in input().split()) day = 0 for num in range(i, j+1): rev_num = int(str(num)[::-1]) if (num - rev_num) % k == 0: day += 1 print(day)
(i, j, k) = (int(x) for x in input().split()) day = 0 for num in range(i, j + 1): rev_num = int(str(num)[::-1]) if (num - rev_num) % k == 0: day += 1 print(day)
"""Advent of Code 2018 Day 8.""" def main(file_input='input.txt'): numbers = [int(num) for num in get_file_contents(file_input)[0].strip().split()] tree, _ = parse_tree(numbers) print(f'Sum of all metadata entries: {sum_metadata(tree)}') print(f'Value of root node: {root_value(tree)}') ...
"""Advent of Code 2018 Day 8.""" def main(file_input='input.txt'): numbers = [int(num) for num in get_file_contents(file_input)[0].strip().split()] (tree, _) = parse_tree(numbers) print(f'Sum of all metadata entries: {sum_metadata(tree)}') print(f'Value of root node: {root_value(tree)}') def parse_tre...
# Paths # Fill this according to own setup BACKGROUND_DIR = 'input/backgrounds/' BACKGROUND_GLOB_STRING = '*.jpg' POISSON_BLENDING_DIR = './pb' SELECTED_LIST_FILE = 'input/selected.txt' DISTRACTOR_LIST_FILE = 'input/neg_list.txt' DISTRACTOR_DIR = 'input/distractor_objects_dir/' DISTRACTOR_GLOB_STRING = '*.jpg' INVERTE...
background_dir = 'input/backgrounds/' background_glob_string = '*.jpg' poisson_blending_dir = './pb' selected_list_file = 'input/selected.txt' distractor_list_file = 'input/neg_list.txt' distractor_dir = 'input/distractor_objects_dir/' distractor_glob_string = '*.jpg' inverted_mask = True number_of_workers = 4 blending...
def poiEmails(): ''' find e-mail list ''' email_list = ["kenneth_lay@enron.net", "kenneth_lay@enron.com", "klay.enron@enron.com", "kenneth.lay@enron.com", "klay@enron.com", "layk@enron.com", "chairman.ken@enron.com", "jeffr...
def poi_emails(): """ find e-mail list """ email_list = ['kenneth_lay@enron.net', 'kenneth_lay@enron.com', 'klay.enron@enron.com', 'kenneth.lay@enron.com', 'klay@enron.com', 'layk@enron.com', 'chairman.ken@enron.com', 'jeffreyskilling@yahoo.com', 'jeff_skilling@enron.com', 'jskilling@enron.com', 'effrey.skillin...
def alternatives(expected_result, indices): return { idx: expected_result for idx in indices } class ExpectedResult: def __init__(self, segment_list, non_empty): self.segment_list = segment_list self.non_empty = {} for index_type in ['a', 'ab', 'abc', 'tuple']: if index_typ...
def alternatives(expected_result, indices): return {idx: expected_result for idx in indices} class Expectedresult: def __init__(self, segment_list, non_empty): self.segment_list = segment_list self.non_empty = {} for index_type in ['a', 'ab', 'abc', 'tuple']: if index_type ...
class GPIO: PUD_UP = 0 BCM = 1000 FALLING = 2000 IN = 3000 # This is the GPIO state: add a value [16, 20, 21, 26] to simulate a # button that is pressed, remove it to indicate release. clear_gpios = set() @classmethod def setup(cls, port, mode, pull_up_down): pass @c...
class Gpio: pud_up = 0 bcm = 1000 falling = 2000 in = 3000 clear_gpios = set() @classmethod def setup(cls, port, mode, pull_up_down): pass @classmethod def setmode(cls, mode): pass @classmethod def add_event_detect(cls, port, edge, callback): pass ...
test = { 'name': 'q1f', 'points': 2, 'suites': [ { 'cases': [ { 'code': '>>> ' 'FGpercent_table.index.values\n' 'array([1, 2, 3, 4, 5])', 'hidden': False, ...
test = {'name': 'q1f', 'points': 2, 'suites': [{'cases': [{'code': '>>> FGpercent_table.index.values\narray([1, 2, 3, 4, 5])', 'hidden': False, 'locked': False}, {'code': '>>> FGpercent_table.shape\n(5, 15)', 'hidden': False, 'locked': False}], 'scored': True, 'setup': '', 'teardown': '', 'type': 'doctest'}]}
types_of_people = 10 # number x = f"There are {types_of_people} types of people." # f-string binary = "binary" # string do_not = "don't" # string y = f"Those who know {binary} and those who {do_not}." # f-string print(x) # print f-string print(y) # print f-string print(f"I said: {x}") # capsule f-string in f...
types_of_people = 10 x = f'There are {types_of_people} types of people.' binary = 'binary' do_not = "don't" y = f'Those who know {binary} and those who {do_not}.' print(x) print(y) print(f'I said: {x}') print(f"I also said: '{y}'") hilarious = False joke_evaluation = "Isn't that joke so funny?! {}" print(joke_evaluatio...
class Solution: def numComponents(self, head: ListNode, G: List[int]) -> int: ans = 0 G = set(G) while head: if head.val in G and (head.next == None or head.next.val not in G): ans += 1 head = head.next return ans
class Solution: def num_components(self, head: ListNode, G: List[int]) -> int: ans = 0 g = set(G) while head: if head.val in G and (head.next == None or head.next.val not in G): ans += 1 head = head.next return ans
_ERROR_BOOTSTRAP_CSS = """/*! * Bootstrap v4.0.0 (https://getbootstrap.com) * Copyright 2011-2018 The Bootstrap Authors * Copyright 2011-2018 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) */:root{--blue:#007bff;--indigo:#6610f2;--purple:#6f42c1;--pink:#e83e8c;--red:#dc3...
_error_bootstrap_css = '/*!\n * Bootstrap v4.0.0 (https://getbootstrap.com)\n * Copyright 2011-2018 The Bootstrap Authors\n * Copyright 2011-2018 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n */:root{--blue:#007bff;--indigo:#6610f2;--purple:#6f42c1;--pink:#e83e8c;--red:#...
""" 172. Factorial Trailing Zeroes Given an integer n, return the number of trailing zeroes in n!. Explanation the number of zeros is the minimum of the number of 2 and the number of 5. Since multiple of 2 is more than multiple of 5, the number of zeros is dominant by the number of 5. """ class Solution(object): ...
""" 172. Factorial Trailing Zeroes Given an integer n, return the number of trailing zeroes in n!. Explanation the number of zeros is the minimum of the number of 2 and the number of 5. Since multiple of 2 is more than multiple of 5, the number of zeros is dominant by the number of 5. """ class Solution(object): ...
class SimpleIter: def __init__(self): pass def __iter__(self): return 'Nope' s = SimpleIter() print('__iter__' in dir(s) ) # => True def is_iterable(obj): try: iter(obj) return True except TypeError: return False obj = 100 if is_iterable(obj): for i in o...
class Simpleiter: def __init__(self): pass def __iter__(self): return 'Nope' s = simple_iter() print('__iter__' in dir(s)) def is_iterable(obj): try: iter(obj) return True except TypeError: return False obj = 100 if is_iterable(obj): for i in obj: p...
def firstDuplicate(a): counts = {} for c in a: if c in counts: return c counts[c] = 1 return -1 # a = [2, 1, 3, 5, 3, 2]
def first_duplicate(a): counts = {} for c in a: if c in counts: return c counts[c] = 1 return -1
description = 'memograph readout' tango_base = 'tango://ictrlfs.ictrl.frm2.tum.de:10000/memograph09/KWS123/' devices = dict( t_in_memograph_kws123 = device('nicos.devices.entangle.Sensor', description = 'inlet temperature memograph', tangodevice = tango_base + 'T_in', ), t_out_memograph_kw...
description = 'memograph readout' tango_base = 'tango://ictrlfs.ictrl.frm2.tum.de:10000/memograph09/KWS123/' devices = dict(t_in_memograph_kws123=device('nicos.devices.entangle.Sensor', description='inlet temperature memograph', tangodevice=tango_base + 'T_in'), t_out_memograph_kws123=device('nicos.devices.entangle.Sen...
def mul_inv(a, b): b0 = b x0, x1 = 0, 1 if b == 1: return 1 while a > 1: q = a / b a, b = b, a%b x0, x1 = x1 - q * x0, x0 if x1 < 0: x1 += b0 return x1 def chinese_remainder(n, a, lena): p = i = prod = 1; sm = 0 for i in range(lena): prod *= n[i] for i in ran...
def mul_inv(a, b): b0 = b (x0, x1) = (0, 1) if b == 1: return 1 while a > 1: q = a / b (a, b) = (b, a % b) (x0, x1) = (x1 - q * x0, x0) if x1 < 0: x1 += b0 return x1 def chinese_remainder(n, a, lena): p = i = prod = 1 sm = 0 for i in range(len...
def treat_results(result_file, out_file, begin_index): out = open(out_file, 'w') ind = begin_index out.write('ID;intention\n') with open(result_file, 'r') as f: for line in f: new_line = line.replace('\n', '') out.write(str(ind) + ';' + new_line) out.write('\n...
def treat_results(result_file, out_file, begin_index): out = open(out_file, 'w') ind = begin_index out.write('ID;intention\n') with open(result_file, 'r') as f: for line in f: new_line = line.replace('\n', '') out.write(str(ind) + ';' + new_line) out.write('\n...
class Base: def __init__(self, func=None): if func is not None: self.execute = func def execute(self): print("Original execution") def constantFunction(self): print("This function won't change across derived classes") class DerivedA(Base): def __init__(self): super().__init__(executeReplacement1) cla...
class Base: def __init__(self, func=None): if func is not None: self.execute = func def execute(self): print('Original execution') def constant_function(self): print("This function won't change across derived classes") class Deriveda(Base): def __init__(self): ...
x = input().split() horainicial, minutoinicial, horafinal, minutofinal = x horainicial = int(x[0]) minutoinicial = int(x[1]) horafinal = int(x[2]) minutofinal = int(x[3]) if horainicial < horafinal: h = horafinal - horainicial if minutoinicial < minutofinal: m = minutofinal - minutoinicial if m...
x = input().split() (horainicial, minutoinicial, horafinal, minutofinal) = x horainicial = int(x[0]) minutoinicial = int(x[1]) horafinal = int(x[2]) minutofinal = int(x[3]) if horainicial < horafinal: h = horafinal - horainicial if minutoinicial < minutofinal: m = minutofinal - minutoinicial if minu...
QB_NAME = input("What is the QB's name?") print(QB_NAME) RUSH_ATTEMPTS = 0 PASS_ATTEMPTS = 0 PASS_YARDS = 0 CURRENT_PASS_YARDS = 0 RUSH_YARDS = 0 CURRENT_RUSH_YARDS = 0 PASS_TD = 0 RUSH_TD = 0 SACKS = 0 SS = 0 INTC = 0 INC = 0 COM = 0 FUM = 0 TD = 0 QBR = 0 SACK_LIST = ["Number", "Of", "Sacks", "="]...
qb_name = input("What is the QB's name?") print(QB_NAME) rush_attempts = 0 pass_attempts = 0 pass_yards = 0 current_pass_yards = 0 rush_yards = 0 current_rush_yards = 0 pass_td = 0 rush_td = 0 sacks = 0 ss = 0 intc = 0 inc = 0 com = 0 fum = 0 td = 0 qbr = 0 sack_list = ['Number', 'Of', 'Sacks', '='] fum_list = ['Number...
''' A list rotation consists of taking the last element and moving it to the front. For instance, if we rotate the list [1,2,3,4,5], we get [5,1,2,3,4]. If we rotate it again, we get [4,5,1,2,3]. Write a Python function rotatelist(l,k) that takes a list l and a positive integer k and returns the list l after k rotation...
""" A list rotation consists of taking the last element and moving it to the front. For instance, if we rotate the list [1,2,3,4,5], we get [5,1,2,3,4]. If we rotate it again, we get [4,5,1,2,3]. Write a Python function rotatelist(l,k) that takes a list l and a positive integer k and returns the list l after k rotation...
# # PySNMP MIB module CISCO-SME-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-SME-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:12:18 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 201...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, single_value_constraint, value_range_constraint, constraints_intersection, value_size_constraint) ...
"""text example of implicit loop iterators Author: Dr. Jan Pearce, Berea College Distributed under the GNU General Public License at gnu.org/licenses/gpl.html. """ def main(): list=[10, 20, 30, 40] for num in list: print(num) main()
"""text example of implicit loop iterators Author: Dr. Jan Pearce, Berea College Distributed under the GNU General Public License at gnu.org/licenses/gpl.html. """ def main(): list = [10, 20, 30, 40] for num in list: print(num) main()
default_az_parameters = { "azure_cluster" : { "subscription": "Bing DLTS", "infra_node_num": 1, "worker_node_num": 2, "mysqlserver_node_num": 0, "nfs_node_num": 1, "azure_location": "westus2", "infra_vm_size" : "Standard_D1_v2", "worker_vm_size": "Sta...
default_az_parameters = {'azure_cluster': {'subscription': 'Bing DLTS', 'infra_node_num': 1, 'worker_node_num': 2, 'mysqlserver_node_num': 0, 'nfs_node_num': 1, 'azure_location': 'westus2', 'infra_vm_size': 'Standard_D1_v2', 'worker_vm_size': 'Standard_NC6', 'mysqlserver_vm_size': 'Standard_D1_v2', 'nfs_vm_size': 'Stan...
train_config = {} # # MODEL PARAMETERS ## # # MNIST train_config['A'] = 28 # image width train_config['B'] = 28 # image height train_config['img_size'] = train_config['B'] * train_config['A'] # the canvas size train_config['draw_with_white'] = True # draw with white ink or black ink train_config['enc_rnn_mod...
train_config = {} train_config['A'] = 28 train_config['B'] = 28 train_config['img_size'] = train_config['B'] * train_config['A'] train_config['draw_with_white'] = True train_config['enc_rnn_mode'] = 'BASIC' train_config['enc_size'] = 256 train_config['n_enc_layers'] = 1 train_config['dec_rnn_mode'] = 'BASIC' train_conf...
def required_fuel(mass): return int(mass / 3) - 2 def fuel_calc(initial_fuel): fuel_on_fuel = required_fuel(initial_fuel) if (fuel_on_fuel) > 0: return fuel_on_fuel + fuel_calc(fuel_on_fuel) else: return 0 def calc(modules): return sum(required_fuel(int(x)) for x in modules) de...
def required_fuel(mass): return int(mass / 3) - 2 def fuel_calc(initial_fuel): fuel_on_fuel = required_fuel(initial_fuel) if fuel_on_fuel > 0: return fuel_on_fuel + fuel_calc(fuel_on_fuel) else: return 0 def calc(modules): return sum((required_fuel(int(x)) for x in modules)) def c...
#!/usr/bin/env python3.8 def infinite_dict_to_tuple(i_dict): """ given infinite dictionary convert to dictionary with key tuples """ list_out = [] for key in dict_a.keys(): s_dict = {"key":None, "value":None} sub_list = [key] new_dict = dict_a[key] if type(new_dict) is not dict: s_dict["...
def infinite_dict_to_tuple(i_dict): """ given infinite dictionary convert to dictionary with key tuples """ list_out = [] for key in dict_a.keys(): s_dict = {'key': None, 'value': None} sub_list = [key] new_dict = dict_a[key] if type(new_dict) is not dict: s_d...
class Node: def __init__(self, value): self.value = value self.next = None def __repr__(self): return str(self.value) class LinkedList: def __init__(self): self.head = None def __str__(self): cur_head = self.head out_string = "" ...
class Node: def __init__(self, value): self.value = value self.next = None def __repr__(self): return str(self.value) class Linkedlist: def __init__(self): self.head = None def __str__(self): cur_head = self.head out_string = '' while cur_head...
class Board: def __init__(self, row = 6, column = 7): self.board = [['.' for x in range(column)]for y in range(row)] self.__row = row self.__column = column def __str__(self): string = "" for item in self.board: for position in item: string += position string += ' ' string += "\n" return s...
class Board: def __init__(self, row=6, column=7): self.board = [['.' for x in range(column)] for y in range(row)] self.__row = row self.__column = column def __str__(self): string = '' for item in self.board: for position in item: string += p...
## ## # File auto-generated against equivalent DynamicSerialize Java class # Jul 27, 2015 4654 skorolev Added filters class AlertVizRequest(object): def __init__(self): self.message = None self.machine = None self.priority = None self.sourceKey = None self.category...
class Alertvizrequest(object): def __init__(self): self.message = None self.machine = None self.priority = None self.sourceKey = None self.category = None self.audioFile = None self.filters = None def get_message(self): return self.message d...
def calculate_rewards(grades: [float]): """given a list of grades represented by positive integers returns rewards number that suits the students grades in the same given orders """ # Runtime: O(n), space: O(n) # initializing the rewards with minimum of 1 for each grade rewards = [1 for _ in gra...
def calculate_rewards(grades: [float]): """given a list of grades represented by positive integers returns rewards number that suits the students grades in the same given orders """ rewards = [1 for _ in grades] for index in range(1, len(grades)): if grades[index] > grades[index - 1]: ...
def get_button_info(number): with open("songs.csv", "r") as fp: for i, line in enumerate(fp, start=1): if i == number: line = line.strip() line = line.split(", ") return line def create_empty_file(): with open("songs.csv", "w") as f...
def get_button_info(number): with open('songs.csv', 'r') as fp: for (i, line) in enumerate(fp, start=1): if i == number: line = line.strip() line = line.split(', ') return line def create_empty_file(): with open('songs.csv', 'w') as fp: ...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ pyprometheus.const ~~~~~~~~~~~~~~~~~~ Prometheus instrumentation library for Python applications :copyright: (c) 2017 by Alexandr Lispython. :license: , see LICENSE for more details. :github: http://github.com/Lispython/pyprometheus """ class Types(object): BAS...
""" pyprometheus.const ~~~~~~~~~~~~~~~~~~ Prometheus instrumentation library for Python applications :copyright: (c) 2017 by Alexandr Lispython. :license: , see LICENSE for more details. :github: http://github.com/Lispython/pyprometheus """ class Types(object): base = 1 gauge = 2 counter = 3 summary ...
# String concatenation # Suppose we want to create a string that says "subscript to ____" # Few ways to do this # youtuber = "FreeCodeCamp" # print("Subscribe to " + youtuber) # print("Subscribe to {}".format(youtuber)) # print(f"Subscribe to {youtuber}") adj = input("Adjective: ") verb1 = input("Verb 1: ") verb2 = i...
adj = input('Adjective: ') verb1 = input('Verb 1: ') verb2 = input('Verb 2: ') famous_person = input('Famous person: ') madlib = f'Computer programming is so {adj}! It makes me so excited all the time because I love to {verb1}. Stay hidrated and {verb2} like you are {famous_person}!' print(madlib)
# -*- coding: utf-8 -*- class AbstractNode(object): def _generic_find(self, node_list_name, **kvargs): found_nodes = self._generic_recursion(node_list_name, kvargs, [], []) return self._check_found_nodes(found_nodes) def _generic_recursion(self, node_list_name, search_clauses, found_nodes, ...
class Abstractnode(object): def _generic_find(self, node_list_name, **kvargs): found_nodes = self._generic_recursion(node_list_name, kvargs, [], []) return self._check_found_nodes(found_nodes) def _generic_recursion(self, node_list_name, search_clauses, found_nodes, visited_nodes): vis...
''' Failed complexity test, the code below returt O(N*N) yet the question wants O(N) ''' # you can write to stdout for debugging purposes, e.g. # print("this is a debug message") def solution(A): # write your code in Python 3.6 lengthy = len(A) if (lengthy == 0 or lengthy == 1): return 0 ...
""" Failed complexity test, the code below returt O(N*N) yet the question wants O(N) """ def solution(A): lengthy = len(A) if lengthy == 0 or lengthy == 1: return 0 diffies = [] for i in range(1, lengthy, 1): (lefty, righty) = (A[:i], A[-(lengthy - i):]) (sumlefty, sumrighty) = ...
# # PySNMP MIB module CISCO-DATA-COLLECTION-CAPABILITY (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-DATA-COLLECTION-CAPABILITY # Produced by pysmi-0.3.4 at Mon Apr 29 17:36:47 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Pyt...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_intersection, value_size_constraint, single_value_constraint, constraints_union) ...
# # PySNMP MIB module APPIAN-PPORT-COMMON-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/APPIAN-PPORT-COMMON-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:07:58 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 ...
(ac_slot_number, ac_port_number, ac_op_status, ac_node_id, ac_admin_status, ac_pport) = mibBuilder.importSymbols('APPIAN-SMI-MIB', 'AcSlotNumber', 'AcPortNumber', 'AcOpStatus', 'AcNodeId', 'AcAdminStatus', 'acPport') (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentif...
"""Constants Module.""" IS = 0.2 VAT = 0.21 SEMESTRAL = 2 MENSUAL = 12 ANUAL = 1 CUATRIMESTRAL = 3 TRIMESTRAL = 4 BIANUAL = 0.5 BIMENSUAL = 6
"""Constants Module.""" is = 0.2 vat = 0.21 semestral = 2 mensual = 12 anual = 1 cuatrimestral = 3 trimestral = 4 bianual = 0.5 bimensual = 6