content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
class Solution: def buildTree(self, inorder: List[int], postorder: List[int]) -> TreeNode: if not postorder: return root = TreeNode(postorder[-1]) rootpos = inorder.index(postorder[-1]) root.left = self.buildTree(inorder[:rootpos], postorder[:rootpos]) root.right = self.buildTree(inorder[rootpos + 1 :], postorder[rootpos : -1]) return root
class Solution: def build_tree(self, inorder: List[int], postorder: List[int]) -> TreeNode: if not postorder: return root = tree_node(postorder[-1]) rootpos = inorder.index(postorder[-1]) root.left = self.buildTree(inorder[:rootpos], postorder[:rootpos]) root.right = self.buildTree(inorder[rootpos + 1:], postorder[rootpos:-1]) return root
class Node: def __init__(self, data=None, next=None): self.__data = data self.__next = next @property def data(self): return self.__data @data.setter def data(self, data): self.__data = data @property def next(self): return self.__next @next.setter def next(self, ptr): self.__next = ptr def equals(node1, node2): if node1 is None and node2 is None: return True elif node1 is None or node2 is None: return False else: return (node1.data == node2.data) and (equals(node1.next, node2.next))
class Node: def __init__(self, data=None, next=None): self.__data = data self.__next = next @property def data(self): return self.__data @data.setter def data(self, data): self.__data = data @property def next(self): return self.__next @next.setter def next(self, ptr): self.__next = ptr def equals(node1, node2): if node1 is None and node2 is None: return True elif node1 is None or node2 is None: return False else: return node1.data == node2.data and equals(node1.next, node2.next)
def y(): raise TypeError def x(): y() try: x() except TypeError: print("x")
def y(): raise TypeError def x(): y() try: x() except TypeError: print('x')
# nominal reactor positions data = dict([ ('YJ1', [52.5]), ('YJ2', [52.5]), ('YJ3', [52.5]), ('YJ4', [52.5]), ('YJ5', [52.5]), ('YJ6', [52.5]), ('TS1', [52.5]), ('TS2', [52.5]), ('TS3', [52.5]), ('TS4', [52.5]), ('DYB', [215.0]), ('HZ', [265.0]), ])
data = dict([('YJ1', [52.5]), ('YJ2', [52.5]), ('YJ3', [52.5]), ('YJ4', [52.5]), ('YJ5', [52.5]), ('YJ6', [52.5]), ('TS1', [52.5]), ('TS2', [52.5]), ('TS3', [52.5]), ('TS4', [52.5]), ('DYB', [215.0]), ('HZ', [265.0])])
class Summary: def __init__(self, total_income, net_income, income_tax, employees_ni, employers_ni): self._total_income = total_income self._net_income = net_income self._income_tax = income_tax self._employees_ni = employees_ni self._employers_ni = employers_ni @property def total_income(self): return self._total_income @property def net_income(self): return self._net_income @property def income_tax(self): return self._income_tax @property def employees_ni(self): return self._employees_ni @property def employers_ni(self): return self._employers_ni
class Summary: def __init__(self, total_income, net_income, income_tax, employees_ni, employers_ni): self._total_income = total_income self._net_income = net_income self._income_tax = income_tax self._employees_ni = employees_ni self._employers_ni = employers_ni @property def total_income(self): return self._total_income @property def net_income(self): return self._net_income @property def income_tax(self): return self._income_tax @property def employees_ni(self): return self._employees_ni @property def employers_ni(self): return self._employers_ni
class Solution: def reverseOnlyLetters(self, s: str) -> str: def isChar(c): return True if ord('z')>=ord(c)>=ord('a') or ord('Z')>=ord(c)>=ord('A') else False right = len(s)-1 left = 0 charArray = [c for c in s] while left<right: print(charArray,right) while right>-1 and isChar(charArray[right])==False: right -= 1 if(not right>left): break while isChar(charArray[left])==False: left += 1 if(right>-1 and left < right): charArray[left],charArray[right] = charArray[right],charArray[left] left += 1 right -= 1 return ''.join(charArray)
class Solution: def reverse_only_letters(self, s: str) -> str: def is_char(c): return True if ord('z') >= ord(c) >= ord('a') or ord('Z') >= ord(c) >= ord('A') else False right = len(s) - 1 left = 0 char_array = [c for c in s] while left < right: print(charArray, right) while right > -1 and is_char(charArray[right]) == False: right -= 1 if not right > left: break while is_char(charArray[left]) == False: left += 1 if right > -1 and left < right: (charArray[left], charArray[right]) = (charArray[right], charArray[left]) left += 1 right -= 1 return ''.join(charArray)
def fp(i,n) : i /= 100 return (1+i)**n def pf(i,n) : i /= 100 return 1/((1+i)**n) def fa(i,n) : i /= 100 return (((1+i)**n)-1)/i def af(i,n) : i /= 100 return i/(((1+i)**n)-1) def pa(i,n) : i /= 100 return (((1+i)**n)-1)/(i*((1+i)**n)) def ap(i,n) : i /= 100 return (i*((1+i)**n))/(((1+i)**n)-1) def pg(i,n) : i /= 100 return (((1+i)**n)-(1+n*i))/((i**2)*((1+i)**n)) def ag(i,n) : i /= 100 return (1/i)-(n/(((1+i)**n)-1))
def fp(i, n): i /= 100 return (1 + i) ** n def pf(i, n): i /= 100 return 1 / (1 + i) ** n def fa(i, n): i /= 100 return ((1 + i) ** n - 1) / i def af(i, n): i /= 100 return i / ((1 + i) ** n - 1) def pa(i, n): i /= 100 return ((1 + i) ** n - 1) / (i * (1 + i) ** n) def ap(i, n): i /= 100 return i * (1 + i) ** n / ((1 + i) ** n - 1) def pg(i, n): i /= 100 return ((1 + i) ** n - (1 + n * i)) / (i ** 2 * (1 + i) ** n) def ag(i, n): i /= 100 return 1 / i - n / ((1 + i) ** n - 1)
"""utility functions to read in and parse a file efficiently """ def gen_file_line(text): with open(text) as fp: for line in fp: yield line
"""utility functions to read in and parse a file efficiently """ def gen_file_line(text): with open(text) as fp: for line in fp: yield line
# Copyright (c) 2018 Turysaz <turysaz@posteo.org> class IoCContainer(): def __init__(self): self.__constructors = {} # {"service_key" : service_ctor} self.__dependencies = {} # {"service_key" : ["dep_key_1", "dep_key_2", ..]} constructor parameters self.__quantity = {} # {"service_key" : "singleton" | "multiple"} self.__singletons = {} def register_on_demand(self, service_name_string, service, *dependencies): self.__register_internal(service_name_string, service, "multiple", dependencies) def register_singleton(self, service_name_string, service, *dependencies): self.__register_internal(service_name_string, service, "singleton", dependencies) def get_instance(self, service_name_string): if service_name_string not in self.__constructors: raise Exception() if self.__quantity[service_name_string] == "multiple": return __create_instance_recursive(service_name_string) elif self.__quantity[service_name_string] == "singleton": if service_name_string in self.__singletons: return self.__singletons[service_name_string] singleton = self.__create_instance_recursive(service_name_string) self.__singletons[service_name_string] = singleton return singleton def __register_internal(self, service_name_string, service, quantity, dependencies): if service_name_string in self.__constructors: raise Exception() # already registered self.__constructors[service_name_string] = service self.__dependencies[service_name_string] = dependencies self.__quantity[service_name_string] = quantity def __create_instance_recursive(self, service_name_string): deps = [self.get_instance(d) for d in self.__dependencies[service_name_string]] return self.__constructors[service_name_string](*deps)
class Ioccontainer: def __init__(self): self.__constructors = {} self.__dependencies = {} self.__quantity = {} self.__singletons = {} def register_on_demand(self, service_name_string, service, *dependencies): self.__register_internal(service_name_string, service, 'multiple', dependencies) def register_singleton(self, service_name_string, service, *dependencies): self.__register_internal(service_name_string, service, 'singleton', dependencies) def get_instance(self, service_name_string): if service_name_string not in self.__constructors: raise exception() if self.__quantity[service_name_string] == 'multiple': return __create_instance_recursive(service_name_string) elif self.__quantity[service_name_string] == 'singleton': if service_name_string in self.__singletons: return self.__singletons[service_name_string] singleton = self.__create_instance_recursive(service_name_string) self.__singletons[service_name_string] = singleton return singleton def __register_internal(self, service_name_string, service, quantity, dependencies): if service_name_string in self.__constructors: raise exception() self.__constructors[service_name_string] = service self.__dependencies[service_name_string] = dependencies self.__quantity[service_name_string] = quantity def __create_instance_recursive(self, service_name_string): deps = [self.get_instance(d) for d in self.__dependencies[service_name_string]] return self.__constructors[service_name_string](*deps)
# def isIPv4Address(inputString): # return len([num for num in inputString.split(".") if num != "" and 0 <= int(num) < 255]) == 4 # def isIPv4Address(inputString): # return len([int(num) for num in inputString.split(".") if num != "" and not num.islower() and 0 <= int(num) <= 255]) == 4 # def isIPv4Address(inputString): # print([num.isdigit() for num in inputString.split(".")]) # print(inputString.count(".")) # numbers = [int(num) for num in inputString.split(".") if num != "" and not num.islower() and 0 <= int(num) <= 255 and len(num) == len(str(int(num)))] # print(numbers) # print(len(numbers)) # return len(numbers) == 4 def isIPv4Address(inputString): if inputString.count(".") != 3: return False return len([int(num) for num in inputString.split(".") if num != "" and not num.islower() and 0 <= int(num) <= 255 and len(num) == len(str(int(num)))]) == 4 # 172.16.254.1 => True # 172.316.254.1 => False # .254.255.0 => False print(isIPv4Address("0..1.0.0"))
def is_i_pv4_address(inputString): if inputString.count('.') != 3: return False return len([int(num) for num in inputString.split('.') if num != '' and (not num.islower()) and (0 <= int(num) <= 255) and (len(num) == len(str(int(num))))]) == 4 print(is_i_pv4_address('0..1.0.0'))
def validTime(time): tokens = time.split(":") hours, mins = tokens[0], tokens[1] if int(hours) < 0 or int(hours) > 23: return False if int(mins) < 0 or int(mins) > 59: return False return True
def valid_time(time): tokens = time.split(':') (hours, mins) = (tokens[0], tokens[1]) if int(hours) < 0 or int(hours) > 23: return False if int(mins) < 0 or int(mins) > 59: return False return True
# # PySNMP MIB module AT-IGMP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AT-IGMP-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:30:12 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") ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ConstraintsUnion, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint", "ConstraintsUnion", "SingleValueConstraint") modules, = mibBuilder.importSymbols("AT-SMI-MIB", "modules") InterfaceIndex, = mibBuilder.importSymbols("IF-MIB", "InterfaceIndex") ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup") TimeTicks, MibScalar, MibTable, MibTableRow, MibTableColumn, Gauge32, ObjectIdentity, Counter32, iso, IpAddress, ModuleIdentity, Counter64, Bits, Unsigned32, NotificationType, MibIdentifier, Integer32 = mibBuilder.importSymbols("SNMPv2-SMI", "TimeTicks", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Gauge32", "ObjectIdentity", "Counter32", "iso", "IpAddress", "ModuleIdentity", "Counter64", "Bits", "Unsigned32", "NotificationType", "MibIdentifier", "Integer32") DisplayString, TruthValue, MacAddress, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TruthValue", "MacAddress", "TextualConvention") igmp = ModuleIdentity((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139)) igmp.setRevisions(('2007-08-08 00:00',)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: igmp.setRevisionsDescriptions(('Initial version, to support IGMP membership status polling.',)) if mibBuilder.loadTexts: igmp.setLastUpdated('200708080000Z') if mibBuilder.loadTexts: igmp.setOrganization('Allied Telesis, Inc.') if mibBuilder.loadTexts: igmp.setContactInfo(' Stan Xiang,Hamish Kellahan Allied Telesis EMail: support@alliedtelesis.co.nz') if mibBuilder.loadTexts: igmp.setDescription('The MIB module for IGMP Management.') igmpIntInfo = MibIdentifier((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1)) igmpIntMember = MibIdentifier((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9)) igmpSnooping = MibIdentifier((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10)) igmpInterfaceTable = MibTable((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1), ) if mibBuilder.loadTexts: igmpInterfaceTable.setStatus('current') if mibBuilder.loadTexts: igmpInterfaceTable.setDescription('The (conceptual) table listing IGMP capable IP interfaces.') igmpInterfaceEntry = MibTableRow((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1, 1), ).setIndexNames((0, "AT-IGMP-MIB", "igmpInterface")) if mibBuilder.loadTexts: igmpInterfaceEntry.setStatus('current') if mibBuilder.loadTexts: igmpInterfaceEntry.setDescription('An entry (conceptual row) in the igmpInterfaceTable.') igmpInterface = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpInterface.setStatus('current') if mibBuilder.loadTexts: igmpInterface.setDescription('The index value of the interface for which IGMP is enabled. This table is indexed by this value.') igmpInterfaceName = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1, 1, 2), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpInterfaceName.setStatus('current') if mibBuilder.loadTexts: igmpInterfaceName.setDescription('The name of the interface for which IGMP or MLD is enabled.') igmpQueryTimeout = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1, 1, 3), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpQueryTimeout.setStatus('current') if mibBuilder.loadTexts: igmpQueryTimeout.setDescription('It represents the maximum expected time interval, in seconds, between successive IGMP general query messages arriving on the interface. A vlaue of zero means there is no limits.') igmpProxy = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2))).clone(namedValues=NamedValues(("off", 0), ("upstream", 1), ("downstream", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpProxy.setStatus('current') if mibBuilder.loadTexts: igmpProxy.setDescription('The object represents states of igmp proxy. When it has a value of 0 then it means the inteface proxy is currently disabled. When it has a value of 1 then it means IGMP is performing upstream inteface proxying. When it has a value of 2 then it means IGMP is performing downstream inteface proxying.') igmpIntStatsTable = MibTable((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2), ) if mibBuilder.loadTexts: igmpIntStatsTable.setStatus('current') if mibBuilder.loadTexts: igmpIntStatsTable.setDescription('The (conceptual) table listing statistics for IGMP capable IP interfaces.') igmpIntStatsEntry = MibTableRow((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1), ).setIndexNames((0, "AT-IGMP-MIB", "igmpInterface")) if mibBuilder.loadTexts: igmpIntStatsEntry.setStatus('current') if mibBuilder.loadTexts: igmpIntStatsEntry.setDescription('An entry (conceptual row) in the igmpIntStatsTable.') igmpInQuery = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 1), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpInQuery.setStatus('current') if mibBuilder.loadTexts: igmpInQuery.setDescription('The number of IGMP Query messages received by the interface.') igmpInReportV1 = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 2), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpInReportV1.setStatus('current') if mibBuilder.loadTexts: igmpInReportV1.setDescription('The number of IGMP version 1 Report messages received by the interface.') igmpInReportV2 = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 3), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpInReportV2.setStatus('current') if mibBuilder.loadTexts: igmpInReportV2.setDescription('The number of IGMP version 2 Report messages received by the interface.') igmpInLeave = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 4), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpInLeave.setStatus('current') if mibBuilder.loadTexts: igmpInLeave.setDescription('The number of IGMP Leave Group messages received by the interface.') igmpInTotal = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 5), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpInTotal.setStatus('current') if mibBuilder.loadTexts: igmpInTotal.setDescription('The total number of IGMP messages received by the interface.') igmpOutQuery = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 6), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpOutQuery.setStatus('current') if mibBuilder.loadTexts: igmpOutQuery.setDescription('The total number of IGMP Query messages that were transmitted by the switch over the interface.') igmpOutTotal = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 7), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpOutTotal.setStatus('current') if mibBuilder.loadTexts: igmpOutTotal.setDescription('The total number of IGMP messages that were transmitted by the switch over the interface.') igmpBadQuery = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 8), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpBadQuery.setStatus('current') if mibBuilder.loadTexts: igmpBadQuery.setDescription('The number of IGMP membership query messages with errors that were received by the interface.') igmpBadReportV1 = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 9), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpBadReportV1.setStatus('current') if mibBuilder.loadTexts: igmpBadReportV1.setDescription('The number of IGMP Version 1 membership report messages with errors that were received by the interface.') igmpBadReportV2 = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 10), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpBadReportV2.setStatus('current') if mibBuilder.loadTexts: igmpBadReportV2.setDescription('The number of IGMP Version 2 membership report messages with errors that were received by the interface.') igmpBadLeave = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 11), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpBadLeave.setStatus('current') if mibBuilder.loadTexts: igmpBadLeave.setDescription('The number of IGMP Leave Group messages with errors that were received by the interface.') igmpBadTotal = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 12), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpBadTotal.setStatus('current') if mibBuilder.loadTexts: igmpBadTotal.setDescription('The total number of IGMP messages with errors that were received by the interface..') igmpIntGroupTable = MibTable((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9, 1), ) if mibBuilder.loadTexts: igmpIntGroupTable.setStatus('current') if mibBuilder.loadTexts: igmpIntGroupTable.setDescription('The (conceptual) table listing the IP multicast groups of which there are members on a particular interface.') igmpIntGroupEntry = MibTableRow((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9, 1, 1), ).setIndexNames((0, "AT-IGMP-MIB", "igmpInterface")) if mibBuilder.loadTexts: igmpIntGroupEntry.setStatus('current') if mibBuilder.loadTexts: igmpIntGroupEntry.setDescription('An entry (conceptual row) in the igmpGroupTable.') igmpIntGroupAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9, 1, 1, 1), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpIntGroupAddress.setStatus('current') if mibBuilder.loadTexts: igmpIntGroupAddress.setDescription('The IP multicast group address for which this entry contains information.') igmpLastHost = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9, 1, 1, 2), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpLastHost.setStatus('current') if mibBuilder.loadTexts: igmpLastHost.setDescription('The IP address of the last host reporting a membership. If it is static, then 0.0.0.0 presents.') igmpRefreshTime = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9, 1, 1, 3), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpRefreshTime.setStatus('current') if mibBuilder.loadTexts: igmpRefreshTime.setDescription('The time in seconds until the membership group is deleted if another membership report is not received. A value of 0xffffffff means infinity.') igmpSnoopAdminInfo = MibIdentifier((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 1)) igmpSnoopAdminEnabled = MibScalar((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 1, 1), TruthValue()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopAdminEnabled.setStatus('current') if mibBuilder.loadTexts: igmpSnoopAdminEnabled.setDescription('Indicates whether IGMP Snooping is globally enabled.') igmpSnoopVlanTable = MibTable((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2), ) if mibBuilder.loadTexts: igmpSnoopVlanTable.setStatus('current') if mibBuilder.loadTexts: igmpSnoopVlanTable.setDescription('The (conceptual) table listing the layer 2 interfaces performing IGMP snooping.') igmpSnoopVlanEntry = MibTableRow((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1), ).setIndexNames((0, "AT-IGMP-MIB", "igmpSnoopVID")) if mibBuilder.loadTexts: igmpSnoopVlanEntry.setStatus('current') if mibBuilder.loadTexts: igmpSnoopVlanEntry.setDescription('An entry (conceptual row) in the IGMP Snooping Vlan Table.') igmpSnoopVID = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopVID.setStatus('current') if mibBuilder.loadTexts: igmpSnoopVID.setDescription('The 802.1 VLAN ID of the layer 2 interface performing IGMP snooping.') igmpSnoopVlanName = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1, 2), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopVlanName.setStatus('current') if mibBuilder.loadTexts: igmpSnoopVlanName.setDescription('The name of the layer 2 interface performing IGMP snooping.') igmpSnoopFastLeave = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2))).clone(namedValues=NamedValues(("off", 0), ("single", 1), ("multi", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopFastLeave.setStatus('current') if mibBuilder.loadTexts: igmpSnoopFastLeave.setDescription('Indicates whether FastLeave is enabled, and operating in Single-Host or Multi-Host mode.') igmpSnoopQuerySolicit = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1, 4), TruthValue()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopQuerySolicit.setStatus('current') if mibBuilder.loadTexts: igmpSnoopQuerySolicit.setDescription('Indicates whether query solicitation is on') igmpSnoopStaticRouterPorts = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1, 5), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopStaticRouterPorts.setStatus('current') if mibBuilder.loadTexts: igmpSnoopStaticRouterPorts.setDescription('Indicates the configured static multicast router ports.') igmpSnoopGroupTable = MibTable((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 3), ) if mibBuilder.loadTexts: igmpSnoopGroupTable.setStatus('current') if mibBuilder.loadTexts: igmpSnoopGroupTable.setDescription('The (conceptual) table of IGMP Groups snooped on a layer 2 interface.') igmpSnoopGroupEntry = MibTableRow((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 3, 1), ).setIndexNames((0, "AT-IGMP-MIB", "igmpSnoopVID"), (0, "AT-IGMP-MIB", "igmpSnoopGroupAddress")) if mibBuilder.loadTexts: igmpSnoopGroupEntry.setStatus('current') if mibBuilder.loadTexts: igmpSnoopGroupEntry.setDescription('A (conceptual) row in the IGMP Snooping Group table.') igmpSnoopGroupAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 3, 1, 1), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopGroupAddress.setStatus('current') if mibBuilder.loadTexts: igmpSnoopGroupAddress.setDescription('The Multicast Group IP Address detected on a layer 2 interface.') igmpSnoopGroupTimer = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 3, 1, 2), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopGroupTimer.setStatus('current') if mibBuilder.loadTexts: igmpSnoopGroupTimer.setDescription('The time remaining before the multicast group is deleted from the layer 2 interface.') igmpSnoopPortTable = MibTable((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 4), ) if mibBuilder.loadTexts: igmpSnoopPortTable.setStatus('current') if mibBuilder.loadTexts: igmpSnoopPortTable.setDescription('A (conceptual) table of ports in a layer 2 interface that are currently members of a multicast group.') igmpSnoopPortEntry = MibTableRow((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 4, 1), ).setIndexNames((0, "AT-IGMP-MIB", "igmpSnoopVID"), (0, "AT-IGMP-MIB", "igmpSnoopGroupAddress"), (0, "AT-IGMP-MIB", "igmpSnoopPortNumber")) if mibBuilder.loadTexts: igmpSnoopPortEntry.setStatus('current') if mibBuilder.loadTexts: igmpSnoopPortEntry.setDescription('A (conceptual) row in the IGMP Snooping Port Table.') igmpSnoopPortNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 4, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopPortNumber.setStatus('current') if mibBuilder.loadTexts: igmpSnoopPortNumber.setDescription('Provides the number of a port in a multicast group.') igmpSnoopPortIsStatic = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 4, 1, 2), TruthValue()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopPortIsStatic.setStatus('current') if mibBuilder.loadTexts: igmpSnoopPortIsStatic.setDescription('Indicates whether a port has been administratively added to a multicast group.') igmpSnoopPortTimer = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 4, 1, 3), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopPortTimer.setStatus('current') if mibBuilder.loadTexts: igmpSnoopPortTimer.setDescription('Indicates the time remaining before the port is removed.') igmpSnoopHostTable = MibTable((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 5), ) if mibBuilder.loadTexts: igmpSnoopHostTable.setStatus('current') if mibBuilder.loadTexts: igmpSnoopHostTable.setDescription('A (conceptual) table of hosts receiving multicast data.') igmpSnoopHostEntry = MibTableRow((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 5, 1), ).setIndexNames((0, "AT-IGMP-MIB", "igmpSnoopVID"), (0, "AT-IGMP-MIB", "igmpSnoopGroupAddress"), (0, "AT-IGMP-MIB", "igmpSnoopPortNumber"), (0, "AT-IGMP-MIB", "igmpSnoopHostMAC")) if mibBuilder.loadTexts: igmpSnoopHostEntry.setStatus('current') if mibBuilder.loadTexts: igmpSnoopHostEntry.setDescription('A (conceptual) row in the IGMP Snooping Host Table.') igmpSnoopHostMAC = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 5, 1, 1), MacAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopHostMAC.setStatus('current') if mibBuilder.loadTexts: igmpSnoopHostMAC.setDescription('Provides the Media Access Control Address of an IGMP Host.') igmpSnoopHostIpAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 5, 1, 2), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopHostIpAddress.setStatus('current') if mibBuilder.loadTexts: igmpSnoopHostIpAddress.setDescription('Provides the Internet Protocol Address of an IGMP Host.') igmpSnoopHostTimer = MibTableColumn((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 5, 1, 3), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: igmpSnoopHostTimer.setStatus('current') if mibBuilder.loadTexts: igmpSnoopHostTimer.setDescription('Indicates the time remaining before the host times out.') mibBuilder.exportSymbols("AT-IGMP-MIB", igmpInReportV1=igmpInReportV1, igmpSnoopQuerySolicit=igmpSnoopQuerySolicit, igmpBadQuery=igmpBadQuery, igmpOutQuery=igmpOutQuery, igmpInterfaceEntry=igmpInterfaceEntry, igmpIntStatsTable=igmpIntStatsTable, igmpProxy=igmpProxy, igmpIntGroupTable=igmpIntGroupTable, igmpSnoopAdminEnabled=igmpSnoopAdminEnabled, igmpSnoopFastLeave=igmpSnoopFastLeave, igmpIntMember=igmpIntMember, igmpRefreshTime=igmpRefreshTime, igmpSnoopPortTimer=igmpSnoopPortTimer, igmpIntInfo=igmpIntInfo, igmpSnoopGroupAddress=igmpSnoopGroupAddress, igmpSnoopVlanName=igmpSnoopVlanName, igmpIntGroupEntry=igmpIntGroupEntry, igmpSnoopAdminInfo=igmpSnoopAdminInfo, igmpInQuery=igmpInQuery, igmpBadTotal=igmpBadTotal, igmpBadReportV1=igmpBadReportV1, igmp=igmp, igmpSnoopGroupEntry=igmpSnoopGroupEntry, igmpBadReportV2=igmpBadReportV2, igmpInterface=igmpInterface, igmpIntGroupAddress=igmpIntGroupAddress, PYSNMP_MODULE_ID=igmp, igmpSnoopVlanTable=igmpSnoopVlanTable, igmpSnoopGroupTimer=igmpSnoopGroupTimer, igmpSnoopHostTable=igmpSnoopHostTable, igmpSnoopHostIpAddress=igmpSnoopHostIpAddress, igmpIntStatsEntry=igmpIntStatsEntry, igmpBadLeave=igmpBadLeave, igmpSnoopPortEntry=igmpSnoopPortEntry, igmpLastHost=igmpLastHost, igmpQueryTimeout=igmpQueryTimeout, igmpSnoopGroupTable=igmpSnoopGroupTable, igmpSnoopHostMAC=igmpSnoopHostMAC, igmpSnoopPortIsStatic=igmpSnoopPortIsStatic, igmpInTotal=igmpInTotal, igmpInterfaceName=igmpInterfaceName, igmpSnoopPortNumber=igmpSnoopPortNumber, igmpSnoopHostEntry=igmpSnoopHostEntry, igmpSnoopStaticRouterPorts=igmpSnoopStaticRouterPorts, igmpSnoopVID=igmpSnoopVID, igmpSnoopHostTimer=igmpSnoopHostTimer, igmpSnoopPortTable=igmpSnoopPortTable, igmpInReportV2=igmpInReportV2, igmpInLeave=igmpInLeave, igmpSnooping=igmpSnooping, igmpSnoopVlanEntry=igmpSnoopVlanEntry, igmpOutTotal=igmpOutTotal, igmpInterfaceTable=igmpInterfaceTable)
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_size_constraint, value_range_constraint, constraints_union, single_value_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsIntersection', 'ValueSizeConstraint', 'ValueRangeConstraint', 'ConstraintsUnion', 'SingleValueConstraint') (modules,) = mibBuilder.importSymbols('AT-SMI-MIB', 'modules') (interface_index,) = mibBuilder.importSymbols('IF-MIB', 'InterfaceIndex') (module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup') (time_ticks, mib_scalar, mib_table, mib_table_row, mib_table_column, gauge32, object_identity, counter32, iso, ip_address, module_identity, counter64, bits, unsigned32, notification_type, mib_identifier, integer32) = mibBuilder.importSymbols('SNMPv2-SMI', 'TimeTicks', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Gauge32', 'ObjectIdentity', 'Counter32', 'iso', 'IpAddress', 'ModuleIdentity', 'Counter64', 'Bits', 'Unsigned32', 'NotificationType', 'MibIdentifier', 'Integer32') (display_string, truth_value, mac_address, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TruthValue', 'MacAddress', 'TextualConvention') igmp = module_identity((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139)) igmp.setRevisions(('2007-08-08 00:00',)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: igmp.setRevisionsDescriptions(('Initial version, to support IGMP membership status polling.',)) if mibBuilder.loadTexts: igmp.setLastUpdated('200708080000Z') if mibBuilder.loadTexts: igmp.setOrganization('Allied Telesis, Inc.') if mibBuilder.loadTexts: igmp.setContactInfo(' Stan Xiang,Hamish Kellahan Allied Telesis EMail: support@alliedtelesis.co.nz') if mibBuilder.loadTexts: igmp.setDescription('The MIB module for IGMP Management.') igmp_int_info = mib_identifier((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1)) igmp_int_member = mib_identifier((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9)) igmp_snooping = mib_identifier((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10)) igmp_interface_table = mib_table((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1)) if mibBuilder.loadTexts: igmpInterfaceTable.setStatus('current') if mibBuilder.loadTexts: igmpInterfaceTable.setDescription('The (conceptual) table listing IGMP capable IP interfaces.') igmp_interface_entry = mib_table_row((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1, 1)).setIndexNames((0, 'AT-IGMP-MIB', 'igmpInterface')) if mibBuilder.loadTexts: igmpInterfaceEntry.setStatus('current') if mibBuilder.loadTexts: igmpInterfaceEntry.setDescription('An entry (conceptual row) in the igmpInterfaceTable.') igmp_interface = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1, 1, 1), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpInterface.setStatus('current') if mibBuilder.loadTexts: igmpInterface.setDescription('The index value of the interface for which IGMP is enabled. This table is indexed by this value.') igmp_interface_name = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1, 1, 2), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpInterfaceName.setStatus('current') if mibBuilder.loadTexts: igmpInterfaceName.setDescription('The name of the interface for which IGMP or MLD is enabled.') igmp_query_timeout = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1, 1, 3), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpQueryTimeout.setStatus('current') if mibBuilder.loadTexts: igmpQueryTimeout.setDescription('It represents the maximum expected time interval, in seconds, between successive IGMP general query messages arriving on the interface. A vlaue of zero means there is no limits.') igmp_proxy = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 1, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1, 2))).clone(namedValues=named_values(('off', 0), ('upstream', 1), ('downstream', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpProxy.setStatus('current') if mibBuilder.loadTexts: igmpProxy.setDescription('The object represents states of igmp proxy. When it has a value of 0 then it means the inteface proxy is currently disabled. When it has a value of 1 then it means IGMP is performing upstream inteface proxying. When it has a value of 2 then it means IGMP is performing downstream inteface proxying.') igmp_int_stats_table = mib_table((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2)) if mibBuilder.loadTexts: igmpIntStatsTable.setStatus('current') if mibBuilder.loadTexts: igmpIntStatsTable.setDescription('The (conceptual) table listing statistics for IGMP capable IP interfaces.') igmp_int_stats_entry = mib_table_row((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1)).setIndexNames((0, 'AT-IGMP-MIB', 'igmpInterface')) if mibBuilder.loadTexts: igmpIntStatsEntry.setStatus('current') if mibBuilder.loadTexts: igmpIntStatsEntry.setDescription('An entry (conceptual row) in the igmpIntStatsTable.') igmp_in_query = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 1), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpInQuery.setStatus('current') if mibBuilder.loadTexts: igmpInQuery.setDescription('The number of IGMP Query messages received by the interface.') igmp_in_report_v1 = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 2), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpInReportV1.setStatus('current') if mibBuilder.loadTexts: igmpInReportV1.setDescription('The number of IGMP version 1 Report messages received by the interface.') igmp_in_report_v2 = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 3), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpInReportV2.setStatus('current') if mibBuilder.loadTexts: igmpInReportV2.setDescription('The number of IGMP version 2 Report messages received by the interface.') igmp_in_leave = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 4), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpInLeave.setStatus('current') if mibBuilder.loadTexts: igmpInLeave.setDescription('The number of IGMP Leave Group messages received by the interface.') igmp_in_total = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 5), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpInTotal.setStatus('current') if mibBuilder.loadTexts: igmpInTotal.setDescription('The total number of IGMP messages received by the interface.') igmp_out_query = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 6), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpOutQuery.setStatus('current') if mibBuilder.loadTexts: igmpOutQuery.setDescription('The total number of IGMP Query messages that were transmitted by the switch over the interface.') igmp_out_total = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 7), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpOutTotal.setStatus('current') if mibBuilder.loadTexts: igmpOutTotal.setDescription('The total number of IGMP messages that were transmitted by the switch over the interface.') igmp_bad_query = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 8), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpBadQuery.setStatus('current') if mibBuilder.loadTexts: igmpBadQuery.setDescription('The number of IGMP membership query messages with errors that were received by the interface.') igmp_bad_report_v1 = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 9), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpBadReportV1.setStatus('current') if mibBuilder.loadTexts: igmpBadReportV1.setDescription('The number of IGMP Version 1 membership report messages with errors that were received by the interface.') igmp_bad_report_v2 = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 10), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpBadReportV2.setStatus('current') if mibBuilder.loadTexts: igmpBadReportV2.setDescription('The number of IGMP Version 2 membership report messages with errors that were received by the interface.') igmp_bad_leave = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 11), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpBadLeave.setStatus('current') if mibBuilder.loadTexts: igmpBadLeave.setDescription('The number of IGMP Leave Group messages with errors that were received by the interface.') igmp_bad_total = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 1, 2, 1, 12), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpBadTotal.setStatus('current') if mibBuilder.loadTexts: igmpBadTotal.setDescription('The total number of IGMP messages with errors that were received by the interface..') igmp_int_group_table = mib_table((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9, 1)) if mibBuilder.loadTexts: igmpIntGroupTable.setStatus('current') if mibBuilder.loadTexts: igmpIntGroupTable.setDescription('The (conceptual) table listing the IP multicast groups of which there are members on a particular interface.') igmp_int_group_entry = mib_table_row((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9, 1, 1)).setIndexNames((0, 'AT-IGMP-MIB', 'igmpInterface')) if mibBuilder.loadTexts: igmpIntGroupEntry.setStatus('current') if mibBuilder.loadTexts: igmpIntGroupEntry.setDescription('An entry (conceptual row) in the igmpGroupTable.') igmp_int_group_address = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9, 1, 1, 1), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpIntGroupAddress.setStatus('current') if mibBuilder.loadTexts: igmpIntGroupAddress.setDescription('The IP multicast group address for which this entry contains information.') igmp_last_host = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9, 1, 1, 2), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpLastHost.setStatus('current') if mibBuilder.loadTexts: igmpLastHost.setDescription('The IP address of the last host reporting a membership. If it is static, then 0.0.0.0 presents.') igmp_refresh_time = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 9, 1, 1, 3), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpRefreshTime.setStatus('current') if mibBuilder.loadTexts: igmpRefreshTime.setDescription('The time in seconds until the membership group is deleted if another membership report is not received. A value of 0xffffffff means infinity.') igmp_snoop_admin_info = mib_identifier((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 1)) igmp_snoop_admin_enabled = mib_scalar((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 1, 1), truth_value()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopAdminEnabled.setStatus('current') if mibBuilder.loadTexts: igmpSnoopAdminEnabled.setDescription('Indicates whether IGMP Snooping is globally enabled.') igmp_snoop_vlan_table = mib_table((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2)) if mibBuilder.loadTexts: igmpSnoopVlanTable.setStatus('current') if mibBuilder.loadTexts: igmpSnoopVlanTable.setDescription('The (conceptual) table listing the layer 2 interfaces performing IGMP snooping.') igmp_snoop_vlan_entry = mib_table_row((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1)).setIndexNames((0, 'AT-IGMP-MIB', 'igmpSnoopVID')) if mibBuilder.loadTexts: igmpSnoopVlanEntry.setStatus('current') if mibBuilder.loadTexts: igmpSnoopVlanEntry.setDescription('An entry (conceptual row) in the IGMP Snooping Vlan Table.') igmp_snoop_vid = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1, 1), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopVID.setStatus('current') if mibBuilder.loadTexts: igmpSnoopVID.setDescription('The 802.1 VLAN ID of the layer 2 interface performing IGMP snooping.') igmp_snoop_vlan_name = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1, 2), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopVlanName.setStatus('current') if mibBuilder.loadTexts: igmpSnoopVlanName.setDescription('The name of the layer 2 interface performing IGMP snooping.') igmp_snoop_fast_leave = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1, 2))).clone(namedValues=named_values(('off', 0), ('single', 1), ('multi', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopFastLeave.setStatus('current') if mibBuilder.loadTexts: igmpSnoopFastLeave.setDescription('Indicates whether FastLeave is enabled, and operating in Single-Host or Multi-Host mode.') igmp_snoop_query_solicit = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1, 4), truth_value()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopQuerySolicit.setStatus('current') if mibBuilder.loadTexts: igmpSnoopQuerySolicit.setDescription('Indicates whether query solicitation is on') igmp_snoop_static_router_ports = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 2, 1, 5), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopStaticRouterPorts.setStatus('current') if mibBuilder.loadTexts: igmpSnoopStaticRouterPorts.setDescription('Indicates the configured static multicast router ports.') igmp_snoop_group_table = mib_table((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 3)) if mibBuilder.loadTexts: igmpSnoopGroupTable.setStatus('current') if mibBuilder.loadTexts: igmpSnoopGroupTable.setDescription('The (conceptual) table of IGMP Groups snooped on a layer 2 interface.') igmp_snoop_group_entry = mib_table_row((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 3, 1)).setIndexNames((0, 'AT-IGMP-MIB', 'igmpSnoopVID'), (0, 'AT-IGMP-MIB', 'igmpSnoopGroupAddress')) if mibBuilder.loadTexts: igmpSnoopGroupEntry.setStatus('current') if mibBuilder.loadTexts: igmpSnoopGroupEntry.setDescription('A (conceptual) row in the IGMP Snooping Group table.') igmp_snoop_group_address = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 3, 1, 1), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopGroupAddress.setStatus('current') if mibBuilder.loadTexts: igmpSnoopGroupAddress.setDescription('The Multicast Group IP Address detected on a layer 2 interface.') igmp_snoop_group_timer = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 3, 1, 2), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopGroupTimer.setStatus('current') if mibBuilder.loadTexts: igmpSnoopGroupTimer.setDescription('The time remaining before the multicast group is deleted from the layer 2 interface.') igmp_snoop_port_table = mib_table((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 4)) if mibBuilder.loadTexts: igmpSnoopPortTable.setStatus('current') if mibBuilder.loadTexts: igmpSnoopPortTable.setDescription('A (conceptual) table of ports in a layer 2 interface that are currently members of a multicast group.') igmp_snoop_port_entry = mib_table_row((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 4, 1)).setIndexNames((0, 'AT-IGMP-MIB', 'igmpSnoopVID'), (0, 'AT-IGMP-MIB', 'igmpSnoopGroupAddress'), (0, 'AT-IGMP-MIB', 'igmpSnoopPortNumber')) if mibBuilder.loadTexts: igmpSnoopPortEntry.setStatus('current') if mibBuilder.loadTexts: igmpSnoopPortEntry.setDescription('A (conceptual) row in the IGMP Snooping Port Table.') igmp_snoop_port_number = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 4, 1, 1), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopPortNumber.setStatus('current') if mibBuilder.loadTexts: igmpSnoopPortNumber.setDescription('Provides the number of a port in a multicast group.') igmp_snoop_port_is_static = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 4, 1, 2), truth_value()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopPortIsStatic.setStatus('current') if mibBuilder.loadTexts: igmpSnoopPortIsStatic.setDescription('Indicates whether a port has been administratively added to a multicast group.') igmp_snoop_port_timer = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 4, 1, 3), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopPortTimer.setStatus('current') if mibBuilder.loadTexts: igmpSnoopPortTimer.setDescription('Indicates the time remaining before the port is removed.') igmp_snoop_host_table = mib_table((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 5)) if mibBuilder.loadTexts: igmpSnoopHostTable.setStatus('current') if mibBuilder.loadTexts: igmpSnoopHostTable.setDescription('A (conceptual) table of hosts receiving multicast data.') igmp_snoop_host_entry = mib_table_row((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 5, 1)).setIndexNames((0, 'AT-IGMP-MIB', 'igmpSnoopVID'), (0, 'AT-IGMP-MIB', 'igmpSnoopGroupAddress'), (0, 'AT-IGMP-MIB', 'igmpSnoopPortNumber'), (0, 'AT-IGMP-MIB', 'igmpSnoopHostMAC')) if mibBuilder.loadTexts: igmpSnoopHostEntry.setStatus('current') if mibBuilder.loadTexts: igmpSnoopHostEntry.setDescription('A (conceptual) row in the IGMP Snooping Host Table.') igmp_snoop_host_mac = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 5, 1, 1), mac_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopHostMAC.setStatus('current') if mibBuilder.loadTexts: igmpSnoopHostMAC.setDescription('Provides the Media Access Control Address of an IGMP Host.') igmp_snoop_host_ip_address = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 5, 1, 2), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopHostIpAddress.setStatus('current') if mibBuilder.loadTexts: igmpSnoopHostIpAddress.setDescription('Provides the Internet Protocol Address of an IGMP Host.') igmp_snoop_host_timer = mib_table_column((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 139, 10, 5, 1, 3), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: igmpSnoopHostTimer.setStatus('current') if mibBuilder.loadTexts: igmpSnoopHostTimer.setDescription('Indicates the time remaining before the host times out.') mibBuilder.exportSymbols('AT-IGMP-MIB', igmpInReportV1=igmpInReportV1, igmpSnoopQuerySolicit=igmpSnoopQuerySolicit, igmpBadQuery=igmpBadQuery, igmpOutQuery=igmpOutQuery, igmpInterfaceEntry=igmpInterfaceEntry, igmpIntStatsTable=igmpIntStatsTable, igmpProxy=igmpProxy, igmpIntGroupTable=igmpIntGroupTable, igmpSnoopAdminEnabled=igmpSnoopAdminEnabled, igmpSnoopFastLeave=igmpSnoopFastLeave, igmpIntMember=igmpIntMember, igmpRefreshTime=igmpRefreshTime, igmpSnoopPortTimer=igmpSnoopPortTimer, igmpIntInfo=igmpIntInfo, igmpSnoopGroupAddress=igmpSnoopGroupAddress, igmpSnoopVlanName=igmpSnoopVlanName, igmpIntGroupEntry=igmpIntGroupEntry, igmpSnoopAdminInfo=igmpSnoopAdminInfo, igmpInQuery=igmpInQuery, igmpBadTotal=igmpBadTotal, igmpBadReportV1=igmpBadReportV1, igmp=igmp, igmpSnoopGroupEntry=igmpSnoopGroupEntry, igmpBadReportV2=igmpBadReportV2, igmpInterface=igmpInterface, igmpIntGroupAddress=igmpIntGroupAddress, PYSNMP_MODULE_ID=igmp, igmpSnoopVlanTable=igmpSnoopVlanTable, igmpSnoopGroupTimer=igmpSnoopGroupTimer, igmpSnoopHostTable=igmpSnoopHostTable, igmpSnoopHostIpAddress=igmpSnoopHostIpAddress, igmpIntStatsEntry=igmpIntStatsEntry, igmpBadLeave=igmpBadLeave, igmpSnoopPortEntry=igmpSnoopPortEntry, igmpLastHost=igmpLastHost, igmpQueryTimeout=igmpQueryTimeout, igmpSnoopGroupTable=igmpSnoopGroupTable, igmpSnoopHostMAC=igmpSnoopHostMAC, igmpSnoopPortIsStatic=igmpSnoopPortIsStatic, igmpInTotal=igmpInTotal, igmpInterfaceName=igmpInterfaceName, igmpSnoopPortNumber=igmpSnoopPortNumber, igmpSnoopHostEntry=igmpSnoopHostEntry, igmpSnoopStaticRouterPorts=igmpSnoopStaticRouterPorts, igmpSnoopVID=igmpSnoopVID, igmpSnoopHostTimer=igmpSnoopHostTimer, igmpSnoopPortTable=igmpSnoopPortTable, igmpInReportV2=igmpInReportV2, igmpInLeave=igmpInLeave, igmpSnooping=igmpSnooping, igmpSnoopVlanEntry=igmpSnoopVlanEntry, igmpOutTotal=igmpOutTotal, igmpInterfaceTable=igmpInterfaceTable)
#!/usr/bin/env python # # Copyright (c) 2018 10X Genomics, Inc. All rights reserved. # MULTI_REFS_PREFIX = 'multi' # Constants for metasamples GENE_EXPRESSION_LIBRARY_TYPE = 'Gene Expression' VDJ_LIBRARY_TYPE = 'VDJ' ATACSEQ_LIBRARY_TYPE = 'Peaks' ATACSEQ_LIBRARY_DERIVED_TYPE = 'Motifs' DEFAULT_LIBRARY_TYPE = GENE_EXPRESSION_LIBRARY_TYPE
multi_refs_prefix = 'multi' gene_expression_library_type = 'Gene Expression' vdj_library_type = 'VDJ' atacseq_library_type = 'Peaks' atacseq_library_derived_type = 'Motifs' default_library_type = GENE_EXPRESSION_LIBRARY_TYPE
def noOfwords(strs): l = strs.split(' ') return len(l) string = input() count = noOfwords(string) print(count)
def no_ofwords(strs): l = strs.split(' ') return len(l) string = input() count = no_ofwords(string) print(count)
def modular_exp(b, e, mod): if e == 0: return 1 res = modular_exp(b, e//2, mod) res = (res * res ) % mod if e%2 == 1: res = (res * b) % mod return res
def modular_exp(b, e, mod): if e == 0: return 1 res = modular_exp(b, e // 2, mod) res = res * res % mod if e % 2 == 1: res = res * b % mod return res
# Copyright (c) 2013 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Top-level presubmit script for Skia. See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for more details about the presubmit API built into gcl. """ def _CheckChangeHasEol(input_api, output_api, source_file_filter=None): """Checks that files end with atleast one \n (LF).""" eof_files = [] for f in input_api.AffectedSourceFiles(source_file_filter): contents = input_api.ReadFile(f, 'rb') # Check that the file ends in atleast one newline character. if len(contents) > 1 and contents[-1:] != '\n': eof_files.append(f.LocalPath()) if eof_files: return [output_api.PresubmitPromptWarning( 'These files should end in a newline character:', items=eof_files)] return [] def _CommonChecks(input_api, output_api): """Presubmit checks common to upload and commit.""" results = [] sources = lambda x: (x.LocalPath().endswith('.h') or x.LocalPath().endswith('.gypi') or x.LocalPath().endswith('.gyp') or x.LocalPath().endswith('.py') or x.LocalPath().endswith('.sh') or x.LocalPath().endswith('.cpp')) results.extend( _CheckChangeHasEol( input_api, output_api, source_file_filter=sources)) return results def CheckChangeOnUpload(input_api, output_api): """Presubmit checks for the change on upload. The following are the presubmit checks: * Check change has one and only one EOL. """ results = [] results.extend(_CommonChecks(input_api, output_api)) return results def _CheckTreeStatus(input_api, output_api, json_url): """Check whether to allow commit. Args: input_api: input related apis. output_api: output related apis. json_url: url to download json style status. """ tree_status_results = input_api.canned_checks.CheckTreeIsOpen( input_api, output_api, json_url=json_url) if not tree_status_results: # Check for caution state only if tree is not closed. connection = input_api.urllib2.urlopen(json_url) status = input_api.json.loads(connection.read()) connection.close() if 'caution' in status['message'].lower(): short_text = 'Tree state is: ' + status['general_state'] long_text = status['message'] + '\n' + json_url tree_status_results.append( output_api.PresubmitPromptWarning( message=short_text, long_text=long_text)) return tree_status_results def CheckChangeOnCommit(input_api, output_api): """Presubmit checks for the change on commit. The following are the presubmit checks: * Check change has one and only one EOL. * Ensures that the Skia tree is open in http://skia-tree-status.appspot.com/. Shows a warning if it is in 'Caution' state and an error if it is in 'Closed' state. """ results = [] results.extend(_CommonChecks(input_api, output_api)) results.extend( _CheckTreeStatus(input_api, output_api, json_url=( 'http://skia-tree-status.appspot.com/banner-status?format=json'))) return results
"""Top-level presubmit script for Skia. See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for more details about the presubmit API built into gcl. """ def __check_change_has_eol(input_api, output_api, source_file_filter=None): """Checks that files end with atleast one (LF).""" eof_files = [] for f in input_api.AffectedSourceFiles(source_file_filter): contents = input_api.ReadFile(f, 'rb') if len(contents) > 1 and contents[-1:] != '\n': eof_files.append(f.LocalPath()) if eof_files: return [output_api.PresubmitPromptWarning('These files should end in a newline character:', items=eof_files)] return [] def __common_checks(input_api, output_api): """Presubmit checks common to upload and commit.""" results = [] sources = lambda x: x.LocalPath().endswith('.h') or x.LocalPath().endswith('.gypi') or x.LocalPath().endswith('.gyp') or x.LocalPath().endswith('.py') or x.LocalPath().endswith('.sh') or x.LocalPath().endswith('.cpp') results.extend(__check_change_has_eol(input_api, output_api, source_file_filter=sources)) return results def check_change_on_upload(input_api, output_api): """Presubmit checks for the change on upload. The following are the presubmit checks: * Check change has one and only one EOL. """ results = [] results.extend(__common_checks(input_api, output_api)) return results def __check_tree_status(input_api, output_api, json_url): """Check whether to allow commit. Args: input_api: input related apis. output_api: output related apis. json_url: url to download json style status. """ tree_status_results = input_api.canned_checks.CheckTreeIsOpen(input_api, output_api, json_url=json_url) if not tree_status_results: connection = input_api.urllib2.urlopen(json_url) status = input_api.json.loads(connection.read()) connection.close() if 'caution' in status['message'].lower(): short_text = 'Tree state is: ' + status['general_state'] long_text = status['message'] + '\n' + json_url tree_status_results.append(output_api.PresubmitPromptWarning(message=short_text, long_text=long_text)) return tree_status_results def check_change_on_commit(input_api, output_api): """Presubmit checks for the change on commit. The following are the presubmit checks: * Check change has one and only one EOL. * Ensures that the Skia tree is open in http://skia-tree-status.appspot.com/. Shows a warning if it is in 'Caution' state and an error if it is in 'Closed' state. """ results = [] results.extend(__common_checks(input_api, output_api)) results.extend(__check_tree_status(input_api, output_api, json_url='http://skia-tree-status.appspot.com/banner-status?format=json')) return results
#!C:\Python27\python.exe # EASY-INSTALL-SCRIPT: 'docutils==0.12','rst2odt_prepstyles.py' __requires__ = 'docutils==0.12' __import__('pkg_resources').run_script('docutils==0.12', 'rst2odt_prepstyles.py')
__requires__ = 'docutils==0.12' __import__('pkg_resources').run_script('docutils==0.12', 'rst2odt_prepstyles.py')
""" FIT1008 Prac 6 Task 1 Loh Hao Bin 25461257, Tan Wen Jie 25839063 @purpose: Knight in Chess File: The columns Rank: The rows @created 20140831 @modified 20140903 """ class Tour: def __init__(self,y,x): self.board = [ [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ] self.knight_history = [ [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ] self.current_pos = [y,x] self.knight_history[y][x] = 1 self.board[y][x] = 1 def display(self,n): """ @purpose To display the current chess board state @complexity: Best & Worst Case: O(n^2) where n is the dimension of the board @parameter none @precondition The Tour class has been initialised @postcondition prints out the current board state """ print('') for i in range(n): for j in range(n): if (self.board[i][j] == 1) and (self.knight_history[i][j] == 1): print("K", end=" ") elif self.knight_history[i][j] == 1 and (self.board[i][j] == 0): print("*", end=" ") else: print("0", end=" ") print('') def move(self,x,y): """ @purpose To display the current chess board state @complexity: O(1) @parameter x: the File to move to y: the Rank to move to @precondition The Tour class has been initialised, and a valid x/y value passed @postcondition current_pos is modified to new Knight position, and Knight's move history is left in knight_history, and the current board is printed out """ if (x >= 0 and x <= 7) and (y >= 0 and y <= 7): #remember current Knight position old_x = self.current_pos[1] old_y = self.current_pos[0] self.board[old_y][old_x] = 0 #set new Knight Position self.current_pos = [y,x] self.board[y][x] = 1 self.knight_history[y][x] = 1 else: #throw a ValueError to ask for valid x/y raise ValueError #FUNCTIONS def menu(): """ @purpose To display the menu @complexity: O(1) @parameter None @precondition None @postcondition displays the menu and allows for user input """ try: print("\n1. Position") print("2. Quit") ans = int(input("Command: ")) if ans == 1: try: posX = int(input("X (File): ")) posY = int(input("Y (Rank): ")) board.move(posX,posY) except ValueError: print("Please input a valid File and Rank.") elif ans == 2: #if Quit print("User stopped the program.") global quit quit = True else: #throw error to ask for valid command raise ValueError except ValueError: print("Please input a valid command.") if __name__ == "__main__": try: quit = False #set flag board = Tour(0,1) #initialise class Tour print("Welcome to Knight Tour. " + "\nPosition: [Rank y, File x]") while not quit: print("-"*30) board.display(8) menu() except KeyboardInterrupt: print("\nUser stopped the program.")
""" FIT1008 Prac 6 Task 1 Loh Hao Bin 25461257, Tan Wen Jie 25839063 @purpose: Knight in Chess File: The columns Rank: The rows @created 20140831 @modified 20140903 """ class Tour: def __init__(self, y, x): self.board = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]] self.knight_history = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]] self.current_pos = [y, x] self.knight_history[y][x] = 1 self.board[y][x] = 1 def display(self, n): """ @purpose To display the current chess board state @complexity: Best & Worst Case: O(n^2) where n is the dimension of the board @parameter none @precondition The Tour class has been initialised @postcondition prints out the current board state """ print('') for i in range(n): for j in range(n): if self.board[i][j] == 1 and self.knight_history[i][j] == 1: print('K', end=' ') elif self.knight_history[i][j] == 1 and self.board[i][j] == 0: print('*', end=' ') else: print('0', end=' ') print('') def move(self, x, y): """ @purpose To display the current chess board state @complexity: O(1) @parameter x: the File to move to y: the Rank to move to @precondition The Tour class has been initialised, and a valid x/y value passed @postcondition current_pos is modified to new Knight position, and Knight's move history is left in knight_history, and the current board is printed out """ if (x >= 0 and x <= 7) and (y >= 0 and y <= 7): old_x = self.current_pos[1] old_y = self.current_pos[0] self.board[old_y][old_x] = 0 self.current_pos = [y, x] self.board[y][x] = 1 self.knight_history[y][x] = 1 else: raise ValueError def menu(): """ @purpose To display the menu @complexity: O(1) @parameter None @precondition None @postcondition displays the menu and allows for user input """ try: print('\n1. Position') print('2. Quit') ans = int(input('Command: ')) if ans == 1: try: pos_x = int(input('X (File): ')) pos_y = int(input('Y (Rank): ')) board.move(posX, posY) except ValueError: print('Please input a valid File and Rank.') elif ans == 2: print('User stopped the program.') global quit quit = True else: raise ValueError except ValueError: print('Please input a valid command.') if __name__ == '__main__': try: quit = False board = tour(0, 1) print('Welcome to Knight Tour. ' + '\nPosition: [Rank y, File x]') while not quit: print('-' * 30) board.display(8) menu() except KeyboardInterrupt: print('\nUser stopped the program.')
""" union operation """ def union(set1: list, set2: list) -> list: result = [] for s1 in set1: for s2 in set2: if s1 == s2: result.append(s1) return result if __name__ == "__main__": cases = [ {"s1": [1, 2, 3], "s2": [3, 4, 5], "ans": [3]}, {"s1": [1], "s2": [3], "ans": []}, {"s1": [], "s2": [], "ans": []}, ] for case in cases: print(case) assert union(case["s1"], case["s2"]) == case["ans"]
""" union operation """ def union(set1: list, set2: list) -> list: result = [] for s1 in set1: for s2 in set2: if s1 == s2: result.append(s1) return result if __name__ == '__main__': cases = [{'s1': [1, 2, 3], 's2': [3, 4, 5], 'ans': [3]}, {'s1': [1], 's2': [3], 'ans': []}, {'s1': [], 's2': [], 'ans': []}] for case in cases: print(case) assert union(case['s1'], case['s2']) == case['ans']
"""Module focussing on the `format` command. Contains the task and helpers to format the codebase given a specific formatter. """ # import pathlib # # # def bob_format(options, cwd): # folders = ['src', 'include'] # filetypes = ['*.c', '*.h', '*.cpp', '*.hpp'] # # files = [] # for f in folders: # base = cwd / f # for type in filetypes: # files += base.rglob(type) # # steps = [] # for file in files: # steps.append(container_command(BuildTarget.Linux, cwd) + [ # "clang-format", # "-style=file", # "-i", # "-fallback-style=none", # str(pathlib.PurePosixPath(file.relative_to(cwd))) # ]) # return steps
"""Module focussing on the `format` command. Contains the task and helpers to format the codebase given a specific formatter. """
template = """ module rom32x4 ( input [4:0] addr, input clk, output [4:0] data); wire [7:0] rdata; wire [15:0] RDATA; wire RCLK; wire [10:0] RADDR; SB_RAM40_4KNR #( // negative edge readclock so we can apply and addres on the positive edge and guarantee data is available on the next posedge .WRITE_MODE(1), .READ_MODE(1), .INIT_0(256'h{init[0][0]:04x}{init[0][1]:04x}{init[0][2]:04x}{init[0][3]:04x}{init[0][4]:04x}{init[0][5]:04x}{init[0][6]:04x}{init[0][7]:04x}{init[0][8]:04x}{init[0][9]:04x}{init[0][10]:04x}{init[0][11]:04x}{init[0][12]:04x}{init[0][13]:04x}{init[0][14]:04x}{init[0][15]:04x}), .INIT_1(256'h{init[1][0]:04x}{init[1][1]:04x}{init[1][2]:04x}{init[1][3]:04x}{init[1][4]:04x}{init[1][5]:04x}{init[1][6]:04x}{init[1][7]:04x}{init[1][8]:04x}{init[1][9]:04x}{init[1][10]:04x}{init[1][11]:04x}{init[1][12]:04x}{init[1][13]:04x}{init[1][14]:04x}{init[1][15]:04x}), .INIT_2(256'h{init[2][0]:04x}{init[2][1]:04x}{init[2][2]:04x}{init[2][3]:04x}{init[2][4]:04x}{init[2][5]:04x}{init[2][6]:04x}{init[2][7]:04x}{init[2][8]:04x}{init[2][9]:04x}{init[2][10]:04x}{init[2][11]:04x}{init[2][12]:04x}{init[2][13]:04x}{init[2][14]:04x}{init[2][15]:04x}), .INIT_3(256'h{init[3][0]:04x}{init[3][1]:04x}{init[3][2]:04x}{init[3][3]:04x}{init[3][4]:04x}{init[3][5]:04x}{init[3][6]:04x}{init[3][7]:04x}{init[3][8]:04x}{init[3][9]:04x}{init[3][10]:04x}{init[3][11]:04x}{init[3][12]:04x}{init[3][13]:04x}{init[3][14]:04x}{init[3][15]:04x}), .INIT_4(256'h{init[4][0]:04x}{init[4][1]:04x}{init[4][2]:04x}{init[4][3]:04x}{init[4][4]:04x}{init[4][5]:04x}{init[4][6]:04x}{init[4][7]:04x}{init[4][8]:04x}{init[4][9]:04x}{init[4][10]:04x}{init[4][11]:04x}{init[4][12]:04x}{init[4][13]:04x}{init[4][14]:04x}{init[4][15]:04x}), .INIT_5(256'h{init[5][0]:04x}{init[5][1]:04x}{init[5][2]:04x}{init[5][3]:04x}{init[5][4]:04x}{init[5][5]:04x}{init[5][6]:04x}{init[5][7]:04x}{init[5][8]:04x}{init[5][9]:04x}{init[5][10]:04x}{init[5][11]:04x}{init[5][12]:04x}{init[5][13]:04x}{init[5][14]:04x}{init[5][15]:04x}), .INIT_6(256'h{init[6][0]:04x}{init[6][1]:04x}{init[6][2]:04x}{init[6][3]:04x}{init[6][4]:04x}{init[6][5]:04x}{init[6][6]:04x}{init[6][7]:04x}{init[6][8]:04x}{init[6][9]:04x}{init[6][10]:04x}{init[6][11]:04x}{init[6][12]:04x}{init[6][13]:04x}{init[6][14]:04x}{init[6][15]:04x}), .INIT_7(256'h{init[7][0]:04x}{init[7][1]:04x}{init[7][2]:04x}{init[7][3]:04x}{init[7][4]:04x}{init[7][5]:04x}{init[7][6]:04x}{init[7][7]:04x}{init[7][8]:04x}{init[7][9]:04x}{init[7][10]:04x}{init[7][11]:04x}{init[7][12]:04x}{init[7][13]:04x}{init[7][14]:04x}{init[7][15]:04x}), .INIT_8(256'h{init[8][0]:04x}{init[8][1]:04x}{init[8][2]:04x}{init[8][3]:04x}{init[8][4]:04x}{init[8][5]:04x}{init[8][6]:04x}{init[8][7]:04x}{init[8][8]:04x}{init[8][9]:04x}{init[8][10]:04x}{init[8][11]:04x}{init[8][12]:04x}{init[8][13]:04x}{init[8][14]:04x}{init[8][15]:04x}), .INIT_9(256'h{init[9][0]:04x}{init[9][1]:04x}{init[9][2]:04x}{init[9][3]:04x}{init[9][4]:04x}{init[9][5]:04x}{init[9][6]:04x}{init[9][7]:04x}{init[9][8]:04x}{init[9][9]:04x}{init[9][10]:04x}{init[9][11]:04x}{init[9][12]:04x}{init[9][13]:04x}{init[9][14]:04x}{init[9][15]:04x}), .INIT_A(256'h{init[10][0]:04x}{init[10][1]:04x}{init[10][2]:04x}{init[10][3]:04x}{init[10][4]:04x}{init[10][5]:04x}{init[10][6]:04x}{init[10][7]:04x}{init[10][8]:04x}{init[10][9]:04x}{init[10][10]:04x}{init[10][11]:04x}{init[10][12]:04x}{init[10][13]:04x}{init[10][14]:04x}{init[10][15]:04x}), .INIT_B(256'h{init[11][0]:04x}{init[11][1]:04x}{init[11][2]:04x}{init[11][3]:04x}{init[11][4]:04x}{init[11][5]:04x}{init[11][6]:04x}{init[11][7]:04x}{init[11][8]:04x}{init[11][9]:04x}{init[11][10]:04x}{init[11][11]:04x}{init[11][12]:04x}{init[11][13]:04x}{init[11][14]:04x}{init[11][15]:04x}), .INIT_C(256'h{init[12][0]:04x}{init[12][1]:04x}{init[12][2]:04x}{init[12][3]:04x}{init[12][4]:04x}{init[12][5]:04x}{init[12][6]:04x}{init[12][7]:04x}{init[12][8]:04x}{init[12][9]:04x}{init[12][10]:04x}{init[12][11]:04x}{init[12][12]:04x}{init[12][13]:04x}{init[12][14]:04x}{init[12][15]:04x}), .INIT_D(256'h{init[13][0]:04x}{init[13][1]:04x}{init[13][2]:04x}{init[13][3]:04x}{init[13][4]:04x}{init[13][5]:04x}{init[13][6]:04x}{init[13][7]:04x}{init[13][8]:04x}{init[13][9]:04x}{init[13][10]:04x}{init[13][11]:04x}{init[13][12]:04x}{init[13][13]:04x}{init[13][14]:04x}{init[13][15]:04x}), .INIT_E(256'h{init[14][0]:04x}{init[14][1]:04x}{init[14][2]:04x}{init[14][3]:04x}{init[14][4]:04x}{init[14][5]:04x}{init[14][6]:04x}{init[14][7]:04x}{init[14][8]:04x}{init[14][9]:04x}{init[14][10]:04x}{init[14][11]:04x}{init[14][12]:04x}{init[14][13]:04x}{init[14][14]:04x}{init[14][15]:04x}), .INIT_F(256'h{init[15][0]:04x}{init[15][1]:04x}{init[15][2]:04x}{init[15][3]:04x}{init[15][4]:04x}{init[15][5]:04x}{init[15][6]:04x}{init[15][7]:04x}{init[15][8]:04x}{init[15][9]:04x}{init[15][10]:04x}{init[15][11]:04x}{init[15][12]:04x}{init[15][13]:04x}{init[15][14]:04x}{init[15][15]:04x}) ) rom( .RDATA(RDATA), .RCLKN(RCLK), // negative edge readclock has an N appended .RCLKE(1), .RE(1), .RADDR(RADDR), .WCLK(0), .WCLKE(0), .WE(0), .WADDR(11'hxxxx), .MASK(16'hxxxx), .WDATA(8'hxx) ); assign rdata = {{RDATA[14],RDATA[12],RDATA[10],RDATA[8],RDATA[6],RDATA[4],RDATA[2],RDATA[0]}}; assign data = rdata[4:0]; assign RADDR = {{6'b0, addr}}; assign RCLK = clk; endmodule """ # https://github.com/jamesbowman/swapforth/blob/master/j1a/mkrom.py # https://stackoverflow.com/questions/41499494/how-can-i-use-ice40-4k-block-ram-in-512x8-read-mode-with-icestorm def fanbits(byt): f = 0 for i in range(8): if byt & (1 << i): f += 1 << i*2+1 return f def genrom(data): init = a=[[0] * 16 for i in range(16)] for i,d in enumerate(data): row = (i % 256) // 16 col = 15 - i % 16 bits= fanbits(d) bits= (bits >> 1) if i < 256 else bits init[row][col] |= bits return template.format(init = init) START = 0; # next is START unless overruled FETCH = 1; # next state is always WAIT DECODE = 2; # next is FETCH unless overruled OPLOAD = 3; # next state is always DECODE ECHO = 4; # next state is always ECHO1 ECHO1 = 5; # next is ECHO1 unless overruled WAIT = 6; # next state is always OPLOAD WAIT2 = 7; # next state is always OPLOAD2 OPLOAD2 = 8; # next state is always DECODE2 DECODE2 = 9; # next is FETCH unless overruled WAIT3 = 10; # next state is always MEMLOAD MEMLOAD = 11; # next state is always FETCH READ = 12; # next is READ unless overruled STACKPUSH = 13; # next state is always STACKPUSH2 STACKPUSH2= 14; # next state is always FETCH CALL1 = 15; # next state is always CALL2 CALL2 = 16; # next state is always CALL3 CALL3 = 17; # next state is always CALL4 CALL4 = 18; # next state is always CALL5 CALL5 = 19; # next state is always FETCH RETURN1 = 20; # next state is always RETURN2 RETURN2 = 21; # next state is always RETURN3 RETURN3 = 22; # next state is always RETURN4 RETURN4 = 23; # next state is always RETURN5 RETURN5 = 24; # next state is always FETCH STIDPWAIT = 25; # next state is always STIDPWAIT1 WAITBASER = 26; # next state is always WAITBASER1 WAITBASER1= 27; # next state is always FETCH STIDPWAIT1= 31; # next state is always FETCH data = { START :START, FETCH :WAIT, DECODE :FETCH, OPLOAD :DECODE, ECHO :ECHO1, ECHO1 :ECHO1, WAIT :OPLOAD, WAIT2 :OPLOAD2, OPLOAD2 :DECODE2, DECODE2 :FETCH, WAIT3 :MEMLOAD, MEMLOAD :FETCH, READ :READ, STACKPUSH :STACKPUSH2, STACKPUSH2:FETCH, CALL1 :CALL2, CALL2 :CALL3, CALL3 :CALL4, CALL4 :CALL5, CALL5 :FETCH, RETURN1 :RETURN2, RETURN2 :RETURN3, RETURN3 :RETURN4, RETURN4 :RETURN5, RETURN5 :FETCH, STIDPWAIT :STIDPWAIT1, WAITBASER :WAITBASER1, WAITBASER1:FETCH, STIDPWAIT1:FETCH, } data = [data[k] for k in sorted(data)] nbytes = len(data) data = data + [0] * (512 - nbytes) print(genrom(data))
template = "\nmodule rom32x4 (\n\tinput [4:0] addr, \n\tinput clk,\n\toutput [4:0] data);\n\n wire [7:0] rdata;\n\twire [15:0] RDATA;\n\twire RCLK;\n\twire [10:0] RADDR;\n\n\tSB_RAM40_4KNR #( // negative edge readclock so we can apply and addres on the positive edge and guarantee data is available on the next posedge\n\t\t.WRITE_MODE(1), \n\t\t.READ_MODE(1),\n .INIT_0(256'h{init[0][0]:04x}{init[0][1]:04x}{init[0][2]:04x}{init[0][3]:04x}{init[0][4]:04x}{init[0][5]:04x}{init[0][6]:04x}{init[0][7]:04x}{init[0][8]:04x}{init[0][9]:04x}{init[0][10]:04x}{init[0][11]:04x}{init[0][12]:04x}{init[0][13]:04x}{init[0][14]:04x}{init[0][15]:04x}),\n .INIT_1(256'h{init[1][0]:04x}{init[1][1]:04x}{init[1][2]:04x}{init[1][3]:04x}{init[1][4]:04x}{init[1][5]:04x}{init[1][6]:04x}{init[1][7]:04x}{init[1][8]:04x}{init[1][9]:04x}{init[1][10]:04x}{init[1][11]:04x}{init[1][12]:04x}{init[1][13]:04x}{init[1][14]:04x}{init[1][15]:04x}),\n .INIT_2(256'h{init[2][0]:04x}{init[2][1]:04x}{init[2][2]:04x}{init[2][3]:04x}{init[2][4]:04x}{init[2][5]:04x}{init[2][6]:04x}{init[2][7]:04x}{init[2][8]:04x}{init[2][9]:04x}{init[2][10]:04x}{init[2][11]:04x}{init[2][12]:04x}{init[2][13]:04x}{init[2][14]:04x}{init[2][15]:04x}),\n .INIT_3(256'h{init[3][0]:04x}{init[3][1]:04x}{init[3][2]:04x}{init[3][3]:04x}{init[3][4]:04x}{init[3][5]:04x}{init[3][6]:04x}{init[3][7]:04x}{init[3][8]:04x}{init[3][9]:04x}{init[3][10]:04x}{init[3][11]:04x}{init[3][12]:04x}{init[3][13]:04x}{init[3][14]:04x}{init[3][15]:04x}),\n .INIT_4(256'h{init[4][0]:04x}{init[4][1]:04x}{init[4][2]:04x}{init[4][3]:04x}{init[4][4]:04x}{init[4][5]:04x}{init[4][6]:04x}{init[4][7]:04x}{init[4][8]:04x}{init[4][9]:04x}{init[4][10]:04x}{init[4][11]:04x}{init[4][12]:04x}{init[4][13]:04x}{init[4][14]:04x}{init[4][15]:04x}),\n .INIT_5(256'h{init[5][0]:04x}{init[5][1]:04x}{init[5][2]:04x}{init[5][3]:04x}{init[5][4]:04x}{init[5][5]:04x}{init[5][6]:04x}{init[5][7]:04x}{init[5][8]:04x}{init[5][9]:04x}{init[5][10]:04x}{init[5][11]:04x}{init[5][12]:04x}{init[5][13]:04x}{init[5][14]:04x}{init[5][15]:04x}),\n .INIT_6(256'h{init[6][0]:04x}{init[6][1]:04x}{init[6][2]:04x}{init[6][3]:04x}{init[6][4]:04x}{init[6][5]:04x}{init[6][6]:04x}{init[6][7]:04x}{init[6][8]:04x}{init[6][9]:04x}{init[6][10]:04x}{init[6][11]:04x}{init[6][12]:04x}{init[6][13]:04x}{init[6][14]:04x}{init[6][15]:04x}),\n .INIT_7(256'h{init[7][0]:04x}{init[7][1]:04x}{init[7][2]:04x}{init[7][3]:04x}{init[7][4]:04x}{init[7][5]:04x}{init[7][6]:04x}{init[7][7]:04x}{init[7][8]:04x}{init[7][9]:04x}{init[7][10]:04x}{init[7][11]:04x}{init[7][12]:04x}{init[7][13]:04x}{init[7][14]:04x}{init[7][15]:04x}),\n .INIT_8(256'h{init[8][0]:04x}{init[8][1]:04x}{init[8][2]:04x}{init[8][3]:04x}{init[8][4]:04x}{init[8][5]:04x}{init[8][6]:04x}{init[8][7]:04x}{init[8][8]:04x}{init[8][9]:04x}{init[8][10]:04x}{init[8][11]:04x}{init[8][12]:04x}{init[8][13]:04x}{init[8][14]:04x}{init[8][15]:04x}),\n .INIT_9(256'h{init[9][0]:04x}{init[9][1]:04x}{init[9][2]:04x}{init[9][3]:04x}{init[9][4]:04x}{init[9][5]:04x}{init[9][6]:04x}{init[9][7]:04x}{init[9][8]:04x}{init[9][9]:04x}{init[9][10]:04x}{init[9][11]:04x}{init[9][12]:04x}{init[9][13]:04x}{init[9][14]:04x}{init[9][15]:04x}),\n .INIT_A(256'h{init[10][0]:04x}{init[10][1]:04x}{init[10][2]:04x}{init[10][3]:04x}{init[10][4]:04x}{init[10][5]:04x}{init[10][6]:04x}{init[10][7]:04x}{init[10][8]:04x}{init[10][9]:04x}{init[10][10]:04x}{init[10][11]:04x}{init[10][12]:04x}{init[10][13]:04x}{init[10][14]:04x}{init[10][15]:04x}),\n .INIT_B(256'h{init[11][0]:04x}{init[11][1]:04x}{init[11][2]:04x}{init[11][3]:04x}{init[11][4]:04x}{init[11][5]:04x}{init[11][6]:04x}{init[11][7]:04x}{init[11][8]:04x}{init[11][9]:04x}{init[11][10]:04x}{init[11][11]:04x}{init[11][12]:04x}{init[11][13]:04x}{init[11][14]:04x}{init[11][15]:04x}),\n .INIT_C(256'h{init[12][0]:04x}{init[12][1]:04x}{init[12][2]:04x}{init[12][3]:04x}{init[12][4]:04x}{init[12][5]:04x}{init[12][6]:04x}{init[12][7]:04x}{init[12][8]:04x}{init[12][9]:04x}{init[12][10]:04x}{init[12][11]:04x}{init[12][12]:04x}{init[12][13]:04x}{init[12][14]:04x}{init[12][15]:04x}),\n .INIT_D(256'h{init[13][0]:04x}{init[13][1]:04x}{init[13][2]:04x}{init[13][3]:04x}{init[13][4]:04x}{init[13][5]:04x}{init[13][6]:04x}{init[13][7]:04x}{init[13][8]:04x}{init[13][9]:04x}{init[13][10]:04x}{init[13][11]:04x}{init[13][12]:04x}{init[13][13]:04x}{init[13][14]:04x}{init[13][15]:04x}),\n .INIT_E(256'h{init[14][0]:04x}{init[14][1]:04x}{init[14][2]:04x}{init[14][3]:04x}{init[14][4]:04x}{init[14][5]:04x}{init[14][6]:04x}{init[14][7]:04x}{init[14][8]:04x}{init[14][9]:04x}{init[14][10]:04x}{init[14][11]:04x}{init[14][12]:04x}{init[14][13]:04x}{init[14][14]:04x}{init[14][15]:04x}),\n .INIT_F(256'h{init[15][0]:04x}{init[15][1]:04x}{init[15][2]:04x}{init[15][3]:04x}{init[15][4]:04x}{init[15][5]:04x}{init[15][6]:04x}{init[15][7]:04x}{init[15][8]:04x}{init[15][9]:04x}{init[15][10]:04x}{init[15][11]:04x}{init[15][12]:04x}{init[15][13]:04x}{init[15][14]:04x}{init[15][15]:04x})\n\t) rom(\n\t\t.RDATA(RDATA),\n\t\t.RCLKN(RCLK), // negative edge readclock has an N appended\n\t\t.RCLKE(1),\n\t\t.RE(1),\n\t\t.RADDR(RADDR),\n\t\t.WCLK(0),\n\t\t.WCLKE(0),\n\t\t.WE(0),\n\t\t.WADDR(11'hxxxx),\n\t\t.MASK(16'hxxxx),\n\t\t.WDATA(8'hxx)\n\t);\n\n assign rdata = {{RDATA[14],RDATA[12],RDATA[10],RDATA[8],RDATA[6],RDATA[4],RDATA[2],RDATA[0]}};\n\tassign data = rdata[4:0];\n\tassign RADDR = {{6'b0, addr}};\n\tassign RCLK = clk;\n\nendmodule\n" def fanbits(byt): f = 0 for i in range(8): if byt & 1 << i: f += 1 << i * 2 + 1 return f def genrom(data): init = a = [[0] * 16 for i in range(16)] for (i, d) in enumerate(data): row = i % 256 // 16 col = 15 - i % 16 bits = fanbits(d) bits = bits >> 1 if i < 256 else bits init[row][col] |= bits return template.format(init=init) start = 0 fetch = 1 decode = 2 opload = 3 echo = 4 echo1 = 5 wait = 6 wait2 = 7 opload2 = 8 decode2 = 9 wait3 = 10 memload = 11 read = 12 stackpush = 13 stackpush2 = 14 call1 = 15 call2 = 16 call3 = 17 call4 = 18 call5 = 19 return1 = 20 return2 = 21 return3 = 22 return4 = 23 return5 = 24 stidpwait = 25 waitbaser = 26 waitbaser1 = 27 stidpwait1 = 31 data = {START: START, FETCH: WAIT, DECODE: FETCH, OPLOAD: DECODE, ECHO: ECHO1, ECHO1: ECHO1, WAIT: OPLOAD, WAIT2: OPLOAD2, OPLOAD2: DECODE2, DECODE2: FETCH, WAIT3: MEMLOAD, MEMLOAD: FETCH, READ: READ, STACKPUSH: STACKPUSH2, STACKPUSH2: FETCH, CALL1: CALL2, CALL2: CALL3, CALL3: CALL4, CALL4: CALL5, CALL5: FETCH, RETURN1: RETURN2, RETURN2: RETURN3, RETURN3: RETURN4, RETURN4: RETURN5, RETURN5: FETCH, STIDPWAIT: STIDPWAIT1, WAITBASER: WAITBASER1, WAITBASER1: FETCH, STIDPWAIT1: FETCH} data = [data[k] for k in sorted(data)] nbytes = len(data) data = data + [0] * (512 - nbytes) print(genrom(data))
#!/usr/bin/env python3 def raw_limit_ranges(callback_values): data = { '__meta': { 'chart': 'cisco-sso/raw', 'version': '0.1.0' }, 'resources': [{ 'apiVersion': 'v1', 'kind': 'LimitRange', 'metadata': { 'name': 'limits' }, 'spec': { 'limits': [{ 'default': { 'cpu': '100m', 'memory': '256Mi' }, 'defaultRequest': { 'cpu': '100m', 'memory': '256Mi' }, 'type': 'Container' }] } }] } callback_values.update(data) return callback_values
def raw_limit_ranges(callback_values): data = {'__meta': {'chart': 'cisco-sso/raw', 'version': '0.1.0'}, 'resources': [{'apiVersion': 'v1', 'kind': 'LimitRange', 'metadata': {'name': 'limits'}, 'spec': {'limits': [{'default': {'cpu': '100m', 'memory': '256Mi'}, 'defaultRequest': {'cpu': '100m', 'memory': '256Mi'}, 'type': 'Container'}]}}]} callback_values.update(data) return callback_values
#definir variables y otros print("Ejemplo 01-Area de un triangulo") #Datos de entrada - Ingresados mediante dispositivos de entrada b=int(input("Ingrese Base:")) h=int(input("Ingrese altura")) #proceso de calculo de Area area=(b*h)/2 #Datos de salida print("El area del triangulo es:", area)
print('Ejemplo 01-Area de un triangulo') b = int(input('Ingrese Base:')) h = int(input('Ingrese altura')) area = b * h / 2 print('El area del triangulo es:', area)
def handle_request(response): if response.error: print("Error:", response.error) else: print('called') print(response.body)
def handle_request(response): if response.error: print('Error:', response.error) else: print('called') print(response.body)
# CPP Program of Prim's algorithm for MST inf = 65000 # To add an edge def addEdge(adj, u, v, wt): adj[u].append([v, wt]) adj[v].append([u, wt]) def primMST(adj, V): # Create a priority queue to store vertices that # are being preinMST. pq = [] src = 0 # Taking vertex 0 as source # Create a vector for keys and initialize all keys as infinite (INF) key = [inf for i in range(V)] # To store parent array which in turn store MST parent = [-1 for i in range(V)] # To keep track of vertices included in MST inMST = [False for i in range(V)] # Insert source itself in priority queue and initialize its key as 0. pq.append([0, src]) key[src] = 0 # Looping till priority queue becomes empty while len(pq) != 0: # The first vertex in pair is the minimum key # vertex, extract it from priority queue. # vertex label is stored in second of pair (it # has to be done this way to keep the vertices # sorted key (key must be first item # in pair) u = pq[0][1] del pq[0] # Different key values for same vertex may exist in the priority queue. # The one with the least key value is always processed first. # Therefore, ignore the rest. if inMST[u] == True: continue inMST[u] = True # Include vertex in MST # Traverse all adjacent of u for x in adj[u]: # Get vertex label and weight of current adjacent of u. v = x[0] weight = x[1] # If v is not in MST and weight of (u,v) is smaller # than current key of v if inMST[v] == False and key[v] > weight: # Updating key of v key[v] = weight pq.append([key[v], v]) pq.sort() parent[v] = u for i in range(1, V): print(parent[i], "-", i) # Driver code V = 9 adj = [[] for i in range(V)] addEdge(adj, 0, 1, 4) addEdge(adj, 0, 7, 8) addEdge(adj, 1, 2, 8) addEdge(adj, 1, 7, 11) addEdge(adj, 2, 3, 7) addEdge(adj, 2, 8, 2) addEdge(adj, 2, 5, 4) addEdge(adj, 3, 4, 9) addEdge(adj, 3, 5, 14) addEdge(adj, 4, 5, 10) addEdge(adj, 5, 6, 2) addEdge(adj, 6, 7, 1) addEdge(adj, 6, 8, 6) addEdge(adj, 7, 8, 7) print("Edges of MST are") primMST(adj, V) # Output: # Edges of MST are # 0 - 1 # 1 - 2 # 2 - 3 # 3 - 4 # 2 - 5 # 5 - 6 # 6 - 7 # 2 - 8
inf = 65000 def add_edge(adj, u, v, wt): adj[u].append([v, wt]) adj[v].append([u, wt]) def prim_mst(adj, V): pq = [] src = 0 key = [inf for i in range(V)] parent = [-1 for i in range(V)] in_mst = [False for i in range(V)] pq.append([0, src]) key[src] = 0 while len(pq) != 0: u = pq[0][1] del pq[0] if inMST[u] == True: continue inMST[u] = True for x in adj[u]: v = x[0] weight = x[1] if inMST[v] == False and key[v] > weight: key[v] = weight pq.append([key[v], v]) pq.sort() parent[v] = u for i in range(1, V): print(parent[i], '-', i) v = 9 adj = [[] for i in range(V)] add_edge(adj, 0, 1, 4) add_edge(adj, 0, 7, 8) add_edge(adj, 1, 2, 8) add_edge(adj, 1, 7, 11) add_edge(adj, 2, 3, 7) add_edge(adj, 2, 8, 2) add_edge(adj, 2, 5, 4) add_edge(adj, 3, 4, 9) add_edge(adj, 3, 5, 14) add_edge(adj, 4, 5, 10) add_edge(adj, 5, 6, 2) add_edge(adj, 6, 7, 1) add_edge(adj, 6, 8, 6) add_edge(adj, 7, 8, 7) print('Edges of MST are') prim_mst(adj, V)
n,m,k = map(int,input().split()) d = list(map(int,input().split())) m = list(map(int,input().split())) ans = [] check = 10**18 for i in range(len(d)): frog=d[i] c=0 for j in range(len(m)): if m[j]%frog==0: c+=1 if c<check: ans.clear() ans.append(i+1) check=c elif c==check: ans.append(i+1) c=check print(len(ans)) print(*ans)
(n, m, k) = map(int, input().split()) d = list(map(int, input().split())) m = list(map(int, input().split())) ans = [] check = 10 ** 18 for i in range(len(d)): frog = d[i] c = 0 for j in range(len(m)): if m[j] % frog == 0: c += 1 if c < check: ans.clear() ans.append(i + 1) check = c elif c == check: ans.append(i + 1) c = check print(len(ans)) print(*ans)
# Variables age = 20 # declaring int variable temperature = 89.8 # declaring float variable name = 'John' # declaring str variable, Note: we use single quotes to store the text. model = "SD902" # declaring str variable print(model) model = 8890 # now re-declaring model variable as int # In Python this is allowed, anywhere you can change the type of variable # just be re declaring with new value of any type. print(model) # Another way of declaring variables # also the variable names are case sensitive msg = str("Big Brother is in town") Msg = str("Case sensitive variable") print(f"msg = {msg}") print(f"Msg = {Msg}")
age = 20 temperature = 89.8 name = 'John' model = 'SD902' print(model) model = 8890 print(model) msg = str('Big Brother is in town') msg = str('Case sensitive variable') print(f'msg = {msg}') print(f'Msg = {Msg}')
# -*- coding: utf-8 -*- ''' Copyright (c) 2014 @author: Marat Khayrullin <xmm.dev@gmail.com> ''' API_VERSION_V0 = 0 API_VERSION = API_VERSION_V0 bp_name = 'api_v0' api_v0_prefix = '{prefix}/v{version}'.format( prefix='/api', # current_app.config['URL_PREFIX'], version=API_VERSION_V0 )
""" Copyright (c) 2014 @author: Marat Khayrullin <xmm.dev@gmail.com> """ api_version_v0 = 0 api_version = API_VERSION_V0 bp_name = 'api_v0' api_v0_prefix = '{prefix}/v{version}'.format(prefix='/api', version=API_VERSION_V0)
hex2bin = dict('{:x} {:04b}'.format(x,x).split() for x in range(16)) def float_dec2bin(n): neg = False if n < 0: n = -n neg = True hx = float(n).hex() p = hx.index('p') bn = ''.join(hex2bin.get(char, char) for char in hx[2:p]) return (('1' if neg else '0') + bn.strip('0') + hx[p:p+2] + bin(int(hx[p+2:]))[2:])
hex2bin = dict(('{:x} {:04b}'.format(x, x).split() for x in range(16))) def float_dec2bin(n): neg = False if n < 0: n = -n neg = True hx = float(n).hex() p = hx.index('p') bn = ''.join((hex2bin.get(char, char) for char in hx[2:p])) return ('1' if neg else '0') + bn.strip('0') + hx[p:p + 2] + bin(int(hx[p + 2:]))[2:]
# basicpackage/foo.py a = 10 class Foo(object): pass print("inside 'basicpackage/foo.py' with a variable in it")
a = 10 class Foo(object): pass print("inside 'basicpackage/foo.py' with a variable in it")
famous_people = [] with open("/Users/coco/Documents/GitHub/python-side-projects/wikipedia-crawler/year1902-2020.txt",'r') as foo: for line in foo.readlines(): if '``' in line: famous_people.append(line) with open("famous_people.txt", "a") as f: for person in famous_people: f.write(person)
famous_people = [] with open('/Users/coco/Documents/GitHub/python-side-projects/wikipedia-crawler/year1902-2020.txt', 'r') as foo: for line in foo.readlines(): if '``' in line: famous_people.append(line) with open('famous_people.txt', 'a') as f: for person in famous_people: f.write(person)
class no_deps(object): pass class one_dep(object): def __init__(self, dependency): self.dependency = dependency class two_deps(object): def __init__(self, first_dep, second_dep): self.first_dep = first_dep self.second_dep = second_dep
class No_Deps(object): pass class One_Dep(object): def __init__(self, dependency): self.dependency = dependency class Two_Deps(object): def __init__(self, first_dep, second_dep): self.first_dep = first_dep self.second_dep = second_dep
# # PySNMP MIB module HP-ICF-ARP-PROTECT (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HP-ICF-ARP-PROTECT # Produced by pysmi-0.3.4 at Mon Apr 29 19:20:43 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, ConstraintsIntersection, ConstraintsUnion, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "SingleValueConstraint", "ConstraintsIntersection", "ConstraintsUnion", "ValueSizeConstraint") hpSwitch, = mibBuilder.importSymbols("HP-ICF-OID", "hpSwitch") ifIndex, = mibBuilder.importSymbols("IF-MIB", "ifIndex") InetAddress, InetAddressType = mibBuilder.importSymbols("INET-ADDRESS-MIB", "InetAddress", "InetAddressType") VlanIndex, = mibBuilder.importSymbols("Q-BRIDGE-MIB", "VlanIndex") ObjectGroup, NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "ObjectGroup", "NotificationGroup", "ModuleCompliance") NotificationType, Integer32, ModuleIdentity, MibIdentifier, Unsigned32, MibScalar, MibTable, MibTableRow, MibTableColumn, ObjectIdentity, Counter64, Gauge32, IpAddress, Bits, Counter32, iso, TimeTicks = mibBuilder.importSymbols("SNMPv2-SMI", "NotificationType", "Integer32", "ModuleIdentity", "MibIdentifier", "Unsigned32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ObjectIdentity", "Counter64", "Gauge32", "IpAddress", "Bits", "Counter32", "iso", "TimeTicks") DisplayString, TextualConvention, MacAddress, TruthValue = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention", "MacAddress", "TruthValue") hpicfArpProtect = ModuleIdentity((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37)) hpicfArpProtect.setRevisions(('2007-08-29 00:00', '2006-05-03 00:27',)) if mibBuilder.loadTexts: hpicfArpProtect.setLastUpdated('200708290000Z') if mibBuilder.loadTexts: hpicfArpProtect.setOrganization('HP Networking') hpicfArpProtectNotifications = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 0)) hpicfArpProtectErrantReply = NotificationType((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 0, 1)).setObjects(("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantCnt"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantSrcMac"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantSrcIpType"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantSrcIp"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantDestMac"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantDestIpType"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantDestIp")) if mibBuilder.loadTexts: hpicfArpProtectErrantReply.setStatus('current') hpicfArpProtectObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1)) hpicfArpProtectConfig = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1)) hpicfArpProtectGlobalCfg = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 1)) hpicfArpProtectEnable = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 1, 1), TruthValue()).setMaxAccess("readwrite") if mibBuilder.loadTexts: hpicfArpProtectEnable.setStatus('current') hpicfArpProtectVlanEnable = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 1, 2), OctetString().subtype(subtypeSpec=ValueSizeConstraint(512, 512)).setFixedLength(512)).setMaxAccess("readwrite") if mibBuilder.loadTexts: hpicfArpProtectVlanEnable.setStatus('current') hpicfArpProtectValidation = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 1, 3), Bits().clone(namedValues=NamedValues(("srcMac", 0), ("dstMac", 1), ("ip", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: hpicfArpProtectValidation.setStatus('current') hpicfArpProtectErrantNotifyEnable = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: hpicfArpProtectErrantNotifyEnable.setStatus('current') hpicfArpProtectPortTable = MibTable((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 2), ) if mibBuilder.loadTexts: hpicfArpProtectPortTable.setStatus('current') hpicfArpProtectPortEntry = MibTableRow((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 2, 1), ).setIndexNames((0, "IF-MIB", "ifIndex")) if mibBuilder.loadTexts: hpicfArpProtectPortEntry.setStatus('current') hpicfArpProtectPortTrust = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 2, 1, 1), TruthValue()).setMaxAccess("readwrite") if mibBuilder.loadTexts: hpicfArpProtectPortTrust.setStatus('current') hpicfArpProtectStatus = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2)) hpicfArpProtectVlanStatTable = MibTable((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1), ) if mibBuilder.loadTexts: hpicfArpProtectVlanStatTable.setStatus('current') hpicfArpProtectVlanStatEntry = MibTableRow((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1), ).setIndexNames((0, "HP-ICF-ARP-PROTECT", "hpicfArpProtectVlanStatIndex")) if mibBuilder.loadTexts: hpicfArpProtectVlanStatEntry.setStatus('current') hpicfArpProtectVlanStatIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 1), VlanIndex()) if mibBuilder.loadTexts: hpicfArpProtectVlanStatIndex.setStatus('current') hpicfArpProtectVlanStatForwards = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 2), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hpicfArpProtectVlanStatForwards.setStatus('current') hpicfArpProtectVlanStatBadPkts = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 3), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hpicfArpProtectVlanStatBadPkts.setStatus('current') hpicfArpProtectVlanStatBadBindings = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 4), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hpicfArpProtectVlanStatBadBindings.setStatus('current') hpicfArpProtectVlanStatBadSrcMacs = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 5), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hpicfArpProtectVlanStatBadSrcMacs.setStatus('current') hpicfArpProtectVlanStatBadDstMacs = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 6), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hpicfArpProtectVlanStatBadDstMacs.setStatus('current') hpicfArpProtectVlanStatBadIpAddrs = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 7), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hpicfArpProtectVlanStatBadIpAddrs.setStatus('current') hpicfArpProtectErrantCnt = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 3), Counter32()).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: hpicfArpProtectErrantCnt.setStatus('current') hpicfArpProtectErrantSrcMac = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 4), MacAddress()).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: hpicfArpProtectErrantSrcMac.setStatus('current') hpicfArpProtectErrantSrcIpType = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 5), InetAddressType()).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: hpicfArpProtectErrantSrcIpType.setStatus('current') hpicfArpProtectErrantSrcIp = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 6), InetAddress()).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: hpicfArpProtectErrantSrcIp.setStatus('current') hpicfArpProtectErrantDestMac = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 7), MacAddress()).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: hpicfArpProtectErrantDestMac.setStatus('current') hpicfArpProtectErrantDestIpType = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 8), InetAddressType()).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: hpicfArpProtectErrantDestIpType.setStatus('current') hpicfArpProtectErrantDestIp = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 9), InetAddress()).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: hpicfArpProtectErrantDestIp.setStatus('current') hpicfArpProtectConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2)) hpicfArpProtectGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2, 1)) hpicfArpProtectBaseGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2, 1, 1)).setObjects(("HP-ICF-ARP-PROTECT", "hpicfArpProtectEnable"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectVlanEnable"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectValidation"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectPortTrust"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectVlanStatForwards"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectVlanStatBadPkts"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectVlanStatBadBindings"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectVlanStatBadSrcMacs"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectVlanStatBadDstMacs"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectVlanStatBadIpAddrs"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantSrcMac"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantSrcIp"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantDestMac"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantSrcIpType"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantDestIpType"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantDestIp"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantCnt"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantNotifyEnable")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): hpicfArpProtectBaseGroup = hpicfArpProtectBaseGroup.setStatus('current') hpicfArpProtectionNotifications = NotificationGroup((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2, 1, 2)).setObjects(("HP-ICF-ARP-PROTECT", "hpicfArpProtectErrantReply")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): hpicfArpProtectionNotifications = hpicfArpProtectionNotifications.setStatus('current') hpicfArpProtectCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2, 2)) hpicfArpProtectCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2, 2, 1)).setObjects(("HP-ICF-ARP-PROTECT", "hpicfArpProtectBaseGroup"), ("HP-ICF-ARP-PROTECT", "hpicfArpProtectionNotifications")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): hpicfArpProtectCompliance = hpicfArpProtectCompliance.setStatus('current') mibBuilder.exportSymbols("HP-ICF-ARP-PROTECT", hpicfArpProtectVlanStatBadDstMacs=hpicfArpProtectVlanStatBadDstMacs, hpicfArpProtectErrantSrcMac=hpicfArpProtectErrantSrcMac, hpicfArpProtectErrantDestIp=hpicfArpProtectErrantDestIp, hpicfArpProtectStatus=hpicfArpProtectStatus, hpicfArpProtectVlanStatBadSrcMacs=hpicfArpProtectVlanStatBadSrcMacs, hpicfArpProtectNotifications=hpicfArpProtectNotifications, hpicfArpProtectionNotifications=hpicfArpProtectionNotifications, hpicfArpProtectGroups=hpicfArpProtectGroups, hpicfArpProtectVlanStatIndex=hpicfArpProtectVlanStatIndex, hpicfArpProtectVlanStatBadBindings=hpicfArpProtectVlanStatBadBindings, hpicfArpProtectEnable=hpicfArpProtectEnable, PYSNMP_MODULE_ID=hpicfArpProtect, hpicfArpProtectValidation=hpicfArpProtectValidation, hpicfArpProtectVlanStatForwards=hpicfArpProtectVlanStatForwards, hpicfArpProtectErrantSrcIpType=hpicfArpProtectErrantSrcIpType, hpicfArpProtectErrantNotifyEnable=hpicfArpProtectErrantNotifyEnable, hpicfArpProtectCompliances=hpicfArpProtectCompliances, hpicfArpProtectBaseGroup=hpicfArpProtectBaseGroup, hpicfArpProtectErrantReply=hpicfArpProtectErrantReply, hpicfArpProtectConfig=hpicfArpProtectConfig, hpicfArpProtectVlanStatBadPkts=hpicfArpProtectVlanStatBadPkts, hpicfArpProtectErrantCnt=hpicfArpProtectErrantCnt, hpicfArpProtectGlobalCfg=hpicfArpProtectGlobalCfg, hpicfArpProtectVlanStatEntry=hpicfArpProtectVlanStatEntry, hpicfArpProtectObjects=hpicfArpProtectObjects, hpicfArpProtectErrantDestIpType=hpicfArpProtectErrantDestIpType, hpicfArpProtectErrantSrcIp=hpicfArpProtectErrantSrcIp, hpicfArpProtectVlanStatBadIpAddrs=hpicfArpProtectVlanStatBadIpAddrs, hpicfArpProtectCompliance=hpicfArpProtectCompliance, hpicfArpProtectConformance=hpicfArpProtectConformance, hpicfArpProtectPortTable=hpicfArpProtectPortTable, hpicfArpProtectVlanEnable=hpicfArpProtectVlanEnable, hpicfArpProtectPortTrust=hpicfArpProtectPortTrust, hpicfArpProtectVlanStatTable=hpicfArpProtectVlanStatTable, hpicfArpProtectErrantDestMac=hpicfArpProtectErrantDestMac, hpicfArpProtect=hpicfArpProtect, hpicfArpProtectPortEntry=hpicfArpProtectPortEntry)
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, single_value_constraint, constraints_intersection, constraints_union, value_size_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueRangeConstraint', 'SingleValueConstraint', 'ConstraintsIntersection', 'ConstraintsUnion', 'ValueSizeConstraint') (hp_switch,) = mibBuilder.importSymbols('HP-ICF-OID', 'hpSwitch') (if_index,) = mibBuilder.importSymbols('IF-MIB', 'ifIndex') (inet_address, inet_address_type) = mibBuilder.importSymbols('INET-ADDRESS-MIB', 'InetAddress', 'InetAddressType') (vlan_index,) = mibBuilder.importSymbols('Q-BRIDGE-MIB', 'VlanIndex') (object_group, notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'ObjectGroup', 'NotificationGroup', 'ModuleCompliance') (notification_type, integer32, module_identity, mib_identifier, unsigned32, mib_scalar, mib_table, mib_table_row, mib_table_column, object_identity, counter64, gauge32, ip_address, bits, counter32, iso, time_ticks) = mibBuilder.importSymbols('SNMPv2-SMI', 'NotificationType', 'Integer32', 'ModuleIdentity', 'MibIdentifier', 'Unsigned32', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'ObjectIdentity', 'Counter64', 'Gauge32', 'IpAddress', 'Bits', 'Counter32', 'iso', 'TimeTicks') (display_string, textual_convention, mac_address, truth_value) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention', 'MacAddress', 'TruthValue') hpicf_arp_protect = module_identity((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37)) hpicfArpProtect.setRevisions(('2007-08-29 00:00', '2006-05-03 00:27')) if mibBuilder.loadTexts: hpicfArpProtect.setLastUpdated('200708290000Z') if mibBuilder.loadTexts: hpicfArpProtect.setOrganization('HP Networking') hpicf_arp_protect_notifications = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 0)) hpicf_arp_protect_errant_reply = notification_type((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 0, 1)).setObjects(('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantCnt'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantSrcMac'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantSrcIpType'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantSrcIp'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantDestMac'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantDestIpType'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantDestIp')) if mibBuilder.loadTexts: hpicfArpProtectErrantReply.setStatus('current') hpicf_arp_protect_objects = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1)) hpicf_arp_protect_config = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1)) hpicf_arp_protect_global_cfg = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 1)) hpicf_arp_protect_enable = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 1, 1), truth_value()).setMaxAccess('readwrite') if mibBuilder.loadTexts: hpicfArpProtectEnable.setStatus('current') hpicf_arp_protect_vlan_enable = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 1, 2), octet_string().subtype(subtypeSpec=value_size_constraint(512, 512)).setFixedLength(512)).setMaxAccess('readwrite') if mibBuilder.loadTexts: hpicfArpProtectVlanEnable.setStatus('current') hpicf_arp_protect_validation = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 1, 3), bits().clone(namedValues=named_values(('srcMac', 0), ('dstMac', 1), ('ip', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: hpicfArpProtectValidation.setStatus('current') hpicf_arp_protect_errant_notify_enable = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enabled', 1), ('disabled', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: hpicfArpProtectErrantNotifyEnable.setStatus('current') hpicf_arp_protect_port_table = mib_table((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 2)) if mibBuilder.loadTexts: hpicfArpProtectPortTable.setStatus('current') hpicf_arp_protect_port_entry = mib_table_row((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 2, 1)).setIndexNames((0, 'IF-MIB', 'ifIndex')) if mibBuilder.loadTexts: hpicfArpProtectPortEntry.setStatus('current') hpicf_arp_protect_port_trust = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 1, 2, 1, 1), truth_value()).setMaxAccess('readwrite') if mibBuilder.loadTexts: hpicfArpProtectPortTrust.setStatus('current') hpicf_arp_protect_status = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2)) hpicf_arp_protect_vlan_stat_table = mib_table((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1)) if mibBuilder.loadTexts: hpicfArpProtectVlanStatTable.setStatus('current') hpicf_arp_protect_vlan_stat_entry = mib_table_row((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1)).setIndexNames((0, 'HP-ICF-ARP-PROTECT', 'hpicfArpProtectVlanStatIndex')) if mibBuilder.loadTexts: hpicfArpProtectVlanStatEntry.setStatus('current') hpicf_arp_protect_vlan_stat_index = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 1), vlan_index()) if mibBuilder.loadTexts: hpicfArpProtectVlanStatIndex.setStatus('current') hpicf_arp_protect_vlan_stat_forwards = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 2), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hpicfArpProtectVlanStatForwards.setStatus('current') hpicf_arp_protect_vlan_stat_bad_pkts = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 3), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hpicfArpProtectVlanStatBadPkts.setStatus('current') hpicf_arp_protect_vlan_stat_bad_bindings = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 4), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hpicfArpProtectVlanStatBadBindings.setStatus('current') hpicf_arp_protect_vlan_stat_bad_src_macs = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 5), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hpicfArpProtectVlanStatBadSrcMacs.setStatus('current') hpicf_arp_protect_vlan_stat_bad_dst_macs = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 6), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hpicfArpProtectVlanStatBadDstMacs.setStatus('current') hpicf_arp_protect_vlan_stat_bad_ip_addrs = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 2, 1, 1, 7), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: hpicfArpProtectVlanStatBadIpAddrs.setStatus('current') hpicf_arp_protect_errant_cnt = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 3), counter32()).setMaxAccess('accessiblefornotify') if mibBuilder.loadTexts: hpicfArpProtectErrantCnt.setStatus('current') hpicf_arp_protect_errant_src_mac = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 4), mac_address()).setMaxAccess('accessiblefornotify') if mibBuilder.loadTexts: hpicfArpProtectErrantSrcMac.setStatus('current') hpicf_arp_protect_errant_src_ip_type = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 5), inet_address_type()).setMaxAccess('accessiblefornotify') if mibBuilder.loadTexts: hpicfArpProtectErrantSrcIpType.setStatus('current') hpicf_arp_protect_errant_src_ip = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 6), inet_address()).setMaxAccess('accessiblefornotify') if mibBuilder.loadTexts: hpicfArpProtectErrantSrcIp.setStatus('current') hpicf_arp_protect_errant_dest_mac = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 7), mac_address()).setMaxAccess('accessiblefornotify') if mibBuilder.loadTexts: hpicfArpProtectErrantDestMac.setStatus('current') hpicf_arp_protect_errant_dest_ip_type = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 8), inet_address_type()).setMaxAccess('accessiblefornotify') if mibBuilder.loadTexts: hpicfArpProtectErrantDestIpType.setStatus('current') hpicf_arp_protect_errant_dest_ip = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 1, 9), inet_address()).setMaxAccess('accessiblefornotify') if mibBuilder.loadTexts: hpicfArpProtectErrantDestIp.setStatus('current') hpicf_arp_protect_conformance = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2)) hpicf_arp_protect_groups = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2, 1)) hpicf_arp_protect_base_group = object_group((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2, 1, 1)).setObjects(('HP-ICF-ARP-PROTECT', 'hpicfArpProtectEnable'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectVlanEnable'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectValidation'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectPortTrust'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectVlanStatForwards'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectVlanStatBadPkts'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectVlanStatBadBindings'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectVlanStatBadSrcMacs'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectVlanStatBadDstMacs'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectVlanStatBadIpAddrs'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantSrcMac'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantSrcIp'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantDestMac'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantSrcIpType'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantDestIpType'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantDestIp'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantCnt'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantNotifyEnable')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): hpicf_arp_protect_base_group = hpicfArpProtectBaseGroup.setStatus('current') hpicf_arp_protection_notifications = notification_group((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2, 1, 2)).setObjects(('HP-ICF-ARP-PROTECT', 'hpicfArpProtectErrantReply')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): hpicf_arp_protection_notifications = hpicfArpProtectionNotifications.setStatus('current') hpicf_arp_protect_compliances = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2, 2)) hpicf_arp_protect_compliance = module_compliance((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 5, 1, 37, 2, 2, 1)).setObjects(('HP-ICF-ARP-PROTECT', 'hpicfArpProtectBaseGroup'), ('HP-ICF-ARP-PROTECT', 'hpicfArpProtectionNotifications')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): hpicf_arp_protect_compliance = hpicfArpProtectCompliance.setStatus('current') mibBuilder.exportSymbols('HP-ICF-ARP-PROTECT', hpicfArpProtectVlanStatBadDstMacs=hpicfArpProtectVlanStatBadDstMacs, hpicfArpProtectErrantSrcMac=hpicfArpProtectErrantSrcMac, hpicfArpProtectErrantDestIp=hpicfArpProtectErrantDestIp, hpicfArpProtectStatus=hpicfArpProtectStatus, hpicfArpProtectVlanStatBadSrcMacs=hpicfArpProtectVlanStatBadSrcMacs, hpicfArpProtectNotifications=hpicfArpProtectNotifications, hpicfArpProtectionNotifications=hpicfArpProtectionNotifications, hpicfArpProtectGroups=hpicfArpProtectGroups, hpicfArpProtectVlanStatIndex=hpicfArpProtectVlanStatIndex, hpicfArpProtectVlanStatBadBindings=hpicfArpProtectVlanStatBadBindings, hpicfArpProtectEnable=hpicfArpProtectEnable, PYSNMP_MODULE_ID=hpicfArpProtect, hpicfArpProtectValidation=hpicfArpProtectValidation, hpicfArpProtectVlanStatForwards=hpicfArpProtectVlanStatForwards, hpicfArpProtectErrantSrcIpType=hpicfArpProtectErrantSrcIpType, hpicfArpProtectErrantNotifyEnable=hpicfArpProtectErrantNotifyEnable, hpicfArpProtectCompliances=hpicfArpProtectCompliances, hpicfArpProtectBaseGroup=hpicfArpProtectBaseGroup, hpicfArpProtectErrantReply=hpicfArpProtectErrantReply, hpicfArpProtectConfig=hpicfArpProtectConfig, hpicfArpProtectVlanStatBadPkts=hpicfArpProtectVlanStatBadPkts, hpicfArpProtectErrantCnt=hpicfArpProtectErrantCnt, hpicfArpProtectGlobalCfg=hpicfArpProtectGlobalCfg, hpicfArpProtectVlanStatEntry=hpicfArpProtectVlanStatEntry, hpicfArpProtectObjects=hpicfArpProtectObjects, hpicfArpProtectErrantDestIpType=hpicfArpProtectErrantDestIpType, hpicfArpProtectErrantSrcIp=hpicfArpProtectErrantSrcIp, hpicfArpProtectVlanStatBadIpAddrs=hpicfArpProtectVlanStatBadIpAddrs, hpicfArpProtectCompliance=hpicfArpProtectCompliance, hpicfArpProtectConformance=hpicfArpProtectConformance, hpicfArpProtectPortTable=hpicfArpProtectPortTable, hpicfArpProtectVlanEnable=hpicfArpProtectVlanEnable, hpicfArpProtectPortTrust=hpicfArpProtectPortTrust, hpicfArpProtectVlanStatTable=hpicfArpProtectVlanStatTable, hpicfArpProtectErrantDestMac=hpicfArpProtectErrantDestMac, hpicfArpProtect=hpicfArpProtect, hpicfArpProtectPortEntry=hpicfArpProtectPortEntry)
pkgname = "libuninameslist" pkgver = "20211114" pkgrel = 0 build_style = "gnu_configure" hostmakedepends = ["pkgconf", "automake", "libtool"] pkgdesc = "Library of Unicode names and annotation data" maintainer = "q66 <q66@chimera-linux.org>" license = "BSD-3-Clause" url = "https://github.com/fontforge/libuninameslist" source = f"{url}/archive/{pkgver}.tar.gz" sha256 = "c089c6164f2cef361c3419a07408be72d6b58d6ef224ec226724a9fa93c0d46e" def pre_configure(self): self.do("autoreconf", "-if") def post_install(self): self.install_license("LICENSE") @subpackage("libuninameslist-devel") def _devel(self): return self.default_devel()
pkgname = 'libuninameslist' pkgver = '20211114' pkgrel = 0 build_style = 'gnu_configure' hostmakedepends = ['pkgconf', 'automake', 'libtool'] pkgdesc = 'Library of Unicode names and annotation data' maintainer = 'q66 <q66@chimera-linux.org>' license = 'BSD-3-Clause' url = 'https://github.com/fontforge/libuninameslist' source = f'{url}/archive/{pkgver}.tar.gz' sha256 = 'c089c6164f2cef361c3419a07408be72d6b58d6ef224ec226724a9fa93c0d46e' def pre_configure(self): self.do('autoreconf', '-if') def post_install(self): self.install_license('LICENSE') @subpackage('libuninameslist-devel') def _devel(self): return self.default_devel()
POSTGRESQL = 'PostgreSQL' MYSQL = 'MySQL' DEV = 'Development' STAGE = 'Staging' TEST = 'Testing' PROD = 'Production'
postgresql = 'PostgreSQL' mysql = 'MySQL' dev = 'Development' stage = 'Staging' test = 'Testing' prod = 'Production'
# 10001st prime # The nth prime number def isPrime(n): for i in range(2, int(math.sqrt(n))+1): if n%i == 0: return False return True def nthPrime(n): num = 2 nums = [] while len(nums) < n: if isPrime(num) == True: nums.append(num) num += 1 return nums[-1]
def is_prime(n): for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: return False return True def nth_prime(n): num = 2 nums = [] while len(nums) < n: if is_prime(num) == True: nums.append(num) num += 1 return nums[-1]
class IntervalNum: def __init__(self,a,b): if a > b: a,b = b,a self.a = a self.b = b def __str__(self): return f"[{self.a};{self.b}]" def __add__(self,other): return IntervalNum(self.a+other.a, self.b+other.b) def __sub__(self,other): return IntervalNum(self.a-other.b, self.b-other.a) def __mul__(self,other): sa, sb = self.a, self.b oa, ob = other.a, other.b a = min([sa*oa,sa*ob,sb*oa,sb*ob]) b = max([sa*oa,sa*ob,sb*oa,sb*ob]) return IntervalNum(a,b) if __name__ == '__main__': x = IntervalNum(-2,3) print(f"x = {x}") print(f"x+x = {x+x}") print(f"x-x = {x-x}") print(f"x*x = {x*x}")
class Intervalnum: def __init__(self, a, b): if a > b: (a, b) = (b, a) self.a = a self.b = b def __str__(self): return f'[{self.a};{self.b}]' def __add__(self, other): return interval_num(self.a + other.a, self.b + other.b) def __sub__(self, other): return interval_num(self.a - other.b, self.b - other.a) def __mul__(self, other): (sa, sb) = (self.a, self.b) (oa, ob) = (other.a, other.b) a = min([sa * oa, sa * ob, sb * oa, sb * ob]) b = max([sa * oa, sa * ob, sb * oa, sb * ob]) return interval_num(a, b) if __name__ == '__main__': x = interval_num(-2, 3) print(f'x = {x}') print(f'x+x = {x + x}') print(f'x-x = {x - x}') print(f'x*x = {x * x}')
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'cv.sqlite', # Or path to database file if using sqlite3. 'USER': '', # Not used with sqlite3. 'PASSWORD': '', # Not used with sqlite3. 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '', # Set to empty string for default. Not used with sqlite3. } } MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'maintenance.middleware.MaintenanceMiddleware', 'django.middleware.transaction.TransactionMiddleware', 'django.middleware.common.CommonMiddleware', ) ROOT_URLCONF = 'maintenance.tests.test_urls' SITE_ID = 1 INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.flatpages', 'maintenance', )
databases = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'cv.sqlite', 'USER': '', 'PASSWORD': '', 'HOST': '', 'PORT': ''}} middleware_classes = ('django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'maintenance.middleware.MaintenanceMiddleware', 'django.middleware.transaction.TransactionMiddleware', 'django.middleware.common.CommonMiddleware') root_urlconf = 'maintenance.tests.test_urls' site_id = 1 installed_apps = ('django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.flatpages', 'maintenance')
vehicles = { 'dream': 'Honda 250T', 'er5': 'Kawasaki ER5', 'can-am': 'Bombardier Can-Am 250', 'virago': 'Yamaha XV250', 'tenere': 'Yamaha XT650', 'jimny': 'Suzuki Jimny 1.5', 'fiesta': 'Ford Fiesta Ghia 1.4', 'roadster': 'Triumph Street Triple' } vehicles["starfighter"] = "Lockhead F-104" vehicles ["learjet"] = "Bombardier Learjet 75" vehicles["toy"] = "Glider" # upgrade Virago vehicles["virago"] = "Yamaha XV535" del vehicles['starfighter'] result = vehicles.pop('f1', "You wish! Sell the Learjet and you might afford a racing car.") print(result) plane = vehicles.pop('learjet') print(plane) bike = vehicles.pop("tenere", "not present") print(bike) print() # for key in vehicles: # print(key, vehicles[key], sep=", ") for key, value in vehicles.items(): print(key, value, sep=", ")
vehicles = {'dream': 'Honda 250T', 'er5': 'Kawasaki ER5', 'can-am': 'Bombardier Can-Am 250', 'virago': 'Yamaha XV250', 'tenere': 'Yamaha XT650', 'jimny': 'Suzuki Jimny 1.5', 'fiesta': 'Ford Fiesta Ghia 1.4', 'roadster': 'Triumph Street Triple'} vehicles['starfighter'] = 'Lockhead F-104' vehicles['learjet'] = 'Bombardier Learjet 75' vehicles['toy'] = 'Glider' vehicles['virago'] = 'Yamaha XV535' del vehicles['starfighter'] result = vehicles.pop('f1', 'You wish! Sell the Learjet and you might afford a racing car.') print(result) plane = vehicles.pop('learjet') print(plane) bike = vehicles.pop('tenere', 'not present') print(bike) print() for (key, value) in vehicles.items(): print(key, value, sep=', ')
class DpiChangedEventArgs(RoutedEventArgs): # no doc NewDpi=property(lambda self: object(),lambda self,v: None,lambda self: None) """Get: NewDpi(self: DpiChangedEventArgs) -> DpiScale """ OldDpi=property(lambda self: object(),lambda self,v: None,lambda self: None) """Get: OldDpi(self: DpiChangedEventArgs) -> DpiScale """
class Dpichangedeventargs(RoutedEventArgs): new_dpi = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Get: NewDpi(self: DpiChangedEventArgs) -> DpiScale\n\n\n\n' old_dpi = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Get: OldDpi(self: DpiChangedEventArgs) -> DpiScale\n\n\n\n'
#!/usr/bin/env python def start(): print("Hello, world.") if __name__ == '__main__': start()
def start(): print('Hello, world.') if __name__ == '__main__': start()
numbers = [3, 6, 2, 8, 4, 10] max = numbers[0] for number in numbers: if number > max: max = number print(max)
numbers = [3, 6, 2, 8, 4, 10] max = numbers[0] for number in numbers: if number > max: max = number print(max)
class StateMachineException(Exception): def __init__(self, message_format, **kwargs): if kwargs: self.message = message_format.format(**kwargs) else: self.message = message_format self.__dict__.update(**kwargs) def __str__(self): return self.message class IncorrectInitialState(StateMachineException): pass class StateChangedElsewhere(StateMachineException): pass class MultipleMachineAncestors(StateMachineException): pass class IncorrectSummary(StateMachineException): pass class InheritedFromState(StateMachineException): pass class CannotInferOutputState(StateMachineException): pass class DuplicateStateNames(StateMachineException): pass class DuplicateOutputStates(StateMachineException): pass class UnknownOutputState(StateMachineException): pass class ReturnedInvalidState(StateMachineException): pass class GetStateDidNotReturnState(StateMachineException): pass class DjangoStateAttrNameWarning(Warning): pass
class Statemachineexception(Exception): def __init__(self, message_format, **kwargs): if kwargs: self.message = message_format.format(**kwargs) else: self.message = message_format self.__dict__.update(**kwargs) def __str__(self): return self.message class Incorrectinitialstate(StateMachineException): pass class Statechangedelsewhere(StateMachineException): pass class Multiplemachineancestors(StateMachineException): pass class Incorrectsummary(StateMachineException): pass class Inheritedfromstate(StateMachineException): pass class Cannotinferoutputstate(StateMachineException): pass class Duplicatestatenames(StateMachineException): pass class Duplicateoutputstates(StateMachineException): pass class Unknownoutputstate(StateMachineException): pass class Returnedinvalidstate(StateMachineException): pass class Getstatedidnotreturnstate(StateMachineException): pass class Djangostateattrnamewarning(Warning): pass
#!/usr/bin/python3 # -*- coding: utf-8 -*- class DataSet: def __init__(self, src_channels_url: str, injection_file_name: str, out_file_name: str, out_file_encoding: str, out_file_first_line: str, out_file_format: str, filter_file_name: str, clean_filter: bool) -> None: self._src_channels_url: str = src_channels_url self._injection_file_name: str = injection_file_name self._out_file_name: str = out_file_name self._out_file_encoding: str = out_file_encoding self._out_file_first_line: str = out_file_first_line self._out_file_format: str = out_file_format self._filter_file_name: str = filter_file_name self._clean_filter: bool = clean_filter @property def src_channels_url(self) -> str: return self._src_channels_url @property def injection_file_name(self) -> str: return self._injection_file_name @property def out_file_name(self) -> str: return self._out_file_name @property def out_file_encoding(self) -> str: return self._out_file_encoding @property def out_file_first_line(self) -> str: return self._out_file_first_line @property def out_file_format(self) -> str: return self._out_file_format @property def filter_file_name(self) -> str: return self._filter_file_name @property def clean_filter(self) -> bool: return self._clean_filter
class Dataset: def __init__(self, src_channels_url: str, injection_file_name: str, out_file_name: str, out_file_encoding: str, out_file_first_line: str, out_file_format: str, filter_file_name: str, clean_filter: bool) -> None: self._src_channels_url: str = src_channels_url self._injection_file_name: str = injection_file_name self._out_file_name: str = out_file_name self._out_file_encoding: str = out_file_encoding self._out_file_first_line: str = out_file_first_line self._out_file_format: str = out_file_format self._filter_file_name: str = filter_file_name self._clean_filter: bool = clean_filter @property def src_channels_url(self) -> str: return self._src_channels_url @property def injection_file_name(self) -> str: return self._injection_file_name @property def out_file_name(self) -> str: return self._out_file_name @property def out_file_encoding(self) -> str: return self._out_file_encoding @property def out_file_first_line(self) -> str: return self._out_file_first_line @property def out_file_format(self) -> str: return self._out_file_format @property def filter_file_name(self) -> str: return self._filter_file_name @property def clean_filter(self) -> bool: return self._clean_filter
sys_word = {} for x in range(0,325): sys_word[x] = 0 file = open("UAD-0015.txt", "r+") words = file.read().split() file.close() for word in words: sys_word[int(word)] += 1 for x in range(0,325): sys_word[x] = sys_word[x]/int(325) file_ = open("a_1.txt", "w") for x in range(0,325): if x is 324: file_.write(str(sys_word[x]) + "\n") else: file_.write(str(sys_word[x]) + ",") file_.close() print(sys_word)
sys_word = {} for x in range(0, 325): sys_word[x] = 0 file = open('UAD-0015.txt', 'r+') words = file.read().split() file.close() for word in words: sys_word[int(word)] += 1 for x in range(0, 325): sys_word[x] = sys_word[x] / int(325) file_ = open('a_1.txt', 'w') for x in range(0, 325): if x is 324: file_.write(str(sys_word[x]) + '\n') else: file_.write(str(sys_word[x]) + ',') file_.close() print(sys_word)
#Soumya Pal #Assignment 2 part 4 info = { "name": "Shomo Pal", "favorite_color": "Blue", "favorite_number": 10, "favorite_movies": ["Inception","The Shashank Redemption","One Piece (Anime not movie)"], "favorite_songs" : [{'artist': 'Metallica', 'title': 'Nothing Else Matters'}, {'artist': 'Nirvana', 'title': 'Come as you are'}] } print(info["name"]) print(info["favorite_color"]) print(info["favorite_number"]) print("Movies:") for movie_title in info["favorite_movies"]: print("\t"+ movie_title) print("Songs:") for song_info in info["favorite_songs"]: print(f"\t{song_info['artist']}: {song_info['title']}")
info = {'name': 'Shomo Pal', 'favorite_color': 'Blue', 'favorite_number': 10, 'favorite_movies': ['Inception', 'The Shashank Redemption', 'One Piece (Anime not movie)'], 'favorite_songs': [{'artist': 'Metallica', 'title': 'Nothing Else Matters'}, {'artist': 'Nirvana', 'title': 'Come as you are'}]} print(info['name']) print(info['favorite_color']) print(info['favorite_number']) print('Movies:') for movie_title in info['favorite_movies']: print('\t' + movie_title) print('Songs:') for song_info in info['favorite_songs']: print(f"\t{song_info['artist']}: {song_info['title']}")
class Solution: # @param {integer[][]} grid # @return {integer} def minPathSum(self, grid): n = len(grid); m = len(grid[0]); p = [([0] * m) for i in range(n)] p[0][0] = grid[0][0]; for k in range (1, n): p[k][0] = p[k-1][0]+grid[k][0]; for k in range (1, m): p[0][k] = p[0][k-1]+grid[0][k]; for i in range (1, n): for j in range (1, m): p[i][j] = min(p[i-1][j], p[i][j-1]) + grid[i][j]; return p[n-1][m-1];
class Solution: def min_path_sum(self, grid): n = len(grid) m = len(grid[0]) p = [[0] * m for i in range(n)] p[0][0] = grid[0][0] for k in range(1, n): p[k][0] = p[k - 1][0] + grid[k][0] for k in range(1, m): p[0][k] = p[0][k - 1] + grid[0][k] for i in range(1, n): for j in range(1, m): p[i][j] = min(p[i - 1][j], p[i][j - 1]) + grid[i][j] return p[n - 1][m - 1]
# Cidades: Crie um dicionario chamado cities. Use os nomes de tres cidades como chaves em seu dicionario. Crie um dicionario com informacoes sobre cada cidade e inclua o pais em que a cidade esta localizada, a populacao aproximada e um fato sobre essa cidade. As chaves do dicionario de cada cidade devem ser algo como coutry, population e fact. Apresente o nome de cada cidade e todas as informacoes que voce armazenou sobre ela. cities = { 'maputo': { 'coutry': 'mozambique', 'population': '12.488.246', 'fact': 'corupt coutry' }, 'sao paulo': { 'coutry': 'brazil', 'population': '145.264.218', 'fact': 'beautiful people' }, 'lisbon': { 'coutry': 'portugal', 'population': '10.264.254', 'fact': 'racist' } } for key, value in cities.items(): print(f"{key} city:".title()) for k, v in value.items(): print(f"{k} => {v}".title()) print("=="*10)
cities = {'maputo': {'coutry': 'mozambique', 'population': '12.488.246', 'fact': 'corupt coutry'}, 'sao paulo': {'coutry': 'brazil', 'population': '145.264.218', 'fact': 'beautiful people'}, 'lisbon': {'coutry': 'portugal', 'population': '10.264.254', 'fact': 'racist'}} for (key, value) in cities.items(): print(f'{key} city:'.title()) for (k, v) in value.items(): print(f'{k} => {v}'.title()) print('==' * 10)
""" Problem - 239. Sliding Window Maximum Problem statement - You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return the max sliding window. Constraints - 1 <= nums.length <= 105 -104 <= nums[i] <= 104 1 <= k <= nums.length Example 1: Input: nums = [1,3,-1,-3,5,3,6,7], k = 3 Output: [3,3,5,5,6,7] Explanation: Window position Max --------------- ----- [1 3 -1] -3 5 3 6 7 3 1 [3 -1 -3] 5 3 6 7 3 1 3 [-1 -3 5] 3 6 7 5 1 3 -1 [-3 5 3] 6 7 5 1 3 -1 -3 [5 3 6] 7 6 1 3 -1 -3 5 [3 6 7] 7 Example 2: Input: nums = [1], k = 1 Output: [1] Example 3: Input: nums = [1,-1], k = 1 Output: [1,-1] Example 4: Input: nums = [9,11], k = 2 Output: [11] Example 5: Input: nums = [4,-2], k = 2 Output: [4] //Solution Idea - Keep indexes of good candidates in deque d. The indexes in d are from the current window, they're increasing, and their corresponding nums are decreasing. Then the first deque element is the index of the largest window value. For each index i: 1.Pop (from the end) indexes of smaller elements (they'll be useless). 2.Append the current index. 3.Pop (from the front) the index i - k, if it's still in the deque (it falls out of the window). 4.If our window has reached size k, append the current window maximum to the output. """ class Solution: def maxSlidingWindow(self, nums: List[int], k: int) -> List[int]: queue = deque() for i in range(k): while queue and nums[queue[-1]]<=nums[i]: queue.pop() queue.append(i) ans = [] for i in range(k,len(nums)): ans.append(nums[queue[0]]) while queue and queue[0]<=i-k: queue.popleft() while queue and nums[queue[-1]]<=nums[i]: queue.pop() queue.append(i) ans.append(nums[queue[0]]) return ans
""" Problem - 239. Sliding Window Maximum Problem statement - You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return the max sliding window. Constraints - 1 <= nums.length <= 105 -104 <= nums[i] <= 104 1 <= k <= nums.length Example 1: Input: nums = [1,3,-1,-3,5,3,6,7], k = 3 Output: [3,3,5,5,6,7] Explanation: Window position Max --------------- ----- [1 3 -1] -3 5 3 6 7 3 1 [3 -1 -3] 5 3 6 7 3 1 3 [-1 -3 5] 3 6 7 5 1 3 -1 [-3 5 3] 6 7 5 1 3 -1 -3 [5 3 6] 7 6 1 3 -1 -3 5 [3 6 7] 7 Example 2: Input: nums = [1], k = 1 Output: [1] Example 3: Input: nums = [1,-1], k = 1 Output: [1,-1] Example 4: Input: nums = [9,11], k = 2 Output: [11] Example 5: Input: nums = [4,-2], k = 2 Output: [4] //Solution Idea - Keep indexes of good candidates in deque d. The indexes in d are from the current window, they're increasing, and their corresponding nums are decreasing. Then the first deque element is the index of the largest window value. For each index i: 1.Pop (from the end) indexes of smaller elements (they'll be useless). 2.Append the current index. 3.Pop (from the front) the index i - k, if it's still in the deque (it falls out of the window). 4.If our window has reached size k, append the current window maximum to the output. """ class Solution: def max_sliding_window(self, nums: List[int], k: int) -> List[int]: queue = deque() for i in range(k): while queue and nums[queue[-1]] <= nums[i]: queue.pop() queue.append(i) ans = [] for i in range(k, len(nums)): ans.append(nums[queue[0]]) while queue and queue[0] <= i - k: queue.popleft() while queue and nums[queue[-1]] <= nums[i]: queue.pop() queue.append(i) ans.append(nums[queue[0]]) return ans
#!/usr/bin/env python """Pseudocode for the OPTICS algorithm.""" def optics(objects, epsilon, min_points): """ Clustering. Parameters ---------- objects : set epsilon : float min_points : int """ assert min_points >= 1 # TODO
"""Pseudocode for the OPTICS algorithm.""" def optics(objects, epsilon, min_points): """ Clustering. Parameters ---------- objects : set epsilon : float min_points : int """ assert min_points >= 1
feedback_poly = { 2: [1], 3: [2], 4: [3], 5: [3], 6: [5], 7: [6], 8: [6, 5, 4], 9: [5], 10: [7], 11: [9], 12: [11, 10, 4], 13: [12, 11, 8], 14: [13, 12, 2], 15: [14], 16: [14, 13, 11], 17: [14], 18: [11], 19: [18, 17, 14], 20: [17], 21: [19], 22: [21], 23: [18], 24: [23, 22, 17] } def one_hot_encode(n): coeffs = [] coeffs.append(1) for i in range(1, n): if i in feedback_poly[n]: coeffs.append(1) else: coeffs.append(0) return coeffs
feedback_poly = {2: [1], 3: [2], 4: [3], 5: [3], 6: [5], 7: [6], 8: [6, 5, 4], 9: [5], 10: [7], 11: [9], 12: [11, 10, 4], 13: [12, 11, 8], 14: [13, 12, 2], 15: [14], 16: [14, 13, 11], 17: [14], 18: [11], 19: [18, 17, 14], 20: [17], 21: [19], 22: [21], 23: [18], 24: [23, 22, 17]} def one_hot_encode(n): coeffs = [] coeffs.append(1) for i in range(1, n): if i in feedback_poly[n]: coeffs.append(1) else: coeffs.append(0) return coeffs
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def binaryTreePaths(self, root): """ :type root: TreeNode :rtype: List[str] """ res = [] if root is None: return res if root.left is None and root.right is None: res.append(str(root.val)) return res left_s = self.binaryTreePaths(root.left) for ele in left_s: res.append(str(root.val) + '->' + ele) right_s = self.binaryTreePaths(root.right) for ele in right_s: res.append(str(root.val) + '->' + ele) return res
class Treenode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def binary_tree_paths(self, root): """ :type root: TreeNode :rtype: List[str] """ res = [] if root is None: return res if root.left is None and root.right is None: res.append(str(root.val)) return res left_s = self.binaryTreePaths(root.left) for ele in left_s: res.append(str(root.val) + '->' + ele) right_s = self.binaryTreePaths(root.right) for ele in right_s: res.append(str(root.val) + '->' + ele) return res
# Generated by h2py from /usr/include/sys/event.h EVFILT_READ = (-1) EVFILT_WRITE = (-2) EVFILT_AIO = (-3) EVFILT_VNODE = (-4) EVFILT_PROC = (-5) EVFILT_SIGNAL = (-6) EVFILT_SYSCOUNT = 6 EV_ADD = 0x0001 EV_DELETE = 0x0002 EV_ENABLE = 0x0004 EV_DISABLE = 0x0008 EV_ONESHOT = 0x0010 EV_CLEAR = 0x0020 EV_SYSFLAGS = 0xF000 EV_FLAG1 = 0x2000 EV_EOF = 0x8000 EV_ERROR = 0x4000 NOTE_DELETE = 0x0001 NOTE_WRITE = 0x0002 NOTE_EXTEND = 0x0004 NOTE_ATTRIB = 0x0008 NOTE_LINK = 0x0010 NOTE_RENAME = 0x0020 NOTE_EXIT = 0x80000000 NOTE_FORK = 0x40000000 NOTE_EXEC = 0x20000000 NOTE_PCTRLMASK = 0xf0000000 NOTE_PDATAMASK = 0x000fffff NOTE_TRACK = 0x00000001 NOTE_TRACKERR = 0x00000002 NOTE_CHILD = 0x00000004
evfilt_read = -1 evfilt_write = -2 evfilt_aio = -3 evfilt_vnode = -4 evfilt_proc = -5 evfilt_signal = -6 evfilt_syscount = 6 ev_add = 1 ev_delete = 2 ev_enable = 4 ev_disable = 8 ev_oneshot = 16 ev_clear = 32 ev_sysflags = 61440 ev_flag1 = 8192 ev_eof = 32768 ev_error = 16384 note_delete = 1 note_write = 2 note_extend = 4 note_attrib = 8 note_link = 16 note_rename = 32 note_exit = 2147483648 note_fork = 1073741824 note_exec = 536870912 note_pctrlmask = 4026531840 note_pdatamask = 1048575 note_track = 1 note_trackerr = 2 note_child = 4
a = 1 b = 2 c = 3 print(a) print(b) print(c)
a = 1 b = 2 c = 3 print(a) print(b) print(c)
default_prefix = "DWB" known_chains = { "BEX": { "chain_id": "38f14b346eb697ba04ae0f5adcfaa0a437ed3711197704aa256a14cb9b4a8f26", "prefix": "DWB", "dpay_symbol": "BEX", "bbd_symbol": "BBD", "vests_symbol": "VESTS", }, "BET": { "chain_id": "9afbce9f2416520733bacb370315d32b6b2c43d6097576df1c1222859d91eecc", "prefix": "DWT", "dpay_symbol": "BET", "bbd_symbol": "TBD", "vests_symbol": "VESTS", }, }
default_prefix = 'DWB' known_chains = {'BEX': {'chain_id': '38f14b346eb697ba04ae0f5adcfaa0a437ed3711197704aa256a14cb9b4a8f26', 'prefix': 'DWB', 'dpay_symbol': 'BEX', 'bbd_symbol': 'BBD', 'vests_symbol': 'VESTS'}, 'BET': {'chain_id': '9afbce9f2416520733bacb370315d32b6b2c43d6097576df1c1222859d91eecc', 'prefix': 'DWT', 'dpay_symbol': 'BET', 'bbd_symbol': 'TBD', 'vests_symbol': 'VESTS'}}
# RemoveDuplicatesfromSortedArray.py # weird accepted answer that doesn't actually remove anything. class Solution: def removeDuplicates(self, nums: List[int]) -> int: if (len(nums)==0): return 0 i=0 j=0 while j < len(nums): # print(nums, i , j) if (nums[j]!=nums[i]): i+=1 nums[i]=nums[j] j+=1 # print(nums, i+1) return i+1
class Solution: def remove_duplicates(self, nums: List[int]) -> int: if len(nums) == 0: return 0 i = 0 j = 0 while j < len(nums): if nums[j] != nums[i]: i += 1 nums[i] = nums[j] j += 1 return i + 1
# Values obtained from running against the Fuss & Navarro 2009 reference implementation vals = [(0.3325402105490861, 0.18224585277734096, 2.0210322268188046, 0.37178992456396914, 0.7513994191503139, 1.6883221884854474, 1.0, 0.082198565245068272), (-0.13074510229340497, 0.44696631528174735, 2.4890334572448456, 0.3816245478330931, 0.9498762676625047, 1.0790903665954314, 0.1, 0.41591722288506577), (0.6056010862462016, 0.16871208306308166, 1.5524386791394562, 0.1286318302691049, 0.19969302867825994, 0.3836652143729468, 1e-07, 0.62063048896871487), (0.3895703269526853, 0.3435094918413777, 2.1750677359226023, 0.25344975464683345, 0.5512703840098271, 3.688305473258689, 0.01, 0.0090709779903460266), (0.42003699302964476, 0.10014569263424461, 2.3012075231555444, 0.0019673685361806803, 0.004527323276278492, 3.009144940928847, 0.0001, 0.0001884560320134888), (-0.5255928511420052, 0.41071488550017876, 2.2389065101119003, 0.2301372155046244, 0.515255710012329, 0.5621315133209579, 1e-05, 1.8640810217155657), (0.008338807811151538, 0.30523807964872274, 2.4560203575759623, 0.032544407891560656, 0.07992972830692877, 3.802538736807515, 1e-05, 0.0030406047220150243), (-0.709463423093855, 0.07788052784603428, 2.0241086070651075, 0.1491208977241244, 0.3018368925766758, 1.213966089059249, 1.0, 0.082017502354950353), (0.460913299169564, 0.2168584116589385, 2.298380160881188, 0.4461371311255309, 1.0253927312113693, 0.25156507383357796, 0.0001, 1.0372891338943479e-05), (-0.6117806447011472, 0.49463268264815274, 1.9686542627132415, 0.25832570907838626, 0.5085540083455858, 1.94831451612509, 0.001, 0.097069006460126561), (0.32861624103817627, 0.12335537773273014, 2.002692863678406, 0.47249065415592595, 0.9462536612328146, 2.796439295540539, 0.001, 0.018459337529972406), (0.021183546657572494, 0.47799029047254493, 2.3569808966748047, 0.4855005752397232, 1.1443155811646561, 2.610216277868382, 0.1, 0.082974887901830302), (0.7175299762398688, 0.3566056886339434, 2.220795104898356, 0.45773365470000554, 1.0165326597050066, 2.1966769477884225, 1e-07, 0.030138660738276948), (-0.7178918281791459, 0.057776773410309845, 1.9358335812071767, 0.10703342161705387, 0.20719889187779905, 1.9963028315012206, 0.01, 0.015193622821588188), (0.38713456753496744, 0.07157449665799648, 2.2096131432869957, 0.017240717413939843, 0.038095315797538463, 3.426246718806154, 1e-07, 0.00089937286951603833), (0.7331877690347837, 0.46552429958519015, 1.8562721149635684, 0.34330970798729826, 0.6372762377331072, 1.6101500341565407, 1.0, 0.071864719581762077), (-0.006430595681853335, 0.1207541730285373, 1.6676102104060564, 0.2604537143639433, 0.4343352734114944, 0.7713437644783603, 1.0, 0.26065820692218827), (-0.5187897244595112, 0.21532637320553233, 2.481938472673327, 0.18482168074390404, 0.4587160400224425, 1.0697490678038166, 1e-09, 0.23165988979463398), (-0.24925121543920914, 0.05753410930092823, 2.1709492103847565, 0.477487812061141, 1.036601788562479, 2.211403925199262, 1e-08, 0.084455290527924637), (-0.5719411096293123, 0.28837526790403306, 2.1929805341020145, 0.2243768947148022, 0.49205416241181843, 1.0791694385505024, 1e-10, 0.27868915917309367)]
vals = [(0.3325402105490861, 0.18224585277734096, 2.0210322268188046, 0.37178992456396914, 0.7513994191503139, 1.6883221884854474, 1.0, 0.08219856524506827), (-0.13074510229340497, 0.44696631528174735, 2.4890334572448456, 0.3816245478330931, 0.9498762676625047, 1.0790903665954314, 0.1, 0.4159172228850658), (0.6056010862462016, 0.16871208306308166, 1.5524386791394562, 0.1286318302691049, 0.19969302867825994, 0.3836652143729468, 1e-07, 0.6206304889687149), (0.3895703269526853, 0.3435094918413777, 2.1750677359226023, 0.25344975464683345, 0.5512703840098271, 3.688305473258689, 0.01, 0.009070977990346027), (0.42003699302964476, 0.10014569263424461, 2.3012075231555444, 0.0019673685361806803, 0.004527323276278492, 3.009144940928847, 0.0001, 0.0001884560320134888), (-0.5255928511420052, 0.41071488550017876, 2.2389065101119003, 0.2301372155046244, 0.515255710012329, 0.5621315133209579, 1e-05, 1.8640810217155657), (0.008338807811151538, 0.30523807964872274, 2.4560203575759623, 0.032544407891560656, 0.07992972830692877, 3.802538736807515, 1e-05, 0.0030406047220150243), (-0.709463423093855, 0.07788052784603428, 2.0241086070651075, 0.1491208977241244, 0.3018368925766758, 1.213966089059249, 1.0, 0.08201750235495035), (0.460913299169564, 0.2168584116589385, 2.298380160881188, 0.4461371311255309, 1.0253927312113693, 0.25156507383357796, 0.0001, 1.0372891338943479e-05), (-0.6117806447011472, 0.49463268264815274, 1.9686542627132415, 0.25832570907838626, 0.5085540083455858, 1.94831451612509, 0.001, 0.09706900646012656), (0.32861624103817627, 0.12335537773273014, 2.002692863678406, 0.47249065415592595, 0.9462536612328146, 2.796439295540539, 0.001, 0.018459337529972406), (0.021183546657572494, 0.47799029047254493, 2.3569808966748047, 0.4855005752397232, 1.1443155811646561, 2.610216277868382, 0.1, 0.0829748879018303), (0.7175299762398688, 0.3566056886339434, 2.220795104898356, 0.45773365470000554, 1.0165326597050066, 2.1966769477884225, 1e-07, 0.030138660738276948), (-0.7178918281791459, 0.057776773410309845, 1.9358335812071767, 0.10703342161705387, 0.20719889187779905, 1.9963028315012206, 0.01, 0.015193622821588188), (0.38713456753496744, 0.07157449665799648, 2.2096131432869957, 0.017240717413939843, 0.038095315797538463, 3.426246718806154, 1e-07, 0.0008993728695160383), (0.7331877690347837, 0.46552429958519015, 1.8562721149635684, 0.34330970798729826, 0.6372762377331072, 1.6101500341565407, 1.0, 0.07186471958176208), (-0.006430595681853335, 0.1207541730285373, 1.6676102104060564, 0.2604537143639433, 0.4343352734114944, 0.7713437644783603, 1.0, 0.2606582069221883), (-0.5187897244595112, 0.21532637320553233, 2.481938472673327, 0.18482168074390404, 0.4587160400224425, 1.0697490678038166, 1e-09, 0.23165988979463398), (-0.24925121543920914, 0.05753410930092823, 2.1709492103847565, 0.477487812061141, 1.036601788562479, 2.211403925199262, 1e-08, 0.08445529052792464), (-0.5719411096293123, 0.28837526790403306, 2.1929805341020145, 0.2243768947148022, 0.49205416241181843, 1.0791694385505024, 1e-10, 0.27868915917309367)]
""" Given a sorted array arr, two integers k and x, find the k closest elements to x in the array. The result should also be sorted in ascending order. If there is a tie, the smaller elements are always preferred. Example: Input: arr = [1,2,3,4,5], k = 4, x = 3 Output: [1,2,3,4] Constraints: - 1 <= k <= arr.length - 1 <= arr.length <= 10^4 - Absolute value of elements in the array and x will not exceed 104 """ #Difficulty: Medium #59 / 59 test cases passed. #Runtime: 320 ms #Memory Usage: 15.3 MB #Runtime: 320 ms, faster than 70.14% of Python3 online submissions for Find K Closest Elements. #Memory Usage: 15.3 MB, less than 41.69% of Python3 online submissions for Find K Closest Elements. class Solution: def findClosestElements(self, arr: List[int], k: int, x: int) -> List[int]: length = len(arr) l = 0 r = length - 1 while l + 1 < r: m = (l + r) // 2 if arr[m-1] <= x <= arr[m]: l, r = self.pickNumber(arr, m, k, x, length) return arr[l: r+1] if x < arr[m]: r = m else: l = m if l == 0: return arr[:min(k, length)] if r == length - 1: return arr[-k:] def pickNumber(self, arr, m, k, x, length): result = [] i = 1 j = 0 while k > 0: if m + j > length - 1: result.sort() return result[0] - k, result[-1] if m-i >= 0 and x - arr[m-i] <= arr[m + j] - x: result.append(m-i) i += 1 else: result.append(m + j) j += 1 k -= 1 result.sort() return result[0], result[-1]
""" Given a sorted array arr, two integers k and x, find the k closest elements to x in the array. The result should also be sorted in ascending order. If there is a tie, the smaller elements are always preferred. Example: Input: arr = [1,2,3,4,5], k = 4, x = 3 Output: [1,2,3,4] Constraints: - 1 <= k <= arr.length - 1 <= arr.length <= 10^4 - Absolute value of elements in the array and x will not exceed 104 """ class Solution: def find_closest_elements(self, arr: List[int], k: int, x: int) -> List[int]: length = len(arr) l = 0 r = length - 1 while l + 1 < r: m = (l + r) // 2 if arr[m - 1] <= x <= arr[m]: (l, r) = self.pickNumber(arr, m, k, x, length) return arr[l:r + 1] if x < arr[m]: r = m else: l = m if l == 0: return arr[:min(k, length)] if r == length - 1: return arr[-k:] def pick_number(self, arr, m, k, x, length): result = [] i = 1 j = 0 while k > 0: if m + j > length - 1: result.sort() return (result[0] - k, result[-1]) if m - i >= 0 and x - arr[m - i] <= arr[m + j] - x: result.append(m - i) i += 1 else: result.append(m + j) j += 1 k -= 1 result.sort() return (result[0], result[-1])
class HourRange(): def __init__(self, start: int, end: int): if start == end: raise ValueError("Start and end may not be equal.") if start < 0 or 23 < start: raise ValueError("Invalid start value: " + str(start)) if end < 0 or 23 < end: raise ValueError("Invalid end value: " + str(end)) if start < end: self._offset = 0 self._start = start self._end = end else: self._offset = 24 - start self._start = 0 self._end = end + self._offset assert self._end < 24 def is_in(self, hour: int) -> bool: if hour < 0 or 23 < hour: raise ValueError("Invalid value for hour: " + str(hour)) h = (hour + self._offset) % 24 assert 0 <= h and h < 24 return self._start <= h and h <= self._end
class Hourrange: def __init__(self, start: int, end: int): if start == end: raise value_error('Start and end may not be equal.') if start < 0 or 23 < start: raise value_error('Invalid start value: ' + str(start)) if end < 0 or 23 < end: raise value_error('Invalid end value: ' + str(end)) if start < end: self._offset = 0 self._start = start self._end = end else: self._offset = 24 - start self._start = 0 self._end = end + self._offset assert self._end < 24 def is_in(self, hour: int) -> bool: if hour < 0 or 23 < hour: raise value_error('Invalid value for hour: ' + str(hour)) h = (hour + self._offset) % 24 assert 0 <= h and h < 24 return self._start <= h and h <= self._end
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def dfs(self, root:TreeNode, sum:int, cur_sum:int): if not root.left and not root.right: if cur_sum + root.val == sum: return True else: return False if root.left: if self.dfs(root.left, sum, cur_sum + root.val): return True if root.right: if self.dfs(root.right, sum, cur_sum + root.val): return True return False def hasPathSum(self, root: TreeNode, sum: int) -> bool: if not root: return False res = self.dfs(root, sum, 0) return res
class Treenode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def dfs(self, root: TreeNode, sum: int, cur_sum: int): if not root.left and (not root.right): if cur_sum + root.val == sum: return True else: return False if root.left: if self.dfs(root.left, sum, cur_sum + root.val): return True if root.right: if self.dfs(root.right, sum, cur_sum + root.val): return True return False def has_path_sum(self, root: TreeNode, sum: int) -> bool: if not root: return False res = self.dfs(root, sum, 0) return res
def moeda(p = 0, moeda = 'R$'): return (f'{moeda}{p:.2f}'.replace('.',',')) def metade(p = 0, formato=False): res = p/2 return res if formato is False else moeda(res) def dobro(p = 0, formato=False): res = p*2 return res if formato is False else moeda(res) def aumentar(p = 0, taxa = 0, formato=False): res = p * (1+taxa/100) return res if formato is False else moeda(res) def diminuir(p = 0, taxa = 0, formato=False): res = p - (p * taxa/100) return res if formato is False else moeda(res)
def moeda(p=0, moeda='R$'): return f'{moeda}{p:.2f}'.replace('.', ',') def metade(p=0, formato=False): res = p / 2 return res if formato is False else moeda(res) def dobro(p=0, formato=False): res = p * 2 return res if formato is False else moeda(res) def aumentar(p=0, taxa=0, formato=False): res = p * (1 + taxa / 100) return res if formato is False else moeda(res) def diminuir(p=0, taxa=0, formato=False): res = p - p * taxa / 100 return res if formato is False else moeda(res)
class BookReader: country = 'South Korea' print(BookReader.country ) BookReader.country = 'USA' print(BookReader.country )
class Bookreader: country = 'South Korea' print(BookReader.country) BookReader.country = 'USA' print(BookReader.country)
""" File used to test the scraping ability of the regular expressions. """ # Setting up our fake functions and objects. _ = lambda x: x f = lambda x: x class C(object): pass obj = C() obj.blah = lambda x: x # A single letter function that we don't want f("_key") # Simple function call. _("_key") # The chained function call, in the simplest format (no args). _("_key").f() # The chained function call with simple arguments. _("_key").f("hello", 1337) # The chained function call with possible, more complex arguments _("_key").f(obj.blah(), {"dog":"cat"}) # And then the possibility for long function calls to extend over one line _("_key").f( "dogs", "cats", {"living":"together"})
""" File used to test the scraping ability of the regular expressions. """ _ = lambda x: x f = lambda x: x class C(object): pass obj = c() obj.blah = lambda x: x f('_key') _('_key') _('_key').f() _('_key').f('hello', 1337) _('_key').f(obj.blah(), {'dog': 'cat'}) _('_key').f('dogs', 'cats', {'living': 'together'})
def patxi(): tip = raw_input("Don't forget to use your new company WC as soon as possible, It's important....") kk = """ @@X @@@@@' +@'+@@; @X''+@@ X@''''@@ @+'''''X@ @@'''''''X@ @@X'''''''''@@ `@@@''''''''''''@X +@@@'''''''''''''''@ +@@@+''''''''''+''''''@@ `X@@@+'''''''''''''''''''''@ .@@@@+''''''''''''''''''''''''@@ X@@@''''''''''''''''''''''''''+''@ @@''''''''''''''''''''''''''''+++'@. @@''''''''''''''''''''''''''''+++++@@ @X''''''''''''''''+'''''''''''+++++++@ '@'''''''''''''''''''''''''''++++++++'@ @+''+'''''''''''''''''''''''+++++++++'@ @+'''''''''''''''''''''''++++++++++++'@ @+'''''''''''''''''''''++++++++++++++'@ '@'''''''''''''''''++++++++++++X+++++'@ @+'''''''''''++++++++++++++++++++++'+@ :@''''''+++++++++++++++++++++++++++'@@ X@'''''+++++++++++++++++++++++++''+@@@@@` `X@@@@@+'''''''''+++++++++++''''''''''+''''@@@ X@@@X''''''''''''''''''''''''''''''''''''''''''@@ ;@@+''''''''''''''''''''''''''''''''''''''''''''''@X @@+'''''''''''''''''''''''''''''''''''''''''''''''''@ @@'''''''''''''''''''''''''''''''''''''''''''''''''''@@ :@'''''''''''''''''''''''''''''''''''''''''''''''''''''@ @+'''''''''''''''''''''''''''''''''''''''''''''''''''''@ +@''''''''''''''''''''''''''''''''''''''''''''''''+++'''@, @+'''''''''''''+''''''''''''''''''''''''+'''''''++++++''@' @''''''''''''''''''''''''''''''''''''''''''''+++++++++''@X ;@'''''''''''''''''''''''''''''''''''''''''++++++++++++''@+ @@'''''''''''''''''''''''''''''''''''''++++++++++++++++''@; @X'''''''''''''''''''''''''''''+'''++++++++++++++++++++''@. @X''''''''''''''''''''''''''''+++++++++++++++++++++++++''@ @@''''''''''''''''''''''+++++++++++++++++++++++++++++++'+@ ;@'''''''''''''''++++++++++++++++++++++++++++'++++++++''@' @''''''''++++++++++++++++++++++++++++++++++++++++++++'+@ @+''''++++++++++++++++++++++++++++++++++++++++++++++''@' ;@'''''''''+++++++++++++++++++++++++++++++++++++'''''@@@@@+` `'@@'''''''''''''''''''''''''''''''''''''''''''''''''++++'X@@@: '@@@X''''''''''''''''''''''''''''''''''''''''''''''''''''''''''X@@ `@@+'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''@@ ,@X'''''''''''+''''''''''''''''''''''''''''''''''''''''''''''''''''''@@ `@+''''''''''''''''''''''''''''''''''''''''+'''''''''''''''''''''''''''@X @X'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''+++''@ ,@''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''+++''@@ @X''''''''''''''''''''''''''''''''''''''''''''''''''''++'''''''''''+++++''@ @'''''''''''''''''''''''''''''''''''''''''''''''''''''+''''''''''''+++++''@+ @'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''++++++''+@ @'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''++++++++'''@ @'''''''''''''+''''''''''''''''++''''''''''''''''''''''''''''''++++++++++''@` @''''''''''''''''''''''''''''''++''''''''''''''''''''''''''''++++++++++++''@' @''''''''''''''''''''''''''''''''''''''''''''''''''''''''''++++++++++++++''@@ @''''''''''''''''''''''''''''''''''''''''''''''''''''''''++++++++++++++++''X@ @X''''''''''''''''''''''''''''''''''''''''''''''''''''++++++++++++++++++'''X@ ;@'''''''''''''''''''''''''''''''''''''''++'''''''++++++++++++++++''++++'''X@ @'''''''''''''''''''''''''''''''''''''''''''+++++++++++++++++++++++++++'''@X @X'''''''''''''''''''''''''''''''''''''+++++++++++++++++++++++++++++++''''@' ,@'''''''''''''''''''''''''''''+++++++++++++++++++++++++++++++++++++++''''@,,` `,,@@'''''''''''''''''''++++++++++++++++++++++++++++++++++++++++++++++'''''+@,,,, ,,,,@X'''''''''''++++++++++++++++++++++++++++++++++++++++++++++++++++''''''@X,,,,` ,,,,,:@X''''''''''''++++++++++++++++++++++++++++++++++++++++++'''''''''''''@@,,,,,, ,,,,,,,@@@@+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''+@@@,,,,,,, ,,,,,,,,,'@@@@@X+''''''''''''''''''''''''''''''''''''''''''''''''''+@@@@@X:,,,,,,,, `,,,,,,,,,,,,;X@@@@@@@X++''''''''''''''''''''''''''''''''''+X@@@@@@@@',,,,,,,,,,,,, ,,,,,,,,,,,,,,,,,,,'@@@@@@@@@@@@@@@@@XXXXXXX@@@@@@@@@@@@@@@@@+:,,,,,,,,,,,,,,,,,, .,,,,,,,,,,,,,,,,,,,,,,,,,,,:;''+XX@@@@@@@@@@@@X+':,,,,,,,,,,,,,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,` `,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,. ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,` `,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,` .,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.` `..,,,,,,,,,,,,,,,,,,,,,,,,,,,,.` """ print('\033[0;33m{0}'.format(kk)) print('\033[0m') patxi()
def patxi(): tip = raw_input("Don't forget to use your new company WC as soon as possible, It's important....") kk = " @@X \n @@@@@' \n +@'+@@; \n @X''+@@ \n X@''''@@ \n @+'''''X@ \n @@'''''''X@ \n @@X'''''''''@@ \n `@@@''''''''''''@X \n +@@@'''''''''''''''@ \n +@@@+''''''''''+''''''@@ \n `X@@@+'''''''''''''''''''''@ \n .@@@@+''''''''''''''''''''''''@@ \n X@@@''''''''''''''''''''''''''+''@ \n @@''''''''''''''''''''''''''''+++'@. \n @@''''''''''''''''''''''''''''+++++@@ \n @X''''''''''''''''+'''''''''''+++++++@ \n '@'''''''''''''''''''''''''''++++++++'@ \n @+''+'''''''''''''''''''''''+++++++++'@ \n @+'''''''''''''''''''''''++++++++++++'@ \n @+'''''''''''''''''''''++++++++++++++'@ \n '@'''''''''''''''''++++++++++++X+++++'@ \n @+'''''''''''++++++++++++++++++++++'+@ \n :@''''''+++++++++++++++++++++++++++'@@ \n X@'''''+++++++++++++++++++++++++''+@@@@@` \n `X@@@@@+'''''''''+++++++++++''''''''''+''''@@@ \n X@@@X''''''''''''''''''''''''''''''''''''''''''@@ \n ;@@+''''''''''''''''''''''''''''''''''''''''''''''@X \n @@+'''''''''''''''''''''''''''''''''''''''''''''''''@ \n @@'''''''''''''''''''''''''''''''''''''''''''''''''''@@ \n :@'''''''''''''''''''''''''''''''''''''''''''''''''''''@ \n @+'''''''''''''''''''''''''''''''''''''''''''''''''''''@ \n +@''''''''''''''''''''''''''''''''''''''''''''''''+++'''@, \n @+'''''''''''''+''''''''''''''''''''''''+'''''''++++++''@' \n @''''''''''''''''''''''''''''''''''''''''''''+++++++++''@X \n ;@'''''''''''''''''''''''''''''''''''''''''++++++++++++''@+ \n @@'''''''''''''''''''''''''''''''''''''++++++++++++++++''@; \n @X'''''''''''''''''''''''''''''+'''++++++++++++++++++++''@. \n @X''''''''''''''''''''''''''''+++++++++++++++++++++++++''@ \n @@''''''''''''''''''''''+++++++++++++++++++++++++++++++'+@ \n ;@'''''''''''''''++++++++++++++++++++++++++++'++++++++''@' \n @''''''''++++++++++++++++++++++++++++++++++++++++++++'+@ \n @+''''++++++++++++++++++++++++++++++++++++++++++++++''@' \n ;@'''''''''+++++++++++++++++++++++++++++++++++++'''''@@@@@+` \n `'@@'''''''''''''''''''''''''''''''''''''''''''''''''++++'X@@@: \n '@@@X''''''''''''''''''''''''''''''''''''''''''''''''''''''''''X@@ \n `@@+'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''@@ \n ,@X'''''''''''+''''''''''''''''''''''''''''''''''''''''''''''''''''''@@ \n `@+''''''''''''''''''''''''''''''''''''''''+'''''''''''''''''''''''''''@X \n @X'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''+++''@ \n ,@''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''+++''@@ \n @X''''''''''''''''''''''''''''''''''''''''''''''''''''++'''''''''''+++++''@ \n @'''''''''''''''''''''''''''''''''''''''''''''''''''''+''''''''''''+++++''@+ \n @'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''++++++''+@ \n @'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''++++++++'''@ \n @'''''''''''''+''''''''''''''''++''''''''''''''''''''''''''''''++++++++++''@` \n @''''''''''''''''''''''''''''''++''''''''''''''''''''''''''''++++++++++++''@' \n @''''''''''''''''''''''''''''''''''''''''''''''''''''''''''++++++++++++++''@@ \n @''''''''''''''''''''''''''''''''''''''''''''''''''''''''++++++++++++++++''X@ \n @X''''''''''''''''''''''''''''''''''''''''''''''''''''++++++++++++++++++'''X@ \n ;@'''''''''''''''''''''''''''''''''''''''++'''''''++++++++++++++++''++++'''X@ \n @'''''''''''''''''''''''''''''''''''''''''''+++++++++++++++++++++++++++'''@X \n @X'''''''''''''''''''''''''''''''''''''+++++++++++++++++++++++++++++++''''@' \n ,@'''''''''''''''''''''''''''''+++++++++++++++++++++++++++++++++++++++''''@,,` \n `,,@@'''''''''''''''''''++++++++++++++++++++++++++++++++++++++++++++++'''''+@,,,, \n ,,,,@X'''''''''''++++++++++++++++++++++++++++++++++++++++++++++++++++''''''@X,,,,` \n ,,,,,:@X''''''''''''++++++++++++++++++++++++++++++++++++++++++'''''''''''''@@,,,,,, \n ,,,,,,,@@@@+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''+@@@,,,,,,, \n ,,,,,,,,,'@@@@@X+''''''''''''''''''''''''''''''''''''''''''''''''''+@@@@@X:,,,,,,,,\n `,,,,,,,,,,,,;X@@@@@@@X++''''''''''''''''''''''''''''''''''+X@@@@@@@@',,,,,,,,,,,,, \n ,,,,,,,,,,,,,,,,,,,'@@@@@@@@@@@@@@@@@XXXXXXX@@@@@@@@@@@@@@@@@+:,,,,,,,,,,,,,,,,,, \n .,,,,,,,,,,,,,,,,,,,,,,,,,,,:;''+XX@@@@@@@@@@@@X+':,,,,,,,,,,,,,,,,,,,,,,,,,,,, \n ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,` \n `,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,. \n ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, \n ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,` \n `,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,` \n .,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.` \n `..,,,,,,,,,,,,,,,,,,,,,,,,,,,,.` " print('\x1b[0;33m{0}'.format(kk)) print('\x1b[0m') patxi()
# DESCRIPTION # Given a string containing only three types of characters: '(', ')' and '*', # write a function to check whether this string is valid. # We define the validity of a string by these rules: # Any left parenthesis '(' must have a corresponding right parenthesis ')'. # Any right parenthesis ')' must have a corresponding left parenthesis '('. # Left parenthesis '(' must go before the corresponding right parenthesis ')'. # '*' could be treated as a single right parenthesis ')' # or a single left parenthesis '(' or an empty string. # An empty string is also valid. # EXAMPLE 1: # Input: "()" # Output: True # EXAMPLE 2: # Input: "(*))" # Output: True class Solution: def checkValidString(self, s: str) -> bool: ''' Time: O(N), where N is the length of the string Space: O(1), constant space no aux space used ''' # Greedy Algorithm # increments at '(' dec for ')' cmin = 0 # incs '(' and '*' decs for ')' cmax = 0 for i in s: if i == '(': cmax += 1 cmin += 1 if i == ')': cmax -= 1 # not including itself find the max between cmin-1 and 0 # this makes sure cmin is not negative cmin = max(cmin - 1, 0) if i == '*': cmax += 1 cmin = max(cmin - 1, 0) if cmax < 0: return False return cmin == 0
class Solution: def check_valid_string(self, s: str) -> bool: """ Time: O(N), where N is the length of the string Space: O(1), constant space no aux space used """ cmin = 0 cmax = 0 for i in s: if i == '(': cmax += 1 cmin += 1 if i == ')': cmax -= 1 cmin = max(cmin - 1, 0) if i == '*': cmax += 1 cmin = max(cmin - 1, 0) if cmax < 0: return False return cmin == 0
lines = open('dayfivedata.txt').read().split('\n') ids = [] for line in lines: top = 0; bottom = 127 for _ in range(7): if 'F' in line[_]: bottom = (top+bottom)//2 else: top = (top+bottom)//2 + 1 left = 0; right = 7 for _ in range(7, 10): if 'L' in line[_]: right = (right+left)//2 else: left = (right+left)//2 + 1 ids.append(top*8 + left) ids.sort() for _ in range(len(ids) - 1): if ids[_] + 2 == ids[_+1]: your_id = ids[_] + 1 break print(your_id)
lines = open('dayfivedata.txt').read().split('\n') ids = [] for line in lines: top = 0 bottom = 127 for _ in range(7): if 'F' in line[_]: bottom = (top + bottom) // 2 else: top = (top + bottom) // 2 + 1 left = 0 right = 7 for _ in range(7, 10): if 'L' in line[_]: right = (right + left) // 2 else: left = (right + left) // 2 + 1 ids.append(top * 8 + left) ids.sort() for _ in range(len(ids) - 1): if ids[_] + 2 == ids[_ + 1]: your_id = ids[_] + 1 break print(your_id)
"""feedshepherd All your (fairly simple) feed needs """
"""feedshepherd All your (fairly simple) feed needs """
def plot_confusion_matrix(cm, class_names): """ Returns a matplotlib figure containing the plotted confusion matrix. Args: cm (array, shape = [n, n]): a confusion matrix of integer classes class_names (array, shape = [n]): String names of the integer classes """ figure = plt.figure(figsize=(8, 8)) plt.imshow(cm, interpolation='nearest', cmap=plt.cm.Blues) plt.title("Confusion matrix") plt.colorbar() tick_marks = np.arange(len(class_names)) plt.xticks(tick_marks, class_names, rotation=45) plt.yticks(tick_marks, class_names) # Compute the labels from the normalized confusion matrix. labels = np.around(cm.astype('float') / cm.sum(axis=1)[:, np.newaxis], decimals=2) # Use white text if squares are dark; otherwise black. threshold = cm.max() / 2. for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])): color = "white" if cm[i, j] > threshold else "black" plt.text(j, i, labels[i, j], horizontalalignment="center", color=color) plt.tight_layout() plt.ylabel('True label') plt.xlabel('Predicted label') return figure
def plot_confusion_matrix(cm, class_names): """ Returns a matplotlib figure containing the plotted confusion matrix. Args: cm (array, shape = [n, n]): a confusion matrix of integer classes class_names (array, shape = [n]): String names of the integer classes """ figure = plt.figure(figsize=(8, 8)) plt.imshow(cm, interpolation='nearest', cmap=plt.cm.Blues) plt.title('Confusion matrix') plt.colorbar() tick_marks = np.arange(len(class_names)) plt.xticks(tick_marks, class_names, rotation=45) plt.yticks(tick_marks, class_names) labels = np.around(cm.astype('float') / cm.sum(axis=1)[:, np.newaxis], decimals=2) threshold = cm.max() / 2.0 for (i, j) in itertools.product(range(cm.shape[0]), range(cm.shape[1])): color = 'white' if cm[i, j] > threshold else 'black' plt.text(j, i, labels[i, j], horizontalalignment='center', color=color) plt.tight_layout() plt.ylabel('True label') plt.xlabel('Predicted label') return figure
n=int(input()) ans=[] used=[False for i in range(n)] d=[i+1 for i in range(n)] a=list(map(int,input().split())) p=0 f=False while True: for i in range(n-1): if f: i=n-2-i if a[i]>i+1 and a[i+1]<i+2 and not used[i]: ans.append(i+1) used[i]=True a[i],a[i+1]=a[i+1],a[i] if len(ans)==p: print(-1) break p=len(ans) if len(ans)==n-1: for i in range(n): if a[i]!=d[i]: print(-1) break else: print(*ans,sep='\n') break f = not f
n = int(input()) ans = [] used = [False for i in range(n)] d = [i + 1 for i in range(n)] a = list(map(int, input().split())) p = 0 f = False while True: for i in range(n - 1): if f: i = n - 2 - i if a[i] > i + 1 and a[i + 1] < i + 2 and (not used[i]): ans.append(i + 1) used[i] = True (a[i], a[i + 1]) = (a[i + 1], a[i]) if len(ans) == p: print(-1) break p = len(ans) if len(ans) == n - 1: for i in range(n): if a[i] != d[i]: print(-1) break else: print(*ans, sep='\n') break f = not f
# position, name, age, level, salary se1 = ["Software Engineer", "Max", 20, "Junior", 5000] se2 = ["Software Engineer", "Lisa", 25, "Senior", 7000] # class class SoftwareEngineer: # class attributes alias = "Keyboard Magician" def __init__(self, name, age, level, salary): # instance attributes self.name = name self.age = age self.level = level self.salary = salary # instance se1 = SoftwareEngineer("Max", 20, "Junior", 5000) print(se1.name, se1.age) se2 = SoftwareEngineer("Lisa", 25, "Senior", 7000) print(se2.alias) print(se1.alias) print(SoftwareEngineer.alias) SoftwareEngineer.alias = "Something Else" print(se2.alias) print(se1.alias) print(SoftwareEngineer.alias) # Recap # create a class (blueprint) # create a instance (object) # instance attributes: defined in __init__(self) method # class attribute
se1 = ['Software Engineer', 'Max', 20, 'Junior', 5000] se2 = ['Software Engineer', 'Lisa', 25, 'Senior', 7000] class Softwareengineer: alias = 'Keyboard Magician' def __init__(self, name, age, level, salary): self.name = name self.age = age self.level = level self.salary = salary se1 = software_engineer('Max', 20, 'Junior', 5000) print(se1.name, se1.age) se2 = software_engineer('Lisa', 25, 'Senior', 7000) print(se2.alias) print(se1.alias) print(SoftwareEngineer.alias) SoftwareEngineer.alias = 'Something Else' print(se2.alias) print(se1.alias) print(SoftwareEngineer.alias)
## # \breif Copula function rotation helpers # # These helpers must be implemented outside of # copula_base since we need access to them in all # our child copula classes as decorators. # # Rotate the data before fitting copula # # Always rotate data to original orientation after # evaluation of copula functions def rotatePDF(input_pdf): def rotatedFn(self, *args, **kwargs): if args[2] == 0: # 0 deg rotation (no action) return input_pdf(self, *args, **kwargs) if args[2] == 1: # 90 deg rotation (flip U) return input_pdf(self, *args, **kwargs) if args[2] == 2: # 180 deg rotation # TODO: Implement return input_pdf(self, *args, **kwargs) if args[2] == 3: # 180 deg rotation # TODO: Implement return input_pdf(self, *args, **kwargs) return rotatedFn def rotateCDF(input_cdf): def rotatedFn(self, *args, **kwargs): if args[2] == 0: # 0 deg rotation (no action) return input_cdf(self, *args, **kwargs) if args[2] == 1: # 90 deg rotation (flip U) return input_cdf(self, *args, **kwargs) return rotatedFn def rotateHfun(input_h): """! H fun provides U given v """ def rotatedFn(self, *args, **kwargs): if args[2] == 0: # 0 deg rotation (no action) return input_h(self, *args, **kwargs) if args[2] == 1: # 90 deg rotation (flip U) return input_h(self, *args, **kwargs) return rotatedFn def rotateVFun(input_v): """! V fun provides V given u """ def rotatedFn(self, *args, **kwargs): if args[2] == 0: # 0 deg rotation (no action) return input_v(self, *args, **kwargs) if args[2] == 1: # 90 deg rotation (no action) return input_v(self, *args, **kwargs) return rotatedFn
def rotate_pdf(input_pdf): def rotated_fn(self, *args, **kwargs): if args[2] == 0: return input_pdf(self, *args, **kwargs) if args[2] == 1: return input_pdf(self, *args, **kwargs) if args[2] == 2: return input_pdf(self, *args, **kwargs) if args[2] == 3: return input_pdf(self, *args, **kwargs) return rotatedFn def rotate_cdf(input_cdf): def rotated_fn(self, *args, **kwargs): if args[2] == 0: return input_cdf(self, *args, **kwargs) if args[2] == 1: return input_cdf(self, *args, **kwargs) return rotatedFn def rotate_hfun(input_h): """! H fun provides U given v """ def rotated_fn(self, *args, **kwargs): if args[2] == 0: return input_h(self, *args, **kwargs) if args[2] == 1: return input_h(self, *args, **kwargs) return rotatedFn def rotate_v_fun(input_v): """! V fun provides V given u """ def rotated_fn(self, *args, **kwargs): if args[2] == 0: return input_v(self, *args, **kwargs) if args[2] == 1: return input_v(self, *args, **kwargs) return rotatedFn
class Usuario: def __init__(self): self.usuario="" self.ingresos=0 def intro(self): self.usuario=input("Ingrese el nombre del usuario:") self.ingresos=float(input("Cantidad ingresos anual:")) def visualizar(self): print("Nombre:",self.usuario) print("Ingresos:",self.ingresos) def fiscalidad(self): if self.ingresos>3000: print("Debe pagar impuestos") else: print("No paga impuestos") # bloque principal usuario=Usuario() usuario.intro() usuario.visualizar() usuario.fiscalidad()
class Usuario: def __init__(self): self.usuario = '' self.ingresos = 0 def intro(self): self.usuario = input('Ingrese el nombre del usuario:') self.ingresos = float(input('Cantidad ingresos anual:')) def visualizar(self): print('Nombre:', self.usuario) print('Ingresos:', self.ingresos) def fiscalidad(self): if self.ingresos > 3000: print('Debe pagar impuestos') else: print('No paga impuestos') usuario = usuario() usuario.intro() usuario.visualizar() usuario.fiscalidad()
a=3 b=6 a,b=b,a print('After Swapping values of A and B are',a,b)
a = 3 b = 6 (a, b) = (b, a) print('After Swapping values of A and B are', a, b)
def pow(base,exponent): """ Given a base b and an exponent e, this function returns b^e """ return base**exponent
def pow(base, exponent): """ Given a base b and an exponent e, this function returns b^e """ return base ** exponent
class LayerManager: """ """ def __init__(self, canvas): self.canvas = canvas self.current_layer = 0 self.layers = [] def set_layer(self, cid): self.current_layer = self.canvas.find_withtag('caption-'+str(cid))[0] print(self.current_layer) def raise_layer(self, object_id): self.canvas.tag_raise(object_id) def lower_layer(self, object_id): self.canvas.tag_lower(object_id) # ------------------------------------------------------------------------- # https://stackoverflow.com/a/9576938/503781 def add_to_layer(self, layer, command, coords, **kwargs): """ :param layer: int :param command: Canvas.element :param coords: (x0, y0, x1, y1) :param kwargs: :return: int """ layer_tag = "layer %s" % layer if layer_tag not in self.layers: self.layers.append(layer_tag) tags = kwargs.setdefault("tags", []) tags.append(layer_tag) item_id = command(coords, **kwargs) self._adjust_layers() return item_id def _adjust_layers(self): for layer in sorted(self.layers): self.canvas.lift(layer) # -------------------------------------------------------------------------
class Layermanager: """ """ def __init__(self, canvas): self.canvas = canvas self.current_layer = 0 self.layers = [] def set_layer(self, cid): self.current_layer = self.canvas.find_withtag('caption-' + str(cid))[0] print(self.current_layer) def raise_layer(self, object_id): self.canvas.tag_raise(object_id) def lower_layer(self, object_id): self.canvas.tag_lower(object_id) def add_to_layer(self, layer, command, coords, **kwargs): """ :param layer: int :param command: Canvas.element :param coords: (x0, y0, x1, y1) :param kwargs: :return: int """ layer_tag = 'layer %s' % layer if layer_tag not in self.layers: self.layers.append(layer_tag) tags = kwargs.setdefault('tags', []) tags.append(layer_tag) item_id = command(coords, **kwargs) self._adjust_layers() return item_id def _adjust_layers(self): for layer in sorted(self.layers): self.canvas.lift(layer)
class Solution: def maximalSquare(self, matrix: List[List[str]]) -> int: if not matrix: return 0 lines = len(matrix) lists = len(matrix[0]) mat = [[0] * lists for _ in range(lines)] for i in range(lists): mat[0][i] = int(matrix[0][i]) for i in range(lines): mat[i][0] = int(matrix[i][0]) for i in range(1, lines): for j in range(1, lists): mat[i][j] = int(matrix[i][j]) if mat[i][j] is not 0: mat[i][j] = (min(mat[i - 1][j - 1], mat[i][j - 1], mat[i - 1][j]) + 1) result = 0 for i in mat: for j in i: if result < j: result = j return result ** 2
class Solution: def maximal_square(self, matrix: List[List[str]]) -> int: if not matrix: return 0 lines = len(matrix) lists = len(matrix[0]) mat = [[0] * lists for _ in range(lines)] for i in range(lists): mat[0][i] = int(matrix[0][i]) for i in range(lines): mat[i][0] = int(matrix[i][0]) for i in range(1, lines): for j in range(1, lists): mat[i][j] = int(matrix[i][j]) if mat[i][j] is not 0: mat[i][j] = min(mat[i - 1][j - 1], mat[i][j - 1], mat[i - 1][j]) + 1 result = 0 for i in mat: for j in i: if result < j: result = j return result ** 2
class Solution: def singleNumber(self, nums: List[int]) -> int: d = {} for num in nums: if num not in d: d[num] = 1 else: d[num] = d[num] + 1 for k,v in d.items(): if v == 1: return k
class Solution: def single_number(self, nums: List[int]) -> int: d = {} for num in nums: if num not in d: d[num] = 1 else: d[num] = d[num] + 1 for (k, v) in d.items(): if v == 1: return k
# https://leetcode.com/problems/find-the-difference/ class Solution: def findTheDifference(self, s: str, t: str) -> str: s = sorted(s) t = sorted(t) count = 0 for i in range(len(s)): if s[i] != t[i] : count = 1 print(t[i]) return t[i] if count == 0: return t[-1]
class Solution: def find_the_difference(self, s: str, t: str) -> str: s = sorted(s) t = sorted(t) count = 0 for i in range(len(s)): if s[i] != t[i]: count = 1 print(t[i]) return t[i] if count == 0: return t[-1]
for i in range(1,5): for j in range(1,5): print(j,end=" ") print( )
for i in range(1, 5): for j in range(1, 5): print(j, end=' ') print()
def round_off(ls2): # Function for the algorithm to obtain the desired output final_grade = [] for value in ls2: # iterating in the list to read every student's marks reminder = value % 5 # calculating remainder if value < 38: final_grade.append(value) elif reminder >= 3: # If remainder is greater than equal to 3 it will get round off # like 73 has remainder 3 hence it will get rounded off to 75 value += 5-reminder # the desired value will be get Ex 73 remainder 3 value = 73+(5-3)=75 final_grade.append(value) else: final_grade.append(value) # Grade that are not likely to round off will be stored as it is return final_grade # returns a list of the final upgrade grade while True: # A while loop to for a valid # input from a user number_students = int(input("Enter number of students(1 to 60): ")) if number_students > 60 or number_students < 1: print("Please Enter number (1 to 60) ") else: break ls = [] # empty list to store marks while number_students > 0: # Taking input n times form # the user where n is number # of students number = int(input("Enter marks (0 to 100): ")) if number > 100 or number < 0: # if a number is out of range print("Please enter marks (0 to 100)") continue ls.append(number) # storing the marks in empty list number_students -= 1 grades = round_off(ls) # Calling the function for mark in grades: # with for loop printing marks of each student print(mark)
def round_off(ls2): final_grade = [] for value in ls2: reminder = value % 5 if value < 38: final_grade.append(value) elif reminder >= 3: value += 5 - reminder final_grade.append(value) else: final_grade.append(value) return final_grade while True: number_students = int(input('Enter number of students(1 to 60): ')) if number_students > 60 or number_students < 1: print('Please Enter number (1 to 60) ') else: break ls = [] while number_students > 0: number = int(input('Enter marks (0 to 100): ')) if number > 100 or number < 0: print('Please enter marks (0 to 100)') continue ls.append(number) number_students -= 1 grades = round_off(ls) for mark in grades: print(mark)
""" Code used for the 'Singly linked list' class. """ class Node: "Represents a single linked node." def __init__(self, data, next = None): self.data = data self.next = None def __str__(self): "String representation of the node data." return str(self.data) def __repr__(self): "Simple representation of the node." return self.data class SinglyLinkedList: "Represents a singly linked list made of several Node instances." def __init__(self): self.tail = None self.size = 0 def append(self, data): "Encapsulates the data in a Node class." node = Node(data) if self.tail == None: self.tail = node else: current = self.tail while current.next: current = current.next current.next = node self.size += 1 def size(self): "Returns the number of nodes in the list." return str(self.size) def iter(self): "Iters through the list." current = self.tail while current: val = current.data current = current.next yield val def delete(self, data): "Removes an element in the singly linked list." current = self.tail previous = self.tail while current: if current.data == data: if current == self.tail: self.tail = current.next else: previous.next = current.next self.size -= 1 return current.data previous = current current = current.next def search(self, data): "Looks for a specific element in the list." for node in self.iter(): if data == node: print(f"Data {data} found") def clear(self): "Clear the entire list." self.tail = None self.head = None self.size = 0 """ Ejemplo en shell de SinglyLinkedList con append words = SinglyLinkedList() words.append('egg') words.append('ham') words.append('spam') current = words.tail while current: print(current.data) current = current.next for word in words.iter(): print(word) words.search('eggs') """
""" Code used for the 'Singly linked list' class. """ class Node: """Represents a single linked node.""" def __init__(self, data, next=None): self.data = data self.next = None def __str__(self): """String representation of the node data.""" return str(self.data) def __repr__(self): """Simple representation of the node.""" return self.data class Singlylinkedlist: """Represents a singly linked list made of several Node instances.""" def __init__(self): self.tail = None self.size = 0 def append(self, data): """Encapsulates the data in a Node class.""" node = node(data) if self.tail == None: self.tail = node else: current = self.tail while current.next: current = current.next current.next = node self.size += 1 def size(self): """Returns the number of nodes in the list.""" return str(self.size) def iter(self): """Iters through the list.""" current = self.tail while current: val = current.data current = current.next yield val def delete(self, data): """Removes an element in the singly linked list.""" current = self.tail previous = self.tail while current: if current.data == data: if current == self.tail: self.tail = current.next else: previous.next = current.next self.size -= 1 return current.data previous = current current = current.next def search(self, data): """Looks for a specific element in the list.""" for node in self.iter(): if data == node: print(f'Data {data} found') def clear(self): """Clear the entire list.""" self.tail = None self.head = None self.size = 0 "\nEjemplo en shell de SinglyLinkedList con append\n\nwords = SinglyLinkedList()\nwords.append('egg')\nwords.append('ham')\nwords.append('spam')\n\ncurrent = words.tail\n\nwhile current:\n print(current.data)\n current = current.next\n\nfor word in words.iter():\n print(word)\n\nwords.search('eggs')\n"
n,m = map(int,input().split()) rows = [input() for _ in range(n)] k = int(input()) for row in sorted(rows, key=lambda row: int(row.split()[k])): print(row)
(n, m) = map(int, input().split()) rows = [input() for _ in range(n)] k = int(input()) for row in sorted(rows, key=lambda row: int(row.split()[k])): print(row)
def func_header(funcname): print('\t.global %s' % funcname) print('\t.type %s, %%function' % funcname) print('%s:' % funcname) def push_stack(reg): print('\tstr %s, [sp, -0x10]!' % reg) def pop_stack(reg): print('\tldr %s, [sp], 0x10' % reg) def store_stack(value, offset): print('\tmov x8, %d' % value) print('\tstr x8, [fp, %s]' % str(hex(offset))) def binary_oprand(oprand, offdst, offsrc1, offsrc2): print('\tldr x8, [fp, %s]' % str(hex(offsrc1))) print('\tldr x9, [fp, %s]' % str(hex(offsrc2))) print('\t%s x8, x8, x9' % oprand) print('\tstr x8, [fp, %s]' % str(hex(offdst))) def copy_stack(offdst, offsrc): print('\tldr x8, [fp, %s]' % str(hex(offsrc))) print('\tstr x8, [fp, %s]' % str(hex(offdst))) def comparison(oprand, offdst, offsrc1, offsrc2): print('\tldr x8, [fp, %s]' % str(hex(offsrc1))) print('\tldr x9, [fp, %s]' % str(hex(offsrc2))) print('\tcmp x8, x9') print('\tcset x8, %s' % oprand) print('\tstr x8, [fp, %s]' % str(hex(offdst))) def unary_oprand(oprand, offdst, offsrc): print('\tldr x8, [fp, %s]' % str(hex(offsrc))) print('\t%s x8, x8' % oprand) print('\tstr x8, [fp, %s]' % str(hex(offdst))) def jmp(label): print('\tb %s' % label) def ret(funcname): print('\tb %s_ret' % funcname) def br(offset, label1, label2): print('\tldr x8, [fp, %s]' % str(hex(offset))) print('\tcbnz x8, %s' % label1) print('\tb %s' % label2) def printint(offset): print('\tadr x0, fmtld') print('\tldr x1, [fp, %s]' % str(hex(offset))) print('\tbl printf') def printbool(offset): print('\tldr x1, [fp, %s]' % str(hex(offset))) print('\tbl printbool') def printstr(label): print('\tadr x0, %s' % label) print('\tbl printf') def printfooter(): print(''' .global printbool printbool: cbz x1, printboolfalse adr x0, strtrue b printboolendif printboolfalse: adr x0, strfalse printboolendif: bl printf ret lr .data fmtld: .string "%ld" strtrue: .string "true" strfalse: .string "false" strspace: .string " " strnewline: .string "\\n"''')
def func_header(funcname): print('\t.global %s' % funcname) print('\t.type %s, %%function' % funcname) print('%s:' % funcname) def push_stack(reg): print('\tstr %s, [sp, -0x10]!' % reg) def pop_stack(reg): print('\tldr %s, [sp], 0x10' % reg) def store_stack(value, offset): print('\tmov x8, %d' % value) print('\tstr x8, [fp, %s]' % str(hex(offset))) def binary_oprand(oprand, offdst, offsrc1, offsrc2): print('\tldr x8, [fp, %s]' % str(hex(offsrc1))) print('\tldr x9, [fp, %s]' % str(hex(offsrc2))) print('\t%s x8, x8, x9' % oprand) print('\tstr x8, [fp, %s]' % str(hex(offdst))) def copy_stack(offdst, offsrc): print('\tldr x8, [fp, %s]' % str(hex(offsrc))) print('\tstr x8, [fp, %s]' % str(hex(offdst))) def comparison(oprand, offdst, offsrc1, offsrc2): print('\tldr x8, [fp, %s]' % str(hex(offsrc1))) print('\tldr x9, [fp, %s]' % str(hex(offsrc2))) print('\tcmp x8, x9') print('\tcset x8, %s' % oprand) print('\tstr x8, [fp, %s]' % str(hex(offdst))) def unary_oprand(oprand, offdst, offsrc): print('\tldr x8, [fp, %s]' % str(hex(offsrc))) print('\t%s x8, x8' % oprand) print('\tstr x8, [fp, %s]' % str(hex(offdst))) def jmp(label): print('\tb %s' % label) def ret(funcname): print('\tb %s_ret' % funcname) def br(offset, label1, label2): print('\tldr x8, [fp, %s]' % str(hex(offset))) print('\tcbnz x8, %s' % label1) print('\tb %s' % label2) def printint(offset): print('\tadr x0, fmtld') print('\tldr x1, [fp, %s]' % str(hex(offset))) print('\tbl printf') def printbool(offset): print('\tldr x1, [fp, %s]' % str(hex(offset))) print('\tbl printbool') def printstr(label): print('\tadr x0, %s' % label) print('\tbl printf') def printfooter(): print('\n .global printbool\nprintbool:\n cbz x1, printboolfalse\n adr\t x0, strtrue\n b printboolendif\n printboolfalse:\n adr\t x0, strfalse\n printboolendif:\n bl\t printf\n ret\t lr\n\n .data\nfmtld: .string "%ld"\nstrtrue: .string "true"\nstrfalse: .string "false"\nstrspace: .string " "\nstrnewline: .string "\\n"')
(10 and 2)[::-5] (10 and 2)[5] (10 and 2)(5) (10 and 2).foo -(10 and 2) +(10 and 2) ~(10 and 2) 5 ** (10 and 2) (10 and 2) ** 5 5 * (10 and 2) (10 and 2) * 5 5 / (10 and 2) (10 and 2) / 5 5 // (10 and 2) (10 and 2) // 5 5 + (10 and 2) (10 and 2) + 5 (10 and 2) - 5 5 - (10 and 2) 5 >> (10 and 2) (10 and 2) << 5 5 & (10 and 2) (10 and 2) & 5 5 ^ (10 and 2) (10 and 2) ^ 5 5 | (10 and 2) (10 and 2) | 5 () in (10 and 2) (10 and 2) in () 5 is (10 and 2) (10 and 2) is 5 5 < (10 and 2) (10 and 2) < 5 not (10 and 2) 5 and 10 and 2 10 and 2 and 5 5 or 10 and 2 10 and 2 or 5 10 and 2 if 10 and 2 else 10 and 2
(10 and 2)[::-5] (10 and 2)[5] (10 and 2)(5) (10 and 2).foo -(10 and 2) +(10 and 2) ~(10 and 2) 5 ** (10 and 2) (10 and 2) ** 5 5 * (10 and 2) (10 and 2) * 5 5 / (10 and 2) (10 and 2) / 5 5 // (10 and 2) (10 and 2) // 5 5 + (10 and 2) (10 and 2) + 5 (10 and 2) - 5 5 - (10 and 2) 5 >> (10 and 2) (10 and 2) << 5 5 & (10 and 2) (10 and 2) & 5 5 ^ (10 and 2) (10 and 2) ^ 5 5 | (10 and 2) (10 and 2) | 5 () in (10 and 2) (10 and 2) in () 5 is (10 and 2) (10 and 2) is 5 5 < (10 and 2) (10 and 2) < 5 not (10 and 2) 5 and 10 and 2 10 and 2 and 5 5 or (10 and 2) 10 and 2 or 5 10 and 2 if 10 and 2 else 10 and 2
inputA = 277 inputB = 349 score = 0 queueA = [] queueB = [] i = 0 while len(queueA) < (5*(10**6)): inputA = (inputA*16807)%2147483647 if inputA%4 == 0: queueA.append(inputA) while len(queueB) < (5*(10**6)): inputB = (inputB*48271)%2147483647 if inputB%8 == 0: queueB.append(inputB) for i in range(0,(5*(10**6))): if (queueA[i] & 0b1111111111111111) == (queueB[i] & 0b1111111111111111): score+=1 print(score)
input_a = 277 input_b = 349 score = 0 queue_a = [] queue_b = [] i = 0 while len(queueA) < 5 * 10 ** 6: input_a = inputA * 16807 % 2147483647 if inputA % 4 == 0: queueA.append(inputA) while len(queueB) < 5 * 10 ** 6: input_b = inputB * 48271 % 2147483647 if inputB % 8 == 0: queueB.append(inputB) for i in range(0, 5 * 10 ** 6): if queueA[i] & 65535 == queueB[i] & 65535: score += 1 print(score)
# Created by MechAviv # [Magic Library Checker] | [1032220] # Ellinia : Magic Library if "1" not in sm.getQuestEx(25566, "c3"): sm.setQuestEx(25566, "c3", "1") sm.chatScript("You search the Magic Library.")
if '1' not in sm.getQuestEx(25566, 'c3'): sm.setQuestEx(25566, 'c3', '1') sm.chatScript('You search the Magic Library.')
""" Write a Python program to find whether a given number (accept from the user) is even or odd, print out an appropriate message to the user. """ x = int(input("Enter a number : ")) if x%2==1: print("The number is an even number") else: print("The number is an odd number")
""" Write a Python program to find whether a given number (accept from the user) is even or odd, print out an appropriate message to the user. """ x = int(input('Enter a number : ')) if x % 2 == 1: print('The number is an even number') else: print('The number is an odd number')
class Comparable: def __init__(self, value): self.value = value def __eq__(self, other): other_value = other.value if isinstance(other, Comparable) else other return self.value == other_value def __ne__(self, other): other_value = other.value if isinstance(other, Comparable) else other return self.value != other_value def __gt__(self, other): other_value = other.value if isinstance(other, Comparable) else other return self.value > other_value def __lt__(self, other): other_value = other.value if isinstance(other, Comparable) else other return self.value < other_value def __ge__(self, other): other_value = other.value if isinstance(other, Comparable) else other return self.value >= other_value def __le__(self, other): other_value = other.value if isinstance(other, Comparable) else other return self.value <= other_value def read_file(s): with open(s, "r") as f: content = f.read() return content def write_file(s, name): with open(name, "w") as f: f.write(s)
class Comparable: def __init__(self, value): self.value = value def __eq__(self, other): other_value = other.value if isinstance(other, Comparable) else other return self.value == other_value def __ne__(self, other): other_value = other.value if isinstance(other, Comparable) else other return self.value != other_value def __gt__(self, other): other_value = other.value if isinstance(other, Comparable) else other return self.value > other_value def __lt__(self, other): other_value = other.value if isinstance(other, Comparable) else other return self.value < other_value def __ge__(self, other): other_value = other.value if isinstance(other, Comparable) else other return self.value >= other_value def __le__(self, other): other_value = other.value if isinstance(other, Comparable) else other return self.value <= other_value def read_file(s): with open(s, 'r') as f: content = f.read() return content def write_file(s, name): with open(name, 'w') as f: f.write(s)
def DecodeToFile(osufile, newfilename, SVLines: list): with open(newfilename, "w+") as f: old = open(osufile, "r") old = old.readlines() old_TotimingPoints = old[:old.index("[TimingPoints]\n") + 1] old_afterTimingPoints = old[old.index("[TimingPoints]\n") + 1:] all_file = old_TotimingPoints + [i.encode() for i in SVLines] + old_afterTimingPoints for k in all_file: f.write(k) def Noteoffset(osufile, start, end, return_only_LN=False): with open(osufile, 'r') as f: f = f.readlines() offseto = [] notecount = [] for i in range(f.index("[HitObjects]\n")+1, len(f) - 1): if start < int(f[i].split(",")[2]) <= end: if int(f[i].split(",")[2]) in offseto: notecount[-1] += 1 continue if return_only_LN: splited = f[i].split(",") release = int(splited[-1].split(":")[0]) if release == 0: continue else: offseto.append([int(splited[2]), release]) else: offseto.append(int(f[i].split(",")[2])) notecount.append(1) return offseto, notecount
def decode_to_file(osufile, newfilename, SVLines: list): with open(newfilename, 'w+') as f: old = open(osufile, 'r') old = old.readlines() old__totiming_points = old[:old.index('[TimingPoints]\n') + 1] old_after_timing_points = old[old.index('[TimingPoints]\n') + 1:] all_file = old_TotimingPoints + [i.encode() for i in SVLines] + old_afterTimingPoints for k in all_file: f.write(k) def noteoffset(osufile, start, end, return_only_LN=False): with open(osufile, 'r') as f: f = f.readlines() offseto = [] notecount = [] for i in range(f.index('[HitObjects]\n') + 1, len(f) - 1): if start < int(f[i].split(',')[2]) <= end: if int(f[i].split(',')[2]) in offseto: notecount[-1] += 1 continue if return_only_LN: splited = f[i].split(',') release = int(splited[-1].split(':')[0]) if release == 0: continue else: offseto.append([int(splited[2]), release]) else: offseto.append(int(f[i].split(',')[2])) notecount.append(1) return (offseto, notecount)
#Program for a Function that takes a list of words and returns the length of the longest one. def longest_word(list): #define a function which takes list as a parameter longest=0 for words in list: #loop for each word in list if len(words)>longest: #compare length iteratively longest=len(words) lword=words return lword #return longest word w=['Entertainment','entire','Elephant','inconsequential'] print("Longest word is",longest_word(w), "with", len(longest_word(w)), "letters.")
def longest_word(list): longest = 0 for words in list: if len(words) > longest: longest = len(words) lword = words return lword w = ['Entertainment', 'entire', 'Elephant', 'inconsequential'] print('Longest word is', longest_word(w), 'with', len(longest_word(w)), 'letters.')
def print_a_string(): my_string = "hello world" print(my_string) def print_a_number(): my_number = 9 print(my_number) # my logic starts here if __name__ == "__main__": print_a_string() print_a_number() print("all done...bye-bye")
def print_a_string(): my_string = 'hello world' print(my_string) def print_a_number(): my_number = 9 print(my_number) if __name__ == '__main__': print_a_string() print_a_number() print('all done...bye-bye')
def hms2dec(h,m,s): return 15*(h + (m/60) + (s/3600)) def dms2dec(d,m,s): if d>=0: return (d + (m/60) + (s/3600)) return (d - (m/60) - (s/3600)) if __name__ == '__main__': print(hms2dec(23, 12, 6)) print(dms2dec(22, 57, 18)) print(dms2dec(-66, 5, 5.1))
def hms2dec(h, m, s): return 15 * (h + m / 60 + s / 3600) def dms2dec(d, m, s): if d >= 0: return d + m / 60 + s / 3600 return d - m / 60 - s / 3600 if __name__ == '__main__': print(hms2dec(23, 12, 6)) print(dms2dec(22, 57, 18)) print(dms2dec(-66, 5, 5.1))
class PossumException(Exception): """Base Possum Exception""" class PipenvPathNotFound(PossumException): """Pipenv could not be located""" class SAMTemplateError(PossumException): """There was an error reading the template file"""
class Possumexception(Exception): """Base Possum Exception""" class Pipenvpathnotfound(PossumException): """Pipenv could not be located""" class Samtemplateerror(PossumException): """There was an error reading the template file"""
no_list = [22,68,90,78,90,88] def average(x): #complete the function's body to return the average length=len(no_list) return sum(no_list)/length print(average(no_list))
no_list = [22, 68, 90, 78, 90, 88] def average(x): length = len(no_list) return sum(no_list) / length print(average(no_list))
__lname__ = "yass" __uname__ = "YASS" __acronym__ = "Yet Another Subdomainer Software" __version__ = "0.8.0" __author__ = "Francesco Marano (@mrnfrancesco)" __author_email__ = "francesco.mrn24@gmail.com" __source_url__ = "https://github.com/mrnfrancesco/yass"
__lname__ = 'yass' __uname__ = 'YASS' __acronym__ = 'Yet Another Subdomainer Software' __version__ = '0.8.0' __author__ = 'Francesco Marano (@mrnfrancesco)' __author_email__ = 'francesco.mrn24@gmail.com' __source_url__ = 'https://github.com/mrnfrancesco/yass'
end = 1000 total = 0 for x in range(1,end): if x % 15 == 0: total = total + x print(x) elif x % 5 == 0: total = total + x print(x) elif x % 3 == 0: total = total + x print(x) print(f"total = {total}")
end = 1000 total = 0 for x in range(1, end): if x % 15 == 0: total = total + x print(x) elif x % 5 == 0: total = total + x print(x) elif x % 3 == 0: total = total + x print(x) print(f'total = {total}')
# Section 3-16 # Question: How do we find the sum of the digits of a positive integer using recursion? # Step 1: The recursive case # Add the current digit to a total # Step 2: The Base Condition # If there are no more digits, return the total # Step 3: The unintended cases # If the input is not a positive integer, throw an exception # perform sum function recursively test = 349587 expected = 3 + 4 + 9 + 5 + 8 + 7 def sum_digits(number): assert number >= 0 and int(number) == number, 'Input must be a nonnegative integer.' # Step 3: the unintended cases return 0 if number == 0 else (number % 10) + sum_digits(int(number / 10)) # Step 1 and 2 # Show the output outcome = sum_digits(test) print('Expected: ', expected) print('Outcome: ', outcome) assert outcome == expected, 'outcome does not match expected value. Check logic and try again.'
test = 349587 expected = 3 + 4 + 9 + 5 + 8 + 7 def sum_digits(number): assert number >= 0 and int(number) == number, 'Input must be a nonnegative integer.' return 0 if number == 0 else number % 10 + sum_digits(int(number / 10)) outcome = sum_digits(test) print('Expected: ', expected) print('Outcome: ', outcome) assert outcome == expected, 'outcome does not match expected value. Check logic and try again.'
# -*- coding: utf-8 -*- """This module contains two variables which will store all defined nodes models and instances """ model_store = {} node_store = {}
"""This module contains two variables which will store all defined nodes models and instances """ model_store = {} node_store = {}
def binarySearch(arr, l, r, x): while l <= r: mid = l + (r - l) / 2; # Check if x is present at mid if arr[mid] == x: return mid # If x is greater, ignore left half elif arr[mid] < x: l = mid + 1 # If x is smaller, ignore right half else: r = mid - 1 # If we reach here, then the element # was not present return -1
def binary_search(arr, l, r, x): while l <= r: mid = l + (r - l) / 2 if arr[mid] == x: return mid elif arr[mid] < x: l = mid + 1 else: r = mid - 1 return -1
# Segment tree class SegmentTree: def __init__(self, data): size = len(data) t = 1 while t < size: t <<= 1 offset = t - 1 index = [0] * (t * 2 - 1) index[offset:offset + size] = range(size) for i in range(offset - 1, -1, -1): x = index[i * 2 + 1] y = index[i * 2 + 2] if data[x] <= data[y]: index[i] = x else: index[i] = y self._data = data self._index = index self._offset = offset def query(self, start, stop): data = self._data index = self._index result = start l = start + self._offset r = stop + self._offset while l < r: if l & 1 == 0: i = index[l] x = data[i] y = data[result] if x < y or (x == y and i < result): result = i if r & 1 == 0: i = index[r - 1] x = data[i] y = data[result] if x < y or (x == y and i < result): result = i l = l // 2 r = (r - 1) // 2 return result N, K, D = map(int, input().split()) A = list(map(int, input().split())) if 1 + (K - 1) * D > N: print(-1) exit() st = SegmentTree(A) result = [] i = 0 for k in range(K - 1, -1, -1): i = st.query(i, N - k * D) result.append(A[i]) i += D print(*result)
class Segmenttree: def __init__(self, data): size = len(data) t = 1 while t < size: t <<= 1 offset = t - 1 index = [0] * (t * 2 - 1) index[offset:offset + size] = range(size) for i in range(offset - 1, -1, -1): x = index[i * 2 + 1] y = index[i * 2 + 2] if data[x] <= data[y]: index[i] = x else: index[i] = y self._data = data self._index = index self._offset = offset def query(self, start, stop): data = self._data index = self._index result = start l = start + self._offset r = stop + self._offset while l < r: if l & 1 == 0: i = index[l] x = data[i] y = data[result] if x < y or (x == y and i < result): result = i if r & 1 == 0: i = index[r - 1] x = data[i] y = data[result] if x < y or (x == y and i < result): result = i l = l // 2 r = (r - 1) // 2 return result (n, k, d) = map(int, input().split()) a = list(map(int, input().split())) if 1 + (K - 1) * D > N: print(-1) exit() st = segment_tree(A) result = [] i = 0 for k in range(K - 1, -1, -1): i = st.query(i, N - k * D) result.append(A[i]) i += D print(*result)