content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
_base_ = "./FlowNet512_1.5AugCosyAAEGray_Aggressive_Flat_Pbr_01_ape.py" OUTPUT_DIR = "output/deepim/lmPbrSO/FlowNet512_1.5AugCosyAAEGray_Aggressive_Flat_lmPbr_SO/benchvise" DATASETS = dict(TRAIN=("lm_pbr_benchvise_train",), TEST=("lm_real_benchvise_test",)) # bbnc7 # objects benchvise Avg(1) # ad_2 10.77 10...
_base_ = './FlowNet512_1.5AugCosyAAEGray_Aggressive_Flat_Pbr_01_ape.py' output_dir = 'output/deepim/lmPbrSO/FlowNet512_1.5AugCosyAAEGray_Aggressive_Flat_lmPbr_SO/benchvise' datasets = dict(TRAIN=('lm_pbr_benchvise_train',), TEST=('lm_real_benchvise_test',))
class ChannelLengthException(Exception): '''channel searched is more than 16 characters use with the command line functions ''' pass class ChannelCharactersException(Exception): ''' it should not contain characters that cannot be used in a channel ''' pass class ChannelQuote...
class Channellengthexception(Exception): """channel searched is more than 16 characters use with the command line functions """ pass class Channelcharactersexception(Exception): """ it should not contain characters that cannot be used in a channel """ pass class Channelquotes...
# Algorithm: Longest monotonic subsequence # Overall Time Complexity: O(n^2). # Space Complexity: O(n). # Author: https://www.linkedin.com/in/kilar. def monotonic_subsequence(arr): Dict = {} maximum = 0 for i in range(len(arr)): Dict[i] = [arr[i]] for j in range(i + 1, len(arr)): ...
def monotonic_subsequence(arr): dict = {} maximum = 0 for i in range(len(arr)): Dict[i] = [arr[i]] for j in range(i + 1, len(arr)): if arr[j] >= Dict[i][-1]: Dict[i].append(arr[j]) for m in Dict: temp = maximum maximum = max(maximum...
class ArticleCandidate: """This is a helpclass to store the result of an article after it was extracted. Every implemented extractor returns an ArticleCanditate as result. """ url = None title = None description = None text = None topimage = None author = None publish_date = None...
class Articlecandidate: """This is a helpclass to store the result of an article after it was extracted. Every implemented extractor returns an ArticleCanditate as result. """ url = None title = None description = None text = None topimage = None author = None publish_date = None...
class Record: def __init__(self, row_id): self.row_id = row_id class Table: lookup_table = {} @classmethod def get_record(cls, row_id: int) -> Record: """ if row_id not in cls.lookup_table, instantiate Record object on the fly. """ if row_id not in cls....
class Record: def __init__(self, row_id): self.row_id = row_id class Table: lookup_table = {} @classmethod def get_record(cls, row_id: int) -> Record: """ if row_id not in cls.lookup_table, instantiate Record object on the fly. """ if row_id not in cls....
class Solution: def sortColors(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ red = 0 white = 0 blue = 0 for i in nums: if i == 0: red += 1 elif i == 1: wh...
class Solution: def sort_colors(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ red = 0 white = 0 blue = 0 for i in nums: if i == 0: red += 1 elif i == 1: wh...
# p43.py str1 = input().split() str1.reverse() def exp(): s = str1.pop() if s[0] == '+': return exp() + exp() elif s[0] == '-': return exp() - exp() elif s[0] == '*': return exp() * exp() elif s[0] == '/': return exp() / exp() else: retur...
str1 = input().split() str1.reverse() def exp(): s = str1.pop() if s[0] == '+': return exp() + exp() elif s[0] == '-': return exp() - exp() elif s[0] == '*': return exp() * exp() elif s[0] == '/': return exp() / exp() else: return float(s) print(int(exp()...
#!/usr/bin/env python3 # calculate path of lowest risk # use Dijkstra algorithm risk = [] with open('input', 'r') as data: lines = data.readlines() for line in lines: risk.append([int(l) for l in line.strip()]) # prepare nodes # we might get up with x <-> y again... graph = [] for y in range...
risk = [] with open('input', 'r') as data: lines = data.readlines() for line in lines: risk.append([int(l) for l in line.strip()]) graph = [] for y in range(len(risk)): graph.append([{'visited': False, 'risk': 10000000} for x in range(len(risk[y]))]) def visit_neighbors(position, graph): x = po...
stack = [] stack.append("Moby Dick") stack.append("The Great Gatsby") stack.append("Hamlet") stack.pop() stack.append("The Iliad") stack.append("Pride and Prejudice") stack.pop() stack.append("To Kill a Mockingbird") stack.append("Gulliver's Travels") stack.append("Don Quixote") stack.pop() stack.pop() stack.pop() stac...
stack = [] stack.append('Moby Dick') stack.append('The Great Gatsby') stack.append('Hamlet') stack.pop() stack.append('The Iliad') stack.append('Pride and Prejudice') stack.pop() stack.append('To Kill a Mockingbird') stack.append("Gulliver's Travels") stack.append('Don Quixote') stack.pop() stack.pop() stack.pop() stac...
MOCK_PLAYER = { "_id": 1234, "uuid": "2ad3kfei9ikmd", "displayname": "TestPlayer123", "knownAliases": ["1234", "test", "TestPlayer123"], "firstLogin": 123456, "lastLogin": 150996, "achievementsOneTime": ["MVP", "MVP2", "BedwarsMVP"], "achievementPoints": 300, "achievements": {"bedwar...
mock_player = {'_id': 1234, 'uuid': '2ad3kfei9ikmd', 'displayname': 'TestPlayer123', 'knownAliases': ['1234', 'test', 'TestPlayer123'], 'firstLogin': 123456, 'lastLogin': 150996, 'achievementsOneTime': ['MVP', 'MVP2', 'BedwarsMVP'], 'achievementPoints': 300, 'achievements': {'bedwars_level': 5, 'general_challenger': 7,...
# -*- coding: utf-8 -* INN_TEST_WEIGHTS_10 = (2, 4, 10, 3, 5, 9, 4, 6, 8, 0) INN_TEST_WEIGHTS_12_0 = (7, 2, 4, 10, 3, 5, 9, 4, 6, 8, 0, 0) INN_TEST_WEIGHTS_12_1 = (3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8, 0) def test_inn_org(inn): """ returns True if inn of the organisation pass the check """ if len(inn) != 10:...
inn_test_weights_10 = (2, 4, 10, 3, 5, 9, 4, 6, 8, 0) inn_test_weights_12_0 = (7, 2, 4, 10, 3, 5, 9, 4, 6, 8, 0, 0) inn_test_weights_12_1 = (3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8, 0) def test_inn_org(inn): """ returns True if inn of the organisation pass the check """ if len(inn) != 10: return False ...
class Solution: def XXX(self, root: TreeNode) -> int: self.maxleftlength = 0 self.maxrightlength = 0 return self.dp(root) def dp(self,root): if(root is None): return 0 self.maxleftlength = self.dp(root.left) self.maxrightlength = self.d...
class Solution: def xxx(self, root: TreeNode) -> int: self.maxleftlength = 0 self.maxrightlength = 0 return self.dp(root) def dp(self, root): if root is None: return 0 self.maxleftlength = self.dp(root.left) self.maxrightlength = self.dp(root.right) ...
{'application':{'type':'Application', 'name':'GuiPyBlog', 'backgrounds': [ {'type':'Background', 'name':'bgTextRouter', 'title':'TextRouter 0.60', 'size':(650, 426), 'statusBar':1, 'icon':'tr.ico', 'style':['resizeable'], 'menubar': {'ty...
{'application': {'type': 'Application', 'name': 'GuiPyBlog', 'backgrounds': [{'type': 'Background', 'name': 'bgTextRouter', 'title': 'TextRouter 0.60', 'size': (650, 426), 'statusBar': 1, 'icon': 'tr.ico', 'style': ['resizeable'], 'menubar': {'type': 'MenuBar', 'menus': [{'type': 'Menu', 'name': 'menuFile', 'label': '&...
""" Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *. Input: "2-1-1". ((2-1)-1) = 0 (2-(1-1)) = 2 Time complexity of this algorithm is Catalan number. """ def way_to_compute(input): ...
""" Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *. Input: "2-1-1". ((2-1)-1) = 0 (2-(1-1)) = 2 Time complexity of this algorithm is Catalan number. """ def way_to_compute(input): ...
WARNING_HEADER = '[\033[1m\033[93mWARNING\033[0m]' def warning_message(message_text): print('{header} {text}'.format(header=WARNING_HEADER, text=message_text))
warning_header = '[\x1b[1m\x1b[93mWARNING\x1b[0m]' def warning_message(message_text): print('{header} {text}'.format(header=WARNING_HEADER, text=message_text))
class WebsocketError(Exception): pass class NoTokenError(WebsocketError): pass
class Websocketerror(Exception): pass class Notokenerror(WebsocketError): pass
a,b=0,1 while b<10: print(b) a,b=b,a+b
(a, b) = (0, 1) while b < 10: print(b) (a, b) = (b, a + b)
# while loops """ a = 1 b = 10 while a < b: print(a) #will go on forever """ # Docstringed loop above. Uncomment to see an infinite loop # then kill it or wait for Python to reach an error a = 1 b = 10 while a < b: print(a) a = a +1 # Now it will stop # Bonus: calculate the iterations before this sto...
""" a = 1 b = 10 while a < b: print(a) #will go on forever """ a = 1 b = 10 while a < b: print(a) a = a + 1 while True: answer = input('Are you happy?') if answer == 'yes': break
def thank_you(donation): if donation >= 1000: print("Thank you for your donation! You have achieved platinum donation status!") elif donation >= 500: print("Thank you for your donation! You have achieved gold donation status!") elif donation >= 100: print("Thank you for your donation! You have achiev...
def thank_you(donation): if donation >= 1000: print('Thank you for your donation! You have achieved platinum donation status!') elif donation >= 500: print('Thank you for your donation! You have achieved gold donation status!') elif donation >= 100: print('Thank you for your donation...
''' This file holds all the constants that are required for programming the LIS3DH including register addresses and their values ''' ''' The LIS3DH I2C address ''' LIS3DH_I2C_ADDR = 0x18 ''' The LIS3DH Register Map ''' #0x00 - 0x06 - reserved STATUS_REG_AUX = 0x07 OUT_ADC1_L = 0x08...
""" This file holds all the constants that are required for programming the LIS3DH including register addresses and their values """ '\nThe LIS3DH I2C address\n' lis3_dh_i2_c_addr = 24 '\nThe LIS3DH Register Map\n' status_reg_aux = 7 out_adc1_l = 8 out_adc1_h = 9 out_adc2_l = 10 out_adc2_h = 11 out_adc3_l = 12 out_adc3...
def moveDictionary(): electro_shock = {"Name" : "Electro Shock", \ "Kind" : "atk",\ "Pwr" : 25, \ "Acc" : 95, \ "Crit" : 80, \ "Txt" : "releases one thousand volts of static"} #special ...
def move_dictionary(): electro_shock = {'Name': 'Electro Shock', 'Kind': 'atk', 'Pwr': 25, 'Acc': 95, 'Crit': 80, 'Txt': 'releases one thousand volts of static'} heal = {'Name': 'Heal', 'Kind': 'heal', 'Pwr': 28, 'Acc': 36, 'Crit': 5, 'Txt': 'attempts to put itself back together'} robot_punch = {'Name': 'Ro...
""" limis management - messages Messages used for logging and exception handling. """ COMMAND_CREATE_PROJECT_RUN_COMPLETED = 'Completed creating limis project: "{}".' COMMAND_CREATE_PROJECT_RUN_ERROR = 'Error creating project in directory: "{}".\nError Message: {}' COMMAND_CREATE_PROJECT_RUN_STARTED = 'Creating limis ...
""" limis management - messages Messages used for logging and exception handling. """ command_create_project_run_completed = 'Completed creating limis project: "{}".' command_create_project_run_error = 'Error creating project in directory: "{}".\nError Message: {}' command_create_project_run_started = 'Creating limis ...
class Solution: def rob(self, nums): robbed, notRobbed = 0, 0 for i in nums: robbed, notRobbed = notRobbed + i, max(robbed, notRobbed) return max(robbed, notRobbed)
class Solution: def rob(self, nums): (robbed, not_robbed) = (0, 0) for i in nums: (robbed, not_robbed) = (notRobbed + i, max(robbed, notRobbed)) return max(robbed, notRobbed)
# Common package prefixes, in the order we want to check for them _PREFIXES = (".com.", ".org.", ".net.", ".io.") # By default bazel computes the name of test classes based on the # standard Maven directory structure, which we may not always use, # so try to compute the correct package name. def get_package_name(): ...
_prefixes = ('.com.', '.org.', '.net.', '.io.') def get_package_name(): pkg = native.package_name().replace('/', '.') for prefix in _PREFIXES: idx = pkg.find(prefix) if idx != -1: return pkg[idx + 1:] + '.' return '' def get_class_name(src): idx = src.rindex('.') name =...
numbers = [int(i) for i in input().split(" ")] opposite_numbers = [] for current_num in numbers: if current_num >= 0: opposite_numbers.append(-current_num) elif current_num < 0: opposite_numbers.append(abs(current_num)) print(opposite_numbers)
numbers = [int(i) for i in input().split(' ')] opposite_numbers = [] for current_num in numbers: if current_num >= 0: opposite_numbers.append(-current_num) elif current_num < 0: opposite_numbers.append(abs(current_num)) print(opposite_numbers)
def finder(data, x): if x == 0: return data[x] v1 = data[x] v2 = finder(data, x-1) if v1 > v2: return v1 else: return v2 print(finder([0, -247, 341, 1001, 741, 22]))
def finder(data, x): if x == 0: return data[x] v1 = data[x] v2 = finder(data, x - 1) if v1 > v2: return v1 else: return v2 print(finder([0, -247, 341, 1001, 741, 22]))
def extractStrictlybromanceCom(item): ''' Parser for 'strictlybromance.com' ''' vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title']) if not (chp or vol) or "preview" in item['title'].lower(): return None tagmap = [ ('grave robbers\' chronicles', 'grave robbers\' chronicles', ...
def extract_strictlybromance_com(item): """ Parser for 'strictlybromance.com' """ (vol, chp, frag, postfix) = extract_vol_chapter_fragment_postfix(item['title']) if not (chp or vol) or 'preview' in item['title'].lower(): return None tagmap = [("grave robbers' chronicles", "grave robbers' chron...
class Solution: def largestTimeFromDigits(self, nums: List[int]) -> str: res=[] def per(depth): if depth==len(nums)-1: res.append(nums[:]) for i in range(depth,len(nums)): nums[i],nums[depth]=nums[depth],nums[i] ...
class Solution: def largest_time_from_digits(self, nums: List[int]) -> str: res = [] def per(depth): if depth == len(nums) - 1: res.append(nums[:]) for i in range(depth, len(nums)): (nums[i], nums[depth]) = (nums[depth], nums[i]) ...
def fbx_references_elements(root, scene_data): """ Have no idea what references are in FBX currently... Just writing empty element. """ docs = elem_empty(root, b"References")
def fbx_references_elements(root, scene_data): """ Have no idea what references are in FBX currently... Just writing empty element. """ docs = elem_empty(root, b'References')
EPS = 1.0e-16 PI = 3.141592653589793
eps = 1e-16 pi = 3.141592653589793
#all binary allSensors = ['D021', 'D022', 'D023', 'D024', 'D025', 'D026', 'D027', 'D028', 'D029', 'D030', 'D031', 'D032', 'M001', 'M002', 'M003', 'M004', 'M005', 'M006', 'M007', 'M008', 'M009', 'M010', 'M011', 'M012', 'M013', 'M014', 'M015', 'M016', 'M017', 'M018', 'M019', 'M020'] doorSens...
all_sensors = ['D021', 'D022', 'D023', 'D024', 'D025', 'D026', 'D027', 'D028', 'D029', 'D030', 'D031', 'D032', 'M001', 'M002', 'M003', 'M004', 'M005', 'M006', 'M007', 'M008', 'M009', 'M010', 'M011', 'M012', 'M013', 'M014', 'M015', 'M016', 'M017', 'M018', 'M019', 'M020'] door_sensors = ['D021', 'D022', 'D023', 'D024', '...
f = [1, 1, 2, 6, 4] for _ in range(int(input())): n = int(input()) if n <= 4: print(f[n]) else: print(0)
f = [1, 1, 2, 6, 4] for _ in range(int(input())): n = int(input()) if n <= 4: print(f[n]) else: print(0)
# 6. Zigzag Conversion # Runtime: 103 ms, faster than 20.89% of Python3 online submissions for Zigzag Conversion. # Memory Usage: 14.7 MB, less than 13.84% of Python3 online submissions for Zigzag Conversion. class Solution: def convert(self, s: str, numRows: int) -> str: if numRows == 1: re...
class Solution: def convert(self, s: str, numRows: int) -> str: if numRows == 1: return s rows = [[] for _ in range(numRows)] largest_interval = numRows * 2 - 2 for r in range(numRows): i = r curr_interval = largest_interval - 2 * r if...
# # PySNMP MIB module AGENTX-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AGENTX-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:15:42 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, value_size_constraint, single_value_constraint, constraints_intersection, constraints_union) ...
class Layer: def __init(self): self.input=None self.output=None def forward(self,input): #to return the output layer pass def backward(self,output_gradient,learning_rate): #change para and return input derivative pass
class Layer: def __init(self): self.input = None self.output = None def forward(self, input): pass def backward(self, output_gradient, learning_rate): pass
class Capture: def capture(self): pass
class Capture: def capture(self): pass
def f(n): if n == 0: return 0 elif n == 1: return 1 else: return f(n-1)+f(n-2) n=int(input()) values = [str(f(x)) for x in range(0, n+1)] print(",".join(values))
def f(n): if n == 0: return 0 elif n == 1: return 1 else: return f(n - 1) + f(n - 2) n = int(input()) values = [str(f(x)) for x in range(0, n + 1)] print(','.join(values))
#TODO Create Functions for PMTA ## TORISPHERICAL TOP HEAD 2:1 - Min thickness allowed and PMTA class TorisphericalCalcs: def __init__(self): self.L_top_head = None self.r_top_head = None self.ratio_L_r_top = None self.M_factor_top_head = None self.t_min_top_head = No...
class Torisphericalcalcs: def __init__(self): self.L_top_head = None self.r_top_head = None self.ratio_L_r_top = None self.M_factor_top_head = None self.t_min_top_head = None self.t_nom_top_head_plate = None self.t_top_head_nom_after_conf = None self....
''' Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values. Example 1: Input: 5 Output: True Explanation: The binary representation of 5 is: 101 Example 2: Input: 7 Output: False Explanation: The binary representation of 7 is: 111. Example 3: In...
""" Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values. Example 1: Input: 5 Output: True Explanation: The binary representation of 5 is: 101 Example 2: Input: 7 Output: False Explanation: The binary representation of 7 is: 111. Example 3: In...
# Collaborators (including web sites where you got help: (enter none if you didn't need help) # claryse adams def avg_temp(user_list): total = 0 for x in range(1, len(user_list)): total += user_list[x] average = total/(len(user_list)-1) average = round(average, 2) return average if __name...
def avg_temp(user_list): total = 0 for x in range(1, len(user_list)): total += user_list[x] average = total / (len(user_list) - 1) average = round(average, 2) return average if __name__ == '__main__': with open('temps.txt') as file_object: contents = file_object.readlines() i...
def fry(): print('The eggs have been fried')
def fry(): print('The eggs have been fried')
class Data: def __init__(self, dia, mes, ano): self.dia = dia self.mes = mes self.ano = ano print(self) @classmethod def de_string(cls, data_string): dia, mes, ano = map(int, data_string.split("-")) data = cls(dia, mes, ano) return data ...
class Data: def __init__(self, dia, mes, ano): self.dia = dia self.mes = mes self.ano = ano print(self) @classmethod def de_string(cls, data_string): (dia, mes, ano) = map(int, data_string.split('-')) data = cls(dia, mes, ano) return data @stati...
""" Created by adam on 5/20/18 """ __author__ = 'adam' class IModifierList(object): """ Interface for classes which act on a list of strings by modifying the input strings and returning a list of modified strings. Used for tasks like lemmatizing etc """ def __init__(self): pass d...
""" Created by adam on 5/20/18 """ __author__ = 'adam' class Imodifierlist(object): """ Interface for classes which act on a list of strings by modifying the input strings and returning a list of modified strings. Used for tasks like lemmatizing etc """ def __init__(self): pass de...
class DummyContext: context = {} dummy_context = DummyContext()
class Dummycontext: context = {} dummy_context = dummy_context()
class NameScope(object,INameScopeDictionary,INameScope,IDictionary[str,object],ICollection[KeyValuePair[str,object]],IEnumerable[KeyValuePair[str,object]],IEnumerable): """ Implements base WPF support for the System.Windows.Markup.INameScope methods that store or retrieve name-object mappings into a particular XAML...
class Namescope(object, INameScopeDictionary, INameScope, IDictionary[str, object], ICollection[KeyValuePair[str, object]], IEnumerable[KeyValuePair[str, object]], IEnumerable): """ Implements base WPF support for the System.Windows.Markup.INameScope methods that store or retrieve name-object mappings into a parti...
# Copyright 2020 BBC Research & Development # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed ...
experiment_name = 'exp1_bn' experiment_path = 'experiment/path' output_path = experiment_path + experiment_name core_model = 'bn_model' d_scales = 1 data_path = 'data/path' input_shape = (256, 256) input_color_mode = 'rgb' output_color_mode = 'lab' interpolation = 'nearest' chunk_size = 10000 samples_rate = 1.0 shuffle...
# -*- coding: utf-8 -*- __author__ = 'Wael Ben Zid El Guebsi' __email__ = 'benzid.wael@hotmail.fr' __version__ = '0.0.0'
__author__ = 'Wael Ben Zid El Guebsi' __email__ = 'benzid.wael@hotmail.fr' __version__ = '0.0.0'
# coding: utf-8 n = int(input()) li = [int(i) for i in input().split()] print(sum(li)/n)
n = int(input()) li = [int(i) for i in input().split()] print(sum(li) / n)
class Question: def __init__(self, text, answer): self.text = text self.answer = answer new_q = Question("lkajsdkf", "False")
class Question: def __init__(self, text, answer): self.text = text self.answer = answer new_q = question('lkajsdkf', 'False')
#!/usr/bin/env python3 """Mtools version.""" __version__ = '1.6.4-dev'
"""Mtools version.""" __version__ = '1.6.4-dev'
def buildMaskSplit(noiseGShape, noiseGTexture, categoryVectorDim, attribKeysOrder, attribShift, keySplits=None, mixedNoise=False): r""" Build a 8bits mask that split a full input latent vector int...
def build_mask_split(noiseGShape, noiseGTexture, categoryVectorDim, attribKeysOrder, attribShift, keySplits=None, mixedNoise=False): """ Build a 8bits mask that split a full input latent vector into two intermediate latent vectors: one for the shape network and one for the texture network. """ n...
def find_three_values_that_sum(lines, sum=2020): for idx1, line1 in enumerate(lines): for idx2, line2 in enumerate(lines[idx1:]): for idx3, line3 in enumerate(lines[idx1+idx2:]): num1 = int(line1) num2 = int(line2) num3 = int(line3) ...
def find_three_values_that_sum(lines, sum=2020): for (idx1, line1) in enumerate(lines): for (idx2, line2) in enumerate(lines[idx1:]): for (idx3, line3) in enumerate(lines[idx1 + idx2:]): num1 = int(line1) num2 = int(line2) num3 = int(line3) ...
class Constants(object): """ Constant declarations. """ API_URL = 'https://i.instagram.com/api/v1/' VERSION = '9.2.0' IG_SIG_KEY = '012a54f51c49aa8c5c322416ab1410909add32c966bbaa0fe3dc58ac43fd7ede' EXPERIMENTS = 'ig_android_ad_holdout_16m5_universe,ig_android_progressive_jpeg,ig_creation_gro...
class Constants(object): """ Constant declarations. """ api_url = 'https://i.instagram.com/api/v1/' version = '9.2.0' ig_sig_key = '012a54f51c49aa8c5c322416ab1410909add32c966bbaa0fe3dc58ac43fd7ede' experiments = 'ig_android_ad_holdout_16m5_universe,ig_android_progressive_jpeg,ig_creation_gro...
"Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k" class Solution: def containsNearbyDuplicate(self, nums: List[int], k: int) -> bool: if not nums or len(nums) == 1: return False ...
"""Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k""" class Solution: def contains_nearby_duplicate(self, nums: List[int], k: int) -> bool: if not nums or len(nums) == 1: return Fa...
class Solution: def generate(self, numRows: int): result = [] if not numRows: return result for i in range(1, numRows + 1): temp = [1] * i lo = 1 hi = i - 2 while lo <= hi: temp[lo] = temp[hi] = result[i - 2...
class Solution: def generate(self, numRows: int): result = [] if not numRows: return result for i in range(1, numRows + 1): temp = [1] * i lo = 1 hi = i - 2 while lo <= hi: temp[lo] = temp[hi] = result[i - 2][lo] + ...
""" This problem was asked by Microsoft. Given an array of numbers, find the length of the longest increasing subsequence in the array. The subsequence does not necessarily have to be contiguous. For example, given the array [0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15], the longest increasing subsequence ha...
""" This problem was asked by Microsoft. Given an array of numbers, find the length of the longest increasing subsequence in the array. The subsequence does not necessarily have to be contiguous. For example, given the array [0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15], the longest increasing subsequence ha...
class Empty(Exception): pass class LinkedQueue: """FIFO queue implkementation using a singly linked list for storage""" class _Node: """Lightweight, nonpublic claass for storing a singly linked node.""" __slots__ = ( "_element", "_next", ) # streamline me...
class Empty(Exception): pass class Linkedqueue: """FIFO queue implkementation using a singly linked list for storage""" class _Node: """Lightweight, nonpublic claass for storing a singly linked node.""" __slots__ = ('_element', '_next') def __init__(self, element, next): ...
# 1921. Eliminate Maximum Number of Monsters # You are playing a video game where you are defending your city from a group of n monsters. # You are given a 0-indexed integer array dist of size n, where dist[i] is the initial # distance in meters of the ith monster from the city. # The monsters walk toward the city at...
class Solution: def eliminate_maximum(self, dist: List[int], speed: List[int]) -> int: if not dist or not speed or len(dist) == 0 or (len(speed) == 0) or (len(dist) != len(speed)): return 0 l = len(speed) orders = [] for i in range(l): orders.append([dist[i],...
__author__ = 'Chetan' class Wizard(): def __init__(self, src, rootdir): self.choices = [] self.rootdir = rootdir self.src = src def preferences(self, command): self.choices.append(command) def execute(self): for choice in self.choices: ...
__author__ = 'Chetan' class Wizard: def __init__(self, src, rootdir): self.choices = [] self.rootdir = rootdir self.src = src def preferences(self, command): self.choices.append(command) def execute(self): for choice in self.choices: if list(choice.val...
####################################################### # # ManageRacacatPinController.py # Python implementation of the Class ManageRacacatPinController # Generated by Enterprise Architect # Created on: 15-Apr-2020 4:57:23 PM # Original author: Giu Platania # ############################################...
class Manageracacatpincontroller: pass
N = int(input()) ans = 0 if N < 10 ** 3: print(0) elif 10 ** 3 <= N < 10 ** 6: print(N - 10 ** 3 + 1) elif 10 ** 6 <= N < 10 ** 9: print(10 ** 6 - 10 ** 3 + (N - 10 ** 6 + 1)*2) elif 10 ** 9 <= N < 10 ** 12: print(10 ** 6 - 10 ** 3 + (10 ** 9 - 10 ** 6)*2 + (N - 10 ** 9 + 1)*3) elif 10 ** 12 <= N < 10 ...
n = int(input()) ans = 0 if N < 10 ** 3: print(0) elif 10 ** 3 <= N < 10 ** 6: print(N - 10 ** 3 + 1) elif 10 ** 6 <= N < 10 ** 9: print(10 ** 6 - 10 ** 3 + (N - 10 ** 6 + 1) * 2) elif 10 ** 9 <= N < 10 ** 12: print(10 ** 6 - 10 ** 3 + (10 ** 9 - 10 ** 6) * 2 + (N - 10 ** 9 + 1) * 3) elif 10 ** 12 <= N ...
valor = 12 def teste_git(testes): result = testes ** 33 return result print(teste_git(valor))
valor = 12 def teste_git(testes): result = testes ** 33 return result print(teste_git(valor))
def show_first(word): print(word[0]) show_first("abc")
def show_first(word): print(word[0]) show_first('abc')
def new_multiplayer(bot, message): """ /new_multiplayer command handler """ chat_id = message.chat.id bot.send_message(chat_id=chat_id, text="Not implemented yet")
def new_multiplayer(bot, message): """ /new_multiplayer command handler """ chat_id = message.chat.id bot.send_message(chat_id=chat_id, text='Not implemented yet')
def count_positives_sum_negatives(arr): if not arr: return [] positive_array_count = 0 negative_array_count = 0 neither_array = 0 for i in arr: if i > 0: positive_array_count = positive_array_count + 1 elif i == 0: neither_array = neither_array + i ...
def count_positives_sum_negatives(arr): if not arr: return [] positive_array_count = 0 negative_array_count = 0 neither_array = 0 for i in arr: if i > 0: positive_array_count = positive_array_count + 1 elif i == 0: neither_array = neither_array + i ...
input_shape = 56, 56, 3 num_class = 80 total_epoches = 50 batch_size = 64 train_num = 11650 val_num = 1254 iterations_per_epoch = train_num // batch_size + 1 test_iterations = val_num // batch_size + 1 weight_decay = 1e-3 label_smoothing = 0.1 ''' numeric characteristics ''' mean = [154.64720717, 163.98750114, 1...
input_shape = (56, 56, 3) num_class = 80 total_epoches = 50 batch_size = 64 train_num = 11650 val_num = 1254 iterations_per_epoch = train_num // batch_size + 1 test_iterations = val_num // batch_size + 1 weight_decay = 0.001 label_smoothing = 0.1 '\nnumeric characteristics\n' mean = [154.64720717, 163.98750114, 175.110...
def sort3(a, b, c): i = [] i.append(a), i.append(b), i.append(c) i = sorted(i) return i a, b, c = input(), input(), input() print(*sort3(a, b, c))
def sort3(a, b, c): i = [] (i.append(a), i.append(b), i.append(c)) i = sorted(i) return i (a, b, c) = (input(), input(), input()) print(*sort3(a, b, c))
''' occurrences_dict loop values: occurrences_dict[value] += 1 ''' # numbers_string = '-2.5 4 3 -2.5 -5.54 4 3 3 -2.5 3' # numbers_string = '2 4 4 5 5 2 3 3 4 4 3 3 4 3 5 3 2 5 4 3' numbers_string = input() occurrence_counts = {} # No such thing as tuple comprehension, this is generator numbers = [float(x) for x...
""" occurrences_dict loop values: occurrences_dict[value] += 1 """ numbers_string = input() occurrence_counts = {} numbers = [float(x) for x in numbers_string.split(' ')] for number in numbers: if number not in occurrence_counts: occurrence_counts[number] = 0 occurrence_counts[number] += 1 for (numb...
count = 0 total = 0 while True: Enter = input('Enter a number:\n') try: if Enter == "Done": break else: inp = int(Enter) total = total + inp count = count + 1 average = total / count except: print('Invalid input') print('Tot...
count = 0 total = 0 while True: enter = input('Enter a number:\n') try: if Enter == 'Done': break else: inp = int(Enter) total = total + inp count = count + 1 average = total / count except: print('Invalid input') print('Tot...
# # PySNMP MIB module BEGEMOT-IP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/BEGEMOT-IP-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:37:03 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_size_constraint, value_range_constraint, single_value_constraint, constraints_union) ...
SECRET_KEY = 'fake-key-here' # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'rest_framework.authtoken', 'd...
secret_key = 'fake-key-here' installed_apps = ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'rest_framework.authtoken', 'data_ingest'] middleware = ['django.contrib.sessions.middleware....
# RUN: test-parser.sh %s # RUN: test-output.sh %s x = 1 # PARSER-LABEL:x = 1i y = 2 # PARSER-NEXT:y = 2i print("Start") # PARSER-NEXT:print("Start") # OUTPUT-LABEL: Start if x == 1: # PARSER-NEXT:if (x == 1i): if y == 3: # PARSER-NEXT: if ...
x = 1 y = 2 print('Start') if x == 1: if y == 3: print('A') else: print('C') print('D') if x == 1: if y == 3: print('A') else: print('B') else: print('C') print('D') if x == 1: if y == 3: print('A') else: print('B') print('D') if x == 1: if y == 3:...
class CameraNotConnected(Exception): pass class WiredControlAlreadyEstablished(Exception): pass
class Cameranotconnected(Exception): pass class Wiredcontrolalreadyestablished(Exception): pass
""" Project Euler: Problem #002 """ def solve(lim = 4 * 1000 * 1000): """ Naive solution with a function. :param lim: Max number to sum up to. :returns: The sum of the even Fibo-numbers. """ a, b = 0, 1 sum = 0 while b < lim: if not b % 2: sum +=...
""" Project Euler: Problem #002 """ def solve(lim=4 * 1000 * 1000): """ Naive solution with a function. :param lim: Max number to sum up to. :returns: The sum of the even Fibo-numbers. """ (a, b) = (0, 1) sum = 0 while b < lim: if not b % 2: sum += b (a, b) ...
# https://codeforces.com/problemset/problem/116/A n = int(input()) stops = [list(map(int, input().split())) for _ in range(n)] p, peak_p = 0, 0 for stop in stops: p -= stop[0] p += stop[1] peak_p = max(p, peak_p) print(peak_p)
n = int(input()) stops = [list(map(int, input().split())) for _ in range(n)] (p, peak_p) = (0, 0) for stop in stops: p -= stop[0] p += stop[1] peak_p = max(p, peak_p) print(peak_p)
def int_to_char(word): arr = list(word) num_str = "" while True: if not arr[0].isdigit(): break num_str += arr[0] arr.pop(0) num = int(num_str) arr.insert(0, chr(num)) return "".join(arr) def switch_letters(word): list_chars = list(word) list_char...
def int_to_char(word): arr = list(word) num_str = '' while True: if not arr[0].isdigit(): break num_str += arr[0] arr.pop(0) num = int(num_str) arr.insert(0, chr(num)) return ''.join(arr) def switch_letters(word): list_chars = list(word) (list_chars[1...
PROJECT_ID = 'dmp-y-tests' DATASET_NAME = 'test_gpl' BUCKET_NAME = 'bucket_gpl' LOCAL_DIR_PATH = '/tmp/gpl_directory'
project_id = 'dmp-y-tests' dataset_name = 'test_gpl' bucket_name = 'bucket_gpl' local_dir_path = '/tmp/gpl_directory'
def commonDiv(num, den, divs = None) : if not divs : divs = divisors(den) for i in divs[1:] : if not num % i : return True return False def validNums(den, minNum, maxNum) : divs = divisors(den) return [i for i in range(minNum,maxNum+1) if not commonDiv(i, den, divs)] def countBetween(lowNum, lowDen, h...
def common_div(num, den, divs=None): if not divs: divs = divisors(den) for i in divs[1:]: if not num % i: return True return False def valid_nums(den, minNum, maxNum): divs = divisors(den) return [i for i in range(minNum, maxNum + 1) if not common_div(i, den, divs)] def...
# Exception Handling function def exception_handling(number1, number2, operator): # Only digit exception try: int(number1) except: return "Error: Numbers must only contain digits." try: int(number2) except: return "Error: Numbers must only contain digits." # More...
def exception_handling(number1, number2, operator): try: int(number1) except: return 'Error: Numbers must only contain digits.' try: int(number2) except: return 'Error: Numbers must only contain digits.' try: if len(number1) > 4 or len(number2) > 4: ...
TWITTER_TAGS = [ "agdq2021", "gamesdonequick.com", "agdq", "sgdq", "gamesdonequick", "awesome games done quick", "games done quick", "summer games done quick", "gdq", ] TWITCH_CHANNEL = "gamesdonequick" TWITCH_HOST = "irc.twitch.tv" TWITCH_PORT = 6667 # Update this value to change t...
twitter_tags = ['agdq2021', 'gamesdonequick.com', 'agdq', 'sgdq', 'gamesdonequick', 'awesome games done quick', 'games done quick', 'summer games done quick', 'gdq'] twitch_channel = 'gamesdonequick' twitch_host = 'irc.twitch.tv' twitch_port = 6667 event_shorthand = 'AGDQ2021' donation_url = 'https://gamesdonequick.com...
''' Problem : Find out duplicate number between 1 to N numbers. - Find array sum - Subtract sum of First (n-1) natural numbers from it to find the result. Author : Alok Tripathi ''' # Method to find duplicate in array def findDuplicate(arr, n): return sum(arr) - (((n - 1) * n) // 2) #it will return int no...
""" Problem : Find out duplicate number between 1 to N numbers. - Find array sum - Subtract sum of First (n-1) natural numbers from it to find the result. Author : Alok Tripathi """ def find_duplicate(arr, n): return sum(arr) - (n - 1) * n // 2 if __name__ == '__main__': arr = [1, 2, 3, 3, 4] n = len...
def get_score(player_deck): score_sum=0 for i in player_deck: try: score_sum+=int(i[1]) except: if i[1] in ['K', 'Q', 'J']: score_sum+=10 if i[1]=='Ace': if (score_sum+11)<=21: score_sum+=11 ...
def get_score(player_deck): score_sum = 0 for i in player_deck: try: score_sum += int(i[1]) except: if i[1] in ['K', 'Q', 'J']: score_sum += 10 if i[1] == 'Ace': if score_sum + 11 <= 21: score_sum += 11 ...
def ok(msg): """OK message :msg: TODO :returns: TODO """ return {"message": str(msg)} def err(msg): """Error message :msg: TODO :returns: TODO """ return {"error": str(msg)}
def ok(msg): """OK message :msg: TODO :returns: TODO """ return {'message': str(msg)} def err(msg): """Error message :msg: TODO :returns: TODO """ return {'error': str(msg)}
#MenuTitle: Count Layer and Edit Note # -*- coding: utf-8 -*- # Edit by Tanukizamurai __doc__=""" Count glyphs layers and add value to glyphs note. """ font = Glyphs.font selectedLayers = font.selectedLayers for thisLayer in selectedLayers: thisGlyph = thisLayer.parent layerCount = len(thisLayer.parent.layers) #c...
__doc__ = '\nCount glyphs layers and add value to glyphs note.\n' font = Glyphs.font selected_layers = font.selectedLayers for this_layer in selectedLayers: this_glyph = thisLayer.parent layer_count = len(thisLayer.parent.layers) glyph_name = thisLayer.parent.name glyph_note = thisGlyph.note if glyp...
class Solution: def simplifyPath(self, path): """ :type path: str :rtype: str """ files = path.split('/') stack = list() for f in files: if len(f) == 0 or f == '.': continue elif f == '..': if len(stack):...
class Solution: def simplify_path(self, path): """ :type path: str :rtype: str """ files = path.split('/') stack = list() for f in files: if len(f) == 0 or f == '.': continue elif f == '..': if len(stack...
# coding: utf-8 n = int(input()) a = [int(i) for i in input().split()] for i in range(n): if i < n-1 and a[i+1]<a[i]: break if i==n-1: ans = 0 else: ans = n-1-i a = a[i+1:]+a[:i+1] for i in range(n-1): if a[i] > a[i+1]: print(-1) break else: print(ans)
n = int(input()) a = [int(i) for i in input().split()] for i in range(n): if i < n - 1 and a[i + 1] < a[i]: break if i == n - 1: ans = 0 else: ans = n - 1 - i a = a[i + 1:] + a[:i + 1] for i in range(n - 1): if a[i] > a[i + 1]: print(-1) break else: print(ans)
# Scrapy settings for dirbot project SPIDER_MODULES = ['dirbot.spiders'] NEWSPIDER_MODULE = 'dirbot.spiders' DEFAULT_ITEM_CLASS = 'dirbot.items.Website' ITEM_PIPELINES = { 'dirbot.pipelines.RequiredFieldsPipeline': 1, 'dirbot.pipelines.FilterWordsPipeline': 2, 'dirbot.pipelines.DbPipeline': 3, } # Databa...
spider_modules = ['dirbot.spiders'] newspider_module = 'dirbot.spiders' default_item_class = 'dirbot.items.Website' item_pipelines = {'dirbot.pipelines.RequiredFieldsPipeline': 1, 'dirbot.pipelines.FilterWordsPipeline': 2, 'dirbot.pipelines.DbPipeline': 3} db_api_name = 'MySQLdb' db_args = {'host': 'localhost', 'db': '...
class Solution: def getHeight(self, root): if root is None: return 0 lh = self.getHeight(root.left) + 1 rh = self.getHeight(root.right) + 1 return max(lh, rh) def isBalanced(self, root): if root is None: return True leftHeight = self....
class Solution: def get_height(self, root): if root is None: return 0 lh = self.getHeight(root.left) + 1 rh = self.getHeight(root.right) + 1 return max(lh, rh) def is_balanced(self, root): if root is None: return True left_height = self.g...
class Solution(object): def nthUglyNumber(self, n): """ :type n: int :rtype: int """ # Dynamic programming, keep track of multiples of ugly 2s, 3s, and 5s # Quick return if n <= 0: return 0 # Create dp array dp = [1] * n ...
class Solution(object): def nth_ugly_number(self, n): """ :type n: int :rtype: int """ if n <= 0: return 0 dp = [1] * n idx_2 = idx_3 = idx_5 = 0 for i in range(1, n): dp[i] = min(dp[idx_2] * 2, dp[idx_3] * 3, dp[idx_5] * 5) ...
# %% ####################################### def merge_arrays(*lsts: list): """Merges all arrays into one flat list. Examples: >>> lst_abc = ['a','b','c']\n >>> lst_123 = [1,2,3]\n >>> lst_names = ['John','Alice','Bob']\n >>> merge_arrays(lst_abc,lst_123,lst_names)\n ['a...
def merge_arrays(*lsts: list): """Merges all arrays into one flat list. Examples: >>> lst_abc = ['a','b','c'] >>> lst_123 = [1,2,3] >>> lst_names = ['John','Alice','Bob'] >>> merge_arrays(lst_abc,lst_123,lst_names) ['a', 'b', 'c', 1, 2, 3, 'John', 'Alice', 'Bob'] ...
def get_products_of_all_ints_except_at_index(int_list): if len(int_list) < 2: raise IndexError('Getting the product of numbers at other ' 'indices requires at least 2 numbers') # We make a list with the length of the input list to # hold our products products_of_all_in...
def get_products_of_all_ints_except_at_index(int_list): if len(int_list) < 2: raise index_error('Getting the product of numbers at other indices requires at least 2 numbers') products_of_all_ints_except_at_index = [None] * len(int_list) product_so_far = 1 for i in range(len(int_list)): p...
count = 0 # A global count variable def remember(): global count count += 1 # Count this invocation print(str(count)) remember() remember() remember() remember() remember()
count = 0 def remember(): global count count += 1 print(str(count)) remember() remember() remember() remember() remember()
# -*- coding: utf-8 -*- """ Created on Sat Nov 16 17:54:07 2019 @author: SaiLikhithK """ def merge_and_count(b,c): res_arr, inv_count = [], 0 while len(b) > 0 or len(c) > 0: if len(b) > 0 and len(c) > 0: if b[0] < c[0]: res_arr.append(b[0]) b = ...
""" Created on Sat Nov 16 17:54:07 2019 @author: SaiLikhithK """ def merge_and_count(b, c): (res_arr, inv_count) = ([], 0) while len(b) > 0 or len(c) > 0: if len(b) > 0 and len(c) > 0: if b[0] < c[0]: res_arr.append(b[0]) b = b[1:] else: ...
class IncapBlocked(ValueError): """ Base exception for exceptions in this module. :param response: The response which was being processed when this error was raised. :type response: requests.Response :param *args: Additional arguments to pass to :class:`ValueError`. """ def __init__(self, r...
class Incapblocked(ValueError): """ Base exception for exceptions in this module. :param response: The response which was being processed when this error was raised. :type response: requests.Response :param *args: Additional arguments to pass to :class:`ValueError`. """ def __init__(self, ...
#!/usr/bin/env python # encoding: utf-8 ''' @author: Jason Lee @license: (C) Copyright @ Jason Lee @contact: jiansenll@163.com @file: median.py @time: 2019/6/15 14:18 @desc: ''' class Solution: """ @param A: An integer array. @param B: An integer array. @return: a double whose format is *.5 or...
""" @author: Jason Lee @license: (C) Copyright @ Jason Lee @contact: jiansenll@163.com @file: median.py @time: 2019/6/15 14:18 @desc: """ class Solution: """ @param A: An integer array. @param B: An integer array. @return: a double whose format is *.5 or *.0 """ def find_median_sorted_a...
def find_rc(rc): rc = rc[:: -1] replacements = {"A": "T", "T": "A", "G": "C", "C": "G"} rc = "".join([replacements.get(c, c) for c in rc]) return rc print(find_rc('ATTA'))
def find_rc(rc): rc = rc[::-1] replacements = {'A': 'T', 'T': 'A', 'G': 'C', 'C': 'G'} rc = ''.join([replacements.get(c, c) for c in rc]) return rc print(find_rc('ATTA'))
"""Configuration settings for baseball team manager program.""" # The starting players list of lists players = [ ['Joe', 'P', 10, 2, 0.2], ['Tom', 'SS', 11, 4, 0.364], ['Ben', '3B', 0, 0, 0.0], ] # valid baseball team positions valid_positions = ('C', '1B', '2B', '3B', 'SS', 'LF'...
"""Configuration settings for baseball team manager program.""" players = [['Joe', 'P', 10, 2, 0.2], ['Tom', 'SS', 11, 4, 0.364], ['Ben', '3B', 0, 0, 0.0]] valid_positions = ('C', '1B', '2B', '3B', 'SS', 'LF', 'CF', 'RF', 'P')
first_name = input("Please enter your first name: ") print(f"Your first name is: {first_name}") print("a regular string: " + first_name) print('a regular string' + first_name) # string literal with the r prefix print(r'a regular string')
first_name = input('Please enter your first name: ') print(f'Your first name is: {first_name}') print('a regular string: ' + first_name) print('a regular string' + first_name) print('a regular string')
""" Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target value to search. If found in the array return its index, otherwise return -1. You may assume no duplicate exists in the array. """ class Solution: # @param A, a...
""" Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target value to search. If found in the array return its index, otherwise return -1. You may assume no duplicate exists in the array. """ class Solution: def search(s...
# A variable lets you save some information to use later # You can save numbers! my_var = 1 print(my_var) # Or strings! my_var = "MARIO" print(my_var) # Or anything else you need!
my_var = 1 print(my_var) my_var = 'MARIO' print(my_var)