content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# NOTE: You need to check directory's permission MAX_HEIGHT = 1536 # 1536 # 768 # 1280 # 1024 # 2048 # 2688 MAX_WIDTH = 3072 # 3072 # 1536 # 2560 # 2048 # 4096 # 5376 CROP_HEIGHT = 512 # 256, 384, 512 CROP_WIDTH = 512 # 512, 768, 1024 RESIZE_HEIGHT = 1536 RESIZE_WIDTH = 3072 # MNT_PATH = '/nfs/host/PConv-Kera...
max_height = 1536 max_width = 3072 crop_height = 512 crop_width = 512 resize_height = 1536 resize_width = 3072 mnt_path = '/nfs/host/PConv-Keras' original_path = ['{}/house-dataset-src/original/'.format(MNT_PATH)] resized_path = ['{}/house-dataset/resize-train-1536x3072/00'.format(MNT_PATH)] train_path = '{}/house-data...
# O(n+k) time complexity (Worst time complexity - O(2n-1)): # O(k) (Get Slice 1) # O(n-k) (Get Slice 2) # O(k) (Concatenate Slices) # CPython time-complexity - https://wiki.python.org/moin/TimeComplexity # O(1) space complexity # Rotates the characters in a string by a given input and have the overflow appear ...
def rotated_string(input_string, input_number): input_number = input_number % len(input_string) print(input_string[-input_number:] + input_string[:-input_number]) return input_string[-input_number:] + input_string[:-input_number] def test_rotated_string(): assert rotated_string('MyString', 2) == 'ngMyS...
def main(): print ('Filter data') input_f = open('../data/result_size_large_files.tsv') output_f = open('../data/result_size_large.csv', 'w') lines = input_f.readlines() distributions = ['Combo', 'Diagonal', 'DiagonalRot', 'Gauss', 'Parcel', 'Uniform'] for line in lines: print (line) ...
def main(): print('Filter data') input_f = open('../data/result_size_large_files.tsv') output_f = open('../data/result_size_large.csv', 'w') lines = input_f.readlines() distributions = ['Combo', 'Diagonal', 'DiagonalRot', 'Gauss', 'Parcel', 'Uniform'] for line in lines: print(line) ...
# Implementation of a Stack. class Stack: class Node: # Node class (or pointers that hold a value and direction to next node). def __init__(self, val=None): self.val = val self.nextNode = None def __init__(self): self.head = None # Add new node with value to stack...
class Stack: class Node: def __init__(self, val=None): self.val = val self.nextNode = None def __init__(self): self.head = None def push(self, val): new_node = self.Node(val) if self.head is None: self.head = newNode else: ...
j= 7 for i in range(9+1): if i%2 ==1: print(f"I={i} J={j}") print(f"I={i} J={j-1}") print(f"I={i} J={j-2}") j =j+2
j = 7 for i in range(9 + 1): if i % 2 == 1: print(f'I={i} J={j}') print(f'I={i} J={j - 1}') print(f'I={i} J={j - 2}') j = j + 2
class BearToy: def __init__(self, name, size, color): self.name = name self.size = size self.color = color def sing(self): print('I am %s, lalala...' % self.name) class NewBear(BearToy): def __init__(self, name, size, color, material): # BearToy.__init__(self, name,...
class Beartoy: def __init__(self, name, size, color): self.name = name self.size = size self.color = color def sing(self): print('I am %s, lalala...' % self.name) class Newbear(BearToy): def __init__(self, name, size, color, material): super(NewBear, self).__init_...
class DesignerSummary(object): def __init__(self, designer_name, summary): self.designer_name = designer_name self.summary = summary def print_summary(self): print("[%s]" % self.designer_name) print(" %s" % self.max_price()) print(" %s" % self.avg_price()) ...
class Designersummary(object): def __init__(self, designer_name, summary): self.designer_name = designer_name self.summary = summary def print_summary(self): print('[%s]' % self.designer_name) print(' %s' % self.max_price()) print(' %s' % self.avg_price()) pri...
qrel_input = 'data/expert/qrels-covid_d4_j3.5-4.txt' doc_type = 'expert' qrel_name = 'baseline_doc' qrel_path = f'qrels/{doc_type}/{qrel_name}' with open(qrel_path, 'w') as fo: with open(qrel_input) as f: for line in f: line = line.strip().split() if line: query_id, _, doc_id, dq_rank = line query_i...
qrel_input = 'data/expert/qrels-covid_d4_j3.5-4.txt' doc_type = 'expert' qrel_name = 'baseline_doc' qrel_path = f'qrels/{doc_type}/{qrel_name}' with open(qrel_path, 'w') as fo: with open(qrel_input) as f: for line in f: line = line.strip().split() if line: (query_id, ...
class BoundingBox: def __init__(self, x1, y1, x2, y2): self.x1 = x1 self.y1 = y1 self.x2 = x2 self.y2 = y2 self.k = 2 # scaling factor def get_x_center(self): return(self.x1 + self.x2) / 2 def get_y_center(self): return(self.y1 + self.y2)...
class Boundingbox: def __init__(self, x1, y1, x2, y2): self.x1 = x1 self.y1 = y1 self.x2 = x2 self.y2 = y2 self.k = 2 def get_x_center(self): return (self.x1 + self.x2) / 2 def get_y_center(self): return (self.y1 + self.y2) / 2 def compute_outp...
s = 0 for i in range(2,100): for j in range(2,i): if i % j == 0: break else: s += i print(s)
s = 0 for i in range(2, 100): for j in range(2, i): if i % j == 0: break else: s += i print(s)
n1= input() n2 = input() j = 1 for i in range(1,n1+1): j = i*j k = j%n2 print(k) print("\n")
n1 = input() n2 = input() j = 1 for i in range(1, n1 + 1): j = i * j k = j % n2 print(k) print('\n')
# Used to test import statements for the NoopAugmentor plugin. def noop(x): return x
def noop(x): return x
C = int(input()) if C>=2 and C<=99: for i in range(C): x =input() print("gzuz")
c = int(input()) if C >= 2 and C <= 99: for i in range(C): x = input() print('gzuz')
def my_bilateral_filter(ImgNoisy, window_size = 3 , sigma_d = 4, sigma_r = 40): # sigma_d : smoothing weight factor # sigma_r : range weight factor height = ImgNoisy.shape[0] width = ImgNoisy.shape[1] # Initialize the filtered image: filtered_image = np.empty([height,width]) # S...
def my_bilateral_filter(ImgNoisy, window_size=3, sigma_d=4, sigma_r=40): height = ImgNoisy.shape[0] width = ImgNoisy.shape[1] filtered_image = np.empty([height, width]) window_boundary = int(np.ceil(window_size / 2)) for i in range(height): for j in range(width): normalization_co...
class EventTableData: def __init__(self): self._header_tag = 'th' self._dispo_header = False self._event_row = -1 def store_data(self, case_parser, data): if self._dispo_header: self._event_row += 1 case_parser.event_table_data.append([]) ...
class Eventtabledata: def __init__(self): self._header_tag = 'th' self._dispo_header = False self._event_row = -1 def store_data(self, case_parser, data): if self._dispo_header: self._event_row += 1 case_parser.event_table_data.append([]) cas...
class IceCreamMachine: all={} def __init__(self, ingredients, toppings): self.ingredients = ingredients self.toppings = toppings def scoops(self): res = [] for i in self.ingredients: for j in self.toppings: res.append([i, j]) return res m...
class Icecreammachine: all = {} def __init__(self, ingredients, toppings): self.ingredients = ingredients self.toppings = toppings def scoops(self): res = [] for i in self.ingredients: for j in self.toppings: res.append([i, j]) return res...
class lennox_period(object): def __init__(self, id): self.id = id self.enabled = False self.startTime = None self.systemMode = None self.hsp = None self.hspC = None self.csp = None self.cspC = None self.sp = None self.spC = None ...
class Lennox_Period(object): def __init__(self, id): self.id = id self.enabled = False self.startTime = None self.systemMode = None self.hsp = None self.hspC = None self.csp = None self.cspC = None self.sp = None self.spC = None ...
#Inverter valores de 2 variaveis lidas. a = input("Insira o valor de A: "); b = input("Insira o valor de B: ") c = a a = b b = c print("O valor de A (invertida): " + str(a) + " e o de B (invertido): " + str(b))
a = input('Insira o valor de A: ') b = input('Insira o valor de B: ') c = a a = b b = c print('O valor de A (invertida): ' + str(a) + ' e o de B (invertido): ' + str(b))
### Insert a node at the head of a linked list - Solution class SinglyLinkedListNode: def __init__(self, node_data): self.data = node_data self.next = None class SinglyLinkedList: def __init__(self): self.head = None self.tail = None def print_singly_linked_list(node): whi...
class Singlylinkedlistnode: def __init__(self, node_data): self.data = node_data self.next = None class Singlylinkedlist: def __init__(self): self.head = None self.tail = None def print_singly_linked_list(node): while node != None: print(node.data) node = ...
# function to increase the pixel by one inside each box def add_heat(heatmap, bbox_list): # Iterate through list of bboxes for box in bbox_list: # Add += 1 for all pixels inside each bbox # Assuming each "box" takes the form ((x1, y1), (x2, y2)) heatmap[box[0][1]:box[1][1], box[0][0]:box...
def add_heat(heatmap, bbox_list): for box in bbox_list: heatmap[box[0][1]:box[1][1], box[0][0]:box[1][0]] += 1 return heatmap def apply_threshold(heatmap, threshold): heatmap[heatmap <= threshold] = 0 return heatmap
fim = int(input("Digite um numero: ")) x = 0 while x <= fim: if not x % 2 == 0: print(x) x += 1
fim = int(input('Digite um numero: ')) x = 0 while x <= fim: if not x % 2 == 0: print(x) x += 1
class EmployeeApi: endpoint = 'Employee.json' def __init__(self, client): self.client = client def get_employee(self, employeeId): return self.client.get(endpoint=self.endpoint, payload={ "employeeID": employeeId, "load_relations": '["Contact"]' })
class Employeeapi: endpoint = 'Employee.json' def __init__(self, client): self.client = client def get_employee(self, employeeId): return self.client.get(endpoint=self.endpoint, payload={'employeeID': employeeId, 'load_relations': '["Contact"]'})
# HARD # Input: "abcd" # reverse input => as rev = "dcba" # compare s[:n-i] with rev[i:] # abcd vs dcba # abc vs cba # ab vs ba # a vs a => i == 3 # the same substring is the overlapped part of the result, thus rev[:i] + s is the result # Time O(N^2) Space O(n) # KMP prefix tabl...
class Solution: def shortest_palindrome(self, s: str) -> str: return self.slow(s) def slow(self, s): n = len(s) rev = ''.join(reversed(list(s))) for i in range(n): if s[:n - i] == rev[i:]: return rev[:i] + s return '' def fast(self, s): ...
{ 'application':{ 'type':'Application', 'name':'HtmlPreview', 'backgrounds': [ { 'type':'Background', 'name':'bgMin', 'title':'HTML Preview', #'size':(800, 600), 'statusBar':1, 'style':['resizeable'], 'components': [ { 'type':'HtmlWindow', 'name':'html', ...
{'application': {'type': 'Application', 'name': 'HtmlPreview', 'backgrounds': [{'type': 'Background', 'name': 'bgMin', 'title': 'HTML Preview', 'statusBar': 1, 'style': ['resizeable'], 'components': [{'type': 'HtmlWindow', 'name': 'html', 'size': (400, 200), 'text': ''}]}]}}
expected_output = { "vrf": { "default": { "address_family": { "ipv4": { "instance": { "1": { "areas": { "0.0.0.0": { "database": { ...
expected_output = {'vrf': {'default': {'address_family': {'ipv4': {'instance': {'1': {'areas': {'0.0.0.0': {'database': {'lsa_types': {1: {'lsa_type': 1, 'lsas': {'10.4.1.1 10.4.1.1': {'adv_router': '10.4.1.1', 'lsa_id': '10.4.1.1', 'ospfv2': {'body': {'router': {'links': {'10.4.1.1': {'link_data': '255.255.255.255', '...
pkgname = "fontconfig" pkgver = "2.14.0" pkgrel = 0 build_style = "gnu_configure" configure_args = [ "--enable-static", "--enable-docs", f"--with-cache-dir=/var/cache/{pkgname}", ] make_cmd = "gmake" hostmakedepends = ["pkgconf", "gperf", "gmake", "python"] makedepends = ["libexpat-devel", "freetype-bootstrap",...
pkgname = 'fontconfig' pkgver = '2.14.0' pkgrel = 0 build_style = 'gnu_configure' configure_args = ['--enable-static', '--enable-docs', f'--with-cache-dir=/var/cache/{pkgname}'] make_cmd = 'gmake' hostmakedepends = ['pkgconf', 'gperf', 'gmake', 'python'] makedepends = ['libexpat-devel', 'freetype-bootstrap', 'libuuid-d...
''' Created on 09-May-2017 @author: Sathesh Rgs ''' print("Program to display armstrong numbers between two intervals") try: print("Enter the starting and ending intervals") si=int(input()) ei=int(input()) print("The armstrong numbers between",si,"and",ei,"are") for num in range(si,ei+1): ...
""" Created on 09-May-2017 @author: Sathesh Rgs """ print('Program to display armstrong numbers between two intervals') try: print('Enter the starting and ending intervals') si = int(input()) ei = int(input()) print('The armstrong numbers between', si, 'and', ei, 'are') for num in range(si, ei + 1)...
class Solution: def minCostConnectPoints(self, points: List[List[int]]) -> int: answer=0 u=[0]*len(points) unionMap={} if len(points)==1: return 0 edges=[] for i in range(len(points)): u[i]=i unionMap[i]=[i] f...
class Solution: def min_cost_connect_points(self, points: List[List[int]]) -> int: answer = 0 u = [0] * len(points) union_map = {} if len(points) == 1: return 0 edges = [] for i in range(len(points)): u[i] = i unionMap[i] = [i] ...
''' A simple test ''' def test_pytest(): '''test_pytest Summary ------- Dummy test function. ''' assert True
""" A simple test """ def test_pytest(): """test_pytest Summary ------- Dummy test function. """ assert True
#!/usr/bin/env python def yell(text): return text.upper() + '!' print(yell('hello')) # Functions are objects bark = yell print(bark('woof')) del yell print(bark('hey')) # error # print(yell('hello')) print(bark.__name__) print(bark.__qualname__) funcs = [bark, str.lower, str.capitalize] print(funcs) for f in ...
def yell(text): return text.upper() + '!' print(yell('hello')) bark = yell print(bark('woof')) del yell print(bark('hey')) print(bark.__name__) print(bark.__qualname__) funcs = [bark, str.lower, str.capitalize] print(funcs) for f in funcs: print(f, f('hey there')) print(funcs[0]('hey yo')) def greet(func): ...
#Python number # int # float # complex x = 1 y = 13.23 z = 1j print(x) print(y) print(z) print("-----------------------------------") print(type(x)) print(type(y)) print(type(z)) print("-----------------------------------")
x = 1 y = 13.23 z = 1j print(x) print(y) print(z) print('-----------------------------------') print(type(x)) print(type(y)) print(type(z)) print('-----------------------------------')
class BaseError(Exception): pass class UnknownError(BaseError): pass class AccessTokenRequired(BaseError): pass class BadOAuthTokenError(BaseError): pass class BadRequestError(BaseError): pass class TokenError(BaseError): pass
class Baseerror(Exception): pass class Unknownerror(BaseError): pass class Accesstokenrequired(BaseError): pass class Badoauthtokenerror(BaseError): pass class Badrequesterror(BaseError): pass class Tokenerror(BaseError): pass
def numIslands(self, grid: List[List[str]]) -> int: count = 0 rows = len(grid) cols = len(grid[0]) ''' very similar solution to all these permuation problems going through each coordinate and changing them if they are connected ''' ...
def num_islands(self, grid: List[List[str]]) -> int: count = 0 rows = len(grid) cols = len(grid[0]) ' very similar solution to all these permuation problems\n going through each coordinate and changing them if they are\n connected\n ' def explore(i, j): if grid[...
extension = ''' # from sqlalchemy.ext.declarative import declarative_base # # from core.factories import Session from sqlalchemy import MetaData from gino.ext.starlette import Gino from core.factories import settings db: MetaData = Gino(dsn=settings.DATABASE_URL) '''
extension = '\n# from sqlalchemy.ext.declarative import declarative_base\n# # from core.factories import Session\nfrom sqlalchemy import MetaData\nfrom gino.ext.starlette import Gino\nfrom core.factories import settings\n\n\ndb: MetaData = Gino(dsn=settings.DATABASE_URL)\n\n'
STATS = [ { "num_node_expansions": 0, "search_time": 0.0553552, "total_time": 0.13778, "plan_length": 231, "plan_cost": 231, "objects_used": 140, "objects_total": 250, "neural_net_time": 0.07324552536010742, "num_replanning_steps": 0, "...
stats = [{'num_node_expansions': 0, 'search_time': 0.0553552, 'total_time': 0.13778, 'plan_length': 231, 'plan_cost': 231, 'objects_used': 140, 'objects_total': 250, 'neural_net_time': 0.07324552536010742, 'num_replanning_steps': 0, 'wall_time': 0.7697024345397949}, {'num_node_expansions': 0, 'search_time': 0.0617813, ...
def jwt_response_payload_handler(token,user=None,request=None): return { 'token': token, 'user_id': user.id, 'username': user.username } def jwt_get_user_secret(user): print(user) return user.user_secret
def jwt_response_payload_handler(token, user=None, request=None): return {'token': token, 'user_id': user.id, 'username': user.username} def jwt_get_user_secret(user): print(user) return user.user_secret
power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate...
power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate Leakage': 0.00662954, 'Peak Dynamic': 0.0, 'Runtime Dynamic': 0.0, 'Subthres...
#!/usr/bin/env python3 k = int(input()) a, b = map(int, input().split()) for i in range(a, b+1): if i%k == 0: print("OK") exit() print("NG")
k = int(input()) (a, b) = map(int, input().split()) for i in range(a, b + 1): if i % k == 0: print('OK') exit() print('NG')
# generated from genmsg/cmake/pkg-genmsg.context.in messages_str = "/home/kinova/MillenCapstone/catkin_ws/src/kinova-ros/kinova_msgs/msg/FingerPosition.msg;/home/kinova/MillenCapstone/catkin_ws/src/kinova-ros/kinova_msgs/msg/JointAngles.msg;/home/kinova/MillenCapstone/catkin_ws/src/kinova-ros/kinova_msgs/msg/JointVelo...
messages_str = '/home/kinova/MillenCapstone/catkin_ws/src/kinova-ros/kinova_msgs/msg/FingerPosition.msg;/home/kinova/MillenCapstone/catkin_ws/src/kinova-ros/kinova_msgs/msg/JointAngles.msg;/home/kinova/MillenCapstone/catkin_ws/src/kinova-ros/kinova_msgs/msg/JointVelocity.msg;/home/kinova/MillenCapstone/catkin_ws/src/ki...
# 5! = 120 # # 5 * 4 * 3 * 2 * 1 def factorial(n): if n == 1: return 1 return n * factorial(n - 1) print(f'5!={factorial(5):,},' # 120 f' 3!={factorial(3):,},' # 6 f' 11!={factorial(11):,}') # HUGE
def factorial(n): if n == 1: return 1 return n * factorial(n - 1) print(f'5!={factorial(5):,}, 3!={factorial(3):,}, 11!={factorial(11):,}')
''' Write a Python program to parse a string to Float or Integer. ''' varStr = input("Enter a number: ") print("The string above was parsed an an integer", int(varStr))
""" Write a Python program to parse a string to Float or Integer. """ var_str = input('Enter a number: ') print('The string above was parsed an an integer', int(varStr))
# Compute the Factorial of a given value (n!) # multiply all whole numbers from our chosen number # down to 1. # 4! = 4 * 3 * 2 * 1 # 1 * 1 = 1 # 1 * 2 = 2 # 2 * 3 # iterative approach def fact_i(n): # set a end point fact initial value fact = 1 # loop from 1 to n+1 using an index for i in range(1, ...
def fact_i(n): fact = 1 for i in range(1, n + 1): fact = fact * i return fact print(fact_i(4)) def rec_fact(n): if n <= 1: return 1 else: return n * rec_fact(n - 1) print(rec_fact(4))
def indent_dotcode(dotcode, indent): return '\n'.join(['%s%s' % (indent, line) for line in dotcode.split('\n')]) def sphinx_format(dotcode): dotcode = indent_dotcode(dotcode, ' ') warning_comment = '.. Autogenerated graphviz code. Do not edit manually.' dotcode = "%s\n\n.. graphviz::\n\n%s" ...
def indent_dotcode(dotcode, indent): return '\n'.join(['%s%s' % (indent, line) for line in dotcode.split('\n')]) def sphinx_format(dotcode): dotcode = indent_dotcode(dotcode, ' ') warning_comment = '.. Autogenerated graphviz code. Do not edit manually.' dotcode = '%s\n\n.. graphviz::\n\n%s' % (warni...
def cal(n, data): for x in range(1, n+1): if (n % x == 0): tmp = data[:x] for y in range(x, n, x): if data[y:y+x] != tmp: break if(y+x >= n): return x return n n = int(input()) data = list(input()) print(ca...
def cal(n, data): for x in range(1, n + 1): if n % x == 0: tmp = data[:x] for y in range(x, n, x): if data[y:y + x] != tmp: break if y + x >= n: return x return n n = int(input()) data = list(input()) print(c...
def resolve(): ''' code here ''' N = int(input()) As = [int(item) for item in input().split()] As.sort() max_num = max(As) res = 10**9 + 1 if max_num % 2 == 0: if max_num //2 in As: res = max_num //2 else: for item in As: if a...
def resolve(): """ code here """ n = int(input()) as = [int(item) for item in input().split()] As.sort() max_num = max(As) res = 10 ** 9 + 1 if max_num % 2 == 0: if max_num // 2 in As: res = max_num // 2 else: for item in As: if...
#!/usr/bin/python3 for i in range(1,10): for j in range(1,10): print("%d * %d = %d "%(j,i,i*j), end="") print("")
for i in range(1, 10): for j in range(1, 10): print('%d * %d = %d ' % (j, i, i * j), end='') print('')
expected_output = { 'vrf': { 'default': { 'interface': { 'GigabitEthernet0/0/0/0': { 'counters': { 'joins': 18, 'leaves': 5 }, 'enable': True, 'interne...
expected_output = {'vrf': {'default': {'interface': {'GigabitEthernet0/0/0/0': {'counters': {'joins': 18, 'leaves': 5}, 'enable': True, 'internet_address': 'fe80::5054:ff:fefa:9ad7', 'interface_status': 'up', 'last_member_query_interval': 1, 'oper_status': 'up', 'querier': 'fe80::5054:ff:fed7:c01f', 'querier_timeout': ...
while True: n=int(input('ENTER A NUMBER TO CHECK DIVISIBILITY: ')) for i in range (2,n): if n%i == 0: print('THE ENTER NO. IS DIVISIBLE BY: ',i)
while True: n = int(input('ENTER A NUMBER TO CHECK DIVISIBILITY: ')) for i in range(2, n): if n % i == 0: print('THE ENTER NO. IS DIVISIBLE BY: ', i)
# SCENARIO: Calculator - Do a substraction # GIVEN a running calculator app type(Key.WIN + "calculator" + Key.ENTER) wait("1471901583292.png") # AND '5' is displayed click("1471901439420.png") wait("1471901563200.png") # WHEN I click on '-', '1', '=' click("1471901612968.png") click("1471901595751.png") click...
type(Key.WIN + 'calculator' + Key.ENTER) wait('1471901583292.png') click('1471901439420.png') wait('1471901563200.png') click('1471901612968.png') click('1471901595751.png') click('1471901627768.png') wait('1471901656932.png')
DbName = "FantasyDraftHost.db" tables = { "leagues": { "name": "Leagues", "columnIndexes": { "Id": 0, "Name": 1 } }, "playerPositions": { "name": "PlayerPositions", "columnIndexes": { "Id": 0, "PlayerId": 1, ...
db_name = 'FantasyDraftHost.db' tables = {'leagues': {'name': 'Leagues', 'columnIndexes': {'Id': 0, 'Name': 1}}, 'playerPositions': {'name': 'PlayerPositions', 'columnIndexes': {'Id': 0, 'PlayerId': 1, 'PositionId': 2}}, 'players': {'name': 'Players', 'columnIndexes': {'Id': 0, 'FirstName': 1, 'LastName': 2, 'TeamId': ...
a = [100,2,1,3,5,200,300,400,2,3,0,1,23,24,56,30,500,20,1000,3000] #print(a.index(max(a))) b = [] for i in range(0,9): b.append(a.index(max(a))) a[a.index(max(a))] = 0 print(b)
a = [100, 2, 1, 3, 5, 200, 300, 400, 2, 3, 0, 1, 23, 24, 56, 30, 500, 20, 1000, 3000] b = [] for i in range(0, 9): b.append(a.index(max(a))) a[a.index(max(a))] = 0 print(b)
class MovieCard: def __init__(self, price): self._price = price self._tickets = 10 if price == 70 else 15 # assume price = 70 or 100 only @property def tickets(self): return self._tickets def redeem_ticket(self, qty=1): if qty > 2: raise ValueError("Ma...
class Moviecard: def __init__(self, price): self._price = price self._tickets = 10 if price == 70 else 15 @property def tickets(self): return self._tickets def redeem_ticket(self, qty=1): if qty > 2: raise value_error('Maximum ticket redemptions is 2.') ...
#!/usr/bin/env python # _*_ coding: utf-8 # See LICENSE for details. class BaseConfig: def __init__(self, logger=None, BaseConfig=None): self self.logger = logger self.stageing = False self.config_directory = None self.default_key_type = 'RSA' # TODO: Support 'ECDS...
class Baseconfig: def __init__(self, logger=None, BaseConfig=None): self self.logger = logger self.stageing = False self.config_directory = None self.default_key_type = 'RSA' self.ec_curve = 'secp256r1' self.storage_mode = 'file' self.storage_file_dir...
# Team 5 def save_to_excel(datatables: list, directory=None): pass def open_excel(): pass
def save_to_excel(datatables: list, directory=None): pass def open_excel(): pass
class Solution: def isValidSerialization(self, preorder: str) -> bool: nodes = preorder.split(",") cnt = 1 for i, x in enumerate(nodes): if x == "#": cnt -= 1 if cnt == 0: return i == len(nodes) - 1 else: ...
class Solution: def is_valid_serialization(self, preorder: str) -> bool: nodes = preorder.split(',') cnt = 1 for (i, x) in enumerate(nodes): if x == '#': cnt -= 1 if cnt == 0: return i == len(nodes) - 1 else: ...
# -*- coding: utf-8 class Document: __slots__ = ('root',) def __init__(self): self.root = None
class Document: __slots__ = ('root',) def __init__(self): self.root = None
def includeme(config): config.add_static_view('static', 'static', cache_max_age=None) config.add_route('home', '/') config.add_route('auth', '/auth') config.add_route('portfolio', '/portfolio') config.add_route('detail', '/portfolio/{symbol}') config.add_route('add', '/add') config.add_route...
def includeme(config): config.add_static_view('static', 'static', cache_max_age=None) config.add_route('home', '/') config.add_route('auth', '/auth') config.add_route('portfolio', '/portfolio') config.add_route('detail', '/portfolio/{symbol}') config.add_route('add', '/add') config.add_route...
print("BMI Calculator") print("=" * 20) height = input("Enter height (m): ") weight = input("Enter weight (kg): ") try: height = float(height) weight = float(weight) except ValueError: print("One or more invalid values entered.") exit(1) print("Your BMI is %d." % int((weight / (height ** 2)))) # 35.5...
print('BMI Calculator') print('=' * 20) height = input('Enter height (m): ') weight = input('Enter weight (kg): ') try: height = float(height) weight = float(weight) except ValueError: print('One or more invalid values entered.') exit(1) print('Your BMI is %d.' % int(weight / height ** 2))
class Solution: def rob(self, nums: List[int]) -> int: n = len(nums) if(n==0): return 0 dp = [0]*n dp[0] = nums[0] for i in range(1,n): if(i == 1): dp[i] = max(nums[0], nums[1]) ...
class Solution: def rob(self, nums: List[int]) -> int: n = len(nums) if n == 0: return 0 dp = [0] * n dp[0] = nums[0] for i in range(1, n): if i == 1: dp[i] = max(nums[0], nums[1]) else: dp[i] = max(dp[i - 1...
def bmw_finder_price_gt_25k(mileage, price): if price > 25000: return 1 else: return 0 def bmw_finder_price_gt_20k(mileage, price): if price > 20000: return 1 else: return 0 def bmw_finder_price_gt_cutoff_price(cutoff_price): def c(x,p): if p > cutoff_pric...
def bmw_finder_price_gt_25k(mileage, price): if price > 25000: return 1 else: return 0 def bmw_finder_price_gt_20k(mileage, price): if price > 20000: return 1 else: return 0 def bmw_finder_price_gt_cutoff_price(cutoff_price): def c(x, p): if p > cutoff_pric...
STATS = [ { "num_node_expansions": 1733, "plan_length": 142, "search_time": 1.66, "total_time": 1.66 }, { "num_node_expansions": 2128, "plan_length": 153, "search_time": 1.93, "total_time": 1.93 }, { "num_node_expansions": 2114,...
stats = [{'num_node_expansions': 1733, 'plan_length': 142, 'search_time': 1.66, 'total_time': 1.66}, {'num_node_expansions': 2128, 'plan_length': 153, 'search_time': 1.93, 'total_time': 1.93}, {'num_node_expansions': 2114, 'plan_length': 148, 'search_time': 29.02, 'total_time': 29.02}, {'num_node_expansions': 1614, 'pl...
LINE_DICT_TEMPLATE = { 'kind': '', 'buy_cur': '', 'buy_amount': 0, 'sell_cur': '', 'sell_amount': 0, 'fee_cur': '', 'fee_amount': 0, 'exchange': 'Bitshares', 'mark': -1, 'comment': '', 'order_id': '', } # CSV format is ccGains generic format HEADER = 'Kind,Date,Buy currency,...
line_dict_template = {'kind': '', 'buy_cur': '', 'buy_amount': 0, 'sell_cur': '', 'sell_amount': 0, 'fee_cur': '', 'fee_amount': 0, 'exchange': 'Bitshares', 'mark': -1, 'comment': '', 'order_id': ''} header = 'Kind,Date,Buy currency,Buy amount,Sell currency,Sell amount,Fee currency,Fee amount,Exchange,Mark,Comment\n' l...
globalval=6 def checkglobalvalue(): return globalval def localvariablevalue(): globalval=8 return globalval print ("This is global value",checkglobalvalue()) print ("This is global value",globalval) print ("This is local value",localvariablevalue()) print ("This is global value",globalval)
globalval = 6 def checkglobalvalue(): return globalval def localvariablevalue(): globalval = 8 return globalval print('This is global value', checkglobalvalue()) print('This is global value', globalval) print('This is local value', localvariablevalue()) print('This is global value', globalval)
class Logger: def __init__(self, simulator, time, image_analyzer, speed_controller, car, gyro, asservissement, sequencer, handles, tachometer): self.tachometer = tachometer self.handles = handles self.time = time self.image_analyzer = image_analyzer self.seq...
class Logger: def __init__(self, simulator, time, image_analyzer, speed_controller, car, gyro, asservissement, sequencer, handles, tachometer): self.tachometer = tachometer self.handles = handles self.time = time self.image_analyzer = image_analyzer self.sequencer = sequence...
total = 0 for line in open('input.txt'): l, w, h = [int(side) for side in line.split('x')] sides = [2*(l+w), 2*(w+h), 2*(h+l)] total += min(sides) + l*w*h print(total)
total = 0 for line in open('input.txt'): (l, w, h) = [int(side) for side in line.split('x')] sides = [2 * (l + w), 2 * (w + h), 2 * (h + l)] total += min(sides) + l * w * h print(total)
def missions_per_year(df): ''' From a dataframe with the 'Year' column, Plot a graph showing the number of missions per year ''' missions_per_year = df.Year.value_counts() plt.plot(missions_per_year.sort_index()) plt.show() def missions_per_week(df): ''' From a dataframe with the '...
def missions_per_year(df): """ From a dataframe with the 'Year' column, Plot a graph showing the number of missions per year """ missions_per_year = df.Year.value_counts() plt.plot(missions_per_year.sort_index()) plt.show() def missions_per_week(df): """ From a dataframe with the 'Y...
def sum_func(a, *args): s = a+sum(args) print(s) sum_func(10) sum_func(10,20) sum_func(10,20,30) sum_func(10, 20, 30, 40)
def sum_func(a, *args): s = a + sum(args) print(s) sum_func(10) sum_func(10, 20) sum_func(10, 20, 30) sum_func(10, 20, 30, 40)
TAG_MAP = { ('landuse', 'forest'): {"TYPE": "forest", "DRAW_TYPE": "plane"}, ('natural', 'wood'): {"TYPE": "forest", "SUBTYPE": "natural", "DRAW_TYPE": "plane"} } def find_type(tags): keys = list(tags.items()) return [TAG_MAP[key] for key in keys if key in TAG_MAP]
tag_map = {('landuse', 'forest'): {'TYPE': 'forest', 'DRAW_TYPE': 'plane'}, ('natural', 'wood'): {'TYPE': 'forest', 'SUBTYPE': 'natural', 'DRAW_TYPE': 'plane'}} def find_type(tags): keys = list(tags.items()) return [TAG_MAP[key] for key in keys if key in TAG_MAP]
# # PySNMP MIB module Webio-Digital-MIB-US (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Webio-Digital-MIB-US # Produced by pysmi-0.3.4 at Mon Apr 29 21:32:33 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (defau...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, constraints_intersection, single_value_constraint, value_range_constraint, value_size_constraint) ...
raspberry = True display_device = "/dev/fb1" mouse_device = "/dev/input/event0" mouse_driver = "TSLIB" if raspberry: mouse_type = "pitft_touchscreen" touch_xmin = 345 touch_xmax = 3715 touch_ymin = 184 touch_ymax = 3853 else: mouse_type = "pygame" if raspberry: screen_fullscreen = True els...
raspberry = True display_device = '/dev/fb1' mouse_device = '/dev/input/event0' mouse_driver = 'TSLIB' if raspberry: mouse_type = 'pitft_touchscreen' touch_xmin = 345 touch_xmax = 3715 touch_ymin = 184 touch_ymax = 3853 else: mouse_type = 'pygame' if raspberry: screen_fullscreen = True else:...
# Copyright 2017 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. def CheckChangeOnUpload(*args): return _CommonChecks(*args) def CheckChangeOnCommit(*args): return _CommonChecks(*args) def _CommonChecks(input_api,...
def check_change_on_upload(*args): return __common_checks(*args) def check_change_on_commit(*args): return __common_checks(*args) def __common_checks(input_api, output_api): cwd = input_api.PresubmitLocalPath() path = input_api.os_path files = [path.basename(f.LocalPath()) for f in input_api.Affec...
messages = ["<b>Shoulder-arm stretch</b>Time to do Shoulder arm stretch, keep one arm horizontally stretched in front of your chest. Push this arm with your other arm towards you until you feel a mild tension in your shoulder. Hold this position briefly, and repeat the exercise for your other arm. Don't do this more th...
messages = ["<b>Shoulder-arm stretch</b>Time to do Shoulder arm stretch, keep one arm horizontally stretched in front of your chest. Push this arm with your other arm towards you until you feel a mild tension in your shoulder. Hold this position briefly, and repeat the exercise for your other arm. Don't do this more th...
myfile=open('country.txt') print(myfile.read()) myfile.close() #with open('country.txt',mode='r') as myfile: # print(myfile.read()) with open('country.txt',mode='a') as f: print(f.write("'IN':'INDIAN'"))
myfile = open('country.txt') print(myfile.read()) myfile.close() with open('country.txt', mode='a') as f: print(f.write("'IN':'INDIAN'"))
L_af = "af" # Afrikaans L_am = "am" # Amharic L_ar = "ar" # Arabic L_az = "az" # Azerbaijani L_be = "be" # Belarusian L_bg = "bg" # Bulgarian L_bn = "bn" # Bengali L_bs = "bs" # Bosnian L_ca = "ca" # Catalan L_ceb = "ceb" # Chechen L_co = "co" # Corsican L...
l_af = 'af' l_am = 'am' l_ar = 'ar' l_az = 'az' l_be = 'be' l_bg = 'bg' l_bn = 'bn' l_bs = 'bs' l_ca = 'ca' l_ceb = 'ceb' l_co = 'co' l_cs = 'cs' l_cy = 'cy' l_da = 'da' l_de = 'de' l_el = 'el' l_en = 'en' l_eo = 'eo' l_es = 'es' l_et = 'et' l_eu = 'eu' l_fa = 'fa' l_fi = 'fi' l_fr = 'fr' l_fy = 'fy' l_ga = 'ga' l_gd =...
km = float(input('Quantos Km percorrido: ')) diaria = int(input('Quantos dias alugado: ')) total = (diaria * 60) + (km * .15) print(f'Foram percorridos {km}km e {diaria} diarias, total de R${total:.2f}')
km = float(input('Quantos Km percorrido: ')) diaria = int(input('Quantos dias alugado: ')) total = diaria * 60 + km * 0.15 print(f'Foram percorridos {km}km e {diaria} diarias, total de R${total:.2f}')
n = int(input()) phonebook=dict() for _ in range(n): q = list(map(str,list(input().split()))) name = q[0] phone = int(q[1]) phonebook[name]=phone try: while True: query = input() if query!="": if query in phonebook: st = query+'='+str(phonebook[query]) ...
n = int(input()) phonebook = dict() for _ in range(n): q = list(map(str, list(input().split()))) name = q[0] phone = int(q[1]) phonebook[name] = phone try: while True: query = input() if query != '': if query in phonebook: st = query + '=' + str(phonebook[...
__author__ = 'deadblue' mime_types = { 'svg': 'image/svg+xml', 'png': 'image/png', 'webp': 'image/webp' }
__author__ = 'deadblue' mime_types = {'svg': 'image/svg+xml', 'png': 'image/png', 'webp': 'image/webp'}
# # PySNMP MIB module MSSSERVER8260-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MSSSERVER8260-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:15:54 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Ma...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, constraints_union, constraints_intersection, value_range_constraint, single_value_constraint) ...
nums = map(float, input().split()) count_values = {} for num in nums: if num not in count_values: count_values[num] = 0 count_values[num] += 1 for key, value in count_values.items(): print(f"{key} - {value} times")
nums = map(float, input().split()) count_values = {} for num in nums: if num not in count_values: count_values[num] = 0 count_values[num] += 1 for (key, value) in count_values.items(): print(f'{key} - {value} times')
def get_ranges(data): # create a list of all valid ranges list_of_ranges = {} for line in data: if line == "": break l = [] key = line.split(":")[0] line = line.split() lower, upper = line[-1].split("-") l.append((int(lower), int(upper))) l...
def get_ranges(data): list_of_ranges = {} for line in data: if line == '': break l = [] key = line.split(':')[0] line = line.split() (lower, upper) = line[-1].split('-') l.append((int(lower), int(upper))) (lower, upper) = line[-3].split('-') ...
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"). # You may not use this file except in compliance with the License. # A copy of the License is located at # # http://www.apache.org/licenses/LICENSE-2.0 # # or in the "...
def generate_ros_package_names(name): names = [name, name.replace('_', '-'), name.replace('-', '_')] for distro in ['kinetic', 'indigo']: names.extend([name.replace('ros-%s-' % (distro,), ''), name.replace('ros-%s-' % (distro,), '').replace('-', '_')]) return set(names)
######################## #### Initialisation #### ######################## input_ex1 = [] with open("inputs/day5_1.txt") as inputfile: for line in inputfile.readlines(): input_ex1.append(int(line.strip())) ######################## #### Part one #### ######################## sample_input = [0, ...
input_ex1 = [] with open('inputs/day5_1.txt') as inputfile: for line in inputfile.readlines(): input_ex1.append(int(line.strip())) sample_input = [0, 3, 0, 1, -3] input_data = input_ex1[:] new_index = 0 steps = 0 while True: try: instruction = input_data[newIndex] input_data[newIndex] +=...
''' Probem Task : This program will return number of solutions to quadratic equation. Problem Link : https://edabit.com/challenge/o2AKq4xy3nfZabKXL ''' def solutions(a,b,c): if ((b**2 - 4*a*c) > 0): return 2 elif ((b**2 - 4*a*c)==0): return 1 else: return 0 if __name__ == ...
""" Probem Task : This program will return number of solutions to quadratic equation. Problem Link : https://edabit.com/challenge/o2AKq4xy3nfZabKXL """ def solutions(a, b, c): if b ** 2 - 4 * a * c > 0: return 2 elif b ** 2 - 4 * a * c == 0: return 1 else: return 0 if __nam...
# -*- coding: utf-8 -*- n = int(input()) p, q, r, s, x, y = map(int, input().split()) i, j = map(int, input().split()) res = 0 for k in range(1, n + 1): res += ((p * i + q * k) % x) * ((r * k + s * j) % y) print(res)
n = int(input()) (p, q, r, s, x, y) = map(int, input().split()) (i, j) = map(int, input().split()) res = 0 for k in range(1, n + 1): res += (p * i + q * k) % x * ((r * k + s * j) % y) print(res)
duo_prim = { "NRES": {"NRES", "GRU-CC", "POA", "HMB", "DS-XX"}, "GRU-CC": {"GRU-CC", "POA", "HMB", "DS-XX"}, "HMB": {"HMB", "DS-XX"}, "POA": {"POA"}, "DS-XX": {"DS-XX"}, } duo_sec = { "GSO", "RUO", "RS-XX", "NMDS", "GS-XX", "NPU", "PUB", "COL-XX", "IRB", "TS-...
duo_prim = {'NRES': {'NRES', 'GRU-CC', 'POA', 'HMB', 'DS-XX'}, 'GRU-CC': {'GRU-CC', 'POA', 'HMB', 'DS-XX'}, 'HMB': {'HMB', 'DS-XX'}, 'POA': {'POA'}, 'DS-XX': {'DS-XX'}} duo_sec = {'GSO', 'RUO', 'RS-XX', 'NMDS', 'GS-XX', 'NPU', 'PUB', 'COL-XX', 'IRB', 'TS-XX', 'COST', 'DSM'} adam_main_mapped_to_duo = {'NRES': 'NRES', 'G...
class Enemy: def __init__(self, name, health, damage): self.name = name self.health = health self.damage = damage def isActive(self): return self.health > 0 class KillerJackal(Enemy): def __init__(self): super().__init__(name="Killer-Jackal", health=30, damage=50) ...
class Enemy: def __init__(self, name, health, damage): self.name = name self.health = health self.damage = damage def is_active(self): return self.health > 0 class Killerjackal(Enemy): def __init__(self): super().__init__(name='Killer-Jackal', health=30, damage=50...
superbowl_wins = [ ['1', 'Pittsburgh', '6'], ['2', 'Dallas', '5'], ['3', 'Paris', '16'], ['4', 'Wembo CLub', '25'], ] for row in superbowl_wins: print (row[1] + " had " + row[2] + " wins") print("========================") for row in superbowl_wins: for el in row: print (el) print('')
superbowl_wins = [['1', 'Pittsburgh', '6'], ['2', 'Dallas', '5'], ['3', 'Paris', '16'], ['4', 'Wembo CLub', '25']] for row in superbowl_wins: print(row[1] + ' had ' + row[2] + ' wins') print('========================') for row in superbowl_wins: for el in row: print(el) print('')
class Solution: def twoSum(self, numbers: List[int], target: int) -> List[int]: left, right = 0, len(numbers) - 1 while left <= right: sum = numbers[left] + numbers[right] if sum == target: return [left + 1, right + 1] elif sum < target: ...
class Solution: def two_sum(self, numbers: List[int], target: int) -> List[int]: (left, right) = (0, len(numbers) - 1) while left <= right: sum = numbers[left] + numbers[right] if sum == target: return [left + 1, right + 1] elif sum < target: ...
# int() # float() # str() # bool() number_input = input("number: ") print(type(number_input)) number_input = int(number_input) print(type(number_input)) # Falsy Values print(bool(0)) print(bool(0.0)) print(bool('')) print(bool(())) print(bool([])) print(bool({})) print(bool(set())) print(bool(complex())) print(bool(...
number_input = input('number: ') print(type(number_input)) number_input = int(number_input) print(type(number_input)) print(bool(0)) print(bool(0.0)) print(bool('')) print(bool(())) print(bool([])) print(bool({})) print(bool(set())) print(bool(complex())) print(bool(range())) print(bool(False)) print(bool(None)) print(...
def surrender(): i01.setHandSpeed("left", 1.0, 1.0, 1.0, 1.0, 1.0, 1.0) i01.setHandSpeed("right", 1.0, 1.0, 1.0, 1.0, 1.0, 1.0) i01.setArmSpeed("right", 0.75, 0.85, 0.95, 0.85) i01.setArmSpeed("left", 0.75, 0.85, 0.95, 0.85) i01.setHeadSpeed(0.65, 0.65) i01.moveHead(90,90) i01.moveArm("left",90,139,15,79)...
def surrender(): i01.setHandSpeed('left', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0) i01.setHandSpeed('right', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0) i01.setArmSpeed('right', 0.75, 0.85, 0.95, 0.85) i01.setArmSpeed('left', 0.75, 0.85, 0.95, 0.85) i01.setHeadSpeed(0.65, 0.65) i01.moveHead(90, 90) i01.moveArm('left...
''' Created on June 5, 2012 @author: Jason Huang ''' ''' Question 1 / 1. There are N objects kept in a row. The ith object is at position x_i. You want to partition them into K groups. You want to move all objects belonging to the same group to the same position. Objects in two different groups may be placed ...
""" Created on June 5, 2012 @author: Jason Huang """ '\nQuestion 1 / 1.\nThere are N objects kept in a row. The ith object is at position x_i. You want to partition them into K groups. You want to move all objects belonging to the same group to the same position. Objects in two different groups may be placed at the sa...
class URLS(): BASE_URL = "http://automationpractice.com/index.php" CONTACT_PAGE_URL = 'http://automationpractice.com/index.php?controller=contact' LOGIN_PAGE_URL = 'http://automationpractice.com/index.php?controller=authentication&back=my-account' REGISTRATION_PAGE_URL = 'http://automationpractice.com/i...
class Urls: base_url = 'http://automationpractice.com/index.php' contact_page_url = 'http://automationpractice.com/index.php?controller=contact' login_page_url = 'http://automationpractice.com/index.php?controller=authentication&back=my-account' registration_page_url = 'http://automationpractice.com/ind...
# # PySNMP MIB module APPIAN-STRATUM-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/APPIAN-STRATUM-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:23:58 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, ...
(ac_chassis_current_time, ac_chassis_ring_id) = mibBuilder.importSymbols('APPIAN-CHASSIS-MIB', 'acChassisCurrentTime', 'acChassisRingId') (ac_osap, ac_op_status, ac_node_id) = mibBuilder.importSymbols('APPIAN-SMI-MIB', 'acOsap', 'AcOpStatus', 'AcNodeId') (object_identifier, octet_string, integer) = mibBuilder.importSym...
class Solution: def majorityElement(self, nums): c1, c2, cnt1, cnt2 = 0, 1, 0, 0 for num in nums: if num == c1: cnt1 += 1 elif num == c2: cnt2 += 1 elif not cnt1: c1, cnt1 = num, 1 elif not cnt2: ...
class Solution: def majority_element(self, nums): (c1, c2, cnt1, cnt2) = (0, 1, 0, 0) for num in nums: if num == c1: cnt1 += 1 elif num == c2: cnt2 += 1 elif not cnt1: (c1, cnt1) = (num, 1) elif not cnt2...
class Node: # Each node is a tree def __init__(self, value): self.data = value self.right = None self.left = None def insert(self, value): if self.data: if value < self.data: if self.left is None: self.left = Node(value) ...
class Node: def __init__(self, value): self.data = value self.right = None self.left = None def insert(self, value): if self.data: if value < self.data: if self.left is None: self.left = node(value) else: ...
''' Statement Chess knight can move to a square that is two squares away horizontally and one square vertically, or two squares vertically and one square horizontally. The complete move therefore looks like the letter L. Given two different squares of the chessboard, determine whether a knight can go from the first squ...
""" Statement Chess knight can move to a square that is two squares away horizontally and one square vertically, or two squares vertically and one square horizontally. The complete move therefore looks like the letter L. Given two different squares of the chessboard, determine whether a knight can go from the first squ...
def strAppend(suffix): return lambda x : x + suffix
def str_append(suffix): return lambda x: x + suffix
numerals = { "I": 1, "IV": 4, "V": 5, "IX": 9, "X": 10, "XL": 40, "L": 50, "XC": 90, "C": 100, "CD": 400, "D": 500, "CM": 900, "M": 1000 } def checkio(inp, output=""): next = max([e for e in numerals if numerals[e]<=inp], key=lambda x: numerals[x]) output = o...
numerals = {'I': 1, 'IV': 4, 'V': 5, 'IX': 9, 'X': 10, 'XL': 40, 'L': 50, 'XC': 90, 'C': 100, 'CD': 400, 'D': 500, 'CM': 900, 'M': 1000} def checkio(inp, output=''): next = max([e for e in numerals if numerals[e] <= inp], key=lambda x: numerals[x]) output = output + next inp = inp - numerals[next] if i...
root_folder = '/var/www/' charset = '<meta charset="utf-8">' def application(env, start_response): scripts = open(root_folder+'scripts.js', 'r').read() forms = open(root_folder+'forms.html', 'r').read() if env['REQUEST_METHOD'] == 'POST': if env.get('CONTENT_LENGTH'): env_len = int(env.get('CONTENT_...
root_folder = '/var/www/' charset = '<meta charset="utf-8">' def application(env, start_response): scripts = open(root_folder + 'scripts.js', 'r').read() forms = open(root_folder + 'forms.html', 'r').read() if env['REQUEST_METHOD'] == 'POST': if env.get('CONTENT_LENGTH'): env_len = int(...
class Solution: def crackSafe(self, n: int, k: int) -> str: # worst case k ** n def dfs(cur, seen, total): if len(seen) == total: return cur for i in range(k): temp = cur[-n + 1: ] + str(i) if n != 1 else str(i) if temp not in s...
class Solution: def crack_safe(self, n: int, k: int) -> str: def dfs(cur, seen, total): if len(seen) == total: return cur for i in range(k): temp = cur[-n + 1:] + str(i) if n != 1 else str(i) if temp not in seen: s...