content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
#!/usr/bin/env python3.10 FILE='test_s1.txt' # in: C200B40A82 sol: 3 FILE='test_s2.txt' # in: 04005AC33890 sol: 54 FILE='test_s3.txt' # in: 880086C3E88112 sol: 7 FILE='test_s4.txt' # in: CE00C43D881120 sol: 9 FILE='test_s5.txt' # in: D8005AC2A8F0 sol: 1 FILE='test_s6.txt' # in: F600BC2D8F sol: 0 FILE='test_s7.txt' # in: 9C005AC2F8F0 sol: 0 FILE='test_s8.txt' # in: 9C0141080250320F1802104A08 sol: 1 FILE='input.txt' # sol: 1549026292886 def parse_input(file): with open(file, 'r') as f: line = f.readline().rstrip() print(f'line: {line}') binary = '' for c in line: match c: case '0': binary += '0000' case '1': binary += '0001' case '2': binary += '0010' case '3': binary += '0011' case '4': binary += '0100' case '5': binary += '0101' case '6': binary += '0110' case '7': binary += '0111' case '8': binary += '1000' case '9': binary += '1001' case 'A': binary += '1010' case 'B': binary += '1011' case 'C': binary += '1100' case 'D': binary += '1101' case 'E': binary += '1110' case 'F': binary += '1111' #binary = format(int(line, 16), 'b') print(f'binary: {binary}') return binary def parse_packet(binary, level): print(' ' * level + f'parsing packet...') #print(' ' * level + f'parsing packet: {binary}') version = int(binary[0:3],2) #print(' ' * level + f'version: {version}') binary = binary[3:] type_id = int(binary[0:3],2) #print(' ' * level + f'type_id: {type_id}') binary = binary[3:] number = 0 match type_id: case 0: number, binary = parse_sum(binary, level) case 1: number, binary = parse_product(binary, level) case 2: number, binary = parse_minimum(binary, level) case 3: number, binary = parse_maximum(binary, level) case 4: number, binary = parse_number(binary, level) case 5: number, binary = parse_greater_than(binary, level) case 6: number, binary = parse_less_than(binary, level) case 7: number, binary = parse_equal_to(binary, level) case 8: number, binary = parse_operators(binary, level) case _: print('unsupported') assert False return number, binary def parse_sum(binary, level): print(' ' * level + 'parsing sum...') total = 0 length_type_id = int(binary[0]) binary = binary[1:] if length_type_id == 0: length_subpacket = int(binary[0:15], 2) binary = binary[15:] sub_binary = binary[0:length_subpacket] binary = binary[length_subpacket:] while sub_binary: number, sub_binary = parse_packet(sub_binary, level+1) total += number elif length_type_id == 1: nb_subpacket = int(binary[0:11], 2) binary = binary[11:] for i in range(nb_subpacket): number, binary = parse_packet(binary, level+1) total += number print(' ' * level + f'sum: {total}') return total, binary def parse_product(binary, level): print(' ' * level + f'parsing product...') total = 1 length_type_id = int(binary[0]) binary = binary[1:] if length_type_id == 0: length_subpacket = int(binary[0:15], 2) binary = binary[15:] sub_binary = binary[0:length_subpacket] binary = binary[length_subpacket:] while sub_binary: number, sub_binary = parse_packet(sub_binary, level+1) total *= number elif length_type_id == 1: nb_subpacket = int(binary[0:11], 2) binary = binary[11:] for i in range(nb_subpacket): number, binary = parse_packet(binary, level+1) total *= number print(' ' * level + f'product: {total}') return total, binary def parse_minimum(binary, level): print(' ' * level + f'parsing minimum...') minimum = None length_type_id = int(binary[0]) binary = binary[1:] if length_type_id == 0: length_subpacket = int(binary[0:15], 2) binary = binary[15:] sub_binary = binary[0:length_subpacket] binary = binary[length_subpacket:] while sub_binary: number, sub_binary = parse_packet(sub_binary, level+1) if minimum == None or number < minimum: minimum = number elif length_type_id == 1: nb_subpacket = int(binary[0:11], 2) binary = binary[11:] for i in range(nb_subpacket): number, binary = parse_packet(binary, level+1) if minimum == None or number < minimum: minimum = number print(' ' * level + f'minimum: {minimum}') return minimum, binary def parse_maximum(binary, level): print(' ' * level + f'parsing maximum...') maximum = None length_type_id = int(binary[0]) binary = binary[1:] if length_type_id == 0: length_subpacket = int(binary[0:15], 2) binary = binary[15:] sub_binary = binary[0:length_subpacket] binary = binary[length_subpacket:] while sub_binary: number, sub_binary = parse_packet(sub_binary, level+1) if maximum == None or number > maximum: maximum = number elif length_type_id == 1: nb_subpacket = int(binary[0:11], 2) binary = binary[11:] for i in range(nb_subpacket): number, binary = parse_packet(binary, level+1) if maximum == None or number > maximum: maximum = number print(' ' * level + f'maximum: {maximum}') return maximum, binary def parse_number(binary, level): print(' ' * level + f'parsing number...') number = '' has_next = 1 # [has_next + 'WXYZ']+ while has_next == 1: has_next = int(binary[0]) #print(' ' * level + f'has next: {has_next}') binary = binary[1:] tmp = binary[0:4] #print(' ' * level + f'tmp: {tmp}') binary = binary[4:] number += tmp number = int(number, 2) print(' ' * level + f'number: {number}') return number, binary def parse_greater_than(binary, level): print(' ' * level + f'parsing greater than...') a = None b = None length_type_id = int(binary[0]) binary = binary[1:] if length_type_id == 0: length_subpacket = int(binary[0:15], 2) binary = binary[15:] sub_binary = binary[0:length_subpacket] binary = binary[length_subpacket:] while sub_binary: number, sub_binary = parse_packet(sub_binary, level+1) if a == None: a = number elif b == None: b = number else: print('error more than 2 literals') assert False elif length_type_id == 1: nb_subpacket = int(binary[0:11], 2) binary = binary[11:] assert nb_subpacket == 2 a, binary = parse_packet(binary, level+1) b, binary = parse_packet(binary, level+1) assert a != None and b != None greater = 1 if a > b else 0 print(' ' * level + f'greater: {greater}') return greater, binary def parse_less_than(binary, level): print(' ' * level + f'parsing less than...') a = None b = None length_type_id = int(binary[0]) binary = binary[1:] if length_type_id == 0: length_subpacket = int(binary[0:15], 2) binary = binary[15:] sub_binary = binary[0:length_subpacket] binary = binary[length_subpacket:] while sub_binary: number, sub_binary = parse_packet(sub_binary, level+1) if a == None: a = number elif b == None: b = number else: print('error more than 2 literals') assert False elif length_type_id == 1: nb_subpacket = int(binary[0:11], 2) binary = binary[11:] assert nb_subpacket == 2 a, binary = parse_packet(binary, level+1) b, binary = parse_packet(binary, level+1) assert a != None and b != None less = 1 if a < b else 0 print(' ' * level + f'less: {less}') return less, binary def parse_equal_to(binary, level): print(' ' * level + f'parsing equal to...') a = None b = None length_type_id = int(binary[0]) binary = binary[1:] if length_type_id == 0: length_subpacket = int(binary[0:15], 2) binary = binary[15:] sub_binary = binary[0:length_subpacket] binary = binary[length_subpacket:] while sub_binary: number, sub_binary = parse_packet(sub_binary, level+1) if a == None: a = number elif b == None: b = number else: print('error more than 2 literals') assert False elif length_type_id == 1: nb_subpacket = int(binary[0:11], 2) binary = binary[11:] assert nb_subpacket == 2 a, binary = parse_packet(binary, level+1) b, binary = parse_packet(binary, level+1) assert a != None and b != None equal = 1 if a == b else 0 print(' ' * level + f'equal: {equal}') return equal, binary def parse_operators(binary, level): print(' ' * level + 'operator 8 is undefined') assert False version = 0 length_type_id = int(binary[0]) print(' ' * level + f'length type id: {length_type_id}') binary = binary[1:] if length_type_id == 0: print(' ' * level + 'parsing 15 bits') length_subpacket = int(binary[0:15], 2) print(' ' * level + f'length_subpacket: {length_subpacket}') binary = binary[15:] sub_binary = binary[0:length_subpacket] binary = binary[length_subpacket:] while sub_binary: sub_ver, sub_binary = parse_packet(sub_binary, level+1) version += sub_ver print() elif length_type_id == 1: print(' ' * level + 'parsing 11 bits') nb_subpacket = int(binary[0:11], 2) print(' ' * level + f'nb_subpacket: {nb_subpacket}') binary = binary[11:] for i in range(nb_subpacket): sub_ver, binary = parse_packet(binary, level+1) print() version += sub_ver else: print(' ' * level + 'parsing error !') return return version, binary # Main binary = parse_input(FILE) number, binary = parse_packet(binary, 0) print(f'result: {number}')
file = 'test_s1.txt' file = 'test_s2.txt' file = 'test_s3.txt' file = 'test_s4.txt' file = 'test_s5.txt' file = 'test_s6.txt' file = 'test_s7.txt' file = 'test_s8.txt' file = 'input.txt' def parse_input(file): with open(file, 'r') as f: line = f.readline().rstrip() print(f'line: {line}') binary = '' for c in line: match c: case '0': binary += '0000' case '1': binary += '0001' case '2': binary += '0010' case '3': binary += '0011' case '4': binary += '0100' case '5': binary += '0101' case '6': binary += '0110' case '7': binary += '0111' case '8': binary += '1000' case '9': binary += '1001' case 'A': binary += '1010' case 'B': binary += '1011' case 'C': binary += '1100' case 'D': binary += '1101' case 'E': binary += '1110' case 'F': binary += '1111' print(f'binary: {binary}') return binary def parse_packet(binary, level): print(' ' * level + f'parsing packet...') version = int(binary[0:3], 2) binary = binary[3:] type_id = int(binary[0:3], 2) binary = binary[3:] number = 0 match type_id: case 0: (number, binary) = parse_sum(binary, level) case 1: (number, binary) = parse_product(binary, level) case 2: (number, binary) = parse_minimum(binary, level) case 3: (number, binary) = parse_maximum(binary, level) case 4: (number, binary) = parse_number(binary, level) case 5: (number, binary) = parse_greater_than(binary, level) case 6: (number, binary) = parse_less_than(binary, level) case 7: (number, binary) = parse_equal_to(binary, level) case 8: (number, binary) = parse_operators(binary, level) case _: print('unsupported') assert False return (number, binary) def parse_sum(binary, level): print(' ' * level + 'parsing sum...') total = 0 length_type_id = int(binary[0]) binary = binary[1:] if length_type_id == 0: length_subpacket = int(binary[0:15], 2) binary = binary[15:] sub_binary = binary[0:length_subpacket] binary = binary[length_subpacket:] while sub_binary: (number, sub_binary) = parse_packet(sub_binary, level + 1) total += number elif length_type_id == 1: nb_subpacket = int(binary[0:11], 2) binary = binary[11:] for i in range(nb_subpacket): (number, binary) = parse_packet(binary, level + 1) total += number print(' ' * level + f'sum: {total}') return (total, binary) def parse_product(binary, level): print(' ' * level + f'parsing product...') total = 1 length_type_id = int(binary[0]) binary = binary[1:] if length_type_id == 0: length_subpacket = int(binary[0:15], 2) binary = binary[15:] sub_binary = binary[0:length_subpacket] binary = binary[length_subpacket:] while sub_binary: (number, sub_binary) = parse_packet(sub_binary, level + 1) total *= number elif length_type_id == 1: nb_subpacket = int(binary[0:11], 2) binary = binary[11:] for i in range(nb_subpacket): (number, binary) = parse_packet(binary, level + 1) total *= number print(' ' * level + f'product: {total}') return (total, binary) def parse_minimum(binary, level): print(' ' * level + f'parsing minimum...') minimum = None length_type_id = int(binary[0]) binary = binary[1:] if length_type_id == 0: length_subpacket = int(binary[0:15], 2) binary = binary[15:] sub_binary = binary[0:length_subpacket] binary = binary[length_subpacket:] while sub_binary: (number, sub_binary) = parse_packet(sub_binary, level + 1) if minimum == None or number < minimum: minimum = number elif length_type_id == 1: nb_subpacket = int(binary[0:11], 2) binary = binary[11:] for i in range(nb_subpacket): (number, binary) = parse_packet(binary, level + 1) if minimum == None or number < minimum: minimum = number print(' ' * level + f'minimum: {minimum}') return (minimum, binary) def parse_maximum(binary, level): print(' ' * level + f'parsing maximum...') maximum = None length_type_id = int(binary[0]) binary = binary[1:] if length_type_id == 0: length_subpacket = int(binary[0:15], 2) binary = binary[15:] sub_binary = binary[0:length_subpacket] binary = binary[length_subpacket:] while sub_binary: (number, sub_binary) = parse_packet(sub_binary, level + 1) if maximum == None or number > maximum: maximum = number elif length_type_id == 1: nb_subpacket = int(binary[0:11], 2) binary = binary[11:] for i in range(nb_subpacket): (number, binary) = parse_packet(binary, level + 1) if maximum == None or number > maximum: maximum = number print(' ' * level + f'maximum: {maximum}') return (maximum, binary) def parse_number(binary, level): print(' ' * level + f'parsing number...') number = '' has_next = 1 while has_next == 1: has_next = int(binary[0]) binary = binary[1:] tmp = binary[0:4] binary = binary[4:] number += tmp number = int(number, 2) print(' ' * level + f'number: {number}') return (number, binary) def parse_greater_than(binary, level): print(' ' * level + f'parsing greater than...') a = None b = None length_type_id = int(binary[0]) binary = binary[1:] if length_type_id == 0: length_subpacket = int(binary[0:15], 2) binary = binary[15:] sub_binary = binary[0:length_subpacket] binary = binary[length_subpacket:] while sub_binary: (number, sub_binary) = parse_packet(sub_binary, level + 1) if a == None: a = number elif b == None: b = number else: print('error more than 2 literals') assert False elif length_type_id == 1: nb_subpacket = int(binary[0:11], 2) binary = binary[11:] assert nb_subpacket == 2 (a, binary) = parse_packet(binary, level + 1) (b, binary) = parse_packet(binary, level + 1) assert a != None and b != None greater = 1 if a > b else 0 print(' ' * level + f'greater: {greater}') return (greater, binary) def parse_less_than(binary, level): print(' ' * level + f'parsing less than...') a = None b = None length_type_id = int(binary[0]) binary = binary[1:] if length_type_id == 0: length_subpacket = int(binary[0:15], 2) binary = binary[15:] sub_binary = binary[0:length_subpacket] binary = binary[length_subpacket:] while sub_binary: (number, sub_binary) = parse_packet(sub_binary, level + 1) if a == None: a = number elif b == None: b = number else: print('error more than 2 literals') assert False elif length_type_id == 1: nb_subpacket = int(binary[0:11], 2) binary = binary[11:] assert nb_subpacket == 2 (a, binary) = parse_packet(binary, level + 1) (b, binary) = parse_packet(binary, level + 1) assert a != None and b != None less = 1 if a < b else 0 print(' ' * level + f'less: {less}') return (less, binary) def parse_equal_to(binary, level): print(' ' * level + f'parsing equal to...') a = None b = None length_type_id = int(binary[0]) binary = binary[1:] if length_type_id == 0: length_subpacket = int(binary[0:15], 2) binary = binary[15:] sub_binary = binary[0:length_subpacket] binary = binary[length_subpacket:] while sub_binary: (number, sub_binary) = parse_packet(sub_binary, level + 1) if a == None: a = number elif b == None: b = number else: print('error more than 2 literals') assert False elif length_type_id == 1: nb_subpacket = int(binary[0:11], 2) binary = binary[11:] assert nb_subpacket == 2 (a, binary) = parse_packet(binary, level + 1) (b, binary) = parse_packet(binary, level + 1) assert a != None and b != None equal = 1 if a == b else 0 print(' ' * level + f'equal: {equal}') return (equal, binary) def parse_operators(binary, level): print(' ' * level + 'operator 8 is undefined') assert False version = 0 length_type_id = int(binary[0]) print(' ' * level + f'length type id: {length_type_id}') binary = binary[1:] if length_type_id == 0: print(' ' * level + 'parsing 15 bits') length_subpacket = int(binary[0:15], 2) print(' ' * level + f'length_subpacket: {length_subpacket}') binary = binary[15:] sub_binary = binary[0:length_subpacket] binary = binary[length_subpacket:] while sub_binary: (sub_ver, sub_binary) = parse_packet(sub_binary, level + 1) version += sub_ver print() elif length_type_id == 1: print(' ' * level + 'parsing 11 bits') nb_subpacket = int(binary[0:11], 2) print(' ' * level + f'nb_subpacket: {nb_subpacket}') binary = binary[11:] for i in range(nb_subpacket): (sub_ver, binary) = parse_packet(binary, level + 1) print() version += sub_ver else: print(' ' * level + 'parsing error !') return return (version, binary) binary = parse_input(FILE) (number, binary) = parse_packet(binary, 0) print(f'result: {number}')
def soma(a, b): x = a + b y = 'qualquer coisa' if x > 5: return x else: return y def soma(a, b): x = a + b y = 'qualquer coisa' yield x yield y def soma(a, b): x = a + b y = 'qualquer coisa' return (x, y) #https://pt.stackoverflow.com/q/331155/101
def soma(a, b): x = a + b y = 'qualquer coisa' if x > 5: return x else: return y def soma(a, b): x = a + b y = 'qualquer coisa' yield x yield y def soma(a, b): x = a + b y = 'qualquer coisa' return (x, y)
class Solution: def maxSubArray(self, nums: List[int]) -> int: best_sum=nums[0] current_sum=nums[0] for i in (nums[1:]): current_sum= max(i, current_sum + i) best_sum=max(best_sum,current_sum) return best_sum
class Solution: def max_sub_array(self, nums: List[int]) -> int: best_sum = nums[0] current_sum = nums[0] for i in nums[1:]: current_sum = max(i, current_sum + i) best_sum = max(best_sum, current_sum) return best_sum
# this function will return a number depending on the balance of parentheses def is_balanced(text): count = 0 # loops through inputted text for char in text: # adds one to count if there is an open paren if char == '(': count += 1 # subtracts one if there is a closed paren if char == ')': count -= 1 # if there is a closed without an open attached, return if count == -1: return count # if there is more than one open paren, just return one if count > 0: return 1 # otherwise return the count return count
def is_balanced(text): count = 0 for char in text: if char == '(': count += 1 if char == ')': count -= 1 if count == -1: return count if count > 0: return 1 return count
# Name: # Date: # proj01: A Simple Program # Part I: # This program asks the user for his/her name and grade. #Then, it prints out a sentence that says the number of years until they graduate. name = input("What is your name? ") name = name[0].upper() + name[1:] grade = int(input("That is a cool name. What grade are you in? ")) years = str(13 - grade) print (name + ", you will graduate in " + years + " years!") # Part II: # This program asks the user for his/her name and birth month. # Then, it prints a sentence that says the number of days and months until their birthday bmonth = int(input("What month were you born in, " + name + "? ")) bday = int(input("What day were you born on? ")) submonth1 = bmonth - 6 submonth2 = 6 - bmonth submonth3 = bmonth - 6 - 1 subday1 = bday - 12 subday2 = 30 - (12 - bday) if (bmonth >= 6) and (bday >= 12): print ("You have " + str(submonth1) + " month(s) ") print("and " + str(subday1) + " day(s) until your birthday!") elif (bmonth >= 6) and (bday <= 12): print("You have " + str(submonth3) + " month(s) ") print("and " + str(subday2) + " day(s) until your birthday!") elif (bmonth <= 6) and (bday <= 12): print ("You have " + str(submonth2) + " month(s) ") print("and " + str(subday1) + " day(s) until your birthday!") else: print ("You have " + str(submonth3) + " month(s) ") print("and " + str(subday2) + " day(s) until your birthday!") age = int(input(name + ", how old are you? ")) if age < 13: print("You can see G and PG movies.") elif (age >= 13) and (age < 18): print("You can see G, PG, and PG-13 movies.") elif age >= 18: print("Since you are " + str(age) + ", you can see any movie you want!") animal = input("What is your favorite animal? ") color = input("What is your favorite color, " + name + "? ") food = input("What is your favorite food to consume? ") sport = input(name + ", what is your favorite sport? ") song = input("Finally, what is your favorite song to listen to? ") print("Great! Here is a sentence that is made just for you: ") print("A " + color + " " + animal + " named " + name + ", played " + sport + " while listening to " + song + " and eating " + food + "! ") # If you complete extensions, describe your extensions here!
name = input('What is your name? ') name = name[0].upper() + name[1:] grade = int(input('That is a cool name. What grade are you in? ')) years = str(13 - grade) print(name + ', you will graduate in ' + years + ' years!') bmonth = int(input('What month were you born in, ' + name + '? ')) bday = int(input('What day were you born on? ')) submonth1 = bmonth - 6 submonth2 = 6 - bmonth submonth3 = bmonth - 6 - 1 subday1 = bday - 12 subday2 = 30 - (12 - bday) if bmonth >= 6 and bday >= 12: print('You have ' + str(submonth1) + ' month(s) ') print('and ' + str(subday1) + ' day(s) until your birthday!') elif bmonth >= 6 and bday <= 12: print('You have ' + str(submonth3) + ' month(s) ') print('and ' + str(subday2) + ' day(s) until your birthday!') elif bmonth <= 6 and bday <= 12: print('You have ' + str(submonth2) + ' month(s) ') print('and ' + str(subday1) + ' day(s) until your birthday!') else: print('You have ' + str(submonth3) + ' month(s) ') print('and ' + str(subday2) + ' day(s) until your birthday!') age = int(input(name + ', how old are you? ')) if age < 13: print('You can see G and PG movies.') elif age >= 13 and age < 18: print('You can see G, PG, and PG-13 movies.') elif age >= 18: print('Since you are ' + str(age) + ', you can see any movie you want!') animal = input('What is your favorite animal? ') color = input('What is your favorite color, ' + name + '? ') food = input('What is your favorite food to consume? ') sport = input(name + ', what is your favorite sport? ') song = input('Finally, what is your favorite song to listen to? ') print('Great! Here is a sentence that is made just for you: ') print('A ' + color + ' ' + animal + ' named ' + name + ', played ' + sport + ' while listening to ' + song + ' and eating ' + food + '! ')
# # PySNMP MIB module CISCO-OAM-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-OAM-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:51:51 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:15) # Integer, ObjectIdentifier, OctetString = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ValueRangeConstraint, SingleValueConstraint, ValueSizeConstraint, ConstraintsIntersection, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "SingleValueConstraint", "ValueSizeConstraint", "ConstraintsIntersection", "ConstraintsUnion") ciscoExperiment, = mibBuilder.importSymbols("CISCO-SMI", "ciscoExperiment") ifIndex, = mibBuilder.importSymbols("IF-MIB", "ifIndex") OwnerString, = mibBuilder.importSymbols("RMON-MIB", "OwnerString") ObjectGroup, NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "ObjectGroup", "NotificationGroup", "ModuleCompliance") ObjectIdentity, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, ModuleIdentity, Counter64, TimeTicks, Counter32, Integer32, iso, IpAddress, Unsigned32, Bits, MibIdentifier, Gauge32 = mibBuilder.importSymbols("SNMPv2-SMI", "ObjectIdentity", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "ModuleIdentity", "Counter64", "TimeTicks", "Counter32", "Integer32", "iso", "IpAddress", "Unsigned32", "Bits", "MibIdentifier", "Gauge32") DisplayString, TimeStamp, RowStatus, TruthValue, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TimeStamp", "RowStatus", "TruthValue", "TextualConvention") ciscoOamPingMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 9, 10, 15)) ciscoOamPingMIB.setRevisions(('2006-02-17 00:00', '2003-06-27 00:00', '2003-04-04 00:00', '1996-05-01 00:00',)) if mibBuilder.loadTexts: ciscoOamPingMIB.setLastUpdated('200602170000Z') if mibBuilder.loadTexts: ciscoOamPingMIB.setOrganization('Cisco Systems, Inc.') ciscoOamPingMIBObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 10, 15, 1)) class CiscoOAMPingDir(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2)) namedValues = NamedValues(("forward", 1), ("backward", 2)) class CiscoOAMPingStatus(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7)) namedValues = NamedValues(("success", 1), ("timeOut", 2), ("resourceNotAvailable", 3), ("aborted", 4), ("inProgress", 5), ("noResponseData", 6), ("failToStart", 7)) oamLoopbackPingTable = MibTable((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1), ) if mibBuilder.loadTexts: oamLoopbackPingTable.setStatus('current') oamLoopbackPingEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1), ).setIndexNames((0, "CISCO-OAM-MIB", "oamLoopbackPingSerialNumber")) if mibBuilder.loadTexts: oamLoopbackPingEntry.setStatus('current') oamLoopbackPingSerialNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647))) if mibBuilder.loadTexts: oamLoopbackPingSerialNumber.setStatus('current') oamLoopbackPingInterface = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647))).setMaxAccess("readcreate") if mibBuilder.loadTexts: oamLoopbackPingInterface.setStatus('current') oamLoopbackPingVpi = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 4095))).setMaxAccess("readcreate") if mibBuilder.loadTexts: oamLoopbackPingVpi.setStatus('current') oamLoopbackPingVci = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 65535))).setMaxAccess("readcreate") if mibBuilder.loadTexts: oamLoopbackPingVci.setStatus('current') oamLoopbackPingType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("segment", 1), ("end2end", 2))).clone('end2end')).setMaxAccess("readcreate") if mibBuilder.loadTexts: oamLoopbackPingType.setStatus('current') oamLoopbackPingLocation = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 6), OctetString().subtype(subtypeSpec=ValueSizeConstraint(0, 16)).clone(hexValue="FF")).setMaxAccess("readcreate") if mibBuilder.loadTexts: oamLoopbackPingLocation.setStatus('current') oamLoopbackPingLocationFlag = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("ipAddress", 1), ("nsapPrefix", 2), ("fixed16byteValue", 3))).clone('ipAddress')).setMaxAccess("readcreate") if mibBuilder.loadTexts: oamLoopbackPingLocationFlag.setStatus('current') oamLoopbackPingCount = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647)).clone(5)).setMaxAccess("readcreate") if mibBuilder.loadTexts: oamLoopbackPingCount.setStatus('current') oamLoopbackPingTimeout = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 3600000)).clone(1000)).setUnits('milliseconds').setMaxAccess("readcreate") if mibBuilder.loadTexts: oamLoopbackPingTimeout.setStatus('current') oamLoopbackPingDelay = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 10), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 3600000))).setUnits('milliseconds').setMaxAccess("readcreate") if mibBuilder.loadTexts: oamLoopbackPingDelay.setStatus('current') oamLoopbackPingTrapOnCompletion = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 11), TruthValue().clone('false')).setMaxAccess("readcreate") if mibBuilder.loadTexts: oamLoopbackPingTrapOnCompletion.setStatus('current') oamLoopbackPingSentCells = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 12), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: oamLoopbackPingSentCells.setStatus('current') oamLoopbackPingReceivedCells = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 13), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: oamLoopbackPingReceivedCells.setStatus('current') oamLoopbackPingMinRtt = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 14), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: oamLoopbackPingMinRtt.setStatus('current') oamLoopbackPingAvgRtt = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 15), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: oamLoopbackPingAvgRtt.setStatus('current') oamLoopbackPingMaxRtt = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 16), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: oamLoopbackPingMaxRtt.setStatus('current') oamLoopbackPingCompleted = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 17), TruthValue()).setMaxAccess("readonly") if mibBuilder.loadTexts: oamLoopbackPingCompleted.setStatus('current') oamLoopbackPingEntryOwner = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 18), OwnerString()).setMaxAccess("readcreate") if mibBuilder.loadTexts: oamLoopbackPingEntryOwner.setStatus('current') oamLoopbackPingEntryStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 19), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: oamLoopbackPingEntryStatus.setStatus('current') oamLoopbackPingDir = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 20), CiscoOAMPingDir()).setMaxAccess("readcreate") if mibBuilder.loadTexts: oamLoopbackPingDir.setStatus('current') oamLoopbackPingOperStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 21), CiscoOAMPingStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: oamLoopbackPingOperStatus.setStatus('current') oamLoopbackPingExecTime = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 22), TimeStamp()).setMaxAccess("readonly") if mibBuilder.loadTexts: oamLoopbackPingExecTime.setStatus('current') oamLoopbackPingMinRttuSec = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 23), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setUnits('microseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: oamLoopbackPingMinRttuSec.setStatus('current') oamLoopbackPingAvgRttuSec = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 24), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setUnits('microseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: oamLoopbackPingAvgRttuSec.setStatus('current') oamLoopbackPingMaxRttuSec = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 25), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setUnits('microseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: oamLoopbackPingMaxRttuSec.setStatus('current') oamLoopbackSegEndPointTable = MibTable((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 2), ) if mibBuilder.loadTexts: oamLoopbackSegEndPointTable.setStatus('current') oamLoopbackSegEndPointEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 2, 1), ).setIndexNames((0, "IF-MIB", "ifIndex"), (0, "CISCO-OAM-MIB", "oamLoopSegVpi"), (0, "CISCO-OAM-MIB", "oamLoopSegVci")) if mibBuilder.loadTexts: oamLoopbackSegEndPointEntry.setStatus('current') oamLoopSegVpi = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 2, 1, 1), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 4095))) if mibBuilder.loadTexts: oamLoopSegVpi.setStatus('current') oamLoopSegVci = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 2, 1, 2), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))) if mibBuilder.loadTexts: oamLoopSegVci.setStatus('current') oamLoopSegRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 2, 1, 3), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: oamLoopSegRowStatus.setStatus('current') oamLoopbackPingMIBTrapPrefix = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 10, 15, 2)) oamLoopbackPingMIBTraps = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 10, 15, 2, 0)) oamLoopbackPingCompletionTrap = NotificationType((1, 3, 6, 1, 4, 1, 9, 10, 15, 2, 0, 1)).setObjects(("CISCO-OAM-MIB", "oamLoopbackPingCompleted")) if mibBuilder.loadTexts: oamLoopbackPingCompletionTrap.setStatus('current') ciscoOamPingMIBConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 10, 15, 3)) ciscoOamPingMIBCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 10, 15, 3, 1)) ciscoOamPingMIBGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 10, 15, 3, 2)) ciscoOamPingMIBCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 9, 10, 15, 3, 1, 1)).setObjects(("CISCO-OAM-MIB", "ciscoOamPingMIBGroup")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ciscoOamPingMIBCompliance = ciscoOamPingMIBCompliance.setStatus('deprecated') ciscoOamPingMIBCompliance2 = ModuleCompliance((1, 3, 6, 1, 4, 1, 9, 10, 15, 3, 1, 2)).setObjects(("CISCO-OAM-MIB", "ciscoOamPing2MIBGroup"), ("CISCO-OAM-MIB", "oamLoopbackNotificationsGroup"), ("CISCO-OAM-MIB", "ciscoOamPingSegEndPointGroup")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ciscoOamPingMIBCompliance2 = ciscoOamPingMIBCompliance2.setStatus('deprecated') ciscoOamPingMIBCompliance3 = ModuleCompliance((1, 3, 6, 1, 4, 1, 9, 10, 15, 3, 1, 3)).setObjects(("CISCO-OAM-MIB", "ciscoOamPingMIBGroupRev3"), ("CISCO-OAM-MIB", "oamLoopbackNotificationsGroup"), ("CISCO-OAM-MIB", "ciscoOamPingSegEndPointGroup")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ciscoOamPingMIBCompliance3 = ciscoOamPingMIBCompliance3.setStatus('current') ciscoOamPingMIBGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 10, 15, 3, 2, 1)).setObjects(("CISCO-OAM-MIB", "oamLoopbackPingInterface"), ("CISCO-OAM-MIB", "oamLoopbackPingVpi"), ("CISCO-OAM-MIB", "oamLoopbackPingVci"), ("CISCO-OAM-MIB", "oamLoopbackPingCount"), ("CISCO-OAM-MIB", "oamLoopbackPingType"), ("CISCO-OAM-MIB", "oamLoopbackPingLocation"), ("CISCO-OAM-MIB", "oamLoopbackPingLocationFlag"), ("CISCO-OAM-MIB", "oamLoopbackPingTimeout"), ("CISCO-OAM-MIB", "oamLoopbackPingDelay"), ("CISCO-OAM-MIB", "oamLoopbackPingTrapOnCompletion"), ("CISCO-OAM-MIB", "oamLoopbackPingSentCells"), ("CISCO-OAM-MIB", "oamLoopbackPingReceivedCells"), ("CISCO-OAM-MIB", "oamLoopbackPingMinRtt"), ("CISCO-OAM-MIB", "oamLoopbackPingAvgRtt"), ("CISCO-OAM-MIB", "oamLoopbackPingMaxRtt"), ("CISCO-OAM-MIB", "oamLoopbackPingCompleted"), ("CISCO-OAM-MIB", "oamLoopbackPingEntryOwner"), ("CISCO-OAM-MIB", "oamLoopbackPingEntryStatus")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ciscoOamPingMIBGroup = ciscoOamPingMIBGroup.setStatus('deprecated') ciscoOamPing2MIBGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 10, 15, 3, 2, 2)).setObjects(("CISCO-OAM-MIB", "oamLoopbackPingInterface"), ("CISCO-OAM-MIB", "oamLoopbackPingVpi"), ("CISCO-OAM-MIB", "oamLoopbackPingVci"), ("CISCO-OAM-MIB", "oamLoopbackPingCount"), ("CISCO-OAM-MIB", "oamLoopbackPingType"), ("CISCO-OAM-MIB", "oamLoopbackPingLocation"), ("CISCO-OAM-MIB", "oamLoopbackPingLocationFlag"), ("CISCO-OAM-MIB", "oamLoopbackPingTimeout"), ("CISCO-OAM-MIB", "oamLoopbackPingDelay"), ("CISCO-OAM-MIB", "oamLoopbackPingTrapOnCompletion"), ("CISCO-OAM-MIB", "oamLoopbackPingSentCells"), ("CISCO-OAM-MIB", "oamLoopbackPingReceivedCells"), ("CISCO-OAM-MIB", "oamLoopbackPingMinRtt"), ("CISCO-OAM-MIB", "oamLoopbackPingAvgRtt"), ("CISCO-OAM-MIB", "oamLoopbackPingMaxRtt"), ("CISCO-OAM-MIB", "oamLoopbackPingCompleted"), ("CISCO-OAM-MIB", "oamLoopbackPingEntryOwner"), ("CISCO-OAM-MIB", "oamLoopbackPingEntryStatus"), ("CISCO-OAM-MIB", "oamLoopbackPingDir"), ("CISCO-OAM-MIB", "oamLoopbackPingOperStatus"), ("CISCO-OAM-MIB", "oamLoopbackPingExecTime")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ciscoOamPing2MIBGroup = ciscoOamPing2MIBGroup.setStatus('deprecated') ciscoOamPingSegEndPointGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 10, 15, 3, 2, 3)).setObjects(("CISCO-OAM-MIB", "oamLoopSegRowStatus")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ciscoOamPingSegEndPointGroup = ciscoOamPingSegEndPointGroup.setStatus('current') oamLoopbackNotificationsGroup = NotificationGroup((1, 3, 6, 1, 4, 1, 9, 10, 15, 3, 2, 4)).setObjects(("CISCO-OAM-MIB", "oamLoopbackPingCompletionTrap")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): oamLoopbackNotificationsGroup = oamLoopbackNotificationsGroup.setStatus('current') ciscoOamPingMIBGroupRev3 = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 10, 15, 3, 2, 5)).setObjects(("CISCO-OAM-MIB", "oamLoopbackPingInterface"), ("CISCO-OAM-MIB", "oamLoopbackPingVpi"), ("CISCO-OAM-MIB", "oamLoopbackPingVci"), ("CISCO-OAM-MIB", "oamLoopbackPingCount"), ("CISCO-OAM-MIB", "oamLoopbackPingType"), ("CISCO-OAM-MIB", "oamLoopbackPingLocation"), ("CISCO-OAM-MIB", "oamLoopbackPingLocationFlag"), ("CISCO-OAM-MIB", "oamLoopbackPingTimeout"), ("CISCO-OAM-MIB", "oamLoopbackPingDelay"), ("CISCO-OAM-MIB", "oamLoopbackPingTrapOnCompletion"), ("CISCO-OAM-MIB", "oamLoopbackPingSentCells"), ("CISCO-OAM-MIB", "oamLoopbackPingReceivedCells"), ("CISCO-OAM-MIB", "oamLoopbackPingMinRtt"), ("CISCO-OAM-MIB", "oamLoopbackPingAvgRtt"), ("CISCO-OAM-MIB", "oamLoopbackPingMaxRtt"), ("CISCO-OAM-MIB", "oamLoopbackPingCompleted"), ("CISCO-OAM-MIB", "oamLoopbackPingEntryOwner"), ("CISCO-OAM-MIB", "oamLoopbackPingEntryStatus"), ("CISCO-OAM-MIB", "oamLoopbackPingDir"), ("CISCO-OAM-MIB", "oamLoopbackPingOperStatus"), ("CISCO-OAM-MIB", "oamLoopbackPingExecTime"), ("CISCO-OAM-MIB", "oamLoopbackPingAvgRttuSec"), ("CISCO-OAM-MIB", "oamLoopbackPingMinRttuSec"), ("CISCO-OAM-MIB", "oamLoopbackPingMaxRttuSec")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ciscoOamPingMIBGroupRev3 = ciscoOamPingMIBGroupRev3.setStatus('current') mibBuilder.exportSymbols("CISCO-OAM-MIB", oamLoopbackPingEntryStatus=oamLoopbackPingEntryStatus, oamLoopbackSegEndPointEntry=oamLoopbackSegEndPointEntry, ciscoOamPingMIBCompliances=ciscoOamPingMIBCompliances, ciscoOamPingSegEndPointGroup=ciscoOamPingSegEndPointGroup, oamLoopbackPingExecTime=oamLoopbackPingExecTime, oamLoopbackPingInterface=oamLoopbackPingInterface, oamLoopbackPingMIBTrapPrefix=oamLoopbackPingMIBTrapPrefix, PYSNMP_MODULE_ID=ciscoOamPingMIB, oamLoopbackPingLocation=oamLoopbackPingLocation, oamLoopbackPingEntryOwner=oamLoopbackPingEntryOwner, oamLoopbackPingDelay=oamLoopbackPingDelay, oamLoopbackPingDir=oamLoopbackPingDir, oamLoopSegVci=oamLoopSegVci, ciscoOamPing2MIBGroup=ciscoOamPing2MIBGroup, ciscoOamPingMIB=ciscoOamPingMIB, oamLoopbackPingCompleted=oamLoopbackPingCompleted, oamLoopbackPingCompletionTrap=oamLoopbackPingCompletionTrap, CiscoOAMPingStatus=CiscoOAMPingStatus, oamLoopbackPingSentCells=oamLoopbackPingSentCells, oamLoopbackPingEntry=oamLoopbackPingEntry, oamLoopbackPingAvgRtt=oamLoopbackPingAvgRtt, oamLoopbackPingMinRttuSec=oamLoopbackPingMinRttuSec, oamLoopbackPingTimeout=oamLoopbackPingTimeout, oamLoopbackPingSerialNumber=oamLoopbackPingSerialNumber, oamLoopbackPingVci=oamLoopbackPingVci, ciscoOamPingMIBObjects=ciscoOamPingMIBObjects, oamLoopbackSegEndPointTable=oamLoopbackSegEndPointTable, ciscoOamPingMIBCompliance=ciscoOamPingMIBCompliance, ciscoOamPingMIBCompliance2=ciscoOamPingMIBCompliance2, oamLoopbackPingType=oamLoopbackPingType, ciscoOamPingMIBGroups=ciscoOamPingMIBGroups, ciscoOamPingMIBGroup=ciscoOamPingMIBGroup, oamLoopbackPingLocationFlag=oamLoopbackPingLocationFlag, oamLoopbackPingCount=oamLoopbackPingCount, CiscoOAMPingDir=CiscoOAMPingDir, oamLoopbackPingReceivedCells=oamLoopbackPingReceivedCells, ciscoOamPingMIBConformance=ciscoOamPingMIBConformance, oamLoopbackPingMinRtt=oamLoopbackPingMinRtt, ciscoOamPingMIBGroupRev3=ciscoOamPingMIBGroupRev3, oamLoopbackPingVpi=oamLoopbackPingVpi, ciscoOamPingMIBCompliance3=ciscoOamPingMIBCompliance3, oamLoopbackPingTrapOnCompletion=oamLoopbackPingTrapOnCompletion, oamLoopbackPingOperStatus=oamLoopbackPingOperStatus, oamLoopbackPingTable=oamLoopbackPingTable, oamLoopbackPingAvgRttuSec=oamLoopbackPingAvgRttuSec, oamLoopbackPingMaxRtt=oamLoopbackPingMaxRtt, oamLoopbackPingMIBTraps=oamLoopbackPingMIBTraps, oamLoopSegRowStatus=oamLoopSegRowStatus, oamLoopbackPingMaxRttuSec=oamLoopbackPingMaxRttuSec, oamLoopbackNotificationsGroup=oamLoopbackNotificationsGroup, oamLoopSegVpi=oamLoopSegVpi)
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, single_value_constraint, value_size_constraint, constraints_intersection, constraints_union) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueRangeConstraint', 'SingleValueConstraint', 'ValueSizeConstraint', 'ConstraintsIntersection', 'ConstraintsUnion') (cisco_experiment,) = mibBuilder.importSymbols('CISCO-SMI', 'ciscoExperiment') (if_index,) = mibBuilder.importSymbols('IF-MIB', 'ifIndex') (owner_string,) = mibBuilder.importSymbols('RMON-MIB', 'OwnerString') (object_group, notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'ObjectGroup', 'NotificationGroup', 'ModuleCompliance') (object_identity, mib_scalar, mib_table, mib_table_row, mib_table_column, notification_type, module_identity, counter64, time_ticks, counter32, integer32, iso, ip_address, unsigned32, bits, mib_identifier, gauge32) = mibBuilder.importSymbols('SNMPv2-SMI', 'ObjectIdentity', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'NotificationType', 'ModuleIdentity', 'Counter64', 'TimeTicks', 'Counter32', 'Integer32', 'iso', 'IpAddress', 'Unsigned32', 'Bits', 'MibIdentifier', 'Gauge32') (display_string, time_stamp, row_status, truth_value, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TimeStamp', 'RowStatus', 'TruthValue', 'TextualConvention') cisco_oam_ping_mib = module_identity((1, 3, 6, 1, 4, 1, 9, 10, 15)) ciscoOamPingMIB.setRevisions(('2006-02-17 00:00', '2003-06-27 00:00', '2003-04-04 00:00', '1996-05-01 00:00')) if mibBuilder.loadTexts: ciscoOamPingMIB.setLastUpdated('200602170000Z') if mibBuilder.loadTexts: ciscoOamPingMIB.setOrganization('Cisco Systems, Inc.') cisco_oam_ping_mib_objects = mib_identifier((1, 3, 6, 1, 4, 1, 9, 10, 15, 1)) class Ciscooampingdir(TextualConvention, Integer32): status = 'current' subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2)) named_values = named_values(('forward', 1), ('backward', 2)) class Ciscooampingstatus(TextualConvention, Integer32): status = 'current' subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7)) named_values = named_values(('success', 1), ('timeOut', 2), ('resourceNotAvailable', 3), ('aborted', 4), ('inProgress', 5), ('noResponseData', 6), ('failToStart', 7)) oam_loopback_ping_table = mib_table((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1)) if mibBuilder.loadTexts: oamLoopbackPingTable.setStatus('current') oam_loopback_ping_entry = mib_table_row((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1)).setIndexNames((0, 'CISCO-OAM-MIB', 'oamLoopbackPingSerialNumber')) if mibBuilder.loadTexts: oamLoopbackPingEntry.setStatus('current') oam_loopback_ping_serial_number = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 2147483647))) if mibBuilder.loadTexts: oamLoopbackPingSerialNumber.setStatus('current') oam_loopback_ping_interface = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 2), integer32().subtype(subtypeSpec=value_range_constraint(1, 2147483647))).setMaxAccess('readcreate') if mibBuilder.loadTexts: oamLoopbackPingInterface.setStatus('current') oam_loopback_ping_vpi = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 3), integer32().subtype(subtypeSpec=value_range_constraint(0, 4095))).setMaxAccess('readcreate') if mibBuilder.loadTexts: oamLoopbackPingVpi.setStatus('current') oam_loopback_ping_vci = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 4), integer32().subtype(subtypeSpec=value_range_constraint(-1, 65535))).setMaxAccess('readcreate') if mibBuilder.loadTexts: oamLoopbackPingVci.setStatus('current') oam_loopback_ping_type = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('segment', 1), ('end2end', 2))).clone('end2end')).setMaxAccess('readcreate') if mibBuilder.loadTexts: oamLoopbackPingType.setStatus('current') oam_loopback_ping_location = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 6), octet_string().subtype(subtypeSpec=value_size_constraint(0, 16)).clone(hexValue='FF')).setMaxAccess('readcreate') if mibBuilder.loadTexts: oamLoopbackPingLocation.setStatus('current') oam_loopback_ping_location_flag = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('ipAddress', 1), ('nsapPrefix', 2), ('fixed16byteValue', 3))).clone('ipAddress')).setMaxAccess('readcreate') if mibBuilder.loadTexts: oamLoopbackPingLocationFlag.setStatus('current') oam_loopback_ping_count = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 8), integer32().subtype(subtypeSpec=value_range_constraint(0, 2147483647)).clone(5)).setMaxAccess('readcreate') if mibBuilder.loadTexts: oamLoopbackPingCount.setStatus('current') oam_loopback_ping_timeout = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 9), integer32().subtype(subtypeSpec=value_range_constraint(0, 3600000)).clone(1000)).setUnits('milliseconds').setMaxAccess('readcreate') if mibBuilder.loadTexts: oamLoopbackPingTimeout.setStatus('current') oam_loopback_ping_delay = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 10), integer32().subtype(subtypeSpec=value_range_constraint(0, 3600000))).setUnits('milliseconds').setMaxAccess('readcreate') if mibBuilder.loadTexts: oamLoopbackPingDelay.setStatus('current') oam_loopback_ping_trap_on_completion = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 11), truth_value().clone('false')).setMaxAccess('readcreate') if mibBuilder.loadTexts: oamLoopbackPingTrapOnCompletion.setStatus('current') oam_loopback_ping_sent_cells = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 12), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: oamLoopbackPingSentCells.setStatus('current') oam_loopback_ping_received_cells = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 13), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: oamLoopbackPingReceivedCells.setStatus('current') oam_loopback_ping_min_rtt = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 14), integer32().subtype(subtypeSpec=value_range_constraint(0, 2147483647))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: oamLoopbackPingMinRtt.setStatus('current') oam_loopback_ping_avg_rtt = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 15), integer32().subtype(subtypeSpec=value_range_constraint(0, 2147483647))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: oamLoopbackPingAvgRtt.setStatus('current') oam_loopback_ping_max_rtt = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 16), integer32().subtype(subtypeSpec=value_range_constraint(0, 2147483647))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: oamLoopbackPingMaxRtt.setStatus('current') oam_loopback_ping_completed = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 17), truth_value()).setMaxAccess('readonly') if mibBuilder.loadTexts: oamLoopbackPingCompleted.setStatus('current') oam_loopback_ping_entry_owner = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 18), owner_string()).setMaxAccess('readcreate') if mibBuilder.loadTexts: oamLoopbackPingEntryOwner.setStatus('current') oam_loopback_ping_entry_status = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 19), row_status()).setMaxAccess('readcreate') if mibBuilder.loadTexts: oamLoopbackPingEntryStatus.setStatus('current') oam_loopback_ping_dir = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 20), cisco_oam_ping_dir()).setMaxAccess('readcreate') if mibBuilder.loadTexts: oamLoopbackPingDir.setStatus('current') oam_loopback_ping_oper_status = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 21), cisco_oam_ping_status()).setMaxAccess('readonly') if mibBuilder.loadTexts: oamLoopbackPingOperStatus.setStatus('current') oam_loopback_ping_exec_time = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 22), time_stamp()).setMaxAccess('readonly') if mibBuilder.loadTexts: oamLoopbackPingExecTime.setStatus('current') oam_loopback_ping_min_rttu_sec = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 23), integer32().subtype(subtypeSpec=value_range_constraint(0, 2147483647))).setUnits('microseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: oamLoopbackPingMinRttuSec.setStatus('current') oam_loopback_ping_avg_rttu_sec = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 24), integer32().subtype(subtypeSpec=value_range_constraint(0, 2147483647))).setUnits('microseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: oamLoopbackPingAvgRttuSec.setStatus('current') oam_loopback_ping_max_rttu_sec = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 1, 1, 25), integer32().subtype(subtypeSpec=value_range_constraint(0, 2147483647))).setUnits('microseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: oamLoopbackPingMaxRttuSec.setStatus('current') oam_loopback_seg_end_point_table = mib_table((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 2)) if mibBuilder.loadTexts: oamLoopbackSegEndPointTable.setStatus('current') oam_loopback_seg_end_point_entry = mib_table_row((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 2, 1)).setIndexNames((0, 'IF-MIB', 'ifIndex'), (0, 'CISCO-OAM-MIB', 'oamLoopSegVpi'), (0, 'CISCO-OAM-MIB', 'oamLoopSegVci')) if mibBuilder.loadTexts: oamLoopbackSegEndPointEntry.setStatus('current') oam_loop_seg_vpi = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 2, 1, 1), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 4095))) if mibBuilder.loadTexts: oamLoopSegVpi.setStatus('current') oam_loop_seg_vci = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 2, 1, 2), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 65535))) if mibBuilder.loadTexts: oamLoopSegVci.setStatus('current') oam_loop_seg_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 9, 10, 15, 1, 2, 1, 3), row_status()).setMaxAccess('readcreate') if mibBuilder.loadTexts: oamLoopSegRowStatus.setStatus('current') oam_loopback_ping_mib_trap_prefix = mib_identifier((1, 3, 6, 1, 4, 1, 9, 10, 15, 2)) oam_loopback_ping_mib_traps = mib_identifier((1, 3, 6, 1, 4, 1, 9, 10, 15, 2, 0)) oam_loopback_ping_completion_trap = notification_type((1, 3, 6, 1, 4, 1, 9, 10, 15, 2, 0, 1)).setObjects(('CISCO-OAM-MIB', 'oamLoopbackPingCompleted')) if mibBuilder.loadTexts: oamLoopbackPingCompletionTrap.setStatus('current') cisco_oam_ping_mib_conformance = mib_identifier((1, 3, 6, 1, 4, 1, 9, 10, 15, 3)) cisco_oam_ping_mib_compliances = mib_identifier((1, 3, 6, 1, 4, 1, 9, 10, 15, 3, 1)) cisco_oam_ping_mib_groups = mib_identifier((1, 3, 6, 1, 4, 1, 9, 10, 15, 3, 2)) cisco_oam_ping_mib_compliance = module_compliance((1, 3, 6, 1, 4, 1, 9, 10, 15, 3, 1, 1)).setObjects(('CISCO-OAM-MIB', 'ciscoOamPingMIBGroup')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cisco_oam_ping_mib_compliance = ciscoOamPingMIBCompliance.setStatus('deprecated') cisco_oam_ping_mib_compliance2 = module_compliance((1, 3, 6, 1, 4, 1, 9, 10, 15, 3, 1, 2)).setObjects(('CISCO-OAM-MIB', 'ciscoOamPing2MIBGroup'), ('CISCO-OAM-MIB', 'oamLoopbackNotificationsGroup'), ('CISCO-OAM-MIB', 'ciscoOamPingSegEndPointGroup')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cisco_oam_ping_mib_compliance2 = ciscoOamPingMIBCompliance2.setStatus('deprecated') cisco_oam_ping_mib_compliance3 = module_compliance((1, 3, 6, 1, 4, 1, 9, 10, 15, 3, 1, 3)).setObjects(('CISCO-OAM-MIB', 'ciscoOamPingMIBGroupRev3'), ('CISCO-OAM-MIB', 'oamLoopbackNotificationsGroup'), ('CISCO-OAM-MIB', 'ciscoOamPingSegEndPointGroup')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cisco_oam_ping_mib_compliance3 = ciscoOamPingMIBCompliance3.setStatus('current') cisco_oam_ping_mib_group = object_group((1, 3, 6, 1, 4, 1, 9, 10, 15, 3, 2, 1)).setObjects(('CISCO-OAM-MIB', 'oamLoopbackPingInterface'), ('CISCO-OAM-MIB', 'oamLoopbackPingVpi'), ('CISCO-OAM-MIB', 'oamLoopbackPingVci'), ('CISCO-OAM-MIB', 'oamLoopbackPingCount'), ('CISCO-OAM-MIB', 'oamLoopbackPingType'), ('CISCO-OAM-MIB', 'oamLoopbackPingLocation'), ('CISCO-OAM-MIB', 'oamLoopbackPingLocationFlag'), ('CISCO-OAM-MIB', 'oamLoopbackPingTimeout'), ('CISCO-OAM-MIB', 'oamLoopbackPingDelay'), ('CISCO-OAM-MIB', 'oamLoopbackPingTrapOnCompletion'), ('CISCO-OAM-MIB', 'oamLoopbackPingSentCells'), ('CISCO-OAM-MIB', 'oamLoopbackPingReceivedCells'), ('CISCO-OAM-MIB', 'oamLoopbackPingMinRtt'), ('CISCO-OAM-MIB', 'oamLoopbackPingAvgRtt'), ('CISCO-OAM-MIB', 'oamLoopbackPingMaxRtt'), ('CISCO-OAM-MIB', 'oamLoopbackPingCompleted'), ('CISCO-OAM-MIB', 'oamLoopbackPingEntryOwner'), ('CISCO-OAM-MIB', 'oamLoopbackPingEntryStatus')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cisco_oam_ping_mib_group = ciscoOamPingMIBGroup.setStatus('deprecated') cisco_oam_ping2_mib_group = object_group((1, 3, 6, 1, 4, 1, 9, 10, 15, 3, 2, 2)).setObjects(('CISCO-OAM-MIB', 'oamLoopbackPingInterface'), ('CISCO-OAM-MIB', 'oamLoopbackPingVpi'), ('CISCO-OAM-MIB', 'oamLoopbackPingVci'), ('CISCO-OAM-MIB', 'oamLoopbackPingCount'), ('CISCO-OAM-MIB', 'oamLoopbackPingType'), ('CISCO-OAM-MIB', 'oamLoopbackPingLocation'), ('CISCO-OAM-MIB', 'oamLoopbackPingLocationFlag'), ('CISCO-OAM-MIB', 'oamLoopbackPingTimeout'), ('CISCO-OAM-MIB', 'oamLoopbackPingDelay'), ('CISCO-OAM-MIB', 'oamLoopbackPingTrapOnCompletion'), ('CISCO-OAM-MIB', 'oamLoopbackPingSentCells'), ('CISCO-OAM-MIB', 'oamLoopbackPingReceivedCells'), ('CISCO-OAM-MIB', 'oamLoopbackPingMinRtt'), ('CISCO-OAM-MIB', 'oamLoopbackPingAvgRtt'), ('CISCO-OAM-MIB', 'oamLoopbackPingMaxRtt'), ('CISCO-OAM-MIB', 'oamLoopbackPingCompleted'), ('CISCO-OAM-MIB', 'oamLoopbackPingEntryOwner'), ('CISCO-OAM-MIB', 'oamLoopbackPingEntryStatus'), ('CISCO-OAM-MIB', 'oamLoopbackPingDir'), ('CISCO-OAM-MIB', 'oamLoopbackPingOperStatus'), ('CISCO-OAM-MIB', 'oamLoopbackPingExecTime')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cisco_oam_ping2_mib_group = ciscoOamPing2MIBGroup.setStatus('deprecated') cisco_oam_ping_seg_end_point_group = object_group((1, 3, 6, 1, 4, 1, 9, 10, 15, 3, 2, 3)).setObjects(('CISCO-OAM-MIB', 'oamLoopSegRowStatus')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cisco_oam_ping_seg_end_point_group = ciscoOamPingSegEndPointGroup.setStatus('current') oam_loopback_notifications_group = notification_group((1, 3, 6, 1, 4, 1, 9, 10, 15, 3, 2, 4)).setObjects(('CISCO-OAM-MIB', 'oamLoopbackPingCompletionTrap')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): oam_loopback_notifications_group = oamLoopbackNotificationsGroup.setStatus('current') cisco_oam_ping_mib_group_rev3 = object_group((1, 3, 6, 1, 4, 1, 9, 10, 15, 3, 2, 5)).setObjects(('CISCO-OAM-MIB', 'oamLoopbackPingInterface'), ('CISCO-OAM-MIB', 'oamLoopbackPingVpi'), ('CISCO-OAM-MIB', 'oamLoopbackPingVci'), ('CISCO-OAM-MIB', 'oamLoopbackPingCount'), ('CISCO-OAM-MIB', 'oamLoopbackPingType'), ('CISCO-OAM-MIB', 'oamLoopbackPingLocation'), ('CISCO-OAM-MIB', 'oamLoopbackPingLocationFlag'), ('CISCO-OAM-MIB', 'oamLoopbackPingTimeout'), ('CISCO-OAM-MIB', 'oamLoopbackPingDelay'), ('CISCO-OAM-MIB', 'oamLoopbackPingTrapOnCompletion'), ('CISCO-OAM-MIB', 'oamLoopbackPingSentCells'), ('CISCO-OAM-MIB', 'oamLoopbackPingReceivedCells'), ('CISCO-OAM-MIB', 'oamLoopbackPingMinRtt'), ('CISCO-OAM-MIB', 'oamLoopbackPingAvgRtt'), ('CISCO-OAM-MIB', 'oamLoopbackPingMaxRtt'), ('CISCO-OAM-MIB', 'oamLoopbackPingCompleted'), ('CISCO-OAM-MIB', 'oamLoopbackPingEntryOwner'), ('CISCO-OAM-MIB', 'oamLoopbackPingEntryStatus'), ('CISCO-OAM-MIB', 'oamLoopbackPingDir'), ('CISCO-OAM-MIB', 'oamLoopbackPingOperStatus'), ('CISCO-OAM-MIB', 'oamLoopbackPingExecTime'), ('CISCO-OAM-MIB', 'oamLoopbackPingAvgRttuSec'), ('CISCO-OAM-MIB', 'oamLoopbackPingMinRttuSec'), ('CISCO-OAM-MIB', 'oamLoopbackPingMaxRttuSec')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cisco_oam_ping_mib_group_rev3 = ciscoOamPingMIBGroupRev3.setStatus('current') mibBuilder.exportSymbols('CISCO-OAM-MIB', oamLoopbackPingEntryStatus=oamLoopbackPingEntryStatus, oamLoopbackSegEndPointEntry=oamLoopbackSegEndPointEntry, ciscoOamPingMIBCompliances=ciscoOamPingMIBCompliances, ciscoOamPingSegEndPointGroup=ciscoOamPingSegEndPointGroup, oamLoopbackPingExecTime=oamLoopbackPingExecTime, oamLoopbackPingInterface=oamLoopbackPingInterface, oamLoopbackPingMIBTrapPrefix=oamLoopbackPingMIBTrapPrefix, PYSNMP_MODULE_ID=ciscoOamPingMIB, oamLoopbackPingLocation=oamLoopbackPingLocation, oamLoopbackPingEntryOwner=oamLoopbackPingEntryOwner, oamLoopbackPingDelay=oamLoopbackPingDelay, oamLoopbackPingDir=oamLoopbackPingDir, oamLoopSegVci=oamLoopSegVci, ciscoOamPing2MIBGroup=ciscoOamPing2MIBGroup, ciscoOamPingMIB=ciscoOamPingMIB, oamLoopbackPingCompleted=oamLoopbackPingCompleted, oamLoopbackPingCompletionTrap=oamLoopbackPingCompletionTrap, CiscoOAMPingStatus=CiscoOAMPingStatus, oamLoopbackPingSentCells=oamLoopbackPingSentCells, oamLoopbackPingEntry=oamLoopbackPingEntry, oamLoopbackPingAvgRtt=oamLoopbackPingAvgRtt, oamLoopbackPingMinRttuSec=oamLoopbackPingMinRttuSec, oamLoopbackPingTimeout=oamLoopbackPingTimeout, oamLoopbackPingSerialNumber=oamLoopbackPingSerialNumber, oamLoopbackPingVci=oamLoopbackPingVci, ciscoOamPingMIBObjects=ciscoOamPingMIBObjects, oamLoopbackSegEndPointTable=oamLoopbackSegEndPointTable, ciscoOamPingMIBCompliance=ciscoOamPingMIBCompliance, ciscoOamPingMIBCompliance2=ciscoOamPingMIBCompliance2, oamLoopbackPingType=oamLoopbackPingType, ciscoOamPingMIBGroups=ciscoOamPingMIBGroups, ciscoOamPingMIBGroup=ciscoOamPingMIBGroup, oamLoopbackPingLocationFlag=oamLoopbackPingLocationFlag, oamLoopbackPingCount=oamLoopbackPingCount, CiscoOAMPingDir=CiscoOAMPingDir, oamLoopbackPingReceivedCells=oamLoopbackPingReceivedCells, ciscoOamPingMIBConformance=ciscoOamPingMIBConformance, oamLoopbackPingMinRtt=oamLoopbackPingMinRtt, ciscoOamPingMIBGroupRev3=ciscoOamPingMIBGroupRev3, oamLoopbackPingVpi=oamLoopbackPingVpi, ciscoOamPingMIBCompliance3=ciscoOamPingMIBCompliance3, oamLoopbackPingTrapOnCompletion=oamLoopbackPingTrapOnCompletion, oamLoopbackPingOperStatus=oamLoopbackPingOperStatus, oamLoopbackPingTable=oamLoopbackPingTable, oamLoopbackPingAvgRttuSec=oamLoopbackPingAvgRttuSec, oamLoopbackPingMaxRtt=oamLoopbackPingMaxRtt, oamLoopbackPingMIBTraps=oamLoopbackPingMIBTraps, oamLoopSegRowStatus=oamLoopSegRowStatus, oamLoopbackPingMaxRttuSec=oamLoopbackPingMaxRttuSec, oamLoopbackNotificationsGroup=oamLoopbackNotificationsGroup, oamLoopSegVpi=oamLoopSegVpi)
n=str(input("Enter the mail id")) le=len(n) st="" for i in range(le): if n[i]=='@': break else: st+=n[i] print(st)
n = str(input('Enter the mail id')) le = len(n) st = '' for i in range(le): if n[i] == '@': break else: st += n[i] print(st)
class Account: __accNumber = 0 __balance = 0 def __init__(self, accNumber, balance = 1000): self.setAccNumber(accNumber) # self.__accNumber = accNumber # the double underscore hides the info self.setBalance(balance) def getAccountNumber(self): return self.__accNumber def setAccNumber(self, accNumber): if len (accNumber) != 10 or not accNumber.isdigit(): # "1234567890" print("Invalid account number!") else: self.__accNumber = accNumber def getBalance(self): return self.__balance def setBalance(self, amount): try: if amount >= 0: self.__balance = amount else: raise Exception("Amount should be greater that zero or " "equal to zero") except Exception as e: print(e.args) def credit(self, amount): if amount > 0: self.__balance += amount else: print("Amount should be positive") def debit(self, amount): if self.__balance < amount: print("amount withdrawn exceeds the current balance") else: self.__balance -= amount def __str__(self): return "Account Number: {}, Balance: ".format(self.getAccountNumber(), self.getBalance()) myAccount = Account("123456") print(myAccount) print(myAccount.getAccountNumber()) print(myAccount) print(myAccount.getAccountNumber) print(myAccount.getBalance()) myAccount.setBalance(2000) print(myAccount.getBalance()) myAccount.credit(1000) print(myAccount.getBalance()) myAccount.debit(500) print(myAccount.getBalance()) myAccount.debit(4000) # Invalid account number! # Account Number: 0, Balance: # 0 # Account Number: 0, Balance: # <bound method Account.getAccountNumber of <__main__.Account object at 0x7fb347c3afd0>> # 1000 # 2000 # 3000 # 2500 # amount withdrawn exceeds the current balance myAccount.setBalance(-100) # Invalid account number! # Account Number: 0, Balance: # 0 # Account Number: 0, Balance: # <bound method Account.getAccountNumber of <__main__.Account object at 0x7f7901bc9fd0>> # 1000 # 2000 # 3000 # 2500 # amount withdrawn exceeds the current balance # ('Amount should be greater that zero or equal to zero',)
class Account: __acc_number = 0 __balance = 0 def __init__(self, accNumber, balance=1000): self.setAccNumber(accNumber) self.setBalance(balance) def get_account_number(self): return self.__accNumber def set_acc_number(self, accNumber): if len(accNumber) != 10 or not accNumber.isdigit(): print('Invalid account number!') else: self.__accNumber = accNumber def get_balance(self): return self.__balance def set_balance(self, amount): try: if amount >= 0: self.__balance = amount else: raise exception('Amount should be greater that zero or equal to zero') except Exception as e: print(e.args) def credit(self, amount): if amount > 0: self.__balance += amount else: print('Amount should be positive') def debit(self, amount): if self.__balance < amount: print('amount withdrawn exceeds the current balance') else: self.__balance -= amount def __str__(self): return 'Account Number: {}, Balance: '.format(self.getAccountNumber(), self.getBalance()) my_account = account('123456') print(myAccount) print(myAccount.getAccountNumber()) print(myAccount) print(myAccount.getAccountNumber) print(myAccount.getBalance()) myAccount.setBalance(2000) print(myAccount.getBalance()) myAccount.credit(1000) print(myAccount.getBalance()) myAccount.debit(500) print(myAccount.getBalance()) myAccount.debit(4000) myAccount.setBalance(-100)
# # PySNMP MIB module CABH-QOS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CABH-QOS-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:44:07 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:15) # OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ValueRangeConstraint, ConstraintsIntersection, ConstraintsUnion, ValueSizeConstraint, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ConstraintsIntersection", "ConstraintsUnion", "ValueSizeConstraint", "SingleValueConstraint") clabProjCableHome, = mibBuilder.importSymbols("CLAB-DEF-MIB", "clabProjCableHome") ifIndex, = mibBuilder.importSymbols("IF-MIB", "ifIndex") InetAddressType, InetAddress, InetPortNumber = mibBuilder.importSymbols("INET-ADDRESS-MIB", "InetAddressType", "InetAddress", "InetPortNumber") NotificationGroup, ObjectGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ObjectGroup", "ModuleCompliance") TimeTicks, ObjectIdentity, NotificationType, Bits, IpAddress, Gauge32, Counter64, MibScalar, MibTable, MibTableRow, MibTableColumn, MibIdentifier, Integer32, iso, Counter32, Unsigned32, ModuleIdentity = mibBuilder.importSymbols("SNMPv2-SMI", "TimeTicks", "ObjectIdentity", "NotificationType", "Bits", "IpAddress", "Gauge32", "Counter64", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "MibIdentifier", "Integer32", "iso", "Counter32", "Unsigned32", "ModuleIdentity") RowStatus, TextualConvention, TruthValue, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "RowStatus", "TextualConvention", "TruthValue", "DisplayString") cabhQosMib = ModuleIdentity((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6)) cabhQosMib.setRevisions(('2003-03-01 00:00',)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: cabhQosMib.setRevisionsDescriptions(('Initial version, published as RFC xxxx.',)) if mibBuilder.loadTexts: cabhQosMib.setLastUpdated('200303010000Z') if mibBuilder.loadTexts: cabhQosMib.setOrganization('CableLabs Broadband Access Department') if mibBuilder.loadTexts: cabhQosMib.setContactInfo('Kevin Luehrs Postal: Cable Television Laboratories, Inc. 400 Centennial Parkway Louisville, Colorado 80027-1266 U.S.A. Phone: +1 303-661-9100 Fax: +1 303-661-9199 E-mail: k.luehrs@cablelabs.com; mibs@cablelabs.com') if mibBuilder.loadTexts: cabhQosMib.setDescription('This MIB module supplies parameters for the configuration and monitoring of CableHome prioritized QoS capability.') cabhQosMibObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1)) cabhPriorityQosMibObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1)) cabhPriorityQosBase = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 1)) cabhPriorityQosBp = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2)) cabhPriorityQosPs = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 3)) cabhPriorityQosMasterTable = MibTable((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 1, 1), ) if mibBuilder.loadTexts: cabhPriorityQosMasterTable.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosMasterTable.setDescription('This table contains a list of mappings for Application IDs to Default CableHome Priorities.') cabhPriorityQosMasterEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 1, 1, 1), ).setIndexNames((0, "CABH-QOS-MIB", "cabhPriorityQosMasterApplicationId")) if mibBuilder.loadTexts: cabhPriorityQosMasterEntry.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosMasterEntry.setDescription('An entry for mapping Application IDs to Default CableHome Priorities.') cabhPriorityQosMasterApplicationId = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 1, 1, 1, 1), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))) if mibBuilder.loadTexts: cabhPriorityQosMasterApplicationId.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosMasterApplicationId.setDescription('The IANA well-known port number identifying an application.') cabhPriorityQosMasterDefaultCHPriority = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 1, 1, 1, 2), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 7))).setMaxAccess("readcreate") if mibBuilder.loadTexts: cabhPriorityQosMasterDefaultCHPriority.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosMasterDefaultCHPriority.setDescription('The Qos priority assigned to the application.') cabhPriorityQosMasterRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 1, 1, 1, 3), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: cabhPriorityQosMasterRowStatus.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosMasterRowStatus.setDescription("The Row Status interlock for creation and deletion of row entries. The PS MUST NOT allow the NMS to set RowStatus to notInService(2). The PS MUST assign a RowStatus of notReady(3) to any new row created without a valid value for both entries. The PS will prevent modification of this table's columns and return an inconsistentValue error if the NMS attempts to make such modifications while RowStatus is active(1).") cabhPriorityQosSetToFactory = MibScalar((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 1, 2), TruthValue()).setMaxAccess("readwrite") if mibBuilder.loadTexts: cabhPriorityQosSetToFactory.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosSetToFactory.setDescription('Reading this object alwyas returns false(2). When this object is set to true(1), the PS MUST clear all the entries in the cabhPriorityQosBpTable and cabhPriorityQosBpDestTable.') cabhPriorityQosBpTable = MibTable((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 1), ) if mibBuilder.loadTexts: cabhPriorityQosBpTable.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpTable.setDescription('This table contains the priorities for each of the discovered CableHome Host (BP) applications and related data.') cabhPriorityQosBpEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 1, 1), ).setIndexNames((0, "CABH-QOS-MIB", "cabhPriorityQosMasterApplicationId"), (0, "CABH-QOS-MIB", "cabhPriorityQosBpIpAddrType"), (0, "CABH-QOS-MIB", "cabhPriorityQosBpIpAddr")) if mibBuilder.loadTexts: cabhPriorityQosBpEntry.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpEntry.setDescription('List of all the discovered applications on a BP and their priorities identified by the PS.') cabhPriorityQosBpIpAddrType = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 1, 1, 1), InetAddressType()).setMaxAccess("readonly") if mibBuilder.loadTexts: cabhPriorityQosBpIpAddrType.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpIpAddrType.setDescription('The type of the IP address assigned to a particular BP element.') cabhPriorityQosBpIpAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 1, 1, 2), InetAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: cabhPriorityQosBpIpAddr.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpIpAddr.setDescription('The IP address assigned to a particular BP element.') cabhPriorityQosBpApplicationId = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 1, 1, 3), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: cabhPriorityQosBpApplicationId.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpApplicationId.setDescription('The IANA well-known port number assigned to a particular application implemented on the CableHome Host device in which this BP resides.') cabhPriorityQosBpDefaultCHPriority = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 1, 1, 4), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 7))).setMaxAccess("readonly") if mibBuilder.loadTexts: cabhPriorityQosBpDefaultCHPriority.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpDefaultCHPriority.setDescription('The priority assigned to a particular application implemented on CableHome Host device in which this BP resides. The PS populates this entry according to the Application Priority Master Table.') cabhPriorityQosBpIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 1, 1, 5), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: cabhPriorityQosBpIndex.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpIndex.setDescription("The unique identifier for a particular row in the BP Application Priority Table. This identifier is used as an index into the 'nested' Destination Priority Table.") cabhPriorityQosBpDestTable = MibTable((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 2), ) if mibBuilder.loadTexts: cabhPriorityQosBpDestTable.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpDestTable.setDescription('This table contains the priorities based on sessions established by a BP, identified by destination IP address and port number. It is indexed with a unique identifier for rows in the BP Application Priority Table (cabhPriorityQoSBpTable.') cabhPriorityQosBpDestEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 2, 1), ).setIndexNames((0, "CABH-QOS-MIB", "cabhPriorityQosBpIndex"), (0, "CABH-QOS-MIB", "cabhPriorityQosBpDestIndex")) if mibBuilder.loadTexts: cabhPriorityQosBpDestEntry.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpDestEntry.setDescription('List of Destination IP addresses and port numbers for an application to which special Qos priority is provisioned.') cabhPriorityQosBpDestIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 2, 1, 1), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))) if mibBuilder.loadTexts: cabhPriorityQosBpDestIndex.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpDestIndex.setDescription('The locally unique index into the Destination Priority Table.') cabhPriorityQosBpDestIpAddrType = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 2, 1, 2), InetAddressType()).setMaxAccess("readonly") if mibBuilder.loadTexts: cabhPriorityQosBpDestIpAddrType.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpDestIpAddrType.setDescription('The type of the Destination IP Address.') cabhPriorityQosBpDestIpAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 2, 1, 3), InetAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: cabhPriorityQosBpDestIpAddr.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpDestIpAddr.setDescription('The Destination IP address of the device to which an application-session is established by a BP and a special Qos priority is provisioned.') cabhPriorityQosBpDestPort = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 2, 1, 4), InetPortNumber()).setMaxAccess("readonly") if mibBuilder.loadTexts: cabhPriorityQosBpDestPort.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpDestPort.setDescription('The port number on a IP device to which an application-session is established by a BP and a special Qos priority is provisioned.') cabhPriorityQosBpDestIpPortPriority = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 2, 1, 5), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 7))).setMaxAccess("readonly") if mibBuilder.loadTexts: cabhPriorityQosBpDestIpPortPriority.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpDestIpPortPriority.setDescription('The Qos priority assigned to a particular application-session (identified by destination IP and Port) on a BP.') cabhPriorityQosPsIfAttribTable = MibTable((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 3, 1), ) if mibBuilder.loadTexts: cabhPriorityQosPsIfAttribTable.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosPsIfAttribTable.setDescription('This table contains the number of media access priorities and number of queues associated with each LAN interface in the Residential Gateway.') cabhPriorityQosPsIfAttribEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 3, 1, 1), ).setIndexNames((0, "IF-MIB", "ifIndex")) if mibBuilder.loadTexts: cabhPriorityQosPsIfAttribEntry.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosPsIfAttribEntry.setDescription('Number of media access priorities and number of queues for each LAN interface in the Residential Gateway. This table applies only to interfaces through which data flows.') cabhPriorityQosPsIfAttribIfNumPriorities = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 3, 1, 1, 1), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 8))).setMaxAccess("readonly") if mibBuilder.loadTexts: cabhPriorityQosPsIfAttribIfNumPriorities.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosPsIfAttribIfNumPriorities.setDescription('The number of media access priorities supported by this LAN interface.') cabhPriorityQosPsIfAttribIfNumQueues = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 3, 1, 1, 2), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 8))).setMaxAccess("readonly") if mibBuilder.loadTexts: cabhPriorityQosPsIfAttribIfNumQueues.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosPsIfAttribIfNumQueues.setDescription('The number of queues associated with this LAN interface.') cabhQosNotification = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 2)) cabhPriorityQosNotification = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 2, 1)) cabhQosConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 3)) cabhPriorityQosConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 3, 1)) cabhPriorityQosGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 3, 1, 1)) cabhPriorityQosCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 3, 1, 2)) cabhPriorityQosCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 3, 1, 2, 1)).setObjects(("CABH-QOS-MIB", "cabhPriorityQosGroup")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cabhPriorityQosCompliance = cabhPriorityQosCompliance.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosCompliance.setDescription('The compliance statement for devices that implement CableHome 1.1 PriorityQos capability.') cabhPriorityQosGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 3, 1, 1, 1)).setObjects(("CABH-QOS-MIB", "cabhPriorityQosMasterDefaultCHPriority"), ("CABH-QOS-MIB", "cabhPriorityQosMasterRowStatus"), ("CABH-QOS-MIB", "cabhPriorityQosSetToFactory"), ("CABH-QOS-MIB", "cabhPriorityQosBpIpAddrType"), ("CABH-QOS-MIB", "cabhPriorityQosBpIpAddr"), ("CABH-QOS-MIB", "cabhPriorityQosBpApplicationId"), ("CABH-QOS-MIB", "cabhPriorityQosBpDefaultCHPriority"), ("CABH-QOS-MIB", "cabhPriorityQosBpIndex"), ("CABH-QOS-MIB", "cabhPriorityQosBpDestIpAddrType"), ("CABH-QOS-MIB", "cabhPriorityQosBpDestIpAddr"), ("CABH-QOS-MIB", "cabhPriorityQosBpDestPort"), ("CABH-QOS-MIB", "cabhPriorityQosBpDestIpPortPriority"), ("CABH-QOS-MIB", "cabhPriorityQosPsIfAttribIfNumPriorities"), ("CABH-QOS-MIB", "cabhPriorityQosPsIfAttribIfNumQueues")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cabhPriorityQosGroup = cabhPriorityQosGroup.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosGroup.setDescription('Group of objects for CableHome Application Priority MIB.') mibBuilder.exportSymbols("CABH-QOS-MIB", cabhPriorityQosBpDestIpAddr=cabhPriorityQosBpDestIpAddr, cabhPriorityQosSetToFactory=cabhPriorityQosSetToFactory, cabhPriorityQosCompliances=cabhPriorityQosCompliances, cabhPriorityQosBpDestIpAddrType=cabhPriorityQosBpDestIpAddrType, cabhPriorityQosBpApplicationId=cabhPriorityQosBpApplicationId, cabhPriorityQosPsIfAttribEntry=cabhPriorityQosPsIfAttribEntry, cabhPriorityQosBpIpAddr=cabhPriorityQosBpIpAddr, cabhPriorityQosBpIpAddrType=cabhPriorityQosBpIpAddrType, cabhPriorityQosBp=cabhPriorityQosBp, cabhPriorityQosBase=cabhPriorityQosBase, cabhPriorityQosPs=cabhPriorityQosPs, cabhPriorityQosBpTable=cabhPriorityQosBpTable, cabhPriorityQosGroup=cabhPriorityQosGroup, cabhPriorityQosMasterRowStatus=cabhPriorityQosMasterRowStatus, cabhQosMib=cabhQosMib, cabhPriorityQosBpDestPort=cabhPriorityQosBpDestPort, cabhPriorityQosBpDefaultCHPriority=cabhPriorityQosBpDefaultCHPriority, cabhPriorityQosBpDestTable=cabhPriorityQosBpDestTable, cabhPriorityQosMasterApplicationId=cabhPriorityQosMasterApplicationId, cabhPriorityQosBpDestIndex=cabhPriorityQosBpDestIndex, cabhPriorityQosConformance=cabhPriorityQosConformance, cabhPriorityQosMasterDefaultCHPriority=cabhPriorityQosMasterDefaultCHPriority, cabhPriorityQosBpDestEntry=cabhPriorityQosBpDestEntry, cabhPriorityQosBpEntry=cabhPriorityQosBpEntry, cabhPriorityQosPsIfAttribIfNumQueues=cabhPriorityQosPsIfAttribIfNumQueues, cabhPriorityQosPsIfAttribIfNumPriorities=cabhPriorityQosPsIfAttribIfNumPriorities, cabhPriorityQosPsIfAttribTable=cabhPriorityQosPsIfAttribTable, cabhQosNotification=cabhQosNotification, cabhPriorityQosMasterEntry=cabhPriorityQosMasterEntry, cabhPriorityQosGroups=cabhPriorityQosGroups, PYSNMP_MODULE_ID=cabhQosMib, cabhQosMibObjects=cabhQosMibObjects, cabhQosConformance=cabhQosConformance, cabhPriorityQosMasterTable=cabhPriorityQosMasterTable, cabhPriorityQosBpDestIpPortPriority=cabhPriorityQosBpDestIpPortPriority, cabhPriorityQosBpIndex=cabhPriorityQosBpIndex, cabhPriorityQosMibObjects=cabhPriorityQosMibObjects, cabhPriorityQosNotification=cabhPriorityQosNotification, cabhPriorityQosCompliance=cabhPriorityQosCompliance)
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_intersection, constraints_union, value_size_constraint, single_value_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueRangeConstraint', 'ConstraintsIntersection', 'ConstraintsUnion', 'ValueSizeConstraint', 'SingleValueConstraint') (clab_proj_cable_home,) = mibBuilder.importSymbols('CLAB-DEF-MIB', 'clabProjCableHome') (if_index,) = mibBuilder.importSymbols('IF-MIB', 'ifIndex') (inet_address_type, inet_address, inet_port_number) = mibBuilder.importSymbols('INET-ADDRESS-MIB', 'InetAddressType', 'InetAddress', 'InetPortNumber') (notification_group, object_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ObjectGroup', 'ModuleCompliance') (time_ticks, object_identity, notification_type, bits, ip_address, gauge32, counter64, mib_scalar, mib_table, mib_table_row, mib_table_column, mib_identifier, integer32, iso, counter32, unsigned32, module_identity) = mibBuilder.importSymbols('SNMPv2-SMI', 'TimeTicks', 'ObjectIdentity', 'NotificationType', 'Bits', 'IpAddress', 'Gauge32', 'Counter64', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'MibIdentifier', 'Integer32', 'iso', 'Counter32', 'Unsigned32', 'ModuleIdentity') (row_status, textual_convention, truth_value, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'RowStatus', 'TextualConvention', 'TruthValue', 'DisplayString') cabh_qos_mib = module_identity((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6)) cabhQosMib.setRevisions(('2003-03-01 00:00',)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: cabhQosMib.setRevisionsDescriptions(('Initial version, published as RFC xxxx.',)) if mibBuilder.loadTexts: cabhQosMib.setLastUpdated('200303010000Z') if mibBuilder.loadTexts: cabhQosMib.setOrganization('CableLabs Broadband Access Department') if mibBuilder.loadTexts: cabhQosMib.setContactInfo('Kevin Luehrs Postal: Cable Television Laboratories, Inc. 400 Centennial Parkway Louisville, Colorado 80027-1266 U.S.A. Phone: +1 303-661-9100 Fax: +1 303-661-9199 E-mail: k.luehrs@cablelabs.com; mibs@cablelabs.com') if mibBuilder.loadTexts: cabhQosMib.setDescription('This MIB module supplies parameters for the configuration and monitoring of CableHome prioritized QoS capability.') cabh_qos_mib_objects = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1)) cabh_priority_qos_mib_objects = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1)) cabh_priority_qos_base = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 1)) cabh_priority_qos_bp = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2)) cabh_priority_qos_ps = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 3)) cabh_priority_qos_master_table = mib_table((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 1, 1)) if mibBuilder.loadTexts: cabhPriorityQosMasterTable.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosMasterTable.setDescription('This table contains a list of mappings for Application IDs to Default CableHome Priorities.') cabh_priority_qos_master_entry = mib_table_row((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 1, 1, 1)).setIndexNames((0, 'CABH-QOS-MIB', 'cabhPriorityQosMasterApplicationId')) if mibBuilder.loadTexts: cabhPriorityQosMasterEntry.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosMasterEntry.setDescription('An entry for mapping Application IDs to Default CableHome Priorities.') cabh_priority_qos_master_application_id = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 1, 1, 1, 1), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 65535))) if mibBuilder.loadTexts: cabhPriorityQosMasterApplicationId.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosMasterApplicationId.setDescription('The IANA well-known port number identifying an application.') cabh_priority_qos_master_default_ch_priority = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 1, 1, 1, 2), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 7))).setMaxAccess('readcreate') if mibBuilder.loadTexts: cabhPriorityQosMasterDefaultCHPriority.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosMasterDefaultCHPriority.setDescription('The Qos priority assigned to the application.') cabh_priority_qos_master_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 1, 1, 1, 3), row_status()).setMaxAccess('readcreate') if mibBuilder.loadTexts: cabhPriorityQosMasterRowStatus.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosMasterRowStatus.setDescription("The Row Status interlock for creation and deletion of row entries. The PS MUST NOT allow the NMS to set RowStatus to notInService(2). The PS MUST assign a RowStatus of notReady(3) to any new row created without a valid value for both entries. The PS will prevent modification of this table's columns and return an inconsistentValue error if the NMS attempts to make such modifications while RowStatus is active(1).") cabh_priority_qos_set_to_factory = mib_scalar((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 1, 2), truth_value()).setMaxAccess('readwrite') if mibBuilder.loadTexts: cabhPriorityQosSetToFactory.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosSetToFactory.setDescription('Reading this object alwyas returns false(2). When this object is set to true(1), the PS MUST clear all the entries in the cabhPriorityQosBpTable and cabhPriorityQosBpDestTable.') cabh_priority_qos_bp_table = mib_table((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 1)) if mibBuilder.loadTexts: cabhPriorityQosBpTable.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpTable.setDescription('This table contains the priorities for each of the discovered CableHome Host (BP) applications and related data.') cabh_priority_qos_bp_entry = mib_table_row((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 1, 1)).setIndexNames((0, 'CABH-QOS-MIB', 'cabhPriorityQosMasterApplicationId'), (0, 'CABH-QOS-MIB', 'cabhPriorityQosBpIpAddrType'), (0, 'CABH-QOS-MIB', 'cabhPriorityQosBpIpAddr')) if mibBuilder.loadTexts: cabhPriorityQosBpEntry.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpEntry.setDescription('List of all the discovered applications on a BP and their priorities identified by the PS.') cabh_priority_qos_bp_ip_addr_type = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 1, 1, 1), inet_address_type()).setMaxAccess('readonly') if mibBuilder.loadTexts: cabhPriorityQosBpIpAddrType.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpIpAddrType.setDescription('The type of the IP address assigned to a particular BP element.') cabh_priority_qos_bp_ip_addr = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 1, 1, 2), inet_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: cabhPriorityQosBpIpAddr.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpIpAddr.setDescription('The IP address assigned to a particular BP element.') cabh_priority_qos_bp_application_id = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 1, 1, 3), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: cabhPriorityQosBpApplicationId.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpApplicationId.setDescription('The IANA well-known port number assigned to a particular application implemented on the CableHome Host device in which this BP resides.') cabh_priority_qos_bp_default_ch_priority = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 1, 1, 4), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 7))).setMaxAccess('readonly') if mibBuilder.loadTexts: cabhPriorityQosBpDefaultCHPriority.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpDefaultCHPriority.setDescription('The priority assigned to a particular application implemented on CableHome Host device in which this BP resides. The PS populates this entry according to the Application Priority Master Table.') cabh_priority_qos_bp_index = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 1, 1, 5), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: cabhPriorityQosBpIndex.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpIndex.setDescription("The unique identifier for a particular row in the BP Application Priority Table. This identifier is used as an index into the 'nested' Destination Priority Table.") cabh_priority_qos_bp_dest_table = mib_table((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 2)) if mibBuilder.loadTexts: cabhPriorityQosBpDestTable.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpDestTable.setDescription('This table contains the priorities based on sessions established by a BP, identified by destination IP address and port number. It is indexed with a unique identifier for rows in the BP Application Priority Table (cabhPriorityQoSBpTable.') cabh_priority_qos_bp_dest_entry = mib_table_row((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 2, 1)).setIndexNames((0, 'CABH-QOS-MIB', 'cabhPriorityQosBpIndex'), (0, 'CABH-QOS-MIB', 'cabhPriorityQosBpDestIndex')) if mibBuilder.loadTexts: cabhPriorityQosBpDestEntry.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpDestEntry.setDescription('List of Destination IP addresses and port numbers for an application to which special Qos priority is provisioned.') cabh_priority_qos_bp_dest_index = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 2, 1, 1), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 65535))) if mibBuilder.loadTexts: cabhPriorityQosBpDestIndex.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpDestIndex.setDescription('The locally unique index into the Destination Priority Table.') cabh_priority_qos_bp_dest_ip_addr_type = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 2, 1, 2), inet_address_type()).setMaxAccess('readonly') if mibBuilder.loadTexts: cabhPriorityQosBpDestIpAddrType.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpDestIpAddrType.setDescription('The type of the Destination IP Address.') cabh_priority_qos_bp_dest_ip_addr = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 2, 1, 3), inet_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: cabhPriorityQosBpDestIpAddr.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpDestIpAddr.setDescription('The Destination IP address of the device to which an application-session is established by a BP and a special Qos priority is provisioned.') cabh_priority_qos_bp_dest_port = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 2, 1, 4), inet_port_number()).setMaxAccess('readonly') if mibBuilder.loadTexts: cabhPriorityQosBpDestPort.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpDestPort.setDescription('The port number on a IP device to which an application-session is established by a BP and a special Qos priority is provisioned.') cabh_priority_qos_bp_dest_ip_port_priority = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 2, 2, 1, 5), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 7))).setMaxAccess('readonly') if mibBuilder.loadTexts: cabhPriorityQosBpDestIpPortPriority.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosBpDestIpPortPriority.setDescription('The Qos priority assigned to a particular application-session (identified by destination IP and Port) on a BP.') cabh_priority_qos_ps_if_attrib_table = mib_table((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 3, 1)) if mibBuilder.loadTexts: cabhPriorityQosPsIfAttribTable.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosPsIfAttribTable.setDescription('This table contains the number of media access priorities and number of queues associated with each LAN interface in the Residential Gateway.') cabh_priority_qos_ps_if_attrib_entry = mib_table_row((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 3, 1, 1)).setIndexNames((0, 'IF-MIB', 'ifIndex')) if mibBuilder.loadTexts: cabhPriorityQosPsIfAttribEntry.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosPsIfAttribEntry.setDescription('Number of media access priorities and number of queues for each LAN interface in the Residential Gateway. This table applies only to interfaces through which data flows.') cabh_priority_qos_ps_if_attrib_if_num_priorities = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 3, 1, 1, 1), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 8))).setMaxAccess('readonly') if mibBuilder.loadTexts: cabhPriorityQosPsIfAttribIfNumPriorities.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosPsIfAttribIfNumPriorities.setDescription('The number of media access priorities supported by this LAN interface.') cabh_priority_qos_ps_if_attrib_if_num_queues = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 1, 1, 3, 1, 1, 2), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 8))).setMaxAccess('readonly') if mibBuilder.loadTexts: cabhPriorityQosPsIfAttribIfNumQueues.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosPsIfAttribIfNumQueues.setDescription('The number of queues associated with this LAN interface.') cabh_qos_notification = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 2)) cabh_priority_qos_notification = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 2, 1)) cabh_qos_conformance = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 3)) cabh_priority_qos_conformance = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 3, 1)) cabh_priority_qos_groups = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 3, 1, 1)) cabh_priority_qos_compliances = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 3, 1, 2)) cabh_priority_qos_compliance = module_compliance((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 3, 1, 2, 1)).setObjects(('CABH-QOS-MIB', 'cabhPriorityQosGroup')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cabh_priority_qos_compliance = cabhPriorityQosCompliance.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosCompliance.setDescription('The compliance statement for devices that implement CableHome 1.1 PriorityQos capability.') cabh_priority_qos_group = object_group((1, 3, 6, 1, 4, 1, 4491, 2, 4, 6, 3, 1, 1, 1)).setObjects(('CABH-QOS-MIB', 'cabhPriorityQosMasterDefaultCHPriority'), ('CABH-QOS-MIB', 'cabhPriorityQosMasterRowStatus'), ('CABH-QOS-MIB', 'cabhPriorityQosSetToFactory'), ('CABH-QOS-MIB', 'cabhPriorityQosBpIpAddrType'), ('CABH-QOS-MIB', 'cabhPriorityQosBpIpAddr'), ('CABH-QOS-MIB', 'cabhPriorityQosBpApplicationId'), ('CABH-QOS-MIB', 'cabhPriorityQosBpDefaultCHPriority'), ('CABH-QOS-MIB', 'cabhPriorityQosBpIndex'), ('CABH-QOS-MIB', 'cabhPriorityQosBpDestIpAddrType'), ('CABH-QOS-MIB', 'cabhPriorityQosBpDestIpAddr'), ('CABH-QOS-MIB', 'cabhPriorityQosBpDestPort'), ('CABH-QOS-MIB', 'cabhPriorityQosBpDestIpPortPriority'), ('CABH-QOS-MIB', 'cabhPriorityQosPsIfAttribIfNumPriorities'), ('CABH-QOS-MIB', 'cabhPriorityQosPsIfAttribIfNumQueues')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cabh_priority_qos_group = cabhPriorityQosGroup.setStatus('current') if mibBuilder.loadTexts: cabhPriorityQosGroup.setDescription('Group of objects for CableHome Application Priority MIB.') mibBuilder.exportSymbols('CABH-QOS-MIB', cabhPriorityQosBpDestIpAddr=cabhPriorityQosBpDestIpAddr, cabhPriorityQosSetToFactory=cabhPriorityQosSetToFactory, cabhPriorityQosCompliances=cabhPriorityQosCompliances, cabhPriorityQosBpDestIpAddrType=cabhPriorityQosBpDestIpAddrType, cabhPriorityQosBpApplicationId=cabhPriorityQosBpApplicationId, cabhPriorityQosPsIfAttribEntry=cabhPriorityQosPsIfAttribEntry, cabhPriorityQosBpIpAddr=cabhPriorityQosBpIpAddr, cabhPriorityQosBpIpAddrType=cabhPriorityQosBpIpAddrType, cabhPriorityQosBp=cabhPriorityQosBp, cabhPriorityQosBase=cabhPriorityQosBase, cabhPriorityQosPs=cabhPriorityQosPs, cabhPriorityQosBpTable=cabhPriorityQosBpTable, cabhPriorityQosGroup=cabhPriorityQosGroup, cabhPriorityQosMasterRowStatus=cabhPriorityQosMasterRowStatus, cabhQosMib=cabhQosMib, cabhPriorityQosBpDestPort=cabhPriorityQosBpDestPort, cabhPriorityQosBpDefaultCHPriority=cabhPriorityQosBpDefaultCHPriority, cabhPriorityQosBpDestTable=cabhPriorityQosBpDestTable, cabhPriorityQosMasterApplicationId=cabhPriorityQosMasterApplicationId, cabhPriorityQosBpDestIndex=cabhPriorityQosBpDestIndex, cabhPriorityQosConformance=cabhPriorityQosConformance, cabhPriorityQosMasterDefaultCHPriority=cabhPriorityQosMasterDefaultCHPriority, cabhPriorityQosBpDestEntry=cabhPriorityQosBpDestEntry, cabhPriorityQosBpEntry=cabhPriorityQosBpEntry, cabhPriorityQosPsIfAttribIfNumQueues=cabhPriorityQosPsIfAttribIfNumQueues, cabhPriorityQosPsIfAttribIfNumPriorities=cabhPriorityQosPsIfAttribIfNumPriorities, cabhPriorityQosPsIfAttribTable=cabhPriorityQosPsIfAttribTable, cabhQosNotification=cabhQosNotification, cabhPriorityQosMasterEntry=cabhPriorityQosMasterEntry, cabhPriorityQosGroups=cabhPriorityQosGroups, PYSNMP_MODULE_ID=cabhQosMib, cabhQosMibObjects=cabhQosMibObjects, cabhQosConformance=cabhQosConformance, cabhPriorityQosMasterTable=cabhPriorityQosMasterTable, cabhPriorityQosBpDestIpPortPriority=cabhPriorityQosBpDestIpPortPriority, cabhPriorityQosBpIndex=cabhPriorityQosBpIndex, cabhPriorityQosMibObjects=cabhPriorityQosMibObjects, cabhPriorityQosNotification=cabhPriorityQosNotification, cabhPriorityQosCompliance=cabhPriorityQosCompliance)
#1->groundBlock groundBlock=(48,0,16,16) #2->supriseBlock supriseBlock=(96,16,16,16) #3->floatingBlock floatingBlock=(0,0,16,16) #4->obstacleBlock obstacleBlock=(80,0,16,16) #5->pipes pipes=(256,96,32,32)
ground_block = (48, 0, 16, 16) suprise_block = (96, 16, 16, 16) floating_block = (0, 0, 16, 16) obstacle_block = (80, 0, 16, 16) pipes = (256, 96, 32, 32)
letter ='''Dear <|NAME|> Greetings from VITian student. I am verry happy to tell you about your selection in our club You are selecteed Have a great day aheas! Thanks and regards. Bill Date: <|DATE|> ''' name = input("Enter Your Name\n") date = input("Enter Date\n") letter=letter.replace("<|NAME|>", name) letter=letter.replace("<|DATE|>", date) print(letter)
letter = 'Dear <|NAME|>\nGreetings from VITian student. I am verry happy to tell you about your selection in our club\nYou are selecteed\nHave a great day aheas!\nThanks and regards.\nBill\nDate: <|DATE|>\n' name = input('Enter Your Name\n') date = input('Enter Date\n') letter = letter.replace('<|NAME|>', name) letter = letter.replace('<|DATE|>', date) print(letter)
def main() -> None: N = int(input()) A = list(map(int, input().split())) assert 1 <= N <= 100 assert len(A) == N assert 2 <= A[0] assert A[-1] <= 10**18 for i in range(1, N): assert A[i - 1] < A[i] if __name__ == '__main__': main()
def main() -> None: n = int(input()) a = list(map(int, input().split())) assert 1 <= N <= 100 assert len(A) == N assert 2 <= A[0] assert A[-1] <= 10 ** 18 for i in range(1, N): assert A[i - 1] < A[i] if __name__ == '__main__': main()
def request_resolver(func): def _wrapped_view(request, *args, **kwargs): if 'dev' in request.path: kwargs['report_type'] = 'dummy' return func(request, *args, **kwargs) else: kwargs['report_type'] = 'status' return func(request, *args, **kwargs) return _wrapped_view
def request_resolver(func): def _wrapped_view(request, *args, **kwargs): if 'dev' in request.path: kwargs['report_type'] = 'dummy' return func(request, *args, **kwargs) else: kwargs['report_type'] = 'status' return func(request, *args, **kwargs) return _wrapped_view
def return_value(status, message, data=None, status_code=200): return_object = dict() return_object['status'] = status return_object['message'] = message if data: return_object['data'] = data return return_object, status_code
def return_value(status, message, data=None, status_code=200): return_object = dict() return_object['status'] = status return_object['message'] = message if data: return_object['data'] = data return (return_object, status_code)
class TxtFile: def read_file(self,PATH_FILE): fd = open(PATH_FILE, mode='r') data = fd.read() fd.close() return data
class Txtfile: def read_file(self, PATH_FILE): fd = open(PATH_FILE, mode='r') data = fd.read() fd.close() return data
a=8 b=28 i=0 while(b>=0): b=b-a i=i+1 b=b+a print(b,i)
a = 8 b = 28 i = 0 while b >= 0: b = b - a i = i + 1 b = b + a print(b, i)
words = input().split(", ") input_string = input() list_new = [i for i in words if i in input_string] print(list_new)
words = input().split(', ') input_string = input() list_new = [i for i in words if i in input_string] print(list_new)
with open('input', 'r') as raw: i = sorted(raw.read().strip().split('\n')) guard = None sleeping = False start = None change = False guards = {} for line in i: minute = int(line[15:17]) if line[19] == 'f': sleeping = True start = minute elif line[19] == 'w': sleeping = False change = True else: if sleeping: sleeping = False change = True guard = line[26:].split(' ')[0] if change: sleeptime = minute - start try: guards[guard][0] += sleeptime except KeyError: guards[guard] = [sleeptime, {}] for i in range(start, minute): try: guards[guard][1][i] += 1 except KeyError: guards[guard][1][i] = 1 change = False guard = sorted(((guards[x][0],x) for x in guards))[-1][1] sleep = guards[guard][1] hour = list(zip(*sorted(zip(sleep.values(), sleep.keys()))))[1][-1] print(int(guard)*hour)
with open('input', 'r') as raw: i = sorted(raw.read().strip().split('\n')) guard = None sleeping = False start = None change = False guards = {} for line in i: minute = int(line[15:17]) if line[19] == 'f': sleeping = True start = minute elif line[19] == 'w': sleeping = False change = True else: if sleeping: sleeping = False change = True guard = line[26:].split(' ')[0] if change: sleeptime = minute - start try: guards[guard][0] += sleeptime except KeyError: guards[guard] = [sleeptime, {}] for i in range(start, minute): try: guards[guard][1][i] += 1 except KeyError: guards[guard][1][i] = 1 change = False guard = sorted(((guards[x][0], x) for x in guards))[-1][1] sleep = guards[guard][1] hour = list(zip(*sorted(zip(sleep.values(), sleep.keys()))))[1][-1] print(int(guard) * hour)
bind = "0.0.0.0:8000" workers = 10 pythonpath = "/home/box/web/ask" errorlog = "/home/box/web/etc/ask-error.log" loglevel = "debug"
bind = '0.0.0.0:8000' workers = 10 pythonpath = '/home/box/web/ask' errorlog = '/home/box/web/etc/ask-error.log' loglevel = 'debug'
# Link to the problem: https://www.hackerrank.com/challenges/common-child/problem def commonChild(s1, s2, n): prev_lcs = [0]*(n+1) curr_lcs = [0]*(n+1) for c1 in s1: curr_lcs, prev_lcs = prev_lcs, curr_lcs for i, c2 in enumerate(s2, 1): curr_lcs[i] = ( 1 + prev_lcs[i-1] if c1 == c2 else max(prev_lcs[i], curr_lcs[i-1]) ) return curr_lcs[-1] s1 = input().strip() s2 = input().strip() n = len(s1) result = commonChild(s1, s2, n) print(result)
def common_child(s1, s2, n): prev_lcs = [0] * (n + 1) curr_lcs = [0] * (n + 1) for c1 in s1: (curr_lcs, prev_lcs) = (prev_lcs, curr_lcs) for (i, c2) in enumerate(s2, 1): curr_lcs[i] = 1 + prev_lcs[i - 1] if c1 == c2 else max(prev_lcs[i], curr_lcs[i - 1]) return curr_lcs[-1] s1 = input().strip() s2 = input().strip() n = len(s1) result = common_child(s1, s2, n) print(result)
class Entry: def __init__(self): self.image_path = "" self.image_small = "" self.image_full = "" self.source = "" self.tags = [] self.score = -1 self.headers = {} self.title = None def as_dict(self): return {'path': self.image_path, 'url': self.image_full, 'source': self.source, 'tags': self.tags, 'score': self.score, 'headers': self.headers, 'title' : self.title } def tags_as_string(self) -> str: tags = "" for tag in self.tags: tags = tags + tag + "\n" return tags
class Entry: def __init__(self): self.image_path = '' self.image_small = '' self.image_full = '' self.source = '' self.tags = [] self.score = -1 self.headers = {} self.title = None def as_dict(self): return {'path': self.image_path, 'url': self.image_full, 'source': self.source, 'tags': self.tags, 'score': self.score, 'headers': self.headers, 'title': self.title} def tags_as_string(self) -> str: tags = '' for tag in self.tags: tags = tags + tag + '\n' return tags
def mergeIntervals(arr): new = list() arr.sort(key=lambda x:x[0]) for i in range(0, len(arr)): if not new or new[-1][1] < arr[i][0]: new.append(arr[i]) else: new[-1][1] = max(new[-1][1], arr[i][1]) return new arr = [[2,3],[4,5],[6,7],[8,9],[1,10]] new = mergeIntervals(arr) print(new)
def merge_intervals(arr): new = list() arr.sort(key=lambda x: x[0]) for i in range(0, len(arr)): if not new or new[-1][1] < arr[i][0]: new.append(arr[i]) else: new[-1][1] = max(new[-1][1], arr[i][1]) return new arr = [[2, 3], [4, 5], [6, 7], [8, 9], [1, 10]] new = merge_intervals(arr) print(new)
class Solution: def combinationSum2(self, candidates: List[int], target: int) -> List[List[int]]: assert isinstance(candidates, list) and isinstance(target, int) if not candidates: return def dfs(l,r,target,rst): if r+1<l or target < 0: return if target == 0: return rsts.append(rst) for i in range(l,r+1,1): if candidates[i] > target: break if i==l or candidates[i] != candidates[i-1]: dfs(i+1,r,target-candidates[i],rst+[candidates[i]]) return rsts = [] candidates.sort() dfs(0,len(candidates)-1,target,[]) return rsts
class Solution: def combination_sum2(self, candidates: List[int], target: int) -> List[List[int]]: assert isinstance(candidates, list) and isinstance(target, int) if not candidates: return def dfs(l, r, target, rst): if r + 1 < l or target < 0: return if target == 0: return rsts.append(rst) for i in range(l, r + 1, 1): if candidates[i] > target: break if i == l or candidates[i] != candidates[i - 1]: dfs(i + 1, r, target - candidates[i], rst + [candidates[i]]) return rsts = [] candidates.sort() dfs(0, len(candidates) - 1, target, []) return rsts
class Solution: def subsets(self, nums: List[int]) -> List[List[int]]: ans = [] for i in range(2**len(nums)): bitmask = bin(i)[2:] bitmask = '0'*(len(nums)-len(bitmask)) + bitmask ans.append([nums[j] for j in range(len(nums)) if bitmask[j] == '1']) return ans
class Solution: def subsets(self, nums: List[int]) -> List[List[int]]: ans = [] for i in range(2 ** len(nums)): bitmask = bin(i)[2:] bitmask = '0' * (len(nums) - len(bitmask)) + bitmask ans.append([nums[j] for j in range(len(nums)) if bitmask[j] == '1']) return ans
ACTIVATED_TEXT = 'ACTIVATED' ACTIVATION_DAYS = 7 REMEMBER_ME_DAYS = 30 LOGIN_REDIRECT_URL = 'home' DEFAULT_AVATAR_URL = 'files/no_image/avatar.jpg'
activated_text = 'ACTIVATED' activation_days = 7 remember_me_days = 30 login_redirect_url = 'home' default_avatar_url = 'files/no_image/avatar.jpg'
list = ['gilbert', 'cuerbo', 'defante', 'exam'] # for loop for name in list: print(f' - { name }') for i in range(0, 5): print(f' * { i }') # while loop index = 0 while index < len(list): print(f' # {list[index]}') index = index + 1
list = ['gilbert', 'cuerbo', 'defante', 'exam'] for name in list: print(f' - {name}') for i in range(0, 5): print(f' * {i}') index = 0 while index < len(list): print(f' # {list[index]}') index = index + 1
class BlastLine(object): __slots__ = ('query', 'subject', 'pctid', 'hitlen', 'nmismatch', 'ngaps', \ 'qstart', 'qstop', 'sstart', 'sstop', 'eval', 'score') def __init__(self, sline): args = sline.split("\t") self.query =args[0] self.subject = args[1] self.pctid =float(args[2]) self.hitlen =int(args[3]) self.nmismatch =int(args[4]) self.ngaps =int(args[5]) self.qstart =int(args[6]) self.qstop =int(args[7]) self.sstart =int(args[8]) self.sstop =int(args[9]) self.eval =float(args[10]) self.score =float(args[11]) def __repr__(self): return "BLine('%s' to '%s', eval=%.3f, score=%.1f)" % (self.query, self.subject, self.eval, self.score) def to_blast_line(self): #def g(attr): # return getattr(self, attr) return "\t".join(map(str, (getattr(self, attr) for attr in BlastLine.__slots__))) #return "\t".join(map(str, map(g, BlastLine.__slots__)))
class Blastline(object): __slots__ = ('query', 'subject', 'pctid', 'hitlen', 'nmismatch', 'ngaps', 'qstart', 'qstop', 'sstart', 'sstop', 'eval', 'score') def __init__(self, sline): args = sline.split('\t') self.query = args[0] self.subject = args[1] self.pctid = float(args[2]) self.hitlen = int(args[3]) self.nmismatch = int(args[4]) self.ngaps = int(args[5]) self.qstart = int(args[6]) self.qstop = int(args[7]) self.sstart = int(args[8]) self.sstop = int(args[9]) self.eval = float(args[10]) self.score = float(args[11]) def __repr__(self): return "BLine('%s' to '%s', eval=%.3f, score=%.1f)" % (self.query, self.subject, self.eval, self.score) def to_blast_line(self): return '\t'.join(map(str, (getattr(self, attr) for attr in BlastLine.__slots__)))
class hosp_features(): def __init__(self): self.P_GOLD = '#FFD700' self.P_ORANGE = "#F08000" self.P_BLU = "#0000FF" self.P_DARK_BLU = "#000080" self.P_GREEN = "#66ff99" self.P_DARK_GREEN = "#026b2c" self.P_FUCHSIA = "#FF00FF" self.P_PURPLE = "#cf03fc" self.P_PINK = "#FFB6C1" self.P_DARK_PINK= "#FF69B4" self.P_BROWN = "#A0522D" self.P_BROWN_DARK = "#8B4513" self.P_CYAN = "#7dbfc7" self.P_DARK_CYAN = "#79a3b6" self.P_LAVANDER = "#E6E6FA" self.P_DARK_LAVANDER = "#D8BFD8" self.P_NAVAJO= "#FFDEAD" self.P_DARK_NAVAJO = "#F4A460" self.P_GRAY = "#708090" self.P_DARK_GREY = "#2F4F4F" self.P_SALMON = "#FA8072" self.P_DARK_SALMON = "#E9967A" self.P_SKY_BLUE = "#ADD8E6" self.P_DARK_SKY_BLUE= "#00BFFF" self.P_LIGHT_GREEN = "#90EE90" self.P_DARK_LIGHT_GREEN = "#7FFF00" self.P_PAPAYA_YELLOW = "#FAFAD2" self.P_DARK_PAPAYA_YELLOW = "#FFEFD5" self.P_RED_LIGHT = "#DC143C" self.P_RED_LIGHT_DARK = "#B22222" self.P_RED = "#FF0000" self.P_DARK_RED = "#8B0000" self.HOSP_PRIORITIES = {1: self.P_GOLD, 2: self.P_ORANGE ,3: self.P_BLU, 4: self.P_DARK_BLU , 5: self.P_GREEN, 6: self.P_DARK_GREEN, 7: self.P_FUCHSIA, 8: self.P_PURPLE, 9: self.P_PINK, 10: self.P_DARK_PINK ,11: self.P_BROWN, 12: self.P_BROWN_DARK , 13: self.P_CYAN, 14: self.P_DARK_CYAN, 15: self.P_LAVANDER, 16: self.P_DARK_LAVANDER, 17: self.P_NAVAJO, 18: self.P_DARK_NAVAJO ,19: self.P_GRAY, 20: self.P_DARK_GREY , 21: self.P_SALMON, 22: self.P_DARK_SALMON, 23: self.P_SKY_BLUE, 24: self.P_DARK_SKY_BLUE, 25: self.P_LIGHT_GREEN, 26: self.P_DARK_LIGHT_GREEN ,27: self.P_PAPAYA_YELLOW, 28: self.P_DARK_PAPAYA_YELLOW , 29: self.P_RED_LIGHT, 30: self.P_RED_LIGHT_DARK} self.PRIORITY_NUM = len(self.HOSP_PRIORITIES) def get_color_name(self, color): if (color==self.P_GOLD): color_name = "gold" elif (color==self.P_ORANGE): color_name = "orange" elif (color == self.P_BLU): color_name = "blu" elif (color == self.P_DARK_BLU): color_name = "dark_blu" elif (color == self.P_GREEN): color_name = "green" elif (color == self.P_DARK_GREEN): color_name = "dark_green" elif (color == self.P_FUCHSIA): color_name = "fuchsia" elif (color==self.P_PURPLE): color_name = "purple" elif (color == self.P_PINK): color_name = "pink" elif (color==self.P_DARK_PINK): color_name = "dark_pink" elif (color == self.P_BROWN): color_name = "brown" elif (color == self.P_BROWN_DARK): color_name = "brown_dark" elif (color == self.P_CYAN): color_name = "cyan" elif (color == self.P_DARK_CYAN): color_name = "dark_cyan" elif (color == self.P_LAVANDER): color_name = "lavander" elif (color == self.P_DARK_LAVANDER): color_name = "dark_lavander" elif (color == P_RED): color_name = "red" else: color_name = None return color_name '''def get_color_id(self, color): color_id = list(self.HOSP_PRIORITIES.keys())[list(self.HOSP_PRIORITIES.values()).index(color)] return color_id''' def get_color_id(self, color): # print("GUARDA QUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA: ", color) if (color == self.P_GOLD): color_id = 1 elif (color == self.P_ORANGE): color_id = 2 elif (color == self.P_BLU): color_id = 3 elif (color == self.P_DARK_BLU): color_id = 4 elif (color == self.P_GREEN): color_id = 5 elif (color == self.P_DARK_GREEN): color_id = 6 elif (color == self.P_FUCHSIA): color_id = 7 elif (color == self.P_PURPLE): color_id = 8 elif (color == self.P_PINK): color_id = 9 elif (color == self.P_DARK_PINK): color_id = 10 elif (color == self.P_BROWN): color_id = 11 elif (color == self.P_BROWN_DARK): color_id = 12 elif (color == self.P_CYAN): color_id = 13 elif (color == self.P_DARK_CYAN): color_id = 14 elif (color == self.P_LAVANDER): color_id = 15 elif (color == self.P_DARK_LAVANDER): color_id = 16 else: color_id = 0 return color_id
class Hosp_Features: def __init__(self): self.P_GOLD = '#FFD700' self.P_ORANGE = '#F08000' self.P_BLU = '#0000FF' self.P_DARK_BLU = '#000080' self.P_GREEN = '#66ff99' self.P_DARK_GREEN = '#026b2c' self.P_FUCHSIA = '#FF00FF' self.P_PURPLE = '#cf03fc' self.P_PINK = '#FFB6C1' self.P_DARK_PINK = '#FF69B4' self.P_BROWN = '#A0522D' self.P_BROWN_DARK = '#8B4513' self.P_CYAN = '#7dbfc7' self.P_DARK_CYAN = '#79a3b6' self.P_LAVANDER = '#E6E6FA' self.P_DARK_LAVANDER = '#D8BFD8' self.P_NAVAJO = '#FFDEAD' self.P_DARK_NAVAJO = '#F4A460' self.P_GRAY = '#708090' self.P_DARK_GREY = '#2F4F4F' self.P_SALMON = '#FA8072' self.P_DARK_SALMON = '#E9967A' self.P_SKY_BLUE = '#ADD8E6' self.P_DARK_SKY_BLUE = '#00BFFF' self.P_LIGHT_GREEN = '#90EE90' self.P_DARK_LIGHT_GREEN = '#7FFF00' self.P_PAPAYA_YELLOW = '#FAFAD2' self.P_DARK_PAPAYA_YELLOW = '#FFEFD5' self.P_RED_LIGHT = '#DC143C' self.P_RED_LIGHT_DARK = '#B22222' self.P_RED = '#FF0000' self.P_DARK_RED = '#8B0000' self.HOSP_PRIORITIES = {1: self.P_GOLD, 2: self.P_ORANGE, 3: self.P_BLU, 4: self.P_DARK_BLU, 5: self.P_GREEN, 6: self.P_DARK_GREEN, 7: self.P_FUCHSIA, 8: self.P_PURPLE, 9: self.P_PINK, 10: self.P_DARK_PINK, 11: self.P_BROWN, 12: self.P_BROWN_DARK, 13: self.P_CYAN, 14: self.P_DARK_CYAN, 15: self.P_LAVANDER, 16: self.P_DARK_LAVANDER, 17: self.P_NAVAJO, 18: self.P_DARK_NAVAJO, 19: self.P_GRAY, 20: self.P_DARK_GREY, 21: self.P_SALMON, 22: self.P_DARK_SALMON, 23: self.P_SKY_BLUE, 24: self.P_DARK_SKY_BLUE, 25: self.P_LIGHT_GREEN, 26: self.P_DARK_LIGHT_GREEN, 27: self.P_PAPAYA_YELLOW, 28: self.P_DARK_PAPAYA_YELLOW, 29: self.P_RED_LIGHT, 30: self.P_RED_LIGHT_DARK} self.PRIORITY_NUM = len(self.HOSP_PRIORITIES) def get_color_name(self, color): if color == self.P_GOLD: color_name = 'gold' elif color == self.P_ORANGE: color_name = 'orange' elif color == self.P_BLU: color_name = 'blu' elif color == self.P_DARK_BLU: color_name = 'dark_blu' elif color == self.P_GREEN: color_name = 'green' elif color == self.P_DARK_GREEN: color_name = 'dark_green' elif color == self.P_FUCHSIA: color_name = 'fuchsia' elif color == self.P_PURPLE: color_name = 'purple' elif color == self.P_PINK: color_name = 'pink' elif color == self.P_DARK_PINK: color_name = 'dark_pink' elif color == self.P_BROWN: color_name = 'brown' elif color == self.P_BROWN_DARK: color_name = 'brown_dark' elif color == self.P_CYAN: color_name = 'cyan' elif color == self.P_DARK_CYAN: color_name = 'dark_cyan' elif color == self.P_LAVANDER: color_name = 'lavander' elif color == self.P_DARK_LAVANDER: color_name = 'dark_lavander' elif color == P_RED: color_name = 'red' else: color_name = None return color_name 'def get_color_id(self, color):\n color_id = list(self.HOSP_PRIORITIES.keys())[list(self.HOSP_PRIORITIES.values()).index(color)]\n\n return color_id' def get_color_id(self, color): if color == self.P_GOLD: color_id = 1 elif color == self.P_ORANGE: color_id = 2 elif color == self.P_BLU: color_id = 3 elif color == self.P_DARK_BLU: color_id = 4 elif color == self.P_GREEN: color_id = 5 elif color == self.P_DARK_GREEN: color_id = 6 elif color == self.P_FUCHSIA: color_id = 7 elif color == self.P_PURPLE: color_id = 8 elif color == self.P_PINK: color_id = 9 elif color == self.P_DARK_PINK: color_id = 10 elif color == self.P_BROWN: color_id = 11 elif color == self.P_BROWN_DARK: color_id = 12 elif color == self.P_CYAN: color_id = 13 elif color == self.P_DARK_CYAN: color_id = 14 elif color == self.P_LAVANDER: color_id = 15 elif color == self.P_DARK_LAVANDER: color_id = 16 else: color_id = 0 return color_id
''' This problem was asked by Apple. Implement a queue using two stacks. Recall that a queue is a FIFO (first-in, first-out) data structure with the following methods: enqueue, which inserts an element into the queue, and dequeue, which removes it. ''' class FIFOQueue: def __init__(self): self.in_stack = [] self.out_stack = [] def enqueue(self, val): self.in_stack.append(val) def dequeue(self): if not self.in_stack and \ not self.out_stack: return None if not self.out_stack: while self.in_stack: self.out_stack.append(self.in_stack.pop()) return self.out_stack.pop() if __name__ == "__main__": data = [ [ [['e', 5], ['e', 6], ['e', 7], ['d'], ['e', 8], ['d'], ['d'], ['d'], ['d'], ['e', 2], ['e', 4], ['d']] ] ] for d in data: print ('init queue for', d[0]) q = FIFOQueue() for cmd in d[0]: if cmd[0]=='d': print('out', q.dequeue()) else: print('in', cmd[1]) q.enqueue(cmd[1])
""" This problem was asked by Apple. Implement a queue using two stacks. Recall that a queue is a FIFO (first-in, first-out) data structure with the following methods: enqueue, which inserts an element into the queue, and dequeue, which removes it. """ class Fifoqueue: def __init__(self): self.in_stack = [] self.out_stack = [] def enqueue(self, val): self.in_stack.append(val) def dequeue(self): if not self.in_stack and (not self.out_stack): return None if not self.out_stack: while self.in_stack: self.out_stack.append(self.in_stack.pop()) return self.out_stack.pop() if __name__ == '__main__': data = [[[['e', 5], ['e', 6], ['e', 7], ['d'], ['e', 8], ['d'], ['d'], ['d'], ['d'], ['e', 2], ['e', 4], ['d']]]] for d in data: print('init queue for', d[0]) q = fifo_queue() for cmd in d[0]: if cmd[0] == 'd': print('out', q.dequeue()) else: print('in', cmd[1]) q.enqueue(cmd[1])
class Fee(object): def __init__(self): self.default_fee = 10 self.fee_cushion = 1.2 def calculate_fee(self): return int(self.default_fee * self.fee_scale * self.load_scale) def set_fee_scale(self, tx): fee_base = float(tx['fee_base']) fee_ref = float(tx['fee_ref']) fee_scale = fee_base / fee_ref self.fee_scale = fee_scale def set_load_scale(self, tx): load_base = float(tx['load_base']) load_factor = float(tx['load_factor']) load_scale = load_factor / load_base self.load_scale = load_scale def set_initial_fee(self, tx_json): result = tx_json['result'] self.set_fee_scale(result) self.set_load_scale(result) return self.calculate_fee()
class Fee(object): def __init__(self): self.default_fee = 10 self.fee_cushion = 1.2 def calculate_fee(self): return int(self.default_fee * self.fee_scale * self.load_scale) def set_fee_scale(self, tx): fee_base = float(tx['fee_base']) fee_ref = float(tx['fee_ref']) fee_scale = fee_base / fee_ref self.fee_scale = fee_scale def set_load_scale(self, tx): load_base = float(tx['load_base']) load_factor = float(tx['load_factor']) load_scale = load_factor / load_base self.load_scale = load_scale def set_initial_fee(self, tx_json): result = tx_json['result'] self.set_fee_scale(result) self.set_load_scale(result) return self.calculate_fee()
def cls(): while(i<=15): print('\n') i=i+1
def cls(): while i <= 15: print('\n') i = i + 1
class DurationTrackingListener(object): ROBOT_LISTENER_API_VERSION = 3 # The following will measure the duration of each test. This listener will fail each test if they run beyond the maximum run time (max_seconds). def __init__(self, max_seconds=10): self.max_milliseconds = float(max_seconds) * 1000 def end_test(self, data, test): if test.status == 'PASS' and test.elapsedtime > self.max_milliseconds: test.status = 'FAIL' test.message = 'FAIL --> FATAL ERROR -- Individual test execution took too long.'
class Durationtrackinglistener(object): robot_listener_api_version = 3 def __init__(self, max_seconds=10): self.max_milliseconds = float(max_seconds) * 1000 def end_test(self, data, test): if test.status == 'PASS' and test.elapsedtime > self.max_milliseconds: test.status = 'FAIL' test.message = 'FAIL --> FATAL ERROR -- Individual test execution took too long.'
class Solution: def numSubarrayBoundedMax(self, nums: List[int], left: int, right: int) -> int: # pick each ele to be maximum ele # Then sliding windows res = 0 for ind,num in enumerate(nums): # num itself is in or not if left <= num <= right: res += 1 # sliding windows # p1, p2 in # in range 0~len(nums)-1 # nums(p1) < num # nums(p2) <= num p1, p2 = ind-1, ind+1 while p1 > -1 and nums[p1] < num: p1 -= 1 res += 1 while p2 < len(nums) and nums[p2] <= num: p2 += 1 res += 1 # Crossing num if p1+1 != ind and p2-1 != ind: res += (ind-p1-1) * (p2-ind-1) return res
class Solution: def num_subarray_bounded_max(self, nums: List[int], left: int, right: int) -> int: res = 0 for (ind, num) in enumerate(nums): if left <= num <= right: res += 1 (p1, p2) = (ind - 1, ind + 1) while p1 > -1 and nums[p1] < num: p1 -= 1 res += 1 while p2 < len(nums) and nums[p2] <= num: p2 += 1 res += 1 if p1 + 1 != ind and p2 - 1 != ind: res += (ind - p1 - 1) * (p2 - ind - 1) return res
class Simulation: def __init__(self, blocks): self._blocks = blocks self._finished = False def run(self): while not self._finished: self._step() def _step(self): visited = set() queue = [b for b in self._blocks if not b.inputs] nothing_changed = True while queue: block = queue.pop() if block in visited: continue outputs_before = [c.value for c in block.outputs] block.push() outputs_after = (c.value for c in block.outputs) nothing_changed &= all(x == y for x, y in zip(outputs_after, outputs_before)) queue.extend((k.block for c in block.outputs for k in c.connections)) visited.add(block) self._finished = nothing_changed
class Simulation: def __init__(self, blocks): self._blocks = blocks self._finished = False def run(self): while not self._finished: self._step() def _step(self): visited = set() queue = [b for b in self._blocks if not b.inputs] nothing_changed = True while queue: block = queue.pop() if block in visited: continue outputs_before = [c.value for c in block.outputs] block.push() outputs_after = (c.value for c in block.outputs) nothing_changed &= all((x == y for (x, y) in zip(outputs_after, outputs_before))) queue.extend((k.block for c in block.outputs for k in c.connections)) visited.add(block) self._finished = nothing_changed
def plus(arr): p, n, z = 0, 0, 0 for i in arr: if i>0: p+=1 elif i<0: n+=1 else: z+=1 print(format(p/len(arr), '.6f')) print(format(n/len(arr), '.6f')) print(format(z/len(arr), '.6f')) arr = list(map(int, input().rstrip().split())) plus(arr)
def plus(arr): (p, n, z) = (0, 0, 0) for i in arr: if i > 0: p += 1 elif i < 0: n += 1 else: z += 1 print(format(p / len(arr), '.6f')) print(format(n / len(arr), '.6f')) print(format(z / len(arr), '.6f')) arr = list(map(int, input().rstrip().split())) plus(arr)
# Mary McHale, 14th April 2018 # Project based on Iris Data, Working out the mean # https://docs.python.org/3/tutorial/floatingpoint.html?highlight=significant%20digits for reducing the number of decimal places in the mean f = open('data/iris.csv' , 'r') # This opens the file called iris.csv print("Means are below") print(" pl pw sl sw") # pl = short for Petal length # pw = short for Petal width # sl = short for Sepal length # sw = short for Sepal width c = 0 # sets the record counter to zero at beginning totpl = 0 totpw = 0 totsl = 0 totsw = 0 # total for each of the 4 header fields record = "" while c < 100000: record = f.readline() if record == "": #print("count = ",c) #this was a test to ensure that the total of c was in fact 150, otherwise the results of the mean could be wrong temp1 = format(totpl/c, ' .1f') temp2 = format(totpw/c, ' .1f') temp3 = format(totsl/c, ' .1f') temp4 = format(totsw/c, ' .1f') print (temp1, temp2, temp3, temp4) f.close() quit() # Working out the number of characters across each row to put the data into columns petallength = (record[0:3]) petalwidth = (record[4:7]) sepallength = (record[8:11]) sepalwidth = (record[12:15]) name = (record[16:30]) petallength = float(petallength) petalwidth = float(petalwidth) sepallength = float(sepallength) sepalwidth = float(sepalwidth) #float is a python function to change a string variable into a decimal number for adding purposes totpl = totpl + petallength totpw = totpw + petalwidth totsl = totsl + sepallength totsw = totsw + sepalwidth #print(petallength, petalwidth, sepallength, sepalwidth) record = "" c = c + 1
f = open('data/iris.csv', 'r') print('Means are below') print(' pl pw sl sw') c = 0 totpl = 0 totpw = 0 totsl = 0 totsw = 0 record = '' while c < 100000: record = f.readline() if record == '': temp1 = format(totpl / c, ' .1f') temp2 = format(totpw / c, ' .1f') temp3 = format(totsl / c, ' .1f') temp4 = format(totsw / c, ' .1f') print(temp1, temp2, temp3, temp4) f.close() quit() petallength = record[0:3] petalwidth = record[4:7] sepallength = record[8:11] sepalwidth = record[12:15] name = record[16:30] petallength = float(petallength) petalwidth = float(petalwidth) sepallength = float(sepallength) sepalwidth = float(sepalwidth) totpl = totpl + petallength totpw = totpw + petalwidth totsl = totsl + sepallength totsw = totsw + sepalwidth record = '' c = c + 1
numbers = [4,2,7,1,8,3,6] f = 0 x = int(input("Enter the number to be found out: ")) for i in range(len(numbers)): if (x==numbers[i]): print(" Successful search, the element is found at position", i) f = 1 break if(f==0): print("Oops! Search unsuccessful")
numbers = [4, 2, 7, 1, 8, 3, 6] f = 0 x = int(input('Enter the number to be found out: ')) for i in range(len(numbers)): if x == numbers[i]: print(' Successful search, the element is found at position', i) f = 1 break if f == 0: print('Oops! Search unsuccessful')
a_binary_string = "110000 1100110 1011111" binary_values = a_binary_string.split() ascii_string = "" for binary_value in binary_values: an_integer = int(binary_value, 2) ascii_character = chr(an_integer) ascii_string += ascii_character print(ascii_string)
a_binary_string = '110000 1100110 1011111' binary_values = a_binary_string.split() ascii_string = '' for binary_value in binary_values: an_integer = int(binary_value, 2) ascii_character = chr(an_integer) ascii_string += ascii_character print(ascii_string)
n= str(input('Qual seu nome completo?')).lower() print ('No seu nome tem Silva?','silva'in n) n1= str(input('Digite um numero:')) print ('Existe o numero 1?','1' in n1)
n = str(input('Qual seu nome completo?')).lower() print('No seu nome tem Silva?', 'silva' in n) n1 = str(input('Digite um numero:')) print('Existe o numero 1?', '1' in n1)
data = ( 'Qiao ', # 0x00 'Chou ', # 0x01 'Bei ', # 0x02 'Xuan ', # 0x03 'Wei ', # 0x04 'Ge ', # 0x05 'Qian ', # 0x06 'Wei ', # 0x07 'Yu ', # 0x08 'Yu ', # 0x09 'Bi ', # 0x0a 'Xuan ', # 0x0b 'Huan ', # 0x0c 'Min ', # 0x0d 'Bi ', # 0x0e 'Yi ', # 0x0f 'Mian ', # 0x10 'Yong ', # 0x11 'Kai ', # 0x12 'Dang ', # 0x13 'Yin ', # 0x14 'E ', # 0x15 'Chen ', # 0x16 'Mou ', # 0x17 'Ke ', # 0x18 'Ke ', # 0x19 'Yu ', # 0x1a 'Ai ', # 0x1b 'Qie ', # 0x1c 'Yan ', # 0x1d 'Nuo ', # 0x1e 'Gan ', # 0x1f 'Yun ', # 0x20 'Zong ', # 0x21 'Sai ', # 0x22 'Leng ', # 0x23 'Fen ', # 0x24 '[?] ', # 0x25 'Kui ', # 0x26 'Kui ', # 0x27 'Que ', # 0x28 'Gong ', # 0x29 'Yun ', # 0x2a 'Su ', # 0x2b 'Su ', # 0x2c 'Qi ', # 0x2d 'Yao ', # 0x2e 'Song ', # 0x2f 'Huang ', # 0x30 'Ji ', # 0x31 'Gu ', # 0x32 'Ju ', # 0x33 'Chuang ', # 0x34 'Ni ', # 0x35 'Xie ', # 0x36 'Kai ', # 0x37 'Zheng ', # 0x38 'Yong ', # 0x39 'Cao ', # 0x3a 'Sun ', # 0x3b 'Shen ', # 0x3c 'Bo ', # 0x3d 'Kai ', # 0x3e 'Yuan ', # 0x3f 'Xie ', # 0x40 'Hun ', # 0x41 'Yong ', # 0x42 'Yang ', # 0x43 'Li ', # 0x44 'Sao ', # 0x45 'Tao ', # 0x46 'Yin ', # 0x47 'Ci ', # 0x48 'Xu ', # 0x49 'Qian ', # 0x4a 'Tai ', # 0x4b 'Huang ', # 0x4c 'Yun ', # 0x4d 'Shen ', # 0x4e 'Ming ', # 0x4f '[?] ', # 0x50 'She ', # 0x51 'Cong ', # 0x52 'Piao ', # 0x53 'Mo ', # 0x54 'Mu ', # 0x55 'Guo ', # 0x56 'Chi ', # 0x57 'Can ', # 0x58 'Can ', # 0x59 'Can ', # 0x5a 'Cui ', # 0x5b 'Min ', # 0x5c 'Te ', # 0x5d 'Zhang ', # 0x5e 'Tong ', # 0x5f 'Ao ', # 0x60 'Shuang ', # 0x61 'Man ', # 0x62 'Guan ', # 0x63 'Que ', # 0x64 'Zao ', # 0x65 'Jiu ', # 0x66 'Hui ', # 0x67 'Kai ', # 0x68 'Lian ', # 0x69 'Ou ', # 0x6a 'Song ', # 0x6b 'Jin ', # 0x6c 'Yin ', # 0x6d 'Lu ', # 0x6e 'Shang ', # 0x6f 'Wei ', # 0x70 'Tuan ', # 0x71 'Man ', # 0x72 'Qian ', # 0x73 'She ', # 0x74 'Yong ', # 0x75 'Qing ', # 0x76 'Kang ', # 0x77 'Di ', # 0x78 'Zhi ', # 0x79 'Lou ', # 0x7a 'Juan ', # 0x7b 'Qi ', # 0x7c 'Qi ', # 0x7d 'Yu ', # 0x7e 'Ping ', # 0x7f 'Liao ', # 0x80 'Cong ', # 0x81 'You ', # 0x82 'Chong ', # 0x83 'Zhi ', # 0x84 'Tong ', # 0x85 'Cheng ', # 0x86 'Qi ', # 0x87 'Qu ', # 0x88 'Peng ', # 0x89 'Bei ', # 0x8a 'Bie ', # 0x8b 'Chun ', # 0x8c 'Jiao ', # 0x8d 'Zeng ', # 0x8e 'Chi ', # 0x8f 'Lian ', # 0x90 'Ping ', # 0x91 'Kui ', # 0x92 'Hui ', # 0x93 'Qiao ', # 0x94 'Cheng ', # 0x95 'Yin ', # 0x96 'Yin ', # 0x97 'Xi ', # 0x98 'Xi ', # 0x99 'Dan ', # 0x9a 'Tan ', # 0x9b 'Duo ', # 0x9c 'Dui ', # 0x9d 'Dui ', # 0x9e 'Su ', # 0x9f 'Jue ', # 0xa0 'Ce ', # 0xa1 'Xiao ', # 0xa2 'Fan ', # 0xa3 'Fen ', # 0xa4 'Lao ', # 0xa5 'Lao ', # 0xa6 'Chong ', # 0xa7 'Han ', # 0xa8 'Qi ', # 0xa9 'Xian ', # 0xaa 'Min ', # 0xab 'Jing ', # 0xac 'Liao ', # 0xad 'Wu ', # 0xae 'Can ', # 0xaf 'Jue ', # 0xb0 'Cu ', # 0xb1 'Xian ', # 0xb2 'Tan ', # 0xb3 'Sheng ', # 0xb4 'Pi ', # 0xb5 'Yi ', # 0xb6 'Chu ', # 0xb7 'Xian ', # 0xb8 'Nao ', # 0xb9 'Dan ', # 0xba 'Tan ', # 0xbb 'Jing ', # 0xbc 'Song ', # 0xbd 'Han ', # 0xbe 'Jiao ', # 0xbf 'Wai ', # 0xc0 'Huan ', # 0xc1 'Dong ', # 0xc2 'Qin ', # 0xc3 'Qin ', # 0xc4 'Qu ', # 0xc5 'Cao ', # 0xc6 'Ken ', # 0xc7 'Xie ', # 0xc8 'Ying ', # 0xc9 'Ao ', # 0xca 'Mao ', # 0xcb 'Yi ', # 0xcc 'Lin ', # 0xcd 'Se ', # 0xce 'Jun ', # 0xcf 'Huai ', # 0xd0 'Men ', # 0xd1 'Lan ', # 0xd2 'Ai ', # 0xd3 'Lin ', # 0xd4 'Yan ', # 0xd5 'Gua ', # 0xd6 'Xia ', # 0xd7 'Chi ', # 0xd8 'Yu ', # 0xd9 'Yin ', # 0xda 'Dai ', # 0xdb 'Meng ', # 0xdc 'Ai ', # 0xdd 'Meng ', # 0xde 'Dui ', # 0xdf 'Qi ', # 0xe0 'Mo ', # 0xe1 'Lan ', # 0xe2 'Men ', # 0xe3 'Chou ', # 0xe4 'Zhi ', # 0xe5 'Nuo ', # 0xe6 'Nuo ', # 0xe7 'Yan ', # 0xe8 'Yang ', # 0xe9 'Bo ', # 0xea 'Zhi ', # 0xeb 'Kuang ', # 0xec 'Kuang ', # 0xed 'You ', # 0xee 'Fu ', # 0xef 'Liu ', # 0xf0 'Mie ', # 0xf1 'Cheng ', # 0xf2 '[?] ', # 0xf3 'Chan ', # 0xf4 'Meng ', # 0xf5 'Lan ', # 0xf6 'Huai ', # 0xf7 'Xuan ', # 0xf8 'Rang ', # 0xf9 'Chan ', # 0xfa 'Ji ', # 0xfb 'Ju ', # 0xfc 'Huan ', # 0xfd 'She ', # 0xfe 'Yi ', # 0xff )
data = ('Qiao ', 'Chou ', 'Bei ', 'Xuan ', 'Wei ', 'Ge ', 'Qian ', 'Wei ', 'Yu ', 'Yu ', 'Bi ', 'Xuan ', 'Huan ', 'Min ', 'Bi ', 'Yi ', 'Mian ', 'Yong ', 'Kai ', 'Dang ', 'Yin ', 'E ', 'Chen ', 'Mou ', 'Ke ', 'Ke ', 'Yu ', 'Ai ', 'Qie ', 'Yan ', 'Nuo ', 'Gan ', 'Yun ', 'Zong ', 'Sai ', 'Leng ', 'Fen ', '[?] ', 'Kui ', 'Kui ', 'Que ', 'Gong ', 'Yun ', 'Su ', 'Su ', 'Qi ', 'Yao ', 'Song ', 'Huang ', 'Ji ', 'Gu ', 'Ju ', 'Chuang ', 'Ni ', 'Xie ', 'Kai ', 'Zheng ', 'Yong ', 'Cao ', 'Sun ', 'Shen ', 'Bo ', 'Kai ', 'Yuan ', 'Xie ', 'Hun ', 'Yong ', 'Yang ', 'Li ', 'Sao ', 'Tao ', 'Yin ', 'Ci ', 'Xu ', 'Qian ', 'Tai ', 'Huang ', 'Yun ', 'Shen ', 'Ming ', '[?] ', 'She ', 'Cong ', 'Piao ', 'Mo ', 'Mu ', 'Guo ', 'Chi ', 'Can ', 'Can ', 'Can ', 'Cui ', 'Min ', 'Te ', 'Zhang ', 'Tong ', 'Ao ', 'Shuang ', 'Man ', 'Guan ', 'Que ', 'Zao ', 'Jiu ', 'Hui ', 'Kai ', 'Lian ', 'Ou ', 'Song ', 'Jin ', 'Yin ', 'Lu ', 'Shang ', 'Wei ', 'Tuan ', 'Man ', 'Qian ', 'She ', 'Yong ', 'Qing ', 'Kang ', 'Di ', 'Zhi ', 'Lou ', 'Juan ', 'Qi ', 'Qi ', 'Yu ', 'Ping ', 'Liao ', 'Cong ', 'You ', 'Chong ', 'Zhi ', 'Tong ', 'Cheng ', 'Qi ', 'Qu ', 'Peng ', 'Bei ', 'Bie ', 'Chun ', 'Jiao ', 'Zeng ', 'Chi ', 'Lian ', 'Ping ', 'Kui ', 'Hui ', 'Qiao ', 'Cheng ', 'Yin ', 'Yin ', 'Xi ', 'Xi ', 'Dan ', 'Tan ', 'Duo ', 'Dui ', 'Dui ', 'Su ', 'Jue ', 'Ce ', 'Xiao ', 'Fan ', 'Fen ', 'Lao ', 'Lao ', 'Chong ', 'Han ', 'Qi ', 'Xian ', 'Min ', 'Jing ', 'Liao ', 'Wu ', 'Can ', 'Jue ', 'Cu ', 'Xian ', 'Tan ', 'Sheng ', 'Pi ', 'Yi ', 'Chu ', 'Xian ', 'Nao ', 'Dan ', 'Tan ', 'Jing ', 'Song ', 'Han ', 'Jiao ', 'Wai ', 'Huan ', 'Dong ', 'Qin ', 'Qin ', 'Qu ', 'Cao ', 'Ken ', 'Xie ', 'Ying ', 'Ao ', 'Mao ', 'Yi ', 'Lin ', 'Se ', 'Jun ', 'Huai ', 'Men ', 'Lan ', 'Ai ', 'Lin ', 'Yan ', 'Gua ', 'Xia ', 'Chi ', 'Yu ', 'Yin ', 'Dai ', 'Meng ', 'Ai ', 'Meng ', 'Dui ', 'Qi ', 'Mo ', 'Lan ', 'Men ', 'Chou ', 'Zhi ', 'Nuo ', 'Nuo ', 'Yan ', 'Yang ', 'Bo ', 'Zhi ', 'Kuang ', 'Kuang ', 'You ', 'Fu ', 'Liu ', 'Mie ', 'Cheng ', '[?] ', 'Chan ', 'Meng ', 'Lan ', 'Huai ', 'Xuan ', 'Rang ', 'Chan ', 'Ji ', 'Ju ', 'Huan ', 'She ', 'Yi ')
[[0,3],[2,7],[3,4],[4,6]] [0,6] def find_min_intervals(intervals, target): intervals.sort() res = 0 cur_target = target[0] i = 0 max_step = 0 while i < len(intervals) and cur_target < target[1]: while i < len(intervals) and intervals[i][0] <= cur_target: max_step = max(max_step, intervals[i][1]) i += 1 cur_target = max_step res += 1 return res if cur_target >= target[1] else 0 print(find_min_intervals([[0, 3], [3, 4], [4, 6], [2, 7]], [0,6]))
[[0, 3], [2, 7], [3, 4], [4, 6]] [0, 6] def find_min_intervals(intervals, target): intervals.sort() res = 0 cur_target = target[0] i = 0 max_step = 0 while i < len(intervals) and cur_target < target[1]: while i < len(intervals) and intervals[i][0] <= cur_target: max_step = max(max_step, intervals[i][1]) i += 1 cur_target = max_step res += 1 return res if cur_target >= target[1] else 0 print(find_min_intervals([[0, 3], [3, 4], [4, 6], [2, 7]], [0, 6]))
class TaskHandler(): def __init__(self, tasks=[]): self.tasks = tasks def add(self): pass def delete(self): pass def clear_all(self): pass def show_info(self): pass class Task(): def __init__(self, task_name, sub_tasks, date): self.task_name = task_name self.sub_tasks = sub_tasks self.date = date
class Taskhandler: def __init__(self, tasks=[]): self.tasks = tasks def add(self): pass def delete(self): pass def clear_all(self): pass def show_info(self): pass class Task: def __init__(self, task_name, sub_tasks, date): self.task_name = task_name self.sub_tasks = sub_tasks self.date = date
BOT_NAME = 'czech_political_parties' SPIDER_MODULES = ['czech_political_parties.spiders'] USER_AGENT = 'czech-political-parties (+https://github.com/honzajavorek/czech-political-parties)' FEED_EXPORTERS = { 'sorted_json': 'czech_political_parties.exporters.SortedJsonItemExporter', } FEEDS = { 'items.json': { 'format': 'sorted_json', 'encoding': 'utf-8', 'indent': 4, 'overwrite': True, }, }
bot_name = 'czech_political_parties' spider_modules = ['czech_political_parties.spiders'] user_agent = 'czech-political-parties (+https://github.com/honzajavorek/czech-political-parties)' feed_exporters = {'sorted_json': 'czech_political_parties.exporters.SortedJsonItemExporter'} feeds = {'items.json': {'format': 'sorted_json', 'encoding': 'utf-8', 'indent': 4, 'overwrite': True}}
# # This file contains the Python code from Program 7.20 of # "Data Structures and Algorithms # with Object-Oriented Design Patterns in Python" # by Bruno R. Preiss. # # Copyright (c) 2003 by Bruno R. Preiss, P.Eng. All rights reserved. # # http://www.brpreiss.com/books/opus7/programs/pgm07_20.txt # class Polynomial(Container): def __init__(self): super(Polynomial, self).__init__() def addTerm(self, term): pass addTerm = abstractmethod(addTerm) def differentiate(self): pass differentiate = abstractmethod(differentiate) def __add__(self, polynomial): pass __add__ = abstractmethod(__add__) # ...
class Polynomial(Container): def __init__(self): super(Polynomial, self).__init__() def add_term(self, term): pass add_term = abstractmethod(addTerm) def differentiate(self): pass differentiate = abstractmethod(differentiate) def __add__(self, polynomial): pass __add__ = abstractmethod(__add__)
def minion_game(s): ls = 'AEIOU' a = 0 b = 0 n = len(s) for i in range(0,n): val = n - i if ls.find(s[i]) == -1: a += val else: b += val if a > b: print('Stuart',a) elif b > a: print('Kevin',b) else: print('Draw') s = input() minion_game(s)
def minion_game(s): ls = 'AEIOU' a = 0 b = 0 n = len(s) for i in range(0, n): val = n - i if ls.find(s[i]) == -1: a += val else: b += val if a > b: print('Stuart', a) elif b > a: print('Kevin', b) else: print('Draw') s = input() minion_game(s)
n = 500 # This is the final formula after lots of counting. # First notice how squares are on the upper right diagonal, # then work you way towards the total. print(int(1 + 2 / 3 * n * (8 * n ** 2 + 15 * n + 13)))
n = 500 print(int(1 + 2 / 3 * n * (8 * n ** 2 + 15 * n + 13)))
a = int(input('Digete um valor: ')) print(type(a)) b = bool(input('Digete um valor: ')) print(type(b)) c = float(input('Digete um valor: ')) print(type(c)) d = str(input('Digete um valor: ')) print(type(d))
a = int(input('Digete um valor: ')) print(type(a)) b = bool(input('Digete um valor: ')) print(type(b)) c = float(input('Digete um valor: ')) print(type(c)) d = str(input('Digete um valor: ')) print(type(d))
# -*- coding: utf-8 -*- # Helper functions def return_sublist(main_list, indices ): sublist = [[item[i] for i in indices] for item in main_list] return sublist
def return_sublist(main_list, indices): sublist = [[item[i] for i in indices] for item in main_list] return sublist
# -*- coding: utf-8 -*- A = input() B = input() X = A + B print ("X = %i" %X)
a = input() b = input() x = A + B print('X = %i' % X)
class UnwrapError(Exception): pass class RedisProtocolFormatError(Exception): pass class ExceptionWithReplyError(Exception): def __init__(self, reply="ERR", *args): super().__init__(*args) self.reply = reply class NoPasswordError(ExceptionWithReplyError): pass class WrongCommand(Exception): pass class KeyNotFound(Exception): pass class NodeNotFound(Exception): pass class DatabaseNotFound(Exception): pass class CommandNotFound(ExceptionWithReplyError): def __init__(self): super(CommandNotFound, self).__init__(reply="COMMAND NOT FOUND") __all__ = [ "UnwrapError", "RedisProtocolFormatError", "ExceptionWithReplyError", "NoPasswordError", "WrongCommand", "KeyNotFound", "NodeNotFound", "DatabaseNotFound", "CommandNotFound", ]
class Unwraperror(Exception): pass class Redisprotocolformaterror(Exception): pass class Exceptionwithreplyerror(Exception): def __init__(self, reply='ERR', *args): super().__init__(*args) self.reply = reply class Nopassworderror(ExceptionWithReplyError): pass class Wrongcommand(Exception): pass class Keynotfound(Exception): pass class Nodenotfound(Exception): pass class Databasenotfound(Exception): pass class Commandnotfound(ExceptionWithReplyError): def __init__(self): super(CommandNotFound, self).__init__(reply='COMMAND NOT FOUND') __all__ = ['UnwrapError', 'RedisProtocolFormatError', 'ExceptionWithReplyError', 'NoPasswordError', 'WrongCommand', 'KeyNotFound', 'NodeNotFound', 'DatabaseNotFound', 'CommandNotFound']
def set_isic_configs(args): args.batch_size = 128 args.fixmatch_k_img = 8192 args.simclr_batch_size = 512 args.stop_labeled = 9134 args.add_labeled = 1015 args.start_labeled = 203 args.merged = False args.pseudo_labeling_num = 20264 - args.stop_labeled if args.novel_class_detection: args.remove_classes = True return args
def set_isic_configs(args): args.batch_size = 128 args.fixmatch_k_img = 8192 args.simclr_batch_size = 512 args.stop_labeled = 9134 args.add_labeled = 1015 args.start_labeled = 203 args.merged = False args.pseudo_labeling_num = 20264 - args.stop_labeled if args.novel_class_detection: args.remove_classes = True return args
############################################################################### # Define everything needed to build nightly Julia for gc debugging ############################################################################### julia_gc_debug_factory = util.BuildFactory() julia_gc_debug_factory.useProgress = True julia_gc_debug_factory.addSteps([ # Clone julia steps.Git( name="Julia checkout", repourl=util.Property('repository', default='git://github.com/JuliaLang/julia.git'), mode='incremental', method='clean', submodules=True, clobberOnFailure=True, progress=True ), # Fetch so that remote branches get updated as well. steps.ShellCommand( name="git fetch", command=["git", "fetch"], flunkOnFailure=False ), # Add our particular configuration to flags steps.SetPropertyFromCommand( name="Add configuration to flags", command=["echo", util.Interpolate("%(prop:flags)s WITH_GC_DEBUG_ENV=1")], property="flags" ), # make clean first, and nuke llvm steps.ShellCommand( name="make cleanall", command=["/bin/sh", "-c", util.Interpolate("%(prop:make_cmd)s %(prop:flags)s cleanall")] ), # Make! steps.ShellCommand( name="make", command=["/bin/sh", "-c", util.Interpolate("%(prop:make_cmd)s -j3 %(prop:flags)s")], haltOnFailure = True ), # Test! steps.ShellCommand( name="make testall", command=["/bin/sh", "-c", util.Interpolate("%(prop:make_cmd)s %(prop:flags)s testall")] ) ]) gc_debug_nightly_scheduler = schedulers.Nightly(name="Julia GC Debug Build", builderNames=["nightly_gc_debug-x86", "nightly_gc_debug-x64"], hour=[3], change_filter=util.ChangeFilter(project=['JuliaLang/julia','staticfloat/julia'], branch='master'), onlyIfChanged=True) c['schedulers'].append(gc_debug_nightly_scheduler) for arch in ["x86", "x64"]: force_scheduler = schedulers.ForceScheduler( name="force_gc_%s"%(arch), label="Force Julia %s GC debug building"%(arch), builderNames=["nightly_gc_debug-%s" % arch], reason=util.FixedParameter(name="reason", default=""), codebases=[ util.CodebaseParameter( "", name="", branch=util.FixedParameter(name="branch", default=""), repository=util.FixedParameter(name="repository", default=""), project=util.FixedParameter(name="project", default=""), ) ], properties=[]) c['schedulers'].append(force_scheduler) for arch in ["x86", "x64"]: c['builders'].append(util.BuilderConfig( name="nightly_gc_debug-%s"%(arch), workernames=["ubuntu16_04-%s"%(arch)], tags=["Nightlies"], factory=julia_gc_debug_factory ))
julia_gc_debug_factory = util.BuildFactory() julia_gc_debug_factory.useProgress = True julia_gc_debug_factory.addSteps([steps.Git(name='Julia checkout', repourl=util.Property('repository', default='git://github.com/JuliaLang/julia.git'), mode='incremental', method='clean', submodules=True, clobberOnFailure=True, progress=True), steps.ShellCommand(name='git fetch', command=['git', 'fetch'], flunkOnFailure=False), steps.SetPropertyFromCommand(name='Add configuration to flags', command=['echo', util.Interpolate('%(prop:flags)s WITH_GC_DEBUG_ENV=1')], property='flags'), steps.ShellCommand(name='make cleanall', command=['/bin/sh', '-c', util.Interpolate('%(prop:make_cmd)s %(prop:flags)s cleanall')]), steps.ShellCommand(name='make', command=['/bin/sh', '-c', util.Interpolate('%(prop:make_cmd)s -j3 %(prop:flags)s')], haltOnFailure=True), steps.ShellCommand(name='make testall', command=['/bin/sh', '-c', util.Interpolate('%(prop:make_cmd)s %(prop:flags)s testall')])]) gc_debug_nightly_scheduler = schedulers.Nightly(name='Julia GC Debug Build', builderNames=['nightly_gc_debug-x86', 'nightly_gc_debug-x64'], hour=[3], change_filter=util.ChangeFilter(project=['JuliaLang/julia', 'staticfloat/julia'], branch='master'), onlyIfChanged=True) c['schedulers'].append(gc_debug_nightly_scheduler) for arch in ['x86', 'x64']: force_scheduler = schedulers.ForceScheduler(name='force_gc_%s' % arch, label='Force Julia %s GC debug building' % arch, builderNames=['nightly_gc_debug-%s' % arch], reason=util.FixedParameter(name='reason', default=''), codebases=[util.CodebaseParameter('', name='', branch=util.FixedParameter(name='branch', default=''), repository=util.FixedParameter(name='repository', default=''), project=util.FixedParameter(name='project', default=''))], properties=[]) c['schedulers'].append(force_scheduler) for arch in ['x86', 'x64']: c['builders'].append(util.BuilderConfig(name='nightly_gc_debug-%s' % arch, workernames=['ubuntu16_04-%s' % arch], tags=['Nightlies'], factory=julia_gc_debug_factory))
n,k=map(int,input().split()) l=[int(x) for x in input().split()] l.sort() s=set([]) ans=0 for i in l: if i%k==0: if i//k not in s: s.add(i) ans+=1 else: ans+=1 s.add(i) print(ans) # https://codeforces.com/problemset/problem/274/A
(n, k) = map(int, input().split()) l = [int(x) for x in input().split()] l.sort() s = set([]) ans = 0 for i in l: if i % k == 0: if i // k not in s: s.add(i) ans += 1 else: ans += 1 s.add(i) print(ans)
num = int(input('digite um numero: ')) total = 0 for c in range(1, num + 1): if num % c == 0: print('\033[33m', end=' ') total = total + 1 else: print('\033[31m', end=' ') print('{}'.format(c), end=' ') print('\n\033[m0 o numero {} foi dividido {} veses '.format(num, total)) if total == 2: print('E por isso ele e PRIMO') else: print('E por isso ele nao e primo')
num = int(input('digite um numero: ')) total = 0 for c in range(1, num + 1): if num % c == 0: print('\x1b[33m', end=' ') total = total + 1 else: print('\x1b[31m', end=' ') print('{}'.format(c), end=' ') print('\n\x1b[m0 o numero {} foi dividido {} veses '.format(num, total)) if total == 2: print('E por isso ele e PRIMO') else: print('E por isso ele nao e primo')
def fib(n): if n <= 1: return n tab = [i for i in range(n+1)] tab[0] = 0 tab[1] = 1 for i in range(2, n + 1): tab[i] = tab[i-1] + tab[i-2] return tab[n] if __name__ == '__main__': print(fib(4))
def fib(n): if n <= 1: return n tab = [i for i in range(n + 1)] tab[0] = 0 tab[1] = 1 for i in range(2, n + 1): tab[i] = tab[i - 1] + tab[i - 2] return tab[n] if __name__ == '__main__': print(fib(4))
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def constructMaximumBinaryTree(self, nums: List[int]) -> TreeNode: def helper(arr): if not arr: return None max_element = max(arr) max_element_index = arr.index(max(arr)) left_arr = arr[: max_element_index] right_arr = arr[max_element_index + 1:] new_node = TreeNode(max_element) new_node.left = helper(left_arr) new_node.right = helper(right_arr) return new_node return helper(nums)
class Solution: def construct_maximum_binary_tree(self, nums: List[int]) -> TreeNode: def helper(arr): if not arr: return None max_element = max(arr) max_element_index = arr.index(max(arr)) left_arr = arr[:max_element_index] right_arr = arr[max_element_index + 1:] new_node = tree_node(max_element) new_node.left = helper(left_arr) new_node.right = helper(right_arr) return new_node return helper(nums)
# -*- coding: utf-8 -*- def test_config_profile(pepper_cli, session_minion_id): '''Test the using a profile''' ret = pepper_cli('*', 'test.ping', profile='pepper') assert ret[session_minion_id] is True
def test_config_profile(pepper_cli, session_minion_id): """Test the using a profile""" ret = pepper_cli('*', 'test.ping', profile='pepper') assert ret[session_minion_id] is True
''' Candies and two Sisters ''' t = int(input()) for i in range(t): n = int(input()) half = n // 2 method = n - 1 - half print(method)
""" Candies and two Sisters """ t = int(input()) for i in range(t): n = int(input()) half = n // 2 method = n - 1 - half print(method)
def infer_breach(value, lowerLimit, upperLimit): if value < lowerLimit: return 'TOO_LOW' if value > upperLimit: return 'TOO_HIGH' return 'NORMAL' def classify_temperature_breach(coolingType, temperatureInC): reference_for_upperLimit = { 'PASSIVE_COOLING' : [0,35], 'HI_ACTIVE_COOLING' : [0,45], 'MED_ACTIVE_COOLING' : [0,40] } lowerLimit, upperLimit = reference_for_upperLimit.get(coolingType, 0) return infer_breach(temperatureInC, lowerLimit, upperLimit) def check_and_alert(alertTarget, batteryChar, temperatureInC): breachType =\ classify_temperature_breach(batteryChar['coolingType'], temperatureInC) alertTarget_reference = { 'TO_CONTROLLER' : send_to_controller(breachType), 'TO_EMAIL' : send_to_email(breachType) } alertMessage = alertTarget_reference.get(alertTarget, 'Invalid Alert Type!') return alertMessage def send_to_controller(breachType): header = 0xfeed messageContent = f'{header}, {breachType}' printFunction(messageContent) return messageContent def send_to_email(breachType): recepient = "a.b@c.com" emailBody_reference = { 'TOO_LOW' : 'Hi, the temperature is too low', 'TOO_HIGH' : 'Hi, the temperature is too high' } email_content = emailBody_reference.get(breachType, 'Hi, Breach not found!') messageContent = f'To: {recepient} \n{email_content}' printFunction(messageContent) return messageContent def printFunction(printData): print(printData)
def infer_breach(value, lowerLimit, upperLimit): if value < lowerLimit: return 'TOO_LOW' if value > upperLimit: return 'TOO_HIGH' return 'NORMAL' def classify_temperature_breach(coolingType, temperatureInC): reference_for_upper_limit = {'PASSIVE_COOLING': [0, 35], 'HI_ACTIVE_COOLING': [0, 45], 'MED_ACTIVE_COOLING': [0, 40]} (lower_limit, upper_limit) = reference_for_upperLimit.get(coolingType, 0) return infer_breach(temperatureInC, lowerLimit, upperLimit) def check_and_alert(alertTarget, batteryChar, temperatureInC): breach_type = classify_temperature_breach(batteryChar['coolingType'], temperatureInC) alert_target_reference = {'TO_CONTROLLER': send_to_controller(breachType), 'TO_EMAIL': send_to_email(breachType)} alert_message = alertTarget_reference.get(alertTarget, 'Invalid Alert Type!') return alertMessage def send_to_controller(breachType): header = 65261 message_content = f'{header}, {breachType}' print_function(messageContent) return messageContent def send_to_email(breachType): recepient = 'a.b@c.com' email_body_reference = {'TOO_LOW': 'Hi, the temperature is too low', 'TOO_HIGH': 'Hi, the temperature is too high'} email_content = emailBody_reference.get(breachType, 'Hi, Breach not found!') message_content = f'To: {recepient} \n{email_content}' print_function(messageContent) return messageContent def print_function(printData): print(printData)
# -*- coding: utf-8 -*- # # "config" here is a python module that must have "parser" function. # That function should generate signature of the email and # pass that to "eeas" object (passed as arg) methods. # Not calling any of these would mean that email can't be classified. # # Already present in the namespace: it, op, ft, re, types, string, vars below # eeas methods: eeas.signature_from, eeas.rate_limit, eeas.mail_pass, eeas.mail_filter ## Optional override for path to db where signatures and rate limiting meta are stored. ## Already set in the namespace, will be checked once after module eval. # db_path = ## Optional override for max email size and verdict for oversized emails # mail_max_bytes = # mail_max_bytes_verdict = ## Other stuff # history_timeout = # history_cleanup_chance = # default_verdicts = def parser(eeas, tags, msg): agg_name = fingerprint = None msg_type = None subject = msg.headers.get('subject') if subject: if 'cron-jobs' in tags: # tags can be passed as a cli args from sieve script m = re.search(r'^Cron\s+<(?P<src>[^>]+)>\s+(?P<name>.*)$', subject) if m: msg_type = 'cron' agg_name = '[{}] {}: {}'.format(m.group('src'), msg_type, m.group('name')) if not agg_name: eeas.log.debug('Did not match agg_name from mail subject: %r', subject) return if msg_type == 'cron': # fingerprint will be bencoded then hashed, so any simple py # Following data types will work: strings, numbers, lists, tuples, dicts, bools, None fingerprint = list() for line in msg.text.splitlines(): # Strip iso8601-ish timestamps from output lines, if any m = re.search(r'^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?:,\d+)? :: (.*)$', line) if m: line = m.group(1) fingerprint.append(line) else: # Can raise error here to have mail dropped into --error-reports-dir for later check eeas.log.debug( 'Failed to calculate fingerprint' ' for mail body (agg_name: %s, msg_type: %s)', agg_name, msg_type ) return # Currently required "signature" keys are: aggregate_name, fingerprint # "aggregate_name" will be only printed in a digest # to show how many mails with this fingerprint were filtered. data_sig = eeas.signature_from(aggregate_name=agg_name, fingerprint=fingerprint) # Parameters for the token-bucket algorithm # burst: each matched mail "grabs" a token, or a fraction # of one, regardless of how it gets classified in the end # burst=5 means "max 5 tokens in a bucket" # tmin: when number of tokens drops below "tmin", stuff gets rate-limited # Note that number of tokens can be fractional, so that if mails hit bucket # with interval=1d more than 1/d, there will always be 0 <= n < 1 tokens, # so with tmin=1, nothing will pass, until rate drops below 1/d # interval: interval between new tokens, in seconds eeas.rate_limit_filter(data_sig, tmin=1, burst=3, interval=3*24*3600) # Only last verdict from eeas.* functions will be used for message
def parser(eeas, tags, msg): agg_name = fingerprint = None msg_type = None subject = msg.headers.get('subject') if subject: if 'cron-jobs' in tags: m = re.search('^Cron\\s+<(?P<src>[^>]+)>\\s+(?P<name>.*)$', subject) if m: msg_type = 'cron' agg_name = '[{}] {}: {}'.format(m.group('src'), msg_type, m.group('name')) if not agg_name: eeas.log.debug('Did not match agg_name from mail subject: %r', subject) return if msg_type == 'cron': fingerprint = list() for line in msg.text.splitlines(): m = re.search('^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}(?:,\\d+)? :: (.*)$', line) if m: line = m.group(1) fingerprint.append(line) else: eeas.log.debug('Failed to calculate fingerprint for mail body (agg_name: %s, msg_type: %s)', agg_name, msg_type) return data_sig = eeas.signature_from(aggregate_name=agg_name, fingerprint=fingerprint) eeas.rate_limit_filter(data_sig, tmin=1, burst=3, interval=3 * 24 * 3600)
{ 'variables': { 'firmware_path': '../src', 'lpc18xx_path': '../lpc18xx', 'usb_path': '../deps/usb', 'runtime_path': "../deps/runtime", 'builtin_path': '../builtin', 'tools_path': '../tools', 'otp_path': '../otp', 'erase_path': '../erase', 'boot_path': '../boot', 'cc3k_path': '../cc3k_patch', 'COLONY_STATE_CACHE%': '0', 'COLONY_PRELOAD_ON_INIT%': '0', }, 'target_defaults': { 'defines': [ 'COLONY_EMBED', 'CONFIG_PLATFORM_EMBED', 'TM_FS_vfs', '__thumb2__=1', 'GPIO_PIN_INT', '_POSIX_SOURCE', 'REGEX_WCHAR=1', 'COLONY_STATE_CACHE=<(COLONY_STATE_CACHE)', 'COLONY_PRELOAD_ON_INIT=<(COLONY_PRELOAD_ON_INIT)', '__TESSEL_FIRMWARE_VERSION__="<!(git log --pretty=format:\'%h\' -n 1)"', '__TESSEL_RUNTIME_VERSION__="<!(git --git-dir <(runtime_path)/.git log --pretty=format:\'%h\' -n 1)"', '__TESSEL_RUNTIME_SEMVER__="<!(node -p \"require(\\\"<(runtime_path)/package.json\\\").version")"', ], 'cflags': [ '-mcpu=cortex-m3', '-mthumb', '-gdwarf-2', '-mtune=cortex-m3', '-march=armv7-m', '-mlong-calls', '-mfix-cortex-m3-ldrd', '-mapcs-frame', '-msoft-float', '-mno-sched-prolog', # '-fno-hosted', '-ffunction-sections', '-fdata-sections', # '-fpermissive', '-include "<!(pwd)/<(runtime_path)/deps/axtls/config/embed/config.h"', '-Wall', '-Werror', ], 'cflags_c': [ '-std=gnu99', ], 'ldflags': [ '-mcpu=cortex-m3', '-mthumb', '-mtune=cortex-m3', '-march=armv7-m', '-mlong-calls', '-mfix-cortex-m3-ldrd', '-mapcs-frame', '-msoft-float', '-mno-sched-prolog', # '-fno-hosted', '-ffunction-sections', '-fdata-sections', # '-fpermissive', '-std=c99', '-Wall', '-Werror', ], 'default_configuration': 'Release', 'configurations': { 'Debug': { 'cflags': [ '-gdwarf-2', '-O0', ], 'ldflags': [ '-gdwarf-2', '-O0', ] }, 'Release': { 'cflags': [ '-Ofast', ] } }, }, "targets": [ { 'target_name': 'tessel-builtin', 'type': 'none', 'sources': [ '<(builtin_path)/tessel.js' ], 'rules': [ { 'rule_name': 'build-tessel', 'extension': 'js', 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).c' ], 'action': [ '<(tools_path)/compile_js.sh', '<(RULE_INPUT_PATH)', '<@(_outputs)' ] } ] }, { 'target_name': 'wifi-cc3000-builtin', 'type': 'none', 'sources': [ '<(builtin_path)/wifi-cc3000.js' ], 'rules': [ { 'rule_name': 'build-wifi-cc3000', 'extension': 'js', 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).c' ], 'action': [ '<(tools_path)/compile_js.sh', '<(RULE_INPUT_PATH)', '<@(_outputs)' ] } ] }, { 'target_name': 'neopixels-builtin', 'type': 'none', 'sources': [ '<(builtin_path)/neopixels.js' ], 'rules': [ { 'rule_name': 'build-neopixels', 'extension': 'js', 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).c' ], 'action': [ '<(tools_path)/compile_js.sh', '<(RULE_INPUT_PATH)', '<@(_outputs)' ] } ] }, { 'target_name': 'cmsis-lpc18xx', 'type': 'static_library', 'sources': [ '<(lpc18xx_path)/Drivers/source/Font5x7.c', '<(lpc18xx_path)/Drivers/source/LCDTerm.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_adc.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_atimer.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_can.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_cgu.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_dac.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_emc.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_evrt.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_gpdma.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_gpio.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_i2c.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_i2s.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_lcd.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_mcpwm.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_nvic.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_pwr.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_qei.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_rgu.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_rit.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_rtc.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_sct.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_scu.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_sdif.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_sdmmc.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_ssp.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_timer.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_uart.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_wwdt.c', '<(lpc18xx_path)/otp/otprom.c', ], 'include_dirs': [ '<(lpc18xx_path)/Drivers/include', '<(lpc18xx_path)/Core/CMSIS/Include', '<(lpc18xx_path)/Core/Include', '<(lpc18xx_path)/Core/Device/NXP/LPC18xx/Include', '<(lpc18xx_path)/otp', '<(firmware_path)/sys', ], 'direct_dependent_settings': { 'include_dirs': [ '<(lpc18xx_path)/Drivers/include', '<(lpc18xx_path)/Core/CMSIS/Include', '<(lpc18xx_path)/Core/Include', '<(lpc18xx_path)/Core/Device/NXP/LPC18xx/Include', '<(lpc18xx_path)/otp', '<(firmware_path)/sys', ], }, }, { 'target_name': 'usb', 'type': 'static_library', 'sources': [ '<(usb_path)/usb_requests.c', '<(usb_path)/lpc18_43/usb_lpc18_43.c', '<(usb_path)/class/dfu/dfu.c', ], 'include_dirs': [ '<(usb_path)', ], 'direct_dependent_settings': { 'include_dirs': [ '<(usb_path)', '<(usb_path)/lpc18_43', ], }, 'dependencies': [ 'cmsis-lpc18xx', ], }, { 'target_name': 'tessel-firmware-elf', 'type': 'executable', 'product_name': 'tessel-firmware.elf', 'cflags': [ '-Wall', '-Wextra', '-Werror', ], 'defines': [ 'CC3000_DEBUG=1', 'SEND_NON_BLOCKING', 'TESSEL_FASTCONNECT=1', 'CC3K_TIMEOUT=1' ], 'sources': [ # Startup script '<(firmware_path)/sys/startup_lpc1800.s', '<(SHARED_INTERMEDIATE_DIR)/tessel.c', '<(SHARED_INTERMEDIATE_DIR)/wifi-cc3000.c', '<(SHARED_INTERMEDIATE_DIR)/neopixels.c', '<(firmware_path)/variants/lpc18xx/variant.c', '<(firmware_path)/tm/tm_net.c', '<(firmware_path)/tm/tm_random.c', '<(firmware_path)/tm/tm_uptime.c', '<(firmware_path)/tm/tm_timestamp.c', '<(firmware_path)/sdram/sdram_init.c', '<(firmware_path)/cc3000/host_spi.c', '<(firmware_path)/hw/hw_analog.c', '<(firmware_path)/hw/hw_highspeedsignal.c', '<(firmware_path)/hw/hw_digital.c', '<(firmware_path)/hw/hw_readpulse.c', '<(firmware_path)/hw/hw_i2c.c', '<(firmware_path)/hw/hw_interrupt.c', '<(firmware_path)/hw/hw_net.c', '<(firmware_path)/hw/hw_pwm.c', '<(firmware_path)/hw/hw_wait.c', '<(firmware_path)/hw/hw_spi.c', '<(firmware_path)/hw/hw_spi_async.c', '<(firmware_path)/hw/hw_uart.c', '<(firmware_path)/hw/hw_swuart.c', '<(firmware_path)/hw/hw_gpdma.c', '<(firmware_path)/hw/l_hw.c', '<(firmware_path)/sys/sbrk.c', '<(firmware_path)/sys/spi_flash.c', '<(firmware_path)/sys/clock.c', '<(firmware_path)/sys/startup.c', '<(firmware_path)/sys/system_lpc18xx.c', '<(firmware_path)/sys/bootloader.c', '<(firmware_path)/test/test.c', '<(firmware_path)/test/test_nmea.c', '<(firmware_path)/test/test_hw.c', '<(firmware_path)/test/testalator.c', '<(firmware_path)/cc3000/utility/cc3000_common.c', '<(firmware_path)/cc3000/utility/evnt_handler.c', '<(firmware_path)/cc3000/utility/hci.c', '<(firmware_path)/cc3000/utility/netapp.c', '<(firmware_path)/cc3000/utility/nvmem.c', '<(firmware_path)/cc3000/utility/security.c', '<(firmware_path)/cc3000/utility/socket.c', '<(firmware_path)/cc3000/utility/wlan.c', '<(firmware_path)/main.c', '<(firmware_path)/syscalls.c', '<(firmware_path)/tessel.c', '<(firmware_path)/tessel_wifi.c', '<(firmware_path)/usb/usb.c', '<(firmware_path)/usb/device.c', '<(firmware_path)/usb/log_interface.c', '<(firmware_path)/usb/msg_interface.c', '<(firmware_path)/module_shims/audio-vs1053b.c', '<(firmware_path)/module_shims/gps-a2235h.c', '<(firmware_path)/module_shims/gps-nmea.c', '<(firmware_path)/addons/neopixel.c' ], 'dependencies': [ '<(runtime_path)/config/libtm.gyp:libtm', '<(runtime_path)/config/libtm.gyp:axtls', '<(runtime_path)/config/libcolony.gyp:libcolony', 'cmsis-lpc18xx', 'tessel-builtin', 'wifi-cc3000-builtin', 'neopixels-builtin', 'usb', ], 'libraries': [ '-lm', '-lc', '-lnosys', ], 'ldflags': [ '-T \'<!(pwd)/<(firmware_path)/ldscript_rom_gnu.ld\'', '-lm', '-lc', '-lnosys', '-Wl,--gc-sections', '-Wl,-marmelf', ], 'include_dirs': [ '<(runtime_path)/src', '<(runtime_path)/deps/colony-lua/src', '<(runtime_path)/deps/axtls/config', '<(runtime_path)/deps/axtls/ssl', '<(runtime_path)/deps/axtls/crypto', '<(firmware_path)/', '<(firmware_path)/cc3000', '<(firmware_path)/cc3000/utility', '<(firmware_path)/hw', '<(firmware_path)/sdram', '<(firmware_path)/sys', '<(firmware_path)/test', '<(firmware_path)/tm', '<(firmware_path)/variants/lpc18xx', '<(firmware_path)/module_shims', '<(firmware_path)/addons' ] }, { "target_name": "tessel-firmware-hex", "type": "none", "sources": [ "<(PRODUCT_DIR)/tessel-firmware.elf" ], "rules": [ { "rule_name": "hex", "extension": "elf", "outputs": [ "<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).hex" ], "action": [ "arm-none-eabi-objcopy", "-O", "ihex", "<(RULE_INPUT_PATH)", "<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).hex" ] } ] }, { "target_name": "tessel-firmware-bin", "type": "none", "sources": [ "<(PRODUCT_DIR)/tessel-firmware.elf" ], "rules": [ { "rule_name": "bin", "extension": "elf", "outputs": [ "<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).bin" ], "action": [ "arm-none-eabi-objcopy", "-O", "binary", "<(RULE_INPUT_PATH)", "<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).bin" ] } ] }, { 'target_name': 'tessel-boot-elf', 'type': 'executable', 'product_name': 'tessel-boot.elf', 'cflags': [ '-Wall', '-Wextra', '-Wno-error', '-Wno-main', '-Wno-unused-parameter', '-Wno-unused-function', ], 'sources': [ # Startup script '<(firmware_path)/sys/startup_lpc1800.s', '<(firmware_path)/variants/lpc18xx/variant.c', '<(firmware_path)/hw/hw_digital.c', '<(firmware_path)/tessel.c', '<(firmware_path)/sys/sbrk.c', '<(firmware_path)/sys/spi_flash.c', '<(firmware_path)/sys/clock.c', '<(firmware_path)/sys/startup.c', '<(firmware_path)/sys/system_lpc18xx.c', '<(firmware_path)/sys/bootloader.c', '<(boot_path)/main.c', '<(boot_path)/usb.c', ], 'dependencies': [ 'cmsis-lpc18xx', 'usb', ], 'libraries': [ '-lm', '-lc', '-lnosys', ], 'ldflags': [ '-T \'<!(pwd)/<(boot_path)/ldscript_rom_gnu.ld\'', '-lm', '-lc', '-lnosys', '-Wl,--gc-sections', '-Wl,-marmelf', ], 'include_dirs': [ '<(boot_path)/', '<(firmware_path)/', '<(firmware_path)/cc3000', '<(firmware_path)/cc3000/utility', '<(firmware_path)/hw', '<(firmware_path)/sdram', '<(firmware_path)/sys', '<(firmware_path)/test', '<(firmware_path)/tm', '<(firmware_path)/variants/lpc18xx', ] }, { "target_name": "tessel-boot-bin", "type": "none", "sources": [ "<(PRODUCT_DIR)/tessel-boot.elf" ], "rules": [ { "rule_name": "bin", "extension": "elf", "outputs": [ "<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).bin" ], "action": [ "arm-none-eabi-objcopy", "-O", "binary", "<(RULE_INPUT_PATH)", "<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).bin" ] } ] }, { 'target_name': 'tessel-otp-elf', 'type': 'executable', 'product_name': 'tessel-otp.elf', 'cflags': [ '-Wall', '-Wextra', ], 'sources': [ # Startup script '<(firmware_path)/sys/startup_lpc1800.s', '<(firmware_path)/variants/lpc18xx/variant.c', '<(firmware_path)/hw/hw_digital.c', '<(firmware_path)/sys/sbrk.c', '<(firmware_path)/sys/spi_flash.c', '<(firmware_path)/sys/clock.c', '<(firmware_path)/sys/startup.c', '<(firmware_path)/sys/system_lpc18xx.c', '<(firmware_path)/sys/bootloader.c', '<(otp_path)/main.c', '<(INTERMEDIATE_DIR)/boot_image.c' ], 'actions': [ { 'action_name': 'boot_image', 'inputs': [ '<(PRODUCT_DIR)/tessel-boot.bin' ], 'outputs': [ '<(INTERMEDIATE_DIR)/boot_image.c' ], 'action': ['sh', '-c', '(cd "<(PRODUCT_DIR)" > /dev/null; xxd -i tessel-boot.bin) > <(INTERMEDIATE_DIR)/boot_image.c'], } ], 'dependencies': [ 'cmsis-lpc18xx', ], 'libraries': [ '-lm', '-lc', '-lnosys', ], 'ldflags': [ '-T \'<!(pwd)/<(otp_path)/ldscript_ram_gnu.ld\'', '-lm', '-lc', '-lnosys', '-Wl,--gc-sections', '-Wl,-marmelf', ], 'include_dirs': [ '<(otp_path)/', '<(firmware_path)/', '<(firmware_path)/cc3000', '<(firmware_path)/cc3000/utility', '<(firmware_path)/hw', '<(firmware_path)/sdram', '<(firmware_path)/sys', '<(firmware_path)/test', '<(firmware_path)/tm', '<(firmware_path)/variants/lpc18xx', ] }, { "target_name": "tessel-otp-bin", "type": "none", "sources": [ "<(PRODUCT_DIR)/tessel-otp.elf" ], "rules": [ { "rule_name": "bin", "extension": "elf", "outputs": [ "<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).bin" ], "action": [ "arm-none-eabi-objcopy", "-O", "binary", "<(RULE_INPUT_PATH)", "<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).bin" ] } ] }, { 'target_name': 'tessel-erase-elf', 'type': 'executable', 'product_name': 'tessel-erase.elf', 'cflags': [ '-Wall', '-Wextra', ], 'sources': [ # Startup script '<(firmware_path)/sys/startup_lpc1800.s', '<(firmware_path)/variants/lpc18xx/variant.c', '<(firmware_path)/hw/hw_digital.c', '<(firmware_path)/sys/sbrk.c', '<(firmware_path)/sys/spi_flash.c', '<(firmware_path)/sys/clock.c', '<(firmware_path)/sys/startup.c', '<(firmware_path)/sys/system_lpc18xx.c', '<(firmware_path)/sys/bootloader.c', '<(erase_path)/main.c', ], 'dependencies': [ 'cmsis-lpc18xx', ], 'libraries': [ '-lm', '-lc', '-lnosys', ], 'ldflags': [ '-T \'<!(pwd)/<(otp_path)/ldscript_ram_gnu.ld\'', '-lm', '-lc', '-lnosys', '-Wl,--gc-sections', '-Wl,-marmelf', ], 'include_dirs': [ '<(otp_path)/', '<(firmware_path)/', '<(firmware_path)/cc3000', '<(firmware_path)/cc3000/utility', '<(firmware_path)/hw', '<(firmware_path)/sdram', '<(firmware_path)/sys', '<(firmware_path)/test', '<(firmware_path)/tm', '<(firmware_path)/variants/lpc18xx', ] }, { "target_name": "tessel-cc3k-patch-elf", 'type': 'executable', 'product_name': 'tessel-cc3k-patch.elf', 'cflags': [ '-Wall', '-Wextra', ], 'sources': [ # Startup script '<(firmware_path)/sys/startup_lpc1800.s', '<(firmware_path)/variants/lpc18xx/variant.c', '<(firmware_path)/hw/hw_digital.c', '<(firmware_path)/cc3000/host_spi.c', '<(firmware_path)/sys/sbrk.c', '<(firmware_path)/sys/spi_flash.c', '<(firmware_path)/sys/clock.c', '<(firmware_path)/sys/startup.c', '<(firmware_path)/sys/system_lpc18xx.c', '<(firmware_path)/sys/bootloader.c', '<(firmware_path)/cc3000/utility/cc3000_common.c', '<(firmware_path)/cc3000/utility/evnt_handler.c', '<(firmware_path)/cc3000/utility/hci.c', '<(firmware_path)/cc3000/utility/netapp.c', '<(firmware_path)/cc3000/utility/nvmem.c', '<(firmware_path)/cc3000/utility/security.c', '<(firmware_path)/cc3000/utility/socket.c', '<(firmware_path)/cc3000/utility/wlan.c', '<(firmware_path)/hw/hw_digital.c', '<(firmware_path)/hw/hw_wait.c', '<(firmware_path)/hw/hw_spi.c', '<(cc3k_path)/main.c', '<(cc3k_path)/PatchProgrammer.c' ], 'dependencies': [ 'cmsis-lpc18xx', ], 'libraries': [ '-lm', '-lc', '-lnosys', ], 'ldflags': [ '-T \'<!(pwd)/<(cc3k_path)/ldscript_ram_gnu.ld\'', '-lm', '-lc', '-lnosys', '-Wl,--gc-sections', '-Wl,-marmelf', ], 'include_dirs': [ '<(cc3k_path)/', '<(firmware_path)/', '<(firmware_path)/cc3000', '<(firmware_path)/cc3000/utility', '<(firmware_path)/hw', '<(firmware_path)/sdram', '<(firmware_path)/sys', '<(firmware_path)/test', '<(firmware_path)/tm', '<(firmware_path)/variants/lpc18xx', ] }, { "target_name": "tessel-cc3k-patch-bin", "type": "none", "sources": [ "<(PRODUCT_DIR)/tessel-cc3k-patch.elf" ], "rules": [ { "rule_name": "bin", "extension": "elf", "outputs": [ "<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).bin" ], "action": [ "arm-none-eabi-objcopy", "-O", "binary", "<(RULE_INPUT_PATH)", "<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).bin" ] } ] }, { "target_name": "tessel-erase-bin", "type": "none", "sources": [ "<(PRODUCT_DIR)/tessel-erase.elf" ], "rules": [ { "rule_name": "bin", "extension": "elf", "outputs": [ "<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).bin" ], "action": [ "arm-none-eabi-objcopy", "-O", "binary", "<(RULE_INPUT_PATH)", "<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).bin" ] } ] }, { "target_name": "tessel-firmware", "type": "none", "dependencies": [ 'tessel-firmware-elf', 'tessel-firmware-hex', 'tessel-firmware-bin', 'tessel-boot-elf', 'tessel-boot-bin', 'tessel-otp-elf', 'tessel-otp-bin', 'tessel-erase-elf', 'tessel-erase-bin', 'tessel-cc3k-patch-elf', 'tessel-cc3k-patch-bin' ] }, ] }
{'variables': {'firmware_path': '../src', 'lpc18xx_path': '../lpc18xx', 'usb_path': '../deps/usb', 'runtime_path': '../deps/runtime', 'builtin_path': '../builtin', 'tools_path': '../tools', 'otp_path': '../otp', 'erase_path': '../erase', 'boot_path': '../boot', 'cc3k_path': '../cc3k_patch', 'COLONY_STATE_CACHE%': '0', 'COLONY_PRELOAD_ON_INIT%': '0'}, 'target_defaults': {'defines': ['COLONY_EMBED', 'CONFIG_PLATFORM_EMBED', 'TM_FS_vfs', '__thumb2__=1', 'GPIO_PIN_INT', '_POSIX_SOURCE', 'REGEX_WCHAR=1', 'COLONY_STATE_CACHE=<(COLONY_STATE_CACHE)', 'COLONY_PRELOAD_ON_INIT=<(COLONY_PRELOAD_ON_INIT)', '__TESSEL_FIRMWARE_VERSION__="<!(git log --pretty=format:\'%h\' -n 1)"', '__TESSEL_RUNTIME_VERSION__="<!(git --git-dir <(runtime_path)/.git log --pretty=format:\'%h\' -n 1)"', '__TESSEL_RUNTIME_SEMVER__="<!(node -p "require(\\"<(runtime_path)/package.json\\").version")"'], 'cflags': ['-mcpu=cortex-m3', '-mthumb', '-gdwarf-2', '-mtune=cortex-m3', '-march=armv7-m', '-mlong-calls', '-mfix-cortex-m3-ldrd', '-mapcs-frame', '-msoft-float', '-mno-sched-prolog', '-ffunction-sections', '-fdata-sections', '-include "<!(pwd)/<(runtime_path)/deps/axtls/config/embed/config.h"', '-Wall', '-Werror'], 'cflags_c': ['-std=gnu99'], 'ldflags': ['-mcpu=cortex-m3', '-mthumb', '-mtune=cortex-m3', '-march=armv7-m', '-mlong-calls', '-mfix-cortex-m3-ldrd', '-mapcs-frame', '-msoft-float', '-mno-sched-prolog', '-ffunction-sections', '-fdata-sections', '-std=c99', '-Wall', '-Werror'], 'default_configuration': 'Release', 'configurations': {'Debug': {'cflags': ['-gdwarf-2', '-O0'], 'ldflags': ['-gdwarf-2', '-O0']}, 'Release': {'cflags': ['-Ofast']}}}, 'targets': [{'target_name': 'tessel-builtin', 'type': 'none', 'sources': ['<(builtin_path)/tessel.js'], 'rules': [{'rule_name': 'build-tessel', 'extension': 'js', 'outputs': ['<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).c'], 'action': ['<(tools_path)/compile_js.sh', '<(RULE_INPUT_PATH)', '<@(_outputs)']}]}, {'target_name': 'wifi-cc3000-builtin', 'type': 'none', 'sources': ['<(builtin_path)/wifi-cc3000.js'], 'rules': [{'rule_name': 'build-wifi-cc3000', 'extension': 'js', 'outputs': ['<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).c'], 'action': ['<(tools_path)/compile_js.sh', '<(RULE_INPUT_PATH)', '<@(_outputs)']}]}, {'target_name': 'neopixels-builtin', 'type': 'none', 'sources': ['<(builtin_path)/neopixels.js'], 'rules': [{'rule_name': 'build-neopixels', 'extension': 'js', 'outputs': ['<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).c'], 'action': ['<(tools_path)/compile_js.sh', '<(RULE_INPUT_PATH)', '<@(_outputs)']}]}, {'target_name': 'cmsis-lpc18xx', 'type': 'static_library', 'sources': ['<(lpc18xx_path)/Drivers/source/Font5x7.c', '<(lpc18xx_path)/Drivers/source/LCDTerm.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_adc.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_atimer.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_can.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_cgu.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_dac.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_emc.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_evrt.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_gpdma.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_gpio.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_i2c.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_i2s.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_lcd.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_mcpwm.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_nvic.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_pwr.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_qei.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_rgu.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_rit.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_rtc.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_sct.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_scu.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_sdif.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_sdmmc.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_ssp.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_timer.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_uart.c', '<(lpc18xx_path)/Drivers/source/lpc18xx_wwdt.c', '<(lpc18xx_path)/otp/otprom.c'], 'include_dirs': ['<(lpc18xx_path)/Drivers/include', '<(lpc18xx_path)/Core/CMSIS/Include', '<(lpc18xx_path)/Core/Include', '<(lpc18xx_path)/Core/Device/NXP/LPC18xx/Include', '<(lpc18xx_path)/otp', '<(firmware_path)/sys'], 'direct_dependent_settings': {'include_dirs': ['<(lpc18xx_path)/Drivers/include', '<(lpc18xx_path)/Core/CMSIS/Include', '<(lpc18xx_path)/Core/Include', '<(lpc18xx_path)/Core/Device/NXP/LPC18xx/Include', '<(lpc18xx_path)/otp', '<(firmware_path)/sys']}}, {'target_name': 'usb', 'type': 'static_library', 'sources': ['<(usb_path)/usb_requests.c', '<(usb_path)/lpc18_43/usb_lpc18_43.c', '<(usb_path)/class/dfu/dfu.c'], 'include_dirs': ['<(usb_path)'], 'direct_dependent_settings': {'include_dirs': ['<(usb_path)', '<(usb_path)/lpc18_43']}, 'dependencies': ['cmsis-lpc18xx']}, {'target_name': 'tessel-firmware-elf', 'type': 'executable', 'product_name': 'tessel-firmware.elf', 'cflags': ['-Wall', '-Wextra', '-Werror'], 'defines': ['CC3000_DEBUG=1', 'SEND_NON_BLOCKING', 'TESSEL_FASTCONNECT=1', 'CC3K_TIMEOUT=1'], 'sources': ['<(firmware_path)/sys/startup_lpc1800.s', '<(SHARED_INTERMEDIATE_DIR)/tessel.c', '<(SHARED_INTERMEDIATE_DIR)/wifi-cc3000.c', '<(SHARED_INTERMEDIATE_DIR)/neopixels.c', '<(firmware_path)/variants/lpc18xx/variant.c', '<(firmware_path)/tm/tm_net.c', '<(firmware_path)/tm/tm_random.c', '<(firmware_path)/tm/tm_uptime.c', '<(firmware_path)/tm/tm_timestamp.c', '<(firmware_path)/sdram/sdram_init.c', '<(firmware_path)/cc3000/host_spi.c', '<(firmware_path)/hw/hw_analog.c', '<(firmware_path)/hw/hw_highspeedsignal.c', '<(firmware_path)/hw/hw_digital.c', '<(firmware_path)/hw/hw_readpulse.c', '<(firmware_path)/hw/hw_i2c.c', '<(firmware_path)/hw/hw_interrupt.c', '<(firmware_path)/hw/hw_net.c', '<(firmware_path)/hw/hw_pwm.c', '<(firmware_path)/hw/hw_wait.c', '<(firmware_path)/hw/hw_spi.c', '<(firmware_path)/hw/hw_spi_async.c', '<(firmware_path)/hw/hw_uart.c', '<(firmware_path)/hw/hw_swuart.c', '<(firmware_path)/hw/hw_gpdma.c', '<(firmware_path)/hw/l_hw.c', '<(firmware_path)/sys/sbrk.c', '<(firmware_path)/sys/spi_flash.c', '<(firmware_path)/sys/clock.c', '<(firmware_path)/sys/startup.c', '<(firmware_path)/sys/system_lpc18xx.c', '<(firmware_path)/sys/bootloader.c', '<(firmware_path)/test/test.c', '<(firmware_path)/test/test_nmea.c', '<(firmware_path)/test/test_hw.c', '<(firmware_path)/test/testalator.c', '<(firmware_path)/cc3000/utility/cc3000_common.c', '<(firmware_path)/cc3000/utility/evnt_handler.c', '<(firmware_path)/cc3000/utility/hci.c', '<(firmware_path)/cc3000/utility/netapp.c', '<(firmware_path)/cc3000/utility/nvmem.c', '<(firmware_path)/cc3000/utility/security.c', '<(firmware_path)/cc3000/utility/socket.c', '<(firmware_path)/cc3000/utility/wlan.c', '<(firmware_path)/main.c', '<(firmware_path)/syscalls.c', '<(firmware_path)/tessel.c', '<(firmware_path)/tessel_wifi.c', '<(firmware_path)/usb/usb.c', '<(firmware_path)/usb/device.c', '<(firmware_path)/usb/log_interface.c', '<(firmware_path)/usb/msg_interface.c', '<(firmware_path)/module_shims/audio-vs1053b.c', '<(firmware_path)/module_shims/gps-a2235h.c', '<(firmware_path)/module_shims/gps-nmea.c', '<(firmware_path)/addons/neopixel.c'], 'dependencies': ['<(runtime_path)/config/libtm.gyp:libtm', '<(runtime_path)/config/libtm.gyp:axtls', '<(runtime_path)/config/libcolony.gyp:libcolony', 'cmsis-lpc18xx', 'tessel-builtin', 'wifi-cc3000-builtin', 'neopixels-builtin', 'usb'], 'libraries': ['-lm', '-lc', '-lnosys'], 'ldflags': ["-T '<!(pwd)/<(firmware_path)/ldscript_rom_gnu.ld'", '-lm', '-lc', '-lnosys', '-Wl,--gc-sections', '-Wl,-marmelf'], 'include_dirs': ['<(runtime_path)/src', '<(runtime_path)/deps/colony-lua/src', '<(runtime_path)/deps/axtls/config', '<(runtime_path)/deps/axtls/ssl', '<(runtime_path)/deps/axtls/crypto', '<(firmware_path)/', '<(firmware_path)/cc3000', '<(firmware_path)/cc3000/utility', '<(firmware_path)/hw', '<(firmware_path)/sdram', '<(firmware_path)/sys', '<(firmware_path)/test', '<(firmware_path)/tm', '<(firmware_path)/variants/lpc18xx', '<(firmware_path)/module_shims', '<(firmware_path)/addons']}, {'target_name': 'tessel-firmware-hex', 'type': 'none', 'sources': ['<(PRODUCT_DIR)/tessel-firmware.elf'], 'rules': [{'rule_name': 'hex', 'extension': 'elf', 'outputs': ['<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).hex'], 'action': ['arm-none-eabi-objcopy', '-O', 'ihex', '<(RULE_INPUT_PATH)', '<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).hex']}]}, {'target_name': 'tessel-firmware-bin', 'type': 'none', 'sources': ['<(PRODUCT_DIR)/tessel-firmware.elf'], 'rules': [{'rule_name': 'bin', 'extension': 'elf', 'outputs': ['<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).bin'], 'action': ['arm-none-eabi-objcopy', '-O', 'binary', '<(RULE_INPUT_PATH)', '<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).bin']}]}, {'target_name': 'tessel-boot-elf', 'type': 'executable', 'product_name': 'tessel-boot.elf', 'cflags': ['-Wall', '-Wextra', '-Wno-error', '-Wno-main', '-Wno-unused-parameter', '-Wno-unused-function'], 'sources': ['<(firmware_path)/sys/startup_lpc1800.s', '<(firmware_path)/variants/lpc18xx/variant.c', '<(firmware_path)/hw/hw_digital.c', '<(firmware_path)/tessel.c', '<(firmware_path)/sys/sbrk.c', '<(firmware_path)/sys/spi_flash.c', '<(firmware_path)/sys/clock.c', '<(firmware_path)/sys/startup.c', '<(firmware_path)/sys/system_lpc18xx.c', '<(firmware_path)/sys/bootloader.c', '<(boot_path)/main.c', '<(boot_path)/usb.c'], 'dependencies': ['cmsis-lpc18xx', 'usb'], 'libraries': ['-lm', '-lc', '-lnosys'], 'ldflags': ["-T '<!(pwd)/<(boot_path)/ldscript_rom_gnu.ld'", '-lm', '-lc', '-lnosys', '-Wl,--gc-sections', '-Wl,-marmelf'], 'include_dirs': ['<(boot_path)/', '<(firmware_path)/', '<(firmware_path)/cc3000', '<(firmware_path)/cc3000/utility', '<(firmware_path)/hw', '<(firmware_path)/sdram', '<(firmware_path)/sys', '<(firmware_path)/test', '<(firmware_path)/tm', '<(firmware_path)/variants/lpc18xx']}, {'target_name': 'tessel-boot-bin', 'type': 'none', 'sources': ['<(PRODUCT_DIR)/tessel-boot.elf'], 'rules': [{'rule_name': 'bin', 'extension': 'elf', 'outputs': ['<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).bin'], 'action': ['arm-none-eabi-objcopy', '-O', 'binary', '<(RULE_INPUT_PATH)', '<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).bin']}]}, {'target_name': 'tessel-otp-elf', 'type': 'executable', 'product_name': 'tessel-otp.elf', 'cflags': ['-Wall', '-Wextra'], 'sources': ['<(firmware_path)/sys/startup_lpc1800.s', '<(firmware_path)/variants/lpc18xx/variant.c', '<(firmware_path)/hw/hw_digital.c', '<(firmware_path)/sys/sbrk.c', '<(firmware_path)/sys/spi_flash.c', '<(firmware_path)/sys/clock.c', '<(firmware_path)/sys/startup.c', '<(firmware_path)/sys/system_lpc18xx.c', '<(firmware_path)/sys/bootloader.c', '<(otp_path)/main.c', '<(INTERMEDIATE_DIR)/boot_image.c'], 'actions': [{'action_name': 'boot_image', 'inputs': ['<(PRODUCT_DIR)/tessel-boot.bin'], 'outputs': ['<(INTERMEDIATE_DIR)/boot_image.c'], 'action': ['sh', '-c', '(cd "<(PRODUCT_DIR)" > /dev/null; xxd -i tessel-boot.bin) > <(INTERMEDIATE_DIR)/boot_image.c']}], 'dependencies': ['cmsis-lpc18xx'], 'libraries': ['-lm', '-lc', '-lnosys'], 'ldflags': ["-T '<!(pwd)/<(otp_path)/ldscript_ram_gnu.ld'", '-lm', '-lc', '-lnosys', '-Wl,--gc-sections', '-Wl,-marmelf'], 'include_dirs': ['<(otp_path)/', '<(firmware_path)/', '<(firmware_path)/cc3000', '<(firmware_path)/cc3000/utility', '<(firmware_path)/hw', '<(firmware_path)/sdram', '<(firmware_path)/sys', '<(firmware_path)/test', '<(firmware_path)/tm', '<(firmware_path)/variants/lpc18xx']}, {'target_name': 'tessel-otp-bin', 'type': 'none', 'sources': ['<(PRODUCT_DIR)/tessel-otp.elf'], 'rules': [{'rule_name': 'bin', 'extension': 'elf', 'outputs': ['<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).bin'], 'action': ['arm-none-eabi-objcopy', '-O', 'binary', '<(RULE_INPUT_PATH)', '<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).bin']}]}, {'target_name': 'tessel-erase-elf', 'type': 'executable', 'product_name': 'tessel-erase.elf', 'cflags': ['-Wall', '-Wextra'], 'sources': ['<(firmware_path)/sys/startup_lpc1800.s', '<(firmware_path)/variants/lpc18xx/variant.c', '<(firmware_path)/hw/hw_digital.c', '<(firmware_path)/sys/sbrk.c', '<(firmware_path)/sys/spi_flash.c', '<(firmware_path)/sys/clock.c', '<(firmware_path)/sys/startup.c', '<(firmware_path)/sys/system_lpc18xx.c', '<(firmware_path)/sys/bootloader.c', '<(erase_path)/main.c'], 'dependencies': ['cmsis-lpc18xx'], 'libraries': ['-lm', '-lc', '-lnosys'], 'ldflags': ["-T '<!(pwd)/<(otp_path)/ldscript_ram_gnu.ld'", '-lm', '-lc', '-lnosys', '-Wl,--gc-sections', '-Wl,-marmelf'], 'include_dirs': ['<(otp_path)/', '<(firmware_path)/', '<(firmware_path)/cc3000', '<(firmware_path)/cc3000/utility', '<(firmware_path)/hw', '<(firmware_path)/sdram', '<(firmware_path)/sys', '<(firmware_path)/test', '<(firmware_path)/tm', '<(firmware_path)/variants/lpc18xx']}, {'target_name': 'tessel-cc3k-patch-elf', 'type': 'executable', 'product_name': 'tessel-cc3k-patch.elf', 'cflags': ['-Wall', '-Wextra'], 'sources': ['<(firmware_path)/sys/startup_lpc1800.s', '<(firmware_path)/variants/lpc18xx/variant.c', '<(firmware_path)/hw/hw_digital.c', '<(firmware_path)/cc3000/host_spi.c', '<(firmware_path)/sys/sbrk.c', '<(firmware_path)/sys/spi_flash.c', '<(firmware_path)/sys/clock.c', '<(firmware_path)/sys/startup.c', '<(firmware_path)/sys/system_lpc18xx.c', '<(firmware_path)/sys/bootloader.c', '<(firmware_path)/cc3000/utility/cc3000_common.c', '<(firmware_path)/cc3000/utility/evnt_handler.c', '<(firmware_path)/cc3000/utility/hci.c', '<(firmware_path)/cc3000/utility/netapp.c', '<(firmware_path)/cc3000/utility/nvmem.c', '<(firmware_path)/cc3000/utility/security.c', '<(firmware_path)/cc3000/utility/socket.c', '<(firmware_path)/cc3000/utility/wlan.c', '<(firmware_path)/hw/hw_digital.c', '<(firmware_path)/hw/hw_wait.c', '<(firmware_path)/hw/hw_spi.c', '<(cc3k_path)/main.c', '<(cc3k_path)/PatchProgrammer.c'], 'dependencies': ['cmsis-lpc18xx'], 'libraries': ['-lm', '-lc', '-lnosys'], 'ldflags': ["-T '<!(pwd)/<(cc3k_path)/ldscript_ram_gnu.ld'", '-lm', '-lc', '-lnosys', '-Wl,--gc-sections', '-Wl,-marmelf'], 'include_dirs': ['<(cc3k_path)/', '<(firmware_path)/', '<(firmware_path)/cc3000', '<(firmware_path)/cc3000/utility', '<(firmware_path)/hw', '<(firmware_path)/sdram', '<(firmware_path)/sys', '<(firmware_path)/test', '<(firmware_path)/tm', '<(firmware_path)/variants/lpc18xx']}, {'target_name': 'tessel-cc3k-patch-bin', 'type': 'none', 'sources': ['<(PRODUCT_DIR)/tessel-cc3k-patch.elf'], 'rules': [{'rule_name': 'bin', 'extension': 'elf', 'outputs': ['<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).bin'], 'action': ['arm-none-eabi-objcopy', '-O', 'binary', '<(RULE_INPUT_PATH)', '<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).bin']}]}, {'target_name': 'tessel-erase-bin', 'type': 'none', 'sources': ['<(PRODUCT_DIR)/tessel-erase.elf'], 'rules': [{'rule_name': 'bin', 'extension': 'elf', 'outputs': ['<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).bin'], 'action': ['arm-none-eabi-objcopy', '-O', 'binary', '<(RULE_INPUT_PATH)', '<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).bin']}]}, {'target_name': 'tessel-firmware', 'type': 'none', 'dependencies': ['tessel-firmware-elf', 'tessel-firmware-hex', 'tessel-firmware-bin', 'tessel-boot-elf', 'tessel-boot-bin', 'tessel-otp-elf', 'tessel-otp-bin', 'tessel-erase-elf', 'tessel-erase-bin', 'tessel-cc3k-patch-elf', 'tessel-cc3k-patch-bin']}]}
def find_low_index(arr, key): low = 0 high = len(arr) - 1 mid = int(high / 2) # Binary Search while low <= high: mid_elem = arr[mid] if mid_elem < key: low = mid + 1 else: high = mid - 1 mid = low + int((high - low) / 2) if low < len(arr) and arr[low] == key: return low return -1 def find_high_index(arr, key): low = 0 high = len(arr) - 1 mid = int(high / 2) # Binary Search while low <= high: mid_elem = arr[mid] if mid_elem <= key: low = mid + 1 else: high = mid - 1 mid = low + int((high - low) / 2) if high < len(arr) and arr[high] == key: return high return -1 # Driver Code arr = [1, 2, 5, 5, 5, 5, 5, 5, 5, 5, 20] key = 5 print(find_low_index(arr, key), find_high_index(arr, key))
def find_low_index(arr, key): low = 0 high = len(arr) - 1 mid = int(high / 2) while low <= high: mid_elem = arr[mid] if mid_elem < key: low = mid + 1 else: high = mid - 1 mid = low + int((high - low) / 2) if low < len(arr) and arr[low] == key: return low return -1 def find_high_index(arr, key): low = 0 high = len(arr) - 1 mid = int(high / 2) while low <= high: mid_elem = arr[mid] if mid_elem <= key: low = mid + 1 else: high = mid - 1 mid = low + int((high - low) / 2) if high < len(arr) and arr[high] == key: return high return -1 arr = [1, 2, 5, 5, 5, 5, 5, 5, 5, 5, 20] key = 5 print(find_low_index(arr, key), find_high_index(arr, key))
# https://leetcode.com/problems/sqrtx/ class Solution: def mySqrt(self, x): i = 0 while x > i * i: i += 1 return i - 1
class Solution: def my_sqrt(self, x): i = 0 while x > i * i: i += 1 return i - 1
def sort(a: list) -> list: for i in range(len(a) - 1): for j in range(len(a) - i - 1): if a[j] > a[j + 1]: a[j], a[j + 1] = a[j + 1], a[j] return a a = [5, 6, 7, 8, 1, 2, 0, 3, 4, 5, 9] print(sort(a))
def sort(a: list) -> list: for i in range(len(a) - 1): for j in range(len(a) - i - 1): if a[j] > a[j + 1]: (a[j], a[j + 1]) = (a[j + 1], a[j]) return a a = [5, 6, 7, 8, 1, 2, 0, 3, 4, 5, 9] print(sort(a))
# ------------------------------------ # CODE BOOLA 2015 PYTHON WORKSHOP # Mike Wu, Jonathan Chang, Kevin Tan # Puzzle Challenges Number 5 # ------------------------------------ # Last one of the group! # You a deserve a break after this one. # ------------------------------------ # INSTRUCTIONS: # Let's keep working with strings # a little bit. You can actually convert # from strings to numbers and back! # Check out these built-in Python functions. # Try them out in the Python interactive terminal! # chr(...) => takes a number and converts # it into a letter. # chr(97) => 'a' # chr(98) => 'b' # chr(99) => 'c' # ord(...) => takes a letter and converts # it into a number. # ord('a') => 97 # ord('b') => 98 # ord('c') => 99 # Now using these... # Write a function that takes a *string* # argument and converts each character # into a number and sums all the "numbers" # in the string. # For example, "cat" => ["c", "a", "t"], # which is [99, 97, 116] => 312 # EXAMPLES: # convert("cat") => 312 # convert("dog") => 314 # convert("boola") => 525 def convert(s): pass
def convert(s): pass
def jumps(lines, part2): a = 0 steps = 0 while a < len(lines): val = lines[a] if part2 and val > 2: lines[a] = lines[a] - 1 else: lines[a] += 1 a += val steps += 1 return steps lines = [] with open("inputs/5.txt") as f: for line in f: lines.append(int(line.strip())) print("done p1:", jumps(lines[:], False)) print("done p2:", jumps(lines[:], True))
def jumps(lines, part2): a = 0 steps = 0 while a < len(lines): val = lines[a] if part2 and val > 2: lines[a] = lines[a] - 1 else: lines[a] += 1 a += val steps += 1 return steps lines = [] with open('inputs/5.txt') as f: for line in f: lines.append(int(line.strip())) print('done p1:', jumps(lines[:], False)) print('done p2:', jumps(lines[:], True))
def digit_stack(commands): value, stack = 0, [] for cmd in commands: if ' ' in cmd: stack.append(int(cmd[-1])) elif stack: value += stack[-1] if cmd == 'PEEK' else stack.pop() return value
def digit_stack(commands): (value, stack) = (0, []) for cmd in commands: if ' ' in cmd: stack.append(int(cmd[-1])) elif stack: value += stack[-1] if cmd == 'PEEK' else stack.pop() return value
print("Format is fghjstei:t:____n") print("Letters to ignore : Letters to include (yellow) : Letters correctly placed (green)") clue = input("What's the clue? ").split(':') #clue = "arosearose::_____".split(':') ignore = clue[0] use = clue[1] placed = clue[2] print(ignore, use, placed, " criteria letters.") with open("5letterwords.txt", 'r') as f: words = f.readlines() print(len(words), " total words.") if ignore: removes = [] ignorelist = list(ignore) for word in words: for letter in ignorelist: if letter in word: removes.append(word) removeset = set(removes) remaining = [i for i in words if i not in removeset] words = remaining print(len(words), " words after ignoring letters.") if use: uselist = list(use) usesletters = [] for word in words: lettercount = 0 for letter in uselist: if letter in word: lettercount += 1 if lettercount == len(uselist): usesletters.append(word) words = usesletters #print(words) if placed: placedlist = list(placed) gotplaced = [] justtheletters = [i for i in placedlist if i != '_'] for word in words: wordlist = list(word) lettercount = 0 for i, letter in enumerate(placedlist): if letter == '_': next elif letter == wordlist[i]: lettercount += 1 #print(lettercount) if lettercount == len(justtheletters): gotplaced.append(word) words = gotplaced orderedwords = [] with open("5lettertop10k.txt", 'r') as f: mostcommon = f.readlines() for commonword in mostcommon: if commonword in words: orderedwords.append(commonword) uncommonwords = [] for word in words: if word not in mostcommon: uncommonwords.append(word) words = orderedwords + uncommonwords for word in words: print(word) print(len(words), " candidates.") print(':'.join(clue), " last used letters.")
print('Format is fghjstei:t:____n') print('Letters to ignore : Letters to include (yellow) : Letters correctly placed (green)') clue = input("What's the clue? ").split(':') ignore = clue[0] use = clue[1] placed = clue[2] print(ignore, use, placed, ' criteria letters.') with open('5letterwords.txt', 'r') as f: words = f.readlines() print(len(words), ' total words.') if ignore: removes = [] ignorelist = list(ignore) for word in words: for letter in ignorelist: if letter in word: removes.append(word) removeset = set(removes) remaining = [i for i in words if i not in removeset] words = remaining print(len(words), ' words after ignoring letters.') if use: uselist = list(use) usesletters = [] for word in words: lettercount = 0 for letter in uselist: if letter in word: lettercount += 1 if lettercount == len(uselist): usesletters.append(word) words = usesletters if placed: placedlist = list(placed) gotplaced = [] justtheletters = [i for i in placedlist if i != '_'] for word in words: wordlist = list(word) lettercount = 0 for (i, letter) in enumerate(placedlist): if letter == '_': next elif letter == wordlist[i]: lettercount += 1 if lettercount == len(justtheletters): gotplaced.append(word) words = gotplaced orderedwords = [] with open('5lettertop10k.txt', 'r') as f: mostcommon = f.readlines() for commonword in mostcommon: if commonword in words: orderedwords.append(commonword) uncommonwords = [] for word in words: if word not in mostcommon: uncommonwords.append(word) words = orderedwords + uncommonwords for word in words: print(word) print(len(words), ' candidates.') print(':'.join(clue), ' last used letters.')
class Product: def __init__(self, name, price, recipe): self.name = name self.price = price self.recipe = recipe def get_price(self): return self.price def make(self): print(self.recipe) class CashBox: def __init__(self): self.credit = 0 #why do i implement this in the init vs above it? self.totalRecieved = 0 def deposit(self, amount): if amount not in (5,10,25,50): print("- INVALID AMOUNT >>>") return self.credit += amount print("Depositing", amount, "cents you have", self.credit, "cents credit.\n") def returnCoins(self): print("Returning", self.credit, "cents.\n") def haveYou(self, amount): return amount <= self.credit def deduct(self, amount): if self.haveYou(amount): self.credit -= amount self.totalRecieved += amount print("Returning", self.credit, "cents.\n") self.credit = 0 def total(self): return self.totalRecieved class Selector: def __init__(self, cashbox, products): self.cashBox = cashbox self.products = products def select(self, choiceIndex): if choiceIndex < 1 or choiceIndex > 5: print("- Invalid Choice >>>") choice = self.products[choiceIndex-1] if not self.cashBox.haveYou(choice.get_price()): print("- Not enough money\n") return else: choice.make() self.cashBox.deduct(choice.get_price()) class CoffeeMachine: def __init__(self): self.cashBox = CashBox() products = [] products.append(Product("Black", 35, "Making Black:\n\tDispensing cup\n\tDispensing coffee\n"+ "\tDispensing water")) products.append(Product("White", 35, "Making White:\n\tDispensing cup\n\tDispensing coffee\n"+ "\tDispensing creamer\n\tDispensing water")) products.append(Product("Sweet", 35, "Making Sweet:\n\tDispensing cup\n\tDispensing coffee\n"+ "Dispensing sugar\n\tDispensing water")) products.append(Product("White and Sweet", 35, "Making White & Sweet:\n\tDispensing cup\n" "\tDispensing coffee\n\tDispensing creamer\n\tDispensing sugar\n" "\tDispensing water")) products.append(Product("Bouillon", 25, "Making Bouillon:\n\tDispensing cup\n" "\tDispensing Bouillon Powder\n\t Dispensing water\n")) self.selector = Selector(self.cashBox, products) def one_action(self): print("PRODUCT LIST: all 35 cents, except bouillon (25 cents)\n" + "1=black, 2=white, 3=sweet, 4= white & sweet, 5=bouillon\n"+ "Sample commands: insert 25, select 1\n") resp = input("- Your Command: ") resp = resp.split() if resp[0] == "quit": print(self.cashBox.totalRecieved) return False if resp[0] == "cancel": self.cashBox.returnCoins() return True elif resp[0] == "insert": self.cashBox.deposit(int(resp[1])) return True elif resp[0] == "select": self.selector.select(int(resp[1])) else: print("- Invalid entry") return True def totalCash(self): return self.cashBox.total() def main(): m = CoffeeMachine() while m.one_action(): pass total = m.totalCash() print(f"Total cash: ${total/100:.2f}") if __name__ == "__main__": main()
class Product: def __init__(self, name, price, recipe): self.name = name self.price = price self.recipe = recipe def get_price(self): return self.price def make(self): print(self.recipe) class Cashbox: def __init__(self): self.credit = 0 self.totalRecieved = 0 def deposit(self, amount): if amount not in (5, 10, 25, 50): print('- INVALID AMOUNT >>>') return self.credit += amount print('Depositing', amount, 'cents you have', self.credit, 'cents credit.\n') def return_coins(self): print('Returning', self.credit, 'cents.\n') def have_you(self, amount): return amount <= self.credit def deduct(self, amount): if self.haveYou(amount): self.credit -= amount self.totalRecieved += amount print('Returning', self.credit, 'cents.\n') self.credit = 0 def total(self): return self.totalRecieved class Selector: def __init__(self, cashbox, products): self.cashBox = cashbox self.products = products def select(self, choiceIndex): if choiceIndex < 1 or choiceIndex > 5: print('- Invalid Choice >>>') choice = self.products[choiceIndex - 1] if not self.cashBox.haveYou(choice.get_price()): print('- Not enough money\n') return else: choice.make() self.cashBox.deduct(choice.get_price()) class Coffeemachine: def __init__(self): self.cashBox = cash_box() products = [] products.append(product('Black', 35, 'Making Black:\n\tDispensing cup\n\tDispensing coffee\n' + '\tDispensing water')) products.append(product('White', 35, 'Making White:\n\tDispensing cup\n\tDispensing coffee\n' + '\tDispensing creamer\n\tDispensing water')) products.append(product('Sweet', 35, 'Making Sweet:\n\tDispensing cup\n\tDispensing coffee\n' + 'Dispensing sugar\n\tDispensing water')) products.append(product('White and Sweet', 35, 'Making White & Sweet:\n\tDispensing cup\n\tDispensing coffee\n\tDispensing creamer\n\tDispensing sugar\n\tDispensing water')) products.append(product('Bouillon', 25, 'Making Bouillon:\n\tDispensing cup\n\tDispensing Bouillon Powder\n\t Dispensing water\n')) self.selector = selector(self.cashBox, products) def one_action(self): print('PRODUCT LIST: all 35 cents, except bouillon (25 cents)\n' + '1=black, 2=white, 3=sweet, 4= white & sweet, 5=bouillon\n' + 'Sample commands: insert 25, select 1\n') resp = input('- Your Command: ') resp = resp.split() if resp[0] == 'quit': print(self.cashBox.totalRecieved) return False if resp[0] == 'cancel': self.cashBox.returnCoins() return True elif resp[0] == 'insert': self.cashBox.deposit(int(resp[1])) return True elif resp[0] == 'select': self.selector.select(int(resp[1])) else: print('- Invalid entry') return True def total_cash(self): return self.cashBox.total() def main(): m = coffee_machine() while m.one_action(): pass total = m.totalCash() print(f'Total cash: ${total / 100:.2f}') if __name__ == '__main__': main()
#TESTS is a dict with all you tests. #Keys for this will be categories' names. #Each test is dict with # "input" -- input data for user function # "answer" -- your right answer # "explanation" -- not necessary key, it's using for additional info in animation. TESTS = { "1. Small By Hand 1 (Example)": [ { "input": [5, [[1, 5], [11, 15], [2, 14], [21, 25]]], "answer": 1, "explanation": [25, [5]] }, { "input": [6, [[1, 5], [11, 15], [2, 14], [21, 25]]], "answer": 2, "explanation": [25, [5, 10]] }, { "input": [11, [[1, 5], [11, 15], [2, 14], [21, 25]]], "answer": 3, "explanation": [25, [5, 10, 15]] }, { "input": [16, [[1, 5], [11, 15], [2, 14], [21, 25]]], "answer": 4, "explanation": [25, [5, 10, 15, 20]] }, { "input": [21, [[1, 5], [11, 15], [2, 14], [21, 25]]], "answer": -1, "explanation": [25, [5, 10, 15, 20]] } ], "2. Small By Hand 2": [ { "input": [5, [[1, 2], [20, 30], [25, 28], [5, 10], [4, 21], [1, 6]]], "answer": 2, "explanation": [30, [2, 13]] }, { "input": [15, [[1, 2], [20, 30], [25, 28], [5, 10], [4, 21], [1, 6]]], "answer": 4, "explanation": [30, [2, 13, 13, 19]] }, { "input": [20, [[1, 2], [20, 30], [25, 28], [5, 10], [4, 21], [1, 6]]], "answer": 5, "explanation": [30, [2, 13, 13, 19, 29]] }, { "input": [30, [[1, 2], [20, 30], [25, 28], [5, 10], [4, 21], [1, 6]]], "answer": 6, "explanation": [30, [2, 13, 13, 19, 29, 30]] }, { "input": [35, [[1, 2], [20, 30], [25, 28], [5, 10], [4, 21], [1, 6]]], "answer": -1, "explanation": [30, [2, 13, 13, 19, 29, 30]] } ], "3. Small Generated 1": [ { "input": [1000, [[8598, 9442], [4221, 4432], [4864, 5415], [1315, 1960], [9577, 10482], [8147, 8346], [6063, 6836], [24, 606], [6170, 7131], [1397, 2020], [4690, 5651], [5267, 5464], [8422, 8886], [5547, 5738], [5722, 6511], [6605, 6905], [1321, 2242], [9335, 9993], [1626, 1887], [4699, 4926]]], "answer": 2 }, { "input": [5000, [[8598, 9442], [4221, 4432], [4864, 5415], [1315, 1960], [9577, 10482], [8147, 8346], [6063, 6836], [24, 606], [6170, 7131], [1397, 2020], [4690, 5651], [5267, 5464], [8422, 8886], [5547, 5738], [5722, 6511], [6605, 6905], [1321, 2242], [9335, 9993], [1626, 1887], [4699, 4926]]], "answer": 9 }, { "input": [5400, [[8598, 9442], [4221, 4432], [4864, 5415], [1315, 1960], [9577, 10482], [8147, 8346], [6063, 6836], [24, 606], [6170, 7131], [1397, 2020], [4690, 5651], [5267, 5464], [8422, 8886], [5547, 5738], [5722, 6511], [6605, 6905], [1321, 2242], [9335, 9993], [1626, 1887], [4699, 4926]]], "answer": 11 }, { "input": [5700, [[8598, 9442], [4221, 4432], [4864, 5415], [1315, 1960], [9577, 10482], [8147, 8346], [6063, 6836], [24, 606], [6170, 7131], [1397, 2020], [4690, 5651], [5267, 5464], [8422, 8886], [5547, 5738], [5722, 6511], [6605, 6905], [1321, 2242], [9335, 9993], [1626, 1887], [4699, 4926]]], "answer": 14 }, { "input": [6000, [[8598, 9442], [4221, 4432], [4864, 5415], [1315, 1960], [9577, 10482], [8147, 8346], [6063, 6836], [24, 606], [6170, 7131], [1397, 2020], [4690, 5651], [5267, 5464], [8422, 8886], [5547, 5738], [5722, 6511], [6605, 6905], [1321, 2242], [9335, 9993], [1626, 1887], [4699, 4926]]], "answer": 15 }, { "input": [6500, [[8598, 9442], [4221, 4432], [4864, 5415], [1315, 1960], [9577, 10482], [8147, 8346], [6063, 6836], [24, 606], [6170, 7131], [1397, 2020], [4690, 5651], [5267, 5464], [8422, 8886], [5547, 5738], [5722, 6511], [6605, 6905], [1321, 2242], [9335, 9993], [1626, 1887], [4699, 4926]]], "answer": -1 } ], "4. Small Generated 2": [ { "input": [30000, [[53013, 58178], [66996, 70770], [46244, 50076], [69373, 79267], [3343, 9935], [80414, 82602], [61293, 68007], [50771, 53974], [34296, 43518], [92413, 100031], [17305, 19487], [84654, 87021], [17333, 21892], [93387, 99456], [92406, 97098], [37781, 42924], [98927, 100960], [86738, 89338], [48177, 52067], [28524, 32583]]], "answer": 6 }, { "input": [57000, [[53013, 58178], [66996, 70770], [46244, 50076], [69373, 79267], [3343, 9935], [80414, 82602], [61293, 68007], [50771, 53974], [34296, 43518], [92413, 100031], [17305, 19487], [84654, 87021], [17333, 21892], [93387, 99456], [92406, 97098], [37781, 42924], [98927, 100960], [86738, 89338], [48177, 52067], [28524, 32583]]], "answer": 11 }, { "input": [68000, [[53013, 58178], [66996, 70770], [46244, 50076], [69373, 79267], [3343, 9935], [80414, 82602], [61293, 68007], [50771, 53974], [34296, 43518], [92413, 100031], [17305, 19487], [84654, 87021], [17333, 21892], [93387, 99456], [92406, 97098], [37781, 42924], [98927, 100960], [86738, 89338], [48177, 52067], [28524, 32583]]], "answer": 20 }, { "input": [70000, [[53013, 58178], [66996, 70770], [46244, 50076], [69373, 79267], [3343, 9935], [80414, 82602], [61293, 68007], [50771, 53974], [34296, 43518], [92413, 100031], [17305, 19487], [84654, 87021], [17333, 21892], [93387, 99456], [92406, 97098], [37781, 42924], [98927, 100960], [86738, 89338], [48177, 52067], [28524, 32583]]], "answer": -1 } ], "5. Large By Hand": [ { "input": [10000000000000, [[183456789012345, 193456789078479], [163456789034827, 173456789028737], [103456789038198, 113456789073490], [123456789073249, 203456789073621]]], "answer": 1 }, { "input": [20000000000000, [[183456789012345, 193456789078479], [163456789034827, 173456789028737], [103456789038198, 113456789073490], [123456789073249, 203456789073621]]], "answer": 2 }, { "input": [30000000000000, [[183456789012345, 193456789078479], [163456789034827, 173456789028737], [103456789038198, 113456789073490], [123456789073249, 203456789073621]]], "answer": 3 }, { "input": [50000000000000, [[183456789012345, 193456789078479], [163456789034827, 173456789028737], [103456789038198, 113456789073490], [123456789073249, 203456789073621]]], "answer": 4 }, { "input": [100000000000000, [[183456789012345, 193456789078479], [163456789034827, 173456789028737], [103456789038198, 113456789073490], [123456789073249, 203456789073621]]], "answer": -1 } ], "6. Large Generated 1": [ { "input": [464578738600000, [[618092831212219, 692920328043160], [784541961979258, 849250239149590], [153212679000591, 170403813123184], [397402071388980, 494330805397679], [947688880896887, 1031315325383029], [935301256930565, 986287435347942], [15780649536663, 68473689252834], [526775205748614, 588991194047996], [655862607385363, 673910180521194], [773094918999390, 841619268667280], [155080217158458, 163523868832795], [619408007658049, 621341345909422], [187242353118947, 253984595396399], [620306694433414, 710742874379812], [268250344952342, 301251875692343], [493812097589401, 585287020679206], [660549666775455, 686382635470395], [953288849899107, 981074697686018], [752283881298002, 800681840076545], [628408208573475, 664503152611721]]], "answer": 8 }, { "input": [623032679900000, [[618092831212219, 692920328043160], [784541961979258, 849250239149590], [153212679000591, 170403813123184], [397402071388980, 494330805397679], [947688880896887, 1031315325383029], [935301256930565, 986287435347942], [15780649536663, 68473689252834], [526775205748614, 588991194047996], [655862607385363, 673910180521194], [773094918999390, 841619268667280], [155080217158458, 163523868832795], [619408007658049, 621341345909422], [187242353118947, 253984595396399], [620306694433414, 710742874379812], [268250344952342, 301251875692343], [493812097589401, 585287020679206], [660549666775455, 686382635470395], [953288849899107, 981074697686018], [752283881298002, 800681840076545], [628408208573475, 664503152611721]]], "answer": 16 }, { "input": [650000000000000, [[618092831212219, 692920328043160], [784541961979258, 849250239149590], [153212679000591, 170403813123184], [397402071388980, 494330805397679], [947688880896887, 1031315325383029], [935301256930565, 986287435347942], [15780649536663, 68473689252834], [526775205748614, 588991194047996], [655862607385363, 673910180521194], [773094918999390, 841619268667280], [155080217158458, 163523868832795], [619408007658049, 621341345909422], [187242353118947, 253984595396399], [620306694433414, 710742874379812], [268250344952342, 301251875692343], [493812097589401, 585287020679206], [660549666775455, 686382635470395], [953288849899107, 981074697686018], [752283881298002, 800681840076545], [628408208573475, 664503152611721]]], "answer": -1 } ], "7. Large Generated 2": [ { "input": [409810512978000, [[858310018365524, 902063077244091], [932665378449117, 1028409672338264], [882165278163239, 957945652291761], [155331862264691, 231608087199557], [309323812898016, 328794059405147], [311727991597994, 391226174154816], [826415306967097, 893972043882819], [170753995991478, 221100797836809], [472995836315594, 478902758061898], [779003863306990, 822734502976504], [539843675072188, 554844466580541], [977564633426502, 991018537238369], [889461015856698, 901719104033374], [268288887276466, 292053591549963], [87698520389374, 109261297832598], [650723837467456, 729926149124749], [627448683684809, 644021001384284], [264317870081369, 322309330307873], [238729907671924, 290743490959244], [938382837602825, 955450166170994]]], "answer": 10 }, { "input": [612742616513000, [[858310018365524, 902063077244091], [932665378449117, 1028409672338264], [882165278163239, 957945652291761], [155331862264691, 231608087199557], [309323812898016, 328794059405147], [311727991597994, 391226174154816], [826415306967097, 893972043882819], [170753995991478, 221100797836809], [472995836315594, 478902758061898], [779003863306990, 822734502976504], [539843675072188, 554844466580541], [977564633426502, 991018537238369], [889461015856698, 901719104033374], [268288887276466, 292053591549963], [87698520389374, 109261297832598], [650723837467456, 729926149124749], [627448683684809, 644021001384284], [264317870081369, 322309330307873], [238729907671924, 290743490959244], [938382837602825, 955450166170994]]], "answer": 19 }, { "input": [620000000000000, [[858310018365524, 902063077244091], [932665378449117, 1028409672338264], [882165278163239, 957945652291761], [155331862264691, 231608087199557], [309323812898016, 328794059405147], [311727991597994, 391226174154816], [826415306967097, 893972043882819], [170753995991478, 221100797836809], [472995836315594, 478902758061898], [779003863306990, 822734502976504], [539843675072188, 554844466580541], [977564633426502, 991018537238369], [889461015856698, 901719104033374], [268288887276466, 292053591549963], [87698520389374, 109261297832598], [650723837467456, 729926149124749], [627448683684809, 644021001384284], [264317870081369, 322309330307873], [238729907671924, 290743490959244], [938382837602825, 955450166170994]]], "answer": -1 } ], }
tests = {'1. Small By Hand 1 (Example)': [{'input': [5, [[1, 5], [11, 15], [2, 14], [21, 25]]], 'answer': 1, 'explanation': [25, [5]]}, {'input': [6, [[1, 5], [11, 15], [2, 14], [21, 25]]], 'answer': 2, 'explanation': [25, [5, 10]]}, {'input': [11, [[1, 5], [11, 15], [2, 14], [21, 25]]], 'answer': 3, 'explanation': [25, [5, 10, 15]]}, {'input': [16, [[1, 5], [11, 15], [2, 14], [21, 25]]], 'answer': 4, 'explanation': [25, [5, 10, 15, 20]]}, {'input': [21, [[1, 5], [11, 15], [2, 14], [21, 25]]], 'answer': -1, 'explanation': [25, [5, 10, 15, 20]]}], '2. Small By Hand 2': [{'input': [5, [[1, 2], [20, 30], [25, 28], [5, 10], [4, 21], [1, 6]]], 'answer': 2, 'explanation': [30, [2, 13]]}, {'input': [15, [[1, 2], [20, 30], [25, 28], [5, 10], [4, 21], [1, 6]]], 'answer': 4, 'explanation': [30, [2, 13, 13, 19]]}, {'input': [20, [[1, 2], [20, 30], [25, 28], [5, 10], [4, 21], [1, 6]]], 'answer': 5, 'explanation': [30, [2, 13, 13, 19, 29]]}, {'input': [30, [[1, 2], [20, 30], [25, 28], [5, 10], [4, 21], [1, 6]]], 'answer': 6, 'explanation': [30, [2, 13, 13, 19, 29, 30]]}, {'input': [35, [[1, 2], [20, 30], [25, 28], [5, 10], [4, 21], [1, 6]]], 'answer': -1, 'explanation': [30, [2, 13, 13, 19, 29, 30]]}], '3. Small Generated 1': [{'input': [1000, [[8598, 9442], [4221, 4432], [4864, 5415], [1315, 1960], [9577, 10482], [8147, 8346], [6063, 6836], [24, 606], [6170, 7131], [1397, 2020], [4690, 5651], [5267, 5464], [8422, 8886], [5547, 5738], [5722, 6511], [6605, 6905], [1321, 2242], [9335, 9993], [1626, 1887], [4699, 4926]]], 'answer': 2}, {'input': [5000, [[8598, 9442], [4221, 4432], [4864, 5415], [1315, 1960], [9577, 10482], [8147, 8346], [6063, 6836], [24, 606], [6170, 7131], [1397, 2020], [4690, 5651], [5267, 5464], [8422, 8886], [5547, 5738], [5722, 6511], [6605, 6905], [1321, 2242], [9335, 9993], [1626, 1887], [4699, 4926]]], 'answer': 9}, {'input': [5400, [[8598, 9442], [4221, 4432], [4864, 5415], [1315, 1960], [9577, 10482], [8147, 8346], [6063, 6836], [24, 606], [6170, 7131], [1397, 2020], [4690, 5651], [5267, 5464], [8422, 8886], [5547, 5738], [5722, 6511], [6605, 6905], [1321, 2242], [9335, 9993], [1626, 1887], [4699, 4926]]], 'answer': 11}, {'input': [5700, [[8598, 9442], [4221, 4432], [4864, 5415], [1315, 1960], [9577, 10482], [8147, 8346], [6063, 6836], [24, 606], [6170, 7131], [1397, 2020], [4690, 5651], [5267, 5464], [8422, 8886], [5547, 5738], [5722, 6511], [6605, 6905], [1321, 2242], [9335, 9993], [1626, 1887], [4699, 4926]]], 'answer': 14}, {'input': [6000, [[8598, 9442], [4221, 4432], [4864, 5415], [1315, 1960], [9577, 10482], [8147, 8346], [6063, 6836], [24, 606], [6170, 7131], [1397, 2020], [4690, 5651], [5267, 5464], [8422, 8886], [5547, 5738], [5722, 6511], [6605, 6905], [1321, 2242], [9335, 9993], [1626, 1887], [4699, 4926]]], 'answer': 15}, {'input': [6500, [[8598, 9442], [4221, 4432], [4864, 5415], [1315, 1960], [9577, 10482], [8147, 8346], [6063, 6836], [24, 606], [6170, 7131], [1397, 2020], [4690, 5651], [5267, 5464], [8422, 8886], [5547, 5738], [5722, 6511], [6605, 6905], [1321, 2242], [9335, 9993], [1626, 1887], [4699, 4926]]], 'answer': -1}], '4. Small Generated 2': [{'input': [30000, [[53013, 58178], [66996, 70770], [46244, 50076], [69373, 79267], [3343, 9935], [80414, 82602], [61293, 68007], [50771, 53974], [34296, 43518], [92413, 100031], [17305, 19487], [84654, 87021], [17333, 21892], [93387, 99456], [92406, 97098], [37781, 42924], [98927, 100960], [86738, 89338], [48177, 52067], [28524, 32583]]], 'answer': 6}, {'input': [57000, [[53013, 58178], [66996, 70770], [46244, 50076], [69373, 79267], [3343, 9935], [80414, 82602], [61293, 68007], [50771, 53974], [34296, 43518], [92413, 100031], [17305, 19487], [84654, 87021], [17333, 21892], [93387, 99456], [92406, 97098], [37781, 42924], [98927, 100960], [86738, 89338], [48177, 52067], [28524, 32583]]], 'answer': 11}, {'input': [68000, [[53013, 58178], [66996, 70770], [46244, 50076], [69373, 79267], [3343, 9935], [80414, 82602], [61293, 68007], [50771, 53974], [34296, 43518], [92413, 100031], [17305, 19487], [84654, 87021], [17333, 21892], [93387, 99456], [92406, 97098], [37781, 42924], [98927, 100960], [86738, 89338], [48177, 52067], [28524, 32583]]], 'answer': 20}, {'input': [70000, [[53013, 58178], [66996, 70770], [46244, 50076], [69373, 79267], [3343, 9935], [80414, 82602], [61293, 68007], [50771, 53974], [34296, 43518], [92413, 100031], [17305, 19487], [84654, 87021], [17333, 21892], [93387, 99456], [92406, 97098], [37781, 42924], [98927, 100960], [86738, 89338], [48177, 52067], [28524, 32583]]], 'answer': -1}], '5. Large By Hand': [{'input': [10000000000000, [[183456789012345, 193456789078479], [163456789034827, 173456789028737], [103456789038198, 113456789073490], [123456789073249, 203456789073621]]], 'answer': 1}, {'input': [20000000000000, [[183456789012345, 193456789078479], [163456789034827, 173456789028737], [103456789038198, 113456789073490], [123456789073249, 203456789073621]]], 'answer': 2}, {'input': [30000000000000, [[183456789012345, 193456789078479], [163456789034827, 173456789028737], [103456789038198, 113456789073490], [123456789073249, 203456789073621]]], 'answer': 3}, {'input': [50000000000000, [[183456789012345, 193456789078479], [163456789034827, 173456789028737], [103456789038198, 113456789073490], [123456789073249, 203456789073621]]], 'answer': 4}, {'input': [100000000000000, [[183456789012345, 193456789078479], [163456789034827, 173456789028737], [103456789038198, 113456789073490], [123456789073249, 203456789073621]]], 'answer': -1}], '6. Large Generated 1': [{'input': [464578738600000, [[618092831212219, 692920328043160], [784541961979258, 849250239149590], [153212679000591, 170403813123184], [397402071388980, 494330805397679], [947688880896887, 1031315325383029], [935301256930565, 986287435347942], [15780649536663, 68473689252834], [526775205748614, 588991194047996], [655862607385363, 673910180521194], [773094918999390, 841619268667280], [155080217158458, 163523868832795], [619408007658049, 621341345909422], [187242353118947, 253984595396399], [620306694433414, 710742874379812], [268250344952342, 301251875692343], [493812097589401, 585287020679206], [660549666775455, 686382635470395], [953288849899107, 981074697686018], [752283881298002, 800681840076545], [628408208573475, 664503152611721]]], 'answer': 8}, {'input': [623032679900000, [[618092831212219, 692920328043160], [784541961979258, 849250239149590], [153212679000591, 170403813123184], [397402071388980, 494330805397679], [947688880896887, 1031315325383029], [935301256930565, 986287435347942], [15780649536663, 68473689252834], [526775205748614, 588991194047996], [655862607385363, 673910180521194], [773094918999390, 841619268667280], [155080217158458, 163523868832795], [619408007658049, 621341345909422], [187242353118947, 253984595396399], [620306694433414, 710742874379812], [268250344952342, 301251875692343], [493812097589401, 585287020679206], [660549666775455, 686382635470395], [953288849899107, 981074697686018], [752283881298002, 800681840076545], [628408208573475, 664503152611721]]], 'answer': 16}, {'input': [650000000000000, [[618092831212219, 692920328043160], [784541961979258, 849250239149590], [153212679000591, 170403813123184], [397402071388980, 494330805397679], [947688880896887, 1031315325383029], [935301256930565, 986287435347942], [15780649536663, 68473689252834], [526775205748614, 588991194047996], [655862607385363, 673910180521194], [773094918999390, 841619268667280], [155080217158458, 163523868832795], [619408007658049, 621341345909422], [187242353118947, 253984595396399], [620306694433414, 710742874379812], [268250344952342, 301251875692343], [493812097589401, 585287020679206], [660549666775455, 686382635470395], [953288849899107, 981074697686018], [752283881298002, 800681840076545], [628408208573475, 664503152611721]]], 'answer': -1}], '7. Large Generated 2': [{'input': [409810512978000, [[858310018365524, 902063077244091], [932665378449117, 1028409672338264], [882165278163239, 957945652291761], [155331862264691, 231608087199557], [309323812898016, 328794059405147], [311727991597994, 391226174154816], [826415306967097, 893972043882819], [170753995991478, 221100797836809], [472995836315594, 478902758061898], [779003863306990, 822734502976504], [539843675072188, 554844466580541], [977564633426502, 991018537238369], [889461015856698, 901719104033374], [268288887276466, 292053591549963], [87698520389374, 109261297832598], [650723837467456, 729926149124749], [627448683684809, 644021001384284], [264317870081369, 322309330307873], [238729907671924, 290743490959244], [938382837602825, 955450166170994]]], 'answer': 10}, {'input': [612742616513000, [[858310018365524, 902063077244091], [932665378449117, 1028409672338264], [882165278163239, 957945652291761], [155331862264691, 231608087199557], [309323812898016, 328794059405147], [311727991597994, 391226174154816], [826415306967097, 893972043882819], [170753995991478, 221100797836809], [472995836315594, 478902758061898], [779003863306990, 822734502976504], [539843675072188, 554844466580541], [977564633426502, 991018537238369], [889461015856698, 901719104033374], [268288887276466, 292053591549963], [87698520389374, 109261297832598], [650723837467456, 729926149124749], [627448683684809, 644021001384284], [264317870081369, 322309330307873], [238729907671924, 290743490959244], [938382837602825, 955450166170994]]], 'answer': 19}, {'input': [620000000000000, [[858310018365524, 902063077244091], [932665378449117, 1028409672338264], [882165278163239, 957945652291761], [155331862264691, 231608087199557], [309323812898016, 328794059405147], [311727991597994, 391226174154816], [826415306967097, 893972043882819], [170753995991478, 221100797836809], [472995836315594, 478902758061898], [779003863306990, 822734502976504], [539843675072188, 554844466580541], [977564633426502, 991018537238369], [889461015856698, 901719104033374], [268288887276466, 292053591549963], [87698520389374, 109261297832598], [650723837467456, 729926149124749], [627448683684809, 644021001384284], [264317870081369, 322309330307873], [238729907671924, 290743490959244], [938382837602825, 955450166170994]]], 'answer': -1}]}
height=4.5 h_inch=height*12 h_meter=(height*2.54)/100 print('Height is ',h_inch,'inch') print('Height is ',h_meter,'meter')
height = 4.5 h_inch = height * 12 h_meter = height * 2.54 / 100 print('Height is ', h_inch, 'inch') print('Height is ', h_meter, 'meter')
with open("advent5.txt", "r") as file: input_ = file.read().split('\n') row_ids = [] for seat in input_: rows = seat[:7] cols = seat[7:] row_range = range(128) for letter in rows: middle_index = len(row_range)//2 if letter == "F": row_range = row_range[:middle_index] else: row_range = row_range[middle_index:] row = row_range[0] col_range = range(8) for letter in cols: middle_index = len(col_range)//2 if letter == "L": col_range = col_range[:middle_index] else: col_range = col_range[middle_index:] col = col_range[0] row_ids.append(row * 8 + col) print(max(row_ids)) for i in range(min(row_ids), max(row_ids)+1): if i not in row_ids: print(i)
with open('advent5.txt', 'r') as file: input_ = file.read().split('\n') row_ids = [] for seat in input_: rows = seat[:7] cols = seat[7:] row_range = range(128) for letter in rows: middle_index = len(row_range) // 2 if letter == 'F': row_range = row_range[:middle_index] else: row_range = row_range[middle_index:] row = row_range[0] col_range = range(8) for letter in cols: middle_index = len(col_range) // 2 if letter == 'L': col_range = col_range[:middle_index] else: col_range = col_range[middle_index:] col = col_range[0] row_ids.append(row * 8 + col) print(max(row_ids)) for i in range(min(row_ids), max(row_ids) + 1): if i not in row_ids: print(i)
shepherd = "Mary" age = 32 stuff_in_string = "Shepherd {} is {} years old.".format(shepherd, age) print(stuff_in_string) shepherd = "Martha" age = 34 # Note f before first quote of string stuff_in_string = "Shepherd %s is %d years old." % (shepherd, age) print(stuff_in_string)
shepherd = 'Mary' age = 32 stuff_in_string = 'Shepherd {} is {} years old.'.format(shepherd, age) print(stuff_in_string) shepherd = 'Martha' age = 34 stuff_in_string = 'Shepherd %s is %d years old.' % (shepherd, age) print(stuff_in_string)
def dict_contains(child_dict, parent_dict): for key, value in child_dict.items(): if key not in parent_dict: return False if parent_dict[key] != value: return False return True
def dict_contains(child_dict, parent_dict): for (key, value) in child_dict.items(): if key not in parent_dict: return False if parent_dict[key] != value: return False return True
class Solution: def wordPattern(self, pattern: str, s: str) -> bool: words = s.split(' ') patternMap, wordMap = {}, {} if len(pattern) != len(words): return False for index, char in enumerate(pattern): if char in patternMap: if patternMap[char] != words[index]: return False else: if words[index] in wordMap: return False else: patternMap[char] = words[index] wordMap[words[index]] = char return True
class Solution: def word_pattern(self, pattern: str, s: str) -> bool: words = s.split(' ') (pattern_map, word_map) = ({}, {}) if len(pattern) != len(words): return False for (index, char) in enumerate(pattern): if char in patternMap: if patternMap[char] != words[index]: return False elif words[index] in wordMap: return False else: patternMap[char] = words[index] wordMap[words[index]] = char return True
#!/usr/bin/env python # # Copyright (c) 2015 Pavel Lazar pavel.lazar (at) gmail.com # # The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. ##################################################################### class ClickConfiguration(object): REQUIREMENTS_PATTERN = 'require(package "{package}");' def __init__(self, requirements=None, elements=None, connections=None): self.requirements = requirements or [] self.elements = elements or [] self.connections = connections or [] self._elements_by_name = dict((element.name, element) for element in self.elements) def to_engine_config(self): config = [] for requirement in self.requirements: config.append(self.REQUIREMENTS_PATTERN.format(package=requirement)) for element in self.elements: config.append(element.to_click_config()) for connection in self.connections: config.append(connection.to_click_config()) return '\n'.join(config) def __eq__(self, other): if not isinstance(other, self.__class__): return False return (self.requirements == other.requirements and self.elements == other.elements and self.connections == other.connections) def __ne__(self, other): return not self.__eq__(other)
class Clickconfiguration(object): requirements_pattern = 'require(package "{package}");' def __init__(self, requirements=None, elements=None, connections=None): self.requirements = requirements or [] self.elements = elements or [] self.connections = connections or [] self._elements_by_name = dict(((element.name, element) for element in self.elements)) def to_engine_config(self): config = [] for requirement in self.requirements: config.append(self.REQUIREMENTS_PATTERN.format(package=requirement)) for element in self.elements: config.append(element.to_click_config()) for connection in self.connections: config.append(connection.to_click_config()) return '\n'.join(config) def __eq__(self, other): if not isinstance(other, self.__class__): return False return self.requirements == other.requirements and self.elements == other.elements and (self.connections == other.connections) def __ne__(self, other): return not self.__eq__(other)
scale = 1000000 prime_checker = [i for i in range(scale + 1)] prime_checker[1] = 0 for i in range(2, int(scale ** 0.5) + 1): if prime_checker[i] != 0: for j in range(2, (scale // i) + 1): prime_checker[i * j] = 0 for _ in range(int(input())): count = 0 k = int(input()) for a in range(2, (k//2)+1): if prime_checker[k - prime_checker[a]] != 0: count += 1 print(count)
scale = 1000000 prime_checker = [i for i in range(scale + 1)] prime_checker[1] = 0 for i in range(2, int(scale ** 0.5) + 1): if prime_checker[i] != 0: for j in range(2, scale // i + 1): prime_checker[i * j] = 0 for _ in range(int(input())): count = 0 k = int(input()) for a in range(2, k // 2 + 1): if prime_checker[k - prime_checker[a]] != 0: count += 1 print(count)
def findDecision(obj): #obj[0]: Passanger, obj[1]: Time, obj[2]: Coupon, obj[3]: Gender, obj[4]: Age, obj[5]: Children, obj[6]: Education, obj[7]: Occupation, obj[8]: Income, obj[9]: Bar, obj[10]: Coffeehouse, obj[11]: Restaurant20to50, obj[12]: Direction_same, obj[13]: Distance # {"feature": "Distance", "instances": 51, "metric_value": 0.9997, "depth": 1} if obj[13]>1: # {"feature": "Occupation", "instances": 27, "metric_value": 0.8256, "depth": 2} if obj[7]>7: # {"feature": "Coupon", "instances": 14, "metric_value": 0.9852, "depth": 3} if obj[2]<=3: # {"feature": "Passanger", "instances": 11, "metric_value": 0.994, "depth": 4} if obj[0]<=1: # {"feature": "Age", "instances": 7, "metric_value": 0.8631, "depth": 5} if obj[4]<=2: # {"feature": "Income", "instances": 6, "metric_value": 0.65, "depth": 6} if obj[8]<=5: return 'False' elif obj[8]>5: # {"feature": "Time", "instances": 2, "metric_value": 1.0, "depth": 7} if obj[1]>1: return 'False' elif obj[1]<=1: return 'True' else: return 'True' else: return 'False' elif obj[4]>2: return 'True' else: return 'True' elif obj[0]>1: return 'True' else: return 'True' elif obj[2]>3: return 'False' else: return 'False' elif obj[7]<=7: # {"feature": "Bar", "instances": 13, "metric_value": 0.3912, "depth": 3} if obj[9]<=1.0: return 'False' elif obj[9]>1.0: # {"feature": "Time", "instances": 2, "metric_value": 1.0, "depth": 4} if obj[1]<=1: return 'False' elif obj[1]>1: return 'True' else: return 'True' else: return 'False' else: return 'False' elif obj[13]<=1: # {"feature": "Income", "instances": 24, "metric_value": 0.7383, "depth": 2} if obj[8]>1: # {"feature": "Coffeehouse", "instances": 19, "metric_value": 0.4855, "depth": 3} if obj[10]>0.0: return 'True' elif obj[10]<=0.0: # {"feature": "Occupation", "instances": 7, "metric_value": 0.8631, "depth": 4} if obj[7]<=5: return 'True' elif obj[7]>5: # {"feature": "Restaurant20to50", "instances": 3, "metric_value": 0.9183, "depth": 5} if obj[11]>0.0: return 'False' elif obj[11]<=0.0: return 'True' else: return 'True' else: return 'False' else: return 'True' elif obj[8]<=1: # {"feature": "Children", "instances": 5, "metric_value": 0.971, "depth": 3} if obj[5]>0: return 'False' elif obj[5]<=0: return 'True' else: return 'True' else: return 'False' else: return 'True'
def find_decision(obj): if obj[13] > 1: if obj[7] > 7: if obj[2] <= 3: if obj[0] <= 1: if obj[4] <= 2: if obj[8] <= 5: return 'False' elif obj[8] > 5: if obj[1] > 1: return 'False' elif obj[1] <= 1: return 'True' else: return 'True' else: return 'False' elif obj[4] > 2: return 'True' else: return 'True' elif obj[0] > 1: return 'True' else: return 'True' elif obj[2] > 3: return 'False' else: return 'False' elif obj[7] <= 7: if obj[9] <= 1.0: return 'False' elif obj[9] > 1.0: if obj[1] <= 1: return 'False' elif obj[1] > 1: return 'True' else: return 'True' else: return 'False' else: return 'False' elif obj[13] <= 1: if obj[8] > 1: if obj[10] > 0.0: return 'True' elif obj[10] <= 0.0: if obj[7] <= 5: return 'True' elif obj[7] > 5: if obj[11] > 0.0: return 'False' elif obj[11] <= 0.0: return 'True' else: return 'True' else: return 'False' else: return 'True' elif obj[8] <= 1: if obj[5] > 0: return 'False' elif obj[5] <= 0: return 'True' else: return 'True' else: return 'False' else: return 'True'
class User: ''' Class that generates new instances of Users ''' user_list=[] def __init__(self,username,password): self.username=username self.password=password def save_user(self): ''' save_user method saves user objects to the user_list ''' User.user_list.append(self) @classmethod def user_verificate(cls,username,password): ''' Return a boolean on given inputs ''' for user in cls.user_list: if user.username==username and user.password==password: return True return False
class User: """ Class that generates new instances of Users """ user_list = [] def __init__(self, username, password): self.username = username self.password = password def save_user(self): """ save_user method saves user objects to the user_list """ User.user_list.append(self) @classmethod def user_verificate(cls, username, password): """ Return a boolean on given inputs """ for user in cls.user_list: if user.username == username and user.password == password: return True return False
#deleting a element from list # deleting one or more element at same time from list is possible using the keyword del. It can also delete the list entirely. list_pri=[1,3,5,7,8,11,13,17,19,23] del list_pri[4] print(list_pri) #[1,3,5,7,11,13,17,19,23] del list_pri[0:9] print(list_pri) del list_pri print(list_pri)#---->will always result in an error
list_pri = [1, 3, 5, 7, 8, 11, 13, 17, 19, 23] del list_pri[4] print(list_pri) del list_pri[0:9] print(list_pri) del list_pri print(list_pri)
# Category description for the widget registry NAME = "SOLEIL SRW Light Sources" DESCRIPTION = "Widgets for SOLEIL SRW" BACKGROUND = "#b8bcdb" ICON = "icons/source.png" PRIORITY = 210
name = 'SOLEIL SRW Light Sources' description = 'Widgets for SOLEIL SRW' background = '#b8bcdb' icon = 'icons/source.png' priority = 210
_base_ = '../htc/htc_r50_fpn_1x_coco_1280.py' # optimizer optimizer = dict(lr=0.005) model = dict( pretrained=\ './checkpoints/lesa_pretrained_imagenet/'+\ 'lesa_wrn50_pretrained/'+\ 'lesa_wrn50/'+\ 'checkpoint.pth', backbone=dict( type='ResNet', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=1, norm_cfg=dict(type='BN', requires_grad=True), norm_eval=True, style='pytorch', strides=(1,2,2,2), wrn=True, dcn=dict(type='DCN', deform_groups=1, fallback_on_stride=False), stage_with_dcn=(False, True, True, True), stage_spatial_res=[320, 160, 80, 40], # 1024: [256, 128, 64, 32], 1280: [320, 160, 80, 40] stage_with_first_conv = [True, True, True, False], lesa=dict( type='LESA', with_cp_UB_terms_only=True, # cp used on the unary and binary terms only. pe_type='detection_qr', # ('classification', 'detection_qr') groups = 8, df_channel_shrink = [2], # df: dynamic fusion df_kernel_size = [1,1], df_group = [1,1], ), stage_with_lesa = (False, False, True, True), ) ) # dataset settings img_norm_cfg = dict( mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) train_pipeline = [ dict(type='LoadImageFromFile'), dict( type='LoadAnnotations', with_bbox=True, with_mask=True, with_seg=True), dict(type='Resize', img_scale=(1280, 1280), keep_ratio=False), dict(type='RandomFlip', flip_ratio=0.5), dict(type='Normalize', **img_norm_cfg), dict(type='Pad', size_divisor=32), dict(type='SegRescale', scale_factor=1 / 8), dict(type='DefaultFormatBundle'), dict( type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks', 'gt_semantic_seg']), ] data_root = 'data/coco/' data = dict( samples_per_gpu=1, workers_per_gpu=1, train=dict(pipeline=train_pipeline), # test=dict( # ann_file=data_root + 'annotations/image_info_test-dev2017.json', # img_prefix=data_root + 'test2017/'), ) # learning policy lr_config = dict(step=[16, 19]) runner = dict(type='EpochBasedRunner', max_epochs=20)
_base_ = '../htc/htc_r50_fpn_1x_coco_1280.py' optimizer = dict(lr=0.005) model = dict(pretrained='./checkpoints/lesa_pretrained_imagenet/' + 'lesa_wrn50_pretrained/' + 'lesa_wrn50/' + 'checkpoint.pth', backbone=dict(type='ResNet', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=1, norm_cfg=dict(type='BN', requires_grad=True), norm_eval=True, style='pytorch', strides=(1, 2, 2, 2), wrn=True, dcn=dict(type='DCN', deform_groups=1, fallback_on_stride=False), stage_with_dcn=(False, True, True, True), stage_spatial_res=[320, 160, 80, 40], stage_with_first_conv=[True, True, True, False], lesa=dict(type='LESA', with_cp_UB_terms_only=True, pe_type='detection_qr', groups=8, df_channel_shrink=[2], df_kernel_size=[1, 1], df_group=[1, 1]), stage_with_lesa=(False, False, True, True))) img_norm_cfg = dict(mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) train_pipeline = [dict(type='LoadImageFromFile'), dict(type='LoadAnnotations', with_bbox=True, with_mask=True, with_seg=True), dict(type='Resize', img_scale=(1280, 1280), keep_ratio=False), dict(type='RandomFlip', flip_ratio=0.5), dict(type='Normalize', **img_norm_cfg), dict(type='Pad', size_divisor=32), dict(type='SegRescale', scale_factor=1 / 8), dict(type='DefaultFormatBundle'), dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks', 'gt_semantic_seg'])] data_root = 'data/coco/' data = dict(samples_per_gpu=1, workers_per_gpu=1, train=dict(pipeline=train_pipeline)) lr_config = dict(step=[16, 19]) runner = dict(type='EpochBasedRunner', max_epochs=20)
class GitHubRequestException(BaseException): pass class GithubDecodeError(BaseException): pass
class Githubrequestexception(BaseException): pass class Githubdecodeerror(BaseException): pass
tests = int(input()) def solve(C, R): c = C//9 r = R//9 if not C%9 ==0: c += 1 if not R%9 == 0: r += 1 if c < r: return [0, c] else: return [1, r] for t in range(tests): C, R = map(int, input().split()) ans = solve(C, R) print(ans[0], ans[1])
tests = int(input()) def solve(C, R): c = C // 9 r = R // 9 if not C % 9 == 0: c += 1 if not R % 9 == 0: r += 1 if c < r: return [0, c] else: return [1, r] for t in range(tests): (c, r) = map(int, input().split()) ans = solve(C, R) print(ans[0], ans[1])
#!/usr/bin/env python3 s = input() i = 0 while i < len(s): print(s[i:]) i = i + 1
s = input() i = 0 while i < len(s): print(s[i:]) i = i + 1
def greeting(name): print("Hello " + name + "!") def goodbye(name): print("Goodbye " + name + "!")
def greeting(name): print('Hello ' + name + '!') def goodbye(name): print('Goodbye ' + name + '!')
''' The Models folder consists of files representing trained/retrained models as part of build jobs, etc. The model names can be appropriately set as projectname_date_time or project_build_id (in case the model is created as part of build jobs). Another approach is to store the model files in a separate storage such as AWS S3, Google Cloud Storage, or any other form of storage. '''
""" The Models folder consists of files representing trained/retrained models as part of build jobs, etc. The model names can be appropriately set as projectname_date_time or project_build_id (in case the model is created as part of build jobs). Another approach is to store the model files in a separate storage such as AWS S3, Google Cloud Storage, or any other form of storage. """
x=int(input("lungima saritura initiala")) n=int(input("numar sarituri pana scade")) p=int(input("cu cate procente scade")) m=int(input("numar sarituri totale")) s=0 for i in range (m): s+=x if i+1 == n: k=p*x//100 x-=k n*=2 print(s)
x = int(input('lungima saritura initiala')) n = int(input('numar sarituri pana scade')) p = int(input('cu cate procente scade')) m = int(input('numar sarituri totale')) s = 0 for i in range(m): s += x if i + 1 == n: k = p * x // 100 x -= k n *= 2 print(s)
# Number of classes N_CLASSES = 1000 # Root directory of the `MS-ASL` dataset _MSASL_DIR = 'D:/datasets/msasl' # Directory of the `MS-ASL` dataset specification files _MSASL_SPECS_DIR = f'{_MSASL_DIR}/specs' # Directory of the filtered `MS-ASL` dataset specification files _MSASL_FILTERED_SPECS_DIR = f'{_MSASL_DIR}/filtered_specs' # Directory of the downloaded `MS-ASL` YouTube videos _MSASL_VIDEOS_DIR = f'{_MSASL_DIR}/videos' # Directory of the `MS-ASL` train, validation and test `TFRecord` files _MSASL_TF_RECORDS_DIR = f'{_MSASL_DIR}/tf_records'
n_classes = 1000 _msasl_dir = 'D:/datasets/msasl' _msasl_specs_dir = f'{_MSASL_DIR}/specs' _msasl_filtered_specs_dir = f'{_MSASL_DIR}/filtered_specs' _msasl_videos_dir = f'{_MSASL_DIR}/videos' _msasl_tf_records_dir = f'{_MSASL_DIR}/tf_records'
class StorageError(Exception): pass class RegistrationError(Exception): pass
class Storageerror(Exception): pass class Registrationerror(Exception): pass
class SetupMaster(object): def check_os(): if 'CentOS Linux' in platform.linux_distribution(): redhat_setup() else: debian_setup()
class Setupmaster(object): def check_os(): if 'CentOS Linux' in platform.linux_distribution(): redhat_setup() else: debian_setup()
''' A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given a non-empty string containing only digits, determine the total number of ways to decode it. The answer is guaranteed to fit in a 32-bit integer. Example 1: Input: s = "12" Output: 2 Explanation: It could be decoded as "AB" (1 2) or "L" (12). Example 2: Input: s = "226" Output: 3 Explanation: It could be decoded as "BZ" (2 26), "VF" (22 6), or "BBF" (2 2 6). Example 3: Input: s = "0" Output: 0 Explanation: There is no character that is mapped to a number starting with '0'. We cannot ignore a zero when we face it while decoding. So, each '0' should be part of "10" --> 'J' or "20" --> 'T'. Example 4: Input: s = "1" Output: 1 ''' #APPROACH -> O(N) TC and O(1) Space ''' For each character, we have two ways to decode it. We can either Decode it as a single digit, or Combine it with the previous character, and decode as two digits. ''' class Solution(object): def numDecodings(self, s): prev = 1 curr = int(s[0] != '0') for elem in range(1, len(s)): if not prev and not curr: # Small optimization: if there are 0 ways to # decode s[:elem-1] and s[:elem], return immediately. return 0 # Single digit case ways = s[elem] != '0' and curr # Two-digit case ways += 10 <= int(s[elem-1:elem+1]) <= 26 and prev prev = curr curr = ways return curr
""" A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given a non-empty string containing only digits, determine the total number of ways to decode it. The answer is guaranteed to fit in a 32-bit integer. Example 1: Input: s = "12" Output: 2 Explanation: It could be decoded as "AB" (1 2) or "L" (12). Example 2: Input: s = "226" Output: 3 Explanation: It could be decoded as "BZ" (2 26), "VF" (22 6), or "BBF" (2 2 6). Example 3: Input: s = "0" Output: 0 Explanation: There is no character that is mapped to a number starting with '0'. We cannot ignore a zero when we face it while decoding. So, each '0' should be part of "10" --> 'J' or "20" --> 'T'. Example 4: Input: s = "1" Output: 1 """ '\nFor each character, we have two ways to decode it. We can either\n\nDecode it as a single digit, or\nCombine it with the previous character, and decode as two digits.\n' class Solution(object): def num_decodings(self, s): prev = 1 curr = int(s[0] != '0') for elem in range(1, len(s)): if not prev and (not curr): return 0 ways = s[elem] != '0' and curr ways += 10 <= int(s[elem - 1:elem + 1]) <= 26 and prev prev = curr curr = ways return curr
def get_parameters(code_header): begin = -1 end = -1 for i in range(0, len(code_header)): if code_header[i] == '(': begin = i for i in reversed(range(0, len(code_header))): if code_header[i] == ')': end = i if begin == -1 or end == -1: parameter = None else: parameter = code_header[begin + 1:end] return parameter, begin, end def get_number_parameters(parameters): number_parameters = len(parameters.split(',')) return number_parameters def get_types_parameters(parameter): types_parameters = [] parameters = parameter.split(',') for param in parameters: temp = param.lstrip() # remove whitespace, tab and newline from begin of string temp = temp.rstrip() # remove whitespace, tab and newline from end of string temp = temp.split(' ') # separate string by space types_parameters.append(temp[0]) # temp[0] is var type and temp[1] is var name return types_parameters def get_return_type(code_header, begin): if begin == -1: return header_without_parameters = code_header[:begin] header_without_parameters = header_without_parameters.split(' ') return_type = header_without_parameters[-2] return return_type # receives list of lines of the method and extract number_parameters, types_parameters, return_type def extractor(method_lines): code_header = method_lines[0] parameter, begin, end = get_parameters(code_header) # begin and end of parameters if parameter is None: return number_parameters = get_number_parameters(parameter) types_parameters = get_types_parameters(parameter) return_type = get_return_type(code_header, begin) return number_parameters, types_parameters, return_type
def get_parameters(code_header): begin = -1 end = -1 for i in range(0, len(code_header)): if code_header[i] == '(': begin = i for i in reversed(range(0, len(code_header))): if code_header[i] == ')': end = i if begin == -1 or end == -1: parameter = None else: parameter = code_header[begin + 1:end] return (parameter, begin, end) def get_number_parameters(parameters): number_parameters = len(parameters.split(',')) return number_parameters def get_types_parameters(parameter): types_parameters = [] parameters = parameter.split(',') for param in parameters: temp = param.lstrip() temp = temp.rstrip() temp = temp.split(' ') types_parameters.append(temp[0]) return types_parameters def get_return_type(code_header, begin): if begin == -1: return header_without_parameters = code_header[:begin] header_without_parameters = header_without_parameters.split(' ') return_type = header_without_parameters[-2] return return_type def extractor(method_lines): code_header = method_lines[0] (parameter, begin, end) = get_parameters(code_header) if parameter is None: return number_parameters = get_number_parameters(parameter) types_parameters = get_types_parameters(parameter) return_type = get_return_type(code_header, begin) return (number_parameters, types_parameters, return_type)
class RenguMapPass: def __call__(self, obj: dict): return obj
class Rengumappass: def __call__(self, obj: dict): return obj
fiboarr=[0,1] def fibonacci(n): if n<=0: print("Invalid input") elif n<=len(fiboarr): return fiboarr[n-1] else: for i in range(len(fiboarr)-1,n-1): fiboarr.append(fiboarr[i]+fiboarr[i-1]) print(fiboarr) return fiboarr[n-1] print(fibonacci(10))
fiboarr = [0, 1] def fibonacci(n): if n <= 0: print('Invalid input') elif n <= len(fiboarr): return fiboarr[n - 1] else: for i in range(len(fiboarr) - 1, n - 1): fiboarr.append(fiboarr[i] + fiboarr[i - 1]) print(fiboarr) return fiboarr[n - 1] print(fibonacci(10))
dec = int(input("Enter any Number: ")) print (" The decimal value of" ,dec, "is:") print (bin(dec)," In binary.") print (oct(dec),"In octal.") print (hex(dec),"In hexadecimal.")
dec = int(input('Enter any Number: ')) print(' The decimal value of', dec, 'is:') print(bin(dec), ' In binary.') print(oct(dec), 'In octal.') print(hex(dec), 'In hexadecimal.')
__author__ = "Andrea de Marco <andrea.demarco@buongiorno.com>" __version__ = '0.2' __classifiers__ = [ 'Development Status :: 4 - Beta', 'Framework :: Django', 'Intended Audience :: Developers', 'License :: OSI Approved :: GNU General Public License (GPL)', 'Operating System :: OS Independent', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Software Development :: Libraries', ]
__author__ = 'Andrea de Marco <andrea.demarco@buongiorno.com>' __version__ = '0.2' __classifiers__ = ['Development Status :: 4 - Beta', 'Framework :: Django', 'Intended Audience :: Developers', 'License :: OSI Approved :: GNU General Public License (GPL)', 'Operating System :: OS Independent', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Software Development :: Libraries']
def of_codon(): pass def of_rna(): pass
def of_codon(): pass def of_rna(): pass
if __name__ == '__main__': a = int(input("Enter a number : ")) if sum([pow(int(d), 3) for d in str(a)]) == a: print(a, " is an armstrong number") else: print(a, " is not an armstrong number")
if __name__ == '__main__': a = int(input('Enter a number : ')) if sum([pow(int(d), 3) for d in str(a)]) == a: print(a, ' is an armstrong number') else: print(a, ' is not an armstrong number')
nums = list(map(int, input().split(' '))) odd_num_list = [num for num in nums if num % 2 == 1] print(len(odd_num_list))
nums = list(map(int, input().split(' '))) odd_num_list = [num for num in nums if num % 2 == 1] print(len(odd_num_list))