content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
class CabernetException(Exception): def __init__(self, value): self.value = value def __str__(self): return 'CabernetException: %s' % self.value
class Cabernetexception(Exception): def __init__(self, value): self.value = value def __str__(self): return 'CabernetException: %s' % self.value
def get_coordinate(record): pass def convert_coordinate(coordinate): pass def compare_records(azara_record, rui_record): pass def create_record(azara_record, rui_record): pass def clean_up(combined_record_group): pass
def get_coordinate(record): pass def convert_coordinate(coordinate): pass def compare_records(azara_record, rui_record): pass def create_record(azara_record, rui_record): pass def clean_up(combined_record_group): pass
# This object is created to carry along the variables of interest for display purposes class RegObject: def __init__(self, res_list, interest, controls): self.res = res_list self.variables_of_interest = list(dict.fromkeys([x.lower() for x in interest])) # This avoids errors in the formatte...
class Regobject: def __init__(self, res_list, interest, controls): self.res = res_list self.variables_of_interest = list(dict.fromkeys([x.lower() for x in interest])) self.controls = [] for item in list(dict.fromkeys([x.lower() for x in controls])): if item not in self.v...
# -*- coding: utf-8 -*- def devices_info_all(pushbots): return pushbots.devices_info_all() def device_info(pushbots, token): return pushbots.device_info(token=token)
def devices_info_all(pushbots): return pushbots.devices_info_all() def device_info(pushbots, token): return pushbots.device_info(token=token)
def determine_config_type(config_parser): '''Determines the type of a ceph.conf file and returns it. Args: config_parser (configparser): Parser object with read in ceph.conf to check. Returns: rados_deploy.StorageType of the ceph.conf.''' if 'memstore device bytes' in config_parser['gl...
def determine_config_type(config_parser): """Determines the type of a ceph.conf file and returns it. Args: config_parser (configparser): Parser object with read in ceph.conf to check. Returns: rados_deploy.StorageType of the ceph.conf.""" if 'memstore device bytes' in config_parser['glo...
class IgnoreMe: def __init__(self, *args, **kwds): ... def __call__(self, *args, **kwds): return self def __getattr__(self, __name: str): return self def __bool__(self): return False def __nonzero__(self): return self.__bool__()
class Ignoreme: def __init__(self, *args, **kwds): ... def __call__(self, *args, **kwds): return self def __getattr__(self, __name: str): return self def __bool__(self): return False def __nonzero__(self): return self.__bool__()
k=1 for i in range(1,6): for j in range(i): if k<10: print(k,end='') k+=1 if k==10: print(1,end='') else: k=2 print()
k = 1 for i in range(1, 6): for j in range(i): if k < 10: print(k, end='') k += 1 if k == 10: print(1, end='') else: k = 2 print()
def launch_network(): global network global difficulty network = set() difficulty = 1
def launch_network(): global network global difficulty network = set() difficulty = 1
''' @Date: 2019-12-08 19:58:01 @Author: ywyz @LastModifiedBy: ywyz @Github: https://github.com/ywyz @LastEditors: ywyz @LastEditTime: 2019-12-08 20:01:19 ''' def count(s, ch): num = 0 for char in s: if char == ch: num += 1 return num def main(): strings = input("Input a string: ...
""" @Date: 2019-12-08 19:58:01 @Author: ywyz @LastModifiedBy: ywyz @Github: https://github.com/ywyz @LastEditors: ywyz @LastEditTime: 2019-12-08 20:01:19 """ def count(s, ch): num = 0 for char in s: if char == ch: num += 1 return num def main(): strings = input('Input a string: ') ...
# # PySNMP MIB module ORiNOCO-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ORiNOCO-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:35:34 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') (value_range_constraint, constraints_intersection, value_size_constraint, constraints_union, single_value_constraint) ...
n = int(input()) segundos = n%60 minutos = (n / 60) % 60 horas = n / (60 * 60) print("%i:%i:%i" % (horas, minutos, segundos))
n = int(input()) segundos = n % 60 minutos = n / 60 % 60 horas = n / (60 * 60) print('%i:%i:%i' % (horas, minutos, segundos))
# s <= ns # 1. e <= ns: change # 2. ns < e < ne: change # => e < ne: change # else: cnt += 1, don't change class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: intervals.sort() s = e = -1 cnt = 0 for ns, ne in intervals: if e < ne: ...
class Solution: def remove_covered_intervals(self, intervals: List[List[int]]) -> int: intervals.sort() s = e = -1 cnt = 0 for (ns, ne) in intervals: if e < ne: if s == ns: cnt += 1 (s, e) = (ns, ne) else: ...
# List grades=[12,60,15,70,90] grades[0]=55 #update grades[0] print (grades[0]) print (grades[1:4]) grades = grades + [12,33] print (grades) length = len(grades) print(length) # Nested List data = [[3,4,5],[6,7,8]] print(data[0][1]) print(data[0][0:2]) data[0][0:2] = [5,5,5] print(data) # Tuple print ("///////////...
grades = [12, 60, 15, 70, 90] grades[0] = 55 print(grades[0]) print(grades[1:4]) grades = grades + [12, 33] print(grades) length = len(grades) print(length) data = [[3, 4, 5], [6, 7, 8]] print(data[0][1]) print(data[0][0:2]) data[0][0:2] = [5, 5, 5] print(data) print('///////////////////////// Tuple ///////////////////...
# Variables x = 15 price = 9.99 discount = 0.2 result = price * (1 - discount) print(result)
x = 15 price = 9.99 discount = 0.2 result = price * (1 - discount) print(result)
# Security misconfiguration is the most commonly seen issue. This is commonly a result of insecure # default configurations, incomplete or ad hoc configurations, open cloud storage, misconfigured # HTTP headers, and verbose error messages containing sensitive information. Not only must all # operating systems, frame...
class Security_Misconfiguration: def __init__(self, scopeURL, outOfScopeURL): self.scopeURL = scopeURL self.outOfScopeURL = outOfScopeURL
class Solution: def nextGreatestLetter(self, letters, target): left, right = 0, len(letters) - 1 while left < right: mid = left + (right - left) // 2 if letters[mid] > target: right = mid else: left = mid + 1 if letters[lef...
class Solution: def next_greatest_letter(self, letters, target): (left, right) = (0, len(letters) - 1) while left < right: mid = left + (right - left) // 2 if letters[mid] > target: right = mid else: left = mid + 1 if lette...
class Document: def __init__(self,SentenceList,id=-1): self.id=id self.value=SentenceList self.attr={} def __str__(self): s ="Document id: {0}, value: {1}, attributes: {2}".format(self.id,self.value,self.attr) return s
class Document: def __init__(self, SentenceList, id=-1): self.id = id self.value = SentenceList self.attr = {} def __str__(self): s = 'Document id: {0}, value: {1}, attributes: {2}'.format(self.id, self.value, self.attr) return s
''' At this point, you've got all the basics necessary to start employing modules. We still have to teach classes, among a few other necessary basics, but now would be a good time to talk about modules. IF you are using linux, installing python modules is incredibly stupid easy. For programming, linux is just lovely...
""" At this point, you've got all the basics necessary to start employing modules. We still have to teach classes, among a few other necessary basics, but now would be a good time to talk about modules. IF you are using linux, installing python modules is incredibly stupid easy. For programming, linux is just lovely...
# You can customize these lists according to you're requirement. #list for finding admin panels: adminfinder_db = ["/acceso.asp", "/acceso.php", "/access/", "/access.php", "/account/", "/account.asp", "/account.html", "/account.php", "/acct_login/", "/_adm_/", "/_adm/", "/adm/", "/adm2/", "/adm/admloginuser.asp", "/ad...
adminfinder_db = ['/acceso.asp', '/acceso.php', '/access/', '/access.php', '/account/', '/account.asp', '/account.html', '/account.php', '/acct_login/', '/_adm_/', '/_adm/', '/adm/', '/adm2/', '/adm/admloginuser.asp', '/adm/admloginuser.php', '/adm.asp', '/adm_auth.asp', '/adm_auth.php', '/adm.html', '/_admin_/', '/_ad...
class Intersection: def __init__(self, no, x_p, y_p): self.no = no self.x = x_p self.y = y_p
class Intersection: def __init__(self, no, x_p, y_p): self.no = no self.x = x_p self.y = y_p
##Ejercicio 2 # el siguiente codigo identifica si existe alguna suma entre dos elementos # distintos dentro de la listta , que sumen 10. # Complejidad del algoritmo : O(n^2) por los dos for implementados uno dentro del otro # # Entrada: # - #Si hay entonces # Salida: # Son: 2 + 8 = 10 # True #Si no # Salida: # Fal...
def two_sum(array): for i in range(len(array)): for j in range(len(array)): if i != j and array[i] + array[j] == 10: print('Hay al menos 2 numeros que suman 10') print('Son: ' + str(array[i]) + ' + ' + str(array[j]) + ' = 10') return True retur...
#fibbonancci numvers def fibonancci(n): if n <= 1: return 1 l = [None]*(n+1) # l[:n] = 0*(n) l[0]= 0 l[1] = 1 # print(l) for i in range(2,n+1): l[i] = l[i-1]+l[i-2] print(l) return l[n+1] def fib_rec(n): if n <= 1: return n print(n) retu...
def fibonancci(n): if n <= 1: return 1 l = [None] * (n + 1) l[0] = 0 l[1] = 1 for i in range(2, n + 1): l[i] = l[i - 1] + l[i - 2] print(l) return l[n + 1] def fib_rec(n): if n <= 1: return n print(n) return fib_rec(n - 1) + fib_rec(n - 2) if __name__...
# Define a function to find the truth by shifting the letter by a specified amount def lassoLetter( letter, shiftAmount ): # Invoke the ord function to translate the letter to its ASCII code # Save the code value to the variable called letterCode letterCode = ord(letter.lower()) # The ASCII number repr...
def lasso_letter(letter, shiftAmount): letter_code = ord(letter.lower()) a_ascii = ord('a') alphabet_size = 26 true_letter_code = aAscii + (letterCode - aAscii + shiftAmount) % alphabetSize decoded_letter = chr(trueLetterCode) return decodedLetter def lasso_word(word, shiftAmount): decoded_...
def reconcile(hub, high): ''' Take the extend statement and reconcile it back into the highdata ''' errors = [] if '__extend__' not in high: return high, errors ext = high.pop('__extend__') for ext_chunk in ext: for id_, body in ext_chunk: if id_ not in high: ...
def reconcile(hub, high): """ Take the extend statement and reconcile it back into the highdata """ errors = [] if '__extend__' not in high: return (high, errors) ext = high.pop('__extend__') for ext_chunk in ext: for (id_, body) in ext_chunk: if id_ not in high: ...
def approximation(x, x1, x2, y, y1, y2): a1 = (y1-y)/(x1-x) a2 = (1/(x2-x1))*(((y2-y)/(x2-x)) - ((y1-y)/(x1-x))) return ((x1+x)/2) - (a1/(2*a2))
def approximation(x, x1, x2, y, y1, y2): a1 = (y1 - y) / (x1 - x) a2 = 1 / (x2 - x1) * ((y2 - y) / (x2 - x) - (y1 - y) / (x1 - x)) return (x1 + x) / 2 - a1 / (2 * a2)
''' CLASS: VnfmDriverTemplate AUTHOR: Vinicius Fulber-Garcia CREATION: 21 Oct. 2020 L. UPDATE: 28 Jul. 2021 (Fulber-Garcia; Included the "vnfmAddress" attribute) DESCRIPTION: Template for the implementation of VNFM drivers that run in the "Access Subsystem" internal module. The drivers must inhert this class ...
""" CLASS: VnfmDriverTemplate AUTHOR: Vinicius Fulber-Garcia CREATION: 21 Oct. 2020 L. UPDATE: 28 Jul. 2021 (Fulber-Garcia; Included the "vnfmAddress" attribute) DESCRIPTION: Template for the implementation of VNFM drivers that run in the "Access Subsystem" internal module. The drivers must inhert this class and ov...
# Optional Problem Set, Question 1 def ndigits(x): ''' assumes x is an integer returns the digits of x ''' # If x equals 0 (due to integer division), it means that no digits are left. if x == 0: return 0 # Otherwise, it returns 1 + the digits of the integer divided by 10. return...
def ndigits(x): """ assumes x is an integer returns the digits of x """ if x == 0: return 0 return 1 + ndigits(abs(x) / 10)
version = '1.3.1' major = 1 minor = 3 micro = 1 release_level = 'final' serial = 0 version_info = (major, minor, micro, release_level, serial)
version = '1.3.1' major = 1 minor = 3 micro = 1 release_level = 'final' serial = 0 version_info = (major, minor, micro, release_level, serial)
#import math res = set() for i in range(2,101): for j in range(2,101): res.add(i ** j) print(len(res))
res = set() for i in range(2, 101): for j in range(2, 101): res.add(i ** j) print(len(res))
class Solution: def addBinary(self, a: str, b: str) -> str: c=int(a,2)+int(b,2) return str(bin(c))[2:]
class Solution: def add_binary(self, a: str, b: str) -> str: c = int(a, 2) + int(b, 2) return str(bin(c))[2:]
n=int(input()) if n%2!=0: print("Weird") if n in range(2,7) and n%2==0: print("Not Weird") if n in range(6,21) and n%2==0: print("Weird") if n>20 and n%2==0: print("Not Weird")
n = int(input()) if n % 2 != 0: print('Weird') if n in range(2, 7) and n % 2 == 0: print('Not Weird') if n in range(6, 21) and n % 2 == 0: print('Weird') if n > 20 and n % 2 == 0: print('Not Weird')
class Solution: def maximalNetworkRank(self, n: int, roads: List[List[int]]) -> int: # n^2 runtime degrees = [0] * n graph = [[] for _ in range(n)] for road in roads: degrees[road[0]] += 1 degrees[road[1]] += 1 graph[road[0]].append(road[1]) ...
class Solution: def maximal_network_rank(self, n: int, roads: List[List[int]]) -> int: degrees = [0] * n graph = [[] for _ in range(n)] for road in roads: degrees[road[0]] += 1 degrees[road[1]] += 1 graph[road[0]].append(road[1]) graph[road[1]...
__author__ = 'hs634' ''' Given a binary tree where all the right nodes are leaf nodes, flip it upside down and turn it into a tree with left leaf nodes. Keep in mind: ALL RIGHT NODES IN ORIGINAL TREE ARE LEAF NODE. /* for example, turn these: * * 1 1 * / \ / \ * ...
__author__ = 'hs634' '\n\nGiven a binary tree where all the right nodes are leaf nodes, flip it upside down and turn it into a tree with left leaf nodes.\n\nKeep in mind: ALL RIGHT NODES IN ORIGINAL TREE ARE LEAF NODE.\n\n\n/* for example, turn these:\n *\n * 1 1\n * / \\ / ...
a = 0 b = 0 c = 0 if a == b: c = 100 else: c = 10 print(c) if c == 10: print('c == 10') else: print('c == 100') ''' output 100 c == 100 '''
a = 0 b = 0 c = 0 if a == b: c = 100 else: c = 10 print(c) if c == 10: print('c == 10') else: print('c == 100') ' output\n100\nc == 100\n'
def simulation_parameter_validate(end_t, initial_conditions, rates_params, drain_params): assert isinstance(end_t, (int, float)), "End_t must be a float or int" assert end_t > 0, "End_t most be a positive number" assert isinstance(initial_conditions, dict), "Expected {} got {} for initial conditions"\ ...
def simulation_parameter_validate(end_t, initial_conditions, rates_params, drain_params): assert isinstance(end_t, (int, float)), 'End_t must be a float or int' assert end_t > 0, 'End_t most be a positive number' assert isinstance(initial_conditions, dict), 'Expected {} got {} for initial conditions'.format...
# # This is the Robotics Language compiler # # Transform.py: Deep Inference code transformer # # Created on: 25 February, 2019 # Author: Gabriel Lopes # Licence: license # Copyright: Robot Care Systems BV # def transform(code, parameters): return code, parameters
def transform(code, parameters): return (code, parameters)
# Operators PLUS = '+' MINUS = '-' MUL = '*' DIV = '/' FLOORDIV = '//' MOD = '%' POWER = '^' ARITHMATIC_LEFT_SHIFT = '<<<' ARITHMATIC_RIGHT_SHIFT = '>>>' XOR = 'xor' BINARY_ONES_COMPLIMENT = '~' BINARY_LEFT_SHIFT = '<<' BINARY_RIGHT_SHIFT = '>>' AND = 'and' OR = 'or' NOT = 'not' IN = 'in' # TODO NOT_IN = 'not in' # T...
plus = '+' minus = '-' mul = '*' div = '/' floordiv = '//' mod = '%' power = '^' arithmatic_left_shift = '<<<' arithmatic_right_shift = '>>>' xor = 'xor' binary_ones_compliment = '~' binary_left_shift = '<<' binary_right_shift = '>>' and = 'and' or = 'or' not = 'not' in = 'in' not_in = 'not in' is = 'is' is_not = 'is n...
# 6-dars 1-uyga vazifa # My_list = ['Dadam: O`ktam ', 'Onam: Dilrabo', 'Akam: Shoxrux', 'O`zim: Abduhalim', 'Ukam: Sardor'] # for elem in My_list: # print(elem) # 2-uyga vazifa # Standart kiruvchi ma'lumotdagi vergul bilan ajratilgan so'zlar ketma-ketligini teskar...
names = input('Please input the names: ') changed = names.split(sep=', ') chosen_name = input('input the name you want to find its repitation: ') print(changed.count(chosen_name))
class User: def __init__(self, username, first, last): self.username = username self.password = None self.first = first self.last = last self.bio = "Datau" self.pic = "default.png"
class User: def __init__(self, username, first, last): self.username = username self.password = None self.first = first self.last = last self.bio = 'Datau' self.pic = 'default.png'
# appfat.cpp MakeNameEx(LocByName("sub_401000"), "j_appfat_cpp_init", SN_NOWARN) MakeNameEx(LocByName("sub_401005"), "appfat_cpp_init", SN_NOWARN) MakeNameEx(LocByName("sub_401010"), "appfat_cpp_free", SN_NOWARN) MakeNameEx(LocByName("sub_40102A"), "GetErr", SN_NOWARN) MakeNameEx(LocByName("sub_4010CE"), "GetDDE...
make_name_ex(loc_by_name('sub_401000'), 'j_appfat_cpp_init', SN_NOWARN) make_name_ex(loc_by_name('sub_401005'), 'appfat_cpp_init', SN_NOWARN) make_name_ex(loc_by_name('sub_401010'), 'appfat_cpp_free', SN_NOWARN) make_name_ex(loc_by_name('sub_40102A'), 'GetErr', SN_NOWARN) make_name_ex(loc_by_name('sub_4010CE'), 'GetDDE...
# -*- coding: utf-8 -*- def xstr(s): if s is None: return "" else: return str(s)
def xstr(s): if s is None: return '' else: return str(s)
fruits = ['grape', 'raspberry', 'apple', 'banana'] fruits_copy = fruits.copy() print(f"fruits: {fruits}") sorted_fruits = sorted(fruits) assert fruits == fruits_copy print(f"sorted(fruits): {sorted_fruits}") sorted_fruits = sorted(fruits, reverse=True) assert fruits == fruits_copy print(f"sorted(fruits, reverse=True...
fruits = ['grape', 'raspberry', 'apple', 'banana'] fruits_copy = fruits.copy() print(f'fruits: {fruits}') sorted_fruits = sorted(fruits) assert fruits == fruits_copy print(f'sorted(fruits): {sorted_fruits}') sorted_fruits = sorted(fruits, reverse=True) assert fruits == fruits_copy print(f'sorted(fruits, reverse=True): ...
# http://codeforces.com/problemset/problem/59/A text = input() upper_counter = 0 lower_counter = 0 for char in text: if char.isupper(): upper_counter += 1 elif char.islower(): lower_counter += 1 if lower_counter > upper_counter: text = text.lower() elif upper_counter > lower_counter: ...
text = input() upper_counter = 0 lower_counter = 0 for char in text: if char.isupper(): upper_counter += 1 elif char.islower(): lower_counter += 1 if lower_counter > upper_counter: text = text.lower() elif upper_counter > lower_counter: text = text.upper() else: text = text.lower() p...
class Base(): def __init__(self, agent, base_location): self.base_location = base_location self.agent = agent self.mineral_fields = [] self.geysers = [] self.compute_mineral_fields() self.compute_geysers() def get_mineral_fields(self): return se...
class Base: def __init__(self, agent, base_location): self.base_location = base_location self.agent = agent self.mineral_fields = [] self.geysers = [] self.compute_mineral_fields() self.compute_geysers() def get_mineral_fields(self): return self.mineral_...
# Represents a single node in the Trie class TrieNode: def __init__(self, end_of_word=False): # Initialize this node in the Trie # Indicates whether the string ends here is a valid word self.end_of_word = end_of_word # A dictionary to store the possible characters in this node ...
class Trienode: def __init__(self, end_of_word=False): self.end_of_word = end_of_word self.char_dict = dict() def insert(self, char): sub_char_node = trie_node() self.char_dict[char] = sub_char_node return sub_char_node def suffixes(self, suffix=''): output...
host = "PASTE_YOUR_HOST_URL_HERE" asrkey = 'PASTE_YOUR_ASR_API_KEY_HERE' ttskey = 'PASTE_YOUR_TTS_API_KEY_HERE' speaker = "nick"
host = 'PASTE_YOUR_HOST_URL_HERE' asrkey = 'PASTE_YOUR_ASR_API_KEY_HERE' ttskey = 'PASTE_YOUR_TTS_API_KEY_HERE' speaker = 'nick'
# -*- coding: utf-8 -*- # # Copyright 2011, Toru Maesaka # Copyright 2014, Carlos Rodrigues # # Redistribution and use of this source code is licensed under # the BSD license. See COPYING file for license description. # class KyotoTycoonException(Exception): pass # EOF - kt_error.py
class Kyototycoonexception(Exception): pass
# # Catching this Exception captures all known/planned error conditions # class OAuthSSHError(Exception): "Base class for all custom exceptions in this module" def __init__(self, msg): super(OAuthSSHError, self).__init__(msg)
class Oauthssherror(Exception): """Base class for all custom exceptions in this module""" def __init__(self, msg): super(OAuthSSHError, self).__init__(msg)
def factorial(n): # test for a base case if n == 0: return 1 else: return n*factorial(n-1) # make a calculation and a recursive call print(factorial(4))
def factorial(n): if n == 0: return 1 else: return n * factorial(n - 1) print(factorial(4))
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def getDecimalValue(self, head: ListNode) -> int: binaryString = "" node = head while(node != None): binaryString...
class Solution: def get_decimal_value(self, head: ListNode) -> int: binary_string = '' node = head while node != None: binary_string += str(node.val) node = node.next length = len(binaryString) decimal_value = 0 while head != None: ...
# # PySNMP MIB module HH3C-IFQOS2-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HH3C-IFQOS2-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:27:24 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, value_size_constraint, constraints_intersection, single_value_constraint, value_range_constraint) ...
# ANSI color codes RED = "\x1b[31m" GREEN = "\x1b[32m" RESET = "\x1b[0m"
red = '\x1b[31m' green = '\x1b[32m' reset = '\x1b[0m'
def dict_eq(d1, d2): return (all(k in d2 and d1[k] == d2[k] for k in d1) and all(k in d1 and d1[k] == d2[k] for k in d2)) assert dict_eq(dict(a=2, b=3), {'a': 2, 'b': 3}) assert dict_eq(dict({'a': 2, 'b': 3}, b=4), {'a': 2, 'b': 4}) assert dict_eq(dict([('a', 2), ('b', 3)]), {'a': 2, 'b': 3}) a = {'g...
def dict_eq(d1, d2): return all((k in d2 and d1[k] == d2[k] for k in d1)) and all((k in d1 and d1[k] == d2[k] for k in d2)) assert dict_eq(dict(a=2, b=3), {'a': 2, 'b': 3}) assert dict_eq(dict({'a': 2, 'b': 3}, b=4), {'a': 2, 'b': 4}) assert dict_eq(dict([('a', 2), ('b', 3)]), {'a': 2, 'b': 3}) a = {'g': 5} b = {'a...
def square(number): if number <= 0 or number > 64: raise ValueError("square must be between 1 and 64") return 2**(number - 1) def total(): return 2**64 - 1
def square(number): if number <= 0 or number > 64: raise value_error('square must be between 1 and 64') return 2 ** (number - 1) def total(): return 2 ** 64 - 1
class BoaExitException(Exception): pass class BoaRunBuildException(Exception): pass
class Boaexitexception(Exception): pass class Boarunbuildexception(Exception): pass
class Solution: def findLengthOfLCIS(self, nums: List[int]) -> int: result = 0 anchor = 0 for ii, i in enumerate(nums): if (ii > 0 and nums[ii-1] >= nums[ii]): anchor = ii result = max(result, ii - anchor + 1) return result
class Solution: def find_length_of_lcis(self, nums: List[int]) -> int: result = 0 anchor = 0 for (ii, i) in enumerate(nums): if ii > 0 and nums[ii - 1] >= nums[ii]: anchor = ii result = max(result, ii - anchor + 1) return result
class Solution: def halvesAreAlike(self, s: str) -> bool: n = len(s) half_n = int(n/2) # print(half_n) first = s[:half_n] second = s[half_n:] count_first = 0 count_second = 0 s = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'] for i...
class Solution: def halves_are_alike(self, s: str) -> bool: n = len(s) half_n = int(n / 2) first = s[:half_n] second = s[half_n:] count_first = 0 count_second = 0 s = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'] for i in first: if i ...
BOT_NAME = 'amazon2' SPIDER_MODULES = ['amazon2.spiders'] NEWSPIDER_MODULE = 'amazon2.spiders' ROBOTSTXT_OBEY = False CONCURRENT_REQUESTS = 32 COOKIES_ENABLED = False SPIDER_MIDDLEWARES = { 'amazon2.middlewares.AmazonSpiderMiddleware.AmazonSpiderMiddleware': 543, } DOWNLOADER_MIDDLEWARES = { 'scrapy.down...
bot_name = 'amazon2' spider_modules = ['amazon2.spiders'] newspider_module = 'amazon2.spiders' robotstxt_obey = False concurrent_requests = 32 cookies_enabled = False spider_middlewares = {'amazon2.middlewares.AmazonSpiderMiddleware.AmazonSpiderMiddleware': 543} downloader_middlewares = {'scrapy.downloadermiddlewares.u...
def good(num, name=None): b = bad(num) u = ugly(name) return f"The GOOD({num}, name={name}), The BAD->{b}, and The UGLY->{u}" def bad(num): u = ugly(num) return f"The BAD({num}) got UGLY->{u}" def ugly(num): return 42 / num
def good(num, name=None): b = bad(num) u = ugly(name) return f'The GOOD({num}, name={name}), The BAD->{b}, and The UGLY->{u}' def bad(num): u = ugly(num) return f'The BAD({num}) got UGLY->{u}' def ugly(num): return 42 / num
class AppControlInterface: def __init__(self): pass def scroll_up(self, amount): pass def scroll_down(self, amount): pass
class Appcontrolinterface: def __init__(self): pass def scroll_up(self, amount): pass def scroll_down(self, amount): pass
#!/usr/bin/python # -*- coding: utf-8 -*- # Created: 02/07/2022(m/d/y) 16:44:11 UTC from "Archnemesis" data desc = "Challenge Autogen" # Base type : settings pair items = { }
desc = 'Challenge Autogen' items = {}
class FourCal: def setdata(self, first, second): self.first = first self.second = second def sum(self): result = self.first + self.second return result def sub(self): result = self.first - self.second return result def mul(self): re...
class Fourcal: def setdata(self, first, second): self.first = first self.second = second def sum(self): result = self.first + self.second return result def sub(self): result = self.first - self.second return result def mul(self): result = self....
# Copyright 2016 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. { 'targets': [ # { # 'target_name': 'files_icon_button', # 'includes': ['../../../compile_js2.gypi'], # }, # { # 'target_name': 'fil...
{'targets': []}
# sample function to get a prediction from the model def getPrediction(text): if type(text) is str: return len(text) else: return -1
def get_prediction(text): if type(text) is str: return len(text) else: return -1
notas = [[['A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T'], 1], [['D', 'G'], 2], [['B', 'C', 'M', 'P'], 3], [['F', 'H', 'V', 'W', 'Y'], 4], [['K'], 5], [['J', 'X'], 8], [['Q', 'Z'], 10]] def score(word): total = 0 word = word.upper() for letra in wo...
notas = [[['A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T'], 1], [['D', 'G'], 2], [['B', 'C', 'M', 'P'], 3], [['F', 'H', 'V', 'W', 'Y'], 4], [['K'], 5], [['J', 'X'], 8], [['Q', 'Z'], 10]] def score(word): total = 0 word = word.upper() for letra in word: for n in notas: if letra in n[0]...
def splitDate(date): splitup = date.split('.') return splitup[1], splitup[0], splitup[2]
def split_date(date): splitup = date.split('.') return (splitup[1], splitup[0], splitup[2])
class Solution: def searchInsert(self, nums: List[int], target: int) -> int: for x in range(len(nums)): if nums[x] >= target: return x return (len(nums))
class Solution: def search_insert(self, nums: List[int], target: int) -> int: for x in range(len(nums)): if nums[x] >= target: return x return len(nums)
# -*- coding: utf-8 -*- ''' File name: code\nontransitive_sets_of_dice\sol_376.py Author: Vaidic Joshi Date created: Oct 20, 2018 Python Version: 3.x ''' # Solution to Project Euler Problem #376 :: Nontransitive sets of dice # # For more information see: # https://projecteuler.net/problem=376 # Prob...
""" File name: code ontransitive_sets_of_dice\\sol_376.py Author: Vaidic Joshi Date created: Oct 20, 2018 Python Version: 3.x """ '\nConsider the following set of dice with nonstandard pips:\n\n\n\nDie A: 1 4 4 4 4 4\nDie B: 2 2 2 5 5 5\nDie C: 3 3 3 3 3 6\n\n\nA game is played by two players picking a ...
def gcd(m,n): while n>0: t=m%n m=n n=t return m input();A=list(map(int,input().split())) input();B=list(map(int,input().split())) AA=1; BB=1 for i in A: AA*=i for i in B: BB*=i result=gcd(AA,BB) if result >= 10**9: print("%09d" % (result%(10**9))) else: print(result)
def gcd(m, n): while n > 0: t = m % n m = n n = t return m input() a = list(map(int, input().split())) input() b = list(map(int, input().split())) aa = 1 bb = 1 for i in A: aa *= i for i in B: bb *= i result = gcd(AA, BB) if result >= 10 ** 9: print('%09d' % (result % 10 ** 9...
def title_card(code_name): print('\n~~~~~~~~~~~~~~~~~~~~~~~') print(code_name) print('~~~~~~~~~~~~~~~~~~~~~~~ \n')
def title_card(code_name): print('\n~~~~~~~~~~~~~~~~~~~~~~~') print(code_name) print('~~~~~~~~~~~~~~~~~~~~~~~ \n')
# 155. Min Stack # ttungl@gmail.com class MinStack(object): # using list array # runtime: 72 ms def __init__(self): self.stack = [] def push(self, x): if not self.stack: self.stack.append((x, x)) else: self.stack.append((x, min(x, self.stack[-1][1]))) # keep track o...
class Minstack(object): def __init__(self): self.stack = [] def push(self, x): if not self.stack: self.stack.append((x, x)) else: self.stack.append((x, min(x, self.stack[-1][1]))) def pop(self): if self.stack: self.stack.pop() def t...
# This file contains defaults that this module uses # Max allowed for assumed safe request, any higher than this # Will raise a RateLimitReached Exception # If the rate limiter cant assume a safe request # Due to the assumption being to risky at this point max_safe_requests = 40 # quater of safe requests max_ongoing...
max_safe_requests = 40 max_ongoing_requests = 10 ratelimit_max = 40 ratelimit_within = 30 ratelimit_maxsleeps = 90 ratelimit_sleep_time = 0.5
x = 10 def foo(x): y = x * 2 return bar(y) def bar(y): y = x / 2 return y z = foo(x)
x = 10 def foo(x): y = x * 2 return bar(y) def bar(y): y = x / 2 return y z = foo(x)
# Copyright (c) 2020 Vishnu J. Seesahai # Use of this source code is governed by an MIT # license that can be found in the LICENSE file. MIN_CONF = '6' MAX_CONF = '9999999'
min_conf = '6' max_conf = '9999999'
class Node: def __init__(self, item, next): self.item = item self.next = next class Stack: def __init__(self): self.last = None def push(self, item): self.last = Node(item, self.last) def pop(self): item = self.last.item self.last = self.last.next ...
class Node: def __init__(self, item, next): self.item = item self.next = next class Stack: def __init__(self): self.last = None def push(self, item): self.last = node(item, self.last) def pop(self): item = self.last.item self.last = self.last.next ...
class Solution: def findPeakElement(self, nums: List[int]) -> int: # dfs solution to solve this problem nums = [-float('inf')] + nums + [-float('inf')] lo, hi = 0, len(nums)-1 while lo < hi: mid = (lo+hi)//2 if nums[mid] > nums[mid-1] and nums[mid] > ...
class Solution: def find_peak_element(self, nums: List[int]) -> int: nums = [-float('inf')] + nums + [-float('inf')] (lo, hi) = (0, len(nums) - 1) while lo < hi: mid = (lo + hi) // 2 if nums[mid] > nums[mid - 1] and nums[mid] > nums[mid + 1]: return m...
a = 2 < 3 b = 2 + 4 c = (1 <= 2 ) and (1 <= 3) x = 1 + 2 * 3 y = 1 * 2 + 3 x = 2+3 < 2+1 or 2 < 3 and not not True y = not True and False
a = 2 < 3 b = 2 + 4 c = 1 <= 2 and 1 <= 3 x = 1 + 2 * 3 y = 1 * 2 + 3 x = 2 + 3 < 2 + 1 or (2 < 3 and (not not True)) y = not True and False
class deque: def __init__(self): self.items=[] def isEmpty(self): return self.item==[] def addRear(self,item): self.items.append(item) def addFront(self,item): self.items.insert(0,item) def removeFront(self): return self.pop() def removeRear(self): ...
class Deque: def __init__(self): self.items = [] def is_empty(self): return self.item == [] def add_rear(self, item): self.items.append(item) def add_front(self, item): self.items.insert(0, item) def remove_front(self): return self.pop() def remove_r...
class Solution: def smallerNumbersThanCurrent(self, nums: List[int]) -> List[int]: x=[] for i in nums: x.append(sum([1 for y in nums if y<i])) return x
class Solution: def smaller_numbers_than_current(self, nums: List[int]) -> List[int]: x = [] for i in nums: x.append(sum([1 for y in nums if y < i])) return x
def score_submission(submission): # first remove existing leaderboard entries # read in scores dictionary, ex: # scoring_program_output = { # "RESULTS": [ # ("Score", 1), # ], # "ALTERNATE_RESULTS": [ # ("Score", 2), # (...
def score_submission(submission): pass
''' Write a function, gooseFilter / goose-filter / goose_filter / GooseFilter, that takes an array of strings as an argument and returns a filtered array containing the same elements but with the 'geese' removed. The geese are any strings in the following array, which is pre-populated in your solution: geese = ["Afri...
""" Write a function, gooseFilter / goose-filter / goose_filter / GooseFilter, that takes an array of strings as an argument and returns a filtered array containing the same elements but with the 'geese' removed. The geese are any strings in the following array, which is pre-populated in your solution: geese = ["Afri...
# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
def gen_box(image_width, image_height, size, step, zoom_step, skip=1): zoom = 1.0 cnt = 0 boxes = [] while zoom <= min(image_width, image_height): s = size * zoom x = 0.0 while x + s <= image_width: y = 0.0 while y + s <= image_height: if c...
# Variables can be used to hold information. # Integer-type initial_amount = 100 # Float-type interest_rate = 5.0 # Integer-type num_of_years = 7 # The type of "final_amount" must be deduced from the number-types in the expression. # The type of "final_amount" will be the least precise type that's involved in the c...
initial_amount = 100 interest_rate = 5.0 num_of_years = 7 final_amount = initial_amount * (1 + interest_rate / 100) ** num_of_years print(f'After {num_of_years} years, {initial_amount} has grown to {final_amount:.2f}.')
# # Author VinhLH <vinh.le@zalora.com> # Copyright Mar 2016 # # Configs host = '' port = 8888 workDir = '/Users/vinhlh/Works/test' log = 'server.log'
host = '' port = 8888 work_dir = '/Users/vinhlh/Works/test' log = 'server.log'
def register(mf): mf.register_defaults({ "fuzzy": __file__, "fuzzychild_nonunique": __file__ })
def register(mf): mf.register_defaults({'fuzzy': __file__, 'fuzzychild_nonunique': __file__})
# !/usr/bin/env python3 # Author: C.K # Email: theck17@163.com # DateTime:2021-09-14 21:20:08 # Description: class Solution: def fractionToDecimal(self, numerator: int, denominator: int) -> str: if numerator % denominator == 0: return str(numerator // denominator) sign = '' if numerator ...
class Solution: def fraction_to_decimal(self, numerator: int, denominator: int) -> str: if numerator % denominator == 0: return str(numerator // denominator) sign = '' if numerator * denominator >= 0 else '-' (numerator, denominator) = (abs(numerator), abs(denominator)) ...
valor = int(input()) print('{}'.format(valor)) numero100 = valor//100 print('{} nota(s) de R$ 100,00'.format(numero100)) valor -= numero100*100 #valor - valor (menos ele mesmo) numero50 = valor//50 print('{} nota(s) de R$ 50,00'.format(numero50)) valor -= numero50*50 numero20 = valor//20 print('{} nota(s) de R$ 20,...
valor = int(input()) print('{}'.format(valor)) numero100 = valor // 100 print('{} nota(s) de R$ 100,00'.format(numero100)) valor -= numero100 * 100 numero50 = valor // 50 print('{} nota(s) de R$ 50,00'.format(numero50)) valor -= numero50 * 50 numero20 = valor // 20 print('{} nota(s) de R$ 20,00'.format(numero20)) valor...
def func_read_in_pattern_file(pattern_file_path): pattern_dict = {} with open(pattern_file_path, 'r') as file: for line in file: line_lst = line.strip().split(",") pattern_dict[line_lst[0]] = [line_lst[1], line_lst[2], line_lst[3], line_lst[4]] return pattern_dict
def func_read_in_pattern_file(pattern_file_path): pattern_dict = {} with open(pattern_file_path, 'r') as file: for line in file: line_lst = line.strip().split(',') pattern_dict[line_lst[0]] = [line_lst[1], line_lst[2], line_lst[3], line_lst[4]] return pattern_dict
# Copyright (c) 2015 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. { 'targets': [ { 'target_name': 'test_default', 'type': 'executable', 'sources': ['hello.cc'], }, { 'target_name'...
{'targets': [{'target_name': 'test_default', 'type': 'executable', 'sources': ['hello.cc']}, {'target_name': 'test_set_reserved_size', 'type': 'executable', 'sources': ['hello.cc'], 'msvs_settings': {'VCLinkerTool': {'StackReserveSize': 2097152}}}, {'target_name': 'test_set_commit_size', 'type': 'executable', 'sources'...
# Write a small program to ask for a name and an age. # When both values have been entered, check if the person # is the right age to go on an 18-30 holiday (they must be # over 18 and under 31). # If they are, welcome them to the holiday, otherwise print # a (polite) message refusing them entry. name = input("Please e...
name = input('Please enter your name: ') age = int(input('How old are you, {0}? '.format(name))) if age >= 18 and age < 31: print('Welcome to club 18-30 holidays, {0}'.format(name)) else: print("I'm sorry, our holidays are only for seriously cool people")
class Phone: def __init__(self, str): str = ''.join([x for x in str if x in '0123456789']) if len(str) == 10: self.number = str elif len(str) == 11 and str[0] == '1': self.number = str[1:] else: raise ValueError('bad format') self....
class Phone: def __init__(self, str): str = ''.join([x for x in str if x in '0123456789']) if len(str) == 10: self.number = str elif len(str) == 11 and str[0] == '1': self.number = str[1:] else: raise value_error('bad format') self.area_co...
ABI_ENDPOINT = "https://api.etherscan.io/api?module=contract&action=getabi&address=" POLYGON_ABI_ENDPOINT = ( "https://api.polygonscan.com/api?module=contract&action=getabi&address=" ) ENDPOINT = "" POLYGON_ENDPOINT = "" ATTRIBUTES_FOLDER = "raw_attributes" IMPLEMENTATION_SLOT = ( "0x360894a13ba1a3210667c828492...
abi_endpoint = 'https://api.etherscan.io/api?module=contract&action=getabi&address=' polygon_abi_endpoint = 'https://api.polygonscan.com/api?module=contract&action=getabi&address=' endpoint = '' polygon_endpoint = '' attributes_folder = 'raw_attributes' implementation_slot = '0x360894a13ba1a3210667c828492db98dca3e2076c...
studentdata = {} alldata = [] studentdata['Name'] = str(input("Type the Student's name: ")) studentdata['AVGRADE'] = float(input("Type the Average Grade of the Student: ")) if studentdata['AVGRADE'] < 5: studentdata['Situation'] = ("Reproved") elif studentdata['AVGRADE'] > 5 and studentdata['AVGRADE'] < 7: stud...
studentdata = {} alldata = [] studentdata['Name'] = str(input("Type the Student's name: ")) studentdata['AVGRADE'] = float(input('Type the Average Grade of the Student: ')) if studentdata['AVGRADE'] < 5: studentdata['Situation'] = 'Reproved' elif studentdata['AVGRADE'] > 5 and studentdata['AVGRADE'] < 7: studen...
# -*- coding: utf-8 -*- f = open(filename) char = f.read(1) while char: process(char) char = f.read(1) f.close()
f = open(filename) char = f.read(1) while char: process(char) char = f.read(1) f.close()
b = str(input()).split() d = int(b[0]) c= int(b[1]) e = '.|.' for i in range(1,d,2): print((e*i).center(c,'-')) print(('WELCOME').center(c,'-')) for i in range(d-2,-1,-2): print((e * i).center(c, '-'))
b = str(input()).split() d = int(b[0]) c = int(b[1]) e = '.|.' for i in range(1, d, 2): print((e * i).center(c, '-')) print('WELCOME'.center(c, '-')) for i in range(d - 2, -1, -2): print((e * i).center(c, '-'))
LANGUAGE_CODE = 'ru-RU' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True
language_code = 'ru-RU' time_zone = 'UTC' use_i18_n = True use_l10_n = True use_tz = True
fila1="abcdefghi" fila2="jklmnopqr" fila3="stuvwxyz" n=int(input()) for i in range(0,n): flag=True palabras=input() palabras=palabras.strip().split() if (len(palabras[0])==len(palabras[1])): if (palabras[0]==palabras[1]): print("1") pass else: ...
fila1 = 'abcdefghi' fila2 = 'jklmnopqr' fila3 = 'stuvwxyz' n = int(input()) for i in range(0, n): flag = True palabras = input() palabras = palabras.strip().split() if len(palabras[0]) == len(palabras[1]): if palabras[0] == palabras[1]: print('1') pass else: ...
# Which of the following expressions return the infinity values? # Suppose, the variables inf and nan have been defined. nan = float("nan") inf = float("inf") print(0.0 / inf) # nan print(inf / 2 - inf) # inf print(100 * inf + nan) # inf print(inf - 10 ** 300) # nan print(-inf * inf) ...
nan = float('nan') inf = float('inf') print(0.0 / inf) print(inf / 2 - inf) print(100 * inf + nan) print(inf - 10 ** 300) print(-inf * inf)
lines = open('input.txt', 'r').readlines() # create graph node_hash_list = dict() node_hash_list["start"] = set() for line in lines: p1, p2 = line.strip().split("-") if p2 not in node_hash_list: node_hash_list[p2] = set() if p1 not in node_hash_list: node_hash_list[p1] = set() if not...
lines = open('input.txt', 'r').readlines() node_hash_list = dict() node_hash_list['start'] = set() for line in lines: (p1, p2) = line.strip().split('-') if p2 not in node_hash_list: node_hash_list[p2] = set() if p1 not in node_hash_list: node_hash_list[p1] = set() if not p1 == 'end' and ...
KEY_TO_SYM = { "ArrowLeft": "Left", "ArrowRight": "Right", "ArrowUp": "Up", "ArrowDown": "Down", "BackSpace": "BackSpace", "Tab": "Tab", "Enter": "Return", # 'Shift': 'Shift_L', # 'Control': 'Control_L', # 'Alt': 'Alt_L', "CapsLock": "Caps_Lock", "Escape": "Escape", "...
key_to_sym = {'ArrowLeft': 'Left', 'ArrowRight': 'Right', 'ArrowUp': 'Up', 'ArrowDown': 'Down', 'BackSpace': 'BackSpace', 'Tab': 'Tab', 'Enter': 'Return', 'CapsLock': 'Caps_Lock', 'Escape': 'Escape', ' ': 'space', 'PageUp': 'Prior', 'PageDown': 'Next', 'Home': 'Home', 'End': 'End', 'Delete': 'Delete', 'Insert': 'Insert...