content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
x = list(input("Input String: ")) x = x [::-1] j = 0 def reverseword(x): i = 0 print(int) while i !=int(len(x)/2): temp = x[i] x[i] = x[len(x)-1-i] x[len(x)-1-i] = temp i+=1 return str(x) print(reverseword(x))
x = list(input('Input String: ')) x = x[::-1] j = 0 def reverseword(x): i = 0 print(int) while i != int(len(x) / 2): temp = x[i] x[i] = x[len(x) - 1 - i] x[len(x) - 1 - i] = temp i += 1 return str(x) print(reverseword(x))
platforms = { "UA": "usaco.org", "CC": "codechef.com", "EOL":"e-olimp.com", "CH24": "ch24.org", "HR": "hackerrank.com", "HE": "hackerearth.com", "ICPC": "icfpcontest.org", "GCJ": "google.com/codejam", "DE24": "deadline24.pl", "IOI": "stats.ioinformatics.org", "PE": "projecteuler.net", "SN...
platforms = {'UA': 'usaco.org', 'CC': 'codechef.com', 'EOL': 'e-olimp.com', 'CH24': 'ch24.org', 'HR': 'hackerrank.com', 'HE': 'hackerearth.com', 'ICPC': 'icfpcontest.org', 'GCJ': 'google.com/codejam', 'DE24': 'deadline24.pl', 'IOI': 'stats.ioinformatics.org', 'PE': 'projecteuler.net', 'SN': 'contests.snarknews.info', '...
class SimpleGroupProvider(object): def __init__(self, *group_names): self.group_names = group_names def get_group_names(self): return self.group_names
class Simplegroupprovider(object): def __init__(self, *group_names): self.group_names = group_names def get_group_names(self): return self.group_names
input_number = input ("Give me number if even or odd") converted_input = int (input_number) print(converted_input) if converted_input % 2 == 0: print("even number") else: print ("odd number")
input_number = input('Give me number if even or odd') converted_input = int(input_number) print(converted_input) if converted_input % 2 == 0: print('even number') else: print('odd number')
class NodeChilds(object): def __init__(self, nodes): self.nodes = nodes self.isArray = type(nodes) == list self.isObject = type(nodes) == dict def add(self, child): if self.isArray: self.node.append(child) elif self.isObject: self.node[child.ke...
class Nodechilds(object): def __init__(self, nodes): self.nodes = nodes self.isArray = type(nodes) == list self.isObject = type(nodes) == dict def add(self, child): if self.isArray: self.node.append(child) elif self.isObject: self.node[child.key]...
# Circular primes # https://projecteuler.net/problem=35 prime = [True for i in range(1000010)] prime[0] = prime[1] = False p = 2 while p <= 1000000: if prime[p]: for i in range(p * 2, 1000001, p): prime[i] = False p += 1 circ = [] for i in range(2, 1000000): if prime[i]: temp = ...
prime = [True for i in range(1000010)] prime[0] = prime[1] = False p = 2 while p <= 1000000: if prime[p]: for i in range(p * 2, 1000001, p): prime[i] = False p += 1 circ = [] for i in range(2, 1000000): if prime[i]: temp = i digits = len(str(i)) for j in range(dig...
# -*- coding: utf-8 -*- # Quaternary ligand binding to aromatic residues in the active-site gorge of acetylcholinesterase. # Harel, M., Schalk, I., Ehret-Sabatier, L., Bouet, F., Goeldner, M., Hirth, C., Axelsen, # P.H., Silman, I., Sussman, J.L. (1993) Proc.Natl.Acad.Sci.USA 90: 9031-9035 reference_1acj = { 'pdb...
reference_1acj = {'pdb_id': '1acj', 'ligand': 999, 'rings': [(5195, 5196, 5198, 5201, 5200, 5199), (5195, 5196, 5194, 5197, 5190, 5191), (5190, 5191, 5192, 5193, 5188, 5189)], 'neighbours': [72, 80, 81, 84, 85, 117, 118, 119, 121, 122, 130, 199, 200, 201, 330, 334, 432, 436, 439, 440, 441, 442, 444], 'hydrophobic': [84...
name='trie' def get_line(in_f,num=1): line = in_f.readline() obj = line.split(' ') if len(obj) != num and -1 != num: print('ERROR') for i in range(len(obj)): obj[i] = int(obj[i]) return obj def check_in_file(in_f): T = int(in_f.readline()) maxn = 0 MaxQc = 0 Is = True Maxdep = 0 for xx in range(T): #p...
name = 'trie' def get_line(in_f, num=1): line = in_f.readline() obj = line.split(' ') if len(obj) != num and -1 != num: print('ERROR') for i in range(len(obj)): obj[i] = int(obj[i]) return obj def check_in_file(in_f): t = int(in_f.readline()) maxn = 0 max_qc = 0 is ...
class InputOutputLabel(): def __init__(self): self.inputs = None self.outputs = None self.labels = None def update(self, inputs, outputs, labels): self.inputs = inputs self.outputs = outputs self.labels = labels
class Inputoutputlabel: def __init__(self): self.inputs = None self.outputs = None self.labels = None def update(self, inputs, outputs, labels): self.inputs = inputs self.outputs = outputs self.labels = labels
# Runtime: 280 ms, faster than 70.79% of Python3 online submissions for Sort an Array. # Memory Usage: 19.7 MB, less than 57.14% of Python3 online submissions for Sort an Array. class Solution: def sortArray(self, nums: List[int]) -> List[int]: # merge sort: avg, worst, best time = O(nlogn), space = O(n) ...
class Solution: def sort_array(self, nums: List[int]) -> List[int]: def mergesort(left, right, nums): if left < right: mid = (left + right) // 2 mergesort(left, mid, nums) mergesort(mid + 1, right, nums) nums[left:right + 1] = mer...
#// The format of this file is descriped in api_kernel32.idc #///func=RtlGetLastWin32Error entry=bochsys._BxWin32GetLastError@0 #///func=RtlSetLastWin32Error entry=bochsys._BxWin32SetLastError@4 #///func=NtSetLdtEntries purge=24 #///func=RtlAllocateHeap entry=nt_HeapAlloc def nt_HeapAlloc(): # Redirect HeapAlloc ->...
def nt__heap_alloc(): cpu.eax = bochs_virt_alloc(0, bochs_get_param(3), 1) return 0 def nt__encode_pointer(): cpu.eax = bochs_get_param(1) ^ 287454020 return 0 def nt__decode_pointer(): cpu.eax = bochs_get_param(1) ^ 287454020 return 0
def get_keywords(tweets_features): query = tweets_features['search_metadata']['query'] keywords = query.split(' -filter')[0].split(' OR ') return keywords
def get_keywords(tweets_features): query = tweets_features['search_metadata']['query'] keywords = query.split(' -filter')[0].split(' OR ') return keywords
# if-else if True: print("True execute") else: print("False execute") x = input("Please enter a number: ") # Get a number from user input x = int(x) # convert the number to integer if x > 200: print("Greater than 200") elif x > 100: print("Greater than 100, Less than 100") else: print("Less than...
if True: print('True execute') else: print('False execute') x = input('Please enter a number: ') x = int(x) if x > 200: print('Greater than 200') elif x > 100: print('Greater than 100, Less than 100') else: print('Less than 100') number1 = int(input('Enter the first number: ')) number2 = int(input('...
#!/usr/bin/env python3 expsz = 4 # number of bits in the exponent wordsz = 8 # number of bits in the word # no config below # how many bits in the mantissa mansz = wordsz - 2 - expsz # please ensure mansz >= 1 # print bits allocation print(f"{wordsz}b allocation: [1b sign] [{mansz}b mantissa] "\ f"[1b e...
expsz = 4 wordsz = 8 mansz = wordsz - 2 - expsz print(f'{wordsz}b allocation: [1b sign] [{mansz}b mantissa] [1b exp sign] [{expsz}b exponent]\n') maxman = (1 << mansz) - 1 manval = 1 + maxman / (1 << mansz) print(f'max mantissa = 1.{maxman:b}b -> {manval:f}') maxexp = (1 << expsz) - 1 expval = 2 ** maxexp print(f'max e...
def main(): message = input('Message: ') alphabet = 'abcdefghijklkmnopqrstuvwxyz' letters = alphabet.split(sep='')
def main(): message = input('Message: ') alphabet = 'abcdefghijklkmnopqrstuvwxyz' letters = alphabet.split(sep='')
# # SOFTWARE HISTORY # # Date Ticket# Engineer Description # ------------ ---------- ----------- -------------------------- # 2015-02-27 4174 nabowle Output full stacktrace. # 2018-10-05 mjames@ucar Fix returned retVal encoding. ...
class Serializableexceptionwrapper(object): def __init__(self): self.stackTrace = None self.message = None self.exceptionClass = None self.wrapper = None def __str__(self): return self.__repr__() def __repr__(self): if not self.message: self.mes...
# # PySNMP MIB module VCP-PRIVATE-MIB-VER-2 (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/VCP-PRIVATE-MIB-VER-2 # Produced by pysmi-0.3.4 at Mon Apr 29 21:26:27 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (def...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, value_size_constraint, constraints_union, constraints_intersection) ...
frase = ('O rato roeu a roupa do rei') letra = ('r') contador = 0 for valor in frase: if valor == letra: contador = contador + 1 print(f'A letra {letra} apareceu {contador} vezes na frase')
frase = 'O rato roeu a roupa do rei' letra = 'r' contador = 0 for valor in frase: if valor == letra: contador = contador + 1 print(f'A letra {letra} apareceu {contador} vezes na frase')
# encoding: utf-8 __author__ = 'lianggao' __date__ = '2019/5/29 10:44 AM' def javpop_url(time): yield 'http://javpop.com/' + time[:4] + '/' + time[4:6] + '/' + time[-2:]
__author__ = 'lianggao' __date__ = '2019/5/29 10:44 AM' def javpop_url(time): yield ('http://javpop.com/' + time[:4] + '/' + time[4:6] + '/' + time[-2:])
# this file was automatically generated major = 1 minor = 4 release = '20130410193624' version = '%d.%d-%s' % (major, minor, release)
major = 1 minor = 4 release = '20130410193624' version = '%d.%d-%s' % (major, minor, release)
a = input ('Put the number a: \n') b= input ('Put the number b: \n') a,b=b,a print(f'Resalt a: {a}') print(f'Resalt b: {b}')
a = input('Put the number a: \n') b = input('Put the number b: \n') (a, b) = (b, a) print(f'Resalt a: {a}') print(f'Resalt b: {b}')
class Player: def __init__(self, id, x, y, z, health): self.id = id self.x = x self.y = y self.z = z self.health = health
class Player: def __init__(self, id, x, y, z, health): self.id = id self.x = x self.y = y self.z = z self.health = health
# General DEBUG_MODE = True # FolderWatcher FOLDER_PATH = 'images/' FRAMERATE = 1 SCALE_TO_SIZE = (640, 480) # Server ROUTE = '/folder_feed'
debug_mode = True folder_path = 'images/' framerate = 1 scale_to_size = (640, 480) route = '/folder_feed'
with open(r"C:\Users\joash\Desktop\CS\haskell\AOC19\aoc\day2.txt", "r") as f: program = [ int(i) for i in f.read().split(",") ] pos = 0 while program[pos] != 99: print("currently on pos:", pos, "opcode is: ", program[pos]) if program[pos] == 1: program[program[pos+3]] = program[program[pos+1]] + program[pr...
with open('C:\\Users\\joash\\Desktop\\CS\\haskell\\AOC19\\aoc\\day2.txt', 'r') as f: program = [int(i) for i in f.read().split(',')] pos = 0 while program[pos] != 99: print('currently on pos:', pos, 'opcode is: ', program[pos]) if program[pos] == 1: program[program[pos + 3]] = program[program[pos + ...
class dotReferenceModel_t(object): # no doc aActiveFilePath = None aBasePointGuid = None aFilename = None ModelObject = None Position = None Rotation = None Scale = None Visibility = None
class Dotreferencemodel_T(object): a_active_file_path = None a_base_point_guid = None a_filename = None model_object = None position = None rotation = None scale = None visibility = None
class FARule(object): def __init__(self, state, char, next): super(FARule, self).__init__() self.state = state self.char = char self.next = next def is_applied(self, state, char): return self.state == state and self.char == char def follow(self, config): ret...
class Farule(object): def __init__(self, state, char, next): super(FARule, self).__init__() self.state = state self.char = char self.next = next def is_applied(self, state, char): return self.state == state and self.char == char def follow(self, config): re...
class Hoge: def hoge(self) -> None: pass @classmethod def fuga(cls) -> None: pass
class Hoge: def hoge(self) -> None: pass @classmethod def fuga(cls) -> None: pass
adict = { "BLACKBOARD_LEARN_INSTANCE" : "", "APPLICATION_KEY" : "", "APPLICATION_SECRET" : "", "django_secret_key" : '', "disable_collectstatic" : "1", "django_allowed_hosts" : "127.0.0.1 localhost .ngrok.io .herokuapp.com [::1]", "django_debug" : "False", }
adict = {'BLACKBOARD_LEARN_INSTANCE': '', 'APPLICATION_KEY': '', 'APPLICATION_SECRET': '', 'django_secret_key': '', 'disable_collectstatic': '1', 'django_allowed_hosts': '127.0.0.1 localhost .ngrok.io .herokuapp.com [::1]', 'django_debug': 'False'}
class MessageStorage: messageList = [] @staticmethod def addMessage(m): MessageStorage.messageList.append(m) @staticmethod def countMessages(): return len(MessageStorage.messageList) @staticmethod def getMessageList(): return MessageStorage.messageList @stati...
class Messagestorage: message_list = [] @staticmethod def add_message(m): MessageStorage.messageList.append(m) @staticmethod def count_messages(): return len(MessageStorage.messageList) @staticmethod def get_message_list(): return MessageStorage.messageList @s...
class Solution: def removeDuplicateLetters(self, s): for c in sorted(set(s)): chop = s[s.index(c):] # print(c, set(chop), set(s), chop, c, s) if set(chop) == set(s): return c + self.removeDuplicateLetters(chop.replace(c, "")) return "" a = Solution...
class Solution: def remove_duplicate_letters(self, s): for c in sorted(set(s)): chop = s[s.index(c):] if set(chop) == set(s): return c + self.removeDuplicateLetters(chop.replace(c, '')) return '' a = solution() b = 'cbabc' print(a.removeDuplicateLetters(b))
print("Look at the assinment statements") #1. Set a variable called playerlives equal to 3 playerlives = 3 #Write assignment statements for 2 to 6 below #2. set a variable called chocolate equal to 2 #3. set a variable called scorevalue equal to 4 #4. set a variable called totalscore equal to scorevalue * 3 #5. set...
print('Look at the assinment statements') playerlives = 3
palavra = input('Informe uma palavra: ') print('palavra invertida: ', palavra[::-1]) for letra in palavra: print(letra)
palavra = input('Informe uma palavra: ') print('palavra invertida: ', palavra[::-1]) for letra in palavra: print(letra)
dy_import_module_symbols("testchunk_helper") SERVER_IP = getmyip() SERVER_PORT = 60606 DATA_RECV = 1024 CHUNK_SIZE_SEND = 2**9 # 512KB chunk size CHUNK_SIZE_RECV = 2**9 DATA_TO_SEND = "Hello" # 5Bytes of data launch_test()
dy_import_module_symbols('testchunk_helper') server_ip = getmyip() server_port = 60606 data_recv = 1024 chunk_size_send = 2 ** 9 chunk_size_recv = 2 ** 9 data_to_send = 'Hello' launch_test()
''' pretrained model for StarGAN details adding soon ! '''
""" pretrained model for StarGAN details adding soon ! """
# # Copyright 2021 Abir Haque # Subject to MIT License in LICENSE file # # # # Perfect Square Roots: # # Find the square root of any given perfect square without multiplication or division. # # This is possible as all perfect squares are the sum of odd integers [1]. # This arithmetic sequence can be seen below: # # ...
def sqrt(n): (i, j, k) = (0, -1, 0) while k < n: j += 2 k += j i += 1 if k == n: return i return 'not possible' n = int(input('Please enter a number: ')) print('Square root of ' + str(n) + ' is ' + str(sqrt(n)) + '.')
# For Keystone Engine. AUTO-GENERATED FILE, DO NOT EDIT [keystone_const.py] KS_API_MAJOR = 0 KS_API_MINOR = 9 KS_VERSION_MAJOR = 0 KS_VERSION_MINOR = 9 KS_VERSION_EXTRA = 1 KS_ARCH_ARM = 1 KS_ARCH_ARM64 = 2 KS_ARCH_MIPS = 3 KS_ARCH_X86 = 4 KS_ARCH_PPC = 5 KS_ARCH_SPARC = 6 KS_ARCH_SYSTEMZ = 7 KS_ARCH_HEXAGON = 8 KS_ARC...
ks_api_major = 0 ks_api_minor = 9 ks_version_major = 0 ks_version_minor = 9 ks_version_extra = 1 ks_arch_arm = 1 ks_arch_arm64 = 2 ks_arch_mips = 3 ks_arch_x86 = 4 ks_arch_ppc = 5 ks_arch_sparc = 6 ks_arch_systemz = 7 ks_arch_hexagon = 8 ks_arch_evm = 9 ks_arch_max = 10 ks_mode_little_endian = 0 ks_mode_big_endian = 10...
class TestDataError(Exception): pass class MissingElementAmountValue(TestDataError): pass class FactoryStartedAlready(TestDataError): pass class NoSuchDatatype(TestDataError): pass class InvalidFieldType(TestDataError): pass class MissingRequiredFields(TestDataError): pass class UnmetDependentFi...
class Testdataerror(Exception): pass class Missingelementamountvalue(TestDataError): pass class Factorystartedalready(TestDataError): pass class Nosuchdatatype(TestDataError): pass class Invalidfieldtype(TestDataError): pass class Missingrequiredfields(TestDataError): pass class Unmetdepen...
# ******Numbers with The Highest Amount of Divisors****** # codewars # An array of different positive integers is given. We should create a code that gives us the number (or the numbers) that has (or have) the highest number of divisors among other data. # The function proc_arrInt(), (Javascript: procArrInt()) will ...
def proc_arr_int(listNum): primes = [] output = [0, [0]] maxi = 0 for i in listNum: count = 1 for j in range(1, i // 2 + 1): if i % j == 0: count += 1 if count == 2: primes.append(i) if count > maxi: output[0] = count ...
# # PySNMP MIB module EDB-snmp (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/EDB-snmp # Produced by pysmi-0.3.4 at Wed May 1 12:59:23 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:1...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, constraints_intersection, constraints_union, single_value_constraint, value_range_constraint) ...
n1 = float(input()) n2 = float(input()) meida = ((n1*3.5)+(n2*7.5))/(3.5+7.5) print(f"MEDIA = {meida:.5f}")
n1 = float(input()) n2 = float(input()) meida = (n1 * 3.5 + n2 * 7.5) / (3.5 + 7.5) print(f'MEDIA = {meida:.5f}')
class Solution: def lengthOfLongestSubstring(self, s: str) -> int: if len(s) == 0: return 0 current_length = 0 max_length = 0 idx = 0 last_dup_index = -1 count = {} while idx < len(s): if s[idx] not in count or count[s[idx]] < last_dup...
class Solution: def length_of_longest_substring(self, s: str) -> int: if len(s) == 0: return 0 current_length = 0 max_length = 0 idx = 0 last_dup_index = -1 count = {} while idx < len(s): if s[idx] not in count or count[s[idx]] < last_...
class move_avg: def __init__(self, bufmax): self.buf = [] self.bufmax = bufmax def add(self, val): self.buf.append(val) if len(self.buf) > self.bufmax: del self.buf[0] def get(self): if len(self.buf) > 0: avg = sum(self.buf)/len(self.buf) else: avg = 0 return avg
class Move_Avg: def __init__(self, bufmax): self.buf = [] self.bufmax = bufmax def add(self, val): self.buf.append(val) if len(self.buf) > self.bufmax: del self.buf[0] def get(self): if len(self.buf) > 0: avg = sum(self.buf) / len(self.buf) ...
TEMPLATES = { "multilingual-record-dumper": "templates/invenio_record_dumper_multilingual.py.jinja2", "record-multilingual": "templates/invenio_record_multilingual.py.jinja2", "subschema-multilingual": "templates/invenio_schema_multilingual.py.jinja2", "multi-search": "templates/invenio_record_search_mu...
templates = {'multilingual-record-dumper': 'templates/invenio_record_dumper_multilingual.py.jinja2', 'record-multilingual': 'templates/invenio_record_multilingual.py.jinja2', 'subschema-multilingual': 'templates/invenio_schema_multilingual.py.jinja2', 'multi-search': 'templates/invenio_record_search_multilingual.py.jin...
# Getting input and converting to int student_heights = input("Input a list of student heights ").split() for n in range(0, len(student_heights)): student_heights[n] = int(student_heights[n]) # Varibales to store sum and total and count sum_of_heights = 0 total_height = 0 count_of_students = 0 # This is to f...
student_heights = input('Input a list of student heights ').split() for n in range(0, len(student_heights)): student_heights[n] = int(student_heights[n]) sum_of_heights = 0 total_height = 0 count_of_students = 0 for student in student_heights: sum_of_heights += student count_of_students += 1 total_heigh...
N, X = input().split() A = list(map(int, input().split())) B = [] for i in range(0, int(N)) : if(A[i] < int(X)) : print(A[i], end=" ")
(n, x) = input().split() a = list(map(int, input().split())) b = [] for i in range(0, int(N)): if A[i] < int(X): print(A[i], end=' ')
def main(): print("Welcome to the casino!") print("Rules are simple, guess a number, if you get it right you win 100000 dollars~") print("Else you loose 5 dollars") while True: try: number = int(input("Choose a number: ")) except ValueError: print("INVALID NU...
def main(): print('Welcome to the casino!') print('Rules are simple, guess a number, if you get it right you win 100000 dollars~') print('Else you loose 5 dollars') while True: try: number = int(input('Choose a number: ')) except ValueError: print('INVALID NUMBER!...
class VectorIndex: @property def files(self): return [] def save(self): pass def load(self): pass def build(self): pass def search(self): pass def search_index(self): pass def add(self, vector): pass def add_bulk(self, vectors): pass def set_bulk(self, indices...
class Vectorindex: @property def files(self): return [] def save(self): pass def load(self): pass def build(self): pass def search(self): pass def search_index(self): pass def add(self, vector): pass def add_bulk(self, v...
class CallbackSettings(object): @property def JAVASCRIPT(self): return super().JAVASCRIPT + ( 'callback/modal.js', ) @property def INSTALLED_APPS(self): apps = super().INSTALLED_APPS + [ 'callback' ] if not 'captcha' in apps: ...
class Callbacksettings(object): @property def javascript(self): return super().JAVASCRIPT + ('callback/modal.js',) @property def installed_apps(self): apps = super().INSTALLED_APPS + ['callback'] if not 'captcha' in apps: apps += ['captcha'] return apps defa...
#Duplicates of ReadyResult constants - keeps this class clean of imported modules leaking into the sandbox NOT_READY = 'NotReady' READY = 'Ready' FAILED = 'Failed' class ReadyResultHolder: def __init__(self): self.__readiness = READY self.__reason = None def ready(self): self.__readi...
not_ready = 'NotReady' ready = 'Ready' failed = 'Failed' class Readyresultholder: def __init__(self): self.__readiness = READY self.__reason = None def ready(self): self.__readiness = READY return self def not_ready(self): self.__readiness = NOT_READY retu...
############################################################################## # Copyright (c) 2017 ZTE Corp # feng.xiaowei@zte.com.cn # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 # which accompanies this distribution, and is ...
not_found_base = 'Could Not Found' exist_base = 'Already Exists' def key_error(key): return "KeyError: '{}'".format(key) def no_file_uploaded(): return 'Please upload a file.' def no_body(): return 'No Body' def not_found(key, value): return '{} {} [{}]'.format(not_found_base, key, value) def missi...
n = int(input()) pieces = {} for _ in range(n): piece, composer, key = input().split('|') pieces[piece] = [composer, key] while True: line = input() if line == 'Stop': break args = line.split('|') command = args[0] piece = args[1] if command == 'Add': ...
n = int(input()) pieces = {} for _ in range(n): (piece, composer, key) = input().split('|') pieces[piece] = [composer, key] while True: line = input() if line == 'Stop': break args = line.split('|') command = args[0] piece = args[1] if command == 'Add': composer = args[2]...
DEBUG = True PLUGINS = ["fastack_sqlmodel", "fastack_migrate"] COMMANDS = [] DB_USER = "fastack_user" DB_PASSWORD = "fastack_pass" DB_HOST = "db" DB_PORT = 5432 DB_NAME = "fastack_db" SQLALCHEMY_DATABASE_URI = ( f"postgresql+psycopg2://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}" ) SQLALCHEMY_OPTIONS = {}...
debug = True plugins = ['fastack_sqlmodel', 'fastack_migrate'] commands = [] db_user = 'fastack_user' db_password = 'fastack_pass' db_host = 'db' db_port = 5432 db_name = 'fastack_db' sqlalchemy_database_uri = f'postgresql+psycopg2://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}' sqlalchemy_options = {}
a = input() p = input() if p in a + '*': print("S") else: print("N")
a = input() p = input() if p in a + '*': print('S') else: print('N')
''' All python scripts are modules and collection modules are package pip is used to install packages ''' def Demo(): a = int(input('Enter a 1st number')) b = int(input('Enter 2nd number')) s = 0 s = a + b return s print(Demo()) print("I will run") print(f'{__name__}') def Solve...
""" All python scripts are modules and collection modules are package pip is used to install packages """ def demo(): a = int(input('Enter a 1st number')) b = int(input('Enter 2nd number')) s = 0 s = a + b return s print(demo()) print('I will run') print(f'{__name__}') def solve(): print('Pyth...
WALL = '#' PASSABLE = '.' class SquareGrid: def __init__(self, width, height): self.width = width self.height = height self.walls = set() def in_bounds(self, id): (x, y) = id return 0 <= x < self.width and 0 <= y < self.height def cost(self, from_node, to_node): ...
wall = '#' passable = '.' class Squaregrid: def __init__(self, width, height): self.width = width self.height = height self.walls = set() def in_bounds(self, id): (x, y) = id return 0 <= x < self.width and 0 <= y < self.height def cost(self, from_node, to_node): ...
s = "" for x in range(33,127): # <33; 126> s += chr(x) print(s)
s = '' for x in range(33, 127): s += chr(x) print(s)
class RadioButtonFsm: def __init__(self, title, position, command=None): self.title = title self.command = command self.position = position
class Radiobuttonfsm: def __init__(self, title, position, command=None): self.title = title self.command = command self.position = position
# Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. # # An input string is valid if: # # Open brackets must be closed by the same type of brackets. # Open brackets must be closed in the correct order. # Note that an empty string is also considered val...
def is_valid(s): stack = [] for c in s: if c == '(': stack.append('(') if c == ')': if len(stack) == 0: return False if stack[-1] != '(': return False else: stack.pop() if c == '[': ...
# Scrapy settings for tutorial project # # For simplicity, this file contains only the most important settings by # default. All the other settings are documented here: # # http://doc.scrapy.org/topics/settings.html # BOT_NAME = 'tutorial' SPIDER_MODULES = ['tutorial.spiders'] NEWSPIDER_MODULE = 'tutorial.spiders...
bot_name = 'tutorial' spider_modules = ['tutorial.spiders'] newspider_module = 'tutorial.spiders' download_delay = 2 cookies_enabled = False retry_enabled = False download_timeout = 10 item_pipelines = ['tutorial.pipelines.SqlitePipeline'] dupefilter_class = 'tutorial.dupefilter.SqliteDupeFilter'
class Solution: def maxDepth(self, root: TreeNode) -> int: if (root is None): return 0 if (root.left is None and root.right is None): return 1 left = self.maxDepth(root.left) right = self.maxDepth(root.right) return max(left, right) + 1
class Solution: def max_depth(self, root: TreeNode) -> int: if root is None: return 0 if root.left is None and root.right is None: return 1 left = self.maxDepth(root.left) right = self.maxDepth(root.right) return max(left, right) + 1
red_flags = [] class RedFlagsModel(): def __init__(self): self.db = red_flags def save(self, data): id = len(red_flags) + 1 payload = { "id": id, "title": data['title'], "description": data['description'], "location": data['location'],...
red_flags = [] class Redflagsmodel: def __init__(self): self.db = red_flags def save(self, data): id = len(red_flags) + 1 payload = {'id': id, 'title': data['title'], 'description': data['description'], 'location': data['location'], 'type': data['type']} self.db.append(payload...
#------------------------------------------------------------------------------# # Copyright 2018 Gabriele Valentini. All rights reserved. Use of this source # # code is governed by a MIT license that can be found in the LICENSE file. # #----------------------------------------------------------------------------...
__cli__ = 'betrack' __version__ = '0.1.1'
class Solution(object): memo = {0: [], 1: [TreeNode(0)]} def allPossibleFBT(self, N): if N not in Solution.memo: ans = [] for x in xrange(N): y = N - 1 - x for left in self.allPossibleFBT(x): for right in self.allPossibleFBT(y)...
class Solution(object): memo = {0: [], 1: [tree_node(0)]} def all_possible_fbt(self, N): if N not in Solution.memo: ans = [] for x in xrange(N): y = N - 1 - x for left in self.allPossibleFBT(x): for right in self.allPossibleFBT...
__all__ = ['cohort', 'daterange', 'dimension', 'metric', 'order', 'pivot', 'report_request', 'segment']
__all__ = ['cohort', 'daterange', 'dimension', 'metric', 'order', 'pivot', 'report_request', 'segment']
word = input("Give me a word: ") wrong = True while wrong: if word == "banana": wrong = False print("END GAME") else: print("WRONG") word = input("Give me a word: ")
word = input('Give me a word: ') wrong = True while wrong: if word == 'banana': wrong = False print('END GAME') else: print('WRONG') word = input('Give me a word: ')
while True: try: line = input().strip().split(' ') except EOFError: break winner = 3 for i in range(3): if line[i] == 'pedra' and line[(i +1) % 3] == 'tesoura' and line[(i +1) % 3] == line[(i + 2) % 3]: winner = i break elif line[i] == 'papel' an...
while True: try: line = input().strip().split(' ') except EOFError: break winner = 3 for i in range(3): if line[i] == 'pedra' and line[(i + 1) % 3] == 'tesoura' and (line[(i + 1) % 3] == line[(i + 2) % 3]): winner = i break elif line[i] == 'papel' ...
# Solution A: class Solution: def reverse(self, x): if -10 < x < 10: return x str_ = str(x) if str_[0] != '-': str_ = str_[::-1] res = int(str_) else: str_ = str_[:0:-1] res = int(str_) res = -res return ...
class Solution: def reverse(self, x): if -10 < x < 10: return x str_ = str(x) if str_[0] != '-': str_ = str_[::-1] res = int(str_) else: str_ = str_[:0:-1] res = int(str_) res = -res return res if -2 ** ...
nodes = {} node_stats = {} buckets_summary = {} stats_summary = {} bucket_info = {} buckets = {} stats = { "minute" : { 'disk_write_queue' : {}, 'cmd_get' : {}, 'cmd_set' : {}, 'delete_hits' : {}, 'curr_items' : {}, 'vb_replica_curr_items' : {}, 'curr_connec...
nodes = {} node_stats = {} buckets_summary = {} stats_summary = {} bucket_info = {} buckets = {} stats = {'minute': {'disk_write_queue': {}, 'cmd_get': {}, 'cmd_set': {}, 'delete_hits': {}, 'curr_items': {}, 'vb_replica_curr_items': {}, 'curr_connections': {}, 'vb_active_queue_drain': {}, 'vb_replica_queue_drain': {}, ...
n = int(input()) a = list(map(int,input().split())) i = 0 money=0 while i<n-1: while i<n-1 and a[i]>=a[i+1]: i+=1 if i==n-1: break buy_at=i i+=1 while i<n and a[i]>=a[i-1]: i+=1 sell_at=i-1 money+=a[sell_at]-a[buy_at] print(money)
n = int(input()) a = list(map(int, input().split())) i = 0 money = 0 while i < n - 1: while i < n - 1 and a[i] >= a[i + 1]: i += 1 if i == n - 1: break buy_at = i i += 1 while i < n and a[i] >= a[i - 1]: i += 1 sell_at = i - 1 money += a[sell_at] - a[buy_at] print(mon...
# # PySNMP MIB module HUAWEI-NAP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-NAP-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:47:27 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2...
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_size_constraint, value_range_constraint, constraints_union, constraints_intersection) ...
class Color(): def __init__(self, red=0, green=0, blue=0, type=False): self.red = red self.green = green self.blue = blue # False = 15bit, True = 24bit self.__type = type if self.__type: self.assert24Bit() else: self.assert15Bit() ...
class Color: def __init__(self, red=0, green=0, blue=0, type=False): self.red = red self.green = green self.blue = blue self.__type = type if self.__type: self.assert24Bit() else: self.assert15Bit() def get_red(self): return self....
a = int(input()) v = 0 for x in range(1,10+1): print(v+1,"x",a,"=",a*(v+1)) v = v+ 1
a = int(input()) v = 0 for x in range(1, 10 + 1): print(v + 1, 'x', a, '=', a * (v + 1)) v = v + 1
# Implementation using list # Initializing queue using a list myQueue = [] # Adding elements to the queue myQueue.append(1) myQueue.append(2) myQueue.append(3) # Printing the queue print("Initial queue:", myQueue) # Size of the queue print("Size: ", len(myQueue)) # Check if queue is empty if not myQueue: print(...
my_queue = [] myQueue.append(1) myQueue.append(2) myQueue.append(3) print('Initial queue:', myQueue) print('Size: ', len(myQueue)) if not myQueue: print('Queue is empty') else: print('Queue is not empty') print('First element in the queue: ', myQueue[0]) print('Dequeued element:', myQueue.pop(0)) print('Queue a...
#!/usr/bin/env python3 def merge(A,l,m,r): L,R = A[l:m+1],A[m+1:r+1] #copied L.append(float("inf")) R.append(float("inf")) i,j = 0,0 for k in range(l,r+1): A[k]= L[i] if L[i]<R[j] else R[j] i,j =(1+i,j) if L[i]<R[j] else (i,j+1) def merge_sort(A,l,r): if l<r: m = l+((...
def merge(A, l, m, r): (l, r) = (A[l:m + 1], A[m + 1:r + 1]) L.append(float('inf')) R.append(float('inf')) (i, j) = (0, 0) for k in range(l, r + 1): A[k] = L[i] if L[i] < R[j] else R[j] (i, j) = (1 + i, j) if L[i] < R[j] else (i, j + 1) def merge_sort(A, l, r): if l < r: ...
# str(Color()) class Color: color = 'orange' def __str__(self): return Color.color print(str(Color()))
class Color: color = 'orange' def __str__(self): return Color.color print(str(color()))
# 1. Define a function that accepts 2 values and returns # its sum, subtraction and multiplication. # SOLUTION: def result(a, b): sum = a+b sub = a-b mul = a*b print(f"Sum is {sum}, Sub is {sub}, & Multiply is {mul}") a = int(input("Enter value of a: ")) b = int(input("Enter value of b: ")) resul...
def result(a, b): sum = a + b sub = a - b mul = a * b print(f'Sum is {sum}, Sub is {sub}, & Multiply is {mul}') a = int(input('Enter value of a: ')) b = int(input('Enter value of b: ')) result(a, b) def max(a, b, c): if a > b and a > c: print(f'{a} is maximum among all') elif b > a and ...
################################################################ ### User input parameters for C3S-LAA ################################################################ ### Required dependencies and input files # Path for the AMOS package that contains minimus assembler amos_path = "/usr/local/amos/bin/" ...
amos_path = '/usr/local/amos/bin/' primer_info_file = 'primer_pairs_info.txt' barcode_info_file = 'barcode_pairs_info.txt' fofn = '/mnt/data27/ffrancis/PacBio_sequence_files/EqPCR_raw/F03_1/Analysis_Results/m160901_060459_42157_c101086112550000001823264003091775_s1_p0.bas.h5' ccs = '/mnt/data27/ffrancis/PacBio_sequence...
# general make_debug = False make_task = "" build_type = "Release" app_name = "MyApp"
make_debug = False make_task = '' build_type = 'Release' app_name = 'MyApp'
sum = 0 for num in range(1,1000): if (num % 3 == 0 or num % 5 == 0): sum += num print(sum)
sum = 0 for num in range(1, 1000): if num % 3 == 0 or num % 5 == 0: sum += num print(sum)
def split_lines(el): return el.split('\n') split_lines('10\n is\n the\n perfect\n number')
def split_lines(el): return el.split('\n') split_lines('10\n is\n the\n perfect\n number')
class Solution: # @param {integer[]} prices # @return {integer} def maxProfit(self, prices): if len(prices) < 2: return 0 minn = prices[:-1] maxn = prices[1:] mi = minn[0] for i in range(1, len(minn)): if minn[i] > mi: minn[i]...
class Solution: def max_profit(self, prices): if len(prices) < 2: return 0 minn = prices[:-1] maxn = prices[1:] mi = minn[0] for i in range(1, len(minn)): if minn[i] > mi: minn[i] = mi else: mi = minn[i] ...
__all__ = ['UndefinedType', 'undefined'] class _SingletonMeta(type): def __call__(self, *args, **kwargs): if not hasattr(self, '__instance__'): self.__instance__ = super().__call__(*args, **kwargs) return self.__instance__ class UndefinedType(metaclass=_SingletonMeta): ...
__all__ = ['UndefinedType', 'undefined'] class _Singletonmeta(type): def __call__(self, *args, **kwargs): if not hasattr(self, '__instance__'): self.__instance__ = super().__call__(*args, **kwargs) return self.__instance__ class Undefinedtype(metaclass=_SingletonMeta): """A new si...
def bubbleSort(alist): for passnum in range(len(alist) - 1, 0, -1): for i in range(passnum): if alist[i] > alist[i + 1]: temp = alist[i] alist[i] = alist[i + 1] alist[i + 1] = temp alist = [54, 26, 93, 17, 77, 31, 44, 55, 20] bubbleSort(alist) pr...
def bubble_sort(alist): for passnum in range(len(alist) - 1, 0, -1): for i in range(passnum): if alist[i] > alist[i + 1]: temp = alist[i] alist[i] = alist[i + 1] alist[i + 1] = temp alist = [54, 26, 93, 17, 77, 31, 44, 55, 20] bubble_sort(alist) pr...
def format_search_terms(search_terms): s='' q=[] if search_terms != None: for term in search_terms: q.append(term) q.append('%20') s= ''.join(q) return s def format_from_user(from_user): s='' q=[] if from_user != None: q.append('from%3A') ...
def format_search_terms(search_terms): s = '' q = [] if search_terms != None: for term in search_terms: q.append(term) q.append('%20') s = ''.join(q) return s def format_from_user(from_user): s = '' q = [] if from_user != None: q.append('from%...
class EventBrokerError(Exception): pass class EventBrokerAuthError(EventBrokerError): pass
class Eventbrokererror(Exception): pass class Eventbrokerautherror(EventBrokerError): pass
# We'll use a greedy algorithm to check to see if we have a # new max sum as we iterate along the along. If at any time # our sum becomes negative, we reset the sum. def largestContiguousSum(arr): maxSum = 0 currentSum = 0 for i, _ in enumerate(arr): currentSum += arr[i] max...
def largest_contiguous_sum(arr): max_sum = 0 current_sum = 0 for (i, _) in enumerate(arr): current_sum += arr[i] max_sum = max(currentSum, maxSum) if currentSum < 0: current_sum = 0 return maxSum print(largest_contiguous_sum([5, -9, 6, -2, 3])) print(largest_contiguou...
def diagonalDifference(arr): diagonal1 = 0 diagonal2 = 0 for pos, line in enumerate(arr): diagonal1 += line[pos] diagonal2 += line[len(arr)-1 - pos] return abs(diagonal1 - diagonal2)
def diagonal_difference(arr): diagonal1 = 0 diagonal2 = 0 for (pos, line) in enumerate(arr): diagonal1 += line[pos] diagonal2 += line[len(arr) - 1 - pos] return abs(diagonal1 - diagonal2)
class MaterialSubsurfaceScattering: back = None color = None color_factor = None error_threshold = None front = None ior = None radius = None scale = None texture_factor = None use = None
class Materialsubsurfacescattering: back = None color = None color_factor = None error_threshold = None front = None ior = None radius = None scale = None texture_factor = None use = None
shiboken_library_soversion = str(6.1) version = "6.1.1" version_info = (6, 1, 1, "", "") __build_date__ = '2021-06-03T07:46:50+00:00' __setup_py_package_version__ = '6.1.1'
shiboken_library_soversion = str(6.1) version = '6.1.1' version_info = (6, 1, 1, '', '') __build_date__ = '2021-06-03T07:46:50+00:00' __setup_py_package_version__ = '6.1.1'
# S1 input_list = [] for i in range(int(6)): input_list.append(input()) win_counter = 0 loss_counter = 0 for i in input_list: if i == "W": win_counter += 1 else: loss_counter += 1 if win_counter == 1 or win_counter == 2: print("3") elif win_counter == 3 or win_counter == 4: print("2"...
input_list = [] for i in range(int(6)): input_list.append(input()) win_counter = 0 loss_counter = 0 for i in input_list: if i == 'W': win_counter += 1 else: loss_counter += 1 if win_counter == 1 or win_counter == 2: print('3') elif win_counter == 3 or win_counter == 4: print('2') eli...
class Evaluator: @staticmethod def zip_evaluate(coefs, words): if (len(coefs) != len(words)): return -1 return sum([coeff * len(word) for (coeff, word) in zip(coefs, words)]) @staticmethod def enumerate_evaluate(coefs, words): if (len(coefs) != le...
class Evaluator: @staticmethod def zip_evaluate(coefs, words): if len(coefs) != len(words): return -1 return sum([coeff * len(word) for (coeff, word) in zip(coefs, words)]) @staticmethod def enumerate_evaluate(coefs, words): if len(coefs) != len(words): ...
# You are given an array of desired filenames in the order of their creation. # Since two files cannot have equal names, the one which comes later will have # an addition to its name in a form of (k), where k is the smallest positive # integer such that the obtained name is not used yet. # # Return an array of names th...
def file_naming(names): new_names = [] for name in names: if name in new_names: name = add_suffix(name, new_names) new_names.append(name) return new_names def add_suffix(name, new_names): count = 1 new_name = name + '(' + str(count) + ')' while new_name in new_names:...
load("@dwtj_rules_markdown//markdown:defs.bzl", "markdown_library") def index_md(name = "index_md"): markdown_library( name = name, srcs = ["INDEX.md"], )
load('@dwtj_rules_markdown//markdown:defs.bzl', 'markdown_library') def index_md(name='index_md'): markdown_library(name=name, srcs=['INDEX.md'])
length_check_fields=['reset_pc', 'physical_addr_size'] bsc_cmd = '''bsc -u -verilog -elab -vdir {0} -bdir {1} -info-dir {1} \ +RTS -K40000M -RTS -check-assert -keep-fires \ -opt-undetermined-vals -remove-false-rules -remove-empty-rules \ -remove-starved-rules -remove-dollar -unspecified-to X -show-schedule \ -show-m...
length_check_fields = ['reset_pc', 'physical_addr_size'] bsc_cmd = 'bsc -u -verilog -elab -vdir {0} -bdir {1} -info-dir {1} +RTS -K40000M -RTS -check-assert -keep-fires -opt-undetermined-vals -remove-false-rules -remove-empty-rules -remove-starved-rules -remove-dollar -unspecified-to X -show-schedule -show-module-use ...
BOT_NAME = 'naver_movie' SPIDER_MODULES = ['naver_movie.spiders'] NEWSPIDER_MODULE = 'naver_movie.spiders' ROBOTSTXT_OBEY = False DOWNLOAD_DELAY = 2 COOKIES_ENABLED = True DEFAULT_REQUEST_HEADERS = { "Referer": "https://movie.naver.com/" } DOWNLOADER_MIDDLEWARES = { 'scrapy.downloadermiddlewares.useragent.U...
bot_name = 'naver_movie' spider_modules = ['naver_movie.spiders'] newspider_module = 'naver_movie.spiders' robotstxt_obey = False download_delay = 2 cookies_enabled = True default_request_headers = {'Referer': 'https://movie.naver.com/'} downloader_middlewares = {'scrapy.downloadermiddlewares.useragent.UserAgentMiddlew...
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def isPalindrome(self, head: ListNode) -> bool: if not head or not head.next: return True # print(head) slow, fast = head, head ...
class Solution: def is_palindrome(self, head: ListNode) -> bool: if not head or not head.next: return True (slow, fast) = (head, head) pre = None while fast and fast.next: pre = slow slow = slow.next fast = fast.next.next def ...
n = float(input()) whole = int(n) fractional = int(round((n % 1), 2) * 100) print(whole, fractional)
n = float(input()) whole = int(n) fractional = int(round(n % 1, 2) * 100) print(whole, fractional)
class Spam(object): def __init__(self, key, value): self.list_ = [value] self.dict_ = {key : value} self.list_.append(value) self.dict_[key] = value print(f'List: {self.list_}') print(f'Dict: {self.dict_}') Spam('Key 1', 'Value 1') Spam('Key 2', 'Value 2')
class Spam(object): def __init__(self, key, value): self.list_ = [value] self.dict_ = {key: value} self.list_.append(value) self.dict_[key] = value print(f'List: {self.list_}') print(f'Dict: {self.dict_}') spam('Key 1', 'Value 1') spam('Key 2', 'Value 2')
lista = [5,7,9,2,4,3,1,6,8] comparaciones = 0 for i in range(len(lista) -1): #recorre la lista for j in range(len(lista)-1): #sirve para comparar los elementos de la lista #print('Comparando: ' , lista[j], "con ", lista[j+1]) if(lista[j] > lista[j+1]): #lista[j], lista[j+1] = lista[j+1] ...
lista = [5, 7, 9, 2, 4, 3, 1, 6, 8] comparaciones = 0 for i in range(len(lista) - 1): for j in range(len(lista) - 1): if lista[j] > lista[j + 1]: comparaciones += 1 temporal = lista[j] lista[j] = lista[j + 1] lista[j + 1] = temporal print(lista) print(...
# # PySNMP MIB module SW-TRUNK-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SW-TRUNK-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:05:02 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019,...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, constraints_intersection, single_value_constraint, constraints_union, value_range_constraint) ...