content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
number = int(input("Enter number: "))
for num in range(1111, 9999 + 1):
is_special = True
for digit in str(num):
digit = int(digit)
if (digit == 0) or (number % digit !=0):
is_special = False
break
if is_special:
print(num) | number = int(input('Enter number: '))
for num in range(1111, 9999 + 1):
is_special = True
for digit in str(num):
digit = int(digit)
if digit == 0 or number % digit != 0:
is_special = False
break
if is_special:
print(num) |
#!/usr/bin/python3
def shift(text):
return text[1:] + text[0]
t = input()
s = input()
found = False
for i in range(len(s)):
if t.find(s) != -1:
found = True
break
s = shift(s)
if found == True: print("yes")
else: print("no")
| def shift(text):
return text[1:] + text[0]
t = input()
s = input()
found = False
for i in range(len(s)):
if t.find(s) != -1:
found = True
break
s = shift(s)
if found == True:
print('yes')
else:
print('no') |
def grep(pattern):
print("Start coroutine")
try:
while True:
line = yield
if pattern in line:
print(line)
except GeneratorExit:
print("Stop coroutine")
def grep_python():
g = grep("Python")
yield from g
g = grep_python() # generator
next(g)
g.send("Is Go better?")
g.send("Python is not simple")
| def grep(pattern):
print('Start coroutine')
try:
while True:
line = (yield)
if pattern in line:
print(line)
except GeneratorExit:
print('Stop coroutine')
def grep_python():
g = grep('Python')
yield from g
g = grep_python()
next(g)
g.send('Is Go better?')
g.send('Python is not simple') |
""" Symlet 7 wavelet """
class Symlet7:
"""
Properties
----------
near symmetric, orthogonal, biorthogonal
All values are from http://wavelets.pybytes.com/wavelet/sym7/
"""
__name__ = "Symlet Wavelet 7"
__motherWaveletLength__ = 14 # length of the mother wavelet
__transformWaveletLength__ = 2 # minimum wavelength of input signal
# decomposition filter
# low-pass
decompositionLowFilter = [
0.002681814568257878,
-0.0010473848886829163,
-0.01263630340325193,
0.03051551316596357,
0.0678926935013727,
-0.049552834937127255,
0.017441255086855827,
0.5361019170917628,
0.767764317003164,
0.2886296317515146,
-0.14004724044296152,
-0.10780823770381774,
0.004010244871533663,
0.010268176708511255,
]
# high-pass
decompositionHighFilter = [
-0.010268176708511255,
0.004010244871533663,
0.10780823770381774,
-0.14004724044296152,
-0.2886296317515146,
0.767764317003164,
-0.5361019170917628,
0.017441255086855827,
0.049552834937127255,
0.0678926935013727,
-0.03051551316596357,
-0.01263630340325193,
0.0010473848886829163,
0.002681814568257878,
]
# reconstruction filters
# low pass
reconstructionLowFilter = [
0.010268176708511255,
0.004010244871533663,
-0.10780823770381774,
-0.14004724044296152,
0.2886296317515146,
0.767764317003164,
0.5361019170917628,
0.017441255086855827,
-0.049552834937127255,
0.0678926935013727,
0.03051551316596357,
-0.01263630340325193,
-0.0010473848886829163,
0.002681814568257878,
]
# high-pass
reconstructionHighFilter = [
0.002681814568257878,
0.0010473848886829163,
-0.01263630340325193,
-0.03051551316596357,
0.0678926935013727,
0.049552834937127255,
0.017441255086855827,
-0.5361019170917628,
0.767764317003164,
-0.2886296317515146,
-0.14004724044296152,
0.10780823770381774,
0.004010244871533663,
-0.010268176708511255,
]
| """ Symlet 7 wavelet """
class Symlet7:
"""
Properties
----------
near symmetric, orthogonal, biorthogonal
All values are from http://wavelets.pybytes.com/wavelet/sym7/
"""
__name__ = 'Symlet Wavelet 7'
__mother_wavelet_length__ = 14
__transform_wavelet_length__ = 2
decomposition_low_filter = [0.002681814568257878, -0.0010473848886829163, -0.01263630340325193, 0.03051551316596357, 0.0678926935013727, -0.049552834937127255, 0.017441255086855827, 0.5361019170917628, 0.767764317003164, 0.2886296317515146, -0.14004724044296152, -0.10780823770381774, 0.004010244871533663, 0.010268176708511255]
decomposition_high_filter = [-0.010268176708511255, 0.004010244871533663, 0.10780823770381774, -0.14004724044296152, -0.2886296317515146, 0.767764317003164, -0.5361019170917628, 0.017441255086855827, 0.049552834937127255, 0.0678926935013727, -0.03051551316596357, -0.01263630340325193, 0.0010473848886829163, 0.002681814568257878]
reconstruction_low_filter = [0.010268176708511255, 0.004010244871533663, -0.10780823770381774, -0.14004724044296152, 0.2886296317515146, 0.767764317003164, 0.5361019170917628, 0.017441255086855827, -0.049552834937127255, 0.0678926935013727, 0.03051551316596357, -0.01263630340325193, -0.0010473848886829163, 0.002681814568257878]
reconstruction_high_filter = [0.002681814568257878, 0.0010473848886829163, -0.01263630340325193, -0.03051551316596357, 0.0678926935013727, 0.049552834937127255, 0.017441255086855827, -0.5361019170917628, 0.767764317003164, -0.2886296317515146, -0.14004724044296152, 0.10780823770381774, 0.004010244871533663, -0.010268176708511255] |
class Solution(object):
self.prev = None
def flatten(self, root):
"""
:type root: TreeNode
:rtype: void Do not return anything, modify root in-place instead.
"""
if not root: return None
self.flatten(root.right)
self.flatten(root.left)
root.right = self.prev
root.left = None
self.prev = root
| class Solution(object):
self.prev = None
def flatten(self, root):
"""
:type root: TreeNode
:rtype: void Do not return anything, modify root in-place instead.
"""
if not root:
return None
self.flatten(root.right)
self.flatten(root.left)
root.right = self.prev
root.left = None
self.prev = root |
class A:
def foo(self):
pass
async def bar(self):
pass
| class A:
def foo(self):
pass
async def bar(self):
pass |
def clamp(floatnum, floatmin, floatmax):
if floatnum < floatmin:
floatnum = floatmin
if floatnum > floatmax:
floatnum = floatmax
return floatnum
def smootherstep(edge0, edge1, x):
# Scale, bias and saturate x to 0..1 range
x = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0)
# Evaluate polynomial
# Standard smoothstep version if needed: x * x * (3 - 2 - x)
return x * x * x * (x * (x * 6 - 15) + 10)
| def clamp(floatnum, floatmin, floatmax):
if floatnum < floatmin:
floatnum = floatmin
if floatnum > floatmax:
floatnum = floatmax
return floatnum
def smootherstep(edge0, edge1, x):
x = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0)
return x * x * x * (x * (x * 6 - 15) + 10) |
ar = [float(i) for i in input().split()]
ar_sq = []
for i in range(len(ar)):
ar_sq.append(ar[i]**2)
ar_sq = sorted(ar_sq)
print(ar_sq[0], end = ' ')
for i in range(1, len(ar_sq)):
if ar_sq[i] != ar_sq[i-1]:
print(ar_sq[i], end = ' ')
| ar = [float(i) for i in input().split()]
ar_sq = []
for i in range(len(ar)):
ar_sq.append(ar[i] ** 2)
ar_sq = sorted(ar_sq)
print(ar_sq[0], end=' ')
for i in range(1, len(ar_sq)):
if ar_sq[i] != ar_sq[i - 1]:
print(ar_sq[i], end=' ') |
#!/usr/bin/python
# -*- coding: utf-8 -*-
################################################################################
# Copyright (c) 2019 University of Utah Student Computing Labs.
# All Rights Reserved.
#
# Author: Thackery Archuletta
# Creation Date: Oct 2018
# Last Updated: March 2019
#
# Permission to use, copy, modify, and distribute this software and
# its documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appears in all copies and
# that both that copyright notice and this permission notice appear
# in supporting documentation, and that the name of The University
# of Utah not be used in advertising or publicity pertaining to
# distribution of the software without specific, written prior
# permission. This software is supplied as is without expressed or
# implied warranties of any kind.
################################################################################
class Controller(object):
"""Parent class for controller objects."""
def _set_to_middle(self, window):
"""Sets a Tkinter window to the center of the screen.
Args:
window: Tkinter window.
Returns:
void
"""
# <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
# Updates window info to current window state
window.update_idletasks()
# <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
# Gets computer screen width and height
screen_width = window.winfo_screenwidth()
screen_height = window.winfo_screenheight()
x = int(screen_width / 2 - window.winfo_width()/2)
y = int(screen_height / 4)
# <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
# Sets window position
window.geometry('+{}+{}'.format(x, y))
| class Controller(object):
"""Parent class for controller objects."""
def _set_to_middle(self, window):
"""Sets a Tkinter window to the center of the screen.
Args:
window: Tkinter window.
Returns:
void
"""
window.update_idletasks()
screen_width = window.winfo_screenwidth()
screen_height = window.winfo_screenheight()
x = int(screen_width / 2 - window.winfo_width() / 2)
y = int(screen_height / 4)
window.geometry('+{}+{}'.format(x, y)) |
#
# PySNMP MIB module DISMAN-EXPRESSION-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DISMAN-EXPRESSION-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:47:14 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, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsUnion, ConstraintsIntersection, ValueRangeConstraint, SingleValueConstraint, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "ConstraintsIntersection", "ValueRangeConstraint", "SingleValueConstraint", "ValueSizeConstraint")
SnmpAdminString, = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString")
ObjectGroup, NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "ObjectGroup", "NotificationGroup", "ModuleCompliance")
sysUpTime, = mibBuilder.importSymbols("SNMPv2-MIB", "sysUpTime")
MibScalar, MibTable, MibTableRow, MibTableColumn, Integer32, Unsigned32, mib_2, zeroDotZero, IpAddress, NotificationType, MibIdentifier, ModuleIdentity, Gauge32, Bits, Counter32, TimeTicks, iso, Counter64, ObjectIdentity = mibBuilder.importSymbols("SNMPv2-SMI", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Integer32", "Unsigned32", "mib-2", "zeroDotZero", "IpAddress", "NotificationType", "MibIdentifier", "ModuleIdentity", "Gauge32", "Bits", "Counter32", "TimeTicks", "iso", "Counter64", "ObjectIdentity")
DisplayString, TruthValue, RowStatus, TextualConvention, TimeStamp = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TruthValue", "RowStatus", "TextualConvention", "TimeStamp")
dismanExpressionMIB = ModuleIdentity((1, 3, 6, 1, 2, 1, 90))
dismanExpressionMIB.setRevisions(('2000-10-16 00:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts: dismanExpressionMIB.setRevisionsDescriptions(('This is the initial version of this MIB. Published as RFC 2982',))
if mibBuilder.loadTexts: dismanExpressionMIB.setLastUpdated('200010160000Z')
if mibBuilder.loadTexts: dismanExpressionMIB.setOrganization('IETF Distributed Management Working Group')
if mibBuilder.loadTexts: dismanExpressionMIB.setContactInfo('Ramanathan Kavasseri Cisco Systems, Inc. 170 West Tasman Drive, San Jose CA 95134-1706. Phone: +1 408 527 2446 Email: ramk@cisco.com')
if mibBuilder.loadTexts: dismanExpressionMIB.setDescription('The MIB module for defining expressions of MIB objects for management purposes.')
dismanExpressionMIBObjects = MibIdentifier((1, 3, 6, 1, 2, 1, 90, 1))
expResource = MibIdentifier((1, 3, 6, 1, 2, 1, 90, 1, 1))
expDefine = MibIdentifier((1, 3, 6, 1, 2, 1, 90, 1, 2))
expValue = MibIdentifier((1, 3, 6, 1, 2, 1, 90, 1, 3))
expResourceDeltaMinimum = MibScalar((1, 3, 6, 1, 2, 1, 90, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(1, 600), ))).setUnits('seconds').setMaxAccess("readwrite")
if mibBuilder.loadTexts: expResourceDeltaMinimum.setStatus('current')
if mibBuilder.loadTexts: expResourceDeltaMinimum.setDescription("The minimum expExpressionDeltaInterval this system will accept. A system may use the larger values of this minimum to lessen the impact of constantly computing deltas. For larger delta sampling intervals the system samples less often and suffers less overhead. This object provides a way to enforce such lower overhead for all expressions created after it is set. The value -1 indicates that expResourceDeltaMinimum is irrelevant as the system will not accept 'deltaValue' as a value for expObjectSampleType. Unless explicitly resource limited, a system's value for this object should be 1, allowing as small as a 1 second interval for ongoing delta sampling. Changing this value will not invalidate an existing setting of expObjectSampleType.")
expResourceDeltaWildcardInstanceMaximum = MibScalar((1, 3, 6, 1, 2, 1, 90, 1, 1, 2), Unsigned32()).setUnits('instances').setMaxAccess("readwrite")
if mibBuilder.loadTexts: expResourceDeltaWildcardInstanceMaximum.setStatus('current')
if mibBuilder.loadTexts: expResourceDeltaWildcardInstanceMaximum.setDescription("For every instance of a deltaValue object, one dynamic instance entry is needed for holding the instance value from the previous sample, i.e. to maintain state. This object limits maximum number of dynamic instance entries this system will support for wildcarded delta objects in expressions. For a given delta expression, the number of dynamic instances is the number of values that meet all criteria to exist times the number of delta values in the expression. A value of 0 indicates no preset limit, that is, the limit is dynamic based on system operation and resources. Unless explicitly resource limited, a system's value for this object should be 0. Changing this value will not eliminate or inhibit existing delta wildcard instance objects but will prevent the creation of more such objects. An attempt to allocate beyond the limit results in expErrorCode being tooManyWildcardValues for that evaluation attempt.")
expResourceDeltaWildcardInstances = MibScalar((1, 3, 6, 1, 2, 1, 90, 1, 1, 3), Gauge32()).setUnits('instances').setMaxAccess("readonly")
if mibBuilder.loadTexts: expResourceDeltaWildcardInstances.setStatus('current')
if mibBuilder.loadTexts: expResourceDeltaWildcardInstances.setDescription('The number of currently active instance entries as defined for expResourceDeltaWildcardInstanceMaximum.')
expResourceDeltaWildcardInstancesHigh = MibScalar((1, 3, 6, 1, 2, 1, 90, 1, 1, 4), Gauge32()).setUnits('instances').setMaxAccess("readonly")
if mibBuilder.loadTexts: expResourceDeltaWildcardInstancesHigh.setStatus('current')
if mibBuilder.loadTexts: expResourceDeltaWildcardInstancesHigh.setDescription('The highest value of expResourceDeltaWildcardInstances that has occurred since initialization of the managed system.')
expResourceDeltaWildcardInstanceResourceLacks = MibScalar((1, 3, 6, 1, 2, 1, 90, 1, 1, 5), Counter32()).setUnits('instances').setMaxAccess("readonly")
if mibBuilder.loadTexts: expResourceDeltaWildcardInstanceResourceLacks.setStatus('current')
if mibBuilder.loadTexts: expResourceDeltaWildcardInstanceResourceLacks.setDescription('The number of times this system could not evaluate an expression because that would have created a value instance in excess of expResourceDeltaWildcardInstanceMaximum.')
expExpressionTable = MibTable((1, 3, 6, 1, 2, 1, 90, 1, 2, 1), )
if mibBuilder.loadTexts: expExpressionTable.setStatus('current')
if mibBuilder.loadTexts: expExpressionTable.setDescription('A table of expression definitions.')
expExpressionEntry = MibTableRow((1, 3, 6, 1, 2, 1, 90, 1, 2, 1, 1), ).setIndexNames((0, "DISMAN-EXPRESSION-MIB", "expExpressionOwner"), (0, "DISMAN-EXPRESSION-MIB", "expExpressionName"))
if mibBuilder.loadTexts: expExpressionEntry.setStatus('current')
if mibBuilder.loadTexts: expExpressionEntry.setDescription("Information about a single expression. New expressions can be created using expExpressionRowStatus. To create an expression first create the named entry in this table. Then use expExpressionName to populate expObjectTable. For expression evaluation to succeed all related entries in expExpressionTable and expObjectTable must be 'active'. If these conditions are not met the corresponding values in expValue simply are not instantiated. Deleting an entry deletes all related entries in expObjectTable and expErrorTable. Because of the relationships among the multiple tables for an expression (expExpressionTable, expObjectTable, and expValueTable) and the SNMP rules for independence in setting object values, it is necessary to do final error checking when an expression is evaluated, that is, when one of its instances in expValueTable is read or a delta interval expires. Earlier checking need not be done and an implementation may not impose any ordering on the creation of objects related to an expression. To maintain security of MIB information, when creating a new row in this table, the managed system must record the security credentials of the requester. These security credentials are the parameters necessary as inputs to isAccessAllowed from the Architecture for Describing SNMP Management Frameworks. When obtaining the objects that make up the expression, the system must (conceptually) use isAccessAllowed to ensure that it does not violate security. The evaluation of the expression takes place under the security credentials of the creator of its expExpressionEntry. Values of read-write objects in this table may be changed at any time.")
expExpressionOwner = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 1, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(0, 32)))
if mibBuilder.loadTexts: expExpressionOwner.setStatus('current')
if mibBuilder.loadTexts: expExpressionOwner.setDescription('The owner of this entry. The exact semantics of this string are subject to the security policy defined by the security administrator.')
expExpressionName = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 1, 1, 2), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 32)))
if mibBuilder.loadTexts: expExpressionName.setStatus('current')
if mibBuilder.loadTexts: expExpressionName.setDescription('The name of the expression. This is locally unique, within the scope of an expExpressionOwner.')
expExpression = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 1, 1, 3), OctetString().subtype(subtypeSpec=ValueSizeConstraint(1, 1024))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: expExpression.setStatus('current')
if mibBuilder.loadTexts: expExpression.setDescription("The expression to be evaluated. This object is the same as a DisplayString (RFC 1903) except for its maximum length. Except for the variable names the expression is in ANSI C syntax. Only the subset of ANSI C operators and functions listed here is allowed. Variables are expressed as a dollar sign ('$') and an integer that corresponds to an expObjectIndex. An example of a valid expression is: ($1-$5)*100 Expressions must not be recursive, that is although an expression may use the results of another expression, it must not contain any variable that is directly or indirectly a result of its own evaluation. The managed system must check for recursive expressions. The only allowed operators are: ( ) - (unary) + - * / % & | ^ << >> ~ ! && || == != > >= < <= Note the parentheses are included for parenthesizing the expression, not for casting data types. The only constant types defined are: int (32-bit signed) long (64-bit signed) unsigned int unsigned long hexadecimal character string oid The default type for a positive integer is int unless it is too large in which case it is long. All but oid are as defined for ANSI C. Note that a hexadecimal constant may end up as a scalar or an array of 8-bit integers. A string constant is enclosed in double quotes and may contain back-slashed individual characters as in ANSI C. An oid constant comprises 32-bit, unsigned integers and at least one period, for example: 0. .0 1.3.6.1 No additional leading or trailing subidentifiers are automatically added to an OID constant. The constant is taken as expressed. Integer-typed objects are treated as 32- or 64-bit, signed or unsigned integers, as appropriate. The results of mixing them are as for ANSI C, including the type of the result. Note that a 32-bit value is thus promoted to 64 bits only in an operation with a 64-bit value. There is no provision for larger values to handle overflow. Relative to SNMP data types, a resulting value becomes unsigned when calculating it uses any unsigned value, including a counter. To force the final value to be of data type counter the expression must explicitly use the counter32() or counter64() function (defined below). OCTET STRINGS and OBJECT IDENTIFIERs are treated as one-dimensioned arrays of unsigned 8-bit integers and unsigned 32-bit integers, respectively. IpAddresses are treated as 32-bit, unsigned integers in network byte order, that is, the hex version of 255.0.0.0 is 0xff000000. Conditional expressions result in a 32-bit, unsigned integer of value 0 for false or 1 for true. When an arbitrary value is used as a boolean 0 is false and non-zero is true. Rules for the resulting data type from an operation, based on the operator: For << and >> the result is the same as the left hand operand. For &&, ||, ==, !=, <, <=, >, and >= the result is always Unsigned32. For unary - the result is always Integer32. For +, -, *, /, %, &, |, and ^ the result is promoted according to the following rules, in order from most to least preferred: If left hand and right hand operands are the same type, use that. If either side is Counter64, use that. If either side is IpAddress, use that. If either side is TimeTicks, use that. If either side is Counter32, use that. Otherwise use Unsigned32. The following rules say what operators apply with what data types. Any combination not explicitly defined does not work. For all operators any of the following can be the left hand or right hand operand: Integer32, Counter32, Unsigned32, Counter64. The operators +, -, *, /, %, <, <=, >, and >= work with TimeTicks. The operators &, |, and ^ work with IpAddress. The operators << and >> work with IpAddress but only as the left hand operand. The + operator performs a concatenation of two OCTET STRINGs or two OBJECT IDENTIFIERs. The operators &, | perform bitwise operations on OCTET STRINGs. If the OCTET STRING happens to be a DisplayString the results may be meaningless, but the agent system does not check this as some such systems do not have this information. The operators << and >> perform bitwise operations on OCTET STRINGs appearing as the left hand operand. The only functions defined are: counter32 counter64 arraySection stringBegins stringEnds stringContains oidBegins oidEnds oidContains average maximum minimum sum exists The following function definitions indicate their parameters by naming the data type of the parameter in the parameter's position in the parameter list. The parameter must be of the type indicated and generally may be a constant, a MIB object, a function, or an expression. counter32(integer) - wrapped around an integer value counter32 forces Counter32 as a data type. counter64(integer) - similar to counter32 except that the resulting data type is 'counter64'. arraySection(array, integer, integer) - selects a piece of an array (i.e. part of an OCTET STRING or OBJECT IDENTIFIER). The integer arguments are in the range 0 to 4,294,967,295. The first is an initial array index (one-dimensioned) and the second is an ending array index. A value of 0 indicates first or last element, respectively. If the first element is larger than the array length the result is 0 length. If the second integer is less than or equal to the first, the result is 0 length. If the second is larger than the array length it indicates last element. stringBegins/Ends/Contains(octetString, octetString) - looks for the second string (which can be a string constant) in the first and returns the one-dimensioned arrayindex where the match began. A return value of 0 indicates no match (i.e. boolean false). oidBegins/Ends/Contains(oid, oid) - looks for the second OID (which can be an OID constant) in the first and returns the the one-dimensioned index where the match began. A return value of 0 indicates no match (i.e. boolean false). average/maximum/minimum(integer) - calculates the average, minimum, or maximum value of the integer valued object over multiple sample times. If the object disappears for any sample period, the accumulation and the resulting value object cease to exist until the object reappears at which point the calculation starts over. sum(integerObject*) - sums all available values of the wildcarded integer object, resulting in an integer scalar. Must be used with caution as it wraps on overflow with no notification. exists(anyTypeObject) - verifies the object instance exists. A return value of 0 indicates NoSuchInstance (i.e. boolean false).")
expExpressionValueType = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 1, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8))).clone(namedValues=NamedValues(("counter32", 1), ("unsigned32", 2), ("timeTicks", 3), ("integer32", 4), ("ipAddress", 5), ("octetString", 6), ("objectId", 7), ("counter64", 8))).clone('counter32')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: expExpressionValueType.setStatus('current')
if mibBuilder.loadTexts: expExpressionValueType.setDescription('The type of the expression value. One and only one of the value objects in expValueTable will be instantiated to match this type. If the result of the expression can not be made into this type, an invalidOperandType error will occur.')
expExpressionComment = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 1, 1, 5), SnmpAdminString().clone(hexValue="")).setMaxAccess("readcreate")
if mibBuilder.loadTexts: expExpressionComment.setStatus('current')
if mibBuilder.loadTexts: expExpressionComment.setDescription('A comment to explain the use or meaning of the expression.')
expExpressionDeltaInterval = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 1, 1, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 86400))).setUnits('seconds').setMaxAccess("readcreate")
if mibBuilder.loadTexts: expExpressionDeltaInterval.setStatus('current')
if mibBuilder.loadTexts: expExpressionDeltaInterval.setDescription("Sampling interval for objects in this expression with expObjectSampleType 'deltaValue'. This object has no effect if the the expression has no deltaValue objects. A value of 0 indicates no automated sampling. In this case the delta is the difference from the last time the expression was evaluated. Note that this is subject to unpredictable delta times in the face of retries or multiple managers. A value greater than zero is the number of seconds between automated samples. Until the delta interval has expired once the delta for the object is effectively not instantiated and evaluating the expression has results as if the object itself were not instantiated. Note that delta values potentially consume large amounts of system CPU and memory. Delta state and processing must continue constantly even if the expression is not being used. That is, the expression is being evaluated every delta interval, even if no application is reading those values. For wildcarded objects this can be substantial overhead. Note that delta intervals, external expression value sampling intervals and delta intervals for expressions within other expressions can have unusual interactions as they are impossible to synchronize accurately. In general one interval embedded below another must be enough shorter that the higher sample sees relatively smooth, predictable behavior. So, for example, to avoid the higher level getting the same sample twice, the lower level should sample at least twice as fast as the higher level does.")
expExpressionPrefix = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 1, 1, 7), ObjectIdentifier()).setMaxAccess("readonly")
if mibBuilder.loadTexts: expExpressionPrefix.setStatus('current')
if mibBuilder.loadTexts: expExpressionPrefix.setDescription('An object prefix to assist an application in determining the instance indexing to use in expValueTable, relieving the application of the need to scan the expObjectTable to determine such a prefix. See expObjectTable for information on wildcarded objects. If the expValueInstance portion of the value OID may be treated as a scalar (that is, normally, 0) the value of expExpressionPrefix is zero length, that is, no OID at all. Note that zero length implies a null OID, not the OID 0.0. Otherwise, the value of expExpressionPrefix is the expObjectID value of any one of the wildcarded objects for the expression. This is sufficient, as the remainder, that is, the instance fragment relevant to instancing the values, must be the same for all wildcarded objects in the expression.')
expExpressionErrors = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 1, 1, 8), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: expExpressionErrors.setStatus('current')
if mibBuilder.loadTexts: expExpressionErrors.setDescription('The number of errors encountered while evaluating this expression. Note that an object in the expression not being accessible, is not considered an error. An example of an inaccessible object is when the object is excluded from the view of the user whose security credentials are used in the expression evaluation. In such cases, it is a legitimate condition that causes the corresponding expression value not to be instantiated.')
expExpressionEntryStatus = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 1, 1, 9), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: expExpressionEntryStatus.setStatus('current')
if mibBuilder.loadTexts: expExpressionEntryStatus.setDescription('The control that allows creation and deletion of entries.')
expErrorTable = MibTable((1, 3, 6, 1, 2, 1, 90, 1, 2, 2), )
if mibBuilder.loadTexts: expErrorTable.setStatus('current')
if mibBuilder.loadTexts: expErrorTable.setDescription('A table of expression errors.')
expErrorEntry = MibTableRow((1, 3, 6, 1, 2, 1, 90, 1, 2, 2, 1), ).setIndexNames((0, "DISMAN-EXPRESSION-MIB", "expExpressionOwner"), (0, "DISMAN-EXPRESSION-MIB", "expExpressionName"))
if mibBuilder.loadTexts: expErrorEntry.setStatus('current')
if mibBuilder.loadTexts: expErrorEntry.setDescription('Information about errors in processing an expression. Entries appear in this table only when there is a matching expExpressionEntry and then only when there has been an error for that expression as reflected by the error codes defined for expErrorCode.')
expErrorTime = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 2, 1, 1), TimeStamp()).setMaxAccess("readonly")
if mibBuilder.loadTexts: expErrorTime.setStatus('current')
if mibBuilder.loadTexts: expErrorTime.setDescription('The value of sysUpTime the last time an error caused a failure to evaluate this expression.')
expErrorIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 2, 1, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: expErrorIndex.setStatus('current')
if mibBuilder.loadTexts: expErrorIndex.setDescription('The one-dimensioned character array index into expExpression for where the error occurred. The value zero indicates irrelevance.')
expErrorCode = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 2, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11))).clone(namedValues=NamedValues(("invalidSyntax", 1), ("undefinedObjectIndex", 2), ("unrecognizedOperator", 3), ("unrecognizedFunction", 4), ("invalidOperandType", 5), ("unmatchedParenthesis", 6), ("tooManyWildcardValues", 7), ("recursion", 8), ("deltaTooShort", 9), ("resourceUnavailable", 10), ("divideByZero", 11)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: expErrorCode.setStatus('current')
if mibBuilder.loadTexts: expErrorCode.setDescription("The error that occurred. In the following explanations the expected timing of the error is in parentheses. 'S' means the error occurs on a Set request. 'E' means the error occurs on the attempt to evaluate the expression either due to Get from expValueTable or in ongoing delta processing. invalidSyntax the value sent for expExpression is not valid Expression MIB expression syntax (S) undefinedObjectIndex an object reference ($n) in expExpression does not have a matching instance in expObjectTable (E) unrecognizedOperator the value sent for expExpression held an unrecognized operator (S) unrecognizedFunction the value sent for expExpression held an unrecognized function name (S) invalidOperandType an operand in expExpression is not the right type for the associated operator or result (SE) unmatchedParenthesis the value sent for expExpression is not correctly parenthesized (S) tooManyWildcardValues evaluating the expression exceeded the limit set by expResourceDeltaWildcardInstanceMaximum (E) recursion through some chain of embedded expressions the expression invokes itself (E) deltaTooShort the delta for the next evaluation passed before the system could evaluate the present sample (E) resourceUnavailable some resource, typically dynamic memory, was unavailable (SE) divideByZero an attempt to divide by zero occurred (E) For the errors that occur when the attempt is made to set expExpression Set request fails with the SNMP error code 'wrongValue'. Such failures refer to the most recent failure to Set expExpression, not to the present value of expExpression which must be either unset or syntactically correct. Errors that occur during evaluation for a Get* operation return the SNMP error code 'genErr' except for 'tooManyWildcardValues' and 'resourceUnavailable' which return the SNMP error code 'resourceUnavailable'.")
expErrorInstance = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 2, 1, 4), ObjectIdentifier()).setMaxAccess("readonly")
if mibBuilder.loadTexts: expErrorInstance.setStatus('current')
if mibBuilder.loadTexts: expErrorInstance.setDescription('The expValueInstance being evaluated when the error occurred. A zero-length indicates irrelevance.')
expObjectTable = MibTable((1, 3, 6, 1, 2, 1, 90, 1, 2, 3), )
if mibBuilder.loadTexts: expObjectTable.setStatus('current')
if mibBuilder.loadTexts: expObjectTable.setDescription('A table of object definitions for each expExpression. Wildcarding instance IDs: It is legal to omit all or part of the instance portion for some or all of the objects in an expression. (See the DESCRIPTION of expObjectID for details. However, note that if more than one object in the same expression is wildcarded in this way, they all must be objects where that portion of the instance is the same. In other words, all objects may be in the same SEQUENCE or in different SEQUENCEs but with the same semantic index value (e.g., a value of ifIndex) for the wildcarded portion.')
expObjectEntry = MibTableRow((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1), ).setIndexNames((0, "DISMAN-EXPRESSION-MIB", "expExpressionOwner"), (0, "DISMAN-EXPRESSION-MIB", "expExpressionName"), (0, "DISMAN-EXPRESSION-MIB", "expObjectIndex"))
if mibBuilder.loadTexts: expObjectEntry.setStatus('current')
if mibBuilder.loadTexts: expObjectEntry.setDescription('Information about an object. An application uses expObjectEntryStatus to create entries in this table while in the process of defining an expression. Values of read-create objects in this table may be changed at any time.')
expObjectIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1, 1), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 4294967295)))
if mibBuilder.loadTexts: expObjectIndex.setStatus('current')
if mibBuilder.loadTexts: expObjectIndex.setDescription("Within an expression, a unique, numeric identification for an object. Prefixed with a dollar sign ('$') this is used to reference the object in the corresponding expExpression.")
expObjectID = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1, 2), ObjectIdentifier()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: expObjectID.setStatus('current')
if mibBuilder.loadTexts: expObjectID.setDescription('The OBJECT IDENTIFIER (OID) of this object. The OID may be fully qualified, meaning it includes a complete instance identifier part (e.g., ifInOctets.1 or sysUpTime.0), or it may not be fully qualified, meaning it may lack all or part of the instance identifier. If the expObjectID is not fully qualified, then expObjectWildcard must be set to true(1). The value of the expression will be multiple values, as if done for a GetNext sweep of the object. An object here may itself be the result of an expression but recursion is not allowed. NOTE: The simplest implementations of this MIB may not allow wildcards.')
expObjectIDWildcard = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1, 3), TruthValue().clone('false')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: expObjectIDWildcard.setStatus('current')
if mibBuilder.loadTexts: expObjectIDWildcard.setDescription('A true value indicates the expObjecID of this row is a wildcard object. False indicates that expObjectID is fully instanced. If all expObjectWildcard values for a given expression are FALSE, expExpressionPrefix will reflect a scalar object (i.e. will be 0.0). NOTE: The simplest implementations of this MIB may not allow wildcards.')
expObjectSampleType = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("absoluteValue", 1), ("deltaValue", 2), ("changedValue", 3))).clone('absoluteValue')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: expObjectSampleType.setStatus('current')
if mibBuilder.loadTexts: expObjectSampleType.setDescription("The method of sampling the selected variable. An 'absoluteValue' is simply the present value of the object. A 'deltaValue' is the present value minus the previous value, which was sampled expExpressionDeltaInterval seconds ago. This is intended primarily for use with SNMP counters, which are meaningless as an 'absoluteValue', but may be used with any integer-based value. A 'changedValue' is a boolean for whether the present value is different from the previous value. It is applicable to any data type and results in an Unsigned32 with value 1 if the object's value is changed and 0 if not. In all other respects it is as a 'deltaValue' and all statements and operation regarding delta values apply to changed values. When an expression contains both delta and absolute values the absolute values are obtained at the end of the delta period.")
sysUpTimeInstance = MibIdentifier((1, 3, 6, 1, 2, 1, 1, 3, 0))
expObjectDeltaDiscontinuityID = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1, 5), ObjectIdentifier().clone((1, 3, 6, 1, 2, 1, 1, 3, 0))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: expObjectDeltaDiscontinuityID.setStatus('current')
if mibBuilder.loadTexts: expObjectDeltaDiscontinuityID.setDescription("The OBJECT IDENTIFIER (OID) of a TimeTicks, TimeStamp, or DateAndTime object that indicates a discontinuity in the value at expObjectID. This object is instantiated only if expObjectSampleType is 'deltaValue' or 'changedValue'. The OID may be for a leaf object (e.g. sysUpTime.0) or may be wildcarded to match expObjectID. This object supports normal checking for a discontinuity in a counter. Note that if this object does not point to sysUpTime discontinuity checking must still check sysUpTime for an overall discontinuity. If the object identified is not accessible no discontinuity check will be made.")
expObjectDiscontinuityIDWildcard = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1, 6), TruthValue().clone('false')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: expObjectDiscontinuityIDWildcard.setStatus('current')
if mibBuilder.loadTexts: expObjectDiscontinuityIDWildcard.setDescription("A true value indicates the expObjectDeltaDiscontinuityID of this row is a wildcard object. False indicates that expObjectDeltaDiscontinuityID is fully instanced. This object is instantiated only if expObjectSampleType is 'deltaValue' or 'changedValue'. NOTE: The simplest implementations of this MIB may not allow wildcards.")
expObjectDiscontinuityIDType = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("timeTicks", 1), ("timeStamp", 2), ("dateAndTime", 3))).clone('timeTicks')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: expObjectDiscontinuityIDType.setStatus('current')
if mibBuilder.loadTexts: expObjectDiscontinuityIDType.setDescription("The value 'timeTicks' indicates the expObjectDeltaDiscontinuityID of this row is of syntax TimeTicks. The value 'timeStamp' indicates syntax TimeStamp. The value 'dateAndTime indicates syntax DateAndTime. This object is instantiated only if expObjectSampleType is 'deltaValue' or 'changedValue'.")
expObjectConditional = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1, 8), ObjectIdentifier().clone((0, 0))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: expObjectConditional.setStatus('current')
if mibBuilder.loadTexts: expObjectConditional.setDescription('The OBJECT IDENTIFIER (OID) of an object that overrides whether the instance of expObjectID is to be considered usable. If the value of the object at expObjectConditional is 0 or not instantiated, the object at expObjectID is treated as if it is not instantiated. In other words, expObjectConditional is a filter that controls whether or not to use the value at expObjectID. The OID may be for a leaf object (e.g. sysObjectID.0) or may be wildcarded to match expObjectID. If expObject is wildcarded and expObjectID in the same row is not, the wild portion of expObjectConditional must match the wildcarding of the rest of the expression. If no object in the expression is wildcarded but expObjectConditional is, use the lexically first instance (if any) of expObjectConditional. If the value of expObjectConditional is 0.0 operation is as if the value pointed to by expObjectConditional is a non-zero (true) value. Note that expObjectConditional can not trivially use an object of syntax TruthValue, since the underlying value is not 0 or 1.')
expObjectConditionalWildcard = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1, 9), TruthValue().clone('false')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: expObjectConditionalWildcard.setStatus('current')
if mibBuilder.loadTexts: expObjectConditionalWildcard.setDescription('A true value indicates the expObjectConditional of this row is a wildcard object. False indicates that expObjectConditional is fully instanced. NOTE: The simplest implementations of this MIB may not allow wildcards.')
expObjectEntryStatus = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1, 10), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: expObjectEntryStatus.setStatus('current')
if mibBuilder.loadTexts: expObjectEntryStatus.setDescription('The control that allows creation/deletion of entries. Objects in this table may be changed while expObjectEntryStatus is in any state.')
expValueTable = MibTable((1, 3, 6, 1, 2, 1, 90, 1, 3, 1), )
if mibBuilder.loadTexts: expValueTable.setStatus('current')
if mibBuilder.loadTexts: expValueTable.setDescription('A table of values from evaluated expressions.')
expValueEntry = MibTableRow((1, 3, 6, 1, 2, 1, 90, 1, 3, 1, 1), ).setIndexNames((0, "DISMAN-EXPRESSION-MIB", "expExpressionOwner"), (0, "DISMAN-EXPRESSION-MIB", "expExpressionName"), (1, "DISMAN-EXPRESSION-MIB", "expValueInstance"))
if mibBuilder.loadTexts: expValueEntry.setStatus('current')
if mibBuilder.loadTexts: expValueEntry.setDescription("A single value from an evaluated expression. For a given instance, only one 'Val' object in the conceptual row will be instantiated, that is, the one with the appropriate type for the value. For values that contain no objects of expObjectSampleType 'deltaValue' or 'changedValue', reading a value from the table causes the evaluation of the expression for that value. For those that contain a 'deltaValue' or 'changedValue' the value read is as of the last sampling interval. If in the attempt to evaluate the expression one or more of the necessary objects is not available, the corresponding entry in this table is effectively not instantiated. To maintain security of MIB information, when creating a new row in this table, the managed system must record the security credentials of the requester. These security credentials are the parameters necessary as inputs to isAccessAllowed from [RFC2571]. When obtaining the objects that make up the expression, the system must (conceptually) use isAccessAllowed to ensure that it does not violate security. The evaluation of that expression takes place under the security credentials of the creator of its expExpressionEntry. To maintain security of MIB information, expression evaluation must take place using security credentials for the implied Gets of the objects in the expression as inputs (conceptually) to isAccessAllowed from the Architecture for Describing SNMP Management Frameworks. These are the security credentials of the creator of the corresponding expExpressionEntry.")
expValueInstance = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 3, 1, 1, 1), ObjectIdentifier())
if mibBuilder.loadTexts: expValueInstance.setStatus('current')
if mibBuilder.loadTexts: expValueInstance.setDescription("The final instance portion of a value's OID according to the wildcarding in instances of expObjectID for the expression. The prefix of this OID fragment is 0.0, leading to the following behavior. If there is no wildcarding, the value is 0.0.0. In other words, there is one value which standing alone would have been a scalar with a 0 at the end of its OID. If there is wildcarding, the value is 0.0 followed by a value that the wildcard can take, thus defining one value instance for each real, possible value of the wildcard. So, for example, if the wildcard worked out to be an ifIndex, there is an expValueInstance for each applicable ifIndex.")
expValueCounter32Val = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 3, 1, 1, 2), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: expValueCounter32Val.setStatus('current')
if mibBuilder.loadTexts: expValueCounter32Val.setDescription("The value when expExpressionValueType is 'counter32'.")
expValueUnsigned32Val = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 3, 1, 1, 3), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: expValueUnsigned32Val.setStatus('current')
if mibBuilder.loadTexts: expValueUnsigned32Val.setDescription("The value when expExpressionValueType is 'unsigned32'.")
expValueTimeTicksVal = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 3, 1, 1, 4), TimeTicks()).setMaxAccess("readonly")
if mibBuilder.loadTexts: expValueTimeTicksVal.setStatus('current')
if mibBuilder.loadTexts: expValueTimeTicksVal.setDescription("The value when expExpressionValueType is 'timeTicks'.")
expValueInteger32Val = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 3, 1, 1, 5), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: expValueInteger32Val.setStatus('current')
if mibBuilder.loadTexts: expValueInteger32Val.setDescription("The value when expExpressionValueType is 'integer32'.")
expValueIpAddressVal = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 3, 1, 1, 6), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: expValueIpAddressVal.setStatus('current')
if mibBuilder.loadTexts: expValueIpAddressVal.setDescription("The value when expExpressionValueType is 'ipAddress'.")
expValueOctetStringVal = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 3, 1, 1, 7), OctetString().subtype(subtypeSpec=ValueSizeConstraint(0, 65536))).setMaxAccess("readonly")
if mibBuilder.loadTexts: expValueOctetStringVal.setStatus('current')
if mibBuilder.loadTexts: expValueOctetStringVal.setDescription("The value when expExpressionValueType is 'octetString'.")
expValueOidVal = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 3, 1, 1, 8), ObjectIdentifier()).setMaxAccess("readonly")
if mibBuilder.loadTexts: expValueOidVal.setStatus('current')
if mibBuilder.loadTexts: expValueOidVal.setDescription("The value when expExpressionValueType is 'objectId'.")
expValueCounter64Val = MibTableColumn((1, 3, 6, 1, 2, 1, 90, 1, 3, 1, 1, 9), Counter64()).setMaxAccess("readonly")
if mibBuilder.loadTexts: expValueCounter64Val.setStatus('current')
if mibBuilder.loadTexts: expValueCounter64Val.setDescription("The value when expExpressionValueType is 'counter64'.")
dismanExpressionMIBConformance = MibIdentifier((1, 3, 6, 1, 2, 1, 90, 3))
dismanExpressionMIBCompliances = MibIdentifier((1, 3, 6, 1, 2, 1, 90, 3, 1))
dismanExpressionMIBGroups = MibIdentifier((1, 3, 6, 1, 2, 1, 90, 3, 2))
dismanExpressionMIBCompliance = ModuleCompliance((1, 3, 6, 1, 2, 1, 90, 3, 1, 1)).setObjects(("DISMAN-EXPRESSION-MIB", "dismanExpressionResourceGroup"), ("DISMAN-EXPRESSION-MIB", "dismanExpressionDefinitionGroup"), ("DISMAN-EXPRESSION-MIB", "dismanExpressionValueGroup"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
dismanExpressionMIBCompliance = dismanExpressionMIBCompliance.setStatus('current')
if mibBuilder.loadTexts: dismanExpressionMIBCompliance.setDescription('The compliance statement for entities which implement the Expression MIB.')
dismanExpressionResourceGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 90, 3, 2, 1)).setObjects(("DISMAN-EXPRESSION-MIB", "expResourceDeltaMinimum"), ("DISMAN-EXPRESSION-MIB", "expResourceDeltaWildcardInstanceMaximum"), ("DISMAN-EXPRESSION-MIB", "expResourceDeltaWildcardInstances"), ("DISMAN-EXPRESSION-MIB", "expResourceDeltaWildcardInstancesHigh"), ("DISMAN-EXPRESSION-MIB", "expResourceDeltaWildcardInstanceResourceLacks"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
dismanExpressionResourceGroup = dismanExpressionResourceGroup.setStatus('current')
if mibBuilder.loadTexts: dismanExpressionResourceGroup.setDescription('Expression definition resource management.')
dismanExpressionDefinitionGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 90, 3, 2, 2)).setObjects(("DISMAN-EXPRESSION-MIB", "expExpression"), ("DISMAN-EXPRESSION-MIB", "expExpressionValueType"), ("DISMAN-EXPRESSION-MIB", "expExpressionComment"), ("DISMAN-EXPRESSION-MIB", "expExpressionDeltaInterval"), ("DISMAN-EXPRESSION-MIB", "expExpressionPrefix"), ("DISMAN-EXPRESSION-MIB", "expExpressionErrors"), ("DISMAN-EXPRESSION-MIB", "expExpressionEntryStatus"), ("DISMAN-EXPRESSION-MIB", "expErrorTime"), ("DISMAN-EXPRESSION-MIB", "expErrorIndex"), ("DISMAN-EXPRESSION-MIB", "expErrorCode"), ("DISMAN-EXPRESSION-MIB", "expErrorInstance"), ("DISMAN-EXPRESSION-MIB", "expObjectID"), ("DISMAN-EXPRESSION-MIB", "expObjectIDWildcard"), ("DISMAN-EXPRESSION-MIB", "expObjectSampleType"), ("DISMAN-EXPRESSION-MIB", "expObjectDeltaDiscontinuityID"), ("DISMAN-EXPRESSION-MIB", "expObjectDiscontinuityIDWildcard"), ("DISMAN-EXPRESSION-MIB", "expObjectDiscontinuityIDType"), ("DISMAN-EXPRESSION-MIB", "expObjectConditional"), ("DISMAN-EXPRESSION-MIB", "expObjectConditionalWildcard"), ("DISMAN-EXPRESSION-MIB", "expObjectEntryStatus"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
dismanExpressionDefinitionGroup = dismanExpressionDefinitionGroup.setStatus('current')
if mibBuilder.loadTexts: dismanExpressionDefinitionGroup.setDescription('Expression definition.')
dismanExpressionValueGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 90, 3, 2, 3)).setObjects(("DISMAN-EXPRESSION-MIB", "expValueCounter32Val"), ("DISMAN-EXPRESSION-MIB", "expValueUnsigned32Val"), ("DISMAN-EXPRESSION-MIB", "expValueTimeTicksVal"), ("DISMAN-EXPRESSION-MIB", "expValueInteger32Val"), ("DISMAN-EXPRESSION-MIB", "expValueIpAddressVal"), ("DISMAN-EXPRESSION-MIB", "expValueOctetStringVal"), ("DISMAN-EXPRESSION-MIB", "expValueOidVal"), ("DISMAN-EXPRESSION-MIB", "expValueCounter64Val"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
dismanExpressionValueGroup = dismanExpressionValueGroup.setStatus('current')
if mibBuilder.loadTexts: dismanExpressionValueGroup.setDescription('Expression value.')
mibBuilder.exportSymbols("DISMAN-EXPRESSION-MIB", expErrorTime=expErrorTime, expObjectConditional=expObjectConditional, expValueIpAddressVal=expValueIpAddressVal, expExpressionValueType=expExpressionValueType, expValueOctetStringVal=expValueOctetStringVal, expExpression=expExpression, expValueInteger32Val=expValueInteger32Val, expObjectSampleType=expObjectSampleType, expObjectConditionalWildcard=expObjectConditionalWildcard, expExpressionTable=expExpressionTable, expObjectTable=expObjectTable, expErrorTable=expErrorTable, expObjectID=expObjectID, expObjectDiscontinuityIDWildcard=expObjectDiscontinuityIDWildcard, dismanExpressionDefinitionGroup=dismanExpressionDefinitionGroup, expValue=expValue, expExpressionEntry=expExpressionEntry, expValueTimeTicksVal=expValueTimeTicksVal, expValueEntry=expValueEntry, dismanExpressionResourceGroup=dismanExpressionResourceGroup, dismanExpressionMIBGroups=dismanExpressionMIBGroups, expErrorInstance=expErrorInstance, expValueOidVal=expValueOidVal, expExpressionErrors=expExpressionErrors, expResourceDeltaWildcardInstanceResourceLacks=expResourceDeltaWildcardInstanceResourceLacks, expObjectDiscontinuityIDType=expObjectDiscontinuityIDType, expObjectEntryStatus=expObjectEntryStatus, expErrorIndex=expErrorIndex, expObjectIndex=expObjectIndex, dismanExpressionValueGroup=dismanExpressionValueGroup, dismanExpressionMIBObjects=dismanExpressionMIBObjects, expDefine=expDefine, expObjectDeltaDiscontinuityID=expObjectDeltaDiscontinuityID, expValueInstance=expValueInstance, PYSNMP_MODULE_ID=dismanExpressionMIB, expResource=expResource, expExpressionOwner=expExpressionOwner, expErrorEntry=expErrorEntry, expValueCounter64Val=expValueCounter64Val, expResourceDeltaWildcardInstanceMaximum=expResourceDeltaWildcardInstanceMaximum, expResourceDeltaMinimum=expResourceDeltaMinimum, expExpressionName=expExpressionName, expErrorCode=expErrorCode, expObjectIDWildcard=expObjectIDWildcard, expValueUnsigned32Val=expValueUnsigned32Val, dismanExpressionMIBCompliance=dismanExpressionMIBCompliance, expValueCounter32Val=expValueCounter32Val, dismanExpressionMIB=dismanExpressionMIB, expResourceDeltaWildcardInstancesHigh=expResourceDeltaWildcardInstancesHigh, dismanExpressionMIBCompliances=dismanExpressionMIBCompliances, sysUpTimeInstance=sysUpTimeInstance, expExpressionComment=expExpressionComment, expExpressionEntryStatus=expExpressionEntryStatus, expExpressionPrefix=expExpressionPrefix, expResourceDeltaWildcardInstances=expResourceDeltaWildcardInstances, expExpressionDeltaInterval=expExpressionDeltaInterval, dismanExpressionMIBConformance=dismanExpressionMIBConformance, expObjectEntry=expObjectEntry, expValueTable=expValueTable)
| (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, constraints_intersection, value_range_constraint, single_value_constraint, value_size_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsUnion', 'ConstraintsIntersection', 'ValueRangeConstraint', 'SingleValueConstraint', 'ValueSizeConstraint')
(snmp_admin_string,) = mibBuilder.importSymbols('SNMP-FRAMEWORK-MIB', 'SnmpAdminString')
(object_group, notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'ObjectGroup', 'NotificationGroup', 'ModuleCompliance')
(sys_up_time,) = mibBuilder.importSymbols('SNMPv2-MIB', 'sysUpTime')
(mib_scalar, mib_table, mib_table_row, mib_table_column, integer32, unsigned32, mib_2, zero_dot_zero, ip_address, notification_type, mib_identifier, module_identity, gauge32, bits, counter32, time_ticks, iso, counter64, object_identity) = mibBuilder.importSymbols('SNMPv2-SMI', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Integer32', 'Unsigned32', 'mib-2', 'zeroDotZero', 'IpAddress', 'NotificationType', 'MibIdentifier', 'ModuleIdentity', 'Gauge32', 'Bits', 'Counter32', 'TimeTicks', 'iso', 'Counter64', 'ObjectIdentity')
(display_string, truth_value, row_status, textual_convention, time_stamp) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TruthValue', 'RowStatus', 'TextualConvention', 'TimeStamp')
disman_expression_mib = module_identity((1, 3, 6, 1, 2, 1, 90))
dismanExpressionMIB.setRevisions(('2000-10-16 00:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts:
dismanExpressionMIB.setRevisionsDescriptions(('This is the initial version of this MIB. Published as RFC 2982',))
if mibBuilder.loadTexts:
dismanExpressionMIB.setLastUpdated('200010160000Z')
if mibBuilder.loadTexts:
dismanExpressionMIB.setOrganization('IETF Distributed Management Working Group')
if mibBuilder.loadTexts:
dismanExpressionMIB.setContactInfo('Ramanathan Kavasseri Cisco Systems, Inc. 170 West Tasman Drive, San Jose CA 95134-1706. Phone: +1 408 527 2446 Email: ramk@cisco.com')
if mibBuilder.loadTexts:
dismanExpressionMIB.setDescription('The MIB module for defining expressions of MIB objects for management purposes.')
disman_expression_mib_objects = mib_identifier((1, 3, 6, 1, 2, 1, 90, 1))
exp_resource = mib_identifier((1, 3, 6, 1, 2, 1, 90, 1, 1))
exp_define = mib_identifier((1, 3, 6, 1, 2, 1, 90, 1, 2))
exp_value = mib_identifier((1, 3, 6, 1, 2, 1, 90, 1, 3))
exp_resource_delta_minimum = mib_scalar((1, 3, 6, 1, 2, 1, 90, 1, 1, 1), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(1, 600)))).setUnits('seconds').setMaxAccess('readwrite')
if mibBuilder.loadTexts:
expResourceDeltaMinimum.setStatus('current')
if mibBuilder.loadTexts:
expResourceDeltaMinimum.setDescription("The minimum expExpressionDeltaInterval this system will accept. A system may use the larger values of this minimum to lessen the impact of constantly computing deltas. For larger delta sampling intervals the system samples less often and suffers less overhead. This object provides a way to enforce such lower overhead for all expressions created after it is set. The value -1 indicates that expResourceDeltaMinimum is irrelevant as the system will not accept 'deltaValue' as a value for expObjectSampleType. Unless explicitly resource limited, a system's value for this object should be 1, allowing as small as a 1 second interval for ongoing delta sampling. Changing this value will not invalidate an existing setting of expObjectSampleType.")
exp_resource_delta_wildcard_instance_maximum = mib_scalar((1, 3, 6, 1, 2, 1, 90, 1, 1, 2), unsigned32()).setUnits('instances').setMaxAccess('readwrite')
if mibBuilder.loadTexts:
expResourceDeltaWildcardInstanceMaximum.setStatus('current')
if mibBuilder.loadTexts:
expResourceDeltaWildcardInstanceMaximum.setDescription("For every instance of a deltaValue object, one dynamic instance entry is needed for holding the instance value from the previous sample, i.e. to maintain state. This object limits maximum number of dynamic instance entries this system will support for wildcarded delta objects in expressions. For a given delta expression, the number of dynamic instances is the number of values that meet all criteria to exist times the number of delta values in the expression. A value of 0 indicates no preset limit, that is, the limit is dynamic based on system operation and resources. Unless explicitly resource limited, a system's value for this object should be 0. Changing this value will not eliminate or inhibit existing delta wildcard instance objects but will prevent the creation of more such objects. An attempt to allocate beyond the limit results in expErrorCode being tooManyWildcardValues for that evaluation attempt.")
exp_resource_delta_wildcard_instances = mib_scalar((1, 3, 6, 1, 2, 1, 90, 1, 1, 3), gauge32()).setUnits('instances').setMaxAccess('readonly')
if mibBuilder.loadTexts:
expResourceDeltaWildcardInstances.setStatus('current')
if mibBuilder.loadTexts:
expResourceDeltaWildcardInstances.setDescription('The number of currently active instance entries as defined for expResourceDeltaWildcardInstanceMaximum.')
exp_resource_delta_wildcard_instances_high = mib_scalar((1, 3, 6, 1, 2, 1, 90, 1, 1, 4), gauge32()).setUnits('instances').setMaxAccess('readonly')
if mibBuilder.loadTexts:
expResourceDeltaWildcardInstancesHigh.setStatus('current')
if mibBuilder.loadTexts:
expResourceDeltaWildcardInstancesHigh.setDescription('The highest value of expResourceDeltaWildcardInstances that has occurred since initialization of the managed system.')
exp_resource_delta_wildcard_instance_resource_lacks = mib_scalar((1, 3, 6, 1, 2, 1, 90, 1, 1, 5), counter32()).setUnits('instances').setMaxAccess('readonly')
if mibBuilder.loadTexts:
expResourceDeltaWildcardInstanceResourceLacks.setStatus('current')
if mibBuilder.loadTexts:
expResourceDeltaWildcardInstanceResourceLacks.setDescription('The number of times this system could not evaluate an expression because that would have created a value instance in excess of expResourceDeltaWildcardInstanceMaximum.')
exp_expression_table = mib_table((1, 3, 6, 1, 2, 1, 90, 1, 2, 1))
if mibBuilder.loadTexts:
expExpressionTable.setStatus('current')
if mibBuilder.loadTexts:
expExpressionTable.setDescription('A table of expression definitions.')
exp_expression_entry = mib_table_row((1, 3, 6, 1, 2, 1, 90, 1, 2, 1, 1)).setIndexNames((0, 'DISMAN-EXPRESSION-MIB', 'expExpressionOwner'), (0, 'DISMAN-EXPRESSION-MIB', 'expExpressionName'))
if mibBuilder.loadTexts:
expExpressionEntry.setStatus('current')
if mibBuilder.loadTexts:
expExpressionEntry.setDescription("Information about a single expression. New expressions can be created using expExpressionRowStatus. To create an expression first create the named entry in this table. Then use expExpressionName to populate expObjectTable. For expression evaluation to succeed all related entries in expExpressionTable and expObjectTable must be 'active'. If these conditions are not met the corresponding values in expValue simply are not instantiated. Deleting an entry deletes all related entries in expObjectTable and expErrorTable. Because of the relationships among the multiple tables for an expression (expExpressionTable, expObjectTable, and expValueTable) and the SNMP rules for independence in setting object values, it is necessary to do final error checking when an expression is evaluated, that is, when one of its instances in expValueTable is read or a delta interval expires. Earlier checking need not be done and an implementation may not impose any ordering on the creation of objects related to an expression. To maintain security of MIB information, when creating a new row in this table, the managed system must record the security credentials of the requester. These security credentials are the parameters necessary as inputs to isAccessAllowed from the Architecture for Describing SNMP Management Frameworks. When obtaining the objects that make up the expression, the system must (conceptually) use isAccessAllowed to ensure that it does not violate security. The evaluation of the expression takes place under the security credentials of the creator of its expExpressionEntry. Values of read-write objects in this table may be changed at any time.")
exp_expression_owner = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 1, 1, 1), snmp_admin_string().subtype(subtypeSpec=value_size_constraint(0, 32)))
if mibBuilder.loadTexts:
expExpressionOwner.setStatus('current')
if mibBuilder.loadTexts:
expExpressionOwner.setDescription('The owner of this entry. The exact semantics of this string are subject to the security policy defined by the security administrator.')
exp_expression_name = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 1, 1, 2), snmp_admin_string().subtype(subtypeSpec=value_size_constraint(1, 32)))
if mibBuilder.loadTexts:
expExpressionName.setStatus('current')
if mibBuilder.loadTexts:
expExpressionName.setDescription('The name of the expression. This is locally unique, within the scope of an expExpressionOwner.')
exp_expression = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 1, 1, 3), octet_string().subtype(subtypeSpec=value_size_constraint(1, 1024))).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
expExpression.setStatus('current')
if mibBuilder.loadTexts:
expExpression.setDescription("The expression to be evaluated. This object is the same as a DisplayString (RFC 1903) except for its maximum length. Except for the variable names the expression is in ANSI C syntax. Only the subset of ANSI C operators and functions listed here is allowed. Variables are expressed as a dollar sign ('$') and an integer that corresponds to an expObjectIndex. An example of a valid expression is: ($1-$5)*100 Expressions must not be recursive, that is although an expression may use the results of another expression, it must not contain any variable that is directly or indirectly a result of its own evaluation. The managed system must check for recursive expressions. The only allowed operators are: ( ) - (unary) + - * / % & | ^ << >> ~ ! && || == != > >= < <= Note the parentheses are included for parenthesizing the expression, not for casting data types. The only constant types defined are: int (32-bit signed) long (64-bit signed) unsigned int unsigned long hexadecimal character string oid The default type for a positive integer is int unless it is too large in which case it is long. All but oid are as defined for ANSI C. Note that a hexadecimal constant may end up as a scalar or an array of 8-bit integers. A string constant is enclosed in double quotes and may contain back-slashed individual characters as in ANSI C. An oid constant comprises 32-bit, unsigned integers and at least one period, for example: 0. .0 1.3.6.1 No additional leading or trailing subidentifiers are automatically added to an OID constant. The constant is taken as expressed. Integer-typed objects are treated as 32- or 64-bit, signed or unsigned integers, as appropriate. The results of mixing them are as for ANSI C, including the type of the result. Note that a 32-bit value is thus promoted to 64 bits only in an operation with a 64-bit value. There is no provision for larger values to handle overflow. Relative to SNMP data types, a resulting value becomes unsigned when calculating it uses any unsigned value, including a counter. To force the final value to be of data type counter the expression must explicitly use the counter32() or counter64() function (defined below). OCTET STRINGS and OBJECT IDENTIFIERs are treated as one-dimensioned arrays of unsigned 8-bit integers and unsigned 32-bit integers, respectively. IpAddresses are treated as 32-bit, unsigned integers in network byte order, that is, the hex version of 255.0.0.0 is 0xff000000. Conditional expressions result in a 32-bit, unsigned integer of value 0 for false or 1 for true. When an arbitrary value is used as a boolean 0 is false and non-zero is true. Rules for the resulting data type from an operation, based on the operator: For << and >> the result is the same as the left hand operand. For &&, ||, ==, !=, <, <=, >, and >= the result is always Unsigned32. For unary - the result is always Integer32. For +, -, *, /, %, &, |, and ^ the result is promoted according to the following rules, in order from most to least preferred: If left hand and right hand operands are the same type, use that. If either side is Counter64, use that. If either side is IpAddress, use that. If either side is TimeTicks, use that. If either side is Counter32, use that. Otherwise use Unsigned32. The following rules say what operators apply with what data types. Any combination not explicitly defined does not work. For all operators any of the following can be the left hand or right hand operand: Integer32, Counter32, Unsigned32, Counter64. The operators +, -, *, /, %, <, <=, >, and >= work with TimeTicks. The operators &, |, and ^ work with IpAddress. The operators << and >> work with IpAddress but only as the left hand operand. The + operator performs a concatenation of two OCTET STRINGs or two OBJECT IDENTIFIERs. The operators &, | perform bitwise operations on OCTET STRINGs. If the OCTET STRING happens to be a DisplayString the results may be meaningless, but the agent system does not check this as some such systems do not have this information. The operators << and >> perform bitwise operations on OCTET STRINGs appearing as the left hand operand. The only functions defined are: counter32 counter64 arraySection stringBegins stringEnds stringContains oidBegins oidEnds oidContains average maximum minimum sum exists The following function definitions indicate their parameters by naming the data type of the parameter in the parameter's position in the parameter list. The parameter must be of the type indicated and generally may be a constant, a MIB object, a function, or an expression. counter32(integer) - wrapped around an integer value counter32 forces Counter32 as a data type. counter64(integer) - similar to counter32 except that the resulting data type is 'counter64'. arraySection(array, integer, integer) - selects a piece of an array (i.e. part of an OCTET STRING or OBJECT IDENTIFIER). The integer arguments are in the range 0 to 4,294,967,295. The first is an initial array index (one-dimensioned) and the second is an ending array index. A value of 0 indicates first or last element, respectively. If the first element is larger than the array length the result is 0 length. If the second integer is less than or equal to the first, the result is 0 length. If the second is larger than the array length it indicates last element. stringBegins/Ends/Contains(octetString, octetString) - looks for the second string (which can be a string constant) in the first and returns the one-dimensioned arrayindex where the match began. A return value of 0 indicates no match (i.e. boolean false). oidBegins/Ends/Contains(oid, oid) - looks for the second OID (which can be an OID constant) in the first and returns the the one-dimensioned index where the match began. A return value of 0 indicates no match (i.e. boolean false). average/maximum/minimum(integer) - calculates the average, minimum, or maximum value of the integer valued object over multiple sample times. If the object disappears for any sample period, the accumulation and the resulting value object cease to exist until the object reappears at which point the calculation starts over. sum(integerObject*) - sums all available values of the wildcarded integer object, resulting in an integer scalar. Must be used with caution as it wraps on overflow with no notification. exists(anyTypeObject) - verifies the object instance exists. A return value of 0 indicates NoSuchInstance (i.e. boolean false).")
exp_expression_value_type = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 1, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8))).clone(namedValues=named_values(('counter32', 1), ('unsigned32', 2), ('timeTicks', 3), ('integer32', 4), ('ipAddress', 5), ('octetString', 6), ('objectId', 7), ('counter64', 8))).clone('counter32')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
expExpressionValueType.setStatus('current')
if mibBuilder.loadTexts:
expExpressionValueType.setDescription('The type of the expression value. One and only one of the value objects in expValueTable will be instantiated to match this type. If the result of the expression can not be made into this type, an invalidOperandType error will occur.')
exp_expression_comment = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 1, 1, 5), snmp_admin_string().clone(hexValue='')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
expExpressionComment.setStatus('current')
if mibBuilder.loadTexts:
expExpressionComment.setDescription('A comment to explain the use or meaning of the expression.')
exp_expression_delta_interval = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 1, 1, 6), integer32().subtype(subtypeSpec=value_range_constraint(0, 86400))).setUnits('seconds').setMaxAccess('readcreate')
if mibBuilder.loadTexts:
expExpressionDeltaInterval.setStatus('current')
if mibBuilder.loadTexts:
expExpressionDeltaInterval.setDescription("Sampling interval for objects in this expression with expObjectSampleType 'deltaValue'. This object has no effect if the the expression has no deltaValue objects. A value of 0 indicates no automated sampling. In this case the delta is the difference from the last time the expression was evaluated. Note that this is subject to unpredictable delta times in the face of retries or multiple managers. A value greater than zero is the number of seconds between automated samples. Until the delta interval has expired once the delta for the object is effectively not instantiated and evaluating the expression has results as if the object itself were not instantiated. Note that delta values potentially consume large amounts of system CPU and memory. Delta state and processing must continue constantly even if the expression is not being used. That is, the expression is being evaluated every delta interval, even if no application is reading those values. For wildcarded objects this can be substantial overhead. Note that delta intervals, external expression value sampling intervals and delta intervals for expressions within other expressions can have unusual interactions as they are impossible to synchronize accurately. In general one interval embedded below another must be enough shorter that the higher sample sees relatively smooth, predictable behavior. So, for example, to avoid the higher level getting the same sample twice, the lower level should sample at least twice as fast as the higher level does.")
exp_expression_prefix = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 1, 1, 7), object_identifier()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
expExpressionPrefix.setStatus('current')
if mibBuilder.loadTexts:
expExpressionPrefix.setDescription('An object prefix to assist an application in determining the instance indexing to use in expValueTable, relieving the application of the need to scan the expObjectTable to determine such a prefix. See expObjectTable for information on wildcarded objects. If the expValueInstance portion of the value OID may be treated as a scalar (that is, normally, 0) the value of expExpressionPrefix is zero length, that is, no OID at all. Note that zero length implies a null OID, not the OID 0.0. Otherwise, the value of expExpressionPrefix is the expObjectID value of any one of the wildcarded objects for the expression. This is sufficient, as the remainder, that is, the instance fragment relevant to instancing the values, must be the same for all wildcarded objects in the expression.')
exp_expression_errors = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 1, 1, 8), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
expExpressionErrors.setStatus('current')
if mibBuilder.loadTexts:
expExpressionErrors.setDescription('The number of errors encountered while evaluating this expression. Note that an object in the expression not being accessible, is not considered an error. An example of an inaccessible object is when the object is excluded from the view of the user whose security credentials are used in the expression evaluation. In such cases, it is a legitimate condition that causes the corresponding expression value not to be instantiated.')
exp_expression_entry_status = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 1, 1, 9), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
expExpressionEntryStatus.setStatus('current')
if mibBuilder.loadTexts:
expExpressionEntryStatus.setDescription('The control that allows creation and deletion of entries.')
exp_error_table = mib_table((1, 3, 6, 1, 2, 1, 90, 1, 2, 2))
if mibBuilder.loadTexts:
expErrorTable.setStatus('current')
if mibBuilder.loadTexts:
expErrorTable.setDescription('A table of expression errors.')
exp_error_entry = mib_table_row((1, 3, 6, 1, 2, 1, 90, 1, 2, 2, 1)).setIndexNames((0, 'DISMAN-EXPRESSION-MIB', 'expExpressionOwner'), (0, 'DISMAN-EXPRESSION-MIB', 'expExpressionName'))
if mibBuilder.loadTexts:
expErrorEntry.setStatus('current')
if mibBuilder.loadTexts:
expErrorEntry.setDescription('Information about errors in processing an expression. Entries appear in this table only when there is a matching expExpressionEntry and then only when there has been an error for that expression as reflected by the error codes defined for expErrorCode.')
exp_error_time = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 2, 1, 1), time_stamp()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
expErrorTime.setStatus('current')
if mibBuilder.loadTexts:
expErrorTime.setDescription('The value of sysUpTime the last time an error caused a failure to evaluate this expression.')
exp_error_index = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 2, 1, 2), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
expErrorIndex.setStatus('current')
if mibBuilder.loadTexts:
expErrorIndex.setDescription('The one-dimensioned character array index into expExpression for where the error occurred. The value zero indicates irrelevance.')
exp_error_code = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 2, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11))).clone(namedValues=named_values(('invalidSyntax', 1), ('undefinedObjectIndex', 2), ('unrecognizedOperator', 3), ('unrecognizedFunction', 4), ('invalidOperandType', 5), ('unmatchedParenthesis', 6), ('tooManyWildcardValues', 7), ('recursion', 8), ('deltaTooShort', 9), ('resourceUnavailable', 10), ('divideByZero', 11)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
expErrorCode.setStatus('current')
if mibBuilder.loadTexts:
expErrorCode.setDescription("The error that occurred. In the following explanations the expected timing of the error is in parentheses. 'S' means the error occurs on a Set request. 'E' means the error occurs on the attempt to evaluate the expression either due to Get from expValueTable or in ongoing delta processing. invalidSyntax the value sent for expExpression is not valid Expression MIB expression syntax (S) undefinedObjectIndex an object reference ($n) in expExpression does not have a matching instance in expObjectTable (E) unrecognizedOperator the value sent for expExpression held an unrecognized operator (S) unrecognizedFunction the value sent for expExpression held an unrecognized function name (S) invalidOperandType an operand in expExpression is not the right type for the associated operator or result (SE) unmatchedParenthesis the value sent for expExpression is not correctly parenthesized (S) tooManyWildcardValues evaluating the expression exceeded the limit set by expResourceDeltaWildcardInstanceMaximum (E) recursion through some chain of embedded expressions the expression invokes itself (E) deltaTooShort the delta for the next evaluation passed before the system could evaluate the present sample (E) resourceUnavailable some resource, typically dynamic memory, was unavailable (SE) divideByZero an attempt to divide by zero occurred (E) For the errors that occur when the attempt is made to set expExpression Set request fails with the SNMP error code 'wrongValue'. Such failures refer to the most recent failure to Set expExpression, not to the present value of expExpression which must be either unset or syntactically correct. Errors that occur during evaluation for a Get* operation return the SNMP error code 'genErr' except for 'tooManyWildcardValues' and 'resourceUnavailable' which return the SNMP error code 'resourceUnavailable'.")
exp_error_instance = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 2, 1, 4), object_identifier()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
expErrorInstance.setStatus('current')
if mibBuilder.loadTexts:
expErrorInstance.setDescription('The expValueInstance being evaluated when the error occurred. A zero-length indicates irrelevance.')
exp_object_table = mib_table((1, 3, 6, 1, 2, 1, 90, 1, 2, 3))
if mibBuilder.loadTexts:
expObjectTable.setStatus('current')
if mibBuilder.loadTexts:
expObjectTable.setDescription('A table of object definitions for each expExpression. Wildcarding instance IDs: It is legal to omit all or part of the instance portion for some or all of the objects in an expression. (See the DESCRIPTION of expObjectID for details. However, note that if more than one object in the same expression is wildcarded in this way, they all must be objects where that portion of the instance is the same. In other words, all objects may be in the same SEQUENCE or in different SEQUENCEs but with the same semantic index value (e.g., a value of ifIndex) for the wildcarded portion.')
exp_object_entry = mib_table_row((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1)).setIndexNames((0, 'DISMAN-EXPRESSION-MIB', 'expExpressionOwner'), (0, 'DISMAN-EXPRESSION-MIB', 'expExpressionName'), (0, 'DISMAN-EXPRESSION-MIB', 'expObjectIndex'))
if mibBuilder.loadTexts:
expObjectEntry.setStatus('current')
if mibBuilder.loadTexts:
expObjectEntry.setDescription('Information about an object. An application uses expObjectEntryStatus to create entries in this table while in the process of defining an expression. Values of read-create objects in this table may be changed at any time.')
exp_object_index = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1, 1), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 4294967295)))
if mibBuilder.loadTexts:
expObjectIndex.setStatus('current')
if mibBuilder.loadTexts:
expObjectIndex.setDescription("Within an expression, a unique, numeric identification for an object. Prefixed with a dollar sign ('$') this is used to reference the object in the corresponding expExpression.")
exp_object_id = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1, 2), object_identifier()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
expObjectID.setStatus('current')
if mibBuilder.loadTexts:
expObjectID.setDescription('The OBJECT IDENTIFIER (OID) of this object. The OID may be fully qualified, meaning it includes a complete instance identifier part (e.g., ifInOctets.1 or sysUpTime.0), or it may not be fully qualified, meaning it may lack all or part of the instance identifier. If the expObjectID is not fully qualified, then expObjectWildcard must be set to true(1). The value of the expression will be multiple values, as if done for a GetNext sweep of the object. An object here may itself be the result of an expression but recursion is not allowed. NOTE: The simplest implementations of this MIB may not allow wildcards.')
exp_object_id_wildcard = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1, 3), truth_value().clone('false')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
expObjectIDWildcard.setStatus('current')
if mibBuilder.loadTexts:
expObjectIDWildcard.setDescription('A true value indicates the expObjecID of this row is a wildcard object. False indicates that expObjectID is fully instanced. If all expObjectWildcard values for a given expression are FALSE, expExpressionPrefix will reflect a scalar object (i.e. will be 0.0). NOTE: The simplest implementations of this MIB may not allow wildcards.')
exp_object_sample_type = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('absoluteValue', 1), ('deltaValue', 2), ('changedValue', 3))).clone('absoluteValue')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
expObjectSampleType.setStatus('current')
if mibBuilder.loadTexts:
expObjectSampleType.setDescription("The method of sampling the selected variable. An 'absoluteValue' is simply the present value of the object. A 'deltaValue' is the present value minus the previous value, which was sampled expExpressionDeltaInterval seconds ago. This is intended primarily for use with SNMP counters, which are meaningless as an 'absoluteValue', but may be used with any integer-based value. A 'changedValue' is a boolean for whether the present value is different from the previous value. It is applicable to any data type and results in an Unsigned32 with value 1 if the object's value is changed and 0 if not. In all other respects it is as a 'deltaValue' and all statements and operation regarding delta values apply to changed values. When an expression contains both delta and absolute values the absolute values are obtained at the end of the delta period.")
sys_up_time_instance = mib_identifier((1, 3, 6, 1, 2, 1, 1, 3, 0))
exp_object_delta_discontinuity_id = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1, 5), object_identifier().clone((1, 3, 6, 1, 2, 1, 1, 3, 0))).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
expObjectDeltaDiscontinuityID.setStatus('current')
if mibBuilder.loadTexts:
expObjectDeltaDiscontinuityID.setDescription("The OBJECT IDENTIFIER (OID) of a TimeTicks, TimeStamp, or DateAndTime object that indicates a discontinuity in the value at expObjectID. This object is instantiated only if expObjectSampleType is 'deltaValue' or 'changedValue'. The OID may be for a leaf object (e.g. sysUpTime.0) or may be wildcarded to match expObjectID. This object supports normal checking for a discontinuity in a counter. Note that if this object does not point to sysUpTime discontinuity checking must still check sysUpTime for an overall discontinuity. If the object identified is not accessible no discontinuity check will be made.")
exp_object_discontinuity_id_wildcard = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1, 6), truth_value().clone('false')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
expObjectDiscontinuityIDWildcard.setStatus('current')
if mibBuilder.loadTexts:
expObjectDiscontinuityIDWildcard.setDescription("A true value indicates the expObjectDeltaDiscontinuityID of this row is a wildcard object. False indicates that expObjectDeltaDiscontinuityID is fully instanced. This object is instantiated only if expObjectSampleType is 'deltaValue' or 'changedValue'. NOTE: The simplest implementations of this MIB may not allow wildcards.")
exp_object_discontinuity_id_type = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('timeTicks', 1), ('timeStamp', 2), ('dateAndTime', 3))).clone('timeTicks')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
expObjectDiscontinuityIDType.setStatus('current')
if mibBuilder.loadTexts:
expObjectDiscontinuityIDType.setDescription("The value 'timeTicks' indicates the expObjectDeltaDiscontinuityID of this row is of syntax TimeTicks. The value 'timeStamp' indicates syntax TimeStamp. The value 'dateAndTime indicates syntax DateAndTime. This object is instantiated only if expObjectSampleType is 'deltaValue' or 'changedValue'.")
exp_object_conditional = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1, 8), object_identifier().clone((0, 0))).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
expObjectConditional.setStatus('current')
if mibBuilder.loadTexts:
expObjectConditional.setDescription('The OBJECT IDENTIFIER (OID) of an object that overrides whether the instance of expObjectID is to be considered usable. If the value of the object at expObjectConditional is 0 or not instantiated, the object at expObjectID is treated as if it is not instantiated. In other words, expObjectConditional is a filter that controls whether or not to use the value at expObjectID. The OID may be for a leaf object (e.g. sysObjectID.0) or may be wildcarded to match expObjectID. If expObject is wildcarded and expObjectID in the same row is not, the wild portion of expObjectConditional must match the wildcarding of the rest of the expression. If no object in the expression is wildcarded but expObjectConditional is, use the lexically first instance (if any) of expObjectConditional. If the value of expObjectConditional is 0.0 operation is as if the value pointed to by expObjectConditional is a non-zero (true) value. Note that expObjectConditional can not trivially use an object of syntax TruthValue, since the underlying value is not 0 or 1.')
exp_object_conditional_wildcard = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1, 9), truth_value().clone('false')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
expObjectConditionalWildcard.setStatus('current')
if mibBuilder.loadTexts:
expObjectConditionalWildcard.setDescription('A true value indicates the expObjectConditional of this row is a wildcard object. False indicates that expObjectConditional is fully instanced. NOTE: The simplest implementations of this MIB may not allow wildcards.')
exp_object_entry_status = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 2, 3, 1, 10), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
expObjectEntryStatus.setStatus('current')
if mibBuilder.loadTexts:
expObjectEntryStatus.setDescription('The control that allows creation/deletion of entries. Objects in this table may be changed while expObjectEntryStatus is in any state.')
exp_value_table = mib_table((1, 3, 6, 1, 2, 1, 90, 1, 3, 1))
if mibBuilder.loadTexts:
expValueTable.setStatus('current')
if mibBuilder.loadTexts:
expValueTable.setDescription('A table of values from evaluated expressions.')
exp_value_entry = mib_table_row((1, 3, 6, 1, 2, 1, 90, 1, 3, 1, 1)).setIndexNames((0, 'DISMAN-EXPRESSION-MIB', 'expExpressionOwner'), (0, 'DISMAN-EXPRESSION-MIB', 'expExpressionName'), (1, 'DISMAN-EXPRESSION-MIB', 'expValueInstance'))
if mibBuilder.loadTexts:
expValueEntry.setStatus('current')
if mibBuilder.loadTexts:
expValueEntry.setDescription("A single value from an evaluated expression. For a given instance, only one 'Val' object in the conceptual row will be instantiated, that is, the one with the appropriate type for the value. For values that contain no objects of expObjectSampleType 'deltaValue' or 'changedValue', reading a value from the table causes the evaluation of the expression for that value. For those that contain a 'deltaValue' or 'changedValue' the value read is as of the last sampling interval. If in the attempt to evaluate the expression one or more of the necessary objects is not available, the corresponding entry in this table is effectively not instantiated. To maintain security of MIB information, when creating a new row in this table, the managed system must record the security credentials of the requester. These security credentials are the parameters necessary as inputs to isAccessAllowed from [RFC2571]. When obtaining the objects that make up the expression, the system must (conceptually) use isAccessAllowed to ensure that it does not violate security. The evaluation of that expression takes place under the security credentials of the creator of its expExpressionEntry. To maintain security of MIB information, expression evaluation must take place using security credentials for the implied Gets of the objects in the expression as inputs (conceptually) to isAccessAllowed from the Architecture for Describing SNMP Management Frameworks. These are the security credentials of the creator of the corresponding expExpressionEntry.")
exp_value_instance = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 3, 1, 1, 1), object_identifier())
if mibBuilder.loadTexts:
expValueInstance.setStatus('current')
if mibBuilder.loadTexts:
expValueInstance.setDescription("The final instance portion of a value's OID according to the wildcarding in instances of expObjectID for the expression. The prefix of this OID fragment is 0.0, leading to the following behavior. If there is no wildcarding, the value is 0.0.0. In other words, there is one value which standing alone would have been a scalar with a 0 at the end of its OID. If there is wildcarding, the value is 0.0 followed by a value that the wildcard can take, thus defining one value instance for each real, possible value of the wildcard. So, for example, if the wildcard worked out to be an ifIndex, there is an expValueInstance for each applicable ifIndex.")
exp_value_counter32_val = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 3, 1, 1, 2), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
expValueCounter32Val.setStatus('current')
if mibBuilder.loadTexts:
expValueCounter32Val.setDescription("The value when expExpressionValueType is 'counter32'.")
exp_value_unsigned32_val = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 3, 1, 1, 3), unsigned32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
expValueUnsigned32Val.setStatus('current')
if mibBuilder.loadTexts:
expValueUnsigned32Val.setDescription("The value when expExpressionValueType is 'unsigned32'.")
exp_value_time_ticks_val = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 3, 1, 1, 4), time_ticks()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
expValueTimeTicksVal.setStatus('current')
if mibBuilder.loadTexts:
expValueTimeTicksVal.setDescription("The value when expExpressionValueType is 'timeTicks'.")
exp_value_integer32_val = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 3, 1, 1, 5), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
expValueInteger32Val.setStatus('current')
if mibBuilder.loadTexts:
expValueInteger32Val.setDescription("The value when expExpressionValueType is 'integer32'.")
exp_value_ip_address_val = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 3, 1, 1, 6), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
expValueIpAddressVal.setStatus('current')
if mibBuilder.loadTexts:
expValueIpAddressVal.setDescription("The value when expExpressionValueType is 'ipAddress'.")
exp_value_octet_string_val = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 3, 1, 1, 7), octet_string().subtype(subtypeSpec=value_size_constraint(0, 65536))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
expValueOctetStringVal.setStatus('current')
if mibBuilder.loadTexts:
expValueOctetStringVal.setDescription("The value when expExpressionValueType is 'octetString'.")
exp_value_oid_val = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 3, 1, 1, 8), object_identifier()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
expValueOidVal.setStatus('current')
if mibBuilder.loadTexts:
expValueOidVal.setDescription("The value when expExpressionValueType is 'objectId'.")
exp_value_counter64_val = mib_table_column((1, 3, 6, 1, 2, 1, 90, 1, 3, 1, 1, 9), counter64()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
expValueCounter64Val.setStatus('current')
if mibBuilder.loadTexts:
expValueCounter64Val.setDescription("The value when expExpressionValueType is 'counter64'.")
disman_expression_mib_conformance = mib_identifier((1, 3, 6, 1, 2, 1, 90, 3))
disman_expression_mib_compliances = mib_identifier((1, 3, 6, 1, 2, 1, 90, 3, 1))
disman_expression_mib_groups = mib_identifier((1, 3, 6, 1, 2, 1, 90, 3, 2))
disman_expression_mib_compliance = module_compliance((1, 3, 6, 1, 2, 1, 90, 3, 1, 1)).setObjects(('DISMAN-EXPRESSION-MIB', 'dismanExpressionResourceGroup'), ('DISMAN-EXPRESSION-MIB', 'dismanExpressionDefinitionGroup'), ('DISMAN-EXPRESSION-MIB', 'dismanExpressionValueGroup'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
disman_expression_mib_compliance = dismanExpressionMIBCompliance.setStatus('current')
if mibBuilder.loadTexts:
dismanExpressionMIBCompliance.setDescription('The compliance statement for entities which implement the Expression MIB.')
disman_expression_resource_group = object_group((1, 3, 6, 1, 2, 1, 90, 3, 2, 1)).setObjects(('DISMAN-EXPRESSION-MIB', 'expResourceDeltaMinimum'), ('DISMAN-EXPRESSION-MIB', 'expResourceDeltaWildcardInstanceMaximum'), ('DISMAN-EXPRESSION-MIB', 'expResourceDeltaWildcardInstances'), ('DISMAN-EXPRESSION-MIB', 'expResourceDeltaWildcardInstancesHigh'), ('DISMAN-EXPRESSION-MIB', 'expResourceDeltaWildcardInstanceResourceLacks'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
disman_expression_resource_group = dismanExpressionResourceGroup.setStatus('current')
if mibBuilder.loadTexts:
dismanExpressionResourceGroup.setDescription('Expression definition resource management.')
disman_expression_definition_group = object_group((1, 3, 6, 1, 2, 1, 90, 3, 2, 2)).setObjects(('DISMAN-EXPRESSION-MIB', 'expExpression'), ('DISMAN-EXPRESSION-MIB', 'expExpressionValueType'), ('DISMAN-EXPRESSION-MIB', 'expExpressionComment'), ('DISMAN-EXPRESSION-MIB', 'expExpressionDeltaInterval'), ('DISMAN-EXPRESSION-MIB', 'expExpressionPrefix'), ('DISMAN-EXPRESSION-MIB', 'expExpressionErrors'), ('DISMAN-EXPRESSION-MIB', 'expExpressionEntryStatus'), ('DISMAN-EXPRESSION-MIB', 'expErrorTime'), ('DISMAN-EXPRESSION-MIB', 'expErrorIndex'), ('DISMAN-EXPRESSION-MIB', 'expErrorCode'), ('DISMAN-EXPRESSION-MIB', 'expErrorInstance'), ('DISMAN-EXPRESSION-MIB', 'expObjectID'), ('DISMAN-EXPRESSION-MIB', 'expObjectIDWildcard'), ('DISMAN-EXPRESSION-MIB', 'expObjectSampleType'), ('DISMAN-EXPRESSION-MIB', 'expObjectDeltaDiscontinuityID'), ('DISMAN-EXPRESSION-MIB', 'expObjectDiscontinuityIDWildcard'), ('DISMAN-EXPRESSION-MIB', 'expObjectDiscontinuityIDType'), ('DISMAN-EXPRESSION-MIB', 'expObjectConditional'), ('DISMAN-EXPRESSION-MIB', 'expObjectConditionalWildcard'), ('DISMAN-EXPRESSION-MIB', 'expObjectEntryStatus'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
disman_expression_definition_group = dismanExpressionDefinitionGroup.setStatus('current')
if mibBuilder.loadTexts:
dismanExpressionDefinitionGroup.setDescription('Expression definition.')
disman_expression_value_group = object_group((1, 3, 6, 1, 2, 1, 90, 3, 2, 3)).setObjects(('DISMAN-EXPRESSION-MIB', 'expValueCounter32Val'), ('DISMAN-EXPRESSION-MIB', 'expValueUnsigned32Val'), ('DISMAN-EXPRESSION-MIB', 'expValueTimeTicksVal'), ('DISMAN-EXPRESSION-MIB', 'expValueInteger32Val'), ('DISMAN-EXPRESSION-MIB', 'expValueIpAddressVal'), ('DISMAN-EXPRESSION-MIB', 'expValueOctetStringVal'), ('DISMAN-EXPRESSION-MIB', 'expValueOidVal'), ('DISMAN-EXPRESSION-MIB', 'expValueCounter64Val'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
disman_expression_value_group = dismanExpressionValueGroup.setStatus('current')
if mibBuilder.loadTexts:
dismanExpressionValueGroup.setDescription('Expression value.')
mibBuilder.exportSymbols('DISMAN-EXPRESSION-MIB', expErrorTime=expErrorTime, expObjectConditional=expObjectConditional, expValueIpAddressVal=expValueIpAddressVal, expExpressionValueType=expExpressionValueType, expValueOctetStringVal=expValueOctetStringVal, expExpression=expExpression, expValueInteger32Val=expValueInteger32Val, expObjectSampleType=expObjectSampleType, expObjectConditionalWildcard=expObjectConditionalWildcard, expExpressionTable=expExpressionTable, expObjectTable=expObjectTable, expErrorTable=expErrorTable, expObjectID=expObjectID, expObjectDiscontinuityIDWildcard=expObjectDiscontinuityIDWildcard, dismanExpressionDefinitionGroup=dismanExpressionDefinitionGroup, expValue=expValue, expExpressionEntry=expExpressionEntry, expValueTimeTicksVal=expValueTimeTicksVal, expValueEntry=expValueEntry, dismanExpressionResourceGroup=dismanExpressionResourceGroup, dismanExpressionMIBGroups=dismanExpressionMIBGroups, expErrorInstance=expErrorInstance, expValueOidVal=expValueOidVal, expExpressionErrors=expExpressionErrors, expResourceDeltaWildcardInstanceResourceLacks=expResourceDeltaWildcardInstanceResourceLacks, expObjectDiscontinuityIDType=expObjectDiscontinuityIDType, expObjectEntryStatus=expObjectEntryStatus, expErrorIndex=expErrorIndex, expObjectIndex=expObjectIndex, dismanExpressionValueGroup=dismanExpressionValueGroup, dismanExpressionMIBObjects=dismanExpressionMIBObjects, expDefine=expDefine, expObjectDeltaDiscontinuityID=expObjectDeltaDiscontinuityID, expValueInstance=expValueInstance, PYSNMP_MODULE_ID=dismanExpressionMIB, expResource=expResource, expExpressionOwner=expExpressionOwner, expErrorEntry=expErrorEntry, expValueCounter64Val=expValueCounter64Val, expResourceDeltaWildcardInstanceMaximum=expResourceDeltaWildcardInstanceMaximum, expResourceDeltaMinimum=expResourceDeltaMinimum, expExpressionName=expExpressionName, expErrorCode=expErrorCode, expObjectIDWildcard=expObjectIDWildcard, expValueUnsigned32Val=expValueUnsigned32Val, dismanExpressionMIBCompliance=dismanExpressionMIBCompliance, expValueCounter32Val=expValueCounter32Val, dismanExpressionMIB=dismanExpressionMIB, expResourceDeltaWildcardInstancesHigh=expResourceDeltaWildcardInstancesHigh, dismanExpressionMIBCompliances=dismanExpressionMIBCompliances, sysUpTimeInstance=sysUpTimeInstance, expExpressionComment=expExpressionComment, expExpressionEntryStatus=expExpressionEntryStatus, expExpressionPrefix=expExpressionPrefix, expResourceDeltaWildcardInstances=expResourceDeltaWildcardInstances, expExpressionDeltaInterval=expExpressionDeltaInterval, dismanExpressionMIBConformance=dismanExpressionMIBConformance, expObjectEntry=expObjectEntry, expValueTable=expValueTable) |
def floatToBin(valor):
f = str(valor)
inteira, deci = f.split(".")
print(inteira, deci)
bint = bin(int(inteira))
deci = list(deci)
deci.insert(0,'.')
print(bint)
print(deci)
# inteira
print('parte inteira')
if inteira.startswith("-"):
print('negativo')
if not len(bint) == 3:
bint = list(bint[3:])
else:
bint = list('0')
bint.insert(0, "1")
bint = ''.join(bint)
else:
print('positivo')
if not len(bint) == 2:
# obs: decimais negativos sao considerados positivos
bint = list(bint[2:])
else:
bint = list('0')
bint.insert(0, "0")
bint = ''.join(bint)
bint = list (bint)
print(bint, type(bint))
# decimal
print('parte decimal')
multiplicacao = 0
deci_aux = float(''.join(deci))
bdeci = []
while not multiplicacao == 1:
multiplicacao = (deci_aux * 2)
a, b = str(multiplicacao).split(".")
bdeci.append(a)
# ajuste para decimal
b = list(b)
b.insert(0, '.')
b = str(''.join(b))
b = float(b)
deci_aux = b
print(bdeci, type(bdeci))
b = bint + bdeci
print('binario final: ', b)
return b, [bint, bdeci]
valor = 2.78125
floatToBin(valor)
| def float_to_bin(valor):
f = str(valor)
(inteira, deci) = f.split('.')
print(inteira, deci)
bint = bin(int(inteira))
deci = list(deci)
deci.insert(0, '.')
print(bint)
print(deci)
print('parte inteira')
if inteira.startswith('-'):
print('negativo')
if not len(bint) == 3:
bint = list(bint[3:])
else:
bint = list('0')
bint.insert(0, '1')
bint = ''.join(bint)
else:
print('positivo')
if not len(bint) == 2:
bint = list(bint[2:])
else:
bint = list('0')
bint.insert(0, '0')
bint = ''.join(bint)
bint = list(bint)
print(bint, type(bint))
print('parte decimal')
multiplicacao = 0
deci_aux = float(''.join(deci))
bdeci = []
while not multiplicacao == 1:
multiplicacao = deci_aux * 2
(a, b) = str(multiplicacao).split('.')
bdeci.append(a)
b = list(b)
b.insert(0, '.')
b = str(''.join(b))
b = float(b)
deci_aux = b
print(bdeci, type(bdeci))
b = bint + bdeci
print('binario final: ', b)
return (b, [bint, bdeci])
valor = 2.78125
float_to_bin(valor) |
times_dict = {
"A": 51,
"B": 23,
"C": 67,
"D": 83,
"E": 77,
}
directions = {
0: "north",
1: "west",
2: "south",
3: "east",
}
for name in times_dict:
times = times_dict[name]
circles = times // 4
direction_index = times % 4
direction = directions[direction_index]
print('%s faces %s, turns %s circles.'%(name, direction, circles))
| times_dict = {'A': 51, 'B': 23, 'C': 67, 'D': 83, 'E': 77}
directions = {0: 'north', 1: 'west', 2: 'south', 3: 'east'}
for name in times_dict:
times = times_dict[name]
circles = times // 4
direction_index = times % 4
direction = directions[direction_index]
print('%s faces %s, turns %s circles.' % (name, direction, circles)) |
def bstutil(root,min_v,max_v):
if root is None:
return True
if root.data>=min_v and root.data<max_v and bstutil(root.left,min_v,root.data) and bstutil(root.right,root.data,max_v):
return True
return False
def isBST(root):
return bstutil(root,-float("inf"),float("inf"))
| def bstutil(root, min_v, max_v):
if root is None:
return True
if root.data >= min_v and root.data < max_v and bstutil(root.left, min_v, root.data) and bstutil(root.right, root.data, max_v):
return True
return False
def is_bst(root):
return bstutil(root, -float('inf'), float('inf')) |
class Scene(object):
MAIN = None
setup = False
destroyed = False
handles = []
handleFunc = {}
def __init__(self, MainObj):
self.MAIN = MainObj
self.createHandleFunctions()
def createHandleFunctions(self):
pass
def setUp(self):
self.setup = True
def mainLoop(self):
pass
def destroy(self):
self.destroyed = True
def isSetUp(self):
return self.setup
def isDestroyed(self):
return self.destroyed
def handlesCall(self, call):
return call in self.handles
def handleCall(self, call, args):
return self.handleFunc[call](*args)
def canChangeChar(self):
return False
def canLeaveGame(self):
return False
| class Scene(object):
main = None
setup = False
destroyed = False
handles = []
handle_func = {}
def __init__(self, MainObj):
self.MAIN = MainObj
self.createHandleFunctions()
def create_handle_functions(self):
pass
def set_up(self):
self.setup = True
def main_loop(self):
pass
def destroy(self):
self.destroyed = True
def is_set_up(self):
return self.setup
def is_destroyed(self):
return self.destroyed
def handles_call(self, call):
return call in self.handles
def handle_call(self, call, args):
return self.handleFunc[call](*args)
def can_change_char(self):
return False
def can_leave_game(self):
return False |
class Solution:
def checkNeedle(self, h: str, n: str) -> bool:
if len(h) < len(n):
return False
for idx, hc in enumerate(h):
if hc != n[idx]:
return False
else:
if len(n) == idx + 1:
return True
return True
def strStr(self, haystack: str, needle: str) -> int:
if len(needle) == 0:
return 0
if len(haystack) == 0:
return -1
if len(haystack) < len(needle):
return -1
needle_idx = 0
for idx, c in enumerate(haystack):
if c == needle[needle_idx]:
if len(needle) == 1 or self.checkNeedle(haystack[idx + 1:], needle[1:]):
return idx
return -1
| class Solution:
def check_needle(self, h: str, n: str) -> bool:
if len(h) < len(n):
return False
for (idx, hc) in enumerate(h):
if hc != n[idx]:
return False
elif len(n) == idx + 1:
return True
return True
def str_str(self, haystack: str, needle: str) -> int:
if len(needle) == 0:
return 0
if len(haystack) == 0:
return -1
if len(haystack) < len(needle):
return -1
needle_idx = 0
for (idx, c) in enumerate(haystack):
if c == needle[needle_idx]:
if len(needle) == 1 or self.checkNeedle(haystack[idx + 1:], needle[1:]):
return idx
return -1 |
"""
@author: yuhao.he
@contact: <hawl.yuhao.he@gmail.com>
@version: 0.0.1
@file: __init__.py.py
@time: 2021/10/27 14:11
"""
| """
@author: yuhao.he
@contact: <hawl.yuhao.he@gmail.com>
@version: 0.0.1
@file: __init__.py.py
@time: 2021/10/27 14:11
""" |
__author__ = 'Michel Llorens'
__email__ = "mllorens@dcc.uchile.cl"
class Stack:
def __init__(self, delta):
self.stack = list()
self.DELTA = delta
return
def push(self, face):
self.stack.append(face)
return
def pop(self):
if not self.empty():
return self.stack.pop()
else:
return False
def multi_pop(self, point):
faces = list()
for face in self.stack:
if point in face:
faces.append(face)
for face in faces:
self.stack.remove(face)
return faces
def empty(self):
if len(self.stack) == 0:
return True
return False
def get_all_points(self):
all_points = list()
for face in self.stack:
all_points.extend(face.get_points())
return self.delete_duplicated_points(all_points)
def delete_duplicated_points(self, points):
final_points = list()
while len(points) != 0:
p = points.pop()
to_delete = list()
duplicated = False
for pp in points:
if (p[0] <= pp[0]+self.DELTA) & (p[0] >= pp[0]-self.DELTA):
if (p[1] <= pp[1]+self.DELTA) & (p[1] >= pp[1]-self.DELTA):
if (p[2] <= pp[2]+self.DELTA) & (p[1] >= pp[1]-self.DELTA):
duplicated = True
to_delete.append(pp)
final_points.append(p)
if duplicated:
for ptd in to_delete:
if ptd in points:
points.remove(ptd)
return final_points
def __str__(self):
string = "Stack:\n"
for f in self.stack:
string = string + str(f) + "\n"
string = string + "End Stack\n"
return string
def size(self):
return len(self.stack)
| __author__ = 'Michel Llorens'
__email__ = 'mllorens@dcc.uchile.cl'
class Stack:
def __init__(self, delta):
self.stack = list()
self.DELTA = delta
return
def push(self, face):
self.stack.append(face)
return
def pop(self):
if not self.empty():
return self.stack.pop()
else:
return False
def multi_pop(self, point):
faces = list()
for face in self.stack:
if point in face:
faces.append(face)
for face in faces:
self.stack.remove(face)
return faces
def empty(self):
if len(self.stack) == 0:
return True
return False
def get_all_points(self):
all_points = list()
for face in self.stack:
all_points.extend(face.get_points())
return self.delete_duplicated_points(all_points)
def delete_duplicated_points(self, points):
final_points = list()
while len(points) != 0:
p = points.pop()
to_delete = list()
duplicated = False
for pp in points:
if (p[0] <= pp[0] + self.DELTA) & (p[0] >= pp[0] - self.DELTA):
if (p[1] <= pp[1] + self.DELTA) & (p[1] >= pp[1] - self.DELTA):
if (p[2] <= pp[2] + self.DELTA) & (p[1] >= pp[1] - self.DELTA):
duplicated = True
to_delete.append(pp)
final_points.append(p)
if duplicated:
for ptd in to_delete:
if ptd in points:
points.remove(ptd)
return final_points
def __str__(self):
string = 'Stack:\n'
for f in self.stack:
string = string + str(f) + '\n'
string = string + 'End Stack\n'
return string
def size(self):
return len(self.stack) |
def build_chrome_options():
chrome_options = webdriver.ChromeOptions()
chrome_options.accept_untrusted_certs = True
chrome_options.assume_untrusted_cert_issuer = True
# chrome configuration
# More: https://github.com/SeleniumHQ/docker-selenium/issues/89
# And: https://github.com/SeleniumHQ/docker-selenium/issues/87
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-impl-side-painting")
chrome_options.add_argument("--disable-setuid-sandbox")
chrome_options.add_argument("--disable-seccomp-filter-sandbox")
chrome_options.add_argument("--disable-breakpad")
chrome_options.add_argument("--disable-client-side-phishing-detection")
chrome_options.add_argument("--disable-cast")
chrome_options.add_argument("--disable-cast-streaming-hw-encoding")
chrome_options.add_argument("--disable-cloud-import")
chrome_options.add_argument("--disable-popup-blocking")
chrome_options.add_argument("--ignore-certificate-errors")
chrome_options.add_argument("--disable-session-crashed-bubble")
chrome_options.add_argument("--disable-ipv6")
chrome_options.add_argument("--allow-http-screen-capture")
chrome_options.add_argument("--start-maximized")
chrome_options.add_argument(
'--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36')
return chrome_options | def build_chrome_options():
chrome_options = webdriver.ChromeOptions()
chrome_options.accept_untrusted_certs = True
chrome_options.assume_untrusted_cert_issuer = True
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-impl-side-painting')
chrome_options.add_argument('--disable-setuid-sandbox')
chrome_options.add_argument('--disable-seccomp-filter-sandbox')
chrome_options.add_argument('--disable-breakpad')
chrome_options.add_argument('--disable-client-side-phishing-detection')
chrome_options.add_argument('--disable-cast')
chrome_options.add_argument('--disable-cast-streaming-hw-encoding')
chrome_options.add_argument('--disable-cloud-import')
chrome_options.add_argument('--disable-popup-blocking')
chrome_options.add_argument('--ignore-certificate-errors')
chrome_options.add_argument('--disable-session-crashed-bubble')
chrome_options.add_argument('--disable-ipv6')
chrome_options.add_argument('--allow-http-screen-capture')
chrome_options.add_argument('--start-maximized')
chrome_options.add_argument('--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36')
return chrome_options |
myset = {1,2,3,4,5,6}
print(myset)
myset = {1,1,1,2,3,4,5,5}
print(myset)
myset = set([1,2,3,4,5,5])
myset2 = set('hello')
print(myset)
print(myset2)
myset = {}
myset2 = set()
print(type(myset))
print(type(myset2))
myset2.add(1)
print(myset2)
myset2.add(1)
print(myset2)
myset2.add(2)
print(myset2)
myset2.add(3)
myset2.add(4)
print(myset2)
myset2.remove(2)
print(myset2)
myset2 = {1,2,3,4,5,6}
# myset2.remove(8)
# print(myset2)
myset2.discard(8)
print(myset2)
print(myset2.pop())
print(myset2)
for x in myset2:
print(x)
if 1 in myset2:
print('yes')
else:
print('no')
# union & intersection
odds = {1,3,5,7}
evens = {0,2,4,6,8}
primes = {2,3,5,7}
u = odds.union(evens)
print(u)
i = odds.intersection(evens)
print(i)
j = odds.intersection(primes)
print(odds)
print(j)
h = evens.intersection(primes)
print(evens)
print(h)
setA = {1,2,3,4,5,6,7,8,9,10}
setB = {1,2,3,11,12,13}
diff = setA.difference(setB)
print(diff)
diff = setB.difference(setA)
print(diff)
diff = setB.symmetric_difference(setA)
print(diff)
diff = setA.symmetric_difference(setB)
print(diff)
setA.update(setB)
print(setA)
setA = {1,2,3,4,5,6,7,8,9,10}
setB = {1,2,3,11,12,13}
setA.intersection_update(setB)
print(setA)
setA = {1,2,3,4,5,6,7,8,9,10}
setB = {1,2,3,11,12,13}
setA.difference_update(setB)
print(setA)
setA = {1,2,3,4,5,6,7,8,9,10}
setB = {1,2,3,11,12,13}
setA.symmetric_difference_update(setB)
print(setA)
setA = {1,2,3,4,5,6}
setB = {1,2,3}
setC = {7,8}
print(setA.issubset(setB))
print(setA.issuperset(setB))
print(setA.isdisjoint(setB))
print(setA.isdisjoint(setC))
myset = {1,2,3,4,5}
myset.add(6)
myset2 = myset
print(myset)
print(myset2)
myset = {1,2,3,4,5}
myset.add(6)
myset2 = myset.copy()
print(myset)
print(myset2)
myset = {1,2,3,4,5}
myset.add(6)
myset2 = set(myset)
print(myset)
print(myset2)
a = frozenset([1,2,3,4])
## not work
# a.add()
# a.remove() | myset = {1, 2, 3, 4, 5, 6}
print(myset)
myset = {1, 1, 1, 2, 3, 4, 5, 5}
print(myset)
myset = set([1, 2, 3, 4, 5, 5])
myset2 = set('hello')
print(myset)
print(myset2)
myset = {}
myset2 = set()
print(type(myset))
print(type(myset2))
myset2.add(1)
print(myset2)
myset2.add(1)
print(myset2)
myset2.add(2)
print(myset2)
myset2.add(3)
myset2.add(4)
print(myset2)
myset2.remove(2)
print(myset2)
myset2 = {1, 2, 3, 4, 5, 6}
myset2.discard(8)
print(myset2)
print(myset2.pop())
print(myset2)
for x in myset2:
print(x)
if 1 in myset2:
print('yes')
else:
print('no')
odds = {1, 3, 5, 7}
evens = {0, 2, 4, 6, 8}
primes = {2, 3, 5, 7}
u = odds.union(evens)
print(u)
i = odds.intersection(evens)
print(i)
j = odds.intersection(primes)
print(odds)
print(j)
h = evens.intersection(primes)
print(evens)
print(h)
set_a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
set_b = {1, 2, 3, 11, 12, 13}
diff = setA.difference(setB)
print(diff)
diff = setB.difference(setA)
print(diff)
diff = setB.symmetric_difference(setA)
print(diff)
diff = setA.symmetric_difference(setB)
print(diff)
setA.update(setB)
print(setA)
set_a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
set_b = {1, 2, 3, 11, 12, 13}
setA.intersection_update(setB)
print(setA)
set_a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
set_b = {1, 2, 3, 11, 12, 13}
setA.difference_update(setB)
print(setA)
set_a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
set_b = {1, 2, 3, 11, 12, 13}
setA.symmetric_difference_update(setB)
print(setA)
set_a = {1, 2, 3, 4, 5, 6}
set_b = {1, 2, 3}
set_c = {7, 8}
print(setA.issubset(setB))
print(setA.issuperset(setB))
print(setA.isdisjoint(setB))
print(setA.isdisjoint(setC))
myset = {1, 2, 3, 4, 5}
myset.add(6)
myset2 = myset
print(myset)
print(myset2)
myset = {1, 2, 3, 4, 5}
myset.add(6)
myset2 = myset.copy()
print(myset)
print(myset2)
myset = {1, 2, 3, 4, 5}
myset.add(6)
myset2 = set(myset)
print(myset)
print(myset2)
a = frozenset([1, 2, 3, 4]) |
# Reading files
# Example 1 - Open and closing files.
nerd_file = open("nerd_names.txt")
nerd_file.close()
# Example 2 - Is the file readable?
nerd_file = open("nerd_names.txt")
print(nerd_file.readable())
nerd_file.close()
# Example 3 - Read the file, with readlines()
nerd_file = open("nerd_names.txt")
print(nerd_file.readlines())
nerd_file.close()
# Example 4 - Read the first line of a file
nerd_file = open("nerd_names.txt")
print(nerd_file.readline())
nerd_file.close()
# Example 5 - Read the first two lines
nerd_file = open("nerd_names.txt")
print(nerd_file.readline())
print(nerd_file.readline())
nerd_file.close()
# Example 6 - Read and print out hte 3rd line or item in the file
nerd_file = open("nerd_names.txt")
print(nerd_file.readlines()[2])
nerd_file.close()
# Example 7 - As is, read
nerd_file = open("nerd_names.txt")
print(nerd_file.read())
nerd_file.close()
nerd_file = open("nerd_names.txt")
# Example 8 - Read vs Readlines
# With Readlines
nerd_file = open("nerd_names.txt")
nerds = nerd_file.readlines()
nerd_file.close()
print("Example 8 - with readlines()")
print(f'Data type is: {type(nerds)}')
print(nerds)
for name in nerds:
name = name.rstrip() + " is a Nerd."
print(name)
print("----Readlines() Example Done----")
# With Read
nerd_file_read = open("nerd_names.txt")
nerds_read = nerd_file_read.read()
nerd_file_read.close()
print("Example 8 - with read()")
print(f'Data type is: {type(nerds_read)}')
print(nerds_read)
for name in nerds_read:
name = name.rstrip() + " is a Nerd."
print(name)
print("----read() Example Done----") | nerd_file = open('nerd_names.txt')
nerd_file.close()
nerd_file = open('nerd_names.txt')
print(nerd_file.readable())
nerd_file.close()
nerd_file = open('nerd_names.txt')
print(nerd_file.readlines())
nerd_file.close()
nerd_file = open('nerd_names.txt')
print(nerd_file.readline())
nerd_file.close()
nerd_file = open('nerd_names.txt')
print(nerd_file.readline())
print(nerd_file.readline())
nerd_file.close()
nerd_file = open('nerd_names.txt')
print(nerd_file.readlines()[2])
nerd_file.close()
nerd_file = open('nerd_names.txt')
print(nerd_file.read())
nerd_file.close()
nerd_file = open('nerd_names.txt')
nerd_file = open('nerd_names.txt')
nerds = nerd_file.readlines()
nerd_file.close()
print('Example 8 - with readlines()')
print(f'Data type is: {type(nerds)}')
print(nerds)
for name in nerds:
name = name.rstrip() + ' is a Nerd.'
print(name)
print('----Readlines() Example Done----')
nerd_file_read = open('nerd_names.txt')
nerds_read = nerd_file_read.read()
nerd_file_read.close()
print('Example 8 - with read()')
print(f'Data type is: {type(nerds_read)}')
print(nerds_read)
for name in nerds_read:
name = name.rstrip() + ' is a Nerd.'
print(name)
print('----read() Example Done----') |
# creates or updates a file with the given text
def write_file(file_path,text_to_write):
with open(file_path,'w') as f:
f.write(text_to_write)
return
| def write_file(file_path, text_to_write):
with open(file_path, 'w') as f:
f.write(text_to_write)
return |
class Card:
"""Standard playing card.
Attributes:
suit: string spades,hearts,diamonds,clubs
rank: string 1-10,jack,queen,king
"""
def __init__(self, rank, suit):
"""Initializes the object Card"""
self.rank = rank
self.suit = suit
def __repr__(self):
"""Returns a string of Card with rank and suit"""
return str(f'{self.rank} of {self.suit}')
class Deck:
"""Class for a regular decks"""
suit = ["Spades", "Hearts", "Diamonds", "Clubs"]
rank = ["Ace", "Two(2)", "Three(3)", "Four(4)", "Five(5)", "Six(6)", "Seven(7)", "Eight(8)", "Nine(9)",
"Ten(10)", "Jack", "Queen", "King"]
def __init__(self):
"""Initializes the object Deck"""
self.cards = [Card(r, s) for r in Deck.rank for s in Deck.suit]
self.counter = 0
def __getitem__(self, position):
"""Returns sliced object"""
return self.cards[position]
def __len__(self):
"""Counts the element inside the object"""
return len(self.cards)
def __iter__(self):
"""Returns an iterator object"""
return self
def __next__(self):
"""Returns the next element"""
if self.counter >= len(self.cards):
raise StopIteration
current = self.cards[self.counter]
self.counter += 1
return current
def __repr__(self):
"""Returns a string of cards in a string list"""
return str(self.cards) | class Card:
"""Standard playing card.
Attributes:
suit: string spades,hearts,diamonds,clubs
rank: string 1-10,jack,queen,king
"""
def __init__(self, rank, suit):
"""Initializes the object Card"""
self.rank = rank
self.suit = suit
def __repr__(self):
"""Returns a string of Card with rank and suit"""
return str(f'{self.rank} of {self.suit}')
class Deck:
"""Class for a regular decks"""
suit = ['Spades', 'Hearts', 'Diamonds', 'Clubs']
rank = ['Ace', 'Two(2)', 'Three(3)', 'Four(4)', 'Five(5)', 'Six(6)', 'Seven(7)', 'Eight(8)', 'Nine(9)', 'Ten(10)', 'Jack', 'Queen', 'King']
def __init__(self):
"""Initializes the object Deck"""
self.cards = [card(r, s) for r in Deck.rank for s in Deck.suit]
self.counter = 0
def __getitem__(self, position):
"""Returns sliced object"""
return self.cards[position]
def __len__(self):
"""Counts the element inside the object"""
return len(self.cards)
def __iter__(self):
"""Returns an iterator object"""
return self
def __next__(self):
"""Returns the next element"""
if self.counter >= len(self.cards):
raise StopIteration
current = self.cards[self.counter]
self.counter += 1
return current
def __repr__(self):
"""Returns a string of cards in a string list"""
return str(self.cards) |
class Solution(object):
def getRow(self, rowIndex):
"""
:type rowIndex: int
:rtype: List[int]
"""
res = [[1 for j in range(i + 1)] for i in range(rowIndex + 1)]
for i in range(2, rowIndex + 1):
for j in range(1, i):
res[i][j] = res[i - 1][j - 1] + res[i - 1][j]
return res[-1]
| class Solution(object):
def get_row(self, rowIndex):
"""
:type rowIndex: int
:rtype: List[int]
"""
res = [[1 for j in range(i + 1)] for i in range(rowIndex + 1)]
for i in range(2, rowIndex + 1):
for j in range(1, i):
res[i][j] = res[i - 1][j - 1] + res[i - 1][j]
return res[-1] |
# To Find The Total Number Of Digits In A Number
N = int(input("Enter The number"))
count = 0
while(N!=0):
N = (N-N%10)/10
count+=1
print(count) | n = int(input('Enter The number'))
count = 0
while N != 0:
n = (N - N % 10) / 10
count += 1
print(count) |
class DummyObject:
# When we try to access any attribute of the
# dummy object, it will return himself.
def __getattr__(self, item):
return self
# And if dummy object is called, nothing is being done,
# and error created if the function did not exist.
def __call__(self, *args, **kwargs):
pass
dummy_object = DummyObject()
| class Dummyobject:
def __getattr__(self, item):
return self
def __call__(self, *args, **kwargs):
pass
dummy_object = dummy_object() |
#Calculate Value of PI using the Neelkantha method to nth digit using upto 50 trailing digits
j = 3.0
k=1
for i in range(2, 4000000, 2): #Change the Desired End Step to get a better nth value
k = k+1
if k % 2 ==0:
j = j+ 4/(i*(i+1)*(i+2))
else:
j = j- 4/(i*(i+1)*(i+2))
kaggle = input('Enter value of n upto which you want to display the value of PI:')
a = '%.'+kaggle+'f'
print (a%(j)) | j = 3.0
k = 1
for i in range(2, 4000000, 2):
k = k + 1
if k % 2 == 0:
j = j + 4 / (i * (i + 1) * (i + 2))
else:
j = j - 4 / (i * (i + 1) * (i + 2))
kaggle = input('Enter value of n upto which you want to display the value of PI:')
a = '%.' + kaggle + 'f'
print(a % j) |
class Solution:
# bottom up
def minimumTotal(self, triangle: 'List[List[int]]') -> 'int':
if not triangle:
return
rst = triangle[-1]
for level in range(len(triangle)-2,-1,-1):
for i in range(0,len(triangle[level]),1):
rst[i] = triangle[level][i] + min(rst[i], rst[i+1])
return rst[0] | class Solution:
def minimum_total(self, triangle: 'List[List[int]]') -> 'int':
if not triangle:
return
rst = triangle[-1]
for level in range(len(triangle) - 2, -1, -1):
for i in range(0, len(triangle[level]), 1):
rst[i] = triangle[level][i] + min(rst[i], rst[i + 1])
return rst[0] |
# -*- coding: utf-8 -*-
"""
Exceptions
==========
Specific application exceptions.
"""
class PyCssStyleguideException(Exception):
"""
Exception base.
You should never use it directly except for test purpose. Instead make or
use a dedicated exception related to the error context.
"""
pass
class SerializerError(PyCssStyleguideException):
"""
Exception to raise when there is a syntax issue during serialization.
"""
pass
class StyleguideValidationError(PyCssStyleguideException):
"""
Exception to raise when there is invalid naming in reference rules and properties.
"""
pass
| """
Exceptions
==========
Specific application exceptions.
"""
class Pycssstyleguideexception(Exception):
"""
Exception base.
You should never use it directly except for test purpose. Instead make or
use a dedicated exception related to the error context.
"""
pass
class Serializererror(PyCssStyleguideException):
"""
Exception to raise when there is a syntax issue during serialization.
"""
pass
class Styleguidevalidationerror(PyCssStyleguideException):
"""
Exception to raise when there is invalid naming in reference rules and properties.
"""
pass |
def digit_sum():
a=int(input('Enter an integer '))
sum=0
for i in range(1,a+1):
sum+=i
if(i!=a):
print(i,end='+')
else:
print(a,'=',sum)
digit_sum()
| def digit_sum():
a = int(input('Enter an integer '))
sum = 0
for i in range(1, a + 1):
sum += i
if i != a:
print(i, end='+')
else:
print(a, '=', sum)
digit_sum() |
"""
map applies a function to all values in one or more iterables
filter runs each value through a function and creates an iterable with all truthy values
"""
# map
a_list = list(range(10))
b_list = list(range(10, 30))
c_list = list(range(30, 60))
def add(value1, value2):
return value1 + value2
added = []
for value1, value2 in zip(a_list, b_list):
added.append(add(value1, value2))
added_comp = [add(value1, value2) for value1, value2 in zip(a_list, b_list)]
added_map = list(map(add, a_list, b_list))
added_lambda = list(map(lambda x, y: x + y, a_list, b_list))
# filter
def div_by_3(value):
return not value % 3
by_3 = []
for value in a_list:
if div_by_3(value):
by_3.append(value)
by_3_filter = list(filter(div_by_3, a_list))
by_3_lambda = list(filter(lambda value: not value % 3, a_list))
by_3_map = list(map(div_by_3, a_list))
# map and filter
def to_point(x, y=None, z=None):
_x = f"x: {x}"
_y = f"y: {y}" if y else y
_z = f"z: {z}" if z else z
return ", ".join(filter(None, [_x, _y, _z]))
x_points = list(map(to_point, a_list))
xy_points = list(map(to_point, a_list, b_list))
xyz_points = list(map(to_point, a_list, b_list, c_list))
| """
map applies a function to all values in one or more iterables
filter runs each value through a function and creates an iterable with all truthy values
"""
a_list = list(range(10))
b_list = list(range(10, 30))
c_list = list(range(30, 60))
def add(value1, value2):
return value1 + value2
added = []
for (value1, value2) in zip(a_list, b_list):
added.append(add(value1, value2))
added_comp = [add(value1, value2) for (value1, value2) in zip(a_list, b_list)]
added_map = list(map(add, a_list, b_list))
added_lambda = list(map(lambda x, y: x + y, a_list, b_list))
def div_by_3(value):
return not value % 3
by_3 = []
for value in a_list:
if div_by_3(value):
by_3.append(value)
by_3_filter = list(filter(div_by_3, a_list))
by_3_lambda = list(filter(lambda value: not value % 3, a_list))
by_3_map = list(map(div_by_3, a_list))
def to_point(x, y=None, z=None):
_x = f'x: {x}'
_y = f'y: {y}' if y else y
_z = f'z: {z}' if z else z
return ', '.join(filter(None, [_x, _y, _z]))
x_points = list(map(to_point, a_list))
xy_points = list(map(to_point, a_list, b_list))
xyz_points = list(map(to_point, a_list, b_list, c_list)) |
with open("Crime.csv",'r') as file:
mainlist=[]
list2=[]
count=[]
i=0
j=1
k=2
countvalue=0
for line in file:
line.strip()
line.split(",")
print(line)
"""
if line[2] in mainlist:
mainlist.index(line[7])
count[index]+=1
list2[k]=count[index]
else:
list1.append(line[7])
list2[i]=list[8]
list2[j]=list[7]
count.append(1)
list2[k]=count[index1]
i+=3
j+=3
k+=3
"""
| with open('Crime.csv', 'r') as file:
mainlist = []
list2 = []
count = []
i = 0
j = 1
k = 2
countvalue = 0
for line in file:
line.strip()
line.split(',')
print(line)
'\n if line[2] in mainlist:\n mainlist.index(line[7])\n count[index]+=1\n list2[k]=count[index]\n else:\n list1.append(line[7])\n list2[i]=list[8]\n list2[j]=list[7]\n count.append(1)\n list2[k]=count[index1]\n i+=3\n j+=3\n k+=3\n' |
"""
Sams Teach Yourself Python in 24 Hours
by Katie Cunningham
Hour 3: Logic in Programming
Exercise:
1.
a) Given a number, write a snippet of code that will print
"You have money" if the number is positive,
"You're out" if the number is zero,
"You seem to be in debt" if less than zero"
Your code should have an if statement, an elif statement,
and an else.
"""
#Hour 3: Logic in Programming
balance = float(input("Insert Money Amount: $"))
if balance > 0:
print ("You have money")
elif balance == 0:
print ("You're out")
else:
print ("You seem to be in debt")
| """
Sams Teach Yourself Python in 24 Hours
by Katie Cunningham
Hour 3: Logic in Programming
Exercise:
1.
a) Given a number, write a snippet of code that will print
"You have money" if the number is positive,
"You're out" if the number is zero,
"You seem to be in debt" if less than zero"
Your code should have an if statement, an elif statement,
and an else.
"""
balance = float(input('Insert Money Amount: $'))
if balance > 0:
print('You have money')
elif balance == 0:
print("You're out")
else:
print('You seem to be in debt') |
"""init py module tells python this folder contains a package.
You don't particularly need this file for python 3.6.
"""
| """init py module tells python this folder contains a package.
You don't particularly need this file for python 3.6.
""" |
# commaCode script
# Chapter 4 - Lists
def func(arg):
text = ""
for i in range(len(arg)):
text = text + arg[i] + ". "
if i == len(arg) - 2:
text += "and "
return text
spam = ['apples', 'bananas', 'tofu', 'cats']
print(func(spam))
| def func(arg):
text = ''
for i in range(len(arg)):
text = text + arg[i] + '. '
if i == len(arg) - 2:
text += 'and '
return text
spam = ['apples', 'bananas', 'tofu', 'cats']
print(func(spam)) |
# https://leetcode.com/problems/is-subsequence/
class Solution:
def isSubsequence(self, s: str, t: str) -> bool:
if not s:
return True
if len(t) < len(s):
return False
s_idx = 0
for t_idx in range(len(t)):
if s[s_idx] == t[t_idx]:
s_idx += 1
if s_idx == len(s):
return True
return False
| class Solution:
def is_subsequence(self, s: str, t: str) -> bool:
if not s:
return True
if len(t) < len(s):
return False
s_idx = 0
for t_idx in range(len(t)):
if s[s_idx] == t[t_idx]:
s_idx += 1
if s_idx == len(s):
return True
return False |
class Validator(object):
def __init__(self):
self.isValid = False
def validate(self, number):
try:
if number is None:
return self.isValid
if isinstance(number, str) and number.find(' ') >= 0:
number = number.replace(' ', '')
self.isValid = number.isdigit() and len(number) == 10
if self.isValid:
multiplier = 10
n = 0
numArray = list(number)
for value in numArray:
if multiplier == 1:
break
n = n + (int(value) * multiplier)
multiplier = multiplier - 1
n = 11 - (n % 11)
if n == 11:
n = 0
if n == 10:
self.isValid = False
return self.isValid
self.isValid = int(numArray[9]) == n
return self.isValid
except Exception:
self.isValid = False
return self.isValid
| class Validator(object):
def __init__(self):
self.isValid = False
def validate(self, number):
try:
if number is None:
return self.isValid
if isinstance(number, str) and number.find(' ') >= 0:
number = number.replace(' ', '')
self.isValid = number.isdigit() and len(number) == 10
if self.isValid:
multiplier = 10
n = 0
num_array = list(number)
for value in numArray:
if multiplier == 1:
break
n = n + int(value) * multiplier
multiplier = multiplier - 1
n = 11 - n % 11
if n == 11:
n = 0
if n == 10:
self.isValid = False
return self.isValid
self.isValid = int(numArray[9]) == n
return self.isValid
except Exception:
self.isValid = False
return self.isValid |
def loss_disc(disc, x_real, x_fake):
"""Compute the discriminator loss for `x_real` and `x_fake` given `disc`
Args:
disc: The discriminator
x_real (ndarray): An array of shape (N,) that contains the real samples
x_fake (ndarray): An array of shape (N,) that contains the fake samples
Returns:
ndarray: The discriminator loss
"""
# Loss for real data
label_real = 1
loss_real = label_real * torch.log(disc.classify(x_real))
# Loss for fake data
label_fake = 0
loss_fake = (1 - label_fake) * torch.log(1 - disc.classify(x_fake))
return torch.cat([loss_real, loss_fake])
# add event to airtable
atform.add_event('Coding Exercise 2.1: Implement Discriminator Loss')
disc = DummyDisc()
gen = DummyGen()
x_real = get_data()
x_fake = gen.sample()
## Uncomment to check your function
ld = loss_disc(disc, x_real, x_fake)
with plt.xkcd():
plotting_ld(ld) | def loss_disc(disc, x_real, x_fake):
"""Compute the discriminator loss for `x_real` and `x_fake` given `disc`
Args:
disc: The discriminator
x_real (ndarray): An array of shape (N,) that contains the real samples
x_fake (ndarray): An array of shape (N,) that contains the fake samples
Returns:
ndarray: The discriminator loss
"""
label_real = 1
loss_real = label_real * torch.log(disc.classify(x_real))
label_fake = 0
loss_fake = (1 - label_fake) * torch.log(1 - disc.classify(x_fake))
return torch.cat([loss_real, loss_fake])
atform.add_event('Coding Exercise 2.1: Implement Discriminator Loss')
disc = dummy_disc()
gen = dummy_gen()
x_real = get_data()
x_fake = gen.sample()
ld = loss_disc(disc, x_real, x_fake)
with plt.xkcd():
plotting_ld(ld) |
message = input().split()
for word in message:
number = ""
letters = ""
for char in word:
if char.isdigit():
number += char
else:
letters += char
first_letter = chr(int(number))
current_word = first_letter + letters
current_word = list(current_word)
current_word[1], current_word[-1] = current_word[-1], current_word[1]
current_word = "".join(current_word)
print(current_word, end=" ")
# data input
# 72olle 103doo 100ya | message = input().split()
for word in message:
number = ''
letters = ''
for char in word:
if char.isdigit():
number += char
else:
letters += char
first_letter = chr(int(number))
current_word = first_letter + letters
current_word = list(current_word)
(current_word[1], current_word[-1]) = (current_word[-1], current_word[1])
current_word = ''.join(current_word)
print(current_word, end=' ') |
def prog(l, noun=12, verb=2):
res = list(map(int, l.split(',')))
res[1] = noun
res[2] = verb
for i in range(0, len(l), 4):
if res[i] == 1:
res[res[i+3]] = res[res[i+1]] + res[res[i+2]]
elif res[i] == 2:
res[res[i+3]] = res[res[i+1]] * res[res[i+2]]
elif res[i] == 99:
return res
else:
raise ValueError(i)
input = '1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,1,10,19,2,6,19,23,1,23,5,27,1,27,13,31,2,6,31,35,1,5,35,39,1,39,10,43,2,6,43,47,1,47,5,51,1,51,9,55,2,55,6,59,1,59,10,63,2,63,9,67,1,67,5,71,1,71,5,75,2,75,6,79,1,5,79,83,1,10,83,87,2,13,87,91,1,10,91,95,2,13,95,99,1,99,9,103,1,5,103,107,1,107,10,111,1,111,5,115,1,115,6,119,1,119,10,123,1,123,10,127,2,127,13,131,1,13,131,135,1,135,10,139,2,139,6,143,1,143,9,147,2,147,6,151,1,5,151,155,1,9,155,159,2,159,6,163,1,163,2,167,1,10,167,0,99,2,14,0,0'
if __name__ == '__main__':
print(prog(input)[0])
| def prog(l, noun=12, verb=2):
res = list(map(int, l.split(',')))
res[1] = noun
res[2] = verb
for i in range(0, len(l), 4):
if res[i] == 1:
res[res[i + 3]] = res[res[i + 1]] + res[res[i + 2]]
elif res[i] == 2:
res[res[i + 3]] = res[res[i + 1]] * res[res[i + 2]]
elif res[i] == 99:
return res
else:
raise value_error(i)
input = '1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,1,10,19,2,6,19,23,1,23,5,27,1,27,13,31,2,6,31,35,1,5,35,39,1,39,10,43,2,6,43,47,1,47,5,51,1,51,9,55,2,55,6,59,1,59,10,63,2,63,9,67,1,67,5,71,1,71,5,75,2,75,6,79,1,5,79,83,1,10,83,87,2,13,87,91,1,10,91,95,2,13,95,99,1,99,9,103,1,5,103,107,1,107,10,111,1,111,5,115,1,115,6,119,1,119,10,123,1,123,10,127,2,127,13,131,1,13,131,135,1,135,10,139,2,139,6,143,1,143,9,147,2,147,6,151,1,5,151,155,1,9,155,159,2,159,6,163,1,163,2,167,1,10,167,0,99,2,14,0,0'
if __name__ == '__main__':
print(prog(input)[0]) |
#
# PySNMP MIB module CISCO-LWAPP-AAA-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-LWAPP-AAA-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:47:44 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsUnion, ValueRangeConstraint, ConstraintsIntersection, SingleValueConstraint, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "ValueRangeConstraint", "ConstraintsIntersection", "SingleValueConstraint", "ValueSizeConstraint")
CLSecKeyFormat, = mibBuilder.importSymbols("CISCO-LWAPP-TC-MIB", "CLSecKeyFormat")
cLWlanIndex, = mibBuilder.importSymbols("CISCO-LWAPP-WLAN-MIB", "cLWlanIndex")
ciscoMgmt, = mibBuilder.importSymbols("CISCO-SMI", "ciscoMgmt")
InetAddressType, InetPortNumber, InetAddress = mibBuilder.importSymbols("INET-ADDRESS-MIB", "InetAddressType", "InetPortNumber", "InetAddress")
SnmpAdminString, = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString")
NotificationGroup, ModuleCompliance, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup")
Integer32, TimeTicks, iso, Unsigned32, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter32, Counter64, ObjectIdentity, NotificationType, IpAddress, Bits, Gauge32, ModuleIdentity, MibIdentifier = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "TimeTicks", "iso", "Unsigned32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter32", "Counter64", "ObjectIdentity", "NotificationType", "IpAddress", "Bits", "Gauge32", "ModuleIdentity", "MibIdentifier")
MacAddress, TimeInterval, DisplayString, TruthValue, RowStatus, TextualConvention, StorageType = mibBuilder.importSymbols("SNMPv2-TC", "MacAddress", "TimeInterval", "DisplayString", "TruthValue", "RowStatus", "TextualConvention", "StorageType")
ciscoLwappAAAMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 9, 9, 598))
ciscoLwappAAAMIB.setRevisions(('2010-07-25 00:00', '2006-11-21 00:00',))
if mibBuilder.loadTexts: ciscoLwappAAAMIB.setLastUpdated('201007250000Z')
if mibBuilder.loadTexts: ciscoLwappAAAMIB.setOrganization('Cisco Systems Inc.')
ciscoLwappAAAMIBNotifs = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 598, 0))
ciscoLwappAAAMIBObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 598, 1))
ciscoLwappAAAMIBConform = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 598, 2))
claConfigObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1))
claStatusObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2))
claPriorityTable = MibTable((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 1), )
if mibBuilder.loadTexts: claPriorityTable.setStatus('current')
claPriorityEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 1, 1), ).setIndexNames((0, "CISCO-LWAPP-AAA-MIB", "claPriorityAuth"))
if mibBuilder.loadTexts: claPriorityEntry.setStatus('current')
claPriorityAuth = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("local", 1), ("radius", 2), ("tacacsplus", 3))))
if mibBuilder.loadTexts: claPriorityAuth.setStatus('current')
claPriorityOrder = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 1, 1, 2), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 10))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: claPriorityOrder.setStatus('current')
claTacacsServerTable = MibTable((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2), )
if mibBuilder.loadTexts: claTacacsServerTable.setStatus('current')
claTacacsServerEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1), ).setIndexNames((0, "CISCO-LWAPP-AAA-MIB", "claTacacsServerType"), (0, "CISCO-LWAPP-AAA-MIB", "claTacacsServerPriority"))
if mibBuilder.loadTexts: claTacacsServerEntry.setStatus('current')
claTacacsServerType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("authentication", 1), ("authorization", 2), ("accounting", 3))))
if mibBuilder.loadTexts: claTacacsServerType.setStatus('current')
claTacacsServerPriority = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 2), Unsigned32())
if mibBuilder.loadTexts: claTacacsServerPriority.setStatus('current')
claTacacsServerAddressType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 3), InetAddressType()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: claTacacsServerAddressType.setStatus('current')
claTacacsServerAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 4), InetAddress()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: claTacacsServerAddress.setStatus('current')
claTacacsServerPortNum = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 5), InetPortNumber()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: claTacacsServerPortNum.setStatus('current')
claTacacsServerEnabled = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 6), TruthValue().clone('true')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: claTacacsServerEnabled.setStatus('current')
claTacacsServerSecretType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 7), CLSecKeyFormat()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: claTacacsServerSecretType.setStatus('current')
claTacacsServerSecret = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 8), DisplayString()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: claTacacsServerSecret.setStatus('current')
claTacacsServerTimeout = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 9), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(5, 30)).clone(5)).setUnits('seconds').setMaxAccess("readcreate")
if mibBuilder.loadTexts: claTacacsServerTimeout.setStatus('current')
claTacacsServerStorageType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 10), StorageType().clone('nonVolatile')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: claTacacsServerStorageType.setStatus('current')
claTacacsServerRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 11), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: claTacacsServerRowStatus.setStatus('current')
claWlanTable = MibTable((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 3), )
if mibBuilder.loadTexts: claWlanTable.setStatus('current')
claWlanEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 3, 1), ).setIndexNames((0, "CISCO-LWAPP-WLAN-MIB", "cLWlanIndex"))
if mibBuilder.loadTexts: claWlanEntry.setStatus('current')
claWlanAcctServerEnabled = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 3, 1, 1), TruthValue().clone('true')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: claWlanAcctServerEnabled.setStatus('current')
claWlanAuthServerEnabled = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 3, 1, 2), TruthValue().clone('true')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: claWlanAuthServerEnabled.setStatus('current')
claSaveUserData = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 9), TruthValue().clone('true')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: claSaveUserData.setStatus('current')
claWebRadiusAuthentication = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("pap", 1), ("chap", 2), ("md5-chap", 3))).clone('pap')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: claWebRadiusAuthentication.setStatus('current')
claRadiusFallbackMode = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 11), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("off", 1), ("passive", 2), ("active", 3))).clone('off')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: claRadiusFallbackMode.setStatus('current')
claRadiusFallbackUsername = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 12), SnmpAdminString()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: claRadiusFallbackUsername.setStatus('current')
claRadiusFallbackInterval = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 13), TimeInterval().subtype(subtypeSpec=ValueRangeConstraint(180, 3600)).clone(300)).setUnits('seconds').setMaxAccess("readwrite")
if mibBuilder.loadTexts: claRadiusFallbackInterval.setStatus('current')
claRadiusAuthMacDelimiter = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 14), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("noDelimiter", 1), ("colon", 2), ("hyphen", 3), ("singleHyphen", 4))).clone('hyphen')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: claRadiusAuthMacDelimiter.setStatus('current')
claRadiusAcctMacDelimiter = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 15), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("noDelimiter", 1), ("colon", 2), ("hyphen", 3), ("singleHyphen", 4))).clone('hyphen')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: claRadiusAcctMacDelimiter.setStatus('current')
claAcceptMICertificate = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 16), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: claAcceptMICertificate.setStatus('current')
claAcceptLSCertificate = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 17), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: claAcceptLSCertificate.setStatus('current')
claAllowAuthorizeLscApAgainstAAA = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 18), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: claAllowAuthorizeLscApAgainstAAA.setStatus('current')
claRadiusServerTable = MibTable((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2, 1), )
if mibBuilder.loadTexts: claRadiusServerTable.setStatus('current')
claRadiusServerEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2, 1, 1), ).setIndexNames((0, "CISCO-LWAPP-AAA-MIB", "claRadiusReqId"))
if mibBuilder.loadTexts: claRadiusServerEntry.setStatus('current')
claRadiusReqId = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2, 1, 1, 1), Unsigned32())
if mibBuilder.loadTexts: claRadiusReqId.setStatus('current')
claRadiusAddressType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2, 1, 1, 2), InetAddressType()).setMaxAccess("readonly")
if mibBuilder.loadTexts: claRadiusAddressType.setStatus('current')
claRadiusAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2, 1, 1, 3), InetAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: claRadiusAddress.setStatus('current')
claRadiusPortNum = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2, 1, 1, 4), InetPortNumber()).setMaxAccess("readonly")
if mibBuilder.loadTexts: claRadiusPortNum.setStatus('current')
claRadiusWlanIdx = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2, 1, 1, 5), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 17))).setMaxAccess("readonly")
if mibBuilder.loadTexts: claRadiusWlanIdx.setStatus('current')
claRadiusClientMacAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2, 1, 1, 6), MacAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: claRadiusClientMacAddress.setStatus('current')
claRadiusUserName = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2, 1, 1, 7), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: claRadiusUserName.setStatus('current')
claDBCurrentUsedEntries = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2, 2), Gauge32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: claDBCurrentUsedEntries.setStatus('current')
claRadiusServerGlobalActivatedEnabled = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 4), TruthValue().clone('true')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: claRadiusServerGlobalActivatedEnabled.setStatus('current')
claRadiusServerGlobalDeactivatedEnabled = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 5), TruthValue().clone('true')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: claRadiusServerGlobalDeactivatedEnabled.setStatus('current')
claRadiusServerWlanActivatedEnabled = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 6), TruthValue().clone('true')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: claRadiusServerWlanActivatedEnabled.setStatus('current')
claRadiusServerWlanDeactivatedEnabled = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 7), TruthValue().clone('true')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: claRadiusServerWlanDeactivatedEnabled.setStatus('current')
claRadiusReqTimedOutEnabled = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 8), TruthValue().clone('true')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: claRadiusReqTimedOutEnabled.setStatus('current')
ciscoLwappAAARadiusServerGlobalActivated = NotificationType((1, 3, 6, 1, 4, 1, 9, 9, 598, 0, 1)).setObjects(("CISCO-LWAPP-AAA-MIB", "claRadiusAddressType"), ("CISCO-LWAPP-AAA-MIB", "claRadiusAddress"), ("CISCO-LWAPP-AAA-MIB", "claRadiusPortNum"))
if mibBuilder.loadTexts: ciscoLwappAAARadiusServerGlobalActivated.setStatus('current')
ciscoLwappAAARadiusServerGlobalDeactivated = NotificationType((1, 3, 6, 1, 4, 1, 9, 9, 598, 0, 2)).setObjects(("CISCO-LWAPP-AAA-MIB", "claRadiusAddressType"), ("CISCO-LWAPP-AAA-MIB", "claRadiusAddress"), ("CISCO-LWAPP-AAA-MIB", "claRadiusPortNum"))
if mibBuilder.loadTexts: ciscoLwappAAARadiusServerGlobalDeactivated.setStatus('current')
ciscoLwappAAARadiusServerWlanActivated = NotificationType((1, 3, 6, 1, 4, 1, 9, 9, 598, 0, 3)).setObjects(("CISCO-LWAPP-AAA-MIB", "claRadiusAddressType"), ("CISCO-LWAPP-AAA-MIB", "claRadiusAddress"), ("CISCO-LWAPP-AAA-MIB", "claRadiusPortNum"), ("CISCO-LWAPP-AAA-MIB", "claRadiusWlanIdx"))
if mibBuilder.loadTexts: ciscoLwappAAARadiusServerWlanActivated.setStatus('current')
ciscoLwappAAARadiusServerWlanDeactivated = NotificationType((1, 3, 6, 1, 4, 1, 9, 9, 598, 0, 4)).setObjects(("CISCO-LWAPP-AAA-MIB", "claRadiusAddressType"), ("CISCO-LWAPP-AAA-MIB", "claRadiusAddress"), ("CISCO-LWAPP-AAA-MIB", "claRadiusPortNum"), ("CISCO-LWAPP-AAA-MIB", "claRadiusWlanIdx"))
if mibBuilder.loadTexts: ciscoLwappAAARadiusServerWlanDeactivated.setStatus('current')
ciscoLwappAAARadiusReqTimedOut = NotificationType((1, 3, 6, 1, 4, 1, 9, 9, 598, 0, 5)).setObjects(("CISCO-LWAPP-AAA-MIB", "claRadiusAddressType"), ("CISCO-LWAPP-AAA-MIB", "claRadiusAddress"), ("CISCO-LWAPP-AAA-MIB", "claRadiusPortNum"), ("CISCO-LWAPP-AAA-MIB", "claRadiusClientMacAddress"), ("CISCO-LWAPP-AAA-MIB", "claRadiusUserName"))
if mibBuilder.loadTexts: ciscoLwappAAARadiusReqTimedOut.setStatus('current')
ciscoLwappAAAMIBCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 1))
ciscoLwappAAAMIBGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 2))
ciscoLwappAAAMIBCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 1, 1)).setObjects(("CISCO-LWAPP-AAA-MIB", "ciscoLwappAAAMIBConfigGroup"), ("CISCO-LWAPP-AAA-MIB", "ciscoLwappAAAMIBNotifsGroup"), ("CISCO-LWAPP-AAA-MIB", "ciscoLwappAAAMIBStatusObjsGroup"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoLwappAAAMIBCompliance = ciscoLwappAAAMIBCompliance.setStatus('deprecated')
ciscoLwappAAAMIBComplianceRev1 = ModuleCompliance((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 1, 2)).setObjects(("CISCO-LWAPP-AAA-MIB", "ciscoLwappAAAMIBConfigGroup"), ("CISCO-LWAPP-AAA-MIB", "ciscoLwappAAAMIBSaveUserConfigGroup"), ("CISCO-LWAPP-AAA-MIB", "ciscoLwappAAAMIBRadiusConfigGroup"), ("CISCO-LWAPP-AAA-MIB", "ciscoLwappAAAMIBAPPolicyConfigGroup"), ("CISCO-LWAPP-AAA-MIB", "ciscoLwappAAAMIBWlanAuthAccServerConfigGroup"), ("CISCO-LWAPP-AAA-MIB", "ciscoLwappAAAMIBNotifsGroup"), ("CISCO-LWAPP-AAA-MIB", "ciscoLwappAAAMIBStatusObjsGroup"), ("CISCO-LWAPP-AAA-MIB", "ciscoLwappAAAMIBDBEntriesGroup"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoLwappAAAMIBComplianceRev1 = ciscoLwappAAAMIBComplianceRev1.setStatus('current')
ciscoLwappAAAMIBConfigGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 2, 1)).setObjects(("CISCO-LWAPP-AAA-MIB", "claPriorityOrder"), ("CISCO-LWAPP-AAA-MIB", "claTacacsServerAddressType"), ("CISCO-LWAPP-AAA-MIB", "claTacacsServerAddress"), ("CISCO-LWAPP-AAA-MIB", "claTacacsServerPortNum"), ("CISCO-LWAPP-AAA-MIB", "claTacacsServerEnabled"), ("CISCO-LWAPP-AAA-MIB", "claTacacsServerSecretType"), ("CISCO-LWAPP-AAA-MIB", "claTacacsServerSecret"), ("CISCO-LWAPP-AAA-MIB", "claTacacsServerTimeout"), ("CISCO-LWAPP-AAA-MIB", "claTacacsServerStorageType"), ("CISCO-LWAPP-AAA-MIB", "claTacacsServerRowStatus"), ("CISCO-LWAPP-AAA-MIB", "claRadiusServerGlobalActivatedEnabled"), ("CISCO-LWAPP-AAA-MIB", "claRadiusServerGlobalDeactivatedEnabled"), ("CISCO-LWAPP-AAA-MIB", "claRadiusServerWlanActivatedEnabled"), ("CISCO-LWAPP-AAA-MIB", "claRadiusServerWlanDeactivatedEnabled"), ("CISCO-LWAPP-AAA-MIB", "claRadiusReqTimedOutEnabled"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoLwappAAAMIBConfigGroup = ciscoLwappAAAMIBConfigGroup.setStatus('current')
ciscoLwappAAAMIBSaveUserConfigGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 2, 2)).setObjects(("CISCO-LWAPP-AAA-MIB", "claSaveUserData"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoLwappAAAMIBSaveUserConfigGroup = ciscoLwappAAAMIBSaveUserConfigGroup.setStatus('current')
ciscoLwappAAAMIBNotifsGroup = NotificationGroup((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 2, 3)).setObjects(("CISCO-LWAPP-AAA-MIB", "ciscoLwappAAARadiusServerGlobalActivated"), ("CISCO-LWAPP-AAA-MIB", "ciscoLwappAAARadiusServerGlobalDeactivated"), ("CISCO-LWAPP-AAA-MIB", "ciscoLwappAAARadiusServerWlanActivated"), ("CISCO-LWAPP-AAA-MIB", "ciscoLwappAAARadiusServerWlanDeactivated"), ("CISCO-LWAPP-AAA-MIB", "ciscoLwappAAARadiusReqTimedOut"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoLwappAAAMIBNotifsGroup = ciscoLwappAAAMIBNotifsGroup.setStatus('current')
ciscoLwappAAAMIBStatusObjsGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 2, 4)).setObjects(("CISCO-LWAPP-AAA-MIB", "claRadiusAddressType"), ("CISCO-LWAPP-AAA-MIB", "claRadiusAddress"), ("CISCO-LWAPP-AAA-MIB", "claRadiusPortNum"), ("CISCO-LWAPP-AAA-MIB", "claRadiusWlanIdx"), ("CISCO-LWAPP-AAA-MIB", "claRadiusClientMacAddress"), ("CISCO-LWAPP-AAA-MIB", "claRadiusUserName"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoLwappAAAMIBStatusObjsGroup = ciscoLwappAAAMIBStatusObjsGroup.setStatus('current')
ciscoLwappAAAMIBDBEntriesGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 2, 5)).setObjects(("CISCO-LWAPP-AAA-MIB", "claDBCurrentUsedEntries"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoLwappAAAMIBDBEntriesGroup = ciscoLwappAAAMIBDBEntriesGroup.setStatus('current')
ciscoLwappAAAMIBRadiusConfigGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 2, 6)).setObjects(("CISCO-LWAPP-AAA-MIB", "claWebRadiusAuthentication"), ("CISCO-LWAPP-AAA-MIB", "claRadiusFallbackMode"), ("CISCO-LWAPP-AAA-MIB", "claRadiusFallbackUsername"), ("CISCO-LWAPP-AAA-MIB", "claRadiusFallbackInterval"), ("CISCO-LWAPP-AAA-MIB", "claRadiusAuthMacDelimiter"), ("CISCO-LWAPP-AAA-MIB", "claRadiusAcctMacDelimiter"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoLwappAAAMIBRadiusConfigGroup = ciscoLwappAAAMIBRadiusConfigGroup.setStatus('current')
ciscoLwappAAAMIBAPPolicyConfigGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 2, 7)).setObjects(("CISCO-LWAPP-AAA-MIB", "claAcceptMICertificate"), ("CISCO-LWAPP-AAA-MIB", "claAcceptLSCertificate"), ("CISCO-LWAPP-AAA-MIB", "claAllowAuthorizeLscApAgainstAAA"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoLwappAAAMIBAPPolicyConfigGroup = ciscoLwappAAAMIBAPPolicyConfigGroup.setStatus('current')
ciscoLwappAAAMIBWlanAuthAccServerConfigGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 2, 8)).setObjects(("CISCO-LWAPP-AAA-MIB", "claWlanAuthServerEnabled"), ("CISCO-LWAPP-AAA-MIB", "claWlanAcctServerEnabled"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoLwappAAAMIBWlanAuthAccServerConfigGroup = ciscoLwappAAAMIBWlanAuthAccServerConfigGroup.setStatus('current')
mibBuilder.exportSymbols("CISCO-LWAPP-AAA-MIB", claRadiusReqTimedOutEnabled=claRadiusReqTimedOutEnabled, ciscoLwappAAAMIBCompliances=ciscoLwappAAAMIBCompliances, claConfigObjects=claConfigObjects, claAllowAuthorizeLscApAgainstAAA=claAllowAuthorizeLscApAgainstAAA, claRadiusUserName=claRadiusUserName, ciscoLwappAAAMIBNotifs=ciscoLwappAAAMIBNotifs, ciscoLwappAAAMIBConform=ciscoLwappAAAMIBConform, claRadiusFallbackUsername=claRadiusFallbackUsername, claStatusObjects=claStatusObjects, claTacacsServerRowStatus=claTacacsServerRowStatus, claRadiusServerEntry=claRadiusServerEntry, claSaveUserData=claSaveUserData, claWebRadiusAuthentication=claWebRadiusAuthentication, claWlanEntry=claWlanEntry, claRadiusWlanIdx=claRadiusWlanIdx, ciscoLwappAAAMIBGroups=ciscoLwappAAAMIBGroups, ciscoLwappAAAMIBCompliance=ciscoLwappAAAMIBCompliance, claTacacsServerSecretType=claTacacsServerSecretType, claRadiusFallbackMode=claRadiusFallbackMode, claRadiusAuthMacDelimiter=claRadiusAuthMacDelimiter, claRadiusServerTable=claRadiusServerTable, ciscoLwappAAAMIBSaveUserConfigGroup=ciscoLwappAAAMIBSaveUserConfigGroup, ciscoLwappAAAMIBComplianceRev1=ciscoLwappAAAMIBComplianceRev1, ciscoLwappAAAMIBStatusObjsGroup=ciscoLwappAAAMIBStatusObjsGroup, claRadiusPortNum=claRadiusPortNum, claRadiusServerGlobalDeactivatedEnabled=claRadiusServerGlobalDeactivatedEnabled, claWlanTable=claWlanTable, PYSNMP_MODULE_ID=ciscoLwappAAAMIB, ciscoLwappAAAMIB=ciscoLwappAAAMIB, claPriorityEntry=claPriorityEntry, ciscoLwappAAAMIBConfigGroup=ciscoLwappAAAMIBConfigGroup, claDBCurrentUsedEntries=claDBCurrentUsedEntries, claTacacsServerType=claTacacsServerType, claTacacsServerTimeout=claTacacsServerTimeout, claRadiusServerWlanActivatedEnabled=claRadiusServerWlanActivatedEnabled, claRadiusFallbackInterval=claRadiusFallbackInterval, ciscoLwappAAARadiusServerWlanDeactivated=ciscoLwappAAARadiusServerWlanDeactivated, claTacacsServerTable=claTacacsServerTable, claTacacsServerStorageType=claTacacsServerStorageType, claPriorityTable=claPriorityTable, claTacacsServerAddressType=claTacacsServerAddressType, ciscoLwappAAARadiusServerGlobalDeactivated=ciscoLwappAAARadiusServerGlobalDeactivated, claRadiusServerWlanDeactivatedEnabled=claRadiusServerWlanDeactivatedEnabled, claRadiusClientMacAddress=claRadiusClientMacAddress, ciscoLwappAAAMIBNotifsGroup=ciscoLwappAAAMIBNotifsGroup, claRadiusAcctMacDelimiter=claRadiusAcctMacDelimiter, claRadiusReqId=claRadiusReqId, claTacacsServerPriority=claTacacsServerPriority, claAcceptMICertificate=claAcceptMICertificate, claRadiusServerGlobalActivatedEnabled=claRadiusServerGlobalActivatedEnabled, ciscoLwappAAARadiusReqTimedOut=ciscoLwappAAARadiusReqTimedOut, ciscoLwappAAAMIBObjects=ciscoLwappAAAMIBObjects, claTacacsServerEnabled=claTacacsServerEnabled, ciscoLwappAAARadiusServerWlanActivated=ciscoLwappAAARadiusServerWlanActivated, claTacacsServerSecret=claTacacsServerSecret, claWlanAuthServerEnabled=claWlanAuthServerEnabled, claTacacsServerEntry=claTacacsServerEntry, claTacacsServerAddress=claTacacsServerAddress, claRadiusAddressType=claRadiusAddressType, claRadiusAddress=claRadiusAddress, claWlanAcctServerEnabled=claWlanAcctServerEnabled, ciscoLwappAAAMIBRadiusConfigGroup=ciscoLwappAAAMIBRadiusConfigGroup, ciscoLwappAAAMIBAPPolicyConfigGroup=ciscoLwappAAAMIBAPPolicyConfigGroup, claPriorityOrder=claPriorityOrder, ciscoLwappAAAMIBWlanAuthAccServerConfigGroup=ciscoLwappAAAMIBWlanAuthAccServerConfigGroup, ciscoLwappAAAMIBDBEntriesGroup=ciscoLwappAAAMIBDBEntriesGroup, claAcceptLSCertificate=claAcceptLSCertificate, ciscoLwappAAARadiusServerGlobalActivated=ciscoLwappAAARadiusServerGlobalActivated, claTacacsServerPortNum=claTacacsServerPortNum, claPriorityAuth=claPriorityAuth)
| (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_range_constraint, constraints_intersection, single_value_constraint, value_size_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsUnion', 'ValueRangeConstraint', 'ConstraintsIntersection', 'SingleValueConstraint', 'ValueSizeConstraint')
(cl_sec_key_format,) = mibBuilder.importSymbols('CISCO-LWAPP-TC-MIB', 'CLSecKeyFormat')
(c_l_wlan_index,) = mibBuilder.importSymbols('CISCO-LWAPP-WLAN-MIB', 'cLWlanIndex')
(cisco_mgmt,) = mibBuilder.importSymbols('CISCO-SMI', 'ciscoMgmt')
(inet_address_type, inet_port_number, inet_address) = mibBuilder.importSymbols('INET-ADDRESS-MIB', 'InetAddressType', 'InetPortNumber', 'InetAddress')
(snmp_admin_string,) = mibBuilder.importSymbols('SNMP-FRAMEWORK-MIB', 'SnmpAdminString')
(notification_group, module_compliance, object_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance', 'ObjectGroup')
(integer32, time_ticks, iso, unsigned32, mib_scalar, mib_table, mib_table_row, mib_table_column, counter32, counter64, object_identity, notification_type, ip_address, bits, gauge32, module_identity, mib_identifier) = mibBuilder.importSymbols('SNMPv2-SMI', 'Integer32', 'TimeTicks', 'iso', 'Unsigned32', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Counter32', 'Counter64', 'ObjectIdentity', 'NotificationType', 'IpAddress', 'Bits', 'Gauge32', 'ModuleIdentity', 'MibIdentifier')
(mac_address, time_interval, display_string, truth_value, row_status, textual_convention, storage_type) = mibBuilder.importSymbols('SNMPv2-TC', 'MacAddress', 'TimeInterval', 'DisplayString', 'TruthValue', 'RowStatus', 'TextualConvention', 'StorageType')
cisco_lwapp_aaamib = module_identity((1, 3, 6, 1, 4, 1, 9, 9, 598))
ciscoLwappAAAMIB.setRevisions(('2010-07-25 00:00', '2006-11-21 00:00'))
if mibBuilder.loadTexts:
ciscoLwappAAAMIB.setLastUpdated('201007250000Z')
if mibBuilder.loadTexts:
ciscoLwappAAAMIB.setOrganization('Cisco Systems Inc.')
cisco_lwapp_aaamib_notifs = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 598, 0))
cisco_lwapp_aaamib_objects = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 598, 1))
cisco_lwapp_aaamib_conform = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 598, 2))
cla_config_objects = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1))
cla_status_objects = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2))
cla_priority_table = mib_table((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 1))
if mibBuilder.loadTexts:
claPriorityTable.setStatus('current')
cla_priority_entry = mib_table_row((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 1, 1)).setIndexNames((0, 'CISCO-LWAPP-AAA-MIB', 'claPriorityAuth'))
if mibBuilder.loadTexts:
claPriorityEntry.setStatus('current')
cla_priority_auth = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 1, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('local', 1), ('radius', 2), ('tacacsplus', 3))))
if mibBuilder.loadTexts:
claPriorityAuth.setStatus('current')
cla_priority_order = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 1, 1, 2), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 10))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
claPriorityOrder.setStatus('current')
cla_tacacs_server_table = mib_table((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2))
if mibBuilder.loadTexts:
claTacacsServerTable.setStatus('current')
cla_tacacs_server_entry = mib_table_row((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1)).setIndexNames((0, 'CISCO-LWAPP-AAA-MIB', 'claTacacsServerType'), (0, 'CISCO-LWAPP-AAA-MIB', 'claTacacsServerPriority'))
if mibBuilder.loadTexts:
claTacacsServerEntry.setStatus('current')
cla_tacacs_server_type = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('authentication', 1), ('authorization', 2), ('accounting', 3))))
if mibBuilder.loadTexts:
claTacacsServerType.setStatus('current')
cla_tacacs_server_priority = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 2), unsigned32())
if mibBuilder.loadTexts:
claTacacsServerPriority.setStatus('current')
cla_tacacs_server_address_type = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 3), inet_address_type()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
claTacacsServerAddressType.setStatus('current')
cla_tacacs_server_address = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 4), inet_address()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
claTacacsServerAddress.setStatus('current')
cla_tacacs_server_port_num = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 5), inet_port_number()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
claTacacsServerPortNum.setStatus('current')
cla_tacacs_server_enabled = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 6), truth_value().clone('true')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
claTacacsServerEnabled.setStatus('current')
cla_tacacs_server_secret_type = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 7), cl_sec_key_format()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
claTacacsServerSecretType.setStatus('current')
cla_tacacs_server_secret = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 8), display_string()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
claTacacsServerSecret.setStatus('current')
cla_tacacs_server_timeout = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 9), unsigned32().subtype(subtypeSpec=value_range_constraint(5, 30)).clone(5)).setUnits('seconds').setMaxAccess('readcreate')
if mibBuilder.loadTexts:
claTacacsServerTimeout.setStatus('current')
cla_tacacs_server_storage_type = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 10), storage_type().clone('nonVolatile')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
claTacacsServerStorageType.setStatus('current')
cla_tacacs_server_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 2, 1, 11), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
claTacacsServerRowStatus.setStatus('current')
cla_wlan_table = mib_table((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 3))
if mibBuilder.loadTexts:
claWlanTable.setStatus('current')
cla_wlan_entry = mib_table_row((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 3, 1)).setIndexNames((0, 'CISCO-LWAPP-WLAN-MIB', 'cLWlanIndex'))
if mibBuilder.loadTexts:
claWlanEntry.setStatus('current')
cla_wlan_acct_server_enabled = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 3, 1, 1), truth_value().clone('true')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
claWlanAcctServerEnabled.setStatus('current')
cla_wlan_auth_server_enabled = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 3, 1, 2), truth_value().clone('true')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
claWlanAuthServerEnabled.setStatus('current')
cla_save_user_data = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 9), truth_value().clone('true')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
claSaveUserData.setStatus('current')
cla_web_radius_authentication = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 10), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('pap', 1), ('chap', 2), ('md5-chap', 3))).clone('pap')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
claWebRadiusAuthentication.setStatus('current')
cla_radius_fallback_mode = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 11), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('off', 1), ('passive', 2), ('active', 3))).clone('off')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
claRadiusFallbackMode.setStatus('current')
cla_radius_fallback_username = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 12), snmp_admin_string()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
claRadiusFallbackUsername.setStatus('current')
cla_radius_fallback_interval = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 13), time_interval().subtype(subtypeSpec=value_range_constraint(180, 3600)).clone(300)).setUnits('seconds').setMaxAccess('readwrite')
if mibBuilder.loadTexts:
claRadiusFallbackInterval.setStatus('current')
cla_radius_auth_mac_delimiter = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 14), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('noDelimiter', 1), ('colon', 2), ('hyphen', 3), ('singleHyphen', 4))).clone('hyphen')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
claRadiusAuthMacDelimiter.setStatus('current')
cla_radius_acct_mac_delimiter = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 15), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('noDelimiter', 1), ('colon', 2), ('hyphen', 3), ('singleHyphen', 4))).clone('hyphen')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
claRadiusAcctMacDelimiter.setStatus('current')
cla_accept_mi_certificate = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 16), truth_value().clone('false')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
claAcceptMICertificate.setStatus('current')
cla_accept_ls_certificate = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 17), truth_value().clone('false')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
claAcceptLSCertificate.setStatus('current')
cla_allow_authorize_lsc_ap_against_aaa = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 18), truth_value().clone('false')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
claAllowAuthorizeLscApAgainstAAA.setStatus('current')
cla_radius_server_table = mib_table((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2, 1))
if mibBuilder.loadTexts:
claRadiusServerTable.setStatus('current')
cla_radius_server_entry = mib_table_row((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2, 1, 1)).setIndexNames((0, 'CISCO-LWAPP-AAA-MIB', 'claRadiusReqId'))
if mibBuilder.loadTexts:
claRadiusServerEntry.setStatus('current')
cla_radius_req_id = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2, 1, 1, 1), unsigned32())
if mibBuilder.loadTexts:
claRadiusReqId.setStatus('current')
cla_radius_address_type = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2, 1, 1, 2), inet_address_type()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
claRadiusAddressType.setStatus('current')
cla_radius_address = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2, 1, 1, 3), inet_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
claRadiusAddress.setStatus('current')
cla_radius_port_num = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2, 1, 1, 4), inet_port_number()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
claRadiusPortNum.setStatus('current')
cla_radius_wlan_idx = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2, 1, 1, 5), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 17))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
claRadiusWlanIdx.setStatus('current')
cla_radius_client_mac_address = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2, 1, 1, 6), mac_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
claRadiusClientMacAddress.setStatus('current')
cla_radius_user_name = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2, 1, 1, 7), display_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
claRadiusUserName.setStatus('current')
cla_db_current_used_entries = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 2, 2), gauge32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
claDBCurrentUsedEntries.setStatus('current')
cla_radius_server_global_activated_enabled = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 4), truth_value().clone('true')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
claRadiusServerGlobalActivatedEnabled.setStatus('current')
cla_radius_server_global_deactivated_enabled = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 5), truth_value().clone('true')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
claRadiusServerGlobalDeactivatedEnabled.setStatus('current')
cla_radius_server_wlan_activated_enabled = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 6), truth_value().clone('true')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
claRadiusServerWlanActivatedEnabled.setStatus('current')
cla_radius_server_wlan_deactivated_enabled = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 7), truth_value().clone('true')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
claRadiusServerWlanDeactivatedEnabled.setStatus('current')
cla_radius_req_timed_out_enabled = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 598, 1, 1, 8), truth_value().clone('true')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
claRadiusReqTimedOutEnabled.setStatus('current')
cisco_lwapp_aaa_radius_server_global_activated = notification_type((1, 3, 6, 1, 4, 1, 9, 9, 598, 0, 1)).setObjects(('CISCO-LWAPP-AAA-MIB', 'claRadiusAddressType'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusAddress'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusPortNum'))
if mibBuilder.loadTexts:
ciscoLwappAAARadiusServerGlobalActivated.setStatus('current')
cisco_lwapp_aaa_radius_server_global_deactivated = notification_type((1, 3, 6, 1, 4, 1, 9, 9, 598, 0, 2)).setObjects(('CISCO-LWAPP-AAA-MIB', 'claRadiusAddressType'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusAddress'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusPortNum'))
if mibBuilder.loadTexts:
ciscoLwappAAARadiusServerGlobalDeactivated.setStatus('current')
cisco_lwapp_aaa_radius_server_wlan_activated = notification_type((1, 3, 6, 1, 4, 1, 9, 9, 598, 0, 3)).setObjects(('CISCO-LWAPP-AAA-MIB', 'claRadiusAddressType'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusAddress'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusPortNum'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusWlanIdx'))
if mibBuilder.loadTexts:
ciscoLwappAAARadiusServerWlanActivated.setStatus('current')
cisco_lwapp_aaa_radius_server_wlan_deactivated = notification_type((1, 3, 6, 1, 4, 1, 9, 9, 598, 0, 4)).setObjects(('CISCO-LWAPP-AAA-MIB', 'claRadiusAddressType'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusAddress'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusPortNum'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusWlanIdx'))
if mibBuilder.loadTexts:
ciscoLwappAAARadiusServerWlanDeactivated.setStatus('current')
cisco_lwapp_aaa_radius_req_timed_out = notification_type((1, 3, 6, 1, 4, 1, 9, 9, 598, 0, 5)).setObjects(('CISCO-LWAPP-AAA-MIB', 'claRadiusAddressType'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusAddress'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusPortNum'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusClientMacAddress'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusUserName'))
if mibBuilder.loadTexts:
ciscoLwappAAARadiusReqTimedOut.setStatus('current')
cisco_lwapp_aaamib_compliances = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 1))
cisco_lwapp_aaamib_groups = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 2))
cisco_lwapp_aaamib_compliance = module_compliance((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 1, 1)).setObjects(('CISCO-LWAPP-AAA-MIB', 'ciscoLwappAAAMIBConfigGroup'), ('CISCO-LWAPP-AAA-MIB', 'ciscoLwappAAAMIBNotifsGroup'), ('CISCO-LWAPP-AAA-MIB', 'ciscoLwappAAAMIBStatusObjsGroup'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
cisco_lwapp_aaamib_compliance = ciscoLwappAAAMIBCompliance.setStatus('deprecated')
cisco_lwapp_aaamib_compliance_rev1 = module_compliance((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 1, 2)).setObjects(('CISCO-LWAPP-AAA-MIB', 'ciscoLwappAAAMIBConfigGroup'), ('CISCO-LWAPP-AAA-MIB', 'ciscoLwappAAAMIBSaveUserConfigGroup'), ('CISCO-LWAPP-AAA-MIB', 'ciscoLwappAAAMIBRadiusConfigGroup'), ('CISCO-LWAPP-AAA-MIB', 'ciscoLwappAAAMIBAPPolicyConfigGroup'), ('CISCO-LWAPP-AAA-MIB', 'ciscoLwappAAAMIBWlanAuthAccServerConfigGroup'), ('CISCO-LWAPP-AAA-MIB', 'ciscoLwappAAAMIBNotifsGroup'), ('CISCO-LWAPP-AAA-MIB', 'ciscoLwappAAAMIBStatusObjsGroup'), ('CISCO-LWAPP-AAA-MIB', 'ciscoLwappAAAMIBDBEntriesGroup'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
cisco_lwapp_aaamib_compliance_rev1 = ciscoLwappAAAMIBComplianceRev1.setStatus('current')
cisco_lwapp_aaamib_config_group = object_group((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 2, 1)).setObjects(('CISCO-LWAPP-AAA-MIB', 'claPriorityOrder'), ('CISCO-LWAPP-AAA-MIB', 'claTacacsServerAddressType'), ('CISCO-LWAPP-AAA-MIB', 'claTacacsServerAddress'), ('CISCO-LWAPP-AAA-MIB', 'claTacacsServerPortNum'), ('CISCO-LWAPP-AAA-MIB', 'claTacacsServerEnabled'), ('CISCO-LWAPP-AAA-MIB', 'claTacacsServerSecretType'), ('CISCO-LWAPP-AAA-MIB', 'claTacacsServerSecret'), ('CISCO-LWAPP-AAA-MIB', 'claTacacsServerTimeout'), ('CISCO-LWAPP-AAA-MIB', 'claTacacsServerStorageType'), ('CISCO-LWAPP-AAA-MIB', 'claTacacsServerRowStatus'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusServerGlobalActivatedEnabled'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusServerGlobalDeactivatedEnabled'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusServerWlanActivatedEnabled'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusServerWlanDeactivatedEnabled'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusReqTimedOutEnabled'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
cisco_lwapp_aaamib_config_group = ciscoLwappAAAMIBConfigGroup.setStatus('current')
cisco_lwapp_aaamib_save_user_config_group = object_group((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 2, 2)).setObjects(('CISCO-LWAPP-AAA-MIB', 'claSaveUserData'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
cisco_lwapp_aaamib_save_user_config_group = ciscoLwappAAAMIBSaveUserConfigGroup.setStatus('current')
cisco_lwapp_aaamib_notifs_group = notification_group((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 2, 3)).setObjects(('CISCO-LWAPP-AAA-MIB', 'ciscoLwappAAARadiusServerGlobalActivated'), ('CISCO-LWAPP-AAA-MIB', 'ciscoLwappAAARadiusServerGlobalDeactivated'), ('CISCO-LWAPP-AAA-MIB', 'ciscoLwappAAARadiusServerWlanActivated'), ('CISCO-LWAPP-AAA-MIB', 'ciscoLwappAAARadiusServerWlanDeactivated'), ('CISCO-LWAPP-AAA-MIB', 'ciscoLwappAAARadiusReqTimedOut'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
cisco_lwapp_aaamib_notifs_group = ciscoLwappAAAMIBNotifsGroup.setStatus('current')
cisco_lwapp_aaamib_status_objs_group = object_group((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 2, 4)).setObjects(('CISCO-LWAPP-AAA-MIB', 'claRadiusAddressType'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusAddress'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusPortNum'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusWlanIdx'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusClientMacAddress'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusUserName'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
cisco_lwapp_aaamib_status_objs_group = ciscoLwappAAAMIBStatusObjsGroup.setStatus('current')
cisco_lwapp_aaamibdb_entries_group = object_group((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 2, 5)).setObjects(('CISCO-LWAPP-AAA-MIB', 'claDBCurrentUsedEntries'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
cisco_lwapp_aaamibdb_entries_group = ciscoLwappAAAMIBDBEntriesGroup.setStatus('current')
cisco_lwapp_aaamib_radius_config_group = object_group((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 2, 6)).setObjects(('CISCO-LWAPP-AAA-MIB', 'claWebRadiusAuthentication'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusFallbackMode'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusFallbackUsername'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusFallbackInterval'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusAuthMacDelimiter'), ('CISCO-LWAPP-AAA-MIB', 'claRadiusAcctMacDelimiter'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
cisco_lwapp_aaamib_radius_config_group = ciscoLwappAAAMIBRadiusConfigGroup.setStatus('current')
cisco_lwapp_aaamibap_policy_config_group = object_group((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 2, 7)).setObjects(('CISCO-LWAPP-AAA-MIB', 'claAcceptMICertificate'), ('CISCO-LWAPP-AAA-MIB', 'claAcceptLSCertificate'), ('CISCO-LWAPP-AAA-MIB', 'claAllowAuthorizeLscApAgainstAAA'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
cisco_lwapp_aaamibap_policy_config_group = ciscoLwappAAAMIBAPPolicyConfigGroup.setStatus('current')
cisco_lwapp_aaamib_wlan_auth_acc_server_config_group = object_group((1, 3, 6, 1, 4, 1, 9, 9, 598, 2, 2, 8)).setObjects(('CISCO-LWAPP-AAA-MIB', 'claWlanAuthServerEnabled'), ('CISCO-LWAPP-AAA-MIB', 'claWlanAcctServerEnabled'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
cisco_lwapp_aaamib_wlan_auth_acc_server_config_group = ciscoLwappAAAMIBWlanAuthAccServerConfigGroup.setStatus('current')
mibBuilder.exportSymbols('CISCO-LWAPP-AAA-MIB', claRadiusReqTimedOutEnabled=claRadiusReqTimedOutEnabled, ciscoLwappAAAMIBCompliances=ciscoLwappAAAMIBCompliances, claConfigObjects=claConfigObjects, claAllowAuthorizeLscApAgainstAAA=claAllowAuthorizeLscApAgainstAAA, claRadiusUserName=claRadiusUserName, ciscoLwappAAAMIBNotifs=ciscoLwappAAAMIBNotifs, ciscoLwappAAAMIBConform=ciscoLwappAAAMIBConform, claRadiusFallbackUsername=claRadiusFallbackUsername, claStatusObjects=claStatusObjects, claTacacsServerRowStatus=claTacacsServerRowStatus, claRadiusServerEntry=claRadiusServerEntry, claSaveUserData=claSaveUserData, claWebRadiusAuthentication=claWebRadiusAuthentication, claWlanEntry=claWlanEntry, claRadiusWlanIdx=claRadiusWlanIdx, ciscoLwappAAAMIBGroups=ciscoLwappAAAMIBGroups, ciscoLwappAAAMIBCompliance=ciscoLwappAAAMIBCompliance, claTacacsServerSecretType=claTacacsServerSecretType, claRadiusFallbackMode=claRadiusFallbackMode, claRadiusAuthMacDelimiter=claRadiusAuthMacDelimiter, claRadiusServerTable=claRadiusServerTable, ciscoLwappAAAMIBSaveUserConfigGroup=ciscoLwappAAAMIBSaveUserConfigGroup, ciscoLwappAAAMIBComplianceRev1=ciscoLwappAAAMIBComplianceRev1, ciscoLwappAAAMIBStatusObjsGroup=ciscoLwappAAAMIBStatusObjsGroup, claRadiusPortNum=claRadiusPortNum, claRadiusServerGlobalDeactivatedEnabled=claRadiusServerGlobalDeactivatedEnabled, claWlanTable=claWlanTable, PYSNMP_MODULE_ID=ciscoLwappAAAMIB, ciscoLwappAAAMIB=ciscoLwappAAAMIB, claPriorityEntry=claPriorityEntry, ciscoLwappAAAMIBConfigGroup=ciscoLwappAAAMIBConfigGroup, claDBCurrentUsedEntries=claDBCurrentUsedEntries, claTacacsServerType=claTacacsServerType, claTacacsServerTimeout=claTacacsServerTimeout, claRadiusServerWlanActivatedEnabled=claRadiusServerWlanActivatedEnabled, claRadiusFallbackInterval=claRadiusFallbackInterval, ciscoLwappAAARadiusServerWlanDeactivated=ciscoLwappAAARadiusServerWlanDeactivated, claTacacsServerTable=claTacacsServerTable, claTacacsServerStorageType=claTacacsServerStorageType, claPriorityTable=claPriorityTable, claTacacsServerAddressType=claTacacsServerAddressType, ciscoLwappAAARadiusServerGlobalDeactivated=ciscoLwappAAARadiusServerGlobalDeactivated, claRadiusServerWlanDeactivatedEnabled=claRadiusServerWlanDeactivatedEnabled, claRadiusClientMacAddress=claRadiusClientMacAddress, ciscoLwappAAAMIBNotifsGroup=ciscoLwappAAAMIBNotifsGroup, claRadiusAcctMacDelimiter=claRadiusAcctMacDelimiter, claRadiusReqId=claRadiusReqId, claTacacsServerPriority=claTacacsServerPriority, claAcceptMICertificate=claAcceptMICertificate, claRadiusServerGlobalActivatedEnabled=claRadiusServerGlobalActivatedEnabled, ciscoLwappAAARadiusReqTimedOut=ciscoLwappAAARadiusReqTimedOut, ciscoLwappAAAMIBObjects=ciscoLwappAAAMIBObjects, claTacacsServerEnabled=claTacacsServerEnabled, ciscoLwappAAARadiusServerWlanActivated=ciscoLwappAAARadiusServerWlanActivated, claTacacsServerSecret=claTacacsServerSecret, claWlanAuthServerEnabled=claWlanAuthServerEnabled, claTacacsServerEntry=claTacacsServerEntry, claTacacsServerAddress=claTacacsServerAddress, claRadiusAddressType=claRadiusAddressType, claRadiusAddress=claRadiusAddress, claWlanAcctServerEnabled=claWlanAcctServerEnabled, ciscoLwappAAAMIBRadiusConfigGroup=ciscoLwappAAAMIBRadiusConfigGroup, ciscoLwappAAAMIBAPPolicyConfigGroup=ciscoLwappAAAMIBAPPolicyConfigGroup, claPriorityOrder=claPriorityOrder, ciscoLwappAAAMIBWlanAuthAccServerConfigGroup=ciscoLwappAAAMIBWlanAuthAccServerConfigGroup, ciscoLwappAAAMIBDBEntriesGroup=ciscoLwappAAAMIBDBEntriesGroup, claAcceptLSCertificate=claAcceptLSCertificate, ciscoLwappAAARadiusServerGlobalActivated=ciscoLwappAAARadiusServerGlobalActivated, claTacacsServerPortNum=claTacacsServerPortNum, claPriorityAuth=claPriorityAuth) |
class Solution:
def gcdOfStrings(self, str1, str2):
if len(str1)<=len(str2):
temp = str1
else:
temp = str2
m = len(temp)
x = 1
res=[""]
while x<=m:
if m%x==0 and temp[:x] * (len(str1)//x) == str1 and temp[:x] * (len(str2)//x) == str2:
res.append(temp[:x])
x+=1
return res[-1]
ob1 = Solution()
print(ob1.gcdOfStrings("ABABAB","ABAB")) | class Solution:
def gcd_of_strings(self, str1, str2):
if len(str1) <= len(str2):
temp = str1
else:
temp = str2
m = len(temp)
x = 1
res = ['']
while x <= m:
if m % x == 0 and temp[:x] * (len(str1) // x) == str1 and (temp[:x] * (len(str2) // x) == str2):
res.append(temp[:x])
x += 1
return res[-1]
ob1 = solution()
print(ob1.gcdOfStrings('ABABAB', 'ABAB')) |
#!/usr/bin/python3
# https://practice.geeksforgeeks.org/problems/extract-maximum/0
def sol(s, n):
"""
If the character is a number and l is not set set it to that index, if it
is set the r.
If character is not a number set both l and r as None
"""
l = None
r = None
mx = 0
for i in range(n):
if 48 <= ord(s[i]) <= 57:
if l == None:
# Be careful when saying "not X" keeping in mind 0 is False
l = i
r = i
mx = max(mx, int(s[l:r+1]))
else:
l = None
return mx | def sol(s, n):
"""
If the character is a number and l is not set set it to that index, if it
is set the r.
If character is not a number set both l and r as None
"""
l = None
r = None
mx = 0
for i in range(n):
if 48 <= ord(s[i]) <= 57:
if l == None:
l = i
r = i
mx = max(mx, int(s[l:r + 1]))
else:
l = None
return mx |
# Magatia (261000000) / NLC Town Center (600000000) => Free Market
sm.setReturnField()
sm.setReturnPortal()
sm.warp(910000000, 36)
| sm.setReturnField()
sm.setReturnPortal()
sm.warp(910000000, 36) |
class KeywordError(Exception):
pass
class SingletonError(Exception):
pass
class StepNotFoundError(Exception):
pass
class EmptyFeatureError(Exception):
pass
| class Keyworderror(Exception):
pass
class Singletonerror(Exception):
pass
class Stepnotfounderror(Exception):
pass
class Emptyfeatureerror(Exception):
pass |
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def buildTree(self, preorder, inorder):
"""
:type preorder: List[int]
:type inorder: List[int]
:rtype: TreeNode
"""
return self.__buildTree(preorder,inorder,0,len(preorder),0,len(inorder))
def __buildTree(self,preorder,inorder,preS,preE,inS,inE):
if preS >= preE:
return None
root = TreeNode(preorder[preS])
leftInS , leftInE = inS , inorder.index(root.val)
rightInS , rightInE = inorder.index(root.val)+1, inE
leftPreS, leftPreE = preS+1, preS+leftInE-leftInS+1
rightPreS, rightPreE = preS+leftInE-leftInS+1, preE
root.left = self.__buildTree(preorder, inorder, leftPreS, leftPreE, leftInS, leftInE)
root.right = self.__buildTree(preorder, inorder, rightPreS, rightPreE, rightInS, rightInE)
return root
sol = Solution()
preorder = [3,9,20,15,7]
inorder = [9,3,15,20,7]
print(sol.buildTree(preorder,inorder)) | class Treenode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def build_tree(self, preorder, inorder):
"""
:type preorder: List[int]
:type inorder: List[int]
:rtype: TreeNode
"""
return self.__buildTree(preorder, inorder, 0, len(preorder), 0, len(inorder))
def __build_tree(self, preorder, inorder, preS, preE, inS, inE):
if preS >= preE:
return None
root = tree_node(preorder[preS])
(left_in_s, left_in_e) = (inS, inorder.index(root.val))
(right_in_s, right_in_e) = (inorder.index(root.val) + 1, inE)
(left_pre_s, left_pre_e) = (preS + 1, preS + leftInE - leftInS + 1)
(right_pre_s, right_pre_e) = (preS + leftInE - leftInS + 1, preE)
root.left = self.__buildTree(preorder, inorder, leftPreS, leftPreE, leftInS, leftInE)
root.right = self.__buildTree(preorder, inorder, rightPreS, rightPreE, rightInS, rightInE)
return root
sol = solution()
preorder = [3, 9, 20, 15, 7]
inorder = [9, 3, 15, 20, 7]
print(sol.buildTree(preorder, inorder)) |
# Number of motors
NUM_MOTORS = 12
# Number of legs
NUM_LEGS = 4
# //////
# Legs
# //////
LEG_NAMES = ["FR", # Front Right
"FL", # Front Left
"RR", # Rear Right
"RL"] # Rear Left
# //////////////
# Joint Types:
# //////////////
JOINT_TYPES = [0, # Hip
1, # Thigh
2] # Knee
# ///////////////
# JOINT_MAPPING
# ///////////////
# Joint names are given by concatenation of
# LEG_NAME + JOINT_TYPE as in following table
#
# ______| Front Right | Front Left | Rear Right | Rear Left
# Hip | FR_0 = 0 | FL_0 = 3 | RR_0 = 6 | RL_0 = 9
# Thigh | FR_1 = 1 | FL_1 = 4 | RR_1 = 7 | RL_1 = 10
# Knee | FR_2 = 2 | FL_2 = 5 | RR_2 = 8 | RL_2 = 11
GAINS = {0: {'P': 100, 'D': 1},
1: {'P': 100, 'D': 2},
2: {'P': 100, 'D': 2}}
# Define the joint limits in rad
LEG_JOINT_LIMITS = {0: {'MIN': -0.802, 'MAX': 0.802},
1: {'MIN': -1.05, 'MAX': 4.19},
2: {'MIN': -2.7, 'MAX': -0.916}}
# Define torque limits in Nm
LEG_TORQUE_LIMITS = {0: {'MIN': -10, 'MAX': 10},
1: {'MIN': -10, 'MAX': 10},
2: {'MIN': -10, 'MAX': 10}}
LEG_JOINT_INITS = {0: 0,
1: 0,
2: 0}
LEG_JOINT_OFFSETS = {0: 0,
1: 0,
2: 0}
# TODO: Do it more concisely
# stand_angles = 4*[0.0, 0.77, -1.82]
# init_angles = [-0.25, 1.14, -2.72,
# 0.25, 1.14, -2.72,
# -0.25, 1.14, -2.72,
# 0.25, 1.14, -2.72]
# ////////////////////////////////////////////////////////////////////////
JOINT_CONSTANTS = {
'OFFSETS': [],
'INITS': [],
'POS_LIMITS': {'MIN': [],
'MAX': []},
'TORQUE_LIMITS': {'MIN': [],
'MAX': []},
'GAINS': {'P': [],
'D': []}}
for JOINT in range(NUM_MOTORS):
JOINT_ID = JOINT % 3
JOINT_CONSTANTS['OFFSETS'].append(LEG_JOINT_INITS[JOINT_ID])
JOINT_CONSTANTS['INITS'].append(LEG_JOINT_OFFSETS[JOINT_ID])
for BOUND in {'MIN', 'MAX'}:
POS_LIMIT = LEG_JOINT_LIMITS[JOINT_ID][BOUND]
JOINT_CONSTANTS['TORQUE_LIMITS'][BOUND].append(POS_LIMIT)
JOINT_CONSTANTS['POS_LIMITS'][BOUND].append(POS_LIMIT)
for GAIN_TYPE in {'P', 'D'}:
GAIN = GAINS[JOINT_ID][GAIN_TYPE]
JOINT_CONSTANTS['GAINS'][GAIN_TYPE].append(GAIN)
JOINT_LIMITS = JOINT_CONSTANTS['POS_LIMITS']
JOINT_LIMITS_MIN = JOINT_LIMITS['MIN']
JOINT_LIMITS_MAX = JOINT_LIMITS['MAX']
TORQUE_LIMITS = JOINT_CONSTANTS['TORQUE_LIMITS']
TORQUE_LIMITS_MIN = TORQUE_LIMITS['MIN']
TORQUE_LIMITS_MAX = TORQUE_LIMITS['MAX']
JOINT_OFFSETS = JOINT_CONSTANTS['OFFSETS']
JOINT_INITS = JOINT_CONSTANTS['INITS']
POSITION_GAINS = JOINT_CONSTANTS['GAINS']['P']
DAMPING_GAINS = JOINT_CONSTANTS['GAINS']['D']
# ////////////////////////////////////////////////////////////////////////
# TODO: Add high level commands scaling factors
# KINEMATIC_PARAMETERS
LEG_KINEMATICS = [0.0838,
0.2,
0.2]
TRUNK_LENGTH = 0.1805 * 2
TRUNK_WIDTH = 0.047 * 2
LEGS_BASES = [[TRUNK_LENGTH/2, -TRUNK_WIDTH/2],
[TRUNK_LENGTH/2, TRUNK_WIDTH/2],
[-TRUNK_LENGTH/2, -TRUNK_WIDTH/2],
[-TRUNK_LENGTH/2, TRUNK_WIDTH/2]]
# LEG_DYNAMICS =
# BODY_DYNAMICS =
| num_motors = 12
num_legs = 4
leg_names = ['FR', 'FL', 'RR', 'RL']
joint_types = [0, 1, 2]
gains = {0: {'P': 100, 'D': 1}, 1: {'P': 100, 'D': 2}, 2: {'P': 100, 'D': 2}}
leg_joint_limits = {0: {'MIN': -0.802, 'MAX': 0.802}, 1: {'MIN': -1.05, 'MAX': 4.19}, 2: {'MIN': -2.7, 'MAX': -0.916}}
leg_torque_limits = {0: {'MIN': -10, 'MAX': 10}, 1: {'MIN': -10, 'MAX': 10}, 2: {'MIN': -10, 'MAX': 10}}
leg_joint_inits = {0: 0, 1: 0, 2: 0}
leg_joint_offsets = {0: 0, 1: 0, 2: 0}
joint_constants = {'OFFSETS': [], 'INITS': [], 'POS_LIMITS': {'MIN': [], 'MAX': []}, 'TORQUE_LIMITS': {'MIN': [], 'MAX': []}, 'GAINS': {'P': [], 'D': []}}
for joint in range(NUM_MOTORS):
joint_id = JOINT % 3
JOINT_CONSTANTS['OFFSETS'].append(LEG_JOINT_INITS[JOINT_ID])
JOINT_CONSTANTS['INITS'].append(LEG_JOINT_OFFSETS[JOINT_ID])
for bound in {'MIN', 'MAX'}:
pos_limit = LEG_JOINT_LIMITS[JOINT_ID][BOUND]
JOINT_CONSTANTS['TORQUE_LIMITS'][BOUND].append(POS_LIMIT)
JOINT_CONSTANTS['POS_LIMITS'][BOUND].append(POS_LIMIT)
for gain_type in {'P', 'D'}:
gain = GAINS[JOINT_ID][GAIN_TYPE]
JOINT_CONSTANTS['GAINS'][GAIN_TYPE].append(GAIN)
joint_limits = JOINT_CONSTANTS['POS_LIMITS']
joint_limits_min = JOINT_LIMITS['MIN']
joint_limits_max = JOINT_LIMITS['MAX']
torque_limits = JOINT_CONSTANTS['TORQUE_LIMITS']
torque_limits_min = TORQUE_LIMITS['MIN']
torque_limits_max = TORQUE_LIMITS['MAX']
joint_offsets = JOINT_CONSTANTS['OFFSETS']
joint_inits = JOINT_CONSTANTS['INITS']
position_gains = JOINT_CONSTANTS['GAINS']['P']
damping_gains = JOINT_CONSTANTS['GAINS']['D']
leg_kinematics = [0.0838, 0.2, 0.2]
trunk_length = 0.1805 * 2
trunk_width = 0.047 * 2
legs_bases = [[TRUNK_LENGTH / 2, -TRUNK_WIDTH / 2], [TRUNK_LENGTH / 2, TRUNK_WIDTH / 2], [-TRUNK_LENGTH / 2, -TRUNK_WIDTH / 2], [-TRUNK_LENGTH / 2, TRUNK_WIDTH / 2]] |
# draw a playing board
def DrawBoard(rows,cols):
dash = " ---"
hline = "| "
for i in range(0,rows):
print (dash * (cols))
print (hline * (cols +1))
DrawBoard(3, 3)
| def draw_board(rows, cols):
dash = ' ---'
hline = '| '
for i in range(0, rows):
print(dash * cols)
print(hline * (cols + 1))
draw_board(3, 3) |
def read_file(test = True):
if test:
filename = '../tests/day3.txt'
else:
filename = '../input/day3.txt'
with open(filename) as file:
temp = list()
for line in file:
temp.append(line.strip())
return temp
def puzzle1():
temp = read_file(False)
houses = set()
for line in temp:
pos = [0,0]
for move in line:
if move == "^":
pos[0] += 1
houses.add(tuple(pos))
elif move == 'v':
pos[0] -= 1
houses.add(tuple(pos))
elif move == ">":
pos[1] += 1
houses.add(tuple(pos))
elif move == '<':
pos[1] -= 1
houses.add(tuple(pos))
print(len(houses))
def puzzle2():
temp = read_file(False)
houses = set()
pos1 = [0,0]
pos2 = [0,0]
houses.add(tuple(pos1))
for line in temp:
pos1 = [0,0]
pos2 = [0,0]
for i, move in enumerate(line):
if i % 2 == 0:
if move == "^":
pos1[0] += 1
houses.add(tuple(pos1))
elif move == 'v':
pos1[0] -= 1
houses.add(tuple(pos1))
elif move == ">":
pos1[1] += 1
houses.add(tuple(pos1))
elif move == '<':
pos1[1] -= 1
houses.add(tuple(pos1))
else:
if move == "^":
pos2[0] += 1
houses.add(tuple(pos2))
elif move == 'v':
pos2[0] -= 1
houses.add(tuple(pos2))
elif move == ">":
pos2[1] += 1
houses.add(tuple(pos2))
elif move == '<':
pos2[1] -= 1
houses.add(tuple(pos2))
print(len(houses))
puzzle1()
puzzle2() | def read_file(test=True):
if test:
filename = '../tests/day3.txt'
else:
filename = '../input/day3.txt'
with open(filename) as file:
temp = list()
for line in file:
temp.append(line.strip())
return temp
def puzzle1():
temp = read_file(False)
houses = set()
for line in temp:
pos = [0, 0]
for move in line:
if move == '^':
pos[0] += 1
houses.add(tuple(pos))
elif move == 'v':
pos[0] -= 1
houses.add(tuple(pos))
elif move == '>':
pos[1] += 1
houses.add(tuple(pos))
elif move == '<':
pos[1] -= 1
houses.add(tuple(pos))
print(len(houses))
def puzzle2():
temp = read_file(False)
houses = set()
pos1 = [0, 0]
pos2 = [0, 0]
houses.add(tuple(pos1))
for line in temp:
pos1 = [0, 0]
pos2 = [0, 0]
for (i, move) in enumerate(line):
if i % 2 == 0:
if move == '^':
pos1[0] += 1
houses.add(tuple(pos1))
elif move == 'v':
pos1[0] -= 1
houses.add(tuple(pos1))
elif move == '>':
pos1[1] += 1
houses.add(tuple(pos1))
elif move == '<':
pos1[1] -= 1
houses.add(tuple(pos1))
elif move == '^':
pos2[0] += 1
houses.add(tuple(pos2))
elif move == 'v':
pos2[0] -= 1
houses.add(tuple(pos2))
elif move == '>':
pos2[1] += 1
houses.add(tuple(pos2))
elif move == '<':
pos2[1] -= 1
houses.add(tuple(pos2))
print(len(houses))
puzzle1()
puzzle2() |
data = open("input.txt", "r").readlines()
score_map = {
")": 3,
"]": 57,
"}": 1197,
">": 25137
}
def get_opening_bracket(bracket):
if bracket == ")":
return "("
if bracket == "]":
return "["
if bracket == "}":
return "{"
if bracket == ">":
return "<"
score = 0
def parse(line: str):
stack = []
for bracket in line.strip():
if bracket in ["{", "(", "<", "["]:
stack.append(bracket)
else:
last = stack.pop()
expected = get_opening_bracket(bracket)
if last != expected:
print("corrupt expected", expected, " found ", bracket)
return score_map[bracket]
return 0
for line in data:
score += parse(line)
print(f"The answer to part 1 is ", score)
| data = open('input.txt', 'r').readlines()
score_map = {')': 3, ']': 57, '}': 1197, '>': 25137}
def get_opening_bracket(bracket):
if bracket == ')':
return '('
if bracket == ']':
return '['
if bracket == '}':
return '{'
if bracket == '>':
return '<'
score = 0
def parse(line: str):
stack = []
for bracket in line.strip():
if bracket in ['{', '(', '<', '[']:
stack.append(bracket)
else:
last = stack.pop()
expected = get_opening_bracket(bracket)
if last != expected:
print('corrupt expected', expected, ' found ', bracket)
return score_map[bracket]
return 0
for line in data:
score += parse(line)
print(f'The answer to part 1 is ', score) |
#write a program to check whether the given number is Disarium or not?
n = int(input("Enter number:"))
i= 1
sum = 0
num = n
while(num!=0):
rem = num%10
sum = sum*10+rem
num = num//10
num = sum
sum = 0
while(num!= 0):
rem = num % 10
sum = sum + pow(rem,i)
num = num//10
i+=1
if sum == n:
print(n,"is a 'Disarium Number'.")
else:
print(n,"is not a 'Disarium Number'.")
| n = int(input('Enter number:'))
i = 1
sum = 0
num = n
while num != 0:
rem = num % 10
sum = sum * 10 + rem
num = num // 10
num = sum
sum = 0
while num != 0:
rem = num % 10
sum = sum + pow(rem, i)
num = num // 10
i += 1
if sum == n:
print(n, "is a 'Disarium Number'.")
else:
print(n, "is not a 'Disarium Number'.") |
'''
Created by Vedant Christian
Created on 18 / 08 / 2020
'''
terms = int(input("How many terms? "))
base = int(input("What is the base? "))
result = list(map(lambda x: base ** x, range(terms+1)))
print("The total terms is: ", terms)
print("The base is ", base)
for i in range(terms+1):
print(base, "raied to the power", i, "is", result[i]) | """
Created by Vedant Christian
Created on 18 / 08 / 2020
"""
terms = int(input('How many terms? '))
base = int(input('What is the base? '))
result = list(map(lambda x: base ** x, range(terms + 1)))
print('The total terms is: ', terms)
print('The base is ', base)
for i in range(terms + 1):
print(base, 'raied to the power', i, 'is', result[i]) |
class TryNode(object):
def __init__(self, line, start, end, handler):
self.buf = ""
self.exception = ""
self.start = None
self.end = None
self.handler = None
self.__parse(line, start, end, handler)
def __repr__(self):
return "Try: %s {%s .. %s} %s" % \
(self.exception, start.index, end.index, handler.index)
def __parse(self, line, start, end, handler):
self.buf = line
self.start = start
self.end = end
end.tries.append(self)
self.handler = handler
segs = self.buf.split()
self.exception = segs[1]
def reload(self):
pass | class Trynode(object):
def __init__(self, line, start, end, handler):
self.buf = ''
self.exception = ''
self.start = None
self.end = None
self.handler = None
self.__parse(line, start, end, handler)
def __repr__(self):
return 'Try: %s {%s .. %s} %s' % (self.exception, start.index, end.index, handler.index)
def __parse(self, line, start, end, handler):
self.buf = line
self.start = start
self.end = end
end.tries.append(self)
self.handler = handler
segs = self.buf.split()
self.exception = segs[1]
def reload(self):
pass |
class Solution:
def maxProfit(self, prices: List[int]) -> int:
first_buy, first_sell = inf, 0
second_buy, second_sell = inf, 0
for price in prices:
first_buy = min(first_buy, price)
first_sell = max(first_sell, price - first_buy)
second_buy = min(second_buy, price - first_sell)
second_sell = max(second_sell, price - second_buy)
return second_sell
| class Solution:
def max_profit(self, prices: List[int]) -> int:
(first_buy, first_sell) = (inf, 0)
(second_buy, second_sell) = (inf, 0)
for price in prices:
first_buy = min(first_buy, price)
first_sell = max(first_sell, price - first_buy)
second_buy = min(second_buy, price - first_sell)
second_sell = max(second_sell, price - second_buy)
return second_sell |
# Copyright (c) 2007-2010 Twisted Matrix Laboratories.
# See LICENSE for details.
"""
Tests for L{twisted.internet.application}.
"""
| """
Tests for L{twisted.internet.application}.
""" |
n, k = input().split(' ')
n, k = int(n), int(k)
c = sorted(list(map(int, input().split(' '))))
count = [0] * k
count_i, min_sum = 0, 0
for i in reversed(range(n)):
min_sum += (count[count_i]+1) * c[i]
count[count_i] += 1
count_i += 1
if count_i >= k:
count_i = 0
#print (count)
print (min_sum)
| (n, k) = input().split(' ')
(n, k) = (int(n), int(k))
c = sorted(list(map(int, input().split(' '))))
count = [0] * k
(count_i, min_sum) = (0, 0)
for i in reversed(range(n)):
min_sum += (count[count_i] + 1) * c[i]
count[count_i] += 1
count_i += 1
if count_i >= k:
count_i = 0
print(min_sum) |
def split(word):
return [int(char) for char in word]
data = '222221202212222122222211222222222222222222222202222022222222222002221222222222220222202222202122222020222222021020220022122222222220222222202222222222222221202202222122222222222222222222222222222202222022222222222022220222222222220222212222212222222220222222221121222022022222222222222222212222222222222220202202222122222210222222222222222222222202222122222222222212222222222022222222212022212122222020222222122021221222122222222221222222222222222222222221202202222022222221222222222222222222222212222022222222222022220222222122222222202122222022222021222222220220220022222222222220222222202222222222222221202222222122222220222212222222222222222202222222222222222022222212222022220222202022202022222120222222121020222122222222222221222222202222222222222221202212222022222221222222222222222222222202222022222222222212220222202022220222202222202022222121222222020021222122022222222220222222212222222220222220212222222122222211222212222222222222222222222122222222222102222202222022222222202222202022222021222222120221220222122222222020222222212222222222222222202212222022222222222222222222222222222212222122222222222012222222202022222222212222222222222120222222122021222122222222222120222222202222222221222121202222222222222201222202222222222222222222222222222222222112221212202222222222202122212122222121222222122020221122122222222220222222212222222222222120212212222222222210222212222222222222222212222122222222222102221212202022222222212022222022222122222222221221222222022222222021222222222222222221222222222212222022222211222202222222222222222212202222222222222112221202222022220222202222202021222121222222220022220122022222222222222222212022222220222020202202222122222211222202222222202222222222222022222222222022222202222222222222202222222120222121222222222120222122122222222221222222202222222222222122202222222122222211220222222222212222022212202122222222222212222222222122222222212022212020222022222222021022221222222222222220222222202022222222222120222222222022222222222222222222202222022202202122222222222012222202212022221222202122212220222120222222222022222022222222222021222221222122222220022220212202222122222200220202222222222222022202200122222222222002221212202122221222202122212222222121222222221120222222122222222221222222212222222220222020222212222022222222220212222222202222122202221122222222222202222222222122222022222122212022222120222222222121220222022222222021222222212022222220122022212202222122222212220212222222212222122222212022222222222222220202212122220122202022212122222022222222021122221122122222222021222221202222222220122100222202122122222200221202222222202222122212201022222222222122220202122022222122212122212020222120222222120121220122222222222220222222212122222220122122222202122022222201222202222222222222022212201122222222222102220212202122222122222022222020222022222222221021222022022222222022222222222122222220222011202222122222222200221222222222212212222202220222222222222002221212022122221022222222212021222220222222122220221222022222222122222221222222222220022201222202122222222212221212222222212002022222201122222222222112222212022022221122222222202120222221222222220020222022122222222122222222212022222220222001202212122122222222222212222222212222022222222222022222222212222222212122221122212122202122222222222222222021220222122222222022222222202222222222222101212212222122222201222222222222212202122212210122122222222002222202202122220222202022212221222122212222020220221022222222222101222220202022222220122110222212122222222222220202222222202122122212202022122222222102221212022222222222202122202022222122222222020221221122022222222122222221202022222221022202202222022122222221220222222222222022222202202222221222222222222202202122220222202122222220222020212222021122220122222222222121222220222022222221122120212222122122222222221202222222202122222222211022222222222222222222102122220122202222212120222122222222122222221022122222222022222222202122222222022021222222222122222210221212222222202022122222202022222222222112222222122222222022222222212220222120202222220021221122022222222121222220202222222221022200212212222022222220221202222222212212022222221122022222222222220222022022221122212222212022222221222222122122221022222222222001222221202022222222022001222212222122222200220212222222212212022222200122220222222212221202022222221222222022222122222020222222020022222222222222222010222222202122222222222122202222022022122221222202222222212012022212200122120222222022220202102222221022212122222122222220212222220222222222022222222001222222202122222222022202222212222022222220221202222222202202222222221022222222222212222212122022222122202122222020222222222222121222222022122222222121222222212022222220222212222202222122022212222202222222212102022202221022222222022222220202002022221022202222202120222020212222220121221222122222222002222220222022222220222021222221222222022200222222222222202002022212220022222222222112221202212222222022212022212222222221212222120220221022222222222201222222221222222222122200202200222222122211221212222222222222222222220222222222122112221202112122221022212022212120222220212222121020222222122222222021222222222022222221222121212210222222122222221202222222202102012212221022022222122002220212122222221222222222202221222021202222121221220022222222222211222221221022222220022021202212022122122220220222222222212022112212220022220222222102220212122222220022222222202020222021222222020221221022222222222102222221200222222221022212202210222022122200220202222222222002222222212122222222222022220212112222220222212222202121222121212222221021222122122222222121222220211222222221222120222210022222222220220202222222212122102202202022020222022212220222002022222222202022202221222222212222121021020222022222222102222220210022222222222010202222122022222212221212222222222202122202201222120222002022220202022222221022222122222120222021222222222121122022222222222022222220211202222200022221212212120022022201220202222222222002102222212222121222102112220222102222220122202022212120222222202222121120120022022222222210222221220212222202222202212200220222222200222212222222202022022222212222221222012102220212102022222022012222212021222121222222021120120122022222222202222221222022222202022012222222122022122220221212222222212122002212220221021222002222222222002022222222202122212221222021222222120020221122022222222202222221212222222202222022212200021122222221220202222222202212202222201020120222222012222202202122221222002122112220222021212222120122021122122222222122222222200102222202022212012221022122122212222212222222012012122222212022022222122012221212002122222122112222102022222022212222222220121022022222222011222221200202222220122021002200022022022201222222222222122212002202212120022222012212222202002122222022002222212021222022202221221020022022122222222120222220212112222222222210102222120222022200220202222222102112012222221222120222002112220212112122220222202122212220222121222220020101022122222222222110222220202202222201122011122200220222222222220222222222122102202222212120120222212002221212112022222022002022002120222020222220121112221122222222222210222221200202222212022112222220022222122220221212222222112212022222222020020222012022221212112122221022202022202221222120212200220021221022222222222221222220221022222220022010222212020022222222220202222222102112102202210020221022022112222202102122222222112222012222222120212221121001020222222222222221222221211222222212122122122200220222122211221202222022002222212222000221121022122012220202122122221022122222012221222120212210221110022022222222222022222222220012222221222200212202120222122220220212222122212002202222021222122222102212121212112022222022102002102020222020212211220001022022222222222121222222222112222202022121002202121122222221220202122222002022022222110222222222222222020212222122220122002222022022222022212211020122121122022222222221222221210002222212022101122200020222122221220222122122112122002222020022222122202012021212222122222222002002122220222021212222121202122022222222222210222221211022222221122122022212220122222200222202122122022012112212112021122022112202222212022022221122222102222122222022222222020210220222122222222122222220211002222201122202022221222122022202220222122122222022222222221120020222222212121212102122222022022212122120222122222221120210122222222022222100222221210122222202122112222211222022222201222202220122102002222222111221201222101212020222122222221222022002222220222022202221120011022122022122222202222220221202222002122011122201120122022220222202021022012112102202000121201222210212020212122022221222112112112020222222222222220211110122022122222012222222202202222202022022222211122022122201220212221122002002112212221120121022000212220202102122222222112122022220222021202220220020010022122122222210222220221112222200122201012200122222122200222212122220121212222202000120110122101212220212202122220122222022022020222120222220122201112022122122222010222220220012222001222211112222022122122202220222121220110222202222001220101122100112122212002122221122122212202020222020212210022212111022022222222121222222221112222112222202102222222222122200222222120222012102122202221220102022100022120222122222220122122120102122222222212212020200201122022022222221222221220002222211022111012212221222222220221212120120112222012202120121101222101002220202120120122222222111112221222121202210221001000222122022222000222222211222222001222110202212022222222212221212221120100012102202210020211022101122021212122222022122112221102120222022212201022120111222022222222210222222211112222120122100012201020122022212221222220120200012122202200222121122101112221221211022120222122222022221222021222210120211112022122222222112222221210112222022222000212201020222222211221210221121000102102212020121120022102022120202201220220222222010012222222121202202000002222222022022222010222222202202222020222002122212122222022222221010121221212112202212111021111222022022020221000120122222202012212120222012222210012221102022222022222021222220201102222110022110002220020222122212220021222120002212202202121222200022200112021202110020221122122222122220222110222211211022111222022122222011222221210012222210022100212212222222002122220202222222102222222112110022111222020022221211110121221022112020012220222011212210220101100222122122222000222221210112222100122001222222120222202021222000120221221122102112121020210222010222122210212120122222012211102122222021212201211202220222022122222221222220201202222221222222212200220122202110222202120020122022222112010021000222210122022220011122022222222022222021220002222020011212102122122222222002222222221112222112222011002212122222112002201200022120221002102012220022000122220002222200010021121122002002122221222121202101121101012022222222222121222222200002222112022020102202122022112210200101021221100222202212021021111022120222020200110222220222122220222222220000222110211022120122222222222000222221210112222020122012202212122222002001210210120122220212202002100021220022212122121200102021021222202120122021222220202220001001221022122122222122222220212122222112022210122212121022012011201010020220222022112112211222011122212112022212022221022022002012112221221221202022022200210122222222222222222221212112222002222122102222020222102222222020220220120212112202111020212222012102122221222122121222212222212222221210022021222212101222022122222211122222201021222121002112202210220122022020221212121122110222212102222020210022122022022222102021122222212002012122200000022102111201200222122022222000122222220000222110102200012220022222122022221220220221011122102212102220002022101102222220121120022122212200102122200102022102200202122022122022222122122221222200222120222002122202022022112220211122021022111222002022120121220022122022222211211021122022122102022222220201112112112002002122122022222020222222200111220102222020122221221222202122202210221220121122022212220120011022011002121211212121022222022022212221212221102212022022101122122222222110222222220021220202202100012212221122202022220211021222012112222002100120010022022212221201121222221222212001122020200212002202110101121122022122222002022222120011222001002210112202022222002022212121121120021102012202002221120022221002022002211021120222222201020221220110012120201202111022222222222202022220212020221002022202002202020022112222221022121020221102212022121221220022121012122000101020020222212111202020210200102121101001210122022022222021122221002222222111112002012221220022102201220012122222101022212122200220021122220112120220202020020222022120002122210121002121001211222022122022222101122221211121220202022120112212021222022100201100020120112002212002001022021222121102222101001120220222212200121122210112122011211010220022022022222100122222010200222222212100222222020122022202211121020122002102222112020022200222122022222002001121120222102001001020221220222220021121202022222022222011022221120212222111222100122202222222211220210211020120212102112212021020020022112012122202110220120122102221011121211000012112201221211012122022222120222222000021222212222211012220022222102021201222022220022022222002201122100022201212022011000021000222002200100222220212022212111002222012122122222201222220020100221120022102212200120222102002201101221120001122022022010121121222220222222210202120101022122121011020020121022222102012010202122122222212022221002101222101012100222220120022202111211202221221201002202222022121110222200202022021100020010122012102011222220122022201212020200222022022222010122222021222021001122210002221120122111220221121220220110002002112001122000022012122121000212022212122212121100122122201110221211112102002122022222020022220001112221112202020102221022022022012201221120221111022212112112121111122022202221110101021122122222210111020111221200011001021020002222122222201222220202101121201112010122211122222011112201102221022200122022012121121200122010212021111022021112122122000021122210100000021000220122222022122222121122220020012222020202112122220122022122112202211220222202212202000120022200222201012022201220020200122112022010221011022120220102201222202022122222220020222201010022010122222012222022222102100212200221121221022102110021220010222201211120121120120020022212110002120220112122111220111221202022222222211121220110021020102012100102220222222211202220222021021002202212110222120012022121222121212202122220022222112020022122112121112111202212122022122222101221221001210122220202102222202220022012222210021120221211012212022222021011122012021222022110220020022112000022022200122012220212102100022122022222000121120211020120100212200012200122022112211210212122021212202022121011022000120022012221220220020121122122222120120201000121220210002210002122222220201121121101101022110122010112202021222122120222021020020001022102120202021212121210011121110021021012122012111212021121201200021010001200012122222220201021120000011020212002210222201220022220222211122022120111012022101201221220212002122120112112221001122101021212121020100202201020202020012222222222010021222201002121221201202010111012000000120021022102012211120100001100000220102221021011011002200112010111012101102112201021120220001010120200100111202002112122101210121'
wide, tall = 25, 6
img = split(data)
bm = wide * tall
it = int(len(img) / bm)
layer_zeros = {}
for i in range(it):
layer = img[(bm*i):(bm*(i+1))]
print((bm*i),(bm*(i+1)))
zeros = 0
for num in layer:
if num == 0:
zeros += 1
layer_zeros[i] = zeros
min_layer = 0
minl = layer_zeros[0]
for k, v in layer_zeros.items():
if minl > v:
min_layer = k
minl = v
layer = img[(bm*min_layer):(bm*(min_layer+1))]
num_1 = 0
num_2 = 0
for num in layer:
if num == 1:
num_1 += 1
elif num == 2:
num_2 += 1
print(num_1 * num_2) | def split(word):
return [int(char) for char in word]
data = '222221202212222122222211222222222222222222222202222022222222222002221222222222220222202222202122222020222222021020220022122222222220222222202222222222222221202202222122222222222222222222222222222202222022222222222022220222222222220222212222212222222220222222221121222022022222222222222222212222222222222220202202222122222210222222222222222222222202222122222222222212222222222022222222212022212122222020222222122021221222122222222221222222222222222222222221202202222022222221222222222222222222222212222022222222222022220222222122222222202122222022222021222222220220220022222222222220222222202222222222222221202222222122222220222212222222222222222202222222222222222022222212222022220222202022202022222120222222121020222122222222222221222222202222222222222221202212222022222221222222222222222222222202222022222222222212220222202022220222202222202022222121222222020021222122022222222220222222212222222220222220212222222122222211222212222222222222222222222122222222222102222202222022222222202222202022222021222222120221220222122222222020222222212222222222222222202212222022222222222222222222222222222212222122222222222012222222202022222222212222222222222120222222122021222122222222222120222222202222222221222121202222222222222201222202222222222222222222222222222222222112221212202222222222202122212122222121222222122020221122122222222220222222212222222222222120212212222222222210222212222222222222222212222122222222222102221212202022222222212022222022222122222222221221222222022222222021222222222222222221222222222212222022222211222202222222222222222212202222222222222112221202222022220222202222202021222121222222220022220122022222222222222222212022222220222020202202222122222211222202222222202222222222222022222222222022222202222222222222202222222120222121222222222120222122122222222221222222202222222222222122202222222122222211220222222222212222022212202122222222222212222222222122222222212022212020222022222222021022221222222222222220222222202022222222222120222222222022222222222222222222202222022202202122222222222012222202212022221222202122212220222120222222222022222022222222222021222221222122222220022220212202222122222200220202222222222222022202200122222222222002221212202122221222202122212222222121222222221120222222122222222221222222212222222220222020222212222022222222220212222222202222122202221122222222222202222222222122222022222122212022222120222222222121220222022222222021222222212022222220122022212202222122222212220212222222212222122222212022222222222222220202212122220122202022212122222022222222021122221122122222222021222221202222222220122100222202122122222200221202222222202222122212201022222222222122220202122022222122212122212020222120222222120121220122222222222220222222212122222220122122222202122022222201222202222222222222022212201122222222222102220212202122222122222022222020222022222222221021222022022222222022222222222122222220222011202222122222222200221222222222212212222202220222222222222002221212022122221022222222212021222220222222122220221222022222222122222221222222222220022201222202122222222212221212222222212002022222201122222222222112222212022022221122222222202120222221222222220020222022122222222122222222212022222220222001202212122122222222222212222222212222022222222222022222222212222222212122221122212122202122222222222222222021220222122222222022222222202222222222222101212212222122222201222222222222212202122212210122122222222002222202202122220222202022212221222122212222020220221022222222222101222220202022222220122110222212122222222222220202222222202122122212202022122222222102221212022222222222202122202022222122222222020221221122022222222122222221202022222221022202202222022122222221220222222222222022222202202222221222222222222202202122220222202122222220222020212222021122220122222222222121222220222022222221122120212222122122222222221202222222202122222222211022222222222222222222102122220122202222212120222122222222122222221022122222222022222222202122222222022021222222222122222210221212222222202022122222202022222222222112222222122222222022222222212220222120202222220021221122022222222121222220202222222221022200212212222022222220221202222222212212022222221122022222222222220222022022221122212222212022222221222222122122221022222222222001222221202022222222022001222212222122222200220212222222212212022222200122220222222212221202022222221222222022222122222020222222020022222222222222222010222222202122222222222122202222022022122221222202222222212012022212200122120222222022220202102222221022212122222122222220212222220222222222022222222001222222202122222222022202222212222022222220221202222222202202222222221022222222222212222212122022222122202122222020222222222222121222222022122222222121222222212022222220222212222202222122022212222202222222212102022202221022222222022222220202002022221022202222202120222020212222220121221222122222222002222220222022222220222021222221222222022200222222222222202002022212220022222222222112221202212222222022212022212222222221212222120220221022222222222201222222221222222222122200202200222222122211221212222222222222222222220222222222122112221202112122221022212022212120222220212222121020222222122222222021222222222022222221222121212210222222122222221202222222202102012212221022022222122002220212122222221222222222202221222021202222121221220022222222222211222221221022222220022021202212022122122220220222222222212022112212220022220222222102220212122222220022222222202020222021222222020221221022222222222102222221200222222221022212202210222022122200220202222222222002222222212122222222222022220212112222220222212222202121222121212222221021222122122222222121222220211222222221222120222210022222222220220202222222212122102202202022020222022212220222002022222222202022202221222222212222121021020222022222222102222220210022222222222010202222122022222212221212222222222202122202201222120222002022220202022222221022222122222120222021222222222121122022222222222022222220211202222200022221212212120022022201220202222222222002102222212222121222102112220222102222220122202022212120222222202222121120120022022222222210222221220212222202222202212200220222222200222212222222202022022222212222221222012102220212102022222022012222212021222121222222021120120122022222222202222221222022222202022012222222122022122220221212222222212122002212220221021222002222222222002022222222202122212221222021222222120020221122022222222202222221212222222202222022212200021122222221220202222222202212202222201020120222222012222202202122221222002122112220222021212222120122021122122222222122222222200102222202022212012221022122122212222212222222012012122222212022022222122012221212002122222122112222102022222022212222222220121022022222222011222221200202222220122021002200022022022201222222222222122212002202212120022222012212222202002122222022002222212021222022202221221020022022122222222120222220212112222222222210102222120222022200220202222222102112012222221222120222002112220212112122220222202122212220222121222220020101022122222222222110222220202202222201122011122200220222222222220222222222122102202222212120120222212002221212112022222022002022002120222020222220121112221122222222222210222221200202222212022112222220022222122220221212222222112212022222222020020222012022221212112122221022202022202221222120212200220021221022222222222221222220221022222220022010222212020022222222220202222222102112102202210020221022022112222202102122222222112222012222222120212221121001020222222222222221222221211222222212122122122200220222122211221202222022002222212222000221121022122012220202122122221022122222012221222120212210221110022022222222222022222222220012222221222200212202120222122220220212222122212002202222021222122222102212121212112022222022102002102020222020212211220001022022222222222121222222222112222202022121002202121122222221220202122222002022022222110222222222222222020212222122220122002222022022222022212211020122121122022222222221222221210002222212022101122200020222122221220222122122112122002222020022222122202012021212222122222222002002122220222021212222121202122022222222222210222221211022222221122122022212220122222200222202122122022012112212112021122022112202222212022022221122222102222122222022222222020210220222122222222122222220211002222201122202022221222122022202220222122122222022222222221120020222222212121212102122222022022212122120222122222221120210122222222022222100222221210122222202122112222211222022222201222202220122102002222222111221201222101212020222122222221222022002222220222022202221120011022122022122222202222220221202222002122011122201120122022220222202021022012112102202000121201222210212020212122022221222112112112020222222222222220211110122022122222012222222202202222202022022222211122022122201220212221122002002112212221120121022000212220202102122222222112122022220222021202220220020010022122122222210222220221112222200122201012200122222122200222212122220121212222202000120110122101212220212202122220122222022022020222120222220122201112022122122222010222220220012222001222211112222022122122202220222121220110222202222001220101122100112122212002122221122122212202020222020212210022212111022022222222121222222221112222112222202102222222222122200222222120222012102122202221220102022100022120222122222220122122120102122222222212212020200201122022022222221222221220002222211022111012212221222222220221212120120112222012202120121101222101002220202120120122222222111112221222121202210221001000222122022222000222222211222222001222110202212022222222212221212221120100012102202210020211022101122021212122222022122112221102120222022212201022120111222022222222210222222211112222120122100012201020122022212221222220120200012122202200222121122101112221221211022120222122222022221222021222210120211112022122222222112222221210112222022222000212201020222222211221210221121000102102212020121120022102022120202201220220222222010012222222121202202000002222222022022222010222222202202222020222002122212122222022222221010121221212112202212111021111222022022020221000120122222202012212120222012222210012221102022222022222021222220201102222110022110002220020222122212220021222120002212202202121222200022200112021202110020221122122222122220222110222211211022111222022122222011222221210012222210022100212212222222002122220202222222102222222112110022111222020022221211110121221022112020012220222011212210220101100222122122222000222221210112222100122001222222120222202021222000120221221122102112121020210222010222122210212120122222012211102122222021212201211202220222022122222221222220201202222221222222212200220122202110222202120020122022222112010021000222210122022220011122022222222022222021220002222020011212102122122222222002222222221112222112222011002212122222112002201200022120221002102012220022000122220002222200010021121122002002122221222121202101121101012022222222222121222222200002222112022020102202122022112210200101021221100222202212021021111022120222020200110222220222122220222222220000222110211022120122222222222000222221210112222020122012202212122222002001210210120122220212202002100021220022212122121200102021021222202120122021222220202220001001221022122122222122222220212122222112022210122212121022012011201010020220222022112112211222011122212112022212022221022022002012112221221221202022022200210122222222222222222221212112222002222122102222020222102222222020220220120212112202111020212222012102122221222122121222212222212222221210022021222212101222022122222211122222201021222121002112202210220122022020221212121122110222212102222020210022122022022222102021122222212002012122200000022102111201200222122022222000122222220000222110102200012220022222122022221220220221011122102212102220002022101102222220121120022122212200102122200102022102200202122022122022222122122221222200222120222002122202022022112220211122021022111222002022120121220022122022222211211021122022122102022222220201112112112002002122122022222020222222200111220102222020122221221222202122202210221220121122022212220120011022011002121211212121022222022022212221212221102212022022101122122222222110222222220021220202202100012212221122202022220211021222012112222002100120010022022212221201121222221222212001122020200212002202110101121122022122222002022222120011222001002210112202022222002022212121121120021102012202002221120022221002022002211021120222222201020221220110012120201202111022222222222202022220212020221002022202002202020022112222221022121020221102212022121221220022121012122000101020020222212111202020210200102121101001210122022022222021122221002222222111112002012221220022102201220012122222101022212122200220021122220112120220202020020222022120002122210121002121001211222022122022222101122221211121220202022120112212021222022100201100020120112002212002001022021222121102222101001120220222212200121122210112122011211010220022022022222100122222010200222222212100222222020122022202211121020122002102222112020022200222122022222002001121120222102001001020221220222220021121202022222022222011022221120212222111222100122202222222211220210211020120212102112212021020020022112012122202110220120122102221011121211000012112201221211012122022222120222222000021222212222211012220022222102021201222022220022022222002201122100022201212022011000021000222002200100222220212022212111002222012122122222201222220020100221120022102212200120222102002201101221120001122022022010121121222220222222210202120101022122121011020020121022222102012010202122122222212022221002101222101012100222220120022202111211202221221201002202222022121110222200202022021100020010122012102011222220122022201212020200222022022222010122222021222021001122210002221120122111220221121220220110002002112001122000022012122121000212022212122212121100122122201110221211112102002122022222020022220001112221112202020102221022022022012201221120221111022212112112121111122022202221110101021122122222210111020111221200011001021020002222122222201222220202101121201112010122211122222011112201102221022200122022012121121200122010212021111022021112122122000021122210100000021000220122222022122222121122220020012222020202112122220122022122112202211220222202212202000120022200222201012022201220020200122112022010221011022120220102201222202022122222220020222201010022010122222012222022222102100212200221121221022102110021220010222201211120121120120020022212110002120220112122111220111221202022222222211121220110021020102012100102220222222211202220222021021002202212110222120012022121222121212202122220022222112020022122112121112111202212122022122222101221221001210122220202102222202220022012222210021120221211012212022222021011122012021222022110220020022112000022022200122012220212102100022122022222000121120211020120100212200012200122022112211210212122021212202022121011022000120022012221220220020121122122222120120201000121220210002210002122222220201121121101101022110122010112202021222122120222021020020001022102120202021212121210011121110021021012122012111212021121201200021010001200012122222220201021120000011020212002210222201220022220222211122022120111012022101201221220212002122120112112221001122101021212121020100202201020202020012222222222010021222201002121221201202010111012000000120021022102012211120100001100000220102221021011011002200112010111012101102112201021120220001010120200100111202002112122101210121'
(wide, tall) = (25, 6)
img = split(data)
bm = wide * tall
it = int(len(img) / bm)
layer_zeros = {}
for i in range(it):
layer = img[bm * i:bm * (i + 1)]
print(bm * i, bm * (i + 1))
zeros = 0
for num in layer:
if num == 0:
zeros += 1
layer_zeros[i] = zeros
min_layer = 0
minl = layer_zeros[0]
for (k, v) in layer_zeros.items():
if minl > v:
min_layer = k
minl = v
layer = img[bm * min_layer:bm * (min_layer + 1)]
num_1 = 0
num_2 = 0
for num in layer:
if num == 1:
num_1 += 1
elif num == 2:
num_2 += 1
print(num_1 * num_2) |
name, age = "Aromal S", 20
username = "aromalsanthosh"
print ('Hello!')
print("Name: {}\nAge: {}\nUsername: {}".format(name, age, username))
| (name, age) = ('Aromal S', 20)
username = 'aromalsanthosh'
print('Hello!')
print('Name: {}\nAge: {}\nUsername: {}'.format(name, age, username)) |
"""
document.py
Contains a simple class that represents a Twitter-esque comment, with hashtags.
"""
class Document:
"""
This class essentially takes in a list of tokenized words and stores two lists, one containing the words
in the order that they appear and a set containing any hashtags in the comment.
"""
def __init__(self, words, tags, raw):
"""
words is expected to be a parameter of tokenized words in the comment
They can be processed further.
"""
self.words = words
self.tags = tags
self.raw = raw
@classmethod
def create_from_raw_list(cls, words, raw):
d = Document([], set(), raw)
for w in words:
if w.startswith('#'):
d.tags.add(w)
else:
d.words.append(w)
return d
def export(self):
"""
Convert this object into a database model
"""
pass
| """
document.py
Contains a simple class that represents a Twitter-esque comment, with hashtags.
"""
class Document:
"""
This class essentially takes in a list of tokenized words and stores two lists, one containing the words
in the order that they appear and a set containing any hashtags in the comment.
"""
def __init__(self, words, tags, raw):
"""
words is expected to be a parameter of tokenized words in the comment
They can be processed further.
"""
self.words = words
self.tags = tags
self.raw = raw
@classmethod
def create_from_raw_list(cls, words, raw):
d = document([], set(), raw)
for w in words:
if w.startswith('#'):
d.tags.add(w)
else:
d.words.append(w)
return d
def export(self):
"""
Convert this object into a database model
"""
pass |
class Solution(object):
# dutch partitioning problem
def sortColors(self, nums):
low, mid, high = 0, 0, len(nums)-1
while(mid <= high):
if(nums[mid] == 0):
nums[low],nums[mid] = nums[mid], nums[low]
low +=1
mid += 1
elif(nums[mid] == 1):
mid += 1
else:
nums[mid], nums[high] = nums[high], nums[mid]
high -= 1
sol = Solution()
arr = [2,0,2,1,1,0]
sol.sortColors(arr)
print(arr)
| class Solution(object):
def sort_colors(self, nums):
(low, mid, high) = (0, 0, len(nums) - 1)
while mid <= high:
if nums[mid] == 0:
(nums[low], nums[mid]) = (nums[mid], nums[low])
low += 1
mid += 1
elif nums[mid] == 1:
mid += 1
else:
(nums[mid], nums[high]) = (nums[high], nums[mid])
high -= 1
sol = solution()
arr = [2, 0, 2, 1, 1, 0]
sol.sortColors(arr)
print(arr) |
def definition():
view = f"""
-- Exists just as a reference, to check the categorisation of accounts to super-sections. Built 'right to left'
SELECT e.super_section_id, e.description as Super,
d.section_id, d.description as Section,
c.sub_section_id, c.description as SubSection,
b.summary_code, b.description as Summary,
a.account, a.description as AccountName
FROM fs_account a
LEFT OUTER JOIN fs_summary_code b ON b.summary_code = a.summary_code
LEFT OUTER JOIN fs_sub_section c ON c.sub_section_id = b.sub_section_id
LEFT OUTER JOIN fs_section d ON d.section_id = c.section_id
LEFT OUTER JOIN fs_super_section e ON e.super_section_id = d.super_section_id
"""
return view
| def definition():
view = f"\n -- Exists just as a reference, to check the categorisation of accounts to super-sections. Built 'right to left'\n SELECT e.super_section_id, e.description as Super, \n\t\t\td.section_id, d.description as Section, \n\t\t\tc.sub_section_id, c.description as SubSection, \n\t\t\tb.summary_code, b.description as Summary, \n\t\t\ta.account, a.description as AccountName\n FROM fs_account a\n LEFT OUTER JOIN fs_summary_code b ON b.summary_code = a.summary_code\n LEFT OUTER JOIN fs_sub_section c ON c.sub_section_id = b.sub_section_id\n LEFT OUTER JOIN fs_section d ON d.section_id = c.section_id\n LEFT OUTER JOIN fs_super_section e ON e.super_section_id = d.super_section_id\n "
return view |
# name this file 'solutions.py'.
"""Volume II Lab 15: Line Search Algorithms
<name>
<class>
<date>
"""
# Problem 1
def newton1d(f, df, ddf, x, niter=10):
"""
Perform Newton's method to minimize a function from R to R.
Parameters:
f (function): The twice-differentiable objective function.
df (function): The first derivative of 'f'.
ddf (function): The second derivative of 'f'.
x (float): The initial guess.
niter (int): The number of iterations. Defaults to 10.
Returns:
(float) The approximated minimizer.
"""
raise NotImplementedError("Problem 1 Incomplete")
def test_newton():
"""Use the newton1d() function to minimixe f(x) = x^2 + sin(5x) with an
initial guess of x_0 = 0. Also try other guesses farther away from the
true minimizer, and note when the method fails to obtain the correct
answer.
Returns:
(float) The true minimizer with an initial guess x_0 = 0.
(float) The result of newton1d() with a bad initial guess.
"""
raise NotImplementedError("Problem 1 Incomplete")
# Problem 2
def backtracking(f, slope, x, p, a=1, rho=.9, c=10e-4):
"""Perform a backtracking line search to satisfy the Armijo Conditions.
Parameters:
f (function): the twice-differentiable objective function.
slope (float): The value of grad(f)^T p.
x (ndarray of shape (n,)): The current iterate.
p (ndarray of shape (n,)): The current search direction.
a (float): The intial step length. (set to 1 in Newton and
quasi-Newton methods)
rho (float): A number in (0,1).
c (float): A number in (0,1).
Returns:
(float) The computed step size satisfying the Armijo condition.
"""
raise NotImplementedError("Problem 2 Incomplete")
# Problem 3
def gradientDescent(f, df, x, niter=10):
"""Minimize a function using gradient descent.
Parameters:
f (function): The twice-differentiable objective function.
df (function): The gradient of the function.
x (ndarray of shape (n,)): The initial point.
niter (int): The number of iterations to run.
Returns:
(list of ndarrays) The sequence of points generated.
"""
raise NotImplementedError("Problem 3 Incomplete")
def newtonsMethod(f, df, ddf, x, niter=10):
"""Minimize a function using Newton's method.
Parameters:
f (function): The twice-differentiable objective function.
df (function): The gradient of the function.
ddf (function): The Hessian of the function.
x (ndarray of shape (n,)): The initial point.
niter (int): The number of iterations.
Returns:
(list of ndarrays) The sequence of points generated.
"""
raise NotImplementedError("Problem 3 Incomplete")
# Problem 4
def gaussNewton(f, df, jac, r, x, niter=10):
"""Solve a nonlinear least squares problem with Gauss-Newton method.
Parameters:
f (function): The objective function.
df (function): The gradient of f.
jac (function): The jacobian of the residual vector.
r (function): The residual vector.
x (ndarray of shape (n,)): The initial point.
niter (int): The number of iterations.
Returns:
(ndarray of shape (n,)) The minimizer.
"""
raise NotImplementedError("Problem 4 Incomplete")
# Problem 5
def census():
"""Generate two plots: one that considers the first 8 decades of the US
Census data (with the exponential model), and one that considers all 16
decades of data (with the logistic model).
"""
# Start with the first 8 decades of data.
years1 = np.arange(8)
pop1 = np.array([3.929, 5.308, 7.240, 9.638,
12.866, 17.069, 23.192, 31.443])
# Now consider the first 16 decades.
years2 = np.arange(16)
pop2 = np.array([3.929, 5.308, 7.240, 9.638,
12.866, 17.069, 23.192, 31.443,
38.558, 50.156, 62.948, 75.996,
91.972, 105.711, 122.775, 131.669])
raise NotImplementedError("Problem 5 Incomplete")
| """Volume II Lab 15: Line Search Algorithms
<name>
<class>
<date>
"""
def newton1d(f, df, ddf, x, niter=10):
"""
Perform Newton's method to minimize a function from R to R.
Parameters:
f (function): The twice-differentiable objective function.
df (function): The first derivative of 'f'.
ddf (function): The second derivative of 'f'.
x (float): The initial guess.
niter (int): The number of iterations. Defaults to 10.
Returns:
(float) The approximated minimizer.
"""
raise not_implemented_error('Problem 1 Incomplete')
def test_newton():
"""Use the newton1d() function to minimixe f(x) = x^2 + sin(5x) with an
initial guess of x_0 = 0. Also try other guesses farther away from the
true minimizer, and note when the method fails to obtain the correct
answer.
Returns:
(float) The true minimizer with an initial guess x_0 = 0.
(float) The result of newton1d() with a bad initial guess.
"""
raise not_implemented_error('Problem 1 Incomplete')
def backtracking(f, slope, x, p, a=1, rho=0.9, c=0.001):
"""Perform a backtracking line search to satisfy the Armijo Conditions.
Parameters:
f (function): the twice-differentiable objective function.
slope (float): The value of grad(f)^T p.
x (ndarray of shape (n,)): The current iterate.
p (ndarray of shape (n,)): The current search direction.
a (float): The intial step length. (set to 1 in Newton and
quasi-Newton methods)
rho (float): A number in (0,1).
c (float): A number in (0,1).
Returns:
(float) The computed step size satisfying the Armijo condition.
"""
raise not_implemented_error('Problem 2 Incomplete')
def gradient_descent(f, df, x, niter=10):
"""Minimize a function using gradient descent.
Parameters:
f (function): The twice-differentiable objective function.
df (function): The gradient of the function.
x (ndarray of shape (n,)): The initial point.
niter (int): The number of iterations to run.
Returns:
(list of ndarrays) The sequence of points generated.
"""
raise not_implemented_error('Problem 3 Incomplete')
def newtons_method(f, df, ddf, x, niter=10):
"""Minimize a function using Newton's method.
Parameters:
f (function): The twice-differentiable objective function.
df (function): The gradient of the function.
ddf (function): The Hessian of the function.
x (ndarray of shape (n,)): The initial point.
niter (int): The number of iterations.
Returns:
(list of ndarrays) The sequence of points generated.
"""
raise not_implemented_error('Problem 3 Incomplete')
def gauss_newton(f, df, jac, r, x, niter=10):
"""Solve a nonlinear least squares problem with Gauss-Newton method.
Parameters:
f (function): The objective function.
df (function): The gradient of f.
jac (function): The jacobian of the residual vector.
r (function): The residual vector.
x (ndarray of shape (n,)): The initial point.
niter (int): The number of iterations.
Returns:
(ndarray of shape (n,)) The minimizer.
"""
raise not_implemented_error('Problem 4 Incomplete')
def census():
"""Generate two plots: one that considers the first 8 decades of the US
Census data (with the exponential model), and one that considers all 16
decades of data (with the logistic model).
"""
years1 = np.arange(8)
pop1 = np.array([3.929, 5.308, 7.24, 9.638, 12.866, 17.069, 23.192, 31.443])
years2 = np.arange(16)
pop2 = np.array([3.929, 5.308, 7.24, 9.638, 12.866, 17.069, 23.192, 31.443, 38.558, 50.156, 62.948, 75.996, 91.972, 105.711, 122.775, 131.669])
raise not_implemented_error('Problem 5 Incomplete') |
vocales ='aeiou'
while True:
palabra = input("Escriba una palabra: ")
letras = palabra.split()
if len(letras) == 1:
break
else:
print("Eso no es solo una palabra")
pass
posicion = -1
puntos_kevin = 0
puntos_stuart = 0
for letras in palabra:
if vocales.__contains__(letras):
if palabra.count(letras) > 1:
posicion = palabra.index(letras, posicion + 1)
puntos_kevin = puntos_kevin + len(palabra) - palabra.index(letras, posicion)
else:
puntos_kevin = puntos_kevin + len(palabra) - palabra.index(letras)
else:
if palabra.count(letras) > 1:
posicion = palabra.index(letras, posicion + 1)
puntos_stuart = puntos_stuart + len(palabra) - palabra.index(letras, posicion)
else:
puntos_stuart = puntos_stuart + len(palabra) - palabra.index(letras)
if puntos_stuart > puntos_kevin:
print("El ganador es Stuart, ha obtenido ", puntos_stuart, " puntos")
elif puntos_kevin > puntos_stuart:
print("El ganador es Kevin, ha obtenido ", puntos_kevin, " puntos")
else:
print("Draw") | vocales = 'aeiou'
while True:
palabra = input('Escriba una palabra: ')
letras = palabra.split()
if len(letras) == 1:
break
else:
print('Eso no es solo una palabra')
pass
posicion = -1
puntos_kevin = 0
puntos_stuart = 0
for letras in palabra:
if vocales.__contains__(letras):
if palabra.count(letras) > 1:
posicion = palabra.index(letras, posicion + 1)
puntos_kevin = puntos_kevin + len(palabra) - palabra.index(letras, posicion)
else:
puntos_kevin = puntos_kevin + len(palabra) - palabra.index(letras)
elif palabra.count(letras) > 1:
posicion = palabra.index(letras, posicion + 1)
puntos_stuart = puntos_stuart + len(palabra) - palabra.index(letras, posicion)
else:
puntos_stuart = puntos_stuart + len(palabra) - palabra.index(letras)
if puntos_stuart > puntos_kevin:
print('El ganador es Stuart, ha obtenido ', puntos_stuart, ' puntos')
elif puntos_kevin > puntos_stuart:
print('El ganador es Kevin, ha obtenido ', puntos_kevin, ' puntos')
else:
print('Draw') |
kheader = '''
<head>
<style>
<!--
body {font-size:12px; font-family:verdana,arial,helvetica,sans-serif; background-color:#ffffff}
.text {font-size:12px; font-family:verdana,arial,helvetica,sans-serif}
h1 {font-size:24px; font-weight:bold; font-family:verdana,arial,helvetica,sans-serif; color:#005050}
h2 {font-size:18px; font-weight:bold; font-family:verdana,arial,helvetica,sans-serif; color:#005050}
h3 {font-size:16px; font-weight:bold; font-family:verdana,arial,helvetica,sans-serif}
h4 {font-size:14px; font-weight:bold; font-family:verdana,arial,helvetica,sans-serif}
h5 {font-size:12px; font-weight:bold; font-family:verdana,arial,helvetica,sans-serif; color:#444444}
b {font-size:12px; font-weight:bold; font-family:verdana,arial,helvetica,sans-serif}
th {font-size:12px; font-weight:bold; font-family:verdana,arial,helvetica,sans-serif}
td {font-size:12px; font-family:verdana,arial,helvetica,sans-serif}
input {font-size:12px; font-family:verdana,arial,helvetica,sans-serif}
select {font-size:12px; font-family:verdana,arial,helvetica,sans-serif}
pre {font-size:12px; font-family:courier,monospace}
a {text-decoration:none}
a:link {color:#003399}
a:visited {color:#003399}
a:hover {color:#33cc99}
font.title3 {color: #005050; font-size:14px; font-weight:bold; font-family:verdana,arial,helvetica,sans-serif}
hr.frame0 {border: 1px solid #f5e05f; color: #f5e05f}
div.poplay {
position: absolute;
padding: 2px;
background-color: #ffff99;
border-top: solid 1px #c0c0c0;
border-left: solid 1px #c0c0c0;
border-bottom: solid 1px #808080;
border-right: solid 1px #808080;
visibility: hidden;
}
span.popup
{
font-weight: bold;
color: #ffffff;
white-space: nowrap;
}
form {
margin: 0px;
}
-->
</style>
<script language="JavaScript">
var MSIE, Netscape, Opera, Safari, Firefox;
if(window.navigator.appName.indexOf("Internet Explorer") >= 0){
MSIE = true;
}else if(window.navigator.appName == "Opera"){
Opera = true;
}else if(window.navigator.userAgent.indexOf("Safari") >= 0){
Safari = true;
}else if(window.navigator.userAgent.indexOf("Firefox") >= 0){
Firefox = true;
Netscape = true;
}else{
Netscape = true;
}
function Component(id)
{
this._component = document.getElementById(id);
this._opacity_change_interval = 1;
var opc = this._component.style.opacity;
if(opc == "")
{
opc = 1;
}
this._opacity = opc * 100;
}
function _Component_ID()
{
return this._component.id;
}
Component.prototype.id = _Component_ID;
function _Component_FontSize(size)
{
if(_defined(size))
{
this._component.style.fontSize = size + "px";
}
else
{
return this._component.style.fontSize;
}
}
Component.prototype.fontSize = _Component_FontSize;
function _Component_OpacityChangeInterval(interval)
{
if(typeof(interval) == "undefined")
{
return this._opacity_change_interval;
}
else
{
this._opacity_change_interval = interval;
}
}
Component.prototype.opacityChangeInterval = _Component_OpacityChangeInterval
function _Component_HTML(html)
{
var component = this._component;
if(typeof(html) == "undefined")
{
return component.innerHTML;
}
else
{
component.innerHTML = html;
}
}
Component.prototype.HTML = _Component_HTML;
function _Component_BackgroundColor(color)
{
this._component.style.backgroundColor = color;
}
Component.prototype.backgroundColor = _Component_BackgroundColor;
function _Component_BorderTop(border)
{
if(_defined(border)){
var comp = this._component;
if(MSIE)
{
//comp.style.borderTop = border.color();
//comp.style.border-top-style = border.style();
//comp.style.border-top-width = border.width();
}
else
{
comp.style.borderTopColor = border.color();
comp.style.borderTopStyle = border.style();
comp.style.borderTopWidth = border.width() + "px";
}
}
}
Component.prototype.borderTop = _Component_BorderTop;
function _Component_BorderBottom(border)
{
if(_defined(border)){
var comp = this._component;
if(MSIE)
{
}
else
{
comp.style.borderBottomColor = border.color();
comp.style.borderBottomStyle = border.style();
comp.style.borderBottomWidth = border.width() + "px";
}
}
}
Component.prototype.borderBottom = _Component_BorderBottom;
function _Component_BorderLeft(border)
{
if(_defined(border)){
var comp = this._component;
if(MSIE)
{
}
else
{
comp.style.borderLeftColor = border.color();
comp.style.borderLeftStyle = border.style();
comp.style.borderLeftWidth = border.width() + "px";
}
}
}
Component.prototype.borderLeft = _Component_BorderLeft;
function _Component_BorderRight(border)
{
if(_defined(border)){
var comp = this._component;
if(MSIE)
{
}
else
{
comp.style.borderRightColor = border.color();
comp.style.borderRightStyle = border.style();
comp.style.borderRightWidth = border.width() + "px";
}
}
}
Component.prototype.borderRight = _Component_BorderRight;
function _Component_Border()
{
var arg = _Component_Border.arguments;
if(arg.length == 1)
{
this.borderTop(arg[0]);
this.borderBottom(arg[0]);
this.borderLeft(arg[0]);
this.borderRight(arg[0]);
}
else if(arg.length == 2)
{
this.borderTop(arg[0]);
this.borderBottom(arg[0]);
this.borderLeft(arg[1]);
this.borderRight(arg[1]);
}else if(arg.length == 3)
{
this.borderTop(arg[0]);
this.borderLeft(arg[1]);
this.borderRight(arg[1]);
this.borderBottom(arg[2]);
}
else if(arg.length == 4)
{
this.borderTop(arg[0]);
this.borderRight(arg[1]);
this.borderBottom(arg[2]);
this.borderLeft(arg[3]);
}
}
Component.prototype.border = _Component_Border;
function _Component_X(x)
{
var component = this._component;
if(typeof(x) == "undefined")
{
var ret = (MSIE) ? component.style.pixelLeft : parseInt(component.style.left);
return ret;
}
else
{
if(MSIE)
{
component.style.pixelLeft = x;
}
else if(Opera)
{
component.style.left = x;
}
else
{
component.style.left = x + "px";
}
}
}
Component.prototype.x = _Component_X;
function _Component_Y(y)
{
var component = this._component;
if(typeof(y) == "undefined")
{
var ret = (MSIE) ? component.style.pixelTop : parseInt(component.style.top);
return ret;
}else
{
if(MSIE)
{
component.style.pixelTop = y;
}
else if(Opera)
{
component.style.top = y;
}
else
{
component.style.top = y + "px";
}
}
}
Component.prototype.y = _Component_Y;
function _Component_Move(x, y)
{
this.x(x);
this.y(y);
}
Component.prototype.move = _Component_Move;
function _Component_Width(width)
{
var component = this._component;
if(typeof(width) == "undefined")
{
var ret = (MSIE) ? component.style.pixelWidth : parseInt(component.style.width);
return ret;
}
else
{
if(MSIE)
{
component.style.pixelWidth = width;
}
else if(Opera)
{
component.style.width = width;
}
else
{
component.style.width = width + "px";
}
}
}
Component.prototype.width = _Component_Width;
function _Component_Height(height)
{
var component = this._component;
if(typeof(height) == "undefined")
{
var ret = (MSIE) ? component.style.pixelWidth : parseInt(component.style.width);
return ret;
}
else
{
if(MSIE)
{
component.style.pixelHeight = height;
}
else if(Opera)
{
component.style.height = height;
}
else
{
component.style.height = height + "px";
}
}
}
Component.prototype.height = _Component_Height;
function _Component_Size(width, height)
{
this.width(width);
this.height(height);
}
Component.prototype.size = _Component_Size;
function _Component_Visible(visible)
{
var component = this._component;
if(typeof(visible) == "undefined")
{
return (component.style.visibility == "visible") ? true : false;
}
else
{
if(MSIE || Safari || Firefox || Opera)
{
if(visible)
{
component.style.visibility = "visible";
this._opacityStep = 10;
this._opacity = 0;
}
else
{
this._opacityStep = -10;
this._opacity = this.opacity();
}
_addComponent(this);
this.changeOpacity();
}
else
{
component.style.visibility = (visible) ? "visible" : "hidden";
}
}
}
Component.prototype.visible = _Component_Visible;
function _Component_ChangeOpacity()
{
var opacity = this._opacity + this._opacityStep;
this.opacity(opacity);
if(opacity >= 100)
{
return;
}
else if(opacity <= 0)
{
this._component.style.visibility = "hidden";
return
}
else
{
var interval = this._opacity_change_interval;
setTimeout("_triggerChangeOpacity('" + this.id() + "')", interval);
}
}
Component.prototype.changeOpacity = _Component_ChangeOpacity;
function _Component_Opacity(opacity)
{
if(typeof(opacity) == "undefined")
{
return this._opacity;
}
else
{
this._opacity = opacity;
var component = this._component;
component.style.opacity = opacity / 100;
component.style.mozOpacity = opacity / 100;
component.style.filter = "alpha(opacity=" + opacity + ")";
}
}
Component.prototype.opacity = _Component_Opacity;
var _component_list = new Array();
function _addComponent(component)
{
var id = component.id();
_component_list[id] = component;
}
function _triggerChangeOpacity(id)
{
var component = _component_list[id];
component.changeOpacity();
}
function _defined(val)
{
return (typeof(val) != "undefined") ? true : false;
}
function Border()
{
this._width = 1;
this._style = "solid";
this._color = "#000000";
}
function _Border_Color(color)
{
if(!_defined(color)){
return this._color;
}else{
this._color = color;
}
}
Border.prototype.color = _Border_Color;
function _Border_Style(style)
{
if(!_defined(style)){
return this._style;
}else{
this._style = style;
}
}
Border.prototype.style = _Border_Style;
function _Border_Width(width)
{
if(!_defined(width)){
return this._width;
}else{
this._width = width;
}
}
Border.prototype.width = _Border_Width;
document.onmousemove = _documentMouseMove;
var _mousePosX = 0;
var _mousePosY = 0;
function _documentMouseMove(evt)
{
_mousePosX = _getEventX(evt);
_mousePosY = _getEventY(evt);
}
function _getEventX(evt)
{
var ret;
if(Netscape){
ret = evt.pageX;
}else if(MSIE){
ret = event.x + getPageXOffset();
}else if(Safari){
ret = event.x + getPageXOffset();
}else{
ret = evt.x;
}
return ret;
}
function _getEventY(evt)
{
var ret;
if(Netscape){
ret = evt.pageY;
}else if(MSIE){
ret = event.y + getPageYOffset();
}else if(Safari){
ret = event.y + getPageYOffset();
}else{
ret = event.y;
}
return ret;
}
function getCurrentMouseX()
{
return _mousePosX;
}
function getCurrentMouseY()
{
return _mousePosY
}
function getPageXOffset()
{
var ret;
if(Safari || Opera){
ret = document.body.scrollLeft;
}else{
if(document.body.scrollLeft > 0){
ret = document.body.scrollLeft;
}else{
ret = document.documentElement.scrollLeft;
}
}
return ret;
}
function getPageYOffset()
{
var ret;
if(Safari || Opera){
ret = document.body.scrollTop;
}else{
if(document.body.scrollTop > 0){
ret = document.body.scrollTop;
}else{
ret = document.documentElement.scrollTop;
}
}
return ret;
}
var timer = 0;
var p_entry, p_title, p_bgcolor;
function popupTimer(entry, title, bgcolor)
{
p_entry = entry;
p_title = title;
p_bgcolor = bgcolor;
if(timer == 0){
var func = "showThumbnail()";
timer = setTimeout(func, 1200);
}
}
function showThumbnail()
{
var url = "";
if(p_entry.match(/^[A-Z]+\d+$/))
{
url = "http://www.genome.jp/kegg/misc/thumbnail/" + p_entry + ".gif";
}
else if(p_entry.match(/(\d+)$/))
{
url = "http://www.genome.jp/kegg/misc/thumbnail/map" + RegExp.$1 + ".gif";
}
var html = "";
html += '<img src="' + url + '" alt="Loading...">';
var x = getCurrentMouseX();
var y = getCurrentMouseY();
var layer = new Component("poplay");
layer.backgroundColor(p_bgcolor);
layer.HTML(html);
layer.move(x, y+40);
layer.visible(true);
timer = 0;
}
function hideMapTn(){
var layer = new Component("poplay");
layer.visible(false);
if(timer != 0){
clearTimeout(timer);
timer = 0;
}
}
</script>
</head>
'''
| kheader = '\n<head>\n<style>\n<!--\nbody {font-size:12px; font-family:verdana,arial,helvetica,sans-serif; background-color:#ffffff}\n.text {font-size:12px; font-family:verdana,arial,helvetica,sans-serif}\nh1 {font-size:24px; font-weight:bold; font-family:verdana,arial,helvetica,sans-serif; color:#005050}\nh2 {font-size:18px; font-weight:bold; font-family:verdana,arial,helvetica,sans-serif; color:#005050}\nh3 {font-size:16px; font-weight:bold; font-family:verdana,arial,helvetica,sans-serif}\nh4 {font-size:14px; font-weight:bold; font-family:verdana,arial,helvetica,sans-serif}\nh5 {font-size:12px; font-weight:bold; font-family:verdana,arial,helvetica,sans-serif; color:#444444}\nb {font-size:12px; font-weight:bold; font-family:verdana,arial,helvetica,sans-serif}\nth {font-size:12px; font-weight:bold; font-family:verdana,arial,helvetica,sans-serif}\ntd {font-size:12px; font-family:verdana,arial,helvetica,sans-serif}\ninput {font-size:12px; font-family:verdana,arial,helvetica,sans-serif}\nselect {font-size:12px; font-family:verdana,arial,helvetica,sans-serif}\npre {font-size:12px; font-family:courier,monospace}\na {text-decoration:none}\na:link {color:#003399}\na:visited {color:#003399}\na:hover {color:#33cc99}\nfont.title3 {color: #005050; font-size:14px; font-weight:bold; font-family:verdana,arial,helvetica,sans-serif}\nhr.frame0 {border: 1px solid #f5e05f; color: #f5e05f}\ndiv.poplay {\n position: absolute;\n padding: 2px;\n background-color: #ffff99;\n border-top: solid 1px #c0c0c0;\n border-left: solid 1px #c0c0c0;\n border-bottom: solid 1px #808080;\n border-right: solid 1px #808080;\n visibility: hidden;\n}\n\nspan.popup\n{\n font-weight: bold;\n color: #ffffff;\n white-space: nowrap;\n}\n\nform {\n margin: 0px;\n}\n-->\n</style>\n<script language="JavaScript">\nvar MSIE, Netscape, Opera, Safari, Firefox;\n\nif(window.navigator.appName.indexOf("Internet Explorer") >= 0){\n MSIE = true;\n}else if(window.navigator.appName == "Opera"){\n Opera = true;\n}else if(window.navigator.userAgent.indexOf("Safari") >= 0){\n Safari = true;\n}else if(window.navigator.userAgent.indexOf("Firefox") >= 0){\n Firefox = true;\n Netscape = true;\n}else{\n Netscape = true;\n}\n\nfunction Component(id)\n{\n this._component = document.getElementById(id);\n this._opacity_change_interval = 1;\n \n var opc = this._component.style.opacity;\n if(opc == "")\n {\n opc = 1;\n }\n this._opacity = opc * 100;\n}\n\n\nfunction _Component_ID()\n{\n return this._component.id;\n}\nComponent.prototype.id = _Component_ID;\n\nfunction _Component_FontSize(size)\n{\n if(_defined(size))\n {\n this._component.style.fontSize = size + "px";\n }\n else\n {\n return this._component.style.fontSize;\n }\n}\nComponent.prototype.fontSize = _Component_FontSize;\n\nfunction _Component_OpacityChangeInterval(interval)\n{\n if(typeof(interval) == "undefined")\n {\n return this._opacity_change_interval;\n }\n else\n {\n this._opacity_change_interval = interval;\n }\n}\nComponent.prototype.opacityChangeInterval = _Component_OpacityChangeInterval\n\n\nfunction _Component_HTML(html)\n{\n var component = this._component;\n \n if(typeof(html) == "undefined")\n {\n return component.innerHTML;\n }\n else\n {\n component.innerHTML = html;\n }\n}\n\nComponent.prototype.HTML = _Component_HTML;\n\nfunction _Component_BackgroundColor(color)\n{\n this._component.style.backgroundColor = color;\n}\nComponent.prototype.backgroundColor = _Component_BackgroundColor;\n\nfunction _Component_BorderTop(border)\n{\n if(_defined(border)){\n var comp = this._component;\n if(MSIE)\n {\n //comp.style.borderTop = border.color();\n //comp.style.border-top-style = border.style();\n //comp.style.border-top-width = border.width();\n }\n else\n {\n comp.style.borderTopColor = border.color();\n comp.style.borderTopStyle = border.style();\n comp.style.borderTopWidth = border.width() + "px";\n }\n }\n}\nComponent.prototype.borderTop = _Component_BorderTop;\n\nfunction _Component_BorderBottom(border)\n{\n if(_defined(border)){\n var comp = this._component;\n if(MSIE)\n {\n }\n else\n {\n comp.style.borderBottomColor = border.color();\n comp.style.borderBottomStyle = border.style();\n comp.style.borderBottomWidth = border.width() + "px";\n }\n }\n}\nComponent.prototype.borderBottom = _Component_BorderBottom;\n\nfunction _Component_BorderLeft(border)\n{\n if(_defined(border)){\n var comp = this._component;\n if(MSIE)\n {\n }\n else\n {\n comp.style.borderLeftColor = border.color();\n comp.style.borderLeftStyle = border.style();\n comp.style.borderLeftWidth = border.width() + "px";\n }\n }\n}\nComponent.prototype.borderLeft = _Component_BorderLeft;\n\nfunction _Component_BorderRight(border)\n{\n if(_defined(border)){\n var comp = this._component;\n if(MSIE)\n {\n }\n else\n {\n comp.style.borderRightColor = border.color();\n comp.style.borderRightStyle = border.style();\n comp.style.borderRightWidth = border.width() + "px";\n }\n }\n}\nComponent.prototype.borderRight = _Component_BorderRight;\n\nfunction _Component_Border()\n{\n var arg = _Component_Border.arguments;\n \n if(arg.length == 1)\n {\n this.borderTop(arg[0]);\n this.borderBottom(arg[0]);\n this.borderLeft(arg[0]);\n this.borderRight(arg[0]);\n \n }\n else if(arg.length == 2)\n {\n this.borderTop(arg[0]);\n this.borderBottom(arg[0]);\n this.borderLeft(arg[1]);\n this.borderRight(arg[1]);\n \n }else if(arg.length == 3)\n {\n this.borderTop(arg[0]);\n this.borderLeft(arg[1]);\n this.borderRight(arg[1]);\n this.borderBottom(arg[2]);\n \n }\n else if(arg.length == 4)\n {\n this.borderTop(arg[0]);\n this.borderRight(arg[1]);\n this.borderBottom(arg[2]);\n this.borderLeft(arg[3]);\n }\n}\nComponent.prototype.border = _Component_Border;\n\nfunction _Component_X(x)\n{\n var component = this._component;\n \n if(typeof(x) == "undefined")\n {\n var ret = (MSIE) ? component.style.pixelLeft : parseInt(component.style.left);\n return ret;\n }\n else\n {\n if(MSIE)\n {\n component.style.pixelLeft = x;\n }\n else if(Opera)\n {\n component.style.left = x;\n }\n else\n {\n component.style.left = x + "px";\n }\n }\n}\nComponent.prototype.x = _Component_X;\n\nfunction _Component_Y(y)\n{\n var component = this._component;\n \n if(typeof(y) == "undefined")\n {\n var ret = (MSIE) ? component.style.pixelTop : parseInt(component.style.top);\n return ret;\n }else\n {\n if(MSIE)\n {\n component.style.pixelTop = y;\n }\n else if(Opera)\n {\n component.style.top = y;\n }\n else\n {\n component.style.top = y + "px";\n }\n }\n}\nComponent.prototype.y = _Component_Y;\n\nfunction _Component_Move(x, y)\n{\n this.x(x);\n this.y(y);\n}\nComponent.prototype.move = _Component_Move;\n\nfunction _Component_Width(width)\n{\n var component = this._component;\n \n if(typeof(width) == "undefined")\n {\n var ret = (MSIE) ? component.style.pixelWidth : parseInt(component.style.width);\n return ret;\n }\n else\n {\n if(MSIE)\n {\n component.style.pixelWidth = width;\n }\n else if(Opera)\n {\n component.style.width = width;\n }\n else\n {\n component.style.width = width + "px";\n }\n }\n}\nComponent.prototype.width = _Component_Width;\n\nfunction _Component_Height(height)\n{\n var component = this._component;\n \n if(typeof(height) == "undefined")\n {\n var ret = (MSIE) ? component.style.pixelWidth : parseInt(component.style.width);\n return ret;\n }\n else\n {\n if(MSIE)\n {\n component.style.pixelHeight = height;\n }\n else if(Opera)\n {\n component.style.height = height;\n }\n else\n {\n component.style.height = height + "px";\n }\n }\n}\nComponent.prototype.height = _Component_Height;\n\nfunction _Component_Size(width, height)\n{\n this.width(width);\n this.height(height);\n}\nComponent.prototype.size = _Component_Size;\n\nfunction _Component_Visible(visible)\n{\n var component = this._component;\n \n if(typeof(visible) == "undefined")\n {\n return (component.style.visibility == "visible") ? true : false;\n }\n else\n {\n if(MSIE || Safari || Firefox || Opera)\n {\n if(visible)\n {\n component.style.visibility = "visible";\n this._opacityStep = 10;\n this._opacity = 0;\n }\n else\n {\n this._opacityStep = -10;\n this._opacity = this.opacity();\n }\n \n _addComponent(this);\n \n this.changeOpacity();\n }\n else\n {\n component.style.visibility = (visible) ? "visible" : "hidden";\n }\n }\n}\nComponent.prototype.visible = _Component_Visible;\n\nfunction _Component_ChangeOpacity()\n{\n var opacity = this._opacity + this._opacityStep;\n \n this.opacity(opacity);\n \n if(opacity >= 100)\n {\n return;\n }\n else if(opacity <= 0)\n {\n this._component.style.visibility = "hidden";\n return\n }\n else\n {\n var interval = this._opacity_change_interval;\n setTimeout("_triggerChangeOpacity(\'" + this.id() + "\')", interval);\n }\n}\nComponent.prototype.changeOpacity = _Component_ChangeOpacity;\n\nfunction _Component_Opacity(opacity)\n{\n if(typeof(opacity) == "undefined")\n {\n return this._opacity;\n }\n else\n {\n this._opacity = opacity;\n \n var component = this._component;\n component.style.opacity = opacity / 100;\n component.style.mozOpacity = opacity / 100;\n component.style.filter = "alpha(opacity=" + opacity + ")";\n }\n}\nComponent.prototype.opacity = _Component_Opacity;\n\nvar _component_list = new Array();\n\nfunction _addComponent(component)\n{\n var id = component.id();\n _component_list[id] = component;\n}\n\nfunction _triggerChangeOpacity(id)\n{\n var component = _component_list[id];\n component.changeOpacity();\n}\n\nfunction _defined(val)\n{\n return (typeof(val) != "undefined") ? true : false;\n}\n\nfunction Border()\n{\n this._width = 1;\n this._style = "solid";\n this._color = "#000000";\n}\n\nfunction _Border_Color(color)\n{\n if(!_defined(color)){\n return this._color;\n }else{\n this._color = color;\n }\n}\nBorder.prototype.color = _Border_Color;\n\nfunction _Border_Style(style)\n{\n if(!_defined(style)){\n return this._style;\n }else{\n this._style = style;\n }\n}\nBorder.prototype.style = _Border_Style;\n\nfunction _Border_Width(width)\n{\n if(!_defined(width)){\n return this._width;\n }else{\n this._width = width;\n }\n}\nBorder.prototype.width = _Border_Width;\n\ndocument.onmousemove = _documentMouseMove;\n\nvar _mousePosX = 0;\nvar _mousePosY = 0;\n\nfunction _documentMouseMove(evt)\n{\n _mousePosX = _getEventX(evt);\n _mousePosY = _getEventY(evt);\n}\n\nfunction _getEventX(evt)\n{\n var ret;\n if(Netscape){\n ret = evt.pageX;\n }else if(MSIE){\n ret = event.x + getPageXOffset();\n }else if(Safari){\n ret = event.x + getPageXOffset();\n }else{\n ret = evt.x;\n }\n\n return ret;\n}\n\nfunction _getEventY(evt)\n{\n var ret;\n\n if(Netscape){\n ret = evt.pageY;\n }else if(MSIE){\n ret = event.y + getPageYOffset();\n }else if(Safari){\n ret = event.y + getPageYOffset();\n }else{\n ret = event.y;\n }\n\n return ret;\n}\n\nfunction getCurrentMouseX()\n{\n return _mousePosX;\n}\n\nfunction getCurrentMouseY()\n{\n return _mousePosY\n}\n\nfunction getPageXOffset()\n{\n var ret;\n if(Safari || Opera){\n ret = document.body.scrollLeft;\n }else{\n if(document.body.scrollLeft > 0){\n ret = document.body.scrollLeft;\n }else{\n ret = document.documentElement.scrollLeft;\n }\n }\n\n return ret;\n}\n\nfunction getPageYOffset()\n{\n var ret;\n if(Safari || Opera){\n ret = document.body.scrollTop;\n }else{\n if(document.body.scrollTop > 0){\n ret = document.body.scrollTop;\n }else{\n ret = document.documentElement.scrollTop;\n }\n }\n\n return ret;\n} \n \n \nvar timer = 0;\nvar p_entry, p_title, p_bgcolor;\nfunction popupTimer(entry, title, bgcolor)\n{\n p_entry = entry;\n p_title = title;\n p_bgcolor = bgcolor;\n\n if(timer == 0){\n var func = "showThumbnail()";\n timer = setTimeout(func, 1200);\n }\n}\n\n\nfunction showThumbnail()\n{\n\n var url = "";\n if(p_entry.match(/^[A-Z]+\\d+$/))\n {\n url = "http://www.genome.jp/kegg/misc/thumbnail/" + p_entry + ".gif";\n }\n else if(p_entry.match(/(\\d+)$/))\n {\n url = "http://www.genome.jp/kegg/misc/thumbnail/map" + RegExp.$1 + ".gif";\n }\n\n var html = "";\n\n html += \'<img src="\' + url + \'" alt="Loading...">\';\n\n var x = getCurrentMouseX();\n var y = getCurrentMouseY();\n\n var layer = new Component("poplay");\n layer.backgroundColor(p_bgcolor);\n layer.HTML(html);\n layer.move(x, y+40);\n layer.visible(true);\n\n timer = 0;\n}\n\n\nfunction hideMapTn(){\n var layer = new Component("poplay");\n layer.visible(false);\n\n if(timer != 0){\n clearTimeout(timer);\n timer = 0;\n }\n}\n</script>\n</head>\n' |
def linear_search(list, target):
result = False
if not target:
return "Error: target is None"
if not list:
return "Error: list is None"
for n in list:
if n == target:
result = True
return result
return result
list = [1,5,2,3,6,10,2]
target = 1
print("original: " + str(list))
print("result : " + str(linear_search(list, target)))
# O(N) | def linear_search(list, target):
result = False
if not target:
return 'Error: target is None'
if not list:
return 'Error: list is None'
for n in list:
if n == target:
result = True
return result
return result
list = [1, 5, 2, 3, 6, 10, 2]
target = 1
print('original: ' + str(list))
print('result : ' + str(linear_search(list, target))) |
# Copyright (c) 2011 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.
{
'variables': {
'chromium_code': 1, # Use higher warning level.
},
'includes': [
'content_browser.gypi',
'content_common.gypi',
'content_gpu.gypi',
'content_plugin.gypi',
'content_ppapi_plugin.gypi',
'content_renderer.gypi',
'content_worker.gypi',
],
}
| {'variables': {'chromium_code': 1}, 'includes': ['content_browser.gypi', 'content_common.gypi', 'content_gpu.gypi', 'content_plugin.gypi', 'content_ppapi_plugin.gypi', 'content_renderer.gypi', 'content_worker.gypi']} |
cx = 250
cy = 250
cRadius = 200
i=0
def setup():
size(500, 500)
smooth()
background(50)
strokeWeight(5)
stroke(250)
noLoop()
def draw():
global i
while i <2*PI :
x1 = cos(i)*cRadius + cx
y1 = sin(i)*cRadius + cy
line(x1 , y1 , x1 , y1)
line(cx , cy , cx , cy)
i += 2*PI/12
def keyPressed():
if (key== "s"):
saveFrame(" myProcessing .png")
| cx = 250
cy = 250
c_radius = 200
i = 0
def setup():
size(500, 500)
smooth()
background(50)
stroke_weight(5)
stroke(250)
no_loop()
def draw():
global i
while i < 2 * PI:
x1 = cos(i) * cRadius + cx
y1 = sin(i) * cRadius + cy
line(x1, y1, x1, y1)
line(cx, cy, cx, cy)
i += 2 * PI / 12
def key_pressed():
if key == 's':
save_frame(' myProcessing .png') |
def m(a,n,b,c,d):
if n<0:
return(abs(b-c))
k = str(n)+'|'+str(b)
try:
return d[k]
except:
inc = m(a,n-1,b+a[n],c,d)
exc = m(a,n-1,b,c+a[n],d)
d[k] = min(inc,exc)
return d[k]
for i in range(int(input())):
d = {}
n = int(input())
a = [int(j) for j in input().split()]
if len(set(a))-n!=0:
print(0)
else:
print(m(a,n-1,0,0,d))
| def m(a, n, b, c, d):
if n < 0:
return abs(b - c)
k = str(n) + '|' + str(b)
try:
return d[k]
except:
inc = m(a, n - 1, b + a[n], c, d)
exc = m(a, n - 1, b, c + a[n], d)
d[k] = min(inc, exc)
return d[k]
for i in range(int(input())):
d = {}
n = int(input())
a = [int(j) for j in input().split()]
if len(set(a)) - n != 0:
print(0)
else:
print(m(a, n - 1, 0, 0, d)) |
class DocumentFileContentToolsViewsTestMixin:
def _request_document_parsing_error_list_view(self):
return self.get(viewname='document_parsing:error_list')
def _request_document_type_parsing_view(self):
return self.post(
viewname='document_parsing:document_type_submit', data={
'document_type': self.test_document_type.pk
}
)
class DocumentFileContentViewTestMixin:
def _request_test_document_file_content_delete_view(self):
return self.post(
viewname='document_parsing:document_file_content_delete',
kwargs={
'document_file_id': self.test_document_file.pk
}
)
def _request_test_document_file_content_download_view(self):
return self.get(
viewname='document_parsing:document_file_content_download',
kwargs={
'document_file_id': self.test_document_file.pk
}
)
def _request_test_document_file_content_view(self):
return self.get(
'document_parsing:document_file_content_view', kwargs={
'document_file_id': self.test_document_file.pk
}
)
def _request_test_document_file_page_content_view(self):
return self.get(
viewname='document_parsing:document_file_page_content_view',
kwargs={
'document_file_page_id': self.test_document_file.pages.first().pk,
}
)
def _request_test_document_file_parsing_error_list_view(self):
return self.get(
viewname='document_parsing:document_file_parsing_error_list',
kwargs={
'document_file_id': self.test_document_file.pk,
}
)
def _request_test_document_file_parsing_submit_view(self):
return self.post(
viewname='document_parsing:document_file_submit', kwargs={
'document_file_id': self.test_document_file.pk
}
)
def _request_test_document_parsing_submit_view(self):
return self.post(
viewname='document_parsing:document_submit', kwargs={
'document_id': self.test_document.pk
}
)
class DocumentParsingAPITestMixin:
def _request_document_file_page_content_api_view(self):
return self.get(
viewname='rest_api:document-file-page-content-view', kwargs={
'document_id': self.test_document.pk,
'document_file_id': self.test_document_file.pk,
'document_file_page_id': self.test_document_file.pages.first().pk
}
)
class DocumentTypeContentViewsTestMixin:
def _request_test_document_type_parsing_settings_view(self):
return self.get(
viewname='document_parsing:document_type_parsing_settings',
kwargs={'document_type_id': self.test_document_type.pk}
)
class DocumentTypeParsingSettingsAPIViewTestMixin():
def _request_document_type_parsing_settings_details_api_view(self):
return self.get(
viewname='rest_api:document-type-parsing-settings-view',
kwargs={'document_type_id': self.test_document_type.pk}
)
def _request_document_type_parsing_settings_patch_api_view(self):
return self.patch(
viewname='rest_api:document-type-parsing-settings-view',
kwargs={'document_type_id': self.test_document_type.pk},
data={'auto_parsing': True}
)
def _request_document_type_parsing_settings_put_api_view(self):
return self.put(
viewname='rest_api:document-type-parsing-settings-view',
kwargs={'document_type_id': self.test_document_type.pk},
data={'auto_parsing': True}
)
| class Documentfilecontenttoolsviewstestmixin:
def _request_document_parsing_error_list_view(self):
return self.get(viewname='document_parsing:error_list')
def _request_document_type_parsing_view(self):
return self.post(viewname='document_parsing:document_type_submit', data={'document_type': self.test_document_type.pk})
class Documentfilecontentviewtestmixin:
def _request_test_document_file_content_delete_view(self):
return self.post(viewname='document_parsing:document_file_content_delete', kwargs={'document_file_id': self.test_document_file.pk})
def _request_test_document_file_content_download_view(self):
return self.get(viewname='document_parsing:document_file_content_download', kwargs={'document_file_id': self.test_document_file.pk})
def _request_test_document_file_content_view(self):
return self.get('document_parsing:document_file_content_view', kwargs={'document_file_id': self.test_document_file.pk})
def _request_test_document_file_page_content_view(self):
return self.get(viewname='document_parsing:document_file_page_content_view', kwargs={'document_file_page_id': self.test_document_file.pages.first().pk})
def _request_test_document_file_parsing_error_list_view(self):
return self.get(viewname='document_parsing:document_file_parsing_error_list', kwargs={'document_file_id': self.test_document_file.pk})
def _request_test_document_file_parsing_submit_view(self):
return self.post(viewname='document_parsing:document_file_submit', kwargs={'document_file_id': self.test_document_file.pk})
def _request_test_document_parsing_submit_view(self):
return self.post(viewname='document_parsing:document_submit', kwargs={'document_id': self.test_document.pk})
class Documentparsingapitestmixin:
def _request_document_file_page_content_api_view(self):
return self.get(viewname='rest_api:document-file-page-content-view', kwargs={'document_id': self.test_document.pk, 'document_file_id': self.test_document_file.pk, 'document_file_page_id': self.test_document_file.pages.first().pk})
class Documenttypecontentviewstestmixin:
def _request_test_document_type_parsing_settings_view(self):
return self.get(viewname='document_parsing:document_type_parsing_settings', kwargs={'document_type_id': self.test_document_type.pk})
class Documenttypeparsingsettingsapiviewtestmixin:
def _request_document_type_parsing_settings_details_api_view(self):
return self.get(viewname='rest_api:document-type-parsing-settings-view', kwargs={'document_type_id': self.test_document_type.pk})
def _request_document_type_parsing_settings_patch_api_view(self):
return self.patch(viewname='rest_api:document-type-parsing-settings-view', kwargs={'document_type_id': self.test_document_type.pk}, data={'auto_parsing': True})
def _request_document_type_parsing_settings_put_api_view(self):
return self.put(viewname='rest_api:document-type-parsing-settings-view', kwargs={'document_type_id': self.test_document_type.pk}, data={'auto_parsing': True}) |
class SqlQueries:
create_staging_events = ("""
CREATE TABLE IF NOT EXISTS public.events_stage (
index integer,
concert varchar(256),
artist varchar(256),
location varchar(256),
start_date date
);
""")
create_staging_songs = ("""
CREATE TABLE IF NOT EXISTS public.songs_stage (
index integer,
artist varchar(256),
artist_listeners integer,
song varchar(256),
song_playcount integer,
song_listeners integer
);
""")
create_dwh_songs = ("""
CREATE TABLE IF NOT EXISTS public.songs_dwh (
song varchar(256),
song_playcount integer,
song_listeners integer,
artist varchar(256)
);
""")
create_dwh_artists = ("""
CREATE TABLE IF NOT EXISTS public.artists_dwh (
artists varchar(256),
artist_listeners integer
);
""")
create_dwh_concerts = ("""
CREATE TABLE IF NOT EXISTS public.concerts_dwh (
name varchar(256),
location varchar(256),
start_date date,
artist varchar(256)
);
""")
songs_insert = ("""
INSERT INTO public.songs_dwh (song, song_playcount, song_listeners, artist)
SELECT song, song_playcount, song_listeners, artist
FROM public.songs_stage
WHERE artist IS NOT NULL
""")
artists_insert = ("""
INSERT INTO public.artists_dwh (artists, artist_listeners)
SELECT DISTINCT ss.artist, ss.artist_listeners
FROM public.songs_stage ss
FULL JOIN public.events_stage es
ON ss.artist = es.artist
WHERE ss.artist IS NOT NULL AND es.artist IS NOT NULL
""")
concerts_insert = ("""
INSERT INTO public.concerts_dwh (name, location, start_date, artist)
SELECT concert, location, start_date, artist
FROM public.events_stage
WHERE artist IS NOT NULL
""")
delete_staging_events = "DROP TABLE IF EXISTS public.events_stage;"
delete_staging_songs = "DROP TABLE IF EXISTS public.songs_stage;"
delete_dwh_songs = "DROP TABLE IF EXISTS public.songs_dwh;"
delete_dwh_artists = "DROP TABLE IF EXISTS public.artists_dwh;"
delete_dwh_concerts = "DROP TABLE IF EXISTS public.concerts_dwh;"
create_staging_table_queries = [create_staging_events, create_staging_songs]
delete_staging_table_queries = [delete_staging_events, delete_staging_songs]
create_dwh_table_queries = [create_dwh_songs, create_dwh_artists, create_dwh_concerts]
delete_dwh_table_queries = [delete_dwh_songs, delete_dwh_artists, delete_dwh_concerts] | class Sqlqueries:
create_staging_events = '\n CREATE TABLE IF NOT EXISTS public.events_stage (\n index integer,\n concert varchar(256),\n artist varchar(256),\n location varchar(256),\n start_date date\n );\n '
create_staging_songs = '\n CREATE TABLE IF NOT EXISTS public.songs_stage (\n index integer,\n artist varchar(256),\n artist_listeners integer,\n song varchar(256),\n song_playcount integer,\n song_listeners integer\n );\n '
create_dwh_songs = '\n CREATE TABLE IF NOT EXISTS public.songs_dwh (\n song varchar(256),\n song_playcount integer,\n song_listeners integer,\n artist varchar(256)\n );\n '
create_dwh_artists = '\n CREATE TABLE IF NOT EXISTS public.artists_dwh (\n artists varchar(256),\n artist_listeners integer\n );\n '
create_dwh_concerts = '\n CREATE TABLE IF NOT EXISTS public.concerts_dwh (\n name varchar(256),\n location varchar(256),\n start_date date,\n artist varchar(256)\n );\n '
songs_insert = '\n INSERT INTO public.songs_dwh (song, song_playcount, song_listeners, artist)\n SELECT song, song_playcount, song_listeners, artist\n FROM public.songs_stage \n WHERE artist IS NOT NULL \n '
artists_insert = '\n INSERT INTO public.artists_dwh (artists, artist_listeners)\n SELECT DISTINCT ss.artist, ss.artist_listeners\n FROM public.songs_stage ss\n FULL JOIN public.events_stage es \n ON ss.artist = es.artist \n WHERE ss.artist IS NOT NULL AND es.artist IS NOT NULL \n '
concerts_insert = '\n INSERT INTO public.concerts_dwh (name, location, start_date, artist)\n SELECT concert, location, start_date, artist\n FROM public.events_stage \n WHERE artist IS NOT NULL \n '
delete_staging_events = 'DROP TABLE IF EXISTS public.events_stage;'
delete_staging_songs = 'DROP TABLE IF EXISTS public.songs_stage;'
delete_dwh_songs = 'DROP TABLE IF EXISTS public.songs_dwh;'
delete_dwh_artists = 'DROP TABLE IF EXISTS public.artists_dwh;'
delete_dwh_concerts = 'DROP TABLE IF EXISTS public.concerts_dwh;'
create_staging_table_queries = [create_staging_events, create_staging_songs]
delete_staging_table_queries = [delete_staging_events, delete_staging_songs]
create_dwh_table_queries = [create_dwh_songs, create_dwh_artists, create_dwh_concerts]
delete_dwh_table_queries = [delete_dwh_songs, delete_dwh_artists, delete_dwh_concerts] |
# Excel Sheet Column Number
'''
Given a column title as appear in an Excel sheet, return its corresponding column number.
For example:
A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
...
Example 1:
Input: "A"
Output: 1
Example 2:
Input: "AB"
Output: 28
Example 3:
Input: "ZY"
Output: 701
Constraints:
1 <= s.length <= 7
s consists only of uppercase English letters.
s is between "A" and "FXSHRXW".
'''
class Solution:
def titleToNumber(self, s: str) -> int:
s = s[::-1]
ans = 0
for i, ch in enumerate(s):
ans = ans + (ord(ch)-64)*(26**i)
return ans | """
Given a column title as appear in an Excel sheet, return its corresponding column number.
For example:
A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
...
Example 1:
Input: "A"
Output: 1
Example 2:
Input: "AB"
Output: 28
Example 3:
Input: "ZY"
Output: 701
Constraints:
1 <= s.length <= 7
s consists only of uppercase English letters.
s is between "A" and "FXSHRXW".
"""
class Solution:
def title_to_number(self, s: str) -> int:
s = s[::-1]
ans = 0
for (i, ch) in enumerate(s):
ans = ans + (ord(ch) - 64) * 26 ** i
return ans |
'''
Add two numbers
'''
def add(a, b):
return a + b
'''
Concatenate two lists
'''
def concat(L1, L2, L3):
return L1 + L2 + L3
'''
Get length of a list
'''
def length(L):
# We will make this one wrong to test failed tests
return len(L) - 1
| """
Add two numbers
"""
def add(a, b):
return a + b
'\nConcatenate two lists\n'
def concat(L1, L2, L3):
return L1 + L2 + L3
'\nGet length of a list\n'
def length(L):
return len(L) - 1 |
# -*- coding: utf-8 -*-
def __reversed__(self):
"""Built-in to implement reverse iteration"""
return self._statements.__reversed__()
| def __reversed__(self):
"""Built-in to implement reverse iteration"""
return self._statements.__reversed__() |
# -*- coding:utf-8 -*-
"""
@author: SiriYang
@file: __init__.py
@createTime: 2021-01-23 13:51:53
@updateTime: 2021-01-23 13:51:53
@codeLines: 0
"""
| """
@author: SiriYang
@file: __init__.py
@createTime: 2021-01-23 13:51:53
@updateTime: 2021-01-23 13:51:53
@codeLines: 0
""" |
"""
home.ts.__init__
================
Nothing to see here!
"""
| """
home.ts.__init__
================
Nothing to see here!
""" |
'''THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE
DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY,
WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.'''
# Bitcoin Cash (BCH) qpz32c4lg7x7lnk9jg6qg7s4uavdce89myax5v5nuk
# Ether (ETH) - 0x843d3DEC2A4705BD4f45F674F641cE2D0022c9FB
# Litecoin (LTC) - Lfk5y4F7KZa9oRxpazETwjQnHszEPvqPvu
# Bitcoin (BTC) - 34L8qWiQyKr8k4TnHDacfjbaSqQASbBtTd
# contact :- github@jamessawyer.co.uk
"""
Wiggle Sort.
Given an unsorted array nums, reorder it such
that nums[0] < nums[1] > nums[2] < nums[3]....
For example:
if input numbers = [3, 5, 2, 1, 6, 4]
one possible Wiggle Sorted answer is [3, 5, 1, 6, 2, 4].
"""
def wiggle_sort(nums):
"""Perform Wiggle Sort."""
for i in range(len(nums)):
if (i % 2 == 1) == (nums[i - 1] > nums[i]):
nums[i - 1], nums[i] = nums[i], nums[i - 1]
if __name__ == "__main__":
print("Enter the array elements:\n")
array = list(map(int, input().split()))
print("The unsorted array is:\n")
print(array)
wiggle_sort(array)
print("Array after Wiggle sort:\n")
print(array)
| """THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE
DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY,
WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE."""
'\nWiggle Sort.\n\nGiven an unsorted array nums, reorder it such\nthat nums[0] < nums[1] > nums[2] < nums[3]....\nFor example:\nif input numbers = [3, 5, 2, 1, 6, 4]\none possible Wiggle Sorted answer is [3, 5, 1, 6, 2, 4].\n'
def wiggle_sort(nums):
"""Perform Wiggle Sort."""
for i in range(len(nums)):
if (i % 2 == 1) == (nums[i - 1] > nums[i]):
(nums[i - 1], nums[i]) = (nums[i], nums[i - 1])
if __name__ == '__main__':
print('Enter the array elements:\n')
array = list(map(int, input().split()))
print('The unsorted array is:\n')
print(array)
wiggle_sort(array)
print('Array after Wiggle sort:\n')
print(array) |
def mul(x, y):
return x * y % 1337
class Solution(object):
def superPow(self, a, b):
"""
:type a: int
:type b: List[int]
:rtype: int
"""
if a >= 1337:
return self.superPow(a % 1337, b)
if a == 0 or a == 1:
return a
n = len(b)
res = 1
for i in range(0, n):
if b[n - 1 - i]:
res = mul(res, pow(a, b[n - 1 - i], 1337))
a = pow(a, 10, 1337)
return res
| def mul(x, y):
return x * y % 1337
class Solution(object):
def super_pow(self, a, b):
"""
:type a: int
:type b: List[int]
:rtype: int
"""
if a >= 1337:
return self.superPow(a % 1337, b)
if a == 0 or a == 1:
return a
n = len(b)
res = 1
for i in range(0, n):
if b[n - 1 - i]:
res = mul(res, pow(a, b[n - 1 - i], 1337))
a = pow(a, 10, 1337)
return res |
Terrain = [
{"stop": 0.00, "color": {'r': 0x00, 'g': 0x9a, 'b': 0x24}},
{"stop": 0.45, "color": {'r': 0xff, 'g': 0xff, 'b': 0x00}},
{"stop": 0.90, "color": {'r': 0xff, 'g': 0x00, 'b': 0x00}},
{"stop": 1.00, "color": {'r': 0xff, 'g': 0xe0, 'b': 0xe0}}
]
Water = [
{"stop": 0.00, "color": {'r': 0x34, 'g': 0x40, 'b': 0x44}},
{"stop": 1.00, "color": {'r': 0x15, 'g': 0x54, 'b': 0xd1}}
]
WaterDepth = [
{"stop": 0.00, "color": {'r': 0x15, 'g': 0x54, 'b': 0xd1}},
{"stop": 1.00, "color": {'r': 0x34, 'g': 0x40, 'b': 0x44}}
]
GrayScale = [
{"stop": 0.00, "color": {'r': 0x00, 'g': 0x00, 'b': 0x00}},
{"stop": 1.00, "color": {'r': 0xff, 'g': 0xff, 'b': 0xff}}
]
| terrain = [{'stop': 0.0, 'color': {'r': 0, 'g': 154, 'b': 36}}, {'stop': 0.45, 'color': {'r': 255, 'g': 255, 'b': 0}}, {'stop': 0.9, 'color': {'r': 255, 'g': 0, 'b': 0}}, {'stop': 1.0, 'color': {'r': 255, 'g': 224, 'b': 224}}]
water = [{'stop': 0.0, 'color': {'r': 52, 'g': 64, 'b': 68}}, {'stop': 1.0, 'color': {'r': 21, 'g': 84, 'b': 209}}]
water_depth = [{'stop': 0.0, 'color': {'r': 21, 'g': 84, 'b': 209}}, {'stop': 1.0, 'color': {'r': 52, 'g': 64, 'b': 68}}]
gray_scale = [{'stop': 0.0, 'color': {'r': 0, 'g': 0, 'b': 0}}, {'stop': 1.0, 'color': {'r': 255, 'g': 255, 'b': 255}}] |
def load(h):
return ({'abbr': 0, 'code': 0, 'title': 'Unknown'},
{'abbr': 'fg', 'code': 1, 'title': 'First guess'},
{'abbr': 'an', 'code': 2, 'title': 'Analysis'},
{'abbr': 'ia', 'code': 3, 'title': 'Initialised analysis'},
{'abbr': 'oi', 'code': 4, 'title': 'Oi analysis'},
{'abbr': '3v', 'code': 5, 'title': '3d variational analysis'},
{'abbr': '4v', 'code': 6, 'title': '4d variational analysis'},
{'abbr': '3g', 'code': 7, 'title': '3d variational gradients'},
{'abbr': '4g', 'code': 8, 'title': '4d variational gradients'},
{'abbr': 'fc', 'code': 9, 'title': 'Forecast'},
{'abbr': 'cf', 'code': 10, 'title': 'Control forecast'},
{'abbr': 'pf', 'code': 11, 'title': 'Perturbed forecast'},
{'abbr': 'ef', 'code': 12, 'title': 'Errors in first guess'},
{'abbr': 'ea', 'code': 13, 'title': 'Errors in analysis'},
{'abbr': 'cm', 'code': 14, 'title': 'Cluster means'},
{'abbr': 'cs', 'code': 15, 'title': 'Cluster std deviations'},
{'abbr': 'fp', 'code': 16, 'title': 'Forecast probability'},
{'abbr': 'em', 'code': 17, 'title': 'Ensemble mean'},
{'abbr': 'es', 'code': 18, 'title': 'Ensemble standard deviation'},
{'abbr': 'fa', 'code': 19, 'title': 'Forecast accumulation'},
{'abbr': 'cl', 'code': 20, 'title': 'Climatology'},
{'abbr': 'si', 'code': 21, 'title': 'Climate simulation'},
{'abbr': 's3', 'code': 22, 'title': 'Climate 30 days simulation'},
{'abbr': 'ed', 'code': 23, 'title': 'Empirical distribution'},
{'abbr': 'tu', 'code': 24, 'title': 'Tubes'},
{'abbr': 'ff', 'code': 25, 'title': 'Flux forcing realtime'},
{'abbr': 'of', 'code': 26, 'title': 'Ocean forward'},
{'abbr': 'efi', 'code': 27, 'title': 'Extreme forecast index'},
{'abbr': 'efic', 'code': 28, 'title': 'Extreme forecast index control'},
{'abbr': 'pb', 'code': 29, 'title': 'Probability boundaries'},
{'abbr': 'ep', 'code': 30, 'title': 'Event probability'},
{'abbr': 'bf', 'code': 31, 'title': 'Bias-corrected forecast'},
{'abbr': 'cd', 'code': 32, 'title': 'Climate distribution'},
{'abbr': '4i', 'code': 33, 'title': '4D analysis increments'},
{'abbr': 'go', 'code': 34, 'title': 'Gridded observations'},
{'abbr': 'me', 'code': 35, 'title': 'Model errors'},
{'abbr': 'pd', 'code': 36, 'title': 'Probability distribution'},
{'abbr': 'ci', 'code': 37, 'title': 'Cluster information'},
{'abbr': 'sot', 'code': 38, 'title': 'Shift of Tail'},
{'abbr': 'eme',
'code': 39,
'title': 'Ensemble data assimilation model errors'},
{'abbr': 'im', 'code': 40, 'title': 'Images'},
{'abbr': 'sim', 'code': 42, 'title': 'Simulated images'},
{'abbr': 'wem', 'code': 43, 'title': 'Weighted ensemble mean'},
{'abbr': 'wes', 'code': 44, 'title': 'Weighted ensemble standard deviation'},
{'abbr': 'cr', 'code': 45, 'title': 'Cluster representative'},
{'abbr': 'ses', 'code': 46, 'title': 'Scaled ensemble standard deviation'},
{'abbr': 'taem', 'code': 47, 'title': 'Time average ensemble mean'},
{'abbr': 'taes',
'code': 48,
'title': 'Time average ensemble standard deviation'},
{'abbr': 'sg', 'code': 50, 'title': 'Sensitivity gradient'},
{'abbr': 'sf', 'code': 52, 'title': 'Sensitivity forecast'},
{'abbr': 'pa', 'code': 60, 'title': 'Perturbed analysis'},
{'abbr': 'icp', 'code': 61, 'title': 'Initial condition perturbation'},
{'abbr': 'sv', 'code': 62, 'title': 'Singular vector'},
{'abbr': 'as', 'code': 63, 'title': 'Adjoint singular vector'},
{'abbr': 'svar', 'code': 64, 'title': 'Signal variance'},
{'abbr': 'cv', 'code': 65, 'title': 'Calibration/Validation forecast'},
{'abbr': 'or', 'code': 70, 'title': 'Ocean reanalysis'},
{'abbr': 'fx', 'code': 71, 'title': 'Flux forcing'},
{'abbr': 'fu', 'code': 72, 'title': 'Fill-up'},
{'abbr': 'sfo', 'code': 73, 'title': 'Simulations with forcing'},
{'abbr': 'fcmean', 'code': 80, 'title': 'Forecast mean'},
{'abbr': 'fcmax', 'code': 81, 'title': 'Forecast maximum'},
{'abbr': 'fcmin', 'code': 82, 'title': 'Forecast minimum'},
{'abbr': 'fcstdev', 'code': 83, 'title': 'Forecast standard deviation'},
{'abbr': 'emtm', 'code': 84, 'title': 'Ensemble mean of temporal mean'},
{'abbr': 'estdtm',
'code': 85,
'title': 'Ensemble standard deviation of temporal mean'},
{'abbr': 'hcmean', 'code': 86, 'title': 'Hindcast climate mean'},
{'abbr': 'ssd', 'code': 87, 'title': 'Simulated satellite data'},
{'abbr': 'gsd', 'code': 88, 'title': 'Gridded satellite data'},
{'abbr': 'ga', 'code': 89, 'title': 'GFAS analysis'},
{'abbr': 'gai', 'code': 90, 'title': 'Gridded analysis input'})
| def load(h):
return ({'abbr': 0, 'code': 0, 'title': 'Unknown'}, {'abbr': 'fg', 'code': 1, 'title': 'First guess'}, {'abbr': 'an', 'code': 2, 'title': 'Analysis'}, {'abbr': 'ia', 'code': 3, 'title': 'Initialised analysis'}, {'abbr': 'oi', 'code': 4, 'title': 'Oi analysis'}, {'abbr': '3v', 'code': 5, 'title': '3d variational analysis'}, {'abbr': '4v', 'code': 6, 'title': '4d variational analysis'}, {'abbr': '3g', 'code': 7, 'title': '3d variational gradients'}, {'abbr': '4g', 'code': 8, 'title': '4d variational gradients'}, {'abbr': 'fc', 'code': 9, 'title': 'Forecast'}, {'abbr': 'cf', 'code': 10, 'title': 'Control forecast'}, {'abbr': 'pf', 'code': 11, 'title': 'Perturbed forecast'}, {'abbr': 'ef', 'code': 12, 'title': 'Errors in first guess'}, {'abbr': 'ea', 'code': 13, 'title': 'Errors in analysis'}, {'abbr': 'cm', 'code': 14, 'title': 'Cluster means'}, {'abbr': 'cs', 'code': 15, 'title': 'Cluster std deviations'}, {'abbr': 'fp', 'code': 16, 'title': 'Forecast probability'}, {'abbr': 'em', 'code': 17, 'title': 'Ensemble mean'}, {'abbr': 'es', 'code': 18, 'title': 'Ensemble standard deviation'}, {'abbr': 'fa', 'code': 19, 'title': 'Forecast accumulation'}, {'abbr': 'cl', 'code': 20, 'title': 'Climatology'}, {'abbr': 'si', 'code': 21, 'title': 'Climate simulation'}, {'abbr': 's3', 'code': 22, 'title': 'Climate 30 days simulation'}, {'abbr': 'ed', 'code': 23, 'title': 'Empirical distribution'}, {'abbr': 'tu', 'code': 24, 'title': 'Tubes'}, {'abbr': 'ff', 'code': 25, 'title': 'Flux forcing realtime'}, {'abbr': 'of', 'code': 26, 'title': 'Ocean forward'}, {'abbr': 'efi', 'code': 27, 'title': 'Extreme forecast index'}, {'abbr': 'efic', 'code': 28, 'title': 'Extreme forecast index control'}, {'abbr': 'pb', 'code': 29, 'title': 'Probability boundaries'}, {'abbr': 'ep', 'code': 30, 'title': 'Event probability'}, {'abbr': 'bf', 'code': 31, 'title': 'Bias-corrected forecast'}, {'abbr': 'cd', 'code': 32, 'title': 'Climate distribution'}, {'abbr': '4i', 'code': 33, 'title': '4D analysis increments'}, {'abbr': 'go', 'code': 34, 'title': 'Gridded observations'}, {'abbr': 'me', 'code': 35, 'title': 'Model errors'}, {'abbr': 'pd', 'code': 36, 'title': 'Probability distribution'}, {'abbr': 'ci', 'code': 37, 'title': 'Cluster information'}, {'abbr': 'sot', 'code': 38, 'title': 'Shift of Tail'}, {'abbr': 'eme', 'code': 39, 'title': 'Ensemble data assimilation model errors'}, {'abbr': 'im', 'code': 40, 'title': 'Images'}, {'abbr': 'sim', 'code': 42, 'title': 'Simulated images'}, {'abbr': 'wem', 'code': 43, 'title': 'Weighted ensemble mean'}, {'abbr': 'wes', 'code': 44, 'title': 'Weighted ensemble standard deviation'}, {'abbr': 'cr', 'code': 45, 'title': 'Cluster representative'}, {'abbr': 'ses', 'code': 46, 'title': 'Scaled ensemble standard deviation'}, {'abbr': 'taem', 'code': 47, 'title': 'Time average ensemble mean'}, {'abbr': 'taes', 'code': 48, 'title': 'Time average ensemble standard deviation'}, {'abbr': 'sg', 'code': 50, 'title': 'Sensitivity gradient'}, {'abbr': 'sf', 'code': 52, 'title': 'Sensitivity forecast'}, {'abbr': 'pa', 'code': 60, 'title': 'Perturbed analysis'}, {'abbr': 'icp', 'code': 61, 'title': 'Initial condition perturbation'}, {'abbr': 'sv', 'code': 62, 'title': 'Singular vector'}, {'abbr': 'as', 'code': 63, 'title': 'Adjoint singular vector'}, {'abbr': 'svar', 'code': 64, 'title': 'Signal variance'}, {'abbr': 'cv', 'code': 65, 'title': 'Calibration/Validation forecast'}, {'abbr': 'or', 'code': 70, 'title': 'Ocean reanalysis'}, {'abbr': 'fx', 'code': 71, 'title': 'Flux forcing'}, {'abbr': 'fu', 'code': 72, 'title': 'Fill-up'}, {'abbr': 'sfo', 'code': 73, 'title': 'Simulations with forcing'}, {'abbr': 'fcmean', 'code': 80, 'title': 'Forecast mean'}, {'abbr': 'fcmax', 'code': 81, 'title': 'Forecast maximum'}, {'abbr': 'fcmin', 'code': 82, 'title': 'Forecast minimum'}, {'abbr': 'fcstdev', 'code': 83, 'title': 'Forecast standard deviation'}, {'abbr': 'emtm', 'code': 84, 'title': 'Ensemble mean of temporal mean'}, {'abbr': 'estdtm', 'code': 85, 'title': 'Ensemble standard deviation of temporal mean'}, {'abbr': 'hcmean', 'code': 86, 'title': 'Hindcast climate mean'}, {'abbr': 'ssd', 'code': 87, 'title': 'Simulated satellite data'}, {'abbr': 'gsd', 'code': 88, 'title': 'Gridded satellite data'}, {'abbr': 'ga', 'code': 89, 'title': 'GFAS analysis'}, {'abbr': 'gai', 'code': 90, 'title': 'Gridded analysis input'}) |
class Solution:
def maxSubArray(self, nums: [int]) -> int:
tmp = nums[0]
maxv = tmp
for i in range(1, len(nums)):
if tmp + nums[i] > nums[i]:
maxv = max(maxv, tmp + nums[i])
tmp = tmp + nums[i]
else:
maxv = max(maxv, tmp, nums[i])
tmp = nums[i]
return maxv | class Solution:
def max_sub_array(self, nums: [int]) -> int:
tmp = nums[0]
maxv = tmp
for i in range(1, len(nums)):
if tmp + nums[i] > nums[i]:
maxv = max(maxv, tmp + nums[i])
tmp = tmp + nums[i]
else:
maxv = max(maxv, tmp, nums[i])
tmp = nums[i]
return maxv |
class SimulationParameters:
start_time = 0. # start time for simulation
end_time = 50000. # end time for simulation
dt_video = 0.1
dt_simulation = 0.03 # smallest time step for simulation
dt_plotting = 0.3 # refresh rate for plots
dt_controller = dt_simulation # sample rate for the controller
dt_observer = dt_simulation # sample rate for the observer
| class Simulationparameters:
start_time = 0.0
end_time = 50000.0
dt_video = 0.1
dt_simulation = 0.03
dt_plotting = 0.3
dt_controller = dt_simulation
dt_observer = dt_simulation |
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def addTwoNumbers(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"""
result = ListNode(0)
head = result
carry = 0
while (l1 or l2):
addition = 0
if l1:
addition = addition + l1.val
if l2:
addition = addition + l2.val
addition = addition + carry
val = addition % 10
carry = addition / 10
result.next = ListNode(val)
result = result.next
if l1:
l1 = l1.next
if l2:
l2 = l2.next
if carry:
result.next = ListNode(carry)
return head.next
| class Solution(object):
def add_two_numbers(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"""
result = list_node(0)
head = result
carry = 0
while l1 or l2:
addition = 0
if l1:
addition = addition + l1.val
if l2:
addition = addition + l2.val
addition = addition + carry
val = addition % 10
carry = addition / 10
result.next = list_node(val)
result = result.next
if l1:
l1 = l1.next
if l2:
l2 = l2.next
if carry:
result.next = list_node(carry)
return head.next |
class CyclesCurveSettings:
radius_scale = None
root_width = None
shape = None
tip_width = None
use_closetip = None
| class Cyclescurvesettings:
radius_scale = None
root_width = None
shape = None
tip_width = None
use_closetip = None |
#from .atributo import Atributo
class TablaDestino:
nombre = " "
atributos = []
datos=[]
funcion=False
atributo=''
proceso=''
def __init__(self,nombre,atributos,funcion=False,atributo=None,proceso=None):
self.nombre=nombre
self.atributos=atributos
self.funcion=funcion
self.atributo=atributo
self.proceso=proceso
def setDato(self,datos):
#print (datos)
self.datos.append(datos)
| class Tabladestino:
nombre = ' '
atributos = []
datos = []
funcion = False
atributo = ''
proceso = ''
def __init__(self, nombre, atributos, funcion=False, atributo=None, proceso=None):
self.nombre = nombre
self.atributos = atributos
self.funcion = funcion
self.atributo = atributo
self.proceso = proceso
def set_dato(self, datos):
self.datos.append(datos) |
#ordena a lista em ordem crescente sem o SORT/SORTED
numeros = list()
for n in range(0,5):
numero = int(input("Digite um numero: "))
for chave, valor in enumerate(numeros):
if numero < valor:
numeros.insert(chave, numero)
break
else:
numeros.append(numero)
print(numeros)
| numeros = list()
for n in range(0, 5):
numero = int(input('Digite um numero: '))
for (chave, valor) in enumerate(numeros):
if numero < valor:
numeros.insert(chave, numero)
break
else:
numeros.append(numero)
print(numeros) |
#
# Copyright (c) 2021 salesforce.com, inc.
# All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
#
"""
Contains all anomaly detection models. Forecaster-based anomaly detection models
may be found in :py:mod:`merlion.models.anomaly.forecast_based`. Change-point detection models may be
found in :py:mod:`merlion.models.anomaly.change_point`.
For anomaly detection, we define an abstract `DetectorBase` class which inherits from `ModelBase` and supports the
following interface, in addition to ``model.save`` and ``DetectorClass.load`` defined for `ModelBase`:
1. ``model = DetectorClass(config)``
- initialization with a model-specific config
- configs contain:
- a (potentially trainable) data pre-processing transform from :py:mod:`merlion.transform`;
note that ``model.transform`` is a property which refers to ``model.config.transform``
- **a (potentially trainable) post-processing rule** from :py:mod:`merlion.post_process`;
note that ``model.post_rule`` is a property which refers to ``model.config.post_rule``.
In general, this post-rule will have two stages: :py:mod:`calibration <merlion.post_process.calibrate>`
and :py:mod:`thresholding <merlion.post_process.threshold>`.
- booleans ``enable_calibrator`` and ``enable_threshold`` (both defaulting to ``True``) indicating
whether to enable calibration and thresholding in the post-rule.
- model-specific hyperparameters
2. ``model.get_anomaly_score(time_series, time_series_prev=None)``
- returns a time series of anomaly scores for each timestamp in ``time_series``
- ``time_series_prev`` (optional): the most recent context, only used for some models. If not provided, the
training data is used as the context instead.
3. ``model.get_anomaly_label(time_series, time_series_prev=None)``
- returns a time series of post-processed anomaly scores for each timestamp in ``time_series``. These scores
are calibrated to correspond to z-scores if ``enable_calibrator`` is ``True``, and they have also been filtered
by a thresholding rule (``model.threshold``) if ``enable_threshold`` is ``True``. ``threshold`` is specified
manually in the config (though it may be modified by `DetectorBase.train`), .
- ``time_series_prev`` (optional): the most recent context, only used for some models. If not provided, the
training data is used as the context instead.
4. ``model.train(train_data, anomaly_labels=None, train_config=None, post_rule_train_config=None)``
- trains the model on the time series ``train_data``
- ``anomaly_labels`` (optional): a time series aligned with ``train_data``, which indicates whether each
time stamp is anomalous
- ``train_config`` (optional): extra configuration describing how the model should be trained (e.g. learning rate
for the `LSTMDetector`). Not used for all models. Class-level default provided for models which do use it.
- ``post_rule_train_config``: extra configuration describing how to train the model's post-rule. Class-level
default is provided for all models.
- returns a time series of anomaly scores produced by the model on ``train_data``.
"""
| """
Contains all anomaly detection models. Forecaster-based anomaly detection models
may be found in :py:mod:`merlion.models.anomaly.forecast_based`. Change-point detection models may be
found in :py:mod:`merlion.models.anomaly.change_point`.
For anomaly detection, we define an abstract `DetectorBase` class which inherits from `ModelBase` and supports the
following interface, in addition to ``model.save`` and ``DetectorClass.load`` defined for `ModelBase`:
1. ``model = DetectorClass(config)``
- initialization with a model-specific config
- configs contain:
- a (potentially trainable) data pre-processing transform from :py:mod:`merlion.transform`;
note that ``model.transform`` is a property which refers to ``model.config.transform``
- **a (potentially trainable) post-processing rule** from :py:mod:`merlion.post_process`;
note that ``model.post_rule`` is a property which refers to ``model.config.post_rule``.
In general, this post-rule will have two stages: :py:mod:`calibration <merlion.post_process.calibrate>`
and :py:mod:`thresholding <merlion.post_process.threshold>`.
- booleans ``enable_calibrator`` and ``enable_threshold`` (both defaulting to ``True``) indicating
whether to enable calibration and thresholding in the post-rule.
- model-specific hyperparameters
2. ``model.get_anomaly_score(time_series, time_series_prev=None)``
- returns a time series of anomaly scores for each timestamp in ``time_series``
- ``time_series_prev`` (optional): the most recent context, only used for some models. If not provided, the
training data is used as the context instead.
3. ``model.get_anomaly_label(time_series, time_series_prev=None)``
- returns a time series of post-processed anomaly scores for each timestamp in ``time_series``. These scores
are calibrated to correspond to z-scores if ``enable_calibrator`` is ``True``, and they have also been filtered
by a thresholding rule (``model.threshold``) if ``enable_threshold`` is ``True``. ``threshold`` is specified
manually in the config (though it may be modified by `DetectorBase.train`), .
- ``time_series_prev`` (optional): the most recent context, only used for some models. If not provided, the
training data is used as the context instead.
4. ``model.train(train_data, anomaly_labels=None, train_config=None, post_rule_train_config=None)``
- trains the model on the time series ``train_data``
- ``anomaly_labels`` (optional): a time series aligned with ``train_data``, which indicates whether each
time stamp is anomalous
- ``train_config`` (optional): extra configuration describing how the model should be trained (e.g. learning rate
for the `LSTMDetector`). Not used for all models. Class-level default provided for models which do use it.
- ``post_rule_train_config``: extra configuration describing how to train the model's post-rule. Class-level
default is provided for all models.
- returns a time series of anomaly scores produced by the model on ``train_data``.
""" |
valid_address_types = [
['ant', 'antenna'],
['mbth', 'marine berth'],
['allotment', 'allotment'],
['atm', 'auto teller machine'],
['bbox', 'bathing box'],
['bbq', 'barbeque'],
['berths', 'berths'],
['berth', 'berth'],
['bldgs', 'buildings'],
['bldg', 'building'],
['bld', 'building'],
['bngws', 'bungalows'],
['bngw', 'bungalow'],
['cages', 'cages'],
['cage', 'cage'],
['carps', 'carparks'],
['carp', 'carpark'],
['cars', 'carspace'],
['carw', 'carwash'],
['cool', 'coolroom'],
['ctges', 'cottages'],
['ctge', 'cottage'],
['ctyds', 'courtyards'],
['ctyd', 'courtyard'],
['dupl', 'duplex'],
['fctys', 'factories'],
['fcty', 'factory'],
['flats', 'flats'],
['grges', 'garages'],
['flat', 'flat'],
['grge', 'garage'],
['heli', 'heliport'],
['hngrs', 'hangers'],
['hngr', 'hanger'],
['host', 'hostel'],
['hses', 'houses'],
['hse', 'house'],
['ksk', 'kiosk'],
['lbby', 'lobby'],
['loft', 'loft'],
['lots', 'lots'],
['lot', 'lot'],
['lse', 'lease'],
['str', 'strata unit'],
['msnt', 'maisonette'],
['offcs', 'offices'],
['offc', 'office'],
['pswy', 'passageway'],
['pths', 'penthouse'],
['rest', 'restaraunt'],
['room', 'room'],
['rptn', 'reception'],
['sapt', 'studio apartment'],
['suites', 'suites'],
['suite', 'suite'],
['shcs', 'showcase'],
['sheds', 'sheds'],
['shed', 'shed'],
['shops', 'shops'],
['shp', 'shop'],
['shop', 'shop'],
['shrms', 'showrooms'],
['shrm', 'showroom'],
['sign', 'sign'],
['sites', 'sites'],
['site', 'site'],
['stlls', 'stalls'],
['stll', 'stall'],
['stors', 'stores'],
['stor', 'store'],
['studios', 'studios'],
['stu', 'studio'],
['subs', 'substation'],
['tncys', 'tenancies'],
['tncy', 'tenancy'],
['townhouses', 'townhouses'],
['tnhs', 'townhouse'],
['twrs', 'towers'],
['twr', 'tower'],
['units', 'units'],
['unit', 'unit'],
['u', 'unit'],
['vllas', 'villas'],
['vlla', 'villa'],
['vlt', 'vault'],
['wards', 'wards'],
['ward', 'ward'],
['wc', 'toilet'],
['whses', 'warehouses'],
['whse', 'warehouse'],
['wkshs', 'workshops'],
['wksh', 'workshop'],
['apts', 'apartments'],
['apt', 'apartment']
]
| valid_address_types = [['ant', 'antenna'], ['mbth', 'marine berth'], ['allotment', 'allotment'], ['atm', 'auto teller machine'], ['bbox', 'bathing box'], ['bbq', 'barbeque'], ['berths', 'berths'], ['berth', 'berth'], ['bldgs', 'buildings'], ['bldg', 'building'], ['bld', 'building'], ['bngws', 'bungalows'], ['bngw', 'bungalow'], ['cages', 'cages'], ['cage', 'cage'], ['carps', 'carparks'], ['carp', 'carpark'], ['cars', 'carspace'], ['carw', 'carwash'], ['cool', 'coolroom'], ['ctges', 'cottages'], ['ctge', 'cottage'], ['ctyds', 'courtyards'], ['ctyd', 'courtyard'], ['dupl', 'duplex'], ['fctys', 'factories'], ['fcty', 'factory'], ['flats', 'flats'], ['grges', 'garages'], ['flat', 'flat'], ['grge', 'garage'], ['heli', 'heliport'], ['hngrs', 'hangers'], ['hngr', 'hanger'], ['host', 'hostel'], ['hses', 'houses'], ['hse', 'house'], ['ksk', 'kiosk'], ['lbby', 'lobby'], ['loft', 'loft'], ['lots', 'lots'], ['lot', 'lot'], ['lse', 'lease'], ['str', 'strata unit'], ['msnt', 'maisonette'], ['offcs', 'offices'], ['offc', 'office'], ['pswy', 'passageway'], ['pths', 'penthouse'], ['rest', 'restaraunt'], ['room', 'room'], ['rptn', 'reception'], ['sapt', 'studio apartment'], ['suites', 'suites'], ['suite', 'suite'], ['shcs', 'showcase'], ['sheds', 'sheds'], ['shed', 'shed'], ['shops', 'shops'], ['shp', 'shop'], ['shop', 'shop'], ['shrms', 'showrooms'], ['shrm', 'showroom'], ['sign', 'sign'], ['sites', 'sites'], ['site', 'site'], ['stlls', 'stalls'], ['stll', 'stall'], ['stors', 'stores'], ['stor', 'store'], ['studios', 'studios'], ['stu', 'studio'], ['subs', 'substation'], ['tncys', 'tenancies'], ['tncy', 'tenancy'], ['townhouses', 'townhouses'], ['tnhs', 'townhouse'], ['twrs', 'towers'], ['twr', 'tower'], ['units', 'units'], ['unit', 'unit'], ['u', 'unit'], ['vllas', 'villas'], ['vlla', 'villa'], ['vlt', 'vault'], ['wards', 'wards'], ['ward', 'ward'], ['wc', 'toilet'], ['whses', 'warehouses'], ['whse', 'warehouse'], ['wkshs', 'workshops'], ['wksh', 'workshop'], ['apts', 'apartments'], ['apt', 'apartment']] |
def get_oauth():
pass
def get_repo(owner, name):
pass
| def get_oauth():
pass
def get_repo(owner, name):
pass |
def decompress(nums):
keep = []
for i in range (0,len(nums),2):
x = nums[i]
while x > 0:
keep.append(nums[i+1])
x-=1
return keep
#nums = [1,2,3,4]
nums = [1,1,2,3]
print(decompress(nums)) | def decompress(nums):
keep = []
for i in range(0, len(nums), 2):
x = nums[i]
while x > 0:
keep.append(nums[i + 1])
x -= 1
return keep
nums = [1, 1, 2, 3]
print(decompress(nums)) |
def weekday(n):
'returns the name of the nth day of the week'
days = ['Monday', 'Tuesday', 'Wednesday']
if 1 <= n and n <= 7:
return days[n-1]
| def weekday(n):
"""returns the name of the nth day of the week"""
days = ['Monday', 'Tuesday', 'Wednesday']
if 1 <= n and n <= 7:
return days[n - 1] |
while True:
enemy = hero.findNearestEnemy()
friend = hero.findNearestFriend()
hero.moveXY((friend.pos.x + enemy.pos.x) / 2, (friend.pos.y + enemy.pos.y) / 2);
| while True:
enemy = hero.findNearestEnemy()
friend = hero.findNearestFriend()
hero.moveXY((friend.pos.x + enemy.pos.x) / 2, (friend.pos.y + enemy.pos.y) / 2) |
r_fib = {}
LIMIT = 100 + 1
fib = [1,2]
for i in range(LIMIT):
fib.append(fib[-1] + fib[-2])
for i in range(LIMIT):
r_fib[fib[i]] = i
num_cases = int(input())
for c in range(num_cases):
input()
code = list(map(int, input().split()))
cipher = input().strip()
out_text = [' '] * 100
i = 0
str_len = 0
for ch in cipher:
if i >= len(code):
break
if ch.isupper():
out_index = r_fib[code[i]]
out_text[out_index] = ch
str_len = max(str_len, out_index+1)
i += 1
print("".join(out_text[:str_len])) | r_fib = {}
limit = 100 + 1
fib = [1, 2]
for i in range(LIMIT):
fib.append(fib[-1] + fib[-2])
for i in range(LIMIT):
r_fib[fib[i]] = i
num_cases = int(input())
for c in range(num_cases):
input()
code = list(map(int, input().split()))
cipher = input().strip()
out_text = [' '] * 100
i = 0
str_len = 0
for ch in cipher:
if i >= len(code):
break
if ch.isupper():
out_index = r_fib[code[i]]
out_text[out_index] = ch
str_len = max(str_len, out_index + 1)
i += 1
print(''.join(out_text[:str_len])) |
"""
Exception for use in the telemetry agent
Copyright (C) 2017-2022 Intel Corporation
SPDX-License-Identifier: Apache-2.0
"""
class TelemetryException(Exception):
pass
| """
Exception for use in the telemetry agent
Copyright (C) 2017-2022 Intel Corporation
SPDX-License-Identifier: Apache-2.0
"""
class Telemetryexception(Exception):
pass |
# O(N * logN)
# https://www.geeksforgeeks.org/longest-monotonically-increasing-subsequence-size-n-log-n/
class Solution(object):
def lengthOfLIS(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
res = []
for n in nums:
index = self.binary_search(res, n) # use bisect.bisect_left to reduce more runtime
if index == -1:
res.append(n)
else:
res[index] = n
return len(res)
def binary_search(self, nums, target):
#find element no less than target
if len(nums) == 0:
return -1
start = 0
end = len(nums) - 1
while(start + 1 < end):
mid = start + (end - start) / 2
if nums[mid] < target:
start = mid
else:
end = mid
if nums[start] >= target:
return start
if nums[end] >= target:
return end
return -1
# f(i) = max(1, f(j) + 1 if j < i and nums[j] < nums[i])
# O(N ^ 2)
class Solution2(object):
def lengthOfLIS(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if nums is None or len(nums) == 0:
return 0
m = len(nums)
table = [0 for _ in range(m)]
table[0] = 1
for i in range(1, m):
value = 1
for j in range(i):
if nums[j] < nums[i]:
value = max(value, table[j] + 1)
table[i] = value
return max(table)
| class Solution(object):
def length_of_lis(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
res = []
for n in nums:
index = self.binary_search(res, n)
if index == -1:
res.append(n)
else:
res[index] = n
return len(res)
def binary_search(self, nums, target):
if len(nums) == 0:
return -1
start = 0
end = len(nums) - 1
while start + 1 < end:
mid = start + (end - start) / 2
if nums[mid] < target:
start = mid
else:
end = mid
if nums[start] >= target:
return start
if nums[end] >= target:
return end
return -1
class Solution2(object):
def length_of_lis(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if nums is None or len(nums) == 0:
return 0
m = len(nums)
table = [0 for _ in range(m)]
table[0] = 1
for i in range(1, m):
value = 1
for j in range(i):
if nums[j] < nums[i]:
value = max(value, table[j] + 1)
table[i] = value
return max(table) |
g = 85
h = 85
if g < h:
print("g is less than h")
else:
if g == h:
print("g is equal to h")
else:
print("g is greater than h")
| g = 85
h = 85
if g < h:
print('g is less than h')
elif g == h:
print('g is equal to h')
else:
print('g is greater than h') |
# -*- coding:utf-8 -*-
# Copyright 2019 TEEX
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class Response:
def __init__(self, type, response_method, result, request_id, chain_name, gas_price, gas_limit, tora_addr, user_addr, params):
self.type = type # builtin 0, collector 1, swap verify 2, cross chain info 3, executor 4
self.response_method = response_method
self.result = result
self.request_id = request_id
self.chain_name = chain_name
self.gas_price = gas_price
self.gas_limit = gas_limit
self.tora_addr = tora_addr
self.user_addr = user_addr
self.params = params
| class Response:
def __init__(self, type, response_method, result, request_id, chain_name, gas_price, gas_limit, tora_addr, user_addr, params):
self.type = type
self.response_method = response_method
self.result = result
self.request_id = request_id
self.chain_name = chain_name
self.gas_price = gas_price
self.gas_limit = gas_limit
self.tora_addr = tora_addr
self.user_addr = user_addr
self.params = params |
"""
# SEARCH IN ROTATED ARRAY
You are given an integer array nums sorted in ascending order, and an integer target.
Suppose that nums is rotated at some pivot unknown to you beforehand (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).
If target is found in the array return its index, otherwise, return -1.
Example 1:
Input: nums = [4,5,6,7,0,1,2], target = 0
Output: 4
Example 2:
Input: nums = [4,5,6,7,0,1,2], target = 3
Output: -1
Example 3:
Input: nums = [1], target = 0
Output: -1
Constraints:
1 <= nums.length <= 5000
-10^4 <= nums[i] <= 10^4
All values of nums are unique.
nums is guranteed to be rotated at some pivot.
-10^4 <= target <= 10^4
"""
def search(nums, target):
l = 0
r = len(nums) - 1
while l <= r:
mid = (l + r) // 2
if nums[mid] == target:
return mid
else:
if nums[l] <= nums[mid]:
if nums[l] <= target < nums[mid]:
r = mid - 1
else:
l = mid + 1
else:
if nums[mid] < target <= nums[r]:
l = mid + 1
else:
r = mid - 1
return -1 | """
# SEARCH IN ROTATED ARRAY
You are given an integer array nums sorted in ascending order, and an integer target.
Suppose that nums is rotated at some pivot unknown to you beforehand (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).
If target is found in the array return its index, otherwise, return -1.
Example 1:
Input: nums = [4,5,6,7,0,1,2], target = 0
Output: 4
Example 2:
Input: nums = [4,5,6,7,0,1,2], target = 3
Output: -1
Example 3:
Input: nums = [1], target = 0
Output: -1
Constraints:
1 <= nums.length <= 5000
-10^4 <= nums[i] <= 10^4
All values of nums are unique.
nums is guranteed to be rotated at some pivot.
-10^4 <= target <= 10^4
"""
def search(nums, target):
l = 0
r = len(nums) - 1
while l <= r:
mid = (l + r) // 2
if nums[mid] == target:
return mid
elif nums[l] <= nums[mid]:
if nums[l] <= target < nums[mid]:
r = mid - 1
else:
l = mid + 1
elif nums[mid] < target <= nums[r]:
l = mid + 1
else:
r = mid - 1
return -1 |
class Solution:
def lengthOfLastWord(self, s: str) -> int:
length = 0
for s_i in reversed(s):
if(s_i != ' '):
length += 1
elif (length != 0):
break
return length
# input = "Hello World"
input = "a "
output = Solution().lengthOfLastWord(input)
print(output)
| class Solution:
def length_of_last_word(self, s: str) -> int:
length = 0
for s_i in reversed(s):
if s_i != ' ':
length += 1
elif length != 0:
break
return length
input = 'a '
output = solution().lengthOfLastWord(input)
print(output) |
# -*- coding: utf-8 -*-
moves = {
0x01: "POUND",
0x02: "KARATE_CHOP",
0x03: "DOUBLESLAP",
0x04: "COMET_PUNCH",
0x05: "MEGA_PUNCH",
0x06: "PAY_DAY",
0x07: "FIRE_PUNCH",
0x08: "ICE_PUNCH",
0x09: "THUNDERPUNCH",
0x0A: "SCRATCH",
0x0B: "VICEGRIP",
0x0C: "GUILLOTINE",
0x0D: "RAZOR_WIND",
0x0E: "SWORDS_DANCE",
0x0F: "CUT",
0x10: "GUST",
0x11: "WING_ATTACK",
0x12: "WHIRLWIND",
0x13: "FLY",
0x14: "BIND",
0x15: "SLAM",
0x16: "VINE_WHIP",
0x17: "STOMP",
0x18: "DOUBLE_KICK",
0x19: "MEGA_KICK",
0x1A: "JUMP_KICK",
0x1B: "ROLLING_KICK",
0x1C: "SAND_ATTACK",
0x1D: "HEADBUTT",
0x1E: "HORN_ATTACK",
0x1F: "FURY_ATTACK",
0x20: "HORN_DRILL",
0x21: "TACKLE",
0x22: "BODY_SLAM",
0x23: "WRAP",
0x24: "TAKE_DOWN",
0x25: "THRASH",
0x26: "DOUBLE_EDGE",
0x27: "TAIL_WHIP",
0x28: "POISON_STING",
0x29: "TWINEEDLE",
0x2A: "PIN_MISSILE",
0x2B: "LEER",
0x2C: "BITE",
0x2D: "GROWL",
0x2E: "ROAR",
0x2F: "SING",
0x30: "SUPERSONIC",
0x31: "SONICBOOM",
0x32: "DISABLE",
0x33: "ACID",
0x34: "EMBER",
0x35: "FLAMETHROWER",
0x36: "MIST",
0x37: "WATER_GUN",
0x38: "HYDRO_PUMP",
0x39: "SURF",
0x3A: "ICE_BEAM",
0x3B: "BLIZZARD",
0x3C: "PSYBEAM",
0x3D: "BUBBLEBEAM",
0x3E: "AURORA_BEAM",
0x3F: "HYPER_BEAM",
0x40: "PECK",
0x41: "DRILL_PECK",
0x42: "SUBMISSION",
0x43: "LOW_KICK",
0x44: "COUNTER",
0x45: "SEISMIC_TOSS",
0x46: "STRENGTH",
0x47: "ABSORB",
0x48: "MEGA_DRAIN",
0x49: "LEECH_SEED",
0x4A: "GROWTH",
0x4B: "RAZOR_LEAF",
0x4C: "SOLARBEAM",
0x4D: "POISONPOWDER",
0x4E: "STUN_SPORE",
0x4F: "SLEEP_POWDER",
0x50: "PETAL_DANCE",
0x51: "STRING_SHOT",
0x52: "DRAGON_RAGE",
0x53: "FIRE_SPIN",
0x54: "THUNDERSHOCK",
0x55: "THUNDERBOLT",
0x56: "THUNDER_WAVE",
0x57: "THUNDER",
0x58: "ROCK_THROW",
0x59: "EARTHQUAKE",
0x5A: "FISSURE",
0x5B: "DIG",
0x5C: "TOXIC",
0x5D: "CONFUSION",
0x5E: "PSYCHIC_M",
0x5F: "HYPNOSIS",
0x60: "MEDITATE",
0x61: "AGILITY",
0x62: "QUICK_ATTACK",
0x63: "RAGE",
0x64: "TELEPORT",
0x65: "NIGHT_SHADE",
0x66: "MIMIC",
0x67: "SCREECH",
0x68: "DOUBLE_TEAM",
0x69: "RECOVER",
0x6A: "HARDEN",
0x6B: "MINIMIZE",
0x6C: "SMOKESCREEN",
0x6D: "CONFUSE_RAY",
0x6E: "WITHDRAW",
0x6F: "DEFENSE_CURL",
0x70: "BARRIER",
0x71: "LIGHT_SCREEN",
0x72: "HAZE",
0x73: "REFLECT",
0x74: "FOCUS_ENERGY",
0x75: "BIDE",
0x76: "METRONOME",
0x77: "MIRROR_MOVE",
0x78: "SELFDESTRUCT",
0x79: "EGG_BOMB",
0x7A: "LICK",
0x7B: "SMOG",
0x7C: "SLUDGE",
0x7D: "BONE_CLUB",
0x7E: "FIRE_BLAST",
0x7F: "WATERFALL",
0x80: "CLAMP",
0x81: "SWIFT",
0x82: "SKULL_BASH",
0x83: "SPIKE_CANNON",
0x84: "CONSTRICT",
0x85: "AMNESIA",
0x86: "KINESIS",
0x87: "SOFTBOILED",
0x88: "HI_JUMP_KICK",
0x89: "GLARE",
0x8A: "DREAM_EATER",
0x8B: "POISON_GAS",
0x8C: "BARRAGE",
0x8D: "LEECH_LIFE",
0x8E: "LOVELY_KISS",
0x8F: "SKY_ATTACK",
0x90: "TRANSFORM",
0x91: "BUBBLE",
0x92: "DIZZY_PUNCH",
0x93: "SPORE",
0x94: "FLASH",
0x95: "PSYWAVE",
0x96: "SPLASH",
0x97: "ACID_ARMOR",
0x98: "CRABHAMMER",
0x99: "EXPLOSION",
0x9A: "FURY_SWIPES",
0x9B: "BONEMERANG",
0x9C: "REST",
0x9D: "ROCK_SLIDE",
0x9E: "HYPER_FANG",
0x9F: "SHARPEN",
0xA0: "CONVERSION",
0xA1: "TRI_ATTACK",
0xA2: "SUPER_FANG",
0xA3: "SLASH",
0xA4: "SUBSTITUTE",
0xA5: "STRUGGLE",
0xA6: "SKETCH",
0xA7: "TRIPLE_KICK",
0xA8: "THIEF",
0xA9: "SPIDER_WEB",
0xAA: "MIND_READER",
0xAB: "NIGHTMARE",
0xAC: "FLAME_WHEEL",
0xAD: "SNORE",
0xAE: "CURSE",
0xAF: "FLAIL",
0xB0: "CONVERSION2",
0xB1: "AEROBLAST",
0xB2: "COTTON_SPORE",
0xB3: "REVERSAL",
0xB4: "SPITE",
0xB5: "POWDER_SNOW",
0xB6: "PROTECT",
0xB7: "MACH_PUNCH",
0xB8: "SCARY_FACE",
0xB9: "FAINT_ATTACK",
0xBA: "SWEET_KISS",
0xBB: "BELLY_DRUM",
0xBC: "SLUDGE_BOMB",
0xBD: "MUD_SLAP",
0xBE: "OCTAZOOKA",
0xBF: "SPIKES",
0xC0: "ZAP_CANNON",
0xC1: "FORESIGHT",
0xC2: "DESTINY_BOND",
0xC3: "PERISH_SONG",
0xC4: "ICY_WIND",
0xC5: "DETECT",
0xC6: "BONE_RUSH",
0xC7: "LOCK_ON",
0xC8: "OUTRAGE",
0xC9: "SANDSTORM",
0xCA: "GIGA_DRAIN",
0xCB: "ENDURE",
0xCC: "CHARM",
0xCD: "ROLLOUT",
0xCE: "FALSE_SWIPE",
0xCF: "SWAGGER",
0xD0: "MILK_DRINK",
0xD1: "SPARK",
0xD2: "FURY_CUTTER",
0xD3: "STEEL_WING",
0xD4: "MEAN_LOOK",
0xD5: "ATTRACT",
0xD6: "SLEEP_TALK",
0xD7: "HEAL_BELL",
0xD8: "RETURN",
0xD9: "PRESENT",
0xDA: "FRUSTRATION",
0xDB: "SAFEGUARD",
0xDC: "PAIN_SPLIT",
0xDD: "SACRED_FIRE",
0xDE: "MAGNITUDE",
0xDF: "DYNAMICPUNCH",
0xE0: "MEGAHORN",
0xE1: "DRAGONBREATH",
0xE2: "BATON_PASS",
0xE3: "ENCORE",
0xE4: "PURSUIT",
0xE5: "RAPID_SPIN",
0xE6: "SWEET_SCENT",
0xE7: "IRON_TAIL",
0xE8: "METAL_CLAW",
0xE9: "VITAL_THROW",
0xEA: "MORNING_SUN",
0xEB: "SYNTHESIS",
0xEC: "MOONLIGHT",
0xED: "HIDDEN_POWER",
0xEE: "CROSS_CHOP",
0xEF: "TWISTER",
0xF0: "RAIN_DANCE",
0xF1: "SUNNY_DAY",
0xF2: "CRUNCH",
0xF3: "MIRROR_COAT",
0xF4: "PSYCH_UP",
0xF5: "EXTREMESPEED",
0xF6: "ANCIENTPOWER",
0xF7: "SHADOW_BALL",
0xF8: "FUTURE_SIGHT",
0xF9: "ROCK_SMASH",
0xFA: "WHIRLPOOL",
0xFB: "BEAT_UP",
}
| moves = {1: 'POUND', 2: 'KARATE_CHOP', 3: 'DOUBLESLAP', 4: 'COMET_PUNCH', 5: 'MEGA_PUNCH', 6: 'PAY_DAY', 7: 'FIRE_PUNCH', 8: 'ICE_PUNCH', 9: 'THUNDERPUNCH', 10: 'SCRATCH', 11: 'VICEGRIP', 12: 'GUILLOTINE', 13: 'RAZOR_WIND', 14: 'SWORDS_DANCE', 15: 'CUT', 16: 'GUST', 17: 'WING_ATTACK', 18: 'WHIRLWIND', 19: 'FLY', 20: 'BIND', 21: 'SLAM', 22: 'VINE_WHIP', 23: 'STOMP', 24: 'DOUBLE_KICK', 25: 'MEGA_KICK', 26: 'JUMP_KICK', 27: 'ROLLING_KICK', 28: 'SAND_ATTACK', 29: 'HEADBUTT', 30: 'HORN_ATTACK', 31: 'FURY_ATTACK', 32: 'HORN_DRILL', 33: 'TACKLE', 34: 'BODY_SLAM', 35: 'WRAP', 36: 'TAKE_DOWN', 37: 'THRASH', 38: 'DOUBLE_EDGE', 39: 'TAIL_WHIP', 40: 'POISON_STING', 41: 'TWINEEDLE', 42: 'PIN_MISSILE', 43: 'LEER', 44: 'BITE', 45: 'GROWL', 46: 'ROAR', 47: 'SING', 48: 'SUPERSONIC', 49: 'SONICBOOM', 50: 'DISABLE', 51: 'ACID', 52: 'EMBER', 53: 'FLAMETHROWER', 54: 'MIST', 55: 'WATER_GUN', 56: 'HYDRO_PUMP', 57: 'SURF', 58: 'ICE_BEAM', 59: 'BLIZZARD', 60: 'PSYBEAM', 61: 'BUBBLEBEAM', 62: 'AURORA_BEAM', 63: 'HYPER_BEAM', 64: 'PECK', 65: 'DRILL_PECK', 66: 'SUBMISSION', 67: 'LOW_KICK', 68: 'COUNTER', 69: 'SEISMIC_TOSS', 70: 'STRENGTH', 71: 'ABSORB', 72: 'MEGA_DRAIN', 73: 'LEECH_SEED', 74: 'GROWTH', 75: 'RAZOR_LEAF', 76: 'SOLARBEAM', 77: 'POISONPOWDER', 78: 'STUN_SPORE', 79: 'SLEEP_POWDER', 80: 'PETAL_DANCE', 81: 'STRING_SHOT', 82: 'DRAGON_RAGE', 83: 'FIRE_SPIN', 84: 'THUNDERSHOCK', 85: 'THUNDERBOLT', 86: 'THUNDER_WAVE', 87: 'THUNDER', 88: 'ROCK_THROW', 89: 'EARTHQUAKE', 90: 'FISSURE', 91: 'DIG', 92: 'TOXIC', 93: 'CONFUSION', 94: 'PSYCHIC_M', 95: 'HYPNOSIS', 96: 'MEDITATE', 97: 'AGILITY', 98: 'QUICK_ATTACK', 99: 'RAGE', 100: 'TELEPORT', 101: 'NIGHT_SHADE', 102: 'MIMIC', 103: 'SCREECH', 104: 'DOUBLE_TEAM', 105: 'RECOVER', 106: 'HARDEN', 107: 'MINIMIZE', 108: 'SMOKESCREEN', 109: 'CONFUSE_RAY', 110: 'WITHDRAW', 111: 'DEFENSE_CURL', 112: 'BARRIER', 113: 'LIGHT_SCREEN', 114: 'HAZE', 115: 'REFLECT', 116: 'FOCUS_ENERGY', 117: 'BIDE', 118: 'METRONOME', 119: 'MIRROR_MOVE', 120: 'SELFDESTRUCT', 121: 'EGG_BOMB', 122: 'LICK', 123: 'SMOG', 124: 'SLUDGE', 125: 'BONE_CLUB', 126: 'FIRE_BLAST', 127: 'WATERFALL', 128: 'CLAMP', 129: 'SWIFT', 130: 'SKULL_BASH', 131: 'SPIKE_CANNON', 132: 'CONSTRICT', 133: 'AMNESIA', 134: 'KINESIS', 135: 'SOFTBOILED', 136: 'HI_JUMP_KICK', 137: 'GLARE', 138: 'DREAM_EATER', 139: 'POISON_GAS', 140: 'BARRAGE', 141: 'LEECH_LIFE', 142: 'LOVELY_KISS', 143: 'SKY_ATTACK', 144: 'TRANSFORM', 145: 'BUBBLE', 146: 'DIZZY_PUNCH', 147: 'SPORE', 148: 'FLASH', 149: 'PSYWAVE', 150: 'SPLASH', 151: 'ACID_ARMOR', 152: 'CRABHAMMER', 153: 'EXPLOSION', 154: 'FURY_SWIPES', 155: 'BONEMERANG', 156: 'REST', 157: 'ROCK_SLIDE', 158: 'HYPER_FANG', 159: 'SHARPEN', 160: 'CONVERSION', 161: 'TRI_ATTACK', 162: 'SUPER_FANG', 163: 'SLASH', 164: 'SUBSTITUTE', 165: 'STRUGGLE', 166: 'SKETCH', 167: 'TRIPLE_KICK', 168: 'THIEF', 169: 'SPIDER_WEB', 170: 'MIND_READER', 171: 'NIGHTMARE', 172: 'FLAME_WHEEL', 173: 'SNORE', 174: 'CURSE', 175: 'FLAIL', 176: 'CONVERSION2', 177: 'AEROBLAST', 178: 'COTTON_SPORE', 179: 'REVERSAL', 180: 'SPITE', 181: 'POWDER_SNOW', 182: 'PROTECT', 183: 'MACH_PUNCH', 184: 'SCARY_FACE', 185: 'FAINT_ATTACK', 186: 'SWEET_KISS', 187: 'BELLY_DRUM', 188: 'SLUDGE_BOMB', 189: 'MUD_SLAP', 190: 'OCTAZOOKA', 191: 'SPIKES', 192: 'ZAP_CANNON', 193: 'FORESIGHT', 194: 'DESTINY_BOND', 195: 'PERISH_SONG', 196: 'ICY_WIND', 197: 'DETECT', 198: 'BONE_RUSH', 199: 'LOCK_ON', 200: 'OUTRAGE', 201: 'SANDSTORM', 202: 'GIGA_DRAIN', 203: 'ENDURE', 204: 'CHARM', 205: 'ROLLOUT', 206: 'FALSE_SWIPE', 207: 'SWAGGER', 208: 'MILK_DRINK', 209: 'SPARK', 210: 'FURY_CUTTER', 211: 'STEEL_WING', 212: 'MEAN_LOOK', 213: 'ATTRACT', 214: 'SLEEP_TALK', 215: 'HEAL_BELL', 216: 'RETURN', 217: 'PRESENT', 218: 'FRUSTRATION', 219: 'SAFEGUARD', 220: 'PAIN_SPLIT', 221: 'SACRED_FIRE', 222: 'MAGNITUDE', 223: 'DYNAMICPUNCH', 224: 'MEGAHORN', 225: 'DRAGONBREATH', 226: 'BATON_PASS', 227: 'ENCORE', 228: 'PURSUIT', 229: 'RAPID_SPIN', 230: 'SWEET_SCENT', 231: 'IRON_TAIL', 232: 'METAL_CLAW', 233: 'VITAL_THROW', 234: 'MORNING_SUN', 235: 'SYNTHESIS', 236: 'MOONLIGHT', 237: 'HIDDEN_POWER', 238: 'CROSS_CHOP', 239: 'TWISTER', 240: 'RAIN_DANCE', 241: 'SUNNY_DAY', 242: 'CRUNCH', 243: 'MIRROR_COAT', 244: 'PSYCH_UP', 245: 'EXTREMESPEED', 246: 'ANCIENTPOWER', 247: 'SHADOW_BALL', 248: 'FUTURE_SIGHT', 249: 'ROCK_SMASH', 250: 'WHIRLPOOL', 251: 'BEAT_UP'} |
x,y,z = 32,31,23;
list = ['Apple','Benana','Mango'];
a,b,c = list;
print(">>> x y z <<<");
print("> x : " + str(x));
print("> y : " + str(y));
print("> z : " + str(z));
print("\n>>> a b c <<<");
print("> a : " + a);
print("> b : " + b);
print("> c : " + c);
| (x, y, z) = (32, 31, 23)
list = ['Apple', 'Benana', 'Mango']
(a, b, c) = list
print('>>> x y z <<<')
print('> x : ' + str(x))
print('> y : ' + str(y))
print('> z : ' + str(z))
print('\n>>> a b c <<<')
print('> a : ' + a)
print('> b : ' + b)
print('> c : ' + c) |
def addr(regs, a, b, c):
result = regs[:]
result[c] = regs[a] + regs[b]
return result
def addi(regs, a, b, c):
result = regs[:]
result[c] = regs[a] + b
return result
def mulr(regs, a, b, c):
result = regs[:]
result[c] = regs[a] * regs[b]
return result
def muli(regs, a, b, c):
result = regs[:]
result[c] = regs[a] * b
return result
def banr(regs, a, b, c):
result = regs[:]
result[c] = regs[a] & regs[b]
return result
def bani(regs, a, b, c):
result = regs[:]
result[c] = regs[a] & b
return result
def borr(regs, a, b, c):
result = regs[:]
result[c] = regs[a] | regs[b]
return result
def bori(regs, a, b, c):
result = regs[:]
result[c] = regs[a] | b
return result
def setr(regs, a, b, c):
result = regs[:]
result[c] = regs[a]
return result
def seti(regs, a, b, c):
result = regs[:]
result[c] = a
return result
def gtir(regs, a, b, c):
result = regs[:]
if a > regs[b]:
result[c] = 1
else:
result[c] = 0
return result
def gtri(regs, a, b, c):
result = regs[:]
if regs[a] > b:
result[c] = 1
else:
result[c] = 0
return result
def gtrr(regs, a, b, c):
result = regs[:]
if regs[a] > regs[b]:
result[c] = 1
else:
result[c] = 0
return result
def eqir(regs, a, b, c):
result = regs[:]
if a == regs[b]:
result[c] = 1
else:
result[c] = 0
return result
def eqri(regs, a, b, c):
result = regs[:]
if regs[a] == b:
result[c] = 1
else:
result[c] = 0
return result
def eqrr(regs, a, b, c):
result = regs[:]
if regs[a] == regs[b]:
result[c] = 1
else:
result[c] = 0
return result
ops = [
addr,
addi,
mulr,
muli,
banr,
bani,
borr,
bori,
setr,
seti,
gtir,
gtri,
gtrr,
eqir,
eqri,
eqrr,
]
def registers(line):
return list(map(int,line[9:-1].split(', ')))
def solve(input):
i = 0
total = 0
while i <= len(input):
before = registers(input[i])
after = registers(input[i+2])
op = list(map(int, input[i+1].split()))
count = 0
for o in ops:
# print( o(before, *op[1:]), after)
if o(before, *op[1:]) == after:
count += 1
if count >= 3:
total +=1
i += 4
print(total)
# with open('test.txt', 'r') as f:
# input = f.read().splitlines()
# solve(input)
with open('input.txt', 'r') as f:
input = f.read().splitlines()
solve(input)
| def addr(regs, a, b, c):
result = regs[:]
result[c] = regs[a] + regs[b]
return result
def addi(regs, a, b, c):
result = regs[:]
result[c] = regs[a] + b
return result
def mulr(regs, a, b, c):
result = regs[:]
result[c] = regs[a] * regs[b]
return result
def muli(regs, a, b, c):
result = regs[:]
result[c] = regs[a] * b
return result
def banr(regs, a, b, c):
result = regs[:]
result[c] = regs[a] & regs[b]
return result
def bani(regs, a, b, c):
result = regs[:]
result[c] = regs[a] & b
return result
def borr(regs, a, b, c):
result = regs[:]
result[c] = regs[a] | regs[b]
return result
def bori(regs, a, b, c):
result = regs[:]
result[c] = regs[a] | b
return result
def setr(regs, a, b, c):
result = regs[:]
result[c] = regs[a]
return result
def seti(regs, a, b, c):
result = regs[:]
result[c] = a
return result
def gtir(regs, a, b, c):
result = regs[:]
if a > regs[b]:
result[c] = 1
else:
result[c] = 0
return result
def gtri(regs, a, b, c):
result = regs[:]
if regs[a] > b:
result[c] = 1
else:
result[c] = 0
return result
def gtrr(regs, a, b, c):
result = regs[:]
if regs[a] > regs[b]:
result[c] = 1
else:
result[c] = 0
return result
def eqir(regs, a, b, c):
result = regs[:]
if a == regs[b]:
result[c] = 1
else:
result[c] = 0
return result
def eqri(regs, a, b, c):
result = regs[:]
if regs[a] == b:
result[c] = 1
else:
result[c] = 0
return result
def eqrr(regs, a, b, c):
result = regs[:]
if regs[a] == regs[b]:
result[c] = 1
else:
result[c] = 0
return result
ops = [addr, addi, mulr, muli, banr, bani, borr, bori, setr, seti, gtir, gtri, gtrr, eqir, eqri, eqrr]
def registers(line):
return list(map(int, line[9:-1].split(', ')))
def solve(input):
i = 0
total = 0
while i <= len(input):
before = registers(input[i])
after = registers(input[i + 2])
op = list(map(int, input[i + 1].split()))
count = 0
for o in ops:
if o(before, *op[1:]) == after:
count += 1
if count >= 3:
total += 1
i += 4
print(total)
with open('input.txt', 'r') as f:
input = f.read().splitlines()
solve(input) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.