content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
class Solution: def lengthOfLongestSubstring(self, s: str) -> int: longest, current = "", "" for j in range(len(s)): i = current.find(s[j]) if i >= 0: current = current[i + 1:] current += s[j] if len(longest) < len(current): ...
class Solution: def length_of_longest_substring(self, s: str) -> int: (longest, current) = ('', '') for j in range(len(s)): i = current.find(s[j]) if i >= 0: current = current[i + 1:] current += s[j] if len(longest) < len(current): ...
''' .. _snippets-pythonapi-metadata: Python API: Managing Metadata ============================= This is the tested source code for the snippets used in :ref:`pythonapi-metadata`. The config file we're using in this example can be downloaded :download:`here <../../examples/snippets/resources/datafs_mongo.yml>`. Se...
""" .. _snippets-pythonapi-metadata: Python API: Managing Metadata ============================= This is the tested source code for the snippets used in :ref:`pythonapi-metadata`. The config file we're using in this example can be downloaded :download:`here <../../examples/snippets/resources/datafs_mongo.yml>`. Se...
# # PySNMP MIB module NV-ATKK-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NV-ATKK-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:25:52 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, 0...
(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, value_size_constraint) ...
# https://www.codewars.com/kata/521c2db8ddc89b9b7a0000c1/ ''' Instructions : Snail Sort Given an n x n array, return the array elements arranged from outermost elements to the middle element, traveling clockwise. array = [[1,2,3], [4,5,6], [7,8,9]] snail(array) #=> [1,2,3,6,9,8,7,4,5] For better u...
""" Instructions : Snail Sort Given an n x n array, return the array elements arranged from outermost elements to the middle element, traveling clockwise. array = [[1,2,3], [4,5,6], [7,8,9]] snail(array) #=> [1,2,3,6,9,8,7,4,5] For better understanding, please follow the numbers of the next array c...
command = '/home/slunk/code/racks_project/env/bin/gunicorn' pythonpath = '/home/slunk/code/racks_project/racks' bind = '127.0.0.1:8001' workers = 5 user = 'slunk' limit_request_fields = 32000 limit_request_field_size = 0 raw_enw = 'DJANGO_SETTINGS_MODULE=racks.settings'
command = '/home/slunk/code/racks_project/env/bin/gunicorn' pythonpath = '/home/slunk/code/racks_project/racks' bind = '127.0.0.1:8001' workers = 5 user = 'slunk' limit_request_fields = 32000 limit_request_field_size = 0 raw_enw = 'DJANGO_SETTINGS_MODULE=racks.settings'
power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate...
power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate Leakage': 0.00662954, 'Peak Dynamic': 0.0, 'Runtime Dynamic': 0.0, 'Subthres...
def calculate_max_profit(prices): '''Calculates the maximum profit given a list of prices of a stock by buying and selling exactly once. >>> calculate_max_profit([9, 11, 8, 5, 7, 10]) 5 >>> calculate_max_profit([10, 9, 8, 5, 2]) 0 ''' smallest_element_so_far = float('inf'...
def calculate_max_profit(prices): """Calculates the maximum profit given a list of prices of a stock by buying and selling exactly once. >>> calculate_max_profit([9, 11, 8, 5, 7, 10]) 5 >>> calculate_max_profit([10, 9, 8, 5, 2]) 0 """ smallest_element_so_far = float('inf'...
class FailedRequestingEcoCounterError(Exception): pass class PublishError(Exception): pass
class Failedrequestingecocountererror(Exception): pass class Publisherror(Exception): pass
fname = input('Enter file: ') try: fhandle = open(fname, 'r') except: print('No such file.') quit() hrs = dict() for line in fhandle: if not line.startswith('From '): continue tmp = line.find(':') hour = line[tmp-2:tmp] hrs[hour] = hrs.get(hour, 0) + 1 for (k, v) in sorted(hrs.it...
fname = input('Enter file: ') try: fhandle = open(fname, 'r') except: print('No such file.') quit() hrs = dict() for line in fhandle: if not line.startswith('From '): continue tmp = line.find(':') hour = line[tmp - 2:tmp] hrs[hour] = hrs.get(hour, 0) + 1 for (k, v) in sorted(hrs.item...
sides = {} data = input() while not data == "Lumpawaroo": keep_it = True idk = False if "|" in data: side, name = data.split(" | ") if side in sides: for person in sides[side]: if name in person: idk = True break ...
sides = {} data = input() while not data == 'Lumpawaroo': keep_it = True idk = False if '|' in data: (side, name) = data.split(' | ') if side in sides: for person in sides[side]: if name in person: idk = True break ...
class Customer: #function to update the details of the customer def __init__(self,name,email): self.name = name self.email = email self.purchases = [] #function to have a customer make a purchase def purchase(self,inventory, product): inventory_dict = inventory.i...
class Customer: def __init__(self, name, email): self.name = name self.email = email self.purchases = [] def purchase(self, inventory, product): inventory_dict = inventory.inventory if product in inventory_dict: if inventory_dict[product] > 1: ...
samples = [ { "input": { "array": [5, 1, 22, 25, 6, -1, 8, 10], }, "output": [1, 6, -1, 10], }, ]
samples = [{'input': {'array': [5, 1, 22, 25, 6, -1, 8, 10]}, 'output': [1, 6, -1, 10]}]
def doNothing(rawSolutions): #TODO - accept some sort of number QoI from somewhere number_qoi = 1 list_of_qoi = [] for _ in range(number_qoi): qoi_values = [] for raw_solution in rawSolutions: qoi_values.append(raw_solution) list_of_qoi.append(qoi_values) return...
def do_nothing(rawSolutions): number_qoi = 1 list_of_qoi = [] for _ in range(number_qoi): qoi_values = [] for raw_solution in rawSolutions: qoi_values.append(raw_solution) list_of_qoi.append(qoi_values) return list_of_qoi
class Plan: def __init__(self): self.tasks = [] def add_task(self, task): assert task.task_id is None self.tasks.append(task) def take_tasks(self): tasks = self.tasks self.tasks = [] return tasks
class Plan: def __init__(self): self.tasks = [] def add_task(self, task): assert task.task_id is None self.tasks.append(task) def take_tasks(self): tasks = self.tasks self.tasks = [] return tasks
# Program : Linear search in an array. # Input : size = 5, array = [1, 3, 5, 2, 4], target = 5 # Output : 2 # Explanation : The index of the element 5 is 2. # Language : Python3 # O(n) time | O(1) space def linear_search(size, array, target): # Do for each element in the array. for i in range(size): #...
def linear_search(size, array, target): for i in range(size): current_element = array[i] if current_element == target: return i return -1 if __name__ == '__main__': size = 5 array = [1, 3, 5, 2, 4] target = 5 answer = linear_search(size, array, target) print(answe...
def pego_correndo(speed, is_birthday): retorno = 0 if is_birthday == True: if speed <= 65: retorno = 0 elif 65 < speed <= 85 : retorno = 1 elif speed > 85 : retorno = 2 elif is_birthday == False: if speed <= 60 : retorno = 0 elif 60 < speed <= 80 : retorno = 1 elif speed > 80 : retorno ...
def pego_correndo(speed, is_birthday): retorno = 0 if is_birthday == True: if speed <= 65: retorno = 0 elif 65 < speed <= 85: retorno = 1 elif speed > 85: retorno = 2 elif is_birthday == False: if speed <= 60: retorno = 0 ...
class Solution: def checkInclusion(self, s1: str, s2: str) -> bool: s1_len = len(s1) s2_len = len(s2) flag = False for i,v in enumerate(s2): for k in s1: if k != v: flag = False break; else: ...
class Solution: def check_inclusion(self, s1: str, s2: str) -> bool: s1_len = len(s1) s2_len = len(s2) flag = False for (i, v) in enumerate(s2): for k in s1: if k != v: flag = False break else: ...
my_list = ["one", 2, "three"] print(my_list) print(type(my_list)) l = [] # an empty list
my_list = ['one', 2, 'three'] print(my_list) print(type(my_list)) l = []
class Solution: def minimumDeviation(self, nums: List[int]) -> int: # since heapq is a min-heap # we use negative of the numbers to mimic a max-heap evens = [] minimum = inf for num in nums: if num % 2 == 0: evens.append(-num) minim...
class Solution: def minimum_deviation(self, nums: List[int]) -> int: evens = [] minimum = inf for num in nums: if num % 2 == 0: evens.append(-num) minimum = min(minimum, num) else: evens.append(-num * 2) ...
# # PySNMP MIB module HPN-ICF-TE-TUNNEL-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-TE-TUNNEL-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:41:36 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (def...
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, constraints_intersection, value_range_constraint, single_value_constraint, value_size_constraint) ...
class Solution: def swapNodes(self, head: ListNode, k: int) -> ListNode: n1, n2, p = None, None, head while p: k -= 1 if n2: n2 = n2.next if k == 0: n1 = p n2 = head p = p.next n1.val, n2.val = n...
class Solution: def swap_nodes(self, head: ListNode, k: int) -> ListNode: (n1, n2, p) = (None, None, head) while p: k -= 1 if n2: n2 = n2.next if k == 0: n1 = p n2 = head p = p.next (n1.val, n2.v...
# # Define a generator # def test(): # print("phase one") # yield 5 # print("phase two") # yield 10 # # call and return the generator # gen=test() # # print(gen) #"only print the object of generator" # # work with for-loop # for data in gen: # print(data) def generateEven(maxNumber): number ...
def generate_even(maxNumber): number = 0 while number < maxNumber: yield number number += 2 even_generator = generate_even(10) for data in evenGenerator: print(data)
c, r = 'ABCDEFGH', '12345678' cell = input("Which chess square? ") cc, cr = c.index(cell[0]), r.index(cell[1]) print("black") if (int(cc)+int(cr)) % 2 == 0 else print("white")
(c, r) = ('ABCDEFGH', '12345678') cell = input('Which chess square? ') (cc, cr) = (c.index(cell[0]), r.index(cell[1])) print('black') if (int(cc) + int(cr)) % 2 == 0 else print('white')
#!/usr/bin/env python3 def encrypt(text, s): result = "" # transverse the plain text for i in range(len(text)): char = text[i] # Encrypt uppercase characters in plain text if (char.isupper()): result += chr((ord(char) + s-65) % 26 + 65) # Encrypt lowercase charac...
def encrypt(text, s): result = '' for i in range(len(text)): char = text[i] if char.isupper(): result += chr((ord(char) + s - 65) % 26 + 65) else: result += chr((ord(char) + s - 97) % 26 + 97) return result text = 'ATTACKATONCE' s = 4 print('Plain Text : ' + t...
# explicit conversion a="32" b=str(32) print(a+b) a=int(a) b=int(b) print(a+b) # python does not convert implicitly in these cases
a = '32' b = str(32) print(a + b) a = int(a) b = int(b) print(a + b)
def part_1(data): return sum(int(line) for line in data) def part_2(data): cumulative = 0 reached = {0} while True: for line in data: cumulative += int(line) if cumulative in reached: return cumulative reached.add(cumulative) if __name__ ==...
def part_1(data): return sum((int(line) for line in data)) def part_2(data): cumulative = 0 reached = {0} while True: for line in data: cumulative += int(line) if cumulative in reached: return cumulative reached.add(cumulative) if __name__ == ...
class Resistor: def __init__(self, p, R): self.type = 'R' self.p = p self.p1 = p.split('-')[0] self.p2 = p.split('-')[1] self.R = R self.Y = 1/R self.v = [] self.ic = [] def resolveInitialConditions(self): # self.v.append(0) # se...
class Resistor: def __init__(self, p, R): self.type = 'R' self.p = p self.p1 = p.split('-')[0] self.p2 = p.split('-')[1] self.R = R self.Y = 1 / R self.v = [] self.ic = [] def resolve_initial_conditions(self): pass def resolve_ih(sel...
def read_file(file_path): with open(file_path) as file: return file.read().split("|") def parser_list(questions): return [question.strip() for question in questions if question.strip()]
def read_file(file_path): with open(file_path) as file: return file.read().split('|') def parser_list(questions): return [question.strip() for question in questions if question.strip()]
def main(): phrase = input("Choose a phrase: ") # Write your code here main()
def main(): phrase = input('Choose a phrase: ') main()
COMPONENTS_BANNER_DOMESTIC = 'eu-exit-banner-domestic' COMPONENTS_BANNER_INTERNATIONAL = 'eu-exit-banner-international' EUEXIT_DOMESTIC_NEWS = 'eu-exit-news' EUEXIT_INTERNATIONAL_NEWS = 'international-eu-exit-news' EUEXIT_DOMESTIC_FORM = 'eu-exit-domestic' EUEXIT_FORM_SUCCESS = 'eu-exit-form-success' EUEXIT_INTERNATIO...
components_banner_domestic = 'eu-exit-banner-domestic' components_banner_international = 'eu-exit-banner-international' euexit_domestic_news = 'eu-exit-news' euexit_international_news = 'international-eu-exit-news' euexit_domestic_form = 'eu-exit-domestic' euexit_form_success = 'eu-exit-form-success' euexit_internation...
def extractFujitranslationWordpressCom(item): ''' Parser for 'fujitranslation.wordpress.com' ''' vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title']) if not (chp or vol) or "preview" in item['title'].lower(): return None tagmap = [ ('My Wife is a Martial Alliance Head', ...
def extract_fujitranslation_wordpress_com(item): """ Parser for 'fujitranslation.wordpress.com' """ (vol, chp, frag, postfix) = extract_vol_chapter_fragment_postfix(item['title']) if not (chp or vol) or 'preview' in item['title'].lower(): return None tagmap = [('My Wife is a Martial Alliance H...
class Solution: def subarraySum(self, nums: List[int], k: int) -> int: # We will construct an additional dictionary to keep the sum of # all the elements before the index, for example # given nums = [1, 4, 0, 3, 2] # the element sum list: sum_list = [0, 1, 5, 5, 8, 10] # Then...
class Solution: def subarray_sum(self, nums: List[int], k: int) -> int: sum_dict = {0: 1} count = s = 0 for n in nums: s += n count += sum_dict.get(s - k, 0) if s in sum_dict: sum_dict[s] += 1 else: sum_dict[s] ...
chars_to_remove = [',', '.', '!', ':', ';', '-', ' ', '?'] def get_longest_palendromes(text): if not text: return [] if len(text) <= 2: return [text] palendromes = [] for window_size in range(len(text), 1, -1): num_shifts = len(text) - window_size for start_index in range(0, num_shif...
chars_to_remove = [',', '.', '!', ':', ';', '-', ' ', '?'] def get_longest_palendromes(text): if not text: return [] if len(text) <= 2: return [text] palendromes = [] for window_size in range(len(text), 1, -1): num_shifts = len(text) - window_size for start_index in rang...
# %% ####################################### # THIS IS NOT THE SAME AS: my_pcap.getlayer(TCP) def scapyget_tcp(packet_list: scapy.plist.PacketList): result_list = [ pckt for pckt in packet_list if pckt.haslayer('TCP')] return PacketList(result_list)
def scapyget_tcp(packet_list: scapy.plist.PacketList): result_list = [pckt for pckt in packet_list if pckt.haslayer('TCP')] return packet_list(result_list)
# -*- coding: utf-8 -*- def formatter(name=None): def decorate(func): func._formatter = name return func return decorate
def formatter(name=None): def decorate(func): func._formatter = name return func return decorate
_UNSET = object() class PyErr: def __init__(self, type=_UNSET, value=_UNSET, traceback=_UNSET): if not(type is _UNSET): self.type = type if not(value is _UNSET): self.value = value if not(traceback is _UNSET): self.traceback = traceback
_unset = object() class Pyerr: def __init__(self, type=_UNSET, value=_UNSET, traceback=_UNSET): if not type is _UNSET: self.type = type if not value is _UNSET: self.value = value if not traceback is _UNSET: self.traceback = traceback
def repeat_string(string, times): return string * times text = input() number = int(input()) result = repeat_string(text, number) print(result)
def repeat_string(string, times): return string * times text = input() number = int(input()) result = repeat_string(text, number) print(result)
#Ask the user for a string and print out whether this string is a palindrome or not. # (A palindrome is a string that reads the same forwards and backwards.) str = input("Let's have a string, shall we?") palindrome = str[::-1]==str if palindrome: print(str,"is a palindrome") else: print(str, "is not a palindr...
str = input("Let's have a string, shall we?") palindrome = str[::-1] == str if palindrome: print(str, 'is a palindrome') else: print(str, 'is not a palindrome')
# Problem URL: https://leetcode.com/problems/reverse-integer/ class Solution: def reverse(self, x: int) -> int: # Handling Negative Input neg_flag = 0 if x<0: neg_flag = 1 string = [i for i in str(x)] if neg_flag == 1: string = string[1:] ...
class Solution: def reverse(self, x: int) -> int: neg_flag = 0 if x < 0: neg_flag = 1 string = [i for i in str(x)] if neg_flag == 1: string = string[1:] reversed_string = string[::-1] final_string = '' for i in reversed_string: ...
def binaryToDecimal(arr): arr = str(arr) arr = arr[::-1] length = len(arr)-1 if int(arr[length]) != 1: length -= 1 count = 0 for i in range(length,-1,-1): count += int(arr[i])*(2**i) return count def binaryToDecimal2(value): return int(str(value),2) def binaryToDeci...
def binary_to_decimal(arr): arr = str(arr) arr = arr[::-1] length = len(arr) - 1 if int(arr[length]) != 1: length -= 1 count = 0 for i in range(length, -1, -1): count += int(arr[i]) * 2 ** i return count def binary_to_decimal2(value): return int(str(value), 2) def binar...
print("********** BIENVENIDO AL MENU INTERACTIVO ********** ") print("Que opcion desea Seleccionar? ") print("1)Saludar") print("2)Sumar dos numeros") print("3)Salir del sistema") Opcion = int( input() ) while Opcion<=3: if (Opcion==1): nombre = input("Enter your name : ") print("Hola, mucho gusto...
print('********** BIENVENIDO AL MENU INTERACTIVO ********** ') print('Que opcion desea Seleccionar? ') print('1)Saludar') print('2)Sumar dos numeros') print('3)Salir del sistema') opcion = int(input()) while Opcion <= 3: if Opcion == 1: nombre = input('Enter your name : ') print('Hola, mucho gusto '...
def bicepup(): i01.setArmSpeed("right", 1.0, 1.0, 1.0, 1.0) i01.rightArm.bicep.attach() i01.rightArm.bicep.moveTo(180) sleep(1) i01.rightArm.bicep.detach()
def bicepup(): i01.setArmSpeed('right', 1.0, 1.0, 1.0, 1.0) i01.rightArm.bicep.attach() i01.rightArm.bicep.moveTo(180) sleep(1) i01.rightArm.bicep.detach()
class Car: def __init__(self, maker, model): carManufacturer = maker carModel = model carModel = "" carManufacturer = "" carYear = 0 def setModel(self, model): self.carModel = model def setManufacturer(self, manufacturer): self.carManufacturer = manufacturer...
class Car: def __init__(self, maker, model): car_manufacturer = maker car_model = model car_model = '' car_manufacturer = '' car_year = 0 def set_model(self, model): self.carModel = model def set_manufacturer(self, manufacturer): self.carManufacturer = manufact...
def hash_key(string): multiplication = 1 for i in string: multiplication *= ord(i) return (multiplication % 97) for i in range(int(input())): str1, str2 = input().split() str1_key = hash_key(str1) str2_key = hash_key(str2) if str1_key == str2_key: print("YES") else: ...
def hash_key(string): multiplication = 1 for i in string: multiplication *= ord(i) return multiplication % 97 for i in range(int(input())): (str1, str2) = input().split() str1_key = hash_key(str1) str2_key = hash_key(str2) if str1_key == str2_key: print('YES') else: ...
{ "targets": [{ "target_name": "opendkim", "sources": [ "src/opendkim_body_async.cc", "src/opendkim_chunk_async.cc", "src/opendkim_chunk_end_async.cc", "src/opendkim_eoh_async.cc", "src/opendkim_eom_async.cc", "src/opendkim_flus...
{'targets': [{'target_name': 'opendkim', 'sources': ['src/opendkim_body_async.cc', 'src/opendkim_chunk_async.cc', 'src/opendkim_chunk_end_async.cc', 'src/opendkim_eoh_async.cc', 'src/opendkim_eom_async.cc', 'src/opendkim_flush_cache_async.cc', 'src/opendkim_header_async.cc', 'src/opendkim_sign_async.cc', 'src/opendkim_...
# Objective # Today, we're delving into Inheritance. Check out the attached tutorial for learning materials and an instructional video. # Task # You are given two classes, Person and Student, where Person is the base class and Student is the derived class. Completed code for Person and a declaration for Student are pr...
class Person: def __init__(self, firstName, lastName, idNumber): self.firstName = firstName self.lastName = lastName self.idNumber = idNumber def print_person(self): print('Name:', self.lastName + ',', self.firstName) print('ID:', self.idNumber) class Student(Person): ...
class ChannelDoesNotExist(Exception): pass class LevelDoesNotExist(Exception): pass class HandlerError(Exception): pass
class Channeldoesnotexist(Exception): pass class Leveldoesnotexist(Exception): pass class Handlererror(Exception): pass
# -*- coding: utf-8 -*- ################################################ # # URL: # ===== # https://leetcode.com/problems/PROBLEM_TITLE/ # # DESC: # ===== # PROBLEM DESCRIPTION ################################################ class Solution: def method(self) -> int: return 0
class Solution: def method(self) -> int: return 0
# -*- coding: utf-8 -*- class _CommitOnSuccess(object): def __init__(self, session): self.session = session def __enter__(self): self.transaction = self.session.begin_nested() def __exit__(self, exc_type, exc_value, traceback): try: if exc_value is not None: ...
class _Commitonsuccess(object): def __init__(self, session): self.session = session def __enter__(self): self.transaction = self.session.begin_nested() def __exit__(self, exc_type, exc_value, traceback): try: if exc_value is not None: self.transaction.r...
# # PySNMP MIB module IEEE8021-EVB-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/IEEE8021-EVB-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:52:20 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar ...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, constraints_intersection, single_value_constraint, value_size_constraint, value_range_constraint) ...
c,b=map(int,input().split()) x=[*map(int,input().split())] oioi=set() ans=0 oioi.add(0) for i in x: tmp=[] for j in oioi: tmp.append(i+j) if i+j<=c: ans=max(ans,i+j) for j in tmp: oioi.add(j) print(ans)
(c, b) = map(int, input().split()) x = [*map(int, input().split())] oioi = set() ans = 0 oioi.add(0) for i in x: tmp = [] for j in oioi: tmp.append(i + j) if i + j <= c: ans = max(ans, i + j) for j in tmp: oioi.add(j) print(ans)
#!/usr/bin/env python NAME = 'Naxsi' def is_waf(self): # Sometimes naxsi waf returns 'x-data-origin: naxsi/waf' if self.matchheader(('X-Data-Origin', '^naxsi(.*)?')): return True # Found samples returning 'server: naxsi/2.0' if self.matchheader(('server', 'naxsi(.*)?')): return True for att...
name = 'Naxsi' def is_waf(self): if self.matchheader(('X-Data-Origin', '^naxsi(.*)?')): return True if self.matchheader(('server', 'naxsi(.*)?')): return True for attack in self.attacks: r = attack(self) if r is None: return (_, responsebody) = r ...
consumer_key = 'v5bb7HD9PmYTvXuCBgCwa44qZ' consumer_secret = 'tlONgznY4y9S0E4D9JkDVABGGT8ACVgOySt3CPpsKUxU9IE2RS' twitter_token = '2888299528-05kwbmRfd82mneeJg2EMGhcMXXlFci6yaBWjxCA' twitter_token_secret = 'h0WLEeq7PNkC1Rd56eyM1oxi1KL4S9sXP8kigYxEB527B'
consumer_key = 'v5bb7HD9PmYTvXuCBgCwa44qZ' consumer_secret = 'tlONgznY4y9S0E4D9JkDVABGGT8ACVgOySt3CPpsKUxU9IE2RS' twitter_token = '2888299528-05kwbmRfd82mneeJg2EMGhcMXXlFci6yaBWjxCA' twitter_token_secret = 'h0WLEeq7PNkC1Rd56eyM1oxi1KL4S9sXP8kigYxEB527B'
def ip_to_int32(ip): temp="" ip=ip.split(".") for i in ip: temp+="{0:08b}".format(int(i)) return int(temp,2)
def ip_to_int32(ip): temp = '' ip = ip.split('.') for i in ip: temp += '{0:08b}'.format(int(i)) return int(temp, 2)
array = [] with open('input-p22.txt') as f: array = f.readlines() array = array[0].split(',') array.sort() print(array) asciA = ord('A') print("ascii A:", asciA) answer = 0 for i in range(0, len(array)): sum = 0 for letter in array[i]: if letter == '"': continue print(letter, ...
array = [] with open('input-p22.txt') as f: array = f.readlines() array = array[0].split(',') array.sort() print(array) asci_a = ord('A') print('ascii A:', asciA) answer = 0 for i in range(0, len(array)): sum = 0 for letter in array[i]: if letter == '"': continue print(letter, or...
# Do not edit this file directly. # It was auto-generated by: code/programs/reflexivity/reflexive_refresh load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def bigIntegerCpp(): http_archive( name="big_integer_cpp" , build_file="//bazel/deps/big_integer_cpp:build.BUILD" , ...
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') def big_integer_cpp(): http_archive(name='big_integer_cpp', build_file='//bazel/deps/big_integer_cpp:build.BUILD', sha256='1c9505406accb1216947ca60299ed70726eade7c9458c7c7f94ca2aea68d288e', strip_prefix='BigIntegerCPP-79e7b023bf5157c0f8d308d3791c...
# Copyright 2018 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. DEPS = [ 'file', 'isolated', 'json', 'path', 'runtime', 'step', ] def RunSteps(api): # Inspect the associated isolated server. ...
deps = ['file', 'isolated', 'json', 'path', 'runtime', 'step'] def run_steps(api): api.isolated.isolate_server temp = api.path.mkdtemp('isolated-example') api.step('touch a', ['touch', temp.join('a')]) api.step('touch b', ['touch', temp.join('b')]) api.step('touch c', ['touch', temp.join('c')]) ...
#!-*- encoding=utf-8 class MegNoriBaseException(Exception): pass class NoAvaliableVolumeError(MegNoriBaseException): pass class PutFileException(MegNoriBaseException): pass class GetFileException(MegNoriBaseException): pass
class Megnoribaseexception(Exception): pass class Noavaliablevolumeerror(MegNoriBaseException): pass class Putfileexception(MegNoriBaseException): pass class Getfileexception(MegNoriBaseException): pass
{ 'target_defaults': { 'conditions': [ ['OS != "win"', { 'defines': [ '_GNU_SOURCE', ], 'conditions': [ ['OS=="solaris"', { 'cflags': ['-pthreads'], 'ldlags': ['-pthreads'], }, { 'cflags': ['-pthread'], 'ld...
{'target_defaults': {'conditions': [['OS != "win"', {'defines': ['_GNU_SOURCE'], 'conditions': [['OS=="solaris"', {'cflags': ['-pthreads'], 'ldlags': ['-pthreads']}, {'cflags': ['-pthread'], 'ldlags': ['-pthread']}]]}]]}, 'targets': [{'target_name': 'lring', 'type': '<(library)', 'include_dirs': ['include/', 'src/'], '...
# # PySNMP MIB module CHEETAH-TRAP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CHEETAH-TRAP-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:48:47 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar ...
(slb_cur_cfg_real_server_index, flt_cur_cfg_indx, slb_cur_cfg_virt_service_real_port, flt_cur_cfg_port_indx, slb_cur_cfg_real_server_name, slb_cur_cfg_real_server_ip_addr, flt_cur_cfg_src_ip) = mibBuilder.importSymbols('ALTEON-CHEETAH-LAYER4-MIB', 'slbCurCfgRealServerIndex', 'fltCurCfgIndx', 'slbCurCfgVirtServiceRealPo...
def imagecreate(): image = open("theimage.ppm", "w") image.write("P3\n") image.write("500 500\n") image.write("255\n\n") for i in range(500): curline = "" for j in range(500): if i > 250: i = 250 - (i % 250) if j > 250: j = 250 ...
def imagecreate(): image = open('theimage.ppm', 'w') image.write('P3\n') image.write('500 500\n') image.write('255\n\n') for i in range(500): curline = '' for j in range(500): if i > 250: i = 250 - i % 250 if j > 250: j = 250 - ...
def calculate_pi(n_terms: int) -> float: numerator: float = 4.0 denominator: float = 1.0 operation: float = 1.0 pi: float = 0.0 for _ in range(n_terms): pi += operation *(numerator/denominator) denominator += 2.0 operation *= -1.0 return pi if __name__ == "__main__": print(calculate_pi(100000)...
def calculate_pi(n_terms: int) -> float: numerator: float = 4.0 denominator: float = 1.0 operation: float = 1.0 pi: float = 0.0 for _ in range(n_terms): pi += operation * (numerator / denominator) denominator += 2.0 operation *= -1.0 return pi if __name__ == '__main__': ...
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def addTwoNumbers(self, l1, l2): # create a Answer node and mark it's start node StartAns = Answer = ListNode(0) carry = 0 ...
class Solution: def add_two_numbers(self, l1, l2): start_ans = answer = list_node(0) carry = 0 while l1 and l2: (carry, sumval) = divmod(l1.val + l2.val + carry, 10) Answer.next = list_node(sumval) l1 = l1.next l2 = l2.next answer ...
class Node: def __init__(self, data): self.data = data self.next = None self.prev = None def deleteNode(head_ref, del_): if (head_ref == None or del_ == None): return if (head_ref == del_): head_ref = del_.next if (del_.next != None): del_.next.prev = del_.prev if (del_.prev != None): del_.prev.next...
class Node: def __init__(self, data): self.data = data self.next = None self.prev = None def delete_node(head_ref, del_): if head_ref == None or del_ == None: return if head_ref == del_: head_ref = del_.next if del_.next != None: del_.next.prev = del_.pr...
class Endereco: def __init__(self, rua="", bairro="", numero="", cidade="", estado="", cep=""): self.rua = rua self.bairro = bairro self.numero = numero self.cidade = cidade self.estado = estado self.cep = cep
class Endereco: def __init__(self, rua='', bairro='', numero='', cidade='', estado='', cep=''): self.rua = rua self.bairro = bairro self.numero = numero self.cidade = cidade self.estado = estado self.cep = cep
input = open('input', 'r').read().strip() input = [list(map(int, r)) for r in input.splitlines()] h, w = len(input), len(input[0]) def neighbours(x, y): return [(p, q) for u in range(-1, 2) for v in range(-1, 2) if 0 <= (p := x+u) < h and 0 <= (q := y+v) < w] def step(m): m = [[n+1 for n in r] ...
input = open('input', 'r').read().strip() input = [list(map(int, r)) for r in input.splitlines()] (h, w) = (len(input), len(input[0])) def neighbours(x, y): return [(p, q) for u in range(-1, 2) for v in range(-1, 2) if 0 <= (p := (x + u)) < h and 0 <= (q := (y + v)) < w] def step(m): m = [[n + 1 for n in r] f...
''' Automatically set `current_app` into context based on URL namespace. ''' def namespaced(request): ''' Set `current_app` to url namespace ''' request.current_app = request.resolver_match.namespace return {}
""" Automatically set `current_app` into context based on URL namespace. """ def namespaced(request): """ Set `current_app` to url namespace """ request.current_app = request.resolver_match.namespace return {}
#!/usr/bin/env python class AssembleError(Exception): def __init__(self, line_no, reason): message = '%d: %s' % (line_no, reason) super(AssembleError, self).__init__(message)
class Assembleerror(Exception): def __init__(self, line_no, reason): message = '%d: %s' % (line_no, reason) super(AssembleError, self).__init__(message)
#Boolean is a Data Type in Python which has 2 values - True and False print (bool(0)) #Python will return False print (bool(1)) #Python will return True print (bool(1.5)) #Pyton will return True print (bool(None)) #Python will return False print (bool('')) #Python will return False
print(bool(0)) print(bool(1)) print(bool(1.5)) print(bool(None)) print(bool(''))
n = int(input()) count = 0 for i in range(1, n + 1): if i < 100: count += 1 else: s = str(i) if int(s[1]) - int(s[0]) == int(s[2]) - int(s[1]): count += 1 print(count)
n = int(input()) count = 0 for i in range(1, n + 1): if i < 100: count += 1 else: s = str(i) if int(s[1]) - int(s[0]) == int(s[2]) - int(s[1]): count += 1 print(count)
l1 = list(range(10)) new_list = [x*x + 2*x + 1 for x in l1] print(l1) print(new_list)
l1 = list(range(10)) new_list = [x * x + 2 * x + 1 for x in l1] print(l1) print(new_list)
# md5 : 2cdb8e874f0950ea17a7135427b4f07d # sha1 : 73b16f132eb0247ea124b6243ca4109f179e564c # sha256 : 099b17422e1df0235e024ff5128a60571e72af451e1c59f4d61d3cf32c1539ed ord_names = { 3: b'mciExecute', 4: b'CloseDriver', 5: b'DefDriverProc', 6: b'DriverCallback', 7: b'DrvGetModuleHandle', 8: b'Get...
ord_names = {3: b'mciExecute', 4: b'CloseDriver', 5: b'DefDriverProc', 6: b'DriverCallback', 7: b'DrvGetModuleHandle', 8: b'GetDriverModuleHandle', 9: b'NotifyCallbackData', 10: b'OpenDriver', 11: b'PlaySound', 12: b'PlaySoundA', 13: b'PlaySoundW', 14: b'SendDriverMessage', 15: b'WOW32DriverCallback', 16: b'WOW32Resolv...
dados = int(input()) pontos = input() pontos = pontos.split(' ') luisa = 0 antonio = 0 pessoa = 0 for vez in pontos: pessoa += 1 if pessoa == 3: pessoa = 1 if pessoa == 1: luisa += int(vez) elif pessoa == 2: antonio += int(vez) if int(vez) == 6 and pessoa == 1: pe...
dados = int(input()) pontos = input() pontos = pontos.split(' ') luisa = 0 antonio = 0 pessoa = 0 for vez in pontos: pessoa += 1 if pessoa == 3: pessoa = 1 if pessoa == 1: luisa += int(vez) elif pessoa == 2: antonio += int(vez) if int(vez) == 6 and pessoa == 1: pessoa...
def getCountLetterString(input): # get range space_index = input.find(" ") range = input[0:space_index] hyphen_index = input.find("-") start = range[0:hyphen_index] end = range[hyphen_index + 1:] # get letter colon_index = input.find(":") letter = input[space_index + 1:colon_index] ...
def get_count_letter_string(input): space_index = input.find(' ') range = input[0:space_index] hyphen_index = input.find('-') start = range[0:hyphen_index] end = range[hyphen_index + 1:] colon_index = input.find(':') letter = input[space_index + 1:colon_index] password = input[colon_inde...
_base_ = [ '../_base_/models/retinanet_r50_fpn.py', '../_base_/datasets/own_data.py', '../_base_/schedules/schedule_1x_own_data.py', '../_base_/default_runtime.py' ] # optimizer optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) load_from = 'https://download.openmmlab.com/mmdetection/...
_base_ = ['../_base_/models/retinanet_r50_fpn.py', '../_base_/datasets/own_data.py', '../_base_/schedules/schedule_1x_own_data.py', '../_base_/default_runtime.py'] optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) load_from = 'https://download.openmmlab.com/mmdetection/v2.0/retinanet/retinanet_r5...
# https://leetcode.com/problems/number-of-digit-one/ class Solution: def countDigitOne(self, n: int) -> int: result = threshold = 0 divisor = limit = 10 while n // limit > 0: limit *= 10 while divisor <= limit: div, mod = divmod(n, divisor) result...
class Solution: def count_digit_one(self, n: int) -> int: result = threshold = 0 divisor = limit = 10 while n // limit > 0: limit *= 10 while divisor <= limit: (div, mod) = divmod(n, divisor) result += div * (divisor // 10) if mod > th...
height = float(input("enter your height in m: ")) weight = float(input("enter your weight in kg: ")) bmi = weight/(height**2) if bmi <= 18.5 : print(f"you bmi is {bmi}, you are underweight") elif bmi <=25 : print(f"you bmi is {bmi}you have a normal weight") elif bmi <= 30 : print(f"you bmi is {bmi...
height = float(input('enter your height in m: ')) weight = float(input('enter your weight in kg: ')) bmi = weight / height ** 2 if bmi <= 18.5: print(f'you bmi is {bmi}, you are underweight') elif bmi <= 25: print(f'you bmi is {bmi}you have a normal weight') elif bmi <= 30: print(f'you bmi is {bmi}you are s...
n, k = map(int,input().split()) cnt = 0 prime = [True]*(n+1) for i in range(2,n+1,1): if prime[i] == False: continue for j in range(i,n+1,i): if prime[j] == True: prime[j] = False;cnt+=1 if cnt == k: print(j);break
(n, k) = map(int, input().split()) cnt = 0 prime = [True] * (n + 1) for i in range(2, n + 1, 1): if prime[i] == False: continue for j in range(i, n + 1, i): if prime[j] == True: prime[j] = False cnt += 1 if cnt == k: print(j) break
def sum_iter(numbers): total = 0 for n in numbers: total = total + n return total def sum_rec(numbers): if len(numbers) == 0: return 0 return numbers[0] + sum_rec(numbers[1:])
def sum_iter(numbers): total = 0 for n in numbers: total = total + n return total def sum_rec(numbers): if len(numbers) == 0: return 0 return numbers[0] + sum_rec(numbers[1:])
with open('data.txt') as f: data = f.readlines() data = [int(i.rstrip()) for i in data] incr = 0 for idx, val in enumerate(data): if idx == 0: print(data[0]) continue if data[idx-1] < data[idx]: incr += 1 print(f"{data[idx]} increase") else: print(f"{data[idx]}"...
with open('data.txt') as f: data = f.readlines() data = [int(i.rstrip()) for i in data] incr = 0 for (idx, val) in enumerate(data): if idx == 0: print(data[0]) continue if data[idx - 1] < data[idx]: incr += 1 print(f'{data[idx]} increase') else: print(f'{data[idx]...
#!/usr/bin/python3 def this_fails(): x = 1/0 try: this_fails() except ZeroDivisionError as err: print('Handling run-time error: ', err)
def this_fails(): x = 1 / 0 try: this_fails() except ZeroDivisionError as err: print('Handling run-time error: ', err)
class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def mergeTrees(self, t1, t2): def recurse(a1, a2): if a1 == None: return a2 if a2 == None: return a1 ...
class Treenode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def merge_trees(self, t1, t2): def recurse(a1, a2): if a1 == None: return a2 if a2 == None: return a1 ...
# -*- coding: utf-8 -*- class Config(object): DEBUG = False TESTING = False DATABASE_URI = ('postgresql+psycopg2://' 'taxo:taxo@localhost:5432/taxonwiki') ASSETS_DEBUG = False ASSETS_CACHE = True ASSETS_MANIFEST = 'json' UGLIFYJS_EXTRA_ARGS = ['--compress', '--mangle'] ...
class Config(object): debug = False testing = False database_uri = 'postgresql+psycopg2://taxo:taxo@localhost:5432/taxonwiki' assets_debug = False assets_cache = True assets_manifest = 'json' uglifyjs_extra_args = ['--compress', '--mangle'] compass_config = {'output_style': ':compressed'...
buttons_dict = {1: [r"$|a|$", "abs"], 2: [r"$\sqrt{a}$", "sqrt"], 3: [r"$\log$", "log"], 4: [r"$\ln$", "ln"], 5: [r"$a^b$", "power"], 6: [r"$()$", "brackets"], 7: [r"%", "percent"], 8: [r"$=$", "equals"], 9: [r"$\lfloor{a}\rfloor$", "floor"], 10: [r"$f(x)$", "...
buttons_dict = {1: ['$|a|$', 'abs'], 2: ['$\\sqrt{a}$', 'sqrt'], 3: ['$\\log$', 'log'], 4: ['$\\ln$', 'ln'], 5: ['$a^b$', 'power'], 6: ['$()$', 'brackets'], 7: ['%', 'percent'], 8: ['$=$', 'equals'], 9: ['$\\lfloor{a}\\rfloor$', 'floor'], 10: ['$f(x)$', 'func'], 11: ['$\\cot$', 'cot'], 12: ['$\\tan$', 'tan'], 13: ['$7$...
default_ingredient_list = ['lentils', 'kale', 'shallots', 'swiss cheese', 'anchovies', 'Quiche', 'cashew nut', 'Waffles', 'chicken liver', 'parsley', 'babaganoosh', 'Toast', 'bouillon', 'hamburger', 'hoisin sauce', 'chaurice sausage', 'fennel', 'curry', 'clams', '...
default_ingredient_list = ['lentils', 'kale', 'shallots', 'swiss cheese', 'anchovies', 'Quiche', 'cashew nut', 'Waffles', 'chicken liver', 'parsley', 'babaganoosh', 'Toast', 'bouillon', 'hamburger', 'hoisin sauce', 'chaurice sausage', 'fennel', 'curry', 'clams', 'spaghetti squash', 'haiku roll', 'ancho chili peppers', ...
# coding:utf-8 # example 04: double_linked_list.py class Node(object): def __init__(self, val=None): self.val = val self.prev = None self.next = None class DoubleLinkedList(object): def __init__(self, maxsize=None): self.maxsize = maxsize self.root = Node() sel...
class Node(object): def __init__(self, val=None): self.val = val self.prev = None self.next = None class Doublelinkedlist(object): def __init__(self, maxsize=None): self.maxsize = maxsize self.root = node() self.tailnode = None self.length = 0 def ...
def trinomial(cfg,i,j,k) : #function t=trinomial(i,j,k) #% Computes the trinomial of #% the three input arguments ...
def trinomial(cfg, i, j, k): aux_1 = cfg.factorial(i + j + k) aux_2 = cfg.factorial(i) * cfg.factorial(j) * cfg.factorial(k) t = aux_1 / aux_2 return t
# -*- coding: utf-8 -*- name = 'tbb' version = '2017.0' def commands(): appendenv('LD_LIBRARY_PATH', '{root}/lib/intel64/gcc4.7') env.TBBROOT.set('{root}') env.TBB_LIBRARIES.set('{root}/lib/intel64/gcc4.7') env.TBB_INCLUDE_DIR.set('{root}/include')
name = 'tbb' version = '2017.0' def commands(): appendenv('LD_LIBRARY_PATH', '{root}/lib/intel64/gcc4.7') env.TBBROOT.set('{root}') env.TBB_LIBRARIES.set('{root}/lib/intel64/gcc4.7') env.TBB_INCLUDE_DIR.set('{root}/include')
budget = float(input()) season = input() if budget <= 100: destination = 'Bulgaria' money_spent = budget * 0.7 info = f'Hotel - {money_spent:.2f}' if season == 'summer': money_spent = budget * 0.3 info = f'Camp - {money_spent:.2f}' elif budget <= 1000: destination = 'Balkans' mon...
budget = float(input()) season = input() if budget <= 100: destination = 'Bulgaria' money_spent = budget * 0.7 info = f'Hotel - {money_spent:.2f}' if season == 'summer': money_spent = budget * 0.3 info = f'Camp - {money_spent:.2f}' elif budget <= 1000: destination = 'Balkans' mon...
def solution(movements): horizontal, vertical = 0, 0 for move in movements: direction, magnitude = move.split(' ') if direction == "forward": horizontal += int(magnitude) elif direction == "down": vertical += int(magnitude) elif direction == "up": ...
def solution(movements): (horizontal, vertical) = (0, 0) for move in movements: (direction, magnitude) = move.split(' ') if direction == 'forward': horizontal += int(magnitude) elif direction == 'down': vertical += int(magnitude) elif direction == 'up': ...
class Solution: def combine(self, n: int, k: int) -> List[List[int]]: if k <= 0 or n < k: return [] res_lst = [] def dfs(i, curr_lst): if len(curr_lst) == k: res_lst.append(curr_lst) for value in range(i, n+1): dfs(value+1,...
class Solution: def combine(self, n: int, k: int) -> List[List[int]]: if k <= 0 or n < k: return [] res_lst = [] def dfs(i, curr_lst): if len(curr_lst) == k: res_lst.append(curr_lst) for value in range(i, n + 1): dfs(value...
# -*- coding: utf-8 -*- __version__ = "0.2.4" __title__ = "pygcgen" __summary__ = "Automatic changelog generation" __uri__ = "https://github.com/topic2k/pygcgen" __author__ = "topic2k" __email__ = "topic2k+pypi@gmail.com" __license__ = "MIT" __copyright__ = "2016-2018 %s" % __author__
__version__ = '0.2.4' __title__ = 'pygcgen' __summary__ = 'Automatic changelog generation' __uri__ = 'https://github.com/topic2k/pygcgen' __author__ = 'topic2k' __email__ = 'topic2k+pypi@gmail.com' __license__ = 'MIT' __copyright__ = '2016-2018 %s' % __author__
class GraphEdgesMapping: def __init__(self, first_dual_edges_mapping, second_dual_edges_mapping): self._first = first_dual_edges_mapping self._second = second_dual_edges_mapping @property def size(self): return self._first.shape[0] @property def first(self): ret...
class Graphedgesmapping: def __init__(self, first_dual_edges_mapping, second_dual_edges_mapping): self._first = first_dual_edges_mapping self._second = second_dual_edges_mapping @property def size(self): return self._first.shape[0] @property def first(self): return...
#!/usr/bin/env python3 data = open("in").read().split("\n\n") data = list(map(lambda x: x.split("\n"), data)) for i in range(len(data)): # todo this is stupid data[i] = list(filter(lambda x: x != '', data[i])) tot = 0 tot2 = 0 for d in data: a = set("".join(d)) tot += len(a) tota = 0 for q in a: ...
data = open('in').read().split('\n\n') data = list(map(lambda x: x.split('\n'), data)) for i in range(len(data)): data[i] = list(filter(lambda x: x != '', data[i])) tot = 0 tot2 = 0 for d in data: a = set(''.join(d)) tot += len(a) tota = 0 for q in a: if len(d) == len(list(filter(lambda x: x...
#operate with params OP_PARAMS_PATH = "/data/params/" def save_bool_param(param_name,param_value): try: real_param_value = 1 if param_value else 0 with open(OP_PARAMS_PATH+"/"+param_name, "w") as outfile: outfile.write(f'{real_param_value}') except IOError: print("Failed t...
op_params_path = '/data/params/' def save_bool_param(param_name, param_value): try: real_param_value = 1 if param_value else 0 with open(OP_PARAMS_PATH + '/' + param_name, 'w') as outfile: outfile.write(f'{real_param_value}') except IOError: print('Failed to save ' + param_n...
# Hello! World! print("Hello, World!") # Learning Strings my_string = "This is a string" ## Make string uppercase my_string_upper = my_string.upper() print(my_string_upper) # Determine data type of string print(type(my_string)) # Slicing strings [python is zero-based and starts at 0 and not 1] print(my_string[0:4]) pri...
print('Hello, World!') my_string = 'This is a string' my_string_upper = my_string.upper() print(my_string_upper) print(type(my_string)) print(my_string[0:4]) print(my_string[:1]) print(my_string[0:14])
class Solution: def combinationSum2(self, candidates: List[int], target: int) -> List[List[int]]: self.ret = [] self.counts = collections.Counter(candidates) nums = [k for k in set(sorted(candidates))] self.Backtrack(nums, target, [], 0) return self.ret def Backtrack(sel...
class Solution: def combination_sum2(self, candidates: List[int], target: int) -> List[List[int]]: self.ret = [] self.counts = collections.Counter(candidates) nums = [k for k in set(sorted(candidates))] self.Backtrack(nums, target, [], 0) return self.ret def backtrack(s...
# Function that detects cycle in a directed graph def cycleCheck(vertices, adj): visited = set() ancestor = set() for vertex in range(vertices): if vertex not in visited: if dfs(vertex, adj, visited, ancestor)==True: return True return False # Recursive dfs funct...
def cycle_check(vertices, adj): visited = set() ancestor = set() for vertex in range(vertices): if vertex not in visited: if dfs(vertex, adj, visited, ancestor) == True: return True return False def dfs(vertex, adj, visited, ancestor): visited.add(vertex) anc...
class Config(object): SECRET_KEY = "CantStopAddictedToTheShinDigChopTopHeSaysImGonnaWinBig" HOST = "0a398d5f.ngrok.io" SHOPIFY_CONFIG = { 'API_KEY': '<API KEY HERE>', 'API_SECRET': '<API SECRET HERE>', 'APP_HOME': 'http://' + HOST, 'CALLBACK_URL': 'http://' + HOST + '/insta...
class Config(object): secret_key = 'CantStopAddictedToTheShinDigChopTopHeSaysImGonnaWinBig' host = '0a398d5f.ngrok.io' shopify_config = {'API_KEY': '<API KEY HERE>', 'API_SECRET': '<API SECRET HERE>', 'APP_HOME': 'http://' + HOST, 'CALLBACK_URL': 'http://' + HOST + '/install', 'REDIRECT_URI': 'http://' + HO...
#!/usr/bin/python # -*- coding: utf-8 -*- __version__ = "3.0.0" __author__ = "Amir Zeldes" __copyright__ = "Copyright 2015-2019, Amir Zeldes" __license__ = "Apache 2.0 License"
__version__ = '3.0.0' __author__ = 'Amir Zeldes' __copyright__ = 'Copyright 2015-2019, Amir Zeldes' __license__ = 'Apache 2.0 License'