content stringlengths 7 1.05M |
|---|
# User input
percentage = float(input("Enter your marks: "))
# Program operation & Computer output
if (percentage >= 90):
print("Your grade is A1 !")
elif (percentage >= 80):
print("Your grade is A !")
elif (percentage >= 70):
print("Your grade is B1 !")
elif (percentage >= 60):
print("Your grade is B !")
elif (percentage >= 50):
print("Your grade is C, try better next time!")
elif (percentage >= 33):
print("Your grade is D, try better next time!")
else:
print("Your grade is E, try better next time!")
|
#!/usr/bin/env python
# -*- coding:utf-8 -*-
def q_s(v):
if len(v) <=1:
return v
left, right = 0, len(v) - 1
item = v[int((left+right))/2]
left_value = [i for i in v if i < item]
right_value = [i for i in v if i > item]
return q_s(left_value) + [item] + q_s(right_value)
if __name__ == "__main__":
v = [1, 2, 4, 3, 6, 7, 8, 5, 9]
q_v = q_s(v)
print(q_v)
|
#
# PySNMP MIB module WWP-LEOS-OAM-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/WWP-LEOS-OAM-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:31:22 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)
#
ObjectIdentifier, Integer, OctetString = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "Integer", "OctetString")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint")
NotificationGroup, ModuleCompliance, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup")
iso, Counter64, MibIdentifier, TimeTicks, Gauge32, Integer32, ObjectIdentity, ModuleIdentity, Unsigned32, Counter32, NotificationType, IpAddress, Bits, MibScalar, MibTable, MibTableRow, MibTableColumn = mibBuilder.importSymbols("SNMPv2-SMI", "iso", "Counter64", "MibIdentifier", "TimeTicks", "Gauge32", "Integer32", "ObjectIdentity", "ModuleIdentity", "Unsigned32", "Counter32", "NotificationType", "IpAddress", "Bits", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn")
DisplayString, TimeStamp, TextualConvention, TruthValue = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TimeStamp", "TextualConvention", "TruthValue")
wwpLeosEtherPortOperStatus, wwpLeosEtherPortDesc = mibBuilder.importSymbols("WWP-LEOS-PORT-MIB", "wwpLeosEtherPortOperStatus", "wwpLeosEtherPortDesc")
wwpModulesLeos, = mibBuilder.importSymbols("WWP-SMI", "wwpModulesLeos")
wwpLeosOamMibModule = ModuleIdentity((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400))
wwpLeosOamMibModule.setRevisions(('2008-01-03 00:00',))
if mibBuilder.loadTexts: wwpLeosOamMibModule.setLastUpdated('200801030000Z')
if mibBuilder.loadTexts: wwpLeosOamMibModule.setOrganization('Ciena, Inc')
wwpLeosOamMIB = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1))
wwpLeosOamConf = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 1))
wwpLeosOamGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 1, 1))
wwpLeosOamCompls = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 1, 2))
wwpLeosOamObjs = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2))
wwpLeosOamTable = MibTable((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1), )
if mibBuilder.loadTexts: wwpLeosOamTable.setStatus('current')
wwpLeosOamEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1), ).setIndexNames((0, "WWP-LEOS-OAM-MIB", "wwpLeosOamPort"))
if mibBuilder.loadTexts: wwpLeosOamEntry.setStatus('current')
wwpLeosOamAdminState = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("disabled", 1), ("enabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamAdminState.setStatus('current')
wwpLeosOamOperStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9))).clone(namedValues=NamedValues(("disabled", 1), ("linkfault", 2), ("passiveWait", 3), ("activeSendLocal", 4), ("sendLocalAndRemote", 5), ("sendLocalAndRemoteOk", 6), ("oamPeeringLocallyRejected", 7), ("oamPeeringRemotelyRejected", 8), ("operational", 9)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamOperStatus.setStatus('current')
wwpLeosOamMode = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("active", 1), ("passive", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamMode.setStatus('current')
wwpLeosMaxOamPduSize = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 4), Integer32()).setUnits('bytes').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosMaxOamPduSize.setStatus('current')
wwpLeosOamConfigRevision = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 5), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamConfigRevision.setStatus('current')
wwpLeosOamFunctionsSupported = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 6), Bits().clone(namedValues=NamedValues(("unidirectionalSupport", 0), ("loopbackSupport", 1), ("eventSupport", 2), ("variableSupport", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamFunctionsSupported.setStatus('current')
wwpLeosOamPort = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 7), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamPort.setStatus('current')
wwpLeosOamPduTimer = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(100, 1000))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamPduTimer.setStatus('current')
wwpLeosOamLinkLostTimer = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(500, 5000))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamLinkLostTimer.setStatus('current')
wwpLeosOamPeerStatusNotifyState = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("on", 1), ("off", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamPeerStatusNotifyState.setStatus('current')
wwpLeosOamPeerTable = MibTable((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2), )
if mibBuilder.loadTexts: wwpLeosOamPeerTable.setStatus('current')
wwpLeosOamPeerEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1), ).setIndexNames((0, "WWP-LEOS-OAM-MIB", "wwpLeosOamLocalPort"))
if mibBuilder.loadTexts: wwpLeosOamPeerEntry.setStatus('current')
wwpLeosOamPeerStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("active", 1), ("inactive", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamPeerStatus.setStatus('current')
wwpLeosOamPeerMacAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 2), OctetString().subtype(subtypeSpec=ValueSizeConstraint(6, 6)).setFixedLength(6)).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamPeerMacAddress.setStatus('current')
wwpLeosOamPeerVendorOui = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 3), OctetString().subtype(subtypeSpec=ValueSizeConstraint(3, 3)).setFixedLength(3)).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamPeerVendorOui.setStatus('current')
wwpLeosOamPeerVendorInfo = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 4), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamPeerVendorInfo.setStatus('current')
wwpLeosOamPeerMode = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("active", 1), ("passive", 2), ("unknown", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamPeerMode.setStatus('current')
wwpLeosOamPeerMaxOamPduSize = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 6), Integer32()).setUnits('bytes').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamPeerMaxOamPduSize.setStatus('current')
wwpLeosOamPeerConfigRevision = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 7), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamPeerConfigRevision.setStatus('current')
wwpLeosOamPeerFunctionsSupported = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 8), Bits().clone(namedValues=NamedValues(("unidirectionalSupport", 0), ("loopbackSupport", 1), ("eventSupport", 2), ("variableSupport", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamPeerFunctionsSupported.setStatus('current')
wwpLeosOamLocalPort = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamLocalPort.setStatus('current')
wwpLeosOamLoopbackTable = MibTable((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3), )
if mibBuilder.loadTexts: wwpLeosOamLoopbackTable.setStatus('current')
wwpLeosOamLoopbackEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1), ).setIndexNames((0, "WWP-LEOS-OAM-MIB", "wwpLeosOamLoopbackPort"))
if mibBuilder.loadTexts: wwpLeosOamLoopbackEntry.setStatus('current')
wwpLeosOamLoopbackCommand = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("noLoopback", 1), ("startRemoteLoopback", 2), ("stopRemoteLoopback", 3)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamLoopbackCommand.setStatus('current')
wwpLeosOamLoopbackStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6))).clone(namedValues=NamedValues(("noLoopback", 1), ("initiatingLoopback", 2), ("remoteLoopback", 3), ("terminatingLoopback", 4), ("localLoopback", 5), ("unknown", 6)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamLoopbackStatus.setStatus('current')
wwpLeosOamLoopbackIgnoreRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("ignore", 1), ("process", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamLoopbackIgnoreRx.setStatus('current')
wwpLeosOamLoopbackPort = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamLoopbackPort.setStatus('current')
wwpLeosOamStatsTable = MibTable((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4), )
if mibBuilder.loadTexts: wwpLeosOamStatsTable.setStatus('current')
wwpLeosOamStatsEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1), ).setIndexNames((0, "WWP-LEOS-OAM-MIB", "wwpLeosOamStatsPort"))
if mibBuilder.loadTexts: wwpLeosOamStatsEntry.setStatus('current')
wwpLeosOamInformationTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 1), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamInformationTx.setStatus('current')
wwpLeosOamInformationRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 2), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamInformationRx.setStatus('current')
wwpLeosOamUniqueEventNotificationTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 3), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamUniqueEventNotificationTx.setStatus('current')
wwpLeosOamUniqueEventNotificationRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 4), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamUniqueEventNotificationRx.setStatus('current')
wwpLeosOamLoopbackControlTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 5), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamLoopbackControlTx.setStatus('current')
wwpLeosOamLoopbackControlRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 6), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamLoopbackControlRx.setStatus('current')
wwpLeosOamVariableRequestTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 7), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamVariableRequestTx.setStatus('current')
wwpLeosOamVariableRequestRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 8), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamVariableRequestRx.setStatus('current')
wwpLeosOamVariableResponseTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 9), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamVariableResponseTx.setStatus('current')
wwpLeosOamVariableResponseRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 10), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamVariableResponseRx.setStatus('current')
wwpLeosOamOrgSpecificTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 11), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamOrgSpecificTx.setStatus('current')
wwpLeosOamOrgSpecificRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 12), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamOrgSpecificRx.setStatus('current')
wwpLeosOamUnsupportedCodesTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 13), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamUnsupportedCodesTx.setStatus('current')
wwpLeosOamUnsupportedCodesRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 14), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamUnsupportedCodesRx.setStatus('current')
wwpLeosOamframesLostDueToOam = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 15), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamframesLostDueToOam.setStatus('current')
wwpLeosOamStatsPort = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 16), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamStatsPort.setStatus('current')
wwpLeosOamDuplicateEventNotificationTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 17), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamDuplicateEventNotificationTx.setStatus('current')
wwpLeosOamDuplicateEventNotificationRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 18), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamDuplicateEventNotificationRx.setStatus('current')
wwpLeosOamSystemEnableDisable = MibScalar((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamSystemEnableDisable.setStatus('current')
wwpLeosOamEventConfigTable = MibTable((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6), )
if mibBuilder.loadTexts: wwpLeosOamEventConfigTable.setStatus('current')
wwpLeosOamEventConfigEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1), ).setIndexNames((0, "WWP-LEOS-OAM-MIB", "wwpLeosOamEventPort"))
if mibBuilder.loadTexts: wwpLeosOamEventConfigEntry.setStatus('current')
wwpLeosOamEventPort = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventPort.setStatus('current')
wwpLeosOamErrFramePeriodWindow = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 2), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(14880, 8928000))).setUnits('frames').setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamErrFramePeriodWindow.setStatus('current')
wwpLeosOamErrFramePeriodThreshold = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 3), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967293))).setUnits('frames').setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamErrFramePeriodThreshold.setStatus('current')
wwpLeosOamErrFramePeriodEvNotifEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamErrFramePeriodEvNotifEnable.setStatus('current')
wwpLeosOamErrFrameWindow = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 5), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(10, 600))).setUnits('tenths of a second').setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamErrFrameWindow.setStatus('current')
wwpLeosOamErrFrameThreshold = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 6), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967293))).setUnits('frames').setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamErrFrameThreshold.setStatus('current')
wwpLeosOamErrFrameEvNotifEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamErrFrameEvNotifEnable.setStatus('current')
wwpLeosOamErrFrameSecsSummaryWindow = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(100, 9000))).setUnits('tenths of a second').setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamErrFrameSecsSummaryWindow.setStatus('current')
wwpLeosOamErrFrameSecsSummaryThreshold = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setUnits('errored frame seconds').setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamErrFrameSecsSummaryThreshold.setStatus('current')
wwpLeosOamErrFrameSecsEvNotifEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamErrFrameSecsEvNotifEnable.setStatus('current')
wwpLeosOamDyingGaspEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 11), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamDyingGaspEnable.setStatus('current')
wwpLeosOamCriticalEventEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 12), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamCriticalEventEnable.setStatus('current')
wwpLeosOamEventLogTable = MibTable((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7), )
if mibBuilder.loadTexts: wwpLeosOamEventLogTable.setStatus('current')
wwpLeosOamEventLogEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1), ).setIndexNames((0, "WWP-LEOS-OAM-MIB", "wwpLeosOamEventLogPort"), (0, "WWP-LEOS-OAM-MIB", "wwpLeosOamEventLogIndex"))
if mibBuilder.loadTexts: wwpLeosOamEventLogEntry.setStatus('current')
wwpLeosOamEventLogPort = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogPort.setStatus('current')
wwpLeosOamEventLogIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 2), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogIndex.setStatus('current')
wwpLeosOamEventLogTimestamp = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 3), TimeStamp()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogTimestamp.setStatus('current')
wwpLeosOamEventLogOui = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 4), OctetString().subtype(subtypeSpec=ValueSizeConstraint(3, 3)).setFixedLength(3)).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogOui.setStatus('current')
wwpLeosOamEventLogType = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 5), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogType.setStatus('current')
wwpLeosOamEventLogLocation = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("local", 1), ("remote", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogLocation.setStatus('current')
wwpLeosOamEventLogWindowHi = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 7), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogWindowHi.setStatus('current')
wwpLeosOamEventLogWindowLo = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 8), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogWindowLo.setStatus('current')
wwpLeosOamEventLogThresholdHi = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 9), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogThresholdHi.setStatus('current')
wwpLeosOamEventLogThresholdLo = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 10), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogThresholdLo.setStatus('current')
wwpLeosOamEventLogValue = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 11), Counter64()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogValue.setStatus('current')
wwpLeosOamEventLogRunningTotal = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 12), Counter64()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogRunningTotal.setStatus('current')
wwpLeosOamEventLogEventTotal = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 13), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogEventTotal.setStatus('current')
wwpLeosOamGlobal = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 8))
wwpLeosOamStatsClear = MibScalar((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 8, 1), TruthValue()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamStatsClear.setStatus('current')
wwpLeosOamNotifMIBNotificationPrefix = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3))
wwpLeosOamNotifMIBNotification = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3, 0))
wwpLeosOamLinkEventTrap = NotificationType((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3, 0, 1)).setObjects(("WWP-LEOS-OAM-MIB", "wwpLeosOamEventLogPort"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamEventLogType"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamEventLogLocation"))
if mibBuilder.loadTexts: wwpLeosOamLinkEventTrap.setStatus('current')
wwpLeosOamLinkLostTimerActiveTrap = NotificationType((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3, 0, 2)).setObjects(("WWP-LEOS-OAM-MIB", "wwpLeosOamPort"), ("WWP-LEOS-PORT-MIB", "wwpLeosEtherPortDesc"), ("WWP-LEOS-PORT-MIB", "wwpLeosEtherPortOperStatus"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamOperStatus"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamPeerStatus"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamPeerMacAddress"))
if mibBuilder.loadTexts: wwpLeosOamLinkLostTimerActiveTrap.setStatus('current')
wwpLeosOamLinkLostTimerExpiredTrap = NotificationType((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3, 0, 3)).setObjects(("WWP-LEOS-OAM-MIB", "wwpLeosOamPort"), ("WWP-LEOS-PORT-MIB", "wwpLeosEtherPortDesc"), ("WWP-LEOS-PORT-MIB", "wwpLeosEtherPortOperStatus"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamOperStatus"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamPeerStatus"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamPeerMacAddress"))
if mibBuilder.loadTexts: wwpLeosOamLinkLostTimerExpiredTrap.setStatus('current')
mibBuilder.exportSymbols("WWP-LEOS-OAM-MIB", wwpLeosOamErrFrameSecsSummaryWindow=wwpLeosOamErrFrameSecsSummaryWindow, wwpLeosOamLoopbackIgnoreRx=wwpLeosOamLoopbackIgnoreRx, wwpLeosOamEventLogEntry=wwpLeosOamEventLogEntry, wwpLeosOamEventLogWindowHi=wwpLeosOamEventLogWindowHi, wwpLeosOamInformationRx=wwpLeosOamInformationRx, wwpLeosOamMode=wwpLeosOamMode, wwpLeosOamPort=wwpLeosOamPort, wwpLeosOamVariableRequestRx=wwpLeosOamVariableRequestRx, wwpLeosOamSystemEnableDisable=wwpLeosOamSystemEnableDisable, wwpLeosOamErrFramePeriodWindow=wwpLeosOamErrFramePeriodWindow, wwpLeosOamErrFramePeriodEvNotifEnable=wwpLeosOamErrFramePeriodEvNotifEnable, wwpLeosOamEventLogTable=wwpLeosOamEventLogTable, wwpLeosOamLinkLostTimerActiveTrap=wwpLeosOamLinkLostTimerActiveTrap, wwpLeosOamEventPort=wwpLeosOamEventPort, wwpLeosOamEventLogWindowLo=wwpLeosOamEventLogWindowLo, wwpLeosOamLoopbackControlTx=wwpLeosOamLoopbackControlTx, wwpLeosOamStatsClear=wwpLeosOamStatsClear, wwpLeosOamLoopbackCommand=wwpLeosOamLoopbackCommand, wwpLeosOamPeerMode=wwpLeosOamPeerMode, wwpLeosOamEventLogTimestamp=wwpLeosOamEventLogTimestamp, wwpLeosOamEventConfigEntry=wwpLeosOamEventConfigEntry, wwpLeosOamErrFrameThreshold=wwpLeosOamErrFrameThreshold, wwpLeosOamEventLogType=wwpLeosOamEventLogType, wwpLeosOamLoopbackControlRx=wwpLeosOamLoopbackControlRx, wwpLeosOamCriticalEventEnable=wwpLeosOamCriticalEventEnable, wwpLeosOamAdminState=wwpLeosOamAdminState, wwpLeosOamPeerFunctionsSupported=wwpLeosOamPeerFunctionsSupported, wwpLeosOamPeerMacAddress=wwpLeosOamPeerMacAddress, wwpLeosOamNotifMIBNotificationPrefix=wwpLeosOamNotifMIBNotificationPrefix, wwpLeosOamLinkEventTrap=wwpLeosOamLinkEventTrap, wwpLeosOamPeerStatusNotifyState=wwpLeosOamPeerStatusNotifyState, wwpLeosOamEventLogIndex=wwpLeosOamEventLogIndex, wwpLeosOamErrFrameWindow=wwpLeosOamErrFrameWindow, wwpLeosOamLinkLostTimerExpiredTrap=wwpLeosOamLinkLostTimerExpiredTrap, wwpLeosOamUnsupportedCodesTx=wwpLeosOamUnsupportedCodesTx, wwpLeosOamPeerVendorOui=wwpLeosOamPeerVendorOui, wwpLeosOamEventLogEventTotal=wwpLeosOamEventLogEventTotal, wwpLeosOamPeerVendorInfo=wwpLeosOamPeerVendorInfo, wwpLeosOamVariableRequestTx=wwpLeosOamVariableRequestTx, wwpLeosOamframesLostDueToOam=wwpLeosOamframesLostDueToOam, wwpLeosOamLocalPort=wwpLeosOamLocalPort, wwpLeosOamFunctionsSupported=wwpLeosOamFunctionsSupported, wwpLeosOamUniqueEventNotificationTx=wwpLeosOamUniqueEventNotificationTx, wwpLeosOamConf=wwpLeosOamConf, wwpLeosOamGroups=wwpLeosOamGroups, wwpLeosOamPeerEntry=wwpLeosOamPeerEntry, wwpLeosOamErrFrameSecsSummaryThreshold=wwpLeosOamErrFrameSecsSummaryThreshold, wwpLeosOamObjs=wwpLeosOamObjs, wwpLeosOamErrFrameEvNotifEnable=wwpLeosOamErrFrameEvNotifEnable, wwpLeosOamLoopbackTable=wwpLeosOamLoopbackTable, wwpLeosOamErrFrameSecsEvNotifEnable=wwpLeosOamErrFrameSecsEvNotifEnable, wwpLeosOamPeerStatus=wwpLeosOamPeerStatus, wwpLeosOamCompls=wwpLeosOamCompls, wwpLeosOamNotifMIBNotification=wwpLeosOamNotifMIBNotification, wwpLeosOamPeerTable=wwpLeosOamPeerTable, wwpLeosOamEventLogOui=wwpLeosOamEventLogOui, wwpLeosOamPeerConfigRevision=wwpLeosOamPeerConfigRevision, wwpLeosOamLinkLostTimer=wwpLeosOamLinkLostTimer, wwpLeosOamPeerMaxOamPduSize=wwpLeosOamPeerMaxOamPduSize, wwpLeosOamErrFramePeriodThreshold=wwpLeosOamErrFramePeriodThreshold, wwpLeosOamDuplicateEventNotificationRx=wwpLeosOamDuplicateEventNotificationRx, wwpLeosOamGlobal=wwpLeosOamGlobal, wwpLeosOamDyingGaspEnable=wwpLeosOamDyingGaspEnable, wwpLeosOamStatsEntry=wwpLeosOamStatsEntry, wwpLeosOamDuplicateEventNotificationTx=wwpLeosOamDuplicateEventNotificationTx, wwpLeosOamConfigRevision=wwpLeosOamConfigRevision, wwpLeosOamLoopbackStatus=wwpLeosOamLoopbackStatus, wwpLeosOamOrgSpecificRx=wwpLeosOamOrgSpecificRx, wwpLeosOamEventLogRunningTotal=wwpLeosOamEventLogRunningTotal, wwpLeosOamMIB=wwpLeosOamMIB, wwpLeosOamStatsTable=wwpLeosOamStatsTable, wwpLeosOamOperStatus=wwpLeosOamOperStatus, wwpLeosOamInformationTx=wwpLeosOamInformationTx, wwpLeosOamEventLogLocation=wwpLeosOamEventLogLocation, wwpLeosOamVariableResponseTx=wwpLeosOamVariableResponseTx, wwpLeosOamEventConfigTable=wwpLeosOamEventConfigTable, wwpLeosOamLoopbackPort=wwpLeosOamLoopbackPort, wwpLeosOamEventLogThresholdLo=wwpLeosOamEventLogThresholdLo, wwpLeosOamTable=wwpLeosOamTable, wwpLeosOamLoopbackEntry=wwpLeosOamLoopbackEntry, wwpLeosOamMibModule=wwpLeosOamMibModule, wwpLeosOamOrgSpecificTx=wwpLeosOamOrgSpecificTx, wwpLeosOamStatsPort=wwpLeosOamStatsPort, wwpLeosOamVariableResponseRx=wwpLeosOamVariableResponseRx, wwpLeosOamUnsupportedCodesRx=wwpLeosOamUnsupportedCodesRx, wwpLeosMaxOamPduSize=wwpLeosMaxOamPduSize, wwpLeosOamEventLogValue=wwpLeosOamEventLogValue, wwpLeosOamEventLogPort=wwpLeosOamEventLogPort, wwpLeosOamEventLogThresholdHi=wwpLeosOamEventLogThresholdHi, wwpLeosOamPduTimer=wwpLeosOamPduTimer, wwpLeosOamUniqueEventNotificationRx=wwpLeosOamUniqueEventNotificationRx, wwpLeosOamEntry=wwpLeosOamEntry, PYSNMP_MODULE_ID=wwpLeosOamMibModule)
|
# https://leetcode.com/problems/longest-palindromic-subsequence/
class Solution:
def longestPalindromeSubseq(self, s: str) -> int:
dp = [[0 for _ in range(len(s))] for _ in range(len(s))]
for row in range(len(s)):
for col in range(len(s)):
# Find len of longest common subsequence of s and reversed(s).
if s[row] == s[-1 - col]:
diagonal_top_left = (
dp[row - 1][col - 1] if row > 0 and col > 0 else 0)
dp[row][col] = diagonal_top_left + 1
else:
top = dp[row - 1][col] if row > 0 else 0
left = dp[row][col - 1] if col > 0 else 0
dp[row][col] = max(top, left)
return dp[-1][-1]
|
# Time: O(n)
# Space: O(1)
class Solution(object):
def findSubstringInWraproundString(self, p):
"""
:type p: str
:rtype: int
"""
letters = [0] * 26
result, length = 0, 0
for i in xrange(len(p)):
curr = ord(p[i]) - ord('a')
if i > 0 and ord(p[i-1]) != (curr-1)%26 + ord('a'):
length = 0
length += 1
if length > letters[curr]:
result += length - letters[curr]
letters[curr] = length
return result
|
# This file is intended for use by the drake_py_test macro defined in
# //tools/skylark:drake_py.bzl and should NOT be used by anything else.
"""A drake_py_test should not `import unittest`. In most cases, your
BUILD.bazel file should use `drake_py_unittest` to declare such tests, which
provides an appropriate main() routine (and will disable this warning).
In the unlikely event that you actually have a unittest and need to write your
own main, set `allow_import_unittest = True` in the drake_py_test rule.
"""
raise RuntimeError(__doc__)
|
"""
将两个列表,合并为一个字典
姓名列表["张无忌","赵敏","周芷若"]
房间列表[101,102,103]
{101: '张无忌', 102: '赵敏', 103: '周芷若'}
"""
name=["张无忌","赵敏","周芷若"]
room=[101,102,103]
# dict01={}
# for i in range(len(name)):
# key=room[i]
# value=name[i]
# dict01[key]=value
# print(dict01)
dict02={room[i]:name[i] for i in range(len(name))}
print(dict02)
# 颠倒练习1字典键值
dict03={v:k for k,v in dict02.items()}
print(dict03) |
# -- Project information -----------------------------------------------------
project = "PyData Tests"
copyright = "2020, Pydata community"
author = "Pydata community"
master_doc = "index"
# -- General configuration ---------------------------------------------------
html_theme = "pydata_sphinx_theme"
html_copy_source = True
html_sourcelink_suffix = ""
|
test = { 'name': 'q5g',
'points': 1,
'suites': [ { 'cases': [ { 'code': ">>> 'result_q5g' in globals()\n"
'True',
'hidden': False,
'locked': False},
{ 'code': '>>> '
'result_q5g.to_string(index=False) '
'== '
'df_usa.fillna(value=0).head().to_string(index=False)\n'
'True',
'hidden': False,
'locked': False}],
'scored': True,
'setup': '',
'teardown': '',
'type': 'doctest'}]}
|
# ========================
# Information
# ========================
# Direct Link: https://www.hackerrank.com/challenges/s10-poisson-distribution-2/problem
# Difficulty: Easy
# Max Score: 30
# Language: Python
# ========================
# Solution
# ========================
AVERAGE_X, AVERAGE_Y = [float(num) for num in input().split(" ")]
# Cost
COST_X = 160 + 40*(AVERAGE_X + AVERAGE_X**2)
COST_Y = 128 + 40*(AVERAGE_Y + AVERAGE_Y**2)
print(round(COST_X, 3))
print(round(COST_Y, 3))
|
def cap_11(packet):
# your code here
try:
if packet["RTMPT"]["string"] == '_result':
packet["RTMPT"]["string"] = '_123456'
print("cambiado")
return packet
except:
print("fallo")
return None
|
'''
Hardcoded string input
no filtering
sink: check if a file exists
'''
class Class_351:
def __init__(self, param):
self.var_351 = param
def get_var_351(self):
return self.var_351 |
class LiveDataFeed(object):
""" A simple "live data feed" abstraction that allows a reader
to read the most recent data and find out whether it was
updated since the last read.
Interface to data writer:
add_data(data):
Add new data to the feed.
Interface to reader:
read_data():
Returns the most recent data.
has_new_data:
A boolean attribute telling the reader whether the
data was updated since the last read.
"""
def __init__(self):
self.cur_data = None
self.has_new_data = False
def add_data(self, data):
self.cur_data = data
self.has_new_data = True
def read_data(self):
self.has_new_data = False
return self.cur_data
if __name__ == "__main__":
pass
|
inv_count = 0
def sorter(l_res , r_res):
global inv_count
i = 0
r = 0
results = []
while i < len(l_res) and r < len(r_res):
if l_res[i] > r_res[r]:
results.append(r_res[r])
inv_count += len(l_res) - i
r += 1
else:
results.append(l_res[i])
i += 1
while i < len(l_res):
results.append(l_res[i])
i += 1
while r < len(r_res):
results.append(r_res[r])
r += 1
return results
def divider(arr):
if len(arr) == 1:
return arr
mid = len(arr)//2
l_arr = arr[0:mid]
r_arr = arr[mid:]
l_res = divider(l_arr)
r_res = divider(r_arr)
arr = sorter(l_res, r_res)
return arr
A = [6, 5, 2, 1, 5, 6]
res = divider(A)
print(inv_count)
#
# def brute_force(arr):
# arr = A
# lent = len(arr)
# inv_c = 0
# for i in range(lent):
# for j in range(i+1, lent):
# if arr[i] > arr[j]:
# inv_c += 1
# return inv_c % (10**7 + 7)
#
#
# A = [1, 2, 3, 4, 5, 6]
# res = brute_force(A)
# print(res)
|
# -*- coding: utf-8 -*-
"""
ENERPIPLOT - Common constants & color palettes
"""
ROUND_W = 500
ROUND_KWH = .5
COLOR_REF_RMS = '#FF0077'
# summary (consumption) var plots
COLS_DATA_KWH = ['kWh', 'p_max', 'p_min', 't_ref']
COLORS_DATA_KWH = ['#8C27D3', '#972625', '#f4af38', '#8C27D3']
UNITS_DATA_KWH = ['kWh', 'W', 'W', '']
LABELS_DATA_KWH = ['Consumption', 'Max Power', 'Min Power', 'Sampled']
FMT_TOOLTIP_DATA_KWH = ['{0.000}', '{0}', '{0}', '{0.000}']
def _gen_tableau20():
# These are the "Tableau 20" colors as RGB.
tableau = [(31, 119, 180), (174, 199, 232), (255, 127, 14), (255, 187, 120),
(44, 160, 44), (152, 223, 138), (214, 39, 40), (255, 152, 150),
(148, 103, 189), (197, 176, 213), (140, 86, 75), (196, 156, 148),
(227, 119, 194), (247, 182, 210), (127, 127, 127), (199, 199, 199),
(188, 189, 34), (219, 219, 141), (23, 190, 207), (158, 218, 229)]
# Scale the RGB values to the [0, 1] range, which is the format matplotlib accepts.
for i in range(len(tableau)):
r, g, b = tableau[i]
tableau[i] = (r / 255., g / 255., b / 255.)
return tableau
# These are the "Tableau 20" colors as RGB.
tableau20 = _gen_tableau20()
|
#
# @lc app=leetcode.cn id=133 lang=python3
#
# [133] clone-graph
#
None
# @lc code=end |
def add_node(v):
if v in graph:
print(v,"already present")
else:
graph[v]=[]
def add_edge(v1,v2):
if v1 not in graph:
print(v1," not present in graph")
elif v2 not in graph:
print(v2,"not present in graph")
else:
graph[v1].append(v2)
graph[v2].append(v1)
def delete_edge(v1,v2):
if v1 not in graph:
print(v1,"not present in graph")
elif v2 not in graph:
print(v2,"not present in graph")
else:
if v2 in graph[v1]:
graph[v1].remove(v2)
graph[v2].remove(v1)
graph={}
add_node('A')
add_node('B')
add_node('C')
add_node('D')
add_edge('A','D')
add_edge('A','C')
add_edge('C','D')
add_edge('C','E')
delete_edge('C','D') #Op=>> {'A': ['D', 'C'], 'B': [], 'C': ['A'], 'D': ['A']}
print(graph)
|
# ================================================================
def total_packet_size_bytes (s):
return (s ['packet_len'] +
s ['num_credits'] +
s ['channel_id'] +
s ['payload'])
def this_packet_size_bytes (s, n):
return (s ['packet_len'] +
s ['num_credits'] +
s ['channel_id'] +
n)
# ================================================================
# Substitution function to expand a template into code.
# 'template' is a list of strings
# Each string represents a line of text,
# and may contain '@FOO' variables to be substituted.
# 'substs' is list of (@FOO, string) substitutions.
# Returns a string which concatenates the lines and substitutes the vars.
def subst (template, substs):
s = "\n".join (template)
for (var, val) in substs:
s = s.replace (var, val)
return s
# ================================================================
|
# print() supports formatting of console output that is rudimentary at best.
# You can choose how to separate printed objects, and you can specify what goes
# at the end of the printed line. That’s about it
# string modulo operator: <format_string> % <values>
# NOTE: If you’re acquainted with the printf() family of functions of C, Perl,
# or Java, then you’ll see that these don’t exist in Python. However, there is a
# quite a bit of similarity between printf() and the string modulo operator, so
# if you’re familiar with printf(), then a lot of the following will feel
# familiar
print('%d %s cost $%.3f' % (6, 'bananas', 1.74))
# In addition to representing the string modulo operation itself, the '%'
# character also denotes the conversion specifiers in the format string—in this
# case, '%d', '%s', and '%.2f'
name = 'hauntarl'
print('Hello my name is %s' % name)
# NOTE: string modulo operation isn’t only for printing. You can also format
# values and assign them to another string variable
greet = 'How are you %s?' % name
print(greet)
# Conversion specifiers appear in the <format_string> and determine how values
# are formatted when they’re inserted: %[<flags>][<width>][.<precision>]<type>
# % and <type> are required. The remaining components shown in square brackets
# are optional
# Refer: https://realpython.com/python-input-output/#the-string-modulo-operator
# Interger conversion type: d, i, u, x, X, o
# d, i, u are functionally equivalent
print('%d, %i, %u' % (42, 42, -42))
# x, X for string representation of hexadecimal integer
print('%x, %X' % (254, 255))
# o for string representation of octal number
print('%o' % 8)
# f, F for string representation of float number
print('%f, %F' % (3.14159, 3.14))
# e, E for string representation in exponential format
print('%e, %E' % (100., 1000.))
# inf and NaN
# Under some circumstances, a floating-point operation can result in a value
# that is essentially infinite. The string representation of such a number in
# Python is 'inf'.
# It also may happen that a floating-point operation produces a value that is
# not representable as a number. Python represents this with the string 'NaN'
x = float('NaN')
print('%f, %e, %F, %E' % (x, x, x, x))
x = float('Inf')
print('%f, %e, %F, %E' % (x, x, x, x))
# The g and G conversion types choose between floating point or exponential
# output, depending on the magnitude of the exponent and the value specified
# for .<precision>. (See below.) Output is the same as e/E if the exponent is
# less than -4 or not less than .<precision>. Otherwise, it’s the same as f/F
pi = 3.14
print('%g, %G' % (pi, pi))
x = .000003
print('%g, %G' % (x, x))
# Character conversion types:
# c inserts a single character. The corresponding value may be either an
# integer or a single-character string
print('%c' % 97)
print('[%c]' % 'c')
# The c conversion type supports conversion to Unicode characters as well
print('%c' % 8721)
# String conversion types:
# s, r, and a produce string output using the built-in functions str(), repr(),
# and ascii(), respectively
print('%s' % '10')
print('%r' % '10')
print('%a' % '10')
# To insert a literal '%' character into the output, specify two consecutive %
# characters in the format string. The first introduces a conversion specifier
# (as usual), and the second specifies that the conversion type is %, which
# results in a single '%' character in the output
# Width and Precision Specifiers:
# %[<flags>][<width>][.<precision>]<type>
# They determine how much horizontal space a formatted value occupies.
# <width> specifier
print('[%5s]' % 'foo')
print('[%3d]' % 4)
# If the output length is greater than <width>, then <width> has no effect
# .<precision> specifier
print('%.2f' % 123.456789)
print('%.2e' % 123.456789)
# For the g and G types, .<precision> determines the total number of significant
# digits before and after the decimal point
print('%.2g' % 123.456789)
# String values formatted with the s, r, and a types are truncated to the length
# specified by .<precision>
print('%.4s' % 'foobar')
# It is very common to see <width> and .<precision> used together
print('[%8.2f]' % 123.45678)
print('[%8.3s]' % 'foobar')
# Either of <width> or .<precision> can be specified as an asterisk character
# (*), in which case the value to be used is taken from the next item in the
# <values> tuple
print('[%*.*f]' % (10, 5, 123))
for i in range(3):
print('[%*s]' % (i + 3, 'foo'))
# Optional conversion <flags> are specified just after the initial % character
# %[<flags>][<width>][.<precision>]<type>
# # flag: For the octal and hexadecimal conversion types, the # flag causes base
# information to be included in the formatted output
print('%#o' % 16)
print('%#x' % 16, '%#X' % 16)
# The # flag is ignored for the decimal conversion types d, i, and u.
# For floating point values, the # flag forces the output to always contain a
# decimal point
print('%.0f' % 123)
print('%#.0f' % 123)
print('%.0e' % 123)
print('%#.0e' % 123)
# The 0 Flag: When a formatted numeric value is shorter than the specified field
# width, the default behavior is to pad the field with ASCII space characters.
# The 0 flag causes padding with '0' characters instead
print('%08.2f' % 1.2)
# The - Flag: When a formatted value is shorter than the specified field width,
# it is usually right-justified in the field. The - flag causes the value to be
# left-justified in the specified field instead
print('[%-8.2f]' % 123.3)
# The + and ' ' Flags: By default, positive numeric values do not have a leading
# sign character. The + flag adds a '+' character to the left of numeric output
print('[%+5d]' % 3)
print('[%+5d]' % -3)
# The ' ' (space character) flag causes positive numeric values to be preceded
# by a space character
print('[% d]' % 3)
print('[% d]' % -3)
|
class S(str):
# Symbol class: the only important difference between S and str is that S has a __substitute__ method
# Note that S('a') == 'a' is True. This lets us use strings as shorthand in certain places.
def __str__(self):
return "S('" + super(S, self).__str__() + "')"
def __repr__(self):
return "S(" + super(S, self).__repr__() + ")"
def __substitute__(self, values):
return values[self]
def identity(x):
return x
class TransSymbol(object):
# A Symbol or SymbolicAddress with a transformation applied
# TODO: reverse transformation currently not applied during match. Use it.
def __init__(self, symbol, forward=identity, reverse=identity):
# Can either pass a single dict, or a pair of functions
self._symbol = symbol
self._map = None
if type(forward) == dict:
reverse = {v:k for k,v in forward.items()}
# TODO: add option to fail on map miss
self._forward_func = lambda k: forward.get(k, None)
self._reverse = lambda k: reverse.get(k, None)
self._map = forward
else:
self._forward_func = forward
self._reverse = reverse
# Note that there is no corresponding wrapper for _reverse. This is a minor hack, and I haven't decided what behavior
# I actually want here.
def _forward(self, inner):
try:
return self._forward_func(inner)
except TypeError:
# Hit if either forward function is None, or forward function receives None but doesn't handle it. Both ok.
# TODO: figure out what I actually want the default behavior to be
return inner
except AttributeError:
# Same story
return inner
# TODO: proper equality & hashing for TransSymbols.
def __str__(self):
return 'Trans(' + str(self._symbol) + ')'
def __repr__(self):
if self._map:
return 'Trans(' + self._symbol.__repr__() + ', ' + self._map.__repr__() + ')'
return 'Trans(' + self._symbol.__repr__() + ')'
class Nullable(object):
# A simple wrapper class to mark part of a template as optional, i.e. match is allowed to fail.
def __init__(self, contents):
self.contents = contents
|
def randomized_partition(arr, low, high):
"""Partition the array into two halfs according to the last element (pivot)
loop invariant:
[low, i] <= pivot
[i+1, j) > pivot
"""
i = low - 1
j = low
pivot = arr[high]
while j < high:
if arr[j] <= pivot:
i = i + 1
arr[i], arr[j] = arr[j], arr[i]
j = j + 1
i = i + 1
arr[i], arr[high] = pivot, arr[i]
return i
def qsort(arr, low, high):
if low < high:
pivot_loc = randomized_partition(arr, low, high)
qsort(arr, low, pivot_loc - 1)
qsort(arr, pivot_loc + 1, high)
def merge(arr, low, mid, high):
left = arr[low:mid + 1]
right = arr[mid + 1:high + 1]
i = 0
j = 0
k = low
while i <= mid - low and j <= high - mid - 1:
if left[i] <= right[j]:
arr[k] = left[i]
i += 1
else:
arr[k] = right[j]
j += 1
k += 1
while i <= mid - low:
arr[k] = left[i]
i += 1
k += 1
while j <= high - mid - 1:
arr[k] = right[j]
j += 1
k += 1
def merge_sort(arr, low, high):
if low < high:
mid = int((low + high) / 2)
merge_sort(arr, low, mid)
merge_sort(arr, mid + 1, high)
merge(arr, low, mid, high)
def left_child(index):
return 2 * index + 1
def right_child(index):
return 2 * index + 2
def min_heapify(arr, index, size):
left = left_child(index)
right = right_child(index)
# find smallest among children, swap and heapify children
if left < size and arr[left] < arr[index]:
smallest_idx = left
else:
smallest_idx = index
if right < size and arr[right] < arr[smallest_idx]:
smallest_idx = right
if smallest_idx != index:
arr[index], arr[smallest_idx] = arr[smallest_idx], arr[index]
min_heapify(arr, smallest_idx, size)
def build_heap(arr, size):
for i in reversed(range(int(size / 2))):
min_heapify(arr, i, size)
def heap_sort(arr, low, high):
copy = arr[low:high + 1]
size = high - low + 1
build_heap(copy, size)
for i in reversed(range(1, size)):
copy[0], copy[i] = copy[i], copy[0]
size = size - 1
min_heapify(copy, 0, size)
arr[low:high + 1] = [x for x in reversed(copy)]
def radix_sort(arr, low, high, digit, base=10):
def sort_digit(arr, low, high, pos, base):
buckets = [[] for _ in range(base)]
for val in arr[low:high + 1]:
digit = (val // base**pos) % base
buckets[digit].append(val)
return [item for digit_list in buckets for item in digit_list]
for i in range(digit):
arr[low:high + 1] = sort_digit(arr, low, high, i, base)
arr = [2, 1, 2, 4, 7, 5, 2, 6, 10, 8]
size = len(arr)
# qsort(arr, 0, size-1)
# heap_sort(arr, 0, size - 1)
radix_sort(arr, 0, size - 1, 1, 10)
print(arr)
|
class SwampyException(Exception):
pass
class ExWelcomeTimeout(SwampyException):
pass
class ExAbort(SwampyException):
pass
class ExInvocationError(SwampyException):
pass
|
# -*- coding:utf-8 -*-
# execute mode(prod/dev/testing)
ENV = 'prod'
# ENV = 'dev'
#ENV = 'testing'
# MRQ Task and Queue configuration
TASK_PATH = 'worker.tasks.CrawlCallHistory'
QUEUE_NAME = 'q-crawl'
#QUEUE_NAME = 'zhijie-crawl'
# SID setting (sec)
SID_EXPIRE_TIME = 300
STATE_TIME_OUT = 170
CRAWLER_TIME_OUT = 1190
STEP_TIME = 0.5
# three main telecom website(聯通, 電信, 移動) flow
TELECOM_FLOW_INFO = {
u'联通': {
'flow_type': '10010',
'register_link' : 'https://uac.10010.com/portal/register.html',
'pwd_reset_link' : 'https://uac.10010.com/cust/resetpwd/inputName'
},
u'电信': {
'flow_type': '10000',
'register_link' : 'http://login.189.cn/reg',
'pwd_reset_link' : 'http://login.189.cn/login'
},
u'移动': {
'flow_type': '10086',
'register_link' : 'https://login.10086.cn/html/register/register.html',
'pwd_reset_link' : 'https://bj.ac.10086.cn/ac/html/resetpassword.html'
}
}
|
"""
aiida_abinit
The AiiDA plugin for ABINIT.
"""
__version__ = "0.1.0a0"
|
class CableTrayConduitBase(MEPCurve,IDisposable):
""" The CableTrayConduitBase class is implemented as the base class for cable tray or conduit """
def Dispose(self):
""" Dispose(self: Element,A_0: bool) """
pass
def getBoundingBox(self,*args):
""" getBoundingBox(self: Element,view: View) -> BoundingBoxXYZ """
pass
@staticmethod
def IsValidEndPoints(startPoint,endPoint):
"""
IsValidEndPoints(startPoint: XYZ,endPoint: XYZ) -> bool
Identifies if two end points are valid.
startPoint: The start point of the location line.
endPoint: The end point of the location line.
Returns: True if the two end points are valid,false otherwise.
"""
pass
@staticmethod
def IsValidLevelId(document,levelId):
"""
IsValidLevelId(document: Document,levelId: ElementId) -> bool
Identifies if a level id is valid.
document: The document.
levelId: The level id.
Returns: True if the level id is valid,false otherwise.
"""
pass
def IsWithFitting(self):
"""
IsWithFitting(self: CableTrayConduitBase) -> bool
Return whether its cable tray/conduit type is with fitting
Returns: return true if its type is with fitting type.
"""
pass
def ReleaseUnmanagedResources(self,*args):
""" ReleaseUnmanagedResources(self: Element,disposing: bool) """
pass
def setElementType(self,*args):
""" setElementType(self: Element,type: ElementType,incompatibleExceptionMessage: str) """
pass
def __enter__(self,*args):
""" __enter__(self: IDisposable) -> object """
pass
def __exit__(self,*args):
""" __exit__(self: IDisposable,exc_type: object,exc_value: object,exc_back: object) """
pass
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
RunId=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""The id of the run to which this element belongs.
Get: RunId(self: CableTrayConduitBase) -> ElementId
"""
|
# Crie um programa que leia qto dinheiro uma pessoa tem na carteira e mostre quantos doláres ela pode comprar.
# Considere 1 dolar igual a 3,27 reais
n1 = float(input('Informe o valor que tem na carteira R$: '))
conversao = n1 / 3.27
print('Com R${}, você poderá comprar US${:.2f}!'.format(n1,conversao))
|
#!/usr/bin/python3
def new_in_list(my_list, idx, element):
new_list = my_list[:]
if idx >= 0 and idx < len(my_list):
new_list[idx] = element
return new_list
|
# https://leetcode.com/problems/bitwise-ors-of-subarrays/
#
# algorithms
# Medium (32.02%)
# Total Accepted: 5,616
# Total Submissions: 17,538
class Solution(object):
def subarrayBitwiseORs(self, A):
"""
:type A: List[int]
:rtype: int
"""
cur, res = set(), set()
for n in A:
cur = {i | n for i in cur} | {n}
res |= cur
return len(res)
|
"""
Class to parse and validate command-line arguments required by train, classify and evaluate.
"""
class ArgumentHandler:
def __init__(self):
#I/O
#data.py: DataHandler
self.logdir = None
self.max_tokens = 200
self.labels = ""
self.num_labels = 3
self.feature_input_dims = self.num_labels + 1 #turn no + context bow
self.context_size = 3
#model.py: Net
self.text_encoder = True
self.text_encoder_dims = 768
self.text_output_dims = 64
self.bert = True
self.feature_encoder = False
self.feature_encoder_dims = 64
self.dropout = 0.1
self.activation = 'relu'
#model.py: ModelHandler
self.batch_size = 8
self.load_from_ckpt = False
self.ckpt_file = None #"best_ckpt.pt"
self.learning_rate = 2e-5
self.weight_decay = 0.01
self.max_grad_norm = 1.0
self.num_epochs = 500 #only using num_iters, essentially.
self.num_iters=100
self.print_iter_no_after = 25#print iter number after.
self.ckpt_after = 50
self.freeze = False
self.oversample = False
self.have_attn = True
self.pretraining = False
self.pretrained_dir = ""
self.store_preds = False
self.majority_prediction = False
def update_hyps(self, hyps):
"""
Update the params
"""
for key, value in hyps.items():
setattr(self, key, value) |
class Body(object):
"""An class which is used to store basic properties about a body"""
def __init__(self, xPos, yPos, xVel, yVel, mass):
"""Create a new body
xPos - The x component of the position
yPos - The y component of the position
xVel - The x component of the velocity
yVel - The y component of the velocity
mass - The mass of the body"""
self.xPos = xPos
self.yPos = yPos
self.xVel = xVel
self.yVel = yVel
self.xAcl = 0.0
self.yAcl = 0.0
self.mass = mass
|
def main(type):
x = 0
print(type)
if type=="wl":
#a while loop
while (x <5):
print(x)
x = x + 1
elif type=="fl":
#a for loop
for x in range(5,10):
print(x)
elif type=="cl":
#a for loop over a collection
days = ["Mon", "Tue", "Wed", "Thurs", "Fri", "Sat", "Sun"]
for d in days:
print(d)
elif type=="en":
# enumerate() function to get index
directions = ["East", "West", "North", "South", "SouthWest", "NorthEast", "NorthWest"]
for i, d in enumerate(directions):
print (i,d)
else:
print("Invalid loop type specified")
if __name__ == "__main__":
main('wl')
|
# Faça um algoritmo que leia o salario de um funcionario e mostre
# seu novo salario, com 15% de aumento.
salario = float(input('Digite o seu salario: '))
novosala = salario + salario * 0.15
print('O seu novo salário sera de {}{}' .format('\033[1;95m', novosala))
|
# Constants in FlexRay spec
cdCycleMax = 16000
cCycleCountMax = 63
cStaticSlotIDMax = 1023
cSlotIDMax = 2047
cPayloadLengthMax = 127
cSamplesPerBit = 8
cSyncFrameIDCountMax = 15
cMicroPerMacroNomMin = 40
cdMinMTNom = 1
cdMaxMTNom = 6
cdFES = 2
cdFSS = 1
cChannelIdleDelimiter = 11
cClockDeviationMax = 0.0015
cStrobeOffset = 5
cVotingSamples = 5
cVotingDelay = (cVotingSamples - 1) / 2
cdBSS = 2
cdWakeupSymbolTxIdle = 18
cdWakeupSymbolTxLow = 6
cdCAS = 30
cMicroPerMacroMin = 20
cdMaxOffsetCalculation = 1350
cdMaxRateCalculation = 1500
SIZEOF_UINT16 = 2
SIZEOF_PACKET_HEADER = SIZEOF_UINT16 * 2
PACKET_TYPE_START_DRIVER = 0
PACKET_TYPE_FLEXRAY_FRAME = 1
PACKET_TYPE_HEALTH = 2
PACKET_TYPE_FLEXRAY_JOINED_CLUSTER = 3
PACKET_TYPE_FLEXRAY_JOIN_CLUSTER_FAILED = 4
PACKET_TYPE_FLEXRAY_DISCONNECTED_FROM_CLUSTER = 5
PACKET_TYPE_FLEXRAY_FATAL_ERROR = 6
PACKET_TYPE_MONIOR_SLOTS = 7
# MPC5748g registers bits
FR_PIFR0_TBVA_IF_U16 = 0x0008
FR_PIFR0_TBVB_IF_U16 = 0x0010
FR_PIFR0_LTXA_IF_U16 = 0x0020
FR_PIFR0_LTXB_IF_U16 = 0x0040
FR_PIER0_CCL_IF_U16 = 0x0200
FR_PIFR0_MOC_IF_U16 = 0x0400
FR_PIFR0_MRC_IF_U16 = 0x0800
FR_PIFR0_FATL_IF_U16 = 0x8000
FR_PIFR0_INTL_IF_U16 = 0x4000
FR_PIFR0_ILCF_IF_U16 = 0x2000
FR_PIFR0_CSA_IF_U16 = 0x1000
FR_PIER0_TI2_IE_U16 = 0x0004
FR_PIER0_TI1_IE_U16 = 0x0002
FR_PSR0_ERRMODE_MASK_U16 = 0xC000
FR_PSR0_SLOTMODE_MASK_U16 = 0x3000
FR_PSR0_PROTSTATE_MASK_U16 = 0x0700
FR_PSR0_STARTUP_MASK_U16 = 0x00F0
FR_PSR0_WUP_MASK_U16 = 0x0007
FR_PSR0_SLOTMODE_SINGLE_U16 = 0x0000
FR_PSR0_SLOTMODE_ALL_PENDING_U16 = 0x1000
FR_PSR0_SLOTMODE_ALL_U16 = 0x2000
FR_PSR0_ERRMODE_ACTIVE_U16 = 0x0000
FR_PSR0_ERRMODE_PASSIVE_U16 = 0x4000
FR_PSR0_ERRMODE_COMM_HALT_U16 = 0x8000
FR_PSR0_PROTSTATE_DEFAULT_CONFIG_U16 = 0x0000
FR_PSR0_PROTSTATE_CONFIG_U16 = 0x0100
FR_PSR0_PROTSTATE_WAKEUP_U16 = 0x0200
FR_PSR0_PROTSTATE_READY_U16 = 0x0300
FR_PSR0_PROTSTATE_NORMAL_PASSIVE_U16 = 0x0400
FR_PSR0_PROTSTATE_NORMAL_ACTIVE_U16 = 0x0500
FR_PSR0_PROTSTATE_HALT_U16 = 0x0600
FR_PSR0_PROTSTATE_STARTUP_U16 = 0x0700
FR_PSR0_STARTUP_CCR_U16 = 0x0020
FR_PSR0_STARTUP_CL_U16 = 0x0030
FR_PSR0_STARTUP_ICOC_U16 = 0x0040
FR_PSR0_STARTUP_IL_U16 = 0x0050
FR_PSR0_STARTUP_IS_U16 = 0x0070
FR_PSR0_STARTUP_CCC_U16 = 0x00A0
FR_PSR0_STARTUP_ICLC_U16 = 0x00D0
FR_PSR0_STARTUP_CG_U16 = 0x00E0
FR_PSR0_STARTUP_CJ_U16 = 0x00F0
FR_PSR1_CPN_U16 = 0x0080
FR_PSR1_HHR_U16 = 0x0040
FR_PSR1_FRZ_U16 = 0x0020
FR_PSR2_NBVB_MASK_U16 = 0x8000
FR_PSR2_NSEB_MASK_U16 = 0x4000
FR_PSR2_STCB_MASK_U16 = 0x2000
FR_PSR2_SBVB_MASK_U16 = 0x1000
FR_PSR2_SSEB_MASK_U16 = 0x0800
FR_PSR2_MTB_MASK_U16 = 0x0400
FR_PSR2_NBVA_MASK_U16 = 0x0200
FR_PSR2_NSEA_MASK_U16 = 0x0100
FR_PSR2_STCA_MASK_U16 = 0x0080
FR_PSR2_SBVA_MASK_U16 = 0x0040
FR_PSR2_SSEA_MASK_U16 = 0x0020
FR_PSR2_MTA_MASK_U16 = 0x0010
FR_PSR2_CKCORFCNT_MASK_U16 = 0x000F
FR_PSR3_ABVB_U16 = 0x1000
FR_PSR3_AACB_U16 = 0x0800
FR_PSR3_ACEB_U16 = 0x0400
FR_PSR3_ASEB_U16 = 0x0200
FR_PSR3_AVFB_U16 = 0x0100
FR_PSR3_ABVA_U16 = 0x0010
FR_PSR3_AACA_U16 = 0x0008
FR_PSR3_ACEA_U16 = 0x0004
FR_PSR3_ASEA_U16 = 0x0002
FR_PSR3_AVFA_U16 = 0x0001
FR_SSR_VFB = 0x8000
FR_SSR_SYB = 0x4000
FR_SSR_NFB = 0x2000
FR_SSR_SUB = 0x1000
FR_SSR_SEB = 0x0800
FR_SSR_CEB = 0x0400
FR_SSR_BVB = 0x0200
FR_SSR_TCB = 0x0100
FR_SSR_VFA = 0x0080
FR_SSR_SYA = 0x0040
FR_SSR_NFA = 0x0020
FR_SSR_SUA = 0x0010
FR_SSR_SEA = 0x0008
FR_SSR_CEA = 0x0004
FR_SSR_BVA = 0x0002
FR_SSR_TCA = 0x0001
|
"""
1. 187_XXX -> Self define exception
"""
class NameIsError(Exception):
pass
class AgeIsError(Exception):
pass
class HahaIsError(Exception):
pass
def check_name(name):
if name.find("li") >= 0:
raise NameIsError("Collision with my king's ", name)
def check_age(age):
if age >= 50 or age <= 18:
raise NameIsError("Age is either too young or old.")
try:
name = "I am feng"
check_name(name)
age = 19
check_age(age)
print(a)
except NameIsError as e:
print(str(e))
except AgeIsError as e:
print(str(e))
except Exception as e:
print("---------")
print(str(e))
|
class Triple:
def __init__(self, subject, predicate, object):
self.subject = subject
self.predicate = predicate
self.object = object
|
def main():
return 0
if __name__ == "__main__":
for case in range(1, int(input()) + 1):
print(f"Case #{case}:", main())
|
file = open('input.txt', 'r')
Lines = file.readlines()
count = 0
# Strips the newline character
for line in Lines:
line_parts = line.strip().split(' ')
rule_part = line_parts[0].split('-')
min_rule = int(rule_part[0])
max_rule = int(rule_part[1])
password = line_parts[2]
char = line_parts[1][0]
char_count = password.count(char)
if max_rule >= char_count >= min_rule:
count += 1
print(count)
|
# Roman numeral/Decimal converter
# Roman to decimal conversion table
RomanValue = { 'I' : 1, 'V' : 5, 'X' : 10, 'L' : 50, 'C' : 100, 'D' : 500, 'M' : 1000 }
def RomanValueList (RomanNumber):
number = []
for i in RomanNumber:
number.append(RomanValue[i])
return number
# Convert Roman number string to list of decimal conversion values
def ToDecimal (number): # Expects a list from RomanValueList()
answer = number[-1] # Start with the rightmost digit
for i in range(len(number)-1,0,-1): # Digits offered in reverse
right = i
left = i-1
if left < 0: # Don't overrun the beginning of the list
break # This should never happen anyway.
else:
# Process every pair of roman digits with a simple rule.
if number[left] < number[right]:
answer -= number[left]
else:
answer += number[left]
return answer
# Decimal to Roman conversion table
ones = { 0: '', 1: 'I', 2: 'II', 3: 'III', 4: 'IV', 5: 'V', 6: 'VI', 7: 'VII', 8: 'VIII', 9: 'IX' }
tens = { 0: '', 1: 'X', 2: 'XX', 3: 'XXX', 4: 'XL', 5: 'L', 6: 'LX', 7: 'LXX', 8: 'LXXX', 9: 'XC' }
huns = { 0: '', 1: 'C', 2: 'CC', 3: 'CCC', 4: 'CD', 5: 'D', 6: 'DC', 7: 'DCC', 8: 'DCCC', 9: 'CM' }
thous = { 0: '', 1: 'M', 2: 'MM', 3: 'MMM' }
# Convert decimal int to Roman number string
def ToRoman (x): # Expects an int 1 to 3999
one = x//1 % 10 # separate the place values
ten = x//10 % 10
hun = x//100 % 10
thou = x//1000 % 10
return thous[thou] + huns[hun] + tens[ten] + ones[one]
# Main code starts here
# accepts improper Roman numbers such as IVMX.
# may give unexpected conversions for improper Roman numbers.
# IVMX converts to 1004. 1004 should be MIV in modern standard notation.
# Does not accept 0, or over large or fractional decimal numbers.
stop = False
while not stop:
baddata = False
while not baddata:
number = ''
while number == '':
number = input ("Enter number to convert: ")
number = number.upper()
# Anything other than decimal digits, decimal point, or Roman digits is rejected.
decimal = Roman = True
for i in number:
if i not in {'0','1','2','3','4','5','6','7','8','9'}:
decimal = False
if i not in {'I','V','X','L','C','D','M'}: # 2 Sets of acceptable chars.
Roman = False
if not decimal and not Roman: # Neither type entered.
if number == 'Q':
stop = True # Trying to end the prog here.
break # Breaks baddata loop.
else:
print ("Decimal (1 to 3999) or Roman numbers only, please.")
continue # Get another input. Continues baddata loop.
else: # Process the number input
if decimal:
if (int(number) < 1) or (int(number) > 3999):
print ("Decimal (1 to 3999) or Roman numbers only, please.")
continue
answer = ToRoman(int(number))
elif Roman:
answer = ToDecimal(RomanValueList (number))
print (number, " converts to ", answer)
# Main code stops here
|
# Python Program To Handle Multiple Exceptions
def avg(list):
tot = 0
for x in list:
tot += x
avg = tot/len(list)
return tot, avg
# Call The avg() And Pass A List
try:
t, a = avg([1,2,3,4,5,'a']) # Here Give Empty List And try
print('Total = {}, Average = {}'.format(t, a))
except TypeError:
print('Type Error, Please Provide Numbers.')
except ZeroDivisionError:
print('ZeroDivisionError, Please Do Not Give Empty List. ')
|
# -*- coding: utf-8 -*-
#
# Copyright 2014-2022 BigML
#
# 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.
"""Options for BigMLer test files processing
"""
def get_test_options(defaults=None):
"""Test files-related options
"""
if defaults is None:
defaults = {}
options = {
# Path to the test set.
"--test": {
'action': 'store',
'dest': 'test_set',
'nargs': '?',
'default': defaults.get('test', None),
'help': "Test set path."},
# Name of the file to output predictions.
"--output": {
'action': 'store',
'dest': 'output',
'default': defaults.get('output', None),
'help': "Path to the file to output predictions."},
# Set when the test set file doesn't include a header on the first
# line.
'--no-test-header': {
'action': 'store_false',
'dest': 'test_header',
'default': defaults.get('test_header', True),
'help': "The test set file hasn't a header."},
# Test set field separator. Defaults to the locale csv
# separator.
'--test-separator': {
'action': 'store',
'dest': 'test_separator',
'default': defaults.get('test_separator', None),
'help': "Test set field separator."},
# The path to a file containing attributes if you want to alter BigML's
# default field attributes or the ones provided by the test file
# header.
'--test-field-attributes': {
'action': 'store',
'dest': 'test_field_attributes',
'default': defaults.get('test_field_attributes', None),
'help': ("Path to a csv file describing field attributes."
" One definition per line"
" (e.g., 0,'Last Name').")},
# The path to a file containing types if you want to alter BigML's
# type auto-detect.
'--test-types': {
'action': 'store',
'dest': 'test_types',
'default': defaults.get('test_types', None),
'help': ("Path to a file describing field types. One"
" definition per line (e.g., 0, 'numeric').")},
# If a BigML test source is provided, the script won't create a new one
'--test-source': {
'action': 'store',
'dest': 'test_source',
'default': defaults.get('test_source', None),
'help': "BigML test source Id."},
# If a BigML test dataset is provided, the script won't create a new
# one
'--test-dataset': {
'action': 'store',
'dest': 'test_dataset',
'default': defaults.get('test_dataset', None),
'help': "BigML test dataset Id."},
# The path to a file containing dataset ids.
'--test-datasets': {
'action': 'store',
'dest': 'test_datasets',
'default': defaults.get('test_datasets', None),
'help': ("Path to a file containing dataset/ids. Just"
" one dataset per line"
" (e.g., dataset/50a20697035d0706da0004a4).")},
# Set when the test set file does include a header on the first
# line. (opposed to --no-test-header)
'--test-header': {
'action': 'store_true',
'dest': 'test_header',
'default': defaults.get('test_header', True),
'help': "The test set file has a header."}}
return options
|
# coding: utf-8
#
# Copyright 2022 :Barry-Thomas-Paul: Moss
#
# 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.
#
# Const Class
# this is a auto generated file generated by Cheetah
# Libre Office Version: 7.3
# Namespace: com.sun.star.util
class MeasureUnit(object):
"""
Const Class
These constants are used to specify a measure.
A component using these constants may not support all units.
See Also:
`API MeasureUnit <https://api.libreoffice.org/docs/idl/ref/namespacecom_1_1sun_1_1star_1_1util_1_1MeasureUnit.html>`_
"""
__ooo_ns__: str = 'com.sun.star.util'
__ooo_full_ns__: str = 'com.sun.star.util.MeasureUnit'
__ooo_type_name__: str = 'const'
MM_100TH = 0
"""
all measures for this component are in 100th millimeter
"""
MM_10TH = 1
"""
all measures for this component are in 10th millimeter
"""
MM = 2
"""
all measures for this component are in millimeter
"""
CM = 3
"""
all measures for this component are in centimeters
"""
INCH_1000TH = 4
"""
all measures for this component are in 1000th inch
"""
INCH_100TH = 5
"""
all measures for this component are in 100th inch
"""
INCH_10TH = 6
"""
all measures for this component are in 10th inch
"""
INCH = 7
"""
all measures for this component are in inch
"""
POINT = 8
"""
all measures for this component are in points
"""
TWIP = 9
"""
all measures for this component are in twips
"""
M = 10
"""
all measures for this component are in meters
"""
KM = 11
"""
all measures for this component are in kilometers
"""
PICA = 12
"""
all measures for this component are in pica
"""
FOOT = 13
"""
all measures for this component are in foot
"""
MILE = 14
"""
all measures for this component are in miles
"""
PERCENT = 15
"""
all measures for this component are in percentage
"""
PIXEL = 16
"""
all measures for this component are in pixel
"""
APPFONT = 17
"""
all measures for this component are in APPFONT
"""
SYSFONT = 18
"""
all measures for this component are in SYSFONT
"""
__all__ = ['MeasureUnit']
|
def dataset():
pass
def model():
pass
def loss():
pass
def opt():
pass |
class Response:
def __init__(self, message=None, data=None):
self.message = message
self.data = data
def build(self):
return {
"message": self.message,
"data": self.data
}
|
def main():
double_letters = 0
triple_letters = 0
input_file = open('input', 'r')
for line in input_file:
double_letters_found = False
triple_letters_found = False
characters = set(line.replace('\n', ''))
for character in characters:
if not double_letters_found and (line.count(character) == 2):
double_letters += 1
double_letters_found = True
elif not triple_letters_found and (line.count(character) == 3):
triple_letters += 1
triple_letters_found = True
if double_letters_found and triple_letters_found:
break
checksum = double_letters * triple_letters
print(checksum)
if __name__ == "__main__":
main()
|
coordinates_E0E1E1 = ((129, 120),
(129, 122), (129, 124), (130, 124), (131, 124), (132, 124), (133, 124), (134, 124), (135, 124), (136, 123), (136, 132), (137, 119), (137, 123), (138, 119), (138, 122), (139, 120), (139, 122), (140, 121), (140, 123), (141, 121), (141, 126), (142, 113), (142, 115), (142, 121), (142, 123), (143, 112), (143, 116), (143, 117), (143, 118), (143, 119), (143, 120), (143, 121), (143, 122), (143, 124), (144, 113), (144, 114), (144, 115), (144, 121), (144, 122), (144, 124), (145, 110), (145, 113), (145, 114), (145, 115), (145, 116), (145, 117), (145, 118), (145, 119), (145, 120), (145, 121), (145, 133), (146, 111), (146, 113), (146, 114), (146, 115), (146, 116), (146, 117), (146, 118), (146, 119), (146, 120), (146, 121), (146, 122), (146, 123), (146, 124), (146, 125), (146, 126), (146, 127), (146, 128), (146, 129), (146, 130), (146, 131), (146, 133), (147, 112),
(147, 114), (147, 115), (147, 116), (147, 117), (147, 118), (147, 120), (147, 127), (147, 131), (147, 132), (148, 113), (148, 115), (148, 116), (148, 117), (148, 118), (148, 119), (148, 121), (148, 127), (148, 129), (149, 114), (149, 117), (149, 118), (149, 119), (149, 120), (149, 122), (149, 128), (150, 115), (150, 116), (150, 119), (150, 120), (150, 121), (150, 124), (150, 125), (150, 127), (151, 117), (151, 122), (151, 126), (152, 120), (152, 123), (152, 125), (153, 125), (154, 123), (154, 125), (155, 124), (155, 125), )
coordinates_E1E1E1 = ((99, 118),
(100, 118), (101, 118), (101, 119), (102, 118), (102, 119), (102, 126), (102, 128), (102, 134), (103, 117), (103, 119), (103, 126), (103, 129), (103, 130), (103, 131), (103, 132), (103, 133), (103, 135), (104, 117), (104, 120), (104, 127), (104, 130), (104, 135), (105, 118), (105, 120), (105, 128), (105, 130), (105, 135), (106, 119), (106, 121), (106, 128), (106, 131), (106, 134), (107, 120), (107, 121), (107, 127), (107, 131), (108, 122), (108, 124), (108, 125), (108, 128), (108, 130), (109, 123), (109, 126), (110, 112), (110, 125), (111, 111), (111, 125), (112, 110), (113, 125), (113, 126), (114, 120), (114, 124), (114, 126), (115, 125), (115, 127), (116, 128), (117, 128), )
coordinates_016400 = ((126, 134),
(127, 134), (127, 136), (128, 134), (128, 137), (129, 134), (129, 137), (130, 134), (130, 136), (130, 138), (131, 133), (131, 134), (131, 136), (131, 138), (132, 133), (132, 135), (132, 136), (132, 138), (133, 134), (133, 136), (133, 137), (133, 139), (134, 134), (134, 136), (134, 137), (134, 138), (134, 141), (135, 134), (135, 136), (135, 137), (135, 138), (135, 140), (136, 135), (136, 137), (136, 138), (136, 140), (137, 140), (138, 132), (138, 134), (138, 135), (138, 136), (138, 137), (139, 133), (139, 139), (139, 140), (140, 131), (141, 130), (142, 128), (142, 129), )
coordinates_006400 = ((105, 133),
(109, 132), (110, 135), (110, 136), (110, 137), (110, 138), (110, 139), (110, 140), (110, 142), (111, 133), (111, 142), (112, 134), (112, 139), (112, 140), (112, 142), (113, 137), (113, 138), (113, 139), (113, 140), (113, 141), (113, 143), (114, 139), (114, 142), (115, 138), (115, 139), (116, 138), (116, 141), (117, 138), (117, 140), (118, 138), (118, 139), (119, 137), (119, 138), )
coordinates_6395ED = ((125, 131),
(126, 129), (126, 131), (127, 128), (127, 132), (128, 127), (128, 129), (128, 130), (128, 132), (129, 126), (129, 128), (129, 129), (129, 130), (129, 132), (130, 126), (130, 127), (130, 128), (130, 129), (130, 130), (130, 132), (131, 126), (131, 128), (131, 129), (131, 131), (132, 126), (132, 128), (132, 129), (132, 131), (133, 126), (133, 128), (133, 129), (133, 131), (134, 126), (134, 128), (134, 129), (134, 131), (135, 126), (135, 128), (135, 130), (136, 126), (136, 128), (136, 130), (137, 125), (137, 130), (138, 124), (138, 127), (138, 129), (139, 125), )
coordinates_00FFFE = ((140, 137),
(141, 137), (141, 139), (142, 137), (142, 141), (143, 138), (143, 142), (144, 138), (144, 140), (144, 142), (145, 138), (145, 140), (145, 142), (146, 138), (146, 142), (147, 139), )
coordinates_F98072 = ((124, 114),
(124, 116), (124, 117), (124, 118), (124, 119), (124, 120), (124, 121), (125, 113), (125, 122), (125, 123), (125, 124), (125, 125), (125, 127), (126, 112), (126, 114), (126, 115), (126, 116), (127, 112), (127, 114), (127, 115), (127, 118), (127, 119), (127, 120), (127, 121), (127, 122), (127, 123), (127, 125), (128, 112), (128, 114), (129, 111), (129, 113), (129, 115), (130, 111), (130, 114), (131, 111), (131, 113), (132, 112), (133, 104), (133, 106), (133, 107), (133, 108), (133, 109), (134, 106), (134, 108), (134, 109), )
coordinates_97FB98 = ((140, 135),
(141, 133), (141, 135), (142, 132), (142, 135), (143, 126), (143, 127), (143, 130), (143, 131), (143, 132), (143, 133), (143, 135), (144, 126), (144, 128), (144, 129), (144, 130), (144, 135), (145, 135), (145, 136), (146, 136), (147, 135), (147, 137), (148, 134), (148, 136), (148, 138), (149, 131), (149, 133), (149, 135), (149, 137), (149, 138), (150, 130), (150, 134), (150, 136), (151, 131), (151, 133), (151, 135), (152, 131), (152, 133), (152, 135), (153, 131), (153, 133), (153, 135), (154, 131), (154, 133), (154, 135), (154, 136), (155, 131), (155, 132), (155, 133), (155, 134), (155, 136), (156, 131), (156, 133), (156, 134), (156, 137), (157, 131), (157, 136), (158, 131), (158, 133), (158, 134), )
coordinates_6495ED = ((110, 128),
(110, 130), (111, 127), (111, 131), (112, 128), (112, 131), (113, 128), (113, 130), (114, 129), (114, 131), (114, 134), (115, 129), (115, 131), (115, 132), (115, 133), (115, 136), (116, 130), (116, 132), (116, 133), (116, 134), (116, 136), (117, 130), (117, 132), (117, 133), (117, 134), (117, 136), (118, 131), (118, 133), (118, 135), (119, 132), (119, 135), (120, 133), (120, 135), )
coordinates_FA8072 = ((111, 113),
(112, 113), (112, 115), (113, 111), (113, 117), (114, 109), (114, 113), (114, 114), (114, 115), (114, 118), (115, 108), (115, 111), (115, 112), (115, 113), (115, 114), (115, 115), (115, 116), (115, 118), (116, 107), (116, 109), (116, 110), (116, 111), (116, 112), (116, 113), (116, 114), (116, 115), (116, 116), (116, 117), (116, 118), (116, 119), (117, 106), (117, 113), (117, 114), (117, 115), (117, 116), (117, 117), (117, 118), (117, 121), (117, 122), (117, 123), (117, 125), (118, 106), (118, 108), (118, 109), (118, 110), (118, 111), (118, 112), (118, 115), (118, 116), (118, 117), (118, 118), (118, 119), (118, 126), (119, 113), (119, 114), (119, 119), (119, 120), (119, 121), (119, 122), (119, 123), (119, 124), (119, 125), (119, 129), (120, 116), (120, 117), (120, 118), (120, 123), (120, 124), (120, 125), (120, 126), (120, 130), (121, 119), (121, 120),
(121, 121), (121, 122), (121, 123), (121, 131), (122, 124), (122, 125), (122, 126), (122, 127), (122, 128), (122, 130), )
coordinates_98FB98 = ((88, 135),
(89, 134), (89, 136), (90, 133), (90, 136), (91, 132), (91, 134), (91, 135), (91, 137), (92, 131), (92, 133), (92, 134), (92, 135), (92, 136), (92, 141), (93, 131), (93, 133), (93, 134), (93, 135), (93, 136), (93, 137), (93, 139), (93, 140), (93, 142), (94, 130), (94, 132), (94, 133), (94, 134), (94, 135), (94, 136), (94, 137), (94, 138), (94, 143), (95, 130), (95, 132), (95, 133), (95, 136), (95, 137), (95, 138), (95, 139), (95, 140), (95, 141), (95, 143), (96, 131), (96, 133), (96, 134), (96, 135), (96, 136), (96, 137), (96, 138), (96, 139), (96, 140), (96, 141), (96, 143), (97, 131), (97, 133), (97, 136), (97, 138), (97, 139), (97, 140), (97, 141), (97, 143), (98, 132), (98, 133), (98, 136), (98, 138), (98, 139), (98, 140), (98, 141), (98, 143), (99, 132), (99, 135), (99, 136),
(99, 137), (99, 138), (99, 139), (99, 140), (99, 141), (99, 143), (100, 133), (100, 137), (100, 138), (100, 139), (100, 140), (100, 141), (100, 143), (101, 136), (101, 138), (101, 139), (101, 140), (101, 141), (101, 143), (102, 137), (102, 139), (102, 140), (102, 142), (103, 137), (103, 139), (103, 140), (103, 142), (104, 137), (104, 138), (104, 139), (104, 140), (104, 142), (105, 137), (105, 139), (105, 140), (105, 142), (106, 137), (106, 139), (106, 140), (106, 142), (107, 136), (107, 142), (108, 135), (108, 137), (108, 138), (108, 139), (108, 140), (108, 142), )
coordinates_FEC0CB = ((130, 117),
(130, 119), (131, 115), (131, 121), (132, 114), (132, 117), (132, 118), (132, 119), (132, 122), (133, 113), (133, 116), (133, 117), (133, 118), (133, 119), (133, 120), (133, 122), (134, 111), (134, 114), (134, 115), (134, 116), (134, 117), (134, 118), (134, 122), (135, 104), (135, 110), (135, 113), (135, 114), (135, 115), (135, 116), (135, 117), (135, 119), (135, 120), (136, 104), (136, 106), (136, 107), (136, 108), (136, 109), (136, 111), (136, 112), (136, 113), (136, 114), (136, 115), (136, 116), (136, 117), (137, 104), (137, 110), (137, 111), (137, 112), (137, 113), (137, 114), (137, 115), (137, 117), (138, 105), (138, 108), (138, 109), (138, 110), (138, 111), (138, 112), (138, 113), (138, 114), (138, 115), (138, 117), (139, 109), (139, 111), (139, 117), (140, 109), (140, 111), (140, 113), (140, 114), (140, 115), (140, 118), (141, 109), (141, 111),
(141, 117), (141, 119), (142, 109), (142, 111), (143, 109), (143, 110), (144, 109), (145, 108), (147, 109), (148, 109), (148, 110), (148, 125), (149, 111), (150, 110), (151, 111), (151, 114), (152, 113), (152, 115), (152, 128), (152, 129), (153, 115), (153, 117), (153, 118), (153, 129), (154, 118), (154, 120), (154, 127), (154, 129), (155, 120), (155, 121), (155, 127), (155, 129), (156, 121), (156, 122), (156, 126), (156, 127), (156, 129), (157, 122), (157, 124), (157, 125), (157, 127), (157, 129), (158, 123), (158, 126), (158, 129), (159, 124), (159, 127), (160, 126), )
coordinates_333287 = ((88, 125),
(88, 127), (89, 124), (89, 128), (90, 123), (90, 125), (90, 126), (90, 127), (90, 129), (91, 123), (91, 125), (91, 126), (91, 127), (91, 129), (92, 124), (92, 126), (92, 127), (92, 129), (93, 124), (93, 126), (93, 128), (94, 124), (94, 126), (94, 128), (95, 125), (95, 128), (96, 126), (96, 128), )
coordinates_FFC0CB = ((92, 115),
(92, 116), (92, 117), (92, 119), (93, 112), (93, 114), (93, 120), (94, 111), (94, 115), (94, 116), (94, 117), (94, 118), (94, 119), (94, 121), (95, 110), (95, 112), (95, 113), (95, 114), (95, 115), (95, 116), (95, 117), (95, 118), (95, 119), (95, 121), (96, 109), (96, 111), (96, 112), (96, 113), (96, 114), (96, 115), (96, 116), (96, 117), (96, 120), (97, 109), (97, 111), (97, 112), (97, 113), (97, 114), (97, 115), (97, 116), (97, 118), (97, 120), (97, 121), (97, 124), (98, 108), (98, 110), (98, 111), (98, 112), (98, 113), (98, 114), (98, 115), (98, 116), (98, 117), (98, 120), (98, 122), (98, 126), (98, 127), (98, 129), (99, 108), (99, 110), (99, 111), (99, 112), (99, 113), (99, 114), (99, 116), (99, 120), (99, 122), (99, 123), (99, 124), (99, 126), (99, 130), (100, 108), (100, 110),
(100, 111), (100, 112), (100, 113), (100, 114), (100, 116), (100, 121), (100, 124), (100, 127), (100, 129), (100, 131), (101, 108), (101, 110), (101, 111), (101, 112), (101, 113), (101, 114), (101, 116), (101, 121), (101, 123), (101, 130), (101, 132), (102, 108), (102, 111), (102, 112), (102, 113), (102, 115), (102, 121), (102, 123), (103, 109), (103, 110), (103, 112), (103, 113), (103, 115), (103, 122), (103, 124), (104, 110), (104, 112), (104, 113), (104, 115), (104, 122), (104, 125), (105, 110), (105, 112), (105, 113), (105, 114), (105, 116), (105, 122), (105, 125), (106, 110), (106, 112), (106, 113), (106, 114), (106, 116), (106, 123), (106, 125), (107, 108), (107, 110), (107, 114), (107, 115), (107, 117), (108, 106), (108, 112), (108, 115), (108, 116), (108, 119), (109, 108), (109, 110), (109, 114), (109, 117), (109, 120), (110, 106), (110, 109),
(110, 115), (110, 119), (110, 122), (111, 106), (111, 108), (111, 117), (111, 123), (112, 107), (112, 108), (112, 119), (112, 123), (113, 107), (113, 121), (113, 122), (115, 105), )
|
num = int(input('digite um numero pra daber sua tabuada: '))
for rep in range(0, 11):
print('{} x {:2} = {}'.format(rep, num, num*rep))
|
print("")
for i in range(5):
peso = float(input("Peso da {}ª Pessoa em Kg: ".format(i+1)))
if (i == 0):
maior = peso
menor = peso
elif (peso > maior): maior = peso
elif (peso < menor): menor = peso
print("O menor peso lido foi {:.2f}Kg".format(menor))
print("O maior peso lido foi {:.2f}Kg".format(maior), end='\n\n') |
class Solution:
def bstFromPreorder(self, preorder: List[int]) -> TreeNode:
if len(preorder)==0:
return None
tn=TreeNode(preorder[0])
l=[]
r=[]
for i in preorder:
if i<preorder[0]:
l.append(i)
elif i>preorder[0]:
r.append(i)
tn.left=self.bstFromPreorder(l)
tn.right=self.bstFromPreorder(r)
return tn
|
n = int(input('digite um numero de 1 a 9999: '))
u = n % 10
d = n // 10 % 10
c = n // 100 % 10
m = n // 1000 % 10
print('A unidade', u)
print('A dezena', d)
print('A centena', c)
print('A milhar', m)
|
def stair(n):
if n == 0 or n == 1:
return 1
elif n == 2:
return 2
elif n == 3:
return 4
else:
return stair(n-3) + stair(n-2) + stair(n-1)
n = int(input())
print(stair(n))
|
#
# PySNMP MIB module CADANT-CMTS-EXPORTIMPORT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CADANT-CMTS-EXPORTIMPORT-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:27:10 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, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ValueRangeConstraint, SingleValueConstraint, ValueSizeConstraint, ConstraintsIntersection, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "SingleValueConstraint", "ValueSizeConstraint", "ConstraintsIntersection", "ConstraintsUnion")
trapSeverity, trapCounter = mibBuilder.importSymbols("CADANT-CMTS-EQUIPMENT-MIB", "trapSeverity", "trapCounter")
cadExperimental, = mibBuilder.importSymbols("CADANT-PRODUCTS-MIB", "cadExperimental")
InterfaceIndexOrZero, = mibBuilder.importSymbols("IF-MIB", "InterfaceIndexOrZero")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
Integer32, Unsigned32, MibScalar, MibTable, MibTableRow, MibTableColumn, ModuleIdentity, Counter64, iso, TimeTicks, Gauge32, ObjectIdentity, IpAddress, Bits, MibIdentifier, Counter32, NotificationType = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "Unsigned32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ModuleIdentity", "Counter64", "iso", "TimeTicks", "Gauge32", "ObjectIdentity", "IpAddress", "Bits", "MibIdentifier", "Counter32", "NotificationType")
TextualConvention, DisplayString, TruthValue = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString", "TruthValue")
cadExportImportMib = ModuleIdentity((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1))
cadExportImportMib.setRevisions(('2001-03-09 00:00', '2004-02-13 00:00', '2004-02-16 00:00',))
if mibBuilder.loadTexts: cadExportImportMib.setLastUpdated('200402160000Z')
if mibBuilder.loadTexts: cadExportImportMib.setOrganization('Arris International Inc.')
class ExportImportAction(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4))
namedValues = NamedValues(("noop", 0), ("export", 1), ("import", 2), ("pCmCertExport", 3), ("caCertExport", 4))
class ExportResult(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4, 5))
namedValues = NamedValues(("unknown", 0), ("success", 1), ("fileNameTooLong", 2), ("invalidCharactersInFilename", 3), ("fileSystemFull", 4), ("otherError", 5))
class ImportResult(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4))
namedValues = NamedValues(("unknown", 0), ("success", 1), ("fileNotFound", 2), ("fileDecodingError", 3), ("otherError", 4))
cadCmtsExportImportGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1))
cadCmtsExportImportFilename = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 1), DisplayString().clone('update:/export.txt')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cadCmtsExportImportFilename.setStatus('current')
cadCmtsExportImportAction = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 2), ExportImportAction().clone('noop')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cadCmtsExportImportAction.setStatus('current')
cadCmtsExportResult = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 3), ExportResult().clone('unknown')).setMaxAccess("readonly")
if mibBuilder.loadTexts: cadCmtsExportResult.setStatus('current')
cadCmtsImportResult = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 4), ImportResult().clone('unknown')).setMaxAccess("readonly")
if mibBuilder.loadTexts: cadCmtsImportResult.setStatus('current')
cadCmtsExportImportWithLineNums = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 5), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cadCmtsExportImportWithLineNums.setStatus('current')
cadCmtsExportImportWithDefaults = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 6), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cadCmtsExportImportWithDefaults.setStatus('current')
cadCmtsExportImportNested = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 7), TruthValue().clone('true')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cadCmtsExportImportNested.setStatus('current')
cadCmtsExportImportWithCertificates = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 8), TruthValue().clone('true')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cadCmtsExportImportWithCertificates.setStatus('current')
cadCmtsExportImportIfIndex = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 9), InterfaceIndexOrZero()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cadCmtsExportImportIfIndex.setStatus('current')
cadCmtsExportImportTraps = MibIdentifier((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 0))
cadCmtsExportNotification = NotificationType((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 0, 1)).setObjects(("CADANT-CMTS-EQUIPMENT-MIB", "trapCounter"), ("CADANT-CMTS-EQUIPMENT-MIB", "trapSeverity"), ("CADANT-CMTS-EXPORTIMPORT-MIB", "cadCmtsExportResult"))
if mibBuilder.loadTexts: cadCmtsExportNotification.setStatus('current')
cadCmtsImportNotification = NotificationType((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 0, 2)).setObjects(("CADANT-CMTS-EQUIPMENT-MIB", "trapCounter"), ("CADANT-CMTS-EQUIPMENT-MIB", "trapSeverity"), ("CADANT-CMTS-EXPORTIMPORT-MIB", "cadCmtsImportResult"))
if mibBuilder.loadTexts: cadCmtsImportNotification.setStatus('current')
mibBuilder.exportSymbols("CADANT-CMTS-EXPORTIMPORT-MIB", cadCmtsExportImportNested=cadCmtsExportImportNested, cadCmtsExportImportWithDefaults=cadCmtsExportImportWithDefaults, ImportResult=ImportResult, cadCmtsExportImportWithCertificates=cadCmtsExportImportWithCertificates, ExportResult=ExportResult, cadCmtsImportNotification=cadCmtsImportNotification, cadExportImportMib=cadExportImportMib, cadCmtsExportImportIfIndex=cadCmtsExportImportIfIndex, PYSNMP_MODULE_ID=cadExportImportMib, cadCmtsExportImportTraps=cadCmtsExportImportTraps, cadCmtsExportNotification=cadCmtsExportNotification, cadCmtsExportImportFilename=cadCmtsExportImportFilename, cadCmtsExportResult=cadCmtsExportResult, cadCmtsExportImportAction=cadCmtsExportImportAction, cadCmtsImportResult=cadCmtsImportResult, ExportImportAction=ExportImportAction, cadCmtsExportImportGroup=cadCmtsExportImportGroup, cadCmtsExportImportWithLineNums=cadCmtsExportImportWithLineNums)
|
class Problem:
"""
Given a string of different arrows designating to four directions.
Then we can rotate arrows so that they designate the same direction.
Example
"^^<>vvv" -> "^^^^^^^" -> 5 operations
"^^<>vvv" -> "vvvvvvv" -> 4 operations
"^^<>vvv" -> ">>>>>>>" -> 6 operations
Find the minimum number of operations that can rotate them into the same direction.
Hash Map
O(N)
O(1)
"""
def find_minimum_ope(self, s):
if not s:
raise Exception("Empty String")
d = {
"^": 0,
"<": 0,
"v": 0,
">": 0,
}
for ch in s:
if ch in d:
d[ch] += 1
else:
raise Exception("Invalid Character {}".format(ch))
return len(s) - max(d.values())
if __name__ == "__main__":
p = Problem()
s = "^^<>vvv"
print(p.find_minimum_ope(s))
|
#!/home/jepoy/anaconda3/bin/python
## at terminal which python
#simple fibonacci series
# the sum of two elements defines the next set
a, b = 0, 1
while b < 1000:
print(b, end = ' ', flush = True)
a, b = b, a + b
print() # line ending |
def create(type):
switcher = {
"L": LPiece(),
"O": OPiece(),
"I": IPiece(),
"J": JPiece(),
"S": SPiece(),
"T": TPiece(),
"Z": ZPiece()
}
return switcher.get(type.upper())
class Piece:
def __init__(self):
self._rotateIndex = 0
self._rotations = []
def turnLeft(self, times=1):
if self._rotateIndex > times-1:
self._rotateIndex -= times
return True
return False
def turnRight(self, times=1):
if self._rotateIndex < len(self._rotations) - times:
self._rotateIndex += times
return True
return False
def rotateCount(self):
return self._rotateIndex
def positions(self):
return self._rotations[self._rotateIndex]
def appendRotation(self, rotation):
self._rotations.append(rotation)
class LPiece(Piece):
def __init__(self):
Piece.__init__(self)
# rotations ordered by their rotation to the right
self._rotations.append([[2, 0], [0, 1], [1, 1], [2, 1]])
self._rotations.append([[1, 0], [1, 1], [1, 2], [2, 2]])
self._rotations.append([[0, 1], [1, 1], [2, 1], [0, 2]])
self._rotations.append([[0, 0], [1, 0], [1, 1], [1, 2]])
class OPiece(Piece):
def __init__(self):
Piece.__init__(self)
self._rotations.append([[0, 0], [1, 0], [0, 1], [1, 1]])
class IPiece(Piece):
def __init__(self):
Piece.__init__(self)
# rotations ordered by their rotation to the right
self._rotations.append([[0, 1], [1, 1], [2, 1], [3, 1]])
self._rotations.append([[2, 0], [2, 1], [2, 2], [2, 3]])
# self._rotations.append([[0, 2], [1, 2], [2, 2], [3, 2]])
# self._rotations.append([[1, 0], [1, 1], [1, 2], [1, 3]])
class JPiece(Piece):
def __init__(self):
Piece.__init__(self)
# rotations ordered by their rotation to the right
self._rotations.append([[0, 0], [0, 1], [1, 1], [2, 1]])
self._rotations.append([[1, 0], [2, 0], [1, 1], [1, 2]])
self._rotations.append([[0, 1], [1, 1], [2, 1], [2, 2]])
self._rotations.append([[1, 0], [1, 1], [0, 2], [1, 2]])
class SPiece(Piece):
def __init__(self):
Piece.__init__(self)
# rotations ordered by their rotation to the right
self._rotations.append([[1, 0], [2, 0], [0, 1], [1, 1]])
self._rotations.append([[1, 0], [1, 1], [2, 1], [2, 2]])
# self._rotations.append([[1, 1], [2, 1], [0, 2], [1, 2]])
# self._rotations.append([[0, 0], [0, 1], [1, 1], [1, 2]])
class TPiece(Piece):
def __init__(self):
Piece.__init__(self)
# rotations ordered by their rotation to the right
self._rotations.append([[1, 0], [0, 1], [1, 1], [2, 1]])
self._rotations.append([[1, 0], [1, 1], [2, 1], [1, 2]])
self._rotations.append([[0, 1], [1, 1], [2, 1], [1, 2]])
self._rotations.append([[1, 0], [0, 1], [1, 1], [1, 2]])
class ZPiece(Piece):
def __init__(self):
Piece.__init__(self)
self._rotations.append([[0, 0], [1, 0], [1, 1], [2, 1]])
self._rotations.append([[2, 0], [1, 1], [2, 1], [1, 2]])
# self._rotations.append([[0, 1], [1, 1], [1, 2], [2, 2]])
# self._rotations.append([[1, 0], [0, 1], [1, 1], [0, 2]])
|
class HelperBase:
def __init__(self, app):
self.app = app
def type(self, locator, text):
wd = self.app.wd
if text is not None:
wd.find_element_by_name(locator).click()
wd.find_element_by_name(locator).clear()
wd.find_element_by_name(locator).send_keys(text)
def is_valid(self):
wd = self.app.wd
try:
wd.current_url
return True
except:
return False |
#!/usr/bin/python3
print("Hello World")
x=4
y="ok,google"
z=[4,77,x,y]
print(y)
print(z)
print(x,y)
|
major = 1
minor = 0
micro = None
pre_release = ".alpha"
post_release = None
dev_release = None
__version__ = '{}'.format(major)
if minor is not None:
__version__ += '.{}'.format(minor)
if micro is not None:
__version__ += '.{}'.format(micro)
if pre_release is not None:
__version__ += '{}'.format(pre_release)
if post_release is not None:
__version__ += '.post{}'.format(post_release)
if dev_release is not None:
__version__ += '.dev{}'.format(dev_release)
|
#############################
#PROJECT : ENCODER-DECODER
#Language :English
#basic encode and decode
#Contact me on ;
#Telegram : Zafiyetsiz0
#Instagram : Zafiyetsiz
#Discord : Zafiyetsiz#4172
##############################
print("1-Encoder ; 2-Decoder")
choise=int(input("Please type the number of transaction you want :"))
print("-----------------------------------------------------------------------------")
if choise==1:
letters=("abcdefghijklmnopqrstuvwxyz")
print("key should be between 1-9999 and do not forget it ;")
key=int(input("Choose a number for your encode key:"))
text=input("Enter text for encode:")
x= len(letters)
encoded=" "
for i in text:
for ii in letters:
if i == ii:
number=letters.index(ii)
number += key
encoded +=letters[number % x]
print("Do not forget your key :", key )
print("Your encoded text :")
print(encoded)
elif choise==2:
letters=("abcdefghijklmnopqrstuvwxyz")
key=int(input("Choose a number for your decode key:"))
text=input("Enter text for decode:")
while key==key:
if key > 26:
key=key-26
print(key)
else:
break
print("--------------------------------------------------")
decoded_key = 26 - key
x= len(letters)
decoded=" "
for i in text:
for ii in letters:
if i == ii:
number=letters.index(ii)
number += decoded_key
decoded +=letters[number % x]
print("Your decoded text :")
print(decoded)
else:
print("ERROR : type 1 or 2")
|
def fib(a,b,n):
if(n==1):
return a
elif(n==2):
return b
else:
return fib(a,b,n-2)+fib(a,b,n-1)*fib(a,b,n-1)
r = input();
r = r.split(' ')
a = int(r[0])
b = int(r[1])
n = int(r[2])
print(fib(a,b,n)) |
#Actividad 2
a=1+2**-53
print(a)
b=a-1
print(b)
a=1+2**-52
print(a)
b=a-1 |
"""
DOBRO, TRIPLO E RAIZ QUADRADA
"""
n1 = int(input('Digite um número: '))
print('O dobro de {} é {} '.format(n1,n1*2))
print('O triplo de {} é {} '.format(n1,n1*3))
print('A raiz quadrada de {} é {:.2f} '.format(n1,pow(n1,(1/2))))
|
a = [{'001': '001', '002': '002'}]
print(a, type(a))
a = a.__str__()
print(a, type(a))
print(['------------------'])
init_list = [0 for n in range(10)]
init_list2 = [0] * 10
print(init_list)
print(init_list2)
# list - replace
a = ['110', '111', '112', '113']
for i in a:
print(i, a.index(i))
if i == '112':
id = a.index(i)
print(a[id])
i = i.replace('112', '000')
a[id] = '000'
print(a)
|
# Check whether the string is palindrome or not considering
# only Alpha-Numeric Characters ignoring cases
s = input();
t = ''.join([i.lower() if i.isalnum() else '' for i in s])
if t==''.join(reversed(t)): print("It is a Palindrome String")
else: print("It is not a Palindrome String")
|
# cannot be changed by user:
coinbaseReward = 5000000000 #50 bitcoins
halvingInterval = 150
maxOutputsPerTx = 1000
scalingUnits = .000001 # units of cap
confirmations = 6
onchainSatoshiMinimum = 100
maxTxPerBlock = 20 # 200 transactions in a block plus coinbase (which is at index 0)
iCoinbasePriv = 100000000 # some private key that is completely insecure. Doesn't matter what it is.
bCoinbasePriv = bytearray(iCoinbasePriv.to_bytes(32, "big"))
|
"""Formatter to extract the output files from a target."""
def format(target):
provider_map = providers(target)
if not provider_map:
return ""
outputs = dict()
# Try to resolve in order.
files_to_run = provider_map.get("FilesToRunProvider", None)
default_info = provider_map.get("DefaultInfo", None)
output_group_info = provider_map.get("OutputGroupInfo", None)
if files_to_run and files_to_run.executable:
outputs[files_to_run.executable.path] = True
elif default_info:
for x in default_info.files:
outputs[x.path] = True
elif output_group_info:
for entry in dir(output_group_info):
# Filter out all built-ins and anything that is not a depset.
if entry.startswith("_") or not hasattr(getattr(output_group_info, entry), "to_list"):
continue
for x in getattr(output_group_info, entry).to_list():
outputs[x.path] = True
# Return all found files.
return "\n".join(outputs.keys())
|
__all__ = [
'base_controller',
'basic_api_controller',
'advanced_api_controller',
'enterprise_only_controller',
]
|
"""
Definition of exceptions thrown by arrus functions.
"""
class ArrusError(Exception):
pass
class IllegalArgumentError(ArrusError, ValueError):
pass
class DeviceNotFoundError(ArrusError, ValueError):
pass
class IllegalStateError(ArrusError, RuntimeError):
pass
class TimeoutError(ArrusError, TimeoutError):
pass |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def convertBST(self, root: Optional[TreeNode]) -> Optional[TreeNode]:
prev = 0
def inorderTraversal(root):
nonlocal prev
if not root:
return
inorderTraversal(root.right)
root.val += prev
prev = root.val
inorderTraversal(root.left)
return
inorderTraversal(root)
return root |
all_boards = {
'sysop': 1,
'vote': 2,
'bbslists': 3,
'notepad': 6,
'Test': 7,
'Dance': 8,
'Board': 9,
'Wisdom': 10,
'Science': 12,
'Linux': 13,
'IBMThinkPad': 14,
'LifeScience': 15,
'BBShelp': 16,
'Mechanics': 17,
'Emprise': 18,
'Philosophy': 20,
'Literature': 21,
'Triangle': 22,
'GSM': 23,
'CS': 24,
'PKULibrary': 25,
'New_Board': 27,
'BoardManager': 28,
'Announce': 29,
'Urban': 31,
'History': 33,
'Girl': 34,
'Networking': 35,
'Love': 36,
'Friend': 37,
'Psychology': 38,
'CStrike': 39,
'Innovation': 40,
'AdvancedEdu': 41,
'Virus_Security': 42,
'CIS': 44,
'CPlusPlus': 45,
'VisualBasic': 46,
'Feeling': 47,
'Memory': 48,
'Game': 49,
'Story': 50,
'SMS': 51,
'Boy': 52,
'Reader': 53,
'Law': 54,
'Mentality': 55,
'EnglishWorld': 56,
'Physics': 57,
'Electronics': 59,
'Geophysics': 60,
'CCME': 61,
'Economics': 62,
'Chinese': 63,
'SFL': 64,
'Geology': 66,
'NSD': 67,
'SG': 69,
'Archaeology': 70,
'SecondHand': 71,
'Joke': 72,
'Banquet': 73,
'Blessing': 74,
'AoA': 75,
'Badminton': 77,
'MUD': 78,
'PopMusic': 79,
'Poems': 80,
'Astrology': 81,
'Movie': 83,
'Riddle': 84,
'Java': 87,
'Basketball': 88,
'Astronomy': 89,
'Food': 90,
'Football': 93,
'Travel': 94,
'CSArch': 95,
'TableTennis': 96,
'Single': 97,
'Job': 99,
'Traffic': 100,
'ForeignLit': 101,
'Water': 103,
'THU': 104,
'Biology': 105,
'post': 106,
'Collection': 107,
'Comic': 108,
'NKU': 109,
'Oversea': 114,
'Ecosociety': 115,
'WHU': 117,
'GIS': 124,
'ClassicalMusic': 125,
'Tennis': 126,
'ColorShow': 130,
'IM': 131,
'Windows': 133,
'Thesis': 134,
'Swimming': 136,
'Skate': 137,
'HSC': 138,
'IME': 140,
'Freshman': 141,
'cntest': 142,
'loveheart': 143,
'NJU': 147,
'ASCIIArt': 149,
'HappyLife': 150,
'PetsEden': 151,
'CCC': 152,
'PersonalCorpus': 154,
'SIS': 155,
'Baseball': 157,
'Anniversary': 162,
'StoneStory': 163,
'Arbitration': 164,
'LostFound': 165,
'DIY': 166,
'PieBridge': 167,
'Romance': 168,
'Graduation': 173,
'BNU': 174,
'Bioinformatics': 175,
'Melancholy': 176,
'Video_Game': 177,
'Beauty': 179,
'RUC': 180,
'Software': 181,
'CinemaArt': 182,
'JapanResearch': 184,
'Military': 185,
'PhotoView': 186,
'Art': 187,
'SL': 188,
'Kaoyan': 190,
'CESE': 192,
'CAPU': 193,
'Chimusic': 194,
'Relatives': 196,
'MobileDigital': 197,
'Homepage': 198,
'Billiards': 199,
'TV': 200,
'Marxism': 203,
'Detective': 204,
'Chorus': 205,
'PKUER': 207,
'NCU': 208,
'NetResources': 209,
'ScienceFiction': 210,
'RockMusic': 211,
'Automobile': 212,
'Collectors': 213,
'Drama': 214,
'GuitarPKU': 216,
'rules': 217,
'Fairytales': 218,
'Fitness': 219,
'Auditory': 222,
'PUMA': 224,
'RedCross': 226,
'Character': 227,
'House': 230,
'FormulaOneZone': 231,
'JLU': 235,
'Mathematics': 236,
'Orchestra': 237,
'Aviation': 238,
'sysreport': 241,
'Volunteers': 242,
'BDSJC': 243,
'Health': 244,
'SLP': 245,
'PKULeagueschool': 246,
'WeClub': 248,
'Stock': 249,
'Counterculture': 251,
'Courses': 252,
'StudentUnion': 253,
'HK_MC_TW': 254,
'SPS': 256,
'Harmonica': 258,
'PKUHighSchool': 260,
'Brush_Art': 262,
'SESS': 267,
'Piefriends': 270,
'Greenlife': 271,
'FantasyWorld': 272,
'cnAdmin': 273,
'TeacherStudent': 274,
'Radio': 275,
'PKUFA': 277,
'Philo': 278,
'Advertising': 281,
'dance_company': 283,
'SAPA': 288,
'STWT': 289,
'PKUdevelopment': 294,
'GSE': 295,
'Tea': 296,
'Shopping': 298,
'PCIA': 299,
'XinWenZX': 300,
'LAAPKU': 301,
'DigitalWorld': 304,
'Volleyball': 307,
'HipHop': 308,
'SANGUO': 309,
'losefat': 310,
'pkuveg': 311,
'Hardware': 312,
'WanLiu': 315,
'PKU_PE': 316,
'sunshine': 318,
'ACM_Algo': 320,
'PKUHistory': 321,
'EECS': 322,
'Leisure_Game': 323,
'ypjh': 325,
'SSM': 327,
'RelicFans': 328,
'HuXiangCulture': 330,
'HiFi': 331,
'PKUTV': 336,
'SST': 337,
'ID': 338,
'NUDT': 339,
'AcademicInfo': 342,
'PKUPA': 343,
'OriginalFire': 344,
'Chemistry': 345,
'MathTools': 346,
'Heroes': 350,
'CampusInfo': 351,
'BBSInfo': 352,
'MNWH': 353,
'TrendyLife': 354,
'Economiclovers': 355,
'DVDZone': 357,
'Renju': 359,
'diary': 361,
'Bridge': 362,
'jingwu': 364,
'lottery': 365,
'JNFQ': 366,
'PKUSZ': 367,
'Application': 368,
'Complain': 369,
'wine': 373,
'TryYourBest': 376,
'Ghost': 377,
'Yueju': 378,
'Music_box': 381,
'Meteo': 382,
'PCA': 384,
'CIO_Forum': 385,
'Green_hut': 387,
'RPKU': 389,
'XiangSheng': 390,
'Muthos': 391,
'PKUSIFEA': 393,
'NIE': 394,
'ITrade': 395,
'WellBeing': 396,
'cnBM': 397,
'OPETech': 398,
'WorldHeritage': 400,
'Communications': 401,
'WesternMusic': 403,
'KoreanSalon': 404,
'CR': 405,
'Englishwriting': 407,
'LuXunStudies': 409,
'PKUYND': 410,
'PKU_OSFA': 411,
'SecretGarden': 414,
'ParttimeJob': 419,
'NewAgemusic': 420,
'Life_Art': 422,
'ccdra': 423,
'Anthropology': 425,
'Herbalism': 426,
'TRA': 430,
'EduLDA': 431,
'PKU_Suggest': 438,
'WenYan': 439,
'ShanXi': 440,
'Pictures': 441,
'GuoXue': 442,
'leagueforum': 443,
'ADAgent': 444,
'ECCA': 445,
'PKU_Feedback': 446,
'PKU_Announce': 447,
'HuBei': 450,
'JiangSu': 451,
'cinemapku': 452,
'ShanDong': 453,
'XSKC': 454,
'Christianity': 455,
'ZheJiang': 457,
'BDQN': 458,
'JiangXi': 459,
'FuJian': 460,
'LiaoNing': 461,
'TianJin': 462,
'ChongQing': 463,
'SiChuan': 464,
'ShaanXi': 466,
'GanSu': 467,
'BeiJing': 468,
'GuangXi': 470,
'ShangHai': 472,
'JiLin': 473,
'HuNan': 474,
'HeBei': 475,
'AnHui': 476,
'HeNan': 477,
'HeiLongJiang': 478,
'Temporary_BM': 480,
'YunNan': 481,
'HaiNan': 482,
'Notebook': 484,
'ITP': 485,
'GuangDong': 486,
'FoxForum': 487,
'Apple': 488,
'News_Editing': 489,
'ADer': 490,
'PKU_ShiJia': 491,
'SpanishStudy': 492,
'PRCEH': 493,
'PE': 494,
'PKUMUN': 495,
'le_francais': 496,
'StarsOfBDWM': 498,
'Languages': 502,
'BJ_Culture': 503,
'XinJiang': 504,
'BaoYan': 507,
'LITnMovie': 509,
'Little_Game': 510,
'ROSS': 511,
'Politics': 513,
'DMM': 514,
'zhijiangforum': 515,
'LangSong': 517,
'Sports_Game': 519,
'SICA': 521,
'pku_129': 524,
'PKUdebate': 527,
'BeiDaZhiFeng': 528,
'KXTS': 529,
'Folklore': 531,
'GuiZhou': 532,
'WMweibo': 533,
'OMW': 534,
'JiaJiao': 535,
'XiZang': 536,
'Bible': 537,
'IIMA': 539,
'SPH': 540,
'ChineseEconomy': 543,
'PKU_Zen': 544,
'HCC': 545,
'Coffee': 546,
'Thanks': 547,
'DoItForYou': 548,
'YanQingbu': 551,
'GengDu': 553,
'Customs': 554,
'SysAid': 555,
'TrafficTicket': 557,
'Actuary': 559,
'OurEileen': 560,
'VisualBible': 562,
'Deutsch': 563,
'Assembly': 564,
'ARTLIFE': 565,
'SFAPU': 566,
'Biography': 568,
'Econometrics': 569,
'Karaoke': 572,
'ACDR': 573,
'SocialPsy': 575,
'IPDA': 577,
'PUDA': 578,
'PKU_EnNews': 579,
'Piano': 580,
'GuQin': 581,
'PKUBA': 584,
'ACJC': 585,
'JMusic': 587,
'JCP': 590,
'PKUQUYI': 591,
'OVTS': 592,
'ForzaMilan': 594,
'Tobacco': 596,
'LordOfTheRings': 598,
'Inter': 603,
'Arsenal': 605,
'Modern_China': 606,
'ExceptNA': 607,
'LiverpoolFC': 608,
'InnerMongolia': 610,
'HXYG': 611,
'Beyond': 613,
'PKU_OOF': 622,
'PKU_SAD': 624,
'PKU_SCC': 625,
'PKU_CE': 627,
'Xuanliu': 628,
'M_M': 629,
'RegionalEcon': 632,
'ArchUrban': 634,
'LSA': 635,
'YangTaiChi': 636,
'QuantumChem': 637,
'Managepsy': 638,
'ILSAPKU': 639,
'VBVC': 640,
'Model': 641,
'HLC': 642,
'IJC': 644,
'Warcraft': 646,
'Railway': 647,
'Conan': 648,
'Referees': 649,
'SUforum': 653,
'HongqiOnline': 654,
'SanJinCulture': 655,
'Aesthetics': 656,
'OBCase': 657,
'RealMadrid': 659,
'Admin4': 661,
'Admin6': 662,
'Admin5': 665,
'BackstreetBack': 667,
'PKU_CC': 668,
'MusicGame': 669,
'ichess': 670,
'AdminG': 672,
'FlightSim': 677,
'WinterSunshine': 689,
'MentalityEdu': 690,
'PKUYAFA': 692,
'Aikido': 693,
'SHE': 695,
'ShouYu': 696,
'Kindergarten': 697,
'WBIA': 698,
'EUS': 699,
'FCBarcelona': 701,
'CCEA': 702,
'ArchSciTech': 703,
'musical': 705,
'Juventus': 706,
'ECPM': 709,
'ManUtd': 710,
'YASP': 711,
'PingShu': 712,
'BayernMunchen': 715,
'PLATEAUDREAM': 716,
'MusicTheory': 717,
'CritiWriting': 718,
'CG': 719,
'Logic': 721,
'AnalChem': 722,
'JingKun': 723,
'BeautyMarket': 724,
'PAPU': 726,
'ArtHistory': 727,
'WMReview': 728,
'Greece_Rome': 730,
'Sorry': 731,
'Loveletter': 732,
'TWLiterature': 734,
'Broadcasting': 736,
'Stefanie': 737,
'Pingtan': 738,
'Admin9': 739,
'AdminABC': 740,
'xcdyb': 742,
'Chelsea': 743,
'MaJiang': 744,
'Admin1': 748,
'Admin2': 749,
'Admin3': 750,
'Admin7': 751,
'Admin8': 752,
'GSMRL': 754,
'FrancisNG': 757,
'EasonChan': 758,
'WOW': 759,
'Wakin': 763,
'pub': 764,
'JayChou': 765,
'UrgentMeet': 766,
'warner_class': 767,
'WisePark': 769,
'FYSN': 772,
'GCHEM': 774,
'Jeff': 775,
'SocialNetwork': 776,
'LeslieCheung': 777,
'PKURELA': 778,
'CMI': 781,
'lostangel': 783,
'LiangPin': 784,
'FinalFantasy': 785,
'AOE': 787,
'KangYong': 788,
'JunXun': 789,
'PKU_EF': 791,
'Admin5_Bar': 792,
'WizArdS': 795,
'zts': 797,
'DY': 799,
'HappyPavilion': 801,
'StarCraft': 803,
'FruitFruit': 804,
'CCYuan': 807,
'HSC_CFAN': 812,
'WAH': 814,
'Friends': 815,
'XiYuCulture': 817,
'Islam': 818,
'Argentina': 821,
'UnivUnion': 825,
'PKUFMU': 826,
'DalianFC': 833,
'ShowTicket': 834,
'PhysicsReview': 835,
'NationalFlagTeam': 836,
'SIEN': 837,
'Xianjian': 838,
'Holland': 839,
'FiveMillion': 840,
'FRIENDFAMILY': 841,
'Kendo': 842,
'Job_Post': 845,
'COE': 846,
'PKUPI': 849,
'PECSA': 852,
'SAS_PKU': 853,
'PKURobot': 856,
'grsxz': 857,
'BJ4HS': 858,
'GSMer_Club': 859,
'PGA': 860,
'FreeRunning': 861,
'WUXIE': 863,
'PMA': 864,
'BDXK': 868,
'Architecture': 870,
'PKU_OMusic': 871,
'Zhuangzi': 872,
'Novoland': 873,
'NumberPark': 875,
'sneaker': 876,
'HGC': 877,
'Hogwarts': 881,
'Dream': 884,
'GalacticHeroes': 885,
'BoC': 886,
'ManCity': 892,
'Intern': 896,
'Rio2016': 900,
'GameTheory': 901,
'phychem': 902,
'LifeEducation': 903,
'Adolescence': 904,
'Maze': 906,
'Italiano': 908,
'CAH': 909,
'cssm': 910,
'CPGP': 911,
'PKU_JuXing': 912,
'kzone': 913,
'SecondBook': 914,
'Guizhou_Culture': 915,
'NuclearTec': 916,
'JapaneseArt': 917,
'RCPER': 919,
'Marxist': 923,
'WangLian': 924,
'WMFund': 927,
'PKUTA': 930,
'standflower': 931,
'PKU_GRS': 933,
'MayDay': 941,
'Euro2016': 944,
'FayeWong': 947,
'DV': 948,
'LeeHom': 949,
'WallaceChung': 950,
'DigitalArt': 951,
'POA': 952,
'BuddhismCHN': 953,
'Olydreams': 956,
'TuanGou': 957,
'KillerGame': 958,
'code_report': 959,
'WorldLiterary': 960,
'AJCD': 961,
'GFJY': 962,
'IEEEPKU': 963,
'CCAC': 964,
'ASRA': 965,
'Opera': 969,
'AAIS': 971,
'Graduate': 972,
'PG_Club': 978,
'Zillionaire': 979,
'webgame': 985,
'AminiEden': 988,
'SLS': 989,
'PKU_VI': 990,
'War3Clan': 991,
'PKUZDS': 993,
'LSU': 995,
'ElecDIY': 996,
'LoveCatMeetU': 997,
'HELP': 998,
'FilmReview': 999,
'ADintro': 1000,
'Google': 1001,
'wenji': 1002,
'Neverland': 1004,
'AngelaChang': 1005,
'ShenaRingo': 1006,
'TECC': 1007,
'Indiapac': 1009,
'DMP': 1010,
'BDWMFinance': 1011,
'WMHXS': 1012,
'Mavis': 1013,
'HSCINFO': 1014,
'DMB': 1015,
'JaneZhang': 1017,
'BeiShe': 1019,
'CACA': 1020,
'YOGA': 1022,
'GXue': 1023,
'twxgx': 1026,
'PRA': 1027,
'FofArt': 1028,
'LSIA': 1029,
'SaintSeiya': 1034,
'YOCSEF_GS': 1038,
'DMA': 1039,
'BibiChou': 1040,
'ElvaHsiao': 1041,
'SkateBoarding': 1043,
'QingHai': 1045,
'NingXia': 1046,
'HKCA': 1047,
'ADA': 1048,
'HscAssn': 1050,
'Skiing': 1051,
'Shin': 1052,
'MengTingWei': 1053,
'Game_Factory': 1054,
'Admin9_Bar': 1055,
'Circuit': 1058,
'pkpk': 1059,
'ChineseCulture': 1061,
'ZongJiaoZheXue': 1062,
'CFH': 1063,
'Adonis': 1064,
'Admin7_Bar': 1066,
'DotA': 1067,
'HSJCE': 1069,
'Magic': 1070,
'DigitalMusic': 1071,
'Echo': 1072,
'BaiduClub': 1073,
'OldSoftware': 1074,
'PKU_HMT': 1075,
'PKU_OIR': 1076,
'AiYuanClub': 1077,
'AbnormalPSY': 1078,
'LogicCriThink': 1079,
'Admin6_Bla': 1080,
'Bourgeoisie': 1081,
'OcciMusic': 1084,
'ILCA': 1088,
'MANYATTA': 1090,
'XiYou': 1091,
'pkuwuxia': 1092,
'FishLeong': 1094,
'IMM': 1095,
}
|
class RequestSourceValidator(object):
REQUIRED_AUTHENTICATIONS = ["manager", "host"]
SUPPORTED_TRANSPORT_METHODS = ['vddk', 'ssh']
def __init__(self, request):
self._request = request
self._errors = []
def validate(self):
for auth in self.REQUIRED_AUTHENTICATIONS:
if auth not in self._request["source"]["authentication"]:
self._errors.append("Missing '%s' in request['source']['authentication']" % auth)
if "hostname" not in self._request["source"]["authentication"][auth]:
self._errors.append("Missing 'hostname' in request['source']['authentication']['%s']" % auth)
if self._request["source"]["transport_method"] not in self.SUPPORTED_TRANSPORT_METHODS:
self._errors.append("Transport method '%s' is not supported" % self._request["source"]["transport_method"])
getattr(self, '_validate_authentication_' + self._request["source"]["transport_method"])
return self._errors
def _validate_authentication_vddk(self):
if "username" not in self._request["source"]["authentication"]:
self._errors.append("Missing 'username' in request['source']['authentication']")
if "password" not in self._request["source"]["authentication"]:
self._errors.append("Missing 'password' in request['source']['authentication']")
def _validate_authentication_ssh(self):
if "username" not in self._request["source"]["authentication"]:
self._errors.append("Missing 'username' in request['source']['authentication']")
if "ssh_key" not in self._request["source"]["authentication"]:
self._errors.append("Missing 'ssh_key' in request['source']['authentication']")
|
#coding: utf-8
#Classe que define uma estação da simulação
class Estacao:
#Construtor da classe
def __init__(self, idEstacao):
#Atributo responsável por armazenar o identificador de uma estação
self.idEstacao = idEstacao
#Atributo responsável por armazenar o slot de transmissão correspondente de uma estação
self.slot = 1
#Atributo responsável por indicar se uma estação transmitiu seu quadro
self.transmitiu = 0
#Atributo responsável por indicar o número de colisões sucessivas de uma estação
self.nColisoes = 0
#Método que altera o valor do slot de uma estação
def setSlot(self, novoSlot):
self.slot = novoSlot
#Método que altera o valor da flag que indica se uma estação transmitiu
def setTransmitiu(self):
self.transmitiu = 1
#Método que retorna o identificador de uma estação
def getIdEstacao(self):
return self.idEstacao
#Método que retorna o respectivo slot de uma estação
def getSlot(self):
return self.slot
#Método que retorna a flag de transmissão de uma estação
def getTransmitiu(self):
return self.transmitiu
#Método que retorna o número de colisões sucessivas de uma estação
def getNColisoes(self):
return self.nColisoes
#Método que incrementa o número de colisões sucessivas de uma estação
def incrementaColisao(self):
self.nColisoes += 1
|
string = input()
result = []
for index in range(len(string)):
if string[index].isupper():
result.append(index)
print(result)
|
x = 10
if (x % 2) == 0 and (x % 5) == 0:
print(x)
A1 = "ostrich"
print('o' in A1)
print('r' not in A1)
|
class Solution:
def XXX(self, nums: List[int]) -> bool:
length = len(nums)
global tag
tag = False
def dfs(idx):
if idx == length - 1:
global tag
tag = True
return
if idx >= length or nums[idx] < 1:
return
for i in range(1, nums[idx] + 1):
dfs(idx + i)
return
dfs(0)
return tag
|
# https://www.youtube.com/watch?v=fFVZt-6sgyo
# broute force
def subarraySum(nums, k):
count = 0
for i in range(len(nums)):
sub_sum = 0
for j in range(i, len(nums)):
sub_sum += nums[j]
if sub_sum == k:
count += 1
return count
# sliding window, only applys to positive numbers(No zero) case
def subarray_sum(arr, k):
if k < arr[0]:
return 0
count, sub_sum = 0, 0
start, end = 0, 0
for end in range(start, len(arr)):
sub_sum += arr[end]
while sub_sum >= k:
if sub_sum == k:
count += 1
sub_sum -= arr[start]
start += 1
return count
# prefix sum + hashmap
def subarraySum(nums, k):
# prefix_sum count, by default we have
prefix_sum = {0 : 1}
sub_sum, count = 0, 0
for i in range(len(nums)):
sub_sum += nums[i]
diff = sub_sum - k
# check if the prefix sum exist the sum equals diff
count += prefix_sum.get(diff, 0)
# increase the count for the cur observed sum
prefix_sum[sub_sum] = 1 + prefix_sum.get(sub_sum, 0)
return count
nums=[0,1,2,3]
#nums=[1,-1,0]
#nums = [1,1,1]
print(subarray_sum(nums, 0))
|
def leer_archivo():
nombre = input("Nombre del archivo donde está el mapa: ")
f = open(nombre,"r")
lineas = f.readlines()
f.close()
mapa = []
for linea in lineas:
mapa.append([c for c in linea.rstrip()])
return mapa
def vecinos(mapa,i,j):
# entrega la lista de vecinos libres de la posición i,j en mapa
ancho = len(mapa[0])
alto = len(mapa)
V = [[-1,0],[1,0],[0,-1],[0,1]]
return [[i+x,j+y] for [x,y] in V if 0<=i+x<alto and 0<=j+y<ancho and mapa[i+x][j+y]==' ']
def pintar_desde(mapa,i,j,letra,limite):
# retorna un mapa en donde una region interior
# ha sido completamente pintada con letra
# y donde no se han usado más que limite letras para pintar
# de no tener exito, retorna una lista vacía
if mapa[i][j] != ' ':
return []
m = [list(linea) for linea in mapa]
cola = [[i,j]]
pintados = 0
while cola != []:
vecinos_sin_pintar = []
primero = cola.pop(0)
i = primero[0]
j = primero[1]
if m[i][j] != letra:
m[i][j] = letra
pintados += 1
if pintados > limite:
return []
for v in vecinos(m,i,j):
x = v[0] # x,y son las coordenadas del vecino
y = v[1]
if m[x][y] != letra:
cola.append([x,y])
if pintados <= limite:
return m
else:
return []
def pretty_print(mapa):
for linea in mapa:
print("".join(linea))
mapa=leer_archivo()
color = input("Con qué letra pinto? ")
limite = int(input("Cuantas letras tengo? "))
total=0
listo = False
i=0
while i < len(mapa) and not listo:
j=0
while j < len(mapa[0]) and not listo:
coloreado = pintar_desde(mapa,i,j,color,limite)
if coloreado != []:
pretty_print(coloreado)
listo = True
j+=1
i+=1
if not listo:
print("Es imposible pintar el mapa con el limite que me das :(")
|
# -*- coding: utf-8 -*-
'''
Management of Open vSwitch ports.
'''
def __virtual__():
'''
Only make these states available if Open vSwitch module is available.
'''
return 'openvswitch.port_add' in __salt__
def present(name, bridge):
'''
Ensures that the named port exists on bridge, eventually creates it.
Args:
name: The name of the port.
bridge: The name of the bridge.
'''
ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''}
bridge_exists = __salt__['openvswitch.bridge_exists'](bridge)
if bridge_exists:
port_list = __salt__['openvswitch.port_list'](bridge)
# Comment and change messages
comment_bridge_notexists = 'Bridge {0} does not exist.'.format(bridge)
comment_port_exists = 'Port {0} already exists.'.format(name)
comment_port_created = 'Port {0} created on bridge {1}.'.format(name, bridge)
comment_port_notcreated = 'Unable to create port {0} on bridge {1}.'.format(name, bridge)
changes_port_created = {name: {'old': 'No port named {0} present.'.format(name),
'new': 'Created port {1} on bridge {0}.'.format(bridge, name),
}
}
# Dry run, test=true mode
if __opts__['test']:
if bridge_exists:
if name in port_list:
ret['result'] = True
ret['comment'] = comment_port_exists
else:
ret['result'] = None
ret['comment'] = comment_port_created
ret['changes'] = changes_port_created
else:
ret['result'] = None
ret['comment'] = comment_bridge_notexists
return ret
if bridge_exists:
if name in port_list:
ret['result'] = True
ret['comment'] = comment_port_exists
else:
port_add = __salt__['openvswitch.port_add'](bridge, name)
if port_add:
ret['result'] = True
ret['comment'] = comment_port_created
ret['changes'] = changes_port_created
else:
ret['result'] = False
ret['comment'] = comment_port_notcreated
else:
ret['result'] = False
ret['comment'] = comment_bridge_notexists
return ret
def absent(name, bridge=None):
'''
Ensures that the named port exists on bridge, eventually deletes it.
If bridge is not set, port is removed from whatever bridge contains it.
Args:
name: The name of the port.
bridge: The name of the bridge.
'''
ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''}
if bridge:
bridge_exists = __salt__['openvswitch.bridge_exists'](bridge)
if bridge_exists:
port_list = __salt__['openvswitch.port_list'](bridge)
else:
port_list = ()
else:
port_list = [name]
# Comment and change messages
comment_bridge_notexists = 'Bridge {0} does not exist.'.format(bridge)
comment_port_notexists = 'Port {0} does not exist on bridge {1}.'.format(name, bridge)
comment_port_deleted = 'Port {0} deleted.'.format(name)
comment_port_notdeleted = 'Unable to delete port {0}.'.format(name)
changes_port_deleted = {name: {'old': 'Port named {0} may exist.'.format(name),
'new': 'Deleted port {0}.'.format(name),
}
}
# Dry run, test=true mode
if __opts__['test']:
if bridge and not bridge_exists:
ret['result'] = None
ret['comment'] = comment_bridge_notexists
elif name not in port_list:
ret['result'] = True
ret['comment'] = comment_port_notexists
else:
ret['result'] = None
ret['comment'] = comment_port_deleted
ret['changes'] = changes_port_deleted
return ret
if bridge and not bridge_exists:
ret['result'] = False
ret['comment'] = comment_bridge_notexists
elif name not in port_list:
ret['result'] = True
ret['comment'] = comment_port_notexists
else:
if bridge:
port_remove = __salt__['openvswitch.port_remove'](br=bridge, port=name)
else:
port_remove = __salt__['openvswitch.port_remove'](br=None, port=name)
if port_remove:
ret['result'] = True
ret['comment'] = comment_port_deleted
ret['changes'] = changes_port_deleted
else:
ret['result'] = False
ret['comment'] = comment_port_notdeleted
return ret
|
# Copyright 2014 Dave Kludt
#
# 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.
auth_return = {
'access': {
'token': {
'RAX-AUTH:authenticatedBy': [
'APIKEY'
],
'expires': '2015-06-23T12:44:18.758Z',
'id': '183e2f66535d4e03a04b2a91cf4a4f83',
'tenant': {
'id': '123456',
'name': '123456'
}
},
'serviceCatalog': [
{
'endpoints': [
{
'region': 'IAD',
'publicURL': (
'https://cdn5.clouddrive.com/'
'v1/MossoCloudFS_123456'
),
'tenantId': 'MossoCloudFS_123456'
}, {
'region': 'SYD',
'publicURL': (
'https://cdn4.clouddrive.com/v1/'
'MossoCloudFS_123456'
),
'tenantId': 'MossoCloudFS_123456'
}, {
'region': 'DFW',
'publicURL': (
'https://cdn1.clouddrive.com/v1/'
'MossoCloudFS_123456'
),
'tenantId': 'MossoCloudFS_123456'
}, {
'region': 'HKG',
'publicURL': (
'https://cdn6.clouddrive.com/v1/'
'MossoCloudFS_123456'
),
'tenantId': 'MossoCloudFS_123456'
}
],
'type': 'rax:object-cdn',
'name': 'cloudFilesCDN'
}, {
'endpoints': [
{
'region': 'IAD',
'publicURL': (
'https://storage101.iad3.clouddrive.com/v1'
'/MossoCloudFS_123456'
),
'internalURL': (
'https://snet-storage101.iad3.clouddrive.com/v1'
'/MossoCloudFS_123456'
),
'tenantId': 'MossoCloudFS_123456'
}, {
'region': 'SYD',
'publicURL': (
'https://storage101.syd2.clouddrive.com/v1'
'/MossoCloudFS_123456'
),
'internalURL': (
'https://snet-storage101.syd2.clouddrive.com/v1'
'/MossoCloudFS_123456'
),
'tenantId': 'MossoCloudFS_123456'
}, {
'region': 'DFW',
'publicURL': (
'https://storage101.dfw1.clouddrive.com/v1'
'/MossoCloudFS_123456'
),
'internalURL': (
'https://snet-storage101.dfw1.clouddrive.com/v1'
'/MossoCloudFS_123456'
),
'tenantId': 'MossoCloudFS_123456'
}, {
'region': 'HKG',
'publicURL': (
'https://storage101.hkg1.clouddrive.com/v1'
'/MossoCloudFS_123456'
),
'internalURL': (
'https://snet-storage101.hkg1.clouddrive.com/v1'
'/MossoCloudFS_123456'
),
'tenantId': 'MossoCloudFS_123456'
}
],
'type': 'object-store',
'name': 'cloudFiles'
}, {
'endpoints': [
{
'region': 'DFW',
'publicURL': (
'https://dfw.blockstorage.api.rackspacecloud.com/'
'v1/123456'
),
'tenantId': '123456'
}, {
'region': 'SYD',
'publicURL': (
'https://syd.blockstorage.api.rackspacecloud.com/'
'v1/123456'
),
'tenantId': '123456'
}, {
'region': 'IAD',
'publicURL': (
'https://iad.blockstorage.api.rackspacecloud.com/'
'v1/123456'
),
'tenantId': '123456'
}, {
'region': 'HKG',
'publicURL': (
'https://hkg.blockstorage.api.rackspacecloud.com/'
'v1/123456'
),
'tenantId': '123456'
}
],
'type': 'volume',
'name': 'cloudBlockStorage'
}, {
'endpoints': [
{
'region': 'IAD',
'publicURL': (
'https://iad.images.api.rackspacecloud.com/v2'
),
'tenantId': '123456'
}, {
'region': 'HKG',
'publicURL': (
'https://hkg.images.api.rackspacecloud.com/v2'
),
'tenantId': '123456'
}, {
'region': 'DFW',
'publicURL': (
'https://dfw.images.api.rackspacecloud.com/v2'
),
'tenantId': '123456'
}, {
'region': 'SYD',
'publicURL': (
'https://syd.images.api.rackspacecloud.com/v2'
),
'tenantId': '123456'
}
],
'type': 'image',
'name': 'cloudImages'
}, {
'endpoints': [
{
'region': 'HKG',
'publicURL': (
'https://hkg.queues.api.rackspacecloud.com/'
'v1/123456'
),
'internalURL': (
'https://snet-hkg.queues.api.rackspacecloud.com/'
'v1/123456'
),
'tenantId': '123456'
}, {
'region': 'SYD',
'publicURL': (
'https://syd.queues.api.rackspacecloud.com/'
'v1/123456'
),
'internalURL': (
'https://snet-syd.queues.api.rackspacecloud.com/'
'v1/123456'
),
'tenantId': '123456'
}, {
'region': 'DFW',
'publicURL': (
'https://dfw.queues.api.rackspacecloud.com/'
'v1/123456'
),
'internalURL': (
'https://snet-dfw.queues.api.rackspacecloud.com/'
'v1/123456'
),
'tenantId': '123456'
}, {
'region': 'IAD',
'publicURL': (
'https://iad.queues.api.rackspacecloud.com/'
'v1/123456'
),
'internalURL': (
'https://snet-iad.queues.api.rackspacecloud.com/'
'v1/123456'
),
'tenantId': '123456'
}
],
'type': 'rax:queues',
'name': 'cloudQueues'
}, {
'endpoints': [
{
'region': 'IAD',
'publicURL': (
'https://iad.bigdata.api.rackspacecloud.com/'
'v1.0/123456'
),
'tenantId': '123456'
}, {
'region': 'DFW',
'publicURL': (
'https://dfw.bigdata.api.rackspacecloud.com/'
'v1.0/123456'
),
'tenantId': '123456'
}
],
'type': 'rax:bigdata',
'name': 'cloudBigData'
}, {
'endpoints': [
{
'region': 'HKG',
'publicURL': (
'https://hkg.orchestration.api.rackspacecloud.com/'
'v1/123456'
),
'tenantId': '123456'
}, {
'region': 'DFW',
'publicURL': (
'https://dfw.orchestration.api.rackspacecloud.com/'
'v1/123456'
),
'tenantId': '123456'
}, {
'region': 'IAD',
'publicURL': (
'https://iad.orchestration.api.rackspacecloud.com/'
'v1/123456'
),
'tenantId': '123456'
}, {
'region': 'SYD',
'publicURL': (
'https://syd.orchestration.api.rackspacecloud.com/'
'v1/123456'
),
'tenantId': '123456'
}
],
'type': 'orchestration',
'name': 'cloudOrchestration'
}, {
'endpoints': [
{
'region': 'IAD',
'tenantId': '123456',
'versionId': '2',
'versionList': (
'https://iad.servers.api.rackspacecloud.com/'
),
'versionInfo': (
'https://iad.servers.api.rackspacecloud.com/v2'
),
'publicURL': (
'https://iad.servers.api.rackspacecloud.com/'
'v2/123456'
)
}, {
'region': 'DFW',
'tenantId': '123456',
'versionId': '2',
'versionList': (
'https://dfw.servers.api.rackspacecloud.com/'
),
'versionInfo': (
'https://dfw.servers.api.rackspacecloud.com/v2'
),
'publicURL': (
'https://dfw.servers.api.rackspacecloud.com/'
'v2/123456'
)
}, {
'region': 'SYD',
'tenantId': '123456',
'versionId': '2',
'versionList': (
'https://syd.servers.api.rackspacecloud.com/'
),
'versionInfo': (
'https://syd.servers.api.rackspacecloud.com/v2'
),
'publicURL': (
'https://syd.servers.api.rackspacecloud.com/'
'v2/123456'
)
}, {
'region': 'HKG',
'tenantId': '123456',
'versionId': '2',
'versionList': (
'https://hkg.servers.api.rackspacecloud.com/'
),
'versionInfo': (
'https://hkg.servers.api.rackspacecloud.com/v2'
),
'publicURL': (
'https://hkg.servers.api.rackspacecloud.com/'
'v2/123456'
)
}
],
'type': 'compute',
'name': 'cloudServersOpenStack'
}, {
'endpoints': [
{
'region': 'DFW',
'publicURL': (
'https://dfw.autoscale.api.rackspacecloud.com/'
'v1.0/123456'
),
'tenantId': '123456'
}, {
'region': 'HKG',
'publicURL': (
'https://hkg.autoscale.api.rackspacecloud.com/'
'v1.0/123456'
),
'tenantId': '123456'
}, {
'region': 'IAD',
'publicURL': (
'https://iad.autoscale.api.rackspacecloud.com/'
'v1.0/123456'
),
'tenantId': '123456'
}, {
'region': 'SYD',
'publicURL': (
'https://syd.autoscale.api.rackspacecloud.com/'
'v1.0/123456'
),
'tenantId': '123456'
}
],
'type': 'rax:autoscale',
'name': 'autoscale'
}, {
'endpoints': [
{
'region': 'DFW',
'publicURL': (
'https://dfw.databases.api.rackspacecloud.com/'
'v1.0/123456'
),
'tenantId': '123456'
}, {
'region': 'IAD',
'publicURL': (
'https://iad.databases.api.rackspacecloud.com/'
'v1.0/123456'
),
'tenantId': '123456'
}, {
'region': 'SYD',
'publicURL': (
'https://syd.databases.api.rackspacecloud.com/'
'v1.0/123456'
),
'tenantId': '123456'
}, {
'region': 'HKG',
'publicURL': (
'https://hkg.databases.api.rackspacecloud.com/'
'v1.0/123456'
),
'tenantId': '123456'
}
],
'type': 'rax:database',
'name': 'cloudDatabases'
}, {
'endpoints': [
{
'region': 'IAD',
'publicURL': (
'https://iad.backup.api.rackspacecloud.com/'
'v1.0/123456'
),
'tenantId': '123456'
}, {
'region': 'HKG',
'publicURL': (
'https://hkg.backup.api.rackspacecloud.com/'
'v1.0/123456'
),
'tenantId': '123456'
}, {
'region': 'SYD',
'publicURL': (
'https://syd.backup.api.rackspacecloud.com/'
'v1.0/123456'
),
'tenantId': '123456'
}, {
'region': 'DFW',
'publicURL': (
'https://dfw.backup.api.rackspacecloud.com/'
'v1.0/123456'
),
'tenantId': '123456'
}
],
'type': 'rax:backup',
'name': 'cloudBackup'
}, {
'endpoints': [
{
'region': 'IAD',
'publicURL': (
'https://iad.networks.api.rackspacecloud.com/v2.0'
),
'tenantId': '123456'
}, {
'region': 'SYD',
'publicURL': (
'https://syd.networks.api.rackspacecloud.com/v2.0'
),
'tenantId': '123456'
}, {
'region': 'DFW',
'publicURL': (
'https://dfw.networks.api.rackspacecloud.com/v2.0'
),
'tenantId': '123456'
}, {
'region': 'HKG',
'publicURL': (
'https://hkg.networks.api.rackspacecloud.com/v2.0'
),
'tenantId': '123456'
}
],
'type': 'network',
'name': 'cloudNetworks'
}, {
'endpoints': [
{
'region': 'IAD',
'publicURL': (
'https://iad.loadbalancers.api.rackspacecloud.com/'
'v1.0/123456'
),
'tenantId': '123456'
}, {
'region': 'HKG',
'publicURL': (
'https://hkg.loadbalancers.api.rackspacecloud.com/'
'v1.0/123456'
),
'tenantId': '123456'
}, {
'region': 'DFW',
'publicURL': (
'https://dfw.loadbalancers.api.rackspacecloud.com/'
'v1.0/123456'
),
'tenantId': '123456'
}, {
'region': 'SYD',
'publicURL': (
'https://syd.loadbalancers.api.rackspacecloud.com/'
'v1.0/123456'
),
'tenantId': '123456'
}
],
'type': 'rax:load-balancer',
'name': 'cloudLoadBalancers'
}, {
'endpoints': [
{
'region': 'IAD',
'publicURL': (
'https://global.metrics.api.rackspacecloud.com/'
'v2.0/123456'
),
'tenantId': '123456'
}
],
'type': 'rax:cloudmetrics',
'name': 'cloudMetrics'
}, {
'endpoints': [
{
'region': 'HKG',
'publicURL': (
'https://hkg.feeds.api.rackspacecloud.com/123456'
),
'internalURL': (
'https://atom.prod.hkg1.us.ci.rackspace.net/123456'
),
'tenantId': '123456'
}, {
'region': 'SYD',
'publicURL': (
'https://syd.feeds.api.rackspacecloud.com/123456'
),
'internalURL': (
'https://atom.prod.syd2.us.ci.rackspace.net/123456'
),
'tenantId': '123456'
}, {
'region': 'IAD',
'publicURL': (
'https://iad.feeds.api.rackspacecloud.com/123456'
),
'internalURL': (
'https://atom.prod.iad3.us.ci.rackspace.net/123456'
),
'tenantId': '123456'
}, {
'region': 'DFW',
'publicURL': (
'https://dfw.feeds.api.rackspacecloud.com/123456'
),
'internalURL': (
'https://atom.prod.dfw1.us.ci.rackspace.net/123456'
),
'tenantId': '123456'
}, {
'region': 'ORD',
'publicURL': (
'https://ord.feeds.api.rackspacecloud.com/123456'
),
'internalURL': (
'https://atom.prod.ord1.us.ci.rackspace.net/123456'
),
'tenantId': '123456'
}
],
'type': 'rax:feeds',
'name': 'cloudFeeds'
}, {
'endpoints': [
{
'region': 'DFW',
'publicURL': (
'https://sites.api.rackspacecloud.com/v1.0/123456'
),
'tenantId': '123456'
}
],
'type': 'rax:sites',
'name': 'cloudSites'
}, {
'endpoints': [
{
'publicURL': (
'https://monitoring.api.rackspacecloud.com/'
'v1.0/123456'
),
'tenantId': '123456'
}
],
'type': 'rax:monitor',
'name': 'cloudMonitoring'
}, {
'endpoints': [
{
'publicURL': (
'https://dns.api.rackspacecloud.com/v1.0/123456'
),
'tenantId': '123456'
}
],
'type': 'rax:dns',
'name': 'cloudDNS'
}, {
'endpoints': [
{
'region': 'DFW',
'publicURL': (
'https://global.cdn.api.rackspacecloud.com/'
'v1.0/123456'
),
'internalURL': (
'https://global.cdn.api.rackspacecloud.com/'
'v1.0/123456'
),
'tenantId': '123456'
}
],
'type': 'rax:cdn',
'name': 'rackCDN'
}
],
'user': {
'RAX-AUTH:defaultRegion': 'IAD',
'id': 'a432dbe77f5e4e20a88aaf1cab26c51b',
'roles': [
{
'description': (
'A Role that allows a user access'
' to keystone Service methods'
),
'id': '5',
'name': 'object-store:default',
'tenantId': 'MossoCloudFS_123456'
}, {
'description': (
'A Role that allows a user access'
' to keystone Service methods'
),
'id': '6',
'name': 'compute:default',
'tenantId': '123456'
}, {
'id': '3',
'name': 'identity:user-admin',
'description': 'User Admin Role.'
}
],
'name': 'rusty.shackelford'
}
}
}
|
'''P36 (**) Determine the prime factors of a given positive integer (2).
Construct a list containing the prime factors and their multiplicity.
Example:
* (prime-factors-mult 315)
((3 2) (5 1) (7 1))'''
base_divident=int(input('Enter number to find prime factors = '))
final_out=[]
original=base_divident #save the original divident,in case needed
#function to calculate prime factors
def prime(divident):
temp_out = [] #temporary list to save the current factor
for divisor in range(2, divident+1): #iterate till the given number
if divident % divisor ==0: #if remainder is zero,it is complete factor
quotient =divident//divisor #save the quotient and use it as the next number
temp_out.append(divisor) #save the number which devides the number as whole
divident=quotient #the quotient will be treated as next number
return divident,temp_out #return the quotient to be passes as new number and the divisor
while base_divident !=1: #till the divident number doesnt equal 1,run the process
base_divident,catch_out= prime(base_divident) #get the new divident(quotient) and the divisor and pass the quotuent as new number
final_out +=catch_out #add the divisor into output list
previous_element = final_out[0] #add the first element of the list to check
counter = 0 #take a variable counter to count instances of a factor
final=[] #final output list
for current_element in final_out: #iterate through list containing prime factors
if current_element == previous_element: #if current element of the list is equal to previously present
counter+=1 #increment the counter
else:
final.append([previous_element,counter]) #if not,then add the previous element and its count to final list
counter=1 #otherwise for non-repeated factor,set the counter to 1
previous_element= current_element #store current value into previous,so new current value will be checked
else:
final.append([previous_element,counter]) #add the last element and its count to final list
print(f'Prime factors of {original}= {final}') |
# This module contains a function to print Hello, World!
# Prints Hello, World!
def hello():
print("Hello, World!")
|
class Difference:
def __init__(self, a):
self.__elements = a
def computeDifference(self):
result = []
data_len = len(self.__elements)
for i in range(data_len):
for n in range(i, data_len):
if i == n:
continue
x = self.__elements[i]
y = self.__elements[n]
# calculate the absolute value and push it into resul
result.append(abs(x - y))
self.maximumDifference = max(result)
if __name__ == '__main__':
_ = input()
a = [int(e) for e in input().split(' ')]
d = Difference(a)
d.computeDifference()
print(d.maximumDifference) |
"""
The overridden attribute manager is a singleton that observes the scene to
react to attribute changes. If the attribute change is on an attribute
that is overridden by render setup, the attribute manager will attempt to
take the value change and reproduce it on the override itself.
This allows for convenient workflows like using direct manipulation on an
object with a value override, where the value is actually written back to
the override.
Apply value override nodes conditionally implement the passive output plug
behavior, through a chain of responsibility. A passive output allows
setting its destination input. If this destination input is connected to
an apply override node, the overridden attribute manager asks the
highest-priority apply override node to write the value to its
corresponding override, if it's enabled, else pass the request to the next
lower-priority apply override node. The chain ends by writing into the
original. If the highest-priority apply override node returns true from
isPassiveOutput(), this means that the overridden attribute write must
succeed, as one of the apply override nodes in the chain will accept the
write.
Autokey functionality is supported in this framework: in autokey mode, we
query the auto keyer to ask if an overridden attribute would be auto-keyed.
If so, we add the override attribute to the list of attributes the auto
keyer will add keys to. See the autoKey render setup module and the
autoKeyframe command for more information.
Note that it is understood that changing the override value will cause all
overridden attributes to change.
"""
class OverriddenAttributeManager(object):
"""
Observe and react to overridden attribute changes.
The overridden attribute manager attempts to convert changes to
overridden attributes to changes to overrides. See the module
documentation for more details.
The overridden attribute manager is only active when a render layer
other than the default (or master) layer is visible.
"""
def __init__(self):
pass
def aboutToDelete(self):
"""
Final clean up before the manager is destroyed.
"""
pass
def addAttributeChangeObservation(self):
"""
Start observing DG attribute changes.
"""
pass
def onAttributeChanged(self, msg, plg, otherPlug, clientData):
pass
def onRenderLayerChanged(self):
"""
Called after the visible render layer has been changed.
"""
pass
def removeAttributeChangeObservation(self):
"""
End observation of DG attribute changes.
"""
pass
def renderSetupAdded(self):
"""
Called just after the render setup node has been added.
"""
pass
def renderSetupPreDelete(self):
"""
Called just before the render setup node is deleted.
Unregisters from visible render layer and attribute change
observation.
"""
pass
__dict__ = None
__weakref__ = None
def isDefaultRenderLayerVisible():
pass
def initialize():
pass
def finalize():
pass
def instance():
pass
_instance = OverriddenAttributeManager()
|
class notifyException(Exception):
"""Base class for other exceptions."""
code: int = None
payload: str = None
def __init__(self, message: str = None, *args, code: int = None, payload: str = None, **kwargs):
super(notifyException, self).__init__(*args, **kwargs)
self.args = (
message,
code,
)
self.message = message
if code:
self.code = code
if payload:
self.payload = payload
def __str__(self):
return f"{__name__} -> {self.message}"
def get(self):
return self.message
class DataError(notifyException, ValueError):
"""An error caused by invalid query input."""
class NotSupported(notifyException):
"""Not Supported functionality."""
class ProviderError(notifyException):
"""Database Provider Error."""
class NotImplementedError(notifyException):
"""Exception for Not implementation."""
class UninitializedError(ProviderError):
"""Exception when provider cant be initialized."""
class ConnectionError(ProviderError):
"""Generic Connection Error."""
class ConnectionTimeout(ProviderError):
"""Connection Timeout Error."""
class TooManyConnections(ProviderError):
"""Too Many Connections."""
|
# https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii
class Solution:
def minMoves2(self, nums: List[int]) -> int:
nums = sorted(nums)
if len(nums) % 2 == 1:
mid = nums[len(nums) // 2]
else:
mid = (nums[len(nums) // 2] + nums[len(nums) // 2 - 1]) // 2
res = 0
for num in nums:
res += abs(num - mid)
return res
|
# encoding:utf-8
# AlgoPlus量化投资开源框架
# 微信公众号:AlgoPlus
# 官网:http://algo.plus
#///正常
ExchangeProperty_Normal = b'0'
#///根据成交生成报单
ExchangeProperty_GenOrderByTrade = b'1'
#///组织机构代码
IdCardType_EID = b'0'
#///中国公民身份证
IdCardType_IDCard = b'1'
#///军官证
IdCardType_OfficerIDCard = b'2'
#///警官证
IdCardType_PoliceIDCard = b'3'
#///士兵证
IdCardType_SoldierIDCard = b'4'
#///户口簿
IdCardType_HouseholdRegister = b'5'
#///护照
IdCardType_Passport = b'6'
#///台胞证
IdCardType_TaiwanCompatriotIDCard = b'7'
#///回乡证
IdCardType_HomeComingCard = b'8'
#///营业执照号
IdCardType_LicenseNo = b'9'
#///税务登记号/当地纳税ID
IdCardType_TaxNo = b'A'
#///港澳居民来往内地通行证
IdCardType_HMMainlandTravelPermit = b'B'
#///台湾居民来往大陆通行证
IdCardType_TwMainlandTravelPermit = b'C'
#///驾照
IdCardType_DrivingLicense = b'D'
#///当地社保ID
IdCardType_SocialID = b'F'
#///当地身份证
IdCardType_LocalID = b'G'
#///商业登记证
IdCardType_BusinessRegistration = b'H'
#///港澳永久性居民身份证
IdCardType_HKMCIDCard = b'I'
#///人行开户许可证
IdCardType_AccountsPermits = b'J'
#///外国人永久居留证
IdCardType_FrgPrmtRdCard = b'K'
#///资管产品备案函
IdCardType_CptMngPrdLetter = b'L'
#///其他证件
IdCardType_OtherCard = b'x'
#///所有
InvestorRange_All = b'1'
#///投资者组
InvestorRange_Group = b'2'
#///单一投资者
InvestorRange_Single = b'3'
#///所有
DepartmentRange_All = b'1'
#///组织架构
DepartmentRange_Group = b'2'
#///单一投资者
DepartmentRange_Single = b'3'
#///未同步
DataSyncStatus_Asynchronous = b'1'
#///同步中
DataSyncStatus_Synchronizing = b'2'
#///已同步
DataSyncStatus_Synchronized = b'3'
#///已同步
BrokerDataSyncStatus_Synchronized = b'1'
#///同步中
BrokerDataSyncStatus_Synchronizing = b'2'
#///没有任何连接
ExchangeConnectStatus_NoConnection = b'1'
#///已经发出合约查询请求
ExchangeConnectStatus_QryInstrumentSent = b'2'
#///已经获取信息
ExchangeConnectStatus_GotInformation = b'9'
#///没有任何连接
TraderConnectStatus_NotConnected = b'1'
#///已经连接
TraderConnectStatus_Connected = b'2'
#///已经发出合约查询请求
TraderConnectStatus_QryInstrumentSent = b'3'
#///订阅私有流
TraderConnectStatus_SubPrivateFlow = b'4'
#///数据异步化
FunctionCode_DataAsync = b'1'
#///强制用户登出
FunctionCode_ForceUserLogout = b'2'
#///变更管理用户口令
FunctionCode_UserPasswordUpdate = b'3'
#///变更经纪公司口令
FunctionCode_BrokerPasswordUpdate = b'4'
#///变更投资者口令
FunctionCode_InvestorPasswordUpdate = b'5'
#///报单插入
FunctionCode_OrderInsert = b'6'
#///报单操作
FunctionCode_OrderAction = b'7'
#///同步系统数据
FunctionCode_SyncSystemData = b'8'
#///同步经纪公司数据
FunctionCode_SyncBrokerData = b'9'
#///批量同步经纪公司数据
FunctionCode_BachSyncBrokerData = b'A'
#///超级查询
FunctionCode_SuperQuery = b'B'
#///预埋报单插入
FunctionCode_ParkedOrderInsert = b'C'
#///预埋报单操作
FunctionCode_ParkedOrderAction = b'D'
#///同步动态令牌
FunctionCode_SyncOTP = b'E'
#///删除未知单
FunctionCode_DeleteOrder = b'F'
#///强制用户登出
BrokerFunctionCode_ForceUserLogout = b'1'
#///变更用户口令
BrokerFunctionCode_UserPasswordUpdate = b'2'
#///同步经纪公司数据
BrokerFunctionCode_SyncBrokerData = b'3'
#///批量同步经纪公司数据
BrokerFunctionCode_BachSyncBrokerData = b'4'
#///报单插入
BrokerFunctionCode_OrderInsert = b'5'
#///报单操作
BrokerFunctionCode_OrderAction = b'6'
#///全部查询
BrokerFunctionCode_AllQuery = b'7'
#///系统功能:登入/登出/修改密码等
BrokerFunctionCode_log = b'a'
#///基本查询:查询基础数据,如合约,交易所等常量
BrokerFunctionCode_BaseQry = b'b'
#///交易查询:如查成交,委托
BrokerFunctionCode_TradeQry = b'c'
#///交易功能:报单,撤单
BrokerFunctionCode_Trade = b'd'
#///银期转账
BrokerFunctionCode_Virement = b'e'
#///风险监控
BrokerFunctionCode_Risk = b'f'
#///查询/管理:查询会话,踢人等
BrokerFunctionCode_Session = b'g'
#///风控通知控制
BrokerFunctionCode_RiskNoticeCtl = b'h'
#///风控通知发送
BrokerFunctionCode_RiskNotice = b'i'
#///察看经纪公司资金权限
BrokerFunctionCode_BrokerDeposit = b'j'
#///资金查询
BrokerFunctionCode_QueryFund = b'k'
#///报单查询
BrokerFunctionCode_QueryOrder = b'l'
#///成交查询
BrokerFunctionCode_QueryTrade = b'm'
#///持仓查询
BrokerFunctionCode_QueryPosition = b'n'
#///行情查询
BrokerFunctionCode_QueryMarketData = b'o'
#///用户事件查询
BrokerFunctionCode_QueryUserEvent = b'p'
#///风险通知查询
BrokerFunctionCode_QueryRiskNotify = b'q'
#///出入金查询
BrokerFunctionCode_QueryFundChange = b'r'
#///投资者信息查询
BrokerFunctionCode_QueryInvestor = b's'
#///交易编码查询
BrokerFunctionCode_QueryTradingCode = b't'
#///强平
BrokerFunctionCode_ForceClose = b'u'
#///压力测试
BrokerFunctionCode_PressTest = b'v'
#///权益反算
BrokerFunctionCode_RemainCalc = b'w'
#///净持仓保证金指标
BrokerFunctionCode_NetPositionInd = b'x'
#///风险预算
BrokerFunctionCode_RiskPredict = b'y'
#///数据导出
BrokerFunctionCode_DataExport = b'z'
#///风控指标设置
BrokerFunctionCode_RiskTargetSetup = b'A'
#///行情预警
BrokerFunctionCode_MarketDataWarn = b'B'
#///业务通知查询
BrokerFunctionCode_QryBizNotice = b'C'
#///业务通知模板设置
BrokerFunctionCode_CfgBizNotice = b'D'
#///同步动态令牌
BrokerFunctionCode_SyncOTP = b'E'
#///发送业务通知
BrokerFunctionCode_SendBizNotice = b'F'
#///风险级别标准设置
BrokerFunctionCode_CfgRiskLevelStd = b'G'
#///交易终端应急功能
BrokerFunctionCode_TbCommand = b'H'
#///删除未知单
BrokerFunctionCode_DeleteOrder = b'J'
#///预埋报单插入
BrokerFunctionCode_ParkedOrderInsert = b'K'
#///预埋报单操作
BrokerFunctionCode_ParkedOrderAction = b'L'
#///资金不够仍允许行权
BrokerFunctionCode_ExecOrderNoCheck = b'M'
#///指定
BrokerFunctionCode_Designate = b'N'
#///证券处置
BrokerFunctionCode_StockDisposal = b'O'
#///席位资金预警
BrokerFunctionCode_BrokerDepositWarn = b'Q'
#///备兑不足预警
BrokerFunctionCode_CoverWarn = b'S'
#///行权试算
BrokerFunctionCode_PreExecOrder = b'T'
#///行权交收风险
BrokerFunctionCode_ExecOrderRisk = b'P'
#///持仓限额预警
BrokerFunctionCode_PosiLimitWarn = b'U'
#///持仓限额查询
BrokerFunctionCode_QryPosiLimit = b'V'
#///银期签到签退
BrokerFunctionCode_FBSign = b'W'
#///银期签约解约
BrokerFunctionCode_FBAccount = b'X'
#///已经提交
OrderActionStatus_Submitted = b'a'
#///已经接受
OrderActionStatus_Accepted = b'b'
#///已经被拒绝
OrderActionStatus_Rejected = b'c'
#///全部成交
OrderStatus_AllTraded = b'0'
#///部分成交还在队列中
OrderStatus_PartTradedQueueing = b'1'
#///部分成交不在队列中
OrderStatus_PartTradedNotQueueing = b'2'
#///未成交还在队列中
OrderStatus_NoTradeQueueing = b'3'
#///未成交不在队列中
OrderStatus_NoTradeNotQueueing = b'4'
#///撤单
OrderStatus_Canceled = b'5'
#///未知
OrderStatus_Unknown = b'a'
#///尚未触发
OrderStatus_NotTouched = b'b'
#///已触发
OrderStatus_Touched = b'c'
#///已经提交
OrderSubmitStatus_InsertSubmitted = b'0'
#///撤单已经提交
OrderSubmitStatus_CancelSubmitted = b'1'
#///修改已经提交
OrderSubmitStatus_ModifySubmitted = b'2'
#///已经接受
OrderSubmitStatus_Accepted = b'3'
#///报单已经被拒绝
OrderSubmitStatus_InsertRejected = b'4'
#///撤单已经被拒绝
OrderSubmitStatus_CancelRejected = b'5'
#///改单已经被拒绝
OrderSubmitStatus_ModifyRejected = b'6'
#///今日持仓
PositionDate_Today = b'1'
#///历史持仓
PositionDate_History = b'2'
#///使用历史持仓
PositionDateType_UseHistory = b'1'
#///不使用历史持仓
PositionDateType_NoUseHistory = b'2'
#///代理
TradingRole_Broker = b'1'
#///自营
TradingRole_Host = b'2'
#///做市商
TradingRole_Maker = b'3'
#///期货
ProductClass_Futures = b'1'
#///期货期权
ProductClass_Options = b'2'
#///组合
ProductClass_Combination = b'3'
#///即期
ProductClass_Spot = b'4'
#///期转现
ProductClass_EFP = b'5'
#///现货期权
ProductClass_SpotOption = b'6'
#///未上市
InstLifePhase_NotStart = b'0'
#///上市
InstLifePhase_Started = b'1'
#///停牌
InstLifePhase_Pause = b'2'
#///到期
InstLifePhase_Expired = b'3'
#///买
Direction_Buy = b'0'
#///卖
Direction_Sell = b'1'
#///净持仓
PositionType_Net = b'1'
#///综合持仓
PositionType_Gross = b'2'
#///净
PosiDirection_Net = b'1'
#///多头
PosiDirection_Long = b'2'
#///空头
PosiDirection_Short = b'3'
#///不活跃
SysSettlementStatus_NonActive = b'1'
#///启动
SysSettlementStatus_Startup = b'2'
#///操作
SysSettlementStatus_Operating = b'3'
#///结算
SysSettlementStatus_Settlement = b'4'
#///结算完成
SysSettlementStatus_SettlementFinished = b'5'
#///交易费率
RatioAttr_Trade = b'0'
#///结算费率
RatioAttr_Settlement = b'1'
#///投机
HedgeFlag_Speculation = b'1'
#///套利
HedgeFlag_Arbitrage = b'2'
#///套保
HedgeFlag_Hedge = b'3'
#///做市商
HedgeFlag_MarketMaker = b'5'
#///第一腿投机第二腿套保 大商所专用
HedgeFlag_SpecHedge = b'6'
#///第一腿套保第二腿投机 大商所专用
HedgeFlag_HedgeSpec = b'7'
#///投机
BillHedgeFlag_Speculation = b'1'
#///套利
BillHedgeFlag_Arbitrage = b'2'
#///套保
BillHedgeFlag_Hedge = b'3'
#///投机
ClientIDType_Speculation = b'1'
#///套利
ClientIDType_Arbitrage = b'2'
#///套保
ClientIDType_Hedge = b'3'
#///做市商
ClientIDType_MarketMaker = b'5'
#///任意价
OrderPriceType_AnyPrice = b'1'
#///限价
OrderPriceType_LimitPrice = b'2'
#///最优价
OrderPriceType_BestPrice = b'3'
#///最新价
OrderPriceType_LastPrice = b'4'
#///最新价浮动上浮1个ticks
OrderPriceType_LastPricePlusOneTicks = b'5'
#///最新价浮动上浮2个ticks
OrderPriceType_LastPricePlusTwoTicks = b'6'
#///最新价浮动上浮3个ticks
OrderPriceType_LastPricePlusThreeTicks = b'7'
#///卖一价
OrderPriceType_AskPrice1 = b'8'
#///卖一价浮动上浮1个ticks
OrderPriceType_AskPrice1PlusOneTicks = b'9'
#///卖一价浮动上浮2个ticks
OrderPriceType_AskPrice1PlusTwoTicks = b'A'
#///卖一价浮动上浮3个ticks
OrderPriceType_AskPrice1PlusThreeTicks = b'B'
#///买一价
OrderPriceType_BidPrice1 = b'C'
#///买一价浮动上浮1个ticks
OrderPriceType_BidPrice1PlusOneTicks = b'D'
#///买一价浮动上浮2个ticks
OrderPriceType_BidPrice1PlusTwoTicks = b'E'
#///买一价浮动上浮3个ticks
OrderPriceType_BidPrice1PlusThreeTicks = b'F'
#///五档价
OrderPriceType_FiveLevelPrice = b'G'
#///开仓
OffsetFlag_Open = b'0'
#///平仓
OffsetFlag_Close = b'1'
#///强平
OffsetFlag_ForceClose = b'2'
#///平今
OffsetFlag_CloseToday = b'3'
#///平昨
OffsetFlag_CloseYesterday = b'4'
#///强减
OffsetFlag_ForceOff = b'5'
#///本地强平
OffsetFlag_LocalForceClose = b'6'
#///非强平
ForceCloseReason_NotForceClose = b'0'
#///资金不足
ForceCloseReason_LackDeposit = b'1'
#///客户超仓
ForceCloseReason_ClientOverPositionLimit = b'2'
#///会员超仓
ForceCloseReason_MemberOverPositionLimit = b'3'
#///持仓非整数倍
ForceCloseReason_NotMultiple = b'4'
#///违规
ForceCloseReason_Violation = b'5'
#///其它
ForceCloseReason_Other = b'6'
#///自然人临近交割
ForceCloseReason_PersonDeliv = b'7'
#///正常
OrderType_Normal = b'0'
#///报价衍生
OrderType_DeriveFromQuote = b'1'
#///组合衍生
OrderType_DeriveFromCombination = b'2'
#///组合报单
OrderType_Combination = b'3'
#///条件单
OrderType_ConditionalOrder = b'4'
#///互换单
OrderType_Swap = b'5'
#///大宗交易成交衍生
OrderType_DeriveFromBlockTrade = b'6'
#///期转现成交衍生
OrderType_DeriveFromEFPTrade = b'7'
#///立即完成,否则撤销
TimeCondition_IOC = b'1'
#///本节有效
TimeCondition_GFS = b'2'
#///当日有效
TimeCondition_GFD = b'3'
#///指定日期前有效
TimeCondition_GTD = b'4'
#///撤销前有效
TimeCondition_GTC = b'5'
#///集合竞价有效
TimeCondition_GFA = b'6'
#///任何数量
VolumeCondition_AV = b'1'
#///最小数量
VolumeCondition_MV = b'2'
#///全部数量
VolumeCondition_CV = b'3'
#///立即
ContingentCondition_Immediately = b'1'
#///止损
ContingentCondition_Touch = b'2'
#///止赢
ContingentCondition_TouchProfit = b'3'
#///预埋单
ContingentCondition_ParkedOrder = b'4'
#///最新价大于条件价
ContingentCondition_LastPriceGreaterThanStopPrice = b'5'
#///最新价大于等于条件价
ContingentCondition_LastPriceGreaterEqualStopPrice = b'6'
#///最新价小于条件价
ContingentCondition_LastPriceLesserThanStopPrice = b'7'
#///最新价小于等于条件价
ContingentCondition_LastPriceLesserEqualStopPrice = b'8'
#///卖一价大于条件价
ContingentCondition_AskPriceGreaterThanStopPrice = b'9'
#///卖一价大于等于条件价
ContingentCondition_AskPriceGreaterEqualStopPrice = b'A'
#///卖一价小于条件价
ContingentCondition_AskPriceLesserThanStopPrice = b'B'
#///卖一价小于等于条件价
ContingentCondition_AskPriceLesserEqualStopPrice = b'C'
#///买一价大于条件价
ContingentCondition_BidPriceGreaterThanStopPrice = b'D'
#///买一价大于等于条件价
ContingentCondition_BidPriceGreaterEqualStopPrice = b'E'
#///买一价小于条件价
ContingentCondition_BidPriceLesserThanStopPrice = b'F'
#///买一价小于等于条件价
ContingentCondition_BidPriceLesserEqualStopPrice = b'H'
#///删除
ActionFlag_Delete = b'0'
#///修改
ActionFlag_Modify = b'3'
#///可以交易
TradingRight_Allow = b'0'
#///只能平仓
TradingRight_CloseOnly = b'1'
#///不能交易
TradingRight_Forbidden = b'2'
#///来自参与者
OrderSource_Participant = b'0'
#///来自管理员
OrderSource_Administrator = b'1'
#///组合持仓拆分为单一持仓,初始化不应包含该类型的持仓
TradeType_SplitCombination = b'#'
#///普通成交
TradeType_Common = b'0'
#///期权执行
TradeType_OptionsExecution = b'1'
#///OTC成交
TradeType_OTC = b'2'
#///期转现衍生成交
TradeType_EFPDerived = b'3'
#///组合衍生成交
TradeType_CombinationDerived = b'4'
#///大宗交易成交
TradeType_BlockTrade = b'5'
#///前成交价
PriceSource_LastPrice = b'0'
#///买委托价
PriceSource_Buy = b'1'
#///卖委托价
PriceSource_Sell = b'2'
#///场外成交价
PriceSource_OTC = b'3'
#///开盘前
InstrumentStatus_BeforeTrading = b'0'
#///非交易
InstrumentStatus_NoTrading = b'1'
#///连续交易
InstrumentStatus_Continous = b'2'
#///集合竞价报单
InstrumentStatus_AuctionOrdering = b'3'
#///集合竞价价格平衡
InstrumentStatus_AuctionBalance = b'4'
#///集合竞价撮合
InstrumentStatus_AuctionMatch = b'5'
#///收盘
InstrumentStatus_Closed = b'6'
#///自动切换
InstStatusEnterReason_Automatic = b'1'
#///手动切换
InstStatusEnterReason_Manual = b'2'
#///熔断
InstStatusEnterReason_Fuse = b'3'
#///未上传
BatchStatus_NoUpload = b'1'
#///已上传
BatchStatus_Uploaded = b'2'
#///审核失败
BatchStatus_Failed = b'3'
#///按所有品种
ReturnStyle_All = b'1'
#///按品种
ReturnStyle_ByProduct = b'2'
#///按成交手数
ReturnPattern_ByVolume = b'1'
#///按留存手续费
ReturnPattern_ByFeeOnHand = b'2'
#///级别1
ReturnLevel_Level1 = b'1'
#///级别2
ReturnLevel_Level2 = b'2'
#///级别3
ReturnLevel_Level3 = b'3'
#///级别4
ReturnLevel_Level4 = b'4'
#///级别5
ReturnLevel_Level5 = b'5'
#///级别6
ReturnLevel_Level6 = b'6'
#///级别7
ReturnLevel_Level7 = b'7'
#///级别8
ReturnLevel_Level8 = b'8'
#///级别9
ReturnLevel_Level9 = b'9'
#///分阶段返还
ReturnStandard_ByPeriod = b'1'
#///按某一标准
ReturnStandard_ByStandard = b'2'
#///质出
MortgageType_Out = b'0'
#///质入
MortgageType_In = b'1'
#///质押比例
InvestorSettlementParamID_MortgageRatio = b'4'
#///保证金算法
InvestorSettlementParamID_MarginWay = b'5'
#///结算单结存是否包含质押
InvestorSettlementParamID_BillDeposit = b'9'
#///质押比例
ExchangeSettlementParamID_MortgageRatio = b'1'
#///分项资金导入项
ExchangeSettlementParamID_OtherFundItem = b'2'
#///分项资金入交易所出入金
ExchangeSettlementParamID_OtherFundImport = b'3'
#///中金所开户最低可用金额
ExchangeSettlementParamID_CFFEXMinPrepa = b'6'
#///郑商所结算方式
ExchangeSettlementParamID_CZCESettlementType = b'7'
#///交易所交割手续费收取方式
ExchangeSettlementParamID_ExchDelivFeeMode = b'9'
#///投资者交割手续费收取方式
ExchangeSettlementParamID_DelivFeeMode = b'0'
#///郑商所组合持仓保证金收取方式
ExchangeSettlementParamID_CZCEComMarginType = b'A'
#///大商所套利保证金是否优惠
ExchangeSettlementParamID_DceComMarginType = b'B'
#///虚值期权保证金优惠比率
ExchangeSettlementParamID_OptOutDisCountRate = b'a'
#///最低保障系数
ExchangeSettlementParamID_OptMiniGuarantee = b'b'
#///投资者代码最小长度
SystemParamID_InvestorIDMinLength = b'1'
#///投资者帐号代码最小长度
SystemParamID_AccountIDMinLength = b'2'
#///投资者开户默认登录权限
SystemParamID_UserRightLogon = b'3'
#///投资者交易结算单成交汇总方式
SystemParamID_SettlementBillTrade = b'4'
#///统一开户更新交易编码方式
SystemParamID_TradingCode = b'5'
#///结算是否判断存在未复核的出入金和分项资金
SystemParamID_CheckFund = b'6'
#///是否启用手续费模板数据权限
SystemParamID_CommModelRight = b'7'
#///是否启用保证金率模板数据权限
SystemParamID_MarginModelRight = b'9'
#///是否规范用户才能激活
SystemParamID_IsStandardActive = b'8'
#///上传的交易所结算文件路径
SystemParamID_UploadSettlementFile = b'U'
#///上报保证金监控中心文件路径
SystemParamID_DownloadCSRCFile = b'D'
#///生成的结算单文件路径
SystemParamID_SettlementBillFile = b'S'
#///证监会文件标识
SystemParamID_CSRCOthersFile = b'C'
#///投资者照片路径
SystemParamID_InvestorPhoto = b'P'
#///全结经纪公司上传文件路径
SystemParamID_CSRCData = b'R'
#///开户密码录入方式
SystemParamID_InvestorPwdModel = b'I'
#///投资者中金所结算文件下载路径
SystemParamID_CFFEXInvestorSettleFile = b'F'
#///投资者代码编码方式
SystemParamID_InvestorIDType = b'a'
#///休眠户最高权益
SystemParamID_FreezeMaxReMain = b'r'
#///手续费相关操作实时上场开关
SystemParamID_IsSync = b'A'
#///解除开仓权限限制
SystemParamID_RelieveOpenLimit = b'O'
#///是否规范用户才能休眠
SystemParamID_IsStandardFreeze = b'X'
#///郑商所是否开放所有品种套保交易
SystemParamID_CZCENormalProductHedge = b'B'
#///系统加密算法
TradeParamID_EncryptionStandard = b'E'
#///系统风险算法
TradeParamID_RiskMode = b'R'
#///系统风险算法是否全局 0-否 1-是
TradeParamID_RiskModeGlobal = b'G'
#///密码加密算法
TradeParamID_modeEncode = b'P'
#///价格小数位数参数
TradeParamID_tickMode = b'T'
#///用户最大会话数
TradeParamID_SingleUserSessionMaxNum = b'S'
#///最大连续登录失败数
TradeParamID_LoginFailMaxNum = b'L'
#///是否强制认证
TradeParamID_IsAuthForce = b'A'
#///是否冻结证券持仓
TradeParamID_IsPosiFreeze = b'F'
#///是否限仓
TradeParamID_IsPosiLimit = b'M'
#///郑商所询价时间间隔
TradeParamID_ForQuoteTimeInterval = b'Q'
#///是否期货限仓
TradeParamID_IsFuturePosiLimit = b'B'
#///是否期货下单频率限制
TradeParamID_IsFutureOrderFreq = b'C'
#///行权冻结是否计算盈利
TradeParamID_IsExecOrderProfit = b'H'
#///银期开户是否验证开户银行卡号是否是预留银行账户
TradeParamID_IsCheckBankAcc = b'I'
#///弱密码最后修改日期
TradeParamID_PasswordDeadLine = b'J'
#///强密码校验
TradeParamID_IsStrongPassword = b'K'
#///自有资金质押比
TradeParamID_BalanceMorgage = b'a'
#///最小密码长度
TradeParamID_MinPwdLen = b'O'
#///IP当日最大登陆失败次数
TradeParamID_LoginFailMaxNumForIP = b'U'
#///密码有效期
TradeParamID_PasswordPeriod = b'V'
#///资金数据
FileID_SettlementFund = b'F'
#///成交数据
FileID_Trade = b'T'
#///投资者持仓数据
FileID_InvestorPosition = b'P'
#///投资者分项资金数据
FileID_SubEntryFund = b'O'
#///组合持仓数据
FileID_CZCECombinationPos = b'C'
#///上报保证金监控中心数据
FileID_CSRCData = b'R'
#///郑商所平仓了结数据
FileID_CZCEClose = b'L'
#///郑商所非平仓了结数据
FileID_CZCENoClose = b'N'
#///持仓明细数据
FileID_PositionDtl = b'D'
#///期权执行文件
FileID_OptionStrike = b'S'
#///结算价比对文件
FileID_SettlementPriceComparison = b'M'
#///上期所非持仓变动明细
FileID_NonTradePosChange = b'B'
#///结算
FileType_Settlement = b'0'
#///核对
FileType_Check = b'1'
#///文本文件(.txt)
FileFormat_Txt = b'0'
#///压缩文件(.zip)
FileFormat_Zip = b'1'
#///DBF文件(.dbf)
FileFormat_DBF = b'2'
#///上传成功
FileUploadStatus_SucceedUpload = b'1'
#///上传失败
FileUploadStatus_FailedUpload = b'2'
#///导入成功
FileUploadStatus_SucceedLoad = b'3'
#///导入部分成功
FileUploadStatus_PartSucceedLoad = b'4'
#///导入失败
FileUploadStatus_FailedLoad = b'5'
#///移出
TransferDirection_Out = b'0'
#///移入
TransferDirection_In = b'1'
#///没有特殊创建规则
SpecialCreateRule_NoSpecialRule = b'0'
#///不包含春节
SpecialCreateRule_NoSpringFestival = b'1'
#///上一合约结算价
BasisPriceType_LastSettlement = b'1'
#///上一合约收盘价
BasisPriceType_LaseClose = b'2'
#///活跃
ProductLifePhase_Active = b'1'
#///不活跃
ProductLifePhase_NonActive = b'2'
#///注销
ProductLifePhase_Canceled = b'3'
#///现金交割
DeliveryMode_CashDeliv = b'1'
#///实物交割
DeliveryMode_CommodityDeliv = b'2'
#///出入金
FundIOType_FundIO = b'1'
#///银期转帐
FundIOType_Transfer = b'2'
#///银期换汇
FundIOType_SwapCurrency = b'3'
#///银行存款
FundType_Deposite = b'1'
#///分项资金
FundType_ItemFund = b'2'
#///公司调整
FundType_Company = b'3'
#///资金内转
FundType_InnerTransfer = b'4'
#///入金
FundDirection_In = b'1'
#///出金
FundDirection_Out = b'2'
#///已录入
FundStatus_Record = b'1'
#///已复核
FundStatus_Check = b'2'
#///已冲销
FundStatus_Charge = b'3'
#///未发布
PublishStatus_None = b'1'
#///正在发布
PublishStatus_Publishing = b'2'
#///已发布
PublishStatus_Published = b'3'
#///不活跃
SystemStatus_NonActive = b'1'
#///启动
SystemStatus_Startup = b'2'
#///交易开始初始化
SystemStatus_Initialize = b'3'
#///交易完成初始化
SystemStatus_Initialized = b'4'
#///收市开始
SystemStatus_Close = b'5'
#///收市完成
SystemStatus_Closed = b'6'
#///结算
SystemStatus_Settlement = b'7'
#///初始
SettlementStatus_Initialize = b'0'
#///结算中
SettlementStatus_Settlementing = b'1'
#///已结算
SettlementStatus_Settlemented = b'2'
#///结算完成
SettlementStatus_Finished = b'3'
#///自然人
InvestorType_Person = b'0'
#///法人
InvestorType_Company = b'1'
#///投资基金
InvestorType_Fund = b'2'
#///特殊法人
InvestorType_SpecialOrgan = b'3'
#///资管户
InvestorType_Asset = b'4'
#///交易会员
BrokerType_Trade = b'0'
#///交易结算会员
BrokerType_TradeSettle = b'1'
#///低风险客户
RiskLevel_Low = b'1'
#///普通客户
RiskLevel_Normal = b'2'
#///关注客户
RiskLevel_Focus = b'3'
#///风险客户
RiskLevel_Risk = b'4'
#///按交易收取
FeeAcceptStyle_ByTrade = b'1'
#///按交割收取
FeeAcceptStyle_ByDeliv = b'2'
#///不收
FeeAcceptStyle_None = b'3'
#///按指定手续费收取
FeeAcceptStyle_FixFee = b'4'
#///交易密码
PasswordType_Trade = b'1'
#///资金密码
PasswordType_Account = b'2'
#///浮盈浮亏都计算
Algorithm_All = b'1'
#///浮盈不计,浮亏计
Algorithm_OnlyLost = b'2'
#///浮盈计,浮亏不计
Algorithm_OnlyGain = b'3'
#///浮盈浮亏都不计算
Algorithm_None = b'4'
#///包含平仓盈利
IncludeCloseProfit_Include = b'0'
#///不包含平仓盈利
IncludeCloseProfit_NotInclude = b'2'
#///无仓无成交不受可提比例限制
AllWithoutTrade_Enable = b'0'
#///受可提比例限制
AllWithoutTrade_Disable = b'2'
#///无仓不受可提比例限制
AllWithoutTrade_NoHoldEnable = b'3'
#///不核对
FuturePwdFlag_UnCheck = b'0'
#///核对
FuturePwdFlag_Check = b'1'
#///银行转期货
TransferType_BankToFuture = b'0'
#///期货转银行
TransferType_FutureToBank = b'1'
#///无效或失败
TransferValidFlag_Invalid = b'0'
#///有效
TransferValidFlag_Valid = b'1'
#///冲正
TransferValidFlag_Reverse = b'2'
#///错单
Reason_CD = b'0'
#///资金在途
Reason_ZT = b'1'
#///其它
Reason_QT = b'2'
#///未知
Sex_None = b'0'
#///男
Sex_Man = b'1'
#///女
Sex_Woman = b'2'
#///投资者
UserType_Investor = b'0'
#///操作员
UserType_Operator = b'1'
#///管理员
UserType_SuperUser = b'2'
#///保证金率
RateType_MarginRate = b'2'
#///交易结算单
NoteType_TradeSettleBill = b'1'
#///交易结算月报
NoteType_TradeSettleMonth = b'2'
#///追加保证金通知书
NoteType_CallMarginNotes = b'3'
#///强行平仓通知书
NoteType_ForceCloseNotes = b'4'
#///成交通知书
NoteType_TradeNotes = b'5'
#///交割通知书
NoteType_DelivNotes = b'6'
#///逐日盯市
SettlementStyle_Day = b'1'
#///逐笔对冲
SettlementStyle_Volume = b'2'
#///日报
SettlementBillType_Day = b'0'
#///月报
SettlementBillType_Month = b'1'
#///登录
UserRightType_Logon = b'1'
#///银期转帐
UserRightType_Transfer = b'2'
#///邮寄结算单
UserRightType_EMail = b'3'
#///传真结算单
UserRightType_Fax = b'4'
#///条件单
UserRightType_ConditionOrder = b'5'
#///昨结算价
MarginPriceType_PreSettlementPrice = b'1'
#///最新价
MarginPriceType_SettlementPrice = b'2'
#///成交均价
MarginPriceType_AveragePrice = b'3'
#///开仓价
MarginPriceType_OpenPrice = b'4'
#///未生成
BillGenStatus_None = b'0'
#///生成中
BillGenStatus_NoGenerated = b'1'
#///已生成
BillGenStatus_Generated = b'2'
#///持仓处理算法
AlgoType_HandlePositionAlgo = b'1'
#///寻找保证金率算法
AlgoType_FindMarginRateAlgo = b'2'
#///基本
HandlePositionAlgoID_Base = b'1'
#///大连商品交易所
HandlePositionAlgoID_DCE = b'2'
#///郑州商品交易所
HandlePositionAlgoID_CZCE = b'3'
#///基本
FindMarginRateAlgoID_Base = b'1'
#///大连商品交易所
FindMarginRateAlgoID_DCE = b'2'
#///郑州商品交易所
FindMarginRateAlgoID_CZCE = b'3'
#///基本
HandleTradingAccountAlgoID_Base = b'1'
#///大连商品交易所
HandleTradingAccountAlgoID_DCE = b'2'
#///郑州商品交易所
HandleTradingAccountAlgoID_CZCE = b'3'
#///指定下单人
PersonType_Order = b'1'
#///开户授权人
PersonType_Open = b'2'
#///资金调拨人
PersonType_Fund = b'3'
#///结算单确认人
PersonType_Settlement = b'4'
#///法人
PersonType_Company = b'5'
#///法人代表
PersonType_Corporation = b'6'
#///投资者联系人
PersonType_LinkMan = b'7'
#///分户管理资产负责人
PersonType_Ledger = b'8'
#///托(保)管人
PersonType_Trustee = b'9'
#///托(保)管机构法人代表
PersonType_TrusteeCorporation = b'A'
#///托(保)管机构开户授权人
PersonType_TrusteeOpen = b'B'
#///托(保)管机构联系人
PersonType_TrusteeContact = b'C'
#///境外自然人参考证件
PersonType_ForeignerRefer = b'D'
#///法人代表参考证件
PersonType_CorporationRefer = b'E'
#///所有
QueryInvestorRange_All = b'1'
#///查询分类
QueryInvestorRange_Group = b'2'
#///单一投资者
QueryInvestorRange_Single = b'3'
#///正常
InvestorRiskStatus_Normal = b'1'
#///警告
InvestorRiskStatus_Warn = b'2'
#///追保
InvestorRiskStatus_Call = b'3'
#///强平
InvestorRiskStatus_Force = b'4'
#///异常
InvestorRiskStatus_Exception = b'5'
#///登录
UserEventType_Login = b'1'
#///登出
UserEventType_Logout = b'2'
#///交易成功
UserEventType_Trading = b'3'
#///交易失败
UserEventType_TradingError = b'4'
#///修改密码
UserEventType_UpdatePassword = b'5'
#///客户端认证
UserEventType_Authenticate = b'6'
#///其他
UserEventType_Other = b'9'
#///先开先平
CloseStyle_Close = b'0'
#///先平今再平昨
CloseStyle_CloseToday = b'1'
#///----
StatMode_Non = b'0'
#///按合约统计
StatMode_Instrument = b'1'
#///按产品统计
StatMode_Product = b'2'
#///按投资者统计
StatMode_Investor = b'3'
#///未发送
ParkedOrderStatus_NotSend = b'1'
#///已发送
ParkedOrderStatus_Send = b'2'
#///已删除
ParkedOrderStatus_Deleted = b'3'
#///正在处理
VirDealStatus_Dealing = b'1'
#///处理成功
VirDealStatus_DeaclSucceed = b'2'
#///综合交易平台
OrgSystemID_Standard = b'0'
#///易盛系统
OrgSystemID_ESunny = b'1'
#///金仕达V6系统
OrgSystemID_KingStarV6 = b'2'
#///正常处理中
VirTradeStatus_NaturalDeal = b'0'
#///成功结束
VirTradeStatus_SucceedEnd = b'1'
#///失败结束
VirTradeStatus_FailedEND = b'2'
#///异常中
VirTradeStatus_Exception = b'3'
#///已人工异常处理
VirTradeStatus_ManualDeal = b'4'
#///通讯异常 ,请人工处理
VirTradeStatus_MesException = b'5'
#///系统出错,请人工处理
VirTradeStatus_SysException = b'6'
#///存折
VirBankAccType_BankBook = b'1'
#///储蓄卡
VirBankAccType_BankCard = b'2'
#///信用卡
VirBankAccType_CreditCard = b'3'
#///正常
VirementStatus_Natural = b'0'
#///销户
VirementStatus_Canceled = b'9'
#///未确认
VirementAvailAbility_NoAvailAbility = b'0'
#///有效
VirementAvailAbility_AvailAbility = b'1'
#///冲正
VirementAvailAbility_Repeal = b'2'
#///银行发起银行资金转期货
VirementTradeCode_BankBankToFuture = b'102001'
#///银行发起期货资金转银行
VirementTradeCode_BankFutureToBank = b'102002'
#///期货发起银行资金转期货
VirementTradeCode_FutureBankToFuture = b'202001'
#///期货发起期货资金转银行
VirementTradeCode_FutureFutureToBank = b'202002'
#///程序生成
AMLGenStatus_Program = b'0'
#///人工生成
AMLGenStatus_HandWork = b'1'
#///主动请求更新
CFMMCKeyKind_REQUEST = b'R'
#///CFMMC自动更新
CFMMCKeyKind_AUTO = b'A'
#///CFMMC手动更新
CFMMCKeyKind_MANUAL = b'M'
#///身份证
CertificationType_IDCard = b'0'
#///护照
CertificationType_Passport = b'1'
#///军官证
CertificationType_OfficerIDCard = b'2'
#///士兵证
CertificationType_SoldierIDCard = b'3'
#///回乡证
CertificationType_HomeComingCard = b'4'
#///户口簿
CertificationType_HouseholdRegister = b'5'
#///营业执照号
CertificationType_LicenseNo = b'6'
#///组织机构代码证
CertificationType_InstitutionCodeCard = b'7'
#///临时营业执照号
CertificationType_TempLicenseNo = b'8'
#///民办非企业登记证书
CertificationType_NoEnterpriseLicenseNo = b'9'
#///其他证件
CertificationType_OtherCard = b'x'
#///主管部门批文
CertificationType_SuperDepAgree = b'a'
#///其他
FileBusinessCode_Others = b'0'
#///转账交易明细对账
FileBusinessCode_TransferDetails = b'1'
#///客户账户状态对账
FileBusinessCode_CustAccStatus = b'2'
#///账户类交易明细对账
FileBusinessCode_AccountTradeDetails = b'3'
#///期货账户信息变更明细对账
FileBusinessCode_FutureAccountChangeInfoDetails = b'4'
#///客户资金台账余额明细对账
FileBusinessCode_CustMoneyDetail = b'5'
#///客户销户结息明细对账
FileBusinessCode_CustCancelAccountInfo = b'6'
#///客户资金余额对账结果
FileBusinessCode_CustMoneyResult = b'7'
#///其它对账异常结果文件
FileBusinessCode_OthersExceptionResult = b'8'
#///客户结息净额明细
FileBusinessCode_CustInterestNetMoneyDetails = b'9'
#///客户资金交收明细
FileBusinessCode_CustMoneySendAndReceiveDetails = b'a'
#///法人存管银行资金交收汇总
FileBusinessCode_CorporationMoneyTotal = b'b'
#///主体间资金交收汇总
FileBusinessCode_MainbodyMoneyTotal = b'c'
#///总分平衡监管数据
FileBusinessCode_MainPartMonitorData = b'd'
#///存管银行备付金余额
FileBusinessCode_PreparationMoney = b'e'
#///协办存管银行资金监管数据
FileBusinessCode_BankMoneyMonitorData = b'f'
#///汇
CashExchangeCode_Exchange = b'1'
#///钞
CashExchangeCode_Cash = b'2'
#///是
YesNoIndicator_Yes = b'0'
#///否
YesNoIndicator_No = b'1'
#///当前余额
BanlanceType_CurrentMoney = b'0'
#///可用余额
BanlanceType_UsableMoney = b'1'
#///可取余额
BanlanceType_FetchableMoney = b'2'
#///冻结余额
BanlanceType_FreezeMoney = b'3'
#///未知状态
Gender_Unknown = b'0'
#///男
Gender_Male = b'1'
#///女
Gender_Female = b'2'
#///由受益方支付费用
FeePayFlag_BEN = b'0'
#///由发送方支付费用
FeePayFlag_OUR = b'1'
#///由发送方支付发起的费用,受益方支付接受的费用
FeePayFlag_SHA = b'2'
#///交换密钥
PassWordKeyType_ExchangeKey = b'0'
#///密码密钥
PassWordKeyType_PassWordKey = b'1'
#///MAC密钥
PassWordKeyType_MACKey = b'2'
#///报文密钥
PassWordKeyType_MessageKey = b'3'
#///查询
FBTPassWordType_Query = b'0'
#///取款
FBTPassWordType_Fetch = b'1'
#///转帐
FBTPassWordType_Transfer = b'2'
#///交易
FBTPassWordType_Trade = b'3'
#///不加密
FBTEncryMode_NoEncry = b'0'
#///DES
FBTEncryMode_DES = b'1'
#///3DES
FBTEncryMode_3DES = b'2'
#///银行无需自动冲正
BankRepealFlag_BankNotNeedRepeal = b'0'
#///银行待自动冲正
BankRepealFlag_BankWaitingRepeal = b'1'
#///银行已自动冲正
BankRepealFlag_BankBeenRepealed = b'2'
#///期商无需自动冲正
BrokerRepealFlag_BrokerNotNeedRepeal = b'0'
#///期商待自动冲正
BrokerRepealFlag_BrokerWaitingRepeal = b'1'
#///期商已自动冲正
BrokerRepealFlag_BrokerBeenRepealed = b'2'
#///银行
InstitutionType_Bank = b'0'
#///期商
InstitutionType_Future = b'1'
#///券商
InstitutionType_Store = b'2'
#///是最后分片
LastFragment_Yes = b'0'
#///不是最后分片
LastFragment_No = b'1'
#///正常
BankAccStatus_Normal = b'0'
#///冻结
BankAccStatus_Freeze = b'1'
#///挂失
BankAccStatus_ReportLoss = b'2'
#///正常
MoneyAccountStatus_Normal = b'0'
#///销户
MoneyAccountStatus_Cancel = b'1'
#///指定存管
ManageStatus_Point = b'0'
#///预指定
ManageStatus_PrePoint = b'1'
#///撤销指定
ManageStatus_CancelPoint = b'2'
#///银期转帐
SystemType_FutureBankTransfer = b'0'
#///银证转帐
SystemType_StockBankTransfer = b'1'
#///第三方存管
SystemType_TheThirdPartStore = b'2'
#///正常处理中
TxnEndFlag_NormalProcessing = b'0'
#///成功结束
TxnEndFlag_Success = b'1'
#///失败结束
TxnEndFlag_Failed = b'2'
#///异常中
TxnEndFlag_Abnormal = b'3'
#///已人工异常处理
TxnEndFlag_ManualProcessedForException = b'4'
#///通讯异常 ,请人工处理
TxnEndFlag_CommuFailedNeedManualProcess = b'5'
#///系统出错,请人工处理
TxnEndFlag_SysErrorNeedManualProcess = b'6'
#///未处理
ProcessStatus_NotProcess = b'0'
#///开始处理
ProcessStatus_StartProcess = b'1'
#///处理完成
ProcessStatus_Finished = b'2'
#///自然人
CustType_Person = b'0'
#///机构户
CustType_Institution = b'1'
#///入金,银行转期货
FBTTransferDirection_FromBankToFuture = b'1'
#///出金,期货转银行
FBTTransferDirection_FromFutureToBank = b'2'
#///开户
OpenOrDestroy_Open = b'1'
#///销户
OpenOrDestroy_Destroy = b'0'
#///未确认
AvailabilityFlag_Invalid = b'0'
#///有效
AvailabilityFlag_Valid = b'1'
#///冲正
AvailabilityFlag_Repeal = b'2'
#///银行代理
OrganType_Bank = b'1'
#///交易前置
OrganType_Future = b'2'
#///银期转帐平台管理
OrganType_PlateForm = b'9'
#///银行总行或期商总部
OrganLevel_HeadQuarters = b'1'
#///银行分中心或期货公司营业部
OrganLevel_Branch = b'2'
#///期商协议
ProtocalID_FutureProtocal = b'0'
#///工行协议
ProtocalID_ICBCProtocal = b'1'
#///农行协议
ProtocalID_ABCProtocal = b'2'
#///中国银行协议
ProtocalID_CBCProtocal = b'3'
#///建行协议
ProtocalID_CCBProtocal = b'4'
#///交行协议
ProtocalID_BOCOMProtocal = b'5'
#///银期转帐平台协议
ProtocalID_FBTPlateFormProtocal = b'X'
#///短连接
ConnectMode_ShortConnect = b'0'
#///长连接
ConnectMode_LongConnect = b'1'
#///异步
SyncMode_ASync = b'0'
#///同步
SyncMode_Sync = b'1'
#///银行存折
BankAccType_BankBook = b'1'
#///储蓄卡
BankAccType_SavingCard = b'2'
#///信用卡
BankAccType_CreditCard = b'3'
#///银行存折
FutureAccType_BankBook = b'1'
#///储蓄卡
FutureAccType_SavingCard = b'2'
#///信用卡
FutureAccType_CreditCard = b'3'
#///启用
OrganStatus_Ready = b'0'
#///签到
OrganStatus_CheckIn = b'1'
#///签退
OrganStatus_CheckOut = b'2'
#///对帐文件到达
OrganStatus_CheckFileArrived = b'3'
#///对帐
OrganStatus_CheckDetail = b'4'
#///日终清理
OrganStatus_DayEndClean = b'5'
#///注销
OrganStatus_Invalid = b'9'
#///按金额扣收
CCBFeeMode_ByAmount = b'1'
#///按月扣收
CCBFeeMode_ByMonth = b'2'
#///客户端
CommApiType_Client = b'1'
#///服务端
CommApiType_Server = b'2'
#///交易系统的UserApi
CommApiType_UserApi = b'3'
#///已经连接
LinkStatus_Connected = b'1'
#///没有连接
LinkStatus_Disconnected = b'2'
#///不核对
PwdFlag_NoCheck = b'0'
#///明文核对
PwdFlag_BlankCheck = b'1'
#///密文核对
PwdFlag_EncryptCheck = b'2'
#///资金帐号
SecuAccType_AccountID = b'1'
#///资金卡号
SecuAccType_CardID = b'2'
#///上海股东帐号
SecuAccType_SHStockholderID = b'3'
#///深圳股东帐号
SecuAccType_SZStockholderID = b'4'
#///正常
TransferStatus_Normal = b'0'
#///被冲正
TransferStatus_Repealed = b'1'
#///期商
SponsorType_Broker = b'0'
#///银行
SponsorType_Bank = b'1'
#///请求
ReqRspType_Request = b'0'
#///响应
ReqRspType_Response = b'1'
#///签到
FBTUserEventType_SignIn = b'0'
#///银行转期货
FBTUserEventType_FromBankToFuture = b'1'
#///期货转银行
FBTUserEventType_FromFutureToBank = b'2'
#///开户
FBTUserEventType_OpenAccount = b'3'
#///销户
FBTUserEventType_CancelAccount = b'4'
#///变更银行账户
FBTUserEventType_ChangeAccount = b'5'
#///冲正银行转期货
FBTUserEventType_RepealFromBankToFuture = b'6'
#///冲正期货转银行
FBTUserEventType_RepealFromFutureToBank = b'7'
#///查询银行账户
FBTUserEventType_QueryBankAccount = b'8'
#///查询期货账户
FBTUserEventType_QueryFutureAccount = b'9'
#///签退
FBTUserEventType_SignOut = b'A'
#///密钥同步
FBTUserEventType_SyncKey = b'B'
#///预约开户
FBTUserEventType_ReserveOpenAccount = b'C'
#///撤销预约开户
FBTUserEventType_CancelReserveOpenAccount = b'D'
#///预约开户确认
FBTUserEventType_ReserveOpenAccountConfirm = b'E'
#///其他
FBTUserEventType_Other = b'Z'
#///插入
DBOperation_Insert = b'0'
#///更新
DBOperation_Update = b'1'
#///删除
DBOperation_Delete = b'2'
#///已同步
SyncFlag_Yes = b'0'
#///未同步
SyncFlag_No = b'1'
#///一次同步
SyncType_OneOffSync = b'0'
#///定时同步
SyncType_TimerSync = b'1'
#///定时完全同步
SyncType_TimerFullSync = b'2'
#///结汇
ExDirection_Settlement = b'0'
#///售汇
ExDirection_Sale = b'1'
#///成功
FBEResultFlag_Success = b'0'
#///账户余额不足
FBEResultFlag_InsufficientBalance = b'1'
#///交易结果未知
FBEResultFlag_UnknownTrading = b'8'
#///失败
FBEResultFlag_Fail = b'x'
#///正常
FBEExchStatus_Normal = b'0'
#///交易重发
FBEExchStatus_ReExchange = b'1'
#///数据包
FBEFileFlag_DataPackage = b'0'
#///文件
FBEFileFlag_File = b'1'
#///未交易
FBEAlreadyTrade_NotTrade = b'0'
#///已交易
FBEAlreadyTrade_Trade = b'1'
#///签到
FBEUserEventType_SignIn = b'0'
#///换汇
FBEUserEventType_Exchange = b'1'
#///换汇重发
FBEUserEventType_ReExchange = b'2'
#///银行账户查询
FBEUserEventType_QueryBankAccount = b'3'
#///换汇明细查询
FBEUserEventType_QueryExchDetial = b'4'
#///换汇汇总查询
FBEUserEventType_QueryExchSummary = b'5'
#///换汇汇率查询
FBEUserEventType_QueryExchRate = b'6'
#///对账文件通知
FBEUserEventType_CheckBankAccount = b'7'
#///签退
FBEUserEventType_SignOut = b'8'
#///其他
FBEUserEventType_Other = b'Z'
#///未处理
FBEReqFlag_UnProcessed = b'0'
#///等待发送
FBEReqFlag_WaitSend = b'1'
#///发送成功
FBEReqFlag_SendSuccess = b'2'
#///发送失败
FBEReqFlag_SendFailed = b'3'
#///等待重发
FBEReqFlag_WaitReSend = b'4'
#///正常
NotifyClass_NOERROR = b'0'
#///警示
NotifyClass_Warn = b'1'
#///追保
NotifyClass_Call = b'2'
#///强平
NotifyClass_Force = b'3'
#///穿仓
NotifyClass_CHUANCANG = b'4'
#///异常
NotifyClass_Exception = b'5'
#///手工强平
ForceCloseType_Manual = b'0'
#///单一投资者辅助强平
ForceCloseType_Single = b'1'
#///批量投资者辅助强平
ForceCloseType_Group = b'2'
#///系统通知
RiskNotifyMethod_System = b'0'
#///短信通知
RiskNotifyMethod_SMS = b'1'
#///邮件通知
RiskNotifyMethod_EMail = b'2'
#///人工通知
RiskNotifyMethod_Manual = b'3'
#///未生成
RiskNotifyStatus_NotGen = b'0'
#///已生成未发送
RiskNotifyStatus_Generated = b'1'
#///发送失败
RiskNotifyStatus_SendError = b'2'
#///已发送未接收
RiskNotifyStatus_SendOk = b'3'
#///已接收未确认
RiskNotifyStatus_Received = b'4'
#///已确认
RiskNotifyStatus_Confirmed = b'5'
#///导出数据
RiskUserEvent_ExportData = b'0'
#///使用最新价升序
ConditionalOrderSortType_LastPriceAsc = b'0'
#///使用最新价降序
ConditionalOrderSortType_LastPriceDesc = b'1'
#///使用卖价升序
ConditionalOrderSortType_AskPriceAsc = b'2'
#///使用卖价降序
ConditionalOrderSortType_AskPriceDesc = b'3'
#///使用买价升序
ConditionalOrderSortType_BidPriceAsc = b'4'
#///使用买价降序
ConditionalOrderSortType_BidPriceDesc = b'5'
#///未发送
SendType_NoSend = b'0'
#///已发送
SendType_Sended = b'1'
#///已生成
SendType_Generated = b'2'
#///报送失败
SendType_SendFail = b'3'
#///接收成功
SendType_Success = b'4'
#///接收失败
SendType_Fail = b'5'
#///取消报送
SendType_Cancel = b'6'
#///未申请
ClientIDStatus_NoApply = b'1'
#///已提交申请
ClientIDStatus_Submited = b'2'
#///已发送申请
ClientIDStatus_Sended = b'3'
#///完成
ClientIDStatus_Success = b'4'
#///拒绝
ClientIDStatus_Refuse = b'5'
#///已撤销编码
ClientIDStatus_Cancel = b'6'
#///单选
QuestionType_Radio = b'1'
#///多选
QuestionType_Option = b'2'
#///填空
QuestionType_Blank = b'3'
#///请求
BusinessType_Request = b'1'
#///应答
BusinessType_Response = b'2'
#///通知
BusinessType_Notice = b'3'
#///成功
CfmmcReturnCode_Success = b'0'
#///该客户已经有流程在处理中
CfmmcReturnCode_Working = b'1'
#///监控中客户资料检查失败
CfmmcReturnCode_InfoFail = b'2'
#///监控中实名制检查失败
CfmmcReturnCode_IDCardFail = b'3'
#///其他错误
CfmmcReturnCode_OtherFail = b'4'
#///所有
ClientType_All = b'0'
#///个人
ClientType_Person = b'1'
#///单位
ClientType_Company = b'2'
#///其他
ClientType_Other = b'3'
#///特殊法人
ClientType_SpecialOrgan = b'4'
#///资管户
ClientType_Asset = b'5'
#///上海期货交易所
ExchangeIDType_SHFE = b'S'
#///郑州商品交易所
ExchangeIDType_CZCE = b'Z'
#///大连商品交易所
ExchangeIDType_DCE = b'D'
#///中国金融期货交易所
ExchangeIDType_CFFEX = b'J'
#///上海国际能源交易中心股份有限公司
ExchangeIDType_INE = b'N'
#///套保
ExClientIDType_Hedge = b'1'
#///套利
ExClientIDType_Arbitrage = b'2'
#///投机
ExClientIDType_Speculation = b'3'
#///未更新
UpdateFlag_NoUpdate = b'0'
#///更新全部信息成功
UpdateFlag_Success = b'1'
#///更新全部信息失败
UpdateFlag_Fail = b'2'
#///更新交易编码成功
UpdateFlag_TCSuccess = b'3'
#///更新交易编码失败
UpdateFlag_TCFail = b'4'
#///已丢弃
UpdateFlag_Cancel = b'5'
#///开户
ApplyOperateID_OpenInvestor = b'1'
#///修改身份信息
ApplyOperateID_ModifyIDCard = b'2'
#///修改一般信息
ApplyOperateID_ModifyNoIDCard = b'3'
#///申请交易编码
ApplyOperateID_ApplyTradingCode = b'4'
#///撤销交易编码
ApplyOperateID_CancelTradingCode = b'5'
#///销户
ApplyOperateID_CancelInvestor = b'6'
#///账户休眠
ApplyOperateID_FreezeAccount = b'8'
#///激活休眠账户
ApplyOperateID_ActiveFreezeAccount = b'9'
#///未补全
ApplyStatusID_NoComplete = b'1'
#///已提交
ApplyStatusID_Submited = b'2'
#///已审核
ApplyStatusID_Checked = b'3'
#///已拒绝
ApplyStatusID_Refused = b'4'
#///已删除
ApplyStatusID_Deleted = b'5'
#///文件发送
SendMethod_ByAPI = b'1'
#///电子发送
SendMethod_ByFile = b'2'
#///增加
EventMode_ADD = b'1'
#///修改
EventMode_UPDATE = b'2'
#///删除
EventMode_DELETE = b'3'
#///复核
EventMode_CHECK = b'4'
#///复制
EventMode_COPY = b'5'
#///注销
EventMode_CANCEL = b'6'
#///冲销
EventMode_Reverse = b'7'
#///自动发送并接收
UOAAutoSend_ASR = b'1'
#///自动发送,不自动接收
UOAAutoSend_ASNR = b'2'
#///不自动发送,自动接收
UOAAutoSend_NSAR = b'3'
#///不自动发送,也不自动接收
UOAAutoSend_NSR = b'4'
#///投资者对应投资者组设置
FlowID_InvestorGroupFlow = b'1'
#///投资者手续费率设置
FlowID_InvestorRate = b'2'
#///投资者手续费率模板关系设置
FlowID_InvestorCommRateModel = b'3'
#///零级复核
CheckLevel_Zero = b'0'
#///一级复核
CheckLevel_One = b'1'
#///二级复核
CheckLevel_Two = b'2'
#///未复核
CheckStatus_Init = b'0'
#///复核中
CheckStatus_Checking = b'1'
#///已复核
CheckStatus_Checked = b'2'
#///拒绝
CheckStatus_Refuse = b'3'
#///作废
CheckStatus_Cancel = b'4'
#///未生效
UsedStatus_Unused = b'0'
#///已生效
UsedStatus_Used = b'1'
#///生效失败
UsedStatus_Fail = b'2'
#///手工录入
BankAcountOrigin_ByAccProperty = b'0'
#///银期转账
BankAcountOrigin_ByFBTransfer = b'1'
#///同日同合约
MonthBillTradeSum_ByInstrument = b'0'
#///同日同合约同价格
MonthBillTradeSum_ByDayInsPrc = b'1'
#///同合约
MonthBillTradeSum_ByDayIns = b'2'
#///银行发起银行转期货
FBTTradeCodeEnum_BankLaunchBankToBroker = b'102001'
#///期货发起银行转期货
FBTTradeCodeEnum_BrokerLaunchBankToBroker = b'202001'
#///银行发起期货转银行
FBTTradeCodeEnum_BankLaunchBrokerToBank = b'102002'
#///期货发起期货转银行
FBTTradeCodeEnum_BrokerLaunchBrokerToBank = b'202002'
#///无动态令牌
OTPType_NONE = b'0'
#///时间令牌
OTPType_TOTP = b'1'
#///未使用
OTPStatus_Unused = b'0'
#///已使用
OTPStatus_Used = b'1'
#///注销
OTPStatus_Disuse = b'2'
#///投资者
BrokerUserType_Investor = b'1'
#///操作员
BrokerUserType_BrokerUser = b'2'
#///商品期货
FutureType_Commodity = b'1'
#///金融期货
FutureType_Financial = b'2'
#///转账限额
FundEventType_Restriction = b'0'
#///当日转账限额
FundEventType_TodayRestriction = b'1'
#///期商流水
FundEventType_Transfer = b'2'
#///资金冻结
FundEventType_Credit = b'3'
#///投资者可提资金比例
FundEventType_InvestorWithdrawAlm = b'4'
#///单个银行帐户转账限额
FundEventType_BankRestriction = b'5'
#///银期签约账户
FundEventType_Accountregister = b'6'
#///交易所出入金
FundEventType_ExchangeFundIO = b'7'
#///投资者出入金
FundEventType_InvestorFundIO = b'8'
#///银期同步
AccountSourceType_FBTransfer = b'0'
#///手工录入
AccountSourceType_ManualEntry = b'1'
#///统一开户(已规范)
CodeSourceType_UnifyAccount = b'0'
#///手工录入(未规范)
CodeSourceType_ManualEntry = b'1'
#///所有
UserRange_All = b'0'
#///单一操作员
UserRange_Single = b'1'
#///按投资者统计
ByGroup_Investor = b'2'
#///按类统计
ByGroup_Group = b'1'
#///按合约统计
TradeSumStatMode_Instrument = b'1'
#///按产品统计
TradeSumStatMode_Product = b'2'
#///按交易所统计
TradeSumStatMode_Exchange = b'3'
#///相对已有规则设置
ExprSetMode_Relative = b'1'
#///典型设置
ExprSetMode_Typical = b'2'
#///公司标准
RateInvestorRange_All = b'1'
#///模板
RateInvestorRange_Model = b'2'
#///单一投资者
RateInvestorRange_Single = b'3'
#///未同步
SyncDataStatus_Initialize = b'0'
#///同步中
SyncDataStatus_Settlementing = b'1'
#///已同步
SyncDataStatus_Settlemented = b'2'
#///来自交易所普通回报
TradeSource_NORMAL = b'0'
#///来自查询
TradeSource_QUERY = b'1'
#///产品统计
FlexStatMode_Product = b'1'
#///交易所统计
FlexStatMode_Exchange = b'2'
#///统计所有
FlexStatMode_All = b'3'
#///属性统计
ByInvestorRange_Property = b'1'
#///统计所有
ByInvestorRange_All = b'2'
#///所有
PropertyInvestorRange_All = b'1'
#///投资者属性
PropertyInvestorRange_Property = b'2'
#///单一投资者
PropertyInvestorRange_Single = b'3'
#///未生成
FileStatus_NoCreate = b'0'
#///已生成
FileStatus_Created = b'1'
#///生成失败
FileStatus_Failed = b'2'
#///下发
FileGenStyle_FileTransmit = b'0'
#///生成
FileGenStyle_FileGen = b'1'
#///增加
SysOperMode_Add = b'1'
#///修改
SysOperMode_Update = b'2'
#///删除
SysOperMode_Delete = b'3'
#///复制
SysOperMode_Copy = b'4'
#///激活
SysOperMode_AcTive = b'5'
#///注销
SysOperMode_CanCel = b'6'
#///重置
SysOperMode_ReSet = b'7'
#///修改操作员密码
SysOperType_UpdatePassword = b'0'
#///操作员组织架构关系
SysOperType_UserDepartment = b'1'
#///角色管理
SysOperType_RoleManager = b'2'
#///角色功能设置
SysOperType_RoleFunction = b'3'
#///基础参数设置
SysOperType_BaseParam = b'4'
#///设置操作员
SysOperType_SetUserID = b'5'
#///用户角色设置
SysOperType_SetUserRole = b'6'
#///用户IP限制
SysOperType_UserIpRestriction = b'7'
#///组织架构管理
SysOperType_DepartmentManager = b'8'
#///组织架构向查询分类复制
SysOperType_DepartmentCopy = b'9'
#///交易编码管理
SysOperType_Tradingcode = b'A'
#///投资者状态维护
SysOperType_InvestorStatus = b'B'
#///投资者权限管理
SysOperType_InvestorAuthority = b'C'
#///属性设置
SysOperType_PropertySet = b'D'
#///重置投资者密码
SysOperType_ReSetInvestorPasswd = b'E'
#///投资者个性信息维护
SysOperType_InvestorPersonalityInfo = b'F'
#///查询当前交易日报送的数据
CSRCDataQueyType_Current = b'0'
#///查询历史报送的代理经纪公司的数据
CSRCDataQueyType_History = b'1'
#///活跃
FreezeStatus_Normal = b'1'
#///休眠
FreezeStatus_Freeze = b'0'
#///已规范
StandardStatus_Standard = b'0'
#///未规范
StandardStatus_NonStandard = b'1'
#///休眠户
RightParamType_Freeze = b'1'
#///激活休眠户
RightParamType_FreezeActive = b'2'
#///开仓权限限制
RightParamType_OpenLimit = b'3'
#///解除开仓权限限制
RightParamType_RelieveOpenLimit = b'4'
#///正常
DataStatus_Normal = b'0'
#///已删除
DataStatus_Deleted = b'1'
#///未复核
AMLCheckStatus_Init = b'0'
#///复核中
AMLCheckStatus_Checking = b'1'
#///已复核
AMLCheckStatus_Checked = b'2'
#///拒绝上报
AMLCheckStatus_RefuseReport = b'3'
#///检查日期
AmlDateType_DrawDay = b'0'
#///发生日期
AmlDateType_TouchDay = b'1'
#///零级审核
AmlCheckLevel_CheckLevel0 = b'0'
#///一级审核
AmlCheckLevel_CheckLevel1 = b'1'
#///二级审核
AmlCheckLevel_CheckLevel2 = b'2'
#///三级审核
AmlCheckLevel_CheckLevel3 = b'3'
#///CSV
ExportFileType_CSV = b'0'
#///Excel
ExportFileType_EXCEL = b'1'
#///DBF
ExportFileType_DBF = b'2'
#///结算前准备
SettleManagerType_Before = b'1'
#///结算
SettleManagerType_Settlement = b'2'
#///结算后核对
SettleManagerType_After = b'3'
#///结算后处理
SettleManagerType_Settlemented = b'4'
#///必要
SettleManagerLevel_Must = b'1'
#///警告
SettleManagerLevel_Alarm = b'2'
#///提示
SettleManagerLevel_Prompt = b'3'
#///不检查
SettleManagerLevel_Ignore = b'4'
#///交易所核对
SettleManagerGroup_Exhcange = b'1'
#///内部核对
SettleManagerGroup_ASP = b'2'
#///上报数据核对
SettleManagerGroup_CSRC = b'3'
#///可重复使用
LimitUseType_Repeatable = b'1'
#///不可重复使用
LimitUseType_Unrepeatable = b'2'
#///本系统
DataResource_Settle = b'1'
#///交易所
DataResource_Exchange = b'2'
#///报送数据
DataResource_CSRC = b'3'
#///交易所保证金率
MarginType_ExchMarginRate = b'0'
#///投资者保证金率
MarginType_InstrMarginRate = b'1'
#///投资者交易保证金率
MarginType_InstrMarginRateTrade = b'2'
#///仅当日生效
ActiveType_Intraday = b'1'
#///长期生效
ActiveType_Long = b'2'
#///交易所保证金率
MarginRateType_Exchange = b'1'
#///投资者保证金率
MarginRateType_Investor = b'2'
#///投资者交易保证金率
MarginRateType_InvestorTrade = b'3'
#///未生成备份数据
BackUpStatus_UnBak = b'0'
#///备份数据生成中
BackUpStatus_BakUp = b'1'
#///已生成备份数据
BackUpStatus_BakUped = b'2'
#///备份数据失败
BackUpStatus_BakFail = b'3'
#///结算初始化未开始
InitSettlement_UnInitialize = b'0'
#///结算初始化中
InitSettlement_Initialize = b'1'
#///结算初始化完成
InitSettlement_Initialized = b'2'
#///未生成报表数据
ReportStatus_NoCreate = b'0'
#///报表数据生成中
ReportStatus_Create = b'1'
#///已生成报表数据
ReportStatus_Created = b'2'
#///生成报表数据失败
ReportStatus_CreateFail = b'3'
#///归档未完成
SaveStatus_UnSaveData = b'0'
#///归档完成
SaveStatus_SaveDatad = b'1'
#///未归档数据
SettArchiveStatus_UnArchived = b'0'
#///数据归档中
SettArchiveStatus_Archiving = b'1'
#///已归档数据
SettArchiveStatus_Archived = b'2'
#///归档数据失败
SettArchiveStatus_ArchiveFail = b'3'
#///未知类型
CTPType_Unkown = b'0'
#///主中心
CTPType_MainCenter = b'1'
#///备中心
CTPType_BackUp = b'2'
#///正常
CloseDealType_Normal = b'0'
#///投机平仓优先
CloseDealType_SpecFirst = b'1'
#///不能使用
MortgageFundUseRange_None = b'0'
#///用于保证金
MortgageFundUseRange_Margin = b'1'
#///用于手续费、盈亏、保证金
MortgageFundUseRange_All = b'2'
#///人民币方案3
MortgageFundUseRange_CNY3 = b'3'
#///郑商所套保产品
SpecProductType_CzceHedge = b'1'
#///货币质押产品
SpecProductType_IneForeignCurrency = b'2'
#///大连短线开平仓产品
SpecProductType_DceOpenClose = b'3'
#///质押
FundMortgageType_Mortgage = b'1'
#///解质
FundMortgageType_Redemption = b'2'
#///基础保证金
AccountSettlementParamID_BaseMargin = b'1'
#///最低权益标准
AccountSettlementParamID_LowestInterest = b'2'
#///货币质入
FundMortDirection_In = b'1'
#///货币质出
FundMortDirection_Out = b'2'
#///盈利
BusinessClass_Profit = b'0'
#///亏损
BusinessClass_Loss = b'1'
#///其他
BusinessClass_Other = b'Z'
#///手工
SwapSourceType_Manual = b'0'
#///自动生成
SwapSourceType_Automatic = b'1'
#///结汇
CurrExDirection_Settlement = b'0'
#///售汇
CurrExDirection_Sale = b'1'
#///已录入
CurrencySwapStatus_Entry = b'1'
#///已审核
CurrencySwapStatus_Approve = b'2'
#///已拒绝
CurrencySwapStatus_Refuse = b'3'
#///已撤销
CurrencySwapStatus_Revoke = b'4'
#///已发送
CurrencySwapStatus_Send = b'5'
#///换汇成功
CurrencySwapStatus_Success = b'6'
#///换汇失败
CurrencySwapStatus_Failure = b'7'
#///未发送
ReqFlag_NoSend = b'0'
#///发送成功
ReqFlag_SendSuccess = b'1'
#///发送失败
ReqFlag_SendFailed = b'2'
#///等待重发
ReqFlag_WaitReSend = b'3'
#///成功
ResFlag_Success = b'0'
#///账户余额不足
ResFlag_InsuffiCient = b'1'
#///交易结果未知
ResFlag_UnKnown = b'8'
#///修改前
ExStatus_Before = b'0'
#///修改后
ExStatus_After = b'1'
#///国内客户
ClientRegion_Domestic = b'1'
#///港澳台客户
ClientRegion_GMT = b'2'
#///国外客户
ClientRegion_Foreign = b'3'
#///没有
HasBoard_No = b'0'
#///有
HasBoard_Yes = b'1'
#///正常
StartMode_Normal = b'1'
#///应急
StartMode_Emerge = b'2'
#///恢复
StartMode_Restore = b'3'
#///全量
TemplateType_Full = b'1'
#///增量
TemplateType_Increment = b'2'
#///备份
TemplateType_BackUp = b'3'
#///交易
LoginMode_Trade = b'0'
#///转账
LoginMode_Transfer = b'1'
#///合约上下市
PromptType_Instrument = b'1'
#///保证金分段生效
PromptType_Margin = b'2'
#///有
HasTrustee_Yes = b'1'
#///没有
HasTrustee_No = b'0'
#///银行
AmType_Bank = b'1'
#///证券公司
AmType_Securities = b'2'
#///基金公司
AmType_Fund = b'3'
#///保险公司
AmType_Insurance = b'4'
#///信托公司
AmType_Trust = b'5'
#///其他
AmType_Other = b'9'
#///出入金
CSRCFundIOType_FundIO = b'0'
#///银期换汇
CSRCFundIOType_SwapCurrency = b'1'
#///期货结算账户
CusAccountType_Futures = b'1'
#///纯期货资管业务下的资管结算账户
CusAccountType_AssetmgrFuture = b'2'
#///综合类资管业务下的期货资管托管账户
CusAccountType_AssetmgrTrustee = b'3'
#///综合类资管业务下的资金中转账户
CusAccountType_AssetmgrTransfer = b'4'
#///中文
LanguageType_Chinese = b'1'
#///英文
LanguageType_English = b'2'
#///个人资管客户
AssetmgrClientType_Person = b'1'
#///单位资管客户
AssetmgrClientType_Organ = b'2'
#///特殊单位资管客户
AssetmgrClientType_SpecialOrgan = b'4'
#///期货类
AssetmgrType_Futures = b'3'
#///综合类
AssetmgrType_SpecialOrgan = b'4'
#///合约交易所不存在
CheckInstrType_HasExch = b'0'
#///合约本系统不存在
CheckInstrType_HasATP = b'1'
#///合约比较不一致
CheckInstrType_HasDiff = b'2'
#///手工交割
DeliveryType_HandDeliv = b'1'
#///到期交割
DeliveryType_PersonDeliv = b'2'
#///不使用大额单边保证金算法
MaxMarginSideAlgorithm_NO = b'0'
#///使用大额单边保证金算法
MaxMarginSideAlgorithm_YES = b'1'
#///自然人
DAClientType_Person = b'0'
#///法人
DAClientType_Company = b'1'
#///其他
DAClientType_Other = b'2'
#///期货类
UOAAssetmgrType_Futures = b'1'
#///综合类
UOAAssetmgrType_SpecialOrgan = b'2'
#///Buy
DirectionEn_Buy = b'0'
#///Sell
DirectionEn_Sell = b'1'
#///Position Opening
OffsetFlagEn_Open = b'0'
#///Position Close
OffsetFlagEn_Close = b'1'
#///Forced Liquidation
OffsetFlagEn_ForceClose = b'2'
#///Close Today
OffsetFlagEn_CloseToday = b'3'
#///Close Prev.
OffsetFlagEn_CloseYesterday = b'4'
#///Forced Reduction
OffsetFlagEn_ForceOff = b'5'
#///Local Forced Liquidation
OffsetFlagEn_LocalForceClose = b'6'
#///Speculation
HedgeFlagEn_Speculation = b'1'
#///Arbitrage
HedgeFlagEn_Arbitrage = b'2'
#///Hedge
HedgeFlagEn_Hedge = b'3'
#///Deposit/Withdrawal
FundIOTypeEn_FundIO = b'1'
#///Bank-Futures Transfer
FundIOTypeEn_Transfer = b'2'
#///Bank-Futures FX Exchange
FundIOTypeEn_SwapCurrency = b'3'
#///Bank Deposit
FundTypeEn_Deposite = b'1'
#///Payment/Fee
FundTypeEn_ItemFund = b'2'
#///Brokerage Adj
FundTypeEn_Company = b'3'
#///Internal Transfer
FundTypeEn_InnerTransfer = b'4'
#///Deposit
FundDirectionEn_In = b'1'
#///Withdrawal
FundDirectionEn_Out = b'2'
#///Pledge
FundMortDirectionEn_In = b'1'
#///Redemption
FundMortDirectionEn_Out = b'2'
#///看涨
OptionsType_CallOptions = b'1'
#///看跌
OptionsType_PutOptions = b'2'
#///欧式
StrikeMode_Continental = b'0'
#///美式
StrikeMode_American = b'1'
#///百慕大
StrikeMode_Bermuda = b'2'
#///自身对冲
StrikeType_Hedge = b'0'
#///匹配执行
StrikeType_Match = b'1'
#///不执行数量
ApplyType_NotStrikeNum = b'4'
#///系统生成
GiveUpDataSource_Gen = b'0'
#///手工添加
GiveUpDataSource_Hand = b'1'
#///没有执行
ExecResult_NoExec = b'n'
#///已经取消
ExecResult_Canceled = b'c'
#///执行成功
ExecResult_OK = b'0'
#///期权持仓不够
ExecResult_NoPosition = b'1'
#///资金不够
ExecResult_NoDeposit = b'2'
#///会员不存在
ExecResult_NoParticipant = b'3'
#///客户不存在
ExecResult_NoClient = b'4'
#///合约不存在
ExecResult_NoInstrument = b'6'
#///没有执行权限
ExecResult_NoRight = b'7'
#///不合理的数量
ExecResult_InvalidVolume = b'8'
#///没有足够的历史成交
ExecResult_NoEnoughHistoryTrade = b'9'
#///未知
ExecResult_Unknown = b'a'
#///期货组合
CombinationType_Future = b'0'
#///垂直价差BUL
CombinationType_BUL = b'1'
#///垂直价差BER
CombinationType_BER = b'2'
#///跨式组合
CombinationType_STD = b'3'
#///宽跨式组合
CombinationType_STG = b'4'
#///备兑组合
CombinationType_PRT = b'5'
#///时间价差组合
CombinationType_CLD = b'6'
#///期货对锁组合
DceCombinationType_SPL = b'0'
#///期权对锁组合
DceCombinationType_OPL = b'1'
#///期货跨期组合
DceCombinationType_SP = b'2'
#///期货跨品种组合
DceCombinationType_SPC = b'3'
#///买入期权垂直价差组合
DceCombinationType_BLS = b'4'
#///卖出期权垂直价差组合
DceCombinationType_BES = b'5'
#///期权日历价差组合
DceCombinationType_CAS = b'6'
#///期权跨式组合
DceCombinationType_STD = b'7'
#///期权宽跨式组合
DceCombinationType_STG = b'8'
#///买入期货期权组合
DceCombinationType_BFO = b'9'
#///卖出期货期权组合
DceCombinationType_SFO = b'a'
#///昨结算价
OptionRoyaltyPriceType_PreSettlementPrice = b'1'
#///开仓价
OptionRoyaltyPriceType_OpenPrice = b'4'
#///最新价与昨结算价较大值
OptionRoyaltyPriceType_MaxPreSettlementPrice = b'5'
#///不计算期权市值盈亏
BalanceAlgorithm_Default = b'1'
#///计算期权市值亏损
BalanceAlgorithm_IncludeOptValLost = b'2'
#///执行
ActionType_Exec = b'1'
#///放弃
ActionType_Abandon = b'2'
#///已经提交
ForQuoteStatus_Submitted = b'a'
#///已经接受
ForQuoteStatus_Accepted = b'b'
#///已经被拒绝
ForQuoteStatus_Rejected = b'c'
#///按绝对值
ValueMethod_Absolute = b'0'
#///按比率
ValueMethod_Ratio = b'1'
#///保留
ExecOrderPositionFlag_Reserve = b'0'
#///不保留
ExecOrderPositionFlag_UnReserve = b'1'
#///自动平仓
ExecOrderCloseFlag_AutoClose = b'0'
#///免于自动平仓
ExecOrderCloseFlag_NotToClose = b'1'
#///期货
ProductType_Futures = b'1'
#///期权
ProductType_Options = b'2'
#///^\d{8}_zz_\d{4}
CZCEUploadFileName_CUFN_O = b'O'
#///^\d{8}成交表
CZCEUploadFileName_CUFN_T = b'T'
#///^\d{8}单腿持仓表new
CZCEUploadFileName_CUFN_P = b'P'
#///^\d{8}非平仓了结表
CZCEUploadFileName_CUFN_N = b'N'
#///^\d{8}平仓表
CZCEUploadFileName_CUFN_L = b'L'
#///^\d{8}资金表
CZCEUploadFileName_CUFN_F = b'F'
#///^\d{8}组合持仓表
CZCEUploadFileName_CUFN_C = b'C'
#///^\d{8}保证金参数表
CZCEUploadFileName_CUFN_M = b'M'
#///^\d{8}_dl_\d{3}
DCEUploadFileName_DUFN_O = b'O'
#///^\d{8}_成交表
DCEUploadFileName_DUFN_T = b'T'
#///^\d{8}_持仓表
DCEUploadFileName_DUFN_P = b'P'
#///^\d{8}_资金结算表
DCEUploadFileName_DUFN_F = b'F'
#///^\d{8}_优惠组合持仓明细表
DCEUploadFileName_DUFN_C = b'C'
#///^\d{8}_持仓明细表
DCEUploadFileName_DUFN_D = b'D'
#///^\d{8}_保证金参数表
DCEUploadFileName_DUFN_M = b'M'
#///^\d{8}_期权执行表
DCEUploadFileName_DUFN_S = b'S'
#///^\d{4}_\d{8}_\d{8}_DailyFundChg
SHFEUploadFileName_SUFN_O = b'O'
#///^\d{4}_\d{8}_\d{8}_Trade
SHFEUploadFileName_SUFN_T = b'T'
#///^\d{4}_\d{8}_\d{8}_SettlementDetail
SHFEUploadFileName_SUFN_P = b'P'
#///^\d{4}_\d{8}_\d{8}_Capital
SHFEUploadFileName_SUFN_F = b'F'
#///^\d{4}_SG\d{1}_\d{8}_\d{1}_Trade
CFFEXUploadFileName_SUFN_T = b'T'
#///^\d{4}_SG\d{1}_\d{8}_\d{1}_SettlementDetail
CFFEXUploadFileName_SUFN_P = b'P'
#///^\d{4}_SG\d{1}_\d{8}_\d{1}_Capital
CFFEXUploadFileName_SUFN_F = b'F'
#///^\d{4}_SG\d{1}_\d{8}_\d{1}_OptionExec
CFFEXUploadFileName_SUFN_S = b'S'
#///申请组合
CombDirection_Comb = b'0'
#///申请拆分
CombDirection_UnComb = b'1'
#///实值额
StrikeOffsetType_RealValue = b'1'
#///盈利额
StrikeOffsetType_ProfitValue = b'2'
#///实值比例
StrikeOffsetType_RealRatio = b'3'
#///盈利比例
StrikeOffsetType_ProfitRatio = b'4'
#///等待处理中
ReserveOpenAccStas_Processing = b'0'
#///已撤销
ReserveOpenAccStas_Cancelled = b'1'
#///已开户
ReserveOpenAccStas_Opened = b'2'
#///无效请求
ReserveOpenAccStas_Invalid = b'3'
#///弱密码库
WeakPasswordSource_Lib = b'1'
#///手工录入
WeakPasswordSource_Manual = b'2'
#///自对冲期权仓位
OptSelfCloseFlag_CloseSelfOptionPosition = b'1'
#///保留期权仓位
OptSelfCloseFlag_ReserveOptionPosition = b'2'
#///自对冲卖方履约后的期货仓位
OptSelfCloseFlag_SellCloseSelfFuturePosition = b'3'
#///保留卖方履约后的期货仓位
OptSelfCloseFlag_ReserveFuturePosition = b'4'
#///期货
BizType_Future = b'1'
#///证券
BizType_Stock = b'2'
#///直连的投资者
AppType_TYPE_Investor = b'1'
#///为每个投资者都创建连接的中继
AppType_TYPE_InvestorRelay = b'2'
#///所有投资者共享一个操作员连接的中继
AppType_TYPE_OperatorRelay = b'3'
#///未知
AppType_TYPE_UnKnown = b'4'
#///检查成功
ResponseValue_Right = b'0'
#///检查失败
ResponseValue_Refuse = b'1'
#///大宗交易
OTCTradeType_TRDT_Block = b'0'
#///期转现
OTCTradeType_TRDT_EFP = b'1'
#///基点价值
MatchType_MT_DV01 = b'1'
#///面值
MatchType_MT_ParValue = b'2' |
guests = ["sam","mike","darren"]
for i in range(len(guests)):
print("Hello, "+guests[i].title()+" you are invited to dinner")
print(" ")
print(guests[0]+" cant make it to dinner unfortunately")
guests[0] = "alicia"
for i in range(len(guests)):
print("Hello, "+guests[i].title()+" you are invited to dinner")
print("Hello, I just reserved a bigger dinner table so now there's room for more people")
guests.insert(0,"john")
middle_index = (len(guests)/2).__ceil__();
guests.insert(middle_index,"janet")
guests.insert(len(guests),"brown")
for i in range(len(guests)):
print("Hello, "+guests[i].title()+" you are invited to dinner")
c = 0
for i in range(len(guests)):
c = c + 1
print("No of guests invited to dinner: ",c) |
__all__=[
'SG_disease',
'SG_weather',
'MY_dengue',
'MY_malaria',
'BN_disease',
'ID_malaria',
'PH_malaria',
'TH_disease',
'apps_who_int',
'wunderground'
] |
while True:
usr = input("Enter username: ")
with open("users.txt", "r") as file:
users = file.readlines()
users = [i.strip("\n") for i in users]
if usr in users:
print("Username exists")
continue
else:
print("Username is fine")
break
while True:
notes = []
psw = input("Enter password: ")
if not any(i.isdigit() for i in psw):
notes.append("You need at least one number")
if not any(i.isupper() for i in psw):
notes.append("You need at least one uppercase letter")
if len(psw) < 5:
notes.append("You need at least 5 characters")
if len(notes) == 0:
print("Password is fine")
break
else:
print("Please check the following: ")
for note in notes:
print(note)
|
class ServiceUnavailable(Exception):
"""Raised when you try to send a request to a service that is
unavailable.
"""
class ServiceError(Exception):
"""Raised when a service failed to fulfill your request."""
class UnknownRejection(Exception):
"""Raised when a service rejects your request, and you haven't
registered an exception for this rejection type
"""
def __init__(self, *args, **kwargs):
self.args = args
self.kwargs = kwargs
class InvalidEventName(Exception):
"""Raised when you try to register an event with an invalid name"""
|
# Atharv Kolhar
# Python Bytes
"""
Question:
1. Create a list 'solar_system' of Planets in the Solar System and
print the 4th planet.
Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto
2. Print the length of the 'solar_system'.
3. Remove the last planet Pluto from the list.
4. Reverse the list solar_system
""" |
#!/usr/bin/env python
# encoding: utf-8
"""
Created by 'bens3' on 2013-06-21.
Copyright (c) 2013 'bens3'. All rights reserved.
""" |
def set_default_values(args, also_hyper_params=True):
# -set default-values for certain arguments based on chosen scenario & experiment
if args.tasks is None:
if args.experiment=='splitMNIST':
args.num_classes = 10
if args.experiment=='splitMNISToneclass':
args.num_classes = 10
elif args.experiment=='permMNIST':
args.num_classes = 100
elif args.experiment=='cifar10':
args.num_classes = 10
elif args.experiment=='cifar100':
args.num_classes = 100
if args.iters is None:
if args.experiment=='splitMNIST':
args.iters = 2000
elif args.experiment=='splitMNISToneclass':
args.iters = 2000
elif args.experiment=='permMNIST':
args.iters = 5000
elif args.experiment=='cifar100':
args.iters = 5000
elif args.experiment=='cifar10':
args.iters = 5000
elif args.experiment=='block2d':
args.iters = 5000
if args.lr is None:
if args.ebm:
if args.experiment=='splitMNIST':
args.lr = 0.0001
if args.experiment=='splitMNISToneclass':
args.lr = 0.0001
elif args.experiment=='permMNIST':
args.lr = 0.00001
elif args.experiment=='cifar100':
args.lr = 0.00001
elif args.experiment=='cifar10':
args.lr = 0.00001
elif args.experiment=='block2d':
args.lr = 0.00001
else:
if args.experiment=='splitMNIST':
args.lr = 0.001
if args.experiment=='splitMNISToneclass':
args.lr = 0.001
elif args.experiment=='permMNIST':
args.lr = 0.0001
elif args.experiment=='cifar100':
args.lr = 0.0001
elif args.experiment=='cifar10':
args.lr = 0.0001
elif args.experiment=='block2d':
args.lr = 0.0001
if args.fc_units is None:
if args.experiment=='splitMNIST':
args.fc_units = 400
if args.experiment=='splitMNISToneclass':
args.fc_units = 400
elif args.experiment=='permMNIST':
args.fc_units = 1000
elif args.experiment=='cifar100':
args.fc_units = 1000
elif args.experiment=='cifar10':
args.fc_units = 1000
elif args.experiment=='block2d':
args.fc_units = 400
print(args)
return args
|
[
{
'date': '2011-01-01',
'description': 'Neujahr',
'locale': 'de-DE',
'notes': '',
'region': '',
'type': 'NF'
},
{
'date': '2011-01-06',
'description': 'Heilige drei Könige',
'locale': 'de-DE',
'notes': '',
'region': 'BW',
'type': 'NRF'
},
{
'date': '2011-01-06',
'description': 'Heilige drei Könige',
'locale': 'de-DE',
'notes': '',
'region': 'BY',
'type': 'NRF'
},
{
'date': '2011-01-06',
'description': 'Heilige drei Könige',
'locale': 'de-DE',
'notes': '',
'region': 'ST',
'type': 'NRF'
},
{
'date': '2011-04-22',
'description': 'Karfreitag',
'locale': 'de-DE',
'notes': '',
'region': '',
'type': 'NRV'
},
{
'date': '2011-04-24',
'description': 'Ostern',
'locale': 'de-DE',
'notes': '',
'region': '',
'type': 'NRV'
},
{
'date': '2011-04-25',
'description': 'Ostermontag',
'locale': 'de-DE',
'notes': '',
'region': '',
'type': 'NRV'
},
{
'date': '2011-05-01',
'description': 'Erster Maifeiertag',
'locale': 'de-DE',
'notes': '',
'region': '',
'type': 'NF'
},
{
'date': '2011-06-02',
'description': 'Christi Himmelfahrt',
'locale': 'de-DE',
'notes': '',
'region': '',
'type': 'NRV'
},
{
'date': '2011-06-12',
'description': 'Pfingstsonntag',
'locale': 'de-DE',
'notes': '',
'region': '',
'type': 'NRV'
},
{
'date': '2011-06-13',
'description': 'Pfingstmontag',
'locale': 'de-DE',
'notes': '',
'region': '',
'type': 'NRV'
},
{
'date': '2011-06-23',
'description': 'Fronleichnam',
'locale': 'de-DE',
'notes': '',
'region': 'BW',
'type': 'NRV'
},
{
'date': '2011-06-23',
'description': 'Fronleichnam',
'locale': 'de-DE',
'notes': '',
'region': 'BY',
'type': 'NRV'
},
{
'date': '2011-06-23',
'description': 'Fronleichnam',
'locale': 'de-DE',
'notes': '',
'region': 'HE',
'type': 'NRV'
},
{
'date': '2011-06-23',
'description': 'Fronleichnam',
'locale': 'de-DE',
'notes': '',
'region': 'NW',
'type': 'NRV'
},
{
'date': '2011-06-23',
'description': 'Fronleichnam',
'locale': 'de-DE',
'notes': '',
'region': 'RP',
'type': 'NRV'
},
{
'date': '2011-06-23',
'description': 'Fronleichnam',
'locale': 'de-DE',
'notes': '',
'region': 'SL',
'type': 'NRV'
},
{
'date': '2011-08-15',
'description': 'Mariä Himmelfahrt',
'locale': 'de-DE',
'notes': '',
'region': 'SL',
'type': 'NRF'
},
{
'date': '2011-10-03',
'description': 'Tag der Deutschen Einheit',
'locale': 'de-DE',
'notes': '',
'region': '',
'type': 'NRF'
},
{
'date': '2011-10-31',
'description': 'Reformationstag',
'locale': 'de-DE',
'notes': '',
'region': 'BB',
'type': 'NRF'
},
{
'date': '2011-10-31',
'description': 'Reformationstag',
'locale': 'de-DE',
'notes': '',
'region': 'MV',
'type': 'NRF'
},
{
'date': '2011-10-31',
'description': 'Reformationstag',
'locale': 'de-DE',
'notes': '',
'region': 'SN',
'type': 'NRF'
},
{
'date': '2011-10-31',
'description': 'Reformationstag',
'locale': 'de-DE',
'notes': '',
'region': 'ST',
'type': 'NRF'
},
{
'date': '2011-10-31',
'description': 'Reformationstag',
'locale': 'de-DE',
'notes': '',
'region': 'TH',
'type': 'NRF'
},
{
'date': '2011-11-01',
'description': 'Allerheiligen',
'locale': 'de-DE',
'notes': '',
'region': 'BW',
'type': 'NRF'
},
{
'date': '2011-11-01',
'description': 'Allerheiligen',
'locale': 'de-DE',
'notes': '',
'region': 'BY',
'type': 'NRF'
},
{
'date': '2011-11-01',
'description': 'Allerheiligen',
'locale': 'de-DE',
'notes': '',
'region': 'NW',
'type': 'NRF'
},
{
'date': '2011-11-01',
'description': 'Allerheiligen',
'locale': 'de-DE',
'notes': '',
'region': 'RP',
'type': 'NRF'
},
{
'date': '2011-11-01',
'description': 'Allerheiligen',
'locale': 'de-DE',
'notes': '',
'region': 'SL',
'type': 'NRF'
},
{
'date': '2011-11-16',
'description': 'Buß- und Bettag',
'locale': 'de-DE',
'notes': '',
'region': 'SN',
'type': 'NRV'
},
{
'date': '2011-12-24',
'description': 'Heilig Abend',
'locale': 'de-DE',
'notes': '',
'region': '',
'type': 'NRF'
},
{
'date': '2011-12-25',
'description': 'Weihnachtstag',
'locale': 'de-DE',
'notes': '',
'region': '',
'type': 'NRF'
},
{
'date': '2011-12-26',
'description': 'Zweiter Weihnachtstag',
'locale': 'de-DE',
'notes': '',
'region': '',
'type': 'NRF'
},
{
'date': '2011-12-31',
'description': 'Silvester',
'locale': 'de-DE',
'notes': '',
'region': '',
'type': 'NF'
}
] |
# coding: utf-8
class DataBatch:
def __init__(self, mxnet_module):
self._data = []
self._label = []
self.mxnet_module = mxnet_module
def append_data(self, new_data):
self._data.append(self.__as_ndarray(new_data))
def append_label(self, new_label):
self._label.append(self.__as_ndarray(new_label))
def __as_ndarray(self, in_data):
return self.mxnet_module.ndarray.array(in_data, self.mxnet_module.cpu())
@property
def data(self):
return self._data
@property
def label(self):
return self._label
|
"""
File: weather_master.py
Name: DiCheng
-----------------------
This program should implement a console program
that asks weather data from user to compute the
average, highest, lowest, cold days among the inputs.
Output format should match what is shown in the sample
run in the Assignment 2 Handout.
"""
# enter EXIT_CODE to exit while loop
EXIT_CODE = -100
def main():
"""
pre-cond: User can enter series of temperatures, using hint number to quit enter.
post-cond: stanCode "Weather Master 4.0" will give you highest, lowest, average temperatures
and the count of cold days among given numbers.
"""
print("stanCode \"Weather Master 4.0\"!")
# define variables
data = int(input("Next Temperature: (or " + str(EXIT_CODE) + " to quit)? "))
data_highest = data
data_lowest = data
data_sum = 0
data_count = 0
cold_days_count = 0
while data != EXIT_CODE:
# calculate count of data and summary of data.
data_count += 1
data_sum += data
# compare data with current data_highest and data_lowest, then reassign variables if True.
if data > data_highest:
data_highest = data
if data < data_lowest:
data_lowest = data
# count the number of data which is under 16.
if data < 16:
cold_days_count += 1
data = int(input("Next Temperature: (or " + str(EXIT_CODE) + " to quit)? "))
# EXIT entering input, print the outcomes.
if data_count != 0:
print("Highest temperature = " + str(data_highest))
print("Lowest temperature = " + str(data_lowest))
print("Average = " + str(data_sum/data_count))
print(str(cold_days_count) + " cold day(s)")
else:
print("No temperatures were entered.")
###### DO NOT EDIT CODE BELOW THIS LINE ######
if __name__ == "__main__":
main()
|
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def maxLevelSum(self, root: TreeNode) -> int:
if root is None:
return 0
result, current = [], [root]
while current:
next_level, vals = [], []
for node in current:
vals.append(node.val)
if node.left:
next_level.append(node.left)
if node.right:
next_level.append(node.right)
current = next_level
result.append(vals)
result = [sum(i) for i in result]
print(result)
for idx, v in enumerate(result):
if v == max(result):
return idx+1
|
test = {
'name': 'Question 4',
'points': 1,
'suites': [
{
'cases': [
{
'code': r"""
>>> is_swap(19, 91)
False
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(19, 19)
True
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(123, 12)
False
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(1, 2)
False
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(12, 2)
True
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(2, 2)
True
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(36, 35)
True
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(114, 12)
True
>>> is_swap(108, 7)
False
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(18, 108)
True
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(8, 108)
True
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(20, 0)
False
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> is_swap(10, 16)
True
""",
'hidden': False,
'locked': False
}
],
'scored': True,
'setup': r"""
>>> from hog import *
""",
'teardown': '',
'type': 'doctest'
}
]
}
|
class Registry(dict):
def __init__(self, *args, **kwargs):
super(Registry, self).__init__(*args, **kwargs)
def register(self, module_name):
def register_fn(module):
assert module_name not in self
self[module_name] = module
return module
return register_fn
|
def findCandidate(A):
maj_index = 0
count = 1
for i in range(len(A)):
if A[maj_index] == A[i]: count += 1
else: count -= 1
if count == 0: maj_index, count = i, 1
return A[maj_index]
def isMajority(A, cand, k):
count = 0
for i in range(len(A)):
if A[i] == cand: count += 1
if count > len(A)/k: return True
else: return False
def printMajority(A, k):
cand = findCandidate(A)
if isMajority(A, cand, k) == True:
print(cand)
else:
print("No Majority Element")
printMajority([4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,4, 4, 5, 6, 7, 8, 4, 4, 5, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4], 3) |
# unihernandez22
# https://atcoder.jp/contests/abc159/tasks/abc159_a
# math
print(sum(map(lambda i: int(i)*(int(i)-1)//2, input().split())))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.