content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
K = 132 nominaly = [1, 2, 5, 10, 20, 50] def change_making_greedy(K, nominaly): nominaly.sort(reverse = True) coins = [] for i in nominaly: while K >= i: coins.append(i) K -= i return coins print(change_making_greedy(K,nominaly))
k = 132 nominaly = [1, 2, 5, 10, 20, 50] def change_making_greedy(K, nominaly): nominaly.sort(reverse=True) coins = [] for i in nominaly: while K >= i: coins.append(i) k -= i return coins print(change_making_greedy(K, nominaly))
class XYZAtom: """An atom record in an XYZ structure""" def __init__(self, name, x, y, z): self.chain = "" self.resid = None self.resname = "" self.name = name self.x = x self.y = y self.z = z def read(infile): """Read an XYZ structure from a filenam...
class Xyzatom: """An atom record in an XYZ structure""" def __init__(self, name, x, y, z): self.chain = '' self.resid = None self.resname = '' self.name = name self.x = x self.y = y self.z = z def read(infile): """Read an XYZ structure from a filenam...
[ { 'date': '2016-01-01', 'description': "New Year's Day", 'locale': 'en-CA', 'notes': '', 'region': '', 'type': 'NF' }, { 'date': '2016-02-15', 'description': 'Family Day', 'locale': 'en-CA', 'notes': '', 'region': 'AB'...
[{'date': '2016-01-01', 'description': "New Year's Day", 'locale': 'en-CA', 'notes': '', 'region': '', 'type': 'NF'}, {'date': '2016-02-15', 'description': 'Family Day', 'locale': 'en-CA', 'notes': '', 'region': 'AB', 'type': 'V'}, {'date': '2016-02-15', 'description': 'Family Day', 'locale': 'en-CA', 'notes': '', 'reg...
#!/usr/bin/env python #coding: utf-8 # VirusTotal vt_key = '' # MISP misp_url = '' misp_key = '' misp_verifycert = False # Twitter consumer_key = '' consumer_secret = '' access_key = '' access_secret = '' # Slack slack_channel = '' slack_username = '' slack_url = ''
vt_key = '' misp_url = '' misp_key = '' misp_verifycert = False consumer_key = '' consumer_secret = '' access_key = '' access_secret = '' slack_channel = '' slack_username = '' slack_url = ''
class SkilletLoaderException(BaseException): pass class LoginException(BaseException): pass class PanoplyException(BaseException): pass class NodeNotFoundException(BaseException): pass
class Skilletloaderexception(BaseException): pass class Loginexception(BaseException): pass class Panoplyexception(BaseException): pass class Nodenotfoundexception(BaseException): pass
MASTER = "127.0.0.1:7070" ROUTER = "127.0.0.1:8080" #MASTER = "11.3.146.195:443" #ROUTER = "11.3.146.195"
master = '127.0.0.1:7070' router = '127.0.0.1:8080'
def to_rna(dna_strand): rna = [] for nuc in dna_strand: if nuc == 'G': rna.append('C') elif nuc == 'C': rna.append('G') elif nuc == 'T': rna.append('A') elif nuc == 'A': rna.append('U') return "".join(rna)
def to_rna(dna_strand): rna = [] for nuc in dna_strand: if nuc == 'G': rna.append('C') elif nuc == 'C': rna.append('G') elif nuc == 'T': rna.append('A') elif nuc == 'A': rna.append('U') return ''.join(rna)
def in_test(a, b=None): if b in a or b is None: print('yaeeee') else: print('oops') a = [1, 2, 3] in_test(a, 1) in_test(a, 4) in_test(a, None)
def in_test(a, b=None): if b in a or b is None: print('yaeeee') else: print('oops') a = [1, 2, 3] in_test(a, 1) in_test(a, 4) in_test(a, None)
# # @lc app=leetcode.cn id=120 lang=python3 # # [120] triangle # None # @lc code=end
None
class Options: def __init__(self, args: list): assert isinstance(args, list) self.args = args def get(self, key: str, has_value: bool = True): assert isinstance(key, str) assert isinstance(has_value, bool) if has_value: if (key in self.args[:-1]) and (path_index := self.args[:-1].index(key)) and (val...
class Options: def __init__(self, args: list): assert isinstance(args, list) self.args = args def get(self, key: str, has_value: bool=True): assert isinstance(key, str) assert isinstance(has_value, bool) if has_value: if key in self.args[:-1] and (path_index...
class Solution(object): def maximumWealth(self, accounts): """ :type accounts: List[List[int]] :rtype: int """ banks = len(accounts[0]) cust = {} for customer_id in range(len(accounts)): cust[customer_id] = sum(accounts[customer_id]) return...
class Solution(object): def maximum_wealth(self, accounts): """ :type accounts: List[List[int]] :rtype: int """ banks = len(accounts[0]) cust = {} for customer_id in range(len(accounts)): cust[customer_id] = sum(accounts[customer_id]) retu...
# Created by MechAviv # Kinesis Introduction # Map ID :: 331002300 # School for the Gifted :: 1-1 Classroom sm.warpInstanceOut(331002000, 2)
sm.warpInstanceOut(331002000, 2)
# 2020.09.04 # Problem Statement: # https://leetcode.com/problems/add-binary/ class Solution: def addBinary(self, a: str, b: str) -> str: # make a to be the longer string if len(a) < len(b): a, b = b, a # do early return if a == "0": return b if...
class Solution: def add_binary(self, a: str, b: str) -> str: if len(a) < len(b): (a, b) = (b, a) if a == '0': return b if b == '0': return a answer = '' carrier = 0 for i in range(0, len(b)): answer = str((int(a[len(a) ...
def capitalize(string): ans = "" i = 0; while i < len(string): ans += string[i].upper() i += 1 while i < len(string) and ord(string[i]) > 64: ans += string[i] i += 1 while i<len(string) and (ord(string[i]) == 32 or ord(string[i]) == 9): ans += string[i] i += 1 return ans string = input() capital...
def capitalize(string): ans = '' i = 0 while i < len(string): ans += string[i].upper() i += 1 while i < len(string) and ord(string[i]) > 64: ans += string[i] i += 1 while i < len(string) and (ord(string[i]) == 32 or ord(string[i]) == 9): an...
names_scores = (('Amy',82,90),('John',33,64),('Zoe',91,94)) for x,y,z in names_scores: print(x) print(y,z) print('End')
names_scores = (('Amy', 82, 90), ('John', 33, 64), ('Zoe', 91, 94)) for (x, y, z) in names_scores: print(x) print(y, z) print('End')
# # PySNMP MIB module HP-SN-TRAP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HP-SN-MIBS # Produced by pysmi-0.3.4 at Wed May 1 13:36:22 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019,...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, single_value_constraint, value_range_constraint, constraints_intersection, constraints_union) ...
""" Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. """ __author__ = 'Daniel' class Solution: def partition(self, s): """ :type s: str :rtype: List[str] """ ret = [] self.ba...
""" Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. """ __author__ = 'Daniel' class Solution: def partition(self, s): """ :type s: str :rtype: List[str] """ ret = [] self.ba...
# secret key SECRET_KEY = 'djangosSecretKey' # development directory DEV_DIR = '/path/to/directory/' # private data PRIVATE_DATA_STREET = 'Examplestreet 1' PRIVATE_DATA_PHONE = '0123456789'
secret_key = 'djangosSecretKey' dev_dir = '/path/to/directory/' private_data_street = 'Examplestreet 1' private_data_phone = '0123456789'
# # PySNMP MIB module CISCO-SESS-BORDER-CTRLR-CALL-STATS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-SESS-BORDER-CTRLR-CALL-STATS-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:55:11 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_intersection, single_value_constraint, value_size_constraint, constraints_union) ...
""" Create three different variables the first variable should use all lower case characters with underscore ( _ ) as the word separator. The second variable should use all upper case characters with underscore as the word separator. The third variable should use numbers, letters, and underscore, but still be a valid v...
""" Create three different variables the first variable should use all lower case characters with underscore ( _ ) as the word separator. The second variable should use all upper case characters with underscore as the word separator. The third variable should use numbers, letters, and underscore, but still be a valid v...
SECRET_KEY = 'test' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'test.sqlite', } } INSTALLED_APPS = [ 'nobot', ] NOBOT_RECAPTCHA_PRIVATE_KEY = 'privkey' NOBOT_RECAPTCHA_PUBLIC_KEY = 'pubkey'
secret_key = 'test' databases = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'test.sqlite'}} installed_apps = ['nobot'] nobot_recaptcha_private_key = 'privkey' nobot_recaptcha_public_key = 'pubkey'
""" [2014-11-24] Challenge #190 [Easy] Webscraping sentiments https://www.reddit.com/r/dailyprogrammer/comments/2nauiv/20141124_challenge_190_easy_webscraping_sentiments/ #Description Webscraping is the delicate process of gathering information from a website (usually) without the assistance of an API. Without an API...
""" [2014-11-24] Challenge #190 [Easy] Webscraping sentiments https://www.reddit.com/r/dailyprogrammer/comments/2nauiv/20141124_challenge_190_easy_webscraping_sentiments/ #Description Webscraping is the delicate process of gathering information from a website (usually) without the assistance of an API. Without an API...
"""Hive Alarm Module.""" class HiveHomeShield: """Hive homeshield alarm. Returns: object: Hive homeshield """ alarmType = "Alarm" async def getMode(self): """Get current mode of the alarm. Returns: str: Mode if the alarm [armed_home, armed_away, armed_night]...
"""Hive Alarm Module.""" class Hivehomeshield: """Hive homeshield alarm. Returns: object: Hive homeshield """ alarm_type = 'Alarm' async def getMode(self): """Get current mode of the alarm. Returns: str: Mode if the alarm [armed_home, armed_away, armed_night] ...
# Problem0020 - Factorial digit sum # # https: // github.com/agileshaw/Project-Euler def digitSum(num): result = 0 while num: result, num = result + num % 10, num // 10 return result if __name__ == "__main__": factorial = 1 for i in range (1, 101): factorial *= i result = digit...
def digit_sum(num): result = 0 while num: (result, num) = (result + num % 10, num // 10) return result if __name__ == '__main__': factorial = 1 for i in range(1, 101): factorial *= i result = digit_sum(factorial) print('The factorial digit sum is: %d' % result)
# Exercise #057 - Data Validation """Make a program that reads a person's sex, but only accepts 'M' or 'F' values. If it is wrong, ask for the typing again until you have a correct value.""" # Create our control variable control = 0 # Here we start our loop with our control variable equals 0 while control == 0: ...
"""Make a program that reads a person's sex, but only accepts 'M' or 'F' values. If it is wrong, ask for the typing again until you have a correct value.""" control = 0 while control == 0: sexo = input('Enter your sex [M/F]:').strip().upper()[0] if sexo == 'M' or sexo == 'F': control += 1 if sex...
class UserNotInGroupException(Exception): def __init__(self, message): self.message = f"user is not in group: {message}" class InvalidRangeException(Exception): def __init__(self, message): self.message = message class NoSuchGroupException(Exception): def __init__(self, message): ...
class Usernotingroupexception(Exception): def __init__(self, message): self.message = f'user is not in group: {message}' class Invalidrangeexception(Exception): def __init__(self, message): self.message = message class Nosuchgroupexception(Exception): def __init__(self, message): ...
WHATSAPP_CRYPT = ''' Utility for WhatsApp crypt databases decryption. Encrypted databases are usually located here: /sdcard/WhatsApp/Databases/ The `key` file must be obtained from the following location: /data/data/com.whatsapp/files/key (Must have root permissions to read this file) Supported crypt files with the ...
whatsapp_crypt = '\nUtility for WhatsApp crypt databases decryption.\n\nEncrypted databases are usually located here:\n/sdcard/WhatsApp/Databases/\n\nThe `key` file must be obtained from the following location:\n/data/data/com.whatsapp/files/key\n(Must have root permissions to read this file)\n\nSupported crypt files w...
def N(xi, i, enum): if enum == 1: if i == 1: return (2*xi-1)**2 if i == 2: return -2*xi*(3*xi-2) if i == 3: return 2*xi*xi if enum == 2: if i == 1: return (2*xi-2)*(xi-1) if i == 2: return -6*xi**2 +...
def n(xi, i, enum): if enum == 1: if i == 1: return (2 * xi - 1) ** 2 if i == 2: return -2 * xi * (3 * xi - 2) if i == 3: return 2 * xi * xi if enum == 2: if i == 1: return (2 * xi - 2) * (xi - 1) if i == 2: retu...
#!/usr/bin/python # coding=utf-8 # Copyright 2019 yaitza. All Rights Reserved. # # https://yaitza.github.io/ # # My Code hope to usefull for you. # =================================================================== __author__ = "yaitza" __date__ = "2019-03-29 16:29"
__author__ = 'yaitza' __date__ = '2019-03-29 16:29'
class Wiggle: def fixedStepParser(self, line): value = line.strip() start_position = self.stepIdx * self.parserConfig['step'] + self.parserConfig['start'] stop_position = start_position + self.parserConfig['span'] - 1 self.stepIdx += 1 for position in range(start_position, ...
class Wiggle: def fixed_step_parser(self, line): value = line.strip() start_position = self.stepIdx * self.parserConfig['step'] + self.parserConfig['start'] stop_position = start_position + self.parserConfig['span'] - 1 self.stepIdx += 1 for position in range(start_position,...
# Python Module example def add(a, b): """This program adds two numbers and return the result""" result = a + b return result
def add(a, b): """This program adds two numbers and return the result""" result = a + b return result
class Assignment: def __init__(self, member_id, date_time, _role): self.assignee_id = member_id self.target_role = _role self.assignment_date = date_time # def __eq__(self, other): # same_member_id = self.assignee_id == other.assignee_id # same_role = self.role == other...
class Assignment: def __init__(self, member_id, date_time, _role): self.assignee_id = member_id self.target_role = _role self.assignment_date = date_time
def reverse(head): """"Reverse a singly linked list.""" # If there is no head. if not head: # Return nothing. return # Create a nodes list. nodes = [] # Set node equal to the head node. node = head # While node is truthy. while node: # Add the node to the ...
def reverse(head): """"Reverse a singly linked list.""" if not head: return nodes = [] node = head while node: nodes.append(node) node = node.next nodes.reverse() count = 0 while count < len(nodes): if count < len(nodes) - 1: nodes[count].next ...
""" HelperFunctions.py A list of pretty helpful functions. """ # Opens a file safely. def OpenFileSafely(fileName, mode, raiseError): try: # Try to open the file return open(fileName, mode) except: # If the file couldn't have been opened if raiseError: print...
""" HelperFunctions.py A list of pretty helpful functions. """ def open_file_safely(fileName, mode, raiseError): try: return open(fileName, mode) except: if raiseError: print('Had trouble opening %s.' % fileName) return None else: print("%s w...
archivo = open("./004 EscribirLeerArchivoTexto/nombres.txt","r") nombres = [] for linea in archivo: linea = linea.replace("\n","") nombres.append(linea) archivo.close() print(nombres)
archivo = open('./004 EscribirLeerArchivoTexto/nombres.txt', 'r') nombres = [] for linea in archivo: linea = linea.replace('\n', '') nombres.append(linea) archivo.close() print(nombres)
style = {'base_mpl_style': 'ggplot', 'marketcolors' : {'candle': {'up': '#000000', 'down': '#ff0000'}, 'edge' : {'up': '#000000', 'down': '#ff0000'}, 'wick' : {'up': '#606060', 'down': '#606060'}, 'ohlc' : {'up': '#000000',...
style = {'base_mpl_style': 'ggplot', 'marketcolors': {'candle': {'up': '#000000', 'down': '#ff0000'}, 'edge': {'up': '#000000', 'down': '#ff0000'}, 'wick': {'up': '#606060', 'down': '#606060'}, 'ohlc': {'up': '#000000', 'down': '#ff0000'}, 'volume': {'up': '#6f6f6f', 'down': '#ff4040'}, 'vcedge': {'up': '#1f77b4', 'dow...
class Graph: def __init__(self, vertices): self.V = vertices self.graph = [[0 for i in range(self.V)] for j in range(self.V)] self.edges = [] def add_edge(self, src: int, dest: int, weight: int): self.graph[src][dest] = weight self.graph[dest][src] = weight self.edges.append([src,dest,...
class Graph: def __init__(self, vertices): self.V = vertices self.graph = [[0 for i in range(self.V)] for j in range(self.V)] self.edges = [] def add_edge(self, src: int, dest: int, weight: int): self.graph[src][dest] = weight self.graph[dest][src] = weight self...
# Problem Set 4A # Name: Gyalpo # Collaborators: # Time Spent: 5:30 # Late Days Used: 0 # Part A0: Data representation # Fill out the following variables correctly. # If correct, the tests named data_representation should pass. treeA = [[14,19],[[3,5],0]] treeB = [[9,3],6] # TODO: change this assignment treeC = [[7],...
tree_a = [[14, 19], [[3, 5], 0]] tree_b = [[9, 3], 6] tree_c = [[7], [16, 4, 2], [8]] def add_tree(tree): """ Recursively computes the sum of all tree leaves. Returns an integer representing the product. Inputs tree: A list (potentially containing sublists) that represents a tree structu...
# -*- coding: ISO-8859-1 -*- """Resource phongprecalc_vert (from file phongprecalc.vert)""" # written by resourcepackage: (1, 0, 1) source = 'phongprecalc.vert' package = 'OpenGLContext.resources' data = "// Vertex-shader pre-calculation for blinn-phong lighting\012vo\ id phong_preCalc( \012 in vec3 vertex_position,...
"""Resource phongprecalc_vert (from file phongprecalc.vert)""" source = 'phongprecalc.vert' package = 'OpenGLContext.resources' data = '// Vertex-shader pre-calculation for blinn-phong lighting\nvoid phong_preCalc( \n in vec3 vertex_position,\n in vec4 light_position,\n out float light_distance,\n out vec3 ...
''' Given a list of coins, find the minimum number of coins to get to a certain value For Example: coins={1,2,3} V=5 Output: 2 (3+2=5) Note: the list must always contain a coin of value 1, so in the worst case the output will be V*'coin 1' ''' def minCoin(coins, amount): return minCoin_(coins, amoun...
""" Given a list of coins, find the minimum number of coins to get to a certain value For Example: coins={1,2,3} V=5 Output: 2 (3+2=5) Note: the list must always contain a coin of value 1, so in the worst case the output will be V*'coin 1' """ def min_coin(coins, amount): return min_coin_(coins, am...
#APRENDIENDO INSTRUCCIONES EN PYTHON print("funciones basicas de python") print("-"*28) print("input:Ingresar Datos") print("print:Imprimir Datos") print("MIN: Menor Valor") print("ROUND:Redondear")
print('funciones basicas de python') print('-' * 28) print('input:Ingresar Datos') print('print:Imprimir Datos') print('MIN: Menor Valor') print('ROUND:Redondear')
{ 'targets': [{ 'target_name': 'bindings', 'sources': [ 'src/serialport.cpp' ], 'include_dirs': [ '<!(node -e "require(\'nan\')")' ], 'variables': { # Lerna seems to strips environment variables. Workaround: create `packages/bindings/GENERATE_COVERAGE_FILE` 'generate_co...
{'targets': [{'target_name': 'bindings', 'sources': ['src/serialport.cpp'], 'include_dirs': ['<!(node -e "require(\'nan\')")'], 'variables': {'generate_coverage': '<!(test -e GENERATE_COVERAGE_FILE && echo "yes" || echo $GENERATE_COVERAGE)'}, 'conditions': [['OS=="win"', {'defines': ['CHECK_NODE_MODULE_VERSION'], 'sour...
""" This file will contain all utility functions for pulling insults(and maybe default values?) from configuration files located somewhere. This increases the modularity and usability of ChaseBot, and allows for users to easily add content to DIS. These configuration files will contain lists of chain words and flat ...
""" This file will contain all utility functions for pulling insults(and maybe default values?) from configuration files located somewhere. This increases the modularity and usability of ChaseBot, and allows for users to easily add content to DIS. These configuration files will contain lists of chain words and flat w...
# coding: utf-8 # Try POH # author: Leonarodne @ NEETSDKASU ############################################## def gs(*_): return input().strip() def gi(*_): return int(gs()) def gss(*_): return gs().split() def gis(*_): return list(map(int, gss())) def nmapf(n,f): return list(map(f, range(n))) def ngs(n): return nmapf...
def gs(*_): return input().strip() def gi(*_): return int(gs()) def gss(*_): return gs().split() def gis(*_): return list(map(int, gss())) def nmapf(n, f): return list(map(f, range(n))) def ngs(n): return nmapf(n, gs) def ngi(n): return nmapf(n, gi) def ngss(n): return nmapf(n, gs...
EARLY_GAME = 36 MIDDLE_GAME = 75 class heuristic: def __init__(self, board): self._size = board.get_board_size() self._weight = [ [200, -100, 100, 50, 50, 50, 50, 100, -100, 200], [-100, -200, -50, -50, -50, -50, - 50, -50, -200, -100], [100, -50, 100, 0, 20, 2...
early_game = 36 middle_game = 75 class Heuristic: def __init__(self, board): self._size = board.get_board_size() self._weight = [[200, -100, 100, 50, 50, 50, 50, 100, -100, 200], [-100, -200, -50, -50, -50, -50, -50, -50, -200, -100], [100, -50, 100, 0, 20, 20, 0, 100, -50, 100], [50, -50, 0, 0, 0...
class Checker: def __init__(self, hin): super().__init__() self.hin = hin self.chain = [] def conv(self, kernel, stride=1, pad=0, dilation=1): self.chain.append([0, kernel, stride, pad, dilation, 0]) def convT(self, kernel, stride=1, pad=0, dilation=1, outpad=0): ...
class Checker: def __init__(self, hin): super().__init__() self.hin = hin self.chain = [] def conv(self, kernel, stride=1, pad=0, dilation=1): self.chain.append([0, kernel, stride, pad, dilation, 0]) def conv_t(self, kernel, stride=1, pad=0, dilation=1, outpad=0): ...
__all__ = [ 'responseclassify', 'responsemorph', 'text_input', 'text_input_classify', 'text_input_tamil', 'url_input', 'url_input_classify', 'api_imagecaption_request', 'api_imagecaption_response', 'api_ner_request', 'api_ner_request_1', 'api_ner_response', ...
__all__ = ['responseclassify', 'responsemorph', 'text_input', 'text_input_classify', 'text_input_tamil', 'url_input', 'url_input_classify', 'api_imagecaption_request', 'api_imagecaption_response', 'api_ner_request', 'api_ner_request_1', 'api_ner_response', 'api_qa_request', 'api_qa_request_1', 'api_qa_response', 'api_q...
class DocumentViewerAutomationPeer(DocumentViewerBaseAutomationPeer): """ Exposes System.Windows.Controls.DocumentViewer types to UI Automation. DocumentViewerAutomationPeer(owner: DocumentViewer) """ def GetPattern(self,patternInterface): """ GetPattern(self: DocumentViewerAutomationPeer,patternIn...
class Documentviewerautomationpeer(DocumentViewerBaseAutomationPeer): """ Exposes System.Windows.Controls.DocumentViewer types to UI Automation. DocumentViewerAutomationPeer(owner: DocumentViewer) """ def get_pattern(self, patternInterface): """ GetPattern(self: DocumentViewerAutomationPeer,pa...
# -*- encoding:utf-8 -*- """ company:IT author:pengjinfu project:migu time:2020.5.14 """ user = 'wind8288@163.com' pw = 'wind121'
""" company:IT author:pengjinfu project:migu time:2020.5.14 """ user = 'wind8288@163.com' pw = 'wind121'
# 48. Rotate Image # https://leetcode.com/problems/rotate-image/ class Solution: def rotate(self, matrix: List[List[int]]) -> None: """ Do not return anything, modify matrix in-place instead. """ for i in range(len(matrix) // 2): self._rotate_layer(matrix, i) d...
class Solution: def rotate(self, matrix: List[List[int]]) -> None: """ Do not return anything, modify matrix in-place instead. """ for i in range(len(matrix) // 2): self._rotate_layer(matrix, i) def _rotate_layer(self, m, layer): n = len(m) for i in ...
class simpAngMo: def __init__(self, m, r, v): self.m = m self.r = r self.v = v def getAngVel(self): return str(self.v/self.r) + ' rad s^(-1)' def getCentAcc(self): return str(self.v**2/self.r) + ' m s^(-2)' def getCentAngAcc(self): return str(self.magnitud...
class Simpangmo: def __init__(self, m, r, v): self.m = m self.r = r self.v = v def get_ang_vel(self): return str(self.v / self.r) + ' rad s^(-1)' def get_cent_acc(self): return str(self.v ** 2 / self.r) + ' m s^(-2)' def get_cent_ang_acc(self): return ...
print( "Chocolate Chip Cookies" ) print( "1 cup butter, softened" ) print( "1 cup white sugar" ) print( "1 cup packed brown sugar" ) print( "2 eggs" ) print( "2 teaspoons vanilla extract" ) print( "3 cups all-purpose flour" ) print( "1 teaspoon baking soda" ) print( "2 teaspoons hot water" ) print( "0.5 teaspoons salt"...
print('Chocolate Chip Cookies') print('1 cup butter, softened') print('1 cup white sugar') print('1 cup packed brown sugar') print('2 eggs') print('2 teaspoons vanilla extract') print('3 cups all-purpose flour') print('1 teaspoon baking soda') print('2 teaspoons hot water') print('0.5 teaspoons salt') print('2 cups sem...
def part1(moves): h_pos = 0 depth = 0 for direction, unit in moves: if direction == 'forward': h_pos += int(unit) elif direction == 'up': depth -= int(unit) elif direction == 'down': depth += int(unit) return h_pos * depth def part2(moves):...
def part1(moves): h_pos = 0 depth = 0 for (direction, unit) in moves: if direction == 'forward': h_pos += int(unit) elif direction == 'up': depth -= int(unit) elif direction == 'down': depth += int(unit) return h_pos * depth def part2(moves): ...
""" ---- begin number constant ---- """ STATUS_OK = 200 CONNECTION_ABORTED = 10054 REFRESH_TIME_IN_SECONDS = 5 """ ---- end number constant ---- """ """ ---- begin text constant ---- """ # When reading the csv: # - Place 'r' before the path string to read any special characters, such as '\' # - Don't forget to put the...
""" ---- begin number constant ---- """ status_ok = 200 connection_aborted = 10054 refresh_time_in_seconds = 5 ' ---- end number constant ---- ' ' ---- begin text constant ---- ' chrome_executable_path = 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe' chrome_driver_path = './libs/chromedriver.exe' fi...
''' You can find this exercise at the following website: https://www.practicepython.org/ 15. Reverse Word Order: Write a program (using functions!) that asks the user for a long string containing multiple words. Print back to the user the same string, except with the words in backwards order. For example, say I type ...
""" You can find this exercise at the following website: https://www.practicepython.org/ 15. Reverse Word Order: Write a program (using functions!) that asks the user for a long string containing multiple words. Print back to the user the same string, except with the words in backwards order. For example, say I type ...
# PySNMP SMI module. Autogenerated from smidump -f python RUCKUS-SCG-SYSTEM-MIB # by libsmi2pysnmp-0.1.3 # Python version sys.version_info(major=2, minor=7, micro=11, releaselevel='final', serial=0) # pylint:disable=C0302 mibBuilder = mibBuilder # pylint:disable=undefined-variable,used-before-assignment # Imports (...
mib_builder = mibBuilder (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, constraints_union, single_value_constraint, value_range_constraint...
def accumulate_left(func, acc, collection): if len(collection) == 0: return acc return accumulate_left(func, func(acc, collection[0]), collection[1:]) def accumulate_right(func, acc, collection): if len(collection) == 0: return acc return func(collection[0], accumulate_right(func, acc,...
def accumulate_left(func, acc, collection): if len(collection) == 0: return acc return accumulate_left(func, func(acc, collection[0]), collection[1:]) def accumulate_right(func, acc, collection): if len(collection) == 0: return acc return func(collection[0], accumulate_right(func, acc, ...
SCHEME = 'wss' HOSTS = ['localhost'] PORT = 8183 MESSAGE_SERIALIZER = 'goblin.driver.GraphSONMessageSerializer'
scheme = 'wss' hosts = ['localhost'] port = 8183 message_serializer = 'goblin.driver.GraphSONMessageSerializer'
TILEMAP = { "#": "pavement_1", "%": "pavement_2", " ": "road", "=": "road", "C": "road_corner", "T": "road_tint1", "&": "pavement_1", # precinct "$": "precinct_path", "E": "precinct_path_alt", "O": "ballot_box" } NO_ROUTING_TILES = [ "#", "%", "&" ] SELECTIVE_ROUTING_TILES ...
tilemap = {'#': 'pavement_1', '%': 'pavement_2', ' ': 'road', '=': 'road', 'C': 'road_corner', 'T': 'road_tint1', '&': 'pavement_1', '$': 'precinct_path', 'E': 'precinct_path_alt', 'O': 'ballot_box'} no_routing_tiles = ['#', '%', '&'] selective_routing_tiles = ['$']
'''A very simple program, showing how short a Python program can be! Authors: ___, ___ ''' print('Hello world!') #This is a stupid comment after the # mark
"""A very simple program, showing how short a Python program can be! Authors: ___, ___ """ print('Hello world!')
"Jest testing macro that can compile typescript files for testing as well" load("@npm//@bazel/typescript:index.bzl", "ts_library") load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary", "nodejs_test") def jest_test( srcs, ts_config, snapshots = [], jest_config = None, #...
"""Jest testing macro that can compile typescript files for testing as well""" load('@npm//@bazel/typescript:index.bzl', 'ts_library') load('@build_bazel_rules_nodejs//:index.bzl', 'nodejs_binary', 'nodejs_test') def jest_test(srcs, ts_config, snapshots=[], jest_config=None, devmode_module='commonjs', setup_file=None,...
# # PySNMP MIB module HPN-ICF-PBR-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-PBR-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:28:32 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_size_constraint, single_value_constraint, value_range_constraint, constraints_union) ...
{ "targets": [ { "target_name" : "dsfmt_js_nv", "sources" : [ "src/main.cc", "dSFMT-src-2.2.3/dSFMT.c" ], "include_dirs": [ 'dSFMT-src-2.2.3' ], 'cflags' : [ '-fexceptions' ], 'cflags_cc' : [ '-fexceptions' ], 'defines' : [ 'DSFMT_MEXP=19937' ] } ] }
{'targets': [{'target_name': 'dsfmt_js_nv', 'sources': ['src/main.cc', 'dSFMT-src-2.2.3/dSFMT.c'], 'include_dirs': ['dSFMT-src-2.2.3'], 'cflags': ['-fexceptions'], 'cflags_cc': ['-fexceptions'], 'defines': ['DSFMT_MEXP=19937']}]}
nomecompleto = str(input('digite seu nome completo: ')) print(nomecompleto.upper()) print(nomecompleto.lower()) print(nomecompleto.capitalize()) print(nomecompleto.title()) print(nomecompleto.split()) print(nomecompleto.swapcase()) print(nomecompleto.find("i")) print(nomecompleto.count('a', 0, 16)) print(len(nomecomple...
nomecompleto = str(input('digite seu nome completo: ')) print(nomecompleto.upper()) print(nomecompleto.lower()) print(nomecompleto.capitalize()) print(nomecompleto.title()) print(nomecompleto.split()) print(nomecompleto.swapcase()) print(nomecompleto.find('i')) print(nomecompleto.count('a', 0, 16)) print(len(nomecomple...
class Solution: # @param {integer[]} height # @return {integer} def largestRectangleArea(self, height): areas = {} sorted_height = sorted(list(set(height))) lh = len(height) for i in range(lh): h = height[lh - 1 - i] areas[lh - 1 - i] = {} ...
class Solution: def largest_rectangle_area(self, height): areas = {} sorted_height = sorted(list(set(height))) lh = len(height) for i in range(lh): h = height[lh - 1 - i] areas[lh - 1 - i] = {} j = 0 while sorted_height[j] <= h: ...
def bubbleSort(alist): for passnum in range(len(alist)-1,0,-1): for i in range(passnum): if alist[i]>alist[i+1]: temp = alist[i] alist[i] = alist[i+1] alist[i+1] = temp alist = [36,38,30,31,38,43,55,38,37,30,48,41,33,25,34,43,37,40,36] bubbleSort(...
def bubble_sort(alist): for passnum in range(len(alist) - 1, 0, -1): for i in range(passnum): if alist[i] > alist[i + 1]: temp = alist[i] alist[i] = alist[i + 1] alist[i + 1] = temp alist = [36, 38, 30, 31, 38, 43, 55, 38, 37, 30, 48, 41, 33, 25, 3...
class HanaError(Exception): pass class HanaPluginError(HanaError): pass class InvalidPluginsDirectory(HanaError): pass class PluginNotFoundError(HanaPluginError): pass
class Hanaerror(Exception): pass class Hanapluginerror(HanaError): pass class Invalidpluginsdirectory(HanaError): pass class Pluginnotfounderror(HanaPluginError): pass
def compress(orginial_list): compressed_list = [] mark_X = True if orginial_list == []: return 0 if len(orginial_list) == 1: return 1 if len(orginial_list) > 1: count = 1 for i in range(len(orginial_list) - 1): begin_pointer = i if orginial_l...
def compress(orginial_list): compressed_list = [] mark_x = True if orginial_list == []: return 0 if len(orginial_list) == 1: return 1 if len(orginial_list) > 1: count = 1 for i in range(len(orginial_list) - 1): begin_pointer = i if orginial_lis...
class No: def __init__(self, chave): self.chave = chave self.esquerdo = None self.direito = None self.pai = None
class No: def __init__(self, chave): self.chave = chave self.esquerdo = None self.direito = None self.pai = None
''' Largest Palindrome of two N-digit numbers given N = 1, 2, 3, 4 ''' def largePali4digit(): answer = 0 for i in range(9999, 1000, -1): for j in range(i, 1000, -1): k = i * j s = str(k) if s == s[::-1] and k > answer: return i, j def largePali3dig...
""" Largest Palindrome of two N-digit numbers given N = 1, 2, 3, 4 """ def large_pali4digit(): answer = 0 for i in range(9999, 1000, -1): for j in range(i, 1000, -1): k = i * j s = str(k) if s == s[::-1] and k > answer: return (i, j) def large_pali3d...
""" Some helpful utility functions. """ __author__ = "Levi Borodenko" __copyright__ = "Levi Borodenko" __license__ = "mit" def is_positive_integer(obj, name: str) -> None: """Checks if obj is a positive integer and raises appropriate errors if it isn't. Arguments: obj: object to be checked. ...
""" Some helpful utility functions. """ __author__ = 'Levi Borodenko' __copyright__ = 'Levi Borodenko' __license__ = 'mit' def is_positive_integer(obj, name: str) -> None: """Checks if obj is a positive integer and raises appropriate errors if it isn't. Arguments: obj: object to be checked. ...
# the for loop works based on a Iterable object # Iterable object is capable of returning values one at a time # regular for loop for i in range(5): print(i) for i in [1, 3, 5, 7]: print(i) for c in 'Hello': print(c) for i in [(1,2), (3,4), (5,6)]: print(i) # unpack the turple for i, j in [(1,2), (...
for i in range(5): print(i) for i in [1, 3, 5, 7]: print(i) for c in 'Hello': print(c) for i in [(1, 2), (3, 4), (5, 6)]: print(i) for (i, j) in [(1, 2), (3, 4), (5, 6)]: print(i, j) d = {'a': 1, 'b': 2, 'c': 3, 'd': 4} for k in d.keys(): print(f'{k} -> {d.get(k)}') for (k, v) in d.items(): ...
#Write a short Pyton function that takes a positive integer n and returns #the sum of the squares of all the positive integers smaller than n. def sigmaSquareN(n): list =[] sum = 0 for i in range(1,n): sum += i**2 if sum < n: print ('Sigma of squrae %d=%d'%(i,sum)) lis...
def sigma_square_n(n): list = [] sum = 0 for i in range(1, n): sum += i ** 2 if sum < n: print('Sigma of squrae %d=%d' % (i, sum)) list.append(sum) else: break return list n = int(input('Please input a positive integer')) if n >= 0: print(...
class Solution: def minCostClimbingStairs(self, cost): """ :type cost: List[int] :rtype: int """ cost.append(0) n = len(cost) minArray = [0]*n minArray[0] = minArray[1] = 0 for i in range(2, n): minArray[i] = min(minArray[i-1] + cos...
class Solution: def min_cost_climbing_stairs(self, cost): """ :type cost: List[int] :rtype: int """ cost.append(0) n = len(cost) min_array = [0] * n minArray[0] = minArray[1] = 0 for i in range(2, n): minArray[i] = min(minArray[i -...
print('DOBRO TRIPLO RAIZ') n = int(input('Digite um numero: ')) print(f'DOBRO: {n * 2}') print(f'TRIPLO: {n * 3}') print(f'RAIZ: {n ** (1/2):.2f}')
print('DOBRO TRIPLO RAIZ') n = int(input('Digite um numero: ')) print(f'DOBRO: {n * 2}') print(f'TRIPLO: {n * 3}') print(f'RAIZ: {n ** (1 / 2):.2f}')
""" Write a Python program that randomizes 7 numbers and prints their sum total. If the sum is divisable by 7, also print the word "Boom" """
""" Write a Python program that randomizes 7 numbers and prints their sum total. If the sum is divisable by 7, also print the word "Boom" """
class NisDomain(basestring): """ NIS Domain """ @staticmethod def get_api_name(): return "nis-domain"
class Nisdomain(basestring): """ NIS Domain """ @staticmethod def get_api_name(): return 'nis-domain'
# Python3 program to find a triplet # that sum to a given value # returns true if there is triplet with # sum equal to 'sum' present in A[]. # Also, prints the triplet def find3Numbers(A, arr_size, sum): # Fix the first element as A[i] for i in range( 0, arr_size-2): # Fix the second element as A[j] for j in r...
def find3_numbers(A, arr_size, sum): for i in range(0, arr_size - 2): for j in range(i + 1, arr_size - 1): for k in range(j + 1, arr_size): if A[i] + A[j] + A[k] == sum: print('Triplet is', A[i], ', ', A[j], ', ', A[k]) return True retu...
"""Local settings for the db.""" DATABASE = { 'drivername': 'postgres', 'host': 'localhost', 'port': '5432', 'username': 'postgres', 'password': 'wassup89', 'database': 'gardendb', }
"""Local settings for the db.""" database = {'drivername': 'postgres', 'host': 'localhost', 'port': '5432', 'username': 'postgres', 'password': 'wassup89', 'database': 'gardendb'}
t = int(input()) for __ in range(t): n, m = map(int, input().split()) inl = input().split() iml = input().split() amps = [] freqs = [] ampsm = [] freqsm = [] c = 0 for i in range(2*n): if i % 2 == 0: temp = int(inl[i]) amps.append(temp) else: freqs.append(inl[i]) for i in range(2*m): if i % 2 ...
t = int(input()) for __ in range(t): (n, m) = map(int, input().split()) inl = input().split() iml = input().split() amps = [] freqs = [] ampsm = [] freqsm = [] c = 0 for i in range(2 * n): if i % 2 == 0: temp = int(inl[i]) amps.append(temp) els...
## ## This is my template descripton... def main(): """This is the 'main()' for this module. I will put my description of what this does here...""" print('Welcome to my Python template!') ## ## Call the 'main()' function... if __name__ == '__main__': main() ## ## End of file...
def main(): """This is the 'main()' for this module. I will put my description of what this does here...""" print('Welcome to my Python template!') if __name__ == '__main__': main()
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def maxPathSum(self, root: TreeNode) -> int: self.res = float('-inf') def get_val(node): if not node: return 0 left = max(0,...
class Treenode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def max_path_sum(self, root: TreeNode) -> int: self.res = float('-inf') def get_val(node): if not node: return 0 left = max(0...
# %% [1480. Running Sum of 1d Array](https://leetcode.com/problems/running-sum-of-1d-array/) class Solution: def runningSum(self, nums: List[int]) -> List[int]: return itertools.accumulate(nums)
class Solution: def running_sum(self, nums: List[int]) -> List[int]: return itertools.accumulate(nums)
# Paint costs ############################## #### Problem Description ##### ############################## # You are getting ready to paint a piece of art. The canvas and brushes that you want to use will cost 40.00. Each color of paint that you buy is an additional 5.00. Determine how much money you will need based ...
paint_varieties = int(input()) canvas_brush_cost = 40 paint_cost = paintVarieties * 5 tax = 0.1 total = (canvasBrushCost + paintCost) * (1 + tax) print(round(total))
def add_new_objects(): for object_type, desc, position in new_objects: desc['position']=position objs_in_position = get_objects_by_coords(position) all_interactable = True for obj_in_position in objs_in_position: if not game_objects[obj_in_position]['interactable']: ...
def add_new_objects(): for (object_type, desc, position) in new_objects: desc['position'] = position objs_in_position = get_objects_by_coords(position) all_interactable = True for obj_in_position in objs_in_position: if not game_objects[obj_in_position]['interactable']: ...
#All Configurations FILE_DUPLICATE_NUM = 2 # how many replications stored FILE_CHUNK_SIZE = 1024*1024 # 1KB, the chunk size, will be larger when finishing debugging HEADER_LENGTH = 16 # header size SAVE_FAKE_LOG = False # for single point failure, will greatly reduce the performance IGNORE_LOCK = True # for test...
file_duplicate_num = 2 file_chunk_size = 1024 * 1024 header_length = 16 save_fake_log = False ignore_lock = True server_log_file_name = 'server_write_log' def name_local_to_remote(name): return name.replace('/', '[[') def name_remote_to_local(name): return name.replace('[[', '/')
# Day of Week That Is k Days Later # Days of the week are represented as three-letter strings. # "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" # Write a javaScript function solution that, given a string # S representing the day of the week and an integer K # (between 0 and 500), returns the day of the week that # is...
def k_days_later(s, k): days_of_week = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] remainder = k % 7 s_index = days_of_week.index(s) move_forward = remainder + s_index if move_forward < 7: return days_of_week[move_forward] else: correct_day_index = move_forward - 7 ...
class Accounts: def __init__(self, first_name, last_name, user_name, password): self.first_name = first_name self.last_name = last_name self.user_name = user_name self.password = password user_accounts = [] def save_account(self): ''' this is a save function...
class Accounts: def __init__(self, first_name, last_name, user_name, password): self.first_name = first_name self.last_name = last_name self.user_name = user_name self.password = password user_accounts = [] def save_account(self): """ this is a save function...
def pyramid_pattern(n): a = 2 * n-2 for i in range(0, n): for j in range(0, a): print(end=" ") a = a-1 for j in range(0, i+1): print("*", end=" ") print("\r") print(pyramid_pattern(10))
def pyramid_pattern(n): a = 2 * n - 2 for i in range(0, n): for j in range(0, a): print(end=' ') a = a - 1 for j in range(0, i + 1): print('*', end=' ') print('\r') print(pyramid_pattern(10))
#!/usr/bin/python3 if __name__ == "__main__": # open text file to read file = open('write_file.txt', 'a') # read a line from the file file.write('This is a line appended to the file\n') file.close() file = open('write_file.txt', 'r') data = file.read() print(data) file.close()
if __name__ == '__main__': file = open('write_file.txt', 'a') file.write('This is a line appended to the file\n') file.close() file = open('write_file.txt', 'r') data = file.read() print(data) file.close()
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") load("@rules_jvm_external//:defs.bzl", "maven_install") load("@rules_jvm_external//:specs.bzl", "maven") def _clojure_toolchain(ctx): return [platform_common.ToolchainInfo( runtime = ctx.attr.classpath, ...
load('@rules_proto//proto:repositories.bzl', 'rules_proto_dependencies', 'rules_proto_toolchains') load('@rules_jvm_external//:defs.bzl', 'maven_install') load('@rules_jvm_external//:specs.bzl', 'maven') def _clojure_toolchain(ctx): return [platform_common.ToolchainInfo(runtime=ctx.attr.classpath, scripts={s.basen...
""" Exceptions """ # Commands class UsageError(Exception): """To indicate a command-line usage error""" def __init__(self, *a, **kw): self.print_help = kw.pop('print_help', True) super(UsageError, self).__init__(*a, **kw) # Settings class ConfigurationError(Exception): def __init__(self...
""" Exceptions """ class Usageerror(Exception): """To indicate a command-line usage error""" def __init__(self, *a, **kw): self.print_help = kw.pop('print_help', True) super(UsageError, self).__init__(*a, **kw) class Configurationerror(Exception): def __init__(self, msg): self.ms...
for c in range(0, 6): print('oi') for b in range (0, 6): print(b) print('fim') for b in range (6, 0, -1): print(b) print('fim') n= int(input('Digite um numero: ')) for c in range(0, n): print(c) print('fim') i = int(input('Inicio: ')) f = int(input('fim: ')) p = int(input('passos: ')...
for c in range(0, 6): print('oi') for b in range(0, 6): print(b) print('fim') for b in range(6, 0, -1): print(b) print('fim') n = int(input('Digite um numero: ')) for c in range(0, n): print(c) print('fim') i = int(input('Inicio: ')) f = int(input('fim: ')) p = int(input('passos: ')) for c in range(i, f...
#ex10 p.64 what was that? # Examples of tabbed list, inline new line char, and escape sequence test # Tabbed list example output tlist= """ \t * item 1 \t * item 2 \t * item 3 """ print("This is a tabbed list:", tlist) #print() print("Split line after THIS,\nthe above is on it's own line") print("This is a backsla...
tlist = '\n\t * item 1\n\t * item 2\n\t * item 3 ' print('This is a tabbed list:', tlist) print("Split line after THIS,\nthe above is on it's own line") print('This is a backslash in python: \\') formatter = '\t{} \t \t{} \t \t {} \t \t{}' print(formatter.format(1, 2, 3, 4))
gritos = 3 soma = 0 while gritos > 0: entrada = input() if entrada == 'caw caw': print(soma) soma = 0 gritos -= 1 continue entrada = int("".join(map(lambda x: '0' if x == '-' else '1', entrada)), 2) soma += entrada
gritos = 3 soma = 0 while gritos > 0: entrada = input() if entrada == 'caw caw': print(soma) soma = 0 gritos -= 1 continue entrada = int(''.join(map(lambda x: '0' if x == '-' else '1', entrada)), 2) soma += entrada
start_node = '0' end_node = '8' def a_star(start_node, end_node): open_set = set(start_node) closed_set = set() g = {} # Store distance from start node. parents = {} # Parents contain an adjacent map of all nodes. # Distance of start node from itself is zero g[start_node] = 0 parents[start_node] = start...
start_node = '0' end_node = '8' def a_star(start_node, end_node): open_set = set(start_node) closed_set = set() g = {} parents = {} g[start_node] = 0 parents[start_node] = start_node while len(open_set) > 0: n = None for v in open_set: if n == None or g[v] + heur...
# -*- coding: utf-8 -*- """ Implements of URLs manipulation. """ def remove_starting_backward_slash(value: str): """ Removes backward slash at the begin of string. """ if value.startswith('\\'): return value[1:] return value def add_trailing_slash(value): """ Add slash to the en...
""" Implements of URLs manipulation. """ def remove_starting_backward_slash(value: str): """ Removes backward slash at the begin of string. """ if value.startswith('\\'): return value[1:] return value def add_trailing_slash(value): """ Add slash to the end of string if needed. ...
data = open("day6.txt").read().split("\n\n") def part_one(): total = 0 for group in data: total += len(set(list(group.replace("\n", "")))) return total def part_two(): total = 0 for group in data: total += len(set.intersection(*map(set, group.split()))) return total print(p...
data = open('day6.txt').read().split('\n\n') def part_one(): total = 0 for group in data: total += len(set(list(group.replace('\n', '')))) return total def part_two(): total = 0 for group in data: total += len(set.intersection(*map(set, group.split()))) return total print(part_...
print() name = 'abc'.upper() def get_name(): name = 'def'.upper() print(f"inside: {name}") get_name() print(f"Outside: {name}") print() def get_name(): global name name = 'def'.upper() print(f"inside: {name}") get_name() print(f"Outside: {name}") def get_name(): global name #but ...
print() name = 'abc'.upper() def get_name(): name = 'def'.upper() print(f'inside: {name}') get_name() print(f'Outside: {name}') print() def get_name(): global name name = 'def'.upper() print(f'inside: {name}') get_name() print(f'Outside: {name}') def get_name(): global name print(f'inside...
# Read from a text file #Open the file, read the value and close the file f = open("output.txt","r") text=f.read() f.close() print(text)
f = open('output.txt', 'r') text = f.read() f.close() print(text)