content
stringlengths 7
1.05M
| fixed_cases
stringlengths 1
1.28M
|
---|---|
# Next Greater Element I: https://leetcode.com/problems/next-greater-element-i/
# The next greater element of some element x in an array is the first greater element that is to the right of x in the same array.
# You are given two distinct 0-indexed integer arrays nums1 and nums2, where nums1 is a subset of nums2.
# For each 0 <= i < nums1.length, find the index j such that nums1[i] == nums2[j] and determine the next greater element of nums2[j] in nums2. If there is no next greater element, then the answer for this query is -1.
# Return an array ans of length nums1.length such that ans[i] is the next greater element as described above.
# The simple solution is to for each i in nums1 search for it in 2 and then find the first largest number after that this will run in o(N^2) and o(N) space as we have to append it to a result
# This is quite a tricky mouthful of a solution basically we need to create a dictionary of the next highest value of every number
# however to do this we will need to implement a stack. Luckily we can bulid this dict in o(N) time and using o(N) space so it ever so slightly optimized
# as we will not be evaluating the same two numbers twice
class Solution:
def nextGreaterElement(self, nums1, nums2):
nextGreater = {}
stack = []
for num in nums2:
while len(stack) > 0 and num > stack[-1]:
nextGreater[stack.pop()] = num
stack.append(num)
# while len(stack) > 0:
# nextGreater[stack.pop()] = -1
result = []
for num in nums1:
result.append(nextGreater.get(num, -1))
return result
# This is a super simple stack scanning solution because we can always see the number we are at and then you can check if the last n numbers were less than its value
# this solution will run in o(M+N) time and space as we will have to iterate through both nums array and store the result in a dict or in result
# Score Card
# Did I need hints? N
# Did you finish within 30 min? 10
# Was the solution optimal? Oh yea
# Were there any bugs? None submitted with 0 issue first try
# 5 5 5 5 = 5
| class Solution:
def next_greater_element(self, nums1, nums2):
next_greater = {}
stack = []
for num in nums2:
while len(stack) > 0 and num > stack[-1]:
nextGreater[stack.pop()] = num
stack.append(num)
result = []
for num in nums1:
result.append(nextGreater.get(num, -1))
return result |
'''
@Date: 2019-12-22 20:38:38
@Author: ywyz
@LastModifiedBy: ywyz
@Github: https://github.com/ywyz
@LastEditors : ywyz
@LastEditTime : 2019-12-22 20:52:02
'''
strings = input("Enter the first 12 digits of an ISBN-13 as a string: ")
temp = 1
total = 0
for i in strings:
if temp % 2 == 0:
total += 3 * int(i)
else:
total += int(i)
temp += 1
total = 10 - total % 10
if total == 10:
total = 0
strings = strings + str(total)
print("The ISBN-13 number is ", strings)
| """
@Date: 2019-12-22 20:38:38
@Author: ywyz
@LastModifiedBy: ywyz
@Github: https://github.com/ywyz
@LastEditors : ywyz
@LastEditTime : 2019-12-22 20:52:02
"""
strings = input('Enter the first 12 digits of an ISBN-13 as a string: ')
temp = 1
total = 0
for i in strings:
if temp % 2 == 0:
total += 3 * int(i)
else:
total += int(i)
temp += 1
total = 10 - total % 10
if total == 10:
total = 0
strings = strings + str(total)
print('The ISBN-13 number is ', strings) |
def count_up_to(max):
count = 1
while count <= max:
yield count
count += 1
counter = count_up_to(5)
for num in counter:
print(num) | def count_up_to(max):
count = 1
while count <= max:
yield count
count += 1
counter = count_up_to(5)
for num in counter:
print(num) |
__strict__ = True
class SpotifyOauthError(Exception):
pass
class SpotifyRepositoryError(Exception):
def __init__(self, http_status: int, body: str):
self.http_status = http_status
self.body = body
def __str__(self):
return 'http status: {0}, code:{1}'.format(str(self.http_status), self.body)
| __strict__ = True
class Spotifyoautherror(Exception):
pass
class Spotifyrepositoryerror(Exception):
def __init__(self, http_status: int, body: str):
self.http_status = http_status
self.body = body
def __str__(self):
return 'http status: {0}, code:{1}'.format(str(self.http_status), self.body) |
# program numbers
BASIC = 140624
GOTO = 158250875866513204219300194287615
VARIABLES = 6198727823
| basic = 140624
goto = 158250875866513204219300194287615
variables = 6198727823 |
ENV_NAMES = {
"PASSWORD": "DECT_MAIL_EXTRACT_PASSWORD",
"USERNAME": "DECT_MAIL_EXTRACT_USER",
"SERVER": "DECT_MAIL_EXTRACT_SERVER",
}
| env_names = {'PASSWORD': 'DECT_MAIL_EXTRACT_PASSWORD', 'USERNAME': 'DECT_MAIL_EXTRACT_USER', 'SERVER': 'DECT_MAIL_EXTRACT_SERVER'} |
@customop('numpy')
def my_softmax(x, y):
probs = numpy.exp(x - numpy.max(x, axis=1, keepdims=True))
probs /= numpy.sum(probs, axis=1, keepdims=True)
N = x.shape[0]
loss = -numpy.sum(numpy.log(probs[numpy.arange(N), y])) / N
return loss
def my_softmax_grad(ans, x, y):
def grad(g):
N = x.shape[0]
probs = numpy.exp(x - numpy.max(x, axis=1, keepdims=True))
probs /= numpy.sum(probs, axis=1, keepdims=True)
probs[numpy.arange(N), y] -= 1
probs /= N
return probs
return grad
my_softmax.def_grad(my_softmax_grad)
| @customop('numpy')
def my_softmax(x, y):
probs = numpy.exp(x - numpy.max(x, axis=1, keepdims=True))
probs /= numpy.sum(probs, axis=1, keepdims=True)
n = x.shape[0]
loss = -numpy.sum(numpy.log(probs[numpy.arange(N), y])) / N
return loss
def my_softmax_grad(ans, x, y):
def grad(g):
n = x.shape[0]
probs = numpy.exp(x - numpy.max(x, axis=1, keepdims=True))
probs /= numpy.sum(probs, axis=1, keepdims=True)
probs[numpy.arange(N), y] -= 1
probs /= N
return probs
return grad
my_softmax.def_grad(my_softmax_grad) |
class MdFile():
def __init__(self, file_path, base_name, title, mdlinks):
self.uid = 0
self.file_path = file_path
self.base_name = base_name
self.title = title if title else base_name
self.mdlinks = mdlinks
def __str__(self):
return f'{self.uid}: {self.file_path}, {self.title}, {self.mdlinks}'
| class Mdfile:
def __init__(self, file_path, base_name, title, mdlinks):
self.uid = 0
self.file_path = file_path
self.base_name = base_name
self.title = title if title else base_name
self.mdlinks = mdlinks
def __str__(self):
return f'{self.uid}: {self.file_path}, {self.title}, {self.mdlinks}' |
#/* *** ODSATag: MinVertex *** */
# Find the unvisited vertex with the smalled distance
def minVertex(G, D):
v = 0 # Initialize v to any unvisited vertex
for i in range(G.nodeCount()):
if G.getValue(i) != VISITED:
v = i
break
for i in range(G.nodeCount()): # Now find smallest value
if G.getValue(i) != VISITED and D[i] < D[v]:
v = i
return v
#/* *** ODSAendTag: MinVertex *** */
#/* *** ODSATag: GraphDijk1 *** */
# Compute shortest path distances from s, store them in D
def Dijkstra(G, s, D):
for i in range(G.nodeCount()): # Initialize
D[i] = INFINITY
D[s] = 0
for i in range(G.nodeCount()): # Process the vertices
v = minVertex(G, D) # Find next-closest vertex
G.setValue(v, VISITED)
if D[v] == INFINITY:
return # Unreachable
for w in G.neighbors(v):
if D[w] > D[v] + G.weight(v, w):
D[w] = D[v] + G.weight(v, w)
#/* *** ODSAendTag: GraphDijk1 *** */
| def min_vertex(G, D):
v = 0
for i in range(G.nodeCount()):
if G.getValue(i) != VISITED:
v = i
break
for i in range(G.nodeCount()):
if G.getValue(i) != VISITED and D[i] < D[v]:
v = i
return v
def dijkstra(G, s, D):
for i in range(G.nodeCount()):
D[i] = INFINITY
D[s] = 0
for i in range(G.nodeCount()):
v = min_vertex(G, D)
G.setValue(v, VISITED)
if D[v] == INFINITY:
return
for w in G.neighbors(v):
if D[w] > D[v] + G.weight(v, w):
D[w] = D[v] + G.weight(v, w) |
config = {
# --------------------------------------------------------------------------
# Database Connections
# --------------------------------------------------------------------------
'database': {
'default': 'auth',
'connections': {
# SQLite
# 'auth': {
# 'driver': 'sqlite',
# 'dialect': None,
# 'host': None,
# 'port': None,
# 'database': ':memory',
# 'username': None,
# 'password': None,
# 'prefix': 'auth_',
# },
# MySQL
'auth': {
'driver': 'mysql',
'dialect': 'pymysql',
'host': '127.0.0.1',
'port': 3306,
'database': 'uvicore_test',
'username': 'root',
'password': 'techie',
'prefix': 'auth_',
},
},
},
}
| config = {'database': {'default': 'auth', 'connections': {'auth': {'driver': 'mysql', 'dialect': 'pymysql', 'host': '127.0.0.1', 'port': 3306, 'database': 'uvicore_test', 'username': 'root', 'password': 'techie', 'prefix': 'auth_'}}}} |
data = open('output_dataset_ALL.txt').readlines()
original = open('dataset_ALL.txt').readlines()
#data = open('dataset.txt').readlines()
out = open('output_gcode_merged.gcode', 'w')
for j in range(len(data)/4):
i = j*4
x = data[i].strip()
y = data[i+1].strip()
z = original[i+2].strip()
e = original[i+3].strip()
out.write('G1 X' + x[:-2] + ' Y' + y[:-2] + ' Z' + z[:-2] + ' E' + e + '\n')
out.close()
| data = open('output_dataset_ALL.txt').readlines()
original = open('dataset_ALL.txt').readlines()
out = open('output_gcode_merged.gcode', 'w')
for j in range(len(data) / 4):
i = j * 4
x = data[i].strip()
y = data[i + 1].strip()
z = original[i + 2].strip()
e = original[i + 3].strip()
out.write('G1 X' + x[:-2] + ' Y' + y[:-2] + ' Z' + z[:-2] + ' E' + e + '\n')
out.close() |
##
# Copyright 2018, Ammar Ali Khan
# Licensed under MIT.
##
# Application configuration
APPLICATION_NAME = ''
APPLICATION_VERSION = '1.0.1'
# HTTP Port for web streaming
HTTP_PORT = 8000
# HTTP page template path
HTML_TEMPLATE_PATH = './src/common/package/http/template'
# Capturing device index (used for web camera)
CAPTURING_DEVICE = 0
# To user Pi Camera
USE_PI_CAMERA = True
# Capture configuration
WIDTH = 640
HEIGHT = 480
RESOLUTION = [WIDTH, HEIGHT]
FRAME_RATE = 24
# Storage configuration
DATABASE_NAME = 'database.db'
STORAGE_DIRECTORY = './dataset/'
UNKNOWN_PREFIX = 'unknown'
FILE_EXTENSION = '.pgm'
| application_name = ''
application_version = '1.0.1'
http_port = 8000
html_template_path = './src/common/package/http/template'
capturing_device = 0
use_pi_camera = True
width = 640
height = 480
resolution = [WIDTH, HEIGHT]
frame_rate = 24
database_name = 'database.db'
storage_directory = './dataset/'
unknown_prefix = 'unknown'
file_extension = '.pgm' |
Total_Fuel_Need =0
Data_File = open("Day1_Data.txt")
Data_Lines = Data_File.readlines()
for i in range(len(Data_Lines)):
Data_Lines[i] = int(Data_Lines[i].rstrip('\n'))
Total_Fuel_Need += int(Data_Lines[i] / 3) - 2
print(Total_Fuel_Need)
| total__fuel__need = 0
data__file = open('Day1_Data.txt')
data__lines = Data_File.readlines()
for i in range(len(Data_Lines)):
Data_Lines[i] = int(Data_Lines[i].rstrip('\n'))
total__fuel__need += int(Data_Lines[i] / 3) - 2
print(Total_Fuel_Need) |
# This sample tests the special-case handling of Self when comparing
# two functions whose signatures differ only in the Self scope.
class SomeClass:
def __str__(self) -> str:
...
__repr__ = __str__
| class Someclass:
def __str__(self) -> str:
...
__repr__ = __str__ |
lines = open("input").read().strip().splitlines()
print("--- Day11 ---")
class Seat:
directions = [
(dx, dy) for dx in [-1, 0, 1] for dy in [-1, 0, 1] if (dx, dy) != (0, 0)
]
def __init__(self, x, y, dx, dy):
self.x = x
self.y = y
self.dx = dx
self.dy = dy
def p1(part2=False):
G, rows, columns = load_grid(lines)
i = 0
while True:
i += 1
NG = {}
for x in range(rows):
for y in range(columns):
other = [Seat(x + d[0], y + d[1], *d) for d in Seat.directions]
adjacent = 4
if part2:
for seat in other:
while G.get((seat.x, seat.y)) == ".":
seat.x += seat.dx
seat.y += seat.dy
adjacent = 5
other = [G[s.x, s.y] for s in other if (s.x, s.y) in G]
if G[x, y] == "L" and all(s != "#" for s in other):
NG[x, y] = "#"
elif G[x, y] == "#" and (sum([s == "#" for s in other]) >= adjacent):
NG[x, y] = "L"
else:
NG[x, y] = G[x, y]
if G == NG:
break
G = NG
print(sum([cell == "#" for cell in G.values()]))
def p2():
p1(part2=True)
def load_grid(lines):
G = {}
first_row = lines[0]
for y, line in enumerate(lines):
# Check if grid is really a grid.
assert len(line) == len(first_row)
for x, ch in enumerate(line):
G[y, x] = ch
rows = len(lines)
columns = len(first_row)
return G, rows, columns
def print_grid(grid, maxx, maxy, zfill_padding=3):
header = [" " * zfill_padding, " "]
for x in range(maxx):
header.append(str(x % 10))
print("".join(header))
for y in range(maxy):
row = [str(y).zfill(zfill_padding), " "]
for x in range(maxx):
row.append(grid[x, y])
print("".join(row))
print("Part1")
p1()
print("Part2")
p2()
print("---- EOD ----")
| lines = open('input').read().strip().splitlines()
print('--- Day11 ---')
class Seat:
directions = [(dx, dy) for dx in [-1, 0, 1] for dy in [-1, 0, 1] if (dx, dy) != (0, 0)]
def __init__(self, x, y, dx, dy):
self.x = x
self.y = y
self.dx = dx
self.dy = dy
def p1(part2=False):
(g, rows, columns) = load_grid(lines)
i = 0
while True:
i += 1
ng = {}
for x in range(rows):
for y in range(columns):
other = [seat(x + d[0], y + d[1], *d) for d in Seat.directions]
adjacent = 4
if part2:
for seat in other:
while G.get((seat.x, seat.y)) == '.':
seat.x += seat.dx
seat.y += seat.dy
adjacent = 5
other = [G[s.x, s.y] for s in other if (s.x, s.y) in G]
if G[x, y] == 'L' and all((s != '#' for s in other)):
NG[x, y] = '#'
elif G[x, y] == '#' and sum([s == '#' for s in other]) >= adjacent:
NG[x, y] = 'L'
else:
NG[x, y] = G[x, y]
if G == NG:
break
g = NG
print(sum([cell == '#' for cell in G.values()]))
def p2():
p1(part2=True)
def load_grid(lines):
g = {}
first_row = lines[0]
for (y, line) in enumerate(lines):
assert len(line) == len(first_row)
for (x, ch) in enumerate(line):
G[y, x] = ch
rows = len(lines)
columns = len(first_row)
return (G, rows, columns)
def print_grid(grid, maxx, maxy, zfill_padding=3):
header = [' ' * zfill_padding, ' ']
for x in range(maxx):
header.append(str(x % 10))
print(''.join(header))
for y in range(maxy):
row = [str(y).zfill(zfill_padding), ' ']
for x in range(maxx):
row.append(grid[x, y])
print(''.join(row))
print('Part1')
p1()
print('Part2')
p2()
print('---- EOD ----') |
#list = [1,2,3,4,5]
arr = list(range(1,6))
count = 0
#print(arr)
#for i in arr:
#print(i)
list = ["a","b","c","d","e"]
for index in range(len(arr)):
print(f'Phan tu tai vi tri {index} cua arr la : {list[index]}')
count += 1
print(count)
| arr = list(range(1, 6))
count = 0
list = ['a', 'b', 'c', 'd', 'e']
for index in range(len(arr)):
print(f'Phan tu tai vi tri {index} cua arr la : {list[index]}')
count += 1
print(count) |
def baseline3(X):
return (
X['ABS']
| X['INT']
| X['UINT']
| (X['TDEP'] > X['TDEP'].mean())
| (X['FIELD'] > X['FIELD'].mean())
| ((X['UAPI']+X['TUAPI']) > (X['UAPI']+X['TUAPI']).mean())
| (X['EXPCAT'] > 0)
| (X['RBFA'] > 0)
| (X['CONDCALL'] > 0)
| (X['SYNC'] > X['SYNC'].mean())
| (X['AFPR'] > 0)
)
| def baseline3(X):
return X['ABS'] | X['INT'] | X['UINT'] | (X['TDEP'] > X['TDEP'].mean()) | (X['FIELD'] > X['FIELD'].mean()) | (X['UAPI'] + X['TUAPI'] > (X['UAPI'] + X['TUAPI']).mean()) | (X['EXPCAT'] > 0) | (X['RBFA'] > 0) | (X['CONDCALL'] > 0) | (X['SYNC'] > X['SYNC'].mean()) | (X['AFPR'] > 0) |
def search_in_rotated_array(alist, k, leftix=0, rightix=None):
if not rightix:
rightix = len(alist)
midpoint = (leftix + rightix) / 2
aleft, amiddle = alist[leftix], alist[midpoint]
if k == amiddle:
return midpoint
if k == aleft:
return leftix
if aleft > amiddle:
if amiddle < k and k < aleft:
return search_in_rotated_array(alist, k, midpoint+1, rightix)
else:
return search_in_rotated_array(alist, k, leftix+1, midpoint)
elif aleft < k and k < amiddle:
return search_in_rotated_array(alist, k, leftix+1, midpoint)
else:
return search_in_rotated_array(alist, k, midpoint+1, rightix)
array = [55, 60, 65, 70, 75, 80, 85, 90, 95, 15, 20, 25, 30, 35, 40, 45]
print(search_in_rotated_array(array, 40))
| def search_in_rotated_array(alist, k, leftix=0, rightix=None):
if not rightix:
rightix = len(alist)
midpoint = (leftix + rightix) / 2
(aleft, amiddle) = (alist[leftix], alist[midpoint])
if k == amiddle:
return midpoint
if k == aleft:
return leftix
if aleft > amiddle:
if amiddle < k and k < aleft:
return search_in_rotated_array(alist, k, midpoint + 1, rightix)
else:
return search_in_rotated_array(alist, k, leftix + 1, midpoint)
elif aleft < k and k < amiddle:
return search_in_rotated_array(alist, k, leftix + 1, midpoint)
else:
return search_in_rotated_array(alist, k, midpoint + 1, rightix)
array = [55, 60, 65, 70, 75, 80, 85, 90, 95, 15, 20, 25, 30, 35, 40, 45]
print(search_in_rotated_array(array, 40)) |
'''
https://www.codingame.com/training/easy/brackets-extreme-edition
'''
e = input()
d = {')': '(', ']': '[', '}': '{'}
s = []
for c in e:
if c in d.values():
s.append(c)
elif c in d.keys():
if len(s) == 0:
print("false")
exit(0)
else:
if d[c] == s.pop():
pass
else:
print("false")
exit(0)
if len(s) == 0:
print("true")
else:
print("false")
| """
https://www.codingame.com/training/easy/brackets-extreme-edition
"""
e = input()
d = {')': '(', ']': '[', '}': '{'}
s = []
for c in e:
if c in d.values():
s.append(c)
elif c in d.keys():
if len(s) == 0:
print('false')
exit(0)
elif d[c] == s.pop():
pass
else:
print('false')
exit(0)
if len(s) == 0:
print('true')
else:
print('false') |
#!/usr/bin/env python
# from .api import SteamAPI
class SteamUser(object):
def __init__(self, steam_id=None, steam_api=None, **kwargs):
self.steam_id = steam_id
self.steam_api = steam_api
self.__dict__.update(**kwargs)
self._friends = None
self._games = None
self._profile_data = None
self._profile_data_items = [
u'steamid', u'primaryclanid', u'realname', u'personaname',
u'personastate', u'personastateflags', u'communityvisibilitystate',
u'loccountrycode', u'profilestate', u'profileurl', u'timecreated',
u'avatar', u'commentpermission', u'avatarfull', u'avatarmedium',
u'lastlogoff'
]
@property
def friends(self, steam_id=None):
if self._friends:
return self._friends
self._friends = self.get_friends_list(steam_id=steam_id)
return self._friends
def Game(self, app_id):
return Game(app_id=app_id, steam_api=self.steam_api, owner=self)
@property
def games(self):
if self._games:
return self._games
self._games = self.get_games_list()
return self._games
@property
def games_set(self):
return set([_.app_id for _ in self.games])
def _profile_property_wrapper(self, profile_data, key):
if self._profile_data:
return self._profile_data.get(key)
self._profile_data = profile_data
return self._profile_data.get(key)
def __getattr__(self, key):
if key in self._profile_data_items:
self._profile_data = self.get_profile()
return self._profile_data.get(key)
return super(SteamUser, self).__getattribute__(key)()
def get_profile(self, steam_id=None):
if self._profile_data:
return self._profile_data
if steam_id:
self.steam_id = steam_id
response_json = self.steam_api.get(
'ISteamUser', 'GetPlayerSummaries',
version='v0002', steamids=self.steam_id
)
# Make this better
return response_json.get('response', {}).get('players', [])[0]
def get_friends_list(self, steam_id=None):
if steam_id:
self.steam_id = steam_id
response_json = self.steam_api.get('ISteamUser', 'GetFriendList', steamid=self.steam_id)
for friend in response_json.get('friendslist', {}).get('friends', []):
yield SteamUser(
steam_id=friend.get('steamid'),
steam_api=self.steam_api,
friend_since=friend.get('friend_since')
)
def get_games_list(self, steam_id=None):
if steam_id:
self.steam_id = steam_id
game_list = self.steam_api.get(
'IPlayerService', 'GetOwnedGames',
steamid=self.steam_id
)
for game in game_list.get('response', {}).get('games', []):
yield Game(app_id=game.get('appid'), owner=self)
def __repr__(self):
return "<SteamUser:{.steam_id}>".format(self)
| class Steamuser(object):
def __init__(self, steam_id=None, steam_api=None, **kwargs):
self.steam_id = steam_id
self.steam_api = steam_api
self.__dict__.update(**kwargs)
self._friends = None
self._games = None
self._profile_data = None
self._profile_data_items = [u'steamid', u'primaryclanid', u'realname', u'personaname', u'personastate', u'personastateflags', u'communityvisibilitystate', u'loccountrycode', u'profilestate', u'profileurl', u'timecreated', u'avatar', u'commentpermission', u'avatarfull', u'avatarmedium', u'lastlogoff']
@property
def friends(self, steam_id=None):
if self._friends:
return self._friends
self._friends = self.get_friends_list(steam_id=steam_id)
return self._friends
def game(self, app_id):
return game(app_id=app_id, steam_api=self.steam_api, owner=self)
@property
def games(self):
if self._games:
return self._games
self._games = self.get_games_list()
return self._games
@property
def games_set(self):
return set([_.app_id for _ in self.games])
def _profile_property_wrapper(self, profile_data, key):
if self._profile_data:
return self._profile_data.get(key)
self._profile_data = profile_data
return self._profile_data.get(key)
def __getattr__(self, key):
if key in self._profile_data_items:
self._profile_data = self.get_profile()
return self._profile_data.get(key)
return super(SteamUser, self).__getattribute__(key)()
def get_profile(self, steam_id=None):
if self._profile_data:
return self._profile_data
if steam_id:
self.steam_id = steam_id
response_json = self.steam_api.get('ISteamUser', 'GetPlayerSummaries', version='v0002', steamids=self.steam_id)
return response_json.get('response', {}).get('players', [])[0]
def get_friends_list(self, steam_id=None):
if steam_id:
self.steam_id = steam_id
response_json = self.steam_api.get('ISteamUser', 'GetFriendList', steamid=self.steam_id)
for friend in response_json.get('friendslist', {}).get('friends', []):
yield steam_user(steam_id=friend.get('steamid'), steam_api=self.steam_api, friend_since=friend.get('friend_since'))
def get_games_list(self, steam_id=None):
if steam_id:
self.steam_id = steam_id
game_list = self.steam_api.get('IPlayerService', 'GetOwnedGames', steamid=self.steam_id)
for game in game_list.get('response', {}).get('games', []):
yield game(app_id=game.get('appid'), owner=self)
def __repr__(self):
return '<SteamUser:{.steam_id}>'.format(self) |
class Solution:
def solve(self, matrix):
if matrix[0][0] == 1: return -1
R,C = len(matrix),len(matrix[0])
bfs = deque([[0,0]])
dists = {(0,0): 1}
while bfs:
r,c = bfs.popleft()
if (r,c) == (R-1,C-1): return dists[r,c]
for nr,nc in [[r-1,c],[r+1,c],[r,c-1],[r,c+1]]:
if 0<=nr<R and 0<=nc<C and (nr,nc) not in dists and matrix[nr][nc] == 0:
dists[nr,nc] = dists[r,c] + 1
bfs.append((nr,nc))
return -1
| class Solution:
def solve(self, matrix):
if matrix[0][0] == 1:
return -1
(r, c) = (len(matrix), len(matrix[0]))
bfs = deque([[0, 0]])
dists = {(0, 0): 1}
while bfs:
(r, c) = bfs.popleft()
if (r, c) == (R - 1, C - 1):
return dists[r, c]
for (nr, nc) in [[r - 1, c], [r + 1, c], [r, c - 1], [r, c + 1]]:
if 0 <= nr < R and 0 <= nc < C and ((nr, nc) not in dists) and (matrix[nr][nc] == 0):
dists[nr, nc] = dists[r, c] + 1
bfs.append((nr, nc))
return -1 |
class Solution:
def rob(self, nums: list[int]) -> int:
if len(nums) == 0:
return 0
max_loot: list[int] = [0 for _ in nums]
for index, num in enumerate(nums):
if index == 0:
max_loot[index] = num
elif index == 1:
max_loot[index] = max(max_loot[index-1], num)
else:
max_loot[index] = max(
max_loot[index-1],
num + max_loot[index-2]
)
return max_loot[-1]
tests = [
(
([1, 2, 3, 1],),
4,
),
(
([2, 7, 9, 3, 1],),
12,
),
]
| class Solution:
def rob(self, nums: list[int]) -> int:
if len(nums) == 0:
return 0
max_loot: list[int] = [0 for _ in nums]
for (index, num) in enumerate(nums):
if index == 0:
max_loot[index] = num
elif index == 1:
max_loot[index] = max(max_loot[index - 1], num)
else:
max_loot[index] = max(max_loot[index - 1], num + max_loot[index - 2])
return max_loot[-1]
tests = [(([1, 2, 3, 1],), 4), (([2, 7, 9, 3, 1],), 12)] |
async def processEvent(event):
# Do event processing here ...
return event
| async def processEvent(event):
return event |
print("\nAverage is being calculated\n")
APITimingFile = open("APITiming.txt", "r")
APITimingVals = APITimingFile.readlines()
sum = 0
for i in APITimingVals:
sum += float(i[slice(len(i)-2)])
print("\nThe average time of start providing is " + str(round(sum/len(APITimingVals), 4)) + "\n")
| print('\nAverage is being calculated\n')
api_timing_file = open('APITiming.txt', 'r')
api_timing_vals = APITimingFile.readlines()
sum = 0
for i in APITimingVals:
sum += float(i[slice(len(i) - 2)])
print('\nThe average time of start providing is ' + str(round(sum / len(APITimingVals), 4)) + '\n') |
class OrderLog:
def __init__(self, size):
self.log = list()
self.size = size
def __repr__(self):
return str(self.log)
def record(self, order_id):
self.log.append(order_id)
if len(self.log) > self.size:
self.log = self.log[1:]
def get_last(self, i):
return self.log[-i]
log = OrderLog(5)
log.record(1)
log.record(2)
assert log.log == [1, 2]
log.record(3)
log.record(4)
log.record(5)
assert log.log == [1, 2, 3, 4, 5]
log.record(6)
log.record(7)
log.record(8)
assert log.log == [4, 5, 6, 7, 8]
assert log.get_last(4) == 5
assert log.get_last(1) == 8
| class Orderlog:
def __init__(self, size):
self.log = list()
self.size = size
def __repr__(self):
return str(self.log)
def record(self, order_id):
self.log.append(order_id)
if len(self.log) > self.size:
self.log = self.log[1:]
def get_last(self, i):
return self.log[-i]
log = order_log(5)
log.record(1)
log.record(2)
assert log.log == [1, 2]
log.record(3)
log.record(4)
log.record(5)
assert log.log == [1, 2, 3, 4, 5]
log.record(6)
log.record(7)
log.record(8)
assert log.log == [4, 5, 6, 7, 8]
assert log.get_last(4) == 5
assert log.get_last(1) == 8 |
#
# PySNMP MIB module OADHCP-SERVER-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/OADHCP-SERVER-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:22:47 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
ObjectIdentifier, OctetString, Integer = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "OctetString", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ValueRangeConstraint, ValueSizeConstraint, ConstraintsIntersection, SingleValueConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsIntersection", "SingleValueConstraint", "ConstraintsUnion")
ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup")
IpAddress, Integer32, Unsigned32, iso, NotificationType, Gauge32, ModuleIdentity, TimeTicks, ObjectIdentity, Counter32, NotificationType, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter64, enterprises, MibIdentifier, Bits = mibBuilder.importSymbols("SNMPv2-SMI", "IpAddress", "Integer32", "Unsigned32", "iso", "NotificationType", "Gauge32", "ModuleIdentity", "TimeTicks", "ObjectIdentity", "Counter32", "NotificationType", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter64", "enterprises", "MibIdentifier", "Bits")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
class HostName(DisplayString):
subtypeSpec = DisplayString.subtypeSpec + ValueSizeConstraint(0, 32)
class EntryStatus(Integer32):
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3))
namedValues = NamedValues(("valid", 1), ("invalid", 2), ("insert", 3))
class ObjectStatus(Integer32):
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3))
namedValues = NamedValues(("enable", 1), ("disable", 2), ("other", 3))
oaccess = MibIdentifier((1, 3, 6, 1, 4, 1, 6926))
oaManagement = MibIdentifier((1, 3, 6, 1, 4, 1, 6926, 1))
oaDhcp = MibIdentifier((1, 3, 6, 1, 4, 1, 6926, 1, 11))
oaDhcpServer = MibIdentifier((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1))
oaDhcpServerGeneral = MibIdentifier((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 1))
oaDhcpServerStatus = MibScalar((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 1, 1), ObjectStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: oaDhcpServerStatus.setStatus('mandatory')
oaDhcpNetbiosNodeType = MibScalar((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("other", 1), ("B-node", 2), ("P-node", 3), ("M-node", 4), ("H-node", 5)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: oaDhcpNetbiosNodeType.setStatus('mandatory')
oaDhcpDomainName = MibScalar((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 1, 3), HostName()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: oaDhcpDomainName.setStatus('mandatory')
oaDhcpDefaultLeaseTime = MibScalar((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 1, 4), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: oaDhcpDefaultLeaseTime.setStatus('mandatory')
oaDhcpMaxLeaseTime = MibScalar((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 1, 5), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: oaDhcpMaxLeaseTime.setStatus('mandatory')
oaDhcpDNSTable = MibTable((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 2), )
if mibBuilder.loadTexts: oaDhcpDNSTable.setStatus('mandatory')
oaDhcpDNSEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 2, 1), ).setIndexNames((0, "OADHCP-SERVER-MIB", "oaDhcpDNSNum"))
if mibBuilder.loadTexts: oaDhcpDNSEntry.setStatus('mandatory')
oaDhcpDNSNum = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 2, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: oaDhcpDNSNum.setStatus('mandatory')
oaDhcpDNSIp = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 2, 1, 2), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: oaDhcpDNSIp.setStatus('mandatory')
oaDhcpDNSStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 2, 1, 3), EntryStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: oaDhcpDNSStatus.setStatus('mandatory')
oaDhcpNetbiosServersTable = MibTable((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 3), )
if mibBuilder.loadTexts: oaDhcpNetbiosServersTable.setStatus('mandatory')
oaDhcpNetbiosServersEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 3, 1), ).setIndexNames((0, "OADHCP-SERVER-MIB", "oaDhcpNetbiosServerNum"))
if mibBuilder.loadTexts: oaDhcpNetbiosServersEntry.setStatus('mandatory')
oaDhcpNetbiosServerNum = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 3, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: oaDhcpNetbiosServerNum.setStatus('mandatory')
oaDhcpNetbiosServerIp = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 3, 1, 2), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: oaDhcpNetbiosServerIp.setStatus('mandatory')
oaDhcpNetbiosServerStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 3, 1, 3), EntryStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: oaDhcpNetbiosServerStatus.setStatus('mandatory')
oaDhcpSubnetConfigTable = MibTable((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 4), )
if mibBuilder.loadTexts: oaDhcpSubnetConfigTable.setStatus('mandatory')
oaDhcpSubnetConfigEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 4, 1), ).setIndexNames((0, "OADHCP-SERVER-MIB", "oaDhcpInterfaceName"), (0, "OADHCP-SERVER-MIB", "oaDhcpSubnetIp"), (0, "OADHCP-SERVER-MIB", "oaDhcpSubnetMask"))
if mibBuilder.loadTexts: oaDhcpSubnetConfigEntry.setStatus('mandatory')
oaDhcpInterfaceName = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 4, 1, 1), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: oaDhcpInterfaceName.setStatus('mandatory')
oaDhcpSubnetIp = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 4, 1, 2), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: oaDhcpSubnetIp.setStatus('mandatory')
oaDhcpSubnetMask = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 4, 1, 3), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: oaDhcpSubnetMask.setStatus('mandatory')
oaDhcpOptionSubnetMask = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 4, 1, 4), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: oaDhcpOptionSubnetMask.setStatus('mandatory')
oaDhcpIsOptionMask = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 4, 1, 5), ObjectStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: oaDhcpIsOptionMask.setStatus('mandatory')
oaDhcpSubnetConfigStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 4, 1, 6), EntryStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: oaDhcpSubnetConfigStatus.setStatus('mandatory')
oaDhcpIpRangeTable = MibTable((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 5), )
if mibBuilder.loadTexts: oaDhcpIpRangeTable.setStatus('mandatory')
oaDhcpIpRangeEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 5, 1), ).setIndexNames((0, "OADHCP-SERVER-MIB", "oaDhcpIpRangeSubnetIp"), (0, "OADHCP-SERVER-MIB", "oaDhcpIpRangeSubnetMask"), (0, "OADHCP-SERVER-MIB", "oaDhcpIpRangeStart"))
if mibBuilder.loadTexts: oaDhcpIpRangeEntry.setStatus('mandatory')
oaDhcpIpRangeSubnetIp = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 5, 1, 1), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: oaDhcpIpRangeSubnetIp.setStatus('mandatory')
oaDhcpIpRangeSubnetMask = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 5, 1, 2), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: oaDhcpIpRangeSubnetMask.setStatus('mandatory')
oaDhcpIpRangeStart = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 5, 1, 3), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: oaDhcpIpRangeStart.setStatus('mandatory')
oaDhcpIpRangeEnd = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 5, 1, 4), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: oaDhcpIpRangeEnd.setStatus('mandatory')
oaDhcpIpRangeStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 5, 1, 5), EntryStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: oaDhcpIpRangeStatus.setStatus('mandatory')
oaDhcpDefaultGWTable = MibTable((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 6), )
if mibBuilder.loadTexts: oaDhcpDefaultGWTable.setStatus('mandatory')
oaDhcpDefaultGWEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 6, 1), ).setIndexNames((0, "OADHCP-SERVER-MIB", "oaDhcpDefaultGWSubnetIp"), (0, "OADHCP-SERVER-MIB", "oaDhcpDefaultGWSubnetMask"), (0, "OADHCP-SERVER-MIB", "oaDhcpDefaultGWIp"))
if mibBuilder.loadTexts: oaDhcpDefaultGWEntry.setStatus('mandatory')
oaDhcpDefaultGWSubnetIp = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 6, 1, 1), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: oaDhcpDefaultGWSubnetIp.setStatus('mandatory')
oaDhcpDefaultGWSubnetMask = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 6, 1, 2), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: oaDhcpDefaultGWSubnetMask.setStatus('mandatory')
oaDhcpDefaultGWIp = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 6, 1, 3), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: oaDhcpDefaultGWIp.setStatus('mandatory')
oaDhcpDefaultGWStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 6, 1, 4), EntryStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: oaDhcpDefaultGWStatus.setStatus('mandatory')
oaDhcpRelay = MibIdentifier((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2))
oaDhcpRelayGeneral = MibIdentifier((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 1))
oaDhcpRelayStatus = MibScalar((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 1, 1), ObjectStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: oaDhcpRelayStatus.setStatus('mandatory')
oaDhcpRelayClearConfig = MibScalar((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("None", 1), ("ResetConfig", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: oaDhcpRelayClearConfig.setStatus('mandatory')
oaDhcpRelayServerTable = MibTable((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 2), )
if mibBuilder.loadTexts: oaDhcpRelayServerTable.setStatus('mandatory')
oaDhcpRelayServerEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 2, 1), ).setIndexNames((0, "OADHCP-SERVER-MIB", "oaDhcpRelayServerIp"))
if mibBuilder.loadTexts: oaDhcpRelayServerEntry.setStatus('mandatory')
oaDhcpRelayServerIp = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 2, 1, 1), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: oaDhcpRelayServerIp.setStatus('mandatory')
oaDhcpRelayServerStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 2, 1, 2), EntryStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: oaDhcpRelayServerStatus.setStatus('mandatory')
oaDhcpRelayInterfaceTable = MibTable((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 3), )
if mibBuilder.loadTexts: oaDhcpRelayInterfaceTable.setStatus('mandatory')
oaDhcpRelayInterfaceEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 3, 1), ).setIndexNames((0, "OADHCP-SERVER-MIB", "oaDhcpRelayIfName"))
if mibBuilder.loadTexts: oaDhcpRelayInterfaceEntry.setStatus('mandatory')
oaDhcpRelayIfName = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 3, 1, 1), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: oaDhcpRelayIfName.setStatus('mandatory')
oaDhcpRelayIfStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 3, 1, 2), EntryStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: oaDhcpRelayIfStatus.setStatus('mandatory')
mibBuilder.exportSymbols("OADHCP-SERVER-MIB", oaDhcpDNSNum=oaDhcpDNSNum, oaDhcpDNSIp=oaDhcpDNSIp, oaDhcpNetbiosServerStatus=oaDhcpNetbiosServerStatus, oaDhcpRelayStatus=oaDhcpRelayStatus, oaDhcpIpRangeTable=oaDhcpIpRangeTable, oaDhcpServer=oaDhcpServer, oaDhcpDefaultGWIp=oaDhcpDefaultGWIp, oaDhcpDefaultGWEntry=oaDhcpDefaultGWEntry, oaDhcpDefaultLeaseTime=oaDhcpDefaultLeaseTime, EntryStatus=EntryStatus, oaDhcpNetbiosServersTable=oaDhcpNetbiosServersTable, oaDhcpRelay=oaDhcpRelay, oaDhcpNetbiosServerNum=oaDhcpNetbiosServerNum, oaManagement=oaManagement, oaDhcpNetbiosNodeType=oaDhcpNetbiosNodeType, oaDhcpOptionSubnetMask=oaDhcpOptionSubnetMask, oaDhcpIpRangeStatus=oaDhcpIpRangeStatus, oaDhcpRelayInterfaceEntry=oaDhcpRelayInterfaceEntry, oaDhcpIpRangeSubnetMask=oaDhcpIpRangeSubnetMask, oaccess=oaccess, oaDhcpSubnetConfigEntry=oaDhcpSubnetConfigEntry, oaDhcpRelayServerIp=oaDhcpRelayServerIp, oaDhcpRelayClearConfig=oaDhcpRelayClearConfig, oaDhcpRelayGeneral=oaDhcpRelayGeneral, oaDhcpRelayIfName=oaDhcpRelayIfName, oaDhcpMaxLeaseTime=oaDhcpMaxLeaseTime, oaDhcpServerGeneral=oaDhcpServerGeneral, ObjectStatus=ObjectStatus, oaDhcpDefaultGWStatus=oaDhcpDefaultGWStatus, oaDhcpDefaultGWSubnetIp=oaDhcpDefaultGWSubnetIp, oaDhcpIpRangeEnd=oaDhcpIpRangeEnd, oaDhcpDNSEntry=oaDhcpDNSEntry, oaDhcpSubnetConfigTable=oaDhcpSubnetConfigTable, oaDhcpSubnetConfigStatus=oaDhcpSubnetConfigStatus, oaDhcpDefaultGWTable=oaDhcpDefaultGWTable, oaDhcpDNSStatus=oaDhcpDNSStatus, oaDhcpNetbiosServersEntry=oaDhcpNetbiosServersEntry, oaDhcp=oaDhcp, oaDhcpServerStatus=oaDhcpServerStatus, oaDhcpInterfaceName=oaDhcpInterfaceName, oaDhcpRelayServerTable=oaDhcpRelayServerTable, oaDhcpRelayInterfaceTable=oaDhcpRelayInterfaceTable, oaDhcpSubnetMask=oaDhcpSubnetMask, oaDhcpIpRangeEntry=oaDhcpIpRangeEntry, oaDhcpIsOptionMask=oaDhcpIsOptionMask, oaDhcpDomainName=oaDhcpDomainName, oaDhcpIpRangeSubnetIp=oaDhcpIpRangeSubnetIp, oaDhcpDNSTable=oaDhcpDNSTable, oaDhcpRelayServerStatus=oaDhcpRelayServerStatus, oaDhcpNetbiosServerIp=oaDhcpNetbiosServerIp, oaDhcpDefaultGWSubnetMask=oaDhcpDefaultGWSubnetMask, oaDhcpRelayServerEntry=oaDhcpRelayServerEntry, oaDhcpRelayIfStatus=oaDhcpRelayIfStatus, HostName=HostName, oaDhcpSubnetIp=oaDhcpSubnetIp, oaDhcpIpRangeStart=oaDhcpIpRangeStart)
| (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(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')
(module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup')
(ip_address, integer32, unsigned32, iso, notification_type, gauge32, module_identity, time_ticks, object_identity, counter32, notification_type, mib_scalar, mib_table, mib_table_row, mib_table_column, counter64, enterprises, mib_identifier, bits) = mibBuilder.importSymbols('SNMPv2-SMI', 'IpAddress', 'Integer32', 'Unsigned32', 'iso', 'NotificationType', 'Gauge32', 'ModuleIdentity', 'TimeTicks', 'ObjectIdentity', 'Counter32', 'NotificationType', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Counter64', 'enterprises', 'MibIdentifier', 'Bits')
(display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention')
class Hostname(DisplayString):
subtype_spec = DisplayString.subtypeSpec + value_size_constraint(0, 32)
class Entrystatus(Integer32):
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3))
named_values = named_values(('valid', 1), ('invalid', 2), ('insert', 3))
class Objectstatus(Integer32):
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3))
named_values = named_values(('enable', 1), ('disable', 2), ('other', 3))
oaccess = mib_identifier((1, 3, 6, 1, 4, 1, 6926))
oa_management = mib_identifier((1, 3, 6, 1, 4, 1, 6926, 1))
oa_dhcp = mib_identifier((1, 3, 6, 1, 4, 1, 6926, 1, 11))
oa_dhcp_server = mib_identifier((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1))
oa_dhcp_server_general = mib_identifier((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 1))
oa_dhcp_server_status = mib_scalar((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 1, 1), object_status()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
oaDhcpServerStatus.setStatus('mandatory')
oa_dhcp_netbios_node_type = mib_scalar((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('other', 1), ('B-node', 2), ('P-node', 3), ('M-node', 4), ('H-node', 5)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
oaDhcpNetbiosNodeType.setStatus('mandatory')
oa_dhcp_domain_name = mib_scalar((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 1, 3), host_name()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
oaDhcpDomainName.setStatus('mandatory')
oa_dhcp_default_lease_time = mib_scalar((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 1, 4), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
oaDhcpDefaultLeaseTime.setStatus('mandatory')
oa_dhcp_max_lease_time = mib_scalar((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 1, 5), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
oaDhcpMaxLeaseTime.setStatus('mandatory')
oa_dhcp_dns_table = mib_table((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 2))
if mibBuilder.loadTexts:
oaDhcpDNSTable.setStatus('mandatory')
oa_dhcp_dns_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 2, 1)).setIndexNames((0, 'OADHCP-SERVER-MIB', 'oaDhcpDNSNum'))
if mibBuilder.loadTexts:
oaDhcpDNSEntry.setStatus('mandatory')
oa_dhcp_dns_num = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 2, 1, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
oaDhcpDNSNum.setStatus('mandatory')
oa_dhcp_dns_ip = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 2, 1, 2), ip_address()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
oaDhcpDNSIp.setStatus('mandatory')
oa_dhcp_dns_status = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 2, 1, 3), entry_status()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
oaDhcpDNSStatus.setStatus('mandatory')
oa_dhcp_netbios_servers_table = mib_table((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 3))
if mibBuilder.loadTexts:
oaDhcpNetbiosServersTable.setStatus('mandatory')
oa_dhcp_netbios_servers_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 3, 1)).setIndexNames((0, 'OADHCP-SERVER-MIB', 'oaDhcpNetbiosServerNum'))
if mibBuilder.loadTexts:
oaDhcpNetbiosServersEntry.setStatus('mandatory')
oa_dhcp_netbios_server_num = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 3, 1, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
oaDhcpNetbiosServerNum.setStatus('mandatory')
oa_dhcp_netbios_server_ip = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 3, 1, 2), ip_address()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
oaDhcpNetbiosServerIp.setStatus('mandatory')
oa_dhcp_netbios_server_status = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 3, 1, 3), entry_status()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
oaDhcpNetbiosServerStatus.setStatus('mandatory')
oa_dhcp_subnet_config_table = mib_table((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 4))
if mibBuilder.loadTexts:
oaDhcpSubnetConfigTable.setStatus('mandatory')
oa_dhcp_subnet_config_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 4, 1)).setIndexNames((0, 'OADHCP-SERVER-MIB', 'oaDhcpInterfaceName'), (0, 'OADHCP-SERVER-MIB', 'oaDhcpSubnetIp'), (0, 'OADHCP-SERVER-MIB', 'oaDhcpSubnetMask'))
if mibBuilder.loadTexts:
oaDhcpSubnetConfigEntry.setStatus('mandatory')
oa_dhcp_interface_name = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 4, 1, 1), display_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
oaDhcpInterfaceName.setStatus('mandatory')
oa_dhcp_subnet_ip = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 4, 1, 2), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
oaDhcpSubnetIp.setStatus('mandatory')
oa_dhcp_subnet_mask = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 4, 1, 3), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
oaDhcpSubnetMask.setStatus('mandatory')
oa_dhcp_option_subnet_mask = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 4, 1, 4), ip_address()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
oaDhcpOptionSubnetMask.setStatus('mandatory')
oa_dhcp_is_option_mask = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 4, 1, 5), object_status()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
oaDhcpIsOptionMask.setStatus('mandatory')
oa_dhcp_subnet_config_status = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 4, 1, 6), entry_status()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
oaDhcpSubnetConfigStatus.setStatus('mandatory')
oa_dhcp_ip_range_table = mib_table((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 5))
if mibBuilder.loadTexts:
oaDhcpIpRangeTable.setStatus('mandatory')
oa_dhcp_ip_range_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 5, 1)).setIndexNames((0, 'OADHCP-SERVER-MIB', 'oaDhcpIpRangeSubnetIp'), (0, 'OADHCP-SERVER-MIB', 'oaDhcpIpRangeSubnetMask'), (0, 'OADHCP-SERVER-MIB', 'oaDhcpIpRangeStart'))
if mibBuilder.loadTexts:
oaDhcpIpRangeEntry.setStatus('mandatory')
oa_dhcp_ip_range_subnet_ip = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 5, 1, 1), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
oaDhcpIpRangeSubnetIp.setStatus('mandatory')
oa_dhcp_ip_range_subnet_mask = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 5, 1, 2), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
oaDhcpIpRangeSubnetMask.setStatus('mandatory')
oa_dhcp_ip_range_start = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 5, 1, 3), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
oaDhcpIpRangeStart.setStatus('mandatory')
oa_dhcp_ip_range_end = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 5, 1, 4), ip_address()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
oaDhcpIpRangeEnd.setStatus('mandatory')
oa_dhcp_ip_range_status = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 5, 1, 5), entry_status()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
oaDhcpIpRangeStatus.setStatus('mandatory')
oa_dhcp_default_gw_table = mib_table((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 6))
if mibBuilder.loadTexts:
oaDhcpDefaultGWTable.setStatus('mandatory')
oa_dhcp_default_gw_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 6, 1)).setIndexNames((0, 'OADHCP-SERVER-MIB', 'oaDhcpDefaultGWSubnetIp'), (0, 'OADHCP-SERVER-MIB', 'oaDhcpDefaultGWSubnetMask'), (0, 'OADHCP-SERVER-MIB', 'oaDhcpDefaultGWIp'))
if mibBuilder.loadTexts:
oaDhcpDefaultGWEntry.setStatus('mandatory')
oa_dhcp_default_gw_subnet_ip = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 6, 1, 1), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
oaDhcpDefaultGWSubnetIp.setStatus('mandatory')
oa_dhcp_default_gw_subnet_mask = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 6, 1, 2), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
oaDhcpDefaultGWSubnetMask.setStatus('mandatory')
oa_dhcp_default_gw_ip = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 6, 1, 3), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
oaDhcpDefaultGWIp.setStatus('mandatory')
oa_dhcp_default_gw_status = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 1, 6, 1, 4), entry_status()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
oaDhcpDefaultGWStatus.setStatus('mandatory')
oa_dhcp_relay = mib_identifier((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2))
oa_dhcp_relay_general = mib_identifier((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 1))
oa_dhcp_relay_status = mib_scalar((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 1, 1), object_status()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
oaDhcpRelayStatus.setStatus('mandatory')
oa_dhcp_relay_clear_config = mib_scalar((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('None', 1), ('ResetConfig', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
oaDhcpRelayClearConfig.setStatus('mandatory')
oa_dhcp_relay_server_table = mib_table((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 2))
if mibBuilder.loadTexts:
oaDhcpRelayServerTable.setStatus('mandatory')
oa_dhcp_relay_server_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 2, 1)).setIndexNames((0, 'OADHCP-SERVER-MIB', 'oaDhcpRelayServerIp'))
if mibBuilder.loadTexts:
oaDhcpRelayServerEntry.setStatus('mandatory')
oa_dhcp_relay_server_ip = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 2, 1, 1), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
oaDhcpRelayServerIp.setStatus('mandatory')
oa_dhcp_relay_server_status = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 2, 1, 2), entry_status()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
oaDhcpRelayServerStatus.setStatus('mandatory')
oa_dhcp_relay_interface_table = mib_table((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 3))
if mibBuilder.loadTexts:
oaDhcpRelayInterfaceTable.setStatus('mandatory')
oa_dhcp_relay_interface_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 3, 1)).setIndexNames((0, 'OADHCP-SERVER-MIB', 'oaDhcpRelayIfName'))
if mibBuilder.loadTexts:
oaDhcpRelayInterfaceEntry.setStatus('mandatory')
oa_dhcp_relay_if_name = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 3, 1, 1), display_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
oaDhcpRelayIfName.setStatus('mandatory')
oa_dhcp_relay_if_status = mib_table_column((1, 3, 6, 1, 4, 1, 6926, 1, 11, 2, 3, 1, 2), entry_status()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
oaDhcpRelayIfStatus.setStatus('mandatory')
mibBuilder.exportSymbols('OADHCP-SERVER-MIB', oaDhcpDNSNum=oaDhcpDNSNum, oaDhcpDNSIp=oaDhcpDNSIp, oaDhcpNetbiosServerStatus=oaDhcpNetbiosServerStatus, oaDhcpRelayStatus=oaDhcpRelayStatus, oaDhcpIpRangeTable=oaDhcpIpRangeTable, oaDhcpServer=oaDhcpServer, oaDhcpDefaultGWIp=oaDhcpDefaultGWIp, oaDhcpDefaultGWEntry=oaDhcpDefaultGWEntry, oaDhcpDefaultLeaseTime=oaDhcpDefaultLeaseTime, EntryStatus=EntryStatus, oaDhcpNetbiosServersTable=oaDhcpNetbiosServersTable, oaDhcpRelay=oaDhcpRelay, oaDhcpNetbiosServerNum=oaDhcpNetbiosServerNum, oaManagement=oaManagement, oaDhcpNetbiosNodeType=oaDhcpNetbiosNodeType, oaDhcpOptionSubnetMask=oaDhcpOptionSubnetMask, oaDhcpIpRangeStatus=oaDhcpIpRangeStatus, oaDhcpRelayInterfaceEntry=oaDhcpRelayInterfaceEntry, oaDhcpIpRangeSubnetMask=oaDhcpIpRangeSubnetMask, oaccess=oaccess, oaDhcpSubnetConfigEntry=oaDhcpSubnetConfigEntry, oaDhcpRelayServerIp=oaDhcpRelayServerIp, oaDhcpRelayClearConfig=oaDhcpRelayClearConfig, oaDhcpRelayGeneral=oaDhcpRelayGeneral, oaDhcpRelayIfName=oaDhcpRelayIfName, oaDhcpMaxLeaseTime=oaDhcpMaxLeaseTime, oaDhcpServerGeneral=oaDhcpServerGeneral, ObjectStatus=ObjectStatus, oaDhcpDefaultGWStatus=oaDhcpDefaultGWStatus, oaDhcpDefaultGWSubnetIp=oaDhcpDefaultGWSubnetIp, oaDhcpIpRangeEnd=oaDhcpIpRangeEnd, oaDhcpDNSEntry=oaDhcpDNSEntry, oaDhcpSubnetConfigTable=oaDhcpSubnetConfigTable, oaDhcpSubnetConfigStatus=oaDhcpSubnetConfigStatus, oaDhcpDefaultGWTable=oaDhcpDefaultGWTable, oaDhcpDNSStatus=oaDhcpDNSStatus, oaDhcpNetbiosServersEntry=oaDhcpNetbiosServersEntry, oaDhcp=oaDhcp, oaDhcpServerStatus=oaDhcpServerStatus, oaDhcpInterfaceName=oaDhcpInterfaceName, oaDhcpRelayServerTable=oaDhcpRelayServerTable, oaDhcpRelayInterfaceTable=oaDhcpRelayInterfaceTable, oaDhcpSubnetMask=oaDhcpSubnetMask, oaDhcpIpRangeEntry=oaDhcpIpRangeEntry, oaDhcpIsOptionMask=oaDhcpIsOptionMask, oaDhcpDomainName=oaDhcpDomainName, oaDhcpIpRangeSubnetIp=oaDhcpIpRangeSubnetIp, oaDhcpDNSTable=oaDhcpDNSTable, oaDhcpRelayServerStatus=oaDhcpRelayServerStatus, oaDhcpNetbiosServerIp=oaDhcpNetbiosServerIp, oaDhcpDefaultGWSubnetMask=oaDhcpDefaultGWSubnetMask, oaDhcpRelayServerEntry=oaDhcpRelayServerEntry, oaDhcpRelayIfStatus=oaDhcpRelayIfStatus, HostName=HostName, oaDhcpSubnetIp=oaDhcpSubnetIp, oaDhcpIpRangeStart=oaDhcpIpRangeStart) |
sample_split=1.0
data_loader_usage = 'Training'
training_data = "train_train"
evaluate_data = "privatetest"
| sample_split = 1.0
data_loader_usage = 'Training'
training_data = 'train_train'
evaluate_data = 'privatetest' |
# This function checks if year is a leap year.
def isLeapYear(year):
if year%100 == 0:
return True if year%400 == 0 else False
elif year%4 == 0:
return True
else:
return False
# This function returns the number of days in a month
def monthDays(year, month):
MONTHDAYS = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
if month == 2 and isLeapYear(year):
return 29
return MONTHDAYS[month-1]
# Returns the next day
def nextDay(year, month, day):
if day == monthDays(year,month):
if month == 12:
return year+1, 1, 1
else:
return year, month+1, 1
return year, month, day+1
# This is the main function
def main():
print("Was", 2017, "a leap year?", isLeapYear(2017)) # False?
print("Was", 2016, "a leap year?", isLeapYear(2016)) # True?
print("Was", 2000, "a leap year?", isLeapYear(2000)) # True?
print("Was", 1900, "a leap year?", isLeapYear(1900)) # False?
print("January 2017 had", monthDays(2017, 1), "days") # 31?
print("February 2017 had", monthDays(2017, 2), "days") # 28?
print("February 2016 had", monthDays(2016, 2), "days") # 29?
print("February 2000 had", monthDays(2000, 2), "days") # 29?
print("February 1900 had", monthDays(1900, 2), "days") # 28?
y, m, d = nextDay(2017, 1, 30)
print(y, m, d) # 2017 1 31 ?
y, m, d = nextDay(2017, 1, 31)
print(y, m, d) # 2017 2 1 ?
y, m, d = nextDay(2017, 2, 28)
print(y, m, d) # 2017 3 1 ?
y, m, d = nextDay(2016, 2, 29)
print(y, m, d) # 2016 3 1 ?
y, m, d = nextDay(2017, 12, 31)
print(y, m, d) # 2018 1 1 ?
# call the main function
main() | def is_leap_year(year):
if year % 100 == 0:
return True if year % 400 == 0 else False
elif year % 4 == 0:
return True
else:
return False
def month_days(year, month):
monthdays = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
if month == 2 and is_leap_year(year):
return 29
return MONTHDAYS[month - 1]
def next_day(year, month, day):
if day == month_days(year, month):
if month == 12:
return (year + 1, 1, 1)
else:
return (year, month + 1, 1)
return (year, month, day + 1)
def main():
print('Was', 2017, 'a leap year?', is_leap_year(2017))
print('Was', 2016, 'a leap year?', is_leap_year(2016))
print('Was', 2000, 'a leap year?', is_leap_year(2000))
print('Was', 1900, 'a leap year?', is_leap_year(1900))
print('January 2017 had', month_days(2017, 1), 'days')
print('February 2017 had', month_days(2017, 2), 'days')
print('February 2016 had', month_days(2016, 2), 'days')
print('February 2000 had', month_days(2000, 2), 'days')
print('February 1900 had', month_days(1900, 2), 'days')
(y, m, d) = next_day(2017, 1, 30)
print(y, m, d)
(y, m, d) = next_day(2017, 1, 31)
print(y, m, d)
(y, m, d) = next_day(2017, 2, 28)
print(y, m, d)
(y, m, d) = next_day(2016, 2, 29)
print(y, m, d)
(y, m, d) = next_day(2017, 12, 31)
print(y, m, d)
main() |
#encoding:utf-8
subreddit = 'wtf'
t_channel = '@reddit_wtf'
def send_post(submission, r2t):
return r2t.send_simple(submission)
| subreddit = 'wtf'
t_channel = '@reddit_wtf'
def send_post(submission, r2t):
return r2t.send_simple(submission) |
programming_languages = ["Python", "Scala", "Haskell", "F#", "C#", "JavaScript"]
for lang in programming_languages:
if (lang == "Haskell"):
continue
print("Found Haskell !!!", end='\n') # this statement will never be executed
print(lang, end=' ') | programming_languages = ['Python', 'Scala', 'Haskell', 'F#', 'C#', 'JavaScript']
for lang in programming_languages:
if lang == 'Haskell':
continue
print('Found Haskell !!!', end='\n')
print(lang, end=' ') |
inc = 1
num = 1
for x in range (5,0,-1):
for y in range(x,0,-1):
print(" ",end="")
print(str(num)*inc)
num += 2
inc += 2 | inc = 1
num = 1
for x in range(5, 0, -1):
for y in range(x, 0, -1):
print(' ', end='')
print(str(num) * inc)
num += 2
inc += 2 |
n = int(input())
a = list(map(int, input().split()))
k_max = 0
g_max = 0
for k in range(2, max(a) + 1):
gcdness = 0
for elem in a:
if elem % k == 0:
gcdness += 1
if gcdness >= g_max:
g_max = gcdness
k_max = k
print(k_max) | n = int(input())
a = list(map(int, input().split()))
k_max = 0
g_max = 0
for k in range(2, max(a) + 1):
gcdness = 0
for elem in a:
if elem % k == 0:
gcdness += 1
if gcdness >= g_max:
g_max = gcdness
k_max = k
print(k_max) |
class Solution:
def getSmallestString(self, n: int, k: int) -> str:
result = ""
for index in range(n):
digitsLeft = n - index - 1
for c in range(1, 27):
if k - c <= digitsLeft * 26:
k -= c
result += chr(ord('a') + c -1)
break
return result | class Solution:
def get_smallest_string(self, n: int, k: int) -> str:
result = ''
for index in range(n):
digits_left = n - index - 1
for c in range(1, 27):
if k - c <= digitsLeft * 26:
k -= c
result += chr(ord('a') + c - 1)
break
return result |
a_val = int(input())
b_val = int(input())
def gcd(a, b):
if b > a:
a, b = b, a
if a % b == 0:
return b
else:
return gcd(b, a % b)
def reduce_fraction(n, m):
divider = gcd(n, m)
return int(n / divider), int(m / divider)
result = reduce_fraction(a_val, b_val)
print(*result)
| a_val = int(input())
b_val = int(input())
def gcd(a, b):
if b > a:
(a, b) = (b, a)
if a % b == 0:
return b
else:
return gcd(b, a % b)
def reduce_fraction(n, m):
divider = gcd(n, m)
return (int(n / divider), int(m / divider))
result = reduce_fraction(a_val, b_val)
print(*result) |
class Solution:
def myPow(self, x: float, n: int) -> float:
if n == 0:
return 0
elif n < 0:
return (1.0 / x) ** abs(n)
else:
return x ** n
s = Solution()
print(s.myPow(2.00000, 10)) | class Solution:
def my_pow(self, x: float, n: int) -> float:
if n == 0:
return 0
elif n < 0:
return (1.0 / x) ** abs(n)
else:
return x ** n
s = solution()
print(s.myPow(2.0, 10)) |
MOD = 998244353
r, c, n = map(int, input().split())
dp = [[0] * (1 << c) for _ in range(r + 1)]
dp[0][0] = 1
for row in range(r):
for bit_prev in range(1 << c):
bit_prev <<= 1
for bit in range(1 << c):
bit <<= 1
count = 0
for i in range(c + 1):
if ((bit_prev >> i) & 1 + (bit_prev >> i + 1) & 1 + (bit >> i) & 1 + (bit >> i + 1) & 1) & 1:
count += 1
bit >>= 1
dp[row + 1][bit] += count
print(sum(dp[-1])) | mod = 998244353
(r, c, n) = map(int, input().split())
dp = [[0] * (1 << c) for _ in range(r + 1)]
dp[0][0] = 1
for row in range(r):
for bit_prev in range(1 << c):
bit_prev <<= 1
for bit in range(1 << c):
bit <<= 1
count = 0
for i in range(c + 1):
if bit_prev >> i & 1 + (bit_prev >> i + 1) & 1 + (bit >> i) & 1 + (bit >> i + 1) & 1 & 1:
count += 1
bit >>= 1
dp[row + 1][bit] += count
print(sum(dp[-1])) |
array([[ -8.71756106, -1.36180276],
[ -8.58324975, -1.6198254 ],
[ -8.44660752, -1.87329902],
[ -8.30694854, -2.12042891],
[ -8.16366778, -2.35941504],
[ -8.01626074, -2.58846783],
[ -7.8643173 , -2.80576865],
[ -7.70752251, -3.0094502 ],
[ -7.5458139 , -3.19806094],
[ -7.37912158, -3.3697834 ],
[ -7.20747945, -3.5226388 ],
[ -7.03113284, -3.65485777],
[ -6.85017635, -3.76269362],
[ -6.66523309, -3.84275185],
[ -6.47736681, -3.89099441],
[ -6.28828709, -3.90157094],
[ -6.10156897, -3.86340302],
[ -5.91871331, -3.79305295],
[ -5.74014533, -3.69605418],
[ -5.56572991, -3.57762694],
[ -5.39517681, -3.44210881],
[ -5.22781241, -3.29456196],
[ -5.06232383, -3.14085048],
[ -4.89257735, -2.98799629],
[ -4.71966422, -2.83672204],
[ -4.54372346, -2.68713228],
[ -4.36476778, -2.53940585],
[ -4.18276114, -2.39377984],
[ -3.99760462, -2.25058361],
[ -3.80926438, -2.11016077],
[ -3.61765447, -1.97299377],
[ -3.4227503 , -1.83963827],
[ -3.22466935, -1.71063201],
[ -3.02363515, -1.5864963 ],
[ -2.8199305 , -1.46774788],
[ -2.61386232, -1.3549046 ],
[ -2.40573771, -1.24848664],
[ -2.19584837, -1.14901525],
[ -1.98446111, -1.05701006],
[ -1.77181225, -0.97298507],
[ -1.55810414, -0.89744287],
[ -1.34350217, -0.83086662],
[ -1.12813134, -0.77370943],
[ -0.91207182, -0.72638078],
[ -0.69535387, -0.68923045],
[ -0.47795283, -0.66253066],
[ -0.25978553, -0.64645761],
[ -0.04070946, -0.64107399],
[ 0.17947379, -0.64631382],
[ 0.40100956, -0.661971 ],
[ 0.62417469, -0.68769217],
[ 0.84925505, -0.72297438],
[ 1.0765168 , -0.7671692 ],
[ 1.30617386, -0.81949558],
[ 1.53834874, -0.87904872],
[ 1.77300538, -0.94474994],
[ 2.01004375, -1.0156523 ],
[ 2.24941382, -1.09111049],
[ 2.49090963, -1.17034172],
[ 2.76505053, -1.25699281],
[ 3.0392737 , -1.33956764],
[ 3.31357819, -1.4173004 ],
[ 3.58794949, -1.48951235],
[ 3.86235753, -1.55528368],
[ 4.13674424, -1.61362995],
[ 4.41101533, -1.66379521],
[ 4.68503054, -1.70493339],
[ 4.95859183, -1.73617318],
[ 5.23143608, -1.75675047],
[ 5.50323138, -1.76605581],
[ 5.77357759, -1.7636462 ],
[ 6.04201219, -1.74925505],
[ 6.30802249, -1.72280316],
[ 6.57106704, -1.6844134 ],
[ 6.83061188, -1.63443731],
[ 7.0861612 , -1.57343982],
[ 7.33719115, -1.50196243],
[ 7.58299863, -1.42023179],
[ 7.8226528 , -1.32820378],
[ 8.0545371 , -1.22514719],
[ 8.27658784, -1.11037577],
[ 8.48611424, -0.9831958 ],
[ 8.67910996, -0.84268891],
[ 8.85098102, -0.68873567],
[ 8.99611087, -0.52182284],
[ 9.10907438, -0.34357458],
[ 9.18417432, -0.15630253],
[ 9.21305752, 0.03692533],
[ 9.1840698 , 0.23008171],
[ 9.11910658, 0.4192829 ],
[ 9.02164578, 0.60281683],
[ 8.8945003 , 0.77935859],
[ 8.73948257, 0.94759291],
[ 8.5591441 , 1.10658568],
[ 8.35621373, 1.25571578],
[ 8.13392856, 1.39493299],
[ 7.89600098, 1.5249387 ],
[ 7.64494533, 1.64617321],
[ 7.38361784, 1.75967206],
[ 7.11449512, 1.86661923],
[ 6.83961129, 1.96821002],
[ 6.56059338, 2.06558415],
[ 6.27873646, 2.15980551],
[ 5.99507103, 2.25185709],
[ 5.71041846, 2.34264296],
[ 5.42539621, 2.43296897],
[ 5.14049084, 2.52356403],
[ 4.85570433, 2.61443171],
[ 4.57103584, 2.70556915],
[ 4.28648169, 2.79696731],
[ 4.00217813, 2.88852238],
[ 3.72231814, 2.97718081],
[ 3.44870505, 3.06108881],
[ 3.18310961, 3.13857246],
[ 2.92666246, 3.20839957],
[ 2.68000575, 3.26968441],
[ 2.44342382, 3.32179983],
[ 2.21693264, 3.36431422],
[ 2.00034546, 3.39694375],
[ 1.79331822, 3.41952112],
[ 1.59535102, 3.4320146 ],
[ 1.40578511, 3.43455695],
[ 1.22408879, 3.42711031],
[ 1.04965328, 3.40969902],
[ 0.88172434, 3.38251449],
[ 0.71940866, 3.34591804],
[ 0.5619256 , 3.29981197],
[ 0.40770804, 3.24544617],
[ 0.25548391, 3.18343735],
[ 0.10399591, 3.11449499],
[ -0.04775527, 3.03962421],
[ -0.20018042, 2.96056489],
[ -0.35331487, 2.8785744 ],
[ -0.52508461, 2.78543704],
[ -0.69712913, 2.70164087],
[ -0.86954503, 2.63519574],
[ -1.04209219, 2.59240169],
[ -1.21405958, 2.57909091],
[ -1.38377538, 2.60407937],
[ -1.55062259, 2.65787841],
[ -1.71439338, 2.73536957],
[ -1.87529031, 2.83169338],
[ -2.03395581, 2.94135403],
[ -2.19140835, 3.05794591],
[ -2.33805266, 3.16255329],
[ -2.48451156, 3.25896796],
[ -2.63059232, 3.3426935 ],
[ -2.77602606, 3.41054738],
[ -2.92043777, 3.46019213],
[ -3.06330851, 3.48968652],
[ -3.20374051, 3.4957004 ],
[ -3.34029351, 3.47415945],
[ -3.47007084, 3.41768448],
[ -3.59300929, 3.33351807],
[ -3.70923634, 3.22566695],
[ -3.81889624, 3.09672268],
[ -3.92268025, 2.95011367],
[ -4.02185397, 2.79022243],
[ -4.1178521 , 2.62159416],
[ -4.2161323 , 2.46452926],
[ -4.31781117, 2.31796144],
[ -4.42318035, 2.1831457 ],
[ -4.5322453 , 2.06073257],
[ -4.64501631, 1.95155647],
[ -4.76140997, 1.85631353],
[ -4.88126733, 1.77560052],
[ -5.00435734, 1.70987926],
[ -5.13042301, 1.65962035],
[ -5.25938944, 1.62667518],
[ -5.39072417, 1.61040595],
[ -5.52382922, 1.60897593],
[ -5.65849722, 1.62377451],
[ -5.79444211, 1.65715234],
[ -5.93107153, 1.71528106],
[ -6.06746368, 1.79081424],
[ -6.20317769, 1.88240466],
[ -6.33788905, 1.98864946],
[ -6.47136342, 2.10834012],
[ -6.60346438, 2.24020588],
[ -6.73412053, 2.3831744 ],
[ -6.86333984, 2.53617923],
[ -6.99113472, 2.69858842],
[ -7.12064178, 2.87523527],
[ -7.25444618, 3.04299389],
[ -7.39243765, 3.20138631],
[ -7.53467379, 3.34977808],
[ -7.68110851, 3.48788772],
[ -7.83182097, 3.61515988],
[ -7.98682564, 3.73117341],
[ -8.14612629, 3.83548086],
[ -8.30966415, 3.92772849],
[ -8.47726222, 4.00781042],
[ -8.64863214, 4.07585135],
[ -8.82344578, 4.13196495],
[ -9.0013035 , 4.17638389],
[ -9.18202552, 4.20814242],
[ -9.36528871, 4.22605346],
[ -9.55064213, 4.22773377],
[ -9.73708983, 4.20936143],
[ -9.92226831, 4.16594795],
[-10.10086343, 4.09095817],
[-10.26193798, 3.97820376],
[-10.38552981, 3.82399663],
[-10.47199275, 3.64300549],
[-10.52918735, 3.44482848],
[-10.5584774 , 3.23235077],
[-10.56124879, 3.00791184],
[-10.53904816, 2.77357185],
[-10.49439476, 2.53143451],
[-10.42938497, 2.2831314 ],
[-10.34681037, 2.03021889],
[-10.24958903, 1.77398657],
[-10.14059192, 1.51544409],
[-10.02259337, 1.25535648],
[ -9.89818344, 0.99427857],
[ -9.76968504, 0.73258465],
[ -9.63916162, 0.47047985],
[ -9.50822 , 0.20830133],
[ -9.37711487, -0.05380021],
[ -9.24579077, -0.31579848],
[ -9.11420368, -0.5776724 ],
[ -8.98238041, -0.83943435],
[ -8.85033536, -1.10109084],
[ -8.71756106, -1.36180276]]) | array([[-8.71756106, -1.36180276], [-8.58324975, -1.6198254], [-8.44660752, -1.87329902], [-8.30694854, -2.12042891], [-8.16366778, -2.35941504], [-8.01626074, -2.58846783], [-7.8643173, -2.80576865], [-7.70752251, -3.0094502], [-7.5458139, -3.19806094], [-7.37912158, -3.3697834], [-7.20747945, -3.5226388], [-7.03113284, -3.65485777], [-6.85017635, -3.76269362], [-6.66523309, -3.84275185], [-6.47736681, -3.89099441], [-6.28828709, -3.90157094], [-6.10156897, -3.86340302], [-5.91871331, -3.79305295], [-5.74014533, -3.69605418], [-5.56572991, -3.57762694], [-5.39517681, -3.44210881], [-5.22781241, -3.29456196], [-5.06232383, -3.14085048], [-4.89257735, -2.98799629], [-4.71966422, -2.83672204], [-4.54372346, -2.68713228], [-4.36476778, -2.53940585], [-4.18276114, -2.39377984], [-3.99760462, -2.25058361], [-3.80926438, -2.11016077], [-3.61765447, -1.97299377], [-3.4227503, -1.83963827], [-3.22466935, -1.71063201], [-3.02363515, -1.5864963], [-2.8199305, -1.46774788], [-2.61386232, -1.3549046], [-2.40573771, -1.24848664], [-2.19584837, -1.14901525], [-1.98446111, -1.05701006], [-1.77181225, -0.97298507], [-1.55810414, -0.89744287], [-1.34350217, -0.83086662], [-1.12813134, -0.77370943], [-0.91207182, -0.72638078], [-0.69535387, -0.68923045], [-0.47795283, -0.66253066], [-0.25978553, -0.64645761], [-0.04070946, -0.64107399], [0.17947379, -0.64631382], [0.40100956, -0.661971], [0.62417469, -0.68769217], [0.84925505, -0.72297438], [1.0765168, -0.7671692], [1.30617386, -0.81949558], [1.53834874, -0.87904872], [1.77300538, -0.94474994], [2.01004375, -1.0156523], [2.24941382, -1.09111049], [2.49090963, -1.17034172], [2.76505053, -1.25699281], [3.0392737, -1.33956764], [3.31357819, -1.4173004], [3.58794949, -1.48951235], [3.86235753, -1.55528368], [4.13674424, -1.61362995], [4.41101533, -1.66379521], [4.68503054, -1.70493339], [4.95859183, -1.73617318], [5.23143608, -1.75675047], [5.50323138, -1.76605581], [5.77357759, -1.7636462], [6.04201219, -1.74925505], [6.30802249, -1.72280316], [6.57106704, -1.6844134], [6.83061188, -1.63443731], [7.0861612, -1.57343982], [7.33719115, -1.50196243], [7.58299863, -1.42023179], [7.8226528, -1.32820378], [8.0545371, -1.22514719], [8.27658784, -1.11037577], [8.48611424, -0.9831958], [8.67910996, -0.84268891], [8.85098102, -0.68873567], [8.99611087, -0.52182284], [9.10907438, -0.34357458], [9.18417432, -0.15630253], [9.21305752, 0.03692533], [9.1840698, 0.23008171], [9.11910658, 0.4192829], [9.02164578, 0.60281683], [8.8945003, 0.77935859], [8.73948257, 0.94759291], [8.5591441, 1.10658568], [8.35621373, 1.25571578], [8.13392856, 1.39493299], [7.89600098, 1.5249387], [7.64494533, 1.64617321], [7.38361784, 1.75967206], [7.11449512, 1.86661923], [6.83961129, 1.96821002], [6.56059338, 2.06558415], [6.27873646, 2.15980551], [5.99507103, 2.25185709], [5.71041846, 2.34264296], [5.42539621, 2.43296897], [5.14049084, 2.52356403], [4.85570433, 2.61443171], [4.57103584, 2.70556915], [4.28648169, 2.79696731], [4.00217813, 2.88852238], [3.72231814, 2.97718081], [3.44870505, 3.06108881], [3.18310961, 3.13857246], [2.92666246, 3.20839957], [2.68000575, 3.26968441], [2.44342382, 3.32179983], [2.21693264, 3.36431422], [2.00034546, 3.39694375], [1.79331822, 3.41952112], [1.59535102, 3.4320146], [1.40578511, 3.43455695], [1.22408879, 3.42711031], [1.04965328, 3.40969902], [0.88172434, 3.38251449], [0.71940866, 3.34591804], [0.5619256, 3.29981197], [0.40770804, 3.24544617], [0.25548391, 3.18343735], [0.10399591, 3.11449499], [-0.04775527, 3.03962421], [-0.20018042, 2.96056489], [-0.35331487, 2.8785744], [-0.52508461, 2.78543704], [-0.69712913, 2.70164087], [-0.86954503, 2.63519574], [-1.04209219, 2.59240169], [-1.21405958, 2.57909091], [-1.38377538, 2.60407937], [-1.55062259, 2.65787841], [-1.71439338, 2.73536957], [-1.87529031, 2.83169338], [-2.03395581, 2.94135403], [-2.19140835, 3.05794591], [-2.33805266, 3.16255329], [-2.48451156, 3.25896796], [-2.63059232, 3.3426935], [-2.77602606, 3.41054738], [-2.92043777, 3.46019213], [-3.06330851, 3.48968652], [-3.20374051, 3.4957004], [-3.34029351, 3.47415945], [-3.47007084, 3.41768448], [-3.59300929, 3.33351807], [-3.70923634, 3.22566695], [-3.81889624, 3.09672268], [-3.92268025, 2.95011367], [-4.02185397, 2.79022243], [-4.1178521, 2.62159416], [-4.2161323, 2.46452926], [-4.31781117, 2.31796144], [-4.42318035, 2.1831457], [-4.5322453, 2.06073257], [-4.64501631, 1.95155647], [-4.76140997, 1.85631353], [-4.88126733, 1.77560052], [-5.00435734, 1.70987926], [-5.13042301, 1.65962035], [-5.25938944, 1.62667518], [-5.39072417, 1.61040595], [-5.52382922, 1.60897593], [-5.65849722, 1.62377451], [-5.79444211, 1.65715234], [-5.93107153, 1.71528106], [-6.06746368, 1.79081424], [-6.20317769, 1.88240466], [-6.33788905, 1.98864946], [-6.47136342, 2.10834012], [-6.60346438, 2.24020588], [-6.73412053, 2.3831744], [-6.86333984, 2.53617923], [-6.99113472, 2.69858842], [-7.12064178, 2.87523527], [-7.25444618, 3.04299389], [-7.39243765, 3.20138631], [-7.53467379, 3.34977808], [-7.68110851, 3.48788772], [-7.83182097, 3.61515988], [-7.98682564, 3.73117341], [-8.14612629, 3.83548086], [-8.30966415, 3.92772849], [-8.47726222, 4.00781042], [-8.64863214, 4.07585135], [-8.82344578, 4.13196495], [-9.0013035, 4.17638389], [-9.18202552, 4.20814242], [-9.36528871, 4.22605346], [-9.55064213, 4.22773377], [-9.73708983, 4.20936143], [-9.92226831, 4.16594795], [-10.10086343, 4.09095817], [-10.26193798, 3.97820376], [-10.38552981, 3.82399663], [-10.47199275, 3.64300549], [-10.52918735, 3.44482848], [-10.5584774, 3.23235077], [-10.56124879, 3.00791184], [-10.53904816, 2.77357185], [-10.49439476, 2.53143451], [-10.42938497, 2.2831314], [-10.34681037, 2.03021889], [-10.24958903, 1.77398657], [-10.14059192, 1.51544409], [-10.02259337, 1.25535648], [-9.89818344, 0.99427857], [-9.76968504, 0.73258465], [-9.63916162, 0.47047985], [-9.50822, 0.20830133], [-9.37711487, -0.05380021], [-9.24579077, -0.31579848], [-9.11420368, -0.5776724], [-8.98238041, -0.83943435], [-8.85033536, -1.10109084], [-8.71756106, -1.36180276]]) |
NAME = 'comic.py'
ORIGINAL_AUTHORS = [
'Miguel Boekhold'
]
ABOUT = '''
Returns a random comic from xkcd
'''
COMMANDS = '''
>>> .comic
returns a url of a random comic
'''
WEBSITE = ''
| name = 'comic.py'
original_authors = ['Miguel Boekhold']
about = '\nReturns a random comic from xkcd\n'
commands = '\n>>> .comic\nreturns a url of a random comic\n'
website = '' |
def printMyName(myName):
print('My name is' + myName)
print('Who are you ?')
myName = input()
printMyName(myName)
| def print_my_name(myName):
print('My name is' + myName)
print('Who are you ?')
my_name = input()
print_my_name(myName) |
def get_version_from_win32_pe(file):
# http://windowssdk.msdn.microsoft.com/en-us/library/ms646997.aspx
sig = struct.pack("32s", u"VS_VERSION_INFO".encode("utf-16-le"))
# This pulls the whole file into memory, so not very feasible for
# large binaries.
try:
filedata = open(file).read()
except IOError:
return "Unknown"
offset = filedata.find(sig)
if offset == -1:
return "Unknown"
filedata = filedata[offset + 32 : offset + 32 + (13*4)]
version_struct = struct.unpack("13I", filedata)
ver_ms, ver_ls = version_struct[4], version_struct[5]
return "%d.%d.%d.%d" % (ver_ls & 0x0000ffff, (ver_ms & 0xffff0000) >> 16,
ver_ms & 0x0000ffff, (ver_ls & 0xffff0000) >> 16)
| def get_version_from_win32_pe(file):
sig = struct.pack('32s', u'VS_VERSION_INFO'.encode('utf-16-le'))
try:
filedata = open(file).read()
except IOError:
return 'Unknown'
offset = filedata.find(sig)
if offset == -1:
return 'Unknown'
filedata = filedata[offset + 32:offset + 32 + 13 * 4]
version_struct = struct.unpack('13I', filedata)
(ver_ms, ver_ls) = (version_struct[4], version_struct[5])
return '%d.%d.%d.%d' % (ver_ls & 65535, (ver_ms & 4294901760) >> 16, ver_ms & 65535, (ver_ls & 4294901760) >> 16) |
class NodeConfig:
def __init__(self, node_name: str, ws_url: str) -> None:
self.node_name = node_name
self.ws_url = ws_url
| class Nodeconfig:
def __init__(self, node_name: str, ws_url: str) -> None:
self.node_name = node_name
self.ws_url = ws_url |
#always put a repr in place to explicitly differentiate str from repr
class Car:
def __init__(self, color, mileage):
self.color = color
self.mileage = mileage
def __repr__(self):
return '{self.__class__.__name__}({self.color}, {self.mileage})'.format(self=self)
def __str__(self):
return 'a {self.color} car'.format(self=self) | class Car:
def __init__(self, color, mileage):
self.color = color
self.mileage = mileage
def __repr__(self):
return '{self.__class__.__name__}({self.color}, {self.mileage})'.format(self=self)
def __str__(self):
return 'a {self.color} car'.format(self=self) |
BROKER_URL = "mongodb://arbor/celery"
CELERY_RESULT_BACKEND = "mongodb"
CELERY_MONGODB_BACKEND_SETTINGS = {
"host": "arbor",
"database": "celery"
}
| broker_url = 'mongodb://arbor/celery'
celery_result_backend = 'mongodb'
celery_mongodb_backend_settings = {'host': 'arbor', 'database': 'celery'} |
def fun():
a=89
str="adar"
return[a,str];
print(fun())
| def fun():
a = 89
str = 'adar'
return [a, str]
print(fun()) |
# input
N, X, Y = map(int, input().split())
As = [*map(int, input().split())]
Bs = [*map(int, input().split())]
# compute
# output
print(sum(i not in As and i not in Bs for i in range(1, N+1)))
| (n, x, y) = map(int, input().split())
as = [*map(int, input().split())]
bs = [*map(int, input().split())]
print(sum((i not in As and i not in Bs for i in range(1, N + 1)))) |
names = ["duanzijie","zhaokeer","lijiaxi","zhuzi","wangwenbo","gongyijun"]
print(names)
print(names[0])
print(names[1])
print(names[2])
print(names[3])
print(names[4])
print(names[5])
hi = "hi" + " " + name[1]
print(hi) | names = ['duanzijie', 'zhaokeer', 'lijiaxi', 'zhuzi', 'wangwenbo', 'gongyijun']
print(names)
print(names[0])
print(names[1])
print(names[2])
print(names[3])
print(names[4])
print(names[5])
hi = 'hi' + ' ' + name[1]
print(hi) |
n = int(input())
s = input()
c=0
for i in range(n-1):
if s[i]==s[i+1]:
c +=1
print(c)
| n = int(input())
s = input()
c = 0
for i in range(n - 1):
if s[i] == s[i + 1]:
c += 1
print(c) |
# practice of anna
class TestClass:
def __init__(self, name):
# __init__ is the rule first creator made so every time we have to foloow
self.name = name
if __name__ == '__main__':
obj1 = TestClass()
print(obj1)
obj2 = TestClass()
print(obj2) | class Testclass:
def __init__(self, name):
self.name = name
if __name__ == '__main__':
obj1 = test_class()
print(obj1)
obj2 = test_class()
print(obj2) |
class SpiderpigError(Exception):
pass
class ValidationError(SpiderpigError):
pass
class NotInitialized(SpiderpigError):
pass
class CyclicExecution(SpiderpigError):
pass
class TooManyDependencies(SpiderpigError):
pass
| class Spiderpigerror(Exception):
pass
class Validationerror(SpiderpigError):
pass
class Notinitialized(SpiderpigError):
pass
class Cyclicexecution(SpiderpigError):
pass
class Toomanydependencies(SpiderpigError):
pass |
## bisenetv2
cfg = dict(
model_type='bisenetv2',
num_aux_heads=4,
lr_start = 5e-2,
weight_decay=5e-4,
warmup_iters = 1000,
max_iter = 150000,
im_root='./datasets/coco',
train_im_anns='./datasets/coco/train.txt',
val_im_anns='./datasets/coco/val.txt',
scales=[0.5, 1.5],
cropsize=[512, 512],
ims_per_gpu=8,
use_fp16=True,
use_sync_bn=False,
respth='./res',
)
| cfg = dict(model_type='bisenetv2', num_aux_heads=4, lr_start=0.05, weight_decay=0.0005, warmup_iters=1000, max_iter=150000, im_root='./datasets/coco', train_im_anns='./datasets/coco/train.txt', val_im_anns='./datasets/coco/val.txt', scales=[0.5, 1.5], cropsize=[512, 512], ims_per_gpu=8, use_fp16=True, use_sync_bn=False, respth='./res') |
class PorterStemmer:
def __init__(self):
self.vowels = ('a', 'e', 'i', 'o', 'u')
def is_consonant(self, s: str, i: int):
return not self.is_vowel(s, i)
def is_vowel(self, s: str, i: int):
if s[i].lower() in self.vowels:
return True
elif s[i].lower() == 'y':
if self.is_consonant(s, i-1):
return True
else:
return False
def find_m(self, s):
i = 0
m = 0
while i < len(s):
if self.is_vowel(s, i) and self.is_consonant(s, i+1):
m += 1
i += 2
else:
i += 1
return m
def contains_vowel(self, s):
for v in self.vowels:
if v in s:
return True
for i in range(len(s)):
if s[i] == 'y':
if self.is_vowel(s, i):
return True
return False
def step1a(self, s):
if s[-4:] == 'sses':
s = s[:-4] + 'ss'
elif s[-3:] == "ies":
s = s[:-3] + "i"
elif s[-2:] == "ss":
pass
elif s[-1] == "s":
s = s[:-1]
return s
def step1b(self, s):
if s[-3:] == 'eed':
m = self.find_m(s[:-3])
if m > 0:
s = s[:-1]
elif s[-2:] == 'ed':
if self.contains_vowel(s[:-2]):
s = s[:-2]
elif s[-3:] == 'ing':
if self.contains_vowel(s[:-3]):
s = s[:-3]
return s
def step2(self, s):
if s[-7:] == 'ational':
m = self.find_m(s[:-7])
if m > 0:
s = s[:-5]+"e"
elif s[-6:] == 'tional':
m = self.find_m(s[:-6])
if m > 0:
s = s[:-2]
elif s[-4:] == 'enci':
m = self.find_m(s[:-4])
if m > 0:
s = s[:-1]+"e"
elif s[-4:] == 'anci':
m = self.find_m(s[:-4])
if m > 0:
s = s[:-1]+"e"
elif s[-4:] == 'izer':
m = self.find_m(s[:-4])
if m > 0:
s = s[:-1]
elif s[-4:] == 'abli':
m = self.find_m(s[:-4])
if m > 0:
s = s[:-1]+"e"
elif s[-4:] == 'alli':
m = self.find_m(s[:-1])
if m > 0:
s = s[:-2]
elif s[-5:] == 'entli':
m = self.find_m(s[:-5])
if m > 0:
s = s[:-2]
elif s[-3:] == 'eli':
m = self.find_m(s[:-3])
if m > 0:
s = s[:-2]
elif s[-5:] == 'ousli':
m = self.find_m(s[:-5])
if m > 0:
s = s[:-2]
elif s[-7:] == 'ization':
m = self.find_m(s[:-7])
if m > 0:
s = s[:-5]+"e"
elif s[-5:] == 'ation':
m = self.find_m(s[:-5])
if m > 0:
s = s[:-3]+"e"
elif s[-4:] == 'ator':
m = self.find_m(s[:-4])
if m > 0:
s = s[:-2]+"e"
elif s[-5:] == 'alism':
m = self.find_m(s[:-5])
if m > 0:
s = s[:-3]
elif s[-7:] == 'iveness':
m = self.find_m(s[:-7])
if m > 0:
s = s[:-4]
elif s[-7:] == 'fulness':
m = self.find_m(s[:-7])
if m > 0:
s = s[:-4]
elif s[-7:] == 'ousness':
m = self.find_m(s[:-7])
if m > 0:
s = s[:-4]
elif s[-5:] == 'aliti':
m = self.find_m(s[:-5])
if m > 0:
s = s[:-3]
elif s[-5:] == 'iviti':
m = self.find_m(s[:-5])
if m > 0:
s = s[:-3]+"e"
elif s[-6:] == 'bliti':
m = self.find_m(s[:-6])
if m > 0:
s = s[:-3]+"e"
return s
def step3(self, s):
if s[-5:] == 'icate':
m = self.find_m(s[:-5])
if m > 0:
s = s[:-3]
elif s[-5:] == 'ative':
m = self.find_m(s[:-5])
if m > 0:
s = s[:-5]
elif s[-5:] == 'alize':
m = self.find_m(s[:-5])
if m > 0:
s = s[:-3]
elif s[-5:] == 'iciti':
m = self.find_m(s[:-5])
if m > 0:
s = s[:-3]
elif s[-4:] == 'ical':
m = self.find_m(s[:-4])
if m > 0:
s = s[:-2]
elif s[-3:] == 'ful':
m = self.find_m(s[:-3])
if m > 0:
s = s[:-3]
elif s[-4:] == 'ness':
m = self.find_m(s[:-4])
if m > 0:
s = s[:-4]
def step4(self, s):
if s[-2:] == 'al':
m = self.find_m(s[:-2])
if m > 1:
s = s[:-2]
elif s[-4:] == 'ance':
m = self.find_m(s[:-4])
if m > 1:
s = s[:-4]
elif s[-4:] == 'ence':
m = self.find_m(s[:-4])
if m > 1:
s = s[:-4]
elif s[-2:] == 'er':
m = self.find_m(s[:-2])
if m > 1:
s = s[:-2]
elif s[-2:] == 'ic':
m = self.find_m(s[:-2])
if m > 1:
s = s[:-2]
elif s[-4:] == 'able':
m = self.find_m(s[:-4])
if m > 1:
s = s[:-4]
elif s[-4:] == 'ible':
m = self.find_m(s[:-4])
if m > 1:
s = s[:-4]
elif s[-4:] == 'ant':
m = self.find_m(s[:-3])
if m > 1:
s = s[:-3]
elif s[-5:] == 'ement':
m = self.find_m(s[:-5])
if m > 1:
s = s[:-5]
elif s[-4:] == 'ment':
m = self.find_m(s[:-4])
if m > 1:
s = s[:-4]
elif s[-3:] == 'ent':
m = self.find_m(s[:-3])
if m > 1:
s = s[:-3]
elif s[-3:] == 'ion':
m = self.find_m(s[:-3])
if m > 1 and (s[-4]== "s" or s[-4]=="t"):
s = s[:-3]
elif s[-2:] == 'ou':
m = self.find_m(s[:-2])
if m > 1:
s = s[:-2]
elif s[-3:] == 'ism':
m = self.find_m(s[:-3])
if m > 1:
s = s[:-3]
elif s[-3:] == 'ate':
m = self.find_m(s[:-3])
if m > 1:
s = s[:-3]
elif s[-3:] == 'iti':
m = self.find_m(s[:-3])
if m > 1:
s = s[:-3]
elif s[-3:] == 'ous':
m = self.find_m(s[:-3])
if m > 1:
s = s[:-3]
elif s[-3:] == 'ive':
m = self.find_m(s[:-3])
if m > 1:
s = s[:-3]
elif s[-3:] == 'ize':
m = self.find_m(s[:-3])
if m > 1:
s = s[:-3]
def __call__(self, s: str):
s = self.step1a(s)
s = self.step1b(s)
return s
| class Porterstemmer:
def __init__(self):
self.vowels = ('a', 'e', 'i', 'o', 'u')
def is_consonant(self, s: str, i: int):
return not self.is_vowel(s, i)
def is_vowel(self, s: str, i: int):
if s[i].lower() in self.vowels:
return True
elif s[i].lower() == 'y':
if self.is_consonant(s, i - 1):
return True
else:
return False
def find_m(self, s):
i = 0
m = 0
while i < len(s):
if self.is_vowel(s, i) and self.is_consonant(s, i + 1):
m += 1
i += 2
else:
i += 1
return m
def contains_vowel(self, s):
for v in self.vowels:
if v in s:
return True
for i in range(len(s)):
if s[i] == 'y':
if self.is_vowel(s, i):
return True
return False
def step1a(self, s):
if s[-4:] == 'sses':
s = s[:-4] + 'ss'
elif s[-3:] == 'ies':
s = s[:-3] + 'i'
elif s[-2:] == 'ss':
pass
elif s[-1] == 's':
s = s[:-1]
return s
def step1b(self, s):
if s[-3:] == 'eed':
m = self.find_m(s[:-3])
if m > 0:
s = s[:-1]
elif s[-2:] == 'ed':
if self.contains_vowel(s[:-2]):
s = s[:-2]
elif s[-3:] == 'ing':
if self.contains_vowel(s[:-3]):
s = s[:-3]
return s
def step2(self, s):
if s[-7:] == 'ational':
m = self.find_m(s[:-7])
if m > 0:
s = s[:-5] + 'e'
elif s[-6:] == 'tional':
m = self.find_m(s[:-6])
if m > 0:
s = s[:-2]
elif s[-4:] == 'enci':
m = self.find_m(s[:-4])
if m > 0:
s = s[:-1] + 'e'
elif s[-4:] == 'anci':
m = self.find_m(s[:-4])
if m > 0:
s = s[:-1] + 'e'
elif s[-4:] == 'izer':
m = self.find_m(s[:-4])
if m > 0:
s = s[:-1]
elif s[-4:] == 'abli':
m = self.find_m(s[:-4])
if m > 0:
s = s[:-1] + 'e'
elif s[-4:] == 'alli':
m = self.find_m(s[:-1])
if m > 0:
s = s[:-2]
elif s[-5:] == 'entli':
m = self.find_m(s[:-5])
if m > 0:
s = s[:-2]
elif s[-3:] == 'eli':
m = self.find_m(s[:-3])
if m > 0:
s = s[:-2]
elif s[-5:] == 'ousli':
m = self.find_m(s[:-5])
if m > 0:
s = s[:-2]
elif s[-7:] == 'ization':
m = self.find_m(s[:-7])
if m > 0:
s = s[:-5] + 'e'
elif s[-5:] == 'ation':
m = self.find_m(s[:-5])
if m > 0:
s = s[:-3] + 'e'
elif s[-4:] == 'ator':
m = self.find_m(s[:-4])
if m > 0:
s = s[:-2] + 'e'
elif s[-5:] == 'alism':
m = self.find_m(s[:-5])
if m > 0:
s = s[:-3]
elif s[-7:] == 'iveness':
m = self.find_m(s[:-7])
if m > 0:
s = s[:-4]
elif s[-7:] == 'fulness':
m = self.find_m(s[:-7])
if m > 0:
s = s[:-4]
elif s[-7:] == 'ousness':
m = self.find_m(s[:-7])
if m > 0:
s = s[:-4]
elif s[-5:] == 'aliti':
m = self.find_m(s[:-5])
if m > 0:
s = s[:-3]
elif s[-5:] == 'iviti':
m = self.find_m(s[:-5])
if m > 0:
s = s[:-3] + 'e'
elif s[-6:] == 'bliti':
m = self.find_m(s[:-6])
if m > 0:
s = s[:-3] + 'e'
return s
def step3(self, s):
if s[-5:] == 'icate':
m = self.find_m(s[:-5])
if m > 0:
s = s[:-3]
elif s[-5:] == 'ative':
m = self.find_m(s[:-5])
if m > 0:
s = s[:-5]
elif s[-5:] == 'alize':
m = self.find_m(s[:-5])
if m > 0:
s = s[:-3]
elif s[-5:] == 'iciti':
m = self.find_m(s[:-5])
if m > 0:
s = s[:-3]
elif s[-4:] == 'ical':
m = self.find_m(s[:-4])
if m > 0:
s = s[:-2]
elif s[-3:] == 'ful':
m = self.find_m(s[:-3])
if m > 0:
s = s[:-3]
elif s[-4:] == 'ness':
m = self.find_m(s[:-4])
if m > 0:
s = s[:-4]
def step4(self, s):
if s[-2:] == 'al':
m = self.find_m(s[:-2])
if m > 1:
s = s[:-2]
elif s[-4:] == 'ance':
m = self.find_m(s[:-4])
if m > 1:
s = s[:-4]
elif s[-4:] == 'ence':
m = self.find_m(s[:-4])
if m > 1:
s = s[:-4]
elif s[-2:] == 'er':
m = self.find_m(s[:-2])
if m > 1:
s = s[:-2]
elif s[-2:] == 'ic':
m = self.find_m(s[:-2])
if m > 1:
s = s[:-2]
elif s[-4:] == 'able':
m = self.find_m(s[:-4])
if m > 1:
s = s[:-4]
elif s[-4:] == 'ible':
m = self.find_m(s[:-4])
if m > 1:
s = s[:-4]
elif s[-4:] == 'ant':
m = self.find_m(s[:-3])
if m > 1:
s = s[:-3]
elif s[-5:] == 'ement':
m = self.find_m(s[:-5])
if m > 1:
s = s[:-5]
elif s[-4:] == 'ment':
m = self.find_m(s[:-4])
if m > 1:
s = s[:-4]
elif s[-3:] == 'ent':
m = self.find_m(s[:-3])
if m > 1:
s = s[:-3]
elif s[-3:] == 'ion':
m = self.find_m(s[:-3])
if m > 1 and (s[-4] == 's' or s[-4] == 't'):
s = s[:-3]
elif s[-2:] == 'ou':
m = self.find_m(s[:-2])
if m > 1:
s = s[:-2]
elif s[-3:] == 'ism':
m = self.find_m(s[:-3])
if m > 1:
s = s[:-3]
elif s[-3:] == 'ate':
m = self.find_m(s[:-3])
if m > 1:
s = s[:-3]
elif s[-3:] == 'iti':
m = self.find_m(s[:-3])
if m > 1:
s = s[:-3]
elif s[-3:] == 'ous':
m = self.find_m(s[:-3])
if m > 1:
s = s[:-3]
elif s[-3:] == 'ive':
m = self.find_m(s[:-3])
if m > 1:
s = s[:-3]
elif s[-3:] == 'ize':
m = self.find_m(s[:-3])
if m > 1:
s = s[:-3]
def __call__(self, s: str):
s = self.step1a(s)
s = self.step1b(s)
return s |
def bubble_sort(L):
swap = False
while not swap:
swap = True
for j in range(1, len(L)):
if L[j-1] > L[j]:
swap = False
temp = L[j]
L[j] = L[j-1]
L[j-1] = temp
| def bubble_sort(L):
swap = False
while not swap:
swap = True
for j in range(1, len(L)):
if L[j - 1] > L[j]:
swap = False
temp = L[j]
L[j] = L[j - 1]
L[j - 1] = temp |
#
# PySNMP MIB module CRESCENDO-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CRESCENDO-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:12:29 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsIntersection, ValueRangeConstraint, SingleValueConstraint, ConstraintsUnion, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueRangeConstraint", "SingleValueConstraint", "ConstraintsUnion", "ValueSizeConstraint")
MibScalar, MibTable, MibTableRow, MibTableColumn = mibBuilder.importSymbols("RFC1212", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn")
DisplayString, = mibBuilder.importSymbols("RFC1213", "DisplayString")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
enterprises, Unsigned32, iso, MibIdentifier, Integer32, NotificationType, Counter32, Counter64, MibScalar, MibTable, MibTableRow, MibTableColumn, TimeTicks, Bits, ObjectIdentity, IpAddress, ModuleIdentity, Gauge32 = mibBuilder.importSymbols("SNMPv2-SMI", "enterprises", "Unsigned32", "iso", "MibIdentifier", "Integer32", "NotificationType", "Counter32", "Counter64", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "TimeTicks", "Bits", "ObjectIdentity", "IpAddress", "ModuleIdentity", "Gauge32")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
crescendo = MibIdentifier((1, 3, 6, 1, 4, 1, 203))
crescendoProducts = MibIdentifier((1, 3, 6, 1, 4, 1, 203, 1))
concentrator = MibIdentifier((1, 3, 6, 1, 4, 1, 203, 1, 1))
conc = MibIdentifier((1, 3, 6, 1, 4, 1, 203, 1, 1, 1))
chassis = MibIdentifier((1, 3, 6, 1, 4, 1, 203, 1, 1, 2))
module = MibIdentifier((1, 3, 6, 1, 4, 1, 203, 1, 1, 3))
port = MibIdentifier((1, 3, 6, 1, 4, 1, 203, 1, 1, 4))
concMgmtType = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("other", 1), ("snmp", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: concMgmtType.setStatus('mandatory')
concIpAddr = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 2), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: concIpAddr.setStatus('mandatory')
concNetMask = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 3), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: concNetMask.setStatus('mandatory')
concBroadcast = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 4), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: concBroadcast.setStatus('mandatory')
concTrapReceiverTable = MibTable((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 5), )
if mibBuilder.loadTexts: concTrapReceiverTable.setStatus('mandatory')
concTrapReceiverEntry = MibTableRow((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 5, 1), ).setIndexNames((0, "CRESCENDO-MIB", "concTrapReceiverAddr"))
if mibBuilder.loadTexts: concTrapReceiverEntry.setStatus('mandatory')
concTrapReceiverType = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 5, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("other", 1), ("invalid", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: concTrapReceiverType.setStatus('mandatory')
concTrapReceiverAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 5, 1, 2), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: concTrapReceiverAddr.setStatus('mandatory')
concTrapReceiverComm = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 5, 1, 3), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 20))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: concTrapReceiverComm.setStatus('mandatory')
concCommunityTable = MibTable((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 6), )
if mibBuilder.loadTexts: concCommunityTable.setStatus('mandatory')
concCommunityEntry = MibTableRow((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 6, 1), ).setIndexNames((0, "CRESCENDO-MIB", "concCommunityAccess"))
if mibBuilder.loadTexts: concCommunityEntry.setStatus('mandatory')
concCommunityAccess = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 6, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("readOnly", 2), ("readWrite", 3), ("readWriteAll", 4)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: concCommunityAccess.setStatus('mandatory')
concCommunityString = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 6, 1, 2), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 20))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: concCommunityString.setStatus('mandatory')
concAttachType = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("dualAttach", 2), ("singleAttach", 3), ("nullAttach", 4)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: concAttachType.setStatus('mandatory')
concTraffic = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 100))).setMaxAccess("readonly")
if mibBuilder.loadTexts: concTraffic.setStatus('mandatory')
concReset = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("other", 1), ("reset", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: concReset.setStatus('mandatory')
concBaudRate = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 10), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: concBaudRate.setStatus('mandatory')
chassisType = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("cxxxx", 2), ("c1000", 3), ("c1001", 4)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chassisType.setStatus('mandatory')
chassisBkplType = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("other", 1), ("fddi", 2), ("fddiEthernet", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chassisBkplType.setStatus('mandatory')
chassisPs1Type = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("other", 1), ("none", 2), ("w50", 3), ("w200", 4), ("w600", 5)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chassisPs1Type.setStatus('mandatory')
chassisPs1Status = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("ok", 2), ("minorFault", 3), ("majorFault", 4)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chassisPs1Status.setStatus('mandatory')
chassisPs1TestResult = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 5), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: chassisPs1TestResult.setStatus('mandatory')
chassisPs2Type = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("other", 1), ("none", 2), ("w50", 3), ("w200", 4), ("w600", 5)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chassisPs2Type.setStatus('mandatory')
chassisPs2Status = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("ok", 2), ("minorFault", 3), ("majorFault", 4)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chassisPs2Status.setStatus('mandatory')
chassisPs2TestResult = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 8), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: chassisPs2TestResult.setStatus('mandatory')
chassisFanStatus = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("ok", 2), ("minorFault", 3), ("majorFault", 4)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chassisFanStatus.setStatus('mandatory')
chassisFanTestResult = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 10), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: chassisFanTestResult.setStatus('mandatory')
chassisMinorAlarm = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 11), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("off", 1), ("on", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chassisMinorAlarm.setStatus('mandatory')
chassisMajorAlarm = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 12), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("off", 1), ("on", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chassisMajorAlarm.setStatus('mandatory')
chassisTempAlarm = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 13), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("off", 1), ("on", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chassisTempAlarm.setStatus('mandatory')
chassisNumSlots = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 14), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: chassisNumSlots.setStatus('mandatory')
chassisSlotConfig = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 15), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: chassisSlotConfig.setStatus('mandatory')
moduleTable = MibTable((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1), )
if mibBuilder.loadTexts: moduleTable.setStatus('mandatory')
moduleEntry = MibTableRow((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1), ).setIndexNames((0, "CRESCENDO-MIB", "moduleIndex"))
if mibBuilder.loadTexts: moduleEntry.setStatus('mandatory')
moduleIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: moduleIndex.setStatus('mandatory')
moduleType = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("empty", 2), ("c1000", 3), ("c1001", 4)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: moduleType.setStatus('mandatory')
moduleSerialNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 3), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: moduleSerialNumber.setStatus('mandatory')
moduleHwHiVersion = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 4), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: moduleHwHiVersion.setStatus('mandatory')
moduleHwLoVersion = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 5), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: moduleHwLoVersion.setStatus('mandatory')
moduleFwHiVersion = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 6), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: moduleFwHiVersion.setStatus('mandatory')
moduleFwLoVersion = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 7), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: moduleFwLoVersion.setStatus('mandatory')
moduleSwHiVersion = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 8), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: moduleSwHiVersion.setStatus('mandatory')
moduleSwLoVersion = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 9), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: moduleSwLoVersion.setStatus('mandatory')
moduleStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("ok", 2), ("minorFault", 3), ("majorFault", 4)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: moduleStatus.setStatus('mandatory')
moduleTestResult = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 11), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: moduleTestResult.setStatus('mandatory')
moduleReset = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 12), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("other", 1), ("reset", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: moduleReset.setStatus('mandatory')
moduleName = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 13), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 20))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: moduleName.setStatus('mandatory')
moduleNumPorts = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 14), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: moduleNumPorts.setStatus('mandatory')
modulePortStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 15), OctetString().subtype(subtypeSpec=ValueSizeConstraint(0, 20))).setMaxAccess("readonly")
if mibBuilder.loadTexts: modulePortStatus.setStatus('mandatory')
portTable = MibTable((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1), )
if mibBuilder.loadTexts: portTable.setStatus('mandatory')
portEntry = MibTableRow((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1), ).setIndexNames((0, "CRESCENDO-MIB", "portModuleIndex"), (0, "CRESCENDO-MIB", "portIndex"))
if mibBuilder.loadTexts: portEntry.setStatus('mandatory')
portModuleIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: portModuleIndex.setStatus('mandatory')
portIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: portIndex.setStatus('mandatory')
portFddiIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 3), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: portFddiIndex.setStatus('mandatory')
portName = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 4), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 20))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: portName.setStatus('mandatory')
portType = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("cddi", 2), ("fiber", 3), ("multiMedia", 4)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: portType.setStatus('mandatory')
portStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("ok", 2), ("minorFault", 3), ("majorFault", 4)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: portStatus.setStatus('mandatory')
mibBuilder.exportSymbols("CRESCENDO-MIB", moduleNumPorts=moduleNumPorts, chassisMinorAlarm=chassisMinorAlarm, concTrapReceiverType=concTrapReceiverType, crescendoProducts=crescendoProducts, chassisType=chassisType, chassisPs1TestResult=chassisPs1TestResult, chassisMajorAlarm=chassisMajorAlarm, chassisSlotConfig=chassisSlotConfig, modulePortStatus=modulePortStatus, chassisPs1Status=chassisPs1Status, moduleHwHiVersion=moduleHwHiVersion, concCommunityEntry=concCommunityEntry, chassisFanTestResult=chassisFanTestResult, chassisPs2TestResult=chassisPs2TestResult, chassisFanStatus=chassisFanStatus, concIpAddr=concIpAddr, chassisPs2Status=chassisPs2Status, moduleReset=moduleReset, chassisPs2Type=chassisPs2Type, concTrapReceiverComm=concTrapReceiverComm, concNetMask=concNetMask, moduleStatus=moduleStatus, chassisPs1Type=chassisPs1Type, chassisNumSlots=chassisNumSlots, concBroadcast=concBroadcast, concTrapReceiverTable=concTrapReceiverTable, concMgmtType=concMgmtType, moduleHwLoVersion=moduleHwLoVersion, moduleSwLoVersion=moduleSwLoVersion, moduleTestResult=moduleTestResult, moduleIndex=moduleIndex, moduleType=moduleType, crescendo=crescendo, module=module, concTrapReceiverEntry=concTrapReceiverEntry, concCommunityString=concCommunityString, moduleTable=moduleTable, portType=portType, concBaudRate=concBaudRate, chassisTempAlarm=chassisTempAlarm, portEntry=portEntry, moduleFwLoVersion=moduleFwLoVersion, moduleSwHiVersion=moduleSwHiVersion, moduleSerialNumber=moduleSerialNumber, concAttachType=concAttachType, portIndex=portIndex, moduleFwHiVersion=moduleFwHiVersion, moduleName=moduleName, chassis=chassis, portName=portName, port=port, concCommunityAccess=concCommunityAccess, concentrator=concentrator, portStatus=portStatus, concTrapReceiverAddr=concTrapReceiverAddr, conc=conc, concCommunityTable=concCommunityTable, concTraffic=concTraffic, moduleEntry=moduleEntry, portTable=portTable, portFddiIndex=portFddiIndex, chassisBkplType=chassisBkplType, concReset=concReset, portModuleIndex=portModuleIndex)
| (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_range_constraint, single_value_constraint, constraints_union, value_size_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsIntersection', 'ValueRangeConstraint', 'SingleValueConstraint', 'ConstraintsUnion', 'ValueSizeConstraint')
(mib_scalar, mib_table, mib_table_row, mib_table_column) = mibBuilder.importSymbols('RFC1212', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn')
(display_string,) = mibBuilder.importSymbols('RFC1213', 'DisplayString')
(notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance')
(enterprises, unsigned32, iso, mib_identifier, integer32, notification_type, counter32, counter64, mib_scalar, mib_table, mib_table_row, mib_table_column, time_ticks, bits, object_identity, ip_address, module_identity, gauge32) = mibBuilder.importSymbols('SNMPv2-SMI', 'enterprises', 'Unsigned32', 'iso', 'MibIdentifier', 'Integer32', 'NotificationType', 'Counter32', 'Counter64', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'TimeTicks', 'Bits', 'ObjectIdentity', 'IpAddress', 'ModuleIdentity', 'Gauge32')
(display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention')
crescendo = mib_identifier((1, 3, 6, 1, 4, 1, 203))
crescendo_products = mib_identifier((1, 3, 6, 1, 4, 1, 203, 1))
concentrator = mib_identifier((1, 3, 6, 1, 4, 1, 203, 1, 1))
conc = mib_identifier((1, 3, 6, 1, 4, 1, 203, 1, 1, 1))
chassis = mib_identifier((1, 3, 6, 1, 4, 1, 203, 1, 1, 2))
module = mib_identifier((1, 3, 6, 1, 4, 1, 203, 1, 1, 3))
port = mib_identifier((1, 3, 6, 1, 4, 1, 203, 1, 1, 4))
conc_mgmt_type = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('other', 1), ('snmp', 2)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
concMgmtType.setStatus('mandatory')
conc_ip_addr = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 2), ip_address()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
concIpAddr.setStatus('mandatory')
conc_net_mask = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 3), ip_address()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
concNetMask.setStatus('mandatory')
conc_broadcast = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 4), ip_address()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
concBroadcast.setStatus('mandatory')
conc_trap_receiver_table = mib_table((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 5))
if mibBuilder.loadTexts:
concTrapReceiverTable.setStatus('mandatory')
conc_trap_receiver_entry = mib_table_row((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 5, 1)).setIndexNames((0, 'CRESCENDO-MIB', 'concTrapReceiverAddr'))
if mibBuilder.loadTexts:
concTrapReceiverEntry.setStatus('mandatory')
conc_trap_receiver_type = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 5, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('other', 1), ('invalid', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
concTrapReceiverType.setStatus('mandatory')
conc_trap_receiver_addr = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 5, 1, 2), ip_address()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
concTrapReceiverAddr.setStatus('mandatory')
conc_trap_receiver_comm = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 5, 1, 3), display_string().subtype(subtypeSpec=value_size_constraint(0, 20))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
concTrapReceiverComm.setStatus('mandatory')
conc_community_table = mib_table((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 6))
if mibBuilder.loadTexts:
concCommunityTable.setStatus('mandatory')
conc_community_entry = mib_table_row((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 6, 1)).setIndexNames((0, 'CRESCENDO-MIB', 'concCommunityAccess'))
if mibBuilder.loadTexts:
concCommunityEntry.setStatus('mandatory')
conc_community_access = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 6, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('readOnly', 2), ('readWrite', 3), ('readWriteAll', 4)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
concCommunityAccess.setStatus('mandatory')
conc_community_string = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 6, 1, 2), display_string().subtype(subtypeSpec=value_size_constraint(0, 20))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
concCommunityString.setStatus('mandatory')
conc_attach_type = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('dualAttach', 2), ('singleAttach', 3), ('nullAttach', 4)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
concAttachType.setStatus('mandatory')
conc_traffic = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 8), integer32().subtype(subtypeSpec=value_range_constraint(0, 100))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
concTraffic.setStatus('mandatory')
conc_reset = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 9), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('other', 1), ('reset', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
concReset.setStatus('mandatory')
conc_baud_rate = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 10), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
concBaudRate.setStatus('mandatory')
chassis_type = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('cxxxx', 2), ('c1000', 3), ('c1001', 4)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chassisType.setStatus('mandatory')
chassis_bkpl_type = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('other', 1), ('fddi', 2), ('fddiEthernet', 3)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chassisBkplType.setStatus('mandatory')
chassis_ps1_type = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('other', 1), ('none', 2), ('w50', 3), ('w200', 4), ('w600', 5)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chassisPs1Type.setStatus('mandatory')
chassis_ps1_status = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('ok', 2), ('minorFault', 3), ('majorFault', 4)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chassisPs1Status.setStatus('mandatory')
chassis_ps1_test_result = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 5), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chassisPs1TestResult.setStatus('mandatory')
chassis_ps2_type = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('other', 1), ('none', 2), ('w50', 3), ('w200', 4), ('w600', 5)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chassisPs2Type.setStatus('mandatory')
chassis_ps2_status = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('ok', 2), ('minorFault', 3), ('majorFault', 4)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chassisPs2Status.setStatus('mandatory')
chassis_ps2_test_result = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 8), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chassisPs2TestResult.setStatus('mandatory')
chassis_fan_status = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 9), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('ok', 2), ('minorFault', 3), ('majorFault', 4)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chassisFanStatus.setStatus('mandatory')
chassis_fan_test_result = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 10), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chassisFanTestResult.setStatus('mandatory')
chassis_minor_alarm = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 11), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('off', 1), ('on', 2)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chassisMinorAlarm.setStatus('mandatory')
chassis_major_alarm = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 12), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('off', 1), ('on', 2)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chassisMajorAlarm.setStatus('mandatory')
chassis_temp_alarm = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 13), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('off', 1), ('on', 2)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chassisTempAlarm.setStatus('mandatory')
chassis_num_slots = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 14), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chassisNumSlots.setStatus('mandatory')
chassis_slot_config = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 15), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chassisSlotConfig.setStatus('mandatory')
module_table = mib_table((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1))
if mibBuilder.loadTexts:
moduleTable.setStatus('mandatory')
module_entry = mib_table_row((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1)).setIndexNames((0, 'CRESCENDO-MIB', 'moduleIndex'))
if mibBuilder.loadTexts:
moduleEntry.setStatus('mandatory')
module_index = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
moduleIndex.setStatus('mandatory')
module_type = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('empty', 2), ('c1000', 3), ('c1001', 4)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
moduleType.setStatus('mandatory')
module_serial_number = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 3), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
moduleSerialNumber.setStatus('mandatory')
module_hw_hi_version = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 4), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
moduleHwHiVersion.setStatus('mandatory')
module_hw_lo_version = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 5), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
moduleHwLoVersion.setStatus('mandatory')
module_fw_hi_version = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 6), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
moduleFwHiVersion.setStatus('mandatory')
module_fw_lo_version = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 7), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
moduleFwLoVersion.setStatus('mandatory')
module_sw_hi_version = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 8), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
moduleSwHiVersion.setStatus('mandatory')
module_sw_lo_version = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 9), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
moduleSwLoVersion.setStatus('mandatory')
module_status = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 10), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('ok', 2), ('minorFault', 3), ('majorFault', 4)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
moduleStatus.setStatus('mandatory')
module_test_result = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 11), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
moduleTestResult.setStatus('mandatory')
module_reset = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 12), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('other', 1), ('reset', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
moduleReset.setStatus('mandatory')
module_name = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 13), display_string().subtype(subtypeSpec=value_size_constraint(0, 20))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
moduleName.setStatus('mandatory')
module_num_ports = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 14), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
moduleNumPorts.setStatus('mandatory')
module_port_status = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 15), octet_string().subtype(subtypeSpec=value_size_constraint(0, 20))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
modulePortStatus.setStatus('mandatory')
port_table = mib_table((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1))
if mibBuilder.loadTexts:
portTable.setStatus('mandatory')
port_entry = mib_table_row((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1)).setIndexNames((0, 'CRESCENDO-MIB', 'portModuleIndex'), (0, 'CRESCENDO-MIB', 'portIndex'))
if mibBuilder.loadTexts:
portEntry.setStatus('mandatory')
port_module_index = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
portModuleIndex.setStatus('mandatory')
port_index = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 2), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
portIndex.setStatus('mandatory')
port_fddi_index = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 3), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
portFddiIndex.setStatus('mandatory')
port_name = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 4), display_string().subtype(subtypeSpec=value_size_constraint(0, 20))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
portName.setStatus('mandatory')
port_type = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('cddi', 2), ('fiber', 3), ('multiMedia', 4)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
portType.setStatus('mandatory')
port_status = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('ok', 2), ('minorFault', 3), ('majorFault', 4)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
portStatus.setStatus('mandatory')
mibBuilder.exportSymbols('CRESCENDO-MIB', moduleNumPorts=moduleNumPorts, chassisMinorAlarm=chassisMinorAlarm, concTrapReceiverType=concTrapReceiverType, crescendoProducts=crescendoProducts, chassisType=chassisType, chassisPs1TestResult=chassisPs1TestResult, chassisMajorAlarm=chassisMajorAlarm, chassisSlotConfig=chassisSlotConfig, modulePortStatus=modulePortStatus, chassisPs1Status=chassisPs1Status, moduleHwHiVersion=moduleHwHiVersion, concCommunityEntry=concCommunityEntry, chassisFanTestResult=chassisFanTestResult, chassisPs2TestResult=chassisPs2TestResult, chassisFanStatus=chassisFanStatus, concIpAddr=concIpAddr, chassisPs2Status=chassisPs2Status, moduleReset=moduleReset, chassisPs2Type=chassisPs2Type, concTrapReceiverComm=concTrapReceiverComm, concNetMask=concNetMask, moduleStatus=moduleStatus, chassisPs1Type=chassisPs1Type, chassisNumSlots=chassisNumSlots, concBroadcast=concBroadcast, concTrapReceiverTable=concTrapReceiverTable, concMgmtType=concMgmtType, moduleHwLoVersion=moduleHwLoVersion, moduleSwLoVersion=moduleSwLoVersion, moduleTestResult=moduleTestResult, moduleIndex=moduleIndex, moduleType=moduleType, crescendo=crescendo, module=module, concTrapReceiverEntry=concTrapReceiverEntry, concCommunityString=concCommunityString, moduleTable=moduleTable, portType=portType, concBaudRate=concBaudRate, chassisTempAlarm=chassisTempAlarm, portEntry=portEntry, moduleFwLoVersion=moduleFwLoVersion, moduleSwHiVersion=moduleSwHiVersion, moduleSerialNumber=moduleSerialNumber, concAttachType=concAttachType, portIndex=portIndex, moduleFwHiVersion=moduleFwHiVersion, moduleName=moduleName, chassis=chassis, portName=portName, port=port, concCommunityAccess=concCommunityAccess, concentrator=concentrator, portStatus=portStatus, concTrapReceiverAddr=concTrapReceiverAddr, conc=conc, concCommunityTable=concCommunityTable, concTraffic=concTraffic, moduleEntry=moduleEntry, portTable=portTable, portFddiIndex=portFddiIndex, chassisBkplType=chassisBkplType, concReset=concReset, portModuleIndex=portModuleIndex) |
la_liga_goals = 43
champions_league_goals = 10
copa_del_rey_goals = 5
total_goals = la_liga_goals + champions_league_goals + copa_del_rey_goals | la_liga_goals = 43
champions_league_goals = 10
copa_del_rey_goals = 5
total_goals = la_liga_goals + champions_league_goals + copa_del_rey_goals |
class NoUserIdOrSessionKeyError(Exception):
pass
class NoProductToDelete(Exception):
pass
class NoCart(Exception):
pass
class BadConfigError(Exception):
pass
| class Nouseridorsessionkeyerror(Exception):
pass
class Noproducttodelete(Exception):
pass
class Nocart(Exception):
pass
class Badconfigerror(Exception):
pass |
def main():
*t, n = map(int, input().split())
t=list(t)
for i in range(2, n):
t.append(t[i-2] + t[i-1]*t[i-1])
print(t[-1])
if __name__ == '__main__':
main()
| def main():
(*t, n) = map(int, input().split())
t = list(t)
for i in range(2, n):
t.append(t[i - 2] + t[i - 1] * t[i - 1])
print(t[-1])
if __name__ == '__main__':
main() |
'''
Created on Oct 2, 2012
@author: vadim
Todo: need to learn string algorithms.
'''
f = open('data/keylog.txt')
mx = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
while True:
line = f.readline()
if not line:
break
line = line[:-1]
mx[int(line[0])][int(line[1])] += 1
mx[int(line[1])][int(line[2])] += 1
for l in mx:
print(l)
f.close()
if __name__ == '__main__':
pass
| """
Created on Oct 2, 2012
@author: vadim
Todo: need to learn string algorithms.
"""
f = open('data/keylog.txt')
mx = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
while True:
line = f.readline()
if not line:
break
line = line[:-1]
mx[int(line[0])][int(line[1])] += 1
mx[int(line[1])][int(line[2])] += 1
for l in mx:
print(l)
f.close()
if __name__ == '__main__':
pass |
# Swap assign variables
print("Enter 3 no.s:")
a = float(input("a: "))
b = float(input("b: "))
c = float(input("c: "))
a, b = a+b, b+c
print("Variables are: ")
print("a:", a)
print("b:", b)
print("c:", c)
| print('Enter 3 no.s:')
a = float(input('a: '))
b = float(input('b: '))
c = float(input('c: '))
(a, b) = (a + b, b + c)
print('Variables are: ')
print('a:', a)
print('b:', b)
print('c:', c) |
class A:
def __setitem__(self, e, f):
print(e + f)
a = A()
a[2] = 8
| class A:
def __setitem__(self, e, f):
print(e + f)
a = a()
a[2] = 8 |
cpp_config = [
'query-lib/official/cpp/codeql-suites/cpp-security-and-quality.qls',
'query-lib/official/cpp/codeql-suites/cpp-security-extended.qls',
]
js_config = []
# exported
lang_configs = {
'cpp' : cpp_config,
'javascript' : js_config
}
need_compile = ['cpp', 'java'] | cpp_config = ['query-lib/official/cpp/codeql-suites/cpp-security-and-quality.qls', 'query-lib/official/cpp/codeql-suites/cpp-security-extended.qls']
js_config = []
lang_configs = {'cpp': cpp_config, 'javascript': js_config}
need_compile = ['cpp', 'java'] |
# Push (temp, idx) in a stack. Pop element when a bigger elem is seen and update arr[idx] with (new_idx-idx).
# class Solution:
# def dailyTemperatures(self, T: List[int]) -> List[int]:
# S = []
# res = [0]*len(T)
# for i in range(len(T)-1, -1, -1):
# while S and T[S[-1]] <= T[i]:
# S.pop()
# if S:
# res[i] = S[-1] - i
# S.append(i)
# return res
class Solution:
# Time: O(n)
# Space: O(n)
def dailyTemperatures(self, T: List[int]) -> List[int]:
res = [0]*len(T)
stack = []
for i, t1 in enumerate(T):
while stack and t1 > stack[-1][1]:
j, t2 = stack.pop()
res[j] = i - j
stack.append((i, t1))
return res | class Solution:
def daily_temperatures(self, T: List[int]) -> List[int]:
res = [0] * len(T)
stack = []
for (i, t1) in enumerate(T):
while stack and t1 > stack[-1][1]:
(j, t2) = stack.pop()
res[j] = i - j
stack.append((i, t1))
return res |
class BaseType:
def __init__(self, db_type: str, python_type: type):
self.db_type = db_type
self.python_type = python_type
Float = BaseType("REAL", float)
Int = BaseType("INTEGER", int)
String = BaseType("TEXT", str)
TypeMap = {
float: Float,
int: Int,
str: String
}
| class Basetype:
def __init__(self, db_type: str, python_type: type):
self.db_type = db_type
self.python_type = python_type
float = base_type('REAL', float)
int = base_type('INTEGER', int)
string = base_type('TEXT', str)
type_map = {float: Float, int: Int, str: String} |
album_info = {
'Arrival - ABBA': {
'image': 'arrival.jpg',
'spotify_link_a': '1M4anG49aEs4YimBdj96Oy',
},
}
| album_info = {'Arrival - ABBA': {'image': 'arrival.jpg', 'spotify_link_a': '1M4anG49aEs4YimBdj96Oy'}} |
print('Hello, world.')
print('Hello, Python!')
print(2 + 3)
print('2' * 3)
print(f'2 + 3 = {2 + 3}')
print('1', '2', '3', sep=' + ', end=' ')
print('=', 1 + 2 + 3, end='')
print('!')
| print('Hello, world.')
print('Hello, Python!')
print(2 + 3)
print('2' * 3)
print(f'2 + 3 = {2 + 3}')
print('1', '2', '3', sep=' + ', end=' ')
print('=', 1 + 2 + 3, end='')
print('!') |
#!/usr/bin/env python
#coding: utf-8
class Solution:
# @param A, a list of integers
# @return an integer
def firstMissingPositive(self, A):
if not A: return 1
la = len(A)
i = 0
while i < la:
if i + 1 == A[i]:
i += 1
continue
if A[i] <= 0:
i += 1
continue
j = A[i]
while j > 0 and j <= la and j != A[j-1] and j != i:
t = A[j-1]
A[j-1] = j
j = t
if j > 0 and j <= la and j != A[j-1]: A[j-1] = j
i += 1
i = 1
while i <= la:
if A[i-1] != i: return i
i += 1
return A[la-1] + 1
if __name__ == '__main__':
s = Solution()
assert 3 == s.firstMissingPositive([1,2,0])
assert 2 == s.firstMissingPositive([3,4,-1,1])
assert 2 == s.firstMissingPositive([1,1])
assert 3 == s.firstMissingPositive([1,1,2,2])
assert 2 == s.firstMissingPositive([1,1,3,3])
assert 1 == s.firstMissingPositive([])
assert 1 == s.firstMissingPositive([2])
assert 3 == s.firstMissingPositive([2,1])
| class Solution:
def first_missing_positive(self, A):
if not A:
return 1
la = len(A)
i = 0
while i < la:
if i + 1 == A[i]:
i += 1
continue
if A[i] <= 0:
i += 1
continue
j = A[i]
while j > 0 and j <= la and (j != A[j - 1]) and (j != i):
t = A[j - 1]
A[j - 1] = j
j = t
if j > 0 and j <= la and (j != A[j - 1]):
A[j - 1] = j
i += 1
i = 1
while i <= la:
if A[i - 1] != i:
return i
i += 1
return A[la - 1] + 1
if __name__ == '__main__':
s = solution()
assert 3 == s.firstMissingPositive([1, 2, 0])
assert 2 == s.firstMissingPositive([3, 4, -1, 1])
assert 2 == s.firstMissingPositive([1, 1])
assert 3 == s.firstMissingPositive([1, 1, 2, 2])
assert 2 == s.firstMissingPositive([1, 1, 3, 3])
assert 1 == s.firstMissingPositive([])
assert 1 == s.firstMissingPositive([2])
assert 3 == s.firstMissingPositive([2, 1]) |
def xor(a, b):
return (a or b) and not (a and b)
def collapse_polymer(polymer):
pos = 0
while pos + 1 < len(polymer):
first = polymer[pos]
second = polymer[pos + 1]
if first.lower() == second.lower() and xor(first.isupper(), second.isupper()):
if pos + 2 >= len(polymer):
polymer = polymer[0:pos]
else:
polymer = polymer[0:pos] + polymer[pos + 2:]
pos = max(0, pos - 1)
else :
pos += 1
return polymer
def find_shortest_poly_by_removing_one_type(polymer):
alphabet = "abcdefghijklmnopqrstuvwxyz"
ans = polymer
for letter in alphabet:
tst = polymer.replace(letter.lower(), '')
tst = tst.replace(letter.upper(), '')
tmp = collapse_polymer(tst)
if len(tmp) < len(ans):
ans = tmp
return ans
| def xor(a, b):
return (a or b) and (not (a and b))
def collapse_polymer(polymer):
pos = 0
while pos + 1 < len(polymer):
first = polymer[pos]
second = polymer[pos + 1]
if first.lower() == second.lower() and xor(first.isupper(), second.isupper()):
if pos + 2 >= len(polymer):
polymer = polymer[0:pos]
else:
polymer = polymer[0:pos] + polymer[pos + 2:]
pos = max(0, pos - 1)
else:
pos += 1
return polymer
def find_shortest_poly_by_removing_one_type(polymer):
alphabet = 'abcdefghijklmnopqrstuvwxyz'
ans = polymer
for letter in alphabet:
tst = polymer.replace(letter.lower(), '')
tst = tst.replace(letter.upper(), '')
tmp = collapse_polymer(tst)
if len(tmp) < len(ans):
ans = tmp
return ans |
class Aula:
def __init__(self, id, numero, titulo):
self._id = id
self._numero = numero
self._titulo = titulo
def get_id(self):
return self._id
def get_numero(self):
return self._numero
def get_titulo(self):
return self._titulo | class Aula:
def __init__(self, id, numero, titulo):
self._id = id
self._numero = numero
self._titulo = titulo
def get_id(self):
return self._id
def get_numero(self):
return self._numero
def get_titulo(self):
return self._titulo |
class Queue(object):
def __init__(self):
self.q = []
def push(self, value):
self.q.insert(0, value)
def pop(self):
return self.q.pop()
def is_empty(self):
return self.q == []
def size(self):
return len(self.q)
# Example
q = Queue()
q.push(1)
q.push(2)
q.push(3)
print(q.q) # [3, 2, 1]
q.pop()
print(q.q) # [3, 2]
| class Queue(object):
def __init__(self):
self.q = []
def push(self, value):
self.q.insert(0, value)
def pop(self):
return self.q.pop()
def is_empty(self):
return self.q == []
def size(self):
return len(self.q)
q = queue()
q.push(1)
q.push(2)
q.push(3)
print(q.q)
q.pop()
print(q.q) |
file = open("day 04/Toon - Python/input", "r")
lines = file.readlines()
numbers = [int(x) for x in lines[0][:-1].split(',')]
boards = [[int(x) for x in line[:-1].split(' ') if x != '' ] for line in lines[2:]]
boards = [boards[i*6:i*6+5] for i in range(100)]
def contains_bingo(board):
return -5 in [sum(line) for line in board] or -5 in [sum(line) for line in [list(i) for i in zip(*board)]]
found = False
for number in numbers:
for i in range(len(boards)):
boards[i] = [[-1 if x == number else x for x in line] for line in boards[i]]
if contains_bingo(boards[i]):
result = boards[i]
result_number = number
found = True
if found:
break
def sum_board(board):
return sum([sum([0 if x == -1 else x for x in line]) for line in board])
print("part 1: %s" % (sum_board(result) * number))
boards = [[int(x) for x in line[:-1].split(' ') if x != '' ] for line in lines[2:]]
boards = [boards[i*6:i*6+5] for i in range(100)]
def find_last(boards, numbers):
good_boards = []
bad_boards = []
for i in range(len(boards)):
boards[i] = [[-1 if x == numbers[0] else x for x in line] for line in boards[i]]
if not contains_bingo(boards[i]):
good_boards += [boards[i]]
else:
bad_boards += [boards[i]]
if len(good_boards) == 0:
return sum_board(bad_boards[0]) * numbers[0]
return find_last(good_boards, numbers[1:])
print("part 2: %s" % find_last(boards, numbers)) | file = open('day 04/Toon - Python/input', 'r')
lines = file.readlines()
numbers = [int(x) for x in lines[0][:-1].split(',')]
boards = [[int(x) for x in line[:-1].split(' ') if x != ''] for line in lines[2:]]
boards = [boards[i * 6:i * 6 + 5] for i in range(100)]
def contains_bingo(board):
return -5 in [sum(line) for line in board] or -5 in [sum(line) for line in [list(i) for i in zip(*board)]]
found = False
for number in numbers:
for i in range(len(boards)):
boards[i] = [[-1 if x == number else x for x in line] for line in boards[i]]
if contains_bingo(boards[i]):
result = boards[i]
result_number = number
found = True
if found:
break
def sum_board(board):
return sum([sum([0 if x == -1 else x for x in line]) for line in board])
print('part 1: %s' % (sum_board(result) * number))
boards = [[int(x) for x in line[:-1].split(' ') if x != ''] for line in lines[2:]]
boards = [boards[i * 6:i * 6 + 5] for i in range(100)]
def find_last(boards, numbers):
good_boards = []
bad_boards = []
for i in range(len(boards)):
boards[i] = [[-1 if x == numbers[0] else x for x in line] for line in boards[i]]
if not contains_bingo(boards[i]):
good_boards += [boards[i]]
else:
bad_boards += [boards[i]]
if len(good_boards) == 0:
return sum_board(bad_boards[0]) * numbers[0]
return find_last(good_boards, numbers[1:])
print('part 2: %s' % find_last(boards, numbers)) |
listOriginPath = [
{
"header": "test.example.com",
"httpPort": 80,
"mappingUniqueId": "993419389425697",
"origin": "10.10.10.1",
"originType": "HOST_SERVER",
"path": "/example",
"status": "RUNNING"
},
{
"header": "test.example.com",
"httpPort": 80,
"mappingUniqueId": "993419389425697",
"origin": "10.10.10.1",
"originType": "HOST_SERVER",
"path": "/example1",
"status": "RUNNING"
}
]
createOriginPath = [
{
"header": "test.example.com",
"httpPort": 80,
"mappingUniqueId": "993419389425697",
"origin": "10.10.10.1",
"originType": "HOST_SERVER",
"path": "/example",
"status": "RUNNING",
"bucketName": "test-bucket",
'fileExtension': 'jpg',
"performanceConfiguration": "General web delivery"
}
]
deleteOriginPath = "Origin with path /example/videos/* has been deleted"
| list_origin_path = [{'header': 'test.example.com', 'httpPort': 80, 'mappingUniqueId': '993419389425697', 'origin': '10.10.10.1', 'originType': 'HOST_SERVER', 'path': '/example', 'status': 'RUNNING'}, {'header': 'test.example.com', 'httpPort': 80, 'mappingUniqueId': '993419389425697', 'origin': '10.10.10.1', 'originType': 'HOST_SERVER', 'path': '/example1', 'status': 'RUNNING'}]
create_origin_path = [{'header': 'test.example.com', 'httpPort': 80, 'mappingUniqueId': '993419389425697', 'origin': '10.10.10.1', 'originType': 'HOST_SERVER', 'path': '/example', 'status': 'RUNNING', 'bucketName': 'test-bucket', 'fileExtension': 'jpg', 'performanceConfiguration': 'General web delivery'}]
delete_origin_path = 'Origin with path /example/videos/* has been deleted' |
@jit(nopython=True)
def pressure_poisson(p, b, l2_target):
J, I = b.shape
iter_diff = l2_target + 1
n = 0
while iter_diff > l2_target and n <= 500:
pn = p.copy()
for i in range(1, I - 1):
for j in range(1, J - 1):
p[j, i] = (.25 * (pn[j, i + 1] +
pn[j, i - 1] +
pn[j + 1, i] +
pn[j - 1, i]) -
b[j, i])
for j in range(J):
p[j, 0] = p[j, 1]
p[j, -1] = p[j, -2]
for i in range(I):
p[0, i] = p[1, i]
p[-1, i] = 0
if n % 10 == 0:
iter_diff = numpy.sqrt(numpy.sum((p - pn)**2)/numpy.sum(pn**2))
n += 1
return p
| @jit(nopython=True)
def pressure_poisson(p, b, l2_target):
(j, i) = b.shape
iter_diff = l2_target + 1
n = 0
while iter_diff > l2_target and n <= 500:
pn = p.copy()
for i in range(1, I - 1):
for j in range(1, J - 1):
p[j, i] = 0.25 * (pn[j, i + 1] + pn[j, i - 1] + pn[j + 1, i] + pn[j - 1, i]) - b[j, i]
for j in range(J):
p[j, 0] = p[j, 1]
p[j, -1] = p[j, -2]
for i in range(I):
p[0, i] = p[1, i]
p[-1, i] = 0
if n % 10 == 0:
iter_diff = numpy.sqrt(numpy.sum((p - pn) ** 2) / numpy.sum(pn ** 2))
n += 1
return p |
a = [int(x) for x in input().split()]
time = None
# a[0] initial hour
# a[1] initial min
# a[2] final hour
# a[3] final min
start = 60 * a[0] + a[1]
finish = 60 * a[2] + a[3]
if finish <= start:
finish += 1440 # 24 * 60
time = finish - start
print(f"O JOGO DUROU {int(time / 60)} HORA(S) E {int(time % 60)} MINUTO(S)")
| a = [int(x) for x in input().split()]
time = None
start = 60 * a[0] + a[1]
finish = 60 * a[2] + a[3]
if finish <= start:
finish += 1440
time = finish - start
print(f'O JOGO DUROU {int(time / 60)} HORA(S) E {int(time % 60)} MINUTO(S)') |
def Compute_kmeans_inertia(resultsDict, FSWRITE = False, gpu_available = False):
# Measure inertia of kmeans model for a variety of values of cluster number n
km_list = list()
data = resultsDict['PCA_fit_transform']
#data = resultsDict['NP_images_STD']
N_clusters = len(resultsDict['imagesFilenameList'])
if gpu_available:
print('Running Compute_kmeans_inertia on GPU: ')
with gpu_context():
for clust in range(1,N_clusters):
km = KMeans(n_clusters=clust, init='random', random_state=42)
km = km.fit(data)
km_list.append({'clusters': clust,
'inertia': km.inertia_,
'model': km})
# It is possible to specify to make the computations on CPU
else:
print('Running Compute_kmeans_inertia on local CPU: ')
for clust in range(1,N_clusters):
km = KMeans(n_clusters=clust, init='random', random_state=42)
km = km.fit(data)
km_list.append({'clusters': clust,
'inertia': km.inertia_,
'model': km})
resultsDict['km'] = km
resultsDict['km_list'] = km_list
if FSWRITE == True:
write_results(resultsDict)
return resultsDict
| def compute_kmeans_inertia(resultsDict, FSWRITE=False, gpu_available=False):
km_list = list()
data = resultsDict['PCA_fit_transform']
n_clusters = len(resultsDict['imagesFilenameList'])
if gpu_available:
print('Running Compute_kmeans_inertia on GPU: ')
with gpu_context():
for clust in range(1, N_clusters):
km = k_means(n_clusters=clust, init='random', random_state=42)
km = km.fit(data)
km_list.append({'clusters': clust, 'inertia': km.inertia_, 'model': km})
else:
print('Running Compute_kmeans_inertia on local CPU: ')
for clust in range(1, N_clusters):
km = k_means(n_clusters=clust, init='random', random_state=42)
km = km.fit(data)
km_list.append({'clusters': clust, 'inertia': km.inertia_, 'model': km})
resultsDict['km'] = km
resultsDict['km_list'] = km_list
if FSWRITE == True:
write_results(resultsDict)
return resultsDict |
n_students = int(input())
skills = list(input().split(" "))
skills = [int(skill) for skill in skills]
skills = sorted(skills)
n_problems = 0
ptr1 = n_students - 1
ptr2 = n_students - 2
while ptr2 >= 0:
if (skills[ptr1] == skills[ptr2]):
ptr1 -= 2
ptr2 -= 2
else:
n_problems += 1
skills[ptr2] += 1
print(n_problems) | n_students = int(input())
skills = list(input().split(' '))
skills = [int(skill) for skill in skills]
skills = sorted(skills)
n_problems = 0
ptr1 = n_students - 1
ptr2 = n_students - 2
while ptr2 >= 0:
if skills[ptr1] == skills[ptr2]:
ptr1 -= 2
ptr2 -= 2
else:
n_problems += 1
skills[ptr2] += 1
print(n_problems) |
teste = [0, 2, 3, 4, 5]
print(teste)
teste.insert(0, teste[3])
print(teste)
teste.pop(4)
print(teste) | teste = [0, 2, 3, 4, 5]
print(teste)
teste.insert(0, teste[3])
print(teste)
teste.pop(4)
print(teste) |
arr = [1, 2, 3, 4, 4, 4, 5, 6, 6, 7, 8, 9]
arr.sort()
my_dict = {i:arr.count(i) for i in arr}
# sorting the dictionary based on value
my_dict = {k: v for k, v in sorted(my_dict.items(), key=lambda item: item[1])}
print(len(my_dict))
print(my_dict)
list = list(my_dict.keys())
print(list[-1])
| arr = [1, 2, 3, 4, 4, 4, 5, 6, 6, 7, 8, 9]
arr.sort()
my_dict = {i: arr.count(i) for i in arr}
my_dict = {k: v for (k, v) in sorted(my_dict.items(), key=lambda item: item[1])}
print(len(my_dict))
print(my_dict)
list = list(my_dict.keys())
print(list[-1]) |
# Model parameters
model_hidden_size = 768
model_embedding_size = 256
model_num_layers = 1
# Training parameters
n_steps = 2e4
learning_rate_init = 1e-3
speakers_per_batch = 16
utterances_per_speaker = 32
## Tensor-train parameters for last linear layer.
compression = 'tt'
n_cores = 2
rank = 2
# Evaluation and Test parameters
val_speakers_per_batch = 40
val_utterances_per_speaker = 32
test_speakers_per_batch = 40
test_utterances_per_speaker = 32
# seed = None
| model_hidden_size = 768
model_embedding_size = 256
model_num_layers = 1
n_steps = 20000.0
learning_rate_init = 0.001
speakers_per_batch = 16
utterances_per_speaker = 32
compression = 'tt'
n_cores = 2
rank = 2
val_speakers_per_batch = 40
val_utterances_per_speaker = 32
test_speakers_per_batch = 40
test_utterances_per_speaker = 32 |
BRIGHTID_NODE = 'http://node.brightid.org/brightid/v5'
VERIFICATIONS_URL = BRIGHTID_NODE + '/verifications/idchain/'
OPERATION_URL = BRIGHTID_NODE + '/operations/'
CONTEXT = 'idchain'
RPC_URL = 'wss://idchain.one/ws/'
RELAYER_ADDRESS = '0x0df7eDDd60D613362ca2b44659F56fEbafFA9bFB'
DISTRIBUTION_ADDRESS = '0x6E39d7540c2ad4C18Eb29501183AFA79156e79aa'
DISTRIBUTION_ABI = '[{"inputs": [{"internalType": "address payable", "name": "beneficiary", "type": "address"}, {"internalType": "uint256", "name": "amount", "type": "uint256"}], "name": "claim", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "previousOwner", "type": "address"}, {"indexed": true, "internalType": "address", "name": "newOwner", "type": "address"}], "name": "OwnershipTransferred", "type": "event"}, {"inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "addr", "type": "address"}], "name": "setBrightid", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "_claimable", "type": "uint256"}], "name": "setClaimable", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "newOwner", "type": "address"}], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"stateMutability": "payable", "type": "receive"}, {"inputs": [], "name": "brightid", "outputs": [{"internalType": "contract BrightID", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "claimable", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "claimed", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "owner", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}]'
BRIGHTID_ADDRESS = '0x72a70314C3adD56127413F78402392744af4EF64'
BRIGHTID_ABI = '[{"anonymous": false, "inputs": [{"indexed": false, "internalType": "contract IERC20", "name": "supervisorToken", "type": "address"}, {"indexed": false, "internalType": "contract IERC20", "name": "proposerToken", "type": "address"}], "name": "MembershipTokensSet", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "previousOwner", "type": "address"}, {"indexed": true, "internalType": "address", "name": "newOwner", "type": "address"}], "name": "OwnershipTransferred", "type": "event"}, {"inputs": [{"internalType": "bytes32", "name": "context", "type": "bytes32"}, {"internalType": "address[]", "name": "addrs", "type": "address[]"}, {"internalType": "uint8", "name": "v", "type": "uint8"}, {"internalType": "bytes32", "name": "r", "type": "bytes32"}, {"internalType": "bytes32", "name": "s", "type": "bytes32"}], "name": "propose", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "addr", "type": "address"}], "name": "Proposed", "type": "event"}, {"inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "contract IERC20", "name": "_supervisorToken", "type": "address"}, {"internalType": "contract IERC20", "name": "_proposerToken", "type": "address"}], "name": "setMembershipTokens", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "_waiting", "type": "uint256"}, {"internalType": "uint256", "name": "_timeout", "type": "uint256"}], "name": "setTiming", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [], "name": "start", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"anonymous": false, "inputs": [], "name": "Started", "type": "event"}, {"inputs": [], "name": "stop", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "address", "name": "stopper", "type": "address"}], "name": "Stopped", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "uint256", "name": "waiting", "type": "uint256"}, {"indexed": false, "internalType": "uint256", "name": "timeout", "type": "uint256"}], "name": "TimingSet", "type": "event"}, {"inputs": [{"internalType": "address", "name": "newOwner", "type": "address"}], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "addr", "type": "address"}], "name": "Verified", "type": "event"}, {"inputs": [{"internalType": "bytes32", "name": "context", "type": "bytes32"}, {"internalType": "address[]", "name": "addrs", "type": "address[]"}], "name": "verify", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "history", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "isRevoked", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "owner", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "bytes32", "name": "", "type": "bytes32"}], "name": "proposals", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "proposerToken", "outputs": [{"internalType": "contract IERC20", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "stopped", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "supervisorToken", "outputs": [{"internalType": "contract IERC20", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "timeout", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "verifications", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "waiting", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}]'
NOT_FOUND = 2
NOT_SPONSORED = 4
CHAINID = '0x4a'
GAS = 500000
GAS_PRICE = 10000000000
WAITING_TIME_AFTER_PROPOSING = 15
LINK_CHECK_NUM = 18
LINK_CHECK_PERIOD = 10
SPONSOR_CHECK_NUM = 6
SPONSOR_CHECK_PERIOD = 10
HOST = 'localhost'
PORT = 5000
SPONSORSHIP_PRIVATEKEY = ''
RELAYER_PRIVATE = ''
| brightid_node = 'http://node.brightid.org/brightid/v5'
verifications_url = BRIGHTID_NODE + '/verifications/idchain/'
operation_url = BRIGHTID_NODE + '/operations/'
context = 'idchain'
rpc_url = 'wss://idchain.one/ws/'
relayer_address = '0x0df7eDDd60D613362ca2b44659F56fEbafFA9bFB'
distribution_address = '0x6E39d7540c2ad4C18Eb29501183AFA79156e79aa'
distribution_abi = '[{"inputs": [{"internalType": "address payable", "name": "beneficiary", "type": "address"}, {"internalType": "uint256", "name": "amount", "type": "uint256"}], "name": "claim", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "previousOwner", "type": "address"}, {"indexed": true, "internalType": "address", "name": "newOwner", "type": "address"}], "name": "OwnershipTransferred", "type": "event"}, {"inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "addr", "type": "address"}], "name": "setBrightid", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "_claimable", "type": "uint256"}], "name": "setClaimable", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "newOwner", "type": "address"}], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"stateMutability": "payable", "type": "receive"}, {"inputs": [], "name": "brightid", "outputs": [{"internalType": "contract BrightID", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "claimable", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "claimed", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "owner", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}]'
brightid_address = '0x72a70314C3adD56127413F78402392744af4EF64'
brightid_abi = '[{"anonymous": false, "inputs": [{"indexed": false, "internalType": "contract IERC20", "name": "supervisorToken", "type": "address"}, {"indexed": false, "internalType": "contract IERC20", "name": "proposerToken", "type": "address"}], "name": "MembershipTokensSet", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "previousOwner", "type": "address"}, {"indexed": true, "internalType": "address", "name": "newOwner", "type": "address"}], "name": "OwnershipTransferred", "type": "event"}, {"inputs": [{"internalType": "bytes32", "name": "context", "type": "bytes32"}, {"internalType": "address[]", "name": "addrs", "type": "address[]"}, {"internalType": "uint8", "name": "v", "type": "uint8"}, {"internalType": "bytes32", "name": "r", "type": "bytes32"}, {"internalType": "bytes32", "name": "s", "type": "bytes32"}], "name": "propose", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "addr", "type": "address"}], "name": "Proposed", "type": "event"}, {"inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "contract IERC20", "name": "_supervisorToken", "type": "address"}, {"internalType": "contract IERC20", "name": "_proposerToken", "type": "address"}], "name": "setMembershipTokens", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "_waiting", "type": "uint256"}, {"internalType": "uint256", "name": "_timeout", "type": "uint256"}], "name": "setTiming", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [], "name": "start", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"anonymous": false, "inputs": [], "name": "Started", "type": "event"}, {"inputs": [], "name": "stop", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "address", "name": "stopper", "type": "address"}], "name": "Stopped", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "uint256", "name": "waiting", "type": "uint256"}, {"indexed": false, "internalType": "uint256", "name": "timeout", "type": "uint256"}], "name": "TimingSet", "type": "event"}, {"inputs": [{"internalType": "address", "name": "newOwner", "type": "address"}], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "addr", "type": "address"}], "name": "Verified", "type": "event"}, {"inputs": [{"internalType": "bytes32", "name": "context", "type": "bytes32"}, {"internalType": "address[]", "name": "addrs", "type": "address[]"}], "name": "verify", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "history", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "isRevoked", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "owner", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "bytes32", "name": "", "type": "bytes32"}], "name": "proposals", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "proposerToken", "outputs": [{"internalType": "contract IERC20", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "stopped", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "supervisorToken", "outputs": [{"internalType": "contract IERC20", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "timeout", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "verifications", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "waiting", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}]'
not_found = 2
not_sponsored = 4
chainid = '0x4a'
gas = 500000
gas_price = 10000000000
waiting_time_after_proposing = 15
link_check_num = 18
link_check_period = 10
sponsor_check_num = 6
sponsor_check_period = 10
host = 'localhost'
port = 5000
sponsorship_privatekey = ''
relayer_private = '' |
# Time: O(n log n); Space: O(n)
def target_indices(nums, target):
nums.sort()
ans = []
for i, n in enumerate(nums):
if n == target:
ans.append(i)
return ans
# Time: O(n + k); Space(n + k)
def target_indices2(nums, target):
count = [0] * (max(nums) + 1)
for n in nums:
count[n] += 1
sorted_nums = []
for i, n in enumerate(count):
if n != 0:
sorted_nums.extend([i] * n)
ans = []
for i, n in enumerate(sorted_nums):
if n == target:
ans.append(i)
return ans
# Time: O(n); Space: O(n)
def target_indices3(nums, target):
less, equal = 0, 0
for num in nums:
if num < target:
less += 1
if num == target:
equal += 1
return list(range(less, less + equal))
# Test cases:
print(target_indices2([1, 2, 5, 2, 3], 2))
print(target_indices2([1, 2, 5, 2, 3], 3))
print(target_indices2([1, 2, 5, 2, 3], 5))
| def target_indices(nums, target):
nums.sort()
ans = []
for (i, n) in enumerate(nums):
if n == target:
ans.append(i)
return ans
def target_indices2(nums, target):
count = [0] * (max(nums) + 1)
for n in nums:
count[n] += 1
sorted_nums = []
for (i, n) in enumerate(count):
if n != 0:
sorted_nums.extend([i] * n)
ans = []
for (i, n) in enumerate(sorted_nums):
if n == target:
ans.append(i)
return ans
def target_indices3(nums, target):
(less, equal) = (0, 0)
for num in nums:
if num < target:
less += 1
if num == target:
equal += 1
return list(range(less, less + equal))
print(target_indices2([1, 2, 5, 2, 3], 2))
print(target_indices2([1, 2, 5, 2, 3], 3))
print(target_indices2([1, 2, 5, 2, 3], 5)) |
class Browser(object):
def __init__(self):
form = {}
def open(self, url):
pass
def set_handle_robots(self, status):
pass
def set_cookiejar(self, cj):
pass
def forms(self):
forms = [{'session[username_or_email]':'', 'session[password]':''}]
return forms
def close(self):
pass
class submit(object):
def __init__(self):
pass
def get_data(self):
return '<code>0123456</code>'
| class Browser(object):
def __init__(self):
form = {}
def open(self, url):
pass
def set_handle_robots(self, status):
pass
def set_cookiejar(self, cj):
pass
def forms(self):
forms = [{'session[username_or_email]': '', 'session[password]': ''}]
return forms
def close(self):
pass
class Submit(object):
def __init__(self):
pass
def get_data(self):
return '<code>0123456</code>' |
class Dataset():
def __init__(self, data,feature=None):
self.len = data.shape[0]
if (feature is not None):
self.data = data[:,:feature]
self.label = data[:,feature:]
else:
feature = data.shape[1]
self.data = data[:,:feature]
self.label = None
def __getitem__(self, index):
if (self.label is None):
return self.data[index]
return self.data[index],self.label[index]
def __len__(self):
return self.len
| class Dataset:
def __init__(self, data, feature=None):
self.len = data.shape[0]
if feature is not None:
self.data = data[:, :feature]
self.label = data[:, feature:]
else:
feature = data.shape[1]
self.data = data[:, :feature]
self.label = None
def __getitem__(self, index):
if self.label is None:
return self.data[index]
return (self.data[index], self.label[index])
def __len__(self):
return self.len |
class UnbundledTradeIndicatorEnum:
UNBUNDLED_TRADE_NONE = 0
FIRST_SUB_TRADE_OF_UNBUNDLED_TRADE = 1
LAST_SUB_TRADE_OF_UNBUNDLED_TRADE = 2
| class Unbundledtradeindicatorenum:
unbundled_trade_none = 0
first_sub_trade_of_unbundled_trade = 1
last_sub_trade_of_unbundled_trade = 2 |
# -*- coding: UTF-8 -*
def input_data2():
return None
| def input_data2():
return None |
def longest_possible_word_length():
return 189819
class iterlines(object):
def __init__(self, filehandle):
self._filehandle = filehandle
def __iter__(self):
self._filehandle.seek(0)
return self
def __next__(self):
line = self._filehandle.readline()
if line == '':
raise StopIteration
return line.strip('\n')
def generate_wordlist_from_file(filename, pred):
with open(filename, 'r') as f:
for word in iterlines(f):
if pred(word.replace('\n', '')):
yield word
def generate_wordlist_from_dict(pred):
for word in generate_wordlist_from_file('/usr/share/dict/words', pred):
yield word
def generate_wordlist(pred, wordlist=None, filename=None):
if wordlist is not None:
return [word for word in wordlist if pred(word)]
if filename is not None:
return [word for word in generate_wordlist_from_file(filename, pred)]
return [word for word in generate_wordlist_from_dict(pred)]
def words_by_ending(ending, wordlist=None):
def endswith(word):
return word.endswith(ending)
return generate_wordlist(endswith, wordlist)
def words_by_start(start, wordlist=None):
def startswith(word):
return word.startswith(start)
return generate_wordlist(startswith, wordlist)
def words_by_length(length, wordlist=None):
def is_correct_length(word):
return len(word) == length
def is_correct_length_tuple(word):
return len(word) >= length[0] and len(word) <= length[1]
if isinstance(length, tuple):
return generate_wordlist(is_correct_length_tuple, wordlist)
return generate_wordlist(is_correct_length, wordlist)
def words_by_maxlength(maxlength, wordlist=None):
return words_by_length((1, maxlength), wordlist)
def words_by_minlength(minlength, wordlist=None):
return words_by_length((minlength, longest_possible_word_length()), wordlist)
def len_hist(wordlist, should_print=False):
def extend_to_length(arr, newlen):
oldlen = len(arr)
if newlen > oldlen:
arr.extend([0] * (newlen - oldlen))
assert(len(arr) == newlen)
hist = []
for word in wordlist:
oldlen = len(hist)
wordlen = len(word)
if wordlen >= oldlen:
extend_to_length(hist, wordlen + 1)
assert(len(hist) == wordlen + 1)
hist[wordlen] += 1
if should_print:
print_len_hist(hist)
return hist
def print_len_hist(h):
print('Word length histogram:')
total = 0
for idx in range(len(h)):
if h[idx] > 0:
print('\t' + str(h[idx]) + ' words of length ' + str(idx))
total += h[idx]
print(str(total) + ' words total')
def remove_duplicates(wordlist):
unique_words = set()
for word in wordlist:
unique_words.add(word)
wordlist = list(unique_words)
return wordlist
def words_from_file(filename):
return generate_wordlist(lambda w: True, None, filename)
def remove_vowels(wordlist, include_y=False):
wordmap = dict()
vowels = 'aeiouy' if include_y else 'aeiou'
for word in wordlist:
trimmed = ''.join([c for c in word if c.lower() not in vowels])
wordmap[trimmed] = word
return wordmap
| def longest_possible_word_length():
return 189819
class Iterlines(object):
def __init__(self, filehandle):
self._filehandle = filehandle
def __iter__(self):
self._filehandle.seek(0)
return self
def __next__(self):
line = self._filehandle.readline()
if line == '':
raise StopIteration
return line.strip('\n')
def generate_wordlist_from_file(filename, pred):
with open(filename, 'r') as f:
for word in iterlines(f):
if pred(word.replace('\n', '')):
yield word
def generate_wordlist_from_dict(pred):
for word in generate_wordlist_from_file('/usr/share/dict/words', pred):
yield word
def generate_wordlist(pred, wordlist=None, filename=None):
if wordlist is not None:
return [word for word in wordlist if pred(word)]
if filename is not None:
return [word for word in generate_wordlist_from_file(filename, pred)]
return [word for word in generate_wordlist_from_dict(pred)]
def words_by_ending(ending, wordlist=None):
def endswith(word):
return word.endswith(ending)
return generate_wordlist(endswith, wordlist)
def words_by_start(start, wordlist=None):
def startswith(word):
return word.startswith(start)
return generate_wordlist(startswith, wordlist)
def words_by_length(length, wordlist=None):
def is_correct_length(word):
return len(word) == length
def is_correct_length_tuple(word):
return len(word) >= length[0] and len(word) <= length[1]
if isinstance(length, tuple):
return generate_wordlist(is_correct_length_tuple, wordlist)
return generate_wordlist(is_correct_length, wordlist)
def words_by_maxlength(maxlength, wordlist=None):
return words_by_length((1, maxlength), wordlist)
def words_by_minlength(minlength, wordlist=None):
return words_by_length((minlength, longest_possible_word_length()), wordlist)
def len_hist(wordlist, should_print=False):
def extend_to_length(arr, newlen):
oldlen = len(arr)
if newlen > oldlen:
arr.extend([0] * (newlen - oldlen))
assert len(arr) == newlen
hist = []
for word in wordlist:
oldlen = len(hist)
wordlen = len(word)
if wordlen >= oldlen:
extend_to_length(hist, wordlen + 1)
assert len(hist) == wordlen + 1
hist[wordlen] += 1
if should_print:
print_len_hist(hist)
return hist
def print_len_hist(h):
print('Word length histogram:')
total = 0
for idx in range(len(h)):
if h[idx] > 0:
print('\t' + str(h[idx]) + ' words of length ' + str(idx))
total += h[idx]
print(str(total) + ' words total')
def remove_duplicates(wordlist):
unique_words = set()
for word in wordlist:
unique_words.add(word)
wordlist = list(unique_words)
return wordlist
def words_from_file(filename):
return generate_wordlist(lambda w: True, None, filename)
def remove_vowels(wordlist, include_y=False):
wordmap = dict()
vowels = 'aeiouy' if include_y else 'aeiou'
for word in wordlist:
trimmed = ''.join([c for c in word if c.lower() not in vowels])
wordmap[trimmed] = word
return wordmap |
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def __repr__(self):
if type(self.data) != 'str':
return str(self.data)
return self.data
def _height(root):
if root is None:
return 0
return max(_height(root.left), _height(root.right)) + 1
def is_balanced_binary_tree(root):
'''
Binary tree where difference between the left and the right
subtree for any node is not more than one
'''
if root is None:
return True
lh = _height(root.left)
rh = _height(root.right)
if ((abs(lh - rh) <= 1) and
is_balanced_binary_tree(root.left) and
is_balanced_binary_tree(root.right)):
return True
return False
def _count_nodes(root):
if root is None:
return 0
return (1 + _count_nodes(root.left) + _count_nodes(root.right))
def is_complete_binary_tree(root, index, number_of_nodes):
'''
Binary tree in which all levels are filled except possibly the
lowest level which is filled from left to right
'''
if root is None:
return True
if index >= number_of_nodes:
return False
return (is_complete_binary_tree(root.left, 2*index+1, number_of_nodes) and
is_complete_binary_tree(root.right, 2*index+2, number_of_nodes))
def _calculate_left_depth(root):
left_depth = 0
while(root is not None):
left_depth += 1
root = root.left
return left_depth
def is_perfect_binary_tree(root, left_depth, level=0):
'''
Binary tree in which every internal node has exactly 2 child nodes and
and all leaf nodes are at the same level is a perfect binary tree
'''
if root is None:
return True
if (root.left is None and root.right is None):
return (left_depth == level + 1)
if (root.left is None or root.right is None):
return False
return (is_perfect_binary_tree(root.left, left_depth, level+1) and
is_perfect_binary_tree(root.right, left_depth, level+1))
def is_full_binary_tree(root):
'''
Binary tree with parent node and all internal nodes having either 2
children nodes or no children nodes are called full binary tree.
'''
if root is None:
return True
if root.left is None and root.right is None:
return True
if root.left is not None and root.right is not None:
return is_full_binary_tree(root.left) and is_full_binary_tree(root.right)
return False
def build_tree_one():
root = Node(1)
root.right = Node(3)
root.left = Node(2)
root.left.left = Node(4)
root.left.right = Node(5)
root.left.right.left = Node(6)
root.left.right.right = Node(7)
return root
def build_tree_two():
root = Node(1)
root.left = Node(12)
root.right = Node(9)
root.left.left = Node(5)
root.left.right = Node(6)
return root
def build_tree_three():
root = Node(1)
root.left = Node(2)
root.right = Node(3)
root.left.left = Node(4)
root.left.right = Node(5)
root.right.left = Node(13)
root.right.right = Node(9)
return root
if __name__ == '__main__':
tree_one = build_tree_one()
if is_full_binary_tree(tree_one):
print('Tree One is full binary tree')
else:
print('Tree One is not full binary tree')
if is_perfect_binary_tree(tree_one, _calculate_left_depth(tree_one)):
print('Tree One is perfect binary tree')
else:
print('Tree One is not perfect binary tree')
if is_complete_binary_tree(tree_one, 0, _count_nodes(tree_one)):
print('Tree One is a complete binary tree')
else:
print('Tree One is not a complete binary tree')
if is_balanced_binary_tree(tree_one):
print('Tree One is balanced binary tree')
else:
print('Tree One is not a balanced binary tree')
tree_two = build_tree_two()
if is_full_binary_tree(tree_two):
print('\nTree Two is full binary tree')
else:
print('\nTree Two is not full binary tree')
if is_perfect_binary_tree(tree_two, _calculate_left_depth(tree_two)):
print('Tree Two is perfect binary tree')
else:
print('Tree Two is not perfect binary tree')
if is_complete_binary_tree(tree_two, 0, _count_nodes(tree_two)):
print('Tree Two is a complete binary tree')
else:
print('Tree Two is not a complete binary tree')
if is_balanced_binary_tree(tree_two):
print('Tree Two is balanced binary tree')
else:
print('Tree Two is not a balanced binary tree')
tree_three = build_tree_three()
if is_full_binary_tree(tree_three):
print('\nTree Three is full binary tree')
else:
print('\nTree Three is not full binary tree')
if is_perfect_binary_tree(tree_three, _calculate_left_depth(tree_three)):
print('Tree Three is perfect binary tree')
else:
print('Tree Three is not perfect binary tree')
if is_complete_binary_tree(tree_three, 0, _count_nodes(tree_three)):
print('Tree Three is a complete binary tree')
else:
print('Tree Three is not a complete binary tree')
if is_balanced_binary_tree(tree_three):
print('Tree Three is balanced binary tree')
else:
print('Tree Three is not a balanced binary tree')
| class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def __repr__(self):
if type(self.data) != 'str':
return str(self.data)
return self.data
def _height(root):
if root is None:
return 0
return max(_height(root.left), _height(root.right)) + 1
def is_balanced_binary_tree(root):
"""
Binary tree where difference between the left and the right
subtree for any node is not more than one
"""
if root is None:
return True
lh = _height(root.left)
rh = _height(root.right)
if abs(lh - rh) <= 1 and is_balanced_binary_tree(root.left) and is_balanced_binary_tree(root.right):
return True
return False
def _count_nodes(root):
if root is None:
return 0
return 1 + _count_nodes(root.left) + _count_nodes(root.right)
def is_complete_binary_tree(root, index, number_of_nodes):
"""
Binary tree in which all levels are filled except possibly the
lowest level which is filled from left to right
"""
if root is None:
return True
if index >= number_of_nodes:
return False
return is_complete_binary_tree(root.left, 2 * index + 1, number_of_nodes) and is_complete_binary_tree(root.right, 2 * index + 2, number_of_nodes)
def _calculate_left_depth(root):
left_depth = 0
while root is not None:
left_depth += 1
root = root.left
return left_depth
def is_perfect_binary_tree(root, left_depth, level=0):
"""
Binary tree in which every internal node has exactly 2 child nodes and
and all leaf nodes are at the same level is a perfect binary tree
"""
if root is None:
return True
if root.left is None and root.right is None:
return left_depth == level + 1
if root.left is None or root.right is None:
return False
return is_perfect_binary_tree(root.left, left_depth, level + 1) and is_perfect_binary_tree(root.right, left_depth, level + 1)
def is_full_binary_tree(root):
"""
Binary tree with parent node and all internal nodes having either 2
children nodes or no children nodes are called full binary tree.
"""
if root is None:
return True
if root.left is None and root.right is None:
return True
if root.left is not None and root.right is not None:
return is_full_binary_tree(root.left) and is_full_binary_tree(root.right)
return False
def build_tree_one():
root = node(1)
root.right = node(3)
root.left = node(2)
root.left.left = node(4)
root.left.right = node(5)
root.left.right.left = node(6)
root.left.right.right = node(7)
return root
def build_tree_two():
root = node(1)
root.left = node(12)
root.right = node(9)
root.left.left = node(5)
root.left.right = node(6)
return root
def build_tree_three():
root = node(1)
root.left = node(2)
root.right = node(3)
root.left.left = node(4)
root.left.right = node(5)
root.right.left = node(13)
root.right.right = node(9)
return root
if __name__ == '__main__':
tree_one = build_tree_one()
if is_full_binary_tree(tree_one):
print('Tree One is full binary tree')
else:
print('Tree One is not full binary tree')
if is_perfect_binary_tree(tree_one, _calculate_left_depth(tree_one)):
print('Tree One is perfect binary tree')
else:
print('Tree One is not perfect binary tree')
if is_complete_binary_tree(tree_one, 0, _count_nodes(tree_one)):
print('Tree One is a complete binary tree')
else:
print('Tree One is not a complete binary tree')
if is_balanced_binary_tree(tree_one):
print('Tree One is balanced binary tree')
else:
print('Tree One is not a balanced binary tree')
tree_two = build_tree_two()
if is_full_binary_tree(tree_two):
print('\nTree Two is full binary tree')
else:
print('\nTree Two is not full binary tree')
if is_perfect_binary_tree(tree_two, _calculate_left_depth(tree_two)):
print('Tree Two is perfect binary tree')
else:
print('Tree Two is not perfect binary tree')
if is_complete_binary_tree(tree_two, 0, _count_nodes(tree_two)):
print('Tree Two is a complete binary tree')
else:
print('Tree Two is not a complete binary tree')
if is_balanced_binary_tree(tree_two):
print('Tree Two is balanced binary tree')
else:
print('Tree Two is not a balanced binary tree')
tree_three = build_tree_three()
if is_full_binary_tree(tree_three):
print('\nTree Three is full binary tree')
else:
print('\nTree Three is not full binary tree')
if is_perfect_binary_tree(tree_three, _calculate_left_depth(tree_three)):
print('Tree Three is perfect binary tree')
else:
print('Tree Three is not perfect binary tree')
if is_complete_binary_tree(tree_three, 0, _count_nodes(tree_three)):
print('Tree Three is a complete binary tree')
else:
print('Tree Three is not a complete binary tree')
if is_balanced_binary_tree(tree_three):
print('Tree Three is balanced binary tree')
else:
print('Tree Three is not a balanced binary tree') |
def most_frequent(arr):
ret = None
counter = {}
max_count = -1
for n in arr:
counter.setdefault(n, 0)
counter[n] += 1
if counter[n] > max_count:
max_count = counter[n]
ret = n
return ret
| def most_frequent(arr):
ret = None
counter = {}
max_count = -1
for n in arr:
counter.setdefault(n, 0)
counter[n] += 1
if counter[n] > max_count:
max_count = counter[n]
ret = n
return ret |
# Created by MechAviv
# Kinesis Introduction
# Map ID :: 331003200
# Subway :: Subway Car #3
JAY = 1531001
GIRL = 1531067
sm.spawnNpc(GIRL, 699, 47)
sm.showNpcSpecialActionByTemplateId(GIRL, "summon")
sm.spawnMob(2700303, 250, 57, False)
sm.spawnMob(2700303, 250, 57, False)
sm.spawnMob(2700303, 250, 57, False)
sm.spawnMob(2700303, 250, 57, False)
sm.spawnMob(2700303, 250, 57, False)
sm.spawnMob(2700304, 300, 57, False)
sm.spawnMob(2700304, 300, 57, False)
sm.spawnMob(2700304, 300, 57, False)
sm.spawnMob(2700304, 300, 57, False)
sm.spawnMob(2700304, 300, 57, False)
sm.spawnMob(2700305, 350, 57, False)
sm.spawnMob(2700305, 350, 57, False)
sm.spawnMob(2700305, 350, 57, False)
sm.spawnMob(2700305, 350, 57, False)
sm.spawnMob(2700305, 350, 57, False)
sm.setSpineObjectEffectPlay(True, "subway_bg", "outside", True, False)
sm.setSpineObjectEffectPlay(True, "subway_main", "outside", True, False)
sm.unlockForIntro()
sm.playSound("Sound/Field.img/flowervioleta/wink")
sm.cameraSwitchNormal("go_next", 1000)
sm.addPopUpSay(JAY, 2000, "#face10#Watch out, there are more on the way!", "") | jay = 1531001
girl = 1531067
sm.spawnNpc(GIRL, 699, 47)
sm.showNpcSpecialActionByTemplateId(GIRL, 'summon')
sm.spawnMob(2700303, 250, 57, False)
sm.spawnMob(2700303, 250, 57, False)
sm.spawnMob(2700303, 250, 57, False)
sm.spawnMob(2700303, 250, 57, False)
sm.spawnMob(2700303, 250, 57, False)
sm.spawnMob(2700304, 300, 57, False)
sm.spawnMob(2700304, 300, 57, False)
sm.spawnMob(2700304, 300, 57, False)
sm.spawnMob(2700304, 300, 57, False)
sm.spawnMob(2700304, 300, 57, False)
sm.spawnMob(2700305, 350, 57, False)
sm.spawnMob(2700305, 350, 57, False)
sm.spawnMob(2700305, 350, 57, False)
sm.spawnMob(2700305, 350, 57, False)
sm.spawnMob(2700305, 350, 57, False)
sm.setSpineObjectEffectPlay(True, 'subway_bg', 'outside', True, False)
sm.setSpineObjectEffectPlay(True, 'subway_main', 'outside', True, False)
sm.unlockForIntro()
sm.playSound('Sound/Field.img/flowervioleta/wink')
sm.cameraSwitchNormal('go_next', 1000)
sm.addPopUpSay(JAY, 2000, '#face10#Watch out, there are more on the way!', '') |
# https://www.hackerrank.com/challenges/30-review-loop/
T = int(input())
S = list()
for i in range(T):
S.append(str(input()))
for i in range(len(S)):
print(S[i][0] + S[i][2::2] + ' ' + S[i][1::2])
| t = int(input())
s = list()
for i in range(T):
S.append(str(input()))
for i in range(len(S)):
print(S[i][0] + S[i][2::2] + ' ' + S[i][1::2]) |
#
# PySNMP MIB module A3COM0420-SWITCH-EXTENSIONS (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/A3COM0420-SWITCH-EXTENSIONS
# Produced by pysmi-0.3.4 at Mon Apr 29 16:54:17 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)
#
brasica2, = mibBuilder.importSymbols("A3COM0004-GENERIC", "brasica2")
OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ValueSizeConstraint, SingleValueConstraint, ConstraintsUnion, ConstraintsIntersection, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "SingleValueConstraint", "ConstraintsUnion", "ConstraintsIntersection", "ValueRangeConstraint")
ifIndex, = mibBuilder.importSymbols("IF-MIB", "ifIndex")
ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup")
NotificationType, Bits, MibIdentifier, TimeTicks, Integer32, ObjectIdentity, Counter64, Unsigned32, iso, Gauge32, ModuleIdentity, IpAddress, Counter32, MibScalar, MibTable, MibTableRow, MibTableColumn = mibBuilder.importSymbols("SNMPv2-SMI", "NotificationType", "Bits", "MibIdentifier", "TimeTicks", "Integer32", "ObjectIdentity", "Counter64", "Unsigned32", "iso", "Gauge32", "ModuleIdentity", "IpAddress", "Counter32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn")
TextualConvention, MacAddress, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "MacAddress", "DisplayString")
stackConfigGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 43, 10, 34, 1))
prConStackFwdingMode = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("fastForward", 1), ("fragmentFree", 2), ("storeAndForward", 3), ("intelligent", 4)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: prConStackFwdingMode.setStatus('mandatory')
prConStackPaceMode = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("notApplicable", 1), ("normalEthernet", 2), ("lowLatency", 3)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: prConStackPaceMode.setStatus('mandatory')
prConStackVLANConfigMode = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("notApplicable", 1), ("portMode", 2), ("autoSelect", 3)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: prConStackVLANConfigMode.setStatus('mandatory')
prConStackRAPStudyPort = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 4), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: prConStackRAPStudyPort.setStatus('mandatory')
prConStackRAPCopyPort = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 5), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: prConStackRAPCopyPort.setStatus('mandatory')
prConStackRAPEnable = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("off", 1), ("on", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: prConStackRAPEnable.setStatus('mandatory')
prConStackBridgeMode = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("single", 1), ("multiple", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: prConStackBridgeMode.setStatus('mandatory')
prConStackIpTos = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("notApplicable", 1), ("enable", 2), ("disable", 3)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: prConStackIpTos.setStatus('mandatory')
prConStackPktRateControl = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9))).clone(namedValues=NamedValues(("notApplicable", 1), ("disable", 2), ("limitUnknownDAs", 3), ("limitMcasts", 4), ("limitMcastsAndUnknownDAs", 5), ("limitBcasts", 6), ("limitBcastsAndUnknownDAs", 7), ("limitBcastsAndMcasts", 8), ("limitBcastsMcastsAndUnknownDAs", 9)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: prConStackPktRateControl.setStatus('mandatory')
prConStackPktRateLimit = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 11), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 262143))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: prConStackPktRateLimit.setStatus('mandatory')
prConStackStpProtocolVersion = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 12), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 2))).clone(namedValues=NamedValues(("stpVersion0", 0), ("rstpVersion2", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: prConStackStpProtocolVersion.setStatus('mandatory')
prConStackStpPathCostDefault = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 13), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("stp8021d1998", 1), ("stp8021t2000", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: prConStackStpPathCostDefault.setStatus('mandatory')
prConStackLacpOperInfo = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 14), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("notOperational", 1), ("operational", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: prConStackLacpOperInfo.setStatus('mandatory')
switchConfigGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 43, 10, 34, 2))
prConfigPortTable = MibTable((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1), )
if mibBuilder.loadTexts: prConfigPortTable.setStatus('mandatory')
prConfigPortEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1), ).setIndexNames((0, "IF-MIB", "ifIndex"))
if mibBuilder.loadTexts: prConfigPortEntry.setStatus('mandatory')
prConPortVLANConfigMode = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("notApplicable", 1), ("useDefault", 2), ("portMode", 3), ("autoSelect", 4)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: prConPortVLANConfigMode.setStatus('mandatory')
prConPortIFM = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1, 13), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))).clone(namedValues=NamedValues(("notApplicable", 1), ("off", 2), ("maxJams6", 3), ("maxJams7", 4), ("maxJams8", 5), ("maxJams9", 6), ("maxJams10", 7), ("maxJams11", 8), ("maxJams12", 9), ("maxJams13", 10)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: prConPortIFM.setStatus('mandatory')
prConPortLacp = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1, 14), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: prConPortLacp.setStatus('mandatory')
prConPortStpAdminPathCost = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1, 15), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 200000000))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: prConPortStpAdminPathCost.setStatus('mandatory')
prConPortCascadeMode = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1, 16), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: prConPortCascadeMode.setStatus('mandatory')
prConPortFdbTable = MibTable((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2), )
if mibBuilder.loadTexts: prConPortFdbTable.setStatus('mandatory')
prConPortFdbEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2, 1), ).setIndexNames((0, "A3COM0420-SWITCH-EXTENSIONS", "prConPortFdbPort"), (0, "A3COM0420-SWITCH-EXTENSIONS", "prConPortFdbId"), (0, "A3COM0420-SWITCH-EXTENSIONS", "prConPortFdbAddress"))
if mibBuilder.loadTexts: prConPortFdbEntry.setStatus('mandatory')
prConPortFdbPort = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535)))
if mibBuilder.loadTexts: prConPortFdbPort.setStatus('mandatory')
prConPortFdbId = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2, 1, 2), Integer32())
if mibBuilder.loadTexts: prConPortFdbId.setStatus('mandatory')
prConPortFdbAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2, 1, 3), MacAddress())
if mibBuilder.loadTexts: prConPortFdbAddress.setStatus('mandatory')
prConPortFdbStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("other", 1), ("invalid", 2), ("learned", 3), ("self", 4), ("mgmt", 5)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: prConPortFdbStatus.setStatus('mandatory')
prConTrunkMulticastTable = MibTable((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3), )
if mibBuilder.loadTexts: prConTrunkMulticastTable.setStatus('mandatory')
prConTrunkMulticastEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1), ).setIndexNames((0, "A3COM0420-SWITCH-EXTENSIONS", "prConTrunkMulticastFdbId"), (0, "A3COM0420-SWITCH-EXTENSIONS", "prConTrunkMulticastAddress"))
if mibBuilder.loadTexts: prConTrunkMulticastEntry.setStatus('mandatory')
prConTrunkMulticastFdbId = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 1), Integer32())
if mibBuilder.loadTexts: prConTrunkMulticastFdbId.setStatus('mandatory')
prConTrunkMulticastAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 2), MacAddress())
if mibBuilder.loadTexts: prConTrunkMulticastAddress.setStatus('mandatory')
prConTrunkMulticastPortlist = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 3), OctetString()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: prConTrunkMulticastPortlist.setStatus('mandatory')
prConTrunkMulticastStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("other", 1), ("invalid", 2), ("permanent", 3), ("deleteOnReset", 4), ("deleteOnTimeout", 5)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: prConTrunkMulticastStatus.setStatus('mandatory')
prConTrunkMulticastType = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("other", 1), ("invalid", 2), ("learned", 3), ("self", 4), ("mgmt", 5)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: prConTrunkMulticastType.setStatus('mandatory')
prConTrunkMulticastRobp = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("true", 1), ("false", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: prConTrunkMulticastRobp.setStatus('mandatory')
prConIfIndexTable = MibTable((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4), )
if mibBuilder.loadTexts: prConIfIndexTable.setStatus('mandatory')
prConIfIndexEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4, 1), ).setIndexNames((0, "A3COM0420-SWITCH-EXTENSIONS", "prConIfIndexGroupIndex"), (0, "A3COM0420-SWITCH-EXTENSIONS", "prConIfIndexPortIndex"))
if mibBuilder.loadTexts: prConIfIndexEntry.setStatus('mandatory')
prConIfIndexGroupIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1024)))
if mibBuilder.loadTexts: prConIfIndexGroupIndex.setStatus('mandatory')
prConIfIndexPortIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1024)))
if mibBuilder.loadTexts: prConIfIndexPortIndex.setStatus('mandatory')
prConIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4, 1, 3), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: prConIfIndex.setStatus('mandatory')
prConIfIndexBridgePort = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly")
if mibBuilder.loadTexts: prConIfIndexBridgePort.setStatus('mandatory')
prConfigAggTable = MibTable((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 5), )
if mibBuilder.loadTexts: prConfigAggTable.setStatus('mandatory')
prConfigAggEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 5, 1), ).setIndexNames((0, "IF-MIB", "ifIndex"))
if mibBuilder.loadTexts: prConfigAggEntry.setStatus('mandatory')
prConfigAggStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 5, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("unused", 1), ("autoInUse", 2), ("autoAgeing", 3), ("autoReusable", 4), ("manual", 5)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: prConfigAggStatus.setStatus('mandatory')
mibBuilder.exportSymbols("A3COM0420-SWITCH-EXTENSIONS", prConIfIndexGroupIndex=prConIfIndexGroupIndex, prConIfIndexTable=prConIfIndexTable, prConfigAggEntry=prConfigAggEntry, prConfigAggStatus=prConfigAggStatus, prConTrunkMulticastStatus=prConTrunkMulticastStatus, switchConfigGroup=switchConfigGroup, prConPortIFM=prConPortIFM, stackConfigGroup=stackConfigGroup, prConPortFdbStatus=prConPortFdbStatus, prConTrunkMulticastAddress=prConTrunkMulticastAddress, prConIfIndexEntry=prConIfIndexEntry, prConStackIpTos=prConStackIpTos, prConStackStpPathCostDefault=prConStackStpPathCostDefault, prConPortFdbId=prConPortFdbId, prConPortVLANConfigMode=prConPortVLANConfigMode, prConTrunkMulticastTable=prConTrunkMulticastTable, prConIfIndexBridgePort=prConIfIndexBridgePort, prConPortFdbPort=prConPortFdbPort, prConPortCascadeMode=prConPortCascadeMode, prConStackBridgeMode=prConStackBridgeMode, prConPortFdbTable=prConPortFdbTable, prConTrunkMulticastRobp=prConTrunkMulticastRobp, prConStackRAPEnable=prConStackRAPEnable, prConPortLacp=prConPortLacp, prConTrunkMulticastType=prConTrunkMulticastType, prConfigAggTable=prConfigAggTable, prConStackPktRateLimit=prConStackPktRateLimit, prConIfIndexPortIndex=prConIfIndexPortIndex, prConTrunkMulticastFdbId=prConTrunkMulticastFdbId, prConStackFwdingMode=prConStackFwdingMode, prConStackStpProtocolVersion=prConStackStpProtocolVersion, prConPortFdbEntry=prConPortFdbEntry, prConPortFdbAddress=prConPortFdbAddress, prConPortStpAdminPathCost=prConPortStpAdminPathCost, prConIfIndex=prConIfIndex, prConStackRAPCopyPort=prConStackRAPCopyPort, prConTrunkMulticastEntry=prConTrunkMulticastEntry, prConTrunkMulticastPortlist=prConTrunkMulticastPortlist, prConStackRAPStudyPort=prConStackRAPStudyPort, prConfigPortEntry=prConfigPortEntry, prConStackPktRateControl=prConStackPktRateControl, prConfigPortTable=prConfigPortTable, prConStackPaceMode=prConStackPaceMode, prConStackVLANConfigMode=prConStackVLANConfigMode, prConStackLacpOperInfo=prConStackLacpOperInfo)
| (brasica2,) = mibBuilder.importSymbols('A3COM0004-GENERIC', 'brasica2')
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, single_value_constraint, constraints_union, constraints_intersection, value_range_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueSizeConstraint', 'SingleValueConstraint', 'ConstraintsUnion', 'ConstraintsIntersection', 'ValueRangeConstraint')
(if_index,) = mibBuilder.importSymbols('IF-MIB', 'ifIndex')
(module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup')
(notification_type, bits, mib_identifier, time_ticks, integer32, object_identity, counter64, unsigned32, iso, gauge32, module_identity, ip_address, counter32, mib_scalar, mib_table, mib_table_row, mib_table_column) = mibBuilder.importSymbols('SNMPv2-SMI', 'NotificationType', 'Bits', 'MibIdentifier', 'TimeTicks', 'Integer32', 'ObjectIdentity', 'Counter64', 'Unsigned32', 'iso', 'Gauge32', 'ModuleIdentity', 'IpAddress', 'Counter32', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn')
(textual_convention, mac_address, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'MacAddress', 'DisplayString')
stack_config_group = mib_identifier((1, 3, 6, 1, 4, 1, 43, 10, 34, 1))
pr_con_stack_fwding_mode = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('fastForward', 1), ('fragmentFree', 2), ('storeAndForward', 3), ('intelligent', 4)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
prConStackFwdingMode.setStatus('mandatory')
pr_con_stack_pace_mode = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('notApplicable', 1), ('normalEthernet', 2), ('lowLatency', 3)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
prConStackPaceMode.setStatus('mandatory')
pr_con_stack_vlan_config_mode = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('notApplicable', 1), ('portMode', 2), ('autoSelect', 3)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
prConStackVLANConfigMode.setStatus('mandatory')
pr_con_stack_rap_study_port = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 4), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
prConStackRAPStudyPort.setStatus('mandatory')
pr_con_stack_rap_copy_port = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 5), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
prConStackRAPCopyPort.setStatus('mandatory')
pr_con_stack_rap_enable = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('off', 1), ('on', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
prConStackRAPEnable.setStatus('mandatory')
pr_con_stack_bridge_mode = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('single', 1), ('multiple', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
prConStackBridgeMode.setStatus('mandatory')
pr_con_stack_ip_tos = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 9), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('notApplicable', 1), ('enable', 2), ('disable', 3)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
prConStackIpTos.setStatus('mandatory')
pr_con_stack_pkt_rate_control = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 10), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9))).clone(namedValues=named_values(('notApplicable', 1), ('disable', 2), ('limitUnknownDAs', 3), ('limitMcasts', 4), ('limitMcastsAndUnknownDAs', 5), ('limitBcasts', 6), ('limitBcastsAndUnknownDAs', 7), ('limitBcastsAndMcasts', 8), ('limitBcastsMcastsAndUnknownDAs', 9)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
prConStackPktRateControl.setStatus('mandatory')
pr_con_stack_pkt_rate_limit = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 11), integer32().subtype(subtypeSpec=value_range_constraint(0, 262143))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
prConStackPktRateLimit.setStatus('mandatory')
pr_con_stack_stp_protocol_version = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 12), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 2))).clone(namedValues=named_values(('stpVersion0', 0), ('rstpVersion2', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
prConStackStpProtocolVersion.setStatus('mandatory')
pr_con_stack_stp_path_cost_default = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 13), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('stp8021d1998', 1), ('stp8021t2000', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
prConStackStpPathCostDefault.setStatus('mandatory')
pr_con_stack_lacp_oper_info = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 14), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('notOperational', 1), ('operational', 2)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
prConStackLacpOperInfo.setStatus('mandatory')
switch_config_group = mib_identifier((1, 3, 6, 1, 4, 1, 43, 10, 34, 2))
pr_config_port_table = mib_table((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1))
if mibBuilder.loadTexts:
prConfigPortTable.setStatus('mandatory')
pr_config_port_entry = mib_table_row((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1)).setIndexNames((0, 'IF-MIB', 'ifIndex'))
if mibBuilder.loadTexts:
prConfigPortEntry.setStatus('mandatory')
pr_con_port_vlan_config_mode = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('notApplicable', 1), ('useDefault', 2), ('portMode', 3), ('autoSelect', 4)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
prConPortVLANConfigMode.setStatus('mandatory')
pr_con_port_ifm = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1, 13), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))).clone(namedValues=named_values(('notApplicable', 1), ('off', 2), ('maxJams6', 3), ('maxJams7', 4), ('maxJams8', 5), ('maxJams9', 6), ('maxJams10', 7), ('maxJams11', 8), ('maxJams12', 9), ('maxJams13', 10)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
prConPortIFM.setStatus('mandatory')
pr_con_port_lacp = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1, 14), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enable', 1), ('disable', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
prConPortLacp.setStatus('mandatory')
pr_con_port_stp_admin_path_cost = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1, 15), integer32().subtype(subtypeSpec=value_range_constraint(0, 200000000))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
prConPortStpAdminPathCost.setStatus('mandatory')
pr_con_port_cascade_mode = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1, 16), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enabled', 1), ('disabled', 2)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
prConPortCascadeMode.setStatus('mandatory')
pr_con_port_fdb_table = mib_table((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2))
if mibBuilder.loadTexts:
prConPortFdbTable.setStatus('mandatory')
pr_con_port_fdb_entry = mib_table_row((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2, 1)).setIndexNames((0, 'A3COM0420-SWITCH-EXTENSIONS', 'prConPortFdbPort'), (0, 'A3COM0420-SWITCH-EXTENSIONS', 'prConPortFdbId'), (0, 'A3COM0420-SWITCH-EXTENSIONS', 'prConPortFdbAddress'))
if mibBuilder.loadTexts:
prConPortFdbEntry.setStatus('mandatory')
pr_con_port_fdb_port = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(0, 65535)))
if mibBuilder.loadTexts:
prConPortFdbPort.setStatus('mandatory')
pr_con_port_fdb_id = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2, 1, 2), integer32())
if mibBuilder.loadTexts:
prConPortFdbId.setStatus('mandatory')
pr_con_port_fdb_address = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2, 1, 3), mac_address())
if mibBuilder.loadTexts:
prConPortFdbAddress.setStatus('mandatory')
pr_con_port_fdb_status = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('other', 1), ('invalid', 2), ('learned', 3), ('self', 4), ('mgmt', 5)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
prConPortFdbStatus.setStatus('mandatory')
pr_con_trunk_multicast_table = mib_table((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3))
if mibBuilder.loadTexts:
prConTrunkMulticastTable.setStatus('mandatory')
pr_con_trunk_multicast_entry = mib_table_row((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1)).setIndexNames((0, 'A3COM0420-SWITCH-EXTENSIONS', 'prConTrunkMulticastFdbId'), (0, 'A3COM0420-SWITCH-EXTENSIONS', 'prConTrunkMulticastAddress'))
if mibBuilder.loadTexts:
prConTrunkMulticastEntry.setStatus('mandatory')
pr_con_trunk_multicast_fdb_id = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 1), integer32())
if mibBuilder.loadTexts:
prConTrunkMulticastFdbId.setStatus('mandatory')
pr_con_trunk_multicast_address = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 2), mac_address())
if mibBuilder.loadTexts:
prConTrunkMulticastAddress.setStatus('mandatory')
pr_con_trunk_multicast_portlist = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 3), octet_string()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
prConTrunkMulticastPortlist.setStatus('mandatory')
pr_con_trunk_multicast_status = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('other', 1), ('invalid', 2), ('permanent', 3), ('deleteOnReset', 4), ('deleteOnTimeout', 5)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
prConTrunkMulticastStatus.setStatus('mandatory')
pr_con_trunk_multicast_type = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('other', 1), ('invalid', 2), ('learned', 3), ('self', 4), ('mgmt', 5)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
prConTrunkMulticastType.setStatus('mandatory')
pr_con_trunk_multicast_robp = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('true', 1), ('false', 2)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
prConTrunkMulticastRobp.setStatus('mandatory')
pr_con_if_index_table = mib_table((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4))
if mibBuilder.loadTexts:
prConIfIndexTable.setStatus('mandatory')
pr_con_if_index_entry = mib_table_row((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4, 1)).setIndexNames((0, 'A3COM0420-SWITCH-EXTENSIONS', 'prConIfIndexGroupIndex'), (0, 'A3COM0420-SWITCH-EXTENSIONS', 'prConIfIndexPortIndex'))
if mibBuilder.loadTexts:
prConIfIndexEntry.setStatus('mandatory')
pr_con_if_index_group_index = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 1024)))
if mibBuilder.loadTexts:
prConIfIndexGroupIndex.setStatus('mandatory')
pr_con_if_index_port_index = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4, 1, 2), integer32().subtype(subtypeSpec=value_range_constraint(1, 1024)))
if mibBuilder.loadTexts:
prConIfIndexPortIndex.setStatus('mandatory')
pr_con_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4, 1, 3), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
prConIfIndex.setStatus('mandatory')
pr_con_if_index_bridge_port = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4, 1, 4), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
prConIfIndexBridgePort.setStatus('mandatory')
pr_config_agg_table = mib_table((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 5))
if mibBuilder.loadTexts:
prConfigAggTable.setStatus('mandatory')
pr_config_agg_entry = mib_table_row((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 5, 1)).setIndexNames((0, 'IF-MIB', 'ifIndex'))
if mibBuilder.loadTexts:
prConfigAggEntry.setStatus('mandatory')
pr_config_agg_status = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 5, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('unused', 1), ('autoInUse', 2), ('autoAgeing', 3), ('autoReusable', 4), ('manual', 5)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
prConfigAggStatus.setStatus('mandatory')
mibBuilder.exportSymbols('A3COM0420-SWITCH-EXTENSIONS', prConIfIndexGroupIndex=prConIfIndexGroupIndex, prConIfIndexTable=prConIfIndexTable, prConfigAggEntry=prConfigAggEntry, prConfigAggStatus=prConfigAggStatus, prConTrunkMulticastStatus=prConTrunkMulticastStatus, switchConfigGroup=switchConfigGroup, prConPortIFM=prConPortIFM, stackConfigGroup=stackConfigGroup, prConPortFdbStatus=prConPortFdbStatus, prConTrunkMulticastAddress=prConTrunkMulticastAddress, prConIfIndexEntry=prConIfIndexEntry, prConStackIpTos=prConStackIpTos, prConStackStpPathCostDefault=prConStackStpPathCostDefault, prConPortFdbId=prConPortFdbId, prConPortVLANConfigMode=prConPortVLANConfigMode, prConTrunkMulticastTable=prConTrunkMulticastTable, prConIfIndexBridgePort=prConIfIndexBridgePort, prConPortFdbPort=prConPortFdbPort, prConPortCascadeMode=prConPortCascadeMode, prConStackBridgeMode=prConStackBridgeMode, prConPortFdbTable=prConPortFdbTable, prConTrunkMulticastRobp=prConTrunkMulticastRobp, prConStackRAPEnable=prConStackRAPEnable, prConPortLacp=prConPortLacp, prConTrunkMulticastType=prConTrunkMulticastType, prConfigAggTable=prConfigAggTable, prConStackPktRateLimit=prConStackPktRateLimit, prConIfIndexPortIndex=prConIfIndexPortIndex, prConTrunkMulticastFdbId=prConTrunkMulticastFdbId, prConStackFwdingMode=prConStackFwdingMode, prConStackStpProtocolVersion=prConStackStpProtocolVersion, prConPortFdbEntry=prConPortFdbEntry, prConPortFdbAddress=prConPortFdbAddress, prConPortStpAdminPathCost=prConPortStpAdminPathCost, prConIfIndex=prConIfIndex, prConStackRAPCopyPort=prConStackRAPCopyPort, prConTrunkMulticastEntry=prConTrunkMulticastEntry, prConTrunkMulticastPortlist=prConTrunkMulticastPortlist, prConStackRAPStudyPort=prConStackRAPStudyPort, prConfigPortEntry=prConfigPortEntry, prConStackPktRateControl=prConStackPktRateControl, prConfigPortTable=prConfigPortTable, prConStackPaceMode=prConStackPaceMode, prConStackVLANConfigMode=prConStackVLANConfigMode, prConStackLacpOperInfo=prConStackLacpOperInfo) |
L = int(input())
R = int(input())
xor = L ^ R
max_xor = 1
while xor:
xor >>= 1
max_xor <<= 1
print (max_xor-1)
| l = int(input())
r = int(input())
xor = L ^ R
max_xor = 1
while xor:
xor >>= 1
max_xor <<= 1
print(max_xor - 1) |
# microbit-module: [email protected]
RADIO_CHANNEL = 17
MSG_DEYLAY = 50
| radio_channel = 17
msg_deylay = 50 |
# Invert a binary tree.
# Input:
# 4
# / \
# 2 7
# / \ / \
# 1 3 6 9
#
# Output:
# 4
# / \
# 7 2
# / \ / \
# 9 6 3 1
class TreeNode:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
class Solution:
def invertTree(self, node: TreeNode) -> TreeNode:
if not node:
return None
node.left, node.right = self.invertTree(node.right), self.invertTree(node.left)
return node
| class Treenode:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
class Solution:
def invert_tree(self, node: TreeNode) -> TreeNode:
if not node:
return None
(node.left, node.right) = (self.invertTree(node.right), self.invertTree(node.left))
return node |
def roundUp(number:float)->int:
split = [int(i) for i in str(number).split(".")]
if split[1] >0:
return split[0]+1
return split[0]
## Program Start ##
n, k = [int(i) for i in input().strip().split(" ")][-2:]
scores = sorted([int(i) for i in input().strip().split(" ")])
min_days = roundUp(n/k)
output = 0
for i in range(0, min_days):
output += scores[len(scores) -1 -i]
print(output) | def round_up(number: float) -> int:
split = [int(i) for i in str(number).split('.')]
if split[1] > 0:
return split[0] + 1
return split[0]
(n, k) = [int(i) for i in input().strip().split(' ')][-2:]
scores = sorted([int(i) for i in input().strip().split(' ')])
min_days = round_up(n / k)
output = 0
for i in range(0, min_days):
output += scores[len(scores) - 1 - i]
print(output) |
class StackOfPlates(object):
def __init__(self):
self.stack = []
self.capacity = 10
def push(self, item):
if self.stack and self.stack[-1].length() < 10:
self.stack[-1].push(item)
else:
new_stack = Stack()
new_stack.push(item)
self.stack.append(new_stack)
def pop(self):
self.stack[-1].pop()
if self.stack[-1].length == 0:
del stack[-1]
def popAt(self, index):
self.stack[index].pop()
class Stack(object):
def __init__(self):
self.items = []
def get_items(self):
return self.items
def length(self):
return len(self.items)
def push(self, item):
self.items.append(item)
def pop(self):
self.items.pop()
stack = StackOfPlates()
stack.push(1)
stack.push(10)
stack.push(11)
stack.push(12)
stack.push(13)
stack.push(14)
stack.push(15)
stack.push(16)
stack.push(17)
stack.push(18)
stack.push(19)
stack.push(20)
stack.push(2)
stack.push(3)
stack.push(4)
stack.push(5)
print(stack.stack[0].items)
print(stack.stack[1].items)
stack.pop()
stack.popAt(0)
print(stack.stack[0].items)
print(stack.stack[1].items)
| class Stackofplates(object):
def __init__(self):
self.stack = []
self.capacity = 10
def push(self, item):
if self.stack and self.stack[-1].length() < 10:
self.stack[-1].push(item)
else:
new_stack = stack()
new_stack.push(item)
self.stack.append(new_stack)
def pop(self):
self.stack[-1].pop()
if self.stack[-1].length == 0:
del stack[-1]
def pop_at(self, index):
self.stack[index].pop()
class Stack(object):
def __init__(self):
self.items = []
def get_items(self):
return self.items
def length(self):
return len(self.items)
def push(self, item):
self.items.append(item)
def pop(self):
self.items.pop()
stack = stack_of_plates()
stack.push(1)
stack.push(10)
stack.push(11)
stack.push(12)
stack.push(13)
stack.push(14)
stack.push(15)
stack.push(16)
stack.push(17)
stack.push(18)
stack.push(19)
stack.push(20)
stack.push(2)
stack.push(3)
stack.push(4)
stack.push(5)
print(stack.stack[0].items)
print(stack.stack[1].items)
stack.pop()
stack.popAt(0)
print(stack.stack[0].items)
print(stack.stack[1].items) |
def skipVowels(word):
novowels = ''
for ch in word:
if ch.lower() in 'aeiou':
continue
novowels += ch
novowels+=ch
return novowels
print(skipVowels('hello'))
print(skipVowels('awaited'))
| def skip_vowels(word):
novowels = ''
for ch in word:
if ch.lower() in 'aeiou':
continue
novowels += ch
novowels += ch
return novowels
print(skip_vowels('hello'))
print(skip_vowels('awaited')) |
DosTags = {
# System
33: "SYS_Input",
34: "SYS_Output",
35: "SYS_Asynch",
36: "SYS_UserShell",
37: "SYS_CustomShell",
# CreateNewProc
1001: "NP_SegList",
1002: "NP_FreeSegList",
1003: "NP_Entry",
1004: "NP_Input",
1005: "NP_Output",
1006: "NP_CloseInput",
1007: "NP_CloseOutput",
1008: "NP_Error",
1009: "NP_CloseError",
1010: "NP_CurrentDir",
1011: "NP_StackSize",
1012: "NP_Name",
1013: "NP_Priority",
1014: "NP_ConsoleTask",
1015: "NP_WindowPtr",
1016: "NP_HomeDir",
1017: "NP_CopyVars",
1018: "NP_Cli",
1019: "NP_Path",
1020: "NP_CommandName",
1021: "NP_Arguments",
1022: "NP_NotifyOnDeath",
1023: "NP_Synchronous",
1024: "NP_ExitCode",
1025: "NP_ExitData",
# AllocDosObject
2001: "ADO_FH_Mode",
2002: "ADO_DirLen",
2003: "ADR_CommNameLen",
2004: "ADR_CommFileLen",
2005: "ADR_PromptLen",
}
| dos_tags = {33: 'SYS_Input', 34: 'SYS_Output', 35: 'SYS_Asynch', 36: 'SYS_UserShell', 37: 'SYS_CustomShell', 1001: 'NP_SegList', 1002: 'NP_FreeSegList', 1003: 'NP_Entry', 1004: 'NP_Input', 1005: 'NP_Output', 1006: 'NP_CloseInput', 1007: 'NP_CloseOutput', 1008: 'NP_Error', 1009: 'NP_CloseError', 1010: 'NP_CurrentDir', 1011: 'NP_StackSize', 1012: 'NP_Name', 1013: 'NP_Priority', 1014: 'NP_ConsoleTask', 1015: 'NP_WindowPtr', 1016: 'NP_HomeDir', 1017: 'NP_CopyVars', 1018: 'NP_Cli', 1019: 'NP_Path', 1020: 'NP_CommandName', 1021: 'NP_Arguments', 1022: 'NP_NotifyOnDeath', 1023: 'NP_Synchronous', 1024: 'NP_ExitCode', 1025: 'NP_ExitData', 2001: 'ADO_FH_Mode', 2002: 'ADO_DirLen', 2003: 'ADR_CommNameLen', 2004: 'ADR_CommFileLen', 2005: 'ADR_PromptLen'} |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def findBottomLeftValue(self, root: TreeNode) -> int:
current = [root]
while True:
children = []
for node in current:
if node.left: children.append(node.left)
if node.right: children.append(node.right)
if not children:
return current[0].val
else:
current = children
| class Solution:
def find_bottom_left_value(self, root: TreeNode) -> int:
current = [root]
while True:
children = []
for node in current:
if node.left:
children.append(node.left)
if node.right:
children.append(node.right)
if not children:
return current[0].val
else:
current = children |
#
# PySNMP MIB module CXMLPPP-IP-NCP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CXMLPPP-IP-NCP-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:33:10 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
ObjectIdentifier, OctetString, Integer = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "OctetString", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
SingleValueConstraint, ConstraintsIntersection, ConstraintsUnion, ValueSizeConstraint, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ConstraintsIntersection", "ConstraintsUnion", "ValueSizeConstraint", "ValueRangeConstraint")
cxMLPPP, SapIndex = mibBuilder.importSymbols("CXProduct-SMI", "cxMLPPP", "SapIndex")
ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup")
Integer32, Unsigned32, MibIdentifier, Gauge32, ObjectIdentity, IpAddress, TimeTicks, Counter64, ModuleIdentity, Bits, NotificationType, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter32, iso = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "Unsigned32", "MibIdentifier", "Gauge32", "ObjectIdentity", "IpAddress", "TimeTicks", "Counter64", "ModuleIdentity", "Bits", "NotificationType", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter32", "iso")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
mlpppIpNsTable = MibTable((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52), )
if mibBuilder.loadTexts: mlpppIpNsTable.setStatus('mandatory')
if mibBuilder.loadTexts: mlpppIpNsTable.setDescription('A table containing status parameters about each MLPPP module layer PPP IP Network Control Protocol.')
mlpppIpNsEntry = MibTableRow((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52, 1), ).setIndexNames((0, "CXMLPPP-IP-NCP-MIB", "mlpppIpNsLSapNumber"), (0, "CXMLPPP-IP-NCP-MIB", "mlpppIpNsNumber"))
if mibBuilder.loadTexts: mlpppIpNsEntry.setStatus('mandatory')
if mibBuilder.loadTexts: mlpppIpNsEntry.setDescription('Status parameters for a specific PPP IP Network Control Protocol.')
mlpppIpNsLSapNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52, 1, 1), SapIndex()).setMaxAccess("readonly")
if mibBuilder.loadTexts: mlpppIpNsLSapNumber.setStatus('mandatory')
if mibBuilder.loadTexts: mlpppIpNsLSapNumber.setDescription('Indicates the row that contains objects for monitoring a SAP that is associated with one of the PPP links. Range of Values: 1-10 Default Value: none')
mlpppIpNsNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52, 1, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: mlpppIpNsNumber.setStatus('mandatory')
if mibBuilder.loadTexts: mlpppIpNsNumber.setDescription('Indicates the row that contains objects for monitoring a SAP that is associated with one of the PPP links. Range of Values: 1 Default Value: none')
mlpppIpNsLocalToRemoteComp = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52, 1, 40), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("none", 1), ("vj-tcp", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: mlpppIpNsLocalToRemoteComp.setStatus('mandatory')
if mibBuilder.loadTexts: mlpppIpNsLocalToRemoteComp.setDescription("Identifies whether the local end of the IP-PPP link is using TCP/IP header compression (vj-tcp) to send packets to the remote. The value of this object is determined when the PPP configuration is negotiated. The local port's preference for header compression is determined using mlpppIpNcComp of mlpppIpNcTable. Options: none (1) vj-tcp (2): header compression Default Value: None")
mlpppIpNsRemoteToLocalComp = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52, 1, 41), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("none", 1), ("vj-tcp", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: mlpppIpNsRemoteToLocalComp.setStatus('mandatory')
if mibBuilder.loadTexts: mlpppIpNsRemoteToLocalComp.setDescription("Identifies whether the remote end of the IP-PPP link is using TCP/IP header compression (vj-tcp) to send packets to the local end. The value of this object is determined when the PPP configuration is negotiated. The local port's preference for header compression is determined using mlpppIpNcComp of mlpppIpNcTable. Options: none (1) vj-tcp (2): header compression Default value: None")
mlpppIpNcTable = MibTable((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 53), )
if mibBuilder.loadTexts: mlpppIpNcTable.setStatus('mandatory')
if mibBuilder.loadTexts: mlpppIpNcTable.setDescription("A table containing configuration parameters about each MLPPP module layer's PPP IP Network Control Protocol.")
mlpppIpNcEntry = MibTableRow((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 53, 1), ).setIndexNames((0, "CXMLPPP-IP-NCP-MIB", "mlpppIpNcUSapNumber"), (0, "CXMLPPP-IP-NCP-MIB", "mlpppIpNcNumber"))
if mibBuilder.loadTexts: mlpppIpNcEntry.setStatus('mandatory')
if mibBuilder.loadTexts: mlpppIpNcEntry.setDescription('The configuration parameters for a specific PPP IP Network Control Protocol.')
mlpppIpNcUSapNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 53, 1, 1), SapIndex()).setMaxAccess("readonly")
if mibBuilder.loadTexts: mlpppIpNcUSapNumber.setStatus('mandatory')
if mibBuilder.loadTexts: mlpppIpNcUSapNumber.setDescription('Indicates the row containing objects for monitoring a SAP that is associated with one of the MLPPP links . Range of Values: 1-10 Default Value: none')
mlpppIpNcNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 53, 1, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: mlpppIpNcNumber.setStatus('mandatory')
if mibBuilder.loadTexts: mlpppIpNcNumber.setDescription('Indicates the row containing objects for monitoring a SAP associated with one of the MLPPP links. Range of Values: 1 Default Value: none')
mlpppIpNcComp = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 53, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("none", 1), ("vj-tcp", 2))).clone('none')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: mlpppIpNcComp.setReference('Section 4.0, Van Jacobson TCP/IP Header Compression of RFC1332.')
if mibBuilder.loadTexts: mlpppIpNcComp.setStatus('mandatory')
if mibBuilder.loadTexts: mlpppIpNcComp.setDescription('Determines whether the local end of PPP link wants to use TCP/IP header compression (vj-tcp) to send packets over the link. If header compression is desired, the local will negotiate for its implementation with the remote end of the link. The result of the negotiation is displayed in mlpppIpNsLocalToRemoteComp (the local) and mlpppIpNsRemoteToLocalComp (remote). If compression is not desired, there will be no attempt to negotiate with the other end of the link. Options: none (1) vj-tcp (2): header compression Default Value: none Configuration Changed: administrative')
mibBuilder.exportSymbols("CXMLPPP-IP-NCP-MIB", mlpppIpNsRemoteToLocalComp=mlpppIpNsRemoteToLocalComp, mlpppIpNcNumber=mlpppIpNcNumber, mlpppIpNsTable=mlpppIpNsTable, mlpppIpNcEntry=mlpppIpNcEntry, mlpppIpNsNumber=mlpppIpNsNumber, mlpppIpNsLocalToRemoteComp=mlpppIpNsLocalToRemoteComp, mlpppIpNcTable=mlpppIpNcTable, mlpppIpNsLSapNumber=mlpppIpNsLSapNumber, mlpppIpNcUSapNumber=mlpppIpNcUSapNumber, mlpppIpNsEntry=mlpppIpNsEntry, mlpppIpNcComp=mlpppIpNcComp)
| (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_intersection, constraints_union, value_size_constraint, value_range_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'SingleValueConstraint', 'ConstraintsIntersection', 'ConstraintsUnion', 'ValueSizeConstraint', 'ValueRangeConstraint')
(cx_mlppp, sap_index) = mibBuilder.importSymbols('CXProduct-SMI', 'cxMLPPP', 'SapIndex')
(module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup')
(integer32, unsigned32, mib_identifier, gauge32, object_identity, ip_address, time_ticks, counter64, module_identity, bits, notification_type, mib_scalar, mib_table, mib_table_row, mib_table_column, counter32, iso) = mibBuilder.importSymbols('SNMPv2-SMI', 'Integer32', 'Unsigned32', 'MibIdentifier', 'Gauge32', 'ObjectIdentity', 'IpAddress', 'TimeTicks', 'Counter64', 'ModuleIdentity', 'Bits', 'NotificationType', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Counter32', 'iso')
(display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention')
mlppp_ip_ns_table = mib_table((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52))
if mibBuilder.loadTexts:
mlpppIpNsTable.setStatus('mandatory')
if mibBuilder.loadTexts:
mlpppIpNsTable.setDescription('A table containing status parameters about each MLPPP module layer PPP IP Network Control Protocol.')
mlppp_ip_ns_entry = mib_table_row((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52, 1)).setIndexNames((0, 'CXMLPPP-IP-NCP-MIB', 'mlpppIpNsLSapNumber'), (0, 'CXMLPPP-IP-NCP-MIB', 'mlpppIpNsNumber'))
if mibBuilder.loadTexts:
mlpppIpNsEntry.setStatus('mandatory')
if mibBuilder.loadTexts:
mlpppIpNsEntry.setDescription('Status parameters for a specific PPP IP Network Control Protocol.')
mlppp_ip_ns_l_sap_number = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52, 1, 1), sap_index()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
mlpppIpNsLSapNumber.setStatus('mandatory')
if mibBuilder.loadTexts:
mlpppIpNsLSapNumber.setDescription('Indicates the row that contains objects for monitoring a SAP that is associated with one of the PPP links. Range of Values: 1-10 Default Value: none')
mlppp_ip_ns_number = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52, 1, 2), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
mlpppIpNsNumber.setStatus('mandatory')
if mibBuilder.loadTexts:
mlpppIpNsNumber.setDescription('Indicates the row that contains objects for monitoring a SAP that is associated with one of the PPP links. Range of Values: 1 Default Value: none')
mlppp_ip_ns_local_to_remote_comp = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52, 1, 40), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('none', 1), ('vj-tcp', 2)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
mlpppIpNsLocalToRemoteComp.setStatus('mandatory')
if mibBuilder.loadTexts:
mlpppIpNsLocalToRemoteComp.setDescription("Identifies whether the local end of the IP-PPP link is using TCP/IP header compression (vj-tcp) to send packets to the remote. The value of this object is determined when the PPP configuration is negotiated. The local port's preference for header compression is determined using mlpppIpNcComp of mlpppIpNcTable. Options: none (1) vj-tcp (2): header compression Default Value: None")
mlppp_ip_ns_remote_to_local_comp = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52, 1, 41), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('none', 1), ('vj-tcp', 2)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
mlpppIpNsRemoteToLocalComp.setStatus('mandatory')
if mibBuilder.loadTexts:
mlpppIpNsRemoteToLocalComp.setDescription("Identifies whether the remote end of the IP-PPP link is using TCP/IP header compression (vj-tcp) to send packets to the local end. The value of this object is determined when the PPP configuration is negotiated. The local port's preference for header compression is determined using mlpppIpNcComp of mlpppIpNcTable. Options: none (1) vj-tcp (2): header compression Default value: None")
mlppp_ip_nc_table = mib_table((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 53))
if mibBuilder.loadTexts:
mlpppIpNcTable.setStatus('mandatory')
if mibBuilder.loadTexts:
mlpppIpNcTable.setDescription("A table containing configuration parameters about each MLPPP module layer's PPP IP Network Control Protocol.")
mlppp_ip_nc_entry = mib_table_row((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 53, 1)).setIndexNames((0, 'CXMLPPP-IP-NCP-MIB', 'mlpppIpNcUSapNumber'), (0, 'CXMLPPP-IP-NCP-MIB', 'mlpppIpNcNumber'))
if mibBuilder.loadTexts:
mlpppIpNcEntry.setStatus('mandatory')
if mibBuilder.loadTexts:
mlpppIpNcEntry.setDescription('The configuration parameters for a specific PPP IP Network Control Protocol.')
mlppp_ip_nc_u_sap_number = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 53, 1, 1), sap_index()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
mlpppIpNcUSapNumber.setStatus('mandatory')
if mibBuilder.loadTexts:
mlpppIpNcUSapNumber.setDescription('Indicates the row containing objects for monitoring a SAP that is associated with one of the MLPPP links . Range of Values: 1-10 Default Value: none')
mlppp_ip_nc_number = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 53, 1, 2), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
mlpppIpNcNumber.setStatus('mandatory')
if mibBuilder.loadTexts:
mlpppIpNcNumber.setDescription('Indicates the row containing objects for monitoring a SAP associated with one of the MLPPP links. Range of Values: 1 Default Value: none')
mlppp_ip_nc_comp = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 53, 1, 10), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('none', 1), ('vj-tcp', 2))).clone('none')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
mlpppIpNcComp.setReference('Section 4.0, Van Jacobson TCP/IP Header Compression of RFC1332.')
if mibBuilder.loadTexts:
mlpppIpNcComp.setStatus('mandatory')
if mibBuilder.loadTexts:
mlpppIpNcComp.setDescription('Determines whether the local end of PPP link wants to use TCP/IP header compression (vj-tcp) to send packets over the link. If header compression is desired, the local will negotiate for its implementation with the remote end of the link. The result of the negotiation is displayed in mlpppIpNsLocalToRemoteComp (the local) and mlpppIpNsRemoteToLocalComp (remote). If compression is not desired, there will be no attempt to negotiate with the other end of the link. Options: none (1) vj-tcp (2): header compression Default Value: none Configuration Changed: administrative')
mibBuilder.exportSymbols('CXMLPPP-IP-NCP-MIB', mlpppIpNsRemoteToLocalComp=mlpppIpNsRemoteToLocalComp, mlpppIpNcNumber=mlpppIpNcNumber, mlpppIpNsTable=mlpppIpNsTable, mlpppIpNcEntry=mlpppIpNcEntry, mlpppIpNsNumber=mlpppIpNsNumber, mlpppIpNsLocalToRemoteComp=mlpppIpNsLocalToRemoteComp, mlpppIpNcTable=mlpppIpNcTable, mlpppIpNsLSapNumber=mlpppIpNsLSapNumber, mlpppIpNcUSapNumber=mlpppIpNcUSapNumber, mlpppIpNsEntry=mlpppIpNsEntry, mlpppIpNcComp=mlpppIpNcComp) |
def B():
n = int(input())
a = [int(x) for x in input().split()]
d = {i:[] for i in range(1,n+1)}
d[0]= [0,0]
for i in range(2*n):
d[a[i]].append(i)
ans = 0
for i in range(n):
a , b = d[i] , d[i+1]
ans+= min(abs(b[0]-a[0])+abs(b[1]-a[1]) , abs(b[0]-a[1])+abs(b[1]-a[0]))
print(ans)
B()
| def b():
n = int(input())
a = [int(x) for x in input().split()]
d = {i: [] for i in range(1, n + 1)}
d[0] = [0, 0]
for i in range(2 * n):
d[a[i]].append(i)
ans = 0
for i in range(n):
(a, b) = (d[i], d[i + 1])
ans += min(abs(b[0] - a[0]) + abs(b[1] - a[1]), abs(b[0] - a[1]) + abs(b[1] - a[0]))
print(ans)
b() |
line_items = [{
"invNumber": 100,
"lineNumber": 1,
"partNumber": "TU100",
"description": "TacUmbrella",
"price": 9.99
},
{
"invNumber": 100,
"lineNumber": 2,
"partNumber": "TLB9000",
"description": "TacLunchbox 9000",
"price": 19.99
},
{
"invNumber": 101,
"lineNumber": 1,
"partNumber": "TPJ5",
"description": "TacPajamas",
"price": 99.99
}]
def main(event, context):
print(f'event: {event}')
source = event['source']
return list(filter(lambda line_item: line_item['invNumber'] == source['invNumber'], line_items))
# Test
# e = {"source": {"invNumber": 100}}
# print(main(e, None)) | line_items = [{'invNumber': 100, 'lineNumber': 1, 'partNumber': 'TU100', 'description': 'TacUmbrella', 'price': 9.99}, {'invNumber': 100, 'lineNumber': 2, 'partNumber': 'TLB9000', 'description': 'TacLunchbox 9000', 'price': 19.99}, {'invNumber': 101, 'lineNumber': 1, 'partNumber': 'TPJ5', 'description': 'TacPajamas', 'price': 99.99}]
def main(event, context):
print(f'event: {event}')
source = event['source']
return list(filter(lambda line_item: line_item['invNumber'] == source['invNumber'], line_items)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.