content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
def get_context_user(context): if 'user' in context: return context['user'] elif 'request' in context: return getattr(context['request'], 'user', None)
def get_context_user(context): if 'user' in context: return context['user'] elif 'request' in context: return getattr(context['request'], 'user', None)
APP_NAME = "PythonCef.Vue.Vuetify2 Template" APP_NAME_NO_SPACE = APP_NAME.replace(' ', '') APP_VERSION = '0.0.1' APP_DESCRIPTION = "Template using PythonCef, Flask, Vue, webpack"
app_name = 'PythonCef.Vue.Vuetify2 Template' app_name_no_space = APP_NAME.replace(' ', '') app_version = '0.0.1' app_description = 'Template using PythonCef, Flask, Vue, webpack'
def count_substring(string, sub_string): c = 0 for i in range(0, len(string)): ss = string[i:len(sub_string)+i] if sub_string == ss: c += 1 return c print(count_substring('ABCDCDC', 'CDC')) print(count_substring('I am an Indian, by birth', 'Birth')) print(count_substring('Th...
def count_substring(string, sub_string): c = 0 for i in range(0, len(string)): ss = string[i:len(sub_string) + i] if sub_string == ss: c += 1 return c print(count_substring('ABCDCDC', 'CDC')) print(count_substring('I am an Indian, by birth', 'Birth')) print(count_substring('ThIsi...
class PortData(object): def __init__(self, from_port, to_port, protocol, destination): """ec2_session :param from_port: to_port-start port :type from_port: int :param to_port: from_port-end port :type to_port: int :param protocol: protocol-can be UDP or TCP :...
class Portdata(object): def __init__(self, from_port, to_port, protocol, destination): """ec2_session :param from_port: to_port-start port :type from_port: int :param to_port: from_port-end port :type to_port: int :param protocol: protocol-can be UDP or TCP ...
a=int(input("Input an integer :")) n1=int("%s"%a) n2=int("%s%s"%(a,a)) n3=int("%s%s%s"%(a,a,a)) print(n1+n2+n3)
a = int(input('Input an integer :')) n1 = int('%s' % a) n2 = int('%s%s' % (a, a)) n3 = int('%s%s%s' % (a, a, a)) print(n1 + n2 + n3)
class Solution: def hasPathSum(self, root, target): def check(curr_node, curr_val): calc_val = curr_val + curr_node.val if calc_val == target and curr_node.left is None and curr_node.right is None: return True elif curr_node.left is not None and check(curr...
class Solution: def has_path_sum(self, root, target): def check(curr_node, curr_val): calc_val = curr_val + curr_node.val if calc_val == target and curr_node.left is None and (curr_node.right is None): return True elif curr_node.left is not None and chec...
#Boolean is like telling Python to do something based on conditions: #if this is true, do this; else do something different. #conditional logic in Python is written using booleans (True and False), along with if statements. user = 'James Bond' if user == 'James Bond': print('Awesome!') elif user == 'Ethan Hunt...
user = 'James Bond' if user == 'James Bond': print('Awesome!') elif user == 'Ethan Hunt': print('Cool!') else: print('Nope!') if 30 > 40 or 40 > 30: print('yeah!') if 1 == 1 and 2 == 2: print('hmmm!') if not False: print('not False is oviously True ') if 30 < 40 and 40 < 50: print('this is o...
##Patterns: W0109 ##Warn: W0109 cities = { 'CA': 'San Francisco', 'MI': 'Detroit', 'FL': 'Jacksonville', 'MI': 'Detroit' }
cities = {'CA': 'San Francisco', 'MI': 'Detroit', 'FL': 'Jacksonville', 'MI': 'Detroit'}
""" Reminders depending on the day of the week """ monday_msg = ["I hope you planned this week on Friday evening itself. If not, please do it now. Send out all the calendar events that you need to for this week. Accept (or reject) the calendar invites you received. Know at least two of your top priorities.", "Did you ...
""" Reminders depending on the day of the week """ monday_msg = ['I hope you planned this week on Friday evening itself. If not, please do it now. Send out all the calendar events that you need to for this week. Accept (or reject) the calendar invites you received. Know at least two of your top priorities.', 'Did you p...
""" Write a Python program to swap cases of a given string. Sample Output: pYTHON eXERCISES jAVA nUMpy """ def swap_case_string(str1): result_str = "" for item in str1: if item.isupper(): result_str += item.lower() else: result_str += item.upper() return result_str pr...
""" Write a Python program to swap cases of a given string. Sample Output: pYTHON eXERCISES jAVA nUMpy """ def swap_case_string(str1): result_str = '' for item in str1: if item.isupper(): result_str += item.lower() else: result_str += item.upper() return result_str p...
matriz = ([0,0,0], [0,0,0], [0,0,0]) par = terceira = maior = 0 for l in range(0,3): for c in range(0,3): matriz[l][c] = int(input(f'Type a value for [{l}, {c}]: ')) if matriz[l][c] % 2 == 0: par += matriz[l][c] print('=-'*15) for l in range (0,3): for c in range(0,3): print(...
matriz = ([0, 0, 0], [0, 0, 0], [0, 0, 0]) par = terceira = maior = 0 for l in range(0, 3): for c in range(0, 3): matriz[l][c] = int(input(f'Type a value for [{l}, {c}]: ')) if matriz[l][c] % 2 == 0: par += matriz[l][c] print('=-' * 15) for l in range(0, 3): for c in range(0, 3): ...
class Constant: __excludes__ = [] class ConstantError(Exception): pass def __setattr__(self, name, value): exclude = name in Constant.__excludes__ if self.__dict__.get(name, None) and not exclude: raise Constant.ConstantError("Property %s is not mutable" % name) ...
class Constant: __excludes__ = [] class Constanterror(Exception): pass def __setattr__(self, name, value): exclude = name in Constant.__excludes__ if self.__dict__.get(name, None) and (not exclude): raise Constant.ConstantError('Property %s is not mutable' % name) ...
even = int(input("total even number : ")) print(even, "first even number : ",end="") for i in range(2,even*2,2): print (i,end=", ") print(even*2)
even = int(input('total even number : ')) print(even, 'first even number : ', end='') for i in range(2, even * 2, 2): print(i, end=', ') print(even * 2)
class Alphabet: """ Bijective mapping from strings to integers. >>> a = Alphabet() >>> [a[x] for x in 'abcd'] [0, 1, 2, 3] >>> list(map(a.lookup, range(4))) ['a', 'b', 'c', 'd'] >>> a.stop_growth() >>> a['e'] >>> a.freeze() >>> a.add('z') Traceback (most recent call last)...
class Alphabet: """ Bijective mapping from strings to integers. >>> a = Alphabet() >>> [a[x] for x in 'abcd'] [0, 1, 2, 3] >>> list(map(a.lookup, range(4))) ['a', 'b', 'c', 'd'] >>> a.stop_growth() >>> a['e'] >>> a.freeze() >>> a.add('z') Traceback (most recent call last)...
__all__ = ["mi_enb_decoder"] PACKET_TYPE = { "0xB0A3": "LTE_PDCP_DL_Cipher_Data_PDU", "0xB0B3": "LTE_PDCP_UL_Cipher_Data_PDU", "0xB173": "LTE_PHY_PDSCH_Stat_Indication", "0xB063": "LTE_MAC_DL_Transport_Block", "0xB064": "LTE_MAC_UL_Transport_Block", "0xB092": "LTE_RLC_UL_AM_All_PDU", "0xB082": "LTE_RLC_D...
__all__ = ['mi_enb_decoder'] packet_type = {'0xB0A3': 'LTE_PDCP_DL_Cipher_Data_PDU', '0xB0B3': 'LTE_PDCP_UL_Cipher_Data_PDU', '0xB173': 'LTE_PHY_PDSCH_Stat_Indication', '0xB063': 'LTE_MAC_DL_Transport_Block', '0xB064': 'LTE_MAC_UL_Transport_Block', '0xB092': 'LTE_RLC_UL_AM_All_PDU', '0xB082': 'LTE_RLC_DL_AM_All_PDU', '...
# Python - 2.7.6 eval_object = lambda v: { '+': v['a'] + v['b'], '-': v['a'] - v['b'], '/': v['a'] / v['b'], '*': v['a'] * v['b'], '%': v['a'] % v['b'], '**': v['a'] ** v['b'] }.get(v['operation'], 0)
eval_object = lambda v: {'+': v['a'] + v['b'], '-': v['a'] - v['b'], '/': v['a'] / v['b'], '*': v['a'] * v['b'], '%': v['a'] % v['b'], '**': v['a'] ** v['b']}.get(v['operation'], 0)
frase = str(input('Digite uma frase: ')) m5 = ' '.join(frase.replace(' ', '')) print(m5.split())
frase = str(input('Digite uma frase: ')) m5 = ' '.join(frase.replace(' ', '')) print(m5.split())
# varia class Sleep: def NREM(self): print('NREM') def REM(self): print('REM') class Awake: def act(self): print('act')
class Sleep: def nrem(self): print('NREM') def rem(self): print('REM') class Awake: def act(self): print('act')
#Init records_storage = dict() line_break = "-----------------------------------------------\n" run_program = True # Define Functions def add_item(key, value): records_storage[key] = value def delete_item(key): try: del records_storage[key] except KeyError: print(f"Key '{key}' could not be f...
records_storage = dict() line_break = '-----------------------------------------------\n' run_program = True def add_item(key, value): records_storage[key] = value def delete_item(key): try: del records_storage[key] except KeyError: print(f"Key '{key}' could not be found") except: ...
def example1(): g = ig.load("data/out_1.graphml") # whichever file you would like dend = g.community_fastgreedy() #get the clustering object c = dend.as_clustering() result = metrics.run_analysis(c) print(c)
def example1(): g = ig.load('data/out_1.graphml') dend = g.community_fastgreedy() c = dend.as_clustering() result = metrics.run_analysis(c) print(c)
class Player(object): def __init__(self): self.name = None self.results = dict() self.rolls = [] self.scores = dict() # # set pins scores for a frame. # def set_result(self, frame, result): self.results[frame] = result def calculate_scor...
class Player(object): def __init__(self): self.name = None self.results = dict() self.rolls = [] self.scores = dict() def set_result(self, frame, result): self.results[frame] = result def calculate_score(self): running_total = 0 for (frame, result) ...
class PyttmanProjectInvalidException(BaseException): """ Exception class for internal use. Raise this exception in situations when a user project is incorrectly configured in whatever way. """ pass class TypeConversionFailed(BaseException): """ Exception class for internal use. Ra...
class Pyttmanprojectinvalidexception(BaseException): """ Exception class for internal use. Raise this exception in situations when a user project is incorrectly configured in whatever way. """ pass class Typeconversionfailed(BaseException): """ Exception class for internal use. Rais...
#--------------------------------- # BATCH DEFAULTS #--------------------------------- # The default options applied to each stage in the shell script. These options # are overwritten by the options provided by the individual stages in the next # section. # Stage options which Rubra will recognise are: # - distribute...
stage_defaults = {'distributed': True, 'walltime': '01:00:00', 'memInGB': 4, 'queue': 'main', 'modules': ['perl/5.18.0', 'java/1.7.0_25', 'samtools-intel/0.1.19', 'python-gcc/2.7.5', 'fastqc/0.10.1', 'bowtie2-intel/2.1.0', 'tophat-gcc/2.0.8', 'cufflinks-gcc/2.1.1', 'bwa-intel/0.7.5a'], 'manager': 'slurm'} stages = {'ma...
class Diamond: START_LETTER = 'A' ENTER = '\n' SPACE = ' ' BLANK = '' def __init__(self, upTo): self.upTo = upTo def show(self): top = self.BLANK bottom = self.BLANK for c in range(ord(self.START_LETTER), ord(self.upTo)+1): line = self....
class Diamond: start_letter = 'A' enter = '\n' space = ' ' blank = '' def __init__(self, upTo): self.upTo = upTo def show(self): top = self.BLANK bottom = self.BLANK for c in range(ord(self.START_LETTER), ord(self.upTo) + 1): line = self.buildLine(ch...
# https://docs.google.com/document/d/1Ljm9S29J-mFOZ3fwrkGohMDrn9fORVteWjzucuZfyaM/edit?usp=sharing # Huu Hung Nguyen # 12/12/2021 # Nguyen_HuuHung_accounts.py # The program stores the Account class, the SavingAccount class, and # the CreditCardAccount class. class Account: ''' Account class for representing and ...
class Account: """ Account class for representing and manipulating number, balance coordinates. """ def __init__(self, number, balance): """ Create a new point at the given coordinates. """ self.number = number self.balance = balance def __str__(self): """ Display t...
path = "data/DataPoints.txt" lines_path = "data/lines.txt" index_and_slope_delim = ';' slope_and_intercept_delim = ":" delim = ","
path = 'data/DataPoints.txt' lines_path = 'data/lines.txt' index_and_slope_delim = ';' slope_and_intercept_delim = ':' delim = ','
routers = dict( BASE = dict( default_application = "webremote", default_controller = "webremote", default_function = "index", ) )
routers = dict(BASE=dict(default_application='webremote', default_controller='webremote', default_function='index'))
# # PySNMP MIB module BIANCA-BRICK-TOKEN-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/BIANCA-BRICK-TOKEN-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:21:46 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (d...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, single_value_constraint, constraints_intersection, constraints_union, value_range_constraint) ...
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def evalFile(f1, f2): op = open(f1) plain = op.read() op.close() op = open(f2) imperfect = op.read() op.close() list1 = [] list2 = [] for letter in plain: if letter.upper() in LETTERS: if letter.upper() not in list1: ...
letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def eval_file(f1, f2): op = open(f1) plain = op.read() op.close() op = open(f2) imperfect = op.read() op.close() list1 = [] list2 = [] for letter in plain: if letter.upper() in LETTERS: if letter.upper() not in list1: ...
''' You work for an airline, and your manager has asked you to do a competitive analysis and see how often passengers flying on other airlines are involuntarily bumped from their flights. You got a CSV file (airline_bumping.csv) from the Department of Transportation containing data on passengers that were involuntarily...
""" You work for an airline, and your manager has asked you to do a competitive analysis and see how often passengers flying on other airlines are involuntarily bumped from their flights. You got a CSV file (airline_bumping.csv) from the Department of Transportation containing data on passengers that were involuntarily...
# LIFO Stack DS using Python Lists (Arrays) class StacksArray: def __init__(self): self.stackArray = [] def __len__(self): return len(self.stackArray) def isempty(self): return len(self.stackArray) == 0 def display(self): print(self.stackArray) def top(self):...
class Stacksarray: def __init__(self): self.stackArray = [] def __len__(self): return len(self.stackArray) def isempty(self): return len(self.stackArray) == 0 def display(self): print(self.stackArray) def top(self): return self.stackArray[-1] def pop...
class ClassDictionary: def __init__(self, value): self.dict_value = value def __getattribute__(self, name): if name == "dict_value": return super().__getattribute__(name) result = self.dict_value.get(name) return result def __setattr__(self, name, value): ...
class Classdictionary: def __init__(self, value): self.dict_value = value def __getattribute__(self, name): if name == 'dict_value': return super().__getattribute__(name) result = self.dict_value.get(name) return result def __setattr__(self, name, value): ...
# String Rotation: Assume you have a method isSubstringwhich checks if one word is a substring # of another. Given two strings, sl and s2, write code to check if s2 is a rotation of sl using only one # call to isSubstring (e.g., "waterbottle" is a rotation of "erbottlewat") def is_substring(s1, s2): return s2 in s...
def is_substring(s1, s2): return s2 in s1 def is_string_rotation(s1, s2): if not len(s1) == len(s2): return False double_s1 = s1 + s1 return is_substring(double_s1, s2) print(is_string_rotation('waterbottle', 'erbottlewat'))
""" I, Andy Le, student number 000805099, certify that all code submitted is my own work; that i have not copied it from any other source. I also certify that I have not allowed my work to be copied by others. """ def score(earnedPercent, overallWeight): if (earnedPercent == -1): return -1 else...
""" I, Andy Le, student number 000805099, certify that all code submitted is my own work; that i have not copied it from any other source. I also certify that I have not allowed my work to be copied by others. """ def score(earnedPercent, overallWeight): if earnedPercent == -1: return -1 else: ...
__author__ = 'fabian' __all__ = ['handler']
__author__ = 'fabian' __all__ = ['handler']
class AccountNotFoundError(Exception): pass class TransactionError(Exception): pass class AccountClosedError(TransactionError): pass class InsufficientFundsError(TransactionError): pass
class Accountnotfounderror(Exception): pass class Transactionerror(Exception): pass class Accountclosederror(TransactionError): pass class Insufficientfundserror(TransactionError): pass
text = input().split() times_seen = {} for word in text: if word not in times_seen: times_seen[word] = 0 print(times_seen[word], end=' ') times_seen[word] += 1
text = input().split() times_seen = {} for word in text: if word not in times_seen: times_seen[word] = 0 print(times_seen[word], end=' ') times_seen[word] += 1
def LeftView(root): ''' :param root: root of given tree. :return: print the left view of tree, dont print new line ''' # code here res = [] while root: res.append(root.data) if root.left: root = root.left elif root.right: root = root.right ...
def left_view(root): """ :param root: root of given tree. :return: print the left view of tree, dont print new line """ res = [] while root: res.append(root.data) if root.left: root = root.left elif root.right: root = root.right else: ...
# # PySNMP MIB module APPIAN-PPORT-SONET-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/APPIAN-PPORT-SONET-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:23:54 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (d...
(ac_pport, ac_admin_status, ac_op_status, ac_slot_number, ac_port_number, ac_node_id) = mibBuilder.importSymbols('APPIAN-SMI-MIB', 'acPport', 'AcAdminStatus', 'AcOpStatus', 'AcSlotNumber', 'AcPortNumber', 'AcNodeId') (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Inte...
class Solution: def longestConsecutive(self, nums): nums_set = set(nums) longest_seq = 0 for num in nums_set: # Don't need to check if there is a - 1 smaller in the list. if num - 1 not in nums_set: current_num = num current_seq = 1 ...
class Solution: def longest_consecutive(self, nums): nums_set = set(nums) longest_seq = 0 for num in nums_set: if num - 1 not in nums_set: current_num = num current_seq = 1 while current_num + 1 in nums_set: cur...
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU...
{'name': 'Advanced Routes', 'version': '1.0', 'category': 'Manufacturing', 'description': "\nThis module supplements the Warehouse application by effectively implementing Push and Pull inventory flows.\n============================================================================================================\n\nTypic...
def test(): # Here we can either check objects created in the solution code, or the # string value of the solution, available as __solution__. A helper for # printing formatted messages is available as __msg__. See the testTemplate # in the meta.json for details. # If an assertion fails, the message...
def test(): assert not numeric_cols is None, 'Your answer for numeric_cols does not exist. Have you assigned the list of labels for numeric columns to the correct variable name?' assert type(numeric_cols) == list, 'numeric_cols does not appear to be of type list. Can you store all the labels of the numeric colu...
# Section 5.16 Self Check snippets # Exercise 4 t = [[10, 7, 3], [20, 4, 17]] total = 0 items = 0 for row in t: for item in row: total += item items += 1 total / items total = 0 items = 0 for row in t: total += sum(row) items += len(row) total / items #######################...
t = [[10, 7, 3], [20, 4, 17]] total = 0 items = 0 for row in t: for item in row: total += item items += 1 total / items total = 0 items = 0 for row in t: total += sum(row) items += len(row) total / items
""" Test getting repo functions. """ # pylint: disable=invalid-sequence-index def test_get_repos(ghh): """ Default get repos. """ ghh.get_requested_object("ckear1989") ghh.requested_object.get_repos() assert "github" in [repo.name for repo in ghh.requested_object.repos] def test_ignore(ghh):...
""" Test getting repo functions. """ def test_get_repos(ghh): """ Default get repos. """ ghh.get_requested_object('ckear1989') ghh.requested_object.get_repos() assert 'github' in [repo.name for repo in ghh.requested_object.repos] def test_ignore(ghh): """ Get repos with ignore option. ...
def minion_game(string): # your code goes here Kevin = 0 Stuart = 0 word = list(string) x = len(word) vowels = ['A','E','I','O','U'] for inx, w in enumerate(word): if w in vowels: Kevin = Kevin + x else: Stuart = Stuart + x x = x - 1 ...
def minion_game(string): kevin = 0 stuart = 0 word = list(string) x = len(word) vowels = ['A', 'E', 'I', 'O', 'U'] for (inx, w) in enumerate(word): if w in vowels: kevin = Kevin + x else: stuart = Stuart + x x = x - 1 if Stuart > Kevin: ...
no_exists = '{}_does_not_exists' already_exists = '{}_already_exists' exception_occurred = 'exception_occurred' no_modification_made = 'mo_modification_made' no_required_args = 'no_required_args' add_success = 'add_{}_success' delete_success = 'delete_{}_success' __all__ = ['no_exists', 'exception_occurred', 'no_modi...
no_exists = '{}_does_not_exists' already_exists = '{}_already_exists' exception_occurred = 'exception_occurred' no_modification_made = 'mo_modification_made' no_required_args = 'no_required_args' add_success = 'add_{}_success' delete_success = 'delete_{}_success' __all__ = ['no_exists', 'exception_occurred', 'no_modifi...
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' ***************************************** Author: zhlinh Email: zhlinhng@gmail.com Version: 0.0.1 Created Time: 2016-03-21 Last_modify: 2016-03-21 ****************************************** ''' ''' Compare two version numbers version1 and v...
""" ***************************************** Author: zhlinh Email: zhlinhng@gmail.com Version: 0.0.1 Created Time: 2016-03-21 Last_modify: 2016-03-21 ****************************************** """ '\nCompare two version numbers version1 and version2.\nIf version1 > version2 return 1,\nif v...
class RetrievalMethod(): def __init__(self,db): self.db = db def get_sentences_for_claim(self,claim_text,include_text=False): pass
class Retrievalmethod: def __init__(self, db): self.db = db def get_sentences_for_claim(self, claim_text, include_text=False): pass
''' WRITTEN BY Ramon Rossi PURPOSE Consider the Fionacci sequence. It is a sequence of natural numbers defined recursively as follows: * the first element is 0 * the second is 1 * each next element is the sum of the previous two elements This function will sum all even elements of the Fibona...
""" WRITTEN BY Ramon Rossi PURPOSE Consider the Fionacci sequence. It is a sequence of natural numbers defined recursively as follows: * the first element is 0 * the second is 1 * each next element is the sum of the previous two elements This function will sum all even elements of the Fibona...
def caesarCipherEncryptor(string, key): # To solve this problem, we need first to break the string into a list of chars, and then apply a function # basically transform each letter the key shifted, and then join them together. Obviously creating the list will take O(n) time and space # the function can be impleme...
def caesar_cipher_encryptor(string, key): new_letters = [] new_key = key % 26 for letter in string: newLetters.append(get_new_letter(letter, newKey)) return ''.join(newLetters) def get_new_letter(letter, key): new_letter_code = ord(letter) + key return chr(newLetterCode) if newLetterCod...
f = open("test_data.txt", "r") fout = open("test_data_commas.txt", "w") for line in f: fout.write(line.replace(" ", ",")) f.close() fout.close()
f = open('test_data.txt', 'r') fout = open('test_data_commas.txt', 'w') for line in f: fout.write(line.replace(' ', ',')) f.close() fout.close()
class Menu: def __init__(self, Requests, log, presences): self.Requests = Requests self.log = log self.presences = presences def get_party_json(self, GamePlayersPuuid, presencesDICT): party_json = {} for presence in presencesDICT: if presence["puuid"] in...
class Menu: def __init__(self, Requests, log, presences): self.Requests = Requests self.log = log self.presences = presences def get_party_json(self, GamePlayersPuuid, presencesDICT): party_json = {} for presence in presencesDICT: if presence['puuid'] in Gam...
# generated from genmsg/cmake/pkg-genmsg.context.in messages_str = "/home/suntao/workspace/gorobots/utils/real_robots/stbot/catkin_ws/src/lilistbot/msg/Jy901imu.msg" services_str = "" pkg_name = "lilistbot" dependencies_str = "std_msgs" langs = "gencpp;geneus;genlisp;gennodejs;genpy" dep_include_paths_str = "lilistbot...
messages_str = '/home/suntao/workspace/gorobots/utils/real_robots/stbot/catkin_ws/src/lilistbot/msg/Jy901imu.msg' services_str = '' pkg_name = 'lilistbot' dependencies_str = 'std_msgs' langs = 'gencpp;geneus;genlisp;gennodejs;genpy' dep_include_paths_str = 'lilistbot;/home/suntao/workspace/gorobots/utils/real_robots/st...
pirate_ship_status = [int(i) for i in input().split('>')] warship_status = [int(i) for i in input().split('>')] health_capacity = int(input()) while True: command_nosplit = input() if command_nosplit == "Retire": break command = command_nosplit.split() if "Fire" in command: index = int(...
pirate_ship_status = [int(i) for i in input().split('>')] warship_status = [int(i) for i in input().split('>')] health_capacity = int(input()) while True: command_nosplit = input() if command_nosplit == 'Retire': break command = command_nosplit.split() if 'Fire' in command: index = int(c...
class Solution(object): def findDisappearedNumbers(self, nums): return list(set(range(1,len(nums)+1)) - set(nums)) nums = [4, 6, 2, 6, 7, 2, 1] def test(): assert Solution().findDisappearedNumbers(nums) == [3, 5]
class Solution(object): def find_disappeared_numbers(self, nums): return list(set(range(1, len(nums) + 1)) - set(nums)) nums = [4, 6, 2, 6, 7, 2, 1] def test(): assert solution().findDisappearedNumbers(nums) == [3, 5]
# Copyright (c) OpenMMLab. All rights reserved. _base_ = './i_base.py' item_cfg = {'b': 2} item6 = {'cfg': item_cfg}
_base_ = './i_base.py' item_cfg = {'b': 2} item6 = {'cfg': item_cfg}
# type: ignore __all__ = [ "datatipinfo", "deprpt", "dbstep", "arrayviewfunc", "openvar", "workspace", "commandwindow", "runreport", "fixcontents", "projdumpmat", "urldecode", "renameStructField", "dbcont", "checkcode", "publish", "urlencode", "uiimpo...
__all__ = ['datatipinfo', 'deprpt', 'dbstep', 'arrayviewfunc', 'openvar', 'workspace', 'commandwindow', 'runreport', 'fixcontents', 'projdumpmat', 'urldecode', 'renameStructField', 'dbcont', 'checkcode', 'publish', 'urlencode', 'uiimport', 'dbstop', 'grabcode', 'mlintrpt', 'workspacefunc', 'dbstack', 'filebrowser', 'db...
#!/usr/bin/env python ######################################################################## # Copyright 2012 Mandiant # Copyright 2014 FireEye # # Mandiant licenses this file to you under the Apache License, Version # 2.0 (the "License"); you may not use this file except in compliance with the # License. You may obt...
description = 'SHIFT LEFT 7 and SUB used in DoublePulsar backdoor' type = 'unsigned_int' test_1 = 2493113697 def hash(data): eax = 0 edi = 0 for i in data: edi = 4294967295 & eax << 7 eax = 4294967295 & edi - eax eax = eax + (255 & i) edi = 4294967295 & eax << 7 eax = 429496...
def loop(subject: int, loop_size: int) -> int: value = 1 for i in range(loop_size): value *= subject value = value % 20201227 return value def find_loopsize(public_key: int) -> int: value = 1 subject = 7 for i in range(100_000_000): value *= subject value = valu...
def loop(subject: int, loop_size: int) -> int: value = 1 for i in range(loop_size): value *= subject value = value % 20201227 return value def find_loopsize(public_key: int) -> int: value = 1 subject = 7 for i in range(100000000): value *= subject value = value %...
def findDecision(obj): #obj[0]: Passanger, obj[1]: Weather, obj[2]: Temperature, obj[3]: Time, obj[4]: Coupon, obj[5]: Coupon_validity, obj[6]: Gender, obj[7]: Age, obj[8]: Maritalstatus, obj[9]: Children, obj[10]: Education, obj[11]: Occupation, obj[12]: Income, obj[13]: Bar, obj[14]: Coffeehouse, obj[15]: Restaurantl...
def find_decision(obj): if obj[16] > 0.0: if obj[15] > 1.0: if obj[7] <= 3: if obj[12] > 1: if obj[3] > 0: if obj[9] > 0: if obj[4] > 0: return 'False' ...
"""while loops, also known as indefinite loops""" # n = 5 # while n > 0: # print(n) # n = n - 1 # print('Blastoff') # print(n) # breaking out of loops # while True: # line = input('> ') # if line == 'done': # break #ends loop and jumps to the end of the code # print(line) # print('Done!') # whi...
"""while loops, also known as indefinite loops""" 'This code find the smallest value in a list of numbers' smallest = None print('Before:', smallest) for itervar in [3, 41, 12, 9, 74, 15]: if smallest is None or itervar < smallest: smallest = itervar break print('Loop:', itervar, smallest) print...
class Solution: def minDistance(self, word1: str, word2: str) -> int: m,n=len(word1),len(word2) dp=[[0 for _ in range(0,n+1)] for _ in range(0,m+1)] for _ in range(0,m+1):dp[_][0]=_ for _ in range(0,n+1):dp[0][_]=_ for i in range(1,m+1): ...
class Solution: def min_distance(self, word1: str, word2: str) -> int: (m, n) = (len(word1), len(word2)) dp = [[0 for _ in range(0, n + 1)] for _ in range(0, m + 1)] for _ in range(0, m + 1): dp[_][0] = _ for _ in range(0, n + 1): dp[0][_] = _ for i i...
a = 999 b = 999 palindromes = [] for n in range(1,1000): for m in range(1,1000): num = m*n if str(num) == str(num)[::-1]: palindromes.append(num) print(max(palindromes))
a = 999 b = 999 palindromes = [] for n in range(1, 1000): for m in range(1, 1000): num = m * n if str(num) == str(num)[::-1]: palindromes.append(num) print(max(palindromes))
def fileNaming(names): outnames = [] for name in names: if name in outnames: k = 1 while "{}({})".format(name, k) in outnames: k += 1 name = "{}({})".format(name, k) outnames.append(name) return outnames
def file_naming(names): outnames = [] for name in names: if name in outnames: k = 1 while '{}({})'.format(name, k) in outnames: k += 1 name = '{}({})'.format(name, k) outnames.append(name) return outnames
print("Hello World") print("Hello Again") print("I Like typing this") print("This is fun.") print("Yay! Printing.") print("I'd much rather you 'not'.") print('I"said" do not touch this.') print("how to fix github")
print('Hello World') print('Hello Again') print('I Like typing this') print('This is fun.') print('Yay! Printing.') print("I'd much rather you 'not'.") print('I"said" do not touch this.') print('how to fix github')
#!/usr/env/bin python # https://www.hackerrank.com/challenges/array-left-rotation # Python 2 # first_input = '5 4' # second_input = '1 2 3 4 5' first_input = raw_input() second_input = raw_input() n, d = map(lambda x: int(x), first_input.split(' ')) items = second_input.split(' ') for i in xrange(d): item = item...
first_input = raw_input() second_input = raw_input() (n, d) = map(lambda x: int(x), first_input.split(' ')) items = second_input.split(' ') for i in xrange(d): item = items.pop(0) items.append(item) print(' '.join(items))
# Reading lines from file and putting in a content string for line in open('rosalind_iev.txt', 'r').readlines(): contents = line.rsplit() AA_AA = float(contents[0]) AA_Aa = float(contents[1]) AA_aa = float(contents[2]) Aa_Aa = float(contents[3]) Aa_aa = float(contents[4]) aa_aa = float(contents[5]) def iev_p...
for line in open('rosalind_iev.txt', 'r').readlines(): contents = line.rsplit() aa_aa = float(contents[0]) aa__aa = float(contents[1]) aa_aa = float(contents[2]) aa__aa = float(contents[3]) aa_aa = float(contents[4]) aa_aa = float(contents[5]) def iev_prob(offsprings, AA_AA, AA_Aa, AA_aa, Aa_Aa, Aa_aa, aa_aa): ...
#------------------------------------------------------------------------------ # Custom whitespace stripping -- Append to bottom of ~/.jupyter/jupyter_notebook_config.py # Found here: https://github.com/jupyter/notebook/issues/1455#issuecomment-519891159 #--------------------------------------------------------------...
def strip_white_space(text): return '\n'.join([line.rstrip() for line in text.split('\n')]) def scrub_output_pre_save(model=None, **kwargs): """Auto strip trailing white space before saving.""" if model['type'] == 'notebook': if model['content']['nbformat'] != 4: print('Skipping white s...
""" --- Day 2: 1202 Program Alarm --- -- Part One -- An Intcode program is a list of integers separated by commas (like 1,0,0,3,99). To run one, start by looking at the first integer (called position 0). Here, you will find an opcode - either 1, 2, or 99. The opcode indicates what to do; for example, 99 means that th...
""" --- Day 2: 1202 Program Alarm --- -- Part One -- An Intcode program is a list of integers separated by commas (like 1,0,0,3,99). To run one, start by looking at the first integer (called position 0). Here, you will find an opcode - either 1, 2, or 99. The opcode indicates what to do; for example, 99 means that th...
"""import numpy as np import matplotlib.pyplot as plt class Grid: def __init__(self, height, weight, start): self.height = height self.weight = weight self.i = start[0] self.j = start[1] def set(self, rewards, actions): self.rewards = rewards self.ac...
"""import numpy as np import matplotlib.pyplot as plt class Grid: def __init__(self, height, weight, start): self.height = height self.weight = weight self.i = start[0] self.j = start[1] def set(self, rewards, actions): self.rewards = rewards self.actions = acti...
''' Represents the different HTTP status codes returned from the API to indicate errors. http://docs.veritranspay.co.id/sandbox/status_code.html ''' # 20x - successful submission to api SUCCESS = 200 # NOTE: this is returned when manually cancelled too! CHALLENGE = 201 PENDING = 201 # NOTE: returned when payment typ...
""" Represents the different HTTP status codes returned from the API to indicate errors. http://docs.veritranspay.co.id/sandbox/status_code.html """ success = 200 challenge = 201 pending = 201 expired = 202 moved_permanently = 300 validation_error = 400 access_denied = 401 unavailable_payment_type = 402 duplicate_orde...
N = 4 board = [input() for _ in range(4)] for i in range(N): for j in range(N): cand = [] if j + 2 < N: cand.append([board[i][j+k] for k in range(3)]) if i + 2 < N: cand.append([board[i+k][j] for k in range(3)]) if i + 2 < N and j + 2 < N: cand.app...
n = 4 board = [input() for _ in range(4)] for i in range(N): for j in range(N): cand = [] if j + 2 < N: cand.append([board[i][j + k] for k in range(3)]) if i + 2 < N: cand.append([board[i + k][j] for k in range(3)]) if i + 2 < N and j + 2 < N: cand...
LOG_FILE = 'temperature.log' ZONE_ID = 'ZoneId' MAX_TEMP = 'MaximumTemperature' TRIGGERED = 'Triggered' INCORRECT_CREDENTIALS = 'Incorrect Credentials.' INCORRECT_ARGUEMENTS = 'Incorrect arguments provided - IP username password' TEMPERATURE_API = 'http://{}/axis-cgi/temperature_alarm/getzonestatus.cgi?' DATE_TIME...
log_file = 'temperature.log' zone_id = 'ZoneId' max_temp = 'MaximumTemperature' triggered = 'Triggered' incorrect_credentials = 'Incorrect Credentials.' incorrect_arguements = 'Incorrect arguments provided - IP username password' temperature_api = 'http://{}/axis-cgi/temperature_alarm/getzonestatus.cgi?' date_time_form...
def coroutine(seq): count = 0 while count < 200: count += yield seq.append(count) seq = [] c = coroutine(seq) next(c) ___assertEqual(seq, []) c.send(10) ___assertEqual(seq, [10]) c.send(10) ___assertEqual(seq, [10, 20])
def coroutine(seq): count = 0 while count < 200: count += (yield) seq.append(count) seq = [] c = coroutine(seq) next(c) ___assert_equal(seq, []) c.send(10) ___assert_equal(seq, [10]) c.send(10) ___assert_equal(seq, [10, 20])
# Make sure you follow the order of reaction # output should be H2O,CO2,CH4 def burner(c,h,o): water = co2 = methane = 0 if h >= 2 and o >= 1: if 2 * o >= h: water = h // 2 o -= water h -= 2*water else: water = o o -= water ...
def burner(c, h, o): water = co2 = methane = 0 if h >= 2 and o >= 1: if 2 * o >= h: water = h // 2 o -= water h -= 2 * water else: water = o o -= water h -= 2 * water if o >= 2 and c >= 1: if 2 * c >= o: ...
class Solution: def convertToBase7(self, num: int) -> str: if num == 0: return "0" num, neg = (num, False) if num > 0 else (-num, True) res = [] while num: num, r = divmod(num, 7) res.append(r) if neg: res.append("-") re...
class Solution: def convert_to_base7(self, num: int) -> str: if num == 0: return '0' (num, neg) = (num, False) if num > 0 else (-num, True) res = [] while num: (num, r) = divmod(num, 7) res.append(r) if neg: res.append('-') ...
fin = open("Crime.csv") for line in fin: word = line.split() def crime(): print(" Crime Type | Crime ID | Crime Count") if (word == "ASSAULT" and word =="ROBBERY" and word == "THEFT OF VEHICLE" and word == "BREAK AND ENTER"): print (word) lst = [] for i in word: lst.append(i) crime
fin = open('Crime.csv') for line in fin: word = line.split() def crime(): print(' Crime Type | Crime ID | Crime Count') if word == 'ASSAULT' and word == 'ROBBERY' and (word == 'THEFT OF VEHICLE') and (word == 'BREAK AND ENTER'): print(word) lst = [] for i in word: lst.append(i) crime
def reduce_polymer(orig, to_remove=None, max_len=-1): polymer = [] for i in range(len(orig)): # We save a lot of processing time for Part 2 # if we cut off the string building once the # array is too long if max_len > 0 and len(polymer) >= max_len: return None # The te...
def reduce_polymer(orig, to_remove=None, max_len=-1): polymer = [] for i in range(len(orig)): if max_len > 0 and len(polymer) >= max_len: return None if to_remove and orig[i].lower() == to_remove: continue polymer.append(orig[i]) end_pair = polymer[len(pol...
# coding: utf-8 """ Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache LICENSE, Version 2.0 (the "LICENSE");...
""" Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache LICENSE, Version 2.0 (the "LICENSE"); you may not use...
na, nb = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) a = set(a) b = set(b) t = len(a & b) t2 = len(a.union(b)) print(t/t2)
(na, nb) = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) a = set(a) b = set(b) t = len(a & b) t2 = len(a.union(b)) print(t / t2)
# # PySNMP MIB module MPLS-LC-FR-STD-MIB (http://pysnmp.sf.net) # ASN.1 source http://mibs.snmplabs.com:80/asn1/MPLS-LC-FR-STD-MIB # Produced by pysmi-0.0.7 at Sun Feb 14 00:21:02 2016 # On host bldfarm platform Linux version 4.1.13-100.fc21.x86_64 by user goose # Using Python version 3.5.0 (default, Jan 5 2016, 17:11...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, value_range_constraint, constraints_intersection, value_size_constraint, single_value_constraint) ...
# O(n^2) overall def get_longest_increasing_subsequence(nums): l = len(nums) # reverse adjacency list O(n^2) reverse_adjacency = {i:set() for i in range(l)} for i,n in enumerate(nums): for j,e in enumerate(nums[i+1:], i +1): if n < e: reverse_adjacency[j].add(i) # dynam...
def get_longest_increasing_subsequence(nums): l = len(nums) reverse_adjacency = {i: set() for i in range(l)} for (i, n) in enumerate(nums): for (j, e) in enumerate(nums[i + 1:], i + 1): if n < e: reverse_adjacency[j].add(i) p = ['-'] * l max_len = [0] * l best...
""" Variables for configuration of zoom meetings using SCA Room Assign Tool """ N = 1 SESSION_PATH = "session_info.obj" CHROME_PATH = "C:/ChromeDriver/chromedriver.exe" existing_meeting_id = None # either a valid meeting ID or None, e.g. "860 1959 8282" username = "" password ...
""" Variables for configuration of zoom meetings using SCA Room Assign Tool """ n = 1 session_path = 'session_info.obj' chrome_path = 'C:/ChromeDriver/chromedriver.exe' existing_meeting_id = None username = '' password = '' room_names = ['Calligraphy', 'Costume', 'Cooking', 'Performance', 'Construction', 'Other', 'Chat...
# This is how we print something print("Hello!") # Let's use python3 hello.py to run the program # We can set variables my_variable = 5 print(my_variable) # We can make a list my_list = [1, 2, 3] print(my_list)
print('Hello!') my_variable = 5 print(my_variable) my_list = [1, 2, 3] print(my_list)
def perm_coord( self, perm_coord_list=[0, 1, 2], ): """Permute coordinates of Mesh Solution in place Parameters ---------- self : MeshSolution a MeshSolution object perm_coord_list : list list of the coordinates to be permuted """ # swap mesh solution for sol i...
def perm_coord(self, perm_coord_list=[0, 1, 2]): """Permute coordinates of Mesh Solution in place Parameters ---------- self : MeshSolution a MeshSolution object perm_coord_list : list list of the coordinates to be permuted """ for sol in self.solution: meshsol_fiel...
class DisjointSets: """ Disjoint-set union data structure in which each element contributes an arbitrary measure. """ __slots__ = ('_parents', '_ranks', '_measures') def __init__(self, measures): """ Constructs DisjointSets with a fixed number of elements, each initiall...
class Disjointsets: """ Disjoint-set union data structure in which each element contributes an arbitrary measure. """ __slots__ = ('_parents', '_ranks', '_measures') def __init__(self, measures): """ Constructs DisjointSets with a fixed number of elements, each initially ...
class Solution: def sortedSquares(self, A: List[int]) -> List[int]: A = [i*i for i in A] return sorted(A)
class Solution: def sorted_squares(self, A: List[int]) -> List[int]: a = [i * i for i in A] return sorted(A)
class Variable(object): def __init__(self, _id , offset): self._id = _id self.offset = offset def __str__(self): s = str(self._id) if self.offset: s = s + "/%d" % self.offset return s class VariableLimited(object): def __init__(self, _id , offset, size):...
class Variable(object): def __init__(self, _id, offset): self._id = _id self.offset = offset def __str__(self): s = str(self._id) if self.offset: s = s + '/%d' % self.offset return s class Variablelimited(object): def __init__(self, _id, offset, size):...
# -*- coding: utf-8 -*- # texttaglib's package version information __author__ = "Le Tuan Anh" __email__ = "tuananh.ke@gmail.com" __copyright__ = "Copyright (c) 2018, texttaglib, Le Tuan Anh" __credits__ = [] __license__ = "MIT License" __description__ = "Python library for managing and annotating text corpuses in diff...
__author__ = 'Le Tuan Anh' __email__ = 'tuananh.ke@gmail.com' __copyright__ = 'Copyright (c) 2018, texttaglib, Le Tuan Anh' __credits__ = [] __license__ = 'MIT License' __description__ = 'Python library for managing and annotating text corpuses in different formats (ELAN, TIG, TTL, et cetera)' __url__ = 'https://github...
# General things: RIGHT = 1 LEFT = 2 TOP = 3 BOTTOM = 4 # Names of layers class Layers: game_actors = 4 main = 3 sticky_background = 2 background = 1 background_color = 0 # Message names: (MSGNs) class MSGN: COLLISION_SIDES = 0 VELOCITY = 1 STATE = 100 LOOKDIRECTION = 101 STATESTACK = 102 # Warios states...
right = 1 left = 2 top = 3 bottom = 4 class Layers: game_actors = 4 main = 3 sticky_background = 2 background = 1 background_color = 0 class Msgn: collision_sides = 0 velocity = 1 state = 100 lookdirection = 101 statestack = 102 class Wariostates: upright_stay = 0 upri...
# -*- coding: utf-8 -*- account = { 'email': 'YOUR EMAIL', 'password': 'YOUR PASSWORD' } op = "Login" form_id = "packt_user_login_form" frequency = 8
account = {'email': 'YOUR EMAIL', 'password': 'YOUR PASSWORD'} op = 'Login' form_id = 'packt_user_login_form' frequency = 8
tabby_dog="\tI'm tabbed in"; persian_dog="I'm split\non s line." backslash_dog="i'm \\ a \\ dog" fat_dog="I'll do a list:\t* dog food \t* Fishies \t* Catnip\n\t* Grass" print(tabby_dog) print(persian_dog) print(backslash_dog) print(fat_dog)
tabby_dog = "\tI'm tabbed in" persian_dog = "I'm split\non s line." backslash_dog = "i'm \\ a \\ dog" fat_dog = "I'll do a list:\t* dog food \t* Fishies \t* Catnip\n\t* Grass" print(tabby_dog) print(persian_dog) print(backslash_dog) print(fat_dog)
# Change these to your instagram login credentials. username = "Username" password = "Password"
username = 'Username' password = 'Password'
#!chuck_extends project/urls.py #!chuck_appends URLS urlpatterns += patterns('', url(r'^', include('filer.server.urls')), url(r'^', include('cms.urls')), ) #!end
urlpatterns += patterns('', url('^', include('filer.server.urls')), url('^', include('cms.urls')))
# Easy horntail gem sm.spawnMob(8810202, 95, 260, False) sm.spawnMob(8810203, 95, 260, False) sm.spawnMob(8810204, 95, 260, False) sm.spawnMob(8810205, 95, 260, False) sm.spawnMob(8810206, 95, 260, False) sm.spawnMob(8810207, 95, 260, False) sm.spawnMob(8810208, 95, 260, False) sm.spawnMob(8810209, 95, 260, False) sm.s...
sm.spawnMob(8810202, 95, 260, False) sm.spawnMob(8810203, 95, 260, False) sm.spawnMob(8810204, 95, 260, False) sm.spawnMob(8810205, 95, 260, False) sm.spawnMob(8810206, 95, 260, False) sm.spawnMob(8810207, 95, 260, False) sm.spawnMob(8810208, 95, 260, False) sm.spawnMob(8810209, 95, 260, False) sm.spawnMob(8810214, 95,...
#https://codeforces.com/contest/1343/problem/C for _ in range(int(input())): n = int(input()) l = input().split() new = [] sn=[] nn=[] ans=0 for i in l: if i[0]!='-': sn.append(int(i)) if(nn!=[]): new.append(nn) nn=[] el...
for _ in range(int(input())): n = int(input()) l = input().split() new = [] sn = [] nn = [] ans = 0 for i in l: if i[0] != '-': sn.append(int(i)) if nn != []: new.append(nn) nn = [] else: nn.append(int(i)) ...
def in_bounds(matrix, i, j): rows = len(matrix) cols = len(matrix[0]) if i < 0 or i >= rows or j < 0 or j >= cols: return False return True def read_matrix(): matrix = [] while row := input(): matrix.append([int(num) for num in list(row)]) return matrix def pretty_print(ma...
def in_bounds(matrix, i, j): rows = len(matrix) cols = len(matrix[0]) if i < 0 or i >= rows or j < 0 or (j >= cols): return False return True def read_matrix(): matrix = [] while (row := input()): matrix.append([int(num) for num in list(row)]) return matrix def pretty_print...
#in=5 #in=10 #in=11 #in=20 #in=22 #in=30 #in=33 #in=40 #in=44 #in=50 #in=55 #golden=6050 n = input_int() out = 0 while (n > 0): x = input_int() y = input_int() out = out + x * y n = n - 1 print(out)
n = input_int() out = 0 while n > 0: x = input_int() y = input_int() out = out + x * y n = n - 1 print(out)
for _ in range(int(input())): n=int(input()) if n%2==0: check=0 while n%2==0: n=n//2 check+=1 if n<=1: if check%2: print("Bob") else: print("Alice") else: print("Alice") else: ...
for _ in range(int(input())): n = int(input()) if n % 2 == 0: check = 0 while n % 2 == 0: n = n // 2 check += 1 if n <= 1: if check % 2: print('Bob') else: print('Alice') else: print('Alic...
class Solution: def isOneEditDistance(self, s, t): l1, l2, cnt, i, j = len(s), len(t), 0, 0, 0 while i < l1 and j < l2: if s[i] != t[j]: cnt += 1 if l1 < l2: i -= 1 elif l1 > l2: j -= 1 i ...
class Solution: def is_one_edit_distance(self, s, t): (l1, l2, cnt, i, j) = (len(s), len(t), 0, 0, 0) while i < l1 and j < l2: if s[i] != t[j]: cnt += 1 if l1 < l2: i -= 1 elif l1 > l2: j -= 1 ...