content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
string_variable = "Nicolas" int_variable = 24 print(string_variable) print(int_variable)
string_variable = 'Nicolas' int_variable = 24 print(string_variable) print(int_variable)
name = input("Please enter your name: ") print("{0}, Please guess a number between 0 and 10: ".format(name)) guess = int(input()) if guess != 5: if guess < 5 : print("Please guess higher") else: print("Please guess lower") guess = int(input()) if guess == 5: print("Well done, {0...
name = input('Please enter your name: ') print('{0}, Please guess a number between 0 and 10: '.format(name)) guess = int(input()) if guess != 5: if guess < 5: print('Please guess higher') else: print('Please guess lower') guess = int(input()) if guess == 5: print('Well done, {0}....
def do_the_thing(): with open("input.txt", "r") as f: nums = list(map(int, f.readlines())) if len(nums) < 3: return 0 count = 0 for i in range(len(nums)-3): if nums[i] < nums[i+3]: count += 1 return count # # windo...
def do_the_thing(): with open('input.txt', 'r') as f: nums = list(map(int, f.readlines())) if len(nums) < 3: return 0 count = 0 for i in range(len(nums) - 3): if nums[i] < nums[i + 3]: count += 1 return count if __name__ == '__main__': ...
_base_ = [ '../_base_/models/mask_rcnn_red50_neck_fpn_head.py', '../_base_/datasets/coco_instance.py', '../_base_/schedules/schedule_1x_warmup.py', '../_base_/default_runtime.py' ] optimizer_config = dict(grad_clip(dict(_delete_=True, max_norm=5, norm_type=2)))
_base_ = ['../_base_/models/mask_rcnn_red50_neck_fpn_head.py', '../_base_/datasets/coco_instance.py', '../_base_/schedules/schedule_1x_warmup.py', '../_base_/default_runtime.py'] optimizer_config = dict(grad_clip(dict(_delete_=True, max_norm=5, norm_type=2)))
def maxSumUsingMid(a, first, last, mid): max_left = -99999 sum1 = 0 for i in range(mid, first - 1, -1): sum1 += a[i] if sum1 > max_left: max_left = sum1 max_right = -99999 sum1 = 0 for i in range(mid + 1, last + 1): sum1 += a[i] if sum1 > max_right: ...
def max_sum_using_mid(a, first, last, mid): max_left = -99999 sum1 = 0 for i in range(mid, first - 1, -1): sum1 += a[i] if sum1 > max_left: max_left = sum1 max_right = -99999 sum1 = 0 for i in range(mid + 1, last + 1): sum1 += a[i] if sum1 > max_right:...
''' This module exists purely to check how to import test cases in the test suite ''' def ex_function(): return True
""" This module exists purely to check how to import test cases in the test suite """ def ex_function(): return True
## Command format COMMAND_SIZE_TOTAL = 14 ## Cammand size total COMMAND_SIZE_HEADER = 4 ## Cammand header size COMMAND_SIZE_CHECKSUM = 4 ## Cammand checksum size COMMAND_SIZE_OVERHEAD = 8 ...
command_size_total = 14 command_size_header = 4 command_size_checksum = 4 command_size_overhead = 8 command_start_mark = 245 command_index_command = 1 command_index_data = 2 command_set_integration_time_3_d = 0 command_set_integration_time_grayscale = 1 command_set_roi = 2 command_set_binning = 3 command_set_mode = 4 c...
def MinNumberInsertionAndDel(a, b, x, y): dp = [[None for _ in range(y + 1)] for _ in range(x + 1)] for i in range(x + 1): for j in range(y + 1): if i == 0 or j == 0: dp[i][j] = 0 elif a[i - 1] == b[j - 1]: dp[i][j] = 1 + dp[i - 1][j - 1] ...
def min_number_insertion_and_del(a, b, x, y): dp = [[None for _ in range(y + 1)] for _ in range(x + 1)] for i in range(x + 1): for j in range(y + 1): if i == 0 or j == 0: dp[i][j] = 0 elif a[i - 1] == b[j - 1]: dp[i][j] = 1 + dp[i - 1][j - 1] ...
''' WRITTEN BY Ramon Rossi PURPOSE Two strings are anagrams if you can make one from the other by rearranging the letters. The function named is_anagram takes two strings as its parameters, returning True if the strings are anagrams and False otherwise. EXAMPLE The call is_anagram("typhoon", "opyt...
""" WRITTEN BY Ramon Rossi PURPOSE Two strings are anagrams if you can make one from the other by rearranging the letters. The function named is_anagram takes two strings as its parameters, returning True if the strings are anagrams and False otherwise. EXAMPLE The call is_anagram("typhoon", "opyt...
class VSBaseModel: IGNORED_DICT_PROPS = [ 'ignored_dict_props', 'plugin', 'plugins', 'host', 'hosts', 'finding', 'findings', 'service', 'services', 'vulnerability', 'vulnerabilities' ] def __init__(self): self...
class Vsbasemodel: ignored_dict_props = ['ignored_dict_props', 'plugin', 'plugins', 'host', 'hosts', 'finding', 'findings', 'service', 'services', 'vulnerability', 'vulnerabilities'] def __init__(self): self.id = '' self.ignored_dict_props = self.IGNORED_DICT_PROPS.copy() def to_dict(self)...
program = [] with open("input.txt", "r") as file: for line in file.readlines(): program.append(line.split()) def execute(op, arg, ic, acc): # return ic change, acc change if op == "nop": return ic+1, acc if op == "jmp": return ic+int(arg), acc if op == "acc": retur...
program = [] with open('input.txt', 'r') as file: for line in file.readlines(): program.append(line.split()) def execute(op, arg, ic, acc): if op == 'nop': return (ic + 1, acc) if op == 'jmp': return (ic + int(arg), acc) if op == 'acc': return (ic + 1, acc + int(arg)) ...
# https://leetcode.com/problems/diameter-of-binary-tree/ # Given the root of a binary tree, return the length of the diameter of the tree. # The diameter of a binary tree is the length of the longest path between any two # nodes in a tree. This path may or may not pass through the root. # The length of a path betwee...
class Solution: def diameter_of_binary_tree(self, root: TreeNode) -> int: self.ans = 0 self.longest_path(root) return self.ans def longest_path(self, node): if not node: return 0 left_longest = self.longest_path(node.left) right_longest = self.longes...
class Group: def __init__(self, group_name, group_level, protocols=None): if protocols is None: protocols = {} self.name = group_name self.level = group_level self.protocols = protocols self.group_contains = set() def __contains__(self, protocol): fl...
class Group: def __init__(self, group_name, group_level, protocols=None): if protocols is None: protocols = {} self.name = group_name self.level = group_level self.protocols = protocols self.group_contains = set() def __contains__(self, protocol): fl...
VARS = { 'CLIENT_SECRET_PATH': 'res/client_secret.json', 'SCOPES': 'https://www.googleapis.com/auth/spreadsheets', 'APPLICATION_NAME': 'Google Sheets API Python Quickstart', 'DISCOVERY_URL': 'https://sheets.googleapis.com/$discovery/rest?version=v4' } CONSTANTS = { 'CREDENTIALS_FILENAME': 'sheets.go...
vars = {'CLIENT_SECRET_PATH': 'res/client_secret.json', 'SCOPES': 'https://www.googleapis.com/auth/spreadsheets', 'APPLICATION_NAME': 'Google Sheets API Python Quickstart', 'DISCOVERY_URL': 'https://sheets.googleapis.com/$discovery/rest?version=v4'} constants = {'CREDENTIALS_FILENAME': 'sheets.googleapis.com-python-qui...
def expandX1(m): c = [1] for i in range(m): c.append(c[-1] * -(m-i) / (i+1)) return c[::-1] def isPrime(m): if m < 2: return False c = expandX1(m) c[0] += 1 return not any(mul % m for mul in c[0:-1]) #----DRIVER PROGRAM---- print('\n# [for small primes]AKS TEST GAVE THE FOLLOWING ...
def expand_x1(m): c = [1] for i in range(m): c.append(c[-1] * -(m - i) / (i + 1)) return c[::-1] def is_prime(m): if m < 2: return False c = expand_x1(m) c[0] += 1 return not any((mul % m for mul in c[0:-1])) print('\n# [for small primes]AKS TEST GAVE THE FOLLOWING AS PRIMES...
class NodeofList(object): def __init__(self, value): self.value = value self.next = None def setElement(self, value): self.value = value def getElement(self): return self.value def setNext(self, next): self.next = next def g...
class Nodeoflist(object): def __init__(self, value): self.value = value self.next = None def set_element(self, value): self.value = value def get_element(self): return self.value def set_next(self, next): self.next = next def get_next(self): retur...
class writeDataClass(): def writeData(self,dataFiles): fileData=open("plt.dat","w") for f in range(0,len(dataFiles)): fileData.write("%s\n" % dataFiles[f]) fileData.close()
class Writedataclass: def write_data(self, dataFiles): file_data = open('plt.dat', 'w') for f in range(0, len(dataFiles)): fileData.write('%s\n' % dataFiles[f]) fileData.close()
discounts = [1.0, 1.0, 0.95, 0.90, 0.80, 0.75] def add(list, element, index): if len(list) < index + 1: list.append([]) if element not in list[index]: list[index].append(element) else: add(list, element, index + 1) def price(l): a = [] total_price = 0 for book in l: ...
discounts = [1.0, 1.0, 0.95, 0.9, 0.8, 0.75] def add(list, element, index): if len(list) < index + 1: list.append([]) if element not in list[index]: list[index].append(element) else: add(list, element, index + 1) def price(l): a = [] total_price = 0 for book in l: ...
# print("Please insert a number") # a = int(input("> ")) # print("Please insert another number") # b = int(input("> ")) # print("Please insert yet another number") # c = int(input("> ")) a = 4 b = 5 c = 10 if a > b: if a > c: print(a) else: print(c) else: if b > c: print(b) ...
a = 4 b = 5 c = 10 if a > b: if a > c: print(a) else: print(c) elif b > c: print(b) else: print(c)
# raider.io api configuration RIO_MAX_PAGE = 5 # need to update in templates/stats_table.html # need to update in templates/compositions.html # need to update in templates/navbar.html RIO_SEASON = "season-sl-2" WCL_SEASON = 2 WCL_PARTITION = 1 # config RAID_NAME = "Sanctum of Domination" # late in the season, se...
rio_max_page = 5 rio_season = 'season-sl-2' wcl_season = 2 wcl_partition = 1 raid_name = 'Sanctum of Domination' min_key_level = 16 max_raid_difficulty = 'Mythic'
################################################################################ # # # #=============================================================================== class CustomDict( dict ): #--------------------------------------------------------------------------- defaultValue = 'THIS ITEM NOT AVAILABLE'...
class Customdict(dict): default_value = 'THIS ITEM NOT AVAILABLE' def __getitem__(self, name): try: return super(CustomDict, self).__getitem__(name) except KeyError: return self.defaultValue def __contains__(self, name): return True def has_key(self, na...
MIDDLEWARES = ( 'middlewares.middle_a', 'middlewares.middle_b', 'middlewares.middle_c', 'middlewares.middle_d' )
middlewares = ('middlewares.middle_a', 'middlewares.middle_b', 'middlewares.middle_c', 'middlewares.middle_d')
y=200 deadtime=0 def setup(): global xs xs=[] size(400,400) stroke(0) def draw(): global xs, deadtime, y strokeWeight(5) background(169) if keyPressed and key == " " and deadtime <=0: xs.append(0) deadtime=10 deadtime -= 1 ...
y = 200 deadtime = 0 def setup(): global xs xs = [] size(400, 400) stroke(0) def draw(): global xs, deadtime, y stroke_weight(5) background(169) if keyPressed and key == ' ' and (deadtime <= 0): xs.append(0) deadtime = 10 deadtime -= 1 if keyPressed and key == '...
def checkcolor(): return [255, 240, 255] def newcolor(a, b): return 255
def checkcolor(): return [255, 240, 255] def newcolor(a, b): return 255
roles = [ { 'name': 'GK', 'description': 'Goalkeeper' }, { 'name': 'LD', 'description': 'Left Defender' }, { 'name': 'CD', 'description': 'Central Defender' }, { 'name': 'RD', 'description': 'Right Defender' }, { ...
roles = [{'name': 'GK', 'description': 'Goalkeeper'}, {'name': 'LD', 'description': 'Left Defender'}, {'name': 'CD', 'description': 'Central Defender'}, {'name': 'RD', 'description': 'Right Defender'}, {'name': 'LM', 'description': 'Left Midfielder'}, {'name': 'CM', 'description': 'Central Midfielder'}, {'name': 'RM', ...
class A: pass var = object() if isinstance(var, A) and var: pass
class A: pass var = object() if isinstance(var, A) and var: pass
# cifar10 ##################### ci7 = {'stages': 3, 'depth': 22, 'branch': 3, 'rock': 'U', 'kldloss': False, 'layers': (3, 3, 3), 'blocks': ('D', 'D', 'S'), 'slink': ('A', 'A', 'A'), 'growth': (0, 0, 0), 'classify': (0, 0, 0), 'expand': (1 * 22, 2 * 22), 'dfunc': ('O', 'O'), 'dstyle': 'maxpool', '...
ci7 = {'stages': 3, 'depth': 22, 'branch': 3, 'rock': 'U', 'kldloss': False, 'layers': (3, 3, 3), 'blocks': ('D', 'D', 'S'), 'slink': ('A', 'A', 'A'), 'growth': (0, 0, 0), 'classify': (0, 0, 0), 'expand': (1 * 22, 2 * 22), 'dfunc': ('O', 'O'), 'dstyle': 'maxpool', 'fcboost': 'none', 'nclass': 10, 'last_branch': 1, 'las...
#!/usr/bin/env python __version__ = '0.0.1' __author__ = 'Fernandes Macedo' __email__ = 'masedos@gmail.com' fruits = ["Apple", "Peach", "Pear"] for fruit in fruits: print(fruit) print(fruit + " Pie") print(fruits)
__version__ = '0.0.1' __author__ = 'Fernandes Macedo' __email__ = 'masedos@gmail.com' fruits = ['Apple', 'Peach', 'Pear'] for fruit in fruits: print(fruit) print(fruit + ' Pie') print(fruits)
wt5_3_7 = {'192.168.122.110': [5.7199, 8.4411, 8.0381, 7.3759, 7.1777, 6.9974, 6.816, 6.7848, 6.811, 6.8666, 6.7605, 7.1659, 7.1058, 7.117, 7.4091, 7.3653, 7.602, 7.5046, 7.5051, 7.4195, 7.3659, 7.2974, 7.2932, 7.4615, 7.6061, 7.7395, 7.7409, 7.699, 7.6546, 7.631, 7.5707, 7.562, 7.5218, 7.4742, 7.6148, 7.5669, 7.5131,...
wt5_3_7 = {'192.168.122.110': [5.7199, 8.4411, 8.0381, 7.3759, 7.1777, 6.9974, 6.816, 6.7848, 6.811, 6.8666, 6.7605, 7.1659, 7.1058, 7.117, 7.4091, 7.3653, 7.602, 7.5046, 7.5051, 7.4195, 7.3659, 7.2974, 7.2932, 7.4615, 7.6061, 7.7395, 7.7409, 7.699, 7.6546, 7.631, 7.5707, 7.562, 7.5218, 7.4742, 7.6148, 7.5669, 7.5131, ...
insert_sensor_schema = { "$schema": "http://json-schema.org/draft-07/schema#", "title": "insert-sensor-schema", "description": "Schema for inserting new sensor readings", "type": "object", "properties": { "temperature": { "$id": "/properties/temperature", "type": "num...
insert_sensor_schema = {'$schema': 'http://json-schema.org/draft-07/schema#', 'title': 'insert-sensor-schema', 'description': 'Schema for inserting new sensor readings', 'type': 'object', 'properties': {'temperature': {'$id': '/properties/temperature', 'type': 'number', 'title': 'A temperature reading (in celsius)', 'e...
with open("zad3.txt", "w") as plik: for i in range(0,11,1): plik.write(str(i)+'\n') with open("zad3.txt", "r") as plik: for i in plik: print(i, end="")
with open('zad3.txt', 'w') as plik: for i in range(0, 11, 1): plik.write(str(i) + '\n') with open('zad3.txt', 'r') as plik: for i in plik: print(i, end='')
''' Problem 019 You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twenty-nine. A...
""" Problem 019 You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twenty-nine. A...
a = 2 ** 62 b = 2 ** 63 c = 0 ** 0 d = 0 ** 1 e = 1 ** 999999999 f = 1 ** 999999999999999999999999999 g = 1 ** (-1) h = 0 ** (-1) i = 999999999999999 ** 99999999999999999999999999999 j = 2 ** 10 k = 10 ** 10 l = 13 ** 3 m = (-3) ** 3 n = (-3) ** 4
a = 2 ** 62 b = 2 ** 63 c = 0 ** 0 d = 0 ** 1 e = 1 ** 999999999 f = 1 ** 999999999999999999999999999 g = 1 ** (-1) h = 0 ** (-1) i = 999999999999999 ** 99999999999999999999999999999 j = 2 ** 10 k = 10 ** 10 l = 13 ** 3 m = (-3) ** 3 n = (-3) ** 4
class State: 'Defined state of cell in grid world' def __init__(self, pos=[0,0], reward= -1, movable=True, absorbing=False, agent_present=False): self.pos = pos self.reward = reward self.movable = movable self.absorbing = absorbing self.v_pi = [] self.v_pi_mean = ...
class State: """Defined state of cell in grid world""" def __init__(self, pos=[0, 0], reward=-1, movable=True, absorbing=False, agent_present=False): self.pos = pos self.reward = reward self.movable = movable self.absorbing = absorbing self.v_pi = [] self.v_pi_me...
# File: minemeld_consts.py # # Copyright (c) 2021 Splunk Inc. # # 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 applica...
minemeld_success_test_connectivity = 'Test Connectivity Passed' minemeld_err_test_connectivity = 'Test Connectivity Failed' minemeld_err_invalid_config_param = 'Check input parameter. For example: Endpoint: https://host:port User: admin Password: ****' minemeld_vault_id_not_found = 'File not found for given vault id' ...
PRIVILEGE_CHOICES = [ ('Users.manageUser', 'Manage Users'), ('Sales.manage', 'Manage Sales'), ('Sales.docs', 'Manage Documents'), ]
privilege_choices = [('Users.manageUser', 'Manage Users'), ('Sales.manage', 'Manage Sales'), ('Sales.docs', 'Manage Documents')]
__all__ = [ 'q1_words_score', 'q2_default_arguments' ]
__all__ = ['q1_words_score', 'q2_default_arguments']
# This example shows one of the possibilities of the canvas: # the ability to access all existing objects on it. size(550, 300) fill(1, 0.8) strokewidth(1.5) # First, generate some rectangles all over the canvas, rotated randomly. for i in range(3000): grob = rect(random(WIDTH)-25, random(HEIGHT)-25,50, 50) ...
size(550, 300) fill(1, 0.8) strokewidth(1.5) for i in range(3000): grob = rect(random(WIDTH) - 25, random(HEIGHT) - 25, 50, 50) grob.rotate(random(360)) sorted_grobs = list(canvas) def compare(a, b): v1 = a.bounds[0][1] v2 = b.bounds[0][1] if v1 > v2: return 1 elif v1 < v2: retu...
#!/usr/bin/python3 # -*- coding: utf-8 -*- # Created by Ross on 19-1-8 def solve(n: int): if n <= 0: return -1 table = [0, 1] if n < 2: return table[n] fib1 = table[0] fib2 = table[1] fib_n = 0 for i in range(2, n + 1): fib_n = fib1 + fib2 fib1 = fib2 ...
def solve(n: int): if n <= 0: return -1 table = [0, 1] if n < 2: return table[n] fib1 = table[0] fib2 = table[1] fib_n = 0 for i in range(2, n + 1): fib_n = fib1 + fib2 fib1 = fib2 fib2 = fib_n return fib_n if __name__ == '__main__': for i in r...
numbe = 1125 strnumbe = str(numbe) sumOfDigit = 0 productOfDigit = 1 listdigits = list(map(int, strnumbe)) for elemen in listdigits: sumOfDigit = sumOfDigit+elemen productOfDigit = productOfDigit*elemen if(sumOfDigit == productOfDigit): print('The given number', strnumbe, 'is spy number') else: ...
numbe = 1125 strnumbe = str(numbe) sum_of_digit = 0 product_of_digit = 1 listdigits = list(map(int, strnumbe)) for elemen in listdigits: sum_of_digit = sumOfDigit + elemen product_of_digit = productOfDigit * elemen if sumOfDigit == productOfDigit: print('The given number', strnumbe, 'is spy number') else: ...
number = int(input()) if number == 1: print("Monday") elif number == 2: print("Tuesday") elif number == 3: print("Wednesday") elif number == 4: print("Thursday") elif number == 5: print("Friday") elif number == 6: print("Saturday") elif number == 7: print("Sunday") else: ...
number = int(input()) if number == 1: print('Monday') elif number == 2: print('Tuesday') elif number == 3: print('Wednesday') elif number == 4: print('Thursday') elif number == 5: print('Friday') elif number == 6: print('Saturday') elif number == 7: print('Sunday') else: print('Error')
def to_role_name(feature_name): return feature_name.replace("-", "_") def to_feature_name(role_name): return role_name.replace("_", "-") def resource_name(prefix, cluster_name, resource_type, component=None): name = '' if (not prefix) or (prefix == 'default'): if component is None: ...
def to_role_name(feature_name): return feature_name.replace('-', '_') def to_feature_name(role_name): return role_name.replace('_', '-') def resource_name(prefix, cluster_name, resource_type, component=None): name = '' if not prefix or prefix == 'default': if component is None: nam...
number_of_wagons = int(input()) train = [0 for x in range(number_of_wagons)] command = input() while command != 'End': current_task = command.split(' ') task = current_task[0] if task == 'add': num_of_people = int(current_task[1]) train[-1] += num_of_people if task == 'insert': ...
number_of_wagons = int(input()) train = [0 for x in range(number_of_wagons)] command = input() while command != 'End': current_task = command.split(' ') task = current_task[0] if task == 'add': num_of_people = int(current_task[1]) train[-1] += num_of_people if task == 'insert': w...
# constants PERCENTAGE_BUILTIN_SLOTS = 0.20 # Time FOUNTAIN_MONTH = 'FOUNTAIN:MONTH' FOUNTAIN_WEEKDAY = 'FOUNTAIN:WEEKDAY' FOUNTAIN_HOLIDAYS = 'FOUNTAIN:HOLIDAYS' FOUNTAIN_MONTH_DAY = 'FOUNTAIN:MONTH_DAY' FOUNTAIN_TIME = 'FOUNTAIN:TIME' FOUNTAIN_NUMBER = 'FOUNTAIN:NUMBER' FOUNTAIN_DATE = 'FOUNTAIN:DATE' # Location F...
percentage_builtin_slots = 0.2 fountain_month = 'FOUNTAIN:MONTH' fountain_weekday = 'FOUNTAIN:WEEKDAY' fountain_holidays = 'FOUNTAIN:HOLIDAYS' fountain_month_day = 'FOUNTAIN:MONTH_DAY' fountain_time = 'FOUNTAIN:TIME' fountain_number = 'FOUNTAIN:NUMBER' fountain_date = 'FOUNTAIN:DATE' fountain_city = 'FOUNTAIN:CITY' fou...
# https://leetcode.com/problems/multiply-strings/ # Given two non-negative integers num1 and num2 represented as strings, return the # product of num1 and num2, also represented as a string. # Note: You must not use any built-in BigInteger library or convert the inputs to # integer directly. ########################...
class Solution: def multiply(self, num1: str, num2: str) -> str: if num1 == '0' or num2 == '0': return '0' if num1 == '1': return num2 if num2 == '1': return num1 (n1, n2) = (len(num1), len(num2)) multi = [0] * (n1 + n2) for i in r...
# Handling negation: "not good", "not worth it" def hack(rev): for i in range(0, len(rev)): line = rev[i].split() for it in range(0, len(line)): if line[it] == 'no' or line[it] == 'not' or line[it] == 'nope' or line[it] == 'never' or line[it] == "isn't" or line[it] == "don't" or line[it] == "dont" or line[...
def hack(rev): for i in range(0, len(rev)): line = rev[i].split() for it in range(0, len(line)): if line[it] == 'no' or line[it] == 'not' or line[it] == 'nope' or (line[it] == 'never') or (line[it] == "isn't") or (line[it] == "don't") or (line[it] == 'dont') or (line[it] == "wasn't"): ...
print("Kinjal Raykarmakar\nSec: CSE2H\tRoll: 29\n") num = int(input("Enter a number: ")) if num % 2 == 0: print("{} is an even number".format(num)) else: print("{} is an odd number".format(num))
print('Kinjal Raykarmakar\nSec: CSE2H\tRoll: 29\n') num = int(input('Enter a number: ')) if num % 2 == 0: print('{} is an even number'.format(num)) else: print('{} is an odd number'.format(num))
_input = [int(num) for num in input().split(" ")] river_width = _input[0] max_jump_length = _input[1] stones = [int(stone) for stone in input().split(" ")]
_input = [int(num) for num in input().split(' ')] river_width = _input[0] max_jump_length = _input[1] stones = [int(stone) for stone in input().split(' ')]
#Compute the max depth of a binary tree class Tree: def __init__(self, val,left = None, right = None): self.val = val self.left = left self.right = right root = Tree(4, left = Tree(3), right=Tree(5, left= Tree(4))) def maxDepth(root): if root is None: return 0 ret...
class Tree: def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right root = tree(4, left=tree(3), right=tree(5, left=tree(4))) def max_depth(root): if root is None: return 0 return max(max_depth(root.left) + 1, max_depth(root.right)...
lst=list(map(int, input().split())) if sum(lst)==180 and 0 not in lst: print('YES') else: print('NO')
lst = list(map(int, input().split())) if sum(lst) == 180 and 0 not in lst: print('YES') else: print('NO')
class Solution: def maxSubArray(self, nums: List[int]) -> int: current_max=nums[0] global_max=nums[0] for i in range(1,len(nums)): current_max=max(nums[i],current_max+nums[i]) global_max=max(current_max,global_max) return global_max
class Solution: def max_sub_array(self, nums: List[int]) -> int: current_max = nums[0] global_max = nums[0] for i in range(1, len(nums)): current_max = max(nums[i], current_max + nums[i]) global_max = max(current_max, global_max) return global_max
''' BITONIC POINT Given an array. The task is to find the bitonic point of the array. The bitonic point in an array is the index before which all the numbers are in increasing order and after which, all are in decreasing order. ''' def bitonic(a, n): l = 1 r = n - 2 while(l <= r): m = (l + r) // 2...
""" BITONIC POINT Given an array. The task is to find the bitonic point of the array. The bitonic point in an array is the index before which all the numbers are in increasing order and after which, all are in decreasing order. """ def bitonic(a, n): l = 1 r = n - 2 while l <= r: m = (l + r) // 2 ...
class Solution: def nthUglyNumber(self, n): dp = [0] * n dp[0] = 1 p2 = 0 p3 = 0 p5 = 0 for i in range(1, n): dp[i] = min(2 * dp[p2], 3 * dp[p3], 5 * dp[p5]) if dp[i] >= 2 * dp[p2]: p2 += 1 if dp[i] >= 3 * dp[p3]: ...
class Solution: def nth_ugly_number(self, n): dp = [0] * n dp[0] = 1 p2 = 0 p3 = 0 p5 = 0 for i in range(1, n): dp[i] = min(2 * dp[p2], 3 * dp[p3], 5 * dp[p5]) if dp[i] >= 2 * dp[p2]: p2 += 1 if dp[i] >= 3 * dp[p3]:...
class SpatialExtent: def __init__(self): self.bbox = "" class TemporalExtent: def __init__(self): self.interval = ""
class Spatialextent: def __init__(self): self.bbox = '' class Temporalextent: def __init__(self): self.interval = ''
#!/usr/bin/python # ============================================================================== # Author: Tao Li (taoli@ucsd.edu) # Date: May 6, 2015 # Question: 001-Two-Sum # Link: https://leetcode.com/problems/two-sum/ # ============================================================================== # Giv...
class Solution: def two_sum(self, nums, target): dic = {} for i in nums: dic[i] = target - i for i in nums: if dic.get(dic[i]) is not None: idx1 = nums.index(i) if dic[i] != i: return sorted([idx1 + 1, nums.index(di...
class Solution: def minMeetingRooms(self, intervals: List[List[int]]) -> int: if not intervals: return 0 result, curr = 0, 0 for i, val in sorted( x for interval in intervals for x in [(interval[0], 1), (interval[1], -1)] ): curr += val ...
class Solution: def min_meeting_rooms(self, intervals: List[List[int]]) -> int: if not intervals: return 0 (result, curr) = (0, 0) for (i, val) in sorted((x for interval in intervals for x in [(interval[0], 1), (interval[1], -1)])): curr += val result = m...
dados = list() pessoas = list() pesados = list() leves = list() maior = menor = 0 while True: dados.append(str(input('Nome: '))) dados.append(float(input('Peso: '))) pessoas.append(dados[:]) dados.clear() continuar = ' ' while continuar not in 'SN': continuar = str(input('Deseja continua...
dados = list() pessoas = list() pesados = list() leves = list() maior = menor = 0 while True: dados.append(str(input('Nome: '))) dados.append(float(input('Peso: '))) pessoas.append(dados[:]) dados.clear() continuar = ' ' while continuar not in 'SN': continuar = str(input('Deseja continua...
# search for the 1000th prime number and print it # author Zhou Fang Version: 1.0 # Problem 1. # Write a program that computes and prints the 1000th prime number. number_prime = 1 i = 3 while number_prime < 1000: divider = 3 status = 1 while status: if i % divider != 0 and divider < i/2: ...
number_prime = 1 i = 3 while number_prime < 1000: divider = 3 status = 1 while status: if i % divider != 0 and divider < i / 2: divider = divider + 2 elif divider >= i / 2: number_prime = number_prime + 1 prime_num = i print('it is the %d th pr...
print("welcome to SBI bank ATM") restart=('y') chances = 3 balance = 1000 while chances>0: restart=('y') pin = int(input("please enter your secret number")) if pin == 1234: print('you entered your pin correctly\n') while restart not in ('n','N','no','NO'): print('press ...
print('welcome to SBI bank ATM') restart = 'y' chances = 3 balance = 1000 while chances > 0: restart = 'y' pin = int(input('please enter your secret number')) if pin == 1234: print('you entered your pin correctly\n') while restart not in ('n', 'N', 'no', 'NO'): print('press 1 for...
A = [[1, 2], [3, 4], [5, 6]] B = max(A) V = 1
a = [[1, 2], [3, 4], [5, 6]] b = max(A) v = 1
class config_library: def __init__(self, default): self.path = default.path + "/system/library/" self.ignore = ['__pycache__', '__init__.py'] def get(self): return self
class Config_Library: def __init__(self, default): self.path = default.path + '/system/library/' self.ignore = ['__pycache__', '__init__.py'] def get(self): return self
f = open("/home/vleite/Desktop/range.txt", "w") f.write("x range:\n") for x in range(0, 55296, 64): f.write(str(x) + "-" + str(x + 64) + "\n") f.write("y range:\n") for x in range(0, 46080, 64): f.write(str(x) + "-" + str(x + 64) + "\n") f.write("z range:\n") for x in range(0, 514, 64): f.write(str(x) +...
f = open('/home/vleite/Desktop/range.txt', 'w') f.write('x range:\n') for x in range(0, 55296, 64): f.write(str(x) + '-' + str(x + 64) + '\n') f.write('y range:\n') for x in range(0, 46080, 64): f.write(str(x) + '-' + str(x + 64) + '\n') f.write('z range:\n') for x in range(0, 514, 64): f.write(str(x) + '-'...
pkgname = "libmodplug" pkgver = "0.8.9.0" pkgrel = 0 build_style = "gnu_configure" configure_args = ["--enable-static"] hostmakedepends = ["pkgconf"] pkgdesc = "MOD playing library" maintainer = "q66 <q66@chimera-linux.org>" license = "custom:none" url = "http://modplug-xmms.sourceforge.net" source = f"$(SOURCEFORGE_SI...
pkgname = 'libmodplug' pkgver = '0.8.9.0' pkgrel = 0 build_style = 'gnu_configure' configure_args = ['--enable-static'] hostmakedepends = ['pkgconf'] pkgdesc = 'MOD playing library' maintainer = 'q66 <q66@chimera-linux.org>' license = 'custom:none' url = 'http://modplug-xmms.sourceforge.net' source = f'$(SOURCEFORGE_SI...
# O(1) constant time! def print_one_item(items): print(items[0]) # liniar O(n) def print_every_item(items): for item in items: print(item) # n = number of steps # quadratic O(n^2) def print_pairs(items): for item_one in items: for item_two in items: print(item_one, item_two)...
def print_one_item(items): print(items[0]) def print_every_item(items): for item in items: print(item) def print_pairs(items): for item_one in items: for item_two in items: print(item_one, item_two) def do_a_bunch_of_stuff(items): last_idx = len(items) - 1 middle_idx =...
word = input() times = int(input()) def repeat(): text = "" for _ in range(times): text += word print(text) repeat()
word = input() times = int(input()) def repeat(): text = '' for _ in range(times): text += word print(text) repeat()
class STLException(Exception): pass class STLParseException(Exception): pass class STLOfflineException(Exception): pass
class Stlexception(Exception): pass class Stlparseexception(Exception): pass class Stlofflineexception(Exception): pass
class TypeDeclaration: def __init__(self, file_path): self.file_path = file_path self.types_declared = set() def add_type_declared(self, new_type): if type(new_type) == set: self.types_declared = self.types_declared.union(new_type) else: self.types_d...
class Typedeclaration: def __init__(self, file_path): self.file_path = file_path self.types_declared = set() def add_type_declared(self, new_type): if type(new_type) == set: self.types_declared = self.types_declared.union(new_type) else: self.types_decla...
''' - Leetcode problem: 797 - Difficulty: Medium - Brief problem description: Given a directed, acyclic graph of N nodes. Find all possible paths from node 0 to node N-1, and return them in any order. The graph is given as follows: the nodes are 0, 1, ..., graph.length - 1. graph[i] is a list of all nodes j for ...
""" - Leetcode problem: 797 - Difficulty: Medium - Brief problem description: Given a directed, acyclic graph of N nodes. Find all possible paths from node 0 to node N-1, and return them in any order. The graph is given as follows: the nodes are 0, 1, ..., graph.length - 1. graph[i] is a list of all nodes j for ...
#Dictionary adalah stuktur data yang bentuknya seperti kamus. #Ada kata kunci kemudian ada nilaninya. Kata kunci harus unik, #sedangkan nilai boleh diisi denga apa saja. # Membuat Dictionary ira_abri = { "nama": "ira abri", "umur": 19, "hobi": ["makan", "jalan", "ngemoll"], "menikah": False,...
ira_abri = {'nama': 'ira abri', 'umur': 19, 'hobi': ['makan', 'jalan', 'ngemoll'], 'menikah': False, 'sosmed': {'facebook': 'iraabri', 'twitter': '@irakode'}} print('Nama saya adalah %s' % ira_abri['nama']) print('Twitter: %s' % ira_abri['sosmed']['twitter'])
class WorkBot: def __init__(self): self.driver = webdriver.Chrome() self.driver.get("https://app.daily.dev/") self.WebDriverWait(self.driver).until(document_initialised) el = self.driver.find_element_by_xpath("/html/body/div/main/div/article/a") # names = [name.text for name ...
class Workbot: def __init__(self): self.driver = webdriver.Chrome() self.driver.get('https://app.daily.dev/') self.WebDriverWait(self.driver).until(document_initialised) el = self.driver.find_element_by_xpath('/html/body/div/main/div/article/a') for e in el: prin...
# This code is written in Python # This code prints the line number next to each line in the file FileName = "file1.txt" f = open(FileName,"r") fileContent = f.read() number_of_lines = 0 line_by_line = fileContent.split("\n") number_of_lines = len(line_by_line) print("The number of lines in the file are : ") print...
file_name = 'file1.txt' f = open(FileName, 'r') file_content = f.read() number_of_lines = 0 line_by_line = fileContent.split('\n') number_of_lines = len(line_by_line) print('The number of lines in the file are : ') print(number_of_lines) new_contents = '' line_index = 1 for line in line_by_line: new_contents = newC...
class Event: def __init__(self): self._callee_list = set() def __iadd__(self, fct): return self._callee_list.add(fct) def __isub__(self, fct): return self._callee_list.remove(fct) def __call__(self, sender, *event_args): for callee in self._callee_list: ...
class Event: def __init__(self): self._callee_list = set() def __iadd__(self, fct): return self._callee_list.add(fct) def __isub__(self, fct): return self._callee_list.remove(fct) def __call__(self, sender, *event_args): for callee in self._callee_list: ca...
# https://www.geeksforgeeks.org/kmp-algorithm-for-pattern-searching/ def get_lps(pat): n = len(pat) lps = [0] * n # longest proper prefix which is also suffix i = 1 l = 0 while i < n: if pat[i] == pat[l]: l += 1 lps[i] = l i += 1 else: if 0 < l: l = lps[l-1] e...
def get_lps(pat): n = len(pat) lps = [0] * n i = 1 l = 0 while i < n: if pat[i] == pat[l]: l += 1 lps[i] = l i += 1 elif 0 < l: l = lps[l - 1] else: i += 1 return lps def find(text, pat): res = [] n = le...
class ParsingSuccess: def __init__(self, string, rule_type, start_pos, end_pos, children): self.string = string self.rule_type = rule_type self.start_pos = start_pos self.end_pos = end_pos self.children = children @property def match_string(self): r...
class Parsingsuccess: def __init__(self, string, rule_type, start_pos, end_pos, children): self.string = string self.rule_type = rule_type self.start_pos = start_pos self.end_pos = end_pos self.children = children @property def match_string(self): return sel...
def information(*args): for arg in args: print(arg) information(1, 3, 6, 7, "Abelardo") def users(**kwargs): for k in kwargs.values(): print(k) users(name="bob", age=19)
def information(*args): for arg in args: print(arg) information(1, 3, 6, 7, 'Abelardo') def users(**kwargs): for k in kwargs.values(): print(k) users(name='bob', age=19)
def sqr(n): if (n**.5)%1==0: return True return False l=[] for d in range(2,1001): if sqr(d)==False: y=1 while True: x=1+d*y*y if sqr(x)==True: print(x**.5,"^2 -",d,"*",y,"^2 = 1") l.append(int(x**.5)) ...
def sqr(n): if n ** 0.5 % 1 == 0: return True return False l = [] for d in range(2, 1001): if sqr(d) == False: y = 1 while True: x = 1 + d * y * y if sqr(x) == True: print(x ** 0.5, '^2 -', d, '*', y, '^2 = 1') l.append(int(x **...
def soma_numeros(primeiro, segundo): return primeiro + segundo print(soma_numeros(15, 15))
def soma_numeros(primeiro, segundo): return primeiro + segundo print(soma_numeros(15, 15))
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...
DISCORD_WEBHOOK_URL = 'https://discord.com/api/webhooks/{webhook_id}/{webhook_token}' DISCORD_WEBHOOK_RELAY_PARAMS = [ 'webhook_id', 'webhook_token', 'content', ]
discord_webhook_url = 'https://discord.com/api/webhooks/{webhook_id}/{webhook_token}' discord_webhook_relay_params = ['webhook_id', 'webhook_token', 'content']
class Forbidden(Exception): pass class InternalServerError(Exception): pass
class Forbidden(Exception): pass class Internalservererror(Exception): pass
print('calculate area of a circle') def circle(): radius = input('enter radius') radius = float(radius) area = 3.14*radius*radius print ('area is ') print (area) circle()
print('calculate area of a circle') def circle(): radius = input('enter radius') radius = float(radius) area = 3.14 * radius * radius print('area is ') print(area) circle()
h = list(map(int, input().rstrip().split())) word = input() h = [h[ord(l) - ord("a")] for l in set(word)] print(max(h) * len(word))
h = list(map(int, input().rstrip().split())) word = input() h = [h[ord(l) - ord('a')] for l in set(word)] print(max(h) * len(word))
load("//:import_external.bzl", import_external = "safe_wix_scala_maven_import_external") def dependencies(): import_external( name = "com_fasterxml_jackson_module_jackson_module_paranamer", artifact = "com.fasterxml.jackson.module:jackson-module-paranamer:2.9.6", artifact_sha256 = "dfd66598c0094d9...
load('//:import_external.bzl', import_external='safe_wix_scala_maven_import_external') def dependencies(): import_external(name='com_fasterxml_jackson_module_jackson_module_paranamer', artifact='com.fasterxml.jackson.module:jackson-module-paranamer:2.9.6', artifact_sha256='dfd66598c0094d9a7ef0b6e6bb3140031fc833f6c...
class Solution: def getRow(self, rowIndex: int) -> List[int]: if rowIndex == 0: return [1] s = [1] for i in range(1, rowIndex + 1): s = [sum(x) for x in zip([0] + s, s + [0])] return s
class Solution: def get_row(self, rowIndex: int) -> List[int]: if rowIndex == 0: return [1] s = [1] for i in range(1, rowIndex + 1): s = [sum(x) for x in zip([0] + s, s + [0])] return s
#!/usr/bin/env python class AsciiFileReader: def __init__(self, infile): self.infile = infile def readInt(self): assert False
class Asciifilereader: def __init__(self, infile): self.infile = infile def read_int(self): assert False
coordinates_E0E1E1 = ((123, 109), (123, 111), (123, 112), (123, 114), (124, 109), (124, 110), (125, 108), (125, 109), (125, 114), (126, 108), (126, 109), (127, 69), (127, 79), (127, 99), (127, 101), (127, 108), (128, 72), (128, 73), (128, 74), (128, 75), (128, 76), (128, 77), (128, 79), (128, 93), (128, 98), (128, 10...
coordinates_e0_e1_e1 = ((123, 109), (123, 111), (123, 112), (123, 114), (124, 109), (124, 110), (125, 108), (125, 109), (125, 114), (126, 108), (126, 109), (127, 69), (127, 79), (127, 99), (127, 101), (127, 108), (128, 72), (128, 73), (128, 74), (128, 75), (128, 76), (128, 77), (128, 79), (128, 93), (128, 98), (128, 10...
def countWords(s): count=1 for i in s: if i==" ": count+=1 return count print(countWords("Hello World This is Rituraj"))
def count_words(s): count = 1 for i in s: if i == ' ': count += 1 return count print(count_words('Hello World This is Rituraj'))
def imprime(nota_fiscal): print(f"Imprimindo nota fiscal {nota_fiscal.cnpj}") def envia_por_email(nota_fiscal): print(f"Enviando nota fiscal {nota_fiscal.cnpj} por email") def salva_no_banco(nota_fiscal): print(f"Salvando nota fiscal {nota_fiscal.cnpj} no banco")
def imprime(nota_fiscal): print(f'Imprimindo nota fiscal {nota_fiscal.cnpj}') def envia_por_email(nota_fiscal): print(f'Enviando nota fiscal {nota_fiscal.cnpj} por email') def salva_no_banco(nota_fiscal): print(f'Salvando nota fiscal {nota_fiscal.cnpj} no banco')
#Write a function that accepts a string and a character as input and returns the #number of times the character is repeated in the string. Note that #capitalization does not matter here i.e. a lower case character should be #treated the same as an upper case character. def count_character(line, character): count =...
def count_character(line, character): count = 0 for x in line.lower(): if x == character.lower(): count += 1 return count print(count_character('supernovas are so awesome', 's'))
def partfast(n): # base case of the recursion: zero is the sum of the empty tuple if n == 0: yield [] return # modify the partitions of n-1 to form the partitions of n for p in partfast(n-1): p.append(1) yield p p.pop() if p and (len(p) < 2 or p[-2] > p[-1...
def partfast(n): if n == 0: yield [] return for p in partfast(n - 1): p.append(1) yield p p.pop() if p and (len(p) < 2 or p[-2] > p[-1]): p[-1] += 1 yield p
mass_list = list(open('d01.in').read().split()) base_fuel = 0 total_fuel = 0 def calculate_fuel(mass): return int(mass) // 3 - 2 for mass in mass_list: fuel = calculate_fuel(mass) base_fuel += fuel while (fuel >= 0): total_fuel += fuel fuel = calculate_fuel(fuel) print('P1:', base_fu...
mass_list = list(open('d01.in').read().split()) base_fuel = 0 total_fuel = 0 def calculate_fuel(mass): return int(mass) // 3 - 2 for mass in mass_list: fuel = calculate_fuel(mass) base_fuel += fuel while fuel >= 0: total_fuel += fuel fuel = calculate_fuel(fuel) print('P1:', base_fuel) p...
f=open('t.txt','r') l=f.readlines() d={} for i in (l): k=i.strip() m = list(k) if(m[0]=='R'): d[k] = [] j=k else: d[j].append(k) p=[] for i in d.keys(): m=d[i] k=''.join(x for x in m) d[i]=list(k) l1 = k.count('G') l2 = k.count('C') l = len(d[i]) per =...
f = open('t.txt', 'r') l = f.readlines() d = {} for i in l: k = i.strip() m = list(k) if m[0] == 'R': d[k] = [] j = k else: d[j].append(k) p = [] for i in d.keys(): m = d[i] k = ''.join((x for x in m)) d[i] = list(k) l1 = k.count('G') l2 = k.count('C') l =...
def sign(val): if val == 0: return 0 return 1 if val > 0 else -1 def linear_interpolation(val, x0, y0, x1, y1): return y0 + ((val - x0) * (y1 - y0))/(x1 - x0)
def sign(val): if val == 0: return 0 return 1 if val > 0 else -1 def linear_interpolation(val, x0, y0, x1, y1): return y0 + (val - x0) * (y1 - y0) / (x1 - x0)
def bbox_xywh2cxcywh(bbox): cx = bbox[0] + bbox[2] / 2 cy = bbox[1] + bbox[3] / 2 return (cx, cy, bbox[2], bbox[3])
def bbox_xywh2cxcywh(bbox): cx = bbox[0] + bbox[2] / 2 cy = bbox[1] + bbox[3] / 2 return (cx, cy, bbox[2], bbox[3])
class Block(object): def __init__(self, name) -> None: super().__init__() self.__name__ = name
class Block(object): def __init__(self, name) -> None: super().__init__() self.__name__ = name
def subsets(l): if not l: return [[]] else: all_subsets = [] for i in range(len(l)): sub_subsets = subsets(l[:i] + l[i + 1:]) [all_subsets.append(subset) for subset in sub_subsets if subset not in all_subsets] if l not in all_subsets: a...
def subsets(l): if not l: return [[]] else: all_subsets = [] for i in range(len(l)): sub_subsets = subsets(l[:i] + l[i + 1:]) [all_subsets.append(subset) for subset in sub_subsets if subset not in all_subsets] if l not in all_subsets: a...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- class SizeError( Exception ): pass
class Sizeerror(Exception): pass
class Solution: def numberOfArithmeticSlices(self, nums: List[int]) -> int: ''' -5 -2 1 4 5 6 7 9 11 <3 = 0 3 -> 1 4 -> 2+1 5 -> 3+2+1 6 -> 4+3+2+1 n -> n(n+1)/2 -n - (n-1) -> (n^2 - 3n + 2)/2 ''' def getCount(n): ...
class Solution: def number_of_arithmetic_slices(self, nums: List[int]) -> int: """ -5 -2 1 4 5 6 7 9 11 <3 = 0 3 -> 1 4 -> 2+1 5 -> 3+2+1 6 -> 4+3+2+1 n -> n(n+1)/2 -n - (n-1) -> (n^2 - 3n + 2)/2 """ def get_count(n): ...
class HelperError(Exception): pass class BaseHelper(object): def get_current_path(self): raise HelperError('you have to customized YourHelper.get_current_path') def get_params(self): raise HelperError('you have to customized YourHelper.get_params') def get_body(self): raise...
class Helpererror(Exception): pass class Basehelper(object): def get_current_path(self): raise helper_error('you have to customized YourHelper.get_current_path') def get_params(self): raise helper_error('you have to customized YourHelper.get_params') def get_body(self): raise...
class Solution: def maxSubArray(self, nums: List[int]) -> int: maxsofar = nums[0] maxendinghere = nums[0] for i in range(1, len(nums)): maxendinghere = max(nums[i], nums[i] + maxendinghere) maxsofar = max(maxsofar, maxendinghere) return m...
class Solution: def max_sub_array(self, nums: List[int]) -> int: maxsofar = nums[0] maxendinghere = nums[0] for i in range(1, len(nums)): maxendinghere = max(nums[i], nums[i] + maxendinghere) maxsofar = max(maxsofar, maxendinghere) return maxsofar