content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
newdata = []
with open("requirements.txt") as f:
data = f.read()
data = data.split("\n")
for i in data:
if "@" not in i:
newdata.append(i)
# print(newdata)
file = open("requirements.txt", "w")
# print("".join(newdata) + "\n")
for i in newdata:
print(i)
file.write(i + "\n")
| newdata = []
with open('requirements.txt') as f:
data = f.read()
data = data.split('\n')
for i in data:
if '@' not in i:
newdata.append(i)
file = open('requirements.txt', 'w')
for i in newdata:
print(i)
file.write(i + '\n') |
source = r'''#include <cstdio>
#include "mylib.h"
void do_something_else()
{
printf("something else\n");
}'''
print(source)
| source = '#include <cstdio>\n#include "mylib.h"\n\nvoid do_something_else()\n{\n printf("something else\\n");\n}'
print(source) |
print(' ')
print('-------Menghitung laba seorang pengusaha-------')
a=100000000
sum=0
b=0
laba=[int(0),int(0),int(a)*.1,int(a)*.1,int(a)*.5,int(a)*.5,int(a)*.5,int(a)*.2]
print('')
print('Modal seorang pengusaha :',a)
print(' ')
for i in laba:
sum=sum+i
b+=1
print('Laba Bulan ke -',b,'Sebesar :',i)
print(' ')
print('Total laba yang didapat pengusaha :', sum) | print(' ')
print('-------Menghitung laba seorang pengusaha-------')
a = 100000000
sum = 0
b = 0
laba = [int(0), int(0), int(a) * 0.1, int(a) * 0.1, int(a) * 0.5, int(a) * 0.5, int(a) * 0.5, int(a) * 0.2]
print('')
print('Modal seorang pengusaha :', a)
print(' ')
for i in laba:
sum = sum + i
b += 1
print('Laba Bulan ke -', b, 'Sebesar :', i)
print(' ')
print('Total laba yang didapat pengusaha :', sum) |
#!python3
msn = 0
for x in range(3,1000000) :
n = x
csn = 0
while n != 1 :
if n % 2 == 0 :
n = int(n / 2)
else :
n = n * 3 +1
csn += 1
if csn > msn :
msn = csn
sn = x
print(sn) | msn = 0
for x in range(3, 1000000):
n = x
csn = 0
while n != 1:
if n % 2 == 0:
n = int(n / 2)
else:
n = n * 3 + 1
csn += 1
if csn > msn:
msn = csn
sn = x
print(sn) |
def day01_1(input_data):
result = 0
for i in range(len(input_data)):
if int(input_data[i]) == int(input_data[(i + 1) % len(input_data)]):
result += int(input_data[i])
return result
def day01_2(input_data):
result = 0
for i in range(len(input_data)):
if int(input_data[i]) == int(input_data[(i + int(len(input_data) / 2)) % len(input_data)]):
result += int(input_data[i])
return result
| def day01_1(input_data):
result = 0
for i in range(len(input_data)):
if int(input_data[i]) == int(input_data[(i + 1) % len(input_data)]):
result += int(input_data[i])
return result
def day01_2(input_data):
result = 0
for i in range(len(input_data)):
if int(input_data[i]) == int(input_data[(i + int(len(input_data) / 2)) % len(input_data)]):
result += int(input_data[i])
return result |
class Fuzzy_logical_relationship(object):
def __init__(self, lhs, rhs):
self.lhs = lhs
self.rhs = rhs
def __str__(self):
return str(self.lhs) + " -> " + str(self.rhs) | class Fuzzy_Logical_Relationship(object):
def __init__(self, lhs, rhs):
self.lhs = lhs
self.rhs = rhs
def __str__(self):
return str(self.lhs) + ' -> ' + str(self.rhs) |
random_list = tuple(range(0, 1000))
def just_mean(x):
total = 0
for xi in x:
total += xi
return total / len(x)
mean_output = just_mean(random_list)
| random_list = tuple(range(0, 1000))
def just_mean(x):
total = 0
for xi in x:
total += xi
return total / len(x)
mean_output = just_mean(random_list) |
INVALID_INPUT = 1
DOCKER_ERROR = 2
UNKNOWN_ERROR = 3
class DkrException(Exception):
def __init__(self, message, exit_code):
self.message = message
self.exit_code = exit_code | invalid_input = 1
docker_error = 2
unknown_error = 3
class Dkrexception(Exception):
def __init__(self, message, exit_code):
self.message = message
self.exit_code = exit_code |
class Action:
def __init__(self, unit, target):
self.unit = unit
self.target = target
def complete(self):
self.unit.walked = []
self.unit.action = None
self.unit._flee_or_fight_if_enemy()
def update(self):
pass
class MoveAction(Action):
def update(self):
if hasattr(self.target, "other_side"):
# move towards the center of the next square
self.unit.go_to_xy(self.target.other_side.place.x, self.target.other_side.place.y)
elif getattr(self.target, "place", None) is self.unit.place:
self.unit.action_reach_and_use()
elif self.unit.airground_type == "air":
self.unit.go_to_xy(self.target.x, self.target.y)
else:
self.complete()
class MoveXYAction(Action):
timer = 15 # 5 seconds # XXXXXXXX not beautiful
def update(self):
if self.timer > 0:
self.timer -= 1
x, y = self.target
if self.unit.go_to_xy(x, y):
self.complete()
else:
self.complete()
class AttackAction(Action):
def update(self): # without moving to another square
if self.unit.range and self.target in self.unit.place.objects:
self.unit.action_reach_and_use()
elif self.unit.can_attack(self.target):
self.unit.aim(self.target)
else:
self.complete()
| class Action:
def __init__(self, unit, target):
self.unit = unit
self.target = target
def complete(self):
self.unit.walked = []
self.unit.action = None
self.unit._flee_or_fight_if_enemy()
def update(self):
pass
class Moveaction(Action):
def update(self):
if hasattr(self.target, 'other_side'):
self.unit.go_to_xy(self.target.other_side.place.x, self.target.other_side.place.y)
elif getattr(self.target, 'place', None) is self.unit.place:
self.unit.action_reach_and_use()
elif self.unit.airground_type == 'air':
self.unit.go_to_xy(self.target.x, self.target.y)
else:
self.complete()
class Movexyaction(Action):
timer = 15
def update(self):
if self.timer > 0:
self.timer -= 1
(x, y) = self.target
if self.unit.go_to_xy(x, y):
self.complete()
else:
self.complete()
class Attackaction(Action):
def update(self):
if self.unit.range and self.target in self.unit.place.objects:
self.unit.action_reach_and_use()
elif self.unit.can_attack(self.target):
self.unit.aim(self.target)
else:
self.complete() |
a=int(input("enter first number:"))
b=int(input("enter second number:"))
sum=0
for i in range (a,b+1):
sum=sum+i
print(sum)
| a = int(input('enter first number:'))
b = int(input('enter second number:'))
sum = 0
for i in range(a, b + 1):
sum = sum + i
print(sum) |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
# @param {integer[]} preorder
# @param {integer[]} inorder
# @return {TreeNode}
def buildTree(self, preorder, inorder):
if not preorder or not inorder:
return None
n1,n2 = len(preorder), len(inorder)
if n1!=n2 or n1 == 0:
return None
root = TreeNode(0)
st = [root]
i = 0
j = 0
last_pop= root
while(i < n1):
num = preorder[i]
node = TreeNode(num)
if last_pop != None:
last_pop.right = node
st.append(node)
last_pop = None
else:
last = st[-1]
last.left = node
st.append(node)
while(j < n1 and st[-1].val == inorder[j]):
last_pop = st.pop()
j += 1
i+=1
return root.right
| class Solution:
def build_tree(self, preorder, inorder):
if not preorder or not inorder:
return None
(n1, n2) = (len(preorder), len(inorder))
if n1 != n2 or n1 == 0:
return None
root = tree_node(0)
st = [root]
i = 0
j = 0
last_pop = root
while i < n1:
num = preorder[i]
node = tree_node(num)
if last_pop != None:
last_pop.right = node
st.append(node)
last_pop = None
else:
last = st[-1]
last.left = node
st.append(node)
while j < n1 and st[-1].val == inorder[j]:
last_pop = st.pop()
j += 1
i += 1
return root.right |
while 1:
a = 1
break
print(a) # pass
| while 1:
a = 1
break
print(a) |
# Migration removed because it depends on models which have been removed
def run():
return False | def run():
return False |
#-----------------------------------------------------------------#
#! Python3
# Author : NK
# Month, Year : March, 2019
# Info : Program to get Squares of numbers upto 25, using return
# Desc : An example program to show usage of return
#-----------------------------------------------------------------#
def nextSquare(x):
return x*x
def main():
for x in range(25):
print(nextSquare(x))
if __name__ == '__main__':
main() | def next_square(x):
return x * x
def main():
for x in range(25):
print(next_square(x))
if __name__ == '__main__':
main() |
def get_planet_name(id):
tmp = {
1: "Mercury",
2: "Venus",
3: "Earth",
4: "Mars",
5: "Jupiter",
6: "Saturn",
7: "Uranus",
8: "Neptune"
}
return tmp[id]
| def get_planet_name(id):
tmp = {1: 'Mercury', 2: 'Venus', 3: 'Earth', 4: 'Mars', 5: 'Jupiter', 6: 'Saturn', 7: 'Uranus', 8: 'Neptune'}
return tmp[id] |
class Solution:
def successfulPairs(self, spells: List[int], potions: List[int], success: int) -> List[int]:
potions = [(val, idx) for idx, val in enumerate(potions)]
potions.sort()
spells = [(val, idx) for idx, val in enumerate(spells)]
spells.sort()
left = 0
right = len(potions) - 1
res = [0] * len(spells)
while left < len(spells):
while right >= 0 and spells[left][0] * potions[right][0] >= success:
right -= 1
res[spells[left][1]] = max(res[left], len(potions) - right - 1)
left += 1
return res
| class Solution:
def successful_pairs(self, spells: List[int], potions: List[int], success: int) -> List[int]:
potions = [(val, idx) for (idx, val) in enumerate(potions)]
potions.sort()
spells = [(val, idx) for (idx, val) in enumerate(spells)]
spells.sort()
left = 0
right = len(potions) - 1
res = [0] * len(spells)
while left < len(spells):
while right >= 0 and spells[left][0] * potions[right][0] >= success:
right -= 1
res[spells[left][1]] = max(res[left], len(potions) - right - 1)
left += 1
return res |
#
# PySNMP MIB module SONOMASYSTEMS-SONOMA-IPAPPS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SONOMASYSTEMS-SONOMA-IPAPPS-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:09:25 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, ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint")
ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup")
Unsigned32, Bits, MibScalar, MibTable, MibTableRow, MibTableColumn, ModuleIdentity, Gauge32, Counter32, Integer32, IpAddress, iso, Counter64, ObjectIdentity, TimeTicks, MibIdentifier, NotificationType = mibBuilder.importSymbols("SNMPv2-SMI", "Unsigned32", "Bits", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ModuleIdentity", "Gauge32", "Counter32", "Integer32", "IpAddress", "iso", "Counter64", "ObjectIdentity", "TimeTicks", "MibIdentifier", "NotificationType")
TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString")
sonomaApplications, = mibBuilder.importSymbols("SONOMASYSTEMS-SONOMA-MIB", "sonomaApplications")
ipApplications = MibIdentifier((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1))
bootpGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 1))
pingGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 2))
class DisplayString(OctetString):
pass
tftpFileServerIpAddress = MibScalar((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 1, 1), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: tftpFileServerIpAddress.setStatus('mandatory')
if mibBuilder.loadTexts: tftpFileServerIpAddress.setDescription('The IP Address of the file server to use for image and parameter file downloads and uploads.')
tftpFileName = MibScalar((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 1, 2), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 127))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: tftpFileName.setStatus('mandatory')
if mibBuilder.loadTexts: tftpFileName.setDescription('The path and name of the file to be uploaded or downloaded. This string is 128 charachters long, any longer causes problems fro Windown NT or Windows 95. This length is recommended in RFC 1542.')
tftpImageNumber = MibScalar((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8))).clone(namedValues=NamedValues(("image1", 1), ("image2", 2), ("image3", 3), ("image4", 4), ("image5", 5), ("image6", 6), ("image7", 7), ("image8", 8))).clone('image1')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: tftpImageNumber.setStatus('mandatory')
if mibBuilder.loadTexts: tftpImageNumber.setDescription('The Image number (1 - 8) for the operational image file to be downloaded to. In the case of BOOTP the image will be stored in the BOOTP/ directory in flash')
tftpFileAction = MibScalar((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))).clone(namedValues=NamedValues(("noAction", 1), ("startBootPImageDownload", 2), ("startTFTPImageDownload", 3), ("startPrimaryImageTFTPDownload", 4), ("startSecondaryImageTFTPDownload", 5), ("startTFTPParameterBinDownload", 6), ("startTFTPParameterTextDownload", 7), ("startTFTPParameterBinUpload", 8), ("startTFTPParameterTextUpload", 9), ("startTFTPProfileDownload", 10))).clone('noAction')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: tftpFileAction.setStatus('mandatory')
if mibBuilder.loadTexts: tftpFileAction.setDescription("This object is used to initiate file transfer between this unit and the file server identified by tftpFileServerIpAddress. A download indicates that the file transfer is from the file server (down) to the device. An upload indicates a file transfer from the device (up) to the server. This object can be used to initiate either image or parameter file downloads and a parameter file upload. There is no image file upload feature. An image file can be downloaded via either a BootP request (where the image filename and the BootP server's IP Address is unknown) or via a TFTP request where the user has configured the tftpFileName object with the path and name of the file. BootP cannot be used to download or upload a parameter file. An attempt to set this object to one of the following values: startTFTPImageDownload, startTFTPParameterDownload or startTFTPParameterUpload, will fail if either the tftpFileName or tftpFileServerIpAddress object has not bee configured. The tftpFileName and tftpFileServerIpAddress objects are ignored for BootP requests. A value of noAction is always returned to a GetRequest. Seting this object with a value of noAction has no effect. The startPrimaryImageTFTPDownload is used to initiate the download of the primary boot image. This image is only downloaded when there is a new revision of the basic boot mechanism or changes to the flash or CMOS sub-systems.")
tftpFileTransferStatus = MibScalar((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18))).clone(namedValues=NamedValues(("idle", 1), ("downloading", 2), ("uploading", 3), ("programmingflash", 4), ("failBootpNoServer", 5), ("failTFTPNoFile", 6), ("errorServerResponse", 7), ("failTFTPInvalidFile", 8), ("failNetworkTimeout", 9), ("failFlashProgError", 10), ("failFlashChksumError", 11), ("errorServerData", 12), ("uploadResultUnknown", 13), ("uploadSuccessful", 14), ("downloadSuccessful", 15), ("generalFailure", 16), ("failCannotOverwriteActiveImage", 17), ("failCannotOverwriteActiveParam", 18)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: tftpFileTransferStatus.setStatus('mandatory')
if mibBuilder.loadTexts: tftpFileTransferStatus.setDescription('This is the current status of the file transfer process.')
pingIpAddress = MibScalar((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 2, 1), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: pingIpAddress.setStatus('mandatory')
if mibBuilder.loadTexts: pingIpAddress.setDescription(' The IP Address to Ping')
pingTimeout = MibScalar((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 2, 2), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: pingTimeout.setStatus('mandatory')
if mibBuilder.loadTexts: pingTimeout.setDescription('This is the timeout, in seconds, for a ping.')
pingRetries = MibScalar((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 2, 3), Integer32().clone(1)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: pingRetries.setStatus('mandatory')
if mibBuilder.loadTexts: pingRetries.setDescription(' This value indicates the number of times, to ping. A value of 1 is the default and insicates that the unit will send one pingp. 0 means no action.')
pingStatus = MibScalar((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 2, 4), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 256))).setMaxAccess("readonly")
if mibBuilder.loadTexts: pingStatus.setStatus('mandatory')
if mibBuilder.loadTexts: pingStatus.setDescription(' A text string which indicates the result or status of the last ping which the unit sent.')
pingAction = MibScalar((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 2, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("start", 1), ("stop", 2), ("noAction", 3))).clone('noAction')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: pingAction.setStatus('mandatory')
if mibBuilder.loadTexts: pingAction.setDescription('Indicates whether to stop or start a ping. This always returns the value noAction to a Get Request.')
mibBuilder.exportSymbols("SONOMASYSTEMS-SONOMA-IPAPPS-MIB", tftpFileTransferStatus=tftpFileTransferStatus, tftpImageNumber=tftpImageNumber, pingRetries=pingRetries, pingGroup=pingGroup, ipApplications=ipApplications, tftpFileAction=tftpFileAction, tftpFileServerIpAddress=tftpFileServerIpAddress, pingTimeout=pingTimeout, pingAction=pingAction, pingStatus=pingStatus, pingIpAddress=pingIpAddress, bootpGroup=bootpGroup, DisplayString=DisplayString, tftpFileName=tftpFileName)
| (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_union, single_value_constraint, constraints_intersection, value_size_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueRangeConstraint', 'ConstraintsUnion', 'SingleValueConstraint', 'ConstraintsIntersection', 'ValueSizeConstraint')
(module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup')
(unsigned32, bits, mib_scalar, mib_table, mib_table_row, mib_table_column, module_identity, gauge32, counter32, integer32, ip_address, iso, counter64, object_identity, time_ticks, mib_identifier, notification_type) = mibBuilder.importSymbols('SNMPv2-SMI', 'Unsigned32', 'Bits', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'ModuleIdentity', 'Gauge32', 'Counter32', 'Integer32', 'IpAddress', 'iso', 'Counter64', 'ObjectIdentity', 'TimeTicks', 'MibIdentifier', 'NotificationType')
(textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString')
(sonoma_applications,) = mibBuilder.importSymbols('SONOMASYSTEMS-SONOMA-MIB', 'sonomaApplications')
ip_applications = mib_identifier((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1))
bootp_group = mib_identifier((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 1))
ping_group = mib_identifier((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 2))
class Displaystring(OctetString):
pass
tftp_file_server_ip_address = mib_scalar((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 1, 1), ip_address()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
tftpFileServerIpAddress.setStatus('mandatory')
if mibBuilder.loadTexts:
tftpFileServerIpAddress.setDescription('The IP Address of the file server to use for image and parameter file downloads and uploads.')
tftp_file_name = mib_scalar((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 1, 2), display_string().subtype(subtypeSpec=value_size_constraint(0, 127))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
tftpFileName.setStatus('mandatory')
if mibBuilder.loadTexts:
tftpFileName.setDescription('The path and name of the file to be uploaded or downloaded. This string is 128 charachters long, any longer causes problems fro Windown NT or Windows 95. This length is recommended in RFC 1542.')
tftp_image_number = mib_scalar((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8))).clone(namedValues=named_values(('image1', 1), ('image2', 2), ('image3', 3), ('image4', 4), ('image5', 5), ('image6', 6), ('image7', 7), ('image8', 8))).clone('image1')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
tftpImageNumber.setStatus('mandatory')
if mibBuilder.loadTexts:
tftpImageNumber.setDescription('The Image number (1 - 8) for the operational image file to be downloaded to. In the case of BOOTP the image will be stored in the BOOTP/ directory in flash')
tftp_file_action = mib_scalar((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))).clone(namedValues=named_values(('noAction', 1), ('startBootPImageDownload', 2), ('startTFTPImageDownload', 3), ('startPrimaryImageTFTPDownload', 4), ('startSecondaryImageTFTPDownload', 5), ('startTFTPParameterBinDownload', 6), ('startTFTPParameterTextDownload', 7), ('startTFTPParameterBinUpload', 8), ('startTFTPParameterTextUpload', 9), ('startTFTPProfileDownload', 10))).clone('noAction')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
tftpFileAction.setStatus('mandatory')
if mibBuilder.loadTexts:
tftpFileAction.setDescription("This object is used to initiate file transfer between this unit and the file server identified by tftpFileServerIpAddress. A download indicates that the file transfer is from the file server (down) to the device. An upload indicates a file transfer from the device (up) to the server. This object can be used to initiate either image or parameter file downloads and a parameter file upload. There is no image file upload feature. An image file can be downloaded via either a BootP request (where the image filename and the BootP server's IP Address is unknown) or via a TFTP request where the user has configured the tftpFileName object with the path and name of the file. BootP cannot be used to download or upload a parameter file. An attempt to set this object to one of the following values: startTFTPImageDownload, startTFTPParameterDownload or startTFTPParameterUpload, will fail if either the tftpFileName or tftpFileServerIpAddress object has not bee configured. The tftpFileName and tftpFileServerIpAddress objects are ignored for BootP requests. A value of noAction is always returned to a GetRequest. Seting this object with a value of noAction has no effect. The startPrimaryImageTFTPDownload is used to initiate the download of the primary boot image. This image is only downloaded when there is a new revision of the basic boot mechanism or changes to the flash or CMOS sub-systems.")
tftp_file_transfer_status = mib_scalar((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18))).clone(namedValues=named_values(('idle', 1), ('downloading', 2), ('uploading', 3), ('programmingflash', 4), ('failBootpNoServer', 5), ('failTFTPNoFile', 6), ('errorServerResponse', 7), ('failTFTPInvalidFile', 8), ('failNetworkTimeout', 9), ('failFlashProgError', 10), ('failFlashChksumError', 11), ('errorServerData', 12), ('uploadResultUnknown', 13), ('uploadSuccessful', 14), ('downloadSuccessful', 15), ('generalFailure', 16), ('failCannotOverwriteActiveImage', 17), ('failCannotOverwriteActiveParam', 18)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
tftpFileTransferStatus.setStatus('mandatory')
if mibBuilder.loadTexts:
tftpFileTransferStatus.setDescription('This is the current status of the file transfer process.')
ping_ip_address = mib_scalar((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 2, 1), ip_address()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
pingIpAddress.setStatus('mandatory')
if mibBuilder.loadTexts:
pingIpAddress.setDescription(' The IP Address to Ping')
ping_timeout = mib_scalar((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 2, 2), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
pingTimeout.setStatus('mandatory')
if mibBuilder.loadTexts:
pingTimeout.setDescription('This is the timeout, in seconds, for a ping.')
ping_retries = mib_scalar((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 2, 3), integer32().clone(1)).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
pingRetries.setStatus('mandatory')
if mibBuilder.loadTexts:
pingRetries.setDescription(' This value indicates the number of times, to ping. A value of 1 is the default and insicates that the unit will send one pingp. 0 means no action.')
ping_status = mib_scalar((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 2, 4), display_string().subtype(subtypeSpec=value_size_constraint(0, 256))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
pingStatus.setStatus('mandatory')
if mibBuilder.loadTexts:
pingStatus.setDescription(' A text string which indicates the result or status of the last ping which the unit sent.')
ping_action = mib_scalar((1, 3, 6, 1, 4, 1, 2926, 25, 8, 1, 2, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('start', 1), ('stop', 2), ('noAction', 3))).clone('noAction')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
pingAction.setStatus('mandatory')
if mibBuilder.loadTexts:
pingAction.setDescription('Indicates whether to stop or start a ping. This always returns the value noAction to a Get Request.')
mibBuilder.exportSymbols('SONOMASYSTEMS-SONOMA-IPAPPS-MIB', tftpFileTransferStatus=tftpFileTransferStatus, tftpImageNumber=tftpImageNumber, pingRetries=pingRetries, pingGroup=pingGroup, ipApplications=ipApplications, tftpFileAction=tftpFileAction, tftpFileServerIpAddress=tftpFileServerIpAddress, pingTimeout=pingTimeout, pingAction=pingAction, pingStatus=pingStatus, pingIpAddress=pingIpAddress, bootpGroup=bootpGroup, DisplayString=DisplayString, tftpFileName=tftpFileName) |
#!/usr/bin/env python3
'''Iterate over multiple sequences in parallel using zip() function
NOET:
zip() stops when the shortest sequence is done
'''
# Init
days = ['Monday', 'Tuesday', 'Wednesday']
fruits = ['banana', 'orange', 'peach']
drinks = ['coffee', 'tea', 'beer']
desserts = ['tiramisu', 'ice cream', 'pie', 'pudding']
for day, fruit, drink, dessert in zip(days, fruits, drinks, desserts) :
print(day, ': drink', drink, '- eat', fruit, '- enjoy', dessert)
| """Iterate over multiple sequences in parallel using zip() function
NOET:
zip() stops when the shortest sequence is done
"""
days = ['Monday', 'Tuesday', 'Wednesday']
fruits = ['banana', 'orange', 'peach']
drinks = ['coffee', 'tea', 'beer']
desserts = ['tiramisu', 'ice cream', 'pie', 'pudding']
for (day, fruit, drink, dessert) in zip(days, fruits, drinks, desserts):
print(day, ': drink', drink, '- eat', fruit, '- enjoy', dessert) |
name=input("Please input my daughter's name:")
while name!="Nina" and name!="Anime":
print("I'm sorry, but the name is not valid.")
name=input("Please input my daughter's name:")
print("Yes."+name+"is my daughter.")
| name = input("Please input my daughter's name:")
while name != 'Nina' and name != 'Anime':
print("I'm sorry, but the name is not valid.")
name = input("Please input my daughter's name:")
print('Yes.' + name + 'is my daughter.') |
cases = [
('pmt -s 1 -n 20 populations, use seed so same run each time',
'pmt -s 1 -n 20 populations'),
('pmt -s 2 -n 6 populations, use seed so same run each time',
'pmt -s 2 -n 6 -r 3 populations')
]
| cases = [('pmt -s 1 -n 20 populations, use seed so same run each time', 'pmt -s 1 -n 20 populations'), ('pmt -s 2 -n 6 populations, use seed so same run each time', 'pmt -s 2 -n 6 -r 3 populations')] |
{
"hawq": {
"master": "localhost",
"standby": "",
"port": 5432,
"user": "johnsaxon",
"password": "test",
"database": "postgres"
},
"data_config": {
"schema": "public",
"table": "elec_tiny",
"features": [
{
"name": "id",
"type": "categorical",
"cates": [
"2019-01-20",
"2019-03-01",
"2019-04-20",
"2018-09-10",
"2018-12-01",
"2019-01-01",
"2019-02-20",
"2019-04-10",
"2018-09-20",
"2018-10-01",
"2019-02-01",
"2018-10-20",
"2018-11-10",
"2018-12-10",
"2018-12-20",
"2019-01-10",
"2019-03-10",
"2019-04-01",
"2018-10-10",
"2018-11-01",
"2018-11-20",
"2019-02-10",
"2019-03-20",
"2018-09-01"
]
},
{
"name": "stat_date",
"type": "n",
"cates": []
},
{
"name": "meter_id",
"type": "n",
"cates": []
},
{
"name": "energy_mean",
"type": "n",
"cates": []
},
{
"name": "energy_max",
"type": "n",
"cates": []
},
{
"name": "energy_min",
"type": "n",
"cates": []
},
{
"name": "energy_sum",
"type": "n",
"cates": []
},
{
"name": "energy_std",
"type": "n",
"cates": []
},
{
"name": "power_mean",
"type": "n",
"cates": []
},
{
"name": "power_max",
"type": "n",
"cates": []
},
{
"name": "power_min",
"type": "n",
"cates": []
},
{
"name": "power_std",
"type": "n",
"cates": []
},
{
"name": "cur_mean",
"type": "n",
"cates": []
},
{
"name": "cur_max",
"type": "n",
"cates": []
},
{
"name": "cur_min",
"type": "n",
"cates": []
},
{
"name": "cur_std",
"type": "n",
"cates": []
},
{
"name": "vol_mean",
"type": "n",
"cates": []
},
{
"name": "vol_max",
"type": "n",
"cates": []
},
{
"name": "vol_min",
"type": "n",
"cates": []
},
{
"name": "vol_std",
"type": "n",
"cates": []
},
{
"name": "x",
"type": "n",
"cates": []
},
{
"name": "avg_h8",
"type": "n",
"cates": []
},
{
"name": "avg_t_8",
"type": "n",
"cates": []
},
{
"name": "avg_ws_h",
"type": "n",
"cates": []
},
{
"name": "avg_wd_h",
"type": "n",
"cates": []
},
{
"name": "max_h8",
"type": "n",
"cates": []
},
{
"name": "max_t_8",
"type": "n",
"cates": []
},
{
"name": "max_ws_h",
"type": "n",
"cates": []
},
{
"name": "min_h8",
"type": "n",
"cates": []
},
{
"name": "min_t_8",
"type": "n",
"cates": []
},
{
"name": "min_ws_h",
"type": "n",
"cates": []
},
{
"name": "avg_irradiance",
"type": "n",
"cates": []
},
{
"name": "max_irradiance",
"type": "n",
"cates": []
},
{
"name": "min_irradiance",
"type": "n",
"cates": []
}
],
"label": {
"name": "load",
"type": "n",
"cates": []
}
},
"task": {
"type": 1,
"algorithm": 1,
"warm_start": false,
"estimators": 3,
"incre": 1,
"batch": 1000
}
} | {'hawq': {'master': 'localhost', 'standby': '', 'port': 5432, 'user': 'johnsaxon', 'password': 'test', 'database': 'postgres'}, 'data_config': {'schema': 'public', 'table': 'elec_tiny', 'features': [{'name': 'id', 'type': 'categorical', 'cates': ['2019-01-20', '2019-03-01', '2019-04-20', '2018-09-10', '2018-12-01', '2019-01-01', '2019-02-20', '2019-04-10', '2018-09-20', '2018-10-01', '2019-02-01', '2018-10-20', '2018-11-10', '2018-12-10', '2018-12-20', '2019-01-10', '2019-03-10', '2019-04-01', '2018-10-10', '2018-11-01', '2018-11-20', '2019-02-10', '2019-03-20', '2018-09-01']}, {'name': 'stat_date', 'type': 'n', 'cates': []}, {'name': 'meter_id', 'type': 'n', 'cates': []}, {'name': 'energy_mean', 'type': 'n', 'cates': []}, {'name': 'energy_max', 'type': 'n', 'cates': []}, {'name': 'energy_min', 'type': 'n', 'cates': []}, {'name': 'energy_sum', 'type': 'n', 'cates': []}, {'name': 'energy_std', 'type': 'n', 'cates': []}, {'name': 'power_mean', 'type': 'n', 'cates': []}, {'name': 'power_max', 'type': 'n', 'cates': []}, {'name': 'power_min', 'type': 'n', 'cates': []}, {'name': 'power_std', 'type': 'n', 'cates': []}, {'name': 'cur_mean', 'type': 'n', 'cates': []}, {'name': 'cur_max', 'type': 'n', 'cates': []}, {'name': 'cur_min', 'type': 'n', 'cates': []}, {'name': 'cur_std', 'type': 'n', 'cates': []}, {'name': 'vol_mean', 'type': 'n', 'cates': []}, {'name': 'vol_max', 'type': 'n', 'cates': []}, {'name': 'vol_min', 'type': 'n', 'cates': []}, {'name': 'vol_std', 'type': 'n', 'cates': []}, {'name': 'x', 'type': 'n', 'cates': []}, {'name': 'avg_h8', 'type': 'n', 'cates': []}, {'name': 'avg_t_8', 'type': 'n', 'cates': []}, {'name': 'avg_ws_h', 'type': 'n', 'cates': []}, {'name': 'avg_wd_h', 'type': 'n', 'cates': []}, {'name': 'max_h8', 'type': 'n', 'cates': []}, {'name': 'max_t_8', 'type': 'n', 'cates': []}, {'name': 'max_ws_h', 'type': 'n', 'cates': []}, {'name': 'min_h8', 'type': 'n', 'cates': []}, {'name': 'min_t_8', 'type': 'n', 'cates': []}, {'name': 'min_ws_h', 'type': 'n', 'cates': []}, {'name': 'avg_irradiance', 'type': 'n', 'cates': []}, {'name': 'max_irradiance', 'type': 'n', 'cates': []}, {'name': 'min_irradiance', 'type': 'n', 'cates': []}], 'label': {'name': 'load', 'type': 'n', 'cates': []}}, 'task': {'type': 1, 'algorithm': 1, 'warm_start': false, 'estimators': 3, 'incre': 1, 'batch': 1000}} |
{
"targets": [{
"target_name": "findGitRepos",
"dependencies": [
"vendor/openpa/openpa.gyp:openpa"
],
"sources": [
"cpp/src/FindGitRepos.cpp",
"cpp/src/Queue.cpp"
],
"include_dirs": [
"<!@(node -p \"require('node-addon-api').include\")",
"cpp/includes"
],
"defines": ["NAPI_DISABLE_CPP_EXCEPTIONS"],
"conditions": [
["OS=='win'", {
"msvs_settings": {
"VCCLCompilerTool": {
"DisableSpecificWarnings": [ "4506", "4538", "4793" ]
},
"VCLinkerTool": {
"AdditionalOptions": [ "/ignore:4248" ]
},
},
"defines": [
"OPA_HAVE_NT_INTRINSICS=1",
"_opa_inline=__inline"
],
"conditions": [
["target_arch=='x64'", {
"VCLibrarianTool": {
"AdditionalOptions": [
"/MACHINE:X64",
],
},
}, {
"VCLibrarianTool": {
"AdditionalOptions": [
"/MACHINE:x86",
],
},
}],
]
}],
["OS=='mac'", {
"cflags+": ["-fvisibility=hidden"],
"xcode_settings": {
"GCC_SYMBOLS_PRIVATE_EXTERN": "YES"
}
}],
["OS=='mac' or OS=='linux'", {
"defines": [
"OPA_HAVE_GCC_INTRINSIC_ATOMICS=1",
"HAVE_STDDEF_H=1",
"HAVE_STDLIB_H=1",
"HAVE_UNISTD_H=1"
]
}],
["target_arch=='x64' or target_arch=='arm64'", {
"defines": [
"OPA_SIZEOF_VOID_P=8"
]
}],
["target_arch=='ia32' or target_arch=='armv7'", {
"defines": [
"OPA_SIZEOF_VOID_P=4"
]
}]
],
}]
}
| {'targets': [{'target_name': 'findGitRepos', 'dependencies': ['vendor/openpa/openpa.gyp:openpa'], 'sources': ['cpp/src/FindGitRepos.cpp', 'cpp/src/Queue.cpp'], 'include_dirs': ['<!@(node -p "require(\'node-addon-api\').include")', 'cpp/includes'], 'defines': ['NAPI_DISABLE_CPP_EXCEPTIONS'], 'conditions': [["OS=='win'", {'msvs_settings': {'VCCLCompilerTool': {'DisableSpecificWarnings': ['4506', '4538', '4793']}, 'VCLinkerTool': {'AdditionalOptions': ['/ignore:4248']}}, 'defines': ['OPA_HAVE_NT_INTRINSICS=1', '_opa_inline=__inline'], 'conditions': [["target_arch=='x64'", {'VCLibrarianTool': {'AdditionalOptions': ['/MACHINE:X64']}}, {'VCLibrarianTool': {'AdditionalOptions': ['/MACHINE:x86']}}]]}], ["OS=='mac'", {'cflags+': ['-fvisibility=hidden'], 'xcode_settings': {'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES'}}], ["OS=='mac' or OS=='linux'", {'defines': ['OPA_HAVE_GCC_INTRINSIC_ATOMICS=1', 'HAVE_STDDEF_H=1', 'HAVE_STDLIB_H=1', 'HAVE_UNISTD_H=1']}], ["target_arch=='x64' or target_arch=='arm64'", {'defines': ['OPA_SIZEOF_VOID_P=8']}], ["target_arch=='ia32' or target_arch=='armv7'", {'defines': ['OPA_SIZEOF_VOID_P=4']}]]}]} |
# Using hash table
# Time Complexity: O(n)
class Solution:
def intersect(self, nums1: List[int], nums2: List[int]) -> List[int]:
checkDict =dict()
final = list()
for i in nums1:
if i not in checkDict:
checkDict[i] = 1
else:
checkDict[i] += 1
for i in nums2:
if i in checkDict:
if checkDict[i] > 0:
final.append(i)
checkDict[i] -= 1
return final
# Time Complexity: O(m + n)
def intersect(self, nums1: List[int], nums2: List[int]) -> List[int]:
final = list()
if len(nums1) < len(nums2):
sl = nums1
ll = nums2
else:
sl = nums2
ll = nums1
for i in range(len(sl)):
new = sl[i]
if new in ll:
ll.remove(new)
final.append(new)
return final
# Using sorted list
# Time Complexity: O(n*logn)
def intersect(self, nums1: List[int], nums2: List[int]) -> List[int]:
i, j = 0, 0
intersection = list()
nums1.sort()
nums2.sort()
# Handle empty array
if len(nums1) == 0:
return intersection
while i < len(nums1) and j < len(nums2):
if nums1[i] == nums2[j]:
# Check for unique elements
if nums1[i] != nums1[i-1] or i == 0:
intersection.append(nums1[i])
i += 1
j += 1
elif nums1[i] < nums2[j]:
i += 1
else:
j += 1
return intersection
| class Solution:
def intersect(self, nums1: List[int], nums2: List[int]) -> List[int]:
check_dict = dict()
final = list()
for i in nums1:
if i not in checkDict:
checkDict[i] = 1
else:
checkDict[i] += 1
for i in nums2:
if i in checkDict:
if checkDict[i] > 0:
final.append(i)
checkDict[i] -= 1
return final
def intersect(self, nums1: List[int], nums2: List[int]) -> List[int]:
final = list()
if len(nums1) < len(nums2):
sl = nums1
ll = nums2
else:
sl = nums2
ll = nums1
for i in range(len(sl)):
new = sl[i]
if new in ll:
ll.remove(new)
final.append(new)
return final
def intersect(self, nums1: List[int], nums2: List[int]) -> List[int]:
(i, j) = (0, 0)
intersection = list()
nums1.sort()
nums2.sort()
if len(nums1) == 0:
return intersection
while i < len(nums1) and j < len(nums2):
if nums1[i] == nums2[j]:
if nums1[i] != nums1[i - 1] or i == 0:
intersection.append(nums1[i])
i += 1
j += 1
elif nums1[i] < nums2[j]:
i += 1
else:
j += 1
return intersection |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class Names():
Chemical_Elemnts = ["Yb", "Pb", "Ca", "Ti", "Mo", "Sn", "Cd", "Ag", "La",
"Cs", "W", "Sb", "Ta", "V", "Fe", "Bi", "Ce", "Nb",
"Cu", "I", "B", "Te", "Al", "Zr", "Gd", "Na", "Ga",
"Cl", "S", "Si", "O", "F", "Mn", "Ba", "K", "Zn",
"N", "Li", "Ge", "Y", "Sr", "P", "Mg", "Er", "As"]
'''
Chemical_Compounds = ['Ag2O', 'Al2O3', 'As2O3', 'As2O5', 'B2O3', 'BaO',
'Bi2O3', 'CaO', 'CdO', 'Ce2O3', 'CeO2', 'Cl', 'Cs2O',
'Cu2O', 'CuO', 'Er2O3', 'F', 'Fe2O3', 'Fe3O4', 'FeO',
'Ga2O3', 'Gd2O3', 'GeO', 'GeO2', 'I', 'K2O', 'La2O3',
'Li2O', 'MgO', 'Mn2O3', 'Mn2O7', 'Mn3O4', 'MnO',
'MnO2', 'Mo2O3', 'Mo2O5', 'MoO', 'MoO2', 'MoO3',
'N', 'N2O5', 'NO2', 'Na2O', 'Nb2O3', 'Nb2O5',
'P2O3', 'P2O5', 'Pb3O4', 'PbO', 'PbO2', 'SO2',
'SO3', 'Sb2O3', 'Sb2O5', 'SbO2', 'SiO', 'SiO2',
'Sn2O3', 'SnO', 'SnO2', 'SrO', 'Ta2O3', 'Ta2O5',
'TeO2', 'TeO3', 'Ti2O3', 'TiO', 'TiO2', 'V2O3',
'V2O5', 'VO2', 'VO6', 'WO3', 'Y2O3', 'Yb2O3', 'ZnO',
'ZrO2']
'''
Chemical_Compounds = ['Ag2O', 'Al2O3', 'As2O3', 'As2O5', 'B2O3', 'BaO',
'Bi2O3', 'CaO', 'CdO', 'Ce2O3', 'CeO2', 'Cl', 'Cs2O',
'Cu2O', 'CuO', 'Er2O3', 'F', 'Fe2O3', 'Fe3O4', 'FeO',
'Ga2O3', 'Gd2O3', 'GeO2', 'I', 'K2O', 'La2O3',
'Li2O', 'MgO', 'Mn2O3', 'Mn2O7', 'Mn3O4', 'MnO',
'MnO2', 'Mo2O3', 'Mo2O5', 'MoO', 'MoO2', 'MoO3', 'N',
'N2O5', 'NO2', 'Na2O', 'Nb2O3', 'Nb2O5', 'P2O3',
'P2O5', 'Pb3O4', 'PbO', 'PbO2', 'SO2', 'SO3',
'Sb2O3', 'Sb2O5', 'SbO2', 'SiO2', 'Sn2O3',
'SnO', 'SnO2', 'SrO', 'Ta2O3', 'Ta2O5',
'TeO3', 'Ti2O3', 'TiO', 'TiO2', 'V2O3', 'V2O5',
'VO2', 'VO6', 'WO3', 'Y2O3', 'Yb2O3', 'ZnO', 'ZrO2']
| class Names:
chemical__elemnts = ['Yb', 'Pb', 'Ca', 'Ti', 'Mo', 'Sn', 'Cd', 'Ag', 'La', 'Cs', 'W', 'Sb', 'Ta', 'V', 'Fe', 'Bi', 'Ce', 'Nb', 'Cu', 'I', 'B', 'Te', 'Al', 'Zr', 'Gd', 'Na', 'Ga', 'Cl', 'S', 'Si', 'O', 'F', 'Mn', 'Ba', 'K', 'Zn', 'N', 'Li', 'Ge', 'Y', 'Sr', 'P', 'Mg', 'Er', 'As']
"\n Chemical_Compounds = ['Ag2O', 'Al2O3', 'As2O3', 'As2O5', 'B2O3', 'BaO',\n 'Bi2O3', 'CaO', 'CdO', 'Ce2O3', 'CeO2', 'Cl', 'Cs2O',\n 'Cu2O', 'CuO', 'Er2O3', 'F', 'Fe2O3', 'Fe3O4', 'FeO',\n 'Ga2O3', 'Gd2O3', 'GeO', 'GeO2', 'I', 'K2O', 'La2O3',\n 'Li2O', 'MgO', 'Mn2O3', 'Mn2O7', 'Mn3O4', 'MnO',\n 'MnO2', 'Mo2O3', 'Mo2O5', 'MoO', 'MoO2', 'MoO3',\n 'N', 'N2O5', 'NO2', 'Na2O', 'Nb2O3', 'Nb2O5',\n 'P2O3', 'P2O5', 'Pb3O4', 'PbO', 'PbO2', 'SO2',\n 'SO3', 'Sb2O3', 'Sb2O5', 'SbO2', 'SiO', 'SiO2',\n 'Sn2O3', 'SnO', 'SnO2', 'SrO', 'Ta2O3', 'Ta2O5',\n 'TeO2', 'TeO3', 'Ti2O3', 'TiO', 'TiO2', 'V2O3',\n 'V2O5', 'VO2', 'VO6', 'WO3', 'Y2O3', 'Yb2O3', 'ZnO',\n 'ZrO2']\n "
chemical__compounds = ['Ag2O', 'Al2O3', 'As2O3', 'As2O5', 'B2O3', 'BaO', 'Bi2O3', 'CaO', 'CdO', 'Ce2O3', 'CeO2', 'Cl', 'Cs2O', 'Cu2O', 'CuO', 'Er2O3', 'F', 'Fe2O3', 'Fe3O4', 'FeO', 'Ga2O3', 'Gd2O3', 'GeO2', 'I', 'K2O', 'La2O3', 'Li2O', 'MgO', 'Mn2O3', 'Mn2O7', 'Mn3O4', 'MnO', 'MnO2', 'Mo2O3', 'Mo2O5', 'MoO', 'MoO2', 'MoO3', 'N', 'N2O5', 'NO2', 'Na2O', 'Nb2O3', 'Nb2O5', 'P2O3', 'P2O5', 'Pb3O4', 'PbO', 'PbO2', 'SO2', 'SO3', 'Sb2O3', 'Sb2O5', 'SbO2', 'SiO2', 'Sn2O3', 'SnO', 'SnO2', 'SrO', 'Ta2O3', 'Ta2O5', 'TeO3', 'Ti2O3', 'TiO', 'TiO2', 'V2O3', 'V2O5', 'VO2', 'VO6', 'WO3', 'Y2O3', 'Yb2O3', 'ZnO', 'ZrO2'] |
# Build a Boolean mask to filter out all the 'LAX' departure flights: mask
mask = df['Destination Airport'] == 'LAX'
# Use the mask to subset the data: la
la = df[mask]
# Combine two columns of data to create a datetime series: times_tz_none
times_tz_none = pd.to_datetime( la['Date (MM/DD/YYYY)'] + ' ' + la['Wheels-off Time'] )
# Localize the time to US/Central: times_tz_central
times_tz_central = times_tz_none.dt.tz_localize('US/Central')
# Convert the datetimes from US/Central to US/Pacific
times_tz_pacific = times_tz_central.dt.tz_convert('US/Pacific')
| mask = df['Destination Airport'] == 'LAX'
la = df[mask]
times_tz_none = pd.to_datetime(la['Date (MM/DD/YYYY)'] + ' ' + la['Wheels-off Time'])
times_tz_central = times_tz_none.dt.tz_localize('US/Central')
times_tz_pacific = times_tz_central.dt.tz_convert('US/Pacific') |
'''
Given an unsorted array of integers, find the number of longest increasing subsequence.
Example 1:
Input: [1,3,5,4,7]
Output: 2
Explanation: The two longest increasing subsequence are [1, 3, 4, 7] and [1, 3, 5, 7].
Example 2:
Input: [2,2,2,2,2]
Output: 5
Explanation: The length of longest continuous increasing subsequence is 1, and there are 5 subsequences' length is 1, so output 5.
Note: Length of the given array will be not exceed 2000 and the answer is guaranteed to be fit in 32-bit signed int.
'''
class Solution(object):
def findNumberOfLIS(self, nums):
length = [1]*len(nums)
count = [1]*len(nums)
result = 0
for end, num in enumerate(nums):
for start in range(end):
if num > nums[start]:
if length[start] >= length[end]:
length[end] = 1+length[start]
count[end] = count[start]
elif length[start] + 1 == length[end]:
count[end] += count[start]
for index, max_subs in enumerate(count):
if length[index] == max(length):
result += max_subs
return result
| """
Given an unsorted array of integers, find the number of longest increasing subsequence.
Example 1:
Input: [1,3,5,4,7]
Output: 2
Explanation: The two longest increasing subsequence are [1, 3, 4, 7] and [1, 3, 5, 7].
Example 2:
Input: [2,2,2,2,2]
Output: 5
Explanation: The length of longest continuous increasing subsequence is 1, and there are 5 subsequences' length is 1, so output 5.
Note: Length of the given array will be not exceed 2000 and the answer is guaranteed to be fit in 32-bit signed int.
"""
class Solution(object):
def find_number_of_lis(self, nums):
length = [1] * len(nums)
count = [1] * len(nums)
result = 0
for (end, num) in enumerate(nums):
for start in range(end):
if num > nums[start]:
if length[start] >= length[end]:
length[end] = 1 + length[start]
count[end] = count[start]
elif length[start] + 1 == length[end]:
count[end] += count[start]
for (index, max_subs) in enumerate(count):
if length[index] == max(length):
result += max_subs
return result |
# python3
def solve(n, v):
#if sum(v) % 3 != 0:
# return False
res = []
values = []
s = sum(v)//3
for i in range(2**n):
bit = [0 for i in range(n)]
k = i
p = n-1
while k!=0:
bit[p] = (k%2)
k = k//2
p -= 1
#print(bit)
val = [a*b for a, b in zip(v, bit)]
#print(val)
if sum(val) == s:
res.append(bit)
values.append(i)
#print(res)
#print(values)
if len(res)<3:
return False
for i in range(len(values)-2):
for j in range(i+1, len(values)-1):
for k in range(i+2, len(values)):
a = values[i]
b = values[j]
c = values[k]
if a^b^c == (2**n-1):
return True
return False
if __name__ == '__main__':
n = int(input())
v = [int(i) for i in input().split()]
if solve(n, v):
print("1")
else:
print("0")
| def solve(n, v):
res = []
values = []
s = sum(v) // 3
for i in range(2 ** n):
bit = [0 for i in range(n)]
k = i
p = n - 1
while k != 0:
bit[p] = k % 2
k = k // 2
p -= 1
val = [a * b for (a, b) in zip(v, bit)]
if sum(val) == s:
res.append(bit)
values.append(i)
if len(res) < 3:
return False
for i in range(len(values) - 2):
for j in range(i + 1, len(values) - 1):
for k in range(i + 2, len(values)):
a = values[i]
b = values[j]
c = values[k]
if a ^ b ^ c == 2 ** n - 1:
return True
return False
if __name__ == '__main__':
n = int(input())
v = [int(i) for i in input().split()]
if solve(n, v):
print('1')
else:
print('0') |
# create string and dictionary
lines = ""
occurrences = {}
# prompt for lines
line = input("Enter line: ")
while line:
lines += line + " "
line = input("Enter line: ")
# iterate through each color and store count
for word in set(lines.split()):
occurrences[word] = lines.split().count(word)
# print results
for word in sorted(occurrences):
print(word, occurrences[word])
| lines = ''
occurrences = {}
line = input('Enter line: ')
while line:
lines += line + ' '
line = input('Enter line: ')
for word in set(lines.split()):
occurrences[word] = lines.split().count(word)
for word in sorted(occurrences):
print(word, occurrences[word]) |
# python3
n, m = map(int, input().split())
clauses = [ list(map(int, input().split())) for i in range(m) ]
# This solution tries all possible 2^n variable assignments.
# It is too slow to pass the problem.
# Implement a more efficient algorithm here.
def isSatisfiable():
for mask in range(1<<n):
result = [ (mask >> i) & 1 for i in range(n) ]
formulaIsSatisfied = True
for clause in clauses:
clauseIsSatisfied = False
if result[abs(clause[0]) - 1] == (clause[0] < 0):
clauseIsSatisfied = True
if result[abs(clause[1]) - 1] == (clause[1] < 0):
clauseIsSatisfied = True
if not clauseIsSatisfied:
formulaIsSatisfied = False
break
if formulaIsSatisfied:
return result
return None
result = isSatisfiable()
if result is None:
print("UNSATISFIABLE")
else:
print("SATISFIABLE");
print(" ".join(str(-i-1 if result[i] else i+1) for i in range(n)))
| (n, m) = map(int, input().split())
clauses = [list(map(int, input().split())) for i in range(m)]
def is_satisfiable():
for mask in range(1 << n):
result = [mask >> i & 1 for i in range(n)]
formula_is_satisfied = True
for clause in clauses:
clause_is_satisfied = False
if result[abs(clause[0]) - 1] == (clause[0] < 0):
clause_is_satisfied = True
if result[abs(clause[1]) - 1] == (clause[1] < 0):
clause_is_satisfied = True
if not clauseIsSatisfied:
formula_is_satisfied = False
break
if formulaIsSatisfied:
return result
return None
result = is_satisfiable()
if result is None:
print('UNSATISFIABLE')
else:
print('SATISFIABLE')
print(' '.join((str(-i - 1 if result[i] else i + 1) for i in range(n)))) |
class FlPosition:
def __init__(self, position_data, column_labels, timestamps, conversion):
self.position_data = position_data
self.column_labels = column_labels
self.timestamps = timestamps
self.conversion = conversion
| class Flposition:
def __init__(self, position_data, column_labels, timestamps, conversion):
self.position_data = position_data
self.column_labels = column_labels
self.timestamps = timestamps
self.conversion = conversion |
class Recipe:
def __init__(self, name, ingredients, yt_link):
self.name = name
self.ingredients = ingredients
self.yt_link = yt_link
self.similarity = 0
self.leftChild = None
self.rightChild = None
class BinarySearchTree:
def __init__(self):
self.root = None
def insert(self, recipe):
if not self.root:
self.root = recipe
else:
self.insertNode(recipe, self.root)
def insertNode(self, recipe, node):
if recipe.similarity < node.similarity:
if node.leftChild:
self.insertNode(recipe, node.leftChild)
else:
node.leftChild = recipe
else:
if node.rightChild:
self.insertNode(recipe, node.rightChild)
else:
node.rightChild = recipe
| class Recipe:
def __init__(self, name, ingredients, yt_link):
self.name = name
self.ingredients = ingredients
self.yt_link = yt_link
self.similarity = 0
self.leftChild = None
self.rightChild = None
class Binarysearchtree:
def __init__(self):
self.root = None
def insert(self, recipe):
if not self.root:
self.root = recipe
else:
self.insertNode(recipe, self.root)
def insert_node(self, recipe, node):
if recipe.similarity < node.similarity:
if node.leftChild:
self.insertNode(recipe, node.leftChild)
else:
node.leftChild = recipe
elif node.rightChild:
self.insertNode(recipe, node.rightChild)
else:
node.rightChild = recipe |
########################################################################
# Useful classes for implementing quantum heterostructures behavior #
# author: Thiago Melo #
# creation: 2018-11-09 #
# update: 2018-11-09 #
class Device(object):
def __init__(self):
pass | class Device(object):
def __init__(self):
pass |
def deco(func):
def temp():
print("-"*60)
func()
print("-"*60)
return temp
@deco
def print_h1():
print("body")
def main():
print_h1()
if __name__ == "__main__":
main() | def deco(func):
def temp():
print('-' * 60)
func()
print('-' * 60)
return temp
@deco
def print_h1():
print('body')
def main():
print_h1()
if __name__ == '__main__':
main() |
# linear search on sorted list
def search(L, e):
for i in range(len(L)):
if L[i] == e:
return True
if L[i] > e: # sorted
return False
return False
# O(n) for the loop and O(1) for the lookup to test if e == L[i]
# overall complexity is O(n) where n is len(L) | def search(L, e):
for i in range(len(L)):
if L[i] == e:
return True
if L[i] > e:
return False
return False |
def CheckPypi(auth, project):
projectInfo = auth.GetJson("https://pypi.org/pypi/" + project + "/json")
return projectInfo["info"]["version"]
| def check_pypi(auth, project):
project_info = auth.GetJson('https://pypi.org/pypi/' + project + '/json')
return projectInfo['info']['version'] |
# Exercise 3:
#
# In this exercise we will create a program that identifies whether someone can
# enter a super secret club.
# Below are the people that are allowed in the club.
# If your name is Bill Gates, Steve Jobs or Jesus, you should be allowed in the
# club.
# If your name is not one of the above, but your name is Maria and you are less
# than 30 years old, then you should be allowed in the club.
# If you don't fulfill the conditions above, but you are older than 100 years
# ol,d you should also be allowed.
# If none of the conditions are met, you shouldn't be allowed in the club.
print("What's your name?")
name = raw_input() # The raw_input() function allows you to get user input,
# don't worry about functions now.
print("What's your age?")
age = input()
if name == "Bill Gates" or name == "Steve Jobs" or name == "Jesus":
# print something saying that the guest was allowed in the club
# don't forget indentation.
print("You are welcomed in our fancy club!")
elif name == 'Maria' and age < 30:
print("You are welcomed in our fancy club!")
elif age > 100:
print("You are welcomed in our fancy club!")
else:
print("Get out! This club is only for special people!")
# print something saying that the guest was not allowed in the club
#
# Test out your program and see if it works as it is supposed to.
| print("What's your name?")
name = raw_input()
print("What's your age?")
age = input()
if name == 'Bill Gates' or name == 'Steve Jobs' or name == 'Jesus':
print('You are welcomed in our fancy club!')
elif name == 'Maria' and age < 30:
print('You are welcomed in our fancy club!')
elif age > 100:
print('You are welcomed in our fancy club!')
else:
print('Get out! This club is only for special people!') |
N, K = [int(a) for a in input().split()]
h = []
for _ in range(N):
h.append(int(input()))
sortedh = sorted(h)
min_ = 1e9
for i in range(N-K+1):
diff = sortedh[i+K-1] - sortedh[i]
min_ = min(min_, diff)
print(min_)
| (n, k) = [int(a) for a in input().split()]
h = []
for _ in range(N):
h.append(int(input()))
sortedh = sorted(h)
min_ = 1000000000.0
for i in range(N - K + 1):
diff = sortedh[i + K - 1] - sortedh[i]
min_ = min(min_, diff)
print(min_) |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by AKM_FAN@163.com on 2017/11/6
if __name__ == '__main__':
pass | if __name__ == '__main__':
pass |
# !/usr/bin/python
# -*- coding: utf-8 -*-
class Friends(object):
def __init__(self, connections):
super(Friends, self).__init__()
self._data = {}
self._add_connections(connections)
def add(self, connection):
is_exists = self.is_exists(connection)
self._add_connection(connection)
return (not is_exists)
def remove(self, connection):
is_exists = self.is_exists(connection)
if (not is_exists):
return False
self._remove_connection(connection)
return True
def names(self):
return self._data.keys()
def connected(self, name):
if (name not in self._data):
return set()
return self._data[name]
def is_exists(self, connection):
copy = connection.copy()
first, second = copy.pop(), copy.pop()
return (first in self._data and second in self._data[first])
def _add_connection(self, connection):
copy = connection.copy()
first, second = copy.pop(), copy.pop()
add = lambda i, x: self._data[i].add(x) if i in self._data else self._data.update({i: {x}})
add(first, second)
add(second, first)
def _add_connections(self, connections):
for connection in connections:
self._add_connection(connection)
def _remove_connection(self, connection):
copy = connection.copy()
first, second = copy.pop(), copy.pop()
removeValue = lambda i, x: self._data[i].remove(x) if True else None
removeKey = lambda i: self._data.pop(i) if not len(self._data[i]) else None
removeValue(first, second)
removeValue(second, first)
removeKey(first)
removeKey(second)
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
letter_friends = Friends(({"a", "b"}, {"b", "c"}, {"c", "a"}, {"a", "c"}))
digit_friends = Friends([{"1", "2"}, {"3", "1"}])
assert letter_friends.add({"c", "d"}) is True, "Add"
assert letter_friends.add({"c", "d"}) is False, "Add again"
assert letter_friends.remove({"c", "d"}) is True, "Remove"
assert digit_friends.remove({"c", "d"}) is False, "Remove non exists"
assert letter_friends.names() == {"a", "b", "c"}, "Names"
assert letter_friends.connected("d") == set(), "Non connected name"
assert letter_friends.connected("a") == {"b", "c"}, "Connected name"
| class Friends(object):
def __init__(self, connections):
super(Friends, self).__init__()
self._data = {}
self._add_connections(connections)
def add(self, connection):
is_exists = self.is_exists(connection)
self._add_connection(connection)
return not is_exists
def remove(self, connection):
is_exists = self.is_exists(connection)
if not is_exists:
return False
self._remove_connection(connection)
return True
def names(self):
return self._data.keys()
def connected(self, name):
if name not in self._data:
return set()
return self._data[name]
def is_exists(self, connection):
copy = connection.copy()
(first, second) = (copy.pop(), copy.pop())
return first in self._data and second in self._data[first]
def _add_connection(self, connection):
copy = connection.copy()
(first, second) = (copy.pop(), copy.pop())
add = lambda i, x: self._data[i].add(x) if i in self._data else self._data.update({i: {x}})
add(first, second)
add(second, first)
def _add_connections(self, connections):
for connection in connections:
self._add_connection(connection)
def _remove_connection(self, connection):
copy = connection.copy()
(first, second) = (copy.pop(), copy.pop())
remove_value = lambda i, x: self._data[i].remove(x) if True else None
remove_key = lambda i: self._data.pop(i) if not len(self._data[i]) else None
remove_value(first, second)
remove_value(second, first)
remove_key(first)
remove_key(second)
if __name__ == '__main__':
letter_friends = friends(({'a', 'b'}, {'b', 'c'}, {'c', 'a'}, {'a', 'c'}))
digit_friends = friends([{'1', '2'}, {'3', '1'}])
assert letter_friends.add({'c', 'd'}) is True, 'Add'
assert letter_friends.add({'c', 'd'}) is False, 'Add again'
assert letter_friends.remove({'c', 'd'}) is True, 'Remove'
assert digit_friends.remove({'c', 'd'}) is False, 'Remove non exists'
assert letter_friends.names() == {'a', 'b', 'c'}, 'Names'
assert letter_friends.connected('d') == set(), 'Non connected name'
assert letter_friends.connected('a') == {'b', 'c'}, 'Connected name' |
def table_service(*args):
text, client, current_channel = args
if text.lower().startswith("tables"):
number = int(text.split()[-1])
result = ""
for i in range(1, 11):
result += f"{number} X {i} = {number*i}\n"
client.chat_postMessage(channel=current_channel, text=result)
| def table_service(*args):
(text, client, current_channel) = args
if text.lower().startswith('tables'):
number = int(text.split()[-1])
result = ''
for i in range(1, 11):
result += f'{number} X {i} = {number * i}\n'
client.chat_postMessage(channel=current_channel, text=result) |
class Parameters:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def info(self):
print("The parameters, and data-type are: ")
for key,values in self.__dict__.items():
print("{} = {}, {}\n".format(key, values, type(values))) | class Parameters:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def info(self):
print('The parameters, and data-type are: ')
for (key, values) in self.__dict__.items():
print('{} = {}, {}\n'.format(key, values, type(values))) |
if __name__ == '__main__':
n = int(input())
arr = list(map(int, input().split()))
max_val = max(arr)
while(max_val in arr):
arr.remove(max_val)
print(max(arr)) | if __name__ == '__main__':
n = int(input())
arr = list(map(int, input().split()))
max_val = max(arr)
while max_val in arr:
arr.remove(max_val)
print(max(arr)) |
def solution(A):
curSlice = float('-inf')
maxSlice = float('-inf')
for num in A:
curSlice = max(num, curSlice+num)
maxSlice = max(curSlice, maxSlice)
return maxSlice
if __name__ == '__main__':
print(solution([3,2,-6,4,0]))
print(solution([-10]))
| def solution(A):
cur_slice = float('-inf')
max_slice = float('-inf')
for num in A:
cur_slice = max(num, curSlice + num)
max_slice = max(curSlice, maxSlice)
return maxSlice
if __name__ == '__main__':
print(solution([3, 2, -6, 4, 0]))
print(solution([-10])) |
class Solution:
def XXX(self, head: ListNode) -> ListNode:
o = head
p = None
while head is not None:
if p is not None and head.val == p.val:
p.next = head.next
else:
p = head
head = head.next
return o
| class Solution:
def xxx(self, head: ListNode) -> ListNode:
o = head
p = None
while head is not None:
if p is not None and head.val == p.val:
p.next = head.next
else:
p = head
head = head.next
return o |
def start():
return
def stop():
return
def apply_command(self, c, e, command, arguments):
pass
def on_welcome(self, c, e):
pass
def on_invite(self, c, e):
pass
def on_join(self, c, e):
pass
def on_namreply(self, c, e):
pass
def on_pubmsg(self, c, e):
pass
def on_privmsg(self, c, e):
pass
| def start():
return
def stop():
return
def apply_command(self, c, e, command, arguments):
pass
def on_welcome(self, c, e):
pass
def on_invite(self, c, e):
pass
def on_join(self, c, e):
pass
def on_namreply(self, c, e):
pass
def on_pubmsg(self, c, e):
pass
def on_privmsg(self, c, e):
pass |
# Code Challenge 13
open_list = ["[", "{", "("]
close_list = ["]", "}", ")"]
def validate_brackets(str):
stack=[]
for i in str:
if i in open_list:
stack.append(i)
elif i in close_list:
x = close_list.index(i)
if ((len(stack) > 0) and (open_list[x] == stack[len(stack) - 1])):
stack.pop()
else:
return False
if len(stack) == 0:
return True
else:
return False
| open_list = ['[', '{', '(']
close_list = [']', '}', ')']
def validate_brackets(str):
stack = []
for i in str:
if i in open_list:
stack.append(i)
elif i in close_list:
x = close_list.index(i)
if len(stack) > 0 and open_list[x] == stack[len(stack) - 1]:
stack.pop()
else:
return False
if len(stack) == 0:
return True
else:
return False |
tail = input()
body = input()
head = input()
meerkat = [tail, body, head]
meerkat.reverse()
print(meerkat)
| tail = input()
body = input()
head = input()
meerkat = [tail, body, head]
meerkat.reverse()
print(meerkat) |
num = int(input())
for i in range(num):
s = input()
t = input()
p = input()
| num = int(input())
for i in range(num):
s = input()
t = input()
p = input() |
def peopleneeded(Smax, S):
needed = 0
for s in range(Smax+1):
if sum(S[:s+1])<s+1:
needed += s+1-sum(S[:s+1])
S[s] += s+1-sum(S[:s+1])
return needed
def get_output(instance):
inputdata = open(instance + ".in", 'r')
output = open(instance+ ".out", 'w')
T = int(inputdata.readline())
for t in range(T):
Smax, S = inputdata.readline().split()
Smax = int(Smax)
S = [int(i) for i in list(S)]
output.write('Case #' + str(t+1) +': ' + str(peopleneeded(Smax, S)) + "\n")
return None
| def peopleneeded(Smax, S):
needed = 0
for s in range(Smax + 1):
if sum(S[:s + 1]) < s + 1:
needed += s + 1 - sum(S[:s + 1])
S[s] += s + 1 - sum(S[:s + 1])
return needed
def get_output(instance):
inputdata = open(instance + '.in', 'r')
output = open(instance + '.out', 'w')
t = int(inputdata.readline())
for t in range(T):
(smax, s) = inputdata.readline().split()
smax = int(Smax)
s = [int(i) for i in list(S)]
output.write('Case #' + str(t + 1) + ': ' + str(peopleneeded(Smax, S)) + '\n')
return None |
class Solution:
def isValidSerialization(self, preorder: str) -> bool:
degree = 1 # outDegree (children) - inDegree (parent)
for node in preorder.split(','):
degree -= 1
if degree < 0:
return False
if node != '#':
degree += 2
return degree == 0
| class Solution:
def is_valid_serialization(self, preorder: str) -> bool:
degree = 1
for node in preorder.split(','):
degree -= 1
if degree < 0:
return False
if node != '#':
degree += 2
return degree == 0 |
class ZoneFilter:
def __init__(self, rules):
self.rules = rules
def filter(self, record):
# TODO Dummy implementation
return [record] | class Zonefilter:
def __init__(self, rules):
self.rules = rules
def filter(self, record):
return [record] |
class HyperparameterGrid():
def __init__(self):
DEFAULT_HYPERPARAMETER_GRID = {
'lr': {
'C': [0.001, 0.01, 0.1, 1],
'penalty': ['l1', 'l2'],
'solver': ['liblinear'],
'intercept_scaling': [1, 1000],
'max_iter': [1000]
},
'dt': {
'criterion': ['gini', 'entropy'],
'max_depth': [3, 5, 10, None],
'min_samples_leaf': [0.01, 0.02, 0.05],
},
'rf': {
'n_estimators': [100, 500, 1000],
'criterion': ['gini','entropy'],
'max_depth': [3, 5, 10, None],
'min_samples_leaf': [0.01, 0.02, 0.05],
},
'xgb': {
'max_depth': [2, 3, 4, 5, 6],
'eta': [.1, .3, .5],
'eval_metric': ['auc'],
'min_child_weight': [1, 3, 5, 7, 9],
'gamma':[0],
'scale_pos_weight': [1],
'bsample': [0.8],
'n_jobs': [4],
'n_estimators': [100],
'colsample_bytree': [0.8],
'objective': ['binary:logistic'],
}
}
self.param_grids = DEFAULT_HYPERPARAMETER_GRID
| class Hyperparametergrid:
def __init__(self):
default_hyperparameter_grid = {'lr': {'C': [0.001, 0.01, 0.1, 1], 'penalty': ['l1', 'l2'], 'solver': ['liblinear'], 'intercept_scaling': [1, 1000], 'max_iter': [1000]}, 'dt': {'criterion': ['gini', 'entropy'], 'max_depth': [3, 5, 10, None], 'min_samples_leaf': [0.01, 0.02, 0.05]}, 'rf': {'n_estimators': [100, 500, 1000], 'criterion': ['gini', 'entropy'], 'max_depth': [3, 5, 10, None], 'min_samples_leaf': [0.01, 0.02, 0.05]}, 'xgb': {'max_depth': [2, 3, 4, 5, 6], 'eta': [0.1, 0.3, 0.5], 'eval_metric': ['auc'], 'min_child_weight': [1, 3, 5, 7, 9], 'gamma': [0], 'scale_pos_weight': [1], 'bsample': [0.8], 'n_jobs': [4], 'n_estimators': [100], 'colsample_bytree': [0.8], 'objective': ['binary:logistic']}}
self.param_grids = DEFAULT_HYPERPARAMETER_GRID |
def uniqueElements(myList):
uniqList = []
for _var in myList:
if _var not in uniqList:
uniqList.append(_var)
else:
return "Not Unique"
return "Unique"
print(uniqueElements([2,99,99,12,3,11,223])) | def unique_elements(myList):
uniq_list = []
for _var in myList:
if _var not in uniqList:
uniqList.append(_var)
else:
return 'Not Unique'
return 'Unique'
print(unique_elements([2, 99, 99, 12, 3, 11, 223])) |
def magic_square(square):
size_square = len(square)
is_magic = True
wanted_sum = 0
for index in range(0, size_square):
wanted_sum += square[0][index]
for row in range(0, size_square):
current_sum = 0
for col in range(0, size_square):
current_sum += square[row][col]
if current_sum != wanted_sum:
is_magic = False
break
for col in range(0, size_square):
current_sum = 0
for row in range(0, size_square):
current_sum += square[row][col]
if current_sum != wanted_sum:
is_magic = False
break
current_sum = 0
row = 0
col = 0
while row < size_square and col < size_square:
current_sum += square[row][col]
row += 1
col += 1
if current_sum != wanted_sum:
is_magic = False
current_sum = 0
row = 0
col = size_square - 1
while row < size_square and col >= 0:
current_sum += square[row][col]
row += 1
col -= 1
if current_sum != wanted_sum:
is_magic = False
return is_magic
square1 = [ [23, 28, 21], [22, 24, 26], [27, 20, 25] ]
square2 = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ]
print (magic_square(square1))
print (magic_square(square2))
| def magic_square(square):
size_square = len(square)
is_magic = True
wanted_sum = 0
for index in range(0, size_square):
wanted_sum += square[0][index]
for row in range(0, size_square):
current_sum = 0
for col in range(0, size_square):
current_sum += square[row][col]
if current_sum != wanted_sum:
is_magic = False
break
for col in range(0, size_square):
current_sum = 0
for row in range(0, size_square):
current_sum += square[row][col]
if current_sum != wanted_sum:
is_magic = False
break
current_sum = 0
row = 0
col = 0
while row < size_square and col < size_square:
current_sum += square[row][col]
row += 1
col += 1
if current_sum != wanted_sum:
is_magic = False
current_sum = 0
row = 0
col = size_square - 1
while row < size_square and col >= 0:
current_sum += square[row][col]
row += 1
col -= 1
if current_sum != wanted_sum:
is_magic = False
return is_magic
square1 = [[23, 28, 21], [22, 24, 26], [27, 20, 25]]
square2 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
print(magic_square(square1))
print(magic_square(square2)) |
def f(x):
y=1
x=x+y
return x
x=3
y=2
z=f(x)
print("x="+str(x))
print("y="+str(y))
print("z="+str(z)) | def f(x):
y = 1
x = x + y
return x
x = 3
y = 2
z = f(x)
print('x=' + str(x))
print('y=' + str(y))
print('z=' + str(z)) |
__all__ = [
"mock_generation_data_frame",
"test_get_monthly_net_generation",
"test_rate_limit",
"test_retry",
]
| __all__ = ['mock_generation_data_frame', 'test_get_monthly_net_generation', 'test_rate_limit', 'test_retry'] |
test = { 'name': 'q1_2',
'points': 1,
'suites': [ { 'cases': [ {'code': ">>> assert trending_vids.shape[0] == '40379'\n", 'hidden': False, 'locked': False},
{'code': ">>> assert trending_vids.iloc[0, 0] == '25231'\n", 'hidden': False, 'locked': False},
{'code': ">>> assert trending_vids.iloc[0, 4] == 'Inside Edition'\n", 'hidden': False, 'locked': False},
{'code': ">>> assert trending_vids.loc[0, 'views'] == 542677.0\n", 'hidden': False, 'locked': False},
{'code': ">>> assert trending_vids.loc[2, 'likes'] == 11390.0\n", 'hidden': False, 'locked': False},
{'code': ">>> assert trending_vids.loc[3, 'dislikes'] == 175.0\n", 'hidden': False, 'locked': False}],
'scored': True,
'setup': '',
'teardown': '',
'type': 'doctest'}]}
| test = {'name': 'q1_2', 'points': 1, 'suites': [{'cases': [{'code': ">>> assert trending_vids.shape[0] == '40379'\n", 'hidden': False, 'locked': False}, {'code': ">>> assert trending_vids.iloc[0, 0] == '25231'\n", 'hidden': False, 'locked': False}, {'code': ">>> assert trending_vids.iloc[0, 4] == 'Inside Edition'\n", 'hidden': False, 'locked': False}, {'code': ">>> assert trending_vids.loc[0, 'views'] == 542677.0\n", 'hidden': False, 'locked': False}, {'code': ">>> assert trending_vids.loc[2, 'likes'] == 11390.0\n", 'hidden': False, 'locked': False}, {'code': ">>> assert trending_vids.loc[3, 'dislikes'] == 175.0\n", 'hidden': False, 'locked': False}], 'scored': True, 'setup': '', 'teardown': '', 'type': 'doctest'}]} |
class Income:
def __init__(self):
self.tranId = ""
self.tradeId = ""
self.symbol = ""
self.incomeType = ""
self.income = 0.0
self.asset = ""
self.time = 0
@staticmethod
def json_parse(json_data):
result = Income()
result.tranId = json_data.get_string("tranId")
result.tradeId = json_data.get_string("tradeId")
result.symbol = json_data.get_string("symbol")
result.incomeType = json_data.get_string("incomeType")
result.income = json_data.get_float("income")
result.asset = json_data.get_string("asset")
result.time = json_data.get_int("time")
return result
| class Income:
def __init__(self):
self.tranId = ''
self.tradeId = ''
self.symbol = ''
self.incomeType = ''
self.income = 0.0
self.asset = ''
self.time = 0
@staticmethod
def json_parse(json_data):
result = income()
result.tranId = json_data.get_string('tranId')
result.tradeId = json_data.get_string('tradeId')
result.symbol = json_data.get_string('symbol')
result.incomeType = json_data.get_string('incomeType')
result.income = json_data.get_float('income')
result.asset = json_data.get_string('asset')
result.time = json_data.get_int('time')
return result |
def game(input,max_turns):
memory = {}
turncounter = 1
most_recent_number = int(input[-1])
for i in range(len(input)):
memory[int(input[i])] = [turncounter,-1]
turncounter += 1
while turncounter <= max_turns:
if memory[most_recent_number][1] == -1:
most_recent_number = 0
else:
most_recent_number = memory[most_recent_number][0] - memory[most_recent_number][1]
if most_recent_number in memory:
memory[most_recent_number] = [turncounter,memory[most_recent_number][0]]
else:
memory[most_recent_number] = [turncounter,-1]
turncounter +=1
return str(most_recent_number)
def main(filepath):
with open(filepath) as file:
rows = [x.strip() for x in file.readlines()]
input = rows[0].split(",")
print("Part a solution: "+game(input,2020))
print("Part b solution: "+game(input,30000000)) #takes a while to run, but less than 1 minute
| def game(input, max_turns):
memory = {}
turncounter = 1
most_recent_number = int(input[-1])
for i in range(len(input)):
memory[int(input[i])] = [turncounter, -1]
turncounter += 1
while turncounter <= max_turns:
if memory[most_recent_number][1] == -1:
most_recent_number = 0
else:
most_recent_number = memory[most_recent_number][0] - memory[most_recent_number][1]
if most_recent_number in memory:
memory[most_recent_number] = [turncounter, memory[most_recent_number][0]]
else:
memory[most_recent_number] = [turncounter, -1]
turncounter += 1
return str(most_recent_number)
def main(filepath):
with open(filepath) as file:
rows = [x.strip() for x in file.readlines()]
input = rows[0].split(',')
print('Part a solution: ' + game(input, 2020))
print('Part b solution: ' + game(input, 30000000)) |
def is_krampus(n):
p = str(n**2)
l_p = len(p)
for i in range(1, l_p - 1):
p_1 = int(p[:i])
p_2 = int(p[i:])
if p_1 and p_2 and p_1 + p_2 == n:
return True
return False
def test_is_krampus():
assert is_krampus(45)
assert not is_krampus(100)
if __name__ == '__main__':
s = 0
for n in open('input/09').readlines():
n = int(n.strip())
if is_krampus(n):
s += n
print(s)
| def is_krampus(n):
p = str(n ** 2)
l_p = len(p)
for i in range(1, l_p - 1):
p_1 = int(p[:i])
p_2 = int(p[i:])
if p_1 and p_2 and (p_1 + p_2 == n):
return True
return False
def test_is_krampus():
assert is_krampus(45)
assert not is_krampus(100)
if __name__ == '__main__':
s = 0
for n in open('input/09').readlines():
n = int(n.strip())
if is_krampus(n):
s += n
print(s) |
def adjacentElementsProduct(inputArray):
first, second = 0, 1
lp = inputArray[first]*inputArray[second]
for index in range(2, len(inputArray)):
first = second
second = index
new_lp = inputArray[first]*inputArray[second]
if new_lp > lp:
lp = new_lp
return lp
| def adjacent_elements_product(inputArray):
(first, second) = (0, 1)
lp = inputArray[first] * inputArray[second]
for index in range(2, len(inputArray)):
first = second
second = index
new_lp = inputArray[first] * inputArray[second]
if new_lp > lp:
lp = new_lp
return lp |
def y():
pass
def x():
y()
for i in range(10):
x()
| def y():
pass
def x():
y()
for i in range(10):
x() |
INSTALLED_APPS = (
'vkontakte_api',
'vkontakte_places',
'vkontakte_users',
'vkontakte_groups',
'vkontakte_comments',
'm2m_history',
)
SOCIAL_API_TOKENS_STORAGES = []
| installed_apps = ('vkontakte_api', 'vkontakte_places', 'vkontakte_users', 'vkontakte_groups', 'vkontakte_comments', 'm2m_history')
social_api_tokens_storages = [] |
#
# PySNMP MIB module AcAlarm (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AcAlarm
# Produced by pysmi-0.3.4 at Wed May 1 11:33:03 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)
#
AcAlarmEventType, AcAlarmProbableCause, AcAlarmSeverity = mibBuilder.importSymbols("AC-FAULT-TC", "AcAlarmEventType", "AcAlarmProbableCause", "AcAlarmSeverity")
OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsIntersection, SingleValueConstraint, ConstraintsUnion, ValueRangeConstraint, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "SingleValueConstraint", "ConstraintsUnion", "ValueRangeConstraint", "ValueSizeConstraint")
SnmpEngineID, SnmpAdminString = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpEngineID", "SnmpAdminString")
ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup")
TimeTicks, enterprises, ModuleIdentity, iso, Bits, NotificationType, Unsigned32, MibScalar, MibTable, MibTableRow, MibTableColumn, MibIdentifier, IpAddress, Counter32, Gauge32, Counter64, ObjectIdentity, Integer32 = mibBuilder.importSymbols("SNMPv2-SMI", "TimeTicks", "enterprises", "ModuleIdentity", "iso", "Bits", "NotificationType", "Unsigned32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "MibIdentifier", "IpAddress", "Counter32", "Gauge32", "Counter64", "ObjectIdentity", "Integer32")
TimeStamp, DateAndTime, DisplayString, RowStatus, TruthValue, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "TimeStamp", "DateAndTime", "DisplayString", "RowStatus", "TruthValue", "TextualConvention")
audioCodes = MibIdentifier((1, 3, 6, 1, 4, 1, 5003))
acFault = MibIdentifier((1, 3, 6, 1, 4, 1, 5003, 11))
acAlarm = ModuleIdentity((1, 3, 6, 1, 4, 1, 5003, 11, 1))
acAlarm.setRevisions(('2003-12-18 00:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts: acAlarm.setRevisionsDescriptions(('4.4. Dec. 18, 2003. Made these changes: o Initial version',))
if mibBuilder.loadTexts: acAlarm.setLastUpdated('200312180000Z')
if mibBuilder.loadTexts: acAlarm.setOrganization('Audiocodes')
if mibBuilder.loadTexts: acAlarm.setContactInfo('Postal: Support AudioCodes LTD 1 Hayarden Street Airport City Lod 70151, ISRAEL Tel: 972-3-9764000 Fax: 972-3-9764040 Email: support@audiocodes.com Web: www.audiocodes.com')
if mibBuilder.loadTexts: acAlarm.setDescription('This MIB defines the enterprise-specific objects needed to support fault management of Audiocodes products. The MIB consists of: o Active alarm table o Alarm history table o Alarm notification varbinds')
acActiveAlarm = MibIdentifier((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1))
acActiveAlarmTable = MibTable((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1), )
if mibBuilder.loadTexts: acActiveAlarmTable.setStatus('current')
if mibBuilder.loadTexts: acActiveAlarmTable.setDescription('Table of active alarms.')
acActiveAlarmEntry = MibTableRow((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1), ).setIndexNames((0, "AcAlarm", "acActiveAlarmSequenceNumber"))
if mibBuilder.loadTexts: acActiveAlarmEntry.setStatus('current')
if mibBuilder.loadTexts: acActiveAlarmEntry.setDescription('A conceptual row in the acActiveAlarmTable')
acActiveAlarmSequenceNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 1), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acActiveAlarmSequenceNumber.setStatus('current')
if mibBuilder.loadTexts: acActiveAlarmSequenceNumber.setDescription('The sequence number of the alarm raise trap.')
acActiveAlarmSysuptime = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 2), TimeStamp()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acActiveAlarmSysuptime.setStatus('current')
if mibBuilder.loadTexts: acActiveAlarmSysuptime.setDescription('The value of sysuptime at the time the alarm raise trap was sent')
acActiveAlarmTrapOID = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 3), ObjectIdentifier()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acActiveAlarmTrapOID.setStatus('current')
if mibBuilder.loadTexts: acActiveAlarmTrapOID.setDescription('The OID of the notification trap')
acActiveAlarmDateAndTime = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 4), DateAndTime()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acActiveAlarmDateAndTime.setStatus('current')
if mibBuilder.loadTexts: acActiveAlarmDateAndTime.setDescription('The date and time at the time the alarm raise trap was sent.')
acActiveAlarmName = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 5), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acActiveAlarmName.setStatus('current')
if mibBuilder.loadTexts: acActiveAlarmName.setDescription('The name of the alarm that was raised. This actually in the form of a number. Each kind of alarm has a unique number associated with it.')
acActiveAlarmTextualDescription = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 6), SnmpAdminString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acActiveAlarmTextualDescription.setStatus('current')
if mibBuilder.loadTexts: acActiveAlarmTextualDescription.setDescription('Text that descries the alarm condition.')
acActiveAlarmSource = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 7), SnmpAdminString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acActiveAlarmSource.setStatus('current')
if mibBuilder.loadTexts: acActiveAlarmSource.setDescription('The component in the system which raised the alarm.')
acActiveAlarmSeverity = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 8), AcAlarmSeverity()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acActiveAlarmSeverity.setStatus('current')
if mibBuilder.loadTexts: acActiveAlarmSeverity.setDescription('The severity of the alarm.')
acActiveAlarmEventType = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 9), AcAlarmEventType()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acActiveAlarmEventType.setStatus('current')
if mibBuilder.loadTexts: acActiveAlarmEventType.setDescription('The event type of the alarm.')
acActiveAlarmProbableCause = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 10), AcAlarmProbableCause()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acActiveAlarmProbableCause.setStatus('current')
if mibBuilder.loadTexts: acActiveAlarmProbableCause.setDescription('The probable cause of the alarm.')
acActiveAlarmAdditionalInfo1 = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 11), SnmpAdminString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acActiveAlarmAdditionalInfo1.setStatus('current')
if mibBuilder.loadTexts: acActiveAlarmAdditionalInfo1.setDescription('Additional miscellaneous info regarding this alarm.')
acActiveAlarmAdditionalInfo2 = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 12), SnmpAdminString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acActiveAlarmAdditionalInfo2.setStatus('current')
if mibBuilder.loadTexts: acActiveAlarmAdditionalInfo2.setDescription('Additional miscellaneous info regarding this alarm.')
acActiveAlarmAdditionalInfo3 = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 13), SnmpAdminString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acActiveAlarmAdditionalInfo3.setStatus('current')
if mibBuilder.loadTexts: acActiveAlarmAdditionalInfo3.setDescription('Additional miscellaneous info regarding this alarm.')
acAlarmHistory = MibIdentifier((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2))
acAlarmHistoryTable = MibTable((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1), )
if mibBuilder.loadTexts: acAlarmHistoryTable.setStatus('current')
if mibBuilder.loadTexts: acAlarmHistoryTable.setDescription('A table of all raise-alarm and clear-alarm traps sent by the system. Internal to the system, this table of traps is a fixed size. Once the table reaches this size, older traps are removed to make room for new traps. The size of the table is the value of the nlmConfigLogEntryLimit (NOTIFICATION-LOG-MIB).')
acAlarmHistoryEntry = MibTableRow((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1), ).setIndexNames((0, "AcAlarm", "acAlarmHistorySequenceNumber"))
if mibBuilder.loadTexts: acAlarmHistoryEntry.setStatus('current')
if mibBuilder.loadTexts: acAlarmHistoryEntry.setDescription('A conceptual row in the acAlarmHistoryTable')
acAlarmHistorySequenceNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 1), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acAlarmHistorySequenceNumber.setStatus('current')
if mibBuilder.loadTexts: acAlarmHistorySequenceNumber.setDescription('The sequence number of the alarm raise or clear trap.')
acAlarmHistorySysuptime = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 2), TimeStamp()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acAlarmHistorySysuptime.setStatus('current')
if mibBuilder.loadTexts: acAlarmHistorySysuptime.setDescription('The value of sysuptime at the time the alarm raise or clear trap was sent')
acAlarmHistoryTrapOID = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 3), ObjectIdentifier()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acAlarmHistoryTrapOID.setStatus('current')
if mibBuilder.loadTexts: acAlarmHistoryTrapOID.setDescription('The OID of the notification trap')
acAlarmHistoryDateAndTime = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 4), DateAndTime()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acAlarmHistoryDateAndTime.setStatus('current')
if mibBuilder.loadTexts: acAlarmHistoryDateAndTime.setDescription('The date and time at the time the alarm raise or clear trap was sent.')
acAlarmHistoryName = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 5), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acAlarmHistoryName.setStatus('current')
if mibBuilder.loadTexts: acAlarmHistoryName.setDescription('The name of the alarm that was raised or cleared. This actually in the form of a number. Each kind of alarm has a unique number associated with it.')
acAlarmHistoryTextualDescription = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 6), SnmpAdminString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acAlarmHistoryTextualDescription.setStatus('current')
if mibBuilder.loadTexts: acAlarmHistoryTextualDescription.setDescription('Text that descries the alarm condition.')
acAlarmHistorySource = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 7), SnmpAdminString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acAlarmHistorySource.setStatus('current')
if mibBuilder.loadTexts: acAlarmHistorySource.setDescription('The component in the system which raised or cleared the alarm.')
acAlarmHistorySeverity = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 8), AcAlarmSeverity()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acAlarmHistorySeverity.setStatus('current')
if mibBuilder.loadTexts: acAlarmHistorySeverity.setDescription('The severity of the alarm. A severity of warning, minor, major or critical indicates a raise trap. A severity of cleared indicates a clear trap.')
acAlarmHistoryEventType = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 9), AcAlarmEventType()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acAlarmHistoryEventType.setStatus('current')
if mibBuilder.loadTexts: acAlarmHistoryEventType.setDescription('The event type of the alarm.')
acAlarmHistoryProbableCause = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 10), AcAlarmProbableCause()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acAlarmHistoryProbableCause.setStatus('current')
if mibBuilder.loadTexts: acAlarmHistoryProbableCause.setDescription('The probable cause of the alarm.')
acAlarmHistoryAdditionalInfo1 = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 11), SnmpAdminString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acAlarmHistoryAdditionalInfo1.setStatus('current')
if mibBuilder.loadTexts: acAlarmHistoryAdditionalInfo1.setDescription('Additional miscellaneous info regarding this alarm.')
acAlarmHistoryAdditionalInfo2 = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 12), SnmpAdminString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acAlarmHistoryAdditionalInfo2.setStatus('current')
if mibBuilder.loadTexts: acAlarmHistoryAdditionalInfo2.setDescription('Additional miscellaneous info regarding this alarm.')
acAlarmHistoryAdditionalInfo3 = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 13), SnmpAdminString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acAlarmHistoryAdditionalInfo3.setStatus('current')
if mibBuilder.loadTexts: acAlarmHistoryAdditionalInfo3.setDescription('Additional miscellaneous info regarding this alarm.')
acAlarmVarbinds = MibIdentifier((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3))
acAlarmVarbindsSequenceNumber = MibScalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 1), Unsigned32()).setMaxAccess("accessiblefornotify")
if mibBuilder.loadTexts: acAlarmVarbindsSequenceNumber.setStatus('current')
if mibBuilder.loadTexts: acAlarmVarbindsSequenceNumber.setDescription('The sequence number of the alarm raise or clear trap.')
acAlarmVarbindsDateAndTime = MibScalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 2), DateAndTime()).setMaxAccess("accessiblefornotify")
if mibBuilder.loadTexts: acAlarmVarbindsDateAndTime.setStatus('current')
if mibBuilder.loadTexts: acAlarmVarbindsDateAndTime.setDescription('The date and time at the time the alarm raise or clear trap was sent.')
acAlarmVarbindsAlarmName = MibScalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 3), Unsigned32()).setMaxAccess("accessiblefornotify")
if mibBuilder.loadTexts: acAlarmVarbindsAlarmName.setStatus('current')
if mibBuilder.loadTexts: acAlarmVarbindsAlarmName.setDescription('The name of the alarm that was raised or cleared. This actually in the form of a number. Each kind of alarm has a unique number associated with it.')
acAlarmVarbindsTextualDescription = MibScalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 4), SnmpAdminString()).setMaxAccess("accessiblefornotify")
if mibBuilder.loadTexts: acAlarmVarbindsTextualDescription.setStatus('current')
if mibBuilder.loadTexts: acAlarmVarbindsTextualDescription.setDescription('Text that descries the alarm condition.')
acAlarmVarbindsSource = MibScalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 5), SnmpAdminString()).setMaxAccess("accessiblefornotify")
if mibBuilder.loadTexts: acAlarmVarbindsSource.setStatus('current')
if mibBuilder.loadTexts: acAlarmVarbindsSource.setDescription('The component in the system which raised or cleared the alarm.')
acAlarmVarbindsSeverity = MibScalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 6), AcAlarmSeverity()).setMaxAccess("accessiblefornotify")
if mibBuilder.loadTexts: acAlarmVarbindsSeverity.setStatus('current')
if mibBuilder.loadTexts: acAlarmVarbindsSeverity.setDescription('The severity of the alarm. A severity of warning, minor, major or critical indicates a raise trap. A severity of cleared indicates a clear trap.')
acAlarmVarbindsEventType = MibScalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 7), AcAlarmEventType()).setMaxAccess("accessiblefornotify")
if mibBuilder.loadTexts: acAlarmVarbindsEventType.setStatus('current')
if mibBuilder.loadTexts: acAlarmVarbindsEventType.setDescription('The event type of the alarm.')
acAlarmVarbindsProbableCause = MibScalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 8), AcAlarmProbableCause()).setMaxAccess("accessiblefornotify")
if mibBuilder.loadTexts: acAlarmVarbindsProbableCause.setStatus('current')
if mibBuilder.loadTexts: acAlarmVarbindsProbableCause.setDescription('The probable cause of the alarm.')
acAlarmVarbindsAdditionalInfo1 = MibScalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 9), SnmpAdminString()).setMaxAccess("accessiblefornotify")
if mibBuilder.loadTexts: acAlarmVarbindsAdditionalInfo1.setStatus('current')
if mibBuilder.loadTexts: acAlarmVarbindsAdditionalInfo1.setDescription('Additional miscellaneous info regarding this alarm.')
acAlarmVarbindsAdditionalInfo2 = MibScalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 10), SnmpAdminString()).setMaxAccess("accessiblefornotify")
if mibBuilder.loadTexts: acAlarmVarbindsAdditionalInfo2.setStatus('current')
if mibBuilder.loadTexts: acAlarmVarbindsAdditionalInfo2.setDescription('Additional miscellaneous info regarding this alarm.')
acAlarmVarbindsAdditionalInfo3 = MibScalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 11), SnmpAdminString()).setMaxAccess("accessiblefornotify")
if mibBuilder.loadTexts: acAlarmVarbindsAdditionalInfo3.setStatus('current')
if mibBuilder.loadTexts: acAlarmVarbindsAdditionalInfo3.setDescription('Additional miscellaneous info regarding this alarm.')
mibBuilder.exportSymbols("AcAlarm", acAlarmVarbinds=acAlarmVarbinds, acActiveAlarmSource=acActiveAlarmSource, acActiveAlarmSeverity=acActiveAlarmSeverity, audioCodes=audioCodes, acAlarmHistorySequenceNumber=acAlarmHistorySequenceNumber, acAlarmVarbindsSource=acAlarmVarbindsSource, acAlarmHistory=acAlarmHistory, acActiveAlarmEventType=acActiveAlarmEventType, acAlarmHistoryEventType=acAlarmHistoryEventType, acActiveAlarmTable=acActiveAlarmTable, acActiveAlarmSysuptime=acActiveAlarmSysuptime, acAlarmVarbindsDateAndTime=acAlarmVarbindsDateAndTime, acAlarmVarbindsSeverity=acAlarmVarbindsSeverity, acAlarmVarbindsTextualDescription=acAlarmVarbindsTextualDescription, acActiveAlarmName=acActiveAlarmName, acAlarmVarbindsEventType=acAlarmVarbindsEventType, acActiveAlarmSequenceNumber=acActiveAlarmSequenceNumber, acActiveAlarm=acActiveAlarm, acAlarmHistoryAdditionalInfo2=acAlarmHistoryAdditionalInfo2, acActiveAlarmTextualDescription=acActiveAlarmTextualDescription, acAlarmHistoryProbableCause=acAlarmHistoryProbableCause, acAlarmHistoryAdditionalInfo3=acAlarmHistoryAdditionalInfo3, acActiveAlarmTrapOID=acActiveAlarmTrapOID, acAlarmVarbindsSequenceNumber=acAlarmVarbindsSequenceNumber, acAlarmVarbindsAlarmName=acAlarmVarbindsAlarmName, acAlarmVarbindsAdditionalInfo2=acAlarmVarbindsAdditionalInfo2, acAlarmHistoryTrapOID=acAlarmHistoryTrapOID, acActiveAlarmDateAndTime=acActiveAlarmDateAndTime, acAlarmHistoryDateAndTime=acAlarmHistoryDateAndTime, acAlarmHistoryEntry=acAlarmHistoryEntry, acAlarm=acAlarm, acAlarmHistoryName=acAlarmHistoryName, acActiveAlarmProbableCause=acActiveAlarmProbableCause, acActiveAlarmAdditionalInfo2=acActiveAlarmAdditionalInfo2, acAlarmHistorySource=acAlarmHistorySource, acActiveAlarmEntry=acActiveAlarmEntry, acAlarmHistoryTable=acAlarmHistoryTable, acActiveAlarmAdditionalInfo3=acActiveAlarmAdditionalInfo3, acAlarmHistoryAdditionalInfo1=acAlarmHistoryAdditionalInfo1, acAlarmVarbindsAdditionalInfo1=acAlarmVarbindsAdditionalInfo1, acAlarmVarbindsAdditionalInfo3=acAlarmVarbindsAdditionalInfo3, PYSNMP_MODULE_ID=acAlarm, acActiveAlarmAdditionalInfo1=acActiveAlarmAdditionalInfo1, acAlarmVarbindsProbableCause=acAlarmVarbindsProbableCause, acFault=acFault, acAlarmHistoryTextualDescription=acAlarmHistoryTextualDescription, acAlarmHistorySysuptime=acAlarmHistorySysuptime, acAlarmHistorySeverity=acAlarmHistorySeverity)
| (ac_alarm_event_type, ac_alarm_probable_cause, ac_alarm_severity) = mibBuilder.importSymbols('AC-FAULT-TC', 'AcAlarmEventType', 'AcAlarmProbableCause', 'AcAlarmSeverity')
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, single_value_constraint, constraints_union, value_range_constraint, value_size_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsIntersection', 'SingleValueConstraint', 'ConstraintsUnion', 'ValueRangeConstraint', 'ValueSizeConstraint')
(snmp_engine_id, snmp_admin_string) = mibBuilder.importSymbols('SNMP-FRAMEWORK-MIB', 'SnmpEngineID', 'SnmpAdminString')
(module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup')
(time_ticks, enterprises, module_identity, iso, bits, notification_type, unsigned32, mib_scalar, mib_table, mib_table_row, mib_table_column, mib_identifier, ip_address, counter32, gauge32, counter64, object_identity, integer32) = mibBuilder.importSymbols('SNMPv2-SMI', 'TimeTicks', 'enterprises', 'ModuleIdentity', 'iso', 'Bits', 'NotificationType', 'Unsigned32', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'MibIdentifier', 'IpAddress', 'Counter32', 'Gauge32', 'Counter64', 'ObjectIdentity', 'Integer32')
(time_stamp, date_and_time, display_string, row_status, truth_value, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'TimeStamp', 'DateAndTime', 'DisplayString', 'RowStatus', 'TruthValue', 'TextualConvention')
audio_codes = mib_identifier((1, 3, 6, 1, 4, 1, 5003))
ac_fault = mib_identifier((1, 3, 6, 1, 4, 1, 5003, 11))
ac_alarm = module_identity((1, 3, 6, 1, 4, 1, 5003, 11, 1))
acAlarm.setRevisions(('2003-12-18 00:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts:
acAlarm.setRevisionsDescriptions(('4.4. Dec. 18, 2003. Made these changes: o Initial version',))
if mibBuilder.loadTexts:
acAlarm.setLastUpdated('200312180000Z')
if mibBuilder.loadTexts:
acAlarm.setOrganization('Audiocodes')
if mibBuilder.loadTexts:
acAlarm.setContactInfo('Postal: Support AudioCodes LTD 1 Hayarden Street Airport City Lod 70151, ISRAEL Tel: 972-3-9764000 Fax: 972-3-9764040 Email: support@audiocodes.com Web: www.audiocodes.com')
if mibBuilder.loadTexts:
acAlarm.setDescription('This MIB defines the enterprise-specific objects needed to support fault management of Audiocodes products. The MIB consists of: o Active alarm table o Alarm history table o Alarm notification varbinds')
ac_active_alarm = mib_identifier((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1))
ac_active_alarm_table = mib_table((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1))
if mibBuilder.loadTexts:
acActiveAlarmTable.setStatus('current')
if mibBuilder.loadTexts:
acActiveAlarmTable.setDescription('Table of active alarms.')
ac_active_alarm_entry = mib_table_row((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1)).setIndexNames((0, 'AcAlarm', 'acActiveAlarmSequenceNumber'))
if mibBuilder.loadTexts:
acActiveAlarmEntry.setStatus('current')
if mibBuilder.loadTexts:
acActiveAlarmEntry.setDescription('A conceptual row in the acActiveAlarmTable')
ac_active_alarm_sequence_number = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 1), unsigned32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acActiveAlarmSequenceNumber.setStatus('current')
if mibBuilder.loadTexts:
acActiveAlarmSequenceNumber.setDescription('The sequence number of the alarm raise trap.')
ac_active_alarm_sysuptime = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 2), time_stamp()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acActiveAlarmSysuptime.setStatus('current')
if mibBuilder.loadTexts:
acActiveAlarmSysuptime.setDescription('The value of sysuptime at the time the alarm raise trap was sent')
ac_active_alarm_trap_oid = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 3), object_identifier()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acActiveAlarmTrapOID.setStatus('current')
if mibBuilder.loadTexts:
acActiveAlarmTrapOID.setDescription('The OID of the notification trap')
ac_active_alarm_date_and_time = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 4), date_and_time()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acActiveAlarmDateAndTime.setStatus('current')
if mibBuilder.loadTexts:
acActiveAlarmDateAndTime.setDescription('The date and time at the time the alarm raise trap was sent.')
ac_active_alarm_name = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 5), unsigned32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acActiveAlarmName.setStatus('current')
if mibBuilder.loadTexts:
acActiveAlarmName.setDescription('The name of the alarm that was raised. This actually in the form of a number. Each kind of alarm has a unique number associated with it.')
ac_active_alarm_textual_description = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 6), snmp_admin_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acActiveAlarmTextualDescription.setStatus('current')
if mibBuilder.loadTexts:
acActiveAlarmTextualDescription.setDescription('Text that descries the alarm condition.')
ac_active_alarm_source = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 7), snmp_admin_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acActiveAlarmSource.setStatus('current')
if mibBuilder.loadTexts:
acActiveAlarmSource.setDescription('The component in the system which raised the alarm.')
ac_active_alarm_severity = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 8), ac_alarm_severity()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acActiveAlarmSeverity.setStatus('current')
if mibBuilder.loadTexts:
acActiveAlarmSeverity.setDescription('The severity of the alarm.')
ac_active_alarm_event_type = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 9), ac_alarm_event_type()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acActiveAlarmEventType.setStatus('current')
if mibBuilder.loadTexts:
acActiveAlarmEventType.setDescription('The event type of the alarm.')
ac_active_alarm_probable_cause = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 10), ac_alarm_probable_cause()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acActiveAlarmProbableCause.setStatus('current')
if mibBuilder.loadTexts:
acActiveAlarmProbableCause.setDescription('The probable cause of the alarm.')
ac_active_alarm_additional_info1 = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 11), snmp_admin_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acActiveAlarmAdditionalInfo1.setStatus('current')
if mibBuilder.loadTexts:
acActiveAlarmAdditionalInfo1.setDescription('Additional miscellaneous info regarding this alarm.')
ac_active_alarm_additional_info2 = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 12), snmp_admin_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acActiveAlarmAdditionalInfo2.setStatus('current')
if mibBuilder.loadTexts:
acActiveAlarmAdditionalInfo2.setDescription('Additional miscellaneous info regarding this alarm.')
ac_active_alarm_additional_info3 = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 1, 1, 1, 13), snmp_admin_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acActiveAlarmAdditionalInfo3.setStatus('current')
if mibBuilder.loadTexts:
acActiveAlarmAdditionalInfo3.setDescription('Additional miscellaneous info regarding this alarm.')
ac_alarm_history = mib_identifier((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2))
ac_alarm_history_table = mib_table((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1))
if mibBuilder.loadTexts:
acAlarmHistoryTable.setStatus('current')
if mibBuilder.loadTexts:
acAlarmHistoryTable.setDescription('A table of all raise-alarm and clear-alarm traps sent by the system. Internal to the system, this table of traps is a fixed size. Once the table reaches this size, older traps are removed to make room for new traps. The size of the table is the value of the nlmConfigLogEntryLimit (NOTIFICATION-LOG-MIB).')
ac_alarm_history_entry = mib_table_row((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1)).setIndexNames((0, 'AcAlarm', 'acAlarmHistorySequenceNumber'))
if mibBuilder.loadTexts:
acAlarmHistoryEntry.setStatus('current')
if mibBuilder.loadTexts:
acAlarmHistoryEntry.setDescription('A conceptual row in the acAlarmHistoryTable')
ac_alarm_history_sequence_number = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 1), unsigned32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acAlarmHistorySequenceNumber.setStatus('current')
if mibBuilder.loadTexts:
acAlarmHistorySequenceNumber.setDescription('The sequence number of the alarm raise or clear trap.')
ac_alarm_history_sysuptime = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 2), time_stamp()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acAlarmHistorySysuptime.setStatus('current')
if mibBuilder.loadTexts:
acAlarmHistorySysuptime.setDescription('The value of sysuptime at the time the alarm raise or clear trap was sent')
ac_alarm_history_trap_oid = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 3), object_identifier()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acAlarmHistoryTrapOID.setStatus('current')
if mibBuilder.loadTexts:
acAlarmHistoryTrapOID.setDescription('The OID of the notification trap')
ac_alarm_history_date_and_time = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 4), date_and_time()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acAlarmHistoryDateAndTime.setStatus('current')
if mibBuilder.loadTexts:
acAlarmHistoryDateAndTime.setDescription('The date and time at the time the alarm raise or clear trap was sent.')
ac_alarm_history_name = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 5), unsigned32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acAlarmHistoryName.setStatus('current')
if mibBuilder.loadTexts:
acAlarmHistoryName.setDescription('The name of the alarm that was raised or cleared. This actually in the form of a number. Each kind of alarm has a unique number associated with it.')
ac_alarm_history_textual_description = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 6), snmp_admin_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acAlarmHistoryTextualDescription.setStatus('current')
if mibBuilder.loadTexts:
acAlarmHistoryTextualDescription.setDescription('Text that descries the alarm condition.')
ac_alarm_history_source = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 7), snmp_admin_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acAlarmHistorySource.setStatus('current')
if mibBuilder.loadTexts:
acAlarmHistorySource.setDescription('The component in the system which raised or cleared the alarm.')
ac_alarm_history_severity = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 8), ac_alarm_severity()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acAlarmHistorySeverity.setStatus('current')
if mibBuilder.loadTexts:
acAlarmHistorySeverity.setDescription('The severity of the alarm. A severity of warning, minor, major or critical indicates a raise trap. A severity of cleared indicates a clear trap.')
ac_alarm_history_event_type = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 9), ac_alarm_event_type()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acAlarmHistoryEventType.setStatus('current')
if mibBuilder.loadTexts:
acAlarmHistoryEventType.setDescription('The event type of the alarm.')
ac_alarm_history_probable_cause = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 10), ac_alarm_probable_cause()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acAlarmHistoryProbableCause.setStatus('current')
if mibBuilder.loadTexts:
acAlarmHistoryProbableCause.setDescription('The probable cause of the alarm.')
ac_alarm_history_additional_info1 = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 11), snmp_admin_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acAlarmHistoryAdditionalInfo1.setStatus('current')
if mibBuilder.loadTexts:
acAlarmHistoryAdditionalInfo1.setDescription('Additional miscellaneous info regarding this alarm.')
ac_alarm_history_additional_info2 = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 12), snmp_admin_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acAlarmHistoryAdditionalInfo2.setStatus('current')
if mibBuilder.loadTexts:
acAlarmHistoryAdditionalInfo2.setDescription('Additional miscellaneous info regarding this alarm.')
ac_alarm_history_additional_info3 = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 11, 1, 2, 1, 1, 13), snmp_admin_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acAlarmHistoryAdditionalInfo3.setStatus('current')
if mibBuilder.loadTexts:
acAlarmHistoryAdditionalInfo3.setDescription('Additional miscellaneous info regarding this alarm.')
ac_alarm_varbinds = mib_identifier((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3))
ac_alarm_varbinds_sequence_number = mib_scalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 1), unsigned32()).setMaxAccess('accessiblefornotify')
if mibBuilder.loadTexts:
acAlarmVarbindsSequenceNumber.setStatus('current')
if mibBuilder.loadTexts:
acAlarmVarbindsSequenceNumber.setDescription('The sequence number of the alarm raise or clear trap.')
ac_alarm_varbinds_date_and_time = mib_scalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 2), date_and_time()).setMaxAccess('accessiblefornotify')
if mibBuilder.loadTexts:
acAlarmVarbindsDateAndTime.setStatus('current')
if mibBuilder.loadTexts:
acAlarmVarbindsDateAndTime.setDescription('The date and time at the time the alarm raise or clear trap was sent.')
ac_alarm_varbinds_alarm_name = mib_scalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 3), unsigned32()).setMaxAccess('accessiblefornotify')
if mibBuilder.loadTexts:
acAlarmVarbindsAlarmName.setStatus('current')
if mibBuilder.loadTexts:
acAlarmVarbindsAlarmName.setDescription('The name of the alarm that was raised or cleared. This actually in the form of a number. Each kind of alarm has a unique number associated with it.')
ac_alarm_varbinds_textual_description = mib_scalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 4), snmp_admin_string()).setMaxAccess('accessiblefornotify')
if mibBuilder.loadTexts:
acAlarmVarbindsTextualDescription.setStatus('current')
if mibBuilder.loadTexts:
acAlarmVarbindsTextualDescription.setDescription('Text that descries the alarm condition.')
ac_alarm_varbinds_source = mib_scalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 5), snmp_admin_string()).setMaxAccess('accessiblefornotify')
if mibBuilder.loadTexts:
acAlarmVarbindsSource.setStatus('current')
if mibBuilder.loadTexts:
acAlarmVarbindsSource.setDescription('The component in the system which raised or cleared the alarm.')
ac_alarm_varbinds_severity = mib_scalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 6), ac_alarm_severity()).setMaxAccess('accessiblefornotify')
if mibBuilder.loadTexts:
acAlarmVarbindsSeverity.setStatus('current')
if mibBuilder.loadTexts:
acAlarmVarbindsSeverity.setDescription('The severity of the alarm. A severity of warning, minor, major or critical indicates a raise trap. A severity of cleared indicates a clear trap.')
ac_alarm_varbinds_event_type = mib_scalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 7), ac_alarm_event_type()).setMaxAccess('accessiblefornotify')
if mibBuilder.loadTexts:
acAlarmVarbindsEventType.setStatus('current')
if mibBuilder.loadTexts:
acAlarmVarbindsEventType.setDescription('The event type of the alarm.')
ac_alarm_varbinds_probable_cause = mib_scalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 8), ac_alarm_probable_cause()).setMaxAccess('accessiblefornotify')
if mibBuilder.loadTexts:
acAlarmVarbindsProbableCause.setStatus('current')
if mibBuilder.loadTexts:
acAlarmVarbindsProbableCause.setDescription('The probable cause of the alarm.')
ac_alarm_varbinds_additional_info1 = mib_scalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 9), snmp_admin_string()).setMaxAccess('accessiblefornotify')
if mibBuilder.loadTexts:
acAlarmVarbindsAdditionalInfo1.setStatus('current')
if mibBuilder.loadTexts:
acAlarmVarbindsAdditionalInfo1.setDescription('Additional miscellaneous info regarding this alarm.')
ac_alarm_varbinds_additional_info2 = mib_scalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 10), snmp_admin_string()).setMaxAccess('accessiblefornotify')
if mibBuilder.loadTexts:
acAlarmVarbindsAdditionalInfo2.setStatus('current')
if mibBuilder.loadTexts:
acAlarmVarbindsAdditionalInfo2.setDescription('Additional miscellaneous info regarding this alarm.')
ac_alarm_varbinds_additional_info3 = mib_scalar((1, 3, 6, 1, 4, 1, 5003, 11, 1, 3, 11), snmp_admin_string()).setMaxAccess('accessiblefornotify')
if mibBuilder.loadTexts:
acAlarmVarbindsAdditionalInfo3.setStatus('current')
if mibBuilder.loadTexts:
acAlarmVarbindsAdditionalInfo3.setDescription('Additional miscellaneous info regarding this alarm.')
mibBuilder.exportSymbols('AcAlarm', acAlarmVarbinds=acAlarmVarbinds, acActiveAlarmSource=acActiveAlarmSource, acActiveAlarmSeverity=acActiveAlarmSeverity, audioCodes=audioCodes, acAlarmHistorySequenceNumber=acAlarmHistorySequenceNumber, acAlarmVarbindsSource=acAlarmVarbindsSource, acAlarmHistory=acAlarmHistory, acActiveAlarmEventType=acActiveAlarmEventType, acAlarmHistoryEventType=acAlarmHistoryEventType, acActiveAlarmTable=acActiveAlarmTable, acActiveAlarmSysuptime=acActiveAlarmSysuptime, acAlarmVarbindsDateAndTime=acAlarmVarbindsDateAndTime, acAlarmVarbindsSeverity=acAlarmVarbindsSeverity, acAlarmVarbindsTextualDescription=acAlarmVarbindsTextualDescription, acActiveAlarmName=acActiveAlarmName, acAlarmVarbindsEventType=acAlarmVarbindsEventType, acActiveAlarmSequenceNumber=acActiveAlarmSequenceNumber, acActiveAlarm=acActiveAlarm, acAlarmHistoryAdditionalInfo2=acAlarmHistoryAdditionalInfo2, acActiveAlarmTextualDescription=acActiveAlarmTextualDescription, acAlarmHistoryProbableCause=acAlarmHistoryProbableCause, acAlarmHistoryAdditionalInfo3=acAlarmHistoryAdditionalInfo3, acActiveAlarmTrapOID=acActiveAlarmTrapOID, acAlarmVarbindsSequenceNumber=acAlarmVarbindsSequenceNumber, acAlarmVarbindsAlarmName=acAlarmVarbindsAlarmName, acAlarmVarbindsAdditionalInfo2=acAlarmVarbindsAdditionalInfo2, acAlarmHistoryTrapOID=acAlarmHistoryTrapOID, acActiveAlarmDateAndTime=acActiveAlarmDateAndTime, acAlarmHistoryDateAndTime=acAlarmHistoryDateAndTime, acAlarmHistoryEntry=acAlarmHistoryEntry, acAlarm=acAlarm, acAlarmHistoryName=acAlarmHistoryName, acActiveAlarmProbableCause=acActiveAlarmProbableCause, acActiveAlarmAdditionalInfo2=acActiveAlarmAdditionalInfo2, acAlarmHistorySource=acAlarmHistorySource, acActiveAlarmEntry=acActiveAlarmEntry, acAlarmHistoryTable=acAlarmHistoryTable, acActiveAlarmAdditionalInfo3=acActiveAlarmAdditionalInfo3, acAlarmHistoryAdditionalInfo1=acAlarmHistoryAdditionalInfo1, acAlarmVarbindsAdditionalInfo1=acAlarmVarbindsAdditionalInfo1, acAlarmVarbindsAdditionalInfo3=acAlarmVarbindsAdditionalInfo3, PYSNMP_MODULE_ID=acAlarm, acActiveAlarmAdditionalInfo1=acActiveAlarmAdditionalInfo1, acAlarmVarbindsProbableCause=acAlarmVarbindsProbableCause, acFault=acFault, acAlarmHistoryTextualDescription=acAlarmHistoryTextualDescription, acAlarmHistorySysuptime=acAlarmHistorySysuptime, acAlarmHistorySeverity=acAlarmHistorySeverity) |
'''
Processing of data via :py:mod:`.json_io`.
Utilities for Excel conversion in :py:mod:`.convert` and :py:mod:`.service_sheet`.
Example code in :py:mod:`.cli_examples` and :py:mod:`.plots`.
'''
| """
Processing of data via :py:mod:`.json_io`.
Utilities for Excel conversion in :py:mod:`.convert` and :py:mod:`.service_sheet`.
Example code in :py:mod:`.cli_examples` and :py:mod:`.plots`.
""" |
# Create by Packetsss
# Personal use is allowed
# Commercial use is prohibited
name = input("Enter your baphoon:")
age = input("Enter your chikka:")
print("WTF " + name + "! You are " + age + "??")
num1 = input("Number 1:")
num2 = input("Number 2:")
result = num1 + num2
| name = input('Enter your baphoon:')
age = input('Enter your chikka:')
print('WTF ' + name + '! You are ' + age + '??')
num1 = input('Number 1:')
num2 = input('Number 2:')
result = num1 + num2 |
class Solution:
def twoCitySchedCost(self, costs: List[List[int]]) -> int:
for i in range(0,len(costs)):
costs[i].append(costs[i][0]-costs[i][1])
costs.sort(key = lambda x:x[2])
result=0
for i in range(0,len(costs)//2):
result+=costs[i][0]
for i in range(len(costs)//2,len(costs)):
result+=costs[i][1]
return result
| class Solution:
def two_city_sched_cost(self, costs: List[List[int]]) -> int:
for i in range(0, len(costs)):
costs[i].append(costs[i][0] - costs[i][1])
costs.sort(key=lambda x: x[2])
result = 0
for i in range(0, len(costs) // 2):
result += costs[i][0]
for i in range(len(costs) // 2, len(costs)):
result += costs[i][1]
return result |
print("To print the place values of integer")
a=int(input("Enter the integer value:"))
n=a%10
print("The unit digit of {} is{}".format(a,n))
| print('To print the place values of integer')
a = int(input('Enter the integer value:'))
n = a % 10
print('The unit digit of {} is{}'.format(a, n)) |
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution(object):
def deleteNode(self, root, key):
if not root: # if root doesn't exist, just return it
return root
if root.val > key: # if key value is less than root value, find the node in the left subtree
root.left = self.deleteNode(root.left, key)
elif root.val < key: # if key value is greater than root value, find the node in right subtree
root.right = self.deleteNode(root.right, key)
else: #if we found the node (root.value == key), start to delete it
if not root.right: # if it doesn't have right children, we delete the node then new root would be root.left
return root.left
if not root.left: # if it has no left children, we delete the node then new root would be root.right
return root.right
# if the node have both left and right children, we replace its value with the minmimum value in the right subtree and then delete that minimum node in the right subtree
temp = root.right
mini = temp.val
while temp.left:
temp = temp.left
mini = temp.val
root.val = mini # replace value
root.right = self.deleteNode(root.right,root.val) # delete the minimum node in right subtree
return root | class Solution(object):
def delete_node(self, root, key):
if not root:
return root
if root.val > key:
root.left = self.deleteNode(root.left, key)
elif root.val < key:
root.right = self.deleteNode(root.right, key)
else:
if not root.right:
return root.left
if not root.left:
return root.right
temp = root.right
mini = temp.val
while temp.left:
temp = temp.left
mini = temp.val
root.val = mini
root.right = self.deleteNode(root.right, root.val)
return root |
ilksayi=1
ikincisayi=1
fibo=[ilksayi,ikincisayi]
for i in range(0,20):
ilksayi,ikincisayi=ikincisayi,ilksayi+ikincisayi
fibo.append(ikincisayi)
print(fibo) | ilksayi = 1
ikincisayi = 1
fibo = [ilksayi, ikincisayi]
for i in range(0, 20):
(ilksayi, ikincisayi) = (ikincisayi, ilksayi + ikincisayi)
fibo.append(ikincisayi)
print(fibo) |
class BinaryNotFound(Exception):
def __init__(self, binary_name):
Exception.__init__(self)
self.binary_name = binary_name
class BinaryCallFailed(Exception):
def __init__(self):
Exception.__init__(self)
class InvalidMedia(Exception):
def __init__(self, media_path):
Exception.__init__(self)
self.media_path = media_path
class StreamIndexOutOfBound(Exception):
def __init__(self):
Exception.__init__(self)
class StreamEntryNotFound(Exception):
def __init__(self):
Exception.__init__(self)
class StreamLoadError(Exception):
def __init__(self):
Exception.__init__(self) | class Binarynotfound(Exception):
def __init__(self, binary_name):
Exception.__init__(self)
self.binary_name = binary_name
class Binarycallfailed(Exception):
def __init__(self):
Exception.__init__(self)
class Invalidmedia(Exception):
def __init__(self, media_path):
Exception.__init__(self)
self.media_path = media_path
class Streamindexoutofbound(Exception):
def __init__(self):
Exception.__init__(self)
class Streamentrynotfound(Exception):
def __init__(self):
Exception.__init__(self)
class Streamloaderror(Exception):
def __init__(self):
Exception.__init__(self) |
# Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def removeElements(self, head: ListNode, val: int) -> ListNode:
current = head
previous = None
while current is not None:
if current.val == val:
if previous is None:
head = current.next
else:
previous.next = current.next
current = current.next
else:
previous = current
current = current.next
return head
class WorseSolution:
def removeElements(self, head: ListNode, val: int) -> ListNode:
current = previous = head
while current is not None:
if current.val == val:
if current == head:
previous = current = head = current.next
else:
previous.next = current.next
current = current.next
else:
previous = current
current = current.next
return head
class SentinelTwoPointersSolution:
def removeElements(self, head: ListNode, val: int) -> ListNode:
sentinel = ListNode(val=0, next=head)
prev, curr = sentinel, head
while curr is not None:
if curr.val == val:
prev.next = curr.next
else:
prev = curr
curr = curr.next
return sentinel.next
class FinalSolution:
def removeElements(self, head: ListNode, val: int) -> ListNode:
sentinel = ListNode(val=0, next=head)
prev = sentinel
while prev.next is not None:
if prev.next.val == val:
prev.next = prev.next.next
else:
prev = prev.next
return sentinel.next
| class Listnode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def remove_elements(self, head: ListNode, val: int) -> ListNode:
current = head
previous = None
while current is not None:
if current.val == val:
if previous is None:
head = current.next
else:
previous.next = current.next
current = current.next
else:
previous = current
current = current.next
return head
class Worsesolution:
def remove_elements(self, head: ListNode, val: int) -> ListNode:
current = previous = head
while current is not None:
if current.val == val:
if current == head:
previous = current = head = current.next
else:
previous.next = current.next
current = current.next
else:
previous = current
current = current.next
return head
class Sentineltwopointerssolution:
def remove_elements(self, head: ListNode, val: int) -> ListNode:
sentinel = list_node(val=0, next=head)
(prev, curr) = (sentinel, head)
while curr is not None:
if curr.val == val:
prev.next = curr.next
else:
prev = curr
curr = curr.next
return sentinel.next
class Finalsolution:
def remove_elements(self, head: ListNode, val: int) -> ListNode:
sentinel = list_node(val=0, next=head)
prev = sentinel
while prev.next is not None:
if prev.next.val == val:
prev.next = prev.next.next
else:
prev = prev.next
return sentinel.next |
##
##
# File auto-generated against equivalent DynamicSerialize Java class
class DeleteFilesRequest(object):
def __init__(self):
self.datesToDelete = None
def getDatesToDelete(self):
return self.datesToDelete
def setDatesToDelete(self, datesToDelete):
self.datesToDelete = datesToDelete
def getFilename(self):
return self.filename
def setFilename(self, filename):
self.filename = filename
| class Deletefilesrequest(object):
def __init__(self):
self.datesToDelete = None
def get_dates_to_delete(self):
return self.datesToDelete
def set_dates_to_delete(self, datesToDelete):
self.datesToDelete = datesToDelete
def get_filename(self):
return self.filename
def set_filename(self, filename):
self.filename = filename |
# -*- coding: utf-8 -*-
'''
In a given list the first element should become the last one.
An empty list or list with only one element should stay the same.
Input: List.
Output: Iterable.
'''
def replace_first(items):
# your code here
return items[1:] + items[:1]
if __name__ == "__main__":
print("Example:")
print(list(replace_first([1, 2, 3, 4])))
# These "asserts" are used for self-checking and not for an auto-testing
assert list(replace_first([1, 2, 3, 4])) == [2, 3, 4, 1]
assert list(replace_first([1])) == [1]
assert list(replace_first([])) == []
print("Coding complete? Click 'Check' to earn cool rewards!")
| """
In a given list the first element should become the last one.
An empty list or list with only one element should stay the same.
Input: List.
Output: Iterable.
"""
def replace_first(items):
return items[1:] + items[:1]
if __name__ == '__main__':
print('Example:')
print(list(replace_first([1, 2, 3, 4])))
assert list(replace_first([1, 2, 3, 4])) == [2, 3, 4, 1]
assert list(replace_first([1])) == [1]
assert list(replace_first([])) == []
print("Coding complete? Click 'Check' to earn cool rewards!") |
'''
FetcherResponse will return a well-formed FetcherResponse object
{
name: string,
payload: {file_name: binary_data} | None,
source: string
error: Error object
}
"payload" - string - binary data from a successful url fetch or None on fail
"source" - string - the url the fetch was performed against
"error" - error / string - None or the __repr__ of the error on fail
'''
class FetcherResponse:
name = ''
source = ''
payload = None
error = None
def __init__(self, name, payload, source, error):
self.name = name
self.payload = payload
self.source = source
self.error = error
def __repr__(self):
return str(self.to_dict())
def to_dict(self):
return {
'name': self.name,
'payload': self.payload,
'source': self.source,
'error': self.error
}
| """
FetcherResponse will return a well-formed FetcherResponse object
{
name: string,
payload: {file_name: binary_data} | None,
source: string
error: Error object
}
"payload" - string - binary data from a successful url fetch or None on fail
"source" - string - the url the fetch was performed against
"error" - error / string - None or the __repr__ of the error on fail
"""
class Fetcherresponse:
name = ''
source = ''
payload = None
error = None
def __init__(self, name, payload, source, error):
self.name = name
self.payload = payload
self.source = source
self.error = error
def __repr__(self):
return str(self.to_dict())
def to_dict(self):
return {'name': self.name, 'payload': self.payload, 'source': self.source, 'error': self.error} |
load(":character_classes.bzl", "is_alphanumeric", "is_lower_case_letter", "is_numeric", "is_upper_case_letter")
def tokenize(s):
queue = []
parts = []
part = ""
for i in range(len(s)):
ch = s[i]
if is_alphanumeric(ch):
if len(queue) == 2:
if is_upper_case_letter(ch):
if is_lower_case_letter(queue[0]) or is_numeric(queue[0]):
part = part + queue.pop() + queue.pop()
parts.append(part)
part = ""
else:
part = part + queue.pop()
elif is_lower_case_letter(ch):
if is_upper_case_letter(queue[0]) and is_upper_case_letter(queue[1]):
part = part + queue.pop()
parts.append(part)
part = ""
else:
part = part + queue.pop()
else:
part = part + queue.pop()
elif len(queue) == 1:
if is_upper_case_letter(ch):
if is_lower_case_letter(queue[0]) or is_numeric(queue[0]):
part = part + queue.pop()
parts.append(part)
part = ""
queue.insert(0, ch)
else:
count = len(queue)
for _ in range(count):
part = part + queue.pop()
if part != "":
parts.append(part)
part = ""
# Drain queue
count = len(queue)
for _ in range(count):
part = part + queue.pop()
if part != "":
parts.append(part)
return parts
| load(':character_classes.bzl', 'is_alphanumeric', 'is_lower_case_letter', 'is_numeric', 'is_upper_case_letter')
def tokenize(s):
queue = []
parts = []
part = ''
for i in range(len(s)):
ch = s[i]
if is_alphanumeric(ch):
if len(queue) == 2:
if is_upper_case_letter(ch):
if is_lower_case_letter(queue[0]) or is_numeric(queue[0]):
part = part + queue.pop() + queue.pop()
parts.append(part)
part = ''
else:
part = part + queue.pop()
elif is_lower_case_letter(ch):
if is_upper_case_letter(queue[0]) and is_upper_case_letter(queue[1]):
part = part + queue.pop()
parts.append(part)
part = ''
else:
part = part + queue.pop()
else:
part = part + queue.pop()
elif len(queue) == 1:
if is_upper_case_letter(ch):
if is_lower_case_letter(queue[0]) or is_numeric(queue[0]):
part = part + queue.pop()
parts.append(part)
part = ''
queue.insert(0, ch)
else:
count = len(queue)
for _ in range(count):
part = part + queue.pop()
if part != '':
parts.append(part)
part = ''
count = len(queue)
for _ in range(count):
part = part + queue.pop()
if part != '':
parts.append(part)
return parts |
# stats.py
def init():
global _stats
_stats = {}
def event_occurred(event):
global _stats
try:
_stats[event] = _stats[event] + 1
except KeyError:
_stats[event] = 1
def get_stats():
global _stats
return sorted(_stats.items())
| def init():
global _stats
_stats = {}
def event_occurred(event):
global _stats
try:
_stats[event] = _stats[event] + 1
except KeyError:
_stats[event] = 1
def get_stats():
global _stats
return sorted(_stats.items()) |
def is_odd(n):
return n % 2 == 1
def collatz(n):
xs = []
while n != 1:
xs.append(n)
if is_odd(n):
n = 3*n + 1
else:
n = n // 2
xs.append(1)
return xs
def test_collatz():
assert collatz(8) == [8, 4, 2, 1]
assert collatz(5) == [5, 16, 8, 4, 2, 1]
| def is_odd(n):
return n % 2 == 1
def collatz(n):
xs = []
while n != 1:
xs.append(n)
if is_odd(n):
n = 3 * n + 1
else:
n = n // 2
xs.append(1)
return xs
def test_collatz():
assert collatz(8) == [8, 4, 2, 1]
assert collatz(5) == [5, 16, 8, 4, 2, 1] |
email = [
"rwandaonline.rw",
"rra.gov.rw",
"ur.ac.rw",
"gmail.com",
"yahoo.com",
"yahoo.fr"
]
| email = ['rwandaonline.rw', 'rra.gov.rw', 'ur.ac.rw', 'gmail.com', 'yahoo.com', 'yahoo.fr'] |
print('list as x y z ...')
a = []
a = input().split(' ')
a = list(map(int, a))
for elemt in (map(lambda x: 'par' if x%2 == 0 else 'impar', a)):
print (elemt) | print('list as x y z ...')
a = []
a = input().split(' ')
a = list(map(int, a))
for elemt in map(lambda x: 'par' if x % 2 == 0 else 'impar', a):
print(elemt) |
while True:
try:
n = int(input())
except:
break
data = list()
maax = list()
miin = list()
for x in range(n):
data.append(list(map(int, input().split())))
for x in range(n):
maax.append(data[x][1])
miin.append(data[x][0])
result = [0]*(max(maax)-min(miin))
for x in range(n):
for y in range(maax[x]-miin[x]):
result[miin[x]-min(miin)+y] = 1
print(result.count(1))
| while True:
try:
n = int(input())
except:
break
data = list()
maax = list()
miin = list()
for x in range(n):
data.append(list(map(int, input().split())))
for x in range(n):
maax.append(data[x][1])
miin.append(data[x][0])
result = [0] * (max(maax) - min(miin))
for x in range(n):
for y in range(maax[x] - miin[x]):
result[miin[x] - min(miin) + y] = 1
print(result.count(1)) |
applyPatch('20210630-dldt-disable-unused-targets.patch')
applyPatch('20210630-dldt-pdb.patch')
applyPatch('20210630-dldt-disable-multidevice-autoplugin.patch')
applyPatch('20210630-dldt-vs-version.patch')
| apply_patch('20210630-dldt-disable-unused-targets.patch')
apply_patch('20210630-dldt-pdb.patch')
apply_patch('20210630-dldt-disable-multidevice-autoplugin.patch')
apply_patch('20210630-dldt-vs-version.patch') |
try:
age = int(input("How old are you: "))
#if statement
if age < 0:
print("You are a time traveller")
else:
if 0 < age <= 17:
print("Too young to vote")
else:
if age >= 18:
print("You can vote")
except:
print("Please use only numeric values")
| try:
age = int(input('How old are you: '))
if age < 0:
print('You are a time traveller')
elif 0 < age <= 17:
print('Too young to vote')
elif age >= 18:
print('You can vote')
except:
print('Please use only numeric values') |
# iterating backwards
# removing rogue vlues
# when an item 's removed from the list, all the later items are shuffled down, to fill in the gap
# That messes upu the index numbers, as we work forwards through the list
data = [104, 101, 4, 105, 308, 103, 5,
107, 100, 306, 106, 102, 108]
min_valid = 100
max_valid = 200
# for index in range(len(data) - 1, - 1, - 1):
# if data[index] < min_valid or data[index] > max_valid:
# print(index, data)
# print(index)
# del data[index]
# print(data)
# this does the same thing as the one in outlier
# another way
top_index = len(data) -1
for index, value in enumerate(reversed(data)):
if value < min_valid or value > max_valid:
print(top_index - index, value)
del data[top_index - index]
print(data) | data = [104, 101, 4, 105, 308, 103, 5, 107, 100, 306, 106, 102, 108]
min_valid = 100
max_valid = 200
top_index = len(data) - 1
for (index, value) in enumerate(reversed(data)):
if value < min_valid or value > max_valid:
print(top_index - index, value)
del data[top_index - index]
print(data) |
# A quick solution for day 12 part 2 in Python
# for debugging of the Pascal version
x = 0
y = 0
wx = 10
wy = -1
with open('resources/input.txt', 'r') as f:
for l in f.readlines():
l = l.strip()
i = l[0]
n = int(l[1:])
if i == 'N':
wy -= n
elif i == 'W':
wx -= n
elif i == 'S':
wy += n
elif i == 'E':
wx += n
elif i == 'F':
x += wx * n
y += wy * n
elif i == 'L':
for i in range(n // 90):
(wx, wy) = (wy, -wx)
elif i == 'R':
for i in range(n // 90):
(wx, wy) = (-wy, wx)
print(f'{l} - pos x: {x}, y: {y}, wp x: {wx}, y: {wy}')
print(f'Part 2: {abs(x) + abs(y)}')
| x = 0
y = 0
wx = 10
wy = -1
with open('resources/input.txt', 'r') as f:
for l in f.readlines():
l = l.strip()
i = l[0]
n = int(l[1:])
if i == 'N':
wy -= n
elif i == 'W':
wx -= n
elif i == 'S':
wy += n
elif i == 'E':
wx += n
elif i == 'F':
x += wx * n
y += wy * n
elif i == 'L':
for i in range(n // 90):
(wx, wy) = (wy, -wx)
elif i == 'R':
for i in range(n // 90):
(wx, wy) = (-wy, wx)
print(f'{l} - pos x: {x}, y: {y}, wp x: {wx}, y: {wy}')
print(f'Part 2: {abs(x) + abs(y)}') |
a = get()
b = execute(mogrify(get()))
print(b)
mogrify(a)
c = get()
| a = get()
b = execute(mogrify(get()))
print(b)
mogrify(a)
c = get() |
year=int(input('enter a num:'))
if year%4==0 or year%400==0:
print('leap year')
else:
print('not') | year = int(input('enter a num:'))
if year % 4 == 0 or year % 400 == 0:
print('leap year')
else:
print('not') |
# A few global config settings
API_KEY=''
ORG_ID=''
S3_BUCKET_NAME=''
S3_ACCESS_KEY=''
S3_SECRET_KEY=''
MY_ID=''
PLAYER_LICENSE='' | api_key = ''
org_id = ''
s3_bucket_name = ''
s3_access_key = ''
s3_secret_key = ''
my_id = ''
player_license = '' |
__authors__ = ""
__copyright__ = "(c) 2014, pymal"
__license__ = "BSD License"
__contact__ = "Name Of Current Guardian of this file <email@address>"
USER_AGENT = 'api-indiv-0829BA2B33942A4A5E6338FE05EFB8A1'
HOST_NAME = "http://myanimelist.net"
DEBUG = False
RETRY_NUMBER = 4
RETRY_SLEEP = 1
SHORT_SITE_FORMAT_TIME = '%b %Y'
LONG_SITE_FORMAT_TIME = '%b %d, %Y'
MALAPPINFO_FORMAT_TIME = "%Y-%m-%d"
MALAPPINFO_NONE_TIME = "0000-00-00"
MALAPI_FORMAT_TIME = "%Y%m%d"
MALAPI_NONE_TIME = "00000000"
| __authors__ = ''
__copyright__ = '(c) 2014, pymal'
__license__ = 'BSD License'
__contact__ = 'Name Of Current Guardian of this file <email@address>'
user_agent = 'api-indiv-0829BA2B33942A4A5E6338FE05EFB8A1'
host_name = 'http://myanimelist.net'
debug = False
retry_number = 4
retry_sleep = 1
short_site_format_time = '%b %Y'
long_site_format_time = '%b %d, %Y'
malappinfo_format_time = '%Y-%m-%d'
malappinfo_none_time = '0000-00-00'
malapi_format_time = '%Y%m%d'
malapi_none_time = '00000000' |
class Solution:
def nextGreaterElements(self, nums: List[int]) -> List[int]:
n = len(nums)
stack = []
result = [-1] * n
for i in range(n * 2):
value = nums[i % n]
while stack and nums[stack[-1] % n] < value:
result[stack.pop() % n] = value
stack.append(i)
return result
| class Solution:
def next_greater_elements(self, nums: List[int]) -> List[int]:
n = len(nums)
stack = []
result = [-1] * n
for i in range(n * 2):
value = nums[i % n]
while stack and nums[stack[-1] % n] < value:
result[stack.pop() % n] = value
stack.append(i)
return result |
# Part One
matrix = []
with open("input") as f:
for row in f:
matrix.append(row)
gama_rate = ""
epsilon_rate = ""
element_list = []
def most_frequent(List):
return max(set(List), key=List.count)
l_row = int(len(matrix[0]))
for el in range(1, l_row):
for row in matrix:
element = row[el - 1]
element_list.append(int(element))
most_fr = str(most_frequent(element_list))
gama_rate += most_fr
if most_fr == "1":
epsilon_rate += "0"
else:
epsilon_rate += "1"
element_list = []
gama_rate_decimal = int(gama_rate, 2)
epsilon_rate_decimal = int(epsilon_rate, 2)
print(gama_rate_decimal * epsilon_rate_decimal)
# Part One
list_ones = []
list_zeroes = []
counter = 0
original_matrix = matrix
while len(matrix) != 1:
for row in matrix:
if row[counter] == '0':
list_zeroes.append(row)
else:
list_ones.append(row)
if len(list_zeroes) > len(list_ones):
list_ones = []
matrix = list_zeroes
list_zeroes = []
elif len(list_ones) > len(list_zeroes):
list_zeroes = []
matrix = list_ones
list_ones = []
else:
list_zeroes = []
matrix = list_ones
list_ones = []
counter += 1
oxygen_generator = matrix[0]
# print(oxygen_generator)
list_ones = []
list_zeroes = []
counter = 0
matrix = original_matrix
while len(matrix) != 1:
for row in matrix:
if row[counter] == '0':
list_zeroes.append(row)
else:
list_ones.append(row)
if len(list_zeroes) < len(list_ones):
list_ones = []
matrix = list_zeroes
list_zeroes = []
elif len(list_ones) < len(list_zeroes):
list_zeroes = []
matrix = list_ones
list_ones = []
else:
list_ones = []
matrix = list_zeroes
list_zeroes = []
counter += 1
co2_scrubber = matrix[0]
# print(co2_scrubber)
oxygen_generator_decimal = int(oxygen_generator, 2)
co2_scrubber_decimal = int(co2_scrubber, 2)
print(oxygen_generator_decimal * co2_scrubber_decimal)
| matrix = []
with open('input') as f:
for row in f:
matrix.append(row)
gama_rate = ''
epsilon_rate = ''
element_list = []
def most_frequent(List):
return max(set(List), key=List.count)
l_row = int(len(matrix[0]))
for el in range(1, l_row):
for row in matrix:
element = row[el - 1]
element_list.append(int(element))
most_fr = str(most_frequent(element_list))
gama_rate += most_fr
if most_fr == '1':
epsilon_rate += '0'
else:
epsilon_rate += '1'
element_list = []
gama_rate_decimal = int(gama_rate, 2)
epsilon_rate_decimal = int(epsilon_rate, 2)
print(gama_rate_decimal * epsilon_rate_decimal)
list_ones = []
list_zeroes = []
counter = 0
original_matrix = matrix
while len(matrix) != 1:
for row in matrix:
if row[counter] == '0':
list_zeroes.append(row)
else:
list_ones.append(row)
if len(list_zeroes) > len(list_ones):
list_ones = []
matrix = list_zeroes
list_zeroes = []
elif len(list_ones) > len(list_zeroes):
list_zeroes = []
matrix = list_ones
list_ones = []
else:
list_zeroes = []
matrix = list_ones
list_ones = []
counter += 1
oxygen_generator = matrix[0]
list_ones = []
list_zeroes = []
counter = 0
matrix = original_matrix
while len(matrix) != 1:
for row in matrix:
if row[counter] == '0':
list_zeroes.append(row)
else:
list_ones.append(row)
if len(list_zeroes) < len(list_ones):
list_ones = []
matrix = list_zeroes
list_zeroes = []
elif len(list_ones) < len(list_zeroes):
list_zeroes = []
matrix = list_ones
list_ones = []
else:
list_ones = []
matrix = list_zeroes
list_zeroes = []
counter += 1
co2_scrubber = matrix[0]
oxygen_generator_decimal = int(oxygen_generator, 2)
co2_scrubber_decimal = int(co2_scrubber, 2)
print(oxygen_generator_decimal * co2_scrubber_decimal) |
class Address:
host = 'localhost'
port = '9666'
def __init__(self, host=None, port=None):
if host is not None:
self.host = host
if port is not None:
self.port = port
def is_empty(self) -> bool:
return self.host == '' or self.port == ''
def string(self) -> str:
return f'{self.host}:{self.port}'
def new_address_from_string(address: str) -> Address:
parts = address.split(':')
if len(parts) == 1:
return Address(host=parts[0])
elif len(parts) == 2:
return Address(host=parts[0], port=parts[1])
else:
raise Exception(f'parsing address error: {address}')
| class Address:
host = 'localhost'
port = '9666'
def __init__(self, host=None, port=None):
if host is not None:
self.host = host
if port is not None:
self.port = port
def is_empty(self) -> bool:
return self.host == '' or self.port == ''
def string(self) -> str:
return f'{self.host}:{self.port}'
def new_address_from_string(address: str) -> Address:
parts = address.split(':')
if len(parts) == 1:
return address(host=parts[0])
elif len(parts) == 2:
return address(host=parts[0], port=parts[1])
else:
raise exception(f'parsing address error: {address}') |
f = open("cub_200/val.txt", "r")
class_dict = {}
rtn = open('val_tmp.txt', 'w')
for x in f:
class_int = int(x[7:10])
if class_int not in class_dict.keys():
class_dict[class_int] = 1
else:
class_dict[class_int] += 1
if class_dict[class_int] > 5:
if class_int % 2 == 0:
if class_dict[class_int] <= 15:
rtn.write(x)
else:
pass
else:
rtn.write(x)
| f = open('cub_200/val.txt', 'r')
class_dict = {}
rtn = open('val_tmp.txt', 'w')
for x in f:
class_int = int(x[7:10])
if class_int not in class_dict.keys():
class_dict[class_int] = 1
else:
class_dict[class_int] += 1
if class_dict[class_int] > 5:
if class_int % 2 == 0:
if class_dict[class_int] <= 15:
rtn.write(x)
else:
pass
else:
rtn.write(x) |
# coding: utf-8
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
},
}
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.sites',
'django.contrib.sessions',
'django.contrib.contenttypes',
'registration',
'test_app',
)
SECRET_KEY = '_'
SITE_ID = 1
ROOT_URLCONF = 'test_app.urls'
TEMPLATE_LOADERS = (
'django.template.loaders.app_directories.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
) | databases = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:'}}
installed_apps = ('django.contrib.auth', 'django.contrib.sites', 'django.contrib.sessions', 'django.contrib.contenttypes', 'registration', 'test_app')
secret_key = '_'
site_id = 1
root_urlconf = 'test_app.urls'
template_loaders = ('django.template.loaders.app_directories.Loader',)
middleware_classes = ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware') |
def show_state(state, player):
return {
'hands': state['hands'],
'turn': state['turn'],
}
| def show_state(state, player):
return {'hands': state['hands'], 'turn': state['turn']} |
class MultimodalDataset:
def __init__(self, samples, modality_factories):
super().__init__()
self.samples = samples
self.modality_factories = modality_factories
self._register_modalites_to_samples()
def _register_modalites_to_samples(self):
for sample in self.samples:
for modality_factory in self.modality_factories:
sample.add_modality(modality_factory)
def __getitem__(self, index):
return self.samples[index].fetch()
def __len__(self):
return len(self.samples)
| class Multimodaldataset:
def __init__(self, samples, modality_factories):
super().__init__()
self.samples = samples
self.modality_factories = modality_factories
self._register_modalites_to_samples()
def _register_modalites_to_samples(self):
for sample in self.samples:
for modality_factory in self.modality_factories:
sample.add_modality(modality_factory)
def __getitem__(self, index):
return self.samples[index].fetch()
def __len__(self):
return len(self.samples) |
class Solution:
def isValid(self, s: str) -> bool:
matched=[0 for i in range(len(s))]
open_brace=0
find=''
for i in range (len(s)):
if(s[i]==')' or s[i]=='}' or s[i]==']'):
if(s[i]==')'):
find='('
elif(s[i]=='}'):
find='{'
elif(s[i]==']'):
find='['
if(i==0):
return False
else:
j=i-1
while j>=0:
if(matched[j]==0 and s[j]==find):
matched[i]=1
matched[j]=1
open_brace-=1
find=''
break
elif(matched[j]==0):
return False
j-=1
else:
open_brace+=1
if(open_brace==0 and find==''):
return True
else:
return False
| class Solution:
def is_valid(self, s: str) -> bool:
matched = [0 for i in range(len(s))]
open_brace = 0
find = ''
for i in range(len(s)):
if s[i] == ')' or s[i] == '}' or s[i] == ']':
if s[i] == ')':
find = '('
elif s[i] == '}':
find = '{'
elif s[i] == ']':
find = '['
if i == 0:
return False
else:
j = i - 1
while j >= 0:
if matched[j] == 0 and s[j] == find:
matched[i] = 1
matched[j] = 1
open_brace -= 1
find = ''
break
elif matched[j] == 0:
return False
j -= 1
else:
open_brace += 1
if open_brace == 0 and find == '':
return True
else:
return False |
def generate( args ):
args = args.split(',')
start = int(args[0])
numGroups = int(args[1])
perGroup = int(args[2])
interval = int(args[3])
ret = ''
for i in range(numGroups):
first = start + i * interval
last = first + perGroup - 1
ret = ret + '{0}-{1}'.format(first,last)
if i + 1 < numGroups:
ret = ret + ','
return ret
| def generate(args):
args = args.split(',')
start = int(args[0])
num_groups = int(args[1])
per_group = int(args[2])
interval = int(args[3])
ret = ''
for i in range(numGroups):
first = start + i * interval
last = first + perGroup - 1
ret = ret + '{0}-{1}'.format(first, last)
if i + 1 < numGroups:
ret = ret + ','
return ret |
_base_ = '../retinanet/retinanet_r50_fpn_1x_coco.py'
model = dict(
neck=[
dict(
type='FPN',
in_channels=[256, 512, 1024, 2048],
out_channels=256,
start_level=1,
add_extra_convs='on_input',
num_outs=5),
dict(
type='SEPC',
out_channels=256,
Pconv_num=4,
pconv_deform=False,
lcconv_deform=False,
iBN=False, # when open, please set imgs/gpu >= 4
)
],
bbox_head=dict(type='SepcRetinaHead',
num_classes=80,
in_channels=256,
stacked_convs=0,
feat_channels=256,
anchor_generator=dict(
type='AnchorGenerator',
octave_base_scale=4,
scales_per_octave=3,
ratios=[0.5, 1.0, 2.0],
strides=[8, 16, 32, 64, 128]),
bbox_coder=dict(
type='DeltaXYWHBBoxCoder',
target_means=[.0, .0, .0, .0],
target_stds=[1.0, 1.0, 1.0, 1.0]),
loss_cls=dict(
type='FocalLoss',
use_sigmoid=True,
gamma=2.0,
alpha=0.25,
loss_weight=1.0),
loss_bbox=dict(type='L1Loss', loss_weight=1.0)))
work_dir = 'work_dirs/coco/spec/pconv_retinanet_r50_fpn_1x_coco' | _base_ = '../retinanet/retinanet_r50_fpn_1x_coco.py'
model = dict(neck=[dict(type='FPN', in_channels=[256, 512, 1024, 2048], out_channels=256, start_level=1, add_extra_convs='on_input', num_outs=5), dict(type='SEPC', out_channels=256, Pconv_num=4, pconv_deform=False, lcconv_deform=False, iBN=False)], bbox_head=dict(type='SepcRetinaHead', num_classes=80, in_channels=256, stacked_convs=0, feat_channels=256, anchor_generator=dict(type='AnchorGenerator', octave_base_scale=4, scales_per_octave=3, ratios=[0.5, 1.0, 2.0], strides=[8, 16, 32, 64, 128]), bbox_coder=dict(type='DeltaXYWHBBoxCoder', target_means=[0.0, 0.0, 0.0, 0.0], target_stds=[1.0, 1.0, 1.0, 1.0]), loss_cls=dict(type='FocalLoss', use_sigmoid=True, gamma=2.0, alpha=0.25, loss_weight=1.0), loss_bbox=dict(type='L1Loss', loss_weight=1.0)))
work_dir = 'work_dirs/coco/spec/pconv_retinanet_r50_fpn_1x_coco' |
def main():
week={'A':'MON','B':'TUE','C':'WED','D':'THU','E':'FRI','F':'SAT','G':'SUN'}
strs = []
for i in range(0,4):
strs.append(input())
for i in range(0,min(len(strs[0]),len(strs[1]))):
if(strs[0][i]==strs[1][i]):
if(strs[0][i]>='A' and strs[0][i]<='G'):
w=week[strs[0][i]]
last = i+1
break
for i in range(last,min(len(strs[0]),len(strs[1]))):
if(strs[0][i]==strs[1][i]):
if((strs[0][i]>='A' and strs[0][i]<='N') or strs[0][i].isdigit()):
hour = int(strs[0][i]) if strs[0][i].isdigit() else int(ord(strs[0][i]))-int(ord('A'))+10
break
for i in range(0,min(len(strs[2]),len(strs[3]))):
if(strs[2][i] == strs[3][i]):
if(strs[2][i].isalpha()):
m = i
break
print("{} {:0>2d}:{:0>2d}".format(w,hour,m))
main() | def main():
week = {'A': 'MON', 'B': 'TUE', 'C': 'WED', 'D': 'THU', 'E': 'FRI', 'F': 'SAT', 'G': 'SUN'}
strs = []
for i in range(0, 4):
strs.append(input())
for i in range(0, min(len(strs[0]), len(strs[1]))):
if strs[0][i] == strs[1][i]:
if strs[0][i] >= 'A' and strs[0][i] <= 'G':
w = week[strs[0][i]]
last = i + 1
break
for i in range(last, min(len(strs[0]), len(strs[1]))):
if strs[0][i] == strs[1][i]:
if strs[0][i] >= 'A' and strs[0][i] <= 'N' or strs[0][i].isdigit():
hour = int(strs[0][i]) if strs[0][i].isdigit() else int(ord(strs[0][i])) - int(ord('A')) + 10
break
for i in range(0, min(len(strs[2]), len(strs[3]))):
if strs[2][i] == strs[3][i]:
if strs[2][i].isalpha():
m = i
break
print('{} {:0>2d}:{:0>2d}'.format(w, hour, m))
main() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.