content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# Errors class Error(Exception): """Base class for errors. A subclass of `Exception`.""" def __init__(self, trace=None): """Extend Exception.__init__() to hold a traceback. Keyword arguments: - trace=None: a traceback usually created by `util.getTrace()` or None. ...
class Error(Exception): """Base class for errors. A subclass of `Exception`.""" def __init__(self, trace=None): """Extend Exception.__init__() to hold a traceback. Keyword arguments: - trace=None: a traceback usually created by `util.getTrace()` or None. ...
class CompositorNodeBrightContrast: use_premultiply = None def update(self): pass
class Compositornodebrightcontrast: use_premultiply = None def update(self): pass
# # PySNMP MIB module TIMETRA-CFLOWD-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TIMETRA-CFLOWD-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:09:44 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, ...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, single_value_constraint, constraints_union, value_range_constraint, value_size_constraint) ...
def factorial(n): if n == 0: return 1 return n * factorial(n-1) def iterativeFactorial(n): result = 1 for i in range(1,n+1): result = result * i return result def main(): print("The factorial of 5 is", factorial(5)) print("The iterative factorial of 5 is", iterativeFactorial(5)) main()
def factorial(n): if n == 0: return 1 return n * factorial(n - 1) def iterative_factorial(n): result = 1 for i in range(1, n + 1): result = result * i return result def main(): print('The factorial of 5 is', factorial(5)) print('The iterative factorial of 5 is', iterative_f...
# AUTOMATICALLY GENERATED BY GENGUPPY about = b'\x80\x03cguppy.gsl.Text\nRecordingInter\nq\x00)\x81q\x01}q\x02(X\x07\x00\x00\x00appendsq\x03]q\x04(K\x00X\x16\x00\x00\x00Heapy Profile Browser\nq\x05K\x01X\x01\x00\x00\x00\tq\x06K\x02X\x07\x00\x00\x00Versionq\x07K\x01h\x06K\x03X\x04\x00\x00\x000.1\nq\x08K\x04h\x06K\x02X\...
about = b'\x80\x03cguppy.gsl.Text\nRecordingInter\nq\x00)\x81q\x01}q\x02(X\x07\x00\x00\x00appendsq\x03]q\x04(K\x00X\x16\x00\x00\x00Heapy Profile Browser\nq\x05K\x01X\x01\x00\x00\x00\tq\x06K\x02X\x07\x00\x00\x00Versionq\x07K\x01h\x06K\x03X\x04\x00\x00\x000.1\nq\x08K\x04h\x06K\x02X\x06\x00\x00\x00Authorq\tK\x04h\x06K\x03...
expected_output = { "interface-policer-information": { "physical-interface": [ { "admin-status": "up", "logical-interface": [ { "admin-status": "up", "name": "ge-0/0/2.0", ...
expected_output = {'interface-policer-information': {'physical-interface': [{'admin-status': 'up', 'logical-interface': [{'admin-status': 'up', 'name': 'ge-0/0/2.0', 'oper-status': 'up', 'policer-information': [{'policer-family': 'inet', 'policer-input': 'GE_1M-ge-0/0/2.0-log_int-i', 'policer-output': 'GE_1M-ge-0/0/2.0...
load( "//scala:scala_cross_version.bzl", _default_scala_version = "default_scala_version", _extract_major_version = "extract_major_version", _scala_mvn_artifact = "scala_mvn_artifact", ) load( "@io_bazel_rules_scala//scala:scala_maven_import_external.bzl", _scala_maven_import_external = "scala_m...
load('//scala:scala_cross_version.bzl', _default_scala_version='default_scala_version', _extract_major_version='extract_major_version', _scala_mvn_artifact='scala_mvn_artifact') load('@io_bazel_rules_scala//scala:scala_maven_import_external.bzl', _scala_maven_import_external='scala_maven_import_external')
class Solution: def romanToInt(self, s: str) -> int: r2n = { 'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000 } n = len(s) # exception if n == 1: return r2n...
class Solution: def roman_to_int(self, s: str) -> int: r2n = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000} n = len(s) if n == 1: return r2n[s] result = 0 i = 0 while i < n - 1: while i < n - 1 and r2n[s[i]] >= r2n[s[i + 1]]...
#!/usr/bin/env python3 #Creates a list for all of the values of a specific category def make_list(arr, category, val): #Checks for special players instance of call if(category == "Maxplayers"): return make_list_players(arr, category, val) position = binary_search(arr, category, 0, len(arr), val) #Che...
def make_list(arr, category, val): if category == 'Maxplayers': return make_list_players(arr, category, val) position = binary_search(arr, category, 0, len(arr), val) if position == -1: return high = position low = position new_arr = [arr[position]] while high + 1 < len(arr) ...
# was difficult due to very large inputs # may be able to optimize, but perhaps with a different strategy #!/bin/python3 t = int(input().strip()) for a0 in range(t): N = int(input().strip()) prices = list(map(int, input().strip().split(' '))) if N == 0 or N == 1: print(0) else: #...
t = int(input().strip()) for a0 in range(t): n = int(input().strip()) prices = list(map(int, input().strip().split(' '))) if N == 0 or N == 1: print(0) else: max_pos = prices.index(max(prices)) opt_sol = [-1] * max_pos opt_sol.append(max_pos) while max_pos < len(p...
class SearchWagonsByNumOfPass: """Basic class for searching wagons by number of passengers""" MAX_INPUT_VALUE = 54 AVERAGE_INPUT_VALUE = 36 MIN_INPUT_VALUE = 0 def findWagonsByValue(self): inputValue = int(input(" Enter value for search :")) if inputValue >= SearchWagonsByNumOfPass.M...
class Searchwagonsbynumofpass: """Basic class for searching wagons by number of passengers""" max_input_value = 54 average_input_value = 36 min_input_value = 0 def find_wagons_by_value(self): input_value = int(input(' Enter value for search :')) if inputValue >= SearchWagonsByNumOfP...
class User: """ Class that generates new User. """ user_list= [] #Array of empty user list def __init__(self,name,password): self.name=name self.password=password def save_user(self): User.user_list.append(self) def delete_user(self): ''' delete...
class User: """ Class that generates new User. """ user_list = [] def __init__(self, name, password): self.name = name self.password = password def save_user(self): User.user_list.append(self) def delete_user(self): """ delete a user account ...
def main(request, response): location = request.GET.first(b"location") response.status = 302 response.headers.set(b"Location", location) if b"allow_origin" in request.GET: response.headers.set(b"Access-Control-Allow-Origin", request.GET.first(b"allow_origin")) if b"timing_allow_origin" in ...
def main(request, response): location = request.GET.first(b'location') response.status = 302 response.headers.set(b'Location', location) if b'allow_origin' in request.GET: response.headers.set(b'Access-Control-Allow-Origin', request.GET.first(b'allow_origin')) if b'timing_allow_origin' in re...
# Copyright (C) 2017 Udacity Inc. # All Rights Reserved. # Author: Brandon Kinman class PIDController: def __init__(self, kp = 0.0, ki = 0.0, kd = 0.0, max_windup = 10, alpha=1.0): self.kp = kp self.ki = ki self.kd = kd self.max_windup = max_windup self.target = 0 ...
class Pidcontroller: def __init__(self, kp=0.0, ki=0.0, kd=0.0, max_windup=10, alpha=1.0): self.kp = kp self.ki = ki self.kd = kd self.max_windup = max_windup self.target = 0 self.alpha = alpha self.error_sum = 0 self.last_timestamp = 0 self.l...
#Debangshu Roy #WAP to print the followingseries and find its sum #1,-9,25,-49...,n #n is a input by user num=int(input("Enter a number: ")) count=0 sumseries = 0 for x in range(1,num+1,2): count+=1 if count%2==0: sumseries + ((-1)*(2)) print("-",(2), sep="") else: sumseries = ...
num = int(input('Enter a number: ')) count = 0 sumseries = 0 for x in range(1, num + 1, 2): count += 1 if count % 2 == 0: sumseries + -1 * 2 print('-', 2, sep='') else: sumseries = sumseries + 2 print(2) print('Sum is', sumseries)
year = int(input("Enter Year: ")) # Leap Year Check if not year % 400: print(year, "is a Leap Year") elif not year % 4 and year % 100: print(year, "is a Leap Year") else: print(year, "is not a Leap Year")
year = int(input('Enter Year: ')) if not year % 400: print(year, 'is a Leap Year') elif not year % 4 and year % 100: print(year, 'is a Leap Year') else: print(year, 'is not a Leap Year')
#!/usr/bin/env python #coding: utf-8 # Definition for a binary tree node class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None cl...
class Treenode: def __init__(self, x): self.val = x self.left = None self.right = None class Listnode: def __init__(self, x): self.val = x self.next = None class Solution: def sorted_array_to_bst(self, num): if not num: return None ln ...
# V0 # V1 # https://blog.csdn.net/fuxuemingzhu/article/details/83422260 class Solution(object): def longestMountain(self, A): """ :type A: List[int] :rtype: int """ N = len(A) inc = [1] * N dec = [1] * N for i in range(1, N): if A[i] - A...
class Solution(object): def longest_mountain(self, A): """ :type A: List[int] :rtype: int """ n = len(A) inc = [1] * N dec = [1] * N for i in range(1, N): if A[i] - A[i - 1] > 0: inc[i] = inc[i - 1] + 1 for i in ran...
text_array = [0x9257e4, 0x925852, 0x9258ce, 0x925be2, 0x925bfa, 0x925ca0, 0x925ccd, 0x925d0b, 0x925fa4, 0x9272bc, 0x9272da, 0x927354, 0x9273d5, 0x927406, 0x92743c, 0x927474, 0x927476, 0x9274b3, 0x9274b5, 0x9274ea, 0x9274ec, 0x927517, 0x927544, 0x927548, 0x927565, 0x927567, 0x9275d8, 0x9275ed, 0x92763f, 0x927648, 0x9276...
text_array = [9590756, 9590866, 9590990, 9591778, 9591802, 9591968, 9592013, 9592075, 9592740, 9597628, 9597658, 9597780, 9597909, 9597958, 9598012, 9598068, 9598070, 9598131, 9598133, 9598186, 9598188, 9598231, 9598276, 9598280, 9598309, 9598311, 9598424, 9598445, 9598527, 9598536, 9598584, 9598680, 9598766, 9598867, ...
"""List of common verbs to make your mother jokes from""" common_verbs_structured = { 'is': [ 'am', 'are', 'be', 'were', 'was', "you're", "i'm" ], "'s": [ "he's", "she's", "it's", "what's", "that's", "they're" ], "isn't": ["aren't", "weren't"], 'has': ['have', 'ha...
"""List of common verbs to make your mother jokes from""" common_verbs_structured = {'is': ['am', 'are', 'be', 'were', 'was', "you're", "i'm"], "'s": ["he's", "she's", "it's", "what's", "that's", "they're"], "isn't": ["aren't", "weren't"], 'has': ['have', 'had', "i'd", "you'd", "he'd", "she'd", "it'd", "that'd", "they'...
def isPhoneNumber(text): # checking the length of the characters of expression if len(text) != 12: return False # checking the first three characters if they are numbers # if any of them is not a number it will return False for i in range(0, 3): if not text[i].isdecimal(): ...
def is_phone_number(text): if len(text) != 12: return False for i in range(0, 3): if not text[i].isdecimal(): return False if text[3] != '-': return False for i in range(4, 7): if not text[i].isdecimal(): return False if text[7] != '-': ...
GET_ALL_MEMBERS = """ SELECT username, first_name, last_name, password, email, created_on, last_login FROM members """ GET_MEMBER_BY_USERNAME = f""" {GET_ALL_MEMBERS} WHERE username = :username """ INSERT_MEMBER = f""" INSERT INTO members (username, password, first_name, last_name, email, last_login) VALUES (:usernam...
get_all_members = '\nSELECT username, first_name, last_name, password, email, created_on, last_login\nFROM members\n' get_member_by_username = f'\n{GET_ALL_MEMBERS}\nWHERE username = :username\n' insert_member = f'\nINSERT INTO members (username, password, first_name, last_name, email, last_login)\nVALUES (:username, :...
def transpose(matrix): return [[matrix[j][i] for j in range(len(matrix))] for i in range(len(matrix[0]))] def get_matrix_first_diagonal(matrix): n = len(matrix) return set(matrix[i][i] for i in range(n)) def get_matrix_second_diagonal(matrix): n = len(matrix) return set(matrix[i][n-i-1] for i in...
def transpose(matrix): return [[matrix[j][i] for j in range(len(matrix))] for i in range(len(matrix[0]))] def get_matrix_first_diagonal(matrix): n = len(matrix) return set((matrix[i][i] for i in range(n))) def get_matrix_second_diagonal(matrix): n = len(matrix) return set((matrix[i][n - i - 1] for...
""" HOW TO USE: In a string, put the color you want first, with the first item and the second item at the emd. (Example: _str = f"{green[0]}Green!{green[1]}" """ reset = [str(u"\u001b[0m"), str(u"\u001b[0m")] bold = [str(u"\u001b[1m"), str(u"\u001b[22m")] dim = [str(u"\u001b[2m"), str(u"\u001b[22m")] itali...
""" HOW TO USE: In a string, put the color you want first, with the first item and the second item at the emd. (Example: _str = f"{green[0]}Green!{green[1]}" """ reset = [str(u'\x1b[0m'), str(u'\x1b[0m')] bold = [str(u'\x1b[1m'), str(u'\x1b[22m')] dim = [str(u'\x1b[2m'), str(u'\x1b[22m')] italic = [str(u'\x1b[3m'), str...
for number in range(1, 101): #if number % 3 == 0 or number % 5 == 0: -> "FizzBuzz" has to be displayed when both the conditions are true, not only one of them if number % 3 == 0 and number % 5 == 0: print("FizzBuzz") #if number % 3 == 0: -> elif has to be used as only one condition should be fulfilled at max ...
for number in range(1, 101): if number % 3 == 0 and number % 5 == 0: print('FizzBuzz') elif number % 3 == 0: print('Fizz') elif number % 5 == 0: print('Buzz') else: print(number)
def bar1(): """__NATIVE__ PmReturn_t retval = PM_RET_OK; /* If wrong number of args, raise TypeError */ if (NATIVE_GET_NUM_ARGS() != 0) { PM_RAISE(retval, PM_RET_EX_TYPE); return retval; } NATIVE_SET_TOS(PM_NONE); return retval; """ pass def bar2(): return bar1()
def bar1(): """__NATIVE__ PmReturn_t retval = PM_RET_OK; /* If wrong number of args, raise TypeError */ if (NATIVE_GET_NUM_ARGS() != 0) { PM_RAISE(retval, PM_RET_EX_TYPE); return retval; } NATIVE_SET_TOS(PM_NONE); return retval; """ pass def bar2(): return bar1()
sum = 0 for x in range(101): sum += x print(sum)
sum = 0 for x in range(101): sum += x print(sum)
# import <module_name> """Test the speed of a code snippet. Import a file and run a function. The results will be stored in a directory you specify.""" filename = 'json_files/' # Enter save directory with open(filename, 'w') as f: exec_times = [] for i in range(1, 31): start_time = time.time() # YOUR CO...
"""Test the speed of a code snippet. Import a file and run a function. The results will be stored in a directory you specify.""" filename = 'json_files/' with open(filename, 'w') as f: exec_times = [] for i in range(1, 31): start_time = time.time() exec_times.append(float('{}'.format(time.time()...
# hostname to listen on HOST = "0.0.0.0" # TCP port for the server to listen on PORT = 8002
host = '0.0.0.0' port = 8002
GITHUB_AUTH_TOKEN = "" EVERNOTE_PROD_TOKEN = "" EVERNOTE_SANDBOX_TOKEN = "" NOTEBOOK_TO_SYNC = "gist-evernote"
github_auth_token = '' evernote_prod_token = '' evernote_sandbox_token = '' notebook_to_sync = 'gist-evernote'
#!/usr/bin/env python step_down = 0.2 start_z = 0 end_z = -4 start_x = 37.0 end_x = 27.0 retract = 0.5 feed_rate = 30 work_z_level = start_z g_code = "%\n" g_code += "G0 X%.4f Z%4f\n" % (start_x, start_z) while work_z_level > end_z: work_z_level -= step_down g_code += "G1 Z%.4f F%4f\n" % (work_z_level, feed...
step_down = 0.2 start_z = 0 end_z = -4 start_x = 37.0 end_x = 27.0 retract = 0.5 feed_rate = 30 work_z_level = start_z g_code = '%\n' g_code += 'G0 X%.4f Z%4f\n' % (start_x, start_z) while work_z_level > end_z: work_z_level -= step_down g_code += 'G1 Z%.4f F%4f\n' % (work_z_level, feed_rate) g_code += 'G1 X...
# Time: O(n) # Space: O(1) # # You are a professional robber planning to rob houses along a street. # Each house has a certain amount of money stashed, the only constraint stopping you # from robbing each of them is that adjacent houses have security system connected # and it will automatically contact the police if t...
class Solution: def rob(self, num): size = len(num) dp = [0] * (size + 1) if size: dp[1] = num[0] for i in range(2, size + 1): dp[i] = max(dp[i - 1], dp[i - 2] + num[i - 1]) return dp[size] class Solution: def rob(self, num): size = len(...
# open the file.txt in write mode. fileptr = open("file2.txt", "a") # overwriting the content of the file fileptr.write(" Python has an easy syntax and user-friendly interaction.") # closing the opened file fileptr.close()
fileptr = open('file2.txt', 'a') fileptr.write(' Python has an easy syntax and user-friendly interaction.') fileptr.close()
def print_helper(val): if val==-10: return '_' elif val==0: return 'O' elif val==1: return 'X' def display_board(board): for row in board: col1, col2, col3 = print_helper(row[0]), print_helper(row[1]), print_helper(row[2]) print(col1, col2, col3)
def print_helper(val): if val == -10: return '_' elif val == 0: return 'O' elif val == 1: return 'X' def display_board(board): for row in board: (col1, col2, col3) = (print_helper(row[0]), print_helper(row[1]), print_helper(row[2])) print(col1, col2, col3)
days="Mon Tue Wed Thu Fri Sat Sun" months="Jan\nFeb\nMar\nApr\nMay\nJune\nJuly\nAug" print("Here are the days:",days) print("Here are the months:",months) print("There's something going on here.") print("With the three doouble-quotes.") print("We'll be able to type as much as we like.") print("Even 4 lines if we want, ...
days = 'Mon Tue Wed Thu Fri Sat Sun' months = 'Jan\nFeb\nMar\nApr\nMay\nJune\nJuly\nAug' print('Here are the days:', days) print('Here are the months:', months) print("There's something going on here.") print('With the three doouble-quotes.') print("We'll be able to type as much as we like.") print('Even 4 lines if we ...
col_name_branch = [ "from_bus_id", "to_bus_id", "r", "x", "b", "rateA", "rateB", "rateC", "ratio", "angle", "status", "angmin", "angmax", "Pf", "Qf", "Pt", "Qt", "mu_Sf", "mu_St", "mu_angmin", "mu_angmax", ] col_type_branch = [ "int...
col_name_branch = ['from_bus_id', 'to_bus_id', 'r', 'x', 'b', 'rateA', 'rateB', 'rateC', 'ratio', 'angle', 'status', 'angmin', 'angmax', 'Pf', 'Qf', 'Pt', 'Qt', 'mu_Sf', 'mu_St', 'mu_angmin', 'mu_angmax'] col_type_branch = ['int', 'int', 'float', 'float', 'float', 'float', 'float', 'float', 'float', 'float', 'int', 'fl...
class Solution: def singleNumber(self, nums: List[int]) -> int: nums.sort() cnt = len(nums) if cnt == 1: return nums[0] if nums[0] != nums[1] and nums[1] == nums[2]: return nums[0] if nums[cnt-1] != nums[cnt-2] and nums[cnt-2...
class Solution: def single_number(self, nums: List[int]) -> int: nums.sort() cnt = len(nums) if cnt == 1: return nums[0] if nums[0] != nums[1] and nums[1] == nums[2]: return nums[0] if nums[cnt - 1] != nums[cnt - 2] and nums[cnt - 2] == nums[cnt - 3]:...
expected_output = { "tag": { "1": { "prefix": { "3.3.3.0": { "subnet": "24", "prefix_attr": { "x_flag": False, "r_flag": False, "n_flag": False }, ...
expected_output = {'tag': {'1': {'prefix': {'3.3.3.0': {'subnet': '24', 'prefix_attr': {'x_flag': False, 'r_flag': False, 'n_flag': False}, 'via_interface': {'TenGigabitEthernet0/0/5': {'distance': 115, 'route_type': 'L2', 'metric': 83886080, 'via_ip': '13.13.1.2', 'src_ip': '6.6.6.6', 'tag': '0', 'lsp': {'next_hop_lsp...
'''input 10 30 22 5 2 18 6 21 28 11 18 1 5 9 30 22 5 2 18 6 21 29 11 18 5 4 10 2 8 4 5 3 3 10 1 1 1 2 ''' # -*- coding: utf-8 -*- # ddcc2017 qual # Problem C if __name__ == '__main__': n, c = list(map(int, input().split())) l = sorted([int(input()) for _ in...
"""input 10 30 22 5 2 18 6 21 28 11 18 1 5 9 30 22 5 2 18 6 21 29 11 18 5 4 10 2 8 4 5 3 3 10 1 1 1 2 """ if __name__ == '__main__': (n, c) = list(map(int, input().split())) l = sorted([int(input()) for _ in range(n)], reverse=True) count = 0 i = 0 j = n - 1 while i <= j and l[j] != 0: ...
class MovieNightBotException(Exception): pass class VoteError(MovieNightBotException): pass
class Movienightbotexception(Exception): pass class Voteerror(MovieNightBotException): pass
# https://atcoder.jp/contests/abc131/tasks/abc131_b N, L = map(int, input().split()) aji = [] for n in range(1, N + 1): aji.append(L + n - 1) ans = 0 min_diff = 10**9 + 7 total = sum(aji) for a in aji: diff = abs(total - (total - a)) if min_diff > diff: min_diff = diff ans = total - a pri...
(n, l) = map(int, input().split()) aji = [] for n in range(1, N + 1): aji.append(L + n - 1) ans = 0 min_diff = 10 ** 9 + 7 total = sum(aji) for a in aji: diff = abs(total - (total - a)) if min_diff > diff: min_diff = diff ans = total - a print(ans)
def swap_case(s): t = '' for char in s: if char.islower(): t += char.upper() else: t += char.lower() return t
def swap_case(s): t = '' for char in s: if char.islower(): t += char.upper() else: t += char.lower() return t
# -*- coding: utf-8 -*- """ heroku_env.exceptions ----------------------- All exceptions used in the heroku.env code base are defined here. """ class HerokuEnvException(Exception): """ Base exception. All other exceptions inherit from here. """ class HerokuRunError(HerokuEnvException): """ ...
""" heroku_env.exceptions ----------------------- All exceptions used in the heroku.env code base are defined here. """ class Herokuenvexception(Exception): """ Base exception. All other exceptions inherit from here. """ class Herokurunerror(HerokuEnvException): """ Exception raised when the H...
#!/usr/bin/python3 class Error(Exception): pass class DomainUrlError(Error): def __init__(self, message): self.message = message class SpiderError(Error): def __init__(self, message): self.message = message
class Error(Exception): pass class Domainurlerror(Error): def __init__(self, message): self.message = message class Spidererror(Error): def __init__(self, message): self.message = message
# https://leetcode.com/problems/delete-operation-for-two-strings class Solution: def minDistance(self, word1: str, word2: str) -> int: tmp1 = " " + word1 tmp2 = " " + word2 dp = [[0 for _ in range(len(tmp2))] for __ in range(len(tmp1))] for r in range(1, len(tmp1)): for...
class Solution: def min_distance(self, word1: str, word2: str) -> int: tmp1 = ' ' + word1 tmp2 = ' ' + word2 dp = [[0 for _ in range(len(tmp2))] for __ in range(len(tmp1))] for r in range(1, len(tmp1)): for c in range(1, len(tmp2)): if tmp1[r] == tmp2[c]:...
with open('./Input/Names/invited_names.txt') as file_names, open('./Input/Letters/starting_letter.txt') as file_letter: names = file_names.read().splitlines() print(names) starting_letter = file_letter.read() # print(starting_letter) for name in names: new_starting_letter = starting_letter.r...
with open('./Input/Names/invited_names.txt') as file_names, open('./Input/Letters/starting_letter.txt') as file_letter: names = file_names.read().splitlines() print(names) starting_letter = file_letter.read() for name in names: new_starting_letter = starting_letter.replace('[name]', name) ...
''' Created: 19.03.2015 @author: Dennis Ligtenberg '''
""" Created: 19.03.2015 @author: Dennis Ligtenberg """
expected_output={ "statistics":{ "vlan":{ "vlan":330, "mdns_pkt_sent":{ "pkt_sent":1, "ipv4_sent":{ "ipv4_sent_val":1, "ipv4_adv_sent":0, "ipv4_qry_sent":1 }, "ipv6_sent":{ "ipv6_sent_v...
expected_output = {'statistics': {'vlan': {'vlan': 330, 'mdns_pkt_sent': {'pkt_sent': 1, 'ipv4_sent': {'ipv4_sent_val': 1, 'ipv4_adv_sent': 0, 'ipv4_qry_sent': 1}, 'ipv6_sent': {'ipv6_sent_val': 0, 'ipv6_adv_sent': 0, 'ipv6_qry_sent': 0}}, 'mdns_rate_lim': 0, 'mdns_pkt_rcvd': {'pkt_rcvd': 0, 'adv_rcvd': 0, 'queries_rcv...
class ModelDatabaseRouter(object): """Allows each model to set its own destiny""" def db_for_read(self, model, **hints): # Specify target database with field in_db in model's Meta class if hasattr(model._meta, 'in_db'): return model._meta.in_db return None def db_fo...
class Modeldatabaserouter(object): """Allows each model to set its own destiny""" def db_for_read(self, model, **hints): if hasattr(model._meta, 'in_db'): return model._meta.in_db return None def db_for_write(self, model, **hints): if hasattr(model._meta, 'in_db'): ...
def countLines(name): """count number lines in a file""" with open(name, 'r') as fd: num_lines = len(fd.readlines()) return num_lines def countChars(name): """count number characters in a file""" with open(name, 'r') as fd: num_chars = len(fd.read()) return num_chars def test...
def count_lines(name): """count number lines in a file""" with open(name, 'r') as fd: num_lines = len(fd.readlines()) return num_lines def count_chars(name): """count number characters in a file""" with open(name, 'r') as fd: num_chars = len(fd.read()) return num_chars def test...
class ExampleClass(object): def __init__(self, number): self.X = int self.number = number def get_number(self): return self.X(self.number) def main(): dict_example = {} obj = ExampleClass(20.123) print(type(ExampleClass)) dict_example[ExampleClass] = str(obj.get_numbe...
class Exampleclass(object): def __init__(self, number): self.X = int self.number = number def get_number(self): return self.X(self.number) def main(): dict_example = {} obj = example_class(20.123) print(type(ExampleClass)) dict_example[ExampleClass] = str(obj.get_numbe...
""" ======================================================================== BasePass.py ======================================================================== An "abstract" base class for all passes. Author : Shunning Jiang Date : Dec 17, 2017 """ class PassMetadata: pass class BasePass: def __init__( self, ...
""" ======================================================================== BasePass.py ======================================================================== An "abstract" base class for all passes. Author : Shunning Jiang Date : Dec 17, 2017 """ class Passmetadata: pass class Basepass: def __init__(s...
# Done by Carlos Amaral (2020/09/21) # SCU 4.4 - Nested if Statements value_entered = input("Please, enter a number less than 100: ") if int(value_entered) > 50: print("The value entered is greater than 50.") if int(value_entered) < 75: print("The value entered is also less than 75") else: prin...
value_entered = input('Please, enter a number less than 100: ') if int(value_entered) > 50: print('The value entered is greater than 50.') if int(value_entered) < 75: print('The value entered is also less than 75') else: print('The value entered is less than or equal to 50.')
inputfile = open('inputDay02.txt', 'r') inputlist = [i.split() for i in inputfile.readlines()] def createrangelist(data): rangelst = [i[0] for i in data] rangelst = [i.split('-') for i in rangelst] rangeaux = [] for i in rangelst: rangeaux = rangeaux + [[int(j) for j in i]] rangelst = [tupl...
inputfile = open('inputDay02.txt', 'r') inputlist = [i.split() for i in inputfile.readlines()] def createrangelist(data): rangelst = [i[0] for i in data] rangelst = [i.split('-') for i in rangelst] rangeaux = [] for i in rangelst: rangeaux = rangeaux + [[int(j) for j in i]] rangelst = [tupl...
class UserName: def newMember(self, existingNames, newName): if newName in existingNames: i = 1 while '{}{}'.format(newName, i) in existingNames: i += 1 return newName + str(i) return newName
class Username: def new_member(self, existingNames, newName): if newName in existingNames: i = 1 while '{}{}'.format(newName, i) in existingNames: i += 1 return newName + str(i) return newName
class Person(object): def __init__(self, name=None, age=None, gender=None): self.name = name self.age = age self.gender = gender self.hp = 10 self.diseases = [] def __str__(self): return "%s: %d" % (self.name, self.hp)
class Person(object): def __init__(self, name=None, age=None, gender=None): self.name = name self.age = age self.gender = gender self.hp = 10 self.diseases = [] def __str__(self): return '%s: %d' % (self.name, self.hp)
# Do not edit this file directly. # It was auto-generated by: code/programs/reflexivity/reflexive_refresh load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") def qRCodeGenerator(): http_archive( name = "QR_Code_generator", ...
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_file') def q_r_code_generator(): http_archive(name='QR_Code_generator', build_file='//bazel/deps/QR_Code_generator:build.BUILD', sha256='1c281781d834e703ec40750ee0e0924567d8edc469d6f43083...
"""Example on pre calculating""" def nbits(val): """Return number of bits set to 1 in n""" n = 0 while val: if val & 1: n += 1 val >>= 1 return n def test_nbits(): cases = [ (0, 0), (1, 1), (2, 1), (3, 2), (6, 2), (7, ...
"""Example on pre calculating""" def nbits(val): """Return number of bits set to 1 in n""" n = 0 while val: if val & 1: n += 1 val >>= 1 return n def test_nbits(): cases = [(0, 0), (1, 1), (2, 1), (3, 2), (6, 2), (7, 3)] for (val, n) in cases: assert nbits(v...
def cap_100(percent): if percent <= 100: return percent else: return 100
def cap_100(percent): if percent <= 100: return percent else: return 100
""" plugin.py Base plugin for Grouper plugins. These are plugins that can be written to extend Grouper functionality. """ class BasePlugin(object): def user_created(self, user): """Called when a new user is created When new users enter into Grouper, you might have reason to set metadata on those...
""" plugin.py Base plugin for Grouper plugins. These are plugins that can be written to extend Grouper functionality. """ class Baseplugin(object): def user_created(self, user): """Called when a new user is created When new users enter into Grouper, you might have reason to set metadata on those...
class DequeNode: def __init__(self, data): self.data = data self.next = None self.previous = None class Deque: def __init__(self, elems = None): self._front = None self._back = None self._length = 0 if elems: for e in elems: self.add_last(e) def __len__(self): return self._length def __...
class Dequenode: def __init__(self, data): self.data = data self.next = None self.previous = None class Deque: def __init__(self, elems=None): self._front = None self._back = None self._length = 0 if elems: for e in elems: se...
expected_output = { "vrf": { "default": { "address_family": { "ipv4": { "prefix": { "10.169.196.241/32": { "nexthop": { "10.0.0.10": { "outg...
expected_output = {'vrf': {'default': {'address_family': {'ipv4': {'prefix': {'10.169.196.241/32': {'nexthop': {'10.0.0.10': {'outgoing_interface': {'GigabitEthernet3': {'local_label': 16022, 'outgoing_label': ['16022'], 'outgoing_label_backup': '16002', 'outgoing_label_info': 'elc'}}}}}}}}}}}
# -*- coding: utf-8 -*- """ file: model_dictionary.py Graph mixin class to add method to a Graph base class that will have it behave like a python dictionary. """ __all__ = ['PythonDictionary'] class PythonDictionary(object): def items(self, keystring=None, valuestring=None): """ Python dict-l...
""" file: model_dictionary.py Graph mixin class to add method to a Graph base class that will have it behave like a python dictionary. """ __all__ = ['PythonDictionary'] class Pythondictionary(object): def items(self, keystring=None, valuestring=None): """ Python dict-like function to return node...
supported_resolutions = [ (640, 350, 70), (640, 350, 85), (640, 400, 70), (640, 400, 85), (640, 480, 60), (640, 480, 73), (640, 480, 75), (640, 480, 85), (640, 480, 100), (720, 400, 85), (768, 576, 60), (768, 576, 72), (768, 576, 75), (768, 576, 85), (768, 576...
supported_resolutions = [(640, 350, 70), (640, 350, 85), (640, 400, 70), (640, 400, 85), (640, 480, 60), (640, 480, 73), (640, 480, 75), (640, 480, 85), (640, 480, 100), (720, 400, 85), (768, 576, 60), (768, 576, 72), (768, 576, 75), (768, 576, 85), (768, 576, 100), (800, 600, 56), (800, 600, 60), (800, 600, 72), (800,...
''' /* * @Author: Shawn Zhang * @Date: 2019-09-08 17:47:48 * @Last Modified by: Shawn Zhang * @Last Modified time: 2019-09-08 21:11:29 */ '''
""" /* * @Author: Shawn Zhang * @Date: 2019-09-08 17:47:48 * @Last Modified by: Shawn Zhang * @Last Modified time: 2019-09-08 21:11:29 */ """
DEFAULT_BORDER_STYLE = { 'style': 'solid', 'width': '1px', } BORDER_STYLES = { 'dashDot': None, 'dashDotDot': None, 'dashed': { 'style': 'dashed', }, 'dotted': { 'style': 'dotted', }, 'double': { 'style': 'double', }, 'hair': None, 'medium': { ...
default_border_style = {'style': 'solid', 'width': '1px'} border_styles = {'dashDot': None, 'dashDotDot': None, 'dashed': {'style': 'dashed'}, 'dotted': {'style': 'dotted'}, 'double': {'style': 'double'}, 'hair': None, 'medium': {'style': 'solid', 'width': '2px'}, 'mediumDashDot': {'style': 'solid', 'width': '2px'}, 'm...
a = 12 b = 3 print(a + b) #15 print(a - b) #9 print(a * b) #36 print(a / b) #4.0 print(a // b) # 4 integer division, rounded down towards minus infinity print(a % b) # 0 modulo: The remainder after interger division #test for upload print() print(a + b / 3 - 4 * 12) print(a + (b / 3) - (4 * 12)) print(((...
a = 12 b = 3 print(a + b) print(a - b) print(a * b) print(a / b) print(a // b) print(a % b) print() print(a + b / 3 - 4 * 12) print(a + b / 3 - 4 * 12) print(((a + b) / 3 - 4) * 12) print(((a + b) / 3 - 4) * 12) c = a + b d = c / 3 e = d - 4 print(e * 12) print() print(a / (b * a) / b)
def greet(name, age, gender): if gender == 'M' and age < 18: title = 'Master' elif gender == 'M': title = 'Mr.' else: title = 'Ms.' return f"Hello {title} {name}" print(greet(name='Wayne', gender='M', age=16)) print(greet(name='Joe', gender='M', age=30)) print(greet(name='Barbie...
def greet(name, age, gender): if gender == 'M' and age < 18: title = 'Master' elif gender == 'M': title = 'Mr.' else: title = 'Ms.' return f'Hello {title} {name}' print(greet(name='Wayne', gender='M', age=16)) print(greet(name='Joe', gender='M', age=30)) print(greet(name='Barbie'...
class PrivateOrInvalidProfileError(Exception): def __init__(self, user): Exception.__init__(self, "User profile " + "'" + user + "'" + " is private or doesn't exist.") class UserIdNotFoundError(Exception): def __init__(self): Exception.__init__(self, "User id not found.") class OutputDirecto...
class Privateorinvalidprofileerror(Exception): def __init__(self, user): Exception.__init__(self, 'User profile ' + "'" + user + "'" + " is private or doesn't exist.") class Useridnotfounderror(Exception): def __init__(self): Exception.__init__(self, 'User id not found.') class Outputdirecto...
""" 0224. Basic Calculator Hard Given a string s representing an expression, implement a basic calculator to evaluate it. Example 1: Input: s = "1 + 1" Output: 2 Example 2: Input: s = " 2-1 + 2 " Output: 3 Example 3: Input: s = "(1+(4+5+2)-3)+(6+8)" Output: 23 Constraints: 1 <= s.length <= 3 * 105 s consist...
""" 0224. Basic Calculator Hard Given a string s representing an expression, implement a basic calculator to evaluate it. Example 1: Input: s = "1 + 1" Output: 2 Example 2: Input: s = " 2-1 + 2 " Output: 3 Example 3: Input: s = "(1+(4+5+2)-3)+(6+8)" Output: 23 Constraints: 1 <= s.length <= 3 * 105 s consist...
def str_to_disct(st): """[return dict containing each letter and its occurrence in string] Args: st ([str]): [string] Returns: [dict]: [dict] """ s = set(list(st)) dic = {} for key in s: dic[key] = 0 for value in st: dic[value] += 1 return dic
def str_to_disct(st): """[return dict containing each letter and its occurrence in string] Args: st ([str]): [string] Returns: [dict]: [dict] """ s = set(list(st)) dic = {} for key in s: dic[key] = 0 for value in st: dic[value] += 1 return dic
#!/usr/bin/env python # coding: utf-8 # This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/interactive-coding-challenges). # # Solution Notebook # ## Problem: Implement depth-first search on a graph. # # * [Constraints]...
get_ipython().run_line_magic('run', '../graph/graph.py') class Graphdfs(Graph): def dfs(self, root, visit_func): if root is None: return visit_func(root) root.visit_state = State.visited for node in root.adj_nodes.values(): if node.visit_state == State.unvis...
class TransportException(Exception): pass class ServiceException(Exception): code = -2 class RemoteServiceException(Exception): pass class ProtocolException(Exception): pass class MethodNotFoundException(ServiceException): code = -3
class Transportexception(Exception): pass class Serviceexception(Exception): code = -2 class Remoteserviceexception(Exception): pass class Protocolexception(Exception): pass class Methodnotfoundexception(ServiceException): code = -3
#!/usr/bin/python3 """ Compute min cut of the graph with Karger algorithm. Problem answer: 17 """
""" Compute min cut of the graph with Karger algorithm. Problem answer: 17 """
# Rachit Agarwal # 1001664316 # Jacobi method # u1 = lambda a, b, c, p, q, r: (5-r+2*b)/6 # u2 = lambda a, b, c, p, q, r: (3+2*a+2*c-q)/6 # u3 = lambda a, b, c, p, q, r: (1+b+p)/3 # u4 = lambda a, b, c, p, q, r: (1+c+q)/3 # u5 = lambda a, b, c, p, q, r: (3-b+2*p+2*r)/6 # u6 = lambda a, b, c, p, q, r: (5-a+2*q)/6 # a0 ...
u1 = lambda a, b, c, p, q, r: (5 - r + 2 * b) / 6 u2 = lambda a, b, c, p, q, r: (3 + 2 * a + 2 * c - q) / 6 u3 = lambda a, b, c, p, q, r: (1 + b + p) / 3 u4 = lambda a, b, c, p, q, r: (1 + c + q) / 3 u5 = lambda a, b, c, p, q, r: (3 - b + 2 * p + 2 * r) / 6 u6 = lambda a, b, c, p, q, r: (5 - a + 2 * q) / 6 a0 = 0 b0 = ...
bicyles = ['trek', 'cannondale', 'redline', 'specialized'] message = f"My first bicycle was a {bicyles[0].title()}" print(bicyles[0].title()) print(bicyles[1]) print(bicyles[3]) print(bicyles[-1]) print(message)
bicyles = ['trek', 'cannondale', 'redline', 'specialized'] message = f'My first bicycle was a {bicyles[0].title()}' print(bicyles[0].title()) print(bicyles[1]) print(bicyles[3]) print(bicyles[-1]) print(message)
# population data def main(): # read the population file pop_file = open("USPopulation.txt", "r") # read the lines pop_list = pop_file.readlines() # read each line as an integer index = 0 while index < len(pop_list): pop_list[index] = int(pop_list[index]) index += 1 #...
def main(): pop_file = open('USPopulation.txt', 'r') pop_list = pop_file.readlines() index = 0 while index < len(pop_list): pop_list[index] = int(pop_list[index]) index += 1 annual_change = annual_change(pop_list) total = 0 for y in annual_change: total += y avera...
name = "ilmbase" version = "2.2.0" authors = [ "ILM" ] description = \ """ Utility libraries from ILM used by OpenEXR. """ private_build_requires = [ "gcc-4.8.2+" ] variants = [ ["platform-linux", "arch-x86_64", "os-CentOS-7"] ] uuid = "repository.ilmbase" def commands(): env.LD_LIBRA...
name = 'ilmbase' version = '2.2.0' authors = ['ILM'] description = '\n Utility libraries from ILM used by OpenEXR.\n ' private_build_requires = ['gcc-4.8.2+'] variants = [['platform-linux', 'arch-x86_64', 'os-CentOS-7']] uuid = 'repository.ilmbase' def commands(): env.LD_LIBRARY_PATH.append('{root}/lib') ...
def Main( ARC ): return None
def main(ARC): return None
my_list = ['apple', 'banana', 'grapes', 'pear'] for c, value in enumerate(my_list, 1): print(c, value) print(list(enumerate(my_list, 0)))
my_list = ['apple', 'banana', 'grapes', 'pear'] for (c, value) in enumerate(my_list, 1): print(c, value) print(list(enumerate(my_list, 0)))
_base_ = './mask_rcnn_r50_fpn_1x_coco.py' model = dict( pretrained='open-mmlab://detectron2/resnet50_caffe', backbone=dict( type='ResNet', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=-1, norm_cfg=dict(type='SyncBN', requires_grad=True), ...
_base_ = './mask_rcnn_r50_fpn_1x_coco.py' model = dict(pretrained='open-mmlab://detectron2/resnet50_caffe', backbone=dict(type='ResNet', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=-1, norm_cfg=dict(type='SyncBN', requires_grad=True), norm_eval=True, style='caffe')) optimizer = dict(type='SGD', lr=0...
STATS = [ { "num_node_expansions": 51, "plan_length": 33, "search_time": 0.04, "total_time": 0.04 }, { "num_node_expansions": 87, "plan_length": 35, "search_time": 0.07, "total_time": 0.07 }, { "num_node_expansions": 104, ...
stats = [{'num_node_expansions': 51, 'plan_length': 33, 'search_time': 0.04, 'total_time': 0.04}, {'num_node_expansions': 87, 'plan_length': 35, 'search_time': 0.07, 'total_time': 0.07}, {'num_node_expansions': 104, 'plan_length': 49, 'search_time': 0.61, 'total_time': 0.61}, {'num_node_expansions': 45, 'plan_length': ...
def delimited(fyle, delimiter='\n', bufsize=4096): ''' generator to yield records of a text file ''' buf = '' while True: newbuf = fyle.read(bufsize) if not newbuf: yield buf return buf += newbuf lines = buf.split(delimiter) for line in lines[:...
def delimited(fyle, delimiter='\n', bufsize=4096): """ generator to yield records of a text file """ buf = '' while True: newbuf = fyle.read(bufsize) if not newbuf: yield buf return buf += newbuf lines = buf.split(delimiter) for line in lines[:...
# ~*~ coding: utf-8 ~*~ __doc__ = """ `opencannabis.geo` --------------------------- Objects and definitions related to geography. """ # `opencannabis.geo`
__doc__ = '\n\n `opencannabis.geo`\n ---------------------------\n Objects and definitions related to geography.\n\n'
GQL_SCHEMA = """ enum Episode { NEWHOPE EMPIRE JEDI } enum LengthUnit { METER } type Character { name: String! appearsIn: [Episode!]! } type Starship { id: ID! name: String! length(unit: LengthUnit = METER): Float } type Query { hero(episode: Episode): Character } """ SOURCE_CODE = """ class ...
gql_schema = '\nenum Episode {\n NEWHOPE\n EMPIRE\n JEDI\n}\n\nenum LengthUnit {\n METER\n} \n\n\ntype Character {\n name: String!\n appearsIn: [Episode!]!\n}\n\ntype Starship {\n id: ID!\n name: String!\n length(unit: LengthUnit = METER): Float\n}\n\ntype Query {\n hero(episode: Episode): Character\n}\n' sou...
# -*- coding: utf-8 -*- """ Created on Fri Mar 31 11:57:54 2017 @author: Chandan Adiga This module is designed assuming: 1) first two rows are to be neglected as they contain meta data.(title, desc etc. in this case, heading and attributes name) 2) Attributes are seperated with tab('\t') and 5th item is class name. ...
""" Created on Fri Mar 31 11:57:54 2017 @author: Chandan Adiga This module is designed assuming: 1) first two rows are to be neglected as they contain meta data.(title, desc etc. in this case, heading and attributes name) 2) Attributes are seperated with tab(' ') and 5th item is class name. To Start run: python Main...
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def middleNode(self, head: Optional[ListNode]) -> Optional[ListNode]: fPtr = head sPtr = head counter = 0 result = []...
class Solution: def middle_node(self, head: Optional[ListNode]) -> Optional[ListNode]: f_ptr = head s_ptr = head counter = 0 result = [] while fPtr: f_ptr = fPtr.next counter += 1 for i in range(0, counter // 2): s_ptr = sPtr.next ...
''' Encoding and decoding to user-readable identifiers ("codes") from integer identifiers Created 2019-05-31 by NGnius ''' READABLE_CHARS = [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9...
""" Encoding and decoding to user-readable identifiers ("codes") from integer identifiers Created 2019-05-31 by NGnius """ readable_chars = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9'] cl...
def is_allowed(fname): allowed_ext = fname.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS return '.' in fname and allowed_ext def generate_random_name(fname): ext = fname.split('.')[-1] rns = [random.randint(0, len(CHAR_SET)-1) for _ in range(6)] chars = ''.join(CHAR_SET[rn] for rn in rns) ne...
def is_allowed(fname): allowed_ext = fname.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS return '.' in fname and allowed_ext def generate_random_name(fname): ext = fname.split('.')[-1] rns = [random.randint(0, len(CHAR_SET) - 1) for _ in range(6)] chars = ''.join((CHAR_SET[rn] for rn in rns)) ...
#!/usr/bin/env python # -*- coding:utf-8 -*- """ FileName: 142. Linked List Cycle II.py Author: Kimberly Gao Date: 2021/07/20 6:31 PM Version: 0.1 """ # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def detectCy...
""" FileName: 142. Linked List Cycle II.py Author: Kimberly Gao Date: 2021/07/20 6:31 PM Version: 0.1 """ class Solution: def detect_cycle(self, head: ListNode) -> ListNode: if head == None or head.next == None: return None (slow, fast) = (head, head) while fast != None and fas...
#Problem 507 def perfect_number(num): divisor_sum = 1 if num == 1: return False for i in range(2, int(num**0.5)): if num%i == 0: divisor_sum = divisor_sum + i + num/i if divisor_sum == num: return True return False #Tests def perfect_number_test(): input_nums1 = 28 input_nums2...
def perfect_number(num): divisor_sum = 1 if num == 1: return False for i in range(2, int(num ** 0.5)): if num % i == 0: divisor_sum = divisor_sum + i + num / i if divisor_sum == num: return True return False def perfect_number_test(): input_nums1 = 28 inp...
# coding=utf-8 """ Just version so that if this is run, there is no side effects. """ __version__ = "0.1.6" # Jiggle Version Was Here
""" Just version so that if this is run, there is no side effects. """ __version__ = '0.1.6'
# # PySNMP MIB module CISCO-LES-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-LES-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:04:28 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 201...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, value_size_constraint, value_range_constraint, single_value_constraint, constraints_intersection) ...
def sort_012(input_list): """ Given an input array consisting on only 0, 1, and 2, sort the array in a single traversal. Args: input_list(list): List to be sorted """ idx = 0 m_idx = 0 n_idx = len(input_list)-1 while idx <= n_idx: if input_list[n_idx] == 2:...
def sort_012(input_list): """ Given an input array consisting on only 0, 1, and 2, sort the array in a single traversal. Args: input_list(list): List to be sorted """ idx = 0 m_idx = 0 n_idx = len(input_list) - 1 while idx <= n_idx: if input_list[n_idx] == 2: n...
# # PySNMP MIB module IDT1-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/IDT1-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:51:57 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:23:1...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, constraints_intersection, value_range_constraint, constraints_union, single_value_constraint) ...
# creating a Class of name Employee class Employee: # creating a Class Variable increament = 1.5 # Creating a Constructor of the Class Employee def __init__(self, fname, lname, salary): # setting Values to the variables self.fname = fname # setting Values to the variables ...
class Employee: increament = 1.5 def __init__(self, fname, lname, salary): self.fname = fname self.lname = lname self.salary = salary def increase(self): self.salary = int(self.salary * Employee.increament) @classmethod def change_increament(cls, amount): c...
def add_digits(num): if num < 10: return num else: return add_digits(sum(map(int, str(num)))) if __name__ == "__main__": input_number = 38 print(add_digits(input_number))
def add_digits(num): if num < 10: return num else: return add_digits(sum(map(int, str(num)))) if __name__ == '__main__': input_number = 38 print(add_digits(input_number))
# Python code to insert a node in AVL tree class TreeNode(object): def __init__(self, val): self.value = val self.left = None self.right = None #self.parent = none self.height = 1 class AVL_Tree(object): def insert(self, root, key): #Step 1 - perf...
class Treenode(object): def __init__(self, val): self.value = val self.left = None self.right = None self.height = 1 class Avl_Tree(object): def insert(self, root, key): if not root: return tree_node(key) elif key < root.value: root.left...
# -*- python -*- # # Copyright (C) 2012, Pigeon Point Systems # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This # file and program are licensed under a BSD style license....
rpc_sahpi_null = 0 rpc_sahpi_session_open = 1 rpc_sahpi_session_close = 2 rpc_sahpi_discover = 3 rpc_sahpi_domain_info_get = 4 rpc_sahpi_drt_entry_get = 5 rpc_sahpi_domain_tag_set = 6 rpc_sahpi_rpt_entry_get = 7 rpc_sahpi_rpt_entry_get_by_resource_id = 8 rpc_sahpi_resource_severity_set = 9 rpc_sahpi_resource_tag_set = ...
def decreaseBlue(picture): for pixel in getPixels(picture): blue = getBlue(pixel) new_blue = blue * 0.1 setBlue(pixel, new_blue) repaint(picture) def swapColor(picture): for pixel in getPixels(picture): blue = getBlue(pixel) red = getRed(pixel) setBlue(pixel, red) setRed...
def decrease_blue(picture): for pixel in get_pixels(picture): blue = get_blue(pixel) new_blue = blue * 0.1 set_blue(pixel, new_blue) repaint(picture) def swap_color(picture): for pixel in get_pixels(picture): blue = get_blue(pixel) red = get_red(pixel) set_bl...