content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# This is an input class. Do not edit. class LinkedList: def __init__(self, value): self.value = value self.next = None def removeDuplicatesFromLinkedList(linkedList): # Write your code here. # Have two pointers # 1. Current Node # 2. Next Node # Check if the current node is equal to th...
class Linkedlist: def __init__(self, value): self.value = value self.next = None def remove_duplicates_from_linked_list(linkedList): curr_node = linkedList next_node = linkedList.next while next_node: if curr_node.value == next_node.value: remove_node = next_node ...
def sumDigits(num, base=10): return sum([int(x, base) for x in list(str(num))]) print(sumDigits(1)) print(sumDigits(12345)) print(sumDigits(123045)) print(sumDigits('fe', 16)) print(sumDigits("f0e", 16))
def sum_digits(num, base=10): return sum([int(x, base) for x in list(str(num))]) print(sum_digits(1)) print(sum_digits(12345)) print(sum_digits(123045)) print(sum_digits('fe', 16)) print(sum_digits('f0e', 16))
# Problem: Rotate Image # Difficulty: Medium # Category: Array # Leetcode 48: https://leetcode.com/problems/rotate-image/description/ # Description: """ You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to rotate the image in-place, which means you have...
""" You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation. Example 1: Given input matrix = [ [1,2,3], [4,5...
def maxSubArraySum(arr,N): maxm_sum=arr[0] curr_sum=0 for ele in arr: curr_sum+=ele if curr_sum>0: if curr_sum>maxm_sum: maxm_sum=curr_sum else: if curr_sum>maxm_sum: maxm_sum=curr_sum curr...
def max_sub_array_sum(arr, N): maxm_sum = arr[0] curr_sum = 0 for ele in arr: curr_sum += ele if curr_sum > 0: if curr_sum > maxm_sum: maxm_sum = curr_sum else: if curr_sum > maxm_sum: maxm_sum = curr_sum curr_sum = ...
__all__ = ['OrderLog', 'OrderLogTruncated'] class OrderLog: def __init__(self): self._key = None self._data = None def get_key(self): return self._key def set_key(self, key): if not isinstance(key, int): raise ValueError('Date must be in int format') s...
__all__ = ['OrderLog', 'OrderLogTruncated'] class Orderlog: def __init__(self): self._key = None self._data = None def get_key(self): return self._key def set_key(self, key): if not isinstance(key, int): raise value_error('Date must be in int format') ...
#coding: utf-8 ''' mbinary ####################################################################### # File : hammingDistance.py # Author: mbinary # Mail: zhuheqin1@gmail.com # Blog: https://mbinary.xyz # Github: https://github.com/mbinary # Created Time: 2018-12-17 17:36 # Description: hamming distance is the numbe...
""" mbinary ####################################################################### # File : hammingDistance.py # Author: mbinary # Mail: zhuheqin1@gmail.com # Blog: https://mbinary.xyz # Github: https://github.com/mbinary # Created Time: 2018-12-17 17:36 # Description: hamming distance is the number of different ...
# Constants repo_path = '/Users/aaron/git/gittle' repo_url = 'git@friendco.de:friendcode/gittle.git' # RSA private key key_file = open('/Users/aaron/git/friendcode-conf/rsa/friendcode_rsa')
repo_path = '/Users/aaron/git/gittle' repo_url = 'git@friendco.de:friendcode/gittle.git' key_file = open('/Users/aaron/git/friendcode-conf/rsa/friendcode_rsa')
# 1.Reverse the order of the items in an array. # Example: # a = [1, 2, 3, 4, 5] # Result: # a = [5, 4, 3, 2, 1] def reverseFunction(aList): return aList.reverse() a=[1,2,3,4,5] reverseFunction(a) print(a) # 2. Get the number of occurrences of var b in array a. # Example: # a = [1, 1, ...
def reverse_function(aList): return aList.reverse() a = [1, 2, 3, 4, 5] reverse_function(a) print(a) def occurences_nr(aList, elem): return aList.count(elem) b = [1, 1, 2, 2, 2, 2, 3, 3, 3] c = 3 d = occurences_nr(b, c) print(d) def words_counter(aString): return len(aString.split()) string = 'ana are mer...
class Converter(): def __init__(self): self.alpha = [chr(k) for k in range(65,91)] #Set an array of chars going to the letter A to the Z def calculate(self, seq, b): if not 2 <= b <= 36: #Bases range is [2,36] return None else: out = [] sequence = seq base = b itr = 0 #Keep track of the number o...
class Converter: def __init__(self): self.alpha = [chr(k) for k in range(65, 91)] def calculate(self, seq, b): if not 2 <= b <= 36: return None else: out = [] sequence = seq base = b itr = 0 while sequence != 0 and...
#create mongoDB client #TODO: what port is db on????? client = MongoClient('localhost', 27017) #get the database from mongoDB client database = client.database #get the tables from the database users = database.users #function that handles client-server connections #creates a thread for a connected client def cl...
client = mongo_client('localhost', 27017) database = client.database users = database.users def client_connected(connection): connection.send('Connected to server successfully\n') while 1: data = connection.recv(1024) reply = 'received something' if not data: break c...
class Player(): def __init__(self): self.points = 0 self.developmentCards = [] self.resourceCards = [] self.roads = [] self.settlements = [] self.cities = [] """ How a player picks up cards at the beginning of a turn """ def pickupResources(): return...
class Player: def __init__(self): self.points = 0 self.developmentCards = [] self.resourceCards = [] self.roads = [] self.settlements = [] self.cities = [] ' How a player picks up cards at the beginning of a turn ' def pickup_resources(): return None...
"""Data Structure introduction - Stack""" class MyStack: """A blueprint to implement basic stack operations""" def __init__(self,size = 10): """Intialize""" self.stack = [] self.size =size def __str__(self): """Pythonic way of converting objects to string""" return ...
"""Data Structure introduction - Stack""" class Mystack: """A blueprint to implement basic stack operations""" def __init__(self, size=10): """Intialize""" self.stack = [] self.size = size def __str__(self): """Pythonic way of converting objects to string""" return...
sum_of_the_squares = 0 square_of_the_sum = 0 for i in range(0,100): sum_of_the_squares = sum_of_the_squares + (i+1)**2 square_of_the_sum = square_of_the_sum + (i+1) print((square_of_the_sum**2) - sum_of_the_squares)
sum_of_the_squares = 0 square_of_the_sum = 0 for i in range(0, 100): sum_of_the_squares = sum_of_the_squares + (i + 1) ** 2 square_of_the_sum = square_of_the_sum + (i + 1) print(square_of_the_sum ** 2 - sum_of_the_squares)
WEB_URL = "https://replicate.ai" DOCS_URL = WEB_URL + "/docs" PYTHON_REFERENCE_DOCS_URL = DOCS_URL + "/reference/python" YAML_REFERENCE_DOCS_URL = DOCS_URL + "/reference/yaml" REPOSITORY_VERSION = 1 HEARTBEAT_MISS_TOLERANCE = 3 EXPERIMENT_STATUS_RUNNING = "running" EXPERIMENT_STATUS_STOPPED = "stopped"
web_url = 'https://replicate.ai' docs_url = WEB_URL + '/docs' python_reference_docs_url = DOCS_URL + '/reference/python' yaml_reference_docs_url = DOCS_URL + '/reference/yaml' repository_version = 1 heartbeat_miss_tolerance = 3 experiment_status_running = 'running' experiment_status_stopped = 'stopped'
class Solution: def floodFill(self, image, sr, sc, newColor): """ :type image: List[List[int]] :type sr: int :type sc: int :type newColor: int :rtype: List[List[int]] """ if image[sr][sc] != newColor: self.helper(image, sr, sc, newColor, im...
class Solution: def flood_fill(self, image, sr, sc, newColor): """ :type image: List[List[int]] :type sr: int :type sc: int :type newColor: int :rtype: List[List[int]] """ if image[sr][sc] != newColor: self.helper(image, sr, sc, newColor, ...
demo_schema = [ { 'name': 'SUMLEV', 'type': 'STRING' }, { 'name': 'STATE', 'type': 'STRING' }, { 'name': 'COUNTY', 'type': 'STRING' ...
demo_schema = [{'name': 'SUMLEV', 'type': 'STRING'}, {'name': 'STATE', 'type': 'STRING'}, {'name': 'COUNTY', 'type': 'STRING'}, {'name': 'TRACT', 'type': 'STRING'}, {'name': 'BLKGRP', 'type': 'STRING'}, {'name': 'BLOCK', 'type': 'STRING'}, {'name': 'POP100', 'type': 'INTEGER'}, {'name': 'HU100', 'type': 'INTEGER'}, {'n...
"""Task class definition""" class Task: """Task class, representing a task""" def __init__(self, num, name): self.num = num self.name = name def __str__(self): return '['+self.str_num()+'] '+self.name def str_num(self): """Prepends zeroes to the task id to make it a 3-...
"""Task class definition""" class Task: """Task class, representing a task""" def __init__(self, num, name): self.num = num self.name = name def __str__(self): return '[' + self.str_num() + '] ' + self.name def str_num(self): """Prepends zeroes to the task id to make ...
# https://leetcode.com/problems/check-if-word-equals-summation-of-two-words alphabet = { 'a': '0', 'b': '1', 'c': '2', 'd': '3', 'e': '4', 'f': '5', 'g': '6', 'h': '7', 'i': '8', 'j': '9', } def get_numerical_value(word): list_of_chars = [] for char in word: ...
alphabet = {'a': '0', 'b': '1', 'c': '2', 'd': '3', 'e': '4', 'f': '5', 'g': '6', 'h': '7', 'i': '8', 'j': '9'} def get_numerical_value(word): list_of_chars = [] for char in word: list_of_chars.append(alphabet[char]) return int(''.join(list_of_chars)) def is_sum_equal(first_word, second_word, targ...
APP_NAME = "dotpyle" DOTPYLE_CONFIG_FILE_NAME = "dotpyle.yml" DOTPYLE_LOCAL_CONFIG_FILE_NAME = "dotpyle.local.yml" DOTFILES_FOLDER = "dotfiles" SCRIPTS_FOLDER = "scripts" DOTPYLE_CONFIG_FILE_NAME_TEMP = "dotpyle.temp.yml" README_NAME = "README.md" README_TEMPLATE_PATH = "dotpyle/templates/readme.md" CONFIG_TEMPLATE_PAT...
app_name = 'dotpyle' dotpyle_config_file_name = 'dotpyle.yml' dotpyle_local_config_file_name = 'dotpyle.local.yml' dotfiles_folder = 'dotfiles' scripts_folder = 'scripts' dotpyle_config_file_name_temp = 'dotpyle.temp.yml' readme_name = 'README.md' readme_template_path = 'dotpyle/templates/readme.md' config_template_pat...
#!/usr/bin/python3 def print_list_integer(my_list=[]): "prints all integers of a list" for i in range(len(my_list)): print("{:d}".format(my_list[i]))
def print_list_integer(my_list=[]): """prints all integers of a list""" for i in range(len(my_list)): print('{:d}'.format(my_list[i]))
""" Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node. - Example 1: Input: head = [1,2,3,4,5] Output: [3,4,5] Explanation: The middle node of the list is node 3. - Example 2: Input: head = [1,2,3,4,5,6] Output: [4,5,6] E...
""" Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node. - Example 1: Input: head = [1,2,3,4,5] Output: [3,4,5] Explanation: The middle node of the list is node 3. - Example 2: Input: head = [1,2,3,4,5,6] Output: [4,5,6] E...
HOST = 'http://kevin:8000' VERSION = 'v2' API_URL = "{host}/{version}".format(host=HOST, version=VERSION) API_TOKEN = None # set by wiredrive.auth.set_token() SSL_VERIFY = True # Any requests for more resources than the limit will be clamped down to it. MAX_PAGINATION_LIMIT = 500 RFC3339_FORMAT = "%Y-%m-%dT%H:%M:%SZ...
host = 'http://kevin:8000' version = 'v2' api_url = '{host}/{version}'.format(host=HOST, version=VERSION) api_token = None ssl_verify = True max_pagination_limit = 500 rfc3339_format = '%Y-%m-%dT%H:%M:%SZ' datetime_format = RFC3339_FORMAT
class Solution: def mirrorReflection(self, p: int, q: int) -> int: m, n = q, p while m % 2 == 0 and n % 2 == 0: m, n = m / 2, n / 2 if n % 2 == 0 and m % 2 == 1: # receive at left side if n is even return 2 # receive at right side: 0, or 1 if n % 2 ==...
class Solution: def mirror_reflection(self, p: int, q: int) -> int: (m, n) = (q, p) while m % 2 == 0 and n % 2 == 0: (m, n) = (m / 2, n / 2) if n % 2 == 0 and m % 2 == 1: return 2 if n % 2 == 1 and m % 2 == 0: return 0 if n % 2 == 1 and m ...
NAMES = { 'lane': 'Test1', 'lb': None, 'pu': 'Test1', 'sample': 'Test1', 'rg': 'Test1', 'pl': 'illumina' } DATA = { 'files': [ '/bcbio-nextgen/tests/test_automated_output/trimmed/1_1_Test1.trimmed.fq.gz', '/bcbio-nextgen/tests/test_automated_output/trimmed/1_2_Test1.trimmed....
names = {'lane': 'Test1', 'lb': None, 'pu': 'Test1', 'sample': 'Test1', 'rg': 'Test1', 'pl': 'illumina'} data = {'files': ['/bcbio-nextgen/tests/test_automated_output/trimmed/1_1_Test1.trimmed.fq.gz', '/bcbio-nextgen/tests/test_automated_output/trimmed/1_2_Test1.trimmed.fq.gz'], 'dirs': {'config': '/bcbio-nextgen/tests...
#zamjena vrijednosti dvije promjeljive a = 5; b = 8 print(a, b) a, b = b, a print(a, b)
a = 5 b = 8 print(a, b) (a, b) = (b, a) print(a, b)
#W.A.P TO PRINT PATTERNS USING NESTED FOR t=65 for i in range(0,4,1): for j in range(0,i+1,1): ch=chr(t) print(ch,end='') t = t + 1 print() t=0 n=0 for i in range(0,5,1): t=n for j in range(0,i+1,1): print(t,end='') t=t+1 print() t =0 for i in range(0, 5, 1)...
t = 65 for i in range(0, 4, 1): for j in range(0, i + 1, 1): ch = chr(t) print(ch, end='') t = t + 1 print() t = 0 n = 0 for i in range(0, 5, 1): t = n for j in range(0, i + 1, 1): print(t, end='') t = t + 1 print() t = 0 for i in range(0, 5, 1): t = 1 for...
""" Exception classes for pyinstaller-versionfile. """ class InputError(Exception): """ The given metadata input file is not as expected. """ class UsageError(Exception): """ Exception for all cases where the end user is giving wrong inputs to the program. """ class ValidationError(Exceptio...
""" Exception classes for pyinstaller-versionfile. """ class Inputerror(Exception): """ The given metadata input file is not as expected. """ class Usageerror(Exception): """ Exception for all cases where the end user is giving wrong inputs to the program. """ class Validationerror(Exception)...
""" PASSENGERS """ numPassengers = 2740 passenger_arriving = ( (2, 5, 2, 2, 1, 0, 12, 12, 4, 3, 0, 0), # 0 (6, 3, 3, 2, 2, 0, 3, 8, 3, 5, 1, 0), # 1 (4, 6, 8, 1, 1, 0, 3, 8, 3, 4, 1, 0), # 2 (6, 5, 3, 4, 4, 0, 6, 2, 5, 1, 0, 0), # 3 (2, 2, 5, 5, 1, 0, 6, 6, 4, 5, 1, 0), # 4 (5, 8, 4, 5, 2, 0, 7, 9, 8, 3, ...
""" PASSENGERS """ num_passengers = 2740 passenger_arriving = ((2, 5, 2, 2, 1, 0, 12, 12, 4, 3, 0, 0), (6, 3, 3, 2, 2, 0, 3, 8, 3, 5, 1, 0), (4, 6, 8, 1, 1, 0, 3, 8, 3, 4, 1, 0), (6, 5, 3, 4, 4, 0, 6, 2, 5, 1, 0, 0), (2, 2, 5, 5, 1, 0, 6, 6, 4, 5, 1, 0), (5, 8, 4, 5, 2, 0, 7, 9, 8, 3, 1, 0), (2, 2, 3, 2, 2, 0, 4, 10, 3...
#!/usr/bin/env python def pin_iteration(fmt): """Iterate over the pinmap, yielding fmt formatted with idx, bank and pin.""" for i, (bank, pin) in enumerate(pinmap): yield fmt.format(idx=i, bank=bank, pin=pin) def strip(line): """Strip the identation of a line for the comment header.""" ...
def pin_iteration(fmt): """Iterate over the pinmap, yielding fmt formatted with idx, bank and pin.""" for (i, (bank, pin)) in enumerate(pinmap): yield fmt.format(idx=i, bank=bank, pin=pin) def strip(line): """Strip the identation of a line for the comment header.""" if line.startswith(' ' * 4):...
magicians = ['alice', 'david', 'carolina'] for magician in magicians: print(magician.title() + ", that was a great trick!") print(f"i can't wait to see your next trick, {magician.title()}", end="\n\n") print("Thank you, everyone. That was a great magic show!") ''' o nome da lista deve vir no plural assim facili...
magicians = ['alice', 'david', 'carolina'] for magician in magicians: print(magician.title() + ', that was a great trick!') print(f"i can't wait to see your next trick, {magician.title()}", end='\n\n') print('Thank you, everyone. That was a great magic show!') '\no nome da lista deve vir no plural\nassim facili...
# TALON: Techonology-Agnostic Long Read Analysis Pipeline # Author: Dana Wyman # ----------------------------------------------------------------------------- # Queries for working with exon and transcript lengths def get_all_exon_lengths(cursor, build): """ Compute all exon lengths and store in a dict """ ex...
def get_all_exon_lengths(cursor, build): """ Compute all exon lengths and store in a dict """ exon_lengths = {} cursor.execute(" SELECT edge_ID,\n loc1.position AS pos1,\n loc2.position AS pos2,\n abs(loc1.position - loc2.position) +...
""" This is a program written in python for finding GCD of two numbers. This solution uses recursive approach as implementation. Recursive approach means a fuction calling itself for which a base condition is given so that the program knows where to terminate. """ #definition of functions to find GCD of 2 numbers. de...
""" This is a program written in python for finding GCD of two numbers. This solution uses recursive approach as implementation. Recursive approach means a fuction calling itself for which a base condition is given so that the program knows where to terminate. """ def gcd_of_nums(x, y): if x > y: t = x ...
obj_path_map = { "long_sofa": "04256520/68fce005fd18b5af598a453fd9fbd988", "l_sofa": "04256520/575876c91251e1923d6e282938a47f9e", "conic_bin": "02747177/cf158e768a6c9c8a17cab8b41d766398", "square_prism_bin": "02747177/9fe4d78e7d4085c2f1b010366bb60ce8", "faucet": "03325088/1f223cac61e3679ef235ab3c41a...
obj_path_map = {'long_sofa': '04256520/68fce005fd18b5af598a453fd9fbd988', 'l_sofa': '04256520/575876c91251e1923d6e282938a47f9e', 'conic_bin': '02747177/cf158e768a6c9c8a17cab8b41d766398', 'square_prism_bin': '02747177/9fe4d78e7d4085c2f1b010366bb60ce8', 'faucet': '03325088/1f223cac61e3679ef235ab3c41aeb5b6', 'bunsen_burne...
# test the pyncparser package # copy some data in here as str, # and try to parse it text = """<SUBMISSION> <PAPER> <ACCESSION-NUMBER>9999999997-22-000253 <TYPE>19B-4E <PUBLIC-DOCUMENT-COUNT>1 <FILING-DATE>20220128 <EFFECTIVENESS-DATE>20220128 <FILER> <COMPANY-DATA> <CONFORMED-NAME>Cboe EDGA Exchange, Inc. <CIK>000147...
text = '<SUBMISSION>\n<PAPER>\n<ACCESSION-NUMBER>9999999997-22-000253\n<TYPE>19B-4E\n<PUBLIC-DOCUMENT-COUNT>1\n<FILING-DATE>20220128\n<EFFECTIVENESS-DATE>20220128\n<FILER>\n<COMPANY-DATA>\n<CONFORMED-NAME>Cboe EDGA Exchange, Inc.\n<CIK>0001473606\n<STATE-OF-INCORPORATION>DE\n<FISCAL-YEAR-END>1231\n</COMPANY-DATA>\n<FIL...
""" ==== KEY POINTS ==== - Given two non-empty arrays of integers, write a function that determines whether the second array is a subsequence of the first one. - [1, 3, 4] form a subsequence of the array [1, 2, 3, 4] """ """ - Time Complexity: O(n) - Space Complexity: O(1) """ def is_valid_subsequence1(array, seque...
""" ==== KEY POINTS ==== - Given two non-empty arrays of integers, write a function that determines whether the second array is a subsequence of the first one. - [1, 3, 4] form a subsequence of the array [1, 2, 3, 4] """ '\n- Time Complexity: O(n)\n- Space Complexity: O(1)\n' def is_valid_subsequence1(array, sequen...
# # PySNMP MIB module CXPCM-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CXPCM-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 18:17:42 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, 09:23...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_union, value_size_constraint, constraints_intersection, single_value_constraint) ...
N = int(input()) H = list(map(int, input().split())) answer = moved = 0 before_h = H[0] for h in H[1:]: if h > before_h: moved = 0 else: moved += 1 answer = max(answer, moved) before_h = h print(answer)
n = int(input()) h = list(map(int, input().split())) answer = moved = 0 before_h = H[0] for h in H[1:]: if h > before_h: moved = 0 else: moved += 1 answer = max(answer, moved) before_h = h print(answer)
# Example distribution config used in tests in both test_cloudfront.py # as well as test_cloudfront_distributions.py. def example_distribution_config(ref): """Return a basic example distribution config for use in tests.""" return { "CallerReference": ref, "Origins": { "Quantity": 1...
def example_distribution_config(ref): """Return a basic example distribution config for use in tests.""" return {'CallerReference': ref, 'Origins': {'Quantity': 1, 'Items': [{'Id': 'origin1', 'DomainName': 'asdf.s3.us-east-1.amazonaws.com', 'S3OriginConfig': {'OriginAccessIdentity': ''}}]}, 'DefaultCacheBehavio...
def generate_matrix(size): matrix = [] for i in range(size): matrix.append([None] * size) return matrix def create_list_of_lines(matrix): lines = [] #adding horizontal lines for hor_line in matrix: lines.append(hor_line) #adding vertical lines for i in range(len(matrix)...
def generate_matrix(size): matrix = [] for i in range(size): matrix.append([None] * size) return matrix def create_list_of_lines(matrix): lines = [] for hor_line in matrix: lines.append(hor_line) for i in range(len(matrix)): ver_line = [] for j in range(len(matri...
consumer_key = "mXzLJ779Al4UPyg3OJr1NzXdg" consumer_secret = "yxQYDNvUs0JNEtEasA9CN4bEweImDIrISQit6eNWEmuCGP008G" access_token = "1431634234783981568-WllRiFW0dQW7PjM2eBqYMIsfpqoJc8" access_token_secret = "HahcSPryVc553SYEV6tOKPJkK2TcS2RX75jK3oOVNjRY1" trigger = "" timezone = 2 #change this into your timezone. for examp...
consumer_key = 'mXzLJ779Al4UPyg3OJr1NzXdg' consumer_secret = 'yxQYDNvUs0JNEtEasA9CN4bEweImDIrISQit6eNWEmuCGP008G' access_token = '1431634234783981568-WllRiFW0dQW7PjM2eBqYMIsfpqoJc8' access_token_secret = 'HahcSPryVc553SYEV6tOKPJkK2TcS2RX75jK3oOVNjRY1' trigger = '' timezone = 2
def getKeys(os): try: dotenv = '.env.ini' with open(dotenv, 'r') as file: content = file.readlines() content = [line.strip().split('=') for line in content if '=' in line] env_vars = dict(content) if file: file.close() return env_vars exc...
def get_keys(os): try: dotenv = '.env.ini' with open(dotenv, 'r') as file: content = file.readlines() content = [line.strip().split('=') for line in content if '=' in line] env_vars = dict(content) if file: file.close() return env_vars exce...
{ "targets": [ { "target_name": "tester", "sources": [ "tester.cc", "tester.js" ] } ] }
{'targets': [{'target_name': 'tester', 'sources': ['tester.cc', 'tester.js']}]}
CONTROL_TOKEN = [int('1101010100', 2), # 00 int('0010101011', 2), # 01 int('0101010100', 2), # 10 int('1010101011', 2)] # 11
control_token = [int('1101010100', 2), int('0010101011', 2), int('0101010100', 2), int('1010101011', 2)]
class CStaticConsts: # Product dictionary indexes title = 'title' currencyType = 'currencyId' itemPrice = 'itemPrice' productUrl = 'productUrl' currencyUSD = 'USD' siteName = 'siteName' # Supported sites Ebay = 'Ebay' Walmart = 'Walmart' Amazon = 'Amazon'
class Cstaticconsts: title = 'title' currency_type = 'currencyId' item_price = 'itemPrice' product_url = 'productUrl' currency_usd = 'USD' site_name = 'siteName' ebay = 'Ebay' walmart = 'Walmart' amazon = 'Amazon'
# Strings taken from https://github.com/b1naryth1ef. __all__ = ( 'BOT_BROKEN_MSG', 'COUNCIL_QUEUE_MSG_NOT_FOUND', 'BAD_SUGGESTION_MSG', 'SUGGESTION_RECEIVED', 'SUGGESTION_APPROVED', 'SUGGESTION_DENIED', 'SUGGESTION_TOO_LARGE', 'UPLOADED_EMOJI_NOT_FOUND', 'SUBMITTER_NOT_FOUND' ) COU...
__all__ = ('BOT_BROKEN_MSG', 'COUNCIL_QUEUE_MSG_NOT_FOUND', 'BAD_SUGGESTION_MSG', 'SUGGESTION_RECEIVED', 'SUGGESTION_APPROVED', 'SUGGESTION_DENIED', 'SUGGESTION_TOO_LARGE', 'UPLOADED_EMOJI_NOT_FOUND', 'SUBMITTER_NOT_FOUND') council_queue_msg_not_found = "⚠ Couldn't delete the associated council queue message (ID: `{sug...
TEXT = b""" Overhead the albatross hangs motionless upon the air And deep beneath the rolling waves in labyrinths of coral caves The echo of a distant tide Comes willowing across the sand And everything is green and submarine And no one showed us to the land And no one knows the wheres or whys But something stirs and ...
text = b'\nOverhead the albatross hangs motionless upon the air\nAnd deep beneath the rolling waves in labyrinths of coral caves\nThe echo of a distant tide\nComes willowing across the sand\nAnd everything is green and submarine\n\nAnd no one showed us to the land\nAnd no one knows the wheres or whys\nBut something sti...
class Solution: def kthGrammar(self, N: int, K: int) -> int: K -= 1 count = 0 while K: count += 1 K &= K - 1 return count & 1
class Solution: def kth_grammar(self, N: int, K: int) -> int: k -= 1 count = 0 while K: count += 1 k &= K - 1 return count & 1
class scheduleElem(): def __init__(self, _tr, _op, _res): self.tr = _tr self.op = _op self.res = _res def __repr__(self): return "{}{}({})".format(self.op, self.tr, self.res) def getElem(strelem): strtr = '' op = '' for i in strelem[0:strelem.find('(')]: ...
class Scheduleelem: def __init__(self, _tr, _op, _res): self.tr = _tr self.op = _op self.res = _res def __repr__(self): return '{}{}({})'.format(self.op, self.tr, self.res) def get_elem(strelem): strtr = '' op = '' for i in strelem[0:strelem.find('(')]: if ...
"""a module housing logic to identify points when curves first cross a certain value """ __author__ = "Reed Essick (reed.essick@gmail.com)" #------------------------------------------------- def _data2crossing(d, ref): '''returns the indecies of the 1D array 'data' that braket the first time it crosses ref''' ...
"""a module housing logic to identify points when curves first cross a certain value """ __author__ = 'Reed Essick (reed.essick@gmail.com)' def _data2crossing(d, ref): """returns the indecies of the 1D array 'data' that braket the first time it crosses ref""" n = len(d) above = d[0] > ref ind = 1 w...
def R(pcset): """Returns retrograde of pcset.""" return [pcset[x] for x in range(len(pcset)-1, -1, -1)] def I(pcset): """Returns inversion of pcset.""" return [(12-x)%12 for x in pcset] def RI(pcset): """Returns retrograde inversion of pcset.""" return I(R(pcset)) def M5(pcset): return [(...
def r(pcset): """Returns retrograde of pcset.""" return [pcset[x] for x in range(len(pcset) - 1, -1, -1)] def i(pcset): """Returns inversion of pcset.""" return [(12 - x) % 12 for x in pcset] def ri(pcset): """Returns retrograde inversion of pcset.""" return i(r(pcset)) def m5(pcset): ret...
def foo(*, a, b): print(a) print(b) def bar(): fo<caret>o(a = 1, b = 2)
def foo(*, a, b): print(a) print(b) def bar(): fo < caret > o(a=1, b=2)
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def print_list(self): cur_node = self.head while cur_node: print(cur_node.data) cur_node = cur_node.next def ...
class Node: def __init__(self, data): self.data = data self.next = None class Linkedlist: def __init__(self): self.head = None def print_list(self): cur_node = self.head while cur_node: print(cur_node.data) cur_node = cur_node.next def...
def max_sum_subarray(nums): if not nums: return nums max_sum = nums[0] cur_sum = 0 for i in range(len(nums)): cur_sum = max( cur_sum + nums[i], nums[i] ) max_sum = max( cur_sum, max_sum ) return max_sum
def max_sum_subarray(nums): if not nums: return nums max_sum = nums[0] cur_sum = 0 for i in range(len(nums)): cur_sum = max(cur_sum + nums[i], nums[i]) max_sum = max(cur_sum, max_sum) return max_sum
class NoHostError(Exception): pass class NoHeartbeatError(Exception): pass class NoSudoError(Exception): pass class ServiceShutdown(Exception): pass
class Nohosterror(Exception): pass class Noheartbeaterror(Exception): pass class Nosudoerror(Exception): pass class Serviceshutdown(Exception): pass
# # PySNMP MIB module FOUNDRY-SN-TRAP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/FOUNDRY-SN-TRAP-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:15:47 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_range_constraint, single_value_constraint, constraints_union, value_size_constraint) ...
n = int(input()) b = list(map(int, input().rstrip().split())) count = 0 total = 0 l = len(b)-1 for i in b: try: if i%2 != 0: b[count] += 1 b[count + 1] += 1 total += 1 except: break count += 1 if count == l: break if b[-1]%2 == 0: pr...
n = int(input()) b = list(map(int, input().rstrip().split())) count = 0 total = 0 l = len(b) - 1 for i in b: try: if i % 2 != 0: b[count] += 1 b[count + 1] += 1 total += 1 except: break count += 1 if count == l: break if b[-1] % 2 == 0: pri...
# # PySNMP MIB module PAIRGAIN-DSLAM-ALARM-SEVERITY-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/PAIRGAIN-DSLAM-ALARM-SEVERITY-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:27:27 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using P...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, value_size_constraint, constraints_union, single_value_constraint, constraints_intersection) ...
def if_mkl_open_source_only(if_true, if_false = []): """Returns `if_true` if OneDNN v0.x is used. Shorthand for select()'ing on whether we're building with OneDNN v0.x open source library only, without depending on OneDNN binary form. Returns a select statement which evaluates to if_true if we're buil...
def if_mkl_open_source_only(if_true, if_false=[]): """Returns `if_true` if OneDNN v0.x is used. Shorthand for select()'ing on whether we're building with OneDNN v0.x open source library only, without depending on OneDNN binary form. Returns a select statement which evaluates to if_true if we're buildi...
FORBIDDEN_TITLE_PUNCTUATION = [ "'", ",", '"', '?', '/' '\\', '`', '|', '&' ] class Query: title = '' from_service = '' artist = '' media_type = '' def __init__(self, title, service = '', artist='', media_type=''): if not (isinstance(title, str) and isinstance(artist, str...
forbidden_title_punctuation = ["'", ',', '"', '?', '/\\', '`', '|', '&'] class Query: title = '' from_service = '' artist = '' media_type = '' def __init__(self, title, service='', artist='', media_type=''): if not (isinstance(title, str) and isinstance(artist, str) and isinstance(media_ty...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Nov 17 13:48:21 2020 @author: zuoxichen """ def get_array_numbers(integer): ''' Parameters ---------- int1 : integer int. Returns ------- a set that contains all the number in a part. ''' a=integer//3 ...
""" Created on Tue Nov 17 13:48:21 2020 @author: zuoxichen """ def get_array_numbers(integer): """ Parameters ---------- int1 : integer int. Returns ------- a set that contains all the number in a part. """ a = integer // 3 b = integer % 3 if b: list1 = s...
""" 04: Scheduling Launch Plans --------------------------- """
""" 04: Scheduling Launch Plans --------------------------- """
class Solution(object): def numberOfArithmeticSlices(self, A): """ :type A: List[int] :rtype: int """ if len(A) < 3: return 0 dp = [0] * len(A) if A[2] - A[1] == A[1] - A[0]: dp[2] = 1 res = dp[2] for i in range(3, len(A...
class Solution(object): def number_of_arithmetic_slices(self, A): """ :type A: List[int] :rtype: int """ if len(A) < 3: return 0 dp = [0] * len(A) if A[2] - A[1] == A[1] - A[0]: dp[2] = 1 res = dp[2] for i in range(3, l...
# This python script is called on build via ModBundlesItems.json configuration def OnPreBuild(**kwargs) -> None: print("OnPreBuildItem.py called ...") bundleItem = kwargs.get("_bundleItem") info = kwargs.get("info") assert bundleItem != None, "_bundleItem kwargs not found" assert info != None, "i...
def on_pre_build(**kwargs) -> None: print('OnPreBuildItem.py called ...') bundle_item = kwargs.get('_bundleItem') info = kwargs.get('info') assert bundleItem != None, '_bundleItem kwargs not found' assert info != None, 'info kwargs not found'
# # Copyright 2016 Google Inc. All Rights Reserved. # # # # Licensed under the Apache License, Version 2.0 (the "License"); # # you may not use this file except in compliance with the License. # # You may obtain a copy of the License at # # # # http://www.apache.org/licenses/LICENSE-2.0 # # # # Unless required by a...
name = 'posix'
#!/usr/bin/python3 class NetworkConfig(object): def __init__(self, public_cidr, vpc, public_subnets, private_subnets, nat, jump, keypair, cd_service_role_arn, public_hosted_zone_name, private_hosted_zone_id, private_hosted_zone_domain, nat_highly_available, nat_gateways, sns_topi...
class Networkconfig(object): def __init__(self, public_cidr, vpc, public_subnets, private_subnets, nat, jump, keypair, cd_service_role_arn, public_hosted_zone_name, private_hosted_zone_id, private_hosted_zone_domain, nat_highly_available, nat_gateways, sns_topic, availability_zones): """ Simple con...
{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "Stocks.py", "provenance": [], "authorship_tag": "ABX9TyN2tEWSWwhJDRg3YG0iUDln", "include_colab_link": true }, "kernelspec": { "name": "python3", "display_name": "Python 3" } }, "cells": ...
{'nbformat': 4, 'nbformat_minor': 0, 'metadata': {'colab': {'name': 'Stocks.py', 'provenance': [], 'authorship_tag': 'ABX9TyN2tEWSWwhJDRg3YG0iUDln', 'include_colab_link': true}, 'kernelspec': {'name': 'python3', 'display_name': 'Python 3'}}, 'cells': [{'cell_type': 'markdown', 'metadata': {'id': 'view-in-github', 'cola...
HF_TOKENIZER_NEWS_CLASSIFIER = "mrm8488/bert-mini-finetuned-age_news-classification" HF_MODEL_NEWS_CLASSIFIER = "mrm8488/bert-mini-finetuned-age_news-classification" SUBREDDITS = "wallstreetbets+investing+options+pennystocks+options+stocks" NEWS_SUBREDDITS = "news" NUM_SUBMISSION_TO_GET = 10 NEWS_CLASSES = ["world",...
hf_tokenizer_news_classifier = 'mrm8488/bert-mini-finetuned-age_news-classification' hf_model_news_classifier = 'mrm8488/bert-mini-finetuned-age_news-classification' subreddits = 'wallstreetbets+investing+options+pennystocks+options+stocks' news_subreddits = 'news' num_submission_to_get = 10 news_classes = ['world', 's...
def getBASIC(): list = [] n = input() while True: line = n if n.endswith('END'): list.append(line) return list else: list.append(line) newN = input() n = newN def findLine(prog, T): for i in range(0, len(prog)): ...
def get_basic(): list = [] n = input() while True: line = n if n.endswith('END'): list.append(line) return list else: list.append(line) new_n = input() n = newN def find_line(prog, T): for i in range(0, len(prog)): ...
# Created By Rabia Alhaffar In 15/February/2020 # A Script To Run From native_01.js And native_01.bat print("Hello World") input()
print('Hello World') input()
''' Question: Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5, between 2000 and 3200 (both included). The numbers obtained should be printed in a comma-separated sequence on a single line. ''' result_list = [] for i in range(2000,3201): # here the end is incremente...
""" Question: Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5, between 2000 and 3200 (both included). The numbers obtained should be printed in a comma-separated sequence on a single line. """ result_list = [] for i in range(2000, 3201): if i % 7 == 0 and i % 5 ...
""" 613. High Five O(nlogn) for sorting. then iterate through the array once. so o(n) overall o(nlogn) """ ''' Definition for a Record class Record: def __init__(self, id, score): self.id = id self.score = score ''' class Solution: # @param {Record[]} results a list of <student_id, score> #...
""" 613. High Five O(nlogn) for sorting. then iterate through the array once. so o(n) overall o(nlogn) """ '\nDefinition for a Record\nclass Record:\n def __init__(self, id, score):\n self.id = id\n self.score = score\n' class Solution: def high_five(self, results): results.sort(key=lamb...
MQTT_HOST = "mqtt-server" MQTT_PORT = 1234 MQTT_USER = "mqtt-user" MQTT_PASS = "mqtt-password" MQTT_TOPIC = "frogbot"
mqtt_host = 'mqtt-server' mqtt_port = 1234 mqtt_user = 'mqtt-user' mqtt_pass = 'mqtt-password' mqtt_topic = 'frogbot'
""" # Definition for a Node. class Node: def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right """ class Solution: def treeToDoublyList(self, root: "Node") -> "Node": def recur(root): nonlocal last, first if r...
""" # Definition for a Node. class Node: def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right """ class Solution: def tree_to_doubly_list(self, root: 'Node') -> 'Node': def recur(root): nonlocal last, first ...
""" Black \e[0;30m Blue \e[0;34m Green \e[0;32m Cyan \e[0;36m Red \e[0;31m Purple \e[0;35m Brown \e[0;33m Gray \e[0;37m Dark Gray \e[1;30m Light Blue \e[1;34m Light Green \e[1;32m Light Cyan \e[1;36m Ligh...
""" Black \\e[0;30m Blue \\e[0;34m Green \\e[0;32m Cyan \\e[0;36m Red \\e[0;31m Purple \\e[0;35m Brown \\e[0;33m Gray \\e[0;37m Dark Gray \\e[1;30m Light Blue \\e[1;34m Light Green \\e[1;32m Light Cyan \\...
# Here's a class Lightbulb. It has only one attribute that # represents its state: whether it's on or off. # Create a method change_state that changes the state of the # lightbulb. In other words, the methods turns the light on or # off depending on its current state. The method doesn't take any # arguments and prin...
class Lightbulb: def __init__(self): self.state = 'off' def change_state(self): self.state = 'on' if self.state == 'off' else 'off' print(f'Turning the light {self.state}') l = lightbulb() l.change_state()
clothes = [int(i) for i in input().split()] # List of clothes' values rack_capacity = int(input()) # The maximum capacity of one rack racks = 1 sum_clothes = 0 while clothes: value = clothes.pop() sum_clothes += value if sum_clothes > rack_capacity: sum_clothes = value ...
clothes = [int(i) for i in input().split()] rack_capacity = int(input()) racks = 1 sum_clothes = 0 while clothes: value = clothes.pop() sum_clothes += value if sum_clothes > rack_capacity: sum_clothes = value racks += 1 print(racks)
# -*- coding: utf-8 -*- thistuple = ("apple",) print(type(thistuple)) #NOT a tuple thistuple = ("apple") print(type(thistuple)) tuple1 = ("abc", 34, True, 40, "male") print(tuple1)
thistuple = ('apple',) print(type(thistuple)) thistuple = 'apple' print(type(thistuple)) tuple1 = ('abc', 34, True, 40, 'male') print(tuple1)
# Title : Find the percentage of odd/even elements # Author : Kiran raj R. # Date : 15:10:2020 list1 = [1, 2, 4, 0, 0, 8, 3, 5, 2, 3, 1, 34, 42] def print_percentage(list_in): count_odd = 0 count_even = 0 count_0 = 0 length = len(list1) for elem in list_in: if elem == 0: ...
list1 = [1, 2, 4, 0, 0, 8, 3, 5, 2, 3, 1, 34, 42] def print_percentage(list_in): count_odd = 0 count_even = 0 count_0 = 0 length = len(list1) for elem in list_in: if elem == 0: count_0 += 1 elif elem % 2 == 1: count_odd += 1 else: count_ev...
a = 5 print(type(a)) b = 5.5 print(type(b)) print(a+b) print((a+b) * 2) print(2+2+4-2/3)
a = 5 print(type(a)) b = 5.5 print(type(b)) print(a + b) print((a + b) * 2) print(2 + 2 + 4 - 2 / 3)
# Copyright 2011 Jamie Norrish (jamie@artefact.org.nz) # # 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...
xsd = 'http://www.w3.org/2001/XMLSchema#' xsd_any_uri = XSD + 'anyURI' xsd_float = XSD + 'float' xsd_int = XSD + 'int' xsd_long = XSD + 'long' xsd_string = XSD + 'string' tmapi_feature_string_base = 'http://tmapi.org/features/' automerge_feature_string = TMAPI_FEATURE_STRING_BASE + 'automerge' merge_by_topic_name_featu...
""" Init file to follow PyPI requirements. """ print("Hello, World!")
""" Init file to follow PyPI requirements. """ print('Hello, World!')
class Card: def __init__(self, suit, value): self.suit = suit self.value = value def getSuit(self): return self.suit def getValue(self): return self.value def __repr__(self): return str(self.suit) + ", " + str(self.value) def __str__(self): return ...
class Card: def __init__(self, suit, value): self.suit = suit self.value = value def get_suit(self): return self.suit def get_value(self): return self.value def __repr__(self): return str(self.suit) + ', ' + str(self.value) def __str__(self): retu...
class Toy: def __init__(self, newdescr: str, newlovable: float): self.__description = newdescr self.__lovable = newlovable def getDescription(self) -> str: return self.__description def getLovable(self) -> float: return self.__lovable def setDescription(self, newdescr:...
class Toy: def __init__(self, newdescr: str, newlovable: float): self.__description = newdescr self.__lovable = newlovable def get_description(self) -> str: return self.__description def get_lovable(self) -> float: return self.__lovable def set_description(self, newde...
# Author: Ashish Jangra from Teenage Coder num = 10 print("*") for i in range(1, num): print("*"+ " "*i +"*") for i in range(num-2, 0, -1): print("*"+ " "*i +"*") print("*")
num = 10 print('*') for i in range(1, num): print('*' + ' ' * i + '*') for i in range(num - 2, 0, -1): print('*' + ' ' * i + '*') print('*')
#Translate account group IDS def translate_acc_grp_ids(grp_id, dest_acc_grps, src_acc_grps): if grp_id in [a_id['id'] for a_id in src_acc_grps]: src_group = [grp for grp in src_acc_grps if grp['id'] == grp_id][0] if src_group['name'] in [a_id['name'] for a_id in dest_acc_grps]: dst_group...
def translate_acc_grp_ids(grp_id, dest_acc_grps, src_acc_grps): if grp_id in [a_id['id'] for a_id in src_acc_grps]: src_group = [grp for grp in src_acc_grps if grp['id'] == grp_id][0] if src_group['name'] in [a_id['name'] for a_id in dest_acc_grps]: dst_group = [grp for grp in dest_acc_g...
class Tile: """ Intersections keeps track of a set of tuples that are the keys to the intersection dictionary Edges keeps track of a set of unique ids that are the keys to the edges dictionary adjacent_tile returns whether a given tile is adjacent to the current tile """ def __init__...
class Tile: """ Intersections keeps track of a set of tuples that are the keys to the intersection dictionary Edges keeps track of a set of unique ids that are the keys to the edges dictionary adjacent_tile returns whether a given tile is adjacent to the current tile """ def __init__...
class Solution: # @param {int} n an integer # @return {boolean} true if this is a happy number or false def isHappy(self, n): # Write your code here sum = n nums = {} while sum != 1: sum = self.cal_square_sum(sum) if sum in nums: return...
class Solution: def is_happy(self, n): sum = n nums = {} while sum != 1: sum = self.cal_square_sum(sum) if sum in nums: return False nums[sum] = 1 return True def cal_square_sum(self, n): sum = 0 while n > 0: ...
class Solution: def findDuplicate(self, nums: List[int]) -> int: if not nums: return -1 left, right = 1, len(nums) while left + 1 < right: mid = (left + right) // 2 count = 0 for num in nums: if num <= mid: ...
class Solution: def find_duplicate(self, nums: List[int]) -> int: if not nums: return -1 (left, right) = (1, len(nums)) while left + 1 < right: mid = (left + right) // 2 count = 0 for num in nums: if num <= mid: ...
A = [3,2,6,8,4,5,7,1] for j in range(1,len(A)): key = A[j] i = j - 1 while i >= 0 and A[i] > key: A[i+1] = A[i] i = i - 1 A[i + 1] = key print(A)
a = [3, 2, 6, 8, 4, 5, 7, 1] for j in range(1, len(A)): key = A[j] i = j - 1 while i >= 0 and A[i] > key: A[i + 1] = A[i] i = i - 1 A[i + 1] = key print(A)
class Solution: def longestLine(self, M: List[List[int]]) -> int: if len(M) == 0: return 0 rows, cols = len(M), len(M[0]) max_len = 0 @lru_cache(maxsize=None) def dfs(row, col, direction): subpath = 0 # directions: left, up, upleft, uprig...
class Solution: def longest_line(self, M: List[List[int]]) -> int: if len(M) == 0: return 0 (rows, cols) = (len(M), len(M[0])) max_len = 0 @lru_cache(maxsize=None) def dfs(row, col, direction): subpath = 0 (ro, co) = direction ...
class Bcolors: WHITE = "\033[97m" CYAN = "\033[96m" MAGENTA = "\033[95m" BLUE = "\033[94m" YELLOW = "\033[93m" GREEN = "\033[92m" RED = "\033[91m" GREY = "\033[90m" SOFTWHITE = "\033[37m" SOFTCYAN = "\033[36m" SOFTMAGENTA = "\033[35m" SOFTBLUE = "\033[34m" SOFTYELLOW ...
class Bcolors: white = '\x1b[97m' cyan = '\x1b[96m' magenta = '\x1b[95m' blue = '\x1b[94m' yellow = '\x1b[93m' green = '\x1b[92m' red = '\x1b[91m' grey = '\x1b[90m' softwhite = '\x1b[37m' softcyan = '\x1b[36m' softmagenta = '\x1b[35m' softblue = '\x1b[34m' softyellow ...
# https://leetcode.com/problems/binary-tree-maximum-path-sum/ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution(object): # Time O(n) | Space O(log(n)...
class Solution(object): def max_path_sum(self, root): """ :type root: TreeNode :rtype: int """ max_values = [float('-inf')] find_sum_path_as_branch(root, maxValues) return maxValues[0] def find_sum_path_as_branch(node, maxValues): if node is None: ...
class Solution(object): def singleNumber(self, nums): """ :type nums: List[int] :rtype: int """ seen = {} for num in nums: if num in seen: del seen[num] else: seen[num] = False for key in...
class Solution(object): def single_number(self, nums): """ :type nums: List[int] :rtype: int """ seen = {} for num in nums: if num in seen: del seen[num] else: seen[num] = False for key in seen.keys(): ...
MAX = 100 sum_even = 0 sum_odd = 0 for i in range(1, MAX+1): if i % 2 == 0: sum_even += i else: sum_odd += i print(f'Suma parzystych {sum_even}\nSuma nieparzystych {sum_odd}')
max = 100 sum_even = 0 sum_odd = 0 for i in range(1, MAX + 1): if i % 2 == 0: sum_even += i else: sum_odd += i print(f'Suma parzystych {sum_even}\nSuma nieparzystych {sum_odd}')
def precision(y_true, y_pred, average='micro'): true_entities = set([item for sublist in y_true for item in sublist]) pred_entities = set([item for sublist in y_pred for item in sublist]) nb_correct = len(true_entities & pred_entities) nb_pred = len(pred_entities) score = nb_correct / nb_pr...
def precision(y_true, y_pred, average='micro'): true_entities = set([item for sublist in y_true for item in sublist]) pred_entities = set([item for sublist in y_pred for item in sublist]) nb_correct = len(true_entities & pred_entities) nb_pred = len(pred_entities) score = nb_correct / nb_pred if nb_...
#Kunal Gautam #Codewars : @Kunalpod #Problem name: Simple Fun #6: Is Infinite Process? #Problem level: 7 kyu def is_infinite_process(a, b): if b<a: return True if (b-a)%2==1: return True return False
def is_infinite_process(a, b): if b < a: return True if (b - a) % 2 == 1: return True return False
class Solution: def maxProfit(self, prices): """ :type prices: List[int] :rtype: int """ if len(prices) == 0: return 0 else: max_profit = 0 for i, v in enumerate(prices[:-1]): if prices[i + 1] - prices[i] > 0: ...
class Solution: def max_profit(self, prices): """ :type prices: List[int] :rtype: int """ if len(prices) == 0: return 0 else: max_profit = 0 for (i, v) in enumerate(prices[:-1]): if prices[i + 1] - prices[i] > 0: ...
class RGBColor(object): def __init__(self, red, green=None, blue=None): self.red = red self.green = green if green is not None else red self.blue = blue if blue is not None else red def __repr__(self): return "#{:02x}{:02x}{:02x}".format(self.red, self.green, self.blue) def...
class Rgbcolor(object): def __init__(self, red, green=None, blue=None): self.red = red self.green = green if green is not None else red self.blue = blue if blue is not None else red def __repr__(self): return '#{:02x}{:02x}{:02x}'.format(self.red, self.green, self.blue) de...
# magicians = ['alica', 'david', 'carolina'] # for magicians in magicians: # print (magicians) # print (magicians.title() + ", the was a great trick! " ) # print ( "I can't wait to see you next trick, " + magicians.title() + ". \n") # print ("Thank you everyone, that was a great magic show!") for valu...
for value in range(1, 5): print(value) for value in range(1, 6): print(value) numbers = list(range(1, 6)) print(numbers) even_numbers = list(range(2, 11, 2)) print(even_numbers) squares = [] for value in range(1, 11): square = value ** 2 squares.append(square) print(squares) squares.append(value...
class Solution: def prisonAfterNDays(self, cells: List[int], N: int) -> List[int]: cur = [0]*8 firstDay = [] count = 0 while N>0: for i in range(1,7): if cells[i-1] == cells[i+1]: cur[i] = 1 else: cur...
class Solution: def prison_after_n_days(self, cells: List[int], N: int) -> List[int]: cur = [0] * 8 first_day = [] count = 0 while N > 0: for i in range(1, 7): if cells[i - 1] == cells[i + 1]: cur[i] = 1 else: ...