content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# -*- coding: utf-8 -*-
class ScraperError(Exception):
pass
| class Scrapererror(Exception):
pass |
PYTHON = "python"
CPP = "cpp"
CSHARP = "csharp"
JAVA = 'java'
CHOICES = (
(PYTHON, 'Python3'),
(CPP, 'C++'),
(CSHARP, 'C#'),
(JAVA, 'Java')
)
| python = 'python'
cpp = 'cpp'
csharp = 'csharp'
java = 'java'
choices = ((PYTHON, 'Python3'), (CPP, 'C++'), (CSHARP, 'C#'), (JAVA, 'Java')) |
# %% Building out get asset events
limit = 50
collection_slug, token_id, ='gutter-cat-gang', None
asset_contract_addresses, offset, only_opensea, auction_type, occurred_before, occurred_after = None, None, None, None, None, None
account_address = None
# initiatie query with limit:
query = {"limit" : str(limit)}
# Check if user provided value for each input parameter, if True, add parameter to query dictionary:
# if on_sale:
# query["on_sale"] = on_sale
if collection_slug:
query["collection_slug"] = collection_slug
if token_id:
query["token_id"] = token_id
if asset_contract_addresses:
query["asset_contract_addresses"] = asset_contract_addresses
if offset:
query["offset"] = str(offset)
if occurred_before:
query["occurred_before"] = pd.to_datetime(occurred_before)
if occurred_after:
query["occurred_after"] = pd.to_datetime(occurred_after)
if account_address:
query["account_address"] = account_address
if only_opensea:
query["only_opensea"] = only_opensea
if auction_type:
query["auction_type"] = auction_type
# Create Header in API call w/ Personal API key (Private)
headers = {"Accept": "application/json",
"X-API-KEY": api_key}
# Get API URL for Bundles:
url = urls['asset_events']
# Query Opensea API
response = requests.request("GET", url, headers=headers, params=query)
raw_output = response.json()
status_code = response.status_code
# Check if Error Code returned in response:
if status_code == 400 or status_code == 404:
err_msg = raw_output
output = []
else:
# If not error in response, expand nested dictionaries in raw JSON format returned
output_list = raw_output["asset_events"]
output = pd.json_normalize(
output_list,
max_level=2,
errors='ignore')
err_msg = "Success"
# %%
# %%
# %% PRIOR CODE TO DO MASS PULL FOR COLLECTIONS
try:
os.remove('events.xlsx')
except:
print('no file to delete')
input_type = 'asset_events'
try:
for i in range(0, 100):
querystring = {
"collection_slug": "cool-cats-nft",
"only_opensea" : "false",
"offset" : "300",
"limit" : "300",
"event_type" : "created",
}
headers = {"Accept": "application/json", "X-API-KEY": api_key}
url = urls[input_type]
response = requests.request("GET", url, headers=headers, params=querystring)
j = response.json()
j = j[input_type]
if i == 0:
df_events_loop, df_asset_loop, df_from_loop, df_payment_loop = read_events(j)
else:
df_events_i, df_asset_i, df_from_i, df_payment_i = read_events(j)
df_events_loop = pd.concat([df_events_loop, df_events_i])
df_asset_loop = pd.concat([df_asset_loop, df_asset_i])
df_from_loop = pd.concat([df_from_loop, df_from_i])
df_payment_loop = pd.concat([df_payment_loop, df_payment_i])
except:
with pd.ExcelWriter('events.xlsx') as writer:
df_events_loop.to_excel(writer, sheet_name='events')
df_asset_loop.to_excel(writer, sheet_name='asset')
df_from_loop.to_excel(writer, sheet_name='from')
df_payment_loop.to_excel(writer, sheet_name='payment')
with pd.ExcelWriter('events.xlsx') as writer:
df_events_loop.to_excel(writer, sheet_name='events')
df_asset_loop.to_excel(writer, sheet_name='asset')
df_from_loop.to_excel(writer, sheet_name='from')
df_payment_loop.to_excel(writer, sheet_name='payment')
| limit = 50
(collection_slug, token_id) = ('gutter-cat-gang', None)
(asset_contract_addresses, offset, only_opensea, auction_type, occurred_before, occurred_after) = (None, None, None, None, None, None)
account_address = None
query = {'limit': str(limit)}
if collection_slug:
query['collection_slug'] = collection_slug
if token_id:
query['token_id'] = token_id
if asset_contract_addresses:
query['asset_contract_addresses'] = asset_contract_addresses
if offset:
query['offset'] = str(offset)
if occurred_before:
query['occurred_before'] = pd.to_datetime(occurred_before)
if occurred_after:
query['occurred_after'] = pd.to_datetime(occurred_after)
if account_address:
query['account_address'] = account_address
if only_opensea:
query['only_opensea'] = only_opensea
if auction_type:
query['auction_type'] = auction_type
headers = {'Accept': 'application/json', 'X-API-KEY': api_key}
url = urls['asset_events']
response = requests.request('GET', url, headers=headers, params=query)
raw_output = response.json()
status_code = response.status_code
if status_code == 400 or status_code == 404:
err_msg = raw_output
output = []
else:
output_list = raw_output['asset_events']
output = pd.json_normalize(output_list, max_level=2, errors='ignore')
err_msg = 'Success'
try:
os.remove('events.xlsx')
except:
print('no file to delete')
input_type = 'asset_events'
try:
for i in range(0, 100):
querystring = {'collection_slug': 'cool-cats-nft', 'only_opensea': 'false', 'offset': '300', 'limit': '300', 'event_type': 'created'}
headers = {'Accept': 'application/json', 'X-API-KEY': api_key}
url = urls[input_type]
response = requests.request('GET', url, headers=headers, params=querystring)
j = response.json()
j = j[input_type]
if i == 0:
(df_events_loop, df_asset_loop, df_from_loop, df_payment_loop) = read_events(j)
else:
(df_events_i, df_asset_i, df_from_i, df_payment_i) = read_events(j)
df_events_loop = pd.concat([df_events_loop, df_events_i])
df_asset_loop = pd.concat([df_asset_loop, df_asset_i])
df_from_loop = pd.concat([df_from_loop, df_from_i])
df_payment_loop = pd.concat([df_payment_loop, df_payment_i])
except:
with pd.ExcelWriter('events.xlsx') as writer:
df_events_loop.to_excel(writer, sheet_name='events')
df_asset_loop.to_excel(writer, sheet_name='asset')
df_from_loop.to_excel(writer, sheet_name='from')
df_payment_loop.to_excel(writer, sheet_name='payment')
with pd.ExcelWriter('events.xlsx') as writer:
df_events_loop.to_excel(writer, sheet_name='events')
df_asset_loop.to_excel(writer, sheet_name='asset')
df_from_loop.to_excel(writer, sheet_name='from')
df_payment_loop.to_excel(writer, sheet_name='payment') |
class AWSCloudWatchAlarmPermissions:
def get_permissions(self, resname, res):
alarmname = self._get_property_or_default(res, "*", "AlarmName")
alarmactions = self._get_property_or_default(res, None, "AlarmActions")
insufficientdataactions = self._get_property_or_default(res, None, "InsufficientDataActions")
okactions = self._get_property_or_default(res, None, "OKActions")
self.permissions.add(
resname=resname,
lifecycle='Create',
actions=[
'cloudwatch:PutMetricAlarm'
],
resources=[
'arn:aws:cloudwatch:{}:{}:alarm:{}'.format(self.region, self.accountid, alarmname)
]
)
if alarmname != "*":
self.permissions.add(
resname=resname,
lifecycle='Create',
actions=[
'cloudwatch:DescribeAlarms'
],
resources=[
'arn:aws:cloudwatch:{}:{}:alarm:{}'.format(self.region, self.accountid, alarmname)
]
)
createslr = False
if alarmactions:
for alarmaction in self._forcelist(alarmactions):
if alarmaction.startswith("arn:aws:automate"):
createslr = True
if insufficientdataactions:
for insufficientdataaction in self._forcelist(insufficientdataactions):
if insufficientdataaction.startswith("arn:aws:automate"):
createslr = True
if okactions:
for okaction in self._forcelist(okactions):
if okaction.startswith("arn:aws:automate"):
createslr = True
if createslr:
self.permissions.add(
resname=resname,
lifecycle='Create',
actions=[
'iam:CreateServiceLinkedRole'
],
resources=[
'arn:aws:iam::{}:role/aws-service-role/events.amazonaws.com/AWSServiceRoleForCloudWatchEvents'.format(self.accountid)
],
conditions={
'StringEquals': {
'iam:AWSServiceName': 'events.amazonaws.com'
}
}
)
self.permissions.add(
resname=resname,
lifecycle='Delete',
actions=[
'cloudwatch:DeleteAlarms'
],
resources=[
'arn:aws:cloudwatch:{}:{}:alarm:{}'.format(self.region, self.accountid, alarmname)
]
) | class Awscloudwatchalarmpermissions:
def get_permissions(self, resname, res):
alarmname = self._get_property_or_default(res, '*', 'AlarmName')
alarmactions = self._get_property_or_default(res, None, 'AlarmActions')
insufficientdataactions = self._get_property_or_default(res, None, 'InsufficientDataActions')
okactions = self._get_property_or_default(res, None, 'OKActions')
self.permissions.add(resname=resname, lifecycle='Create', actions=['cloudwatch:PutMetricAlarm'], resources=['arn:aws:cloudwatch:{}:{}:alarm:{}'.format(self.region, self.accountid, alarmname)])
if alarmname != '*':
self.permissions.add(resname=resname, lifecycle='Create', actions=['cloudwatch:DescribeAlarms'], resources=['arn:aws:cloudwatch:{}:{}:alarm:{}'.format(self.region, self.accountid, alarmname)])
createslr = False
if alarmactions:
for alarmaction in self._forcelist(alarmactions):
if alarmaction.startswith('arn:aws:automate'):
createslr = True
if insufficientdataactions:
for insufficientdataaction in self._forcelist(insufficientdataactions):
if insufficientdataaction.startswith('arn:aws:automate'):
createslr = True
if okactions:
for okaction in self._forcelist(okactions):
if okaction.startswith('arn:aws:automate'):
createslr = True
if createslr:
self.permissions.add(resname=resname, lifecycle='Create', actions=['iam:CreateServiceLinkedRole'], resources=['arn:aws:iam::{}:role/aws-service-role/events.amazonaws.com/AWSServiceRoleForCloudWatchEvents'.format(self.accountid)], conditions={'StringEquals': {'iam:AWSServiceName': 'events.amazonaws.com'}})
self.permissions.add(resname=resname, lifecycle='Delete', actions=['cloudwatch:DeleteAlarms'], resources=['arn:aws:cloudwatch:{}:{}:alarm:{}'.format(self.region, self.accountid, alarmname)]) |
#!/usr/bin/env python3
distro={ }
library=[]
distro["name"]="RedHat"
distro["versions"]=["4.0","5.0","6.0","7.0","8.0"]
library.append(distro.copy())
distro["name"]="Suse"
distro["versions"]=["10.0","11.0","15.0","42.0"]
library.append(distro.copy())
print(library)
| distro = {}
library = []
distro['name'] = 'RedHat'
distro['versions'] = ['4.0', '5.0', '6.0', '7.0', '8.0']
library.append(distro.copy())
distro['name'] = 'Suse'
distro['versions'] = ['10.0', '11.0', '15.0', '42.0']
library.append(distro.copy())
print(library) |
class Method():
def __init__(self):
self.methodDefinition = None
self.locals = []
self.instructions = []
self.maxStack = -1
self.returnType = None
self.parameters = []
self.attributes = [] | class Method:
def __init__(self):
self.methodDefinition = None
self.locals = []
self.instructions = []
self.maxStack = -1
self.returnType = None
self.parameters = []
self.attributes = [] |
class Elevator:
occupancy_limit = 8
def __init__(self, occupants):
if occupants > self.occupancy_limit:
print("The maximum occupancy limit has been exceeded."
f" {occupants - self.occupancy_limit} occupants must exit the elevator.")
self.occupants = occupants
elevator1 = Elevator(6)
print("Elevator 1 occupants:", elevator1.occupants)
elevator2 = Elevator(10)
print("Elevator 2 occupants:", elevator2.occupants)
| class Elevator:
occupancy_limit = 8
def __init__(self, occupants):
if occupants > self.occupancy_limit:
print(f'The maximum occupancy limit has been exceeded. {occupants - self.occupancy_limit} occupants must exit the elevator.')
self.occupants = occupants
elevator1 = elevator(6)
print('Elevator 1 occupants:', elevator1.occupants)
elevator2 = elevator(10)
print('Elevator 2 occupants:', elevator2.occupants) |
first = ['Aousnik', 'Ronodeep', 'Anirban']
last = ['Gupta', 'Gupta', 'Chaudhuri']
names = zip(first, last) # joins the first and last list in the tuples 'names'
for a, b in names:
print(a, b)
''' this function just basically makes a list of tuples like:
[('Aousnik', 'Gupta'), ('Ronodeep', Gupta), ('Anirban', 'Chaudhuri')] just like tuples
'''
| first = ['Aousnik', 'Ronodeep', 'Anirban']
last = ['Gupta', 'Gupta', 'Chaudhuri']
names = zip(first, last)
for (a, b) in names:
print(a, b)
" this function just basically makes a list of tuples like:\n [('Aousnik', 'Gupta'), ('Ronodeep', Gupta), ('Anirban', 'Chaudhuri')] just like tuples\n" |
# x = 5
# y = 10
# z = 20
# x, y, z = 5, 16, 20
# x, y = y, x
# x += 5 #x = x + 5
# x -= 5 #x = x - 5
# x *= 5 #x = x * 5
# x /= 5 #x = x / 5
# x %= 5 #x = x % 5
# y //= 5 #y = y // 5
# y **= z #y = y ** z
values = 1, 2, 3, 4, 5
print(values)
print(type(values))
x, y, *z = values
print(x, y, z)
print(x, y, z[1]) | values = (1, 2, 3, 4, 5)
print(values)
print(type(values))
(x, y, *z) = values
print(x, y, z)
print(x, y, z[1]) |
hght = 420
wdth = 1188
#size(1188,420) #define window size - doesnt work unless in setup
inix = int(random(10,50)) #define x as first value for loop
iniy1 = int(random(0,hght)) #define y1 as random between 0 and 420=height, no global value yet
#iniy2 = iniy1
iniy2 = int(random(0,hght)) #define y2 ---"--- , start values for first line
while iniy1 == iniy2 :
iniy2 = int(random(0,hght)) #iniy1 and iniy2 shouldnt be the same value
cnt = 0 #define count and assign value 0
x = 0
isw = int(random (1,3)) #initial strokeweight random
x_values=[] #create a list to hold the x values
y_values=[] #create a list to hold the y values
def setup():
global x
background(255) #white bg (RGB)
stroke(0) #black stroke
size(wdth,hght) #define window size
x= inix
strokeWeight(isw)
line(inix, iniy1, inix, iniy2) #draws the initial vertical line
x_values.append(inix)
x_values.append(inix)
y_values.append(iniy1)
y_values.append(iniy2)
print("X",x_values,"Y", y_values)
#while cnt =< hour():
def draw():
# delay(2000)
global x, inix, cnt, isw
y=year()
mo=month()
d=day()
h=hour()
m=minute()
s=second()
timeframe = str(str(y)+"-"+str(mo)+"-"+str(d)+"-"+str(h)+":"+str(m)+":"+str(s))
# print(timeframe)
while cnt<= second():
loop()
cnt=cnt+1
print ('count', cnt)
colorMode(HSB, 255) #set color mode to HSB - max value = 255
hu= int(random(0,255)) #random color
sa= int(random(150,255))
br= int(random(150,255))
op= int(random(50,200))
stroke(hu,255,50,)
y1= int(random(0,height))
x1= int(random(inix, width))
x_values.append(x1)
y_values.append(y1)
print("X",x_values,"Y", y_values)
fill(hu,sa,br,op)
strokeWeight(isw) #define width of stroke
beginShape()
vertex(x_values[-3], y_values[-3])
vertex(x_values[-2], y_values[-2])
vertex(x_values[-1], y_values[-1])
vertex(x_values[-3], y_values[-3])
endShape()
#saveFrame("1-4-####.png")
def mousePressed():
noLoop() #Holding down the mouse activates looping
def mouseReleased():
loop() #Releasing the mouse stops looping draw()
| hght = 420
wdth = 1188
inix = int(random(10, 50))
iniy1 = int(random(0, hght))
iniy2 = int(random(0, hght))
while iniy1 == iniy2:
iniy2 = int(random(0, hght))
cnt = 0
x = 0
isw = int(random(1, 3))
x_values = []
y_values = []
def setup():
global x
background(255)
stroke(0)
size(wdth, hght)
x = inix
stroke_weight(isw)
line(inix, iniy1, inix, iniy2)
x_values.append(inix)
x_values.append(inix)
y_values.append(iniy1)
y_values.append(iniy2)
print('X', x_values, 'Y', y_values)
def draw():
global x, inix, cnt, isw
y = year()
mo = month()
d = day()
h = hour()
m = minute()
s = second()
timeframe = str(str(y) + '-' + str(mo) + '-' + str(d) + '-' + str(h) + ':' + str(m) + ':' + str(s))
while cnt <= second():
loop()
cnt = cnt + 1
print('count', cnt)
color_mode(HSB, 255)
hu = int(random(0, 255))
sa = int(random(150, 255))
br = int(random(150, 255))
op = int(random(50, 200))
stroke(hu, 255, 50)
y1 = int(random(0, height))
x1 = int(random(inix, width))
x_values.append(x1)
y_values.append(y1)
print('X', x_values, 'Y', y_values)
fill(hu, sa, br, op)
stroke_weight(isw)
begin_shape()
vertex(x_values[-3], y_values[-3])
vertex(x_values[-2], y_values[-2])
vertex(x_values[-1], y_values[-1])
vertex(x_values[-3], y_values[-3])
end_shape()
def mouse_pressed():
no_loop()
def mouse_released():
loop() |
class InvalidWithdrawal(Exception):
pass
raise InvalidWithdrawal("You don't have $50 in your account")
| class Invalidwithdrawal(Exception):
pass
raise invalid_withdrawal("You don't have $50 in your account") |
speed_light_si = 299792458.0
electron_mass_si = 9.10938215e-31
elementary_charge_si = 1.602176487e-19
mu_0_si = 4.0*math.pi*1e-7
epsilon_0_si = 1.0/(mu_0_si*speed_light_si**2)
planck_si = 6.62606896e-34
hbar_si = planck_si / (2.0 * math.pi)
fine_structure_si = elementary_charge_si**2/(4.0*math.pi*epsilon_0_si*hbar_si*speed_light_si)
metre = electron_mass_si*speed_light_si*fine_structure_si/hbar_si
barn = metre*metre*1.0e-28
millibarn = barn*1.0e-3
joule = 1.0/(fine_structure_si**2*electron_mass_si*speed_light_si**2)
hertz = planck_si*joule
megahertz = hertz*1e6
def efg_to_Cq(efg, s):
# Magic constants to convert from millibarns to a.u. and then back to MHz
if s in Q_iso:
return sorted_evals(efg)[0] * (Q_common[s] * millibarn) / megahertz
else:
return None
def efg_to_Cq_isotope(efg, species, isotope):
# Magic constants to convert from millibarns to a.u. and then back to MHz
return sorted_evals(efg)[0] * (Q[(species, isotope)] * millibarn) / megahertz
def val_to_Cq(ev, s):
if s in Q_iso:
return ev * Q_common[s] * millibarn / megahertz
else:
return ev
def K_to_J(K, s1, s2):
# More magic constants. Should make a proper atomic unit conversion function
return (K + K.T)/2.0 * gamma_common[s1] * gamma_common[s2] * 1.05457148e-15 / (2*math.pi)
def K_to_J_iso(K, s1, iso1, s2, iso2):
return (K + K.T)/2.0 * gamma[(s1,iso1)] * gamma[(s2,iso2)] * 1.05457148e-15 / (2*math.pi)
# Nuclear gyromagnetic ratios, from constants.f90, source IUPAC Recommendations 2001, Robin K. Harris et al
gamma={('H', 1): 26.7522128e7,
('H', 2): 4.10662791e7,
('H', 3): 28.5349779e7,
('He', 3): -20.3801587e7,
('Li', 6): 3.9371709e7,
('Li', 7): 10.3977013e7,
('Be', 9): -3.759666e7,
('B', 10): 2.8746786e7,
('B', 11): 8.5847044e7,
('C', 13): 6.728284e7,
('N', 14): 1.9337792e7,
('N', 15): -2.71261804e7,
('O', 17): -3.62808e7,
('F', 19): 25.18148e7,
('Ne', 21): -2.11308e7,
('Na', 23): 7.0808493e7,
('Mg', 25): -1.63887e7,
('Al', 27): 6.9762715e7,
('Si', 29): -5.3190e7,
('P', 31): 10.8394e7,
('S', 33): 2.055685e7,
('Cl', 35): 2.624198e7,
('Cl', 37): 2.184368e7,
('K', 39): 1.2500608e7,
('K', 40): -1.5542854e7,
('K', 41): 0.68606808e7,
('Ca', 43): -1.803069e7,
('Sc', 45): 6.5087973e7,
('Ti', 47): -1.5105e7,
('Ti', 49): -1.51095e7,
('V', 50): 2.6706490e7,
('V', 51): 7.0455117e7,
('Cr', 53): -1.5152e7,
('Mn', 55): 6.6452546e7,
('Fe', 57): 0.8680624e7,
('Co', 59): 6.332e7,
('Ni', 61): -2.3948e7,
('Cu', 63): 7.1117890e7,
('Cu', 65): 7.60435e7,
('Zn', 67): 1.676688e7,
('Ga', 69): 6.438855e7,
('Ga', 71): 8.181171e7,
('Ge', 73): -0.9360303e7,
('As', 75): 4.596163e7,
('Se', 77): 5.1253857e7,
('Br', 79): 6.725616e7,
('Br', 81): 7.249776e7,
('Kr', 83): -1.03310e7,
('Rb', 85): 2.5927050e7,
('Rb', 87): 8.786400e7,
('Sr', 87): -1.1639376e7,
('Y', 89): -1.3162791e7,
('Zr', 91): -2.49743e7,
('Nb', 93): 6.5674e7,
('Mo', 95): 1.751e7,
('Mo', 97): -1.788e7,
('Tc', 99): 6.046e7,
('Ru', 99): -1.229e7,
('Rh', 103): -0.8468e7,
('Pd', 105): -1.23e7,
('Ag', 107): -1.0889181e7,
('Ag', 109): -1.2518634e7,
('Cd', 111): -5.6983131e7,
('Cd', 113): -5.9609155e7,
('In', 113): 5.8845e7,
('In', 115): 5.8972e7,
('Sn', 115): -8.8013e7,
('Sn', 117): -9.58879e7,
('Sn', 119): -10.0317e7,
('Sb', 121): 6.4435e7,
('Sb', 123): 3.4892e7,
('Te', 123): -7.059098e7,
('Te', 125): -8.5108404e7,
('I', 127): 5.389573e7,
('Xe', 131): 2.209076e7,
('Cs', 133): 3.5332539e7,
('Ba', 135): 2.67550e7,
('Ba', 137): 2.99295e7,
('La', 138): 3.557239e7,
('La', 139): 3.8083318e7,
('Pr', 141): 8.1907e7,
('Nd', 143): -1.457e7,
('Nd', 145): -0.898e7,
('Sm', 147): -1.115e7,
('Sm', 149): -0.9192e7,
('Eu', 151): 6.6510e7,
('Eu', 153): 2.9369e7,
('Gd', 155): -0.82132e7,
('Gd', 157): -1.0769e7,
('Tb', 159): 6.431e7,
('Dy', 161): -0.9201e7,
('Dy', 163): 1.289e7,
('Ho', 165): 5.710e7,
('Er', 167): -0.77157e7,
('Tm', 169): -2.218e7,
('Yb', 171): 4.7288e7,
('Yb', 173): -1.3025e7,
('Lu', 175): 3.0552e7,
('Lu', 176): 2.1684e7,
('Hf', 177): 1.086e7,
('Hf', 179): -0.6821,
('Ta', 181): 3.2438e7,
('W', 183): 1.1282403e7,
('Re', 185): 6.1057e7,
('Re', 187): 6.1682e7,
('Os', 189): 2.10713e7,
('Ir', 191): 0.4812e7,
('Ir', 193): 0.5227e7,
('Pt', 195): 5.8385e7,
('Au', 197): 0.473060e7,
('Hg', 201): -1.788769e7,
('Hg', 199): 4.8457916e7,
('Tl', 203): 15.5393338e7,
('Tl', 205): 15.6921808e7,
('Pb', 207): 5.58046e7,
('Bi', 209): 4.3750e7,
('U', 235): -0.52e7,}
# Isotope of most common spin active nucleus for each species
gamma_iso = {'H': 1,
'He': 3,
'Li': 7,
'Be': 9,
'B': 11,
'C': 13,
'N': 14, #
'O': 17,
'F': 19,
'Ne': 21,
'Na': 23,
'Mg': 25,
'Al': 27,
'Si': 29,
'P': 31,
'S': 33,
'Cl': 35,
'K': 39,
'Ca': 43,
'Sc': 45,
'Ti': 49, # Maybe exclude arbitrary ones from this? 47Ti and 49Ti both fairly equal, UI can prompt
'V': 51,
'Cr': 53,
'Mn': 55,
'Fe': 57,
'Co': 59,
'Ni': 61,
'Cu': 65, #
'Zn': 67,
'Ga': 71,
'Ge': 73,
'As': 75,
'Se': 77,
'Br': 81,
'Kr': 83,
'Rb': 87,
'Sr': 87,
'Y': 89,
'Zr': 91,
'Nb': 93,
'Mo': 95,
'Tc': 99,
'Ru': 99, # Also 101
'Rh': 103,
'Pd': 105,
'Ag': 109, #
'Cd': 113,
'In': 115,
'Sb': 121,
'I': 127,
'Sn': 119,
'Te': 125,
'Xe': 129, # Also 131
'Cs': 133,
'Ba': 137,
'La': 139,
'Hf': 179, # Also 177
'Ta': 181,
'W': 183,
'Re': 187,
'Os': 187, # Also 189 ?? no 187Os in gamma list
'Ir': 193,
'Pt': 195,
'Au': 197,
'Hg': 199, # Also 201
'Tl': 205,
'Pb': 207,
'Bi': 209,}
gamma_common = {}
for s, i in gamma_iso.items():
if (s,i) in gamma:
gamma_common[s] = gamma[(s,i)]
# Quadrupole moments of all nuclear isotopes, from P. Pyykko, J. Mol. Phys, 2008 106 1965-1974
# Units of mb, Q/10/fm^2
Q = {('H', 2): 2.860,
('Li', 6): -0.808,
('Li', 7): -40.1,
('Be', 9): 52.88,
('B', 10): 84.59,
('B', 11): 40.59,
('C', 11): 33.27,
('N', 14): 20.44,
('O', 17): -25.58,
('F', 19): -94.2,
('Ne', 21): 101.55,
('Na', 23): 104,
('Mg', 25): 199.4,
('Al', 27): 146.6,
('S', 33): -67.8,
('S', 35): 47.1,
('Cl', 35): -81.65,
('Cl', 37): -64.35,
('K', 39): 58.5,
('K', 40): -73,
('K', 41): 71.1,
('Ca', 41): -66.5,
('Ca', 43): -40.8,
('Sc', 45): -220,
('Ti', 47): 302,
('Ti', 49): 247,
('V', 50): 210,
('V', 51): -52,
('Cr', 53): -150,
('Mn', 55): 330,
('Fe', 57): 160,
('Co', 59): 420,
('Ni', 61): 162,
('Cu', 63): -220,
('Cu', 65): -204,
('Zn', 67): 150,
('Ga', 69): 171,
('Ga', 71): 107,
('Ge', 73): -196,
('As', 75): 314,
('Se', 77): 760,
('Br', 79): 313,
('Br', 81): 262,
('Kr', 83): 259,
('Rb', 85): 276,
('Rb', 87): 133.5,
('Sr', 87): 305,
('Y', 90): -125,
('Zr', 91): -176,
('Nb', 93): -320,
('Mo', 95): -22,
('Mo', 97): 255,
('Tc', 99): -129,
('Ru', 99): 79,
('Ru', 101): 457,
('Pd', 105): 660,
('In', 113): 759,
('In', 115): 770,
('Sn', 119): -132,
('Sb', 121): -543,
('Sb', 123): -692,
('I', 127): -696,
('Xe', 131): -114,
('Cs', 133): -3.43,
('Ba', 135): 160,
('Ba', 137): 245,
('La', 138): 450,
('La', 139): 200,
('Pr', 141): -58.9,
('Nd', 143): -630,
('Nd', 145): -330,
('Pm', 147): 740,
('Sm', 147): -259,
('Sm', 149): 75,
('Eu', 151): 903,
('Eu', 153): 2412,
('Gd', 155): 1270,
('Gd', 157): 1350,
('Tb', 159): 1432,
('Dy', 161): 2507,
('Dy', 163): 2648,
('Ho', 165): 3580,
('Er', 167): 3565,
('Tm', 169): -1200, # Tm missing from Pyykko
('Yb', 173): 2800,
('Lu', 175): 3490,
('Lu', 176): 4970,
('Hf', 177): 3365,
('Hf', 179): 3793,
('Ta', 181): 3170,
('Re', 185): 2180,
('Re', 187): 2070,
('Os', 189): 856,
('Ir', 191): 816,
('Ir', 193): 751,
('Au', 197): 547,
('Hg', 201): 387,
('Pb', 209): -269,
('Bi', 209): -516,
('Rn', 209): 311,
('Fr', 223): 1170,
('Ra', 223): 1210, # Ra missing from Pyykko
('Ac', 227): 1700,
('Th', 229): 4300,
('Pa', 231): -1720,
('U', 233): 3663,
('U', 235): 4936,
('Np', 237): 3886,
('Pu', 241): 5600,
('Am', 243): 4210,
('Es', 253): 6700,
}
# Isotope of most common quadrupolar nucleus, from castep constants.f90
Q_iso = {'H': 2,
'Li': 7,
'Be': 9,
'B': 11,
'C': 11,
'N': 14,
'O': 17,
'Ne': 21,
'Na': 23,
'Mg': 25,
'Al': 27,
'S': 33,
'Cl': 35,
'K': 39,
'Ca': 43,
'Sc': 45,
'Ti': 47,
'V': 51,
'Cr': 53,
'Mn': 55,
'Fe': 57,
'Co': 59,
'Ni': 61,
'Cu': 63,
'Zn': 67,
'Ga': 71,
'Ge': 73,
'As': 75,
'Br': 81,
'Kr': 83,
'Rb': 87,
'Sr': 87,
'Y': 90,
'Zr': 91,
'Nb': 93,
'Mo': 95,
'Tc': 99,
'Ru': 99,
'Pd': 105,
'In': 115,
'Sb': 121,
'I': 127,
'Xe': 131,
'Cs': 133,
'Ba': 137,
'La': 139,
'Pr': 141,
'Nd': 143,
'Pm': 147,
'Sm': 149,
'Eu': 153,
'Gd': 157,
'Tb': 159,
'Dy': 163,
'Ho': 165,
'Er': 167,
'Tm': 169,
'Yb': 173,
'Lu': 175,
'Hf': 177,
'Ta': 181,
'Re': 187,
'Os': 189,
'Ir': 193,
'Au': 197,
'Hg': 201,
'Pb': 209,
'Bi': 209,
'Rn': 209,
'Fr': 223,
'Ra': 223,
'Ac': 227,
'Th': 229,
'Pa': 231,
'U': 235,
'Np': 237,
'Pu': 241,
'Am': 243,
'Es': 253,}
Q_common = {}
for s, i in Q_iso.items():
if (s,i) in gamma:
Q_common[s] = Q[(s,i)]
iso_spin = {('Ne', 22): 0.0, ('Cl', 35): 1.5, ('Tl', 205): 0.5, ('Te', 123): 0.5, ('W', 180): 0.0, ('Pm', 147): 3.5, ('Tb', 160): 3.0, ('Cd', 106): 0.0, ('Sb', 121): 2.5, ('Hf', 180): 0.0, ('Ac', 227): 1.5, ('Eu', 151): 2.5, ('Pb', 206): 0.0, ('Kr', 80): 0.0, ('As', 75): 1.5, ('K', 41): 1.5, ('Pb', 204): 0.0, ('Sb', 125): 3.5, ('Zr', 90): 0.0, ('Sn', 117): 0.5, ('In', 113): 4.5, ('Os', 189): 1.5, ('Ca', 48): 0.0, ('Gd', 157): 1.5, ('S', 36): 0.0, ('Ce', 136): 0.0, ('Xe', 124): 0.0, ('Tb', 157): 1.5, ('Hf', 179): 4.5, ('Cs', 133): 3.5, ('Ge', 72): 0.0, ('Nb', 93): 4.5, ('Sn', 115): 0.5, ('Kr', 78): 0.0, ('Mo', 95): 2.5, ('Tb', 159): 1.5, ('Kr', 83): 4.5, ('Ca', 43): 3.5, ('Sm', 150): 0.0, ('Se', 78): 0.0, ('Pd', 108): 0.0, ('Sm', 154): 0.0, ('Ar', 36): 0.0, ('Ba', 132): 0.0, ('Se', 80): 0.0, ('Ru', 101): 2.5, ('Xe', 134): 0.0, ('Cl', 37): 1.5, ('Yb', 172): 0.0, ('C', 12): 0.0, ('Yb', 174): 0.0, ('Zn', 66): 0.0, ('Ta', 180): 0.0, ('Cr', 53): 1.5, ('Ba', 133): 0.5, ('Pt', 195): 0.5, ('Ni', 62): 0.0, ('Rh', 102): 6.0, ('Er', 170): 0.0, ('Er', 167): 3.5, ('Cd', 108): 0.0, ('Fe', 57): 0.5, ('Cu', 65): 1.5, ('Ta', 181): 3.5, ('Ru', 99): 2.5, ('Fe', 54): 0.0, ('Cd', 112): 0.0, ('B', 10): 3.0, ('Lu', 176): 7.0, ('Ca', 44): 0.0, ('Y', 89): 0.5, ('Te', 120): 0.0, ('Pd', 105): 2.5, ('Sb', 123): 3.5, ('Xe', 136): 0.0, ('Be', 9): 1.5, ('Mo', 97): 2.5, ('He', 3): 0.5, ('Ru', 96): 0.0, ('Gd', 154): 0.0, ('Rb', 85): 2.5, ('Zr', 91): 2.5, ('Re', 185): 2.5, ('Ba', 138): 0.0, ('Yb', 171): 0.5, ('Th', 232): 0.0, ('Hf', 176): 0.0, ('Dy', 156): 0.0, ('Sn', 120): 0.0, ('H', 3): 0.5, ('Na', 22): 3.0, ('Dy', 158): 0.0, ('Ga', 69): 1.5, ('Sm', 144): 0.0, ('Pb', 208): 0.0, ('Si', 28): 0.0, ('Pt', 196): 0.0, ('Zr', 94): 0.0, ('Mg', 24): 0.0, ('Pd', 106): 0.0, ('Ne', 21): 1.5, ('Ge', 76): 0.0, ('S', 32): 0.0, ('Te', 122): 0.0, ('Se', 82): 0.0, ('Xe', 130): 0.0, ('Dy', 164): 0.0, ('W', 184): 0.0, ('Hg', 201): 1.5, ('Cd', 114): 0.0, ('Os', 190): 0.0, ('Eu', 152): 3.0, ('Po', 209): 0.5, ('Se', 77): 0.5, ('Ag', 109): 0.5, ('Dy', 160): 0.0, ('Hg', 198): 0.0, ('Tm', 171): 0.5, ('Kr', 84): 0.0, ('Ar', 40): 0.0, ('Sn', 116): 0.0, ('Co', 60): 5.0, ('Nd', 142): 0.0, ('Sr', 84): 0.0, ('W', 182): 0.0, ('Gd', 155): 1.5, ('Ce', 140): 0.0, ('Ir', 193): 1.5, ('Ge', 73): 4.5, ('Tc', 99): 4.5, ('Gd', 160): 0.0, ('Hf', 177): 3.5, ('Tl', 204): 2.0, ('Mo', 92): 0.0, ('Gd', 158): 0.0, ('Kr', 82): 0.0, ('Ca', 40): 0.0, ('Se', 79): 3.5, ('I', 129): 3.5, ('Ar', 39): 3.5, ('Sn', 119): 0.5, ('Pr', 141): 2.5, ('Ru', 100): 0.0, ('Sr', 87): 4.5, ('Cl', 36): 2.0, ('Mn', 55): 2.5, ('C', 13): 0.5, ('Pt', 194): 0.0, ('Zn', 67): 2.5, ('Sm', 149): 3.5, ('Cr', 52): 0.0, ('Xe', 131): 1.5, ('Yb', 168): 0.0, ('Ni', 61): 1.5, ('Rh', 103): 0.5, ('N', 15): 0.5, ('Fe', 56): 0.0, ('Ge', 74): 0.0, ('Yb', 176): 0.0, ('Er', 166): 0.0, ('Bi', 207): 4.5, ('Se', 76): 0.0, ('Ag', 107): 0.5, ('Pt', 192): 0.0, ('Co', 59): 3.5, ('Pd', 110): 0.0, ('Dy', 163): 2.5, ('Hg', 204): 0.0, ('Cu', 63): 1.5, ('Sm', 148): 0.0, ('Te', 126): 0.0, ('Nd', 144): 0.0, ('Xe', 132): 0.0, ('La', 139): 3.5, ('Ni', 64): 0.0, ('C', 14): 3.0, ('Zn', 68): 0.0, ('Ti', 50): 0.0, ('Cd', 113): 0.5, ('Ba', 137): 1.5, ('Yb', 170): 0.0, ('Ce', 138): 0.0, ('Er', 168): 0.0, ('O', 16): 0.0, ('Lu', 175): 3.5, ('H', 2): 1.0, ('Br', 81): 1.5, ('Pt', 190): 0.0, ('Gd', 152): 0.0, ('Sn', 118): 0.0, ('Si', 29): 0.5, ('Ca', 46): 0.0, ('Sc', 45): 3.5, ('Ho', 165): 3.5, ('Mg', 25): 2.5, ('Os', 186): 0.0, ('Ne', 20): 0.0, ('Bi', 209): 4.5, ('Tl', 203): 0.5, ('Eu', 155): 2.5, ('S', 33): 1.5, ('Te', 125): 0.5, ('Ru', 98): 0.0, ('V', 51): 3.5, ('Ba', 135): 1.5, ('Rb', 87): 1.5, ('Sn', 112): 0.0, ('Ti', 49): 3.5, ('Cr', 50): 0.0, ('Xe', 128): 0.0, ('Cd', 111): 0.5, ('Nd', 148): 0.0, ('Th', 229): 2.5, ('U', 238): 0.0, ('Eu', 153): 2.5, ('Ga', 71): 1.5, ('Ti', 47): 2.5, ('Cs', 137): 3.5, ('Sn', 122): 0.0, ('Si', 30): 0.0, ('Sr', 88): 0.0, ('Mg', 26): 0.0, ('In', 115): 4.5, ('Nd', 143): 3.5, ('W', 183): 0.5, ('Mo', 100): 0.0, ('Hg', 199): 0.5, ('S', 34): 0.0, ('He', 4): 0.0, ('Ir', 191): 1.5, ('Xe', 126): 0.0, ('W', 186): 0.0, ('Re', 187): 2.5, ('F', 19): 0.5, ('Ge', 70): 0.0, ('Er', 162): 0.0, ('Os', 192): 0.0, ('Au', 197): 1.5, ('Te', 130): 0.0, ('U', 234): 0.0, ('Ca', 41): 3.5, ('Hf', 174): 0.0, ('K', 40): 4.0, ('Tm', 169): 0.5, ('Sm', 152): 0.0, ('Ar', 38): 0.0, ('K', 39): 1.5, ('Os', 188): 0.0, ('Sr', 86): 0.0, ('U', 235): 3.5, ('P', 31): 0.5, ('Zn', 64): 0.0, ('Ru', 104): 0.0, ('Ni', 60): 0.0, ('Ce', 142): 0.0, ('Sm', 151): 2.5, ('N', 14): 1.0, ('Xe', 129): 0.5, ('Ba', 130): 0.0, ('Cd', 110): 0.0, ('Mo', 94): 0.0, ('Gd', 156): 0.0, ('Hg', 200): 0.0, ('Ca', 42): 0.0, ('Sn', 124): 0.0, ('Pt', 198): 0.0, ('Br', 79): 1.5, ('Li', 6): 1.0, ('Dy', 162): 0.0, ('Cd', 116): 0.0, ('Ru', 102): 0.0, ('Cs', 134): 4.0, ('La', 138): 5.0, ('Mn', 53): 3.5, ('Mo', 98): 0.0, ('Cr', 54): 0.0, ('Ba', 136): 0.0, ('Yb', 173): 2.5, ('Hf', 178): 0.0, ('O', 17): 2.5, ('I', 127): 2.5, ('Fe', 58): 0.0, ('H', 1): 0.5, ('Os', 184): 0.0, ('Er', 164): 0.0, ('Hg', 202): 0.0, ('Lu', 173): 3.5, ('B', 11): 1.5, ('Lu', 174): 1.0, ('Al', 27): 2.5, ('Sm', 147): 3.5, ('Zr', 92): 0.0, ('Se', 74): 0.0, ('Pd', 104): 0.0, ('Os', 187): 0.5, ('Dy', 161): 2.5, ('Mo', 96): 0.0, ('Te', 124): 0.0, ('Nd', 150): 0.0, ('V', 50): 6.0, ('La', 137): 3.5, ('Te', 128): 0.0, ('Zn', 70): 0.0, ('Ti', 48): 0.0, ('Zr', 96): 0.0, ('Nd', 146): 0.0, ('Ni', 58): 0.0, ('Cs', 135): 3.5, ('O', 18): 0.0, ('Eu', 154): 3.0, ('Na', 23): 1.5, ('Kr', 85): 4.5, ('Ti', 46): 0.0, ('Ba', 134): 0.0, ('Pb', 207): 0.5, ('Pd', 102): 0.0, ('Kr', 86): 0.0, ('Hg', 196): 0.0, ('Nd', 145): 3.5, ('Sn', 114): 0.0, ('Li', 7): 1.5}
| speed_light_si = 299792458.0
electron_mass_si = 9.10938215e-31
elementary_charge_si = 1.602176487e-19
mu_0_si = 4.0 * math.pi * 1e-07
epsilon_0_si = 1.0 / (mu_0_si * speed_light_si ** 2)
planck_si = 6.62606896e-34
hbar_si = planck_si / (2.0 * math.pi)
fine_structure_si = elementary_charge_si ** 2 / (4.0 * math.pi * epsilon_0_si * hbar_si * speed_light_si)
metre = electron_mass_si * speed_light_si * fine_structure_si / hbar_si
barn = metre * metre * 1e-28
millibarn = barn * 0.001
joule = 1.0 / (fine_structure_si ** 2 * electron_mass_si * speed_light_si ** 2)
hertz = planck_si * joule
megahertz = hertz * 1000000.0
def efg_to__cq(efg, s):
if s in Q_iso:
return sorted_evals(efg)[0] * (Q_common[s] * millibarn) / megahertz
else:
return None
def efg_to__cq_isotope(efg, species, isotope):
return sorted_evals(efg)[0] * (Q[species, isotope] * millibarn) / megahertz
def val_to__cq(ev, s):
if s in Q_iso:
return ev * Q_common[s] * millibarn / megahertz
else:
return ev
def k_to_j(K, s1, s2):
return (K + K.T) / 2.0 * gamma_common[s1] * gamma_common[s2] * 1.05457148e-15 / (2 * math.pi)
def k_to_j_iso(K, s1, iso1, s2, iso2):
return (K + K.T) / 2.0 * gamma[s1, iso1] * gamma[s2, iso2] * 1.05457148e-15 / (2 * math.pi)
gamma = {('H', 1): 267522128.0, ('H', 2): 41066279.1, ('H', 3): 285349779.0, ('He', 3): -203801587.0, ('Li', 6): 39371709.0, ('Li', 7): 103977013.0, ('Be', 9): -37596660.0, ('B', 10): 28746786.0, ('B', 11): 85847044.0, ('C', 13): 67282840.0, ('N', 14): 19337792.0, ('N', 15): -27126180.4, ('O', 17): -36280800.0, ('F', 19): 251814800.0, ('Ne', 21): -21130800.0, ('Na', 23): 70808493.0, ('Mg', 25): -16388700.0, ('Al', 27): 69762715.0, ('Si', 29): -53190000.0, ('P', 31): 108394000.0, ('S', 33): 20556850.0, ('Cl', 35): 26241980.0, ('Cl', 37): 21843680.0, ('K', 39): 12500608.0, ('K', 40): -15542854.0, ('K', 41): 6860680.8, ('Ca', 43): -18030690.0, ('Sc', 45): 65087973.0, ('Ti', 47): -15105000.0, ('Ti', 49): -15109500.0, ('V', 50): 26706490.0, ('V', 51): 70455117.0, ('Cr', 53): -15152000.0, ('Mn', 55): 66452546.0, ('Fe', 57): 8680624.0, ('Co', 59): 63320000.0, ('Ni', 61): -23948000.0, ('Cu', 63): 71117890.0, ('Cu', 65): 76043500.0, ('Zn', 67): 16766880.0, ('Ga', 69): 64388550.0, ('Ga', 71): 81811710.0, ('Ge', 73): -9360303.0, ('As', 75): 45961630.0, ('Se', 77): 51253857.0, ('Br', 79): 67256160.0, ('Br', 81): 72497760.0, ('Kr', 83): -10331000.0, ('Rb', 85): 25927050.0, ('Rb', 87): 87864000.0, ('Sr', 87): -11639376.0, ('Y', 89): -13162791.0, ('Zr', 91): -24974300.0, ('Nb', 93): 65674000.0, ('Mo', 95): 17510000.0, ('Mo', 97): -17880000.0, ('Tc', 99): 60460000.0, ('Ru', 99): -12290000.0, ('Rh', 103): -8468000.0, ('Pd', 105): -12300000.0, ('Ag', 107): -10889181.0, ('Ag', 109): -12518634.0, ('Cd', 111): -56983131.0, ('Cd', 113): -59609155.0, ('In', 113): 58845000.0, ('In', 115): 58972000.0, ('Sn', 115): -88013000.0, ('Sn', 117): -95887900.0, ('Sn', 119): -100317000.0, ('Sb', 121): 64435000.0, ('Sb', 123): 34892000.0, ('Te', 123): -70590980.0, ('Te', 125): -85108404.0, ('I', 127): 53895730.0, ('Xe', 131): 22090760.0, ('Cs', 133): 35332539.0, ('Ba', 135): 26755000.0, ('Ba', 137): 29929500.0, ('La', 138): 35572390.0, ('La', 139): 38083318.0, ('Pr', 141): 81907000.0, ('Nd', 143): -14570000.0, ('Nd', 145): -8980000.0, ('Sm', 147): -11150000.0, ('Sm', 149): -9192000.0, ('Eu', 151): 66510000.0, ('Eu', 153): 29369000.0, ('Gd', 155): -8213200.0, ('Gd', 157): -10769000.0, ('Tb', 159): 64310000.0, ('Dy', 161): -9201000.0, ('Dy', 163): 12890000.0, ('Ho', 165): 57100000.0, ('Er', 167): -7715700.0, ('Tm', 169): -22180000.0, ('Yb', 171): 47288000.0, ('Yb', 173): -13025000.0, ('Lu', 175): 30552000.0, ('Lu', 176): 21684000.0, ('Hf', 177): 10860000.0, ('Hf', 179): -0.6821, ('Ta', 181): 32438000.0, ('W', 183): 11282403.0, ('Re', 185): 61057000.0, ('Re', 187): 61682000.0, ('Os', 189): 21071300.0, ('Ir', 191): 4812000.0, ('Ir', 193): 5227000.0, ('Pt', 195): 58385000.0, ('Au', 197): 4730600.0, ('Hg', 201): -17887690.0, ('Hg', 199): 48457916.0, ('Tl', 203): 155393338.0, ('Tl', 205): 156921808.0, ('Pb', 207): 55804600.0, ('Bi', 209): 43750000.0, ('U', 235): -5200000.0}
gamma_iso = {'H': 1, 'He': 3, 'Li': 7, 'Be': 9, 'B': 11, 'C': 13, 'N': 14, 'O': 17, 'F': 19, 'Ne': 21, 'Na': 23, 'Mg': 25, 'Al': 27, 'Si': 29, 'P': 31, 'S': 33, 'Cl': 35, 'K': 39, 'Ca': 43, 'Sc': 45, 'Ti': 49, 'V': 51, 'Cr': 53, 'Mn': 55, 'Fe': 57, 'Co': 59, 'Ni': 61, 'Cu': 65, 'Zn': 67, 'Ga': 71, 'Ge': 73, 'As': 75, 'Se': 77, 'Br': 81, 'Kr': 83, 'Rb': 87, 'Sr': 87, 'Y': 89, 'Zr': 91, 'Nb': 93, 'Mo': 95, 'Tc': 99, 'Ru': 99, 'Rh': 103, 'Pd': 105, 'Ag': 109, 'Cd': 113, 'In': 115, 'Sb': 121, 'I': 127, 'Sn': 119, 'Te': 125, 'Xe': 129, 'Cs': 133, 'Ba': 137, 'La': 139, 'Hf': 179, 'Ta': 181, 'W': 183, 'Re': 187, 'Os': 187, 'Ir': 193, 'Pt': 195, 'Au': 197, 'Hg': 199, 'Tl': 205, 'Pb': 207, 'Bi': 209}
gamma_common = {}
for (s, i) in gamma_iso.items():
if (s, i) in gamma:
gamma_common[s] = gamma[s, i]
q = {('H', 2): 2.86, ('Li', 6): -0.808, ('Li', 7): -40.1, ('Be', 9): 52.88, ('B', 10): 84.59, ('B', 11): 40.59, ('C', 11): 33.27, ('N', 14): 20.44, ('O', 17): -25.58, ('F', 19): -94.2, ('Ne', 21): 101.55, ('Na', 23): 104, ('Mg', 25): 199.4, ('Al', 27): 146.6, ('S', 33): -67.8, ('S', 35): 47.1, ('Cl', 35): -81.65, ('Cl', 37): -64.35, ('K', 39): 58.5, ('K', 40): -73, ('K', 41): 71.1, ('Ca', 41): -66.5, ('Ca', 43): -40.8, ('Sc', 45): -220, ('Ti', 47): 302, ('Ti', 49): 247, ('V', 50): 210, ('V', 51): -52, ('Cr', 53): -150, ('Mn', 55): 330, ('Fe', 57): 160, ('Co', 59): 420, ('Ni', 61): 162, ('Cu', 63): -220, ('Cu', 65): -204, ('Zn', 67): 150, ('Ga', 69): 171, ('Ga', 71): 107, ('Ge', 73): -196, ('As', 75): 314, ('Se', 77): 760, ('Br', 79): 313, ('Br', 81): 262, ('Kr', 83): 259, ('Rb', 85): 276, ('Rb', 87): 133.5, ('Sr', 87): 305, ('Y', 90): -125, ('Zr', 91): -176, ('Nb', 93): -320, ('Mo', 95): -22, ('Mo', 97): 255, ('Tc', 99): -129, ('Ru', 99): 79, ('Ru', 101): 457, ('Pd', 105): 660, ('In', 113): 759, ('In', 115): 770, ('Sn', 119): -132, ('Sb', 121): -543, ('Sb', 123): -692, ('I', 127): -696, ('Xe', 131): -114, ('Cs', 133): -3.43, ('Ba', 135): 160, ('Ba', 137): 245, ('La', 138): 450, ('La', 139): 200, ('Pr', 141): -58.9, ('Nd', 143): -630, ('Nd', 145): -330, ('Pm', 147): 740, ('Sm', 147): -259, ('Sm', 149): 75, ('Eu', 151): 903, ('Eu', 153): 2412, ('Gd', 155): 1270, ('Gd', 157): 1350, ('Tb', 159): 1432, ('Dy', 161): 2507, ('Dy', 163): 2648, ('Ho', 165): 3580, ('Er', 167): 3565, ('Tm', 169): -1200, ('Yb', 173): 2800, ('Lu', 175): 3490, ('Lu', 176): 4970, ('Hf', 177): 3365, ('Hf', 179): 3793, ('Ta', 181): 3170, ('Re', 185): 2180, ('Re', 187): 2070, ('Os', 189): 856, ('Ir', 191): 816, ('Ir', 193): 751, ('Au', 197): 547, ('Hg', 201): 387, ('Pb', 209): -269, ('Bi', 209): -516, ('Rn', 209): 311, ('Fr', 223): 1170, ('Ra', 223): 1210, ('Ac', 227): 1700, ('Th', 229): 4300, ('Pa', 231): -1720, ('U', 233): 3663, ('U', 235): 4936, ('Np', 237): 3886, ('Pu', 241): 5600, ('Am', 243): 4210, ('Es', 253): 6700}
q_iso = {'H': 2, 'Li': 7, 'Be': 9, 'B': 11, 'C': 11, 'N': 14, 'O': 17, 'Ne': 21, 'Na': 23, 'Mg': 25, 'Al': 27, 'S': 33, 'Cl': 35, 'K': 39, 'Ca': 43, 'Sc': 45, 'Ti': 47, 'V': 51, 'Cr': 53, 'Mn': 55, 'Fe': 57, 'Co': 59, 'Ni': 61, 'Cu': 63, 'Zn': 67, 'Ga': 71, 'Ge': 73, 'As': 75, 'Br': 81, 'Kr': 83, 'Rb': 87, 'Sr': 87, 'Y': 90, 'Zr': 91, 'Nb': 93, 'Mo': 95, 'Tc': 99, 'Ru': 99, 'Pd': 105, 'In': 115, 'Sb': 121, 'I': 127, 'Xe': 131, 'Cs': 133, 'Ba': 137, 'La': 139, 'Pr': 141, 'Nd': 143, 'Pm': 147, 'Sm': 149, 'Eu': 153, 'Gd': 157, 'Tb': 159, 'Dy': 163, 'Ho': 165, 'Er': 167, 'Tm': 169, 'Yb': 173, 'Lu': 175, 'Hf': 177, 'Ta': 181, 'Re': 187, 'Os': 189, 'Ir': 193, 'Au': 197, 'Hg': 201, 'Pb': 209, 'Bi': 209, 'Rn': 209, 'Fr': 223, 'Ra': 223, 'Ac': 227, 'Th': 229, 'Pa': 231, 'U': 235, 'Np': 237, 'Pu': 241, 'Am': 243, 'Es': 253}
q_common = {}
for (s, i) in Q_iso.items():
if (s, i) in gamma:
Q_common[s] = Q[s, i]
iso_spin = {('Ne', 22): 0.0, ('Cl', 35): 1.5, ('Tl', 205): 0.5, ('Te', 123): 0.5, ('W', 180): 0.0, ('Pm', 147): 3.5, ('Tb', 160): 3.0, ('Cd', 106): 0.0, ('Sb', 121): 2.5, ('Hf', 180): 0.0, ('Ac', 227): 1.5, ('Eu', 151): 2.5, ('Pb', 206): 0.0, ('Kr', 80): 0.0, ('As', 75): 1.5, ('K', 41): 1.5, ('Pb', 204): 0.0, ('Sb', 125): 3.5, ('Zr', 90): 0.0, ('Sn', 117): 0.5, ('In', 113): 4.5, ('Os', 189): 1.5, ('Ca', 48): 0.0, ('Gd', 157): 1.5, ('S', 36): 0.0, ('Ce', 136): 0.0, ('Xe', 124): 0.0, ('Tb', 157): 1.5, ('Hf', 179): 4.5, ('Cs', 133): 3.5, ('Ge', 72): 0.0, ('Nb', 93): 4.5, ('Sn', 115): 0.5, ('Kr', 78): 0.0, ('Mo', 95): 2.5, ('Tb', 159): 1.5, ('Kr', 83): 4.5, ('Ca', 43): 3.5, ('Sm', 150): 0.0, ('Se', 78): 0.0, ('Pd', 108): 0.0, ('Sm', 154): 0.0, ('Ar', 36): 0.0, ('Ba', 132): 0.0, ('Se', 80): 0.0, ('Ru', 101): 2.5, ('Xe', 134): 0.0, ('Cl', 37): 1.5, ('Yb', 172): 0.0, ('C', 12): 0.0, ('Yb', 174): 0.0, ('Zn', 66): 0.0, ('Ta', 180): 0.0, ('Cr', 53): 1.5, ('Ba', 133): 0.5, ('Pt', 195): 0.5, ('Ni', 62): 0.0, ('Rh', 102): 6.0, ('Er', 170): 0.0, ('Er', 167): 3.5, ('Cd', 108): 0.0, ('Fe', 57): 0.5, ('Cu', 65): 1.5, ('Ta', 181): 3.5, ('Ru', 99): 2.5, ('Fe', 54): 0.0, ('Cd', 112): 0.0, ('B', 10): 3.0, ('Lu', 176): 7.0, ('Ca', 44): 0.0, ('Y', 89): 0.5, ('Te', 120): 0.0, ('Pd', 105): 2.5, ('Sb', 123): 3.5, ('Xe', 136): 0.0, ('Be', 9): 1.5, ('Mo', 97): 2.5, ('He', 3): 0.5, ('Ru', 96): 0.0, ('Gd', 154): 0.0, ('Rb', 85): 2.5, ('Zr', 91): 2.5, ('Re', 185): 2.5, ('Ba', 138): 0.0, ('Yb', 171): 0.5, ('Th', 232): 0.0, ('Hf', 176): 0.0, ('Dy', 156): 0.0, ('Sn', 120): 0.0, ('H', 3): 0.5, ('Na', 22): 3.0, ('Dy', 158): 0.0, ('Ga', 69): 1.5, ('Sm', 144): 0.0, ('Pb', 208): 0.0, ('Si', 28): 0.0, ('Pt', 196): 0.0, ('Zr', 94): 0.0, ('Mg', 24): 0.0, ('Pd', 106): 0.0, ('Ne', 21): 1.5, ('Ge', 76): 0.0, ('S', 32): 0.0, ('Te', 122): 0.0, ('Se', 82): 0.0, ('Xe', 130): 0.0, ('Dy', 164): 0.0, ('W', 184): 0.0, ('Hg', 201): 1.5, ('Cd', 114): 0.0, ('Os', 190): 0.0, ('Eu', 152): 3.0, ('Po', 209): 0.5, ('Se', 77): 0.5, ('Ag', 109): 0.5, ('Dy', 160): 0.0, ('Hg', 198): 0.0, ('Tm', 171): 0.5, ('Kr', 84): 0.0, ('Ar', 40): 0.0, ('Sn', 116): 0.0, ('Co', 60): 5.0, ('Nd', 142): 0.0, ('Sr', 84): 0.0, ('W', 182): 0.0, ('Gd', 155): 1.5, ('Ce', 140): 0.0, ('Ir', 193): 1.5, ('Ge', 73): 4.5, ('Tc', 99): 4.5, ('Gd', 160): 0.0, ('Hf', 177): 3.5, ('Tl', 204): 2.0, ('Mo', 92): 0.0, ('Gd', 158): 0.0, ('Kr', 82): 0.0, ('Ca', 40): 0.0, ('Se', 79): 3.5, ('I', 129): 3.5, ('Ar', 39): 3.5, ('Sn', 119): 0.5, ('Pr', 141): 2.5, ('Ru', 100): 0.0, ('Sr', 87): 4.5, ('Cl', 36): 2.0, ('Mn', 55): 2.5, ('C', 13): 0.5, ('Pt', 194): 0.0, ('Zn', 67): 2.5, ('Sm', 149): 3.5, ('Cr', 52): 0.0, ('Xe', 131): 1.5, ('Yb', 168): 0.0, ('Ni', 61): 1.5, ('Rh', 103): 0.5, ('N', 15): 0.5, ('Fe', 56): 0.0, ('Ge', 74): 0.0, ('Yb', 176): 0.0, ('Er', 166): 0.0, ('Bi', 207): 4.5, ('Se', 76): 0.0, ('Ag', 107): 0.5, ('Pt', 192): 0.0, ('Co', 59): 3.5, ('Pd', 110): 0.0, ('Dy', 163): 2.5, ('Hg', 204): 0.0, ('Cu', 63): 1.5, ('Sm', 148): 0.0, ('Te', 126): 0.0, ('Nd', 144): 0.0, ('Xe', 132): 0.0, ('La', 139): 3.5, ('Ni', 64): 0.0, ('C', 14): 3.0, ('Zn', 68): 0.0, ('Ti', 50): 0.0, ('Cd', 113): 0.5, ('Ba', 137): 1.5, ('Yb', 170): 0.0, ('Ce', 138): 0.0, ('Er', 168): 0.0, ('O', 16): 0.0, ('Lu', 175): 3.5, ('H', 2): 1.0, ('Br', 81): 1.5, ('Pt', 190): 0.0, ('Gd', 152): 0.0, ('Sn', 118): 0.0, ('Si', 29): 0.5, ('Ca', 46): 0.0, ('Sc', 45): 3.5, ('Ho', 165): 3.5, ('Mg', 25): 2.5, ('Os', 186): 0.0, ('Ne', 20): 0.0, ('Bi', 209): 4.5, ('Tl', 203): 0.5, ('Eu', 155): 2.5, ('S', 33): 1.5, ('Te', 125): 0.5, ('Ru', 98): 0.0, ('V', 51): 3.5, ('Ba', 135): 1.5, ('Rb', 87): 1.5, ('Sn', 112): 0.0, ('Ti', 49): 3.5, ('Cr', 50): 0.0, ('Xe', 128): 0.0, ('Cd', 111): 0.5, ('Nd', 148): 0.0, ('Th', 229): 2.5, ('U', 238): 0.0, ('Eu', 153): 2.5, ('Ga', 71): 1.5, ('Ti', 47): 2.5, ('Cs', 137): 3.5, ('Sn', 122): 0.0, ('Si', 30): 0.0, ('Sr', 88): 0.0, ('Mg', 26): 0.0, ('In', 115): 4.5, ('Nd', 143): 3.5, ('W', 183): 0.5, ('Mo', 100): 0.0, ('Hg', 199): 0.5, ('S', 34): 0.0, ('He', 4): 0.0, ('Ir', 191): 1.5, ('Xe', 126): 0.0, ('W', 186): 0.0, ('Re', 187): 2.5, ('F', 19): 0.5, ('Ge', 70): 0.0, ('Er', 162): 0.0, ('Os', 192): 0.0, ('Au', 197): 1.5, ('Te', 130): 0.0, ('U', 234): 0.0, ('Ca', 41): 3.5, ('Hf', 174): 0.0, ('K', 40): 4.0, ('Tm', 169): 0.5, ('Sm', 152): 0.0, ('Ar', 38): 0.0, ('K', 39): 1.5, ('Os', 188): 0.0, ('Sr', 86): 0.0, ('U', 235): 3.5, ('P', 31): 0.5, ('Zn', 64): 0.0, ('Ru', 104): 0.0, ('Ni', 60): 0.0, ('Ce', 142): 0.0, ('Sm', 151): 2.5, ('N', 14): 1.0, ('Xe', 129): 0.5, ('Ba', 130): 0.0, ('Cd', 110): 0.0, ('Mo', 94): 0.0, ('Gd', 156): 0.0, ('Hg', 200): 0.0, ('Ca', 42): 0.0, ('Sn', 124): 0.0, ('Pt', 198): 0.0, ('Br', 79): 1.5, ('Li', 6): 1.0, ('Dy', 162): 0.0, ('Cd', 116): 0.0, ('Ru', 102): 0.0, ('Cs', 134): 4.0, ('La', 138): 5.0, ('Mn', 53): 3.5, ('Mo', 98): 0.0, ('Cr', 54): 0.0, ('Ba', 136): 0.0, ('Yb', 173): 2.5, ('Hf', 178): 0.0, ('O', 17): 2.5, ('I', 127): 2.5, ('Fe', 58): 0.0, ('H', 1): 0.5, ('Os', 184): 0.0, ('Er', 164): 0.0, ('Hg', 202): 0.0, ('Lu', 173): 3.5, ('B', 11): 1.5, ('Lu', 174): 1.0, ('Al', 27): 2.5, ('Sm', 147): 3.5, ('Zr', 92): 0.0, ('Se', 74): 0.0, ('Pd', 104): 0.0, ('Os', 187): 0.5, ('Dy', 161): 2.5, ('Mo', 96): 0.0, ('Te', 124): 0.0, ('Nd', 150): 0.0, ('V', 50): 6.0, ('La', 137): 3.5, ('Te', 128): 0.0, ('Zn', 70): 0.0, ('Ti', 48): 0.0, ('Zr', 96): 0.0, ('Nd', 146): 0.0, ('Ni', 58): 0.0, ('Cs', 135): 3.5, ('O', 18): 0.0, ('Eu', 154): 3.0, ('Na', 23): 1.5, ('Kr', 85): 4.5, ('Ti', 46): 0.0, ('Ba', 134): 0.0, ('Pb', 207): 0.5, ('Pd', 102): 0.0, ('Kr', 86): 0.0, ('Hg', 196): 0.0, ('Nd', 145): 3.5, ('Sn', 114): 0.0, ('Li', 7): 1.5} |
def print_sum(*values):
s = 0
for number in values:
s += number
print(f'The sum of {values} is {s}')
print_sum(5, 2)
print_sum(2, 9, 4)
| def print_sum(*values):
s = 0
for number in values:
s += number
print(f'The sum of {values} is {s}')
print_sum(5, 2)
print_sum(2, 9, 4) |
x = 0
soma = 0
i = 0
while x != -1:
x = int(input('digite uma idade: '))
if x != -1:
soma += x
i += 1
print(soma/i) | x = 0
soma = 0
i = 0
while x != -1:
x = int(input('digite uma idade: '))
if x != -1:
soma += x
i += 1
print(soma / i) |
if __name__ == '__main__':
n = int(input())
output = ""
for i in range(1, n+1):
output = output + str(i)
print(output) | if __name__ == '__main__':
n = int(input())
output = ''
for i in range(1, n + 1):
output = output + str(i)
print(output) |
# # arr1 = [100,100,200,300,300,400,400]
# # arr2 = [14,90,100,100,200,200,450,450,0,0,0,0,0,0,0]
# # arr1 = [1,3,5]
# # arr2 = [2,4,6,0,0,0]
# arr1 = [1,1,1,1,1,1]
# arr2 = [12,1,1,1,1,1,2,0,0,0,0,0,0]
# # arr1_ptr, arr2_ptr = 0,0
# # while arr2_ptr <= len(arr1) - 1:
# # if arr2[arr2_ptr] <= arr1[arr1_ptr]:
# # arr2_ptr += 1
# # else: # arr2_ptr > arr1_ptr
# # arr2[arr2_ptr], arr1[arr1_ptr] = arr1[arr1_ptr], arr2[arr2_ptr]
# # arr2_ptr += 1
# # arr1.sort()
# # arr2[len(arr1):] = arr1
# # print(arr2)
# ptr1, ptr2 = len(arr1) - 1, len(arr2) -1
# run_ptr = len(arr2) - len(arr1) - 1
# while ptr2 > 0:
# if arr2[run_ptr] < arr1[ptr1]:
# arr2[ptr2] = arr1[ptr1]
# ptr2 -= 1
# ptr1 -= 1
# else:
# arr2[ptr2] = arr2[run_ptr]
# ptr2 -= 1
# run_ptr -= 1
# while ptr1 >= 0:
# arr2[ptr2] = arr1[ptr1]
# ptr1 -= 1
# # ptr1, ptr2 = 0,0
# # while ptr2 <= len(arr1) - 1:
# # if arr2[ptr2] > arr1[0]:
# # arr2[ptr2], arr1[0] = arr1[0], arr2[ptr2]
# # ptr2 += 1
# # # arr1.sort()
# # while ptr1 < len(arr1) - 1:
# # if arr1[ptr1] > arr1[ptr1 + 1]:
# # arr1[ptr1], arr1[ptr1 + 1] = arr1[ptr1 + 1], arr1[ptr1]
# # ptr1 += 1
# # else: # arr1[ptr1] <= ptr1+1
# # ptr1 = 0
# # break
# # else: # arr2 < arr1
# # ptr2 += 1
# # arr2[len(arr1):] = arr1
# print(arr2)
# # s = "abcde"
# # # res = [""]
# # # new_elm = ""
# # # for str in s:
# # # new_elm += str
# # # res.append(new_elm)
# # # print(res)
# # # string = [char for char in s]
# # # string2=''
# # # string2= "".join(string[0])
# # def generate_all_subsets(s):
# # res = []
# # string = [char for char in s]
# # def helper(data, index, slate):
# # #base case
# # if index < 0:
# # res.append("")
# # return
# # #recurssion
# # slate = helper(data, index-1, slate)
# # slate += ''.join(data[index])
# # res.append(slate)
# # return slate
# # helper(string,len(s)-1,"")
# # return res
# # if __name__ == "__main__":
# # print(generate_all_subsets(s))
def generate_all_subsets(s):
res = []
def helper(data, index, slate):
#base case
if index == len(data):
# if slate == slate[::-1]:
res.append("|".join(slate))
return
#rcursion
for i in range(index+1,len(data)+1):
curr = string[index,i]
slate.append(data[index])
helper(data, index+1, slate)
slate.pop()
return
helper(s,len(s)-1,[])
return res
if __name__ == "__main__":
s = "abracadabra"
print(generate_all_subsets(s))
| def generate_all_subsets(s):
res = []
def helper(data, index, slate):
if index == len(data):
res.append('|'.join(slate))
return
for i in range(index + 1, len(data) + 1):
curr = string[index, i]
slate.append(data[index])
helper(data, index + 1, slate)
slate.pop()
return
helper(s, len(s) - 1, [])
return res
if __name__ == '__main__':
s = 'abracadabra'
print(generate_all_subsets(s)) |
def factorize(x: int):
d = 2
while x != 1:
if x % d == 0:
print('Hello')
yield d
x //= d
else:
d += 1
A = factorize(1023)
print(A)
for x in map(str, A):
print('Factor:', x) | def factorize(x: int):
d = 2
while x != 1:
if x % d == 0:
print('Hello')
yield d
x //= d
else:
d += 1
a = factorize(1023)
print(A)
for x in map(str, A):
print('Factor:', x) |
def insertion_sort(v):
for i in range (1, len(v)):
x = v[i]
j = i-1
while j>=0 and x< v[j]:
v[j+1] = v[j]
j -= 1
v[j+1] = x
print()
b = [8,3,9,2,1,10,7,5,4,6]
print(b)
print()
a = insertion_sort(b)
print()
a = b
print(a)
print()
| def insertion_sort(v):
for i in range(1, len(v)):
x = v[i]
j = i - 1
while j >= 0 and x < v[j]:
v[j + 1] = v[j]
j -= 1
v[j + 1] = x
print()
b = [8, 3, 9, 2, 1, 10, 7, 5, 4, 6]
print(b)
print()
a = insertion_sort(b)
print()
a = b
print(a)
print() |
class User():
def __init__(self , Name , userName , username_type , Game , data_dict):
self.index = data_dict.getIndex()+1
self.name = Name
self.username = userName
self.username_type = username_type
self.game = Game
self.data = data_dict
self.data.AddUser(self)
class DataStorage():
def __init__(self):
self.dict = self.CreateDict()
def CreateDict(self):
return dict()
def AddUser(self,user):
self.dict[user.index] = user
def getIndex(self):
max_index = 0
for user in self.dict.values():
if user.index > max_index:
max_index = user.index
return max_index
def getUser(self,name="",index=0):
if name:
for user in self.dict:
if user.name == name:
return user
elif index:
for user in self.data:
if user.index == index:
return user
else:
return None
def CheckUsername(self , username,game):
for user in self.dict.values():
if user.username == username and user.game == game:
return True
return False
def UpdateJSON(self):
pass
def CreateJSON(self):
pass
class GameSort():
def __init__(self,data_dict):
self.game_dict = dict()
self.data = data_dict
self.__init_gameslist()
def __init_gameslist(self):
list_ = ['Destiny2' ,'Fortnite','Call Of Duty Warzone','PUBG' , 'Apex Legends','Clash Royale','Clash of Clans','Houseparty']
for game in list_:
self.game_dict[game] = 0
def Count(self):
for user in self.data.values():
if user.game in self.game_dict.keys():
self.game_dict[user.game]+=1
else:
self.game_dict[user.game] = 1
def CheckGame(self , game):
if game in self.game_dict.keys():
self.game_dict[game]+=1
else:
self.game_dict[game]=1
def GetList(self):
self.Count()
return self.game_dict.keys() | class User:
def __init__(self, Name, userName, username_type, Game, data_dict):
self.index = data_dict.getIndex() + 1
self.name = Name
self.username = userName
self.username_type = username_type
self.game = Game
self.data = data_dict
self.data.AddUser(self)
class Datastorage:
def __init__(self):
self.dict = self.CreateDict()
def create_dict(self):
return dict()
def add_user(self, user):
self.dict[user.index] = user
def get_index(self):
max_index = 0
for user in self.dict.values():
if user.index > max_index:
max_index = user.index
return max_index
def get_user(self, name='', index=0):
if name:
for user in self.dict:
if user.name == name:
return user
elif index:
for user in self.data:
if user.index == index:
return user
else:
return None
def check_username(self, username, game):
for user in self.dict.values():
if user.username == username and user.game == game:
return True
return False
def update_json(self):
pass
def create_json(self):
pass
class Gamesort:
def __init__(self, data_dict):
self.game_dict = dict()
self.data = data_dict
self.__init_gameslist()
def __init_gameslist(self):
list_ = ['Destiny2', 'Fortnite', 'Call Of Duty Warzone', 'PUBG', 'Apex Legends', 'Clash Royale', 'Clash of Clans', 'Houseparty']
for game in list_:
self.game_dict[game] = 0
def count(self):
for user in self.data.values():
if user.game in self.game_dict.keys():
self.game_dict[user.game] += 1
else:
self.game_dict[user.game] = 1
def check_game(self, game):
if game in self.game_dict.keys():
self.game_dict[game] += 1
else:
self.game_dict[game] = 1
def get_list(self):
self.Count()
return self.game_dict.keys() |
class Time60(object):
'Time60 - track hours and minutes'
def __init__(self, hr, min):
self.hr = hr
self.min = min
def __str__(self):
return '%d:%d' %(self.hr, self.min)
__repr__ = __str__
def __add__(self, other):
return self.__class__(self.hr + other.hr, self.min + other.min)
def __iadd__(self, other):
self.hr += other.hr
self.min += other.min
return self
| class Time60(object):
"""Time60 - track hours and minutes"""
def __init__(self, hr, min):
self.hr = hr
self.min = min
def __str__(self):
return '%d:%d' % (self.hr, self.min)
__repr__ = __str__
def __add__(self, other):
return self.__class__(self.hr + other.hr, self.min + other.min)
def __iadd__(self, other):
self.hr += other.hr
self.min += other.min
return self |
# internal flags
TRANS_FLIPX = 1
TRANS_FLIPY = 2
TRANS_ROT = 4
# Tiled gid flags
GID_TRANS_FLIPX = 1 << 31
GID_TRANS_FLIPY = 1 << 30
GID_TRANS_ROT = 1 << 29
| trans_flipx = 1
trans_flipy = 2
trans_rot = 4
gid_trans_flipx = 1 << 31
gid_trans_flipy = 1 << 30
gid_trans_rot = 1 << 29 |
INSTALLED_APPS += (
"django_mailbox",
# "social",
'reversion',
# "social_django",
'django_outlook',
)
| installed_apps += ('django_mailbox', 'reversion', 'django_outlook') |
#Cleansing
#remove urls, usernames, NA, special charactars, and numbers
class TwitterCleanuper:
def iterate(self):
for cleanup_method in [self.remove_urls,
self.remove_usernames,
self.remove_na,
self.remove_special_chars,
self.remove_numbers]:
yield cleanup_method
def remove_by_regex(tweets, regexp):
tweets.loc[:, "text"].replace(regexp, "", inplace=True)
return tweets
def remove_urls(self, tweets):
return TwitterCleanuper.remove_by_regex(tweets, regex.compile(r"http.?://[^\s]+[\s]?"))
def remove_na(self, tweets):
return tweets[tweets["text"] != "Not Available"]
def remove_special_chars(self, tweets): # it unrolls the hashtags to normal words
for remove in map(lambda r: regex.compile(regex.escape(r)), [",", ":", "\"", "=", "&", ";", "%", "$",
"@", "%", "^", "*", "(", ")", "{", "}",
"[", "]", "|", "/", "\\", ">", "<", "-",
"!", "?", ".", "'", "_", "\n", "RT",
"--", "---", "#"]):
tweets.loc[:, "text"].replace(remove, "", inplace=True)
return tweets
def remove_usernames(self, tweets):
return TwitterCleanuper.remove_by_regex(tweets, regex.compile(r"@[^\s]+[\s]?"))
def remove_numbers(self, tweets):
return TwitterCleanuper.remove_by_regex(tweets, regex.compile(r"\s?[0-9]+\.?[0-9]*"))
class TwitterData_Cleansing(TwitterData_Initialize):
def __init__(self, previous):
self.processed_data = previous.processed_data
def cleanup(self, cleanuper):
t = self.processed_data
for cleanup_method in cleanuper.iterate():
if not self.is_testing:
t = cleanup_method(t)
else:
if cleanup_method.__name__ != "remove_na":
t = cleanup_method(t)
self.processed_data = t
# Remove Chinese Characthers
self.processed_data['text'] = self.processed_data['text'].str.replace(r'[^\x00-\x7F]+', '')
data = TwitterData_Cleansing(data)
data.cleanup(TwitterCleanuper()) # implement text cleansing.
# remove uncessary space between text.
def ls_strip(x):
return x.strip()
data.processed_data['text'] = data.processed_data.apply(lambda row: ls_strip(row['text']), axis=1)
# lower case
def lower_case(x):
return x.lower()
data.processed_data['text'] = data.processed_data.apply(lambda row: lower_case(row['text']), axis=1)
| class Twittercleanuper:
def iterate(self):
for cleanup_method in [self.remove_urls, self.remove_usernames, self.remove_na, self.remove_special_chars, self.remove_numbers]:
yield cleanup_method
def remove_by_regex(tweets, regexp):
tweets.loc[:, 'text'].replace(regexp, '', inplace=True)
return tweets
def remove_urls(self, tweets):
return TwitterCleanuper.remove_by_regex(tweets, regex.compile('http.?://[^\\s]+[\\s]?'))
def remove_na(self, tweets):
return tweets[tweets['text'] != 'Not Available']
def remove_special_chars(self, tweets):
for remove in map(lambda r: regex.compile(regex.escape(r)), [',', ':', '"', '=', '&', ';', '%', '$', '@', '%', '^', '*', '(', ')', '{', '}', '[', ']', '|', '/', '\\', '>', '<', '-', '!', '?', '.', "'", '_', '\n', 'RT', '--', '---', '#']):
tweets.loc[:, 'text'].replace(remove, '', inplace=True)
return tweets
def remove_usernames(self, tweets):
return TwitterCleanuper.remove_by_regex(tweets, regex.compile('@[^\\s]+[\\s]?'))
def remove_numbers(self, tweets):
return TwitterCleanuper.remove_by_regex(tweets, regex.compile('\\s?[0-9]+\\.?[0-9]*'))
class Twitterdata_Cleansing(TwitterData_Initialize):
def __init__(self, previous):
self.processed_data = previous.processed_data
def cleanup(self, cleanuper):
t = self.processed_data
for cleanup_method in cleanuper.iterate():
if not self.is_testing:
t = cleanup_method(t)
elif cleanup_method.__name__ != 'remove_na':
t = cleanup_method(t)
self.processed_data = t
self.processed_data['text'] = self.processed_data['text'].str.replace('[^\\x00-\\x7F]+', '')
data = twitter_data__cleansing(data)
data.cleanup(twitter_cleanuper())
def ls_strip(x):
return x.strip()
data.processed_data['text'] = data.processed_data.apply(lambda row: ls_strip(row['text']), axis=1)
def lower_case(x):
return x.lower()
data.processed_data['text'] = data.processed_data.apply(lambda row: lower_case(row['text']), axis=1) |
def get_right(pat, r=256):
right = [-1] * r
for i in range(len(pat)):
right[ord(pat[i])] = i
return right
def boyemoore_search(txt, pat):
right = get_right(pat)
skip = 0
i = 0
while i <= len(txt) - len(pat):
skip = 0
j = len(pat) - 1
while j >= 0:
if pat[j] != txt[i + j]:
skip = j - right[ord(txt[i + j])]
if skip < 1:
skip = 1
break
j -= 1
if skip == 0:
return i
i += skip
return len(txt)
def boyemoore_test():
txt = 'abcabcabdabcabcabc'
pat = 'abcabcabc'
ret = boyemoore_search(txt, pat)
print(ret)
print(txt[ret:])
| def get_right(pat, r=256):
right = [-1] * r
for i in range(len(pat)):
right[ord(pat[i])] = i
return right
def boyemoore_search(txt, pat):
right = get_right(pat)
skip = 0
i = 0
while i <= len(txt) - len(pat):
skip = 0
j = len(pat) - 1
while j >= 0:
if pat[j] != txt[i + j]:
skip = j - right[ord(txt[i + j])]
if skip < 1:
skip = 1
break
j -= 1
if skip == 0:
return i
i += skip
return len(txt)
def boyemoore_test():
txt = 'abcabcabdabcabcabc'
pat = 'abcabcabc'
ret = boyemoore_search(txt, pat)
print(ret)
print(txt[ret:]) |
def validate_empty(field, name=None):
if not field:
raise ValueError('This field is Required.')
if name and not field:
raise validate_empty('{} is Required'.format(name))
| def validate_empty(field, name=None):
if not field:
raise value_error('This field is Required.')
if name and (not field):
raise validate_empty('{} is Required'.format(name)) |
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
DEPS = [
'chromium',
'chromium_android',
'recipe_engine/json',
'recipe_engine/properties',
]
def RunSteps(api):
api.chromium.set_config('chromium')
api.chromium_android.set_config('main_builder')
api.chromium_android.run_sharded_perf_tests(
config=api.json.input({'steps': {}, 'version': 1}),
max_battery_temp=350)
def GenTests(api):
yield (
api.test('basic') +
api.properties(
buildername='test_buildername',
buildnumber=123,
bot_id='test_bot_id')
)
| deps = ['chromium', 'chromium_android', 'recipe_engine/json', 'recipe_engine/properties']
def run_steps(api):
api.chromium.set_config('chromium')
api.chromium_android.set_config('main_builder')
api.chromium_android.run_sharded_perf_tests(config=api.json.input({'steps': {}, 'version': 1}), max_battery_temp=350)
def gen_tests(api):
yield (api.test('basic') + api.properties(buildername='test_buildername', buildnumber=123, bot_id='test_bot_id')) |
# coded in python3
# video :
text = input("Enter your text : ")
check = True
etext = ""
for chars in text:
if(ord(chars)) <= 90 and ord(chars) <= 65:
if((ord(chars) + 13) > 90):
x = 64 + ((ord(chars) + 13) - 90)
else:
x = ord(chars) + 13
elif(ord(chars) <= 122 and ord(chars) >= 97):
if (ord(chars) + 13 > 122):
x = 96 + ((ord(chars) + 13) - 122)
else:
x = ord(chars) + 13
elif(ord(chars) == 32):
x = 32
else:
check = False
break
etext = str(etext) + chr(x)
if(check == False):
print("Invalid Characters found")
else:
print(etext)
| text = input('Enter your text : ')
check = True
etext = ''
for chars in text:
if ord(chars) <= 90 and ord(chars) <= 65:
if ord(chars) + 13 > 90:
x = 64 + (ord(chars) + 13 - 90)
else:
x = ord(chars) + 13
elif ord(chars) <= 122 and ord(chars) >= 97:
if ord(chars) + 13 > 122:
x = 96 + (ord(chars) + 13 - 122)
else:
x = ord(chars) + 13
elif ord(chars) == 32:
x = 32
else:
check = False
break
etext = str(etext) + chr(x)
if check == False:
print('Invalid Characters found')
else:
print(etext) |
a = [74,-72,94,-53,-59,-3,-66,36,-13,22,73,15,-52,75]
def maxSubArraySum(a):
current_sequence = 0
best_sequence = a[0]
for x in a:
current_sequence = max(x,current_sequence+x)
best_sequence = max(best_sequence,current_sequence)
return best_sequence
print("Largest sum contiguous subarray:",maxSubArraySum(a)) | a = [74, -72, 94, -53, -59, -3, -66, 36, -13, 22, 73, 15, -52, 75]
def max_sub_array_sum(a):
current_sequence = 0
best_sequence = a[0]
for x in a:
current_sequence = max(x, current_sequence + x)
best_sequence = max(best_sequence, current_sequence)
return best_sequence
print('Largest sum contiguous subarray:', max_sub_array_sum(a)) |
class Pic16f15356DeviceInformationArea:
def __init__(self, address, dia):
if len(dia) != 32:
raise ValueError('dia', f'PIC16F15356 DIA is 32 words but received {len(dia)} words')
self._address = address
self._raw = dia.copy()
self._device_id = ''.join(['{:04x}'.format(id_byte) for id_byte in dia[0x00:0x09]])
self._fvra2x = dia[0x19]
@property
def address(self): return self._address
@property
def raw(self): return self._raw.copy()
@property
def device_id(self): return self._device_id
@property
def fvra2x(self): return self._fvra2x
| class Pic16F15356Deviceinformationarea:
def __init__(self, address, dia):
if len(dia) != 32:
raise value_error('dia', f'PIC16F15356 DIA is 32 words but received {len(dia)} words')
self._address = address
self._raw = dia.copy()
self._device_id = ''.join(['{:04x}'.format(id_byte) for id_byte in dia[0:9]])
self._fvra2x = dia[25]
@property
def address(self):
return self._address
@property
def raw(self):
return self._raw.copy()
@property
def device_id(self):
return self._device_id
@property
def fvra2x(self):
return self._fvra2x |
arduino = Runtime.createAndStart("arduino","Arduino")
arduino.setBoardMega()
arduino.connect("COM7")
arduino1 = Runtime.createAndStart("arduino1","Arduino")
arduino1.setBoardNano()
#connecting arduino1 to arduino Serial1 instead to a COMX
arduino1.connect(arduino,"Serial1")
servo = Runtime.createAndStart("servo","Servo")
servo.attach(arduino1,5)
#attaching procedure take a bit more time to do, wait a little before using it
sleep(1)
servo.moveTo(90)
| arduino = Runtime.createAndStart('arduino', 'Arduino')
arduino.setBoardMega()
arduino.connect('COM7')
arduino1 = Runtime.createAndStart('arduino1', 'Arduino')
arduino1.setBoardNano()
arduino1.connect(arduino, 'Serial1')
servo = Runtime.createAndStart('servo', 'Servo')
servo.attach(arduino1, 5)
sleep(1)
servo.moveTo(90) |
# Copyright (c) 2015 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class DashboardApiConfig(object):
dashboard_api_version = "v1"
dashboard_call_auth_token = dashboard_api_version + "/api/auth/token"
class GearpumpApiConfig(object):
version = "v1.0"
prefix = "/api/" + version
prefix_master = prefix + "/master/"
call_login = "/login"
call_submit = prefix_master + "submitapp"
call_submit_with_args = call_submit + "?args="
call_applist = prefix_master + "applist"
call_appmaster = prefix + "/appmaster" | class Dashboardapiconfig(object):
dashboard_api_version = 'v1'
dashboard_call_auth_token = dashboard_api_version + '/api/auth/token'
class Gearpumpapiconfig(object):
version = 'v1.0'
prefix = '/api/' + version
prefix_master = prefix + '/master/'
call_login = '/login'
call_submit = prefix_master + 'submitapp'
call_submit_with_args = call_submit + '?args='
call_applist = prefix_master + 'applist'
call_appmaster = prefix + '/appmaster' |
##Patterns: W0199
assert (1 == 1, 2 == 2), "no error"
##Warn: W0199
assert (1 == 1, 2 == 2)
assert 1 == 1, "no error"
assert (1 == 1,), "no error"
assert (1 == 1,)
assert (1 == 1, 2 == 2, 3 == 5), "no error"
assert ()
##Warn: W0199
assert (True, 'error msg')
| assert (1 == 1, 2 == 2), 'no error'
assert (1 == 1, 2 == 2)
assert 1 == 1, 'no error'
assert (1 == 1,), 'no error'
assert (1 == 1,)
assert (1 == 1, 2 == 2, 3 == 5), 'no error'
assert ()
assert (True, 'error msg') |
class Parameters(object):
def __init__(self, *, p, q, g):
if isinstance(p, bytes):
p = int.from_bytes(p, 'big')
self.p = p
if isinstance(q, bytes):
q = int.from_bytes(q, 'big')
self.q = q
if isinstance(g, bytes):
g = int.from_bytes(g, 'big')
self.g = g
NIST_80 = Parameters(
p=(
b'\xfd\x7f\x53\x81\x1d\x75\x12\x29\x52\xdf\x4a\x9c\x2e\xec\xe4\xe7'
b'\xf6\x11\xb7\x52\x3c\xef\x44\x00\xc3\x1e\x3f\x80\xb6\x51\x26\x69'
b'\x45\x5d\x40\x22\x51\xfb\x59\x3d\x8d\x58\xfa\xbf\xc5\xf5\xba\x30'
b'\xf6\xcb\x9b\x55\x6c\xd7\x81\x3b\x80\x1d\x34\x6f\xf2\x66\x60\xb7'
b'\x6b\x99\x50\xa5\xa4\x9f\x9f\xe8\x04\x7b\x10\x22\xc2\x4f\xbb\xa9'
b'\xd7\xfe\xb7\xc6\x1b\xf8\x3b\x57\xe7\xc6\xa8\xa6\x15\x0f\x04\xfb'
b'\x83\xf6\xd3\xc5\x1e\xc3\x02\x35\x54\x13\x5a\x16\x91\x32\xf6\x75'
b'\xf3\xae\x2b\x61\xd7\x2a\xef\xf2\x22\x03\x19\x9d\xd1\x48\x01\xc7'
),
q=(
b'\x97\x60\x50\x8f\x15\x23\x0b\xcc\xb2\x92\xb9\x82\xa2\xeb\x84\x0b'
b'\xf0\x58\x1c\xf5'
),
g=(
b'\xf7\xe1\xa0\x85\xd6\x9b\x3d\xde\xcb\xbc\xab\x5c\x36\xb8\x57\xb9'
b'\x79\x94\xaf\xbb\xfa\x3a\xea\x82\xf9\x57\x4c\x0b\x3d\x07\x82\x67'
b'\x51\x59\x57\x8e\xba\xd4\x59\x4f\xe6\x71\x07\x10\x81\x80\xb4\x49'
b'\x16\x71\x23\xe8\x4c\x28\x16\x13\xb7\xcf\x09\x32\x8c\xc8\xa6\xe1'
b'\x3c\x16\x7a\x8b\x54\x7c\x8d\x28\xe0\xa3\xae\x1e\x2b\xb3\xa6\x75'
b'\x91\x6e\xa3\x7f\x0b\xfa\x21\x35\x62\xf1\xfb\x62\x7a\x01\x24\x3b'
b'\xcc\xa4\xf1\xbe\xa8\x51\x90\x89\xa8\x83\xdf\xe1\x5a\xe5\x9f\x06'
b'\x92\x8b\x66\x5e\x80\x7b\x55\x25\x64\x01\x4c\x3b\xfe\xcf\x49\x2a'
),
)
NIST_112 = Parameters(
p=(
b'\xC1\x96\xBA\x05\xAC\x29\xE1\xF9\xC3\xC7\x2D\x56\xDF\xFC\x61\x54'
b'\xA0\x33\xF1\x47\x7A\xC8\x8E\xC3\x7F\x09\xBE\x6C\x5B\xB9\x5F\x51'
b'\xC2\x96\xDD\x20\xD1\xA2\x8A\x06\x7C\xCC\x4D\x43\x16\xA4\xBD\x1D'
b'\xCA\x55\xED\x10\x66\xD4\x38\xC3\x5A\xEB\xAA\xBF\x57\xE7\xDA\xE4'
b'\x28\x78\x2A\x95\xEC\xA1\xC1\x43\xDB\x70\x1F\xD4\x85\x33\xA3\xC1'
b'\x8F\x0F\xE2\x35\x57\xEA\x7A\xE6\x19\xEC\xAC\xC7\xE0\xB5\x16\x52'
b'\xA8\x77\x6D\x02\xA4\x25\x56\x7D\xED\x36\xEA\xBD\x90\xCA\x33\xA1'
b'\xE8\xD9\x88\xF0\xBB\xB9\x2D\x02\xD1\xD2\x02\x90\x11\x3B\xB5\x62'
b'\xCE\x1F\xC8\x56\xEE\xB7\xCD\xD9\x2D\x33\xEE\xA6\xF4\x10\x85\x9B'
b'\x17\x9E\x7E\x78\x9A\x8F\x75\xF6\x45\xFA\xE2\xE1\x36\xD2\x52\xBF'
b'\xFA\xFF\x89\x52\x89\x45\xC1\xAB\xE7\x05\xA3\x8D\xBC\x2D\x36\x4A'
b'\xAD\xE9\x9B\xE0\xD0\xAA\xD8\x2E\x53\x20\x12\x14\x96\xDC\x65\xB3'
b'\x93\x0E\x38\x04\x72\x94\xFF\x87\x78\x31\xA1\x6D\x52\x28\x41\x8D'
b'\xE8\xAB\x27\x5D\x7D\x75\x65\x1C\xEF\xED\x65\xF7\x8A\xFC\x3E\xA7'
b'\xFE\x4D\x79\xB3\x5F\x62\xA0\x40\x2A\x11\x17\x59\x9A\xDA\xC7\xB2'
b'\x69\xA5\x9F\x35\x3C\xF4\x50\xE6\x98\x2D\x3B\x17\x02\xD9\xCA\x83'
),
q=(
b'\x90\xEA\xF4\xD1\xAF\x07\x08\xB1\xB6\x12\xFF\x35\xE0\xA2\x99\x7E'
b'\xB9\xE9\xD2\x63\xC9\xCE\x65\x95\x28\x94\x5C\x0D'
),
g=(
b'\xA5\x9A\x74\x9A\x11\x24\x2C\x58\xC8\x94\xE9\xE5\xA9\x18\x04\xE8'
b'\xFA\x0A\xC6\x4B\x56\x28\x8F\x8D\x47\xD5\x1B\x1E\xDC\x4D\x65\x44'
b'\x4F\xEC\xA0\x11\x1D\x78\xF3\x5F\xC9\xFD\xD4\xCB\x1F\x1B\x79\xA3'
b'\xBA\x9C\xBE\xE8\x3A\x3F\x81\x10\x12\x50\x3C\x81\x17\xF9\x8E\x50'
b'\x48\xB0\x89\xE3\x87\xAF\x69\x49\xBF\x87\x84\xEB\xD9\xEF\x45\x87'
b'\x6F\x2E\x6A\x5A\x49\x5B\xE6\x4B\x6E\x77\x04\x09\x49\x4B\x7F\xEE'
b'\x1D\xBB\x1E\x4B\x2B\xC2\xA5\x3D\x4F\x89\x3D\x41\x8B\x71\x59\x59'
b'\x2E\x4F\xFF\xDF\x69\x69\xE9\x1D\x77\x0D\xAE\xBD\x0B\x5C\xB1\x4C'
b'\x00\xAD\x68\xEC\x7D\xC1\xE5\x74\x5E\xA5\x5C\x70\x6C\x4A\x1C\x5C'
b'\x88\x96\x4E\x34\xD0\x9D\xEB\x75\x3A\xD4\x18\xC1\xAD\x0F\x4F\xDF'
b'\xD0\x49\xA9\x55\xE5\xD7\x84\x91\xC0\xB7\xA2\xF1\x57\x5A\x00\x8C'
b'\xCD\x72\x7A\xB3\x76\xDB\x6E\x69\x55\x15\xB0\x5B\xD4\x12\xF5\xB8'
b'\xC2\xF4\xC7\x7E\xE1\x0D\xA4\x8A\xBD\x53\xF5\xDD\x49\x89\x27\xEE'
b'\x7B\x69\x2B\xBB\xCD\xA2\xFB\x23\xA5\x16\xC5\xB4\x53\x3D\x73\x98'
b'\x0B\x2A\x3B\x60\xE3\x84\xED\x20\x0A\xE2\x1B\x40\xD2\x73\x65\x1A'
b'\xD6\x06\x0C\x13\xD9\x7F\xD6\x9A\xA1\x3C\x56\x11\xA5\x1B\x90\x85'
),
)
NIST_128 = Parameters(
p=(
b'\x90\x06\x64\x55\xB5\xCF\xC3\x8F\x9C\xAA\x4A\x48\xB4\x28\x1F\x29'
b'\x2C\x26\x0F\xEE\xF0\x1F\xD6\x10\x37\xE5\x62\x58\xA7\x79\x5A\x1C'
b'\x7A\xD4\x60\x76\x98\x2C\xE6\xBB\x95\x69\x36\xC6\xAB\x4D\xCF\xE0'
b'\x5E\x67\x84\x58\x69\x40\xCA\x54\x4B\x9B\x21\x40\xE1\xEB\x52\x3F'
b'\x00\x9D\x20\xA7\xE7\x88\x0E\x4E\x5B\xFA\x69\x0F\x1B\x90\x04\xA2'
b'\x78\x11\xCD\x99\x04\xAF\x70\x42\x0E\xEF\xD6\xEA\x11\xEF\x7D\xA1'
b'\x29\xF5\x88\x35\xFF\x56\xB8\x9F\xAA\x63\x7B\xC9\xAC\x2E\xFA\xAB'
b'\x90\x34\x02\x22\x9F\x49\x1D\x8D\x34\x85\x26\x1C\xD0\x68\x69\x9B'
b'\x6B\xA5\x8A\x1D\xDB\xBE\xF6\xDB\x51\xE8\xFE\x34\xE8\xA7\x8E\x54'
b'\x2D\x7B\xA3\x51\xC2\x1E\xA8\xD8\xF1\xD2\x9F\x5D\x5D\x15\x93\x94'
b'\x87\xE2\x7F\x44\x16\xB0\xCA\x63\x2C\x59\xEF\xD1\xB1\xEB\x66\x51'
b'\x1A\x5A\x0F\xBF\x61\x5B\x76\x6C\x58\x62\xD0\xBD\x8A\x3F\xE7\xA0'
b'\xE0\xDA\x0F\xB2\xFE\x1F\xCB\x19\xE8\xF9\x99\x6A\x8E\xA0\xFC\xCD'
b'\xE5\x38\x17\x52\x38\xFC\x8B\x0E\xE6\xF2\x9A\xF7\xF6\x42\x77\x3E'
b'\xBE\x8C\xD5\x40\x24\x15\xA0\x14\x51\xA8\x40\x47\x6B\x2F\xCE\xB0'
b'\xE3\x88\xD3\x0D\x4B\x37\x6C\x37\xFE\x40\x1C\x2A\x2C\x2F\x94\x1D'
b'\xAD\x17\x9C\x54\x0C\x1C\x8C\xE0\x30\xD4\x60\xC4\xD9\x83\xBE\x9A'
b'\xB0\xB2\x0F\x69\x14\x4C\x1A\xE1\x3F\x93\x83\xEA\x1C\x08\x50\x4F'
b'\xB0\xBF\x32\x15\x03\xEF\xE4\x34\x88\x31\x0D\xD8\xDC\x77\xEC\x5B'
b'\x83\x49\xB8\xBF\xE9\x7C\x2C\x56\x0E\xA8\x78\xDE\x87\xC1\x1E\x3D'
b'\x59\x7F\x1F\xEA\x74\x2D\x73\xEE\xC7\xF3\x7B\xE4\x39\x49\xEF\x1A'
b'\x0D\x15\xC3\xF3\xE3\xFC\x0A\x83\x35\x61\x70\x55\xAC\x91\x32\x8E'
b'\xC2\x2B\x50\xFC\x15\xB9\x41\xD3\xD1\x62\x4C\xD8\x8B\xC2\x5F\x3E'
b'\x94\x1F\xDD\xC6\x20\x06\x89\x58\x1B\xFE\xC4\x16\xB4\xB2\xCB\x73'
),
q=(
b'\xCF\xA0\x47\x8A\x54\x71\x7B\x08\xCE\x64\x80\x5B\x76\xE5\xB1\x42'
b'\x49\xA7\x7A\x48\x38\x46\x9D\xF7\xF7\xDC\x98\x7E\xFC\xCF\xB1\x1D'
),
g=(
b'\x5E\x5C\xBA\x99\x2E\x0A\x68\x0D\x88\x5E\xB9\x03\xAE\xA7\x8E\x4A'
b'\x45\xA4\x69\x10\x3D\x44\x8E\xDE\x3B\x7A\xCC\xC5\x4D\x52\x1E\x37'
b'\xF8\x4A\x4B\xDD\x5B\x06\xB0\x97\x0C\xC2\xD2\xBB\xB7\x15\xF7\xB8'
b'\x28\x46\xF9\xA0\xC3\x93\x91\x4C\x79\x2E\x6A\x92\x3E\x21\x17\xAB'
b'\x80\x52\x76\xA9\x75\xAA\xDB\x52\x61\xD9\x16\x73\xEA\x9A\xAF\xFE'
b'\xEC\xBF\xA6\x18\x3D\xFC\xB5\xD3\xB7\x33\x2A\xA1\x92\x75\xAF\xA1'
b'\xF8\xEC\x0B\x60\xFB\x6F\x66\xCC\x23\xAE\x48\x70\x79\x1D\x59\x82'
b'\xAA\xD1\xAA\x94\x85\xFD\x8F\x4A\x60\x12\x6F\xEB\x2C\xF0\x5D\xB8'
b'\xA7\xF0\xF0\x9B\x33\x97\xF3\x93\x7F\x2E\x90\xB9\xE5\xB9\xC9\xB6'
b'\xEF\xEF\x64\x2B\xC4\x83\x51\xC4\x6F\xB1\x71\xB9\xBF\xA9\xEF\x17'
b'\xA9\x61\xCE\x96\xC7\xE7\xA7\xCC\x3D\x3D\x03\xDF\xAD\x10\x78\xBA'
b'\x21\xDA\x42\x51\x98\xF0\x7D\x24\x81\x62\x2B\xCE\x45\x96\x9D\x9C'
b'\x4D\x60\x63\xD7\x2A\xB7\xA0\xF0\x8B\x2F\x49\xA7\xCC\x6A\xF3\x35'
b'\xE0\x8C\x47\x20\xE3\x14\x76\xB6\x72\x99\xE2\x31\xF8\xBD\x90\xB3'
b'\x9A\xC3\xAE\x3B\xE0\xC6\xB6\xCA\xCE\xF8\x28\x9A\x2E\x28\x73\xD5'
b'\x8E\x51\xE0\x29\xCA\xFB\xD5\x5E\x68\x41\x48\x9A\xB6\x6B\x5B\x4B'
b'\x9B\xA6\xE2\xF7\x84\x66\x08\x96\xAF\xF3\x87\xD9\x28\x44\xCC\xB8'
b'\xB6\x94\x75\x49\x6D\xE1\x9D\xA2\xE5\x82\x59\xB0\x90\x48\x9A\xC8'
b'\xE6\x23\x63\xCD\xF8\x2C\xFD\x8E\xF2\xA4\x27\xAB\xCD\x65\x75\x0B'
b'\x50\x6F\x56\xDD\xE3\xB9\x88\x56\x7A\x88\x12\x6B\x91\x4D\x78\x28'
b'\xE2\xB6\x3A\x6D\x7E\xD0\x74\x7E\xC5\x9E\x0E\x0A\x23\xCE\x7D\x8A'
b'\x74\xC1\xD2\xC2\xA7\xAF\xB6\xA2\x97\x99\x62\x0F\x00\xE1\x1C\x33'
b'\x78\x7F\x7D\xED\x3B\x30\xE1\xA2\x2D\x09\xF1\xFB\xDA\x1A\xBB\xBF'
b'\xBF\x25\xCA\xE0\x5A\x13\xF8\x12\xE3\x45\x63\xF9\x94\x10\xE7\x3B'
),
)
| class Parameters(object):
def __init__(self, *, p, q, g):
if isinstance(p, bytes):
p = int.from_bytes(p, 'big')
self.p = p
if isinstance(q, bytes):
q = int.from_bytes(q, 'big')
self.q = q
if isinstance(g, bytes):
g = int.from_bytes(g, 'big')
self.g = g
nist_80 = parameters(p=b'\xfd\x7fS\x81\x1du\x12)R\xdfJ\x9c.\xec\xe4\xe7\xf6\x11\xb7R<\xefD\x00\xc3\x1e?\x80\xb6Q&iE]@"Q\xfbY=\x8dX\xfa\xbf\xc5\xf5\xba0\xf6\xcb\x9bUl\xd7\x81;\x80\x1d4o\xf2f`\xb7k\x99P\xa5\xa4\x9f\x9f\xe8\x04{\x10"\xc2O\xbb\xa9\xd7\xfe\xb7\xc6\x1b\xf8;W\xe7\xc6\xa8\xa6\x15\x0f\x04\xfb\x83\xf6\xd3\xc5\x1e\xc3\x025T\x13Z\x16\x912\xf6u\xf3\xae+a\xd7*\xef\xf2"\x03\x19\x9d\xd1H\x01\xc7', q=b'\x97`P\x8f\x15#\x0b\xcc\xb2\x92\xb9\x82\xa2\xeb\x84\x0b\xf0X\x1c\xf5', g=b'\xf7\xe1\xa0\x85\xd6\x9b=\xde\xcb\xbc\xab\\6\xb8W\xb9y\x94\xaf\xbb\xfa:\xea\x82\xf9WL\x0b=\x07\x82gQYW\x8e\xba\xd4YO\xe6q\x07\x10\x81\x80\xb4I\x16q#\xe8L(\x16\x13\xb7\xcf\t2\x8c\xc8\xa6\xe1<\x16z\x8bT|\x8d(\xe0\xa3\xae\x1e+\xb3\xa6u\x91n\xa3\x7f\x0b\xfa!5b\xf1\xfbbz\x01$;\xcc\xa4\xf1\xbe\xa8Q\x90\x89\xa8\x83\xdf\xe1Z\xe5\x9f\x06\x92\x8bf^\x80{U%d\x01L;\xfe\xcfI*')
nist_112 = parameters(p=b"\xc1\x96\xba\x05\xac)\xe1\xf9\xc3\xc7-V\xdf\xfcaT\xa03\xf1Gz\xc8\x8e\xc3\x7f\t\xbel[\xb9_Q\xc2\x96\xdd \xd1\xa2\x8a\x06|\xccMC\x16\xa4\xbd\x1d\xcaU\xed\x10f\xd48\xc3Z\xeb\xaa\xbfW\xe7\xda\xe4(x*\x95\xec\xa1\xc1C\xdbp\x1f\xd4\x853\xa3\xc1\x8f\x0f\xe25W\xeaz\xe6\x19\xec\xac\xc7\xe0\xb5\x16R\xa8wm\x02\xa4%V}\xed6\xea\xbd\x90\xca3\xa1\xe8\xd9\x88\xf0\xbb\xb9-\x02\xd1\xd2\x02\x90\x11;\xb5b\xce\x1f\xc8V\xee\xb7\xcd\xd9-3\xee\xa6\xf4\x10\x85\x9b\x17\x9e~x\x9a\x8fu\xf6E\xfa\xe2\xe16\xd2R\xbf\xfa\xff\x89R\x89E\xc1\xab\xe7\x05\xa3\x8d\xbc-6J\xad\xe9\x9b\xe0\xd0\xaa\xd8.S \x12\x14\x96\xdce\xb3\x93\x0e8\x04r\x94\xff\x87x1\xa1mR(A\x8d\xe8\xab']}ue\x1c\xef\xede\xf7\x8a\xfc>\xa7\xfeMy\xb3_b\xa0@*\x11\x17Y\x9a\xda\xc7\xb2i\xa5\x9f5<\xf4P\xe6\x98-;\x17\x02\xd9\xca\x83", q=b'\x90\xea\xf4\xd1\xaf\x07\x08\xb1\xb6\x12\xff5\xe0\xa2\x99~\xb9\xe9\xd2c\xc9\xcee\x95(\x94\\\r', g=b"\xa5\x9at\x9a\x11$,X\xc8\x94\xe9\xe5\xa9\x18\x04\xe8\xfa\n\xc6KV(\x8f\x8dG\xd5\x1b\x1e\xdcMeDO\xec\xa0\x11\x1dx\xf3_\xc9\xfd\xd4\xcb\x1f\x1by\xa3\xba\x9c\xbe\xe8:?\x81\x10\x12P<\x81\x17\xf9\x8ePH\xb0\x89\xe3\x87\xafiI\xbf\x87\x84\xeb\xd9\xefE\x87o.jZI[\xe6Knw\x04\tIK\x7f\xee\x1d\xbb\x1eK+\xc2\xa5=O\x89=A\x8bqYY.O\xff\xdfii\xe9\x1dw\r\xae\xbd\x0b\\\xb1L\x00\xadh\xec}\xc1\xe5t^\xa5\\plJ\x1c\\\x88\x96N4\xd0\x9d\xebu:\xd4\x18\xc1\xad\x0fO\xdf\xd0I\xa9U\xe5\xd7\x84\x91\xc0\xb7\xa2\xf1WZ\x00\x8c\xcdrz\xb3v\xdbniU\x15\xb0[\xd4\x12\xf5\xb8\xc2\xf4\xc7~\xe1\r\xa4\x8a\xbdS\xf5\xddI\x89'\xee{i+\xbb\xcd\xa2\xfb#\xa5\x16\xc5\xb4S=s\x98\x0b*;`\xe3\x84\xed \n\xe2\x1b@\xd2se\x1a\xd6\x06\x0c\x13\xd9\x7f\xd6\x9a\xa1<V\x11\xa5\x1b\x90\x85")
nist_128 = parameters(p=b'\x90\x06dU\xb5\xcf\xc3\x8f\x9c\xaaJH\xb4(\x1f),&\x0f\xee\xf0\x1f\xd6\x107\xe5bX\xa7yZ\x1cz\xd4`v\x98,\xe6\xbb\x95i6\xc6\xabM\xcf\xe0^g\x84Xi@\xcaTK\x9b!@\xe1\xebR?\x00\x9d \xa7\xe7\x88\x0eN[\xfai\x0f\x1b\x90\x04\xa2x\x11\xcd\x99\x04\xafpB\x0e\xef\xd6\xea\x11\xef}\xa1)\xf5\x885\xffV\xb8\x9f\xaac{\xc9\xac.\xfa\xab\x904\x02"\x9fI\x1d\x8d4\x85&\x1c\xd0hi\x9bk\xa5\x8a\x1d\xdb\xbe\xf6\xdbQ\xe8\xfe4\xe8\xa7\x8eT-{\xa3Q\xc2\x1e\xa8\xd8\xf1\xd2\x9f]]\x15\x93\x94\x87\xe2\x7fD\x16\xb0\xcac,Y\xef\xd1\xb1\xebfQ\x1aZ\x0f\xbfa[vlXb\xd0\xbd\x8a?\xe7\xa0\xe0\xda\x0f\xb2\xfe\x1f\xcb\x19\xe8\xf9\x99j\x8e\xa0\xfc\xcd\xe58\x17R8\xfc\x8b\x0e\xe6\xf2\x9a\xf7\xf6Bw>\xbe\x8c\xd5@$\x15\xa0\x14Q\xa8@Gk/\xce\xb0\xe3\x88\xd3\rK7l7\xfe@\x1c*,/\x94\x1d\xad\x17\x9cT\x0c\x1c\x8c\xe00\xd4`\xc4\xd9\x83\xbe\x9a\xb0\xb2\x0fi\x14L\x1a\xe1?\x93\x83\xea\x1c\x08PO\xb0\xbf2\x15\x03\xef\xe44\x881\r\xd8\xdcw\xec[\x83I\xb8\xbf\xe9|,V\x0e\xa8x\xde\x87\xc1\x1e=Y\x7f\x1f\xeat-s\xee\xc7\xf3{\xe49I\xef\x1a\r\x15\xc3\xf3\xe3\xfc\n\x835apU\xac\x912\x8e\xc2+P\xfc\x15\xb9A\xd3\xd1bL\xd8\x8b\xc2_>\x94\x1f\xdd\xc6 \x06\x89X\x1b\xfe\xc4\x16\xb4\xb2\xcbs', q=b'\xcf\xa0G\x8aTq{\x08\xced\x80[v\xe5\xb1BI\xa7zH8F\x9d\xf7\xf7\xdc\x98~\xfc\xcf\xb1\x1d', g=b"^\\\xba\x99.\nh\r\x88^\xb9\x03\xae\xa7\x8eJE\xa4i\x10=D\x8e\xde;z\xcc\xc5MR\x1e7\xf8JK\xdd[\x06\xb0\x97\x0c\xc2\xd2\xbb\xb7\x15\xf7\xb8(F\xf9\xa0\xc3\x93\x91Ly.j\x92>!\x17\xab\x80Rv\xa9u\xaa\xdbRa\xd9\x16s\xea\x9a\xaf\xfe\xec\xbf\xa6\x18=\xfc\xb5\xd3\xb73*\xa1\x92u\xaf\xa1\xf8\xec\x0b`\xfbof\xcc#\xaeHpy\x1dY\x82\xaa\xd1\xaa\x94\x85\xfd\x8fJ`\x12o\xeb,\xf0]\xb8\xa7\xf0\xf0\x9b3\x97\xf3\x93\x7f.\x90\xb9\xe5\xb9\xc9\xb6\xef\xefd+\xc4\x83Q\xc4o\xb1q\xb9\xbf\xa9\xef\x17\xa9a\xce\x96\xc7\xe7\xa7\xcc==\x03\xdf\xad\x10x\xba!\xdaBQ\x98\xf0}$\x81b+\xceE\x96\x9d\x9cM`c\xd7*\xb7\xa0\xf0\x8b/I\xa7\xccj\xf35\xe0\x8cG \xe3\x14v\xb6r\x99\xe21\xf8\xbd\x90\xb3\x9a\xc3\xae;\xe0\xc6\xb6\xca\xce\xf8(\x9a.(s\xd5\x8eQ\xe0)\xca\xfb\xd5^hAH\x9a\xb6k[K\x9b\xa6\xe2\xf7\x84f\x08\x96\xaf\xf3\x87\xd9(D\xcc\xb8\xb6\x94uIm\xe1\x9d\xa2\xe5\x82Y\xb0\x90H\x9a\xc8\xe6#c\xcd\xf8,\xfd\x8e\xf2\xa4'\xab\xcdeu\x0bPoV\xdd\xe3\xb9\x88Vz\x88\x12k\x91Mx(\xe2\xb6:m~\xd0t~\xc5\x9e\x0e\n#\xce}\x8at\xc1\xd2\xc2\xa7\xaf\xb6\xa2\x97\x99b\x0f\x00\xe1\x1c3x\x7f}\xed;0\xe1\xa2-\t\xf1\xfb\xda\x1a\xbb\xbf\xbf%\xca\xe0Z\x13\xf8\x12\xe3Ec\xf9\x94\x10\xe7;") |
##############################################
## CONFIG BLOCK ##
##############################################
# @string token - API Token
# @string user - This is found in Zendesk under Admin > Channels > API, Commonly your login_email/token
# @list user_defined_list - List of emails comma delimeted with the users you need to pull time from
# @string admin_email - Email of the person that will recieve the JIRA importable CSV
# @int default_days - Number of days to pull time for
# @string from_addr - Email that will be set up to send email via SMTP
# @string smtp_server - Hostname to send email from
# @string password - Password to the email that this will be sent from
token = 'TOKEN'
user = 'APIUSER/token'
user_defined_list = ['useremail@company.com', 'useremail2@company.com']
admin_email = "user@email.com"
default_days = 7
from_addr = "user@company.com"
smtp_server = 'mail.server.net'
email_pass = 'password'
| token = 'TOKEN'
user = 'APIUSER/token'
user_defined_list = ['useremail@company.com', 'useremail2@company.com']
admin_email = 'user@email.com'
default_days = 7
from_addr = 'user@company.com'
smtp_server = 'mail.server.net'
email_pass = 'password' |
# define the time range we are interested in
end_time = datetime(2017, 9, 12, 0)
start_time = end_time - timedelta(days=2)
# build the query
query = ncss.query()
query.lonlat_point(-155.1, 19.7)
query.time_range(start_time, end_time)
query.variables('altimeter_setting', 'temperature', 'dewpoint',
'wind_direction', 'wind_speed')
query.accept('csv')
data = ncss.get_data(query)
df = pd.DataFrame(data)
# Parse the date time stamps
df['time'] = pd.to_datetime(df['time'].str.decode('utf-8'), infer_datetime_format=True)
# Station names are bytes, we need to convert them to strings
df['station'] = df['station'].str.decode('utf-8')
# Make the plot
ax = df.plot(x='time', y=['temperature', 'dewpoint'],
color=['tab:red', 'tab:green'],
grid=True,
figsize=(10,6),
fontsize=14)
# Set good labels
ax.set_xlabel('Time', fontsize=16)
ax.set_ylabel('DegC', fontsize=16)
ax.set_title(f"{df['station'][0]} {df['time'][0]:%Y/%m/%d}", fontsize=22)
# Improve on the default ticking
locator = AutoDateLocator()
hoursFmt = DateFormatter('%H')
ax.xaxis.set_major_locator(locator)
ax.xaxis.set_major_formatter(hoursFmt) | end_time = datetime(2017, 9, 12, 0)
start_time = end_time - timedelta(days=2)
query = ncss.query()
query.lonlat_point(-155.1, 19.7)
query.time_range(start_time, end_time)
query.variables('altimeter_setting', 'temperature', 'dewpoint', 'wind_direction', 'wind_speed')
query.accept('csv')
data = ncss.get_data(query)
df = pd.DataFrame(data)
df['time'] = pd.to_datetime(df['time'].str.decode('utf-8'), infer_datetime_format=True)
df['station'] = df['station'].str.decode('utf-8')
ax = df.plot(x='time', y=['temperature', 'dewpoint'], color=['tab:red', 'tab:green'], grid=True, figsize=(10, 6), fontsize=14)
ax.set_xlabel('Time', fontsize=16)
ax.set_ylabel('DegC', fontsize=16)
ax.set_title(f"{df['station'][0]} {df['time'][0]:%Y/%m/%d}", fontsize=22)
locator = auto_date_locator()
hours_fmt = date_formatter('%H')
ax.xaxis.set_major_locator(locator)
ax.xaxis.set_major_formatter(hoursFmt) |
# -*- coding: utf-8 -*-
class Announce:
def __init__(self, data=None):
self.guild_id: str = ""
self.channel_id: str = ""
self.message_id: str = ""
if data:
self.__dict__ = data
class CreateAnnounceRequest:
def __init__(self, channel_id: str, message_id: str):
self.channel_id = channel_id
self.message_id = message_id
class CreateChannelAnnounceRequest:
def __init__(self, message_id: str):
self.message_id = message_id
| class Announce:
def __init__(self, data=None):
self.guild_id: str = ''
self.channel_id: str = ''
self.message_id: str = ''
if data:
self.__dict__ = data
class Createannouncerequest:
def __init__(self, channel_id: str, message_id: str):
self.channel_id = channel_id
self.message_id = message_id
class Createchannelannouncerequest:
def __init__(self, message_id: str):
self.message_id = message_id |
__all__ = ['class_in_class_factory']
def class_in_class_factory(parent_class, name, bases=None, **fields):
if not (isinstance(bases, tuple) or bases is None):
raise TypeError('`bases` must be tuple.')
fields['__module__'] = '{parent_class_module_name}.{parent_class_name}'.format(
parent_class_module_name=parent_class.__module__,
parent_class_name=parent_class.__name__,
)
return type(name, bases or (object, ), fields)
| __all__ = ['class_in_class_factory']
def class_in_class_factory(parent_class, name, bases=None, **fields):
if not (isinstance(bases, tuple) or bases is None):
raise type_error('`bases` must be tuple.')
fields['__module__'] = '{parent_class_module_name}.{parent_class_name}'.format(parent_class_module_name=parent_class.__module__, parent_class_name=parent_class.__name__)
return type(name, bases or (object,), fields) |
class Tree(object):
def __init__(self, x):
self.value = x
self.left = None
self.right = None
def balancedBinaryTree(root):
def get_height(root):
if root is None:
return 0
return max(get_height(root.left), get_height(root.right)) + 1
if root is None:
return True
left_height = get_height(root.left)
right_height = get_height(root.right)
if (
(abs(left_height - right_height) <= 1)
and balancedBinaryTree(root.left) is True
and balancedBinaryTree(root.right) is True
):
return True
return False
| class Tree(object):
def __init__(self, x):
self.value = x
self.left = None
self.right = None
def balanced_binary_tree(root):
def get_height(root):
if root is None:
return 0
return max(get_height(root.left), get_height(root.right)) + 1
if root is None:
return True
left_height = get_height(root.left)
right_height = get_height(root.right)
if abs(left_height - right_height) <= 1 and balanced_binary_tree(root.left) is True and (balanced_binary_tree(root.right) is True):
return True
return False |
#Project Euler Question 54
#Poker hands
poker_file = open(r"C:\Users\Clayton\Documents\Python Other Files\p054_poker.txt")
content = poker_file.read()
content = content.replace(" ", "")
content = content.split("\n")
card_values = {"2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, "9": 9, "T": 10, "J": 11, "Q": 12, "K": 13, "A": 14}
def royal_flush(hand, suits):
if len(suits) == 1:
pass
else:
return []
royal_values = ["T", "J", "Q", "K", "A"]
for value in royal_values:
if value in hand:
pass
else:
return []
return ["A"]
def straight_flush(hand, suits):
if len(suits) == 1:
pass
else:
return []
hand = [card_values[card] for card in hand]
hand.sort()
c1 = 1
for card in hand[0:4]:
if hand[c1] - card == 1:
pass
else:
return []
c1 += 1
hand = [list(card_values.keys())[list(card_values.values()).index(card)] for card in hand]
return [hand[4]]
def four_of_a_kind(hand, suits):
for card in hand:
if hand.count(card) > 3:
return card
return []
def full_house(hand, suits):
hand_check = hand.copy()
high_cards = []
for card in hand_check:
if hand_check.count(card) > 2:
high_cards.append(card)
while card in hand_check:
hand_check.remove(card)
break
else:
return []
for card in hand_check:
if hand_check.count(card) > 1:
return high_cards
else:
return []
def flush(hand, suits):
if len(suits) == 1:
hand.sort()
return [hand[4]]
else:
return []
def straight(hand, suits):
low_values = ["A", "2", "3", "4", "5"]
for value in low_values:
if value in hand:
pass
else:
break
else:
return ["5"]
hand = [card_values[card] for card in hand]
hand.sort()
c1 = 1
for card in hand[0:4]:
if int(hand[c1]) - int(card) == 1:
pass
else:
return []
c1 += 1
hand = [list(card_values.keys())[list(card_values.values()).index(card)] for card in hand]
return hand[4]
def three_of_a_kind(hand, suits):
for card in hand:
if hand.count(card) > 2:
return card
return []
def two_pair(hand, suits):
hand_check = hand.copy()
hand_check = [card_values[card] for card in hand]
counter = 0
high_cards = []
for card in hand_check:
if hand_check.count(card) > 1:
counter += 1
high_cards.append(card)
while card in hand_check:
hand_check.remove(card)
if counter == 2:
high_cards.sort()
high_cards = [list(card_values.keys())[list(card_values.values()).index(card)] for card in high_cards]
return high_cards
return []
def one_pair(hand, suits):
for card in hand:
if hand.count(card) > 1:
return card
return []
def high_card(hand, suits):
highest = 2
for card in hand:
high_card = card_values[card]
if high_card > highest:
highest = high_card
highest_card = card
return highest_card
def winning_hand(h1, s1, h2, s2):
check_1 = royal_flush(h1, s1)
check_2 = royal_flush(h2, s2)
if len(check_1) > 0:
return True
elif len(check_2) > 0:
return False
else:
check_1 = straight_flush(h1, s1)
check_2 = straight_flush(h2, s2)
#Royal Flush to Straight Flush
if len(check_1) > 0:
if len(check_2) > 0:
if card_values[check_1] > card_values[check_2]:
return True
else:
return False
else:
return True
elif len(check_2) > 0:
return False
else:
check_1 = four_of_a_kind(h1, s1)
check_2 = four_of_a_kind(h2, s2)
#Straight Flush to Four of a Kind
if len(check_1) > 0:
if len(check_2) > 0:
if card_values[check_1] > card_values[check_2]:
return True
else:
return False
else:
return True
elif len(check_2) > 0:
return False
else:
check_1 = full_house(h1, s1)
check_2 = full_house(h2, s2)
#Four of a Kind to Full House
if len(check_1) > 0:
if len(check_2) > 0:
if card_values[check_1] > card_values[check_2]:
return True
else:
return False
else:
return True
elif len(check_2) > 0:
return False
else:
check_1 = flush(h1, s1)
check_2 = flush(h2, s2)
#Full House to Flush
if len(check_1) > 0:
if len(check_2) > 0:
if card_values[check_1] > card_values[check_2]:
return True
else:
return False
else:
return True
elif len(check_2) > 0:
return False
else:
check_1 = straight(h1, s1)
check_2 = straight(h2, s2)
#Flush to Straight
if len(check_1) > 0:
if len(check_2) > 0:
if card_values[check_1] > card_values[check_2]:
return True
else:
return False
else:
return True
elif len(check_2) > 0:
return False
else:
check_1 = three_of_a_kind(h1, s1)
check_2 = three_of_a_kind(h2, s2)
#Straight to Three of a Kind
if len(check_1) > 0:
if len(check_2) > 0:
if card_values[check_1] > card_values[check_2]:
return True
else:
return False
else:
return True
elif len(check_2) > 0:
return False
else:
check_1 = two_pair(h1, s1)
check_2 = two_pair(h2, s2)
#Three of a Kind to Two Pair
if len(check_1) > 0:
if len(check_2) > 0:
if card_values[check_1[1]] > card_values[check_2[1]]:
return True
elif card_values[check_2[1]] > card_values[check_1[1]]:
return False
elif card_values[check_1[0]] > card_values[check_2[0]]:
return True
elif card_values[check_2[0]] > card_values[check_1[0]]:
return False
else:
h1_copy = h1.copy()
h2_copy = h2.copy()
for term in check_1:
while term in h1_copy:
h1_copy.remove(term)
for term in check_2:
while term in h2_copy:
h2_copy.remove(term)
check_1 = one_pair(h1_copy, s1)
check_2 = one_pair(h2_copy, s2)
if len(check_1) > 0:
if len(check_2) > 0:
if card_values[check_1] > card_values[check_2]:
return True
elif card_values[check_2] > card_values[check_1]:
return False
else:
h1_copy = h1.copy()
h2_copy = h2.copy()
while check_1 in h1_copy:
h1_copy.remove(check_1)
while check_2 in h2_copy:
h2_copy.remove(check_2)
check_1 = high_card(h1_copy, s1)
check_2 = high_card(h2_copy, s2)
if card_values[check_1] > card_values[check_2]:
return True
elif card_values[check_2] > card_values[check_1]:
return False
else:
return None
else:
return True
else:
return True
elif len(check_2) > 0:
return False
else:
check_1 = one_pair(h1, s1)
check_2 = one_pair(h2, s2)
#Two Pair to One Pair
if len(check_1) > 0:
if len(check_2) > 0:
if card_values[check_1] > card_values[check_2]:
return True
elif card_values[check_2] > card_values[check_1]:
return False
else:
h1_copy = h1.copy()
h2_copy = h2.copy()
while check_1 in h1_copy:
h1_copy.remove(check_1)
while check_2 in h2_copy:
h2_copy.remove(check_2)
check_1 = high_card(h1_copy, s1)
check_2 = high_card(h2_copy, s2)
for x in range(0,3):
if card_values[check_1] > card_values[check_2]:
return True
elif card_values[check_2] > card_values[check_1]:
return False
else:
while check_1 in h1_copy:
h1_copy.remove(check_1)
while check_2 in h2_copy:
h2_copy.remove(check_2)
check_1 = high_card(h1_copy, s1)
check_2 = high_card(h2_copy, s2)
else:
return True
elif len(check_2) > 0:
return False
else:
check_1 = high_card(h1, s1)
check_2 = high_card(h2, s2)
#One Pair to High Card
h1_copy = h1.copy()
h2_copy = h2.copy()
for x in range(0,5):
if card_values[check_1] > card_values[check_2]:
return True
elif card_values[check_2] > card_values[check_1]:
return False
else:
while check_1 in h1_copy:
h1_copy.remove(check_1)
while check_2 in h2_copy:
h2_copy.remove(check_2)
check_1 = high_card(h1_copy, s1)
check_2 = high_card(h2_copy, s2)
win1_list = 0
for row in content:
if len(row) == 0:
continue
hand_1 = [card for card in row[0:10:2]]
suits_1 = {card for card in row[1:11:2]}
hand_2 = [card for card in row[10::2]]
suits_2 = {card for card in row[11::2]}
#print (hand_1, hand_2)
#print (suits_1, suits_2)
winner_1 = winning_hand(hand_1, suits_1, hand_2, suits_2)
#print (winner_1)
#print ()
if winner_1 is True:
win1_list += 1
print (win1_list)
poker_file.close() | poker_file = open('C:\\Users\\Clayton\\Documents\\Python Other Files\\p054_poker.txt')
content = poker_file.read()
content = content.replace(' ', '')
content = content.split('\n')
card_values = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'T': 10, 'J': 11, 'Q': 12, 'K': 13, 'A': 14}
def royal_flush(hand, suits):
if len(suits) == 1:
pass
else:
return []
royal_values = ['T', 'J', 'Q', 'K', 'A']
for value in royal_values:
if value in hand:
pass
else:
return []
return ['A']
def straight_flush(hand, suits):
if len(suits) == 1:
pass
else:
return []
hand = [card_values[card] for card in hand]
hand.sort()
c1 = 1
for card in hand[0:4]:
if hand[c1] - card == 1:
pass
else:
return []
c1 += 1
hand = [list(card_values.keys())[list(card_values.values()).index(card)] for card in hand]
return [hand[4]]
def four_of_a_kind(hand, suits):
for card in hand:
if hand.count(card) > 3:
return card
return []
def full_house(hand, suits):
hand_check = hand.copy()
high_cards = []
for card in hand_check:
if hand_check.count(card) > 2:
high_cards.append(card)
while card in hand_check:
hand_check.remove(card)
break
else:
return []
for card in hand_check:
if hand_check.count(card) > 1:
return high_cards
else:
return []
def flush(hand, suits):
if len(suits) == 1:
hand.sort()
return [hand[4]]
else:
return []
def straight(hand, suits):
low_values = ['A', '2', '3', '4', '5']
for value in low_values:
if value in hand:
pass
else:
break
else:
return ['5']
hand = [card_values[card] for card in hand]
hand.sort()
c1 = 1
for card in hand[0:4]:
if int(hand[c1]) - int(card) == 1:
pass
else:
return []
c1 += 1
hand = [list(card_values.keys())[list(card_values.values()).index(card)] for card in hand]
return hand[4]
def three_of_a_kind(hand, suits):
for card in hand:
if hand.count(card) > 2:
return card
return []
def two_pair(hand, suits):
hand_check = hand.copy()
hand_check = [card_values[card] for card in hand]
counter = 0
high_cards = []
for card in hand_check:
if hand_check.count(card) > 1:
counter += 1
high_cards.append(card)
while card in hand_check:
hand_check.remove(card)
if counter == 2:
high_cards.sort()
high_cards = [list(card_values.keys())[list(card_values.values()).index(card)] for card in high_cards]
return high_cards
return []
def one_pair(hand, suits):
for card in hand:
if hand.count(card) > 1:
return card
return []
def high_card(hand, suits):
highest = 2
for card in hand:
high_card = card_values[card]
if high_card > highest:
highest = high_card
highest_card = card
return highest_card
def winning_hand(h1, s1, h2, s2):
check_1 = royal_flush(h1, s1)
check_2 = royal_flush(h2, s2)
if len(check_1) > 0:
return True
elif len(check_2) > 0:
return False
else:
check_1 = straight_flush(h1, s1)
check_2 = straight_flush(h2, s2)
if len(check_1) > 0:
if len(check_2) > 0:
if card_values[check_1] > card_values[check_2]:
return True
else:
return False
else:
return True
elif len(check_2) > 0:
return False
else:
check_1 = four_of_a_kind(h1, s1)
check_2 = four_of_a_kind(h2, s2)
if len(check_1) > 0:
if len(check_2) > 0:
if card_values[check_1] > card_values[check_2]:
return True
else:
return False
else:
return True
elif len(check_2) > 0:
return False
else:
check_1 = full_house(h1, s1)
check_2 = full_house(h2, s2)
if len(check_1) > 0:
if len(check_2) > 0:
if card_values[check_1] > card_values[check_2]:
return True
else:
return False
else:
return True
elif len(check_2) > 0:
return False
else:
check_1 = flush(h1, s1)
check_2 = flush(h2, s2)
if len(check_1) > 0:
if len(check_2) > 0:
if card_values[check_1] > card_values[check_2]:
return True
else:
return False
else:
return True
elif len(check_2) > 0:
return False
else:
check_1 = straight(h1, s1)
check_2 = straight(h2, s2)
if len(check_1) > 0:
if len(check_2) > 0:
if card_values[check_1] > card_values[check_2]:
return True
else:
return False
else:
return True
elif len(check_2) > 0:
return False
else:
check_1 = three_of_a_kind(h1, s1)
check_2 = three_of_a_kind(h2, s2)
if len(check_1) > 0:
if len(check_2) > 0:
if card_values[check_1] > card_values[check_2]:
return True
else:
return False
else:
return True
elif len(check_2) > 0:
return False
else:
check_1 = two_pair(h1, s1)
check_2 = two_pair(h2, s2)
if len(check_1) > 0:
if len(check_2) > 0:
if card_values[check_1[1]] > card_values[check_2[1]]:
return True
elif card_values[check_2[1]] > card_values[check_1[1]]:
return False
elif card_values[check_1[0]] > card_values[check_2[0]]:
return True
elif card_values[check_2[0]] > card_values[check_1[0]]:
return False
else:
h1_copy = h1.copy()
h2_copy = h2.copy()
for term in check_1:
while term in h1_copy:
h1_copy.remove(term)
for term in check_2:
while term in h2_copy:
h2_copy.remove(term)
check_1 = one_pair(h1_copy, s1)
check_2 = one_pair(h2_copy, s2)
if len(check_1) > 0:
if len(check_2) > 0:
if card_values[check_1] > card_values[check_2]:
return True
elif card_values[check_2] > card_values[check_1]:
return False
else:
h1_copy = h1.copy()
h2_copy = h2.copy()
while check_1 in h1_copy:
h1_copy.remove(check_1)
while check_2 in h2_copy:
h2_copy.remove(check_2)
check_1 = high_card(h1_copy, s1)
check_2 = high_card(h2_copy, s2)
if card_values[check_1] > card_values[check_2]:
return True
elif card_values[check_2] > card_values[check_1]:
return False
else:
return None
else:
return True
else:
return True
elif len(check_2) > 0:
return False
else:
check_1 = one_pair(h1, s1)
check_2 = one_pair(h2, s2)
if len(check_1) > 0:
if len(check_2) > 0:
if card_values[check_1] > card_values[check_2]:
return True
elif card_values[check_2] > card_values[check_1]:
return False
else:
h1_copy = h1.copy()
h2_copy = h2.copy()
while check_1 in h1_copy:
h1_copy.remove(check_1)
while check_2 in h2_copy:
h2_copy.remove(check_2)
check_1 = high_card(h1_copy, s1)
check_2 = high_card(h2_copy, s2)
for x in range(0, 3):
if card_values[check_1] > card_values[check_2]:
return True
elif card_values[check_2] > card_values[check_1]:
return False
else:
while check_1 in h1_copy:
h1_copy.remove(check_1)
while check_2 in h2_copy:
h2_copy.remove(check_2)
check_1 = high_card(h1_copy, s1)
check_2 = high_card(h2_copy, s2)
else:
return True
elif len(check_2) > 0:
return False
else:
check_1 = high_card(h1, s1)
check_2 = high_card(h2, s2)
h1_copy = h1.copy()
h2_copy = h2.copy()
for x in range(0, 5):
if card_values[check_1] > card_values[check_2]:
return True
elif card_values[check_2] > card_values[check_1]:
return False
else:
while check_1 in h1_copy:
h1_copy.remove(check_1)
while check_2 in h2_copy:
h2_copy.remove(check_2)
check_1 = high_card(h1_copy, s1)
check_2 = high_card(h2_copy, s2)
win1_list = 0
for row in content:
if len(row) == 0:
continue
hand_1 = [card for card in row[0:10:2]]
suits_1 = {card for card in row[1:11:2]}
hand_2 = [card for card in row[10::2]]
suits_2 = {card for card in row[11::2]}
winner_1 = winning_hand(hand_1, suits_1, hand_2, suits_2)
if winner_1 is True:
win1_list += 1
print(win1_list)
poker_file.close() |
def did_from_credential_definition_id(credential_definition_id: str) -> str:
parts = credential_definition_id.split(":")
return parts[0]
| def did_from_credential_definition_id(credential_definition_id: str) -> str:
parts = credential_definition_id.split(':')
return parts[0] |
def solve_knapsack(profits, weights, capacity):
n = len(profits)
if capacity <= 0 or n == 0 or len(weights) != n: # basic checks
return 0
# We only need one previous row to find the optimal solution,
# Overall we need '2' rows, the solution is similar to the previous solution, the only difference is that
# we use `i % 2` instead if `i` and `(i-1) % 2` instead if `i-1` when querying the DP matrix
dp = [[0 for x in range(capacity + 1)] for y in range(2)]
# if we have only one weight, we will take it if it is not more than the capacity
for c in range(0, capacity + 1):
if weights[0] <= c:
dp[0][c] = dp[1][c] = profits[0] # Note : Updating data in both the rows **
# process all sub-arrays for all the capacities
for i in range(1, n):
for c in range(0, capacity + 1):
profit_by_including, profit_by_excluding = 0, 0
if weights[i] <= c: # include the item, if it is not more than the capacity
profit_by_including = profits[i] + dp[(i - 1) % 2][c - weights[i]]
profit_by_excluding = dp[(i - 1) % 2][c] # exclude the item
dp[i % 2][c] = max(profit_by_including, profit_by_excluding) # take maximum
return dp[(n - 1) % 2][capacity]
if __name__ == '__main__':
print("Total knapsack profit: ", str(solve_knapsack([1, 6, 10, 16], [1, 2, 3, 5], 7)))
print("Total knapsack profit: ", str(solve_knapsack([1, 6, 10, 16], [1, 2, 3, 5], 6)))
| def solve_knapsack(profits, weights, capacity):
n = len(profits)
if capacity <= 0 or n == 0 or len(weights) != n:
return 0
dp = [[0 for x in range(capacity + 1)] for y in range(2)]
for c in range(0, capacity + 1):
if weights[0] <= c:
dp[0][c] = dp[1][c] = profits[0]
for i in range(1, n):
for c in range(0, capacity + 1):
(profit_by_including, profit_by_excluding) = (0, 0)
if weights[i] <= c:
profit_by_including = profits[i] + dp[(i - 1) % 2][c - weights[i]]
profit_by_excluding = dp[(i - 1) % 2][c]
dp[i % 2][c] = max(profit_by_including, profit_by_excluding)
return dp[(n - 1) % 2][capacity]
if __name__ == '__main__':
print('Total knapsack profit: ', str(solve_knapsack([1, 6, 10, 16], [1, 2, 3, 5], 7)))
print('Total knapsack profit: ', str(solve_knapsack([1, 6, 10, 16], [1, 2, 3, 5], 6))) |
# Parent class 1
class Person:
def person_info(self, name, age):
print('Inside Person class')
print('Name:', name, 'Age:', age)
# Parent class 2
class Company:
def company_info(self, company_name, location):
print('Inside Company class')
print('Name:', company_name, 'location:', location)
# Child class
class Employee(Person, Company):
def employee_info(self, salary, skill):
print('Inside Employee class')
print('Salary:', salary, 'Skill:', skill)
# Create object of Employee
emp = Employee()
# access data
emp.person_info('Jessa', 28)
emp.company_info('Google', 'Atlanta')
emp.employee_info(12000, 'Machine Learning')
class Employee2(Person):
def __init__(self):
self.company = Company()
def employee_info(self, salary, skill):
print('Inside Employee class')
print('Salary:', salary, 'Skill:', skill)
# Create object of Employee
emp2 = Employee2()
# access data
emp2.person_info('Lisa', 26)
emp2.company.company_info('Facebook', 'San Francisco')
emp2.employee_info(11000, 'Machine Learning')
| class Person:
def person_info(self, name, age):
print('Inside Person class')
print('Name:', name, 'Age:', age)
class Company:
def company_info(self, company_name, location):
print('Inside Company class')
print('Name:', company_name, 'location:', location)
class Employee(Person, Company):
def employee_info(self, salary, skill):
print('Inside Employee class')
print('Salary:', salary, 'Skill:', skill)
emp = employee()
emp.person_info('Jessa', 28)
emp.company_info('Google', 'Atlanta')
emp.employee_info(12000, 'Machine Learning')
class Employee2(Person):
def __init__(self):
self.company = company()
def employee_info(self, salary, skill):
print('Inside Employee class')
print('Salary:', salary, 'Skill:', skill)
emp2 = employee2()
emp2.person_info('Lisa', 26)
emp2.company.company_info('Facebook', 'San Francisco')
emp2.employee_info(11000, 'Machine Learning') |
BINDIR = '/usr/local/bin'
BLOCK_MESSAGE_KEYS = []
BUILD_TYPE = 'app'
BUNDLE_NAME = 'pebble-World-Cup.pbw'
DEFINES = ['RELEASE']
LIBDIR = '/usr/local/lib'
LIB_DIR = 'node_modules'
MESSAGE_KEYS = {}
MESSAGE_KEYS_HEADER = '/root/hello-pebblejs/pebble-World-Cup/build/include/message_keys.auto.h'
NODE_PATH = '/root/.pebble-sdk/SDKs/current/node_modules'
PEBBLE_SDK_COMMON = '/root/.pebble-sdk/SDKs/current/sdk-core/pebble/common'
PEBBLE_SDK_ROOT = '/root/.pebble-sdk/SDKs/current/sdk-core/pebble'
PREFIX = '/usr/local'
PROJECT_INFO = {u'sdkVersion': u'3', u'uuid': u'133215f0-cf20-4c05-997b-3c9be5a64e5b', u'appKeys': {}, u'companyName': u'Araulin', 'messageKeys': {}, u'targetPlatforms': [u'aplite', u'basalt', u'chalk', u'diorite', u'emery'], u'capabilities': [u'configurable'], u'versionLabel': u'0.4', u'longName': u'World Cup', u'versionCode': 1, u'shortName': u'World Cup', u'watchapp': {u'watchface': False}, u'resources': {u'media': [{u'menuIcon': True, u'type': u'bitmap', u'name': u'IMAGE_MENU_ICON', u'file': u'images/menu_icon.png'}, {u'type': u'bitmap', u'name': u'IMAGE_CUP', u'file': u'images/cup.png'}, {u'type': u'font', u'name': u'SANS_50', u'file': u'fonts/OpenSans.ttf'}]}}
REQUESTED_PLATFORMS = [u'aplite', u'basalt', u'chalk', u'diorite', u'emery']
RESOURCES_JSON = [{u'menuIcon': True, u'type': u'bitmap', u'name': u'IMAGE_MENU_ICON', u'file': u'images/menu_icon.png'}, {u'type': u'bitmap', u'name': u'IMAGE_CUP', u'file': u'images/cup.png'}, {u'type': u'font', u'name': u'SANS_50', u'file': u'fonts/OpenSans.ttf'}]
SANDBOX = False
SUPPORTED_PLATFORMS = ['aplite', 'basalt', 'chalk', 'diorite', 'emery']
TARGET_PLATFORMS = ['emery', 'diorite', 'chalk', 'basalt', 'aplite']
TIMESTAMP = 1530641517
USE_GROUPS = True
VERBOSE = 0
WEBPACK = '/root/.pebble-sdk/SDKs/current/node_modules/.bin/webpack'
| bindir = '/usr/local/bin'
block_message_keys = []
build_type = 'app'
bundle_name = 'pebble-World-Cup.pbw'
defines = ['RELEASE']
libdir = '/usr/local/lib'
lib_dir = 'node_modules'
message_keys = {}
message_keys_header = '/root/hello-pebblejs/pebble-World-Cup/build/include/message_keys.auto.h'
node_path = '/root/.pebble-sdk/SDKs/current/node_modules'
pebble_sdk_common = '/root/.pebble-sdk/SDKs/current/sdk-core/pebble/common'
pebble_sdk_root = '/root/.pebble-sdk/SDKs/current/sdk-core/pebble'
prefix = '/usr/local'
project_info = {u'sdkVersion': u'3', u'uuid': u'133215f0-cf20-4c05-997b-3c9be5a64e5b', u'appKeys': {}, u'companyName': u'Araulin', 'messageKeys': {}, u'targetPlatforms': [u'aplite', u'basalt', u'chalk', u'diorite', u'emery'], u'capabilities': [u'configurable'], u'versionLabel': u'0.4', u'longName': u'World Cup', u'versionCode': 1, u'shortName': u'World Cup', u'watchapp': {u'watchface': False}, u'resources': {u'media': [{u'menuIcon': True, u'type': u'bitmap', u'name': u'IMAGE_MENU_ICON', u'file': u'images/menu_icon.png'}, {u'type': u'bitmap', u'name': u'IMAGE_CUP', u'file': u'images/cup.png'}, {u'type': u'font', u'name': u'SANS_50', u'file': u'fonts/OpenSans.ttf'}]}}
requested_platforms = [u'aplite', u'basalt', u'chalk', u'diorite', u'emery']
resources_json = [{u'menuIcon': True, u'type': u'bitmap', u'name': u'IMAGE_MENU_ICON', u'file': u'images/menu_icon.png'}, {u'type': u'bitmap', u'name': u'IMAGE_CUP', u'file': u'images/cup.png'}, {u'type': u'font', u'name': u'SANS_50', u'file': u'fonts/OpenSans.ttf'}]
sandbox = False
supported_platforms = ['aplite', 'basalt', 'chalk', 'diorite', 'emery']
target_platforms = ['emery', 'diorite', 'chalk', 'basalt', 'aplite']
timestamp = 1530641517
use_groups = True
verbose = 0
webpack = '/root/.pebble-sdk/SDKs/current/node_modules/.bin/webpack' |
# -*- coding: utf-8 -*-
__author__ = 'viruzzz-kun'
class OptionsFinish(Exception):
pass
| __author__ = 'viruzzz-kun'
class Optionsfinish(Exception):
pass |
cube = lambda x: pow(x,3)
def fibonacci(n):
if n >= 0:
lst = [0]
if n >= 1:
lst.append(1)
if n >= 2:
for i in range(2,n+1):
lst.append(lst[-1]+ lst[-2])
return lst[:n]
if __name__ == '__main__':
n = int(input())
print(list(map(cube, fibonacci(n)))) | cube = lambda x: pow(x, 3)
def fibonacci(n):
if n >= 0:
lst = [0]
if n >= 1:
lst.append(1)
if n >= 2:
for i in range(2, n + 1):
lst.append(lst[-1] + lst[-2])
return lst[:n]
if __name__ == '__main__':
n = int(input())
print(list(map(cube, fibonacci(n)))) |
def wire(data):
x, y = (0, 0)
for dir, step in [(x[0], int(x[1:])) for x in data.split(",")]:
for _ in range(step):
x += -1 if dir == "L" else 1 if dir == "R" else 0
y += -1 if dir == "D" else 1 if dir == "U" else 0
yield x, y
def aoc(data):
wires = [set(wire(line)) for line in data.split("\n")]
dist = set()
for cord in wires[0] | wires[1]:
if cord in wires[0] and cord in wires[1]:
dist.add(abs(cord[0]) + abs(cord[1]))
return min(dist)
| def wire(data):
(x, y) = (0, 0)
for (dir, step) in [(x[0], int(x[1:])) for x in data.split(',')]:
for _ in range(step):
x += -1 if dir == 'L' else 1 if dir == 'R' else 0
y += -1 if dir == 'D' else 1 if dir == 'U' else 0
yield (x, y)
def aoc(data):
wires = [set(wire(line)) for line in data.split('\n')]
dist = set()
for cord in wires[0] | wires[1]:
if cord in wires[0] and cord in wires[1]:
dist.add(abs(cord[0]) + abs(cord[1]))
return min(dist) |
def find_tree(row, index):
if index > len(row):
row = row * ((index // len(row)) + 1)
if row[index] == '#':
return 1
return 0
if __name__ == '__main__':
with open('input.txt') as f:
data = [r.strip() for r in f.readlines()]
indices = range(0, len(data) * 3, 3)
tree_count = 0
for row, i in zip(data, indices):
tree_count += find_tree(row, i)
print(f'Total trees: {tree_count}')
| def find_tree(row, index):
if index > len(row):
row = row * (index // len(row) + 1)
if row[index] == '#':
return 1
return 0
if __name__ == '__main__':
with open('input.txt') as f:
data = [r.strip() for r in f.readlines()]
indices = range(0, len(data) * 3, 3)
tree_count = 0
for (row, i) in zip(data, indices):
tree_count += find_tree(row, i)
print(f'Total trees: {tree_count}') |
class BufferToLines(object):
def __init__(self):
self._acc_buff = ""
self._last_line = ""
self._in_middle_of_line = False
def add(self, buff):
self._acc_buff += buff.decode()
self._in_middle_of_line = False if self._acc_buff[-1] == '\n' else True
def lines(self):
lines = self._acc_buff.split('\n')
up_to_index = len(lines) - 2 if self._in_middle_of_line else len(lines) - 1
self._acc_buff = lines[-1] if self._in_middle_of_line else ""
for iii in range(up_to_index):
yield lines[iii]
| class Buffertolines(object):
def __init__(self):
self._acc_buff = ''
self._last_line = ''
self._in_middle_of_line = False
def add(self, buff):
self._acc_buff += buff.decode()
self._in_middle_of_line = False if self._acc_buff[-1] == '\n' else True
def lines(self):
lines = self._acc_buff.split('\n')
up_to_index = len(lines) - 2 if self._in_middle_of_line else len(lines) - 1
self._acc_buff = lines[-1] if self._in_middle_of_line else ''
for iii in range(up_to_index):
yield lines[iii] |
GET_ACTION_LIST = 'get_action_list'
EXECUTE_ACTION = 'execute_action'
GET_FIELD_OPTIONS = 'get_field_options'
GET_ELEMENT_STATUS = 'get_element_status'
message_handlers = {}
def add_handler(message_name, func):
message_handlers[message_name] = func
def get_handler(message_name):
return message_handlers.get(message_name)
| get_action_list = 'get_action_list'
execute_action = 'execute_action'
get_field_options = 'get_field_options'
get_element_status = 'get_element_status'
message_handlers = {}
def add_handler(message_name, func):
message_handlers[message_name] = func
def get_handler(message_name):
return message_handlers.get(message_name) |
# Write a program that asks the number of kilometers a car has driven and the number of days it has been hired.
# Calculate the price to pay, knowing that the car costs US$ 60 per day and US$ 0.15 per km driven.
k = float(input('Enter how many kilometers the car has traveled: '))
d = float(input('Enter how many days the car has been rented: '))
t = (k * 0.15) + (d * 60)
print('The total rental of the car is {}US${:.2f}{}'.format('\033[1;31;40m', t, '\033[m'))
| k = float(input('Enter how many kilometers the car has traveled: '))
d = float(input('Enter how many days the car has been rented: '))
t = k * 0.15 + d * 60
print('The total rental of the car is {}US${:.2f}{}'.format('\x1b[1;31;40m', t, '\x1b[m')) |
class BaseMemory(object):
def __init__(self,
max_num=20000,
key_num=2000,
sampling_policy='random',
updating_policy='random', ):
super(BaseMemory, self).__init__()
self.max_num = max_num
self.key_num = key_num
self.sampling_policy = sampling_policy
self.updating_policy = updating_policy
self.feat = None
def reset(self):
self.feat = None
def init_memory(self, feat):
self.feat = feat
def sample(self):
raise NotImplementedError
def update(self, new_feat):
raise NotImplementedError
def __len__(self):
if self.feat is None:
return 0
return len(self.feat)
| class Basememory(object):
def __init__(self, max_num=20000, key_num=2000, sampling_policy='random', updating_policy='random'):
super(BaseMemory, self).__init__()
self.max_num = max_num
self.key_num = key_num
self.sampling_policy = sampling_policy
self.updating_policy = updating_policy
self.feat = None
def reset(self):
self.feat = None
def init_memory(self, feat):
self.feat = feat
def sample(self):
raise NotImplementedError
def update(self, new_feat):
raise NotImplementedError
def __len__(self):
if self.feat is None:
return 0
return len(self.feat) |
commands = input().split(" ")
my_list = []
team_a_count = 11
team_b_count = 11
condition = False
for i in commands:
if i not in my_list:
my_list.append(i)
if "A" in i:
team_a_count -= 1
if "B" in i:
team_b_count -= 1
if team_a_count < 7 or team_b_count < 7:
condition = True
break
print(f'Team A - {team_a_count}; Team B - {team_b_count}')
if condition:
print ("Game was terminated") | commands = input().split(' ')
my_list = []
team_a_count = 11
team_b_count = 11
condition = False
for i in commands:
if i not in my_list:
my_list.append(i)
if 'A' in i:
team_a_count -= 1
if 'B' in i:
team_b_count -= 1
if team_a_count < 7 or team_b_count < 7:
condition = True
break
print(f'Team A - {team_a_count}; Team B - {team_b_count}')
if condition:
print('Game was terminated') |
class ActivePlan(object):
def __init__(self, join_observer_list, on_next, on_completed):
self.join_observer_list = join_observer_list
self.on_next = on_next
self.on_completed = on_completed
self.join_observers = {}
for join_observer in self.join_observer_list:
self.join_observers[join_observer] = join_observer
def dequeue(self):
for join_observer in self.join_observers.values():
join_observer.queue.pop(0)
def match(self):
has_values = True
for join_observer in self.join_observer_list:
if not len(join_observer.queue):
has_values = False
break
if has_values:
first_values = []
is_completed = False
for join_observer in self.join_observer_list:
first_values.append(join_observer.queue[0])
if join_observer.queue[0].kind == 'C':
is_completed = True
if is_completed:
self.on_completed()
else:
self.dequeue()
values = []
for value in first_values:
values.append(value.value)
self.on_next(*values)
| class Activeplan(object):
def __init__(self, join_observer_list, on_next, on_completed):
self.join_observer_list = join_observer_list
self.on_next = on_next
self.on_completed = on_completed
self.join_observers = {}
for join_observer in self.join_observer_list:
self.join_observers[join_observer] = join_observer
def dequeue(self):
for join_observer in self.join_observers.values():
join_observer.queue.pop(0)
def match(self):
has_values = True
for join_observer in self.join_observer_list:
if not len(join_observer.queue):
has_values = False
break
if has_values:
first_values = []
is_completed = False
for join_observer in self.join_observer_list:
first_values.append(join_observer.queue[0])
if join_observer.queue[0].kind == 'C':
is_completed = True
if is_completed:
self.on_completed()
else:
self.dequeue()
values = []
for value in first_values:
values.append(value.value)
self.on_next(*values) |
COINS = (
(25, 'Quarters'),
(10, 'Dimes'),
(5, 'Nickels'),
(1, 'Pennies')
)
def loose_change(cents):
change = {'Pennies': 0, 'Nickels': 0, 'Dimes': 0, 'Quarters': 0}
cents = int(cents)
if cents <= 0:
return change
for coin_value, coin_name in COINS:
q, r = divmod(cents, coin_value)
change[coin_name] = q
cents = r
return change
| coins = ((25, 'Quarters'), (10, 'Dimes'), (5, 'Nickels'), (1, 'Pennies'))
def loose_change(cents):
change = {'Pennies': 0, 'Nickels': 0, 'Dimes': 0, 'Quarters': 0}
cents = int(cents)
if cents <= 0:
return change
for (coin_value, coin_name) in COINS:
(q, r) = divmod(cents, coin_value)
change[coin_name] = q
cents = r
return change |
'''input
97
89
20000
25899
10
5
8
10
97
89
8634
17266
97
89
8633
8633
100
100
101
200
1
1
1
1
1
1
20000
20000
100
100
20000
20000
12
8
25
48
2
3
8
12
2
2
2
2
'''
# -*- coding: utf-8 -*-
# AtCoder Beginner Contest
# Problem A
if __name__ == '__main__':
a = int(input())
b = int(input())
n = int(input())
# See:
# https://beta.atcoder.jp/contests/abc032/submissions/2264731
for i in range(n, 30000 + 1):
if i % a == 0 and i % b == 0:
print(i)
exit()
| """input
97
89
20000
25899
10
5
8
10
97
89
8634
17266
97
89
8633
8633
100
100
101
200
1
1
1
1
1
1
20000
20000
100
100
20000
20000
12
8
25
48
2
3
8
12
2
2
2
2
"""
if __name__ == '__main__':
a = int(input())
b = int(input())
n = int(input())
for i in range(n, 30000 + 1):
if i % a == 0 and i % b == 0:
print(i)
exit() |
def count_largest_group(n: int) -> int:
hash_ = {}
for i in range(1, n + 1):
num = i
count = 0
while num >= 10:
count += num % 10
num //= 10
count += num
if count in hash_:
hash_[count] += 1
else:
hash_[count] = 1
max_val = max(hash_.values())
ans = 0
for e in hash_.values():
if e == max_val:
ans += 1
return ans
if __name__ == '__main__':
print(count_largest_group(15)) | def count_largest_group(n: int) -> int:
hash_ = {}
for i in range(1, n + 1):
num = i
count = 0
while num >= 10:
count += num % 10
num //= 10
count += num
if count in hash_:
hash_[count] += 1
else:
hash_[count] = 1
max_val = max(hash_.values())
ans = 0
for e in hash_.values():
if e == max_val:
ans += 1
return ans
if __name__ == '__main__':
print(count_largest_group(15)) |
#Accept a list of words and return length of longest word.
def long_word(word_list):
word_len=[]
for word in word_list:
word_len.append((len(word),word))
word_len.sort()
return word_len[-1][0], word_len[-1][1]
word=long_word(["hai","everyone","bye"])
print("\nThe longest word is: ",word[1])
print("\nand the length of '",word[1],"' is: ",word[0]) | def long_word(word_list):
word_len = []
for word in word_list:
word_len.append((len(word), word))
word_len.sort()
return (word_len[-1][0], word_len[-1][1])
word = long_word(['hai', 'everyone', 'bye'])
print('\nThe longest word is: ', word[1])
print("\nand the length of '", word[1], "' is: ", word[0]) |
# 5-5 Problems
print(all([1, 2, abs(-3)-3]))
print(chr(ord('a')) == 'a')
x = [1, -2, 3, -5, 8, -3]
print(list(filter(lambda val: val > 0, x)))
x = hex(234)
print(int(x, 16))
x = [1, 2, 3, 4]
print(list(map(lambda a: a * 3, x)))
x = [-8, 2, 7, 5, -3, 5, 0, 1]
print(max(x) + min(x))
x = 17 / 3
print(round(x, 4)) | print(all([1, 2, abs(-3) - 3]))
print(chr(ord('a')) == 'a')
x = [1, -2, 3, -5, 8, -3]
print(list(filter(lambda val: val > 0, x)))
x = hex(234)
print(int(x, 16))
x = [1, 2, 3, 4]
print(list(map(lambda a: a * 3, x)))
x = [-8, 2, 7, 5, -3, 5, 0, 1]
print(max(x) + min(x))
x = 17 / 3
print(round(x, 4)) |
def get_max_profits(stock_prices):
if len(stock_prices) < 2:
raise ValueError("Getting a profit requires at least two prices")
min_price = stock_prices[0]
max_profit = stock_prices[1] - stock_prices[0]
for current_time in range(1, len(stock_prices)):
print(current_time, "currenttime")
current_price = stock_prices[current_time]
potential_profit = current_price - min_price
max_profit = max(max_profit, potential_profit)
min_price = min(min_price, current_price)
return max_profit
stock_prices = [10, 7, 5, 8, 11, 9]
print("max profit is:", get_max_profits(stock_prices))
| def get_max_profits(stock_prices):
if len(stock_prices) < 2:
raise value_error('Getting a profit requires at least two prices')
min_price = stock_prices[0]
max_profit = stock_prices[1] - stock_prices[0]
for current_time in range(1, len(stock_prices)):
print(current_time, 'currenttime')
current_price = stock_prices[current_time]
potential_profit = current_price - min_price
max_profit = max(max_profit, potential_profit)
min_price = min(min_price, current_price)
return max_profit
stock_prices = [10, 7, 5, 8, 11, 9]
print('max profit is:', get_max_profits(stock_prices)) |
# https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher
PLAINTEXT = 'ATTACKATDAWN'
KEY = 'LEMON'
def vigenere_cipher_func(key, message):
message = message.lower()
key = key.lower()
cipher_message = ''
key_value = 0
for char in message:
if ord(char) >= 97 and ord(char) < 134:
mi = ord(char) - 97
ki = ord(key[key_value % len(key)])
ci = (mi + ki - 97) % 26 + 97
cipher_message += chr(ci)
key_value += 1
else:
cipher_message += char
return cipher_message.upper()
def vigenere_decipher_func(key, message):
message = message.lower()
key = key.lower()
plain_messages = ''
key_value = 0
for char in message:
if ord(char) >= 97 and ord(char) < 134:
ci = ord(char) - 97
ki = ord(key[key_value % len(key)]) - 97
mi = (ci - ki) % 26 + 97
plain_messages += chr(mi)
key_value += 1
else:
plain_messages += char
return plain_messages.upper()
crypto_text = vigenere_cipher_func(KEY, PLAINTEXT)
decrypto_text = vigenere_decipher_func(KEY, crypto_text)
# tests
print(PLAINTEXT, ' + ', KEY, ' >> ', crypto_text)
print(crypto_text, ' - ', KEY, ' >> ', decrypto_text)
| plaintext = 'ATTACKATDAWN'
key = 'LEMON'
def vigenere_cipher_func(key, message):
message = message.lower()
key = key.lower()
cipher_message = ''
key_value = 0
for char in message:
if ord(char) >= 97 and ord(char) < 134:
mi = ord(char) - 97
ki = ord(key[key_value % len(key)])
ci = (mi + ki - 97) % 26 + 97
cipher_message += chr(ci)
key_value += 1
else:
cipher_message += char
return cipher_message.upper()
def vigenere_decipher_func(key, message):
message = message.lower()
key = key.lower()
plain_messages = ''
key_value = 0
for char in message:
if ord(char) >= 97 and ord(char) < 134:
ci = ord(char) - 97
ki = ord(key[key_value % len(key)]) - 97
mi = (ci - ki) % 26 + 97
plain_messages += chr(mi)
key_value += 1
else:
plain_messages += char
return plain_messages.upper()
crypto_text = vigenere_cipher_func(KEY, PLAINTEXT)
decrypto_text = vigenere_decipher_func(KEY, crypto_text)
print(PLAINTEXT, ' + ', KEY, ' >> ', crypto_text)
print(crypto_text, ' - ', KEY, ' >> ', decrypto_text) |
#
# PySNMP MIB module SVRNTCLU-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SVRNTCLU-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:04:39 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
Integer, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
SingleValueConstraint, ConstraintsUnion, ValueRangeConstraint, ValueSizeConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ConstraintsUnion", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsIntersection")
ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup")
Counter64, IpAddress, NotificationType, Bits, Gauge32, MibScalar, MibTable, MibTableRow, MibTableColumn, MibIdentifier, Counter32, TimeTicks, ModuleIdentity, Unsigned32, Integer32, enterprises, mgmt, iso, ObjectIdentity = mibBuilder.importSymbols("SNMPv2-SMI", "Counter64", "IpAddress", "NotificationType", "Bits", "Gauge32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "MibIdentifier", "Counter32", "TimeTicks", "ModuleIdentity", "Unsigned32", "Integer32", "enterprises", "mgmt", "iso", "ObjectIdentity")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
dec = MibIdentifier((1, 3, 6, 1, 4, 1, 36))
ema = MibIdentifier((1, 3, 6, 1, 4, 1, 36, 2))
class ObjectType(Integer32):
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7))
namedValues = NamedValues(("objectUnknown", 1), ("objectOther", 2), ("share", 3), ("disk", 4), ("application", 5), ("ipAddress", 6), ("fileShare", 7))
class PolicyType(Integer32):
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6))
namedValues = NamedValues(("policyUnknown", 1), ("policyOther", 2), ("inOrder", 3), ("random", 4), ("leastLoad", 5), ("roundRobin", 6))
class Boolean(Integer32):
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2))
namedValues = NamedValues(("true", 1), ("false", 2))
class DateAndTime(DisplayString):
pass
class FailoverReason(Integer32):
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))
namedValues = NamedValues(("reasonUnknown", 1), ("reasonOther", 2), ("reconfiguration", 3), ("failure", 4), ("failback", 5))
mib_extensions_1 = MibIdentifier((1, 3, 6, 1, 4, 1, 36, 2, 18)).setLabel("mib-extensions-1")
svrSystem = MibIdentifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22))
svrCluster = MibIdentifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4))
svrNTClu = MibIdentifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2))
svrNTCluObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1))
svrNTCluMibInfo = MibIdentifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 1))
svrNTCluClusterInfo = MibIdentifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2))
ntcExMgtMibMajorRev = MibScalar((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ntcExMgtMibMajorRev.setStatus('mandatory')
ntcExMgtMibMinorRev = MibScalar((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 1, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ntcExMgtMibMinorRev.setStatus('mandatory')
ntcExAlias = MibScalar((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 1), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ntcExAlias.setStatus('mandatory')
ntcExGroupTable = MibTable((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7), )
if mibBuilder.loadTexts: ntcExGroupTable.setStatus('mandatory')
ntcExGroupEntry = MibTableRow((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1), ).setIndexNames((0, "SVRNTCLU-MIB", "ntcExGroupIndex"))
if mibBuilder.loadTexts: ntcExGroupEntry.setStatus('mandatory')
ntcExGroupIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ntcExGroupIndex.setStatus('mandatory')
ntcExGroupName = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 2), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ntcExGroupName.setStatus('mandatory')
ntcExGroupComment = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 3), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ntcExGroupComment.setStatus('mandatory')
ntcExGroupOnLine = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 4), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ntcExGroupOnLine.setStatus('mandatory')
ntcExGroupFailedOver = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 5), Boolean()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ntcExGroupFailedOver.setStatus('mandatory')
ntcExGroupPolicy = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 6), PolicyType()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ntcExGroupPolicy.setStatus('mandatory')
ntcExGroupReevaluate = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 7), Boolean()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ntcExGroupReevaluate.setStatus('mandatory')
ntcExGroupMembers = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 8), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ntcExGroupMembers.setStatus('mandatory')
ntcExGroupObjects = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 9), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ntcExGroupObjects.setStatus('mandatory')
ntcExObjectTable = MibTable((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8), )
if mibBuilder.loadTexts: ntcExObjectTable.setStatus('mandatory')
ntcExObjectEntry = MibTableRow((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1), ).setIndexNames((0, "SVRNTCLU-MIB", "ntcExObjectIndex"))
if mibBuilder.loadTexts: ntcExObjectEntry.setStatus('mandatory')
ntcExObjectIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ntcExObjectIndex.setStatus('mandatory')
ntcExObjectName = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 2), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ntcExObjectName.setStatus('mandatory')
ntcExObjectComment = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 3), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ntcExObjectComment.setStatus('mandatory')
ntcExObjectType = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 4), ObjectType()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ntcExObjectType.setStatus('mandatory')
ntcExObjectDrives = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 5), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ntcExObjectDrives.setStatus('mandatory')
ntcExObjectIpAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 6), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ntcExObjectIpAddress.setStatus('mandatory')
mibBuilder.exportSymbols("SVRNTCLU-MIB", ntcExGroupName=ntcExGroupName, PolicyType=PolicyType, ntcExGroupComment=ntcExGroupComment, ntcExGroupMembers=ntcExGroupMembers, ntcExObjectEntry=ntcExObjectEntry, ntcExMgtMibMinorRev=ntcExMgtMibMinorRev, mib_extensions_1=mib_extensions_1, ntcExObjectDrives=ntcExObjectDrives, svrNTCluClusterInfo=svrNTCluClusterInfo, ntcExGroupTable=ntcExGroupTable, ntcExGroupOnLine=ntcExGroupOnLine, ntcExObjectIpAddress=ntcExObjectIpAddress, ntcExGroupFailedOver=ntcExGroupFailedOver, FailoverReason=FailoverReason, ntcExObjectComment=ntcExObjectComment, ema=ema, svrSystem=svrSystem, ntcExObjectType=ntcExObjectType, ntcExGroupIndex=ntcExGroupIndex, Boolean=Boolean, svrNTCluObjects=svrNTCluObjects, svrNTClu=svrNTClu, ntcExMgtMibMajorRev=ntcExMgtMibMajorRev, svrNTCluMibInfo=svrNTCluMibInfo, ntcExObjectIndex=ntcExObjectIndex, ntcExGroupReevaluate=ntcExGroupReevaluate, ntcExGroupEntry=ntcExGroupEntry, dec=dec, DateAndTime=DateAndTime, ntcExAlias=ntcExAlias, ntcExGroupPolicy=ntcExGroupPolicy, ntcExObjectTable=ntcExObjectTable, ObjectType=ObjectType, svrCluster=svrCluster, ntcExGroupObjects=ntcExGroupObjects, ntcExObjectName=ntcExObjectName)
| (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_union, value_range_constraint, value_size_constraint, constraints_intersection) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'SingleValueConstraint', 'ConstraintsUnion', 'ValueRangeConstraint', 'ValueSizeConstraint', 'ConstraintsIntersection')
(module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup')
(counter64, ip_address, notification_type, bits, gauge32, mib_scalar, mib_table, mib_table_row, mib_table_column, mib_identifier, counter32, time_ticks, module_identity, unsigned32, integer32, enterprises, mgmt, iso, object_identity) = mibBuilder.importSymbols('SNMPv2-SMI', 'Counter64', 'IpAddress', 'NotificationType', 'Bits', 'Gauge32', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'MibIdentifier', 'Counter32', 'TimeTicks', 'ModuleIdentity', 'Unsigned32', 'Integer32', 'enterprises', 'mgmt', 'iso', 'ObjectIdentity')
(display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention')
dec = mib_identifier((1, 3, 6, 1, 4, 1, 36))
ema = mib_identifier((1, 3, 6, 1, 4, 1, 36, 2))
class Objecttype(Integer32):
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7))
named_values = named_values(('objectUnknown', 1), ('objectOther', 2), ('share', 3), ('disk', 4), ('application', 5), ('ipAddress', 6), ('fileShare', 7))
class Policytype(Integer32):
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6))
named_values = named_values(('policyUnknown', 1), ('policyOther', 2), ('inOrder', 3), ('random', 4), ('leastLoad', 5), ('roundRobin', 6))
class Boolean(Integer32):
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2))
named_values = named_values(('true', 1), ('false', 2))
class Dateandtime(DisplayString):
pass
class Failoverreason(Integer32):
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5))
named_values = named_values(('reasonUnknown', 1), ('reasonOther', 2), ('reconfiguration', 3), ('failure', 4), ('failback', 5))
mib_extensions_1 = mib_identifier((1, 3, 6, 1, 4, 1, 36, 2, 18)).setLabel('mib-extensions-1')
svr_system = mib_identifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22))
svr_cluster = mib_identifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4))
svr_nt_clu = mib_identifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2))
svr_nt_clu_objects = mib_identifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1))
svr_nt_clu_mib_info = mib_identifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 1))
svr_nt_clu_cluster_info = mib_identifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2))
ntc_ex_mgt_mib_major_rev = mib_scalar((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 1, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ntcExMgtMibMajorRev.setStatus('mandatory')
ntc_ex_mgt_mib_minor_rev = mib_scalar((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 1, 2), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ntcExMgtMibMinorRev.setStatus('mandatory')
ntc_ex_alias = mib_scalar((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 1), display_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ntcExAlias.setStatus('mandatory')
ntc_ex_group_table = mib_table((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7))
if mibBuilder.loadTexts:
ntcExGroupTable.setStatus('mandatory')
ntc_ex_group_entry = mib_table_row((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1)).setIndexNames((0, 'SVRNTCLU-MIB', 'ntcExGroupIndex'))
if mibBuilder.loadTexts:
ntcExGroupEntry.setStatus('mandatory')
ntc_ex_group_index = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ntcExGroupIndex.setStatus('mandatory')
ntc_ex_group_name = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 2), display_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ntcExGroupName.setStatus('mandatory')
ntc_ex_group_comment = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 3), display_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ntcExGroupComment.setStatus('mandatory')
ntc_ex_group_on_line = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 4), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ntcExGroupOnLine.setStatus('mandatory')
ntc_ex_group_failed_over = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 5), boolean()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ntcExGroupFailedOver.setStatus('mandatory')
ntc_ex_group_policy = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 6), policy_type()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ntcExGroupPolicy.setStatus('mandatory')
ntc_ex_group_reevaluate = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 7), boolean()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ntcExGroupReevaluate.setStatus('mandatory')
ntc_ex_group_members = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 8), display_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ntcExGroupMembers.setStatus('mandatory')
ntc_ex_group_objects = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 9), display_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ntcExGroupObjects.setStatus('mandatory')
ntc_ex_object_table = mib_table((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8))
if mibBuilder.loadTexts:
ntcExObjectTable.setStatus('mandatory')
ntc_ex_object_entry = mib_table_row((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1)).setIndexNames((0, 'SVRNTCLU-MIB', 'ntcExObjectIndex'))
if mibBuilder.loadTexts:
ntcExObjectEntry.setStatus('mandatory')
ntc_ex_object_index = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ntcExObjectIndex.setStatus('mandatory')
ntc_ex_object_name = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 2), display_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ntcExObjectName.setStatus('mandatory')
ntc_ex_object_comment = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 3), display_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ntcExObjectComment.setStatus('mandatory')
ntc_ex_object_type = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 4), object_type()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ntcExObjectType.setStatus('mandatory')
ntc_ex_object_drives = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 5), display_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ntcExObjectDrives.setStatus('mandatory')
ntc_ex_object_ip_address = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 6), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ntcExObjectIpAddress.setStatus('mandatory')
mibBuilder.exportSymbols('SVRNTCLU-MIB', ntcExGroupName=ntcExGroupName, PolicyType=PolicyType, ntcExGroupComment=ntcExGroupComment, ntcExGroupMembers=ntcExGroupMembers, ntcExObjectEntry=ntcExObjectEntry, ntcExMgtMibMinorRev=ntcExMgtMibMinorRev, mib_extensions_1=mib_extensions_1, ntcExObjectDrives=ntcExObjectDrives, svrNTCluClusterInfo=svrNTCluClusterInfo, ntcExGroupTable=ntcExGroupTable, ntcExGroupOnLine=ntcExGroupOnLine, ntcExObjectIpAddress=ntcExObjectIpAddress, ntcExGroupFailedOver=ntcExGroupFailedOver, FailoverReason=FailoverReason, ntcExObjectComment=ntcExObjectComment, ema=ema, svrSystem=svrSystem, ntcExObjectType=ntcExObjectType, ntcExGroupIndex=ntcExGroupIndex, Boolean=Boolean, svrNTCluObjects=svrNTCluObjects, svrNTClu=svrNTClu, ntcExMgtMibMajorRev=ntcExMgtMibMajorRev, svrNTCluMibInfo=svrNTCluMibInfo, ntcExObjectIndex=ntcExObjectIndex, ntcExGroupReevaluate=ntcExGroupReevaluate, ntcExGroupEntry=ntcExGroupEntry, dec=dec, DateAndTime=DateAndTime, ntcExAlias=ntcExAlias, ntcExGroupPolicy=ntcExGroupPolicy, ntcExObjectTable=ntcExObjectTable, ObjectType=ObjectType, svrCluster=svrCluster, ntcExGroupObjects=ntcExGroupObjects, ntcExObjectName=ntcExObjectName) |
def iteritems(dictonary):
pass
class StringIO(object):
pass
| def iteritems(dictonary):
pass
class Stringio(object):
pass |
r= int(input())
pi= 3.14159
sphere= (4/3)* pi* pow(r,3)
print("VOLUME = %.3f" %sphere)
| r = int(input())
pi = 3.14159
sphere = 4 / 3 * pi * pow(r, 3)
print('VOLUME = %.3f' % sphere) |
class CoreConstraintConstants:
core_constraint_slots = (
"table", "constraint_name", "constraint_definition",
"UNIQUE", "PRIMARY_KEY", "FOREIGN_KEY", "REFERENCES",
"CHECK", "DEFAULT", "FOR"
)
core_constraint_default_values = {
"table": None,
"constraint_name": None,
"constraint_definition": "",
"UNIQUE": (),
"PRIMARY_KEY": (),
"FOREIGN_KEY": None,
"REFERENCES": None,
"CHECK": (),
"DEFAULT": None,
"FOR": None
}
| class Coreconstraintconstants:
core_constraint_slots = ('table', 'constraint_name', 'constraint_definition', 'UNIQUE', 'PRIMARY_KEY', 'FOREIGN_KEY', 'REFERENCES', 'CHECK', 'DEFAULT', 'FOR')
core_constraint_default_values = {'table': None, 'constraint_name': None, 'constraint_definition': '', 'UNIQUE': (), 'PRIMARY_KEY': (), 'FOREIGN_KEY': None, 'REFERENCES': None, 'CHECK': (), 'DEFAULT': None, 'FOR': None} |
# -*- coding: utf-8 -*-
COMMIT_AUTHOR_NAME = 'Mimiron'
COMMIT_AUTHOR_EMAIL = ''
| commit_author_name = 'Mimiron'
commit_author_email = '' |
#
# PySNMP MIB module IP-FORWARD-MIB (http://pysnmp.sf.net)
# ASN.1 source http://mibs.snmplabs.com:80/asn1/IP-FORWARD-MIB
# Produced by pysmi-0.0.7 at Sun Feb 14 00:17:45 2016
# On host bldfarm platform Linux version 4.1.13-100.fc21.x86_64 by user goose
# Using Python version 3.5.0 (default, Jan 5 2016, 17:11:52)
#
( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString")
( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
( ValueRangeConstraint, ValueSizeConstraint, ConstraintsIntersection, SingleValueConstraint, ConstraintsUnion, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsIntersection", "SingleValueConstraint", "ConstraintsUnion")
( IANAipRouteProtocol, ) = mibBuilder.importSymbols("IANA-RTPROTO-MIB", "IANAipRouteProtocol")
( InterfaceIndexOrZero, ) = mibBuilder.importSymbols("IF-MIB", "InterfaceIndexOrZero")
( InetAutonomousSystemNumber, InetAddressPrefixLength, InetAddressType, InetAddress, ) = mibBuilder.importSymbols("INET-ADDRESS-MIB", "InetAutonomousSystemNumber", "InetAddressPrefixLength", "InetAddressType", "InetAddress")
( ip, ) = mibBuilder.importSymbols("IP-MIB", "ip")
( ModuleCompliance, ObjectGroup, NotificationGroup, ) = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "ObjectGroup", "NotificationGroup")
( Unsigned32, ModuleIdentity, Gauge32, Counter64, MibIdentifier, iso, Counter32, NotificationType, ObjectIdentity, Bits, IpAddress, MibScalar, MibTable, MibTableRow, MibTableColumn, TimeTicks, Integer32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Unsigned32", "ModuleIdentity", "Gauge32", "Counter64", "MibIdentifier", "iso", "Counter32", "NotificationType", "ObjectIdentity", "Bits", "IpAddress", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "TimeTicks", "Integer32")
( RowStatus, TextualConvention, DisplayString, ) = mibBuilder.importSymbols("SNMPv2-TC", "RowStatus", "TextualConvention", "DisplayString")
ipForward = ModuleIdentity((1, 3, 6, 1, 2, 1, 4, 24)).setRevisions(("2006-02-01 00:00", "1996-09-19 00:00", "1992-07-02 21:56",))
if mibBuilder.loadTexts: ipForward.setLastUpdated('200602010000Z')
if mibBuilder.loadTexts: ipForward.setOrganization('IETF IPv6 Working Group\n http://www.ietf.org/html.charters/ipv6-charter.html')
if mibBuilder.loadTexts: ipForward.setContactInfo('Editor:\n Brian Haberman\n Johns Hopkins University - Applied Physics Laboratory\n Mailstop 17-S442\n 11100 Johns Hopkins Road\n Laurel MD, 20723-6099 USA\n\n Phone: +1-443-778-1319\n Email: brian@innovationslab.net\n\n Send comments to <ipv6@ietf.org>')
if mibBuilder.loadTexts: ipForward.setDescription('The MIB module for the management of CIDR multipath IP\n Routes.\n\n Copyright (C) The Internet Society (2006). This version\n of this MIB module is a part of RFC 4292; see the RFC\n itself for full legal notices.')
inetCidrRouteNumber = MibScalar((1, 3, 6, 1, 2, 1, 4, 24, 6), Gauge32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: inetCidrRouteNumber.setDescription('The number of current inetCidrRouteTable entries that\n are not invalid.')
inetCidrRouteDiscards = MibScalar((1, 3, 6, 1, 2, 1, 4, 24, 8), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: inetCidrRouteDiscards.setDescription('The number of valid route entries discarded from the\n inetCidrRouteTable. Discarded route entries do not\n appear in the inetCidrRouteTable. One possible reason\n for discarding an entry would be to free-up buffer space\n for other route table entries.')
inetCidrRouteTable = MibTable((1, 3, 6, 1, 2, 1, 4, 24, 7), )
if mibBuilder.loadTexts: inetCidrRouteTable.setDescription("This entity's IP Routing table.")
inetCidrRouteEntry = MibTableRow((1, 3, 6, 1, 2, 1, 4, 24, 7, 1), ).setIndexNames((0, "IP-FORWARD-MIB", "inetCidrRouteDestType"), (0, "IP-FORWARD-MIB", "inetCidrRouteDest"), (0, "IP-FORWARD-MIB", "inetCidrRoutePfxLen"), (0, "IP-FORWARD-MIB", "inetCidrRoutePolicy"), (0, "IP-FORWARD-MIB", "inetCidrRouteNextHopType"), (0, "IP-FORWARD-MIB", "inetCidrRouteNextHop"))
if mibBuilder.loadTexts: inetCidrRouteEntry.setDescription('A particular route to a particular destination, under a\n particular policy (as reflected in the\n inetCidrRoutePolicy object).\n\n Dynamically created rows will survive an agent reboot.\n\n Implementers need to be aware that if the total number\n of elements (octets or sub-identifiers) in\n inetCidrRouteDest, inetCidrRoutePolicy, and\n inetCidrRouteNextHop exceeds 111, then OIDs of column\n instances in this table will have more than 128 sub-\n identifiers and cannot be accessed using SNMPv1,\n SNMPv2c, or SNMPv3.')
inetCidrRouteDestType = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 1), InetAddressType())
if mibBuilder.loadTexts: inetCidrRouteDestType.setDescription('The type of the inetCidrRouteDest address, as defined\n in the InetAddress MIB.\n\n Only those address types that may appear in an actual\n routing table are allowed as values of this object.')
inetCidrRouteDest = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 2), InetAddress())
if mibBuilder.loadTexts: inetCidrRouteDest.setDescription('The destination IP address of this route.\n\n The type of this address is determined by the value of\n the inetCidrRouteDestType object.\n\n The values for the index objects inetCidrRouteDest and\n inetCidrRoutePfxLen must be consistent. When the value\n of inetCidrRouteDest (excluding the zone index, if one\n is present) is x, then the bitwise logical-AND\n of x with the value of the mask formed from the\n corresponding index object inetCidrRoutePfxLen MUST be\n equal to x. If not, then the index pair is not\n consistent and an inconsistentName error must be\n returned on SET or CREATE requests.')
inetCidrRoutePfxLen = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 3), InetAddressPrefixLength())
if mibBuilder.loadTexts: inetCidrRoutePfxLen.setDescription('Indicates the number of leading one bits that form the\n mask to be logical-ANDed with the destination address\n before being compared to the value in the\n inetCidrRouteDest field.\n The values for the index objects inetCidrRouteDest and\n inetCidrRoutePfxLen must be consistent. When the value\n of inetCidrRouteDest (excluding the zone index, if one\n is present) is x, then the bitwise logical-AND\n of x with the value of the mask formed from the\n corresponding index object inetCidrRoutePfxLen MUST be\n equal to x. If not, then the index pair is not\n consistent and an inconsistentName error must be\n returned on SET or CREATE requests.')
inetCidrRoutePolicy = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 4), ObjectIdentifier())
if mibBuilder.loadTexts: inetCidrRoutePolicy.setDescription('This object is an opaque object without any defined\n semantics. Its purpose is to serve as an additional\n index that may delineate between multiple entries to\n the same destination. The value { 0 0 } shall be used\n as the default value for this object.')
inetCidrRouteNextHopType = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 5), InetAddressType())
if mibBuilder.loadTexts: inetCidrRouteNextHopType.setDescription('The type of the inetCidrRouteNextHop address, as\n defined in the InetAddress MIB.\n\n Value should be set to unknown(0) for non-remote\n routes.\n\n Only those address types that may appear in an actual\n routing table are allowed as values of this object.')
inetCidrRouteNextHop = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 6), InetAddress())
if mibBuilder.loadTexts: inetCidrRouteNextHop.setDescription('On remote routes, the address of the next system en\n route. For non-remote routes, a zero length string.\n The type of this address is determined by the value of\n the inetCidrRouteNextHopType object.')
inetCidrRouteIfIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 7), InterfaceIndexOrZero()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: inetCidrRouteIfIndex.setDescription('The ifIndex value that identifies the local interface\n through which the next hop of this route should be\n reached. A value of 0 is valid and represents the\n scenario where no interface is specified.')
inetCidrRouteType = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 8), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5,))).clone(namedValues=NamedValues(("other", 1), ("reject", 2), ("local", 3), ("remote", 4), ("blackhole", 5),))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: inetCidrRouteType.setDescription('The type of route. Note that local(3) refers to a\n route for which the next hop is the final destination;\n remote(4) refers to a route for which the next hop is\n not the final destination.\n\n Routes that do not result in traffic forwarding or\n rejection should not be displayed, even if the\n implementation keeps them stored internally.\n\n reject(2) refers to a route that, if matched, discards\n the message as unreachable and returns a notification\n (e.g., ICMP error) to the message sender. This is used\n in some protocols as a means of correctly aggregating\n routes.\n\n blackhole(5) refers to a route that, if matched,\n discards the message silently.')
inetCidrRouteProto = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 9), IANAipRouteProtocol()).setMaxAccess("readonly")
if mibBuilder.loadTexts: inetCidrRouteProto.setDescription('The routing mechanism via which this route was learned.\n Inclusion of values for gateway routing protocols is\n not intended to imply that hosts should support those\n protocols.')
inetCidrRouteAge = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 10), Gauge32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: inetCidrRouteAge.setDescription("The number of seconds since this route was last updated\n or otherwise determined to be correct. Note that no\n semantics of 'too old' can be implied, except through\n knowledge of the routing protocol by which the route\n was learned.")
inetCidrRouteNextHopAS = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 11), InetAutonomousSystemNumber()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: inetCidrRouteNextHopAS.setDescription("The Autonomous System Number of the Next Hop. The\n semantics of this object are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. When this object is unknown or not relevant, its\n value should be set to zero.")
inetCidrRouteMetric1 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 12), Integer32().clone(-1)).setMaxAccess("readcreate")
if mibBuilder.loadTexts: inetCidrRouteMetric1.setDescription("The primary routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.")
inetCidrRouteMetric2 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 13), Integer32().clone(-1)).setMaxAccess("readcreate")
if mibBuilder.loadTexts: inetCidrRouteMetric2.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.")
inetCidrRouteMetric3 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 14), Integer32().clone(-1)).setMaxAccess("readcreate")
if mibBuilder.loadTexts: inetCidrRouteMetric3.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.")
inetCidrRouteMetric4 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 15), Integer32().clone(-1)).setMaxAccess("readcreate")
if mibBuilder.loadTexts: inetCidrRouteMetric4.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.")
inetCidrRouteMetric5 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 16), Integer32().clone(-1)).setMaxAccess("readcreate")
if mibBuilder.loadTexts: inetCidrRouteMetric5.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.")
inetCidrRouteStatus = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 17), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: inetCidrRouteStatus.setDescription('The row status variable, used according to row\n installation and removal conventions.\n\n A row entry cannot be modified when the status is\n marked as active(1).')
ipForwardConformance = MibIdentifier((1, 3, 6, 1, 2, 1, 4, 24, 5))
ipForwardGroups = MibIdentifier((1, 3, 6, 1, 2, 1, 4, 24, 5, 1))
ipForwardCompliances = MibIdentifier((1, 3, 6, 1, 2, 1, 4, 24, 5, 2))
ipForwardFullCompliance = ModuleCompliance((1, 3, 6, 1, 2, 1, 4, 24, 5, 2, 3)).setObjects(*(("IP-FORWARD-MIB", "inetForwardCidrRouteGroup"),))
if mibBuilder.loadTexts: ipForwardFullCompliance.setDescription('When this MIB is implemented for read-create, the\n implementation can claim full compliance.\n\n There are a number of INDEX objects that cannot be\n represented in the form of OBJECT clauses in SMIv2,\n but for which there are compliance requirements,\n expressed in OBJECT clause form in this description:\n\n -- OBJECT inetCidrRouteDestType\n -- SYNTAX InetAddressType (ipv4(1), ipv6(2),\n -- ipv4z(3), ipv6z(4))\n -- DESCRIPTION\n -- This MIB requires support for global and\n -- non-global ipv4 and ipv6 addresses.\n --\n -- OBJECT inetCidrRouteDest\n -- SYNTAX InetAddress (SIZE (4 | 8 | 16 | 20))\n -- DESCRIPTION\n -- This MIB requires support for global and\n -- non-global IPv4 and IPv6 addresses.\n --\n -- OBJECT inetCidrRouteNextHopType\n -- SYNTAX InetAddressType (unknown(0), ipv4(1),\n -- ipv6(2), ipv4z(3)\n -- ipv6z(4))\n -- DESCRIPTION\n -- This MIB requires support for global and\n -- non-global ipv4 and ipv6 addresses.\n --\n -- OBJECT inetCidrRouteNextHop\n -- SYNTAX InetAddress (SIZE (0 | 4 | 8 | 16 | 20))\n -- DESCRIPTION\n -- This MIB requires support for global and\n -- non-global IPv4 and IPv6 addresses.\n ')
ipForwardReadOnlyCompliance = ModuleCompliance((1, 3, 6, 1, 2, 1, 4, 24, 5, 2, 4)).setObjects(*(("IP-FORWARD-MIB", "inetForwardCidrRouteGroup"),))
if mibBuilder.loadTexts: ipForwardReadOnlyCompliance.setDescription('When this MIB is implemented without support for read-\n create (i.e., in read-only mode), the implementation can\n claim read-only compliance.')
inetForwardCidrRouteGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 4, 24, 5, 1, 4)).setObjects(*(("IP-FORWARD-MIB", "inetCidrRouteDiscards"), ("IP-FORWARD-MIB", "inetCidrRouteIfIndex"), ("IP-FORWARD-MIB", "inetCidrRouteType"), ("IP-FORWARD-MIB", "inetCidrRouteProto"), ("IP-FORWARD-MIB", "inetCidrRouteAge"), ("IP-FORWARD-MIB", "inetCidrRouteNextHopAS"), ("IP-FORWARD-MIB", "inetCidrRouteMetric1"), ("IP-FORWARD-MIB", "inetCidrRouteMetric2"), ("IP-FORWARD-MIB", "inetCidrRouteMetric3"), ("IP-FORWARD-MIB", "inetCidrRouteMetric4"), ("IP-FORWARD-MIB", "inetCidrRouteMetric5"), ("IP-FORWARD-MIB", "inetCidrRouteStatus"), ("IP-FORWARD-MIB", "inetCidrRouteNumber"),))
if mibBuilder.loadTexts: inetForwardCidrRouteGroup.setDescription('The IP version-independent CIDR Route Table.')
ipCidrRouteNumber = MibScalar((1, 3, 6, 1, 2, 1, 4, 24, 3), Gauge32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipCidrRouteNumber.setDescription('The number of current ipCidrRouteTable entries that are\n not invalid. This object is deprecated in favor of\n inetCidrRouteNumber and the inetCidrRouteTable.')
ipCidrRouteTable = MibTable((1, 3, 6, 1, 2, 1, 4, 24, 4), )
if mibBuilder.loadTexts: ipCidrRouteTable.setDescription("This entity's IP Routing table. This table has been\n deprecated in favor of the IP version neutral\n inetCidrRouteTable.")
ipCidrRouteEntry = MibTableRow((1, 3, 6, 1, 2, 1, 4, 24, 4, 1), ).setIndexNames((0, "IP-FORWARD-MIB", "ipCidrRouteDest"), (0, "IP-FORWARD-MIB", "ipCidrRouteMask"), (0, "IP-FORWARD-MIB", "ipCidrRouteTos"), (0, "IP-FORWARD-MIB", "ipCidrRouteNextHop"))
if mibBuilder.loadTexts: ipCidrRouteEntry.setDescription('A particular route to a particular destination, under a\n particular policy.')
ipCidrRouteDest = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 1), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipCidrRouteDest.setDescription('The destination IP address of this route.\n\n This object may not take a Multicast (Class D) address\n value.\n\n Any assignment (implicit or otherwise) of an instance\n of this object to a value x must be rejected if the\n bitwise logical-AND of x with the value of the\n corresponding instance of the ipCidrRouteMask object is\n not equal to x.')
ipCidrRouteMask = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 2), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipCidrRouteMask.setDescription('Indicate the mask to be logical-ANDed with the\n destination address before being compared to the value\n in the ipCidrRouteDest field. For those systems that\n do not support arbitrary subnet masks, an agent\n constructs the value of the ipCidrRouteMask by\n reference to the IP Address Class.\n\n Any assignment (implicit or otherwise) of an instance\n of this object to a value x must be rejected if the\n bitwise logical-AND of x with the value of the\n corresponding instance of the ipCidrRouteDest object is\n not equal to ipCidrRouteDest.')
ipCidrRouteTos = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0,2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipCidrRouteTos.setDescription('The policy specifier is the IP TOS Field. The encoding\n of IP TOS is as specified by the following convention.\n Zero indicates the default path if no more specific\n policy applies.\n\n +-----+-----+-----+-----+-----+-----+-----+-----+\n | | | |\n | PRECEDENCE | TYPE OF SERVICE | 0 |\n | | | |\n +-----+-----+-----+-----+-----+-----+-----+-----+\n\n IP TOS IP TOS\n Field Policy Field Policy\n Contents Code Contents Code\n 0 0 0 0 ==> 0 0 0 0 1 ==> 2\n 0 0 1 0 ==> 4 0 0 1 1 ==> 6\n 0 1 0 0 ==> 8 0 1 0 1 ==> 10\n 0 1 1 0 ==> 12 0 1 1 1 ==> 14\n 1 0 0 0 ==> 16 1 0 0 1 ==> 18\n 1 0 1 0 ==> 20 1 0 1 1 ==> 22\n 1 1 0 0 ==> 24 1 1 0 1 ==> 26\n 1 1 1 0 ==> 28 1 1 1 1 ==> 30')
ipCidrRouteNextHop = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 4), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipCidrRouteNextHop.setDescription('On remote routes, the address of the next system en\n route; Otherwise, 0.0.0.0.')
ipCidrRouteIfIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 5), Integer32()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: ipCidrRouteIfIndex.setDescription('The ifIndex value that identifies the local interface\n through which the next hop of this route should be\n reached.')
ipCidrRouteType = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4,))).clone(namedValues=NamedValues(("other", 1), ("reject", 2), ("local", 3), ("remote", 4),))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: ipCidrRouteType.setDescription('The type of route. Note that local(3) refers to a\n route for which the next hop is the final destination;\n remote(4) refers to a route for which the next hop is\n not the final destination.\n\n Routes that do not result in traffic forwarding or\n rejection should not be displayed, even if the\n implementation keeps them stored internally.\n\n reject (2) refers to a route that, if matched,\n discards the message as unreachable. This is used in\n some protocols as a means of correctly aggregating\n routes.')
ipCidrRouteProto = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,))).clone(namedValues=NamedValues(("other", 1), ("local", 2), ("netmgmt", 3), ("icmp", 4), ("egp", 5), ("ggp", 6), ("hello", 7), ("rip", 8), ("isIs", 9), ("esIs", 10), ("ciscoIgrp", 11), ("bbnSpfIgp", 12), ("ospf", 13), ("bgp", 14), ("idpr", 15), ("ciscoEigrp", 16),))).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipCidrRouteProto.setDescription('The routing mechanism via which this route was learned.\n Inclusion of values for gateway routing protocols is\n not intended to imply that hosts should support those\n protocols.')
ipCidrRouteAge = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 8), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipCidrRouteAge.setDescription("The number of seconds since this route was last updated\n or otherwise determined to be correct. Note that no\n semantics of `too old' can be implied, except through\n knowledge of the routing protocol by which the route\n was learned.")
ipCidrRouteInfo = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 9), ObjectIdentifier()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: ipCidrRouteInfo.setDescription("A reference to MIB definitions specific to the\n particular routing protocol that is responsible for\n this route, as determined by the value specified in the\n route's ipCidrRouteProto value. If this information is\n not present, its value should be set to the OBJECT\n IDENTIFIER { 0 0 }, which is a syntactically valid\n object identifier, and any implementation conforming to\n ASN.1 and the Basic Encoding Rules must be able to\n generate and recognize this value.")
ipCidrRouteNextHopAS = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 10), Integer32()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: ipCidrRouteNextHopAS.setDescription("The Autonomous System Number of the Next Hop. The\n semantics of this object are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. When this object is unknown or not relevant, its\n value should be set to zero.")
ipCidrRouteMetric1 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 11), Integer32().clone(-1)).setMaxAccess("readcreate")
if mibBuilder.loadTexts: ipCidrRouteMetric1.setDescription("The primary routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.")
ipCidrRouteMetric2 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 12), Integer32().clone(-1)).setMaxAccess("readcreate")
if mibBuilder.loadTexts: ipCidrRouteMetric2.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.")
ipCidrRouteMetric3 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 13), Integer32().clone(-1)).setMaxAccess("readcreate")
if mibBuilder.loadTexts: ipCidrRouteMetric3.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.")
ipCidrRouteMetric4 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 14), Integer32().clone(-1)).setMaxAccess("readcreate")
if mibBuilder.loadTexts: ipCidrRouteMetric4.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.")
ipCidrRouteMetric5 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 15), Integer32().clone(-1)).setMaxAccess("readcreate")
if mibBuilder.loadTexts: ipCidrRouteMetric5.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.")
ipCidrRouteStatus = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 16), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: ipCidrRouteStatus.setDescription('The row status variable, used according to row\n installation and removal conventions.')
ipForwardCompliance = ModuleCompliance((1, 3, 6, 1, 2, 1, 4, 24, 5, 2, 1)).setObjects(*(("IP-FORWARD-MIB", "ipForwardCidrRouteGroup"),))
if mibBuilder.loadTexts: ipForwardCompliance.setDescription('The compliance statement for SNMPv2 entities that\n implement the ipForward MIB.\n\n This compliance statement has been deprecated and\n replaced with ipForwardFullCompliance and\n ipForwardReadOnlyCompliance.')
ipForwardCidrRouteGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 4, 24, 5, 1, 3)).setObjects(*(("IP-FORWARD-MIB", "ipCidrRouteNumber"), ("IP-FORWARD-MIB", "ipCidrRouteDest"), ("IP-FORWARD-MIB", "ipCidrRouteMask"), ("IP-FORWARD-MIB", "ipCidrRouteTos"), ("IP-FORWARD-MIB", "ipCidrRouteNextHop"), ("IP-FORWARD-MIB", "ipCidrRouteIfIndex"), ("IP-FORWARD-MIB", "ipCidrRouteType"), ("IP-FORWARD-MIB", "ipCidrRouteProto"), ("IP-FORWARD-MIB", "ipCidrRouteAge"), ("IP-FORWARD-MIB", "ipCidrRouteInfo"), ("IP-FORWARD-MIB", "ipCidrRouteNextHopAS"), ("IP-FORWARD-MIB", "ipCidrRouteMetric1"), ("IP-FORWARD-MIB", "ipCidrRouteMetric2"), ("IP-FORWARD-MIB", "ipCidrRouteMetric3"), ("IP-FORWARD-MIB", "ipCidrRouteMetric4"), ("IP-FORWARD-MIB", "ipCidrRouteMetric5"), ("IP-FORWARD-MIB", "ipCidrRouteStatus"),))
if mibBuilder.loadTexts: ipForwardCidrRouteGroup.setDescription('The CIDR Route Table.\n\n This group has been deprecated and replaced with\n inetForwardCidrRouteGroup.')
ipForwardNumber = MibScalar((1, 3, 6, 1, 2, 1, 4, 24, 1), Gauge32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipForwardNumber.setDescription('The number of current ipForwardTable entries that are\n not invalid.')
ipForwardTable = MibTable((1, 3, 6, 1, 2, 1, 4, 24, 2), )
if mibBuilder.loadTexts: ipForwardTable.setDescription("This entity's IP Routing table.")
ipForwardEntry = MibTableRow((1, 3, 6, 1, 2, 1, 4, 24, 2, 1), ).setIndexNames((0, "IP-FORWARD-MIB", "ipForwardDest"), (0, "IP-FORWARD-MIB", "ipForwardProto"), (0, "IP-FORWARD-MIB", "ipForwardPolicy"), (0, "IP-FORWARD-MIB", "ipForwardNextHop"))
if mibBuilder.loadTexts: ipForwardEntry.setDescription('A particular route to a particular destination, under a\n particular policy.')
ipForwardDest = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 1), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipForwardDest.setDescription('The destination IP address of this route. An entry\n with a value of 0.0.0.0 is considered a default route.\n\n This object may not take a Multicast (Class D) address\n value.\n\n Any assignment (implicit or otherwise) of an instance\n of this object to a value x must be rejected if the\n bitwise logical-AND of x with the value of the\n corresponding instance of the ipForwardMask object is\n not equal to x.')
ipForwardMask = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 2), IpAddress().clone(hexValue="00000000")).setMaxAccess("readcreate")
if mibBuilder.loadTexts: ipForwardMask.setDescription('Indicate the mask to be logical-ANDed with the\n destination address before being compared to the value\n in the ipForwardDest field. For those systems that do\n not support arbitrary subnet masks, an agent constructs\n the value of the ipForwardMask by reference to the IP\n Address Class.\n\n Any assignment (implicit or otherwise) of an instance\n of this object to a value x must be rejected if the\n bitwise logical-AND of x with the value of the\n corresponding instance of the ipForwardDest object is\n not equal to ipForwardDest.')
ipForwardPolicy = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0,2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipForwardPolicy.setDescription("The general set of conditions that would cause\n the selection of one multipath route (set of\n next hops for a given destination) is referred\n to as 'policy'.\n\n Unless the mechanism indicated by ipForwardProto\n specifies otherwise, the policy specifier is\n the IP TOS Field. The encoding of IP TOS is as\n specified by the following convention. Zero\n indicates the default path if no more specific\n policy applies.\n\n +-----+-----+-----+-----+-----+-----+-----+-----+\n | | | |\n | PRECEDENCE | TYPE OF SERVICE | 0 |\n | | | |\n +-----+-----+-----+-----+-----+-----+-----+-----+\n\n IP TOS IP TOS\n Field Policy Field Policy\n Contents Code Contents Code\n 0 0 0 0 ==> 0 0 0 0 1 ==> 2\n 0 0 1 0 ==> 4 0 0 1 1 ==> 6\n 0 1 0 0 ==> 8 0 1 0 1 ==> 10\n 0 1 1 0 ==> 12 0 1 1 1 ==> 14\n 1 0 0 0 ==> 16 1 0 0 1 ==> 18\n 1 0 1 0 ==> 20 1 0 1 1 ==> 22\n 1 1 0 0 ==> 24 1 1 0 1 ==> 26\n 1 1 1 0 ==> 28 1 1 1 1 ==> 30\n\n Protocols defining 'policy' otherwise must either\n define a set of values that are valid for\n this object or must implement an integer-instanced\n policy table for which this object's\n value acts as an index.")
ipForwardNextHop = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 4), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipForwardNextHop.setDescription('On remote routes, the address of the next system en\n route; otherwise, 0.0.0.0.')
ipForwardIfIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 5), Integer32()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: ipForwardIfIndex.setDescription('The ifIndex value that identifies the local interface\n through which the next hop of this route should be\n reached.')
ipForwardType = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4,))).clone(namedValues=NamedValues(("other", 1), ("invalid", 2), ("local", 3), ("remote", 4),)).clone('invalid')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: ipForwardType.setDescription('The type of route. Note that local(3) refers to a\n route for which the next hop is the final destination;\n remote(4) refers to a route for which the next hop is\n not the final destination.\n\n Setting this object to the value invalid(2) has the\n effect of invalidating the corresponding entry in the\n ipForwardTable object. That is, it effectively\n disassociates the destination identified with said\n entry from the route identified with said entry. It is\n an implementation-specific matter as to whether the\n agent removes an invalidated entry from the table.\n Accordingly, management stations must be prepared to\n receive tabular information from agents that\n corresponds to entries not currently in use. Proper\n interpretation of such entries requires examination of\n the relevant ipForwardType object.')
ipForwardProto = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,))).clone(namedValues=NamedValues(("other", 1), ("local", 2), ("netmgmt", 3), ("icmp", 4), ("egp", 5), ("ggp", 6), ("hello", 7), ("rip", 8), ("is-is", 9), ("es-is", 10), ("ciscoIgrp", 11), ("bbnSpfIgp", 12), ("ospf", 13), ("bgp", 14), ("idpr", 15),))).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipForwardProto.setDescription('The routing mechanism via which this route was learned.\n Inclusion of values for gateway routing protocols is\n not intended to imply that hosts should support those\n protocols.')
ipForwardAge = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 8), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ipForwardAge.setDescription("The number of seconds since this route was last updated\n or otherwise determined to be correct. Note that no\n semantics of `too old' can be implied except through\n knowledge of the routing protocol by which the route\n was learned.")
ipForwardInfo = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 9), ObjectIdentifier()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: ipForwardInfo.setDescription("A reference to MIB definitions specific to the\n particular routing protocol that is responsible for\n this route, as determined by the value specified in the\n route's ipForwardProto value. If this information is\n not present, its value should be set to the OBJECT\n IDENTIFIER { 0 0 }, which is a syntactically valid\n object identifier, and any implementation conforming to\n ASN.1 and the Basic Encoding Rules must be able to\n generate and recognize this value.")
ipForwardNextHopAS = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 10), Integer32()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: ipForwardNextHopAS.setDescription('The Autonomous System Number of the Next Hop. When\n this is unknown or not relevant to the protocol\n indicated by ipForwardProto, zero.')
ipForwardMetric1 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 11), Integer32().clone(-1)).setMaxAccess("readcreate")
if mibBuilder.loadTexts: ipForwardMetric1.setDescription("The primary routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipForwardProto value.\n If this metric is not used, its value should be set to\n -1.")
ipForwardMetric2 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 12), Integer32().clone(-1)).setMaxAccess("readcreate")
if mibBuilder.loadTexts: ipForwardMetric2.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipForwardProto value.\n If this metric is not used, its value should be set to\n -1.")
ipForwardMetric3 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 13), Integer32().clone(-1)).setMaxAccess("readcreate")
if mibBuilder.loadTexts: ipForwardMetric3.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipForwardProto value.\n If this metric is not used, its value should be set to\n -1.")
ipForwardMetric4 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 14), Integer32().clone(-1)).setMaxAccess("readcreate")
if mibBuilder.loadTexts: ipForwardMetric4.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipForwardProto value.\n If this metric is not used, its value should be set to\n -1.")
ipForwardMetric5 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 15), Integer32().clone(-1)).setMaxAccess("readcreate")
if mibBuilder.loadTexts: ipForwardMetric5.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipForwardProto value.\n If this metric is not used, its value should be set to\n -1.")
ipForwardOldCompliance = ModuleCompliance((1, 3, 6, 1, 2, 1, 4, 24, 5, 2, 2)).setObjects(*(("IP-FORWARD-MIB", "ipForwardMultiPathGroup"),))
if mibBuilder.loadTexts: ipForwardOldCompliance.setDescription('The compliance statement for SNMP entities that\n implement the ipForward MIB.')
ipForwardMultiPathGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 4, 24, 5, 1, 2)).setObjects(*(("IP-FORWARD-MIB", "ipForwardNumber"), ("IP-FORWARD-MIB", "ipForwardDest"), ("IP-FORWARD-MIB", "ipForwardMask"), ("IP-FORWARD-MIB", "ipForwardPolicy"), ("IP-FORWARD-MIB", "ipForwardNextHop"), ("IP-FORWARD-MIB", "ipForwardIfIndex"), ("IP-FORWARD-MIB", "ipForwardType"), ("IP-FORWARD-MIB", "ipForwardProto"), ("IP-FORWARD-MIB", "ipForwardAge"), ("IP-FORWARD-MIB", "ipForwardInfo"), ("IP-FORWARD-MIB", "ipForwardNextHopAS"), ("IP-FORWARD-MIB", "ipForwardMetric1"), ("IP-FORWARD-MIB", "ipForwardMetric2"), ("IP-FORWARD-MIB", "ipForwardMetric3"), ("IP-FORWARD-MIB", "ipForwardMetric4"), ("IP-FORWARD-MIB", "ipForwardMetric5"),))
if mibBuilder.loadTexts: ipForwardMultiPathGroup.setDescription('IP Multipath Route Table.')
mibBuilder.exportSymbols("IP-FORWARD-MIB", inetCidrRouteAge=inetCidrRouteAge, ipForwardFullCompliance=ipForwardFullCompliance, inetCidrRouteDest=inetCidrRouteDest, ipCidrRouteInfo=ipCidrRouteInfo, ipForwardNextHop=ipForwardNextHop, ipForwardConformance=ipForwardConformance, PYSNMP_MODULE_ID=ipForward, inetCidrRouteMetric5=inetCidrRouteMetric5, inetCidrRouteEntry=inetCidrRouteEntry, inetCidrRouteIfIndex=inetCidrRouteIfIndex, ipForwardNextHopAS=ipForwardNextHopAS, ipCidrRouteIfIndex=ipCidrRouteIfIndex, inetCidrRouteMetric2=inetCidrRouteMetric2, ipForwardInfo=ipForwardInfo, ipForwardDest=ipForwardDest, inetCidrRouteMetric1=inetCidrRouteMetric1, ipForwardEntry=ipForwardEntry, inetCidrRouteNextHop=inetCidrRouteNextHop, ipCidrRouteNextHopAS=ipCidrRouteNextHopAS, ipCidrRouteNumber=ipCidrRouteNumber, ipForwardMask=ipForwardMask, ipForwardPolicy=ipForwardPolicy, ipCidrRouteProto=ipCidrRouteProto, ipCidrRouteMetric2=ipCidrRouteMetric2, ipForward=ipForward, ipCidrRouteMetric4=ipCidrRouteMetric4, inetForwardCidrRouteGroup=inetForwardCidrRouteGroup, ipForwardMetric3=ipForwardMetric3, ipForwardCompliances=ipForwardCompliances, ipForwardReadOnlyCompliance=ipForwardReadOnlyCompliance, ipCidrRouteMask=ipCidrRouteMask, ipForwardIfIndex=ipForwardIfIndex, ipForwardCompliance=ipForwardCompliance, ipCidrRouteMetric3=ipCidrRouteMetric3, ipForwardProto=ipForwardProto, ipForwardMetric4=ipForwardMetric4, inetCidrRouteDiscards=inetCidrRouteDiscards, ipCidrRouteNextHop=ipCidrRouteNextHop, ipForwardTable=ipForwardTable, ipCidrRouteAge=ipCidrRouteAge, inetCidrRouteNextHopAS=inetCidrRouteNextHopAS, inetCidrRouteTable=inetCidrRouteTable, inetCidrRoutePolicy=inetCidrRoutePolicy, ipCidrRouteType=ipCidrRouteType, ipForwardOldCompliance=ipForwardOldCompliance, ipForwardGroups=ipForwardGroups, ipForwardMetric1=ipForwardMetric1, ipForwardNumber=ipForwardNumber, inetCidrRouteProto=inetCidrRouteProto, ipForwardMetric2=ipForwardMetric2, ipForwardAge=ipForwardAge, inetCidrRouteMetric3=inetCidrRouteMetric3, inetCidrRoutePfxLen=inetCidrRoutePfxLen, ipCidrRouteEntry=ipCidrRouteEntry, ipCidrRouteMetric5=ipCidrRouteMetric5, ipForwardType=ipForwardType, ipCidrRouteTable=ipCidrRouteTable, ipForwardMultiPathGroup=ipForwardMultiPathGroup, inetCidrRouteStatus=inetCidrRouteStatus, ipCidrRouteDest=ipCidrRouteDest, ipForwardMetric5=ipForwardMetric5, ipCidrRouteTos=ipCidrRouteTos, inetCidrRouteType=inetCidrRouteType, inetCidrRouteNumber=inetCidrRouteNumber, ipCidrRouteStatus=ipCidrRouteStatus, ipForwardCidrRouteGroup=ipForwardCidrRouteGroup, ipCidrRouteMetric1=ipCidrRouteMetric1, inetCidrRouteMetric4=inetCidrRouteMetric4, inetCidrRouteNextHopType=inetCidrRouteNextHopType, inetCidrRouteDestType=inetCidrRouteDestType)
| (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, value_size_constraint, constraints_intersection, single_value_constraint, constraints_union) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueRangeConstraint', 'ValueSizeConstraint', 'ConstraintsIntersection', 'SingleValueConstraint', 'ConstraintsUnion')
(ian_aip_route_protocol,) = mibBuilder.importSymbols('IANA-RTPROTO-MIB', 'IANAipRouteProtocol')
(interface_index_or_zero,) = mibBuilder.importSymbols('IF-MIB', 'InterfaceIndexOrZero')
(inet_autonomous_system_number, inet_address_prefix_length, inet_address_type, inet_address) = mibBuilder.importSymbols('INET-ADDRESS-MIB', 'InetAutonomousSystemNumber', 'InetAddressPrefixLength', 'InetAddressType', 'InetAddress')
(ip,) = mibBuilder.importSymbols('IP-MIB', 'ip')
(module_compliance, object_group, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'ObjectGroup', 'NotificationGroup')
(unsigned32, module_identity, gauge32, counter64, mib_identifier, iso, counter32, notification_type, object_identity, bits, ip_address, mib_scalar, mib_table, mib_table_row, mib_table_column, time_ticks, integer32) = mibBuilder.importSymbols('SNMPv2-SMI', 'Unsigned32', 'ModuleIdentity', 'Gauge32', 'Counter64', 'MibIdentifier', 'iso', 'Counter32', 'NotificationType', 'ObjectIdentity', 'Bits', 'IpAddress', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'TimeTicks', 'Integer32')
(row_status, textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'RowStatus', 'TextualConvention', 'DisplayString')
ip_forward = module_identity((1, 3, 6, 1, 2, 1, 4, 24)).setRevisions(('2006-02-01 00:00', '1996-09-19 00:00', '1992-07-02 21:56'))
if mibBuilder.loadTexts:
ipForward.setLastUpdated('200602010000Z')
if mibBuilder.loadTexts:
ipForward.setOrganization('IETF IPv6 Working Group\n http://www.ietf.org/html.charters/ipv6-charter.html')
if mibBuilder.loadTexts:
ipForward.setContactInfo('Editor:\n Brian Haberman\n Johns Hopkins University - Applied Physics Laboratory\n Mailstop 17-S442\n 11100 Johns Hopkins Road\n Laurel MD, 20723-6099 USA\n\n Phone: +1-443-778-1319\n Email: brian@innovationslab.net\n\n Send comments to <ipv6@ietf.org>')
if mibBuilder.loadTexts:
ipForward.setDescription('The MIB module for the management of CIDR multipath IP\n Routes.\n\n Copyright (C) The Internet Society (2006). This version\n of this MIB module is a part of RFC 4292; see the RFC\n itself for full legal notices.')
inet_cidr_route_number = mib_scalar((1, 3, 6, 1, 2, 1, 4, 24, 6), gauge32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
inetCidrRouteNumber.setDescription('The number of current inetCidrRouteTable entries that\n are not invalid.')
inet_cidr_route_discards = mib_scalar((1, 3, 6, 1, 2, 1, 4, 24, 8), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
inetCidrRouteDiscards.setDescription('The number of valid route entries discarded from the\n inetCidrRouteTable. Discarded route entries do not\n appear in the inetCidrRouteTable. One possible reason\n for discarding an entry would be to free-up buffer space\n for other route table entries.')
inet_cidr_route_table = mib_table((1, 3, 6, 1, 2, 1, 4, 24, 7))
if mibBuilder.loadTexts:
inetCidrRouteTable.setDescription("This entity's IP Routing table.")
inet_cidr_route_entry = mib_table_row((1, 3, 6, 1, 2, 1, 4, 24, 7, 1)).setIndexNames((0, 'IP-FORWARD-MIB', 'inetCidrRouteDestType'), (0, 'IP-FORWARD-MIB', 'inetCidrRouteDest'), (0, 'IP-FORWARD-MIB', 'inetCidrRoutePfxLen'), (0, 'IP-FORWARD-MIB', 'inetCidrRoutePolicy'), (0, 'IP-FORWARD-MIB', 'inetCidrRouteNextHopType'), (0, 'IP-FORWARD-MIB', 'inetCidrRouteNextHop'))
if mibBuilder.loadTexts:
inetCidrRouteEntry.setDescription('A particular route to a particular destination, under a\n particular policy (as reflected in the\n inetCidrRoutePolicy object).\n\n Dynamically created rows will survive an agent reboot.\n\n Implementers need to be aware that if the total number\n of elements (octets or sub-identifiers) in\n inetCidrRouteDest, inetCidrRoutePolicy, and\n inetCidrRouteNextHop exceeds 111, then OIDs of column\n instances in this table will have more than 128 sub-\n identifiers and cannot be accessed using SNMPv1,\n SNMPv2c, or SNMPv3.')
inet_cidr_route_dest_type = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 1), inet_address_type())
if mibBuilder.loadTexts:
inetCidrRouteDestType.setDescription('The type of the inetCidrRouteDest address, as defined\n in the InetAddress MIB.\n\n Only those address types that may appear in an actual\n routing table are allowed as values of this object.')
inet_cidr_route_dest = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 2), inet_address())
if mibBuilder.loadTexts:
inetCidrRouteDest.setDescription('The destination IP address of this route.\n\n The type of this address is determined by the value of\n the inetCidrRouteDestType object.\n\n The values for the index objects inetCidrRouteDest and\n inetCidrRoutePfxLen must be consistent. When the value\n of inetCidrRouteDest (excluding the zone index, if one\n is present) is x, then the bitwise logical-AND\n of x with the value of the mask formed from the\n corresponding index object inetCidrRoutePfxLen MUST be\n equal to x. If not, then the index pair is not\n consistent and an inconsistentName error must be\n returned on SET or CREATE requests.')
inet_cidr_route_pfx_len = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 3), inet_address_prefix_length())
if mibBuilder.loadTexts:
inetCidrRoutePfxLen.setDescription('Indicates the number of leading one bits that form the\n mask to be logical-ANDed with the destination address\n before being compared to the value in the\n inetCidrRouteDest field.\n The values for the index objects inetCidrRouteDest and\n inetCidrRoutePfxLen must be consistent. When the value\n of inetCidrRouteDest (excluding the zone index, if one\n is present) is x, then the bitwise logical-AND\n of x with the value of the mask formed from the\n corresponding index object inetCidrRoutePfxLen MUST be\n equal to x. If not, then the index pair is not\n consistent and an inconsistentName error must be\n returned on SET or CREATE requests.')
inet_cidr_route_policy = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 4), object_identifier())
if mibBuilder.loadTexts:
inetCidrRoutePolicy.setDescription('This object is an opaque object without any defined\n semantics. Its purpose is to serve as an additional\n index that may delineate between multiple entries to\n the same destination. The value { 0 0 } shall be used\n as the default value for this object.')
inet_cidr_route_next_hop_type = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 5), inet_address_type())
if mibBuilder.loadTexts:
inetCidrRouteNextHopType.setDescription('The type of the inetCidrRouteNextHop address, as\n defined in the InetAddress MIB.\n\n Value should be set to unknown(0) for non-remote\n routes.\n\n Only those address types that may appear in an actual\n routing table are allowed as values of this object.')
inet_cidr_route_next_hop = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 6), inet_address())
if mibBuilder.loadTexts:
inetCidrRouteNextHop.setDescription('On remote routes, the address of the next system en\n route. For non-remote routes, a zero length string.\n The type of this address is determined by the value of\n the inetCidrRouteNextHopType object.')
inet_cidr_route_if_index = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 7), interface_index_or_zero()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
inetCidrRouteIfIndex.setDescription('The ifIndex value that identifies the local interface\n through which the next hop of this route should be\n reached. A value of 0 is valid and represents the\n scenario where no interface is specified.')
inet_cidr_route_type = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 8), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('other', 1), ('reject', 2), ('local', 3), ('remote', 4), ('blackhole', 5)))).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
inetCidrRouteType.setDescription('The type of route. Note that local(3) refers to a\n route for which the next hop is the final destination;\n remote(4) refers to a route for which the next hop is\n not the final destination.\n\n Routes that do not result in traffic forwarding or\n rejection should not be displayed, even if the\n implementation keeps them stored internally.\n\n reject(2) refers to a route that, if matched, discards\n the message as unreachable and returns a notification\n (e.g., ICMP error) to the message sender. This is used\n in some protocols as a means of correctly aggregating\n routes.\n\n blackhole(5) refers to a route that, if matched,\n discards the message silently.')
inet_cidr_route_proto = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 9), ian_aip_route_protocol()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
inetCidrRouteProto.setDescription('The routing mechanism via which this route was learned.\n Inclusion of values for gateway routing protocols is\n not intended to imply that hosts should support those\n protocols.')
inet_cidr_route_age = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 10), gauge32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
inetCidrRouteAge.setDescription("The number of seconds since this route was last updated\n or otherwise determined to be correct. Note that no\n semantics of 'too old' can be implied, except through\n knowledge of the routing protocol by which the route\n was learned.")
inet_cidr_route_next_hop_as = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 11), inet_autonomous_system_number()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
inetCidrRouteNextHopAS.setDescription("The Autonomous System Number of the Next Hop. The\n semantics of this object are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. When this object is unknown or not relevant, its\n value should be set to zero.")
inet_cidr_route_metric1 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 12), integer32().clone(-1)).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
inetCidrRouteMetric1.setDescription("The primary routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.")
inet_cidr_route_metric2 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 13), integer32().clone(-1)).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
inetCidrRouteMetric2.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.")
inet_cidr_route_metric3 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 14), integer32().clone(-1)).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
inetCidrRouteMetric3.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.")
inet_cidr_route_metric4 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 15), integer32().clone(-1)).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
inetCidrRouteMetric4.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.")
inet_cidr_route_metric5 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 16), integer32().clone(-1)).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
inetCidrRouteMetric5.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.")
inet_cidr_route_status = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 17), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
inetCidrRouteStatus.setDescription('The row status variable, used according to row\n installation and removal conventions.\n\n A row entry cannot be modified when the status is\n marked as active(1).')
ip_forward_conformance = mib_identifier((1, 3, 6, 1, 2, 1, 4, 24, 5))
ip_forward_groups = mib_identifier((1, 3, 6, 1, 2, 1, 4, 24, 5, 1))
ip_forward_compliances = mib_identifier((1, 3, 6, 1, 2, 1, 4, 24, 5, 2))
ip_forward_full_compliance = module_compliance((1, 3, 6, 1, 2, 1, 4, 24, 5, 2, 3)).setObjects(*(('IP-FORWARD-MIB', 'inetForwardCidrRouteGroup'),))
if mibBuilder.loadTexts:
ipForwardFullCompliance.setDescription('When this MIB is implemented for read-create, the\n implementation can claim full compliance.\n\n There are a number of INDEX objects that cannot be\n represented in the form of OBJECT clauses in SMIv2,\n but for which there are compliance requirements,\n expressed in OBJECT clause form in this description:\n\n -- OBJECT inetCidrRouteDestType\n -- SYNTAX InetAddressType (ipv4(1), ipv6(2),\n -- ipv4z(3), ipv6z(4))\n -- DESCRIPTION\n -- This MIB requires support for global and\n -- non-global ipv4 and ipv6 addresses.\n --\n -- OBJECT inetCidrRouteDest\n -- SYNTAX InetAddress (SIZE (4 | 8 | 16 | 20))\n -- DESCRIPTION\n -- This MIB requires support for global and\n -- non-global IPv4 and IPv6 addresses.\n --\n -- OBJECT inetCidrRouteNextHopType\n -- SYNTAX InetAddressType (unknown(0), ipv4(1),\n -- ipv6(2), ipv4z(3)\n -- ipv6z(4))\n -- DESCRIPTION\n -- This MIB requires support for global and\n -- non-global ipv4 and ipv6 addresses.\n --\n -- OBJECT inetCidrRouteNextHop\n -- SYNTAX InetAddress (SIZE (0 | 4 | 8 | 16 | 20))\n -- DESCRIPTION\n -- This MIB requires support for global and\n -- non-global IPv4 and IPv6 addresses.\n ')
ip_forward_read_only_compliance = module_compliance((1, 3, 6, 1, 2, 1, 4, 24, 5, 2, 4)).setObjects(*(('IP-FORWARD-MIB', 'inetForwardCidrRouteGroup'),))
if mibBuilder.loadTexts:
ipForwardReadOnlyCompliance.setDescription('When this MIB is implemented without support for read-\n create (i.e., in read-only mode), the implementation can\n claim read-only compliance.')
inet_forward_cidr_route_group = object_group((1, 3, 6, 1, 2, 1, 4, 24, 5, 1, 4)).setObjects(*(('IP-FORWARD-MIB', 'inetCidrRouteDiscards'), ('IP-FORWARD-MIB', 'inetCidrRouteIfIndex'), ('IP-FORWARD-MIB', 'inetCidrRouteType'), ('IP-FORWARD-MIB', 'inetCidrRouteProto'), ('IP-FORWARD-MIB', 'inetCidrRouteAge'), ('IP-FORWARD-MIB', 'inetCidrRouteNextHopAS'), ('IP-FORWARD-MIB', 'inetCidrRouteMetric1'), ('IP-FORWARD-MIB', 'inetCidrRouteMetric2'), ('IP-FORWARD-MIB', 'inetCidrRouteMetric3'), ('IP-FORWARD-MIB', 'inetCidrRouteMetric4'), ('IP-FORWARD-MIB', 'inetCidrRouteMetric5'), ('IP-FORWARD-MIB', 'inetCidrRouteStatus'), ('IP-FORWARD-MIB', 'inetCidrRouteNumber')))
if mibBuilder.loadTexts:
inetForwardCidrRouteGroup.setDescription('The IP version-independent CIDR Route Table.')
ip_cidr_route_number = mib_scalar((1, 3, 6, 1, 2, 1, 4, 24, 3), gauge32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ipCidrRouteNumber.setDescription('The number of current ipCidrRouteTable entries that are\n not invalid. This object is deprecated in favor of\n inetCidrRouteNumber and the inetCidrRouteTable.')
ip_cidr_route_table = mib_table((1, 3, 6, 1, 2, 1, 4, 24, 4))
if mibBuilder.loadTexts:
ipCidrRouteTable.setDescription("This entity's IP Routing table. This table has been\n deprecated in favor of the IP version neutral\n inetCidrRouteTable.")
ip_cidr_route_entry = mib_table_row((1, 3, 6, 1, 2, 1, 4, 24, 4, 1)).setIndexNames((0, 'IP-FORWARD-MIB', 'ipCidrRouteDest'), (0, 'IP-FORWARD-MIB', 'ipCidrRouteMask'), (0, 'IP-FORWARD-MIB', 'ipCidrRouteTos'), (0, 'IP-FORWARD-MIB', 'ipCidrRouteNextHop'))
if mibBuilder.loadTexts:
ipCidrRouteEntry.setDescription('A particular route to a particular destination, under a\n particular policy.')
ip_cidr_route_dest = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 1), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ipCidrRouteDest.setDescription('The destination IP address of this route.\n\n This object may not take a Multicast (Class D) address\n value.\n\n Any assignment (implicit or otherwise) of an instance\n of this object to a value x must be rejected if the\n bitwise logical-AND of x with the value of the\n corresponding instance of the ipCidrRouteMask object is\n not equal to x.')
ip_cidr_route_mask = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 2), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ipCidrRouteMask.setDescription('Indicate the mask to be logical-ANDed with the\n destination address before being compared to the value\n in the ipCidrRouteDest field. For those systems that\n do not support arbitrary subnet masks, an agent\n constructs the value of the ipCidrRouteMask by\n reference to the IP Address Class.\n\n Any assignment (implicit or otherwise) of an instance\n of this object to a value x must be rejected if the\n bitwise logical-AND of x with the value of the\n corresponding instance of the ipCidrRouteDest object is\n not equal to ipCidrRouteDest.')
ip_cidr_route_tos = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 3), integer32().subtype(subtypeSpec=value_range_constraint(0, 2147483647))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ipCidrRouteTos.setDescription('The policy specifier is the IP TOS Field. The encoding\n of IP TOS is as specified by the following convention.\n Zero indicates the default path if no more specific\n policy applies.\n\n +-----+-----+-----+-----+-----+-----+-----+-----+\n | | | |\n | PRECEDENCE | TYPE OF SERVICE | 0 |\n | | | |\n +-----+-----+-----+-----+-----+-----+-----+-----+\n\n IP TOS IP TOS\n Field Policy Field Policy\n Contents Code Contents Code\n 0 0 0 0 ==> 0 0 0 0 1 ==> 2\n 0 0 1 0 ==> 4 0 0 1 1 ==> 6\n 0 1 0 0 ==> 8 0 1 0 1 ==> 10\n 0 1 1 0 ==> 12 0 1 1 1 ==> 14\n 1 0 0 0 ==> 16 1 0 0 1 ==> 18\n 1 0 1 0 ==> 20 1 0 1 1 ==> 22\n 1 1 0 0 ==> 24 1 1 0 1 ==> 26\n 1 1 1 0 ==> 28 1 1 1 1 ==> 30')
ip_cidr_route_next_hop = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 4), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ipCidrRouteNextHop.setDescription('On remote routes, the address of the next system en\n route; Otherwise, 0.0.0.0.')
ip_cidr_route_if_index = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 5), integer32()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
ipCidrRouteIfIndex.setDescription('The ifIndex value that identifies the local interface\n through which the next hop of this route should be\n reached.')
ip_cidr_route_type = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('reject', 2), ('local', 3), ('remote', 4)))).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
ipCidrRouteType.setDescription('The type of route. Note that local(3) refers to a\n route for which the next hop is the final destination;\n remote(4) refers to a route for which the next hop is\n not the final destination.\n\n Routes that do not result in traffic forwarding or\n rejection should not be displayed, even if the\n implementation keeps them stored internally.\n\n reject (2) refers to a route that, if matched,\n discards the message as unreachable. This is used in\n some protocols as a means of correctly aggregating\n routes.')
ip_cidr_route_proto = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16))).clone(namedValues=named_values(('other', 1), ('local', 2), ('netmgmt', 3), ('icmp', 4), ('egp', 5), ('ggp', 6), ('hello', 7), ('rip', 8), ('isIs', 9), ('esIs', 10), ('ciscoIgrp', 11), ('bbnSpfIgp', 12), ('ospf', 13), ('bgp', 14), ('idpr', 15), ('ciscoEigrp', 16)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ipCidrRouteProto.setDescription('The routing mechanism via which this route was learned.\n Inclusion of values for gateway routing protocols is\n not intended to imply that hosts should support those\n protocols.')
ip_cidr_route_age = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 8), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ipCidrRouteAge.setDescription("The number of seconds since this route was last updated\n or otherwise determined to be correct. Note that no\n semantics of `too old' can be implied, except through\n knowledge of the routing protocol by which the route\n was learned.")
ip_cidr_route_info = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 9), object_identifier()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
ipCidrRouteInfo.setDescription("A reference to MIB definitions specific to the\n particular routing protocol that is responsible for\n this route, as determined by the value specified in the\n route's ipCidrRouteProto value. If this information is\n not present, its value should be set to the OBJECT\n IDENTIFIER { 0 0 }, which is a syntactically valid\n object identifier, and any implementation conforming to\n ASN.1 and the Basic Encoding Rules must be able to\n generate and recognize this value.")
ip_cidr_route_next_hop_as = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 10), integer32()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
ipCidrRouteNextHopAS.setDescription("The Autonomous System Number of the Next Hop. The\n semantics of this object are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. When this object is unknown or not relevant, its\n value should be set to zero.")
ip_cidr_route_metric1 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 11), integer32().clone(-1)).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
ipCidrRouteMetric1.setDescription("The primary routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.")
ip_cidr_route_metric2 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 12), integer32().clone(-1)).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
ipCidrRouteMetric2.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.")
ip_cidr_route_metric3 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 13), integer32().clone(-1)).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
ipCidrRouteMetric3.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.")
ip_cidr_route_metric4 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 14), integer32().clone(-1)).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
ipCidrRouteMetric4.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.")
ip_cidr_route_metric5 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 15), integer32().clone(-1)).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
ipCidrRouteMetric5.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.")
ip_cidr_route_status = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 16), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
ipCidrRouteStatus.setDescription('The row status variable, used according to row\n installation and removal conventions.')
ip_forward_compliance = module_compliance((1, 3, 6, 1, 2, 1, 4, 24, 5, 2, 1)).setObjects(*(('IP-FORWARD-MIB', 'ipForwardCidrRouteGroup'),))
if mibBuilder.loadTexts:
ipForwardCompliance.setDescription('The compliance statement for SNMPv2 entities that\n implement the ipForward MIB.\n\n This compliance statement has been deprecated and\n replaced with ipForwardFullCompliance and\n ipForwardReadOnlyCompliance.')
ip_forward_cidr_route_group = object_group((1, 3, 6, 1, 2, 1, 4, 24, 5, 1, 3)).setObjects(*(('IP-FORWARD-MIB', 'ipCidrRouteNumber'), ('IP-FORWARD-MIB', 'ipCidrRouteDest'), ('IP-FORWARD-MIB', 'ipCidrRouteMask'), ('IP-FORWARD-MIB', 'ipCidrRouteTos'), ('IP-FORWARD-MIB', 'ipCidrRouteNextHop'), ('IP-FORWARD-MIB', 'ipCidrRouteIfIndex'), ('IP-FORWARD-MIB', 'ipCidrRouteType'), ('IP-FORWARD-MIB', 'ipCidrRouteProto'), ('IP-FORWARD-MIB', 'ipCidrRouteAge'), ('IP-FORWARD-MIB', 'ipCidrRouteInfo'), ('IP-FORWARD-MIB', 'ipCidrRouteNextHopAS'), ('IP-FORWARD-MIB', 'ipCidrRouteMetric1'), ('IP-FORWARD-MIB', 'ipCidrRouteMetric2'), ('IP-FORWARD-MIB', 'ipCidrRouteMetric3'), ('IP-FORWARD-MIB', 'ipCidrRouteMetric4'), ('IP-FORWARD-MIB', 'ipCidrRouteMetric5'), ('IP-FORWARD-MIB', 'ipCidrRouteStatus')))
if mibBuilder.loadTexts:
ipForwardCidrRouteGroup.setDescription('The CIDR Route Table.\n\n This group has been deprecated and replaced with\n inetForwardCidrRouteGroup.')
ip_forward_number = mib_scalar((1, 3, 6, 1, 2, 1, 4, 24, 1), gauge32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ipForwardNumber.setDescription('The number of current ipForwardTable entries that are\n not invalid.')
ip_forward_table = mib_table((1, 3, 6, 1, 2, 1, 4, 24, 2))
if mibBuilder.loadTexts:
ipForwardTable.setDescription("This entity's IP Routing table.")
ip_forward_entry = mib_table_row((1, 3, 6, 1, 2, 1, 4, 24, 2, 1)).setIndexNames((0, 'IP-FORWARD-MIB', 'ipForwardDest'), (0, 'IP-FORWARD-MIB', 'ipForwardProto'), (0, 'IP-FORWARD-MIB', 'ipForwardPolicy'), (0, 'IP-FORWARD-MIB', 'ipForwardNextHop'))
if mibBuilder.loadTexts:
ipForwardEntry.setDescription('A particular route to a particular destination, under a\n particular policy.')
ip_forward_dest = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 1), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ipForwardDest.setDescription('The destination IP address of this route. An entry\n with a value of 0.0.0.0 is considered a default route.\n\n This object may not take a Multicast (Class D) address\n value.\n\n Any assignment (implicit or otherwise) of an instance\n of this object to a value x must be rejected if the\n bitwise logical-AND of x with the value of the\n corresponding instance of the ipForwardMask object is\n not equal to x.')
ip_forward_mask = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 2), ip_address().clone(hexValue='00000000')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
ipForwardMask.setDescription('Indicate the mask to be logical-ANDed with the\n destination address before being compared to the value\n in the ipForwardDest field. For those systems that do\n not support arbitrary subnet masks, an agent constructs\n the value of the ipForwardMask by reference to the IP\n Address Class.\n\n Any assignment (implicit or otherwise) of an instance\n of this object to a value x must be rejected if the\n bitwise logical-AND of x with the value of the\n corresponding instance of the ipForwardDest object is\n not equal to ipForwardDest.')
ip_forward_policy = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 3), integer32().subtype(subtypeSpec=value_range_constraint(0, 2147483647))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ipForwardPolicy.setDescription("The general set of conditions that would cause\n the selection of one multipath route (set of\n next hops for a given destination) is referred\n to as 'policy'.\n\n Unless the mechanism indicated by ipForwardProto\n specifies otherwise, the policy specifier is\n the IP TOS Field. The encoding of IP TOS is as\n specified by the following convention. Zero\n indicates the default path if no more specific\n policy applies.\n\n +-----+-----+-----+-----+-----+-----+-----+-----+\n | | | |\n | PRECEDENCE | TYPE OF SERVICE | 0 |\n | | | |\n +-----+-----+-----+-----+-----+-----+-----+-----+\n\n IP TOS IP TOS\n Field Policy Field Policy\n Contents Code Contents Code\n 0 0 0 0 ==> 0 0 0 0 1 ==> 2\n 0 0 1 0 ==> 4 0 0 1 1 ==> 6\n 0 1 0 0 ==> 8 0 1 0 1 ==> 10\n 0 1 1 0 ==> 12 0 1 1 1 ==> 14\n 1 0 0 0 ==> 16 1 0 0 1 ==> 18\n 1 0 1 0 ==> 20 1 0 1 1 ==> 22\n 1 1 0 0 ==> 24 1 1 0 1 ==> 26\n 1 1 1 0 ==> 28 1 1 1 1 ==> 30\n\n Protocols defining 'policy' otherwise must either\n define a set of values that are valid for\n this object or must implement an integer-instanced\n policy table for which this object's\n value acts as an index.")
ip_forward_next_hop = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 4), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ipForwardNextHop.setDescription('On remote routes, the address of the next system en\n route; otherwise, 0.0.0.0.')
ip_forward_if_index = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 5), integer32()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
ipForwardIfIndex.setDescription('The ifIndex value that identifies the local interface\n through which the next hop of this route should be\n reached.')
ip_forward_type = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('invalid', 2), ('local', 3), ('remote', 4))).clone('invalid')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
ipForwardType.setDescription('The type of route. Note that local(3) refers to a\n route for which the next hop is the final destination;\n remote(4) refers to a route for which the next hop is\n not the final destination.\n\n Setting this object to the value invalid(2) has the\n effect of invalidating the corresponding entry in the\n ipForwardTable object. That is, it effectively\n disassociates the destination identified with said\n entry from the route identified with said entry. It is\n an implementation-specific matter as to whether the\n agent removes an invalidated entry from the table.\n Accordingly, management stations must be prepared to\n receive tabular information from agents that\n corresponds to entries not currently in use. Proper\n interpretation of such entries requires examination of\n the relevant ipForwardType object.')
ip_forward_proto = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15))).clone(namedValues=named_values(('other', 1), ('local', 2), ('netmgmt', 3), ('icmp', 4), ('egp', 5), ('ggp', 6), ('hello', 7), ('rip', 8), ('is-is', 9), ('es-is', 10), ('ciscoIgrp', 11), ('bbnSpfIgp', 12), ('ospf', 13), ('bgp', 14), ('idpr', 15)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ipForwardProto.setDescription('The routing mechanism via which this route was learned.\n Inclusion of values for gateway routing protocols is\n not intended to imply that hosts should support those\n protocols.')
ip_forward_age = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 8), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
ipForwardAge.setDescription("The number of seconds since this route was last updated\n or otherwise determined to be correct. Note that no\n semantics of `too old' can be implied except through\n knowledge of the routing protocol by which the route\n was learned.")
ip_forward_info = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 9), object_identifier()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
ipForwardInfo.setDescription("A reference to MIB definitions specific to the\n particular routing protocol that is responsible for\n this route, as determined by the value specified in the\n route's ipForwardProto value. If this information is\n not present, its value should be set to the OBJECT\n IDENTIFIER { 0 0 }, which is a syntactically valid\n object identifier, and any implementation conforming to\n ASN.1 and the Basic Encoding Rules must be able to\n generate and recognize this value.")
ip_forward_next_hop_as = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 10), integer32()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
ipForwardNextHopAS.setDescription('The Autonomous System Number of the Next Hop. When\n this is unknown or not relevant to the protocol\n indicated by ipForwardProto, zero.')
ip_forward_metric1 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 11), integer32().clone(-1)).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
ipForwardMetric1.setDescription("The primary routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipForwardProto value.\n If this metric is not used, its value should be set to\n -1.")
ip_forward_metric2 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 12), integer32().clone(-1)).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
ipForwardMetric2.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipForwardProto value.\n If this metric is not used, its value should be set to\n -1.")
ip_forward_metric3 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 13), integer32().clone(-1)).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
ipForwardMetric3.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipForwardProto value.\n If this metric is not used, its value should be set to\n -1.")
ip_forward_metric4 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 14), integer32().clone(-1)).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
ipForwardMetric4.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipForwardProto value.\n If this metric is not used, its value should be set to\n -1.")
ip_forward_metric5 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 15), integer32().clone(-1)).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
ipForwardMetric5.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipForwardProto value.\n If this metric is not used, its value should be set to\n -1.")
ip_forward_old_compliance = module_compliance((1, 3, 6, 1, 2, 1, 4, 24, 5, 2, 2)).setObjects(*(('IP-FORWARD-MIB', 'ipForwardMultiPathGroup'),))
if mibBuilder.loadTexts:
ipForwardOldCompliance.setDescription('The compliance statement for SNMP entities that\n implement the ipForward MIB.')
ip_forward_multi_path_group = object_group((1, 3, 6, 1, 2, 1, 4, 24, 5, 1, 2)).setObjects(*(('IP-FORWARD-MIB', 'ipForwardNumber'), ('IP-FORWARD-MIB', 'ipForwardDest'), ('IP-FORWARD-MIB', 'ipForwardMask'), ('IP-FORWARD-MIB', 'ipForwardPolicy'), ('IP-FORWARD-MIB', 'ipForwardNextHop'), ('IP-FORWARD-MIB', 'ipForwardIfIndex'), ('IP-FORWARD-MIB', 'ipForwardType'), ('IP-FORWARD-MIB', 'ipForwardProto'), ('IP-FORWARD-MIB', 'ipForwardAge'), ('IP-FORWARD-MIB', 'ipForwardInfo'), ('IP-FORWARD-MIB', 'ipForwardNextHopAS'), ('IP-FORWARD-MIB', 'ipForwardMetric1'), ('IP-FORWARD-MIB', 'ipForwardMetric2'), ('IP-FORWARD-MIB', 'ipForwardMetric3'), ('IP-FORWARD-MIB', 'ipForwardMetric4'), ('IP-FORWARD-MIB', 'ipForwardMetric5')))
if mibBuilder.loadTexts:
ipForwardMultiPathGroup.setDescription('IP Multipath Route Table.')
mibBuilder.exportSymbols('IP-FORWARD-MIB', inetCidrRouteAge=inetCidrRouteAge, ipForwardFullCompliance=ipForwardFullCompliance, inetCidrRouteDest=inetCidrRouteDest, ipCidrRouteInfo=ipCidrRouteInfo, ipForwardNextHop=ipForwardNextHop, ipForwardConformance=ipForwardConformance, PYSNMP_MODULE_ID=ipForward, inetCidrRouteMetric5=inetCidrRouteMetric5, inetCidrRouteEntry=inetCidrRouteEntry, inetCidrRouteIfIndex=inetCidrRouteIfIndex, ipForwardNextHopAS=ipForwardNextHopAS, ipCidrRouteIfIndex=ipCidrRouteIfIndex, inetCidrRouteMetric2=inetCidrRouteMetric2, ipForwardInfo=ipForwardInfo, ipForwardDest=ipForwardDest, inetCidrRouteMetric1=inetCidrRouteMetric1, ipForwardEntry=ipForwardEntry, inetCidrRouteNextHop=inetCidrRouteNextHop, ipCidrRouteNextHopAS=ipCidrRouteNextHopAS, ipCidrRouteNumber=ipCidrRouteNumber, ipForwardMask=ipForwardMask, ipForwardPolicy=ipForwardPolicy, ipCidrRouteProto=ipCidrRouteProto, ipCidrRouteMetric2=ipCidrRouteMetric2, ipForward=ipForward, ipCidrRouteMetric4=ipCidrRouteMetric4, inetForwardCidrRouteGroup=inetForwardCidrRouteGroup, ipForwardMetric3=ipForwardMetric3, ipForwardCompliances=ipForwardCompliances, ipForwardReadOnlyCompliance=ipForwardReadOnlyCompliance, ipCidrRouteMask=ipCidrRouteMask, ipForwardIfIndex=ipForwardIfIndex, ipForwardCompliance=ipForwardCompliance, ipCidrRouteMetric3=ipCidrRouteMetric3, ipForwardProto=ipForwardProto, ipForwardMetric4=ipForwardMetric4, inetCidrRouteDiscards=inetCidrRouteDiscards, ipCidrRouteNextHop=ipCidrRouteNextHop, ipForwardTable=ipForwardTable, ipCidrRouteAge=ipCidrRouteAge, inetCidrRouteNextHopAS=inetCidrRouteNextHopAS, inetCidrRouteTable=inetCidrRouteTable, inetCidrRoutePolicy=inetCidrRoutePolicy, ipCidrRouteType=ipCidrRouteType, ipForwardOldCompliance=ipForwardOldCompliance, ipForwardGroups=ipForwardGroups, ipForwardMetric1=ipForwardMetric1, ipForwardNumber=ipForwardNumber, inetCidrRouteProto=inetCidrRouteProto, ipForwardMetric2=ipForwardMetric2, ipForwardAge=ipForwardAge, inetCidrRouteMetric3=inetCidrRouteMetric3, inetCidrRoutePfxLen=inetCidrRoutePfxLen, ipCidrRouteEntry=ipCidrRouteEntry, ipCidrRouteMetric5=ipCidrRouteMetric5, ipForwardType=ipForwardType, ipCidrRouteTable=ipCidrRouteTable, ipForwardMultiPathGroup=ipForwardMultiPathGroup, inetCidrRouteStatus=inetCidrRouteStatus, ipCidrRouteDest=ipCidrRouteDest, ipForwardMetric5=ipForwardMetric5, ipCidrRouteTos=ipCidrRouteTos, inetCidrRouteType=inetCidrRouteType, inetCidrRouteNumber=inetCidrRouteNumber, ipCidrRouteStatus=ipCidrRouteStatus, ipForwardCidrRouteGroup=ipForwardCidrRouteGroup, ipCidrRouteMetric1=ipCidrRouteMetric1, inetCidrRouteMetric4=inetCidrRouteMetric4, inetCidrRouteNextHopType=inetCidrRouteNextHopType, inetCidrRouteDestType=inetCidrRouteDestType) |
# Declare any variables (as constants) that are or could be used anywhere in the application
# TODO: Determine what a good fingerprint length is
FINGERPRINT_LENGTH = 40
| fingerprint_length = 40 |
def multi(a,b):
return a*b
if __name__ == '__main__':
print(multi(2,3))
| def multi(a, b):
return a * b
if __name__ == '__main__':
print(multi(2, 3)) |
class LayerShape:
def __init__(self, *dims):
self.dims = dims
if len(dims) == 1:
self.channels = dims[0]
elif len(dims) == 2:
self.channels = dims[0]
self.height = dims[1]
elif len(dims) == 3:
self.channels = dims[0]
self.height = dims[1]
self.width = dims[2]
elif len(dims) == 4:
self.frames = dims[0]
self.channels = dims[1]
self.height = dims[2]
self.width = dims[3]
def squeeze_dims(self):
filter(lambda x: x == 1, self.dims)
def size(self):
if len(self.dims) == 1:
return self.channels
if len(self.dims) == 2:
return self.channels * self.height
if len(self.dims) == 3:
return self.channels * self.height * self.width
return self.channels * self.height * self.width * self.frames
def __repr__(self):
return "LayerShape(" + ", ".join([str(x) for x in self.dims]) + ")"
def __str__(self):
return self.__repr__()
| class Layershape:
def __init__(self, *dims):
self.dims = dims
if len(dims) == 1:
self.channels = dims[0]
elif len(dims) == 2:
self.channels = dims[0]
self.height = dims[1]
elif len(dims) == 3:
self.channels = dims[0]
self.height = dims[1]
self.width = dims[2]
elif len(dims) == 4:
self.frames = dims[0]
self.channels = dims[1]
self.height = dims[2]
self.width = dims[3]
def squeeze_dims(self):
filter(lambda x: x == 1, self.dims)
def size(self):
if len(self.dims) == 1:
return self.channels
if len(self.dims) == 2:
return self.channels * self.height
if len(self.dims) == 3:
return self.channels * self.height * self.width
return self.channels * self.height * self.width * self.frames
def __repr__(self):
return 'LayerShape(' + ', '.join([str(x) for x in self.dims]) + ')'
def __str__(self):
return self.__repr__() |
# Time: O(Log n) We performed a Binary Search
# Space: O(1)
class Solution:
def findMin(self, nums):
if len(nums) == 1:
return nums[0]
left = 0
right = len(nums) - 1
if nums[0] < nums[right]:
return nums[0]
while left <= right:
mid = (right + left) // 2
mid_val = nums[mid]
right_of_mid_val = nums[mid + 1]
left_of_mid_val = nums[mid - 1]
if mid_val > right_of_mid_val:
return right_of_mid_val
if left_of_mid_val > mid_val:
return mid_val
if mid_val > nums[0]:
left = mid + 1
else:
right = mid - 1
solution = Solution()
print(solution.findMin([3, 4, 5, 1, 2])) | class Solution:
def find_min(self, nums):
if len(nums) == 1:
return nums[0]
left = 0
right = len(nums) - 1
if nums[0] < nums[right]:
return nums[0]
while left <= right:
mid = (right + left) // 2
mid_val = nums[mid]
right_of_mid_val = nums[mid + 1]
left_of_mid_val = nums[mid - 1]
if mid_val > right_of_mid_val:
return right_of_mid_val
if left_of_mid_val > mid_val:
return mid_val
if mid_val > nums[0]:
left = mid + 1
else:
right = mid - 1
solution = solution()
print(solution.findMin([3, 4, 5, 1, 2])) |
def foo_task():
print('Foo task is running...')
print('Foo task completed.')
return True
def sum_task(arg_1: int, arg_2: int):
print('Sum task is running...')
result = arg_1 + arg_2
print('Sum task completed.')
return result
| def foo_task():
print('Foo task is running...')
print('Foo task completed.')
return True
def sum_task(arg_1: int, arg_2: int):
print('Sum task is running...')
result = arg_1 + arg_2
print('Sum task completed.')
return result |
#!/usr/bin/env python3
# Tax calculator
# This program currently
# only works with the hungarian tax
def calcTax(cost, country='hungary'):
countries = {'hungary' : 27}
if country in countries.keys():
tax = (cost / 100) * countries[country]
else:
return "Country can't be found"
return tax
def main(): # Wrapper function
tax = calcTax(int(input('What was the cost of your purchase? ')),
input('Which country are you in? '))
if type(tax) == str:
print(tax)
else:
print('The tax on your purchase was:', tax)
if __name__ == '__main__':
main() | def calc_tax(cost, country='hungary'):
countries = {'hungary': 27}
if country in countries.keys():
tax = cost / 100 * countries[country]
else:
return "Country can't be found"
return tax
def main():
tax = calc_tax(int(input('What was the cost of your purchase? ')), input('Which country are you in? '))
if type(tax) == str:
print(tax)
else:
print('The tax on your purchase was:', tax)
if __name__ == '__main__':
main() |
'''
Details about this Python package.
'''
__version__ = '1.1.0'
__title__ = 'example-python'
__author__ = 'Mahathir Almashor'
__author_email__ = 'mahathir.almashor@data61.csiro.au'
__description__ = 'Example Python repository for Cyber Security Cooperative Research Centre'
__url__ = 'https://github.com/ma-al/example-python'
| """
Details about this Python package.
"""
__version__ = '1.1.0'
__title__ = 'example-python'
__author__ = 'Mahathir Almashor'
__author_email__ = 'mahathir.almashor@data61.csiro.au'
__description__ = 'Example Python repository for Cyber Security Cooperative Research Centre'
__url__ = 'https://github.com/ma-al/example-python' |
with open("day13.in") as f:
lines = f.read().splitlines()
dots = set()
for i, line in enumerate(lines):
if line == "":
break
x, y = line.split(",")
dots.add((int(x), int(y)))
# folds
for line in lines[i+1:]:
_, _, fold = line.split(" ")
axis, num = fold.split("=")
num = int(num)
new_dots = set()
if axis == "x":
# vertical line at |num|.
for (xpos, ypos) in dots:
if xpos > num:
newxpos = num - (xpos - num)
new_dots.add((newxpos, ypos))
else:
new_dots.add((xpos, ypos))
elif axis == "y":
# horizontal line at |num|
for (xpos, ypos) in dots:
if ypos > num:
newypos = num - (ypos - num)
new_dots.add((xpos, newypos))
else:
new_dots.add((xpos, ypos))
dots = new_dots
print(len(new_dots))
max_x = 0
max_y = 0
for (x, y) in dots:
max_x = max(max_x, x)
max_y = max(max_y, y)
print(max_x, max_y)
for j in range(max_y + 1):
print("".join(["#" if (i, j) in dots else " " for i in range(max_x + 1)]))
| with open('day13.in') as f:
lines = f.read().splitlines()
dots = set()
for (i, line) in enumerate(lines):
if line == '':
break
(x, y) = line.split(',')
dots.add((int(x), int(y)))
for line in lines[i + 1:]:
(_, _, fold) = line.split(' ')
(axis, num) = fold.split('=')
num = int(num)
new_dots = set()
if axis == 'x':
for (xpos, ypos) in dots:
if xpos > num:
newxpos = num - (xpos - num)
new_dots.add((newxpos, ypos))
else:
new_dots.add((xpos, ypos))
elif axis == 'y':
for (xpos, ypos) in dots:
if ypos > num:
newypos = num - (ypos - num)
new_dots.add((xpos, newypos))
else:
new_dots.add((xpos, ypos))
dots = new_dots
print(len(new_dots))
max_x = 0
max_y = 0
for (x, y) in dots:
max_x = max(max_x, x)
max_y = max(max_y, y)
print(max_x, max_y)
for j in range(max_y + 1):
print(''.join(['#' if (i, j) in dots else ' ' for i in range(max_x + 1)])) |
# Copyright (c) 2019-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
def f_gold ( num ) :
series = [ 1 , 3 , 2 , - 1 , - 3 , - 2 ] ;
series_index = 0 ;
result = 0 ;
for i in range ( ( len ( num ) - 1 ) , - 1 , - 1 ) :
digit = ord ( num [ i ] ) - 48 ;
result += digit * series [ series_index ] ;
series_index = ( series_index + 1 ) % 6 ;
result %= 7 ;
if ( result < 0 ) :
result = ( result + 7 ) % 7 ;
return result ;
#TOFILL
if __name__ == '__main__':
param = [
('K',),
('850076',),
('00111',),
('X',),
('1',),
('10010001100',),
(' pgPeLz',),
('53212456821275',),
('101',),
('V',)
]
n_success = 0
for i, parameters_set in enumerate(param):
if f_filled(*parameters_set) == f_gold(*parameters_set):
n_success+=1
print("#Results: %i, %i" % (n_success, len(param))) | def f_gold(num):
series = [1, 3, 2, -1, -3, -2]
series_index = 0
result = 0
for i in range(len(num) - 1, -1, -1):
digit = ord(num[i]) - 48
result += digit * series[series_index]
series_index = (series_index + 1) % 6
result %= 7
if result < 0:
result = (result + 7) % 7
return result
if __name__ == '__main__':
param = [('K',), ('850076',), ('00111',), ('X',), ('1',), ('10010001100',), (' pgPeLz',), ('53212456821275',), ('101',), ('V',)]
n_success = 0
for (i, parameters_set) in enumerate(param):
if f_filled(*parameters_set) == f_gold(*parameters_set):
n_success += 1
print('#Results: %i, %i' % (n_success, len(param))) |
VALUE_INITIALIZED = 0
def test_owner_address(box, accounts):
# verify that accounts[0] is contract owner
assert accounts[0].address == box.owner()
def test_value_after_contract_creation(box, accounts):
# verify initialized value of box
assert VALUE_INITIALIZED == box.retrieve()
| value_initialized = 0
def test_owner_address(box, accounts):
assert accounts[0].address == box.owner()
def test_value_after_contract_creation(box, accounts):
assert VALUE_INITIALIZED == box.retrieve() |
# This file creates custom rules to make tests can easily run under
# certain environment(like inside a docker).
#
# For example:
#
# run_under_test(
# name = "test_under_docker",
# under = "//tools/docker:zookeper",
# command = "//sometest",
# data = [
# ],
# args = [
# "--gtest_filter=abc",
# ]
# )
#
# This is almost equivalent to
# bazel run --script_path "name" --run_under "under" "command"
#
# under: any build target that produces an executable binary, this is
# the top level command to run, and it should take another executable
# as command line flag to run as subprocess.
#
# command: any build target that produces an executable binary.
#
# data: list of files that need to be accessed when running the
# "under" and the "command".
def _run_under_impl(ctx):
bin_dir = ctx.configuration.bin_dir
build_directory = str(bin_dir)[:-len('[derived]')] + '/'
under = ctx.executable.under
under_args = ctx.attr.under_args
command = ctx.executable.command
exe = ctx.outputs.executable
ctx.file_action(output=exe,
content='''#!/bin/bash
cd %s.runfiles && \\
exec %s %s \\
%s "$@"
''' % (build_directory + exe.short_path,
build_directory + under.short_path,
" ".join(under_args),
build_directory + command.short_path))
# The $@ above will pass ctx.attr.args along to the command
runfiles = [command, under] + ctx.files.data
return struct(
runfiles=ctx.runfiles(
files=runfiles,
collect_data=True,
collect_default=True)
)
run_under_attr = {
"command": attr.label(mandatory=True,
allow_files=True,
cfg='target',
executable=True),
"under": attr.label(mandatory=True,
allow_files=True,
cfg='target',
executable=True),
# Arguments for the "under" command to setup the environment.
"under_args": attr.string_list(),
"data": attr.label_list(allow_files=True,
cfg='data'),
# bazel automatically implements "args": attr.string_list()
# and passes them on invocation
}
run_under_binary = rule(
_run_under_impl,
attrs = run_under_attr,
executable=True)
run_under_test = rule(
_run_under_impl,
test = True,
attrs = run_under_attr,
executable=True)
| def _run_under_impl(ctx):
bin_dir = ctx.configuration.bin_dir
build_directory = str(bin_dir)[:-len('[derived]')] + '/'
under = ctx.executable.under
under_args = ctx.attr.under_args
command = ctx.executable.command
exe = ctx.outputs.executable
ctx.file_action(output=exe, content='#!/bin/bash\ncd %s.runfiles && \\\nexec %s %s \\\n%s "$@"\n' % (build_directory + exe.short_path, build_directory + under.short_path, ' '.join(under_args), build_directory + command.short_path))
runfiles = [command, under] + ctx.files.data
return struct(runfiles=ctx.runfiles(files=runfiles, collect_data=True, collect_default=True))
run_under_attr = {'command': attr.label(mandatory=True, allow_files=True, cfg='target', executable=True), 'under': attr.label(mandatory=True, allow_files=True, cfg='target', executable=True), 'under_args': attr.string_list(), 'data': attr.label_list(allow_files=True, cfg='data')}
run_under_binary = rule(_run_under_impl, attrs=run_under_attr, executable=True)
run_under_test = rule(_run_under_impl, test=True, attrs=run_under_attr, executable=True) |
# x = n^2 + an + b; |a| < 1000 and |b| < 1000
# b has to be odd, positive and prime as we are testing consecutive values for n
# a has to be negative otherwise the difference between consecutive x's will be huge!
def is_prime(num) :
if (num <= 1) :
return False
if (num <= 3) :
return True
if (num % 2 == 0 or num % 3 == 0) :
return False
i = 5
while(i * i <= num) :
if (num % i == 0 or num % (i + 2) == 0) :
return False
i = i + 6
return True
def max_prod(max_val_a , max_val_b):
max_n = 0
max_b = 0
max_a = 0
for i in range(-max_val_a, -1):
for j in range(1, max_val_b, 2):
n = 0
while is_prime(n**2 + i*n + j):
n += 1
if n > max_n:
max_a = i
max_b = j
max_n = n
return max_a * max_b
if __name__ == '__main__':
print(max_prod(1000, 1000)) | def is_prime(num):
if num <= 1:
return False
if num <= 3:
return True
if num % 2 == 0 or num % 3 == 0:
return False
i = 5
while i * i <= num:
if num % i == 0 or num % (i + 2) == 0:
return False
i = i + 6
return True
def max_prod(max_val_a, max_val_b):
max_n = 0
max_b = 0
max_a = 0
for i in range(-max_val_a, -1):
for j in range(1, max_val_b, 2):
n = 0
while is_prime(n ** 2 + i * n + j):
n += 1
if n > max_n:
max_a = i
max_b = j
max_n = n
return max_a * max_b
if __name__ == '__main__':
print(max_prod(1000, 1000)) |
if __name__ == '__main__':
x = int(input())
y = int(input())
z = int(input())
n = int(input())
nlist = [[i,j,k] for i in range(0, x+1) for j in range(0, y+1) for k in range(0, z+1) if (i+j+k) > n or (i+j+k)< n]
print(nlist) | if __name__ == '__main__':
x = int(input())
y = int(input())
z = int(input())
n = int(input())
nlist = [[i, j, k] for i in range(0, x + 1) for j in range(0, y + 1) for k in range(0, z + 1) if i + j + k > n or i + j + k < n]
print(nlist) |
##Collect data:
'''
#SMI: 2021/10/30
SAF: 308214 Standard Beamline 12-ID proposal: (CFN, 307961)
create proposal: proposal_id( '2021_3', '307961_Dinca' ) #create the proposal id and folder
%run -i /home/xf12id/.ipython/profile_collection/startup/users/30-user-Dinca2021C2B.py
RE( shopen() ) # to open the beam and feedback
RE( shclose())
# Energy: 16.1 keV, 0.77009 A
# SAXS distance 5000
##for the run >=5
# 5 m, beam stop: 1.9
# 5m, 1M, x=-5, Y = -40
# the correspond beam center is [ 454, 682 ]
# beamstop_save()
FOR MIT CELL,
Cables:
Cell A:
#3, red to red
#2 orange to blue
Cell B:
#9 black to black
#4 brown to brown
'''
username = 'Dinca'
#####First Run
sample_dict = {
1: 'Cell01_NaCl_Electrolyte' ,
2: 'Cell03_AlCl3_Electrolyte' ,
}
#####Second Run
sample_dict = {
1: 'Cell05_MgCl2_Electrolyte' ,
2: 'Cell06_AlCl3_Electrolyte' ,
}
#####Third Run
sample_dict = {
1: 'Cell04_NH4Cl_Electrolyte' ,
2: 'Cell07_NaCl_Electrolyte_PH1' ,
}
pxy_dict = {
1: ( 35800, 800 ),
2: (-23400, 1200),
}
PZ = -1500
# Plan
# measure at RT without apply V,
# -0.7 V, measure
# keep 30 min, measure
#############
## For sample 1
# Without V,
# Manually measure one by one
# measure_pos_noV()
# apply V = -0.7
# measure_pos_V()
user_name = 'Dinca'
pos = 1
def _measure( sample ):
if abs(waxs.arc.user_readback.value-20 ) < 2:
RE( measure_wsaxs( t = 1, waxs_angle=20, att='None', dy=0, user_name=user_name, sample= sample ) )
RE( measure_waxs( t = 1, waxs_angle=0, att='None', dy=0, user_name=user_name, sample= sample ) )
else:
RE( measure_waxs( t = 1, waxs_angle=0, att='None', dy=0, user_name=user_name, sample= sample ) )
RE( measure_wsaxs( t = 1, waxs_angle=20, att='None', dy=0, user_name=user_name, sample= sample ) )
def measure_pos_noV( pos ):
mov_sam( pos )
samplei = RE.md['sample']
_measure( samplei )
def measure_pos_V( pos , N = 20, wait_time= 5 * 60, start_time= 2 ):
mov_sam( pos )
t0 = time.time()
for i in range(N):
dt = (time.time() - t0)/60 + start_time
samplei = RE.md['sample'] + 'ApplyN0p7_t_%.1fmin'%dt
print( i, samplei )
_measure( samplei )
print( 'Sleep for 5 min...')
time.sleep( wait_time )
def _measure_one_potential( V ='' ):
mov_sam ( 2 )
RE.md['sample'] += V
print( RE.md['sample'])
RE( measure_waxs() )
time.sleep(3)
RE(measure_saxs(1, move_y= False ) )
##################################################
############ Some convinent functions#################
#########################################################
def movx( dx ):
RE( bps.mvr(piezo.x, dx) )
def movy( dy ):
RE( bps.mvr(piezo.y, dy) )
def get_posxy( ):
return round( piezo.x.user_readback.value, 2 ),round( piezo.y.user_readback.value , 2 )
def move_waxs( waxs_angle=8.0):
RE( bps.mv(waxs, waxs_angle) )
def move_waxs_off( waxs_angle=8.0 ):
RE( bps.mv(waxs, waxs_angle) )
def move_waxs_on( waxs_angle=0.0 ):
RE( bps.mv(waxs, waxs_angle) )
def mov_sam( pos ):
px,py = pxy_dict[ pos ]
RE( bps.mv(piezo.x, px) )
RE( bps.mv(piezo.y, py) )
sample = sample_dict[pos]
print('Move to pos=%s for sample:%s...'%(pos, sample ))
RE.md['sample'] = sample
def check_saxs_sample_loc( sleep = 5 ):
ks = list( sample_dict.keys() )
for k in ks:
mov_sam( k )
time.sleep( sleep )
def measure_saxs( t = 1, att='None', dx=0, dy=0, user_name=username, sample= None ):
if sample is None:
sample = RE.md['sample']
dets = [ pil1M ]
if dy:
yield from bps.mvr(piezo.y, dy )
if dx:
yield from bps.mvr(piezo.x, dx )
name_fmt = '{sample}_x{x:05.2f}_y{y:05.2f}_z{z_pos:05.2f}_det{saxs_z:05.2f}m_expt{t}s_sid{scan_id:08d}'
sample_name = name_fmt.format(
sample = sample, x=np.round(piezo.x.position,2), y=np.round(piezo.y.position,2), z_pos=piezo.z.position,
saxs_z=np.round(pil1m_pos.z.position,2), t=t, scan_id=RE.md['scan_id'])
det_exposure_time( t, t)
#sample_name='test'
sample_id(user_name=user_name, sample_name=sample_name )
print(f'\n\t=== Sample: {sample_name} ===\n')
print('Collect data here....')
yield from bp.count(dets, num=1)
sample_id(user_name='test', sample_name='test')
def measure_waxs( t = 1, waxs_angle=0, att='None', dx=0, dy=0, user_name=username, sample= None ):
if sample is None:
sample = RE.md['sample']
yield from bps.mv(waxs, waxs_angle)
dets = [ pil900KW, pil300KW ]
#att_in( att )
if dx:
yield from bps.mvr(piezo.x, dx )
if dy:
yield from bps.mvr(piezo.y, dy )
name_fmt = '{sample}_x{x_pos:05.2f}_y{y_pos:05.2f}_z{z_pos:05.2f}_waxs{waxs_angle:05.2f}_expt{expt}s_sid{scan_id:08d}'
sample_name = name_fmt.format(sample=sample, x_pos=piezo.x.position, y_pos=piezo.y.position, z_pos=piezo.z.position,
waxs_angle=waxs_angle, expt= t, scan_id=RE.md['scan_id'])
det_exposure_time( t, t)
sample_id(user_name=user_name, sample_name=sample_name )
print(f'\n\t=== Sample: {sample_name} ===\n')
print('Collect data here....')
yield from bp.count(dets, num=1)
#att_out( att )
#sample_id(user_name='test', sample_name='test')
def measure_wsaxs( t = 1, waxs_angle=20, att='None', dx=0, dy=0, user_name=username, sample= None ):
if sample is None:
sample = RE.md['sample']
yield from bps.mv(waxs, waxs_angle)
dets = [ pil900KW, pil300KW , pil1M ]
if dx:
yield from bps.mvr(piezo.x, dx )
if dy:
yield from bps.mvr(piezo.y, dy )
name_fmt = '{sample}_x{x_pos:05.2f}_y{y_pos:05.2f}_z{z_pos:05.2f}_det{saxs_z}_waxs{waxs_angle:05.2f}_expt{expt}s_sid{scan_id:08d}'
sample_name = name_fmt.format(sample=sample, x_pos=piezo.x.position, y_pos=piezo.y.position, z_pos=piezo.z.position,
saxs_z=np.round(pil1m_pos.z.position,2), waxs_angle=waxs_angle, expt= t, scan_id=RE.md['scan_id'])
det_exposure_time( t, t)
sample_id(user_name=user_name, sample_name=sample_name )
print(f'\n\t=== Sample: {sample_name} ===\n')
print('Collect data here....')
yield from bp.count(dets, num=1)
#att_out( att )
#sample_id(user_name='test', sample_name='test')
| """
#SMI: 2021/10/30
SAF: 308214 Standard Beamline 12-ID proposal: (CFN, 307961)
create proposal: proposal_id( '2021_3', '307961_Dinca' ) #create the proposal id and folder
%run -i /home/xf12id/.ipython/profile_collection/startup/users/30-user-Dinca2021C2B.py
RE( shopen() ) # to open the beam and feedback
RE( shclose())
# Energy: 16.1 keV, 0.77009 A
# SAXS distance 5000
##for the run >=5
# 5 m, beam stop: 1.9
# 5m, 1M, x=-5, Y = -40
# the correspond beam center is [ 454, 682 ]
# beamstop_save()
FOR MIT CELL,
Cables:
Cell A:
#3, red to red
#2 orange to blue
Cell B:
#9 black to black
#4 brown to brown
"""
username = 'Dinca'
sample_dict = {1: 'Cell01_NaCl_Electrolyte', 2: 'Cell03_AlCl3_Electrolyte'}
sample_dict = {1: 'Cell05_MgCl2_Electrolyte', 2: 'Cell06_AlCl3_Electrolyte'}
sample_dict = {1: 'Cell04_NH4Cl_Electrolyte', 2: 'Cell07_NaCl_Electrolyte_PH1'}
pxy_dict = {1: (35800, 800), 2: (-23400, 1200)}
pz = -1500
user_name = 'Dinca'
pos = 1
def _measure(sample):
if abs(waxs.arc.user_readback.value - 20) < 2:
re(measure_wsaxs(t=1, waxs_angle=20, att='None', dy=0, user_name=user_name, sample=sample))
re(measure_waxs(t=1, waxs_angle=0, att='None', dy=0, user_name=user_name, sample=sample))
else:
re(measure_waxs(t=1, waxs_angle=0, att='None', dy=0, user_name=user_name, sample=sample))
re(measure_wsaxs(t=1, waxs_angle=20, att='None', dy=0, user_name=user_name, sample=sample))
def measure_pos_no_v(pos):
mov_sam(pos)
samplei = RE.md['sample']
_measure(samplei)
def measure_pos_v(pos, N=20, wait_time=5 * 60, start_time=2):
mov_sam(pos)
t0 = time.time()
for i in range(N):
dt = (time.time() - t0) / 60 + start_time
samplei = RE.md['sample'] + 'ApplyN0p7_t_%.1fmin' % dt
print(i, samplei)
_measure(samplei)
print('Sleep for 5 min...')
time.sleep(wait_time)
def _measure_one_potential(V=''):
mov_sam(2)
RE.md['sample'] += V
print(RE.md['sample'])
re(measure_waxs())
time.sleep(3)
re(measure_saxs(1, move_y=False))
def movx(dx):
re(bps.mvr(piezo.x, dx))
def movy(dy):
re(bps.mvr(piezo.y, dy))
def get_posxy():
return (round(piezo.x.user_readback.value, 2), round(piezo.y.user_readback.value, 2))
def move_waxs(waxs_angle=8.0):
re(bps.mv(waxs, waxs_angle))
def move_waxs_off(waxs_angle=8.0):
re(bps.mv(waxs, waxs_angle))
def move_waxs_on(waxs_angle=0.0):
re(bps.mv(waxs, waxs_angle))
def mov_sam(pos):
(px, py) = pxy_dict[pos]
re(bps.mv(piezo.x, px))
re(bps.mv(piezo.y, py))
sample = sample_dict[pos]
print('Move to pos=%s for sample:%s...' % (pos, sample))
RE.md['sample'] = sample
def check_saxs_sample_loc(sleep=5):
ks = list(sample_dict.keys())
for k in ks:
mov_sam(k)
time.sleep(sleep)
def measure_saxs(t=1, att='None', dx=0, dy=0, user_name=username, sample=None):
if sample is None:
sample = RE.md['sample']
dets = [pil1M]
if dy:
yield from bps.mvr(piezo.y, dy)
if dx:
yield from bps.mvr(piezo.x, dx)
name_fmt = '{sample}_x{x:05.2f}_y{y:05.2f}_z{z_pos:05.2f}_det{saxs_z:05.2f}m_expt{t}s_sid{scan_id:08d}'
sample_name = name_fmt.format(sample=sample, x=np.round(piezo.x.position, 2), y=np.round(piezo.y.position, 2), z_pos=piezo.z.position, saxs_z=np.round(pil1m_pos.z.position, 2), t=t, scan_id=RE.md['scan_id'])
det_exposure_time(t, t)
sample_id(user_name=user_name, sample_name=sample_name)
print(f'\n\t=== Sample: {sample_name} ===\n')
print('Collect data here....')
yield from bp.count(dets, num=1)
sample_id(user_name='test', sample_name='test')
def measure_waxs(t=1, waxs_angle=0, att='None', dx=0, dy=0, user_name=username, sample=None):
if sample is None:
sample = RE.md['sample']
yield from bps.mv(waxs, waxs_angle)
dets = [pil900KW, pil300KW]
if dx:
yield from bps.mvr(piezo.x, dx)
if dy:
yield from bps.mvr(piezo.y, dy)
name_fmt = '{sample}_x{x_pos:05.2f}_y{y_pos:05.2f}_z{z_pos:05.2f}_waxs{waxs_angle:05.2f}_expt{expt}s_sid{scan_id:08d}'
sample_name = name_fmt.format(sample=sample, x_pos=piezo.x.position, y_pos=piezo.y.position, z_pos=piezo.z.position, waxs_angle=waxs_angle, expt=t, scan_id=RE.md['scan_id'])
det_exposure_time(t, t)
sample_id(user_name=user_name, sample_name=sample_name)
print(f'\n\t=== Sample: {sample_name} ===\n')
print('Collect data here....')
yield from bp.count(dets, num=1)
def measure_wsaxs(t=1, waxs_angle=20, att='None', dx=0, dy=0, user_name=username, sample=None):
if sample is None:
sample = RE.md['sample']
yield from bps.mv(waxs, waxs_angle)
dets = [pil900KW, pil300KW, pil1M]
if dx:
yield from bps.mvr(piezo.x, dx)
if dy:
yield from bps.mvr(piezo.y, dy)
name_fmt = '{sample}_x{x_pos:05.2f}_y{y_pos:05.2f}_z{z_pos:05.2f}_det{saxs_z}_waxs{waxs_angle:05.2f}_expt{expt}s_sid{scan_id:08d}'
sample_name = name_fmt.format(sample=sample, x_pos=piezo.x.position, y_pos=piezo.y.position, z_pos=piezo.z.position, saxs_z=np.round(pil1m_pos.z.position, 2), waxs_angle=waxs_angle, expt=t, scan_id=RE.md['scan_id'])
det_exposure_time(t, t)
sample_id(user_name=user_name, sample_name=sample_name)
print(f'\n\t=== Sample: {sample_name} ===\n')
print('Collect data here....')
yield from bp.count(dets, num=1) |
class Arithmetic:
def __init__(self):
self.value1 = 0
self.value2 = 0
def Accept(self, no1, no2):
self.value1 = no1
self.value2 = no2
def Addition(self):
result = self.value1 + self.value2
print("Addition is = ", result)
def Subtraction(self):
result = self.value1 - self.value2
print("Subtraction is = ", result)
def Multiplication(self):
result = self.value1 * self.value2
print("Multiplication is = ", result)
def Division(self):
result = self.value1 / self.value2
print("Division is = ", result)
def main():
a = int(input("Enter value1 : "))
b = int(input("Enter value2 = "))
obj = Arithmetic()
obj.Accept(a, b)
obj.Addition()
obj.Subtraction()
obj.Multiplication()
obj.Division()
if __name__ == '__main__':
main()
| class Arithmetic:
def __init__(self):
self.value1 = 0
self.value2 = 0
def accept(self, no1, no2):
self.value1 = no1
self.value2 = no2
def addition(self):
result = self.value1 + self.value2
print('Addition is = ', result)
def subtraction(self):
result = self.value1 - self.value2
print('Subtraction is = ', result)
def multiplication(self):
result = self.value1 * self.value2
print('Multiplication is = ', result)
def division(self):
result = self.value1 / self.value2
print('Division is = ', result)
def main():
a = int(input('Enter value1 : '))
b = int(input('Enter value2 = '))
obj = arithmetic()
obj.Accept(a, b)
obj.Addition()
obj.Subtraction()
obj.Multiplication()
obj.Division()
if __name__ == '__main__':
main() |
class Config(object) :
#DETECTRON_URL = 'http://localhost/predictions'
DETECTRON_URL = 'https://master-ainized-detectron2-gkswjdzz.endpoint.ainize.ai/predictions'
#STANFORDNLP_URL = 'http://localhost:81/analyze'
STANFORDNLP_URL = 'https://master-ainized-stanfordnlp-gkswjdzz.endpoint.ainize.ai/analyze'
| class Config(object):
detectron_url = 'https://master-ainized-detectron2-gkswjdzz.endpoint.ainize.ai/predictions'
stanfordnlp_url = 'https://master-ainized-stanfordnlp-gkswjdzz.endpoint.ainize.ai/analyze' |
# -*- coding: utf-8 -*-
# AtCoder Beginner Contest
def main():
n, a, b = list(map(int, input().split()))
position = 0
for i in range(n):
s, d = list(map(str, input().split()))
if int(d) < a:
d = a
elif int(d) > b:
d = b
else:
d = d
if s == 'West':
d = -1 * int(d)
else:
d = int(d)
position += d
if position == 0:
print(str(0))
elif position > 0:
print('East ' + str(position))
else:
print('West ' + str(abs(position)))
if __name__ == '__main__':
main()
| def main():
(n, a, b) = list(map(int, input().split()))
position = 0
for i in range(n):
(s, d) = list(map(str, input().split()))
if int(d) < a:
d = a
elif int(d) > b:
d = b
else:
d = d
if s == 'West':
d = -1 * int(d)
else:
d = int(d)
position += d
if position == 0:
print(str(0))
elif position > 0:
print('East ' + str(position))
else:
print('West ' + str(abs(position)))
if __name__ == '__main__':
main() |
class CFG:
# Disease:
_TARGET_R0 = 1.4 # before Test and Trace and Isolation
DAYS_BEFORE_INFECTIOUS = 4 # t0
DAYS_INFECTIOUS_TO_SYMPTOMS = 2 # t1
DAYS_OF_SYMPTOMS = 5 # t2
PROB_SYMPTOMATIC = 0.6 # pS probability that an infected person develops actionable symptoms
# Person:
PROB_ISOLATE_IF_SYMPTOMS = 0.75 # pIsolSimpt
PROB_ISOLATE_IF_TRACED = 0.3 #
PROB_ISOLATE_IF_TESTPOS = 0.3 #
PROB_GET_TEST_IF_TRACED = 0.75 #
PROB_APPLY_FOR_TEST_IF_SYMPTOMS = 0.75 # pA
DURATION_OF_ISOLATION = 10 #tIsol
# Society:
PROB_INFECT_IF_TOGETHER_ON_A_DAY = 0.025 # this is a moving target - because depends on hand-washing, masks ...
PROB_NON_C19_SYMPTOMS_PER_DAY = 0.01 # like b - probability someone unnecessarily requests a test on a given day
PROB_TEST_IF_REQUESTED = 1 # pG # set to 1 ... however, see the next parameter ... with capacity idea
DAILY_TEST_CAPACITY_PER_HEAD = 0.0075 # being very generous here ... this is probably more like 0.005
TEST_DAYS_ELAPSED = 1 # like pR # time to get result to the index in an ideal world with no backlog
# DAYS_GETTING_TO_CONTACTS = 1 # tricky to implement, leaving for now
PROB_TRACING_GIVEN_CONTACT = 0.8 * 0.75 # pT
# Simulator
SIMULATOR_PERIODS_PER_DAY = 1
MEAN_NETWORK_SIZE = 1 +_TARGET_R0 / (DAYS_INFECTIOUS_TO_SYMPTOMS + DAYS_OF_SYMPTOMS) / PROB_INFECT_IF_TOGETHER_ON_A_DAY
# the above formula, and the _TARGET_R0 concept, assumes that all people have identical network size
_PROPORTION_OF_INFECTED_WHO_GET_TESTED = PROB_SYMPTOMATIC * \
PROB_APPLY_FOR_TEST_IF_SYMPTOMS * \
PROB_TEST_IF_REQUESTED # should be 0.205
def set_config(obj, conf):
obj.cfg = CFG()
if conf is not None:
extra_params = (conf.keys() - set(dir(obj.cfg)))
if len(extra_params) > 0:
raise AttributeError(f"unrecognised parameter overrides: {extra_params}")
obj.cfg.__dict__.update(conf or {})
def print_baseline_config():
cfg = CFG()
for param in dir(cfg):
if not param.startswith("__"):
print(param, getattr(cfg, param))
| class Cfg:
_target_r0 = 1.4
days_before_infectious = 4
days_infectious_to_symptoms = 2
days_of_symptoms = 5
prob_symptomatic = 0.6
prob_isolate_if_symptoms = 0.75
prob_isolate_if_traced = 0.3
prob_isolate_if_testpos = 0.3
prob_get_test_if_traced = 0.75
prob_apply_for_test_if_symptoms = 0.75
duration_of_isolation = 10
prob_infect_if_together_on_a_day = 0.025
prob_non_c19_symptoms_per_day = 0.01
prob_test_if_requested = 1
daily_test_capacity_per_head = 0.0075
test_days_elapsed = 1
prob_tracing_given_contact = 0.8 * 0.75
simulator_periods_per_day = 1
mean_network_size = 1 + _TARGET_R0 / (DAYS_INFECTIOUS_TO_SYMPTOMS + DAYS_OF_SYMPTOMS) / PROB_INFECT_IF_TOGETHER_ON_A_DAY
_proportion_of_infected_who_get_tested = PROB_SYMPTOMATIC * PROB_APPLY_FOR_TEST_IF_SYMPTOMS * PROB_TEST_IF_REQUESTED
def set_config(obj, conf):
obj.cfg = cfg()
if conf is not None:
extra_params = conf.keys() - set(dir(obj.cfg))
if len(extra_params) > 0:
raise attribute_error(f'unrecognised parameter overrides: {extra_params}')
obj.cfg.__dict__.update(conf or {})
def print_baseline_config():
cfg = cfg()
for param in dir(cfg):
if not param.startswith('__'):
print(param, getattr(cfg, param)) |
getMappingUsageMetrics = [
{
"names": [
"TotalBandwidth",
"TotalHits",
"HitRatio"
],
"totals": [
"0.0",
"0",
"0.0"
],
"type": "TOTALS"
}
]
| get_mapping_usage_metrics = [{'names': ['TotalBandwidth', 'TotalHits', 'HitRatio'], 'totals': ['0.0', '0', '0.0'], 'type': 'TOTALS'}] |
class Solution:
def reverse(self, x: int) -> int:
l = 0
val = 0
flag = 1
if x == 0:
return x
else:
if x>0:
val = x
l = len(str(val))
else:
val = -1*x
l = len(str(val))
flag = 0
count = 10 ** (l-1)
output = 0
while count>=1:
output = output + int(val%10*count)
val=int(val//10)
count/=10
return (0,(-1*output,output) [flag==1]) [output<2**31 and (output>-1*(2**31))]
| class Solution:
def reverse(self, x: int) -> int:
l = 0
val = 0
flag = 1
if x == 0:
return x
else:
if x > 0:
val = x
l = len(str(val))
else:
val = -1 * x
l = len(str(val))
flag = 0
count = 10 ** (l - 1)
output = 0
while count >= 1:
output = output + int(val % 10 * count)
val = int(val // 10)
count /= 10
return (0, (-1 * output, output)[flag == 1])[output < 2 ** 31 and output > -1 * 2 ** 31] |
class Solution:
def oddCells(self, n: int, m: int, indices: list) -> int:
row_operation = [False] * n
col_operation = [False] * m
for index in indices:
row_id, col_id = index
row_operation[row_id] = not row_operation[row_id]
col_operation[col_id] = not col_operation[col_id]
row_operated_num = 0
col_operated_num = 0
for op in row_operation:
if op:
row_operated_num += 1
for op in col_operation:
if op:
col_operated_num += 1
return (row_operated_num * m
+ col_operated_num * n
- 2 * row_operated_num * col_operated_num)
| class Solution:
def odd_cells(self, n: int, m: int, indices: list) -> int:
row_operation = [False] * n
col_operation = [False] * m
for index in indices:
(row_id, col_id) = index
row_operation[row_id] = not row_operation[row_id]
col_operation[col_id] = not col_operation[col_id]
row_operated_num = 0
col_operated_num = 0
for op in row_operation:
if op:
row_operated_num += 1
for op in col_operation:
if op:
col_operated_num += 1
return row_operated_num * m + col_operated_num * n - 2 * row_operated_num * col_operated_num |
print("Premier programme")
nom = input("Donnez votre nom : ")
print("Bonjour %s, comment vas-tu? " % nom)
| print('Premier programme')
nom = input('Donnez votre nom : ')
print('Bonjour %s, comment vas-tu? ' % nom) |
def read_data(filename="data/input1.data"):
with open(filename) as f:
return f.read()
def rot(l, i):
offset = len(l) // 2
pos = (i+offset) % len(l)
return l[pos] if l[pos] == l[i] else 0
if __name__ == "__main__":
captcha = [int(x) for x in read_data()]
captcha.append(captcha[0])
print(sum([captcha[i] for i in range(1, len(captcha)) if captcha[i-1] == captcha[i]]))
captcha = [int(x) for x in read_data()]
total = 0
for i in range(len(captcha)):
total += rot(captcha, i)
print(total)
| def read_data(filename='data/input1.data'):
with open(filename) as f:
return f.read()
def rot(l, i):
offset = len(l) // 2
pos = (i + offset) % len(l)
return l[pos] if l[pos] == l[i] else 0
if __name__ == '__main__':
captcha = [int(x) for x in read_data()]
captcha.append(captcha[0])
print(sum([captcha[i] for i in range(1, len(captcha)) if captcha[i - 1] == captcha[i]]))
captcha = [int(x) for x in read_data()]
total = 0
for i in range(len(captcha)):
total += rot(captcha, i)
print(total) |
#################### version 1 #################################################
a = list(range(10))
# print(a, id(a))
res_1 = list(a)
# print(res_1, id(res_1))
for i in a:
if i in (3, 5):
print(">>>", i, id(i))
res_1 = list(filter(lambda x: x != i, res_1))
# print(type(res_1), id(res_1))
print(list(res_1))
#################### version 2 #################################################
b = list(range(10))
# print(b, id(b))
res_2 = list(b)
# print(res_2, id(res_2))
for i in b:
if i in {3, 5}:
print(">>>", i, id(i))
res_2 = filter(lambda x: x != i, res_2)
for w in res_2:
pass
# print(type(res_2), id(res_2))
res_2 = list(res_2)
print(list(res_2))
#################### version 3 #################################################
c = list(range(10))
# print(c, id(c))
res_3 = list(c)
# print(res_3, id(res_3))
for i in c:
if i in (3, 5):
print(">>>", i, id(i))
res_3 = filter(lambda x: x != i, res_3)
# print(type(res_3), id(res_3))
print(list(res_3))
| a = list(range(10))
res_1 = list(a)
for i in a:
if i in (3, 5):
print('>>>', i, id(i))
res_1 = list(filter(lambda x: x != i, res_1))
print(list(res_1))
b = list(range(10))
res_2 = list(b)
for i in b:
if i in {3, 5}:
print('>>>', i, id(i))
res_2 = filter(lambda x: x != i, res_2)
for w in res_2:
pass
res_2 = list(res_2)
print(list(res_2))
c = list(range(10))
res_3 = list(c)
for i in c:
if i in (3, 5):
print('>>>', i, id(i))
res_3 = filter(lambda x: x != i, res_3)
print(list(res_3)) |
def add_native_methods(clazz):
def initPbuffer__long__long__boolean__int__int__(a0, a1, a2, a3, a4, a5):
raise NotImplementedError()
clazz.initPbuffer__long__long__boolean__int__int__ = initPbuffer__long__long__boolean__int__int__
| def add_native_methods(clazz):
def init_pbuffer__long__long__boolean__int__int__(a0, a1, a2, a3, a4, a5):
raise not_implemented_error()
clazz.initPbuffer__long__long__boolean__int__int__ = initPbuffer__long__long__boolean__int__int__ |
class CompressString(object):
def compress(self, string):
if string is None or not string:
return string
result = ''
prev_char = string[0]
count = 0
for char in string:
if char == prev_char:
count += 1
else:
result += self._calc_partial_result(prev_char, count)
prev_char = char
count = 1
result += self._calc_partial_result(prev_char, count)
return result if len(result) < len(string) else string
def _calc_partial_result(self, prev_char, count):
return prev_char + (str(count) if count > 1 else '') | class Compressstring(object):
def compress(self, string):
if string is None or not string:
return string
result = ''
prev_char = string[0]
count = 0
for char in string:
if char == prev_char:
count += 1
else:
result += self._calc_partial_result(prev_char, count)
prev_char = char
count = 1
result += self._calc_partial_result(prev_char, count)
return result if len(result) < len(string) else string
def _calc_partial_result(self, prev_char, count):
return prev_char + (str(count) if count > 1 else '') |
def solution(a):
answer = 0
left_min = 1000000001
left_zero = []
reverse_a = a[::-1]
right_zero = []
right_min = 1000000001
for i in range(len(a)):
left_min = min(a[i], left_min)
if left_min == a[i]:
left_zero.append(1)
else:
left_zero.append(0)
for i in range(len(a)):
right_min = min(reverse_a[i], right_min)
if right_min == reverse_a[i]:
right_zero.append(1)
else:
right_zero.append(0)
right_zero = right_zero[::-1]
for i in range(len(right_zero)):
if left_zero[i] or right_zero[i]:
answer += 1
return answer
temp = [-16, 27, 65, -2, 58, -92, -71, -68, -61, -33]
print(solution(temp))
| def solution(a):
answer = 0
left_min = 1000000001
left_zero = []
reverse_a = a[::-1]
right_zero = []
right_min = 1000000001
for i in range(len(a)):
left_min = min(a[i], left_min)
if left_min == a[i]:
left_zero.append(1)
else:
left_zero.append(0)
for i in range(len(a)):
right_min = min(reverse_a[i], right_min)
if right_min == reverse_a[i]:
right_zero.append(1)
else:
right_zero.append(0)
right_zero = right_zero[::-1]
for i in range(len(right_zero)):
if left_zero[i] or right_zero[i]:
answer += 1
return answer
temp = [-16, 27, 65, -2, 58, -92, -71, -68, -61, -33]
print(solution(temp)) |
data = (
((-0.195090, 0.980785), (0.000000, 1.000000)),
((-0.382683, 0.923880), (-0.195090, 0.980785)),
((-0.555570, 0.831470), (-0.382683, 0.923880)),
((-0.707107, 0.707107), (-0.555570, 0.831470)),
((-0.831470, 0.555570), (-0.707107, 0.707107)),
((-0.923880, 0.382683), (-0.831470, 0.555570)),
((-0.980785, 0.195090), (-0.923880, 0.382683)),
((-0.651678, 0.500014), (0.831491, 0.344416)),
((0.831491, 0.344416), (-0.817293, 0.175582)),
((-0.882707, 0.175581), (0.768508, 0.344415)),
((0.768508, 0.344415), (-0.748323, 0.500013)),
((-0.748323, 0.500013), (0.563604, 0.636396)),
((0.563604, 0.636396), (-0.500013, 0.748323)),
((-0.500013, 0.748323), (0.255585, 0.831492)),
((0.923879, 0.382684), (0.980785, 0.195091)),
((0.831469, 0.555571), (0.923879, 0.382684)),
((0.707106, 0.707108), (0.831469, 0.555571)),
((0.555569, 0.831470), (0.707106, 0.707108)),
((0.382682, 0.923880), (0.555569, 0.831470)),
((0.195089, 0.980786), (0.382682, 0.923880)),
((0.000000, 1.000000), (0.195089, 0.980786)),
((0.255585, 0.831492), (-0.175581, 0.882707)),
((-0.175581, 0.882707), (-0.000000, 0.900000)),
((-0.399988, 0.748323), (0.636395, 0.636397)),
((0.344414, 0.831492), (-0.399988, 0.748323)),
((-0.124420, 0.882707), (0.344414, 0.831492)),
((-0.195090, -0.980785), (0.000000, -1.000000)),
((-0.382683, -0.923880), (-0.195090, -0.980785)),
((-0.555570, -0.831470), (-0.382683, -0.923880)),
((-0.707107, -0.707107), (-0.555570, -0.831470)),
((-0.831470, -0.555570), (-0.707107, -0.707107)),
((-0.923880, -0.382683), (-0.831470, -0.555570)),
((-0.980785, -0.195090), (-0.923880, -0.382683)),
((-1.000000, -0.000000), (-0.980785, -0.195090)),
((-0.651678, -0.500014), (0.831491, -0.344416)),
((0.831491, -0.344416), (-0.817293, -0.175582)),
((-0.817293, -0.175582), (0.900000, -0.000001)),
((0.800000, -0.000000), (-0.882707, -0.175581)),
((-0.882707, -0.175581), (0.768508, -0.344415)),
((0.768508, -0.344415), (-0.748323, -0.500013)),
((-0.748323, -0.500013), (0.563604, -0.636396)),
((0.563604, -0.636396), (-0.500013, -0.748323)),
((-0.500013, -0.748323), (0.255585, -0.831492)),
((0.980785, -0.195091), (1.000000, -0.000001)),
((0.923879, -0.382684), (0.980785, -0.195091)),
((0.831469, -0.555571), (0.923879, -0.382684)),
((0.707106, -0.707108), (0.831469, -0.555571)),
((0.555569, -0.831470), (0.707106, -0.707108)),
((0.382682, -0.923880), (0.555569, -0.831470)),
((0.195089, -0.980786), (0.382682, -0.923880)),
((0.000000, -1.000000), (0.195089, -0.980786)),
((0.255585, -0.831492), (-0.175581, -0.882707)),
((-0.175581, -0.882707), (-0.000000, -0.900000)),
((-0.399988, -0.748323), (0.636395, -0.636397)),
((0.344414, -0.831492), (-0.399988, -0.748323)),
((-0.124420, -0.882707), (0.344414, -0.831492)),
((-1.000000, -0.000000), (-0.980785, 0.195090)),
((-0.000000, 0.900000), (-0.124420, 0.882707)),
((0.636395, 0.636397), (-0.651678, 0.500014)),
((-0.817293, 0.175582), (0.900000, -0.000001)),
((0.800000, -0.000000), (-0.882707, 0.175581)),
((0.980785, 0.195091), (1.000000, -0.000001)),
((-0.000000, -0.900000), (-0.124420, -0.882707)),
((0.636395, -0.636397), (-0.651678, -0.500014)),
)
| data = (((-0.19509, 0.980785), (0.0, 1.0)), ((-0.382683, 0.92388), (-0.19509, 0.980785)), ((-0.55557, 0.83147), (-0.382683, 0.92388)), ((-0.707107, 0.707107), (-0.55557, 0.83147)), ((-0.83147, 0.55557), (-0.707107, 0.707107)), ((-0.92388, 0.382683), (-0.83147, 0.55557)), ((-0.980785, 0.19509), (-0.92388, 0.382683)), ((-0.651678, 0.500014), (0.831491, 0.344416)), ((0.831491, 0.344416), (-0.817293, 0.175582)), ((-0.882707, 0.175581), (0.768508, 0.344415)), ((0.768508, 0.344415), (-0.748323, 0.500013)), ((-0.748323, 0.500013), (0.563604, 0.636396)), ((0.563604, 0.636396), (-0.500013, 0.748323)), ((-0.500013, 0.748323), (0.255585, 0.831492)), ((0.923879, 0.382684), (0.980785, 0.195091)), ((0.831469, 0.555571), (0.923879, 0.382684)), ((0.707106, 0.707108), (0.831469, 0.555571)), ((0.555569, 0.83147), (0.707106, 0.707108)), ((0.382682, 0.92388), (0.555569, 0.83147)), ((0.195089, 0.980786), (0.382682, 0.92388)), ((0.0, 1.0), (0.195089, 0.980786)), ((0.255585, 0.831492), (-0.175581, 0.882707)), ((-0.175581, 0.882707), (-0.0, 0.9)), ((-0.399988, 0.748323), (0.636395, 0.636397)), ((0.344414, 0.831492), (-0.399988, 0.748323)), ((-0.12442, 0.882707), (0.344414, 0.831492)), ((-0.19509, -0.980785), (0.0, -1.0)), ((-0.382683, -0.92388), (-0.19509, -0.980785)), ((-0.55557, -0.83147), (-0.382683, -0.92388)), ((-0.707107, -0.707107), (-0.55557, -0.83147)), ((-0.83147, -0.55557), (-0.707107, -0.707107)), ((-0.92388, -0.382683), (-0.83147, -0.55557)), ((-0.980785, -0.19509), (-0.92388, -0.382683)), ((-1.0, -0.0), (-0.980785, -0.19509)), ((-0.651678, -0.500014), (0.831491, -0.344416)), ((0.831491, -0.344416), (-0.817293, -0.175582)), ((-0.817293, -0.175582), (0.9, -1e-06)), ((0.8, -0.0), (-0.882707, -0.175581)), ((-0.882707, -0.175581), (0.768508, -0.344415)), ((0.768508, -0.344415), (-0.748323, -0.500013)), ((-0.748323, -0.500013), (0.563604, -0.636396)), ((0.563604, -0.636396), (-0.500013, -0.748323)), ((-0.500013, -0.748323), (0.255585, -0.831492)), ((0.980785, -0.195091), (1.0, -1e-06)), ((0.923879, -0.382684), (0.980785, -0.195091)), ((0.831469, -0.555571), (0.923879, -0.382684)), ((0.707106, -0.707108), (0.831469, -0.555571)), ((0.555569, -0.83147), (0.707106, -0.707108)), ((0.382682, -0.92388), (0.555569, -0.83147)), ((0.195089, -0.980786), (0.382682, -0.92388)), ((0.0, -1.0), (0.195089, -0.980786)), ((0.255585, -0.831492), (-0.175581, -0.882707)), ((-0.175581, -0.882707), (-0.0, -0.9)), ((-0.399988, -0.748323), (0.636395, -0.636397)), ((0.344414, -0.831492), (-0.399988, -0.748323)), ((-0.12442, -0.882707), (0.344414, -0.831492)), ((-1.0, -0.0), (-0.980785, 0.19509)), ((-0.0, 0.9), (-0.12442, 0.882707)), ((0.636395, 0.636397), (-0.651678, 0.500014)), ((-0.817293, 0.175582), (0.9, -1e-06)), ((0.8, -0.0), (-0.882707, 0.175581)), ((0.980785, 0.195091), (1.0, -1e-06)), ((-0.0, -0.9), (-0.12442, -0.882707)), ((0.636395, -0.636397), (-0.651678, -0.500014))) |
sum = float(input())
counter_of_coins = 0
sum = int(sum*100)
counter_of_coins += sum // 200
sum = sum % 200
counter_of_coins += sum // 100
sum = sum % 100
counter_of_coins += sum // 50
sum = sum % 50
counter_of_coins += sum // 20
sum = sum % 20
counter_of_coins += sum // 10
sum = sum % 10
counter_of_coins += sum // 5
sum = sum % 5
counter_of_coins += sum // 2
sum = sum % 2
if sum == 1:
counter_of_coins += 1
print(int(counter_of_coins)) | sum = float(input())
counter_of_coins = 0
sum = int(sum * 100)
counter_of_coins += sum // 200
sum = sum % 200
counter_of_coins += sum // 100
sum = sum % 100
counter_of_coins += sum // 50
sum = sum % 50
counter_of_coins += sum // 20
sum = sum % 20
counter_of_coins += sum // 10
sum = sum % 10
counter_of_coins += sum // 5
sum = sum % 5
counter_of_coins += sum // 2
sum = sum % 2
if sum == 1:
counter_of_coins += 1
print(int(counter_of_coins)) |
def validate_string(s):
is_alpha_numeric = False
is_alpha = False
is_digits = False
is_lowercase = False
is_uppercase = False
for letter in s:
if letter.isalnum():
is_alpha_numeric = True
if letter.isalpha():
is_alpha = True
if letter.isdigit():
is_digits = True
if letter.islower():
is_lowercase = True
if letter.isupper():
is_uppercase = True
print(f'{is_alpha_numeric}\n{is_alpha}\n{is_digits}\n{is_lowercase}\n{is_uppercase}')
if __name__ == '__main__':
s = input()
validate_string(s)
| def validate_string(s):
is_alpha_numeric = False
is_alpha = False
is_digits = False
is_lowercase = False
is_uppercase = False
for letter in s:
if letter.isalnum():
is_alpha_numeric = True
if letter.isalpha():
is_alpha = True
if letter.isdigit():
is_digits = True
if letter.islower():
is_lowercase = True
if letter.isupper():
is_uppercase = True
print(f'{is_alpha_numeric}\n{is_alpha}\n{is_digits}\n{is_lowercase}\n{is_uppercase}')
if __name__ == '__main__':
s = input()
validate_string(s) |
class TestScheduleJobFileData:
test_job_connection = {
"Name": "TestIntegrationConnection",
"ConnectorTypeName": "POSTGRESQL",
"Host": "localhost",
"Port": 5432,
"Sid": "",
"DatabaseName": "test_pdi_integration",
"User": "postgres",
"Password": "123456"
}
test_file_connection = {
"Name": "TestIntegrationConnectionFile",
"ConnectorTypeName": "CSV",
"Host": "",
"Port": 0,
"User": "",
"Password": ""
}
test_data_operation = {
"Name": "TEST_JOB_FILE_DATA_OPERATION",
"Contacts": [
{"Email": "ahmetcagriakca@gmail.com"}
],
"Integrations": [
{
"Limit": 100,
"ProcessCount": 1,
"Integration": {
"Code": "TEST_CSV_TO_DB_INTEGRATION",
"SourceConnections": {
"ConnectionName": "TestIntegrationConnectionFile",
"File": {
"Folder": "",
"FileName": "test.csv",
"Csv": {
"HasHeader": True,
"Header": "Id;Name",
"Separator": ";",
}
},
"Columns": "Id,Name",
},
"TargetConnections": {
"ConnectionName": "TestIntegrationConnection",
"Database": {
"Schema": "test",
"TableName": "test_integration_target",
"Query": ""
},
"Columns": "Id,Name",
},
"IsTargetTruncate": True,
"IsDelta": True,
"Comments": "Test data_integration record",
}
},
{
"Limit": 100,
"ProcessCount": 1,
"Integration": {
"Code": "TEST_DB_TO_CSV_NONE_HEADER_INTEGRATION",
"SourceConnections": {
"ConnectionName": "TestIntegrationConnection",
"Database": {
"Schema": "test",
"TableName": "test_integration_target",
"Query": ""
},
"Columns": "Id,Name",
},
"TargetConnections": {
"ConnectionName": "TestIntegrationConnectionFile",
"File": {
"Folder": "",
"FileName": "test_new_none_header.csv",
"Csv": {
"HasHeader": False,
"Header": "",
"Separator": ",",
}
},
"Columns": "Id,Name",
},
"IsTargetTruncate": True,
"IsDelta": True,
"Comments": "Test data_integration record",
}
},
{
"Limit": 100,
"ProcessCount": 1,
"Integration": {
"Code": "TEST_CSV_TO_CSV_INTEGRATION_WITHOUT_HEADER",
"SourceConnections": {
"ConnectionName": "TestIntegrationConnectionFile",
"File": {
"Folder": "",
"FileName": "test_new_none_header.csv",
"Csv": {
"HasHeader": False,
"Header": "Id,Name",
"Separator": ",",
}
},
"Columns": "Name,Id",
},
"TargetConnections": {
"ConnectionName": "TestIntegrationConnectionFile",
"File": {
"Folder": "",
"FileName": "test_new_change_column_order.csv",
"Csv": {
"HasHeader": True,
"Header": "Name;Id",
"Separator": ";",
}
},
"Columns": "Name,Id",
},
"IsTargetTruncate": True,
"IsDelta": True,
"Comments": "Test data_integration record",
}
},
{
"Limit": 100,
"ProcessCount": 1,
"Integration": {
"Code": "TEST_CSV_TO_CSV_INTEGRATION",
"SourceConnections": {
"ConnectionName": "TestIntegrationConnectionFile",
"File": {
"Folder": "",
"FileName": "test_new_none_header.csv",
"Csv": {
"HasHeader": False,
"Header": "Id,Name",
"Separator": ",",
}
},
"Columns": "Id",
},
"TargetConnections": {
"ConnectionName": "TestIntegrationConnectionFile",
"File": {
"Folder": "",
"FileName": "test_new_only_id.csv",
"Csv": {
"HasHeader": True,
"Header": "Id",
"Separator": ";",
}
},
"Columns": "Id",
},
"IsTargetTruncate": True,
"IsDelta": True,
"Comments": "Test data_integration record",
}
},
]
}
| class Testschedulejobfiledata:
test_job_connection = {'Name': 'TestIntegrationConnection', 'ConnectorTypeName': 'POSTGRESQL', 'Host': 'localhost', 'Port': 5432, 'Sid': '', 'DatabaseName': 'test_pdi_integration', 'User': 'postgres', 'Password': '123456'}
test_file_connection = {'Name': 'TestIntegrationConnectionFile', 'ConnectorTypeName': 'CSV', 'Host': '', 'Port': 0, 'User': '', 'Password': ''}
test_data_operation = {'Name': 'TEST_JOB_FILE_DATA_OPERATION', 'Contacts': [{'Email': 'ahmetcagriakca@gmail.com'}], 'Integrations': [{'Limit': 100, 'ProcessCount': 1, 'Integration': {'Code': 'TEST_CSV_TO_DB_INTEGRATION', 'SourceConnections': {'ConnectionName': 'TestIntegrationConnectionFile', 'File': {'Folder': '', 'FileName': 'test.csv', 'Csv': {'HasHeader': True, 'Header': 'Id;Name', 'Separator': ';'}}, 'Columns': 'Id,Name'}, 'TargetConnections': {'ConnectionName': 'TestIntegrationConnection', 'Database': {'Schema': 'test', 'TableName': 'test_integration_target', 'Query': ''}, 'Columns': 'Id,Name'}, 'IsTargetTruncate': True, 'IsDelta': True, 'Comments': 'Test data_integration record'}}, {'Limit': 100, 'ProcessCount': 1, 'Integration': {'Code': 'TEST_DB_TO_CSV_NONE_HEADER_INTEGRATION', 'SourceConnections': {'ConnectionName': 'TestIntegrationConnection', 'Database': {'Schema': 'test', 'TableName': 'test_integration_target', 'Query': ''}, 'Columns': 'Id,Name'}, 'TargetConnections': {'ConnectionName': 'TestIntegrationConnectionFile', 'File': {'Folder': '', 'FileName': 'test_new_none_header.csv', 'Csv': {'HasHeader': False, 'Header': '', 'Separator': ','}}, 'Columns': 'Id,Name'}, 'IsTargetTruncate': True, 'IsDelta': True, 'Comments': 'Test data_integration record'}}, {'Limit': 100, 'ProcessCount': 1, 'Integration': {'Code': 'TEST_CSV_TO_CSV_INTEGRATION_WITHOUT_HEADER', 'SourceConnections': {'ConnectionName': 'TestIntegrationConnectionFile', 'File': {'Folder': '', 'FileName': 'test_new_none_header.csv', 'Csv': {'HasHeader': False, 'Header': 'Id,Name', 'Separator': ','}}, 'Columns': 'Name,Id'}, 'TargetConnections': {'ConnectionName': 'TestIntegrationConnectionFile', 'File': {'Folder': '', 'FileName': 'test_new_change_column_order.csv', 'Csv': {'HasHeader': True, 'Header': 'Name;Id', 'Separator': ';'}}, 'Columns': 'Name,Id'}, 'IsTargetTruncate': True, 'IsDelta': True, 'Comments': 'Test data_integration record'}}, {'Limit': 100, 'ProcessCount': 1, 'Integration': {'Code': 'TEST_CSV_TO_CSV_INTEGRATION', 'SourceConnections': {'ConnectionName': 'TestIntegrationConnectionFile', 'File': {'Folder': '', 'FileName': 'test_new_none_header.csv', 'Csv': {'HasHeader': False, 'Header': 'Id,Name', 'Separator': ','}}, 'Columns': 'Id'}, 'TargetConnections': {'ConnectionName': 'TestIntegrationConnectionFile', 'File': {'Folder': '', 'FileName': 'test_new_only_id.csv', 'Csv': {'HasHeader': True, 'Header': 'Id', 'Separator': ';'}}, 'Columns': 'Id'}, 'IsTargetTruncate': True, 'IsDelta': True, 'Comments': 'Test data_integration record'}}]} |
def func(a, b=5, c=10):
print('a equals {}, b equals {}, and c equals {}'.format(a, b, c))
func(3, 7)
func(25, c=24)
func(c=50, a=100)
| def func(a, b=5, c=10):
print('a equals {}, b equals {}, and c equals {}'.format(a, b, c))
func(3, 7)
func(25, c=24)
func(c=50, a=100) |
def isPrime(number):
if number > 1:
for i in range(2, number):
if (number % i) == 0:
return False
else:
return True
else:
return False
inputFile = open('test.txt')
lines = inputFile.readlines()
inputFile.close()
pyramid = []
for i in lines:
print(i)
for line in lines:
pyramid.append(line.split())
for i in range(0,len(pyramid)):
for j in range(0,len(pyramid[i])):
pyramid[i][j] = int(pyramid[i][j])
for i in range(len(pyramid)-2, -1, -1):
for j in range(0, len(pyramid[i])):
if isPrime(pyramid[i][j]) == False:
pyramid[i][j] += max(pyramid[i+1][j], pyramid[i+1][j+1])
print('\nThe maximum sum of the numbers is',max(pyramid)[0]) | def is_prime(number):
if number > 1:
for i in range(2, number):
if number % i == 0:
return False
else:
return True
else:
return False
input_file = open('test.txt')
lines = inputFile.readlines()
inputFile.close()
pyramid = []
for i in lines:
print(i)
for line in lines:
pyramid.append(line.split())
for i in range(0, len(pyramid)):
for j in range(0, len(pyramid[i])):
pyramid[i][j] = int(pyramid[i][j])
for i in range(len(pyramid) - 2, -1, -1):
for j in range(0, len(pyramid[i])):
if is_prime(pyramid[i][j]) == False:
pyramid[i][j] += max(pyramid[i + 1][j], pyramid[i + 1][j + 1])
print('\nThe maximum sum of the numbers is', max(pyramid)[0]) |
def verify(output):
scopes = False
fail = False
for line in output.split('\n'):
if scopes:
if line.startswith(' '):
name,size = [x.strip() for x in line.split('-')]
if size != '0':
print("unfreed memory in scope",name,":",size)
fail = True
continue
if line.startswith('Unfreed memory'):
scopes = True
if not fail:
raise Exception('expected unfreed memory, but didn\'t fined it') | def verify(output):
scopes = False
fail = False
for line in output.split('\n'):
if scopes:
if line.startswith(' '):
(name, size) = [x.strip() for x in line.split('-')]
if size != '0':
print('unfreed memory in scope', name, ':', size)
fail = True
continue
if line.startswith('Unfreed memory'):
scopes = True
if not fail:
raise exception("expected unfreed memory, but didn't fined it") |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.