content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# -*- coding: utf-8 -*-
'''
module used while testing mock hubs provided in 'testing'.
'''
__contracts__ = ['testing']
def noparam(hub):
pass
def echo(hub, param):
return param
def signature_func(hub, param1, param2='default'):
pass
def attr_func(hub):
pass
attr_func.test = True
attr_func.__test__ = True
async def async_echo(hub, param):
return param
| """
module used while testing mock hubs provided in 'testing'.
"""
__contracts__ = ['testing']
def noparam(hub):
pass
def echo(hub, param):
return param
def signature_func(hub, param1, param2='default'):
pass
def attr_func(hub):
pass
attr_func.test = True
attr_func.__test__ = True
async def async_echo(hub, param):
return param |
def add(first,second):
"""Adds two numbers"""
return first + second
if __name__ == "__main__":
add(2,3)
| def add(first, second):
"""Adds two numbers"""
return first + second
if __name__ == '__main__':
add(2, 3) |
code = "he.elk.set.to"
decode = code.split("e")
print(decode[-1])
| code = 'he.elk.set.to'
decode = code.split('e')
print(decode[-1]) |
"""Infer read orientation from sample data."""
def infer():
"""Main function coordinating the execution of all other functions.
Should be imported/called from main app and return results to it.
"""
# implement me
| """Infer read orientation from sample data."""
def infer():
"""Main function coordinating the execution of all other functions.
Should be imported/called from main app and return results to it.
""" |
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(M, A):
hash = [0] * (M + 1)
slices = 0
max_slices = 1000000000
head = 0
for tail in range(len(A)):
while head < len(A) and ( not hash[A[head]]):
hash[A[head]] = 1
slices += head - tail + 1
if slices > max_slices:
return max_slices
head += 1
hash[A[tail]] = False
return slices
solution(6, [3, 4, 5, 5, 2])
| def solution(M, A):
hash = [0] * (M + 1)
slices = 0
max_slices = 1000000000
head = 0
for tail in range(len(A)):
while head < len(A) and (not hash[A[head]]):
hash[A[head]] = 1
slices += head - tail + 1
if slices > max_slices:
return max_slices
head += 1
hash[A[tail]] = False
return slices
solution(6, [3, 4, 5, 5, 2]) |
"""
Author: Alberto Marci
"""
class DecimalToRoman:
# convert number from 0 to 9
def __zero_to_nine(self, number):
if number == '0':
return ''
if number == '1':
return 'I'
if number == '2':
return 'II'
if number == '3':
return 'III'
if number == '4':
return 'IV'
if number == '5':
return 'V'
if number == '6':
return 'VI'
if number == '7':
return 'VII'
if number == '8':
return 'VIII'
if number == '9':
return 'IX'
# convert number from 10 to 90
def __ten_to_ninety(self, number):
if number == '0':
return ''
if number == '1':
return 'X'
if number == '2':
return 'XX'
if number == '3':
return 'XXX'
if number == '4':
return 'XL'
if number == '5':
return 'L'
if number == '6':
return 'LX'
if number == '7':
return 'LXX'
if number == '8':
return 'LXXX'
if number == '9':
return 'XC'
# convert number from 100 to 900
def __one_hundred_to_nine_hundred(self, number):
if number == '0':
return ''
if number == '1':
return 'C'
if number == '2':
return 'CC'
if number == '3':
return 'CCC'
if number == '4':
return 'CD'
if number == '5':
return 'D'
if number == '6':
return 'DC'
if number == '7':
return 'DCC'
if number == '8':
return 'DCCC'
if number == '9':
return 'CM'
# convert number from 1000 to 3000
def __one_thousand_to_three_thousand(self, number):
if number == '1':
return 'M'
if number == '2':
return 'MM'
if number == '3':
return 'MMM'
# return roman string
def integer_to_roman(self, number):
tmp = str(number)
str_len = len(tmp)
if str_len == 1:
return self.__zero_to_nine(tmp[0])
if str_len == 2:
roman_str0 = self.__zero_to_nine(tmp[1])
roman_str1 = self.__ten_to_ninety(tmp[0])
return roman_str1 + roman_str0
if str_len == 3:
roman_str0 = self.__zero_to_nine(tmp[2])
roman_str1 = self.__ten_to_ninety(tmp[1])
roman_str2 = self.__one_hundred_to_nine_hundred(tmp[0])
return roman_str2 + roman_str1 + roman_str0
if str_len == 4:
roman_str0 = self.__zero_to_nine(tmp[3])
roman_str1 = self.__ten_to_ninety(tmp[2])
roman_str2 = self.__one_hundred_to_nine_hundred(tmp[1])
roman_str3 = self.__one_thousand_to_three_thousand(tmp[0])
return roman_str3 + roman_str2 + roman_str1 + roman_str0
def test(self):
print(self.integer_to_roman(13))
print('-------------------------------------------')
print(self.integer_to_roman(48))
print('-------------------------------------------')
print(self.integer_to_roman(444))
print('-------------------------------------------')
print(self.integer_to_roman(3444))
print('-------------------------------------------')
print(self.integer_to_roman(3999))
print('-------------------------------------------')
print(self.integer_to_roman(100))
# ----------------------------------------------------------------------------------------------------------------------
converter = DecimalToRoman()
converter.test()
print('-------------------------------------------')
print('-------------------------------------------')
print(converter.integer_to_roman(1234))
| """
Author: Alberto Marci
"""
class Decimaltoroman:
def __zero_to_nine(self, number):
if number == '0':
return ''
if number == '1':
return 'I'
if number == '2':
return 'II'
if number == '3':
return 'III'
if number == '4':
return 'IV'
if number == '5':
return 'V'
if number == '6':
return 'VI'
if number == '7':
return 'VII'
if number == '8':
return 'VIII'
if number == '9':
return 'IX'
def __ten_to_ninety(self, number):
if number == '0':
return ''
if number == '1':
return 'X'
if number == '2':
return 'XX'
if number == '3':
return 'XXX'
if number == '4':
return 'XL'
if number == '5':
return 'L'
if number == '6':
return 'LX'
if number == '7':
return 'LXX'
if number == '8':
return 'LXXX'
if number == '9':
return 'XC'
def __one_hundred_to_nine_hundred(self, number):
if number == '0':
return ''
if number == '1':
return 'C'
if number == '2':
return 'CC'
if number == '3':
return 'CCC'
if number == '4':
return 'CD'
if number == '5':
return 'D'
if number == '6':
return 'DC'
if number == '7':
return 'DCC'
if number == '8':
return 'DCCC'
if number == '9':
return 'CM'
def __one_thousand_to_three_thousand(self, number):
if number == '1':
return 'M'
if number == '2':
return 'MM'
if number == '3':
return 'MMM'
def integer_to_roman(self, number):
tmp = str(number)
str_len = len(tmp)
if str_len == 1:
return self.__zero_to_nine(tmp[0])
if str_len == 2:
roman_str0 = self.__zero_to_nine(tmp[1])
roman_str1 = self.__ten_to_ninety(tmp[0])
return roman_str1 + roman_str0
if str_len == 3:
roman_str0 = self.__zero_to_nine(tmp[2])
roman_str1 = self.__ten_to_ninety(tmp[1])
roman_str2 = self.__one_hundred_to_nine_hundred(tmp[0])
return roman_str2 + roman_str1 + roman_str0
if str_len == 4:
roman_str0 = self.__zero_to_nine(tmp[3])
roman_str1 = self.__ten_to_ninety(tmp[2])
roman_str2 = self.__one_hundred_to_nine_hundred(tmp[1])
roman_str3 = self.__one_thousand_to_three_thousand(tmp[0])
return roman_str3 + roman_str2 + roman_str1 + roman_str0
def test(self):
print(self.integer_to_roman(13))
print('-------------------------------------------')
print(self.integer_to_roman(48))
print('-------------------------------------------')
print(self.integer_to_roman(444))
print('-------------------------------------------')
print(self.integer_to_roman(3444))
print('-------------------------------------------')
print(self.integer_to_roman(3999))
print('-------------------------------------------')
print(self.integer_to_roman(100))
converter = decimal_to_roman()
converter.test()
print('-------------------------------------------')
print('-------------------------------------------')
print(converter.integer_to_roman(1234)) |
class Solution:
def gameOfLife(self, board):
"""
:type board: List[List[int]]
:rtype: void Do not return anything, modify board in-place instead.
"""
if not board:
return board
last = copy.deepcopy(board)
for i in range(len(board)):
for j in range(len(board[0])):
cur_count = self.findCount(last, i, j)
print(cur_count)
if board[i][j] == 1:
if cur_count < 2 or cur_count > 3:
board[i][j] = 0
else:
if cur_count == 3:
board[i][j] = 1
def findCount(self, board, i, j):
count = 0
if len(board) == 1 and len(board[0]) == 1:
return 0
if len(board[0]) == 1:
try:
count += board[i][j-1]
except:
pass
try:
count += board[i][j+1]
except:
pass
return count
if len(board) == 1:
try:
count += board[i-1][j]
except:
pass
try:
count += board[i+1][j]
except:
pass
return count
if i > 0 and i < len(board)-1 and j > 0 and j < len(board[0])-1:
count += board[i-1][j]
count += board[i-1][j-1]
count += board[i-1][j+1]
count += board[i][j-1]
count += board[i][j+1]
count += board[i+1][j-1]
count += board[i+1][j]
count += board[i+1][j+1]
return count
if i == 0 and j == 0:
count += board[i][j+1]
count += board[i+1][j]
count += board[i+1][j+1]
return count
if i == 0 and j == len(board[0])-1:
count += board[i][j-1]
count += board[i+1][j]
count += board[i+1][j-1]
return count
if i == len(board)-1 and j == 0:
count += board[i][j+1]
count += board[i-1][j]
count += board[i-1][j+1]
return count
if i == len(board)-1 and j == len(board[0])-1:
count += board[i][j-1]
count += board[i-1][j]
count += board[i-1][j-1]
return count
if i == 0:
count += board[i][j-1]
count += board[i][j+1]
count += board[i+1][j]
count += board[i+1][j-1]
count += board[i+1][j+1]
return count
if i == len(board)-1:
count += board[i][j-1]
count += board[i][j+1]
count += board[i-1][j]
count += board[i-1][j-1]
count += board[i-1][j+1]
return count
if j == 0:
count += board[i-1][j]
count += board[i+1][j]
count += board[i-1][j+1]
count += board[i][j+1]
count += board[i+1][j+1]
return count
if j == len(board[0])-1:
count += board[i-1][j]
count += board[i+1][j]
count += board[i-1][j-1]
count += board[i][j-1]
count += board[i+1][j-1]
return count
| class Solution:
def game_of_life(self, board):
"""
:type board: List[List[int]]
:rtype: void Do not return anything, modify board in-place instead.
"""
if not board:
return board
last = copy.deepcopy(board)
for i in range(len(board)):
for j in range(len(board[0])):
cur_count = self.findCount(last, i, j)
print(cur_count)
if board[i][j] == 1:
if cur_count < 2 or cur_count > 3:
board[i][j] = 0
elif cur_count == 3:
board[i][j] = 1
def find_count(self, board, i, j):
count = 0
if len(board) == 1 and len(board[0]) == 1:
return 0
if len(board[0]) == 1:
try:
count += board[i][j - 1]
except:
pass
try:
count += board[i][j + 1]
except:
pass
return count
if len(board) == 1:
try:
count += board[i - 1][j]
except:
pass
try:
count += board[i + 1][j]
except:
pass
return count
if i > 0 and i < len(board) - 1 and (j > 0) and (j < len(board[0]) - 1):
count += board[i - 1][j]
count += board[i - 1][j - 1]
count += board[i - 1][j + 1]
count += board[i][j - 1]
count += board[i][j + 1]
count += board[i + 1][j - 1]
count += board[i + 1][j]
count += board[i + 1][j + 1]
return count
if i == 0 and j == 0:
count += board[i][j + 1]
count += board[i + 1][j]
count += board[i + 1][j + 1]
return count
if i == 0 and j == len(board[0]) - 1:
count += board[i][j - 1]
count += board[i + 1][j]
count += board[i + 1][j - 1]
return count
if i == len(board) - 1 and j == 0:
count += board[i][j + 1]
count += board[i - 1][j]
count += board[i - 1][j + 1]
return count
if i == len(board) - 1 and j == len(board[0]) - 1:
count += board[i][j - 1]
count += board[i - 1][j]
count += board[i - 1][j - 1]
return count
if i == 0:
count += board[i][j - 1]
count += board[i][j + 1]
count += board[i + 1][j]
count += board[i + 1][j - 1]
count += board[i + 1][j + 1]
return count
if i == len(board) - 1:
count += board[i][j - 1]
count += board[i][j + 1]
count += board[i - 1][j]
count += board[i - 1][j - 1]
count += board[i - 1][j + 1]
return count
if j == 0:
count += board[i - 1][j]
count += board[i + 1][j]
count += board[i - 1][j + 1]
count += board[i][j + 1]
count += board[i + 1][j + 1]
return count
if j == len(board[0]) - 1:
count += board[i - 1][j]
count += board[i + 1][j]
count += board[i - 1][j - 1]
count += board[i][j - 1]
count += board[i + 1][j - 1]
return count |
#less than operator
print(4<10) # --- L1
print(10<4) # --- L2
print(4<4.0) # --- L3
print(4.0<4) # --- L4
print('python'<'Python') #--- L5
print('python'<'python') # --- L6
print('Python'<'python') #--- L7
| print(4 < 10)
print(10 < 4)
print(4 < 4.0)
print(4.0 < 4)
print('python' < 'Python')
print('python' < 'python')
print('Python' < 'python') |
DIGITS = "0123456789abcdef"
def convert_base_stack(decimal_number, base):
remainder_stack = []
while decimal_number > 0:
remainder = decimal_number % base
remainder_stack.append(remainder)
decimal_number = decimal_number // base
new_digits = []
while remainder_stack:
new_digits.append(DIGITS[remainder_stack.pop()])
return "".join(new_digits)
def convert_base_rec(decimal_number, base):
if decimal_number < base:
return DIGITS[decimal_number]
return convert_base_rec(decimal_number // base, base) + DIGITS[decimal_number % base]
| digits = '0123456789abcdef'
def convert_base_stack(decimal_number, base):
remainder_stack = []
while decimal_number > 0:
remainder = decimal_number % base
remainder_stack.append(remainder)
decimal_number = decimal_number // base
new_digits = []
while remainder_stack:
new_digits.append(DIGITS[remainder_stack.pop()])
return ''.join(new_digits)
def convert_base_rec(decimal_number, base):
if decimal_number < base:
return DIGITS[decimal_number]
return convert_base_rec(decimal_number // base, base) + DIGITS[decimal_number % base] |
def add(a,b):
return a+b
def substract(a,b):
return a * b
## Imagine I made a valid change
def absolut(a,b):
return np.abs(a,b)
| def add(a, b):
return a + b
def substract(a, b):
return a * b
def absolut(a, b):
return np.abs(a, b) |
class Solution:
def findRestaurant(self, list1, list2):
mp1, mp2 = {x: i for i, x in enumerate(list1)}, {x: i for i, x in enumerate(list2)}
ans = [10 ** 4, []]
for k, v in mp1.items():
if k in mp2 and v + mp2[k] == ans[0]: ans[1].append(k)
elif k in mp2 and v + mp2[k] < ans[0]: ans = [v + mp2[k], [k]]
return ans[1]
| class Solution:
def find_restaurant(self, list1, list2):
(mp1, mp2) = ({x: i for (i, x) in enumerate(list1)}, {x: i for (i, x) in enumerate(list2)})
ans = [10 ** 4, []]
for (k, v) in mp1.items():
if k in mp2 and v + mp2[k] == ans[0]:
ans[1].append(k)
elif k in mp2 and v + mp2[k] < ans[0]:
ans = [v + mp2[k], [k]]
return ans[1] |
# Solution 1
# O(n) time / O(n) space
def branchSums(root):
sums = []
calculateBranchSums(root, 0, sums)
return sums
def calculateBranchSums(node, runningSum, sums):
if node is None:
return sums
newRunningSum = runningSum + node.value
if node.left is None and node.right is None:
sums.append(newRunningSum)
return
calculateBranchSums(node.left, newRunningSum, sums)
calculateBranchSums(node.right, newRunningSum, sums)
| def branch_sums(root):
sums = []
calculate_branch_sums(root, 0, sums)
return sums
def calculate_branch_sums(node, runningSum, sums):
if node is None:
return sums
new_running_sum = runningSum + node.value
if node.left is None and node.right is None:
sums.append(newRunningSum)
return
calculate_branch_sums(node.left, newRunningSum, sums)
calculate_branch_sums(node.right, newRunningSum, sums) |
class Context(dict):
"""docstring for _Context"""
def __init__(self, name, parameters={}, lifespan=5):
self.name = name
self.parameters = parameters
self.lifespan = lifespan
# def __getattr__(self, param):
# if param in ['name', 'parameters', 'lifespan']:
# return getattr(self, param)
# return self.parameters[param]
def set(self, param_name, value):
self.parameters[param_name] = value
def get(self, param):
return self.parameters.get(param)
def sync(self, context_json):
self.__dict__.update(context_json)
def __repr__(self):
return self.name
@property
def serialize(self):
return {"name": self.name, "lifespan": self.lifespan, "parameters": self.parameters}
class ContextManager():
def __init__(self):
self._cache = {}
def add(self, *args, **kwargs):
context = Context(*args, **kwargs)
self._cache[context.name] = context
return context
def get(self, context_name, default=None):
return self._cache.get(context_name, default)
def set(self, context_name, param, val):
context = self.get(context_name)
context.set(param, val)
return context
def get_param(self, context_name, param):
return self._cache[context_name].parameters[param]
def update(self, contexts_json):
for obj in contexts_json:
context = Context(obj['name']) # TODO
context.lifespan = obj['lifespan']
context.parameters = obj['parameters']
self._cache[context.name] = context
@property
def status(self):
return {
'Active contexts': self.active,
'Expired contexts': self.expired,
}
@property
def active(self):
return [self._cache[c] for c in self._cache if self._cache[c].lifespan > 0]
@property
def expired(self):
return [self._cache[c] for c in self._cache if self._cache[c].lifespan == 0]
| class Context(dict):
"""docstring for _Context"""
def __init__(self, name, parameters={}, lifespan=5):
self.name = name
self.parameters = parameters
self.lifespan = lifespan
def set(self, param_name, value):
self.parameters[param_name] = value
def get(self, param):
return self.parameters.get(param)
def sync(self, context_json):
self.__dict__.update(context_json)
def __repr__(self):
return self.name
@property
def serialize(self):
return {'name': self.name, 'lifespan': self.lifespan, 'parameters': self.parameters}
class Contextmanager:
def __init__(self):
self._cache = {}
def add(self, *args, **kwargs):
context = context(*args, **kwargs)
self._cache[context.name] = context
return context
def get(self, context_name, default=None):
return self._cache.get(context_name, default)
def set(self, context_name, param, val):
context = self.get(context_name)
context.set(param, val)
return context
def get_param(self, context_name, param):
return self._cache[context_name].parameters[param]
def update(self, contexts_json):
for obj in contexts_json:
context = context(obj['name'])
context.lifespan = obj['lifespan']
context.parameters = obj['parameters']
self._cache[context.name] = context
@property
def status(self):
return {'Active contexts': self.active, 'Expired contexts': self.expired}
@property
def active(self):
return [self._cache[c] for c in self._cache if self._cache[c].lifespan > 0]
@property
def expired(self):
return [self._cache[c] for c in self._cache if self._cache[c].lifespan == 0] |
def minInsertions(s: str) -> int:
dp = [[0] * len(s) for _ in range(len(s))]
for left in range(len(s) - 1, -1, -1):
for right in range(0, len(s)):
if left >= right:
continue
if s[left] == s[right]:
dp[left][right] = dp[left+1][right-1]
else:
dp[left][right] = 1 + min(dp[left+1][right], dp[left][right-1])
return dp[0][len(s) - 1] | def min_insertions(s: str) -> int:
dp = [[0] * len(s) for _ in range(len(s))]
for left in range(len(s) - 1, -1, -1):
for right in range(0, len(s)):
if left >= right:
continue
if s[left] == s[right]:
dp[left][right] = dp[left + 1][right - 1]
else:
dp[left][right] = 1 + min(dp[left + 1][right], dp[left][right - 1])
return dp[0][len(s) - 1] |
# -*- coding: UTF-8 -*-
PROXYSOCKET = ''
RETRY_TIMES = 5
HEADERS = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
'Accept': 'application/json,application/xml'
}
INPUT_FILE = 'dependencies/input.xlsx'
API_DEBUG = True
API_PORT = 5678
POST_TIME = 60
| proxysocket = ''
retry_times = 5
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36', 'Accept': 'application/json,application/xml'}
input_file = 'dependencies/input.xlsx'
api_debug = True
api_port = 5678
post_time = 60 |
N = int(input(""))
for x in range(0, N):
if N > 0:
s = input("")
s = s.split() #separar
if s[0] == s[1]:
print("empate")
else:
if s[0] == "tesoura":
if s[1] == "papel" or s[1] =="lagarto":
print("rajesh")
elif s[1] == "pedra" or s[1]=="spock":
print("sheldon")
elif s[0] == "papel":
if s[1] == "pedra" or s[1] =="spock":
print("rajesh")
elif s[1] == "tesoura" or s[1]=="lagarto":
print("sheldon")
elif s[0] == "pedra":
if s[1] == "lagarto" or s[1] =="tesoura":
print("rajesh")
elif s[1] == "spock" or s[1]=="papel":
print("sheldon")
elif s[0] == "lagarto":
if s[1] == "spock" or s[1] =="papel":
print("rajesh")
elif s[1] == "pedra" or s[1]=="tesoura":
print("sheldon")
elif s[0] == "spock":
if s[1] == "tesoura" or s[1] =="pedra":
print("rajesh")
elif s[1] == "lagarto" or s[1]=="papel":
print("sheldon")
else:
print("invalido")
| n = int(input(''))
for x in range(0, N):
if N > 0:
s = input('')
s = s.split()
if s[0] == s[1]:
print('empate')
elif s[0] == 'tesoura':
if s[1] == 'papel' or s[1] == 'lagarto':
print('rajesh')
elif s[1] == 'pedra' or s[1] == 'spock':
print('sheldon')
elif s[0] == 'papel':
if s[1] == 'pedra' or s[1] == 'spock':
print('rajesh')
elif s[1] == 'tesoura' or s[1] == 'lagarto':
print('sheldon')
elif s[0] == 'pedra':
if s[1] == 'lagarto' or s[1] == 'tesoura':
print('rajesh')
elif s[1] == 'spock' or s[1] == 'papel':
print('sheldon')
elif s[0] == 'lagarto':
if s[1] == 'spock' or s[1] == 'papel':
print('rajesh')
elif s[1] == 'pedra' or s[1] == 'tesoura':
print('sheldon')
elif s[0] == 'spock':
if s[1] == 'tesoura' or s[1] == 'pedra':
print('rajesh')
elif s[1] == 'lagarto' or s[1] == 'papel':
print('sheldon')
else:
print('invalido') |
def extract_organization_id_from_request_query(request):
return request.query_params.get('organization') or request.query_params.get('organization_id')
def extract_organization_id_from_request_data(request) -> (int, bool):
"""
Returns the organization id from the request.data and a bool indicating if the key
was present in the data (to distinguish between missing data and empty input value)
:param request:
:return:
"""
for source in (request.data, request.GET):
if 'organization' in source:
return source.get('organization'), True
if 'organization_id' in request.data:
return source.get('organization_id'), True
return None, False
| def extract_organization_id_from_request_query(request):
return request.query_params.get('organization') or request.query_params.get('organization_id')
def extract_organization_id_from_request_data(request) -> (int, bool):
"""
Returns the organization id from the request.data and a bool indicating if the key
was present in the data (to distinguish between missing data and empty input value)
:param request:
:return:
"""
for source in (request.data, request.GET):
if 'organization' in source:
return (source.get('organization'), True)
if 'organization_id' in request.data:
return (source.get('organization_id'), True)
return (None, False) |
"""Provides the repository macro to import rocksdb."""
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
def repo():
"""Imports rocksdb."""
ROCKSDB_VERSION = "6.15.5"
ROCKSDB_SHA256 = "d7b994e1eb4dff9dfefcd51a63f86630282e1927fc42a300b93c573c853aa5d0"
http_archive(
name = "rocksdb",
build_file = "//research/carls/third_party/rocksdb:rocksdb.BUILD",
sha256 = ROCKSDB_SHA256,
strip_prefix = "rocksdb-{version}".format(version = ROCKSDB_VERSION),
url = "https://github.com/facebook/rocksdb/archive/v{version}.tar.gz".format(version = ROCKSDB_VERSION),
)
# A dependency of rocksdb that is required for rocksdb::ClockCache.
http_archive(
name = "tbb",
build_file = "//research/carls/third_party/rocksdb:tbb.BUILD",
sha256 = "b182c73caaaabc44ddc5ad13113aca7e453af73c1690e4061f71dfe4935d74e8",
strip_prefix = "oneTBB-2021.1.1",
url = "https://github.com/oneapi-src/oneTBB/archive/v2021.1.1.tar.gz",
)
http_archive(
name = "gflags",
sha256 = "ce2931dd537eaab7dab78b25bec6136a0756ca0b2acbdab9aec0266998c0d9a7",
strip_prefix = "gflags-827c769e5fc98e0f2a34c47cef953cc6328abced",
url = "https://github.com/gflags/gflags/archive/827c769e5fc98e0f2a34c47cef953cc6328abced.tar.gz",
)
| """Provides the repository macro to import rocksdb."""
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive')
def repo():
"""Imports rocksdb."""
rocksdb_version = '6.15.5'
rocksdb_sha256 = 'd7b994e1eb4dff9dfefcd51a63f86630282e1927fc42a300b93c573c853aa5d0'
http_archive(name='rocksdb', build_file='//research/carls/third_party/rocksdb:rocksdb.BUILD', sha256=ROCKSDB_SHA256, strip_prefix='rocksdb-{version}'.format(version=ROCKSDB_VERSION), url='https://github.com/facebook/rocksdb/archive/v{version}.tar.gz'.format(version=ROCKSDB_VERSION))
http_archive(name='tbb', build_file='//research/carls/third_party/rocksdb:tbb.BUILD', sha256='b182c73caaaabc44ddc5ad13113aca7e453af73c1690e4061f71dfe4935d74e8', strip_prefix='oneTBB-2021.1.1', url='https://github.com/oneapi-src/oneTBB/archive/v2021.1.1.tar.gz')
http_archive(name='gflags', sha256='ce2931dd537eaab7dab78b25bec6136a0756ca0b2acbdab9aec0266998c0d9a7', strip_prefix='gflags-827c769e5fc98e0f2a34c47cef953cc6328abced', url='https://github.com/gflags/gflags/archive/827c769e5fc98e0f2a34c47cef953cc6328abced.tar.gz') |
#===============================================================================
# Copyright 2020 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#===============================================================================
load("@onedal//dev/bazel:utils.bzl", "utils", "paths")
def _create_symlinks(repo_ctx, root, entries, substitutions={}):
for entry in entries:
entry_fmt = utils.substitude(entry, substitutions)
src_entry_path = paths.join(root, entry_fmt)
dst_entry_path = entry_fmt
repo_ctx.symlink(src_entry_path, dst_entry_path)
def _download(repo_ctx):
output = repo_ctx.path("archive")
repo_ctx.download_and_extract(
url = repo_ctx.attr.url,
sha256 = repo_ctx.attr.sha256,
output = output,
stripPrefix = repo_ctx.attr.strip_prefix,
)
return str(output)
def _prebuilt_libs_repo_impl(repo_ctx):
root = repo_ctx.os.environ.get(repo_ctx.attr.root_env_var)
if not root:
if repo_ctx.attr.url:
root = _download(repo_ctx)
elif repo_ctx.attr.fallback_root:
root = repo_ctx.attr.fallback_root
else:
fail("Cannot locate {} dependency".format(repo_ctx.name))
substitutions = {
# TODO: Detect OS
"%{os}": "lnx",
}
_create_symlinks(repo_ctx, root, repo_ctx.attr.includes, substitutions)
_create_symlinks(repo_ctx, root, repo_ctx.attr.libs, substitutions)
repo_ctx.template(
"BUILD",
repo_ctx.attr.build_template,
substitutions = substitutions,
)
def prebuilt_libs_repo_rule(includes, libs, build_template,
root_env_var="", fallback_root="",
url="", sha256="", strip_prefix=""):
return repository_rule(
implementation = _prebuilt_libs_repo_impl,
environ = [
root_env_var,
],
local = True,
configure = True,
attrs = {
"root_env_var": attr.string(default=root_env_var),
"fallback_root": attr.string(default=fallback_root),
"url": attr.string(default=url),
"sha256": attr.string(default=sha256),
"strip_prefix": attr.string(default=strip_prefix),
"includes": attr.string_list(default=includes),
"libs": attr.string_list(default=libs),
"build_template": attr.label(allow_files=True,
default=Label(build_template)),
}
)
repos = struct(
prebuilt_libs_repo_rule = prebuilt_libs_repo_rule,
)
| load('@onedal//dev/bazel:utils.bzl', 'utils', 'paths')
def _create_symlinks(repo_ctx, root, entries, substitutions={}):
for entry in entries:
entry_fmt = utils.substitude(entry, substitutions)
src_entry_path = paths.join(root, entry_fmt)
dst_entry_path = entry_fmt
repo_ctx.symlink(src_entry_path, dst_entry_path)
def _download(repo_ctx):
output = repo_ctx.path('archive')
repo_ctx.download_and_extract(url=repo_ctx.attr.url, sha256=repo_ctx.attr.sha256, output=output, stripPrefix=repo_ctx.attr.strip_prefix)
return str(output)
def _prebuilt_libs_repo_impl(repo_ctx):
root = repo_ctx.os.environ.get(repo_ctx.attr.root_env_var)
if not root:
if repo_ctx.attr.url:
root = _download(repo_ctx)
elif repo_ctx.attr.fallback_root:
root = repo_ctx.attr.fallback_root
else:
fail('Cannot locate {} dependency'.format(repo_ctx.name))
substitutions = {'%{os}': 'lnx'}
_create_symlinks(repo_ctx, root, repo_ctx.attr.includes, substitutions)
_create_symlinks(repo_ctx, root, repo_ctx.attr.libs, substitutions)
repo_ctx.template('BUILD', repo_ctx.attr.build_template, substitutions=substitutions)
def prebuilt_libs_repo_rule(includes, libs, build_template, root_env_var='', fallback_root='', url='', sha256='', strip_prefix=''):
return repository_rule(implementation=_prebuilt_libs_repo_impl, environ=[root_env_var], local=True, configure=True, attrs={'root_env_var': attr.string(default=root_env_var), 'fallback_root': attr.string(default=fallback_root), 'url': attr.string(default=url), 'sha256': attr.string(default=sha256), 'strip_prefix': attr.string(default=strip_prefix), 'includes': attr.string_list(default=includes), 'libs': attr.string_list(default=libs), 'build_template': attr.label(allow_files=True, default=label(build_template))})
repos = struct(prebuilt_libs_repo_rule=prebuilt_libs_repo_rule) |
def intersects(line1, line2):
def onSeg(p, q, r):
if (q[0] <= max(p[0],r[0]) and q[0] >= min(p[0],r[0]) and
q[0] <= max(p[1],r[1]) and q[1] >= min(p[1],r[1])):
return True
return False
#0 -> colinear, 1 -> clockwise, 2 -> ccw
def orientation(p,q,r):
val = (q[1]-p[1]) * (r[0] - q[0]) - (q[0]-p[0]) * (r[1] - q[1])
if val == 0:
return 0
if val > 0:
return 1
return 2
p1 , q1 = line1
p2 , q2 = line2
o1 = orientation(p1, q1, p2)
o2 = orientation(p1, q1, q2)
o3 = orientation(p2, q2, p1)
o4 = orientation(p2, q2, q1)
x1, y1 = p1
x2, y2 = q1
x3, y3 = p2
x4, y4 = q2
if (o1 != o2 and o3 != o4): #general
xd = (x1*y2 - y1*x2)*(x3-x4)-(x1-x2)*(x3*y4-y3*x4)
xn = (x1-x2)*(y3-y4) - (y1-y2)*(x3-x4)
yd = (x1*y2 - y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-y3*x4)
yn = (x1-x2)*(y3-y4) - (y1-y2)*(x3-x4)
return (xd/xn , yd/yn)
if (o1 == 0 and onSeg(p1,p2,q1)): #p2 lies on p1q1
return p2
if (o2 == 0 and onSeg(p1,q2,q1)): #q2 lies on p1q1
return q2
if (o3 == 0 and onSeg(p2,p1,q2)): #p1 lies on p2q2
return p1
if (o4 == 0 and onSeg(p2,q1,q2)): #q1 lies on p2q2
return q1
return (-1,-1)
| def intersects(line1, line2):
def on_seg(p, q, r):
if q[0] <= max(p[0], r[0]) and q[0] >= min(p[0], r[0]) and (q[0] <= max(p[1], r[1])) and (q[1] >= min(p[1], r[1])):
return True
return False
def orientation(p, q, r):
val = (q[1] - p[1]) * (r[0] - q[0]) - (q[0] - p[0]) * (r[1] - q[1])
if val == 0:
return 0
if val > 0:
return 1
return 2
(p1, q1) = line1
(p2, q2) = line2
o1 = orientation(p1, q1, p2)
o2 = orientation(p1, q1, q2)
o3 = orientation(p2, q2, p1)
o4 = orientation(p2, q2, q1)
(x1, y1) = p1
(x2, y2) = q1
(x3, y3) = p2
(x4, y4) = q2
if o1 != o2 and o3 != o4:
xd = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4)
xn = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)
yd = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4)
yn = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)
return (xd / xn, yd / yn)
if o1 == 0 and on_seg(p1, p2, q1):
return p2
if o2 == 0 and on_seg(p1, q2, q1):
return q2
if o3 == 0 and on_seg(p2, p1, q2):
return p1
if o4 == 0 and on_seg(p2, q1, q2):
return q1
return (-1, -1) |
# Q1
class Thing:
pass
example = Thing()
print(Thing)
print(example)
# Q2
class Thing2:
letters = 'abc'
print(Thing2.letters)
# Q3
class Thing3:
def __init__(self):
self.letters = 'xyz'
thing3 = Thing3()
print(thing3.letters)
# Q4
class Element:
def __init__(self, name, symbol, number):
self.name = name
self.symbol = symbol
self.number = number
hydrogen = Element('Hydrogen', 'H', 1)
# Q5
kargs = {'name': 'Hydrogen', 'symbol': 'H', 'number': 1}
hydrogen = Element(**kargs)
# Q6
class Element:
def __init__(self, name, symbol, number):
self.name = name
self.symbol = symbol
self.number = number
def dump(self):
print(f'Name:{self.name}, Symbol:{self.symbol}, Number:{self.number}')
hydrogen = Element('Hydrogen', 'H', 1)
hydrogen.dump()
# Q7
class Element:
def __init__(self, name, symbol, number):
self.name = name
self.symbol = symbol
self.number = number
def __str__(self):
return f'Name:{self.name}, Symbol:{self.symbol}, Number:{self.number}'
hydrogen = Element('Hydrogen', 'H', 1)
print(hydrogen)
# Q9
class Element:
def __init__(self, name, symbol, number):
self.__name = name
self.__symbol = symbol
self.__number = number
@property
def name(self):
return self.__name
@property
def symbol(self):
return self.__symbol
@property
def number(self):
return self.__number
def __str__(self):
return f'Name:{self.__name}, Symbol:{self.__symbol}, Number:{self.__number}'
# Q9
class Bear:
def eats(self):
return 'berries'
class Rabbit:
def eats(self):
return 'clover'
class Octothorpe:
def eats(self):
return 'campers'
bear = Bear()
rabbit = Rabbit()
octothorpe = Octothorpe()
bear.eats()
rabbit.eats()
octothorpe.eats()
# Q10
class Lasor:
def does(self):
return 'disintegrate'
class Claw:
def does(self):
return 'crush'
class SmartPhone:
def does(self):
return 'ring'
class Robot:
def __init__(self):
self.lasor = Lasor()
self.claw = Claw()
self.smartPhone = SmartPhone()
def does(self):
print(f'{self.lasor.does()} {self.claw.does()} {self.smartPhone.does()}')
robot = Robot()
robot.does()
| class Thing:
pass
example = thing()
print(Thing)
print(example)
class Thing2:
letters = 'abc'
print(Thing2.letters)
class Thing3:
def __init__(self):
self.letters = 'xyz'
thing3 = thing3()
print(thing3.letters)
class Element:
def __init__(self, name, symbol, number):
self.name = name
self.symbol = symbol
self.number = number
hydrogen = element('Hydrogen', 'H', 1)
kargs = {'name': 'Hydrogen', 'symbol': 'H', 'number': 1}
hydrogen = element(**kargs)
class Element:
def __init__(self, name, symbol, number):
self.name = name
self.symbol = symbol
self.number = number
def dump(self):
print(f'Name:{self.name}, Symbol:{self.symbol}, Number:{self.number}')
hydrogen = element('Hydrogen', 'H', 1)
hydrogen.dump()
class Element:
def __init__(self, name, symbol, number):
self.name = name
self.symbol = symbol
self.number = number
def __str__(self):
return f'Name:{self.name}, Symbol:{self.symbol}, Number:{self.number}'
hydrogen = element('Hydrogen', 'H', 1)
print(hydrogen)
class Element:
def __init__(self, name, symbol, number):
self.__name = name
self.__symbol = symbol
self.__number = number
@property
def name(self):
return self.__name
@property
def symbol(self):
return self.__symbol
@property
def number(self):
return self.__number
def __str__(self):
return f'Name:{self.__name}, Symbol:{self.__symbol}, Number:{self.__number}'
class Bear:
def eats(self):
return 'berries'
class Rabbit:
def eats(self):
return 'clover'
class Octothorpe:
def eats(self):
return 'campers'
bear = bear()
rabbit = rabbit()
octothorpe = octothorpe()
bear.eats()
rabbit.eats()
octothorpe.eats()
class Lasor:
def does(self):
return 'disintegrate'
class Claw:
def does(self):
return 'crush'
class Smartphone:
def does(self):
return 'ring'
class Robot:
def __init__(self):
self.lasor = lasor()
self.claw = claw()
self.smartPhone = smart_phone()
def does(self):
print(f'{self.lasor.does()} {self.claw.does()} {self.smartPhone.does()}')
robot = robot()
robot.does() |
j = 7
for i in range(1,(10),2):
for jump in range(0,3):
print("I={0} J={1}".format(i,j))
j = j - 1
j = 7
| j = 7
for i in range(1, 10, 2):
for jump in range(0, 3):
print('I={0} J={1}'.format(i, j))
j = j - 1
j = 7 |
result = [
[0.6, 0.7],
{'a': 'b'},
None,
[
'uu',
'ii',
[None],
[7, 8, 9, {}]
]
]
| result = [[0.6, 0.7], {'a': 'b'}, None, ['uu', 'ii', [None], [7, 8, 9, {}]]] |
def DependsOn(pack, deps):
return And([ Implies(pack, dep) for dep in deps ])
def Conflict(p1, p2):
return Or(Not(p1), Not(p2))
a, b, c, d, e, f, g, z = Bools('a b c d e f g z')
solve(DependsOn(a, [b, c, z]),
DependsOn(b, [d]),
DependsOn(c, [Or(d, e), Or(f, g)]),
Conflict(d, e),
a, z)
| def depends_on(pack, deps):
return and([implies(pack, dep) for dep in deps])
def conflict(p1, p2):
return or(not(p1), not(p2))
(a, b, c, d, e, f, g, z) = bools('a b c d e f g z')
solve(depends_on(a, [b, c, z]), depends_on(b, [d]), depends_on(c, [or(d, e), or(f, g)]), conflict(d, e), a, z) |
#
# PySNMP MIB module SW-LAYER2-PORT-MANAGEMENT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SW-LAYER2-PORT-MANAGEMENT-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:12:34 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
Integer, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsUnion, ValueRangeConstraint, SingleValueConstraint, ValueSizeConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "ValueRangeConstraint", "SingleValueConstraint", "ValueSizeConstraint", "ConstraintsIntersection")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
TimeTicks, MibIdentifier, NotificationType, Integer32, NotificationType, Unsigned32, MibScalar, MibTable, MibTableRow, MibTableColumn, IpAddress, iso, ModuleIdentity, Counter32, Gauge32, Bits, ObjectIdentity, enterprises, Counter64 = mibBuilder.importSymbols("SNMPv2-SMI", "TimeTicks", "MibIdentifier", "NotificationType", "Integer32", "NotificationType", "Unsigned32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "IpAddress", "iso", "ModuleIdentity", "Counter32", "Gauge32", "Bits", "ObjectIdentity", "enterprises", "Counter64")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
marconi = MibIdentifier((1, 3, 6, 1, 4, 1, 326))
systems = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2))
external = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20))
dlink = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1))
dlinkcommon = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 1))
golf = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2))
golfproducts = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 1))
es2000 = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 1, 3))
golfcommon = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2))
marconi_products = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 1)).setLabel("marconi-products")
marconi_es2000Prod = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 1, 28)).setLabel("marconi-es2000Prod")
swProperty = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 1, 28, 1))
marconi_mgmt = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2)).setLabel("marconi-mgmt")
es2000Mgmt = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28))
swL2Mgmt = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2))
swL2PortMgmt = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4))
swL2PortInfoTable = MibTable((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 1), )
if mibBuilder.loadTexts: swL2PortInfoTable.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortInfoTable.setDescription('A table that contains information about every port.')
swL2PortInfoEntry = MibTableRow((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 1, 1), ).setIndexNames((0, "SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortInfoUnitIndex"), (0, "SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortInfoModuleIndex"), (0, "SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortInfoIndex"))
if mibBuilder.loadTexts: swL2PortInfoEntry.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortInfoEntry.setDescription('A list of information for each port of the device.')
swL2PortInfoUnitIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 1, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortInfoUnitIndex.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortInfoUnitIndex.setDescription('Indicates ID of the unit in the device.')
swL2PortInfoModuleIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 1, 1, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortInfoModuleIndex.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortInfoModuleIndex.setDescription('Indicates ID of the module on the unit.')
swL2PortInfoIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 1, 1, 3), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortInfoIndex.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortInfoIndex.setDescription('Indicates ID of the port on the module.')
swL2PortInfoType = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 1, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7))).clone(namedValues=NamedValues(("portType-100TX", 1), ("portType-100FX", 2), ("portType-GIGA-MTRJSX", 3), ("portType-GIGA-MTRJLX", 4), ("portType-GIGA-SCSX", 5), ("portType-GIGA-SCLX", 6), ("other", 7)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortInfoType.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortInfoType.setDescription('Indicates the connector type of this port.')
swL2PortInfoDescr = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 1, 1, 5), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 64))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortInfoDescr.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortInfoDescr.setDescription('Provides port type information in displayed string format.')
swL2PortInfoLinkStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 1, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("other", 1), ("link-pass", 2), ("link-fail", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortInfoLinkStatus.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortInfoLinkStatus.setDescription('Indicates port link status.')
swL2PortInfoNwayStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 1, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7))).clone(namedValues=NamedValues(("other", 1), ("half-10Mbps", 2), ("full-10Mbps", 3), ("half-100Mbps", 4), ("full-100Mbps", 5), ("half-1Gigabps", 6), ("full-1Gigabps", 7)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortInfoNwayStatus.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortInfoNwayStatus.setDescription('This object indicates the port speed and duplex mode.')
swL2PortCtrlTable = MibTable((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2), )
if mibBuilder.loadTexts: swL2PortCtrlTable.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortCtrlTable.setDescription('A table that contains control information about every port.')
swL2PortCtrlEntry = MibTableRow((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1), ).setIndexNames((0, "SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortCtrlUnitIndex"), (0, "SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortCtrlModuleIndex"), (0, "SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortCtrlIndex"))
if mibBuilder.loadTexts: swL2PortCtrlEntry.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortCtrlEntry.setDescription('A list of control information for each port of the device.')
swL2PortCtrlUnitIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortCtrlUnitIndex.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortCtrlUnitIndex.setDescription('Indicates ID of the unit in the device.')
swL2PortCtrlModuleIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortCtrlModuleIndex.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortCtrlModuleIndex.setDescription('Indicates ID of the module on the unit.')
swL2PortCtrlIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 3), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortCtrlIndex.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortCtrlIndex.setDescription('This object indicates the device port number.(1..Max port number).')
swL2PortCtrlAdminState = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("disabled", 2), ("enabled", 3), ("notAvailable", 4)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swL2PortCtrlAdminState.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortCtrlAdminState.setDescription('This object decides the port to be enabled or disabled.')
swL2PortCtrlLinkStatusAlarmState = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("disabled", 2), ("enabled", 3), ("notAvailable", 4)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swL2PortCtrlLinkStatusAlarmState.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortCtrlLinkStatusAlarmState.setDescription('Depends on this object to determine to send a trap or not when link status changes.')
swL2PortCtrlNwayState = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 10))).clone(namedValues=NamedValues(("other", 1), ("nway-enabled", 2), ("nway-disabled-10Mbps-Half", 3), ("nway-disabled-10Mbps-Full", 4), ("nway-disabled-100Mbps-Half", 5), ("nway-disabled-100Mbps-Full", 6), ("nway-disabled-1Gigabps-Half", 7), ("nway-disabled-1Gigabps-Full", 8), ("notAvailable", 10)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swL2PortCtrlNwayState.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortCtrlNwayState.setDescription('Chooses the port speed, duplex mode, and N-Way function mode.')
swL2PortCtrlFlowCtrlState = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("other", 1), ("disabled", 2), ("enabled", 3)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swL2PortCtrlFlowCtrlState.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortCtrlFlowCtrlState.setDescription('Sets IEEE 802.3x compliant flow control function as enabled or disabled. And IEEE 802.3x compliant flow control function work only when the port is in full duplex mode.The setting is effective the next time you reset or power on the hub.')
swL2PortCtrlBackPressState = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 8), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("other", 1), ("disabled", 2), ("enabled", 3)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swL2PortCtrlBackPressState.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortCtrlBackPressState.setDescription('Depends on this object to determine to enable or disable the backpressure function when the port is working in half duplex mode.')
swL2PortCtrlLockState = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("disable", 2), ("enable", 3), ("notAvailable", 4)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swL2PortCtrlLockState.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortCtrlLockState.setDescription('The state of this entry. The meanings of the values are: other(1) - this entry is currently in use but the conditions under which it will remain so are different from each of the following values. disable(2) - Port lock funtion disable. enable(3) - Locking a port provides the CPU with the ability to decide which address are permitted to reside on such port, who knows about these address, and unknown packet forwarding to/from such ports. This is a way to prevent undesired traffic from being received or transmmited on the port.')
swL2PortCtrlPriority = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("other", 1), ("default", 2), ("force-low-priority", 3), ("force-high-priority", 4), ("notAvailable", 5)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swL2PortCtrlPriority.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortCtrlPriority.setDescription('The priority queueing for packets received on this port, except for BPDU/IGMP packets and packets with unknown unicast destination address. IGMP and BPDU packets are always routed with high priority; packets with unknown unicast destination addresses are always routed with low priority. Other packets follow the rules below: other(1) - this entry is currently in use but the conditions under which it will remain so are different from each of the following values. default(2) - A packet is normally classified as low priority, unless at least one of the following is true: (a)The packet contained a TAG (per 802.1Q definition) with the priority greater or equal to 4. (b)The address-table entry for the destination address had Pd=HIGH. force-low_priority(3) - A packet is normally classified as low priority. force-high_priority(4) - A packet is normally classified as high priority.')
swL2PortCtrlStpState = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 11), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("disabled", 2), ("enabled", 3), ("notAvailable", 4)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swL2PortCtrlStpState.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortCtrlStpState.setDescription("The state of STP(spanning tree algorithm) operation on this port. That's meaning the port whether add in the STP. The value enabled(3) indicates that STP is enabled on this port, as long as swDevCtrlStpState is also enabled for this device. When disabled(2) but swDevCtrlStpState is still enabled for the device, STP is disabled on this port : any BPDU packets received will be discarded and no BPDU packets will be propagated from the port.")
swL2PortCtrlHOLState = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 12), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("disabled", 2), ("enabled", 3), ("notAvailable", 4)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swL2PortCtrlHOLState.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortCtrlHOLState.setDescription("The object provides a way to prevent HOL (Head Of Line) blocking between ports. HOL protection may prevent forwarding a packet to a blocking port. The idea relies on the assumption that it is better to discard packets destined to blocking ports, then to let them consume more and more buffers in the input-port's Rx-counters because eventually these input ports may become totally blocked. The meanings of the values are: other(1) - this entry is currently in use but the conditions under which it will remain so are different from each of the following values. disabled(2) - HOL function disable. enabled(3) - HOL function enable.")
swL2PortCtrlBcastRisingAct = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 13), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("other", 1), ("do-nothing", 2), ("blocking", 3), ("blocking-trap", 4), ("notAvailable", 5)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swL2PortCtrlBcastRisingAct.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortCtrlBcastRisingAct.setDescription('This object indicates the system action when broadcast storm rising threshold is met. other(1) - this entry is currently in use but the conditions under which it will remain so are different from each of the following values. do-nothing(2) - no action. blocking(3) - the port can discard any coming broadcast frame. blocking-trap(4) - the port can discard any coming broadcast frame. And the device can send a broadcast rising trap.')
swL2PortCtrlBcastFallingAct = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 14), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("other", 1), ("do-nothing", 2), ("forwarding", 3), ("forwarding-trap", 4), ("notAvailable", 5)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swL2PortCtrlBcastFallingAct.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortCtrlBcastFallingAct.setDescription('This object indicates the device action when broadcast storm falling threshold is met. other(1) - this entry is currently in use but the conditions under which it will remain so are different from each of the following values. do-nothing(2) - no action. forwarding(3) - the port has returned to normal operation mode. forwarding-trap(4) - the port has returned to normal operation mode. And the device can send a broadcast falling trap.')
swL2PortCtrlClearCounter = MibScalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 15), Integer32()).setMaxAccess("writeonly")
if mibBuilder.loadTexts: swL2PortCtrlClearCounter.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortCtrlClearCounter.setDescription('Sets choosed port to clear counter. First of all, any unsigned integer can be used to set.')
swL2PortStTable = MibTable((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3), )
if mibBuilder.loadTexts: swL2PortStTable.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStTable.setDescription('A list of port statistic Counter entries.')
swL2PortStEntry = MibTableRow((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1), ).setIndexNames((0, "SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortStUnitIndex"), (0, "SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortStModuleIndex"), (0, "SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortStIndex"))
if mibBuilder.loadTexts: swL2PortStEntry.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStEntry.setDescription('This entry include all the port statistic Counter which support by the device, like Bytes received, Bytes Sent ...')
swL2PortStUnitIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStUnitIndex.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStUnitIndex.setDescription('Indicates ID of the unit in the device.')
swL2PortStModuleIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStModuleIndex.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStModuleIndex.setDescription('Indicates ID of the module on the unit.')
swL2PortStIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 3), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStIndex.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStIndex.setDescription('This object indicates the device port number.(1..Max port number)')
swL2PortStByteRx = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 4), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStByteRx.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStByteRx.setDescription('swDevCtrlCounterMode = 2(switched-frames) : This counter is incremented once for every data octet of good packets(unicast + multicast + broadcast) received. swDevCtrlCounterMode = 3(all-frames) : This counter is incremented once for every data octet of good packets(unicast + multicast + broadcast packets) and for local and dropped packets.')
swL2PortStByteTx = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 5), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStByteTx.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStByteTx.setDescription('This counter is incremented once for every data octet of a transmitted good packet.')
swL2PortStFrameRx = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 6), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStFrameRx.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStFrameRx.setDescription('swDevCtrlCounterMode = 2(switched-frames) : This counter is incremented once for every good packet(unicast + multicast + broadcast) received. swDevCtrlCounterMode = 3(all-frames) : This counter is incremented once for every good packet(unicast + multicast + broadcast packets) and for local and dropped packets received.')
swL2PortStFrameTx = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 7), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStFrameTx.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStFrameTx.setDescription('This counter is incremented once for every transmitted good packet.')
swL2PortStTotalBytesRx = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 8), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStTotalBytesRx.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStTotalBytesRx.setDescription('This counter is incremented once for every data octet of all received packets. This include data octets of rejected and local packets which are not forwarded to the switching core for transmission. This counter should reflect all the data octets received on the line. Note: A nibble is not counted as a whole byte.')
swL2PortStTotalFramesRx = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 9), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStTotalFramesRx.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStTotalFramesRx.setDescription('This counter is incremented once for every received packets. This include rejected and local packets which are not forwarded to the switching core for transmission. This counter should reflect all packets received on the line.')
swL2PortStBroadcastFramesRx = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 10), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStBroadcastFramesRx.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStBroadcastFramesRx.setDescription('swDevCtrlCounterMode = 2(switched-frames) : This counter is incremented once for every good broadcast packet received. swDevCtrlCounterMode = 3(all-frames) : This counter is incremented once for every good broadcast packet received and for local and dropped broadcast packets.')
swL2PortStMulticastFramesRx = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 11), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStMulticastFramesRx.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStMulticastFramesRx.setDescription('swDevCtrlCounterMode = 2(switched-frames) : This counter is incremented once for every good multicast packet received. swDevCtrlCounterMode = 3(all-frames) : This counter is incremented once for every good multicast packet received and for local and dropped multicast packets. This counter does not include broadcast packets.')
swL2PortStCRCError = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 12), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStCRCError.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStCRCError.setDescription('This counter is incremented once for every received packet which meets all the following conditions: 1. Packet data length is between 64 and 1536 bytes inclusive. 2. Packet has invalid CRC. 3. Collision event, late collision event and receive error event have not been detected.')
swL2PortStOversizeFrames = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 13), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStOversizeFrames.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStOversizeFrames.setDescription('The number of good frames with length more than 1536 bytes.')
swL2PortStFragments = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 14), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStFragments.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStFragments.setDescription('This counter is incremented once for every received packet which meets all the following conditions: 1. Packet data length is less than 64 bytes or packet withourt SFD and is less than 64 bytes in length. 2. Packet has invalid CRC. 3. Collision event, late collision event and receive error event have not been detected.')
swL2PortStJabber = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 15), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStJabber.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStJabber.setDescription('The number of frames with length more than 1536 bytes and with CRC error or misaligned.')
swL2PortStCollision = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 16), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStCollision.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStCollision.setDescription('The number of Collisions.')
swL2PortStLateCollision = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 17), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStLateCollision.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStLateCollision.setDescription('The number of Late Collision(collision occurring later than 576th transmitted bit).')
swL2PortStFrames_64_bytes = MibScalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 18), Counter32()).setLabel("swL2PortStFrames-64-bytes").setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStFrames_64_bytes.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStFrames_64_bytes.setDescription('This counter is incremented once for every received and transmitted packet with size of 64 bytes. This counter includes rejected received and transmitted packets.')
swL2PortStFrames_65_127_bytes = MibScalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 19), Counter32()).setLabel("swL2PortStFrames-65-127-bytes").setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStFrames_65_127_bytes.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStFrames_65_127_bytes.setDescription('This counter is incremented once for every received and transmitted packet with size of 65 to 127 bytes. This counter includes rejected received and transmitted packets.')
swL2PortStFrames_128_255_bytes = MibScalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 20), Counter32()).setLabel("swL2PortStFrames-128-255-bytes").setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStFrames_128_255_bytes.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStFrames_128_255_bytes.setDescription('This counter is incremented once for every received and transmitted packet with size of 128 to 255 bytes. This counter includes rejected received and transmitted packets.')
swL2PortStFrames_256_511_bytes = MibScalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 21), Counter32()).setLabel("swL2PortStFrames-256-511-bytes").setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStFrames_256_511_bytes.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStFrames_256_511_bytes.setDescription('This counter is incremented once for every received and transmitted packet with size of 256 to 511 bytes. This counter includes rejected received and transmitted packets.')
swL2PortStFrames_512_1023_bytes = MibScalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 22), Counter32()).setLabel("swL2PortStFrames-512-1023-bytes").setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStFrames_512_1023_bytes.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStFrames_512_1023_bytes.setDescription('This counter is incremented once for every received and transmitted packet with size of 512 to 1023 bytes. This counter includes rejected received and transmitted packets.')
swL2PortStFrames_1024_1536_bytes = MibScalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 23), Counter32()).setLabel("swL2PortStFrames-1024-1536-bytes").setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStFrames_1024_1536_bytes.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStFrames_1024_1536_bytes.setDescription('This counter is incremented once for every received and transmitted packet with size of 1024 to 1536 bytes. This counter includes rejected received and transmitted packets.')
swL2PortStFramesDroppedFrames = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 24), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStFramesDroppedFrames.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStFramesDroppedFrames.setDescription('This counter is incremented once for every received dropped packet.')
swL2PortStMulticastFramesTx = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 25), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStMulticastFramesTx.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStMulticastFramesTx.setDescription('The number of multicast frames sent. This counter does not include broadcast packets.')
swL2PortStBroadcastFramesTx = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 26), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStBroadcastFramesTx.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStBroadcastFramesTx.setDescription('The number of broadcast frames sent.')
swL2PortStUndersizeFrames = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 27), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swL2PortStUndersizeFrames.setStatus('mandatory')
if mibBuilder.loadTexts: swL2PortStUndersizeFrames.setDescription('This counter is incremented once for every received packet which meets all the following conditions: 1. Packet data length is less than 64 bytes. 2. Packet has valid CRC. 3. Collision event, late collision event and receive error event have not been detected.')
swEventPortPartition = NotificationType((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 1, 3) + (0,1)).setObjects(("SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortInfoUnitIndex"), ("SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortInfoModuleIndex"), ("SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortInfoIndex"))
if mibBuilder.loadTexts: swEventPortPartition.setDescription('The trap is sent whenever the port state enter the Partion mode when more than 61 collisions occur while trasmitting.')
swEventlinkChangeEvent = NotificationType((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 1, 3) + (0,2)).setObjects(("SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortInfoUnitIndex"), ("SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortInfoModuleIndex"), ("SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortInfoIndex"))
if mibBuilder.loadTexts: swEventlinkChangeEvent.setDescription('The trap is sent whenever the link state of a port changes from link up to link down or from link down to link up')
swEventBcastRisingStorm = NotificationType((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 1, 3) + (0,3)).setObjects(("SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortInfoUnitIndex"), ("SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortInfoModuleIndex"), ("SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortInfoIndex"))
if mibBuilder.loadTexts: swEventBcastRisingStorm.setDescription('The trap indicates that broadcast higher rising threshold. This trap including the port ID')
swEventBcastFallingStorm = NotificationType((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 1, 3) + (0,4)).setObjects(("SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortInfoUnitIndex"), ("SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortInfoModuleIndex"), ("SW-LAYER2-PORT-MANAGEMENT-MIB", "swL2PortInfoIndex"))
if mibBuilder.loadTexts: swEventBcastFallingStorm.setDescription('The trap indicates that broadcast higher falling threshold. This trap including the port ID')
mibBuilder.exportSymbols("SW-LAYER2-PORT-MANAGEMENT-MIB", swL2PortStCRCError=swL2PortStCRCError, swL2PortStFrames_1024_1536_bytes=swL2PortStFrames_1024_1536_bytes, swL2PortCtrlModuleIndex=swL2PortCtrlModuleIndex, swL2PortStLateCollision=swL2PortStLateCollision, swL2PortStOversizeFrames=swL2PortStOversizeFrames, systems=systems, swL2PortInfoTable=swL2PortInfoTable, golfcommon=golfcommon, swL2PortCtrlAdminState=swL2PortCtrlAdminState, swL2PortStByteRx=swL2PortStByteRx, swL2PortCtrlEntry=swL2PortCtrlEntry, es2000=es2000, swL2PortStFragments=swL2PortStFragments, swL2Mgmt=swL2Mgmt, swL2PortCtrlClearCounter=swL2PortCtrlClearCounter, swL2PortStJabber=swL2PortStJabber, dlinkcommon=dlinkcommon, es2000Mgmt=es2000Mgmt, swL2PortInfoNwayStatus=swL2PortInfoNwayStatus, swL2PortStUnitIndex=swL2PortStUnitIndex, swL2PortInfoUnitIndex=swL2PortInfoUnitIndex, swL2PortStFrames_128_255_bytes=swL2PortStFrames_128_255_bytes, swL2PortStModuleIndex=swL2PortStModuleIndex, swL2PortCtrlStpState=swL2PortCtrlStpState, marconi=marconi, swL2PortCtrlLockState=swL2PortCtrlLockState, swL2PortInfoType=swL2PortInfoType, swL2PortStTotalBytesRx=swL2PortStTotalBytesRx, swL2PortStTable=swL2PortStTable, swL2PortMgmt=swL2PortMgmt, swL2PortInfoIndex=swL2PortInfoIndex, swEventBcastFallingStorm=swEventBcastFallingStorm, swL2PortStMulticastFramesRx=swL2PortStMulticastFramesRx, swL2PortStFramesDroppedFrames=swL2PortStFramesDroppedFrames, swL2PortStFrames_64_bytes=swL2PortStFrames_64_bytes, swL2PortStMulticastFramesTx=swL2PortStMulticastFramesTx, swL2PortCtrlFlowCtrlState=swL2PortCtrlFlowCtrlState, marconi_products=marconi_products, swL2PortStFrames_65_127_bytes=swL2PortStFrames_65_127_bytes, swL2PortStUndersizeFrames=swL2PortStUndersizeFrames, swL2PortStBroadcastFramesTx=swL2PortStBroadcastFramesTx, dlink=dlink, swL2PortStEntry=swL2PortStEntry, external=external, golfproducts=golfproducts, swL2PortStIndex=swL2PortStIndex, swL2PortStFrameRx=swL2PortStFrameRx, marconi_mgmt=marconi_mgmt, golf=golf, swL2PortInfoLinkStatus=swL2PortInfoLinkStatus, swL2PortCtrlTable=swL2PortCtrlTable, swL2PortCtrlLinkStatusAlarmState=swL2PortCtrlLinkStatusAlarmState, swL2PortCtrlHOLState=swL2PortCtrlHOLState, swL2PortCtrlBackPressState=swL2PortCtrlBackPressState, swL2PortStByteTx=swL2PortStByteTx, swL2PortStTotalFramesRx=swL2PortStTotalFramesRx, swL2PortStFrames_256_511_bytes=swL2PortStFrames_256_511_bytes, swEventBcastRisingStorm=swEventBcastRisingStorm, swL2PortCtrlUnitIndex=swL2PortCtrlUnitIndex, swL2PortStFrames_512_1023_bytes=swL2PortStFrames_512_1023_bytes, swL2PortInfoModuleIndex=swL2PortInfoModuleIndex, swL2PortCtrlBcastFallingAct=swL2PortCtrlBcastFallingAct, swL2PortStFrameTx=swL2PortStFrameTx, swL2PortInfoEntry=swL2PortInfoEntry, swProperty=swProperty, swL2PortStBroadcastFramesRx=swL2PortStBroadcastFramesRx, swEventPortPartition=swEventPortPartition, marconi_es2000Prod=marconi_es2000Prod, swEventlinkChangeEvent=swEventlinkChangeEvent, swL2PortStCollision=swL2PortStCollision, swL2PortCtrlBcastRisingAct=swL2PortCtrlBcastRisingAct, swL2PortInfoDescr=swL2PortInfoDescr, swL2PortCtrlPriority=swL2PortCtrlPriority, swL2PortCtrlNwayState=swL2PortCtrlNwayState, swL2PortCtrlIndex=swL2PortCtrlIndex)
| (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_range_constraint, single_value_constraint, value_size_constraint, constraints_intersection) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsUnion', 'ValueRangeConstraint', 'SingleValueConstraint', 'ValueSizeConstraint', 'ConstraintsIntersection')
(notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance')
(time_ticks, mib_identifier, notification_type, integer32, notification_type, unsigned32, mib_scalar, mib_table, mib_table_row, mib_table_column, ip_address, iso, module_identity, counter32, gauge32, bits, object_identity, enterprises, counter64) = mibBuilder.importSymbols('SNMPv2-SMI', 'TimeTicks', 'MibIdentifier', 'NotificationType', 'Integer32', 'NotificationType', 'Unsigned32', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'IpAddress', 'iso', 'ModuleIdentity', 'Counter32', 'Gauge32', 'Bits', 'ObjectIdentity', 'enterprises', 'Counter64')
(display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention')
marconi = mib_identifier((1, 3, 6, 1, 4, 1, 326))
systems = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2))
external = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20))
dlink = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1))
dlinkcommon = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 1))
golf = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2))
golfproducts = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 1))
es2000 = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 1, 3))
golfcommon = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2))
marconi_products = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 1)).setLabel('marconi-products')
marconi_es2000_prod = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 1, 28)).setLabel('marconi-es2000Prod')
sw_property = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 1, 28, 1))
marconi_mgmt = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2)).setLabel('marconi-mgmt')
es2000_mgmt = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28))
sw_l2_mgmt = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2))
sw_l2_port_mgmt = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4))
sw_l2_port_info_table = mib_table((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 1))
if mibBuilder.loadTexts:
swL2PortInfoTable.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortInfoTable.setDescription('A table that contains information about every port.')
sw_l2_port_info_entry = mib_table_row((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 1, 1)).setIndexNames((0, 'SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortInfoUnitIndex'), (0, 'SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortInfoModuleIndex'), (0, 'SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortInfoIndex'))
if mibBuilder.loadTexts:
swL2PortInfoEntry.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortInfoEntry.setDescription('A list of information for each port of the device.')
sw_l2_port_info_unit_index = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 1, 1, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortInfoUnitIndex.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortInfoUnitIndex.setDescription('Indicates ID of the unit in the device.')
sw_l2_port_info_module_index = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 1, 1, 2), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortInfoModuleIndex.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortInfoModuleIndex.setDescription('Indicates ID of the module on the unit.')
sw_l2_port_info_index = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 1, 1, 3), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortInfoIndex.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortInfoIndex.setDescription('Indicates ID of the port on the module.')
sw_l2_port_info_type = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 1, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7))).clone(namedValues=named_values(('portType-100TX', 1), ('portType-100FX', 2), ('portType-GIGA-MTRJSX', 3), ('portType-GIGA-MTRJLX', 4), ('portType-GIGA-SCSX', 5), ('portType-GIGA-SCLX', 6), ('other', 7)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortInfoType.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortInfoType.setDescription('Indicates the connector type of this port.')
sw_l2_port_info_descr = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 1, 1, 5), display_string().subtype(subtypeSpec=value_size_constraint(0, 64))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortInfoDescr.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortInfoDescr.setDescription('Provides port type information in displayed string format.')
sw_l2_port_info_link_status = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 1, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('other', 1), ('link-pass', 2), ('link-fail', 3)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortInfoLinkStatus.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortInfoLinkStatus.setDescription('Indicates port link status.')
sw_l2_port_info_nway_status = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 1, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7))).clone(namedValues=named_values(('other', 1), ('half-10Mbps', 2), ('full-10Mbps', 3), ('half-100Mbps', 4), ('full-100Mbps', 5), ('half-1Gigabps', 6), ('full-1Gigabps', 7)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortInfoNwayStatus.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortInfoNwayStatus.setDescription('This object indicates the port speed and duplex mode.')
sw_l2_port_ctrl_table = mib_table((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2))
if mibBuilder.loadTexts:
swL2PortCtrlTable.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortCtrlTable.setDescription('A table that contains control information about every port.')
sw_l2_port_ctrl_entry = mib_table_row((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1)).setIndexNames((0, 'SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortCtrlUnitIndex'), (0, 'SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortCtrlModuleIndex'), (0, 'SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortCtrlIndex'))
if mibBuilder.loadTexts:
swL2PortCtrlEntry.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortCtrlEntry.setDescription('A list of control information for each port of the device.')
sw_l2_port_ctrl_unit_index = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortCtrlUnitIndex.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortCtrlUnitIndex.setDescription('Indicates ID of the unit in the device.')
sw_l2_port_ctrl_module_index = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 2), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortCtrlModuleIndex.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortCtrlModuleIndex.setDescription('Indicates ID of the module on the unit.')
sw_l2_port_ctrl_index = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 3), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortCtrlIndex.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortCtrlIndex.setDescription('This object indicates the device port number.(1..Max port number).')
sw_l2_port_ctrl_admin_state = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('disabled', 2), ('enabled', 3), ('notAvailable', 4)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swL2PortCtrlAdminState.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortCtrlAdminState.setDescription('This object decides the port to be enabled or disabled.')
sw_l2_port_ctrl_link_status_alarm_state = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('disabled', 2), ('enabled', 3), ('notAvailable', 4)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swL2PortCtrlLinkStatusAlarmState.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortCtrlLinkStatusAlarmState.setDescription('Depends on this object to determine to send a trap or not when link status changes.')
sw_l2_port_ctrl_nway_state = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 10))).clone(namedValues=named_values(('other', 1), ('nway-enabled', 2), ('nway-disabled-10Mbps-Half', 3), ('nway-disabled-10Mbps-Full', 4), ('nway-disabled-100Mbps-Half', 5), ('nway-disabled-100Mbps-Full', 6), ('nway-disabled-1Gigabps-Half', 7), ('nway-disabled-1Gigabps-Full', 8), ('notAvailable', 10)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swL2PortCtrlNwayState.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortCtrlNwayState.setDescription('Chooses the port speed, duplex mode, and N-Way function mode.')
sw_l2_port_ctrl_flow_ctrl_state = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('other', 1), ('disabled', 2), ('enabled', 3)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swL2PortCtrlFlowCtrlState.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortCtrlFlowCtrlState.setDescription('Sets IEEE 802.3x compliant flow control function as enabled or disabled. And IEEE 802.3x compliant flow control function work only when the port is in full duplex mode.The setting is effective the next time you reset or power on the hub.')
sw_l2_port_ctrl_back_press_state = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 8), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('other', 1), ('disabled', 2), ('enabled', 3)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swL2PortCtrlBackPressState.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortCtrlBackPressState.setDescription('Depends on this object to determine to enable or disable the backpressure function when the port is working in half duplex mode.')
sw_l2_port_ctrl_lock_state = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 9), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('disable', 2), ('enable', 3), ('notAvailable', 4)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swL2PortCtrlLockState.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortCtrlLockState.setDescription('The state of this entry. The meanings of the values are: other(1) - this entry is currently in use but the conditions under which it will remain so are different from each of the following values. disable(2) - Port lock funtion disable. enable(3) - Locking a port provides the CPU with the ability to decide which address are permitted to reside on such port, who knows about these address, and unknown packet forwarding to/from such ports. This is a way to prevent undesired traffic from being received or transmmited on the port.')
sw_l2_port_ctrl_priority = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 10), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('other', 1), ('default', 2), ('force-low-priority', 3), ('force-high-priority', 4), ('notAvailable', 5)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swL2PortCtrlPriority.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortCtrlPriority.setDescription('The priority queueing for packets received on this port, except for BPDU/IGMP packets and packets with unknown unicast destination address. IGMP and BPDU packets are always routed with high priority; packets with unknown unicast destination addresses are always routed with low priority. Other packets follow the rules below: other(1) - this entry is currently in use but the conditions under which it will remain so are different from each of the following values. default(2) - A packet is normally classified as low priority, unless at least one of the following is true: (a)The packet contained a TAG (per 802.1Q definition) with the priority greater or equal to 4. (b)The address-table entry for the destination address had Pd=HIGH. force-low_priority(3) - A packet is normally classified as low priority. force-high_priority(4) - A packet is normally classified as high priority.')
sw_l2_port_ctrl_stp_state = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 11), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('disabled', 2), ('enabled', 3), ('notAvailable', 4)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swL2PortCtrlStpState.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortCtrlStpState.setDescription("The state of STP(spanning tree algorithm) operation on this port. That's meaning the port whether add in the STP. The value enabled(3) indicates that STP is enabled on this port, as long as swDevCtrlStpState is also enabled for this device. When disabled(2) but swDevCtrlStpState is still enabled for the device, STP is disabled on this port : any BPDU packets received will be discarded and no BPDU packets will be propagated from the port.")
sw_l2_port_ctrl_hol_state = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 12), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('disabled', 2), ('enabled', 3), ('notAvailable', 4)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swL2PortCtrlHOLState.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortCtrlHOLState.setDescription("The object provides a way to prevent HOL (Head Of Line) blocking between ports. HOL protection may prevent forwarding a packet to a blocking port. The idea relies on the assumption that it is better to discard packets destined to blocking ports, then to let them consume more and more buffers in the input-port's Rx-counters because eventually these input ports may become totally blocked. The meanings of the values are: other(1) - this entry is currently in use but the conditions under which it will remain so are different from each of the following values. disabled(2) - HOL function disable. enabled(3) - HOL function enable.")
sw_l2_port_ctrl_bcast_rising_act = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 13), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('other', 1), ('do-nothing', 2), ('blocking', 3), ('blocking-trap', 4), ('notAvailable', 5)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swL2PortCtrlBcastRisingAct.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortCtrlBcastRisingAct.setDescription('This object indicates the system action when broadcast storm rising threshold is met. other(1) - this entry is currently in use but the conditions under which it will remain so are different from each of the following values. do-nothing(2) - no action. blocking(3) - the port can discard any coming broadcast frame. blocking-trap(4) - the port can discard any coming broadcast frame. And the device can send a broadcast rising trap.')
sw_l2_port_ctrl_bcast_falling_act = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 14), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('other', 1), ('do-nothing', 2), ('forwarding', 3), ('forwarding-trap', 4), ('notAvailable', 5)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swL2PortCtrlBcastFallingAct.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortCtrlBcastFallingAct.setDescription('This object indicates the device action when broadcast storm falling threshold is met. other(1) - this entry is currently in use but the conditions under which it will remain so are different from each of the following values. do-nothing(2) - no action. forwarding(3) - the port has returned to normal operation mode. forwarding-trap(4) - the port has returned to normal operation mode. And the device can send a broadcast falling trap.')
sw_l2_port_ctrl_clear_counter = mib_scalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 2, 1, 15), integer32()).setMaxAccess('writeonly')
if mibBuilder.loadTexts:
swL2PortCtrlClearCounter.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortCtrlClearCounter.setDescription('Sets choosed port to clear counter. First of all, any unsigned integer can be used to set.')
sw_l2_port_st_table = mib_table((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3))
if mibBuilder.loadTexts:
swL2PortStTable.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStTable.setDescription('A list of port statistic Counter entries.')
sw_l2_port_st_entry = mib_table_row((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1)).setIndexNames((0, 'SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortStUnitIndex'), (0, 'SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortStModuleIndex'), (0, 'SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortStIndex'))
if mibBuilder.loadTexts:
swL2PortStEntry.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStEntry.setDescription('This entry include all the port statistic Counter which support by the device, like Bytes received, Bytes Sent ...')
sw_l2_port_st_unit_index = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStUnitIndex.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStUnitIndex.setDescription('Indicates ID of the unit in the device.')
sw_l2_port_st_module_index = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 2), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStModuleIndex.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStModuleIndex.setDescription('Indicates ID of the module on the unit.')
sw_l2_port_st_index = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 3), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStIndex.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStIndex.setDescription('This object indicates the device port number.(1..Max port number)')
sw_l2_port_st_byte_rx = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 4), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStByteRx.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStByteRx.setDescription('swDevCtrlCounterMode = 2(switched-frames) : This counter is incremented once for every data octet of good packets(unicast + multicast + broadcast) received. swDevCtrlCounterMode = 3(all-frames) : This counter is incremented once for every data octet of good packets(unicast + multicast + broadcast packets) and for local and dropped packets.')
sw_l2_port_st_byte_tx = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 5), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStByteTx.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStByteTx.setDescription('This counter is incremented once for every data octet of a transmitted good packet.')
sw_l2_port_st_frame_rx = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 6), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStFrameRx.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStFrameRx.setDescription('swDevCtrlCounterMode = 2(switched-frames) : This counter is incremented once for every good packet(unicast + multicast + broadcast) received. swDevCtrlCounterMode = 3(all-frames) : This counter is incremented once for every good packet(unicast + multicast + broadcast packets) and for local and dropped packets received.')
sw_l2_port_st_frame_tx = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 7), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStFrameTx.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStFrameTx.setDescription('This counter is incremented once for every transmitted good packet.')
sw_l2_port_st_total_bytes_rx = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 8), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStTotalBytesRx.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStTotalBytesRx.setDescription('This counter is incremented once for every data octet of all received packets. This include data octets of rejected and local packets which are not forwarded to the switching core for transmission. This counter should reflect all the data octets received on the line. Note: A nibble is not counted as a whole byte.')
sw_l2_port_st_total_frames_rx = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 9), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStTotalFramesRx.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStTotalFramesRx.setDescription('This counter is incremented once for every received packets. This include rejected and local packets which are not forwarded to the switching core for transmission. This counter should reflect all packets received on the line.')
sw_l2_port_st_broadcast_frames_rx = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 10), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStBroadcastFramesRx.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStBroadcastFramesRx.setDescription('swDevCtrlCounterMode = 2(switched-frames) : This counter is incremented once for every good broadcast packet received. swDevCtrlCounterMode = 3(all-frames) : This counter is incremented once for every good broadcast packet received and for local and dropped broadcast packets.')
sw_l2_port_st_multicast_frames_rx = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 11), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStMulticastFramesRx.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStMulticastFramesRx.setDescription('swDevCtrlCounterMode = 2(switched-frames) : This counter is incremented once for every good multicast packet received. swDevCtrlCounterMode = 3(all-frames) : This counter is incremented once for every good multicast packet received and for local and dropped multicast packets. This counter does not include broadcast packets.')
sw_l2_port_st_crc_error = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 12), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStCRCError.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStCRCError.setDescription('This counter is incremented once for every received packet which meets all the following conditions: 1. Packet data length is between 64 and 1536 bytes inclusive. 2. Packet has invalid CRC. 3. Collision event, late collision event and receive error event have not been detected.')
sw_l2_port_st_oversize_frames = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 13), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStOversizeFrames.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStOversizeFrames.setDescription('The number of good frames with length more than 1536 bytes.')
sw_l2_port_st_fragments = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 14), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStFragments.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStFragments.setDescription('This counter is incremented once for every received packet which meets all the following conditions: 1. Packet data length is less than 64 bytes or packet withourt SFD and is less than 64 bytes in length. 2. Packet has invalid CRC. 3. Collision event, late collision event and receive error event have not been detected.')
sw_l2_port_st_jabber = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 15), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStJabber.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStJabber.setDescription('The number of frames with length more than 1536 bytes and with CRC error or misaligned.')
sw_l2_port_st_collision = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 16), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStCollision.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStCollision.setDescription('The number of Collisions.')
sw_l2_port_st_late_collision = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 17), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStLateCollision.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStLateCollision.setDescription('The number of Late Collision(collision occurring later than 576th transmitted bit).')
sw_l2_port_st_frames_64_bytes = mib_scalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 18), counter32()).setLabel('swL2PortStFrames-64-bytes').setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStFrames_64_bytes.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStFrames_64_bytes.setDescription('This counter is incremented once for every received and transmitted packet with size of 64 bytes. This counter includes rejected received and transmitted packets.')
sw_l2_port_st_frames_65_127_bytes = mib_scalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 19), counter32()).setLabel('swL2PortStFrames-65-127-bytes').setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStFrames_65_127_bytes.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStFrames_65_127_bytes.setDescription('This counter is incremented once for every received and transmitted packet with size of 65 to 127 bytes. This counter includes rejected received and transmitted packets.')
sw_l2_port_st_frames_128_255_bytes = mib_scalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 20), counter32()).setLabel('swL2PortStFrames-128-255-bytes').setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStFrames_128_255_bytes.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStFrames_128_255_bytes.setDescription('This counter is incremented once for every received and transmitted packet with size of 128 to 255 bytes. This counter includes rejected received and transmitted packets.')
sw_l2_port_st_frames_256_511_bytes = mib_scalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 21), counter32()).setLabel('swL2PortStFrames-256-511-bytes').setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStFrames_256_511_bytes.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStFrames_256_511_bytes.setDescription('This counter is incremented once for every received and transmitted packet with size of 256 to 511 bytes. This counter includes rejected received and transmitted packets.')
sw_l2_port_st_frames_512_1023_bytes = mib_scalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 22), counter32()).setLabel('swL2PortStFrames-512-1023-bytes').setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStFrames_512_1023_bytes.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStFrames_512_1023_bytes.setDescription('This counter is incremented once for every received and transmitted packet with size of 512 to 1023 bytes. This counter includes rejected received and transmitted packets.')
sw_l2_port_st_frames_1024_1536_bytes = mib_scalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 23), counter32()).setLabel('swL2PortStFrames-1024-1536-bytes').setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStFrames_1024_1536_bytes.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStFrames_1024_1536_bytes.setDescription('This counter is incremented once for every received and transmitted packet with size of 1024 to 1536 bytes. This counter includes rejected received and transmitted packets.')
sw_l2_port_st_frames_dropped_frames = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 24), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStFramesDroppedFrames.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStFramesDroppedFrames.setDescription('This counter is incremented once for every received dropped packet.')
sw_l2_port_st_multicast_frames_tx = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 25), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStMulticastFramesTx.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStMulticastFramesTx.setDescription('The number of multicast frames sent. This counter does not include broadcast packets.')
sw_l2_port_st_broadcast_frames_tx = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 26), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStBroadcastFramesTx.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStBroadcastFramesTx.setDescription('The number of broadcast frames sent.')
sw_l2_port_st_undersize_frames = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 4, 3, 1, 27), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swL2PortStUndersizeFrames.setStatus('mandatory')
if mibBuilder.loadTexts:
swL2PortStUndersizeFrames.setDescription('This counter is incremented once for every received packet which meets all the following conditions: 1. Packet data length is less than 64 bytes. 2. Packet has valid CRC. 3. Collision event, late collision event and receive error event have not been detected.')
sw_event_port_partition = notification_type((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 1, 3) + (0, 1)).setObjects(('SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortInfoUnitIndex'), ('SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortInfoModuleIndex'), ('SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortInfoIndex'))
if mibBuilder.loadTexts:
swEventPortPartition.setDescription('The trap is sent whenever the port state enter the Partion mode when more than 61 collisions occur while trasmitting.')
sw_eventlink_change_event = notification_type((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 1, 3) + (0, 2)).setObjects(('SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortInfoUnitIndex'), ('SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortInfoModuleIndex'), ('SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortInfoIndex'))
if mibBuilder.loadTexts:
swEventlinkChangeEvent.setDescription('The trap is sent whenever the link state of a port changes from link up to link down or from link down to link up')
sw_event_bcast_rising_storm = notification_type((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 1, 3) + (0, 3)).setObjects(('SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortInfoUnitIndex'), ('SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortInfoModuleIndex'), ('SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortInfoIndex'))
if mibBuilder.loadTexts:
swEventBcastRisingStorm.setDescription('The trap indicates that broadcast higher rising threshold. This trap including the port ID')
sw_event_bcast_falling_storm = notification_type((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 1, 3) + (0, 4)).setObjects(('SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortInfoUnitIndex'), ('SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortInfoModuleIndex'), ('SW-LAYER2-PORT-MANAGEMENT-MIB', 'swL2PortInfoIndex'))
if mibBuilder.loadTexts:
swEventBcastFallingStorm.setDescription('The trap indicates that broadcast higher falling threshold. This trap including the port ID')
mibBuilder.exportSymbols('SW-LAYER2-PORT-MANAGEMENT-MIB', swL2PortStCRCError=swL2PortStCRCError, swL2PortStFrames_1024_1536_bytes=swL2PortStFrames_1024_1536_bytes, swL2PortCtrlModuleIndex=swL2PortCtrlModuleIndex, swL2PortStLateCollision=swL2PortStLateCollision, swL2PortStOversizeFrames=swL2PortStOversizeFrames, systems=systems, swL2PortInfoTable=swL2PortInfoTable, golfcommon=golfcommon, swL2PortCtrlAdminState=swL2PortCtrlAdminState, swL2PortStByteRx=swL2PortStByteRx, swL2PortCtrlEntry=swL2PortCtrlEntry, es2000=es2000, swL2PortStFragments=swL2PortStFragments, swL2Mgmt=swL2Mgmt, swL2PortCtrlClearCounter=swL2PortCtrlClearCounter, swL2PortStJabber=swL2PortStJabber, dlinkcommon=dlinkcommon, es2000Mgmt=es2000Mgmt, swL2PortInfoNwayStatus=swL2PortInfoNwayStatus, swL2PortStUnitIndex=swL2PortStUnitIndex, swL2PortInfoUnitIndex=swL2PortInfoUnitIndex, swL2PortStFrames_128_255_bytes=swL2PortStFrames_128_255_bytes, swL2PortStModuleIndex=swL2PortStModuleIndex, swL2PortCtrlStpState=swL2PortCtrlStpState, marconi=marconi, swL2PortCtrlLockState=swL2PortCtrlLockState, swL2PortInfoType=swL2PortInfoType, swL2PortStTotalBytesRx=swL2PortStTotalBytesRx, swL2PortStTable=swL2PortStTable, swL2PortMgmt=swL2PortMgmt, swL2PortInfoIndex=swL2PortInfoIndex, swEventBcastFallingStorm=swEventBcastFallingStorm, swL2PortStMulticastFramesRx=swL2PortStMulticastFramesRx, swL2PortStFramesDroppedFrames=swL2PortStFramesDroppedFrames, swL2PortStFrames_64_bytes=swL2PortStFrames_64_bytes, swL2PortStMulticastFramesTx=swL2PortStMulticastFramesTx, swL2PortCtrlFlowCtrlState=swL2PortCtrlFlowCtrlState, marconi_products=marconi_products, swL2PortStFrames_65_127_bytes=swL2PortStFrames_65_127_bytes, swL2PortStUndersizeFrames=swL2PortStUndersizeFrames, swL2PortStBroadcastFramesTx=swL2PortStBroadcastFramesTx, dlink=dlink, swL2PortStEntry=swL2PortStEntry, external=external, golfproducts=golfproducts, swL2PortStIndex=swL2PortStIndex, swL2PortStFrameRx=swL2PortStFrameRx, marconi_mgmt=marconi_mgmt, golf=golf, swL2PortInfoLinkStatus=swL2PortInfoLinkStatus, swL2PortCtrlTable=swL2PortCtrlTable, swL2PortCtrlLinkStatusAlarmState=swL2PortCtrlLinkStatusAlarmState, swL2PortCtrlHOLState=swL2PortCtrlHOLState, swL2PortCtrlBackPressState=swL2PortCtrlBackPressState, swL2PortStByteTx=swL2PortStByteTx, swL2PortStTotalFramesRx=swL2PortStTotalFramesRx, swL2PortStFrames_256_511_bytes=swL2PortStFrames_256_511_bytes, swEventBcastRisingStorm=swEventBcastRisingStorm, swL2PortCtrlUnitIndex=swL2PortCtrlUnitIndex, swL2PortStFrames_512_1023_bytes=swL2PortStFrames_512_1023_bytes, swL2PortInfoModuleIndex=swL2PortInfoModuleIndex, swL2PortCtrlBcastFallingAct=swL2PortCtrlBcastFallingAct, swL2PortStFrameTx=swL2PortStFrameTx, swL2PortInfoEntry=swL2PortInfoEntry, swProperty=swProperty, swL2PortStBroadcastFramesRx=swL2PortStBroadcastFramesRx, swEventPortPartition=swEventPortPartition, marconi_es2000Prod=marconi_es2000Prod, swEventlinkChangeEvent=swEventlinkChangeEvent, swL2PortStCollision=swL2PortStCollision, swL2PortCtrlBcastRisingAct=swL2PortCtrlBcastRisingAct, swL2PortInfoDescr=swL2PortInfoDescr, swL2PortCtrlPriority=swL2PortCtrlPriority, swL2PortCtrlNwayState=swL2PortCtrlNwayState, swL2PortCtrlIndex=swL2PortCtrlIndex) |
class Queue:
# Constructor to initiate queue
def __init__(self, queue=None):
if queue is None:
queue = []
self.queue = queue
# push to append an item into queue
def push(self, value):
self.queue.append(value)
# front to return starting element from queue
def front(self):
if Queue.empty(self) is False:
return self.queue[0]
else:
raise IndexError("You are trying to front in an empty queue.")
# pop to remove front element from queue
def pop(self):
if Queue.empty(self) is False:
self.queue.pop(0)
else:
raise IndexError("You are trying to pop in an empty queue.")
# to check queue size
def size(self):
return len(self.queue)
# to check queue is empty or not
def empty(self):
if self.size() > 0:
return False
else:
return True
# to see elements of queue
def display(self):
return self.queue
| class Queue:
def __init__(self, queue=None):
if queue is None:
queue = []
self.queue = queue
def push(self, value):
self.queue.append(value)
def front(self):
if Queue.empty(self) is False:
return self.queue[0]
else:
raise index_error('You are trying to front in an empty queue.')
def pop(self):
if Queue.empty(self) is False:
self.queue.pop(0)
else:
raise index_error('You are trying to pop in an empty queue.')
def size(self):
return len(self.queue)
def empty(self):
if self.size() > 0:
return False
else:
return True
def display(self):
return self.queue |
class EnumType(object):
# Internal data storage uses integer running from 0 to range_end
# range_end is set to the number of possible values that the Enum can take on
# External representation of Enum starts at 1 and goes to range_end + 1
def __init__(self, initial_value):
self.set(initial_value)
def load_json(self, json_struct):
self.set(json_struct)
def json_serializer(self):
# Returns a string
# This could be changed to encode enums as integers when transmitting messages
if self.value < 0:
return None
else:
return type(self).possible_values[self.value]
def __str__(self):
return str(self.json_serializer())
def get(self):
# Returns an integer, using the external representation
return self.value + 1
def set(self, value):
# The value to set can be either a string or an integer
if type(value) is str:
# This will raise ValueError for wrong assignments
try:
self.value = type(self).possible_values.index(value)
except ValueError:
raise ValueError('', value, type(self).possible_values)
elif type(value) is int:
if value >= 0 and value <= type(self).range_end:
# External representation of Enum starts at 1, internal at 0. External value 0 by default
# to indicate empty object.
value = value - 1
self.value = value
else:
raise ValueError('', value, type(self).range_end)
else:
raise TypeError('', value, 'string or integer')
| class Enumtype(object):
def __init__(self, initial_value):
self.set(initial_value)
def load_json(self, json_struct):
self.set(json_struct)
def json_serializer(self):
if self.value < 0:
return None
else:
return type(self).possible_values[self.value]
def __str__(self):
return str(self.json_serializer())
def get(self):
return self.value + 1
def set(self, value):
if type(value) is str:
try:
self.value = type(self).possible_values.index(value)
except ValueError:
raise value_error('', value, type(self).possible_values)
elif type(value) is int:
if value >= 0 and value <= type(self).range_end:
value = value - 1
self.value = value
else:
raise value_error('', value, type(self).range_end)
else:
raise type_error('', value, 'string or integer') |
# -*- coding: utf-8 -*-
#
class LineLoop(object):
_ID = 0
dimension = 1
def __init__(self, lines):
self.lines = lines
self.id = 'll{}'.format(LineLoop._ID)
LineLoop._ID += 1
self.code = '\n'.join([
'{} = newll;'.format(self.id),
'Line Loop({}) = {{{}}};'.format(
self.id, ', '.join([l.id for l in lines])
)])
return
def __len__(self):
return len(self.lines)
| class Lineloop(object):
_id = 0
dimension = 1
def __init__(self, lines):
self.lines = lines
self.id = 'll{}'.format(LineLoop._ID)
LineLoop._ID += 1
self.code = '\n'.join(['{} = newll;'.format(self.id), 'Line Loop({}) = {{{}}};'.format(self.id, ', '.join([l.id for l in lines]))])
return
def __len__(self):
return len(self.lines) |
# Binary search
def binary_search(A: list, x: int):
i = 0
j = len(A)
while i < j:
m = (i + j) // 2
if A[m] == x:
return True
elif A[m] > x:
j = m
else:
i = m + 1
return False
def recursive_binary_search(A: list, x: int, start: int, end: int):
if end >= start:
m = start + (end - start) // 2
if A[m] == x:
return m
elif A[m] > m:
return recursive_binary_search(A, start, m - 1, x)
else:
return recursive_binary_search(A, m + 1, end, x)
else:
return -1 | def binary_search(A: list, x: int):
i = 0
j = len(A)
while i < j:
m = (i + j) // 2
if A[m] == x:
return True
elif A[m] > x:
j = m
else:
i = m + 1
return False
def recursive_binary_search(A: list, x: int, start: int, end: int):
if end >= start:
m = start + (end - start) // 2
if A[m] == x:
return m
elif A[m] > m:
return recursive_binary_search(A, start, m - 1, x)
else:
return recursive_binary_search(A, m + 1, end, x)
else:
return -1 |
class BaseDBDriver():
"""
This will stub the most basic methods that a GraphDB driver must have.
"""
_connected = False
_settings = {}
def __init__(self, dbapi):
self.dbapi = dbapi
def _debug(self, *args):
if self.debug:
print ("[GraphDB #%x]:" % id(self), *args)
def _debugOut(self, *args):
self._debug("OUT --> ", *args)
def _debugIn(self, *args):
self._debug("IN <-- ", *args)
def connect(self):
"""
Performs connection to the database service.
connect() -> self
"""
raise NotImplementedError('Not Implemented Yet')
def query(self, sql):
"""
Performs a query to the database.
query( sql ) -> dict
"""
raise NotImplementedError('Not Implemented Yet')
def disconnect(self):
"""
Performs disconnection and garbage collection for the driver.
connect() -> self
"""
raise NotImplementedError('Not Implemented Yet')
class BaseEdgeDriver(object):
"""
Base driver for managing Edges.
This will provide CRUD & search operations to be extended by
drivers.
"""
def __init__(self, driver):
self.driver = driver
def create(self, eType, origin, destiny, data = {}):
"""
create(eType, origin, destiny [, data]) -> dict
Creates an edge from *origin* to *destiny*
"""
raise NotImplementedError('Not Implemented Yet')
def update(self, eType, criteria = {}, data = {}):
"""
update(eType [, criteria [, data]]) -> dict
Update edges mathing a given criteria
"""
raise NotImplementedError('Not Implemented Yet')
def delete(self, eType, criteria = {}):
"""
delete(eType [, criteria]) -> dict
Delete edges mathing a given criteria
"""
raise NotImplementedError('Not Implemented Yet')
def find(self, eType, criteria = {}):
"""
find(eType [, criteria]) -> list
Find an edge for a given criteria.
"""
raise NotImplementedError('Not Implemented Yet')
class BaseVertexDriver(object):
"""
Base driver for managing Vertexes.
This will provide CRUD & search operations to be extended by
drivers.
"""
def __init__(self, driver):
self.driver = driver
def create(self, vType, data = {}):
"""
create(vType, [, data]) -> dict
Create a Vertex
"""
raise NotImplementedError('Not Implemented Yet')
def update(self, vType, criteria = {}, data = {}):
"""
update(vType, criteria, data) -> dict
Update a Vertex given a criteria
"""
raise NotImplementedError('Not Implemented Yet')
def delete(self, vType, criteria = {}):
"""
delete(vType, criteria) -> dict
Delete a Vertex given a criteria
"""
raise NotImplementedError('Not Implemented Yet')
def find(self, vType, criteria = None):
"""
find(vType [, criteria]) -> list
Look for vertexes matching criteria.
"""
raise NotImplementedError('Not Implemented Yet')
| class Basedbdriver:
"""
This will stub the most basic methods that a GraphDB driver must have.
"""
_connected = False
_settings = {}
def __init__(self, dbapi):
self.dbapi = dbapi
def _debug(self, *args):
if self.debug:
print('[GraphDB #%x]:' % id(self), *args)
def _debug_out(self, *args):
self._debug('OUT --> ', *args)
def _debug_in(self, *args):
self._debug('IN <-- ', *args)
def connect(self):
"""
Performs connection to the database service.
connect() -> self
"""
raise not_implemented_error('Not Implemented Yet')
def query(self, sql):
"""
Performs a query to the database.
query( sql ) -> dict
"""
raise not_implemented_error('Not Implemented Yet')
def disconnect(self):
"""
Performs disconnection and garbage collection for the driver.
connect() -> self
"""
raise not_implemented_error('Not Implemented Yet')
class Baseedgedriver(object):
"""
Base driver for managing Edges.
This will provide CRUD & search operations to be extended by
drivers.
"""
def __init__(self, driver):
self.driver = driver
def create(self, eType, origin, destiny, data={}):
"""
create(eType, origin, destiny [, data]) -> dict
Creates an edge from *origin* to *destiny*
"""
raise not_implemented_error('Not Implemented Yet')
def update(self, eType, criteria={}, data={}):
"""
update(eType [, criteria [, data]]) -> dict
Update edges mathing a given criteria
"""
raise not_implemented_error('Not Implemented Yet')
def delete(self, eType, criteria={}):
"""
delete(eType [, criteria]) -> dict
Delete edges mathing a given criteria
"""
raise not_implemented_error('Not Implemented Yet')
def find(self, eType, criteria={}):
"""
find(eType [, criteria]) -> list
Find an edge for a given criteria.
"""
raise not_implemented_error('Not Implemented Yet')
class Basevertexdriver(object):
"""
Base driver for managing Vertexes.
This will provide CRUD & search operations to be extended by
drivers.
"""
def __init__(self, driver):
self.driver = driver
def create(self, vType, data={}):
"""
create(vType, [, data]) -> dict
Create a Vertex
"""
raise not_implemented_error('Not Implemented Yet')
def update(self, vType, criteria={}, data={}):
"""
update(vType, criteria, data) -> dict
Update a Vertex given a criteria
"""
raise not_implemented_error('Not Implemented Yet')
def delete(self, vType, criteria={}):
"""
delete(vType, criteria) -> dict
Delete a Vertex given a criteria
"""
raise not_implemented_error('Not Implemented Yet')
def find(self, vType, criteria=None):
"""
find(vType [, criteria]) -> list
Look for vertexes matching criteria.
"""
raise not_implemented_error('Not Implemented Yet') |
class Solution:
def numberOfLines(self, widths: List[int], s: str) -> List[int]:
s = list(s); lines = 1; line = 0
while s:
if line + widths[ord(s[0])-97] > 100:
lines += 1; line = 0
else:
line += widths[ord(s.pop(0))-97]
return [lines, line] | class Solution:
def number_of_lines(self, widths: List[int], s: str) -> List[int]:
s = list(s)
lines = 1
line = 0
while s:
if line + widths[ord(s[0]) - 97] > 100:
lines += 1
line = 0
else:
line += widths[ord(s.pop(0)) - 97]
return [lines, line] |
Lakh = 100 * 1000
Crore = 100 * Lakh
biggerNumbers = {
100 : "sau",
1000 : "hazaar",
Lakh : "laakh",
Crore : "karoD"
}
| lakh = 100 * 1000
crore = 100 * Lakh
bigger_numbers = {100: 'sau', 1000: 'hazaar', Lakh: 'laakh', Crore: 'karoD'} |
class Match:
def __init__(self):
self.date = ""
self.round = ""
self.tournament = ""
self.home = ""
self.score = ""
self.away = ""
self.channels = ""
| class Match:
def __init__(self):
self.date = ''
self.round = ''
self.tournament = ''
self.home = ''
self.score = ''
self.away = ''
self.channels = '' |
class Solution:
def intToRoman(self, num):
"""
:type num: int
:rtype: str
"""
res = ""
while num:
if num >= 1000:
res += (num//1000) * 'M'
num = num%1000
elif num >= 900:
res += 'CM'
num -= 900
elif num >= 500:
res += 'D'
num -= 500
elif num >= 400:
res += 'CD'
num -= 400
elif num >= 100:
res += (num//100) * 'C'
num = num%100
elif num >= 90:
res += 'XC'
num -= 90
elif num >= 50:
res += 'L'
num -= 50
elif num >= 40:
res += 'XL'
num -= 40
elif num >= 10:
res += (num//10) * 'X'
num = num%10
elif num >= 9:
res += 'IX'
num -= 9
elif num >= 5:
res += 'V'
num -= 5
elif num >= 4:
res += 'IV'
num -= 4
elif num >= 1:
res += (num//1) * 'I'
num = 0
return res
| class Solution:
def int_to_roman(self, num):
"""
:type num: int
:rtype: str
"""
res = ''
while num:
if num >= 1000:
res += num // 1000 * 'M'
num = num % 1000
elif num >= 900:
res += 'CM'
num -= 900
elif num >= 500:
res += 'D'
num -= 500
elif num >= 400:
res += 'CD'
num -= 400
elif num >= 100:
res += num // 100 * 'C'
num = num % 100
elif num >= 90:
res += 'XC'
num -= 90
elif num >= 50:
res += 'L'
num -= 50
elif num >= 40:
res += 'XL'
num -= 40
elif num >= 10:
res += num // 10 * 'X'
num = num % 10
elif num >= 9:
res += 'IX'
num -= 9
elif num >= 5:
res += 'V'
num -= 5
elif num >= 4:
res += 'IV'
num -= 4
elif num >= 1:
res += num // 1 * 'I'
num = 0
return res |
class Solution:
def productExceptSelf(self, nums: List[int]) -> List[int]:
prod = 1
prods = [1]*len(nums)
for i in range(len(nums)):
prods[i] = prod
prod *= nums[i]
prod = 1
for i in range(len(nums)-1, -1, -1):
prods[i] *= prod
prod *= nums[i]
return prods
| class Solution:
def product_except_self(self, nums: List[int]) -> List[int]:
prod = 1
prods = [1] * len(nums)
for i in range(len(nums)):
prods[i] = prod
prod *= nums[i]
prod = 1
for i in range(len(nums) - 1, -1, -1):
prods[i] *= prod
prod *= nums[i]
return prods |
def all_index(array, num):
indx = []
for i in range(0,len(array)):
for j in range(0,array[i].count(num)):
if j == 0:
indx.append([i, array[i].index(num)])
else:
indx.append([i, array[i].index(num,indx[j-1][1]+1)])
return indx
tic = [[1,1,0],[0,2,1],[1,2,2]]
print(all_index(tic, 1))
| def all_index(array, num):
indx = []
for i in range(0, len(array)):
for j in range(0, array[i].count(num)):
if j == 0:
indx.append([i, array[i].index(num)])
else:
indx.append([i, array[i].index(num, indx[j - 1][1] + 1)])
return indx
tic = [[1, 1, 0], [0, 2, 1], [1, 2, 2]]
print(all_index(tic, 1)) |
"""This problem was asked by Uber.
You have N stones in a row, and would like to create from them a pyramid.
This pyramid should be constructed such that the height of each stone
increases by one until reaching the tallest stone, after which the heights
decrease by one. In addition, the start and end stones of the pyramid
should each be one stone high.
You can change the height of any stone by paying a cost of 1 unit to
lower its height by 1, as many times as necessary. Given this information,
determine the lowest cost method to produce this pyramid.
For example, given the stones [1, 1, 3, 3, 2, 1], the optimal solution
is to pay 2 to create [0, 1, 2, 3, 2, 1].
""" | """This problem was asked by Uber.
You have N stones in a row, and would like to create from them a pyramid.
This pyramid should be constructed such that the height of each stone
increases by one until reaching the tallest stone, after which the heights
decrease by one. In addition, the start and end stones of the pyramid
should each be one stone high.
You can change the height of any stone by paying a cost of 1 unit to
lower its height by 1, as many times as necessary. Given this information,
determine the lowest cost method to produce this pyramid.
For example, given the stones [1, 1, 3, 3, 2, 1], the optimal solution
is to pay 2 to create [0, 1, 2, 3, 2, 1].
""" |
"""Constants for the xbox integration."""
DOMAIN = "xbox"
OAUTH2_AUTHORIZE = "https://login.live.com/oauth20_authorize.srf"
OAUTH2_TOKEN = "https://login.live.com/oauth20_token.srf"
EVENT_NEW_FAVORITE = "xbox/new_favorite"
| """Constants for the xbox integration."""
domain = 'xbox'
oauth2_authorize = 'https://login.live.com/oauth20_authorize.srf'
oauth2_token = 'https://login.live.com/oauth20_token.srf'
event_new_favorite = 'xbox/new_favorite' |
def encrypt(message, key):
encrypted_message = ''
for char in message:
if char.isalpha():
#ord() returns an integer representing the Unicode code point of the character
unicode_num = ord(char)
unicode_num += key
if char.isupper():
if unicode_num > ord('Z'):
unicode_num -= 26
elif unicode_num < ord('A'):
unicode_num += 26
elif char.islower():
if unicode_num > ord('z'):
unicode_num -= 26
elif unicode_num < ord('a'):
unicode_num += 26
#chr() returns a character from a string
encrypted_message += chr(unicode_num)
else:
encrypted_message += char
return encrypted_message
def decrypt(encoded, key):
return encrypt(encoded, -key)
def encrypt_input():
e_message = input('\nEnter message to encrypt: ')
e_key = int(input('\nEnter key number from 1 - 26: '))
while e_key > 26:
e_key = int(input('\nEnter key number from 1 - 26: '))
return f'\nYour encrypted message is =====> {encrypt(e_message, e_key)}'
def decrypt_input():
d_message = input('\nEnter message to decrypt: ')
d_key = int(input('\nEnter key number from 1 - 26: '))
while d_key > 26:
d_key = int(input('\nEnter key number from 1 - 26: '))
return f'\nYour decrypted message is =====> {decrypt(d_message, d_key)}'
def start():
question = input('\nEncrpyt (e) or Decrypt (d) a message? ')
if question == 'e':
return encrypt_input()
if question == 'd':
return decrypt_input()
# else:
# start()
if __name__ == "__main__":
while True:
print(start())
| def encrypt(message, key):
encrypted_message = ''
for char in message:
if char.isalpha():
unicode_num = ord(char)
unicode_num += key
if char.isupper():
if unicode_num > ord('Z'):
unicode_num -= 26
elif unicode_num < ord('A'):
unicode_num += 26
elif char.islower():
if unicode_num > ord('z'):
unicode_num -= 26
elif unicode_num < ord('a'):
unicode_num += 26
encrypted_message += chr(unicode_num)
else:
encrypted_message += char
return encrypted_message
def decrypt(encoded, key):
return encrypt(encoded, -key)
def encrypt_input():
e_message = input('\nEnter message to encrypt: ')
e_key = int(input('\nEnter key number from 1 - 26: '))
while e_key > 26:
e_key = int(input('\nEnter key number from 1 - 26: '))
return f'\nYour encrypted message is =====> {encrypt(e_message, e_key)}'
def decrypt_input():
d_message = input('\nEnter message to decrypt: ')
d_key = int(input('\nEnter key number from 1 - 26: '))
while d_key > 26:
d_key = int(input('\nEnter key number from 1 - 26: '))
return f'\nYour decrypted message is =====> {decrypt(d_message, d_key)}'
def start():
question = input('\nEncrpyt (e) or Decrypt (d) a message? ')
if question == 'e':
return encrypt_input()
if question == 'd':
return decrypt_input()
if __name__ == '__main__':
while True:
print(start()) |
# In "and" operator if ONE is false the whole is false
# in "or" operator if ONE is true the whole is true
print("Welcome to the rollercoaster!")
height = int(input("What is your height in cms? "))
bill = 0
if height >= 120:
print("You can ride the rollercoaster")
age = int(input("What is your age? "))
if age < 12:
bill = 5
print("Child tickets are $5")
elif age <= 18:
bill = 7
print("Youth tickets are $7")
elif age >= 45 and age <= 55:
print("Everything is going to be ok. Have a free ride")
else:
bill = 14
print("Adult tickets are $14")
wants_photo = input("Do you want a photo taken? Y or N.")
if wants_photo == "Y":
bill += 3
print(f"Your final bill is $ {bill}")
else:
print("Sorry, your pp isn't grown up to ride the rollercoaster") | print('Welcome to the rollercoaster!')
height = int(input('What is your height in cms? '))
bill = 0
if height >= 120:
print('You can ride the rollercoaster')
age = int(input('What is your age? '))
if age < 12:
bill = 5
print('Child tickets are $5')
elif age <= 18:
bill = 7
print('Youth tickets are $7')
elif age >= 45 and age <= 55:
print('Everything is going to be ok. Have a free ride')
else:
bill = 14
print('Adult tickets are $14')
wants_photo = input('Do you want a photo taken? Y or N.')
if wants_photo == 'Y':
bill += 3
print(f'Your final bill is $ {bill}')
else:
print("Sorry, your pp isn't grown up to ride the rollercoaster") |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Problem 021
Divisible Sum Pairs
Source : https://www.hackerrank.com/challenges/divisible-sum-pairs/problem
"""
_, d = map(int, input().split())
numbers = list(map(int, input().split()))
nb = len(numbers)
count = 0
for i in range(nb-1):
for j in range(i+1, nb):
count += (numbers[i] + numbers[j]) % d == 0
print(count)
| """Problem 021
Divisible Sum Pairs
Source : https://www.hackerrank.com/challenges/divisible-sum-pairs/problem
"""
(_, d) = map(int, input().split())
numbers = list(map(int, input().split()))
nb = len(numbers)
count = 0
for i in range(nb - 1):
for j in range(i + 1, nb):
count += (numbers[i] + numbers[j]) % d == 0
print(count) |
class User:
def __init__(self, username, name, email, bio, repositories):
self.username = username
self.name = name
self.email = email
self.bio = bio
self.repositories = repositories
def __str__(self):
final = "Name: {} ({}):".format(self.name, self.username)
if self.email:
final = "{} ({})".format(final, self.email)
if self.bio:
final = "{} - {}".format(final, self.bio)
if self.repositories:
for repo in self.repositories:
final = "{}\n{}".format(final, repo.__str__())
return final
def __eq__(self, other):
return self.__dict__ == other.__dict__
| class User:
def __init__(self, username, name, email, bio, repositories):
self.username = username
self.name = name
self.email = email
self.bio = bio
self.repositories = repositories
def __str__(self):
final = 'Name: {} ({}):'.format(self.name, self.username)
if self.email:
final = '{} ({})'.format(final, self.email)
if self.bio:
final = '{} - {}'.format(final, self.bio)
if self.repositories:
for repo in self.repositories:
final = '{}\n{}'.format(final, repo.__str__())
return final
def __eq__(self, other):
return self.__dict__ == other.__dict__ |
#-------------------------------------------------------------------------------
def checkUser( username, passwd ):
return False
#-------------------------------------------------------------------------------
def checkIfUserAvailable( username ):
return False
#-------------------------------------------------------------------------------
def getUserEmail( username ):
return None
#-------------------------------------------------------------------------------
def allowPasswordChange( username ):
return False
#-------------------------------------------------------------------------------
def changeUserPassword( username, oldpass, newpass ):
return False
#-------------------------------------------------------------------------------
| def check_user(username, passwd):
return False
def check_if_user_available(username):
return False
def get_user_email(username):
return None
def allow_password_change(username):
return False
def change_user_password(username, oldpass, newpass):
return False |
# using modified merge function
def compute_union(arr1, arr2):
union = []
index1 = 0
index2 = 0
while (index1 < len(arr1)) and (index2 < len(arr2)):
if arr1[index1] < arr2[index2]:
union.append(arr1[index1])
index1 += 1
elif arr1[index1] > arr2[index2]:
union.append(arr2[index2])
index2 += 1
else:
union.append(arr2[index2])
index1 += 1
index2 += 1
while index1 < len(arr1):
union.append(arr1[index1])
index1 += 1
while index2 < len(arr2):
union.append(arr2[index2])
index2 += 1
return union
# using modified merge function
def compute_intersection(arr1, arr2):
intersection = []
index1 = 0
index2 = 0
while (index1 < len(arr1)) and (index2 < len(arr2)):
if arr1[index1] < arr2[index2]:
index1 += 1
elif arr1[index1] > arr2[index2]:
index2 += 1
else:
intersection.append(arr2[index2])
index1 += 1
index2 += 1
return intersection
if __name__ == "__main__":
arr1 = [1, 3, 4, 5, 7]
arr2 = [2, 3, 5, 6]
# arr1=[2, 5, 6]
# arr2=[4, 6, 8, 10]
union = compute_union(arr1, arr2)
print('union : ', union)
intersection = compute_intersection(arr1, arr2)
print('intersection : ', intersection)
| def compute_union(arr1, arr2):
union = []
index1 = 0
index2 = 0
while index1 < len(arr1) and index2 < len(arr2):
if arr1[index1] < arr2[index2]:
union.append(arr1[index1])
index1 += 1
elif arr1[index1] > arr2[index2]:
union.append(arr2[index2])
index2 += 1
else:
union.append(arr2[index2])
index1 += 1
index2 += 1
while index1 < len(arr1):
union.append(arr1[index1])
index1 += 1
while index2 < len(arr2):
union.append(arr2[index2])
index2 += 1
return union
def compute_intersection(arr1, arr2):
intersection = []
index1 = 0
index2 = 0
while index1 < len(arr1) and index2 < len(arr2):
if arr1[index1] < arr2[index2]:
index1 += 1
elif arr1[index1] > arr2[index2]:
index2 += 1
else:
intersection.append(arr2[index2])
index1 += 1
index2 += 1
return intersection
if __name__ == '__main__':
arr1 = [1, 3, 4, 5, 7]
arr2 = [2, 3, 5, 6]
union = compute_union(arr1, arr2)
print('union : ', union)
intersection = compute_intersection(arr1, arr2)
print('intersection : ', intersection) |
levels = [
#{
# 'geometry': [ ' bbb ',
# ' bbb ',
# ' bbb ',
# ' bbb ',
# ' b ',
# ' b ',
# ' bbb ',
# ' bbbbb ',
# ' bbb ',
# ' b ',
# ' ',
# ' b e ',
# ' b b ',
# ' b b ',
# ' v b '],
# 'start': {'x': 4, 'y': 11},
# 'swatches': [ { 'fields': [ { 'action': 'split1',
# 'position': {'x': 6, 'y': 12}},
# { 'action': 'split2',
# 'position': {'x': 6, 'y': 14}}],
# 'position': {'x': 4, 'y': 14},
# 'type': 'v'}]},
{ 'geometry': [ ' ',
' ',
' bbb ',
' bbbb ',
' bbbb ',
' bbb ',
' bbb ',
' bbbb ',
' bbbb ',
' bebb ',
' bbbb ',
' bb ',
' ',
' ',
' '],
'start': {'x': 6, 'y': 3},
'swatches': []},
{ 'geometry': [ ' bbbbb ',
' bbbbb ',
' bbbsb ',
' bbbbb ',
' l ',
' r ',
' bbbbbb ',
' bbbbbb ',
' bbbbhb ',
' bbbbbb ',
' l ',
' r ',
' bbbbb ',
' bbbeb ',
' bbbbb '],
'start': {'x': 4, 'y': 1},
'swatches': [ { 'fields': [ { 'action': 'onoff',
'position': {'x': 4, 'y': 10}},
{ 'action': 'onoff',
'position': {'x': 4, 'y': 11}}],
'position': {'x': 7, 'y': 8},
'type': 'h'},
{ 'fields': [ { 'action': 'onoff',
'position': {'x': 4, 'y': 4}},
{ 'action': 'onoff',
'position': {'x': 4, 'y': 5}}],
'position': {'x': 6, 'y': 2},
'type': 's'}]},
{ 'geometry': [ ' bbbb ',
' bbbb ',
' bbbb ',
' bbbb ',
' b ',
' b ',
' bbb ',
' bbb ',
' bbb ',
' b ',
' b ',
' bbbbb ',
' bbbbbb ',
' bbeb ',
' bbbb '],
'start': {'x': 4, 'y': 1},
'swatches': []},
{ 'geometry': [ ' bbbbb ',
' bbbbb ',
' bbbbb ',
' bff ',
' ff ',
'bbbb ff ',
'bebb ff ',
'bbbb ff ',
' bb ff ',
' ff bff ',
'ffffbbb ',
'ffffbbb ',
'fbff ',
'ffff ',
' '],
'start': {'x': 3, 'y': 1},
'swatches': []},
{ 'geometry': [ 'bbb ',
'beb bbbb ',
'bbb bbbb ',
'bb bbsbb ',
' b bbbbb ',
' k b k ',
' q s q ',
' b b b ',
' b k s ',
' b q b ',
' bbbb b ',
' bbbb bb',
' bbbb bbb',
' bb bbb',
' bs bbb'],
'start': {'x': 8, 'y': 13},
'swatches': [ { 'fields': [ { 'action': 'onoff',
'position': {'x': 8, 'y': 6}},
{ 'action': 'onoff',
'position': {'x': 8, 'y': 5}}],
'position': {'x': 8, 'y': 8},
'type': 's'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 1, 'y': 5}},
{ 'action': 'on',
'position': {'x': 1, 'y': 6}}],
'position': {'x': 6, 'y': 3},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 1, 'y': 5}},
{ 'action': 'off',
'position': {'x': 1, 'y': 6}}],
'position': {'x': 4, 'y': 6},
'type': 's'},
{ 'fields': [ { 'action': 'onoff',
'position': {'x': 1, 'y': 5}},
{ 'action': 'onoff',
'position': {'x': 1, 'y': 6}}],
'position': {'x': 3, 'y': 14},
'type': 's'}]},
{ 'geometry': [ ' b ',
' b ',
' b ',
' b ',
' bbb ',
' bbbbbb',
' bbbbb b',
'bbb b',
'bbb bbb',
'bbbb bbb',
' bbb bbb',
' bbb ',
' bbbb ',
' beb ',
' bbb '],
'start': {'x': 6, 'y': 0},
'swatches': []},
{ 'geometry': [ ' bbbb ',
' bbbbb ',
' bbbbbb ',
' bl b ',
' b b ',
' b b ',
' b b ',
' bbbbb ',
' bbbbbb ',
' bh bb ',
' bb ',
' bbb ',
' bbbb ',
' bbeb ',
' bbbb '],
'start': {'x': 5, 'y': 1},
'swatches': [ { 'fields': [ { 'action': 'onoff',
'position': {'x': 2, 'y': 3}}],
'position': {'x': 4, 'y': 9},
'type': 'h'}]},
{ 'geometry': [ ' bbb ',
' bbb ',
' bbb ',
' bbb ',
' bvb ',
' bbb ',
' ',
' ',
' ',
' bbbbbbbbb',
' bbbbbbbbb',
' bbbbbbbbb',
' bbb ',
' beb ',
' bbb '],
'start': {'x': 5, 'y': 1},
'swatches': [ { 'fields': [ { 'action': 'split1',
'position': {'x': 8, 'y': 10}},
{ 'action': 'split2',
'position': {'x': 2, 'y': 10}}],
'position': {'x': 5, 'y': 4},
'type': 'v'}]},
{ 'geometry': [ ' bbb ',
' bbb ',
' bbb ',
' bbb ',
' b ',
' b ',
' bbb ',
' bebbb ',
' bbb ',
' b ',
' b ',
' bbb ',
' bbb ',
' bvb ',
' bbb '],
'start': {'x': 5, 'y': 1},
'swatches': [ { 'fields': [ { 'action': 'split1',
'position': {'x': 5, 'y': 12}},
{ 'action': 'split2',
'position': {'x': 5, 'y': 2}}],
'position': {'x': 5, 'y': 13},
'type': 'v'}]},
{ 'geometry': [ ' ',
' bbb',
' beb',
' bbb',
' l ',
'bb r ',
'sb b ',
' b l ',
' b r ',
'bb bbb',
'b bbbb',
'b bbbb',
'hbb bbbbb',
'bbbbbbllvb',
' bb'],
'start': {'x': 8, 'y': 10},
'swatches': [ { 'fields': [ { 'action': 'split1',
'position': {'x': 8, 'y': 13}},
{ 'action': 'split2',
'position': {'x': 8, 'y': 10}}],
'position': {'x': 8, 'y': 13},
'type': 'v'},
{ 'fields': [ { 'action': 'onoff',
'position': {'x': 8, 'y': 4}},
{ 'action': 'onoff',
'position': {'x': 8, 'y': 5}}],
'position': {'x': 0, 'y': 6},
'type': 's'},
{ 'fields': [ { 'action': 'onoff',
'position': {'x': 8, 'y': 7}},
{ 'action': 'onoff',
'position': {'x': 8, 'y': 8}},
{ 'action': 'onoff',
'position': {'x': 7, 'y': 13}},
{ 'action': 'onoff',
'position': {'x': 6, 'y': 13}}],
'position': {'x': 0, 'y': 12},
'type': 'h'}]},
{ 'geometry': [ ' ',
' ',
' b ',
' bbbbbb',
' b beb',
' b bbb',
' b kk',
' bbbbbb ',
' bbsbbb ',
' bb b ',
'bbb b ',
'bb bbb ',
'bb bbb ',
' bbbb ',
' '],
'start': {'x': 4, 'y': 2},
'swatches': [ { 'fields': [ { 'action': 'off',
'position': {'x': 9, 'y': 6}},
{ 'action': 'off',
'position': {'x': 8, 'y': 6}}],
'position': {'x': 3, 'y': 8},
'type': 's'}]},
{ 'geometry': [ ' ',
' bb ',
' bbb ',
' bbb ',
' bbbbb ',
' beb ',
'bb bbbbb ',
'bbb lbhb ',
'bbb bbb ',
' b b ',
' bbb b ',
' bbbbbbb ',
' bbbbbb ',
' bb lbh',
' '],
'start': {'x': 3, 'y': 3},
'swatches': [ { 'fields': [ { 'action': 'onoff',
'position': {'x': 5, 'y': 7}}],
'position': {'x': 9, 'y': 13},
'type': 'h'},
{ 'fields': [ { 'action': 'onoff',
'position': {'x': 7, 'y': 13}}],
'position': {'x': 7, 'y': 7},
'type': 'h'}]},
{ 'geometry': [ ' ',
' bbbbbb',
' bbbbbb',
' bbbbb b',
'bbb f f',
'bbb f b',
'bfffff b',
' fffbbb b',
' fbfbeb b',
'bfffbbb f',
'bfff b',
' ffb bb',
' bbbbbbb',
' bbbbb',
' bbb '],
'start': {'x': 6, 'y': 13},
'swatches': []},
{ 'geometry': [ ' bbbbbb ',
' bb ll ',
'bbb rr ',
'beb bbb ',
'bbb bbb ',
' bbb ',
' b ',
' b ',
'bbbb bbb',
'bbbb bbb',
'bbbb bbb',
'b b b ',
'b bbbhb ',
'h bbbbb ',
' '],
'start': {'x': 7, 'y': 4},
'swatches': [ { 'fields': [ { 'action': 'onoff',
'position': {'x': 7, 'y': 1}},
{ 'action': 'onoff',
'position': {'x': 7, 'y': 2}}],
'position': {'x': 6, 'y': 12},
'type': 'h'},
{ 'fields': [ { 'action': 'onoff',
'position': {'x': 6, 'y': 1}},
{ 'action': 'onoff',
'position': {'x': 6, 'y': 2}}],
'position': {'x': 0, 'y': 13},
'type': 'h'}]},
{ 'geometry': [ 'bbb bbb ',
'bbbbbbbb ',
'bbb bl ',
' b br ',
' b bbb ',
' b k ',
'bbb q ',
'bbbbv bbb',
'bbb sbbb',
' k bbb',
' q l ',
'sbs r ',
'beb bhb',
'bbb bbb',
' bbb'],
'start': {'x': 1, 'y': 1},
'swatches': [ { 'fields': [ { 'action': 'onoff',
'position': {'x': 7, 'y': 2}},
{ 'action': 'onoff',
'position': {'x': 7, 'y': 3}},
{ 'action': 'onoff',
'position': {'x': 8, 'y': 5}},
{ 'action': 'onoff',
'position': {'x': 8, 'y': 6}}],
'position': {'x': 8, 'y': 12},
'type': 'h'},
{ 'fields': [ { 'action': 'onoff',
'position': {'x': 8, 'y': 5}},
{ 'action': 'onoff',
'position': {'x': 8, 'y': 6}},
{ 'action': 'onoff',
'position': {'x': 8, 'y': 10}},
{ 'action': 'onoff',
'position': {'x': 8, 'y': 11}}],
'position': {'x': 6, 'y': 8},
'type': 's'},
{ 'fields': [ { 'action': 'split1',
'position': {'x': 8, 'y': 13}},
{ 'action': 'split2',
'position': {'x': 1, 'y': 1}}],
'position': {'x': 4, 'y': 7},
'type': 'v'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 1, 'y': 9}},
{ 'action': 'off',
'position': {'x': 1, 'y': 10}}],
'position': {'x': 2, 'y': 11},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 1, 'y': 9}},
{ 'action': 'off',
'position': {'x': 1, 'y': 10}}],
'position': {'x': 0, 'y': 11},
'type': 's'}]},
{ 'geometry': [ ' v ',
' vbv ',
'bbb v ',
'bbb l ',
'bbb r ',
' b h ',
' b h ',
' b b ',
'bbb l ',
'bvb r ',
'bbb bbb ',
' beb ',
' bbb ',
' ',
' '],
'start': {'x': 1, 'y': 3},
'swatches': [ { 'fields': [ { 'action': 'split1',
'position': {'x': 6, 'y': 7}},
{ 'action': 'split2',
'position': {'x': 6, 'y': 5}}],
'position': {'x': 7, 'y': 1},
'type': 'v'},
{ 'fields': [ { 'action': 'split1',
'position': {'x': 6, 'y': 2}},
{ 'action': 'split2',
'position': {'x': 7, 'y': 1}}],
'position': {'x': 6, 'y': 0},
'type': 'v'},
{ 'fields': [ { 'action': 'split1',
'position': {'x': 6, 'y': 0}},
{ 'action': 'split2',
'position': {'x': 6, 'y': 2}}],
'position': {'x': 6, 'y': 2},
'type': 'v'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 6, 'y': 3}},
{ 'action': 'on',
'position': {'x': 6, 'y': 4}}],
'position': {'x': 6, 'y': 5},
'type': 'h'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 6, 'y': 8}},
{ 'action': 'on',
'position': {'x': 6, 'y': 9}}],
'position': {'x': 6, 'y': 6},
'type': 'h'},
{ 'fields': [ { 'action': 'split1',
'position': {'x': 5, 'y': 1}},
{ 'action': 'split2',
'position': {'x': 6, 'y': 0}}],
'position': {'x': 5, 'y': 1},
'type': 'v'},
{ 'fields': [ { 'action': 'split1',
'position': {'x': 7, 'y': 1}},
{ 'action': 'split2',
'position': {'x': 6, 'y': 0}}],
'position': {'x': 1, 'y': 9},
'type': 'v'}]},
{ 'geometry': [ 'bbbbbbbbbb',
'bsbbbbbbbb',
'bbbbbbbbbb',
' b b ',
' b b ',
' b b ',
' br b ',
' bb rb ',
' lb bb ',
' b bl ',
' b b ',
'bbbb b ',
'hbbh hbb ',
' heb ',
' bbb '],
'start': {'x': 8, 'y': 1},
'swatches': [ { 'fields': [ { 'action': 'off',
'position': {'x': 3, 'y': 6}}],
'position': {'x': 6, 'y': 12},
'type': 'h'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 3, 'y': 6}}],
'position': {'x': 6, 'y': 13},
'type': 'h'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 7, 'y': 7}}],
'position': {'x': 3, 'y': 12},
'type': 'h'},
{ 'fields': [ { 'action': 'onoff',
'position': {'x': 2, 'y': 8}}],
'position': {'x': 1, 'y': 1},
'type': 's'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 8, 'y': 9}},
{ 'action': 'off',
'position': {'x': 2, 'y': 8}}],
'position': {'x': 0, 'y': 12},
'type': 'h'}]},
{ 'geometry': [ 'bbbbbbbb ',
'l bbsbb ',
'r sbbbs ',
'h bbbbb ',
' bbb ',
' lb ',
' b ',
' bbbs ',
' sbbl ',
' r ',
'bb b ',
'bbb b ',
'bebbbl ',
'bbb r ',
' b '],
'start': {'x': 5, 'y': 2},
'swatches': [ { 'fields': [ { 'action': 'on',
'position': {'x': 5, 'y': 8}},
{ 'action': 'on',
'position': {'x': 5, 'y': 9}}],
'position': {'x': 8, 'y': 7},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 5, 'y': 12}},
{ 'action': 'off',
'position': {'x': 5, 'y': 13}},
{ 'action': 'off',
'position': {'x': 0, 'y': 1}},
{ 'action': 'off',
'position': {'x': 0, 'y': 2}}],
'position': {'x': 7, 'y': 2},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 5, 'y': 8}},
{ 'action': 'off',
'position': {'x': 5, 'y': 9}}],
'position': {'x': 5, 'y': 1},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 5, 'y': 12}},
{ 'action': 'off',
'position': {'x': 5, 'y': 13}},
{ 'action': 'off',
'position': {'x': 0, 'y': 1}},
{ 'action': 'off',
'position': {'x': 0, 'y': 2}}],
'position': {'x': 3, 'y': 2},
'type': 's'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 5, 'y': 12}},
{ 'action': 'on',
'position': {'x': 5, 'y': 13}},
{ 'action': 'on',
'position': {'x': 0, 'y': 1}},
{ 'action': 'on',
'position': {'x': 0, 'y': 2}}],
'position': {'x': 2, 'y': 8},
'type': 's'},
{ 'fields': [ { 'action': 'onoff',
'position': {'x': 4, 'y': 5}}],
'position': {'x': 0, 'y': 3},
'type': 'h'}]},
{ 'geometry': [ ' bbb ',
'bbbeb b',
'kbbbb b',
'q b',
'b b',
'bbbbb bbb',
'bbbbb bbb',
'b l b',
'b r b',
'b b b',
's s s',
'b b b',
'b b b',
'b bbbbbb',
' bbbbbb'],
'start': {'x': 9, 'y': 1},
'swatches': [ { 'fields': [ { 'action': 'onoff',
'position': {'x': 4, 'y': 7}},
{ 'action': 'onoff',
'position': {'x': 4, 'y': 8}}],
'position': {'x': 9, 'y': 10},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 0, 'y': 2}},
{ 'action': 'off',
'position': {'x': 0, 'y': 3}}],
'position': {'x': 4, 'y': 10},
'type': 's'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 0, 'y': 2}},
{ 'action': 'on',
'position': {'x': 0, 'y': 3}}],
'position': {'x': 0, 'y': 10},
'type': 's'}]},
{ 'geometry': [ ' bb ',
' sb ',
' bbbbbb ',
' bbsbbb ',
' bbbbb ',
' k ',
' q ',
' bbvbsb ',
' bbbbbb ',
' bbsbbb ',
' l l ',
' r r ',
'bbbs bbb',
'bebb bbb',
'bbbb bbb'],
'start': {'x': 7, 'y': 8},
'swatches': [ { 'fields': [ { 'action': 'off',
'position': {'x': 8, 'y': 5}},
{ 'action': 'off',
'position': {'x': 8, 'y': 6}}],
'position': {'x': 7, 'y': 7},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 8, 'y': 5}},
{ 'action': 'off',
'position': {'x': 8, 'y': 6}}],
'position': {'x': 5, 'y': 3},
'type': 's'},
{ 'fields': [ { 'action': 'split1',
'position': {'x': 8, 'y': 13}},
{ 'action': 'split2',
'position': {'x': 2, 'y': 13}}],
'position': {'x': 5, 'y': 7},
'type': 'v'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 8, 'y': 5}},
{ 'action': 'off',
'position': {'x': 8, 'y': 6}}],
'position': {'x': 5, 'y': 9},
'type': 's'},
{ 'fields': [ { 'action': 'onoff',
'position': {'x': 3, 'y': 10}},
{ 'action': 'onoff',
'position': {'x': 3, 'y': 11}}],
'position': {'x': 3, 'y': 12},
'type': 's'},
{ 'fields': [ { 'action': 'onoff',
'position': {'x': 8, 'y': 10}},
{ 'action': 'onoff',
'position': {'x': 8, 'y': 11}}],
'position': {'x': 2, 'y': 1},
'type': 's'}]},
{ 'geometry': [ ' bbb ',
' bbbb ',
' bbbbb ',
'rbb bb ',
'bbb bb ',
'bbl bb ',
'b b ',
'b bb ',
'bbbhhbbbbb',
'bbbbb bbb',
' b ',
' b ',
' bbb ',
' beb ',
' bbb '],
'start': {'x': 6, 'y': 1},
'swatches': [ { 'fields': [ { 'action': 'onoff',
'position': {'x': 0, 'y': 3}}],
'position': {'x': 4, 'y': 8},
'type': 'h'},
{ 'fields': [ { 'action': 'onoff',
'position': {'x': 2, 'y': 5}}],
'position': {'x': 3, 'y': 8},
'type': 'h'}]},
{ 'geometry': [ ' ',
' bbb ',
' bbbbbbb ',
'hbl bbb ',
' bbb ',
' sbb ',
' bbb',
' sbb',
' bbb ',
' bbb ',
'hbq bbb ',
' bbbbbbb ',
' bbbbb',
' lbeb',
' bbb'],
'start': {'x': 6, 'y': 2},
'swatches': [ { 'fields': [ { 'action': 'off',
'position': {'x': 2, 'y': 3}},
{ 'action': 'off',
'position': {'x': 6, 'y': 13}}],
'position': {'x': 7, 'y': 7},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 2, 'y': 3}},
{ 'action': 'off',
'position': {'x': 6, 'y': 13}}],
'position': {'x': 6, 'y': 5},
'type': 's'},
{ 'fields': [ { 'action': 'onoff',
'position': {'x': 6, 'y': 13}}],
'position': {'x': 0, 'y': 3},
'type': 'h'},
{ 'fields': [ { 'action': 'onoff',
'position': {'x': 2, 'y': 3}}],
'position': {'x': 0, 'y': 10},
'type': 'h'}]},
{ 'geometry': [ ' bsbr ',
' l bbbb',
' r bbhb',
'bbbb bbbb',
'bbbbbbl ',
'bbbb ',
'bfff ',
'bffffbbb ',
'lffffbeb ',
' ffffbbb ',
' fff k ',
' bbb q ',
' bvb bbbb',
' bbb bbsb',
' kbbsbbb'],
'start': {'x': 2, 'y': 4},
'swatches': [ { 'fields': [ { 'action': 'on',
'position': {'x': 6, 'y': 4}}],
'position': {'x': 8, 'y': 2},
'type': 'h'},
{ 'fields': [ { 'action': 'onoff',
'position': {'x': 0, 'y': 8}},
{ 'action': 'on',
'position': {'x': 3, 'y': 1}},
{ 'action': 'on',
'position': {'x': 3, 'y': 2}}],
'position': {'x': 8, 'y': 13},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 3, 'y': 14}},
{ 'action': 'off',
'position': {'x': 7, 'y': 10}},
{ 'action': 'off',
'position': {'x': 7, 'y': 11}}],
'position': {'x': 6, 'y': 14},
'type': 's'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 6, 'y': 0}},
{ 'action': 'off',
'position': {'x': 3, 'y': 1}},
{ 'action': 'off',
'position': {'x': 3, 'y': 2}}],
'position': {'x': 4, 'y': 0},
'type': 's'},
{ 'fields': [ { 'action': 'split1',
'position': {'x': 2, 'y': 12}},
{ 'action': 'split2',
'position': {'x': 7, 'y': 2}}],
'position': {'x': 2, 'y': 12},
'type': 'v'}]},
{ 'geometry': [ ' ',
' bbbh ',
' bbbbb ',
' bb l ',
' b rr ',
' bbbbb ',
' hb bhb ',
' bb bb ',
' lb b ',
' l b ',
' r b ',
' bbb bbb ',
' beb bhb ',
' bbbbbbbb ',
' bvb '],
'start': {'x': 6, 'y': 2},
'swatches': [ { 'fields': [ { 'action': 'on',
'position': {'x': 6, 'y': 4}},
{ 'action': 'on',
'position': {'x': 6, 'y': 3}}],
'position': {'x': 7, 'y': 12},
'type': 'h'},
{ 'fields': [ { 'action': 'split1',
'position': {'x': 2, 'y': 6}},
{ 'action': 'split2',
'position': {'x': 2, 'y': 8}}],
'position': {'x': 7, 'y': 14},
'type': 'v'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 1, 'y': 8}}],
'position': {'x': 6, 'y': 6},
'type': 'h'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 7, 'y': 4}}],
'position': {'x': 5, 'y': 1},
'type': 'h'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 2, 'y': 9}},
{ 'action': 'on',
'position': {'x': 2, 'y': 10}}],
'position': {'x': 1, 'y': 6},
'type': 'h'}]},
{ 'geometry': [ ' bbb ',
' bbbb ',
' kkhb bbb',
' b bbbb',
' k bsb ',
' q b ',
' bbbbbb ',
' bbbbbl ',
' s l ',
' b r ',
' b bbb ',
'bbb beb ',
'bbb bbb ',
'bbb ll ',
' '],
'start': {'x': 2, 'y': 1},
'swatches': [ { 'fields': [ { 'action': 'onoff',
'position': {'x': 7, 'y': 13}},
{ 'action': 'onoff',
'position': {'x': 6, 'y': 13}},
{ 'action': 'onoff',
'position': {'x': 5, 'y': 8}},
{ 'action': 'onoff',
'position': {'x': 5, 'y': 9}}],
'position': {'x': 7, 'y': 4},
'type': 's'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 5, 'y': 8}},
{ 'action': 'on',
'position': {'x': 5, 'y': 9}}],
'position': {'x': 3, 'y': 2},
'type': 'h'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 6, 'y': 7}},
{ 'action': 'off',
'position': {'x': 3, 'y': 4}},
{ 'action': 'off',
'position': {'x': 3, 'y': 5}}],
'position': {'x': 1, 'y': 8},
'type': 's'}]},
{ 'geometry': [ ' bbb ',
' hbbbb ',
' bbk ',
' lq ',
' bb ',
' bbbb',
' bbbbbbbbb',
' beb bbsb',
' bbb bbb',
' l bb ',
' bbbbb ',
' bb ',
' b ',
' bbbv',
' '],
'start': {'x': 4, 'y': 10},
'swatches': [ { 'fields': [ { 'action': 'split1',
'position': {'x': 6, 'y': 12}},
{ 'action': 'split2',
'position': {'x': 4, 'y': 10}}],
'position': {'x': 9, 'y': 13},
'type': 'v'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 6, 'y': 2}},
{ 'action': 'off',
'position': {'x': 6, 'y': 3}}],
'position': {'x': 8, 'y': 7},
'type': 's'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 2, 'y': 9}},
{ 'action': 'on',
'position': {'x': 5, 'y': 3}}],
'position': {'x': 2, 'y': 1},
'type': 'h'}]},
{ 'geometry': [ ' bbb bbb',
' beb bbb',
' bbb bbb',
' ff b ',
' ff b ',
' ffff b ',
'qffff b ',
'bffff bbb',
'bffff bbb',
'kfffb bb',
' ff bb',
' ff b',
' bbbsbb b',
' bbbsbhbbb',
' bbb bbbb'],
'start': {'x': 8, 'y': 1},
'swatches': [ { 'fields': [ { 'action': 'off',
'position': {'x': 0, 'y': 6}},
{ 'action': 'off',
'position': {'x': 0, 'y': 9}}],
'position': {'x': 6, 'y': 13},
'type': 'h'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 0, 'y': 6}}],
'position': {'x': 4, 'y': 12},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 0, 'y': 9}}],
'position': {'x': 4, 'y': 13},
'type': 's'}]},
{ 'geometry': [ ' ffff ',
' bbbfffbb',
'bbbeb bbb',
' bbb k',
' b q',
'bbb bbb',
'bbb bbb',
'b bbb ',
'k bbb ',
'q bbb ',
'bbbbbb ',
'bbsbv ',
'bbbb ',
' bb ',
' bb '],
'start': {'x': 7, 'y': 2},
'swatches': [ { 'fields': [ { 'action': 'split1',
'position': {'x': 3, 'y': 14}},
{ 'action': 'split2',
'position': {'x': 0, 'y': 12}}],
'position': {'x': 4, 'y': 11},
'type': 'v'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 9, 'y': 4}},
{ 'action': 'off',
'position': {'x': 9, 'y': 3}},
{ 'action': 'off',
'position': {'x': 0, 'y': 8}},
{ 'action': 'off',
'position': {'x': 0, 'y': 9}}],
'position': {'x': 2, 'y': 11},
'type': 's'}]},
{ 'geometry': [ 'bbb h ',
'beb l ',
'bbb r s',
'll b k',
' r b q',
' bbrrbbbbb',
' bbbbbb ',
' bbb ',
' bbb ',
'bbbbbbbbbb',
'k k b l',
'q q b r',
's s l h',
' r ',
' h '],
'start': {'x': 6, 'y': 7},
'swatches': [ { 'fields': [ { 'action': 'on',
'position': {'x': 9, 'y': 10}},
{ 'action': 'on',
'position': {'x': 9, 'y': 11}},
{ 'action': 'off',
'position': {'x': 3, 'y': 10}},
{ 'action': 'off',
'position': {'x': 3, 'y': 11}}],
'position': {'x': 9, 'y': 2},
'type': 's'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 4, 'y': 5}},
{ 'action': 'on',
'position': {'x': 3, 'y': 5}}],
'position': {'x': 9, 'y': 12},
'type': 'h'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 1, 'y': 3}},
{ 'action': 'on',
'position': {'x': 1, 'y': 4}},
{ 'action': 'off',
'position': {'x': 0, 'y': 10}},
{ 'action': 'off',
'position': {'x': 0, 'y': 11}}],
'position': {'x': 6, 'y': 0},
'type': 'h'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 0, 'y': 3}}],
'position': {'x': 6, 'y': 14},
'type': 'h'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 6, 'y': 1}},
{ 'action': 'on',
'position': {'x': 6, 'y': 2}}],
'position': {'x': 3, 'y': 12},
'type': 's'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 6, 'y': 12}},
{ 'action': 'on',
'position': {'x': 6, 'y': 13}},
{ 'action': 'off',
'position': {'x': 3, 'y': 10}},
{ 'action': 'off',
'position': {'x': 3, 'y': 11}},
{ 'action': 'off',
'position': {'x': 9, 'y': 3}},
{ 'action': 'off',
'position': {'x': 9, 'y': 4}},
{ 'action': 'off',
'position': {'x': 9, 'y': 10}},
{ 'action': 'off',
'position': {'x': 9, 'y': 11}}],
'position': {'x': 0, 'y': 12},
'type': 's'}]},
{ 'geometry': [ ' bff ',
'ffffh ',
'bfffbb ',
'ffbff bbb',
'fff beb',
'ffb bbb',
' ff bb',
' ffbfff b',
'ffbbffb f',
'fffl b f',
'ff k b',
'ff q b',
'bbhr bffb',
' bb bbbb',
' lbbbbh '],
'start': {'x': 5, 'y': 2},
'swatches': [ { 'fields': [ { 'action': 'off',
'position': {'x': 6, 'y': 10}},
{ 'action': 'off',
'position': {'x': 6, 'y': 11}},
{ 'action': 'on',
'position': {'x': 3, 'y': 9}},
{ 'action': 'on',
'position': {'x': 3, 'y': 12}}],
'position': {'x': 7, 'y': 14},
'type': 'h'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 6, 'y': 10}},
{ 'action': 'on',
'position': {'x': 6, 'y': 11}}],
'position': {'x': 4, 'y': 1},
'type': 'h'},
{ 'fields': [ { 'action': 'onoff',
'position': {'x': 2, 'y': 14}}],
'position': {'x': 2, 'y': 12},
'type': 'h'}]},
{ 'geometry': [ 'qqq ',
'bbb fbbb ',
'bhbbffbbb ',
'bbb fbbb ',
' l k ',
' r q ',
' hbbbsbb ',
' sbbbbb ',
' bbbbbbh ',
' k l ',
' q r ',
' bbbf bbb',
' bbbffbbeb',
' bbbf bbb',
' lll'],
'start': {'x': 2, 'y': 12},
'swatches': [ { 'fields': [ { 'action': 'onoff',
'position': {'x': 7, 'y': 9}},
{ 'action': 'onoff',
'position': {'x': 7, 'y': 10}}],
'position': {'x': 8, 'y': 8},
'type': 'h'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 7, 'y': 4}},
{ 'action': 'off',
'position': {'x': 7, 'y': 5}},
{ 'action': 'off',
'position': {'x': 7, 'y': 9}},
{ 'action': 'off',
'position': {'x': 7, 'y': 10}},
{ 'action': 'off',
'position': {'x': 2, 'y': 4}},
{ 'action': 'off',
'position': {'x': 2, 'y': 5}},
{ 'action': 'off',
'position': {'x': 2, 'y': 9}},
{ 'action': 'off',
'position': {'x': 2, 'y': 10}}],
'position': {'x': 5, 'y': 6},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 7, 'y': 4}},
{ 'action': 'off',
'position': {'x': 7, 'y': 5}},
{ 'action': 'off',
'position': {'x': 7, 'y': 9}},
{ 'action': 'off',
'position': {'x': 7, 'y': 10}},
{ 'action': 'off',
'position': {'x': 2, 'y': 4}},
{ 'action': 'off',
'position': {'x': 2, 'y': 5}},
{ 'action': 'off',
'position': {'x': 2, 'y': 9}},
{ 'action': 'off',
'position': {'x': 2, 'y': 10}}],
'position': {'x': 2, 'y': 7},
'type': 's'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 7, 'y': 14}},
{ 'action': 'on',
'position': {'x': 8, 'y': 14}},
{ 'action': 'on',
'position': {'x': 9, 'y': 14}},
{ 'action': 'off',
'position': {'x': 7, 'y': 4}},
{ 'action': 'off',
'position': {'x': 7, 'y': 5}}],
'position': {'x': 1, 'y': 2},
'type': 'h'},
{ 'fields': [ { 'action': 'onoff',
'position': {'x': 2, 'y': 4}},
{ 'action': 'onoff',
'position': {'x': 2, 'y': 5}}],
'position': {'x': 1, 'y': 6},
'type': 'h'}]},
{ 'geometry': [ ' ',
' bb ',
' bb bbb ',
' ll bebb ',
' rr bbbb ',
' bbb lk ',
' bhb rq ',
' bbb bb ',
' b bbb ',
' b bb ',
' bbbbbb ',
' bbbbbbb ',
' bhb ',
' bbb',
' bbh'],
'start': {'x': 3, 'y': 11},
'swatches': [ { 'fields': [ { 'action': 'onoff',
'position': {'x': 2, 'y': 3}},
{ 'action': 'onoff',
'position': {'x': 2, 'y': 4}},
{ 'action': 'onoff',
'position': {'x': 8, 'y': 5}},
{ 'action': 'onoff',
'position': {'x': 8, 'y': 6}}],
'position': {'x': 9, 'y': 14},
'type': 'h'},
{ 'fields': [ { 'action': 'onoff',
'position': {'x': 1, 'y': 3}},
{ 'action': 'onoff',
'position': {'x': 1, 'y': 4}}],
'position': {'x': 7, 'y': 12},
'type': 'h'},
{ 'fields': [ { 'action': 'onoff',
'position': {'x': 7, 'y': 5}},
{ 'action': 'onoff',
'position': {'x': 7, 'y': 6}}],
'position': {'x': 2, 'y': 6},
'type': 'h'}]},
{ 'geometry': [ 'bbbb bb ',
'bbeb bb ',
'bbbb bb ',
' k k ',
' q q ',
' bbbbbbsbb',
' bsbbbbbbb',
' bbbbsbbbs',
' bbbbsbb',
' bbbsbbb',
' bbbssbbb',
' bbssbbbl ',
'bbbbbbbb ',
'bbsbbbsb ',
'bbhb '],
'start': {'x': 6, 'y': 1},
'swatches': [ { 'fields': [ { 'action': 'off',
'position': {'x': 2, 'y': 3}},
{ 'action': 'off',
'position': {'x': 2, 'y': 4}}],
'position': {'x': 9, 'y': 7},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 2, 'y': 3}},
{ 'action': 'off',
'position': {'x': 2, 'y': 4}}],
'position': {'x': 7, 'y': 5},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 2, 'y': 3}},
{ 'action': 'off',
'position': {'x': 2, 'y': 4}}],
'position': {'x': 7, 'y': 8},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 2, 'y': 3}},
{ 'action': 'off',
'position': {'x': 2, 'y': 4}}],
'position': {'x': 6, 'y': 9},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 2, 'y': 3}},
{ 'action': 'off',
'position': {'x': 2, 'y': 4}}],
'position': {'x': 6, 'y': 10},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 2, 'y': 3}},
{ 'action': 'off',
'position': {'x': 2, 'y': 4}}],
'position': {'x': 6, 'y': 13},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 2, 'y': 3}},
{ 'action': 'off',
'position': {'x': 2, 'y': 4}}],
'position': {'x': 5, 'y': 7},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 2, 'y': 3}},
{ 'action': 'off',
'position': {'x': 2, 'y': 4}}],
'position': {'x': 5, 'y': 10},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 2, 'y': 3}},
{ 'action': 'off',
'position': {'x': 2, 'y': 4}}],
'position': {'x': 4, 'y': 11},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 2, 'y': 3}},
{ 'action': 'off',
'position': {'x': 2, 'y': 4}}],
'position': {'x': 3, 'y': 11},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 2, 'y': 3}},
{ 'action': 'off',
'position': {'x': 2, 'y': 4}}],
'position': {'x': 2, 'y': 6},
'type': 's'},
{ 'fields': [ { 'action': 'off',
'position': {'x': 2, 'y': 3}},
{ 'action': 'off',
'position': {'x': 2, 'y': 4}}],
'position': {'x': 2, 'y': 13},
'type': 's'},
{ 'fields': [ { 'action': 'on',
'position': {'x': 8, 'y': 11}}],
'position': {'x': 2, 'y': 14},
'type': 'h'}]}]
| levels = [{'geometry': [' ', ' ', ' bbb ', ' bbbb ', ' bbbb ', ' bbb ', ' bbb ', ' bbbb ', ' bbbb ', ' bebb ', ' bbbb ', ' bb ', ' ', ' ', ' '], 'start': {'x': 6, 'y': 3}, 'swatches': []}, {'geometry': [' bbbbb ', ' bbbbb ', ' bbbsb ', ' bbbbb ', ' l ', ' r ', ' bbbbbb ', ' bbbbbb ', ' bbbbhb ', ' bbbbbb ', ' l ', ' r ', ' bbbbb ', ' bbbeb ', ' bbbbb '], 'start': {'x': 4, 'y': 1}, 'swatches': [{'fields': [{'action': 'onoff', 'position': {'x': 4, 'y': 10}}, {'action': 'onoff', 'position': {'x': 4, 'y': 11}}], 'position': {'x': 7, 'y': 8}, 'type': 'h'}, {'fields': [{'action': 'onoff', 'position': {'x': 4, 'y': 4}}, {'action': 'onoff', 'position': {'x': 4, 'y': 5}}], 'position': {'x': 6, 'y': 2}, 'type': 's'}]}, {'geometry': [' bbbb ', ' bbbb ', ' bbbb ', ' bbbb ', ' b ', ' b ', ' bbb ', ' bbb ', ' bbb ', ' b ', ' b ', ' bbbbb ', ' bbbbbb ', ' bbeb ', ' bbbb '], 'start': {'x': 4, 'y': 1}, 'swatches': []}, {'geometry': [' bbbbb ', ' bbbbb ', ' bbbbb ', ' bff ', ' ff ', 'bbbb ff ', 'bebb ff ', 'bbbb ff ', ' bb ff ', ' ff bff ', 'ffffbbb ', 'ffffbbb ', 'fbff ', 'ffff ', ' '], 'start': {'x': 3, 'y': 1}, 'swatches': []}, {'geometry': ['bbb ', 'beb bbbb ', 'bbb bbbb ', 'bb bbsbb ', ' b bbbbb ', ' k b k ', ' q s q ', ' b b b ', ' b k s ', ' b q b ', ' bbbb b ', ' bbbb bb', ' bbbb bbb', ' bb bbb', ' bs bbb'], 'start': {'x': 8, 'y': 13}, 'swatches': [{'fields': [{'action': 'onoff', 'position': {'x': 8, 'y': 6}}, {'action': 'onoff', 'position': {'x': 8, 'y': 5}}], 'position': {'x': 8, 'y': 8}, 'type': 's'}, {'fields': [{'action': 'on', 'position': {'x': 1, 'y': 5}}, {'action': 'on', 'position': {'x': 1, 'y': 6}}], 'position': {'x': 6, 'y': 3}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 1, 'y': 5}}, {'action': 'off', 'position': {'x': 1, 'y': 6}}], 'position': {'x': 4, 'y': 6}, 'type': 's'}, {'fields': [{'action': 'onoff', 'position': {'x': 1, 'y': 5}}, {'action': 'onoff', 'position': {'x': 1, 'y': 6}}], 'position': {'x': 3, 'y': 14}, 'type': 's'}]}, {'geometry': [' b ', ' b ', ' b ', ' b ', ' bbb ', ' bbbbbb', ' bbbbb b', 'bbb b', 'bbb bbb', 'bbbb bbb', ' bbb bbb', ' bbb ', ' bbbb ', ' beb ', ' bbb '], 'start': {'x': 6, 'y': 0}, 'swatches': []}, {'geometry': [' bbbb ', ' bbbbb ', ' bbbbbb ', ' bl b ', ' b b ', ' b b ', ' b b ', ' bbbbb ', ' bbbbbb ', ' bh bb ', ' bb ', ' bbb ', ' bbbb ', ' bbeb ', ' bbbb '], 'start': {'x': 5, 'y': 1}, 'swatches': [{'fields': [{'action': 'onoff', 'position': {'x': 2, 'y': 3}}], 'position': {'x': 4, 'y': 9}, 'type': 'h'}]}, {'geometry': [' bbb ', ' bbb ', ' bbb ', ' bbb ', ' bvb ', ' bbb ', ' ', ' ', ' ', ' bbbbbbbbb', ' bbbbbbbbb', ' bbbbbbbbb', ' bbb ', ' beb ', ' bbb '], 'start': {'x': 5, 'y': 1}, 'swatches': [{'fields': [{'action': 'split1', 'position': {'x': 8, 'y': 10}}, {'action': 'split2', 'position': {'x': 2, 'y': 10}}], 'position': {'x': 5, 'y': 4}, 'type': 'v'}]}, {'geometry': [' bbb ', ' bbb ', ' bbb ', ' bbb ', ' b ', ' b ', ' bbb ', ' bebbb ', ' bbb ', ' b ', ' b ', ' bbb ', ' bbb ', ' bvb ', ' bbb '], 'start': {'x': 5, 'y': 1}, 'swatches': [{'fields': [{'action': 'split1', 'position': {'x': 5, 'y': 12}}, {'action': 'split2', 'position': {'x': 5, 'y': 2}}], 'position': {'x': 5, 'y': 13}, 'type': 'v'}]}, {'geometry': [' ', ' bbb', ' beb', ' bbb', ' l ', 'bb r ', 'sb b ', ' b l ', ' b r ', 'bb bbb', 'b bbbb', 'b bbbb', 'hbb bbbbb', 'bbbbbbllvb', ' bb'], 'start': {'x': 8, 'y': 10}, 'swatches': [{'fields': [{'action': 'split1', 'position': {'x': 8, 'y': 13}}, {'action': 'split2', 'position': {'x': 8, 'y': 10}}], 'position': {'x': 8, 'y': 13}, 'type': 'v'}, {'fields': [{'action': 'onoff', 'position': {'x': 8, 'y': 4}}, {'action': 'onoff', 'position': {'x': 8, 'y': 5}}], 'position': {'x': 0, 'y': 6}, 'type': 's'}, {'fields': [{'action': 'onoff', 'position': {'x': 8, 'y': 7}}, {'action': 'onoff', 'position': {'x': 8, 'y': 8}}, {'action': 'onoff', 'position': {'x': 7, 'y': 13}}, {'action': 'onoff', 'position': {'x': 6, 'y': 13}}], 'position': {'x': 0, 'y': 12}, 'type': 'h'}]}, {'geometry': [' ', ' ', ' b ', ' bbbbbb', ' b beb', ' b bbb', ' b kk', ' bbbbbb ', ' bbsbbb ', ' bb b ', 'bbb b ', 'bb bbb ', 'bb bbb ', ' bbbb ', ' '], 'start': {'x': 4, 'y': 2}, 'swatches': [{'fields': [{'action': 'off', 'position': {'x': 9, 'y': 6}}, {'action': 'off', 'position': {'x': 8, 'y': 6}}], 'position': {'x': 3, 'y': 8}, 'type': 's'}]}, {'geometry': [' ', ' bb ', ' bbb ', ' bbb ', ' bbbbb ', ' beb ', 'bb bbbbb ', 'bbb lbhb ', 'bbb bbb ', ' b b ', ' bbb b ', ' bbbbbbb ', ' bbbbbb ', ' bb lbh', ' '], 'start': {'x': 3, 'y': 3}, 'swatches': [{'fields': [{'action': 'onoff', 'position': {'x': 5, 'y': 7}}], 'position': {'x': 9, 'y': 13}, 'type': 'h'}, {'fields': [{'action': 'onoff', 'position': {'x': 7, 'y': 13}}], 'position': {'x': 7, 'y': 7}, 'type': 'h'}]}, {'geometry': [' ', ' bbbbbb', ' bbbbbb', ' bbbbb b', 'bbb f f', 'bbb f b', 'bfffff b', ' fffbbb b', ' fbfbeb b', 'bfffbbb f', 'bfff b', ' ffb bb', ' bbbbbbb', ' bbbbb', ' bbb '], 'start': {'x': 6, 'y': 13}, 'swatches': []}, {'geometry': [' bbbbbb ', ' bb ll ', 'bbb rr ', 'beb bbb ', 'bbb bbb ', ' bbb ', ' b ', ' b ', 'bbbb bbb', 'bbbb bbb', 'bbbb bbb', 'b b b ', 'b bbbhb ', 'h bbbbb ', ' '], 'start': {'x': 7, 'y': 4}, 'swatches': [{'fields': [{'action': 'onoff', 'position': {'x': 7, 'y': 1}}, {'action': 'onoff', 'position': {'x': 7, 'y': 2}}], 'position': {'x': 6, 'y': 12}, 'type': 'h'}, {'fields': [{'action': 'onoff', 'position': {'x': 6, 'y': 1}}, {'action': 'onoff', 'position': {'x': 6, 'y': 2}}], 'position': {'x': 0, 'y': 13}, 'type': 'h'}]}, {'geometry': ['bbb bbb ', 'bbbbbbbb ', 'bbb bl ', ' b br ', ' b bbb ', ' b k ', 'bbb q ', 'bbbbv bbb', 'bbb sbbb', ' k bbb', ' q l ', 'sbs r ', 'beb bhb', 'bbb bbb', ' bbb'], 'start': {'x': 1, 'y': 1}, 'swatches': [{'fields': [{'action': 'onoff', 'position': {'x': 7, 'y': 2}}, {'action': 'onoff', 'position': {'x': 7, 'y': 3}}, {'action': 'onoff', 'position': {'x': 8, 'y': 5}}, {'action': 'onoff', 'position': {'x': 8, 'y': 6}}], 'position': {'x': 8, 'y': 12}, 'type': 'h'}, {'fields': [{'action': 'onoff', 'position': {'x': 8, 'y': 5}}, {'action': 'onoff', 'position': {'x': 8, 'y': 6}}, {'action': 'onoff', 'position': {'x': 8, 'y': 10}}, {'action': 'onoff', 'position': {'x': 8, 'y': 11}}], 'position': {'x': 6, 'y': 8}, 'type': 's'}, {'fields': [{'action': 'split1', 'position': {'x': 8, 'y': 13}}, {'action': 'split2', 'position': {'x': 1, 'y': 1}}], 'position': {'x': 4, 'y': 7}, 'type': 'v'}, {'fields': [{'action': 'off', 'position': {'x': 1, 'y': 9}}, {'action': 'off', 'position': {'x': 1, 'y': 10}}], 'position': {'x': 2, 'y': 11}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 1, 'y': 9}}, {'action': 'off', 'position': {'x': 1, 'y': 10}}], 'position': {'x': 0, 'y': 11}, 'type': 's'}]}, {'geometry': [' v ', ' vbv ', 'bbb v ', 'bbb l ', 'bbb r ', ' b h ', ' b h ', ' b b ', 'bbb l ', 'bvb r ', 'bbb bbb ', ' beb ', ' bbb ', ' ', ' '], 'start': {'x': 1, 'y': 3}, 'swatches': [{'fields': [{'action': 'split1', 'position': {'x': 6, 'y': 7}}, {'action': 'split2', 'position': {'x': 6, 'y': 5}}], 'position': {'x': 7, 'y': 1}, 'type': 'v'}, {'fields': [{'action': 'split1', 'position': {'x': 6, 'y': 2}}, {'action': 'split2', 'position': {'x': 7, 'y': 1}}], 'position': {'x': 6, 'y': 0}, 'type': 'v'}, {'fields': [{'action': 'split1', 'position': {'x': 6, 'y': 0}}, {'action': 'split2', 'position': {'x': 6, 'y': 2}}], 'position': {'x': 6, 'y': 2}, 'type': 'v'}, {'fields': [{'action': 'on', 'position': {'x': 6, 'y': 3}}, {'action': 'on', 'position': {'x': 6, 'y': 4}}], 'position': {'x': 6, 'y': 5}, 'type': 'h'}, {'fields': [{'action': 'on', 'position': {'x': 6, 'y': 8}}, {'action': 'on', 'position': {'x': 6, 'y': 9}}], 'position': {'x': 6, 'y': 6}, 'type': 'h'}, {'fields': [{'action': 'split1', 'position': {'x': 5, 'y': 1}}, {'action': 'split2', 'position': {'x': 6, 'y': 0}}], 'position': {'x': 5, 'y': 1}, 'type': 'v'}, {'fields': [{'action': 'split1', 'position': {'x': 7, 'y': 1}}, {'action': 'split2', 'position': {'x': 6, 'y': 0}}], 'position': {'x': 1, 'y': 9}, 'type': 'v'}]}, {'geometry': ['bbbbbbbbbb', 'bsbbbbbbbb', 'bbbbbbbbbb', ' b b ', ' b b ', ' b b ', ' br b ', ' bb rb ', ' lb bb ', ' b bl ', ' b b ', 'bbbb b ', 'hbbh hbb ', ' heb ', ' bbb '], 'start': {'x': 8, 'y': 1}, 'swatches': [{'fields': [{'action': 'off', 'position': {'x': 3, 'y': 6}}], 'position': {'x': 6, 'y': 12}, 'type': 'h'}, {'fields': [{'action': 'on', 'position': {'x': 3, 'y': 6}}], 'position': {'x': 6, 'y': 13}, 'type': 'h'}, {'fields': [{'action': 'on', 'position': {'x': 7, 'y': 7}}], 'position': {'x': 3, 'y': 12}, 'type': 'h'}, {'fields': [{'action': 'onoff', 'position': {'x': 2, 'y': 8}}], 'position': {'x': 1, 'y': 1}, 'type': 's'}, {'fields': [{'action': 'on', 'position': {'x': 8, 'y': 9}}, {'action': 'off', 'position': {'x': 2, 'y': 8}}], 'position': {'x': 0, 'y': 12}, 'type': 'h'}]}, {'geometry': ['bbbbbbbb ', 'l bbsbb ', 'r sbbbs ', 'h bbbbb ', ' bbb ', ' lb ', ' b ', ' bbbs ', ' sbbl ', ' r ', 'bb b ', 'bbb b ', 'bebbbl ', 'bbb r ', ' b '], 'start': {'x': 5, 'y': 2}, 'swatches': [{'fields': [{'action': 'on', 'position': {'x': 5, 'y': 8}}, {'action': 'on', 'position': {'x': 5, 'y': 9}}], 'position': {'x': 8, 'y': 7}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 5, 'y': 12}}, {'action': 'off', 'position': {'x': 5, 'y': 13}}, {'action': 'off', 'position': {'x': 0, 'y': 1}}, {'action': 'off', 'position': {'x': 0, 'y': 2}}], 'position': {'x': 7, 'y': 2}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 5, 'y': 8}}, {'action': 'off', 'position': {'x': 5, 'y': 9}}], 'position': {'x': 5, 'y': 1}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 5, 'y': 12}}, {'action': 'off', 'position': {'x': 5, 'y': 13}}, {'action': 'off', 'position': {'x': 0, 'y': 1}}, {'action': 'off', 'position': {'x': 0, 'y': 2}}], 'position': {'x': 3, 'y': 2}, 'type': 's'}, {'fields': [{'action': 'on', 'position': {'x': 5, 'y': 12}}, {'action': 'on', 'position': {'x': 5, 'y': 13}}, {'action': 'on', 'position': {'x': 0, 'y': 1}}, {'action': 'on', 'position': {'x': 0, 'y': 2}}], 'position': {'x': 2, 'y': 8}, 'type': 's'}, {'fields': [{'action': 'onoff', 'position': {'x': 4, 'y': 5}}], 'position': {'x': 0, 'y': 3}, 'type': 'h'}]}, {'geometry': [' bbb ', 'bbbeb b', 'kbbbb b', 'q b', 'b b', 'bbbbb bbb', 'bbbbb bbb', 'b l b', 'b r b', 'b b b', 's s s', 'b b b', 'b b b', 'b bbbbbb', ' bbbbbb'], 'start': {'x': 9, 'y': 1}, 'swatches': [{'fields': [{'action': 'onoff', 'position': {'x': 4, 'y': 7}}, {'action': 'onoff', 'position': {'x': 4, 'y': 8}}], 'position': {'x': 9, 'y': 10}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 0, 'y': 2}}, {'action': 'off', 'position': {'x': 0, 'y': 3}}], 'position': {'x': 4, 'y': 10}, 'type': 's'}, {'fields': [{'action': 'on', 'position': {'x': 0, 'y': 2}}, {'action': 'on', 'position': {'x': 0, 'y': 3}}], 'position': {'x': 0, 'y': 10}, 'type': 's'}]}, {'geometry': [' bb ', ' sb ', ' bbbbbb ', ' bbsbbb ', ' bbbbb ', ' k ', ' q ', ' bbvbsb ', ' bbbbbb ', ' bbsbbb ', ' l l ', ' r r ', 'bbbs bbb', 'bebb bbb', 'bbbb bbb'], 'start': {'x': 7, 'y': 8}, 'swatches': [{'fields': [{'action': 'off', 'position': {'x': 8, 'y': 5}}, {'action': 'off', 'position': {'x': 8, 'y': 6}}], 'position': {'x': 7, 'y': 7}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 8, 'y': 5}}, {'action': 'off', 'position': {'x': 8, 'y': 6}}], 'position': {'x': 5, 'y': 3}, 'type': 's'}, {'fields': [{'action': 'split1', 'position': {'x': 8, 'y': 13}}, {'action': 'split2', 'position': {'x': 2, 'y': 13}}], 'position': {'x': 5, 'y': 7}, 'type': 'v'}, {'fields': [{'action': 'off', 'position': {'x': 8, 'y': 5}}, {'action': 'off', 'position': {'x': 8, 'y': 6}}], 'position': {'x': 5, 'y': 9}, 'type': 's'}, {'fields': [{'action': 'onoff', 'position': {'x': 3, 'y': 10}}, {'action': 'onoff', 'position': {'x': 3, 'y': 11}}], 'position': {'x': 3, 'y': 12}, 'type': 's'}, {'fields': [{'action': 'onoff', 'position': {'x': 8, 'y': 10}}, {'action': 'onoff', 'position': {'x': 8, 'y': 11}}], 'position': {'x': 2, 'y': 1}, 'type': 's'}]}, {'geometry': [' bbb ', ' bbbb ', ' bbbbb ', 'rbb bb ', 'bbb bb ', 'bbl bb ', 'b b ', 'b bb ', 'bbbhhbbbbb', 'bbbbb bbb', ' b ', ' b ', ' bbb ', ' beb ', ' bbb '], 'start': {'x': 6, 'y': 1}, 'swatches': [{'fields': [{'action': 'onoff', 'position': {'x': 0, 'y': 3}}], 'position': {'x': 4, 'y': 8}, 'type': 'h'}, {'fields': [{'action': 'onoff', 'position': {'x': 2, 'y': 5}}], 'position': {'x': 3, 'y': 8}, 'type': 'h'}]}, {'geometry': [' ', ' bbb ', ' bbbbbbb ', 'hbl bbb ', ' bbb ', ' sbb ', ' bbb', ' sbb', ' bbb ', ' bbb ', 'hbq bbb ', ' bbbbbbb ', ' bbbbb', ' lbeb', ' bbb'], 'start': {'x': 6, 'y': 2}, 'swatches': [{'fields': [{'action': 'off', 'position': {'x': 2, 'y': 3}}, {'action': 'off', 'position': {'x': 6, 'y': 13}}], 'position': {'x': 7, 'y': 7}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 2, 'y': 3}}, {'action': 'off', 'position': {'x': 6, 'y': 13}}], 'position': {'x': 6, 'y': 5}, 'type': 's'}, {'fields': [{'action': 'onoff', 'position': {'x': 6, 'y': 13}}], 'position': {'x': 0, 'y': 3}, 'type': 'h'}, {'fields': [{'action': 'onoff', 'position': {'x': 2, 'y': 3}}], 'position': {'x': 0, 'y': 10}, 'type': 'h'}]}, {'geometry': [' bsbr ', ' l bbbb', ' r bbhb', 'bbbb bbbb', 'bbbbbbl ', 'bbbb ', 'bfff ', 'bffffbbb ', 'lffffbeb ', ' ffffbbb ', ' fff k ', ' bbb q ', ' bvb bbbb', ' bbb bbsb', ' kbbsbbb'], 'start': {'x': 2, 'y': 4}, 'swatches': [{'fields': [{'action': 'on', 'position': {'x': 6, 'y': 4}}], 'position': {'x': 8, 'y': 2}, 'type': 'h'}, {'fields': [{'action': 'onoff', 'position': {'x': 0, 'y': 8}}, {'action': 'on', 'position': {'x': 3, 'y': 1}}, {'action': 'on', 'position': {'x': 3, 'y': 2}}], 'position': {'x': 8, 'y': 13}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 3, 'y': 14}}, {'action': 'off', 'position': {'x': 7, 'y': 10}}, {'action': 'off', 'position': {'x': 7, 'y': 11}}], 'position': {'x': 6, 'y': 14}, 'type': 's'}, {'fields': [{'action': 'on', 'position': {'x': 6, 'y': 0}}, {'action': 'off', 'position': {'x': 3, 'y': 1}}, {'action': 'off', 'position': {'x': 3, 'y': 2}}], 'position': {'x': 4, 'y': 0}, 'type': 's'}, {'fields': [{'action': 'split1', 'position': {'x': 2, 'y': 12}}, {'action': 'split2', 'position': {'x': 7, 'y': 2}}], 'position': {'x': 2, 'y': 12}, 'type': 'v'}]}, {'geometry': [' ', ' bbbh ', ' bbbbb ', ' bb l ', ' b rr ', ' bbbbb ', ' hb bhb ', ' bb bb ', ' lb b ', ' l b ', ' r b ', ' bbb bbb ', ' beb bhb ', ' bbbbbbbb ', ' bvb '], 'start': {'x': 6, 'y': 2}, 'swatches': [{'fields': [{'action': 'on', 'position': {'x': 6, 'y': 4}}, {'action': 'on', 'position': {'x': 6, 'y': 3}}], 'position': {'x': 7, 'y': 12}, 'type': 'h'}, {'fields': [{'action': 'split1', 'position': {'x': 2, 'y': 6}}, {'action': 'split2', 'position': {'x': 2, 'y': 8}}], 'position': {'x': 7, 'y': 14}, 'type': 'v'}, {'fields': [{'action': 'on', 'position': {'x': 1, 'y': 8}}], 'position': {'x': 6, 'y': 6}, 'type': 'h'}, {'fields': [{'action': 'on', 'position': {'x': 7, 'y': 4}}], 'position': {'x': 5, 'y': 1}, 'type': 'h'}, {'fields': [{'action': 'on', 'position': {'x': 2, 'y': 9}}, {'action': 'on', 'position': {'x': 2, 'y': 10}}], 'position': {'x': 1, 'y': 6}, 'type': 'h'}]}, {'geometry': [' bbb ', ' bbbb ', ' kkhb bbb', ' b bbbb', ' k bsb ', ' q b ', ' bbbbbb ', ' bbbbbl ', ' s l ', ' b r ', ' b bbb ', 'bbb beb ', 'bbb bbb ', 'bbb ll ', ' '], 'start': {'x': 2, 'y': 1}, 'swatches': [{'fields': [{'action': 'onoff', 'position': {'x': 7, 'y': 13}}, {'action': 'onoff', 'position': {'x': 6, 'y': 13}}, {'action': 'onoff', 'position': {'x': 5, 'y': 8}}, {'action': 'onoff', 'position': {'x': 5, 'y': 9}}], 'position': {'x': 7, 'y': 4}, 'type': 's'}, {'fields': [{'action': 'on', 'position': {'x': 5, 'y': 8}}, {'action': 'on', 'position': {'x': 5, 'y': 9}}], 'position': {'x': 3, 'y': 2}, 'type': 'h'}, {'fields': [{'action': 'on', 'position': {'x': 6, 'y': 7}}, {'action': 'off', 'position': {'x': 3, 'y': 4}}, {'action': 'off', 'position': {'x': 3, 'y': 5}}], 'position': {'x': 1, 'y': 8}, 'type': 's'}]}, {'geometry': [' bbb ', ' hbbbb ', ' bbk ', ' lq ', ' bb ', ' bbbb', ' bbbbbbbbb', ' beb bbsb', ' bbb bbb', ' l bb ', ' bbbbb ', ' bb ', ' b ', ' bbbv', ' '], 'start': {'x': 4, 'y': 10}, 'swatches': [{'fields': [{'action': 'split1', 'position': {'x': 6, 'y': 12}}, {'action': 'split2', 'position': {'x': 4, 'y': 10}}], 'position': {'x': 9, 'y': 13}, 'type': 'v'}, {'fields': [{'action': 'off', 'position': {'x': 6, 'y': 2}}, {'action': 'off', 'position': {'x': 6, 'y': 3}}], 'position': {'x': 8, 'y': 7}, 'type': 's'}, {'fields': [{'action': 'on', 'position': {'x': 2, 'y': 9}}, {'action': 'on', 'position': {'x': 5, 'y': 3}}], 'position': {'x': 2, 'y': 1}, 'type': 'h'}]}, {'geometry': [' bbb bbb', ' beb bbb', ' bbb bbb', ' ff b ', ' ff b ', ' ffff b ', 'qffff b ', 'bffff bbb', 'bffff bbb', 'kfffb bb', ' ff bb', ' ff b', ' bbbsbb b', ' bbbsbhbbb', ' bbb bbbb'], 'start': {'x': 8, 'y': 1}, 'swatches': [{'fields': [{'action': 'off', 'position': {'x': 0, 'y': 6}}, {'action': 'off', 'position': {'x': 0, 'y': 9}}], 'position': {'x': 6, 'y': 13}, 'type': 'h'}, {'fields': [{'action': 'off', 'position': {'x': 0, 'y': 6}}], 'position': {'x': 4, 'y': 12}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 0, 'y': 9}}], 'position': {'x': 4, 'y': 13}, 'type': 's'}]}, {'geometry': [' ffff ', ' bbbfffbb', 'bbbeb bbb', ' bbb k', ' b q', 'bbb bbb', 'bbb bbb', 'b bbb ', 'k bbb ', 'q bbb ', 'bbbbbb ', 'bbsbv ', 'bbbb ', ' bb ', ' bb '], 'start': {'x': 7, 'y': 2}, 'swatches': [{'fields': [{'action': 'split1', 'position': {'x': 3, 'y': 14}}, {'action': 'split2', 'position': {'x': 0, 'y': 12}}], 'position': {'x': 4, 'y': 11}, 'type': 'v'}, {'fields': [{'action': 'off', 'position': {'x': 9, 'y': 4}}, {'action': 'off', 'position': {'x': 9, 'y': 3}}, {'action': 'off', 'position': {'x': 0, 'y': 8}}, {'action': 'off', 'position': {'x': 0, 'y': 9}}], 'position': {'x': 2, 'y': 11}, 'type': 's'}]}, {'geometry': ['bbb h ', 'beb l ', 'bbb r s', 'll b k', ' r b q', ' bbrrbbbbb', ' bbbbbb ', ' bbb ', ' bbb ', 'bbbbbbbbbb', 'k k b l', 'q q b r', 's s l h', ' r ', ' h '], 'start': {'x': 6, 'y': 7}, 'swatches': [{'fields': [{'action': 'on', 'position': {'x': 9, 'y': 10}}, {'action': 'on', 'position': {'x': 9, 'y': 11}}, {'action': 'off', 'position': {'x': 3, 'y': 10}}, {'action': 'off', 'position': {'x': 3, 'y': 11}}], 'position': {'x': 9, 'y': 2}, 'type': 's'}, {'fields': [{'action': 'on', 'position': {'x': 4, 'y': 5}}, {'action': 'on', 'position': {'x': 3, 'y': 5}}], 'position': {'x': 9, 'y': 12}, 'type': 'h'}, {'fields': [{'action': 'on', 'position': {'x': 1, 'y': 3}}, {'action': 'on', 'position': {'x': 1, 'y': 4}}, {'action': 'off', 'position': {'x': 0, 'y': 10}}, {'action': 'off', 'position': {'x': 0, 'y': 11}}], 'position': {'x': 6, 'y': 0}, 'type': 'h'}, {'fields': [{'action': 'on', 'position': {'x': 0, 'y': 3}}], 'position': {'x': 6, 'y': 14}, 'type': 'h'}, {'fields': [{'action': 'on', 'position': {'x': 6, 'y': 1}}, {'action': 'on', 'position': {'x': 6, 'y': 2}}], 'position': {'x': 3, 'y': 12}, 'type': 's'}, {'fields': [{'action': 'on', 'position': {'x': 6, 'y': 12}}, {'action': 'on', 'position': {'x': 6, 'y': 13}}, {'action': 'off', 'position': {'x': 3, 'y': 10}}, {'action': 'off', 'position': {'x': 3, 'y': 11}}, {'action': 'off', 'position': {'x': 9, 'y': 3}}, {'action': 'off', 'position': {'x': 9, 'y': 4}}, {'action': 'off', 'position': {'x': 9, 'y': 10}}, {'action': 'off', 'position': {'x': 9, 'y': 11}}], 'position': {'x': 0, 'y': 12}, 'type': 's'}]}, {'geometry': [' bff ', 'ffffh ', 'bfffbb ', 'ffbff bbb', 'fff beb', 'ffb bbb', ' ff bb', ' ffbfff b', 'ffbbffb f', 'fffl b f', 'ff k b', 'ff q b', 'bbhr bffb', ' bb bbbb', ' lbbbbh '], 'start': {'x': 5, 'y': 2}, 'swatches': [{'fields': [{'action': 'off', 'position': {'x': 6, 'y': 10}}, {'action': 'off', 'position': {'x': 6, 'y': 11}}, {'action': 'on', 'position': {'x': 3, 'y': 9}}, {'action': 'on', 'position': {'x': 3, 'y': 12}}], 'position': {'x': 7, 'y': 14}, 'type': 'h'}, {'fields': [{'action': 'on', 'position': {'x': 6, 'y': 10}}, {'action': 'on', 'position': {'x': 6, 'y': 11}}], 'position': {'x': 4, 'y': 1}, 'type': 'h'}, {'fields': [{'action': 'onoff', 'position': {'x': 2, 'y': 14}}], 'position': {'x': 2, 'y': 12}, 'type': 'h'}]}, {'geometry': ['qqq ', 'bbb fbbb ', 'bhbbffbbb ', 'bbb fbbb ', ' l k ', ' r q ', ' hbbbsbb ', ' sbbbbb ', ' bbbbbbh ', ' k l ', ' q r ', ' bbbf bbb', ' bbbffbbeb', ' bbbf bbb', ' lll'], 'start': {'x': 2, 'y': 12}, 'swatches': [{'fields': [{'action': 'onoff', 'position': {'x': 7, 'y': 9}}, {'action': 'onoff', 'position': {'x': 7, 'y': 10}}], 'position': {'x': 8, 'y': 8}, 'type': 'h'}, {'fields': [{'action': 'off', 'position': {'x': 7, 'y': 4}}, {'action': 'off', 'position': {'x': 7, 'y': 5}}, {'action': 'off', 'position': {'x': 7, 'y': 9}}, {'action': 'off', 'position': {'x': 7, 'y': 10}}, {'action': 'off', 'position': {'x': 2, 'y': 4}}, {'action': 'off', 'position': {'x': 2, 'y': 5}}, {'action': 'off', 'position': {'x': 2, 'y': 9}}, {'action': 'off', 'position': {'x': 2, 'y': 10}}], 'position': {'x': 5, 'y': 6}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 7, 'y': 4}}, {'action': 'off', 'position': {'x': 7, 'y': 5}}, {'action': 'off', 'position': {'x': 7, 'y': 9}}, {'action': 'off', 'position': {'x': 7, 'y': 10}}, {'action': 'off', 'position': {'x': 2, 'y': 4}}, {'action': 'off', 'position': {'x': 2, 'y': 5}}, {'action': 'off', 'position': {'x': 2, 'y': 9}}, {'action': 'off', 'position': {'x': 2, 'y': 10}}], 'position': {'x': 2, 'y': 7}, 'type': 's'}, {'fields': [{'action': 'on', 'position': {'x': 7, 'y': 14}}, {'action': 'on', 'position': {'x': 8, 'y': 14}}, {'action': 'on', 'position': {'x': 9, 'y': 14}}, {'action': 'off', 'position': {'x': 7, 'y': 4}}, {'action': 'off', 'position': {'x': 7, 'y': 5}}], 'position': {'x': 1, 'y': 2}, 'type': 'h'}, {'fields': [{'action': 'onoff', 'position': {'x': 2, 'y': 4}}, {'action': 'onoff', 'position': {'x': 2, 'y': 5}}], 'position': {'x': 1, 'y': 6}, 'type': 'h'}]}, {'geometry': [' ', ' bb ', ' bb bbb ', ' ll bebb ', ' rr bbbb ', ' bbb lk ', ' bhb rq ', ' bbb bb ', ' b bbb ', ' b bb ', ' bbbbbb ', ' bbbbbbb ', ' bhb ', ' bbb', ' bbh'], 'start': {'x': 3, 'y': 11}, 'swatches': [{'fields': [{'action': 'onoff', 'position': {'x': 2, 'y': 3}}, {'action': 'onoff', 'position': {'x': 2, 'y': 4}}, {'action': 'onoff', 'position': {'x': 8, 'y': 5}}, {'action': 'onoff', 'position': {'x': 8, 'y': 6}}], 'position': {'x': 9, 'y': 14}, 'type': 'h'}, {'fields': [{'action': 'onoff', 'position': {'x': 1, 'y': 3}}, {'action': 'onoff', 'position': {'x': 1, 'y': 4}}], 'position': {'x': 7, 'y': 12}, 'type': 'h'}, {'fields': [{'action': 'onoff', 'position': {'x': 7, 'y': 5}}, {'action': 'onoff', 'position': {'x': 7, 'y': 6}}], 'position': {'x': 2, 'y': 6}, 'type': 'h'}]}, {'geometry': ['bbbb bb ', 'bbeb bb ', 'bbbb bb ', ' k k ', ' q q ', ' bbbbbbsbb', ' bsbbbbbbb', ' bbbbsbbbs', ' bbbbsbb', ' bbbsbbb', ' bbbssbbb', ' bbssbbbl ', 'bbbbbbbb ', 'bbsbbbsb ', 'bbhb '], 'start': {'x': 6, 'y': 1}, 'swatches': [{'fields': [{'action': 'off', 'position': {'x': 2, 'y': 3}}, {'action': 'off', 'position': {'x': 2, 'y': 4}}], 'position': {'x': 9, 'y': 7}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 2, 'y': 3}}, {'action': 'off', 'position': {'x': 2, 'y': 4}}], 'position': {'x': 7, 'y': 5}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 2, 'y': 3}}, {'action': 'off', 'position': {'x': 2, 'y': 4}}], 'position': {'x': 7, 'y': 8}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 2, 'y': 3}}, {'action': 'off', 'position': {'x': 2, 'y': 4}}], 'position': {'x': 6, 'y': 9}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 2, 'y': 3}}, {'action': 'off', 'position': {'x': 2, 'y': 4}}], 'position': {'x': 6, 'y': 10}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 2, 'y': 3}}, {'action': 'off', 'position': {'x': 2, 'y': 4}}], 'position': {'x': 6, 'y': 13}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 2, 'y': 3}}, {'action': 'off', 'position': {'x': 2, 'y': 4}}], 'position': {'x': 5, 'y': 7}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 2, 'y': 3}}, {'action': 'off', 'position': {'x': 2, 'y': 4}}], 'position': {'x': 5, 'y': 10}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 2, 'y': 3}}, {'action': 'off', 'position': {'x': 2, 'y': 4}}], 'position': {'x': 4, 'y': 11}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 2, 'y': 3}}, {'action': 'off', 'position': {'x': 2, 'y': 4}}], 'position': {'x': 3, 'y': 11}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 2, 'y': 3}}, {'action': 'off', 'position': {'x': 2, 'y': 4}}], 'position': {'x': 2, 'y': 6}, 'type': 's'}, {'fields': [{'action': 'off', 'position': {'x': 2, 'y': 3}}, {'action': 'off', 'position': {'x': 2, 'y': 4}}], 'position': {'x': 2, 'y': 13}, 'type': 's'}, {'fields': [{'action': 'on', 'position': {'x': 8, 'y': 11}}], 'position': {'x': 2, 'y': 14}, 'type': 'h'}]}] |
while True:
a, b, c = sorted(map(int, input().split()))
if a == 0 and b == 0 and c == 0:
break
print("right" if a ** 2 + b ** 2 == c ** 2 else "wrong")
| while True:
(a, b, c) = sorted(map(int, input().split()))
if a == 0 and b == 0 and (c == 0):
break
print('right' if a ** 2 + b ** 2 == c ** 2 else 'wrong') |
# EASY
# count each element in array and store in dict{}
# loop through the array check if exist nums[i]+1 in dict{}
class Solution:
def findLHS(self, nums: List[int]) -> int:
n = len(nums)
appear = {}
for i in range(n):
appear[nums[i]] = appear.get(nums[i],0) + 1
result = 0
for k,v in appear.items():
if k+1 in appear:
result = max(result,v+appear[k+1])
return result | class Solution:
def find_lhs(self, nums: List[int]) -> int:
n = len(nums)
appear = {}
for i in range(n):
appear[nums[i]] = appear.get(nums[i], 0) + 1
result = 0
for (k, v) in appear.items():
if k + 1 in appear:
result = max(result, v + appear[k + 1])
return result |
class Clock():
# Set initial Clock state
def __init__(self, hours, minutes):
timeDic = self.calculateMinutes(minutes)
self.minutes = timeDic['minutes']
self.hours = self.calculateHour(hours + timeDic['hours'])
self.time = self.generateTimeString()
# Add minutes to the clock (Can be positive or subtracting)
def add(self, numMinutes=0):
timeDic = self.calculateMinutes(self.minutes + numMinutes)
self.setMinutes(timeDic['minutes'])
hours = self.calculateHour(self.hours + timeDic['hours'])
self.setHours(hours)
self.time = self.generateTimeString()
return self.time
# Calculate Clock Hour in '24' from num of hours (Positive or Negative)
def calculateHour(self, numHours=0):
if numHours >= 0 and numHours < 24:
return numHours
hours = abs(numHours % 24)
return hours
# Caluclate Clock Minutes from num of minutes (Positive or Negative)
# returns a dict of hours and minutes
def calculateMinutes(self, numMinutes=0):
if numMinutes >= 0 and numMinutes < 60:
return { 'hours': 0, 'minutes': numMinutes }
hours = (numMinutes / 60)
minutes = (numMinutes % 60)
if minutes == 60:
minutes = 0
hours = hours + 1
return { 'hours': hours, 'minutes': minutes }
# Generates time string from hours and minutes
def generateTimeString(self):
hourDigit = str(self.hours)
if len(hourDigit) < 2:
hourDigit = '%d%s' % (0, hourDigit)
minuteDigit = str(self.minutes)
if len(minuteDigit) < 2:
minuteDigit = '%d%s' % (0, minuteDigit)
return '%s:%s' % (hourDigit, minuteDigit)
# ToString overide for instance
def __str__(self):
return self.time
# Equality overide for instance
def __eq__(self, other):
return self.time == other.time
# Setter for hours
def setHours(self, hours):
self.hours = hours
# Setter for minutes
def setMinutes(self, minutes):
self.minutes = minutes
| class Clock:
def __init__(self, hours, minutes):
time_dic = self.calculateMinutes(minutes)
self.minutes = timeDic['minutes']
self.hours = self.calculateHour(hours + timeDic['hours'])
self.time = self.generateTimeString()
def add(self, numMinutes=0):
time_dic = self.calculateMinutes(self.minutes + numMinutes)
self.setMinutes(timeDic['minutes'])
hours = self.calculateHour(self.hours + timeDic['hours'])
self.setHours(hours)
self.time = self.generateTimeString()
return self.time
def calculate_hour(self, numHours=0):
if numHours >= 0 and numHours < 24:
return numHours
hours = abs(numHours % 24)
return hours
def calculate_minutes(self, numMinutes=0):
if numMinutes >= 0 and numMinutes < 60:
return {'hours': 0, 'minutes': numMinutes}
hours = numMinutes / 60
minutes = numMinutes % 60
if minutes == 60:
minutes = 0
hours = hours + 1
return {'hours': hours, 'minutes': minutes}
def generate_time_string(self):
hour_digit = str(self.hours)
if len(hourDigit) < 2:
hour_digit = '%d%s' % (0, hourDigit)
minute_digit = str(self.minutes)
if len(minuteDigit) < 2:
minute_digit = '%d%s' % (0, minuteDigit)
return '%s:%s' % (hourDigit, minuteDigit)
def __str__(self):
return self.time
def __eq__(self, other):
return self.time == other.time
def set_hours(self, hours):
self.hours = hours
def set_minutes(self, minutes):
self.minutes = minutes |
class Order:
__slots__ = (
'id',
'order_number',
'customer_name',
'shipping_name',
'order_date',
'order_details_url',
'subtotal',
'shipping_fee',
'tax',
'status',
'retail_bonus',
'order_type',
'customer_url',
'customer_id',
'customer_contact',
'total',
'qv',
'hostess',
'party',
'ship_date',
'line_items',
'shipping_address',
)
class OrderLineItem:
__slots__ = (
'sku',
'name',
'price',
'quantity',
'total',
)
| class Order:
__slots__ = ('id', 'order_number', 'customer_name', 'shipping_name', 'order_date', 'order_details_url', 'subtotal', 'shipping_fee', 'tax', 'status', 'retail_bonus', 'order_type', 'customer_url', 'customer_id', 'customer_contact', 'total', 'qv', 'hostess', 'party', 'ship_date', 'line_items', 'shipping_address')
class Orderlineitem:
__slots__ = ('sku', 'name', 'price', 'quantity', 'total') |
'''
Find the largest continuous sum
'''
def largest_cont_sum(arr):
if len(arr) == 0:
return 0
cur_sum = arr[0]
max_sum = arr[0]
for item in arr[1:]:
cur_sum = max(cur_sum+item, item)
if cur_sum >= max_sum:
max_sum = cur_sum
return max_sum
| """
Find the largest continuous sum
"""
def largest_cont_sum(arr):
if len(arr) == 0:
return 0
cur_sum = arr[0]
max_sum = arr[0]
for item in arr[1:]:
cur_sum = max(cur_sum + item, item)
if cur_sum >= max_sum:
max_sum = cur_sum
return max_sum |
class Solution:
def matrixReshape(self, mat: List[List[int]], newRows: int, newCols: int) -> List[List[int]]:
rows = len(mat)
cols = len(mat[0])
if rows * cols != newRows * newCols:
return mat
newMat = [[0] * newCols for _ in range(newRows)]
for x in range(rows):
for y in range(cols):
num = x * cols + y
newMat[num // newCols][num % newCols] = mat[x][y]
return newMat | class Solution:
def matrix_reshape(self, mat: List[List[int]], newRows: int, newCols: int) -> List[List[int]]:
rows = len(mat)
cols = len(mat[0])
if rows * cols != newRows * newCols:
return mat
new_mat = [[0] * newCols for _ in range(newRows)]
for x in range(rows):
for y in range(cols):
num = x * cols + y
newMat[num // newCols][num % newCols] = mat[x][y]
return newMat |
input = """
c num blocks = 1
c num vars = 180
c minblockids[0] = 1
c maxblockids[0] = 180
p cnf 180 765
43 -70 -94 0
80 70 -20 0
34 -89 37 0
-99 -140 153 0
-30 131 14 0
136 20 17 0
-125 -172 -114 0
19 -13 -126 0
127 -138 -142 0
-127 -84 79 0
-63 -13 50 0
-15 -118 17 0
6 65 -116 0
-30 -167 157 0
-156 -143 -12 0
38 -60 154 0
-121 18 -76 0
142 -152 130 0
177 41 -62 0
-51 180 -105 0
-61 -76 26 0
-177 -180 -110 0
32 42 -144 0
155 119 73 0
95 -39 104 0
111 -56 -167 0
126 82 -111 0
-64 159 -36 0
-28 -79 40 0
157 -130 88 0
172 16 -88 0
100 21 -110 0
93 40 -22 0
-172 -179 28 0
178 36 -104 0
-45 1 -100 0
-55 -1 32 0
178 32 -16 0
-26 22 63 0
-13 -42 73 0
-131 107 -16 0
-61 -98 -91 0
154 -42 -67 0
-161 -87 9 0
-151 27 -77 0
129 121 -122 0
108 -97 -15 0
-6 12 86 0
-108 -171 -57 0
-30 -145 175 0
1 -78 3 0
141 54 -62 0
-69 -119 58 0
-177 142 -59 0
-144 -164 163 0
21 -116 -119 0
106 -69 -129 0
174 34 -2 0
-33 -119 -152 0
88 -45 -142 0
-56 -164 -22 0
-15 82 -132 0
-162 -45 179 0
67 46 -78 0
-11 -170 86 0
-145 111 -21 0
-23 20 -27 0
39 60 53 0
160 -116 -47 0
-160 45 102 0
-113 143 45 0
112 115 -140 0
29 174 -126 0
132 157 -25 0
123 69 -167 0
99 -36 -63 0
-164 29 -43 0
-152 149 -23 0
149 35 173 0
-81 75 -84 0
-161 -142 84 0
-124 -113 -172 0
7 -143 -18 0
90 55 -118 0
179 -103 23 0
-119 -35 161 0
-160 -153 -133 0
114 99 -4 0
-116 -85 122 0
141 72 -71 0
-163 52 -20 0
-112 144 161 0
-173 111 -120 0
-145 -33 -86 0
-31 144 -94 0
-74 94 158 0
-4 107 -119 0
15 -43 -76 0
117 179 -51 0
159 -104 158 0
-160 -117 21 0
-23 97 59 0
-97 143 91 0
8 61 69 0
41 164 160 0
60 -175 -160 0
-27 169 -67 0
-178 33 -69 0
-119 -107 83 0
53 93 -160 0
-45 -155 -153 0
9 167 15 0
-38 127 168 0
-28 -69 -108 0
135 21 -117 0
146 48 41 0
139 -2 104 0
44 -31 176 0
104 -23 -109 0
106 49 123 0
-14 -2 -63 0
-170 -5 -177 0
88 -180 -161 0
175 23 168 0
98 -135 -45 0
79 -161 136 0
-140 123 -129 0
-104 -79 178 0
-158 46 24 0
76 -165 -65 0
-31 82 -29 0
-16 -124 58 0
-11 83 -21 0
43 -33 -121 0
4 133 23 0
-9 -157 72 0
-27 -86 13 0
35 140 54 0
167 64 21 0
-118 -122 97 0
-23 149 126 0
65 128 96 0
-167 -175 -177 0
-53 -116 -92 0
52 139 37 0
-50 -1 -85 0
105 -132 53 0
-119 -8 20 0
-112 100 53 0
-74 45 -39 0
-59 -44 -23 0
-31 146 1 0
23 114 -20 0
39 -25 166 0
54 110 47 0
-43 -9 154 0
116 -123 -109 0
-26 138 -12 0
-169 128 37 0
-147 -119 -105 0
17 -49 -21 0
174 27 18 0
101 -121 -166 0
-99 161 -90 0
9 90 -142 0
158 161 169 0
-38 -9 171 0
-165 87 -48 0
-18 -15 148 0
-48 -130 -57 0
-32 -2 50 0
-171 65 -30 0
12 -30 29 0
-106 -136 -67 0
-98 -61 174 0
29 46 -132 0
177 -116 42 0
-140 176 10 0
-147 105 165 0
57 68 -95 0
56 44 -173 0
-68 9 119 0
-89 69 -172 0
-17 146 15 0
6 149 27 0
-141 -32 -136 0
-111 -67 84 0
-147 -133 -108 0
137 -126 -123 0
175 105 -101 0
-60 177 -98 0
52 -19 -31 0
-61 -123 -91 0
-155 101 62 0
44 119 -109 0
8 138 32 0
166 131 -56 0
-46 -54 -116 0
66 132 100 0
-158 -83 180 0
117 160 69 0
-159 -132 48 0
-21 -59 -123 0
-107 -42 27 0
-9 -50 35 0
-56 96 142 0
143 110 -147 0
75 17 -68 0
22 17 -144 0
-56 152 41 0
-141 163 -108 0
-66 -49 -155 0
-134 8 157 0
-18 49 31 0
-4 -106 146 0
-153 38 -39 0
-99 -61 119 0
-105 156 98 0
-42 -173 178 0
25 -102 -51 0
-180 -85 -6 0
-18 52 129 0
-93 130 -25 0
-149 77 106 0
-157 -180 43 0
-136 -129 -87 0
-121 151 -83 0
79 153 -15 0
-85 13 -116 0
-63 150 74 0
-8 95 -1 0
171 -152 -167 0
-165 176 -17 0
-35 -74 -122 0
160 155 -87 0
32 -73 -106 0
145 -180 -47 0
-39 178 -120 0
-120 35 174 0
112 167 58 0
-42 53 135 0
50 141 54 0
32 -101 154 0
-128 85 -143 0
-90 -53 -144 0
-50 -143 46 0
65 -175 9 0
-4 -3 16 0
-158 103 88 0
-110 142 -27 0
-146 -138 -133 0
151 -71 -129 0
116 24 119 0
-25 -116 138 0
-170 -77 -5 0
111 -154 87 0
47 39 89 0
148 163 -106 0
-156 -38 -168 0
-25 4 165 0
-1 -13 15 0
164 -15 -92 0
-65 -163 19 0
-10 -137 -131 0
46 86 149 0
-30 61 168 0
-75 93 43 0
-89 114 -25 0
-159 163 -9 0
53 73 -148 0
-124 32 -27 0
94 104 -164 0
134 -143 -11 0
-107 -85 61 0
21 55 82 0
5 170 54 0
83 117 34 0
-1 -31 -78 0
54 162 43 0
-171 48 4 0
-157 -45 -135 0
55 -131 127 0
13 76 -173 0
-109 -120 -25 0
19 82 -31 0
27 30 68 0
6 9 72 0
-63 -86 -62 0
97 160 -53 0
129 5 102 0
-178 -116 -19 0
-95 -157 -59 0
171 17 157 0
-178 -61 -98 0
42 -43 81 0
110 -139 -134 0
-158 -146 116 0
18 22 79 0
-161 130 -59 0
68 -133 -9 0
163 30 -177 0
-30 -34 114 0
89 -170 83 0
64 -55 -82 0
-3 121 -145 0
41 -74 87 0
-135 -19 11 0
32 81 31 0
130 -138 31 0
123 -63 39 0
-94 -38 149 0
-168 -125 -35 0
139 -95 -87 0
131 -56 -85 0
168 152 78 0
170 -145 39 0
121 -131 124 0
-124 83 177 0
50 -42 -37 0
-39 -37 158 0
156 107 115 0
171 35 -121 0
74 14 -51 0
-72 -21 -97 0
-44 102 85 0
-174 -46 2 0
-168 -6 -42 0
-75 42 47 0
-16 -112 -146 0
102 -82 79 0
-111 -33 -167 0
-167 -101 130 0
-74 -71 -17 0
110 -117 -88 0
171 92 -80 0
-39 126 -91 0
66 -165 83 0
87 -28 9 0
-128 -84 -15 0
-146 128 -90 0
31 -78 39 0
160 132 79 0
86 -111 -171 0
-138 -175 -128 0
101 46 85 0
-78 1 63 0
40 96 -53 0
68 -123 109 0
-74 79 132 0
-90 20 50 0
-180 97 -53 0
-60 112 143 0
157 -175 -40 0
79 -82 -160 0
-159 142 -9 0
129 -179 131 0
-107 72 34 0
-71 -163 16 0
-131 -64 10 0
-48 150 -30 0
52 -118 155 0
-72 42 -87 0
-135 118 16 0
178 3 -70 0
-28 -3 116 0
95 -60 160 0
73 -162 -39 0
129 -130 163 0
140 53 -130 0
-25 -108 -134 0
169 -4 -60 0
107 -113 55 0
171 -91 179 0
-111 -59 94 0
14 -56 -40 0
-125 -44 172 0
-34 42 -101 0
79 70 -139 0
-53 -106 55 0
17 158 128 0
102 -60 146 0
-134 -56 -176 0
71 153 89 0
-48 -97 -168 0
-15 23 160 0
107 119 93 0
-148 -142 12 0
26 -142 -16 0
10 179 -160 0
63 -179 112 0
-105 -17 -141 0
172 164 55 0
-107 -26 67 0
142 12 -125 0
-18 -148 -92 0
-87 -116 -84 0
-134 12 35 0
-150 142 82 0
-95 -171 -154 0
-72 18 81 0
24 -166 68 0
-146 45 -122 0
-89 -57 -77 0
57 68 -98 0
6 -169 73 0
94 138 -41 0
-41 46 -36 0
104 -161 -149 0
121 13 -92 0
-150 115 2 0
-93 18 136 0
-80 115 81 0
128 -15 39 0
-71 109 -111 0
-94 -147 53 0
-165 116 -54 0
179 -8 -148 0
48 -114 65 0
160 -127 -68 0
40 -88 -59 0
43 -63 15 0
-15 -6 -23 0
-112 140 49 0
78 -102 -93 0
120 -20 -42 0
51 15 -114 0
159 20 -75 0
-85 -3 10 0
-104 54 72 0
132 142 21 0
-151 122 153 0
-20 -81 -59 0
113 -132 -29 0
-113 -58 74 0
-130 88 144 0
91 -84 -2 0
5 -74 -145 0
-106 171 140 0
90 -134 115 0
145 50 -13 0
12 54 24 0
-129 101 -18 0
-60 -126 5 0
-179 -107 100 0
-103 -35 -7 0
34 66 7 0
-128 -23 -11 0
70 -92 23 0
19 166 140 0
-154 87 173 0
77 -103 -70 0
-26 177 86 0
152 72 -141 0
95 -64 -169 0
-147 57 -162 0
21 69 124 0
-157 -5 -68 0
128 11 -66 0
-154 61 92 0
18 -11 -175 0
-119 51 163 0
58 157 176 0
-124 63 -10 0
71 -160 -127 0
26 87 136 0
94 -148 134 0
49 -82 43 0
-164 -87 -167 0
162 -83 -167 0
-66 126 55 0
-88 -92 167 0
64 106 158 0
113 124 -118 0
-84 -91 146 0
160 114 131 0
-57 43 -7 0
160 -38 -65 0
-7 83 129 0
-131 82 -48 0
-79 122 -121 0
-157 54 -176 0
40 44 -56 0
-116 -98 36 0
26 142 -69 0
-20 90 -69 0
-117 -50 -111 0
-17 173 108 0
-96 31 -98 0
-164 30 -151 0
120 139 -50 0
-144 147 56 0
4 91 -39 0
-126 155 105 0
-174 106 -7 0
-169 86 136 0
121 -20 -55 0
-97 -93 104 0
-164 -104 102 0
-8 101 -39 0
-124 -31 -107 0
88 93 -63 0
-28 -84 -108 0
-91 135 155 0
-76 112 35 0
-50 99 56 0
-114 -77 56 0
-76 -99 13 0
-20 16 117 0
-11 1 179 0
-11 -68 133 0
81 155 -17 0
106 110 158 0
123 -137 -78 0
94 -11 -123 0
-137 -174 136 0
-138 154 36 0
19 -72 -78 0
165 14 -2 0
116 -26 119 0
107 79 -10 0
120 82 -158 0
24 55 -139 0
22 -25 102 0
-32 -94 -36 0
-64 150 5 0
-178 60 33 0
166 62 110 0
-77 -138 -11 0
12 -146 101 0
-73 -1 -123 0
15 -154 -150 0
109 -59 115 0
33 139 42 0
174 -177 -13 0
-124 146 125 0
136 1 -173 0
-172 -147 -51 0
142 45 163 0
-150 -177 137 0
52 170 -71 0
-54 -178 -83 0
-129 -51 127 0
-110 -141 -19 0
-155 129 87 0
-153 -116 84 0
101 139 54 0
119 -134 92 0
67 -49 110 0
-2 59 -53 0
75 105 100 0
51 -85 112 0
-41 -22 -120 0
-78 92 48 0
138 102 -108 0
-98 -26 90 0
-132 111 -113 0
-30 -160 170 0
-163 78 58 0
129 24 169 0
112 166 107 0
92 -12 104 0
169 -49 107 0
44 -86 -55 0
-83 -88 4 0
-103 -158 -71 0
37 18 -130 0
-62 -175 51 0
157 -137 -97 0
-72 -141 -96 0
-163 -40 -146 0
32 133 -10 0
-180 28 -102 0
-138 88 -157 0
-139 -179 -80 0
-80 -21 -169 0
15 -168 -10 0
-63 -41 -96 0
29 -95 -118 0
-83 -87 146 0
-119 -62 -135 0
60 -175 -128 0
81 145 73 0
93 -167 112 0
28 -79 -158 0
163 171 -162 0
-74 100 138 0
153 69 -176 0
-153 -174 -65 0
141 -29 165 0
126 158 112 0
-165 92 161 0
-82 125 15 0
15 -170 -71 0
68 89 -118 0
-172 56 45 0
-120 -52 177 0
-129 -127 168 0
-36 49 -147 0
135 -47 -10 0
16 -103 -28 0
52 -64 -87 0
-105 -71 140 0
-9 97 -136 0
95 -85 -93 0
-161 82 -107 0
-118 11 83 0
16 132 -21 0
166 103 -102 0
44 68 -19 0
149 -150 -170 0
8 -93 -6 0
-142 -29 66 0
-47 -85 -112 0
19 123 -2 0
-119 149 -152 0
-144 99 -150 0
-19 152 51 0
118 13 147 0
-73 -25 -15 0
173 -13 -11 0
-126 -98 -35 0
-160 91 60 0
27 -52 45 0
122 -33 -13 0
53 -22 87 0
-78 -44 -89 0
-11 -117 33 0
107 121 -143 0
-166 -66 147 0
140 124 29 0
115 -52 -112 0
-18 94 149 0
-141 142 -144 0
8 -152 56 0
107 40 -110 0
106 110 -144 0
-47 -167 -162 0
15 14 -91 0
27 93 -157 0
146 105 -138 0
154 38 127 0
170 39 -156 0
17 -19 84 0
-170 23 -46 0
36 -91 -81 0
-114 161 -113 0
167 -136 -16 0
-54 -134 -33 0
30 47 -127 0
-10 12 -14 0
-91 141 28 0
-32 -44 -38 0
-144 90 142 0
1 -118 -169 0
-178 -44 -79 0
-115 -70 -109 0
111 -102 93 0
21 -90 83 0
82 -50 154 0
158 -114 -82 0
-96 -174 137 0
-18 -161 -19 0
-24 -2 -136 0
-34 175 167 0
-155 13 -124 0
130 98 -76 0
-61 109 -143 0
-24 149 33 0
148 132 -44 0
-79 17 169 0
-127 158 150 0
162 139 -37 0
-100 66 -65 0
67 -50 78 0
107 -124 59 0
-72 114 -24 0
-172 -52 -118 0
-82 115 42 0
-90 -48 51 0
-80 -45 124 0
-106 -180 46 0
58 -172 129 0
87 105 -52 0
-99 -178 -176 0
-52 -4 113 0
-113 101 -76 0
-51 68 67 0
-10 -68 77 0
128 138 -126 0
10 147 20 0
-47 50 -126 0
-61 -73 -112 0
-77 -46 -138 0
37 -102 -12 0
62 -2 31 0
-165 32 -4 0
-169 -134 149 0
137 -32 33 0
127 49 67 0
-169 -84 -47 0
-43 6 117 0
20 104 54 0
122 141 103 0
-72 -142 -149 0
2 -62 -10 0
-136 -103 -9 0
-173 -44 -24 0
-8 57 169 0
9 -146 -47 0
76 -28 146 0
-149 -115 89 0
94 -157 81 0
176 -106 162 0
12 -2 -123 0
-82 -25 60 0
-123 74 -180 0
-62 -38 -36 0
-87 -99 44 0
-131 -82 122 0
-115 -85 -52 0
163 44 -117 0
63 42 -136 0
4 16 -71 0
-64 42 -142 0
-104 -15 106 0
4 139 -89 0
-70 -42 144 0
86 17 -91 0
7 -29 -21 0
-16 -127 -104 0
154 144 -157 0
-16 -121 -51 0
-124 164 142 0
-145 -39 -165 0
136 91 44 0
100 -33 -3 0
110 167 -47 0
2 -128 -105 0
-76 -142 73 0
55 95 -121 0
62 -12 20 0
20 -34 -14 0
-175 -99 19 0
166 74 175 0
61 -123 100 0
127 92 21 0
1 -38 -3 0
135 107 -38 0
174 12 19 0
176 97 136 0
152 -3 102 0
163 -108 -6 0
15 -47 -56 0
92 164 -105 0
-144 11 46 0
26 113 49 0
141 152 -7 0
-39 16 37 0
-129 -101 -50 0
-42 89 111 0
27 72 -84 0
167 -4 11 0
-154 -178 176 0
138 -149 -73 0
-89 9 -127 0
"""
output = "UNSAT"
| input = '\nc num blocks = 1\nc num vars = 180\nc minblockids[0] = 1\nc maxblockids[0] = 180\np cnf 180 765\n43 -70 -94 0\n80 70 -20 0\n34 -89 37 0\n-99 -140 153 0\n-30 131 14 0\n136 20 17 0\n-125 -172 -114 0\n19 -13 -126 0\n127 -138 -142 0\n-127 -84 79 0\n-63 -13 50 0\n-15 -118 17 0\n6 65 -116 0\n-30 -167 157 0\n-156 -143 -12 0\n38 -60 154 0\n-121 18 -76 0\n142 -152 130 0\n177 41 -62 0\n-51 180 -105 0\n-61 -76 26 0\n-177 -180 -110 0\n32 42 -144 0\n155 119 73 0\n95 -39 104 0\n111 -56 -167 0\n126 82 -111 0\n-64 159 -36 0\n-28 -79 40 0\n157 -130 88 0\n172 16 -88 0\n100 21 -110 0\n93 40 -22 0\n-172 -179 28 0\n178 36 -104 0\n-45 1 -100 0\n-55 -1 32 0\n178 32 -16 0\n-26 22 63 0\n-13 -42 73 0\n-131 107 -16 0\n-61 -98 -91 0\n154 -42 -67 0\n-161 -87 9 0\n-151 27 -77 0\n129 121 -122 0\n108 -97 -15 0\n-6 12 86 0\n-108 -171 -57 0\n-30 -145 175 0\n1 -78 3 0\n141 54 -62 0\n-69 -119 58 0\n-177 142 -59 0\n-144 -164 163 0\n21 -116 -119 0\n106 -69 -129 0\n174 34 -2 0\n-33 -119 -152 0\n88 -45 -142 0\n-56 -164 -22 0\n-15 82 -132 0\n-162 -45 179 0\n67 46 -78 0\n-11 -170 86 0\n-145 111 -21 0\n-23 20 -27 0\n39 60 53 0\n160 -116 -47 0\n-160 45 102 0\n-113 143 45 0\n112 115 -140 0\n29 174 -126 0\n132 157 -25 0\n123 69 -167 0\n99 -36 -63 0\n-164 29 -43 0\n-152 149 -23 0\n149 35 173 0\n-81 75 -84 0\n-161 -142 84 0\n-124 -113 -172 0\n7 -143 -18 0\n90 55 -118 0\n179 -103 23 0\n-119 -35 161 0\n-160 -153 -133 0\n114 99 -4 0\n-116 -85 122 0\n141 72 -71 0\n-163 52 -20 0\n-112 144 161 0\n-173 111 -120 0\n-145 -33 -86 0\n-31 144 -94 0\n-74 94 158 0\n-4 107 -119 0\n15 -43 -76 0\n117 179 -51 0\n159 -104 158 0\n-160 -117 21 0\n-23 97 59 0\n-97 143 91 0\n8 61 69 0\n41 164 160 0\n60 -175 -160 0\n-27 169 -67 0\n-178 33 -69 0\n-119 -107 83 0\n53 93 -160 0\n-45 -155 -153 0\n9 167 15 0\n-38 127 168 0\n-28 -69 -108 0\n135 21 -117 0\n146 48 41 0\n139 -2 104 0\n44 -31 176 0\n104 -23 -109 0\n106 49 123 0\n-14 -2 -63 0\n-170 -5 -177 0\n88 -180 -161 0\n175 23 168 0\n98 -135 -45 0\n79 -161 136 0\n-140 123 -129 0\n-104 -79 178 0\n-158 46 24 0\n76 -165 -65 0\n-31 82 -29 0\n-16 -124 58 0\n-11 83 -21 0\n43 -33 -121 0\n4 133 23 0\n-9 -157 72 0\n-27 -86 13 0\n35 140 54 0\n167 64 21 0\n-118 -122 97 0\n-23 149 126 0\n65 128 96 0\n-167 -175 -177 0\n-53 -116 -92 0\n52 139 37 0\n-50 -1 -85 0\n105 -132 53 0\n-119 -8 20 0\n-112 100 53 0\n-74 45 -39 0\n-59 -44 -23 0\n-31 146 1 0\n23 114 -20 0\n39 -25 166 0\n54 110 47 0\n-43 -9 154 0\n116 -123 -109 0\n-26 138 -12 0\n-169 128 37 0\n-147 -119 -105 0\n17 -49 -21 0\n174 27 18 0\n101 -121 -166 0\n-99 161 -90 0\n9 90 -142 0\n158 161 169 0\n-38 -9 171 0\n-165 87 -48 0\n-18 -15 148 0\n-48 -130 -57 0\n-32 -2 50 0\n-171 65 -30 0\n12 -30 29 0\n-106 -136 -67 0\n-98 -61 174 0\n29 46 -132 0\n177 -116 42 0\n-140 176 10 0\n-147 105 165 0\n57 68 -95 0\n56 44 -173 0\n-68 9 119 0\n-89 69 -172 0\n-17 146 15 0\n6 149 27 0\n-141 -32 -136 0\n-111 -67 84 0\n-147 -133 -108 0\n137 -126 -123 0\n175 105 -101 0\n-60 177 -98 0\n52 -19 -31 0\n-61 -123 -91 0\n-155 101 62 0\n44 119 -109 0\n8 138 32 0\n166 131 -56 0\n-46 -54 -116 0\n66 132 100 0\n-158 -83 180 0\n117 160 69 0\n-159 -132 48 0\n-21 -59 -123 0\n-107 -42 27 0\n-9 -50 35 0\n-56 96 142 0\n143 110 -147 0\n75 17 -68 0\n22 17 -144 0\n-56 152 41 0\n-141 163 -108 0\n-66 -49 -155 0\n-134 8 157 0\n-18 49 31 0\n-4 -106 146 0\n-153 38 -39 0\n-99 -61 119 0\n-105 156 98 0\n-42 -173 178 0\n25 -102 -51 0\n-180 -85 -6 0\n-18 52 129 0\n-93 130 -25 0\n-149 77 106 0\n-157 -180 43 0\n-136 -129 -87 0\n-121 151 -83 0\n79 153 -15 0\n-85 13 -116 0\n-63 150 74 0\n-8 95 -1 0\n171 -152 -167 0\n-165 176 -17 0\n-35 -74 -122 0\n160 155 -87 0\n32 -73 -106 0\n145 -180 -47 0\n-39 178 -120 0\n-120 35 174 0\n112 167 58 0\n-42 53 135 0\n50 141 54 0\n32 -101 154 0\n-128 85 -143 0\n-90 -53 -144 0\n-50 -143 46 0\n65 -175 9 0\n-4 -3 16 0\n-158 103 88 0\n-110 142 -27 0\n-146 -138 -133 0\n151 -71 -129 0\n116 24 119 0\n-25 -116 138 0\n-170 -77 -5 0\n111 -154 87 0\n47 39 89 0\n148 163 -106 0\n-156 -38 -168 0\n-25 4 165 0\n-1 -13 15 0\n164 -15 -92 0\n-65 -163 19 0\n-10 -137 -131 0\n46 86 149 0\n-30 61 168 0\n-75 93 43 0\n-89 114 -25 0\n-159 163 -9 0\n53 73 -148 0\n-124 32 -27 0\n94 104 -164 0\n134 -143 -11 0\n-107 -85 61 0\n21 55 82 0\n5 170 54 0\n83 117 34 0\n-1 -31 -78 0\n54 162 43 0\n-171 48 4 0\n-157 -45 -135 0\n55 -131 127 0\n13 76 -173 0\n-109 -120 -25 0\n19 82 -31 0\n27 30 68 0\n6 9 72 0\n-63 -86 -62 0\n97 160 -53 0\n129 5 102 0\n-178 -116 -19 0\n-95 -157 -59 0\n171 17 157 0\n-178 -61 -98 0\n42 -43 81 0\n110 -139 -134 0\n-158 -146 116 0\n18 22 79 0\n-161 130 -59 0\n68 -133 -9 0\n163 30 -177 0\n-30 -34 114 0\n89 -170 83 0\n64 -55 -82 0\n-3 121 -145 0\n41 -74 87 0\n-135 -19 11 0\n32 81 31 0\n130 -138 31 0\n123 -63 39 0\n-94 -38 149 0\n-168 -125 -35 0\n139 -95 -87 0\n131 -56 -85 0\n168 152 78 0\n170 -145 39 0\n121 -131 124 0\n-124 83 177 0\n50 -42 -37 0\n-39 -37 158 0\n156 107 115 0\n171 35 -121 0\n74 14 -51 0\n-72 -21 -97 0\n-44 102 85 0\n-174 -46 2 0\n-168 -6 -42 0\n-75 42 47 0\n-16 -112 -146 0\n102 -82 79 0\n-111 -33 -167 0\n-167 -101 130 0\n-74 -71 -17 0\n110 -117 -88 0\n171 92 -80 0\n-39 126 -91 0\n66 -165 83 0\n87 -28 9 0\n-128 -84 -15 0\n-146 128 -90 0\n31 -78 39 0\n160 132 79 0\n86 -111 -171 0\n-138 -175 -128 0\n101 46 85 0\n-78 1 63 0\n40 96 -53 0\n68 -123 109 0\n-74 79 132 0\n-90 20 50 0\n-180 97 -53 0\n-60 112 143 0\n157 -175 -40 0\n79 -82 -160 0\n-159 142 -9 0\n129 -179 131 0\n-107 72 34 0\n-71 -163 16 0\n-131 -64 10 0\n-48 150 -30 0\n52 -118 155 0\n-72 42 -87 0\n-135 118 16 0\n178 3 -70 0\n-28 -3 116 0\n95 -60 160 0\n73 -162 -39 0\n129 -130 163 0\n140 53 -130 0\n-25 -108 -134 0\n169 -4 -60 0\n107 -113 55 0\n171 -91 179 0\n-111 -59 94 0\n14 -56 -40 0\n-125 -44 172 0\n-34 42 -101 0\n79 70 -139 0\n-53 -106 55 0\n17 158 128 0\n102 -60 146 0\n-134 -56 -176 0\n71 153 89 0\n-48 -97 -168 0\n-15 23 160 0\n107 119 93 0\n-148 -142 12 0\n26 -142 -16 0\n10 179 -160 0\n63 -179 112 0\n-105 -17 -141 0\n172 164 55 0\n-107 -26 67 0\n142 12 -125 0\n-18 -148 -92 0\n-87 -116 -84 0\n-134 12 35 0\n-150 142 82 0\n-95 -171 -154 0\n-72 18 81 0\n24 -166 68 0\n-146 45 -122 0\n-89 -57 -77 0\n57 68 -98 0\n6 -169 73 0\n94 138 -41 0\n-41 46 -36 0\n104 -161 -149 0\n121 13 -92 0\n-150 115 2 0\n-93 18 136 0\n-80 115 81 0\n128 -15 39 0\n-71 109 -111 0\n-94 -147 53 0\n-165 116 -54 0\n179 -8 -148 0\n48 -114 65 0\n160 -127 -68 0\n40 -88 -59 0\n43 -63 15 0\n-15 -6 -23 0\n-112 140 49 0\n78 -102 -93 0\n120 -20 -42 0\n51 15 -114 0\n159 20 -75 0\n-85 -3 10 0\n-104 54 72 0\n132 142 21 0\n-151 122 153 0\n-20 -81 -59 0\n113 -132 -29 0\n-113 -58 74 0\n-130 88 144 0\n91 -84 -2 0\n5 -74 -145 0\n-106 171 140 0\n90 -134 115 0\n145 50 -13 0\n12 54 24 0\n-129 101 -18 0\n-60 -126 5 0\n-179 -107 100 0\n-103 -35 -7 0\n34 66 7 0\n-128 -23 -11 0\n70 -92 23 0\n19 166 140 0\n-154 87 173 0\n77 -103 -70 0\n-26 177 86 0\n152 72 -141 0\n95 -64 -169 0\n-147 57 -162 0\n21 69 124 0\n-157 -5 -68 0\n128 11 -66 0\n-154 61 92 0\n18 -11 -175 0\n-119 51 163 0\n58 157 176 0\n-124 63 -10 0\n71 -160 -127 0\n26 87 136 0\n94 -148 134 0\n49 -82 43 0\n-164 -87 -167 0\n162 -83 -167 0\n-66 126 55 0\n-88 -92 167 0\n64 106 158 0\n113 124 -118 0\n-84 -91 146 0\n160 114 131 0\n-57 43 -7 0\n160 -38 -65 0\n-7 83 129 0\n-131 82 -48 0\n-79 122 -121 0\n-157 54 -176 0\n40 44 -56 0\n-116 -98 36 0\n26 142 -69 0\n-20 90 -69 0\n-117 -50 -111 0\n-17 173 108 0\n-96 31 -98 0\n-164 30 -151 0\n120 139 -50 0\n-144 147 56 0\n4 91 -39 0\n-126 155 105 0\n-174 106 -7 0\n-169 86 136 0\n121 -20 -55 0\n-97 -93 104 0\n-164 -104 102 0\n-8 101 -39 0\n-124 -31 -107 0\n88 93 -63 0\n-28 -84 -108 0\n-91 135 155 0\n-76 112 35 0\n-50 99 56 0\n-114 -77 56 0\n-76 -99 13 0\n-20 16 117 0\n-11 1 179 0\n-11 -68 133 0\n81 155 -17 0\n106 110 158 0\n123 -137 -78 0\n94 -11 -123 0\n-137 -174 136 0\n-138 154 36 0\n19 -72 -78 0\n165 14 -2 0\n116 -26 119 0\n107 79 -10 0\n120 82 -158 0\n24 55 -139 0\n22 -25 102 0\n-32 -94 -36 0\n-64 150 5 0\n-178 60 33 0\n166 62 110 0\n-77 -138 -11 0\n12 -146 101 0\n-73 -1 -123 0\n15 -154 -150 0\n109 -59 115 0\n33 139 42 0\n174 -177 -13 0\n-124 146 125 0\n136 1 -173 0\n-172 -147 -51 0\n142 45 163 0\n-150 -177 137 0\n52 170 -71 0\n-54 -178 -83 0\n-129 -51 127 0\n-110 -141 -19 0\n-155 129 87 0\n-153 -116 84 0\n101 139 54 0\n119 -134 92 0\n67 -49 110 0\n-2 59 -53 0\n75 105 100 0\n51 -85 112 0\n-41 -22 -120 0\n-78 92 48 0\n138 102 -108 0\n-98 -26 90 0\n-132 111 -113 0\n-30 -160 170 0\n-163 78 58 0\n129 24 169 0\n112 166 107 0\n92 -12 104 0\n169 -49 107 0\n44 -86 -55 0\n-83 -88 4 0\n-103 -158 -71 0\n37 18 -130 0\n-62 -175 51 0\n157 -137 -97 0\n-72 -141 -96 0\n-163 -40 -146 0\n32 133 -10 0\n-180 28 -102 0\n-138 88 -157 0\n-139 -179 -80 0\n-80 -21 -169 0\n15 -168 -10 0\n-63 -41 -96 0\n29 -95 -118 0\n-83 -87 146 0\n-119 -62 -135 0\n60 -175 -128 0\n81 145 73 0\n93 -167 112 0\n28 -79 -158 0\n163 171 -162 0\n-74 100 138 0\n153 69 -176 0\n-153 -174 -65 0\n141 -29 165 0\n126 158 112 0\n-165 92 161 0\n-82 125 15 0\n15 -170 -71 0\n68 89 -118 0\n-172 56 45 0\n-120 -52 177 0\n-129 -127 168 0\n-36 49 -147 0\n135 -47 -10 0\n16 -103 -28 0\n52 -64 -87 0\n-105 -71 140 0\n-9 97 -136 0\n95 -85 -93 0\n-161 82 -107 0\n-118 11 83 0\n16 132 -21 0\n166 103 -102 0\n44 68 -19 0\n149 -150 -170 0\n8 -93 -6 0\n-142 -29 66 0\n-47 -85 -112 0\n19 123 -2 0\n-119 149 -152 0\n-144 99 -150 0\n-19 152 51 0\n118 13 147 0\n-73 -25 -15 0\n173 -13 -11 0\n-126 -98 -35 0\n-160 91 60 0\n27 -52 45 0\n122 -33 -13 0\n53 -22 87 0\n-78 -44 -89 0\n-11 -117 33 0\n107 121 -143 0\n-166 -66 147 0\n140 124 29 0\n115 -52 -112 0\n-18 94 149 0\n-141 142 -144 0\n8 -152 56 0\n107 40 -110 0\n106 110 -144 0\n-47 -167 -162 0\n15 14 -91 0\n27 93 -157 0\n146 105 -138 0\n154 38 127 0\n170 39 -156 0\n17 -19 84 0\n-170 23 -46 0\n36 -91 -81 0\n-114 161 -113 0\n167 -136 -16 0\n-54 -134 -33 0\n30 47 -127 0\n-10 12 -14 0\n-91 141 28 0\n-32 -44 -38 0\n-144 90 142 0\n1 -118 -169 0\n-178 -44 -79 0\n-115 -70 -109 0\n111 -102 93 0\n21 -90 83 0\n82 -50 154 0\n158 -114 -82 0\n-96 -174 137 0\n-18 -161 -19 0\n-24 -2 -136 0\n-34 175 167 0\n-155 13 -124 0\n130 98 -76 0\n-61 109 -143 0\n-24 149 33 0\n148 132 -44 0\n-79 17 169 0\n-127 158 150 0\n162 139 -37 0\n-100 66 -65 0\n67 -50 78 0\n107 -124 59 0\n-72 114 -24 0\n-172 -52 -118 0\n-82 115 42 0\n-90 -48 51 0\n-80 -45 124 0\n-106 -180 46 0\n58 -172 129 0\n87 105 -52 0\n-99 -178 -176 0\n-52 -4 113 0\n-113 101 -76 0\n-51 68 67 0\n-10 -68 77 0\n128 138 -126 0\n10 147 20 0\n-47 50 -126 0\n-61 -73 -112 0\n-77 -46 -138 0\n37 -102 -12 0\n62 -2 31 0\n-165 32 -4 0\n-169 -134 149 0\n137 -32 33 0\n127 49 67 0\n-169 -84 -47 0\n-43 6 117 0\n20 104 54 0\n122 141 103 0\n-72 -142 -149 0\n2 -62 -10 0\n-136 -103 -9 0\n-173 -44 -24 0\n-8 57 169 0\n9 -146 -47 0\n76 -28 146 0\n-149 -115 89 0\n94 -157 81 0\n176 -106 162 0\n12 -2 -123 0\n-82 -25 60 0\n-123 74 -180 0\n-62 -38 -36 0\n-87 -99 44 0\n-131 -82 122 0\n-115 -85 -52 0\n163 44 -117 0\n63 42 -136 0\n4 16 -71 0\n-64 42 -142 0\n-104 -15 106 0\n4 139 -89 0\n-70 -42 144 0\n86 17 -91 0\n7 -29 -21 0\n-16 -127 -104 0\n154 144 -157 0\n-16 -121 -51 0\n-124 164 142 0\n-145 -39 -165 0\n136 91 44 0\n100 -33 -3 0\n110 167 -47 0\n2 -128 -105 0\n-76 -142 73 0\n55 95 -121 0\n62 -12 20 0\n20 -34 -14 0\n-175 -99 19 0\n166 74 175 0\n61 -123 100 0\n127 92 21 0\n1 -38 -3 0\n135 107 -38 0\n174 12 19 0\n176 97 136 0\n152 -3 102 0\n163 -108 -6 0\n15 -47 -56 0\n92 164 -105 0\n-144 11 46 0\n26 113 49 0\n141 152 -7 0\n-39 16 37 0\n-129 -101 -50 0\n-42 89 111 0\n27 72 -84 0\n167 -4 11 0\n-154 -178 176 0\n138 -149 -73 0\n-89 9 -127 0\n'
output = 'UNSAT' |
def multiplication_table(size):
return [[ x * y for y in range(1, size + 1)] for x in range(1, size + 1)]
print(multiplication_table(3)) # [[1,2,3],[2,4,6],[3,6,9]] | def multiplication_table(size):
return [[x * y for y in range(1, size + 1)] for x in range(1, size + 1)]
print(multiplication_table(3)) |
a=5
b=50
if a>=b:
c=a-b
else:
c=a-b
print(c)
| a = 5
b = 50
if a >= b:
c = a - b
else:
c = a - b
print(c) |
# -*- coding: utf-8 -*-
# Put here your production specific settings
ADMINS = [
('Francesca Alberti', 'francydark91@gmail.com'),
]
EMAIL_SUBJECT_PREFIX = '[ALBERTIFRA]' | admins = [('Francesca Alberti', 'francydark91@gmail.com')]
email_subject_prefix = '[ALBERTIFRA]' |
# autocord
# package for simple automation with discord client
#
# m: error
class ApiError(Exception):
pass | class Apierror(Exception):
pass |
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt
copy("src", "out_encodings")
run("""
coverage run utf8.py
coverage annotate utf8.py
""", rundir="out_encodings")
compare("out_encodings", "gold_encodings", "*,cover")
clean("out_encodings")
| copy('src', 'out_encodings')
run('\n coverage run utf8.py\n coverage annotate utf8.py\n ', rundir='out_encodings')
compare('out_encodings', 'gold_encodings', '*,cover')
clean('out_encodings') |
"""
0604. Design Compressed String Iterator
Design and implement a data structure for a compressed string iterator. The given compressed string will be in the form of each letter followed by a positive integer representing the number of this letter existing in the original uncompressed string.
Implement the StringIterator class:
next() Returns the next character if the original string still has uncompressed characters, otherwise returns a white space.
hasNext() Returns true if there is any letter needs to be uncompressed in the original string, otherwise returns false.
Example 1:
Input
["StringIterator", "next", "next", "next", "next", "next", "next", "hasNext", "next", "hasNext"]
[["L1e2t1C1o1d1e1"], [], [], [], [], [], [], [], [], []]
Output
[null, "L", "e", "e", "t", "C", "o", true, "d", true]
Explanation
StringIterator stringIterator = new StringIterator("L1e2t1C1o1d1e1");
stringIterator.next(); // return "L"
stringIterator.next(); // return "e"
stringIterator.next(); // return "e"
stringIterator.next(); // return "t"
stringIterator.next(); // return "C"
stringIterator.next(); // return "o"
stringIterator.hasNext(); // return True
stringIterator.next(); // return "d"
stringIterator.hasNext(); // return True
Constraints:
1 <= compressedString.length <= 1000
compressedString consists of lower-case an upper-case English letters and digits.
The number of a single character repetitions in compressedString is in the range [1, 10^9]
At most 100 calls will be made to next and hasNext.
"""
class StringIterator:
def __init__(self, compressedString: str):
self.tokens = []
for token in re.findall('\D\d+', compressedString):
self.tokens.append((token[0], int(token[1:])))
self.tokens = self.tokens[::-1]
def next(self):
if not self.tokens: return ' '
t, n = self.tokens.pop()
if n > 1:
self.tokens.append((t, n - 1))
return t
def hasNext(self):
return bool(self.tokens)
# Your StringIterator object will be instantiated and called as such:
# obj = StringIterator(compressedString)
# param_1 = obj.next()
# param_2 = obj.hasNext() | """
0604. Design Compressed String Iterator
Design and implement a data structure for a compressed string iterator. The given compressed string will be in the form of each letter followed by a positive integer representing the number of this letter existing in the original uncompressed string.
Implement the StringIterator class:
next() Returns the next character if the original string still has uncompressed characters, otherwise returns a white space.
hasNext() Returns true if there is any letter needs to be uncompressed in the original string, otherwise returns false.
Example 1:
Input
["StringIterator", "next", "next", "next", "next", "next", "next", "hasNext", "next", "hasNext"]
[["L1e2t1C1o1d1e1"], [], [], [], [], [], [], [], [], []]
Output
[null, "L", "e", "e", "t", "C", "o", true, "d", true]
Explanation
StringIterator stringIterator = new StringIterator("L1e2t1C1o1d1e1");
stringIterator.next(); // return "L"
stringIterator.next(); // return "e"
stringIterator.next(); // return "e"
stringIterator.next(); // return "t"
stringIterator.next(); // return "C"
stringIterator.next(); // return "o"
stringIterator.hasNext(); // return True
stringIterator.next(); // return "d"
stringIterator.hasNext(); // return True
Constraints:
1 <= compressedString.length <= 1000
compressedString consists of lower-case an upper-case English letters and digits.
The number of a single character repetitions in compressedString is in the range [1, 10^9]
At most 100 calls will be made to next and hasNext.
"""
class Stringiterator:
def __init__(self, compressedString: str):
self.tokens = []
for token in re.findall('\\D\\d+', compressedString):
self.tokens.append((token[0], int(token[1:])))
self.tokens = self.tokens[::-1]
def next(self):
if not self.tokens:
return ' '
(t, n) = self.tokens.pop()
if n > 1:
self.tokens.append((t, n - 1))
return t
def has_next(self):
return bool(self.tokens) |
class HarmonyConfig(object):
def __init__(self, config):
self.json = config
def get_activities(self):
return self._build_kv_menu('activity')
def get_devices(self):
return self._build_kv_menu('device')
def _build_kv_menu(self, key):
menu = {}
for d in self.json[key]:
menu.update({int(d['id']): d['label']})
return menu | class Harmonyconfig(object):
def __init__(self, config):
self.json = config
def get_activities(self):
return self._build_kv_menu('activity')
def get_devices(self):
return self._build_kv_menu('device')
def _build_kv_menu(self, key):
menu = {}
for d in self.json[key]:
menu.update({int(d['id']): d['label']})
return menu |
# Copyright 2018 Databricks, Inc.
VERSION = "1.12.1.dev0"
| version = '1.12.1.dev0' |
#!/usr/bin/env python
#
# Copyright (c) 2018 10X Genomics, Inc. All rights reserved.
#
__MRO__ = """
stage CHOOSE_DIMENSION_REDUCTION(
in bool chemistry_batch_correction,
out bool disable_run_pca,
out bool disable_correct_chemistry_batch,
src py "stages/analyzer/choose_dimension_reduction",
)
"""
def main(args, outs):
if args.chemistry_batch_correction is None or args.chemistry_batch_correction is False:
outs.disable_run_pca = False
outs.disable_correct_chemistry_batch = True
else:
outs.disable_run_pca = True
outs.disable_correct_chemistry_batch = False
| __mro__ = '\nstage CHOOSE_DIMENSION_REDUCTION(\n in bool chemistry_batch_correction,\n out bool disable_run_pca,\n out bool disable_correct_chemistry_batch,\n src py "stages/analyzer/choose_dimension_reduction",\n)\n'
def main(args, outs):
if args.chemistry_batch_correction is None or args.chemistry_batch_correction is False:
outs.disable_run_pca = False
outs.disable_correct_chemistry_batch = True
else:
outs.disable_run_pca = True
outs.disable_correct_chemistry_batch = False |
'''https://leetcode.com/problems/longest-common-subsequence/
1143. Longest Common Subsequence
Medium
4663
55
Add to List
Share
Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0.
A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.
For example, "ace" is a subsequence of "abcde".
A common subsequence of two strings is a subsequence that is common to both strings.
Example 1:
Input: text1 = "abcde", text2 = "ace"
Output: 3
Explanation: The longest common subsequence is "ace" and its length is 3.
Example 2:
Input: text1 = "abc", text2 = "abc"
Output: 3
Explanation: The longest common subsequence is "abc" and its length is 3.
Example 3:
Input: text1 = "abc", text2 = "def"
Output: 0
Explanation: There is no such common subsequence, so the result is 0.
Constraints:
1 <= text1.length, text2.length <= 1000
text1 and text2 consist of only lowercase English characters.'''
# Time: O(m * n)
# Space: O(min(m, n))
class Solution(object):
def longestCommonSubsequence(self, text1, text2):
"""
:type text1: str
:type text2: str
:rtype: int
"""
if len(text1) < len(text2):
return self.longestCommonSubsequence(text2, text1)
dp = [[0 for _ in range(len(text2)+1)] for _ in range(2)]
for i in range(1, len(text1)+1):
for j in range(1, len(text2)+1):
dp[i % 2][j] = dp[(i-1) % 2][j-1]+1 if text1[i-1] == text2[j-1] \
else max(dp[(i-1) % 2][j], dp[i % 2][j-1])
return dp[len(text1) % 2][len(text2)]
| """https://leetcode.com/problems/longest-common-subsequence/
1143. Longest Common Subsequence
Medium
4663
55
Add to List
Share
Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0.
A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.
For example, "ace" is a subsequence of "abcde".
A common subsequence of two strings is a subsequence that is common to both strings.
Example 1:
Input: text1 = "abcde", text2 = "ace"
Output: 3
Explanation: The longest common subsequence is "ace" and its length is 3.
Example 2:
Input: text1 = "abc", text2 = "abc"
Output: 3
Explanation: The longest common subsequence is "abc" and its length is 3.
Example 3:
Input: text1 = "abc", text2 = "def"
Output: 0
Explanation: There is no such common subsequence, so the result is 0.
Constraints:
1 <= text1.length, text2.length <= 1000
text1 and text2 consist of only lowercase English characters."""
class Solution(object):
def longest_common_subsequence(self, text1, text2):
"""
:type text1: str
:type text2: str
:rtype: int
"""
if len(text1) < len(text2):
return self.longestCommonSubsequence(text2, text1)
dp = [[0 for _ in range(len(text2) + 1)] for _ in range(2)]
for i in range(1, len(text1) + 1):
for j in range(1, len(text2) + 1):
dp[i % 2][j] = dp[(i - 1) % 2][j - 1] + 1 if text1[i - 1] == text2[j - 1] else max(dp[(i - 1) % 2][j], dp[i % 2][j - 1])
return dp[len(text1) % 2][len(text2)] |
# Copyright 2021 BenchSci Analytics Inc.
# Copyright 2021 Nate Gay
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"rules_kustomize"
load("//:kustomization.bzl", _kustomization = "kustomization")
load("//:kustomize_image.bzl", _kustomize_image = "kustomize_image")
kustomization = _kustomization
kustomize_image = _kustomize_image
| """rules_kustomize"""
load('//:kustomization.bzl', _kustomization='kustomization')
load('//:kustomize_image.bzl', _kustomize_image='kustomize_image')
kustomization = _kustomization
kustomize_image = _kustomize_image |
class Program:
language = 'Python'
def say_hello():
print(f'Hello from {Program.language}')
p = Program()
print(type(p))
print(p.__dict__)
print(Program.__dict__)
print(p.__class__)
# BEST PRACTICES
print(isinstance(p, Program))
| class Program:
language = 'Python'
def say_hello():
print(f'Hello from {Program.language}')
p = program()
print(type(p))
print(p.__dict__)
print(Program.__dict__)
print(p.__class__)
print(isinstance(p, Program)) |
def assert_status_with_message(status_code=200, response=None, message=None):
"""
Check to see if a message is contained within a response.
:param status_code: Status code that defaults to 200
:type status_code: int
:param response: Flask response
:type response: str
:param message: String to check for
:type message: str
:return: None
"""
assert response.status_code == status_code
assert message in str(response.data)
| def assert_status_with_message(status_code=200, response=None, message=None):
"""
Check to see if a message is contained within a response.
:param status_code: Status code that defaults to 200
:type status_code: int
:param response: Flask response
:type response: str
:param message: String to check for
:type message: str
:return: None
"""
assert response.status_code == status_code
assert message in str(response.data) |
class TreeLeaf( object ):
"""Base class for Tree Leaf objects.
Supports a single parent.
Cannot have children.
"""
def __init__( self ):
"""Creates a tree leaf object.
"""
super( TreeLeaf, self ).__init__()
self._parent = None
@property
def parent( self ):
"""The current parent of the node or None
if there isn't one.
This is an @property decorated method which allows
retrieval and assignment of the scale value.
"""
if self._parent != None:
return self._parent()
return None
def predecessors( self ):
"""Returns successive parents of the node.
Generator function that allows iteration
up the tree.
"""
parent = self.parent
while parent != None:
yield parent
parent = parent.parent
| class Treeleaf(object):
"""Base class for Tree Leaf objects.
Supports a single parent.
Cannot have children.
"""
def __init__(self):
"""Creates a tree leaf object.
"""
super(TreeLeaf, self).__init__()
self._parent = None
@property
def parent(self):
"""The current parent of the node or None
if there isn't one.
This is an @property decorated method which allows
retrieval and assignment of the scale value.
"""
if self._parent != None:
return self._parent()
return None
def predecessors(self):
"""Returns successive parents of the node.
Generator function that allows iteration
up the tree.
"""
parent = self.parent
while parent != None:
yield parent
parent = parent.parent |
def roman_to_int(s):
s = s.upper()
try:
rom_val = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
int_val = 0
for i in range(len(s)):
if i > 0 and rom_val[s[i]] > rom_val[s[i - 1]]:
int_val += rom_val[s[i]] - 2 * rom_val[s[i - 1]]
else:
int_val += rom_val[s[i]]
return int_val
except KeyError:
pass
return None | def roman_to_int(s):
s = s.upper()
try:
rom_val = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
int_val = 0
for i in range(len(s)):
if i > 0 and rom_val[s[i]] > rom_val[s[i - 1]]:
int_val += rom_val[s[i]] - 2 * rom_val[s[i - 1]]
else:
int_val += rom_val[s[i]]
return int_val
except KeyError:
pass
return None |
#!/usr/bin/env python3
"""
This module containes general-purpose chemical data (aka tables).
Sources:
1. www.ccdc.cam.ac.uk/Lists/ResourceFileList/Elemental_Radii.xlsx, (access
date: 13 Oct 2015)
2. C. W. Yong, 'DL_FIELD - A force field and model development tool for
DL_POLY', R. Blake, Ed., CSE Frontier, STFC Computational Science and
Engineering, Daresbury Laboratory, UK, p38-40 (2010)
3. https://www.ccdc.cam.ac.uk/support-and-resources/ccdcresources/
Elemental_Radii.xlsx (access date: 26 Jul 2017)
Note:
Added atomic mass, atomic van der Waals radius and covalent radius, that equals
1, for a dummy atom `X`. This is for the shape descriptors calculations to use
with functions for molecular shape descriptors that require mass.
"""
# Atomic mass dictionary (in upper case!)
atomic_mass = {
'AL': 26.982,
'SB': 121.76,
'AR': 39.948,
'AS': 74.922,
'BA': 137.327,
'BE': 9.012,
'BI': 208.98,
'B': 10.811,
'BR': 79.904,
'CD': 112.411,
'CS': 132.905,
'CA': 40.078,
'C': 12.011,
'CE': 140.116,
'CL': 35.453,
'CR': 51.996,
'CO': 58.933,
'CU': 63.546,
'DY': 162.5,
'ER': 167.26,
'EU': 151.964,
'F': 18.998,
'GD': 157.25,
'GA': 69.723,
'GE': 72.61,
'AU': 196.967,
'HF': 178.49,
'HE': 4.003,
'HO': 164.93,
'H': 1.008,
'IN': 114.818,
'I': 126.904,
'IR': 192.217,
'FE': 55.845,
'KR': 83.8,
'LA': 138.906,
'PB': 207.2,
'LI': 6.941,
'LU': 174.967,
'MG': 24.305,
'MN': 54.938,
'HG': 200.59,
'MO': 95.94,
'ND': 144.24,
'NE': 20.18,
'NI': 58.693,
'NB': 92.906,
'N': 14.007,
'OS': 190.23,
'O': 15.999,
'PD': 106.42,
'P': 30.974,
'PT': 195.078,
'K': 39.098,
'PR': 140.908,
'PA': 231.036,
'RE': 186.207,
'RH': 102.906,
'RB': 85.468,
'RU': 101.07,
'SM': 150.36,
'SC': 44.956,
'SE': 78.96,
'SI': 28.086,
'AG': 107.868,
'NA': 22.991,
'SR': 87.62,
'S': 32.066,
'TA': 180.948,
'TE': 127.6,
'TB': 158.925,
'TL': 204.383,
'TH': 232.038,
'TM': 168.934,
'SN': 118.71,
'TI': 47.867,
'W': 183.84,
'U': 238.029,
'V': 50.942,
'XE': 131.29,
'YB': 173.04,
'Y': 88.906,
'ZN': 65.39,
'ZR': 91.224,
'X': 1,
}
# Atomic vdW radii dictionary (in upper case!)
atomic_vdw_radius = {
'AL': 2,
'SB': 2,
'AR': 1.88,
'AS': 1.85,
'BA': 2,
'BE': 2,
'BI': 2,
'B': 2,
'BR': 1.85,
'CD': 1.58,
'CS': 2,
'CA': 2,
'C': 1.7,
'CE': 2,
'CL': 1.75,
'CR': 2,
'CO': 2,
'CU': 1.4,
'DY': 2,
'ER': 2,
'EU': 2,
'F': 1.47,
'GD': 2,
'GA': 1.87,
'GE': 2,
'AU': 1.66,
'HF': 2,
'HE': 1.4,
'HO': 2,
'H': 1.09,
'IN': 1.93,
'I': 1.98,
'IR': 2,
'FE': 2,
'KR': 2.02,
'LA': 2,
'PB': 2.02,
'LI': 1.82,
'LU': 2,
'MG': 1.73,
'MN': 2,
'HG': 1.55,
'MO': 2,
'ND': 2,
'NE': 1.54,
'NI': 1.63,
'NB': 2,
'N': 1.55,
'OS': 2,
'O': 1.52,
'PD': 1.63,
'P': 1.8,
'PT': 1.72,
'K': 2.75,
'PR': 2,
'PA': 2,
'RE': 2,
'RH': 2,
'RB': 2,
'RU': 2,
'SM': 2,
'SC': 2,
'SE': 1.9,
'SI': 2.1,
'AG': 1.72,
'NA': 2.27,
'SR': 2,
'S': 1.8,
'TA': 2,
'TE': 2.06,
'TB': 2,
'TL': 1.96,
'TH': 2,
'TM': 2,
'SN': 2.17,
'TI': 2,
'W': 2,
'U': 1.86,
'V': 2,
'XE': 2.16,
'YB': 2,
'Y': 2,
'ZN': 1.29,
'ZR': 2,
'X': 1,
}
# Atomic covalent radii dictionary (in upper case!)
atomic_covalent_radius = {
'AL': 1.21,
'SB': 1.39,
'AR': 1.51,
'AS': 1.21,
'BA': 2.15,
'BE': 0.96,
'BI': 1.48,
'B': 0.83,
'BR': 1.21,
'CD': 1.54,
'CS': 2.44,
'CA': 1.76,
'C': 0.68,
'CE': 2.04,
'CL': 0.99,
'CR': 1.39,
'CO': 1.26,
'CU': 1.32,
'DY': 1.92,
'ER': 1.89,
'EU': 1.98,
'F': 0.64,
'GD': 1.96,
'GA': 1.22,
'GE': 1.17,
'AU': 1.36,
'HF': 1.75,
'HE': 1.5,
'HO': 1.92,
'H': 0.23,
'IN': 1.42,
'I': 1.4,
'IR': 1.41,
'FE': 1.52,
'KR': 1.5,
'LA': 2.07,
'PB': 1.46,
'LI': 1.28,
'LU': 1.87,
'MG': 1.41,
'MN': 1.61,
'HG': 1.32,
'MO': 1.54,
'ND': 2.01,
'NE': 1.5,
'NI': 1.24,
'NB': 1.64,
'N': 0.68,
'OS': 1.44,
'O': 0.68,
'PD': 1.39,
'P': 1.05,
'PT': 1.36,
'K': 2.03,
'PR': 2.03,
'PA': 2,
'RE': 1.51,
'RH': 1.42,
'RB': 2.2,
'RU': 1.46,
'SM': 1.98,
'SC': 1.7,
'SE': 1.22,
'SI': 1.2,
'AG': 1.45,
'NA': 1.66,
'SR': 1.95,
'S': 1.02,
'TA': 1.7,
'TE': 1.47,
'TB': 1.94,
'TL': 1.45,
'TH': 2.06,
'TM': 1.9,
'SN': 1.39,
'TI': 1.6,
'W': 1.62,
'U': 1.96,
'V': 1.53,
'XE': 1.5,
'YB': 1.87,
'Y': 1.9,
'ZN': 1.22,
'ZR': 1.75,
'X': 1,
}
# Atom symbols - atom keys pairs for deciphering OPLS force field
# from dl_field.atom_type file - DL_FIELD 3.5 by C. W. Yong
opls_atom_keys = {
# The list has to be case sensitive.
# The OPLS atom types can overlap in case of noble gasses.
# 'He' - helim, 'HE' or 'he' - hydrogen
# 'Ne'- neon, 'NE' or 'ne' - imine nitrogen
# 'Na' - sodium, 'NA' - nitrogen
# In case of these there still a warning sould be raised
# as 'ne' can be just lower case for 'Ne'.
'Ar': ['AR', 'Ar', 'ar'],
'B': ['B', 'b'],
'Br': ['BR', 'BR-', 'Br', 'br', 'br-'],
'C': [
'CTD', 'CZN', 'C', 'CBO', 'CZB', 'CDS', 'CALK', 'CG', 'CML', 'C5B',
'CTP', 'CTF', 'C5BC', 'CZA', 'CTS', 'CO', 'C5X', 'CQ', 'CP1', 'CDXR',
'CANI', 'CRA', 'C4T', 'CHZ', 'CAO', 'CTA', 'CDX', 'CA5', 'CTJ', 'CZ',
'CO4', 'CTI', 'C5BB', 'CG1', 'C5M', 'CTM', 'CT', 'C5A', 'CN', 'C3M',
'CB', 'CT1', 'C5N', 'CO3', 'CTQ', 'CTH', 'CTU', 'CTE', 'CTC', 'CTG',
'C3T', 'CD', 'CME', 'CT_F', 'CA', 'C56B', 'CT1G', 'C56A', 'CM', 'CTNC',
'CR3', 'ctd', 'czn', 'c', 'cbo', 'czb', 'cds', 'calk', 'cg', 'cml',
'c5b', 'ctp', 'ctf', 'c5bc', 'cza', 'cts', 'co', 'c5x', 'cq', 'cp1',
'cdxr', 'cani', 'cra', 'c4t', 'chz', 'cao', 'cta', 'cdx', 'ca5', 'ctj',
'cz', 'co4', 'cti', 'c5bb', 'cg1', 'c5m', 'ctm', 'ct', 'c5a', 'cn',
'c3m', 'cb', 'ct1', 'c5n', 'co3', 'ctq', 'cth', 'ctu', 'cte', 'ctc',
'ctg', 'c3t', 'cd', 'cme', 'ct_f', 'ca', 'c56b', 'ct1g', 'c56a', 'cm',
'ctnc', 'cr3'
],
'Cl': ['CL', 'CL-', 'Cl', 'cl', 'cl-'],
'F': [
'F', 'FX1', 'FX2', 'FX3', 'FX4', 'FG', 'F-', 'f', 'fx1', 'fx2', 'fx3',
'fx4', 'fg', 'f-'
],
'H': [
'HA', 'HAE', 'HS', 'HT3', 'HC', 'HWS', 'H', 'HNP', 'HAM', 'H_OH', 'HP',
'HT4', 'HG', 'HMET', 'HO', 'HANI', 'HY', 'HCG', 'HE', 'ha', 'hae',
'hs', 'ht3', 'hc', 'hws', 'h', 'hnp', 'ham', 'h_oh', 'hp', 'ht4', 'hg',
'hmet', 'ho', 'hani', 'hy', 'hcg'
],
'He': ['He'],
'I': ['I', 'I-', 'i', 'i-'],
'Kr': ['Kr', 'kr'],
'N': [
'NAP', 'NN', 'NB', 'N5BB', 'NS', 'NOM', 'NTC', 'NP', 'N', 'NTH2',
'NTH', 'NZC', 'NO', 'N5B', 'NO3', 'NZT', 'NZ', 'NI', 'NTH0', 'NA5B',
'NT', 'NO2', 'NBQ', 'NG', 'NE', 'NZA', 'NA', 'NZB', 'NHZ', 'NO2B',
'NEA', 'NA5', 'NE', 'nap', 'nn', 'nb', 'n5bb', 'ns', 'nom', 'ntc',
'np', 'n', 'nth2', 'nth', 'nzc', 'no', 'n5b', 'no3', 'nzt', 'nz', 'ni',
'nth0', 'na5b', 'nt', 'no2', 'nbq', 'ng', 'nza', 'nzb', 'nhz', 'no2b',
'nea', 'na5'
],
'Na': ['Na', 'Na+'],
'Ne': ['Ne'],
'O': [
'OM', 'OAB', 'ONI', 'O2ZP', 'O2Z', 'OHE', 'OES', 'OBS', 'OT4', 'OWS',
'O3T', 'OT3', 'O4T', 'OAL', 'O2', 'OAS', 'OS', 'ON', 'OVE', 'OZ', 'O',
'OHX', 'OY', 'ONA', 'OA', 'OHP', 'OSP', 'OH', 'om', 'oab', 'oni',
'o2zp', 'o2z', 'ohe', 'oes', 'obs', 'ot4', 'ows', 'o3t', 'ot3', 'o4t',
'oal', 'o2', 'oas', 'os', 'on', 'ove', 'oz', 'o', 'ohx', 'oy', 'ona',
'oa', 'ohp', 'osp', 'oh'
],
'P':
['P', 'P1', 'P2', 'P3', 'P4', 'PR', 'p', 'p1', 'p2', 'p3', 'p4', 'pr'],
'Rn': ['Rn', 'rn'],
'S': [
'S', 'SX6', 'SY', 'SH', 'SA', 'SZ', 'SD', 's', 'sx6', 'sy', 'sh', 'sa',
'sz', 'sd'
],
'Xe': ['Xe', 'xe']
}
| """
This module containes general-purpose chemical data (aka tables).
Sources:
1. www.ccdc.cam.ac.uk/Lists/ResourceFileList/Elemental_Radii.xlsx, (access
date: 13 Oct 2015)
2. C. W. Yong, 'DL_FIELD - A force field and model development tool for
DL_POLY', R. Blake, Ed., CSE Frontier, STFC Computational Science and
Engineering, Daresbury Laboratory, UK, p38-40 (2010)
3. https://www.ccdc.cam.ac.uk/support-and-resources/ccdcresources/
Elemental_Radii.xlsx (access date: 26 Jul 2017)
Note:
Added atomic mass, atomic van der Waals radius and covalent radius, that equals
1, for a dummy atom `X`. This is for the shape descriptors calculations to use
with functions for molecular shape descriptors that require mass.
"""
atomic_mass = {'AL': 26.982, 'SB': 121.76, 'AR': 39.948, 'AS': 74.922, 'BA': 137.327, 'BE': 9.012, 'BI': 208.98, 'B': 10.811, 'BR': 79.904, 'CD': 112.411, 'CS': 132.905, 'CA': 40.078, 'C': 12.011, 'CE': 140.116, 'CL': 35.453, 'CR': 51.996, 'CO': 58.933, 'CU': 63.546, 'DY': 162.5, 'ER': 167.26, 'EU': 151.964, 'F': 18.998, 'GD': 157.25, 'GA': 69.723, 'GE': 72.61, 'AU': 196.967, 'HF': 178.49, 'HE': 4.003, 'HO': 164.93, 'H': 1.008, 'IN': 114.818, 'I': 126.904, 'IR': 192.217, 'FE': 55.845, 'KR': 83.8, 'LA': 138.906, 'PB': 207.2, 'LI': 6.941, 'LU': 174.967, 'MG': 24.305, 'MN': 54.938, 'HG': 200.59, 'MO': 95.94, 'ND': 144.24, 'NE': 20.18, 'NI': 58.693, 'NB': 92.906, 'N': 14.007, 'OS': 190.23, 'O': 15.999, 'PD': 106.42, 'P': 30.974, 'PT': 195.078, 'K': 39.098, 'PR': 140.908, 'PA': 231.036, 'RE': 186.207, 'RH': 102.906, 'RB': 85.468, 'RU': 101.07, 'SM': 150.36, 'SC': 44.956, 'SE': 78.96, 'SI': 28.086, 'AG': 107.868, 'NA': 22.991, 'SR': 87.62, 'S': 32.066, 'TA': 180.948, 'TE': 127.6, 'TB': 158.925, 'TL': 204.383, 'TH': 232.038, 'TM': 168.934, 'SN': 118.71, 'TI': 47.867, 'W': 183.84, 'U': 238.029, 'V': 50.942, 'XE': 131.29, 'YB': 173.04, 'Y': 88.906, 'ZN': 65.39, 'ZR': 91.224, 'X': 1}
atomic_vdw_radius = {'AL': 2, 'SB': 2, 'AR': 1.88, 'AS': 1.85, 'BA': 2, 'BE': 2, 'BI': 2, 'B': 2, 'BR': 1.85, 'CD': 1.58, 'CS': 2, 'CA': 2, 'C': 1.7, 'CE': 2, 'CL': 1.75, 'CR': 2, 'CO': 2, 'CU': 1.4, 'DY': 2, 'ER': 2, 'EU': 2, 'F': 1.47, 'GD': 2, 'GA': 1.87, 'GE': 2, 'AU': 1.66, 'HF': 2, 'HE': 1.4, 'HO': 2, 'H': 1.09, 'IN': 1.93, 'I': 1.98, 'IR': 2, 'FE': 2, 'KR': 2.02, 'LA': 2, 'PB': 2.02, 'LI': 1.82, 'LU': 2, 'MG': 1.73, 'MN': 2, 'HG': 1.55, 'MO': 2, 'ND': 2, 'NE': 1.54, 'NI': 1.63, 'NB': 2, 'N': 1.55, 'OS': 2, 'O': 1.52, 'PD': 1.63, 'P': 1.8, 'PT': 1.72, 'K': 2.75, 'PR': 2, 'PA': 2, 'RE': 2, 'RH': 2, 'RB': 2, 'RU': 2, 'SM': 2, 'SC': 2, 'SE': 1.9, 'SI': 2.1, 'AG': 1.72, 'NA': 2.27, 'SR': 2, 'S': 1.8, 'TA': 2, 'TE': 2.06, 'TB': 2, 'TL': 1.96, 'TH': 2, 'TM': 2, 'SN': 2.17, 'TI': 2, 'W': 2, 'U': 1.86, 'V': 2, 'XE': 2.16, 'YB': 2, 'Y': 2, 'ZN': 1.29, 'ZR': 2, 'X': 1}
atomic_covalent_radius = {'AL': 1.21, 'SB': 1.39, 'AR': 1.51, 'AS': 1.21, 'BA': 2.15, 'BE': 0.96, 'BI': 1.48, 'B': 0.83, 'BR': 1.21, 'CD': 1.54, 'CS': 2.44, 'CA': 1.76, 'C': 0.68, 'CE': 2.04, 'CL': 0.99, 'CR': 1.39, 'CO': 1.26, 'CU': 1.32, 'DY': 1.92, 'ER': 1.89, 'EU': 1.98, 'F': 0.64, 'GD': 1.96, 'GA': 1.22, 'GE': 1.17, 'AU': 1.36, 'HF': 1.75, 'HE': 1.5, 'HO': 1.92, 'H': 0.23, 'IN': 1.42, 'I': 1.4, 'IR': 1.41, 'FE': 1.52, 'KR': 1.5, 'LA': 2.07, 'PB': 1.46, 'LI': 1.28, 'LU': 1.87, 'MG': 1.41, 'MN': 1.61, 'HG': 1.32, 'MO': 1.54, 'ND': 2.01, 'NE': 1.5, 'NI': 1.24, 'NB': 1.64, 'N': 0.68, 'OS': 1.44, 'O': 0.68, 'PD': 1.39, 'P': 1.05, 'PT': 1.36, 'K': 2.03, 'PR': 2.03, 'PA': 2, 'RE': 1.51, 'RH': 1.42, 'RB': 2.2, 'RU': 1.46, 'SM': 1.98, 'SC': 1.7, 'SE': 1.22, 'SI': 1.2, 'AG': 1.45, 'NA': 1.66, 'SR': 1.95, 'S': 1.02, 'TA': 1.7, 'TE': 1.47, 'TB': 1.94, 'TL': 1.45, 'TH': 2.06, 'TM': 1.9, 'SN': 1.39, 'TI': 1.6, 'W': 1.62, 'U': 1.96, 'V': 1.53, 'XE': 1.5, 'YB': 1.87, 'Y': 1.9, 'ZN': 1.22, 'ZR': 1.75, 'X': 1}
opls_atom_keys = {'Ar': ['AR', 'Ar', 'ar'], 'B': ['B', 'b'], 'Br': ['BR', 'BR-', 'Br', 'br', 'br-'], 'C': ['CTD', 'CZN', 'C', 'CBO', 'CZB', 'CDS', 'CALK', 'CG', 'CML', 'C5B', 'CTP', 'CTF', 'C5BC', 'CZA', 'CTS', 'CO', 'C5X', 'CQ', 'CP1', 'CDXR', 'CANI', 'CRA', 'C4T', 'CHZ', 'CAO', 'CTA', 'CDX', 'CA5', 'CTJ', 'CZ', 'CO4', 'CTI', 'C5BB', 'CG1', 'C5M', 'CTM', 'CT', 'C5A', 'CN', 'C3M', 'CB', 'CT1', 'C5N', 'CO3', 'CTQ', 'CTH', 'CTU', 'CTE', 'CTC', 'CTG', 'C3T', 'CD', 'CME', 'CT_F', 'CA', 'C56B', 'CT1G', 'C56A', 'CM', 'CTNC', 'CR3', 'ctd', 'czn', 'c', 'cbo', 'czb', 'cds', 'calk', 'cg', 'cml', 'c5b', 'ctp', 'ctf', 'c5bc', 'cza', 'cts', 'co', 'c5x', 'cq', 'cp1', 'cdxr', 'cani', 'cra', 'c4t', 'chz', 'cao', 'cta', 'cdx', 'ca5', 'ctj', 'cz', 'co4', 'cti', 'c5bb', 'cg1', 'c5m', 'ctm', 'ct', 'c5a', 'cn', 'c3m', 'cb', 'ct1', 'c5n', 'co3', 'ctq', 'cth', 'ctu', 'cte', 'ctc', 'ctg', 'c3t', 'cd', 'cme', 'ct_f', 'ca', 'c56b', 'ct1g', 'c56a', 'cm', 'ctnc', 'cr3'], 'Cl': ['CL', 'CL-', 'Cl', 'cl', 'cl-'], 'F': ['F', 'FX1', 'FX2', 'FX3', 'FX4', 'FG', 'F-', 'f', 'fx1', 'fx2', 'fx3', 'fx4', 'fg', 'f-'], 'H': ['HA', 'HAE', 'HS', 'HT3', 'HC', 'HWS', 'H', 'HNP', 'HAM', 'H_OH', 'HP', 'HT4', 'HG', 'HMET', 'HO', 'HANI', 'HY', 'HCG', 'HE', 'ha', 'hae', 'hs', 'ht3', 'hc', 'hws', 'h', 'hnp', 'ham', 'h_oh', 'hp', 'ht4', 'hg', 'hmet', 'ho', 'hani', 'hy', 'hcg'], 'He': ['He'], 'I': ['I', 'I-', 'i', 'i-'], 'Kr': ['Kr', 'kr'], 'N': ['NAP', 'NN', 'NB', 'N5BB', 'NS', 'NOM', 'NTC', 'NP', 'N', 'NTH2', 'NTH', 'NZC', 'NO', 'N5B', 'NO3', 'NZT', 'NZ', 'NI', 'NTH0', 'NA5B', 'NT', 'NO2', 'NBQ', 'NG', 'NE', 'NZA', 'NA', 'NZB', 'NHZ', 'NO2B', 'NEA', 'NA5', 'NE', 'nap', 'nn', 'nb', 'n5bb', 'ns', 'nom', 'ntc', 'np', 'n', 'nth2', 'nth', 'nzc', 'no', 'n5b', 'no3', 'nzt', 'nz', 'ni', 'nth0', 'na5b', 'nt', 'no2', 'nbq', 'ng', 'nza', 'nzb', 'nhz', 'no2b', 'nea', 'na5'], 'Na': ['Na', 'Na+'], 'Ne': ['Ne'], 'O': ['OM', 'OAB', 'ONI', 'O2ZP', 'O2Z', 'OHE', 'OES', 'OBS', 'OT4', 'OWS', 'O3T', 'OT3', 'O4T', 'OAL', 'O2', 'OAS', 'OS', 'ON', 'OVE', 'OZ', 'O', 'OHX', 'OY', 'ONA', 'OA', 'OHP', 'OSP', 'OH', 'om', 'oab', 'oni', 'o2zp', 'o2z', 'ohe', 'oes', 'obs', 'ot4', 'ows', 'o3t', 'ot3', 'o4t', 'oal', 'o2', 'oas', 'os', 'on', 'ove', 'oz', 'o', 'ohx', 'oy', 'ona', 'oa', 'ohp', 'osp', 'oh'], 'P': ['P', 'P1', 'P2', 'P3', 'P4', 'PR', 'p', 'p1', 'p2', 'p3', 'p4', 'pr'], 'Rn': ['Rn', 'rn'], 'S': ['S', 'SX6', 'SY', 'SH', 'SA', 'SZ', 'SD', 's', 'sx6', 'sy', 'sh', 'sa', 'sz', 'sd'], 'Xe': ['Xe', 'xe']} |
class OuterClass(object):
def outer_method(self):
def nested_function():
class InnerClass(object):
class InnermostClass(object):
def innermost_method(self):
print()
InnerClass.InnermostClass().innermost_method()
nested_function()
OuterClass().outer_method()
| class Outerclass(object):
def outer_method(self):
def nested_function():
class Innerclass(object):
class Innermostclass(object):
def innermost_method(self):
print()
InnerClass.InnermostClass().innermost_method()
nested_function()
outer_class().outer_method() |
# -*- coding: utf-8 -*-
#
# Copyright (c) 2015, ParaTools, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# (1) Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# (2) Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# (3) Neither the name of ParaTools, Inc. nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
"""TODO: FIXME: Docs
TAU Commander core software architecture.
TAU Commander follows the `Model-View-Controller (MVC)`_ architectural pattern.
Packages in :py:mod:`taucmdr.model` define models and controllers. The `model` module
declares the model attributes as a dictionary named `ATTRIBUTES` in the form::
<attribute>: {
property: value,
[[property: value], ...]
}
Attribute properties can be anything you wish, including these special properties:
* ``type`` (str): The attribute is of the specified type.
* ``required`` (bool): The attribute must be specified in the data record.
* ``model`` (str): The attribute associates this model with another data model.
* ``collection`` (str): The attribute associates this model with another data model.
* ``via`` (str): The attribute associates with another model "via" the specified attribute.
The `controller` module declares the controller as a subclass of :any:`Controller`. Controller
class objects are not bound to any particular data record and so can be used to create, update,
and delete records. Controller class instances **are** bound to a single data record.
Models may have **associations** and **references**. An association creates a relationship between
an attribute of this model and an attribute of another (a.k.a foreign) model. If the associated
attribute changes then the foreign model will update its associated attribute. A reference indicates
that this model is being referened by one or more attributes of a foreign model. If a record of the
referenced model changes then the referencing model, i.e. the foreign model, will update all referencing
attributes.
Associations, references, and attributes are constructed when :py:mod:`taucmdr.model` is imported.
Examples:
*One-sided relationship*
::
class Pet(Controller):
attributes = {'name': {'type': 'string'}, 'hungry': {'type': 'bool'}}
class Person(Controller):
attributes = {'name': {'type': 'string'}, 'pet': {'model': 'Pet'}}
We've related a Person to a Pet but not a Pet to a Person. That is, we can query a Person
to get information about their Pet, but we can't query a Pet to get information about their Person.
If a Pet record changes then the Person record that referenced the Pet record is notified of the
change. If a Person record changes then nothing happens to Pet. The Pet and Person classes codify
this relationship as:
* Pet.references = set( (Person, 'pet') )
* Pet.associations = {}
* Person.references = set()
* Person.associations = {}
Some example data for this model::
{
'Pet': {1: {'name': 'Fluffy', 'hungry': True}},
'Person': {0: {'name': 'Bob', 'pet': 1}}
}
*One-to-one relationship*
::
class Husband(Controller):
attributes = {'name': {'type': 'string'}, 'wife': {'model': 'Wife'}}
class Wife(Controller):
attributes = {'name': {'type': 'string'}, 'husband': {'model': 'Husband'}}
We've related a Husband to a Wife. The Husband may have only one Wife and the Wife may have
only one Husband. We can query a Husband to get information about their Wife and we can query a
Wife to get information about their Husband. If a Husband/Wife record changes then the Wife/Husband
record that referenced the Husband/Wife record is notified of the change. The Husband and Wife classes
codify this relationship as:
* Husband.references = set( (Wife, 'husband') )
* Husband.associations = {}
* Wife.references = set( (Husband, 'wife') )
* Wife.associations = {}
Example data::
{
'Husband': {2: {'name': 'Filbert', 'wife': 1}},
'Wife': {1: {'name': 'Matilda', 'husband': 2}}
}
*One-to-many relationship*
::
class Brewery(Controller):
attributes = {'address': {'type': 'string'},
'brews': {'collection': 'Beer',
'via': 'origin'}}
class Beer(Controller):
attributes = {'origin': {'model': 'Brewery'},
'color': {'type': 'string'},
'ibu': {'type': 'int'}}
We've related one Brewery to many Beers. A Beer has only one Brewery but a Brewery has zero or
more Beers. The `brews` attribute has a `via` property along with a `collection` property to specify
which attribute of Beer relates Beer to Brewery, i.e. you may want a model to have multiple
one-to-many relationship with another model. The Brewery and Beer classes codify this relationship as:
* Brewery.references = set()
* Brewery.associations = {'brews': (Beer, 'origin')}
* Beer.references = set()
* Beer.associations = {'origin': (Brewery, 'brews')}
Example data::
{
'Brewery': {100: {'address': '4615 Hollins Ferry Rd, Halethorpe, MD 21227',
'brews': [10, 12, 14]}},
'Beer': {10: {'origin': 100, 'color': 'gold', 'ibu': 45},
12: {'origin': 100, 'color': 'dark', 'ibu': 15},
14: {'origin': 100, 'color': 'pale', 'ibu': 30}}
}
*Many-to-many relationship*
::
class Actor(Controller):
attributes = {'home_town': {'type': 'string'},
'appears_in': {'collection': 'Movie',
'via': 'cast'}}
class Movie(Controller):
attributes = {'title': {'type': 'string'},
'cast': {'collection': 'Actor',
'via': 'appears_in'}}
An Actor may appear in many Movies and a Movie may have many Actors. Changing the `cast` of a Movie
notifies Actor and changing the movies an Actor `apppears_in` notifies Movie. This relationship is
codified as:
* Actor.references = set()
* Actor.associations = {'appears_in': (Movies, 'cast')}
* Movie.references = set()
* Movie.associations = {'cast': (Actor, 'appears_in')}
.. _Model-View-Controller (MVC): https://en.wikipedia.org/wiki/Model-view-controller
"""
| """TODO: FIXME: Docs
TAU Commander core software architecture.
TAU Commander follows the `Model-View-Controller (MVC)`_ architectural pattern.
Packages in :py:mod:`taucmdr.model` define models and controllers. The `model` module
declares the model attributes as a dictionary named `ATTRIBUTES` in the form::
<attribute>: {
property: value,
[[property: value], ...]
}
Attribute properties can be anything you wish, including these special properties:
* ``type`` (str): The attribute is of the specified type.
* ``required`` (bool): The attribute must be specified in the data record.
* ``model`` (str): The attribute associates this model with another data model.
* ``collection`` (str): The attribute associates this model with another data model.
* ``via`` (str): The attribute associates with another model "via" the specified attribute.
The `controller` module declares the controller as a subclass of :any:`Controller`. Controller
class objects are not bound to any particular data record and so can be used to create, update,
and delete records. Controller class instances **are** bound to a single data record.
Models may have **associations** and **references**. An association creates a relationship between
an attribute of this model and an attribute of another (a.k.a foreign) model. If the associated
attribute changes then the foreign model will update its associated attribute. A reference indicates
that this model is being referened by one or more attributes of a foreign model. If a record of the
referenced model changes then the referencing model, i.e. the foreign model, will update all referencing
attributes.
Associations, references, and attributes are constructed when :py:mod:`taucmdr.model` is imported.
Examples:
*One-sided relationship*
::
class Pet(Controller):
attributes = {'name': {'type': 'string'}, 'hungry': {'type': 'bool'}}
class Person(Controller):
attributes = {'name': {'type': 'string'}, 'pet': {'model': 'Pet'}}
We've related a Person to a Pet but not a Pet to a Person. That is, we can query a Person
to get information about their Pet, but we can't query a Pet to get information about their Person.
If a Pet record changes then the Person record that referenced the Pet record is notified of the
change. If a Person record changes then nothing happens to Pet. The Pet and Person classes codify
this relationship as:
* Pet.references = set( (Person, 'pet') )
* Pet.associations = {}
* Person.references = set()
* Person.associations = {}
Some example data for this model::
{
'Pet': {1: {'name': 'Fluffy', 'hungry': True}},
'Person': {0: {'name': 'Bob', 'pet': 1}}
}
*One-to-one relationship*
::
class Husband(Controller):
attributes = {'name': {'type': 'string'}, 'wife': {'model': 'Wife'}}
class Wife(Controller):
attributes = {'name': {'type': 'string'}, 'husband': {'model': 'Husband'}}
We've related a Husband to a Wife. The Husband may have only one Wife and the Wife may have
only one Husband. We can query a Husband to get information about their Wife and we can query a
Wife to get information about their Husband. If a Husband/Wife record changes then the Wife/Husband
record that referenced the Husband/Wife record is notified of the change. The Husband and Wife classes
codify this relationship as:
* Husband.references = set( (Wife, 'husband') )
* Husband.associations = {}
* Wife.references = set( (Husband, 'wife') )
* Wife.associations = {}
Example data::
{
'Husband': {2: {'name': 'Filbert', 'wife': 1}},
'Wife': {1: {'name': 'Matilda', 'husband': 2}}
}
*One-to-many relationship*
::
class Brewery(Controller):
attributes = {'address': {'type': 'string'},
'brews': {'collection': 'Beer',
'via': 'origin'}}
class Beer(Controller):
attributes = {'origin': {'model': 'Brewery'},
'color': {'type': 'string'},
'ibu': {'type': 'int'}}
We've related one Brewery to many Beers. A Beer has only one Brewery but a Brewery has zero or
more Beers. The `brews` attribute has a `via` property along with a `collection` property to specify
which attribute of Beer relates Beer to Brewery, i.e. you may want a model to have multiple
one-to-many relationship with another model. The Brewery and Beer classes codify this relationship as:
* Brewery.references = set()
* Brewery.associations = {'brews': (Beer, 'origin')}
* Beer.references = set()
* Beer.associations = {'origin': (Brewery, 'brews')}
Example data::
{
'Brewery': {100: {'address': '4615 Hollins Ferry Rd, Halethorpe, MD 21227',
'brews': [10, 12, 14]}},
'Beer': {10: {'origin': 100, 'color': 'gold', 'ibu': 45},
12: {'origin': 100, 'color': 'dark', 'ibu': 15},
14: {'origin': 100, 'color': 'pale', 'ibu': 30}}
}
*Many-to-many relationship*
::
class Actor(Controller):
attributes = {'home_town': {'type': 'string'},
'appears_in': {'collection': 'Movie',
'via': 'cast'}}
class Movie(Controller):
attributes = {'title': {'type': 'string'},
'cast': {'collection': 'Actor',
'via': 'appears_in'}}
An Actor may appear in many Movies and a Movie may have many Actors. Changing the `cast` of a Movie
notifies Actor and changing the movies an Actor `apppears_in` notifies Movie. This relationship is
codified as:
* Actor.references = set()
* Actor.associations = {'appears_in': (Movies, 'cast')}
* Movie.references = set()
* Movie.associations = {'cast': (Actor, 'appears_in')}
.. _Model-View-Controller (MVC): https://en.wikipedia.org/wiki/Model-view-controller
""" |
# S-box Table
# We have 8 different 4x16 matrices for each S box
#It converts 48 bits to 32 bits
# Each S box will get 6 bits and output will be 4 bits
s_box = [
[[14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7],
[0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8],
[4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0],
[15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13]],
[[15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10],
[3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5],
[0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15],
[13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9]],
[[10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8],
[13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1],
[13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7],
[1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12]],
[[7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15],
[13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9],
[10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4],
[3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14]],
[[2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9],
[14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6],
[4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14],
[11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3]],
[[12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11],
[10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8],
[9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6],
[4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13]],
[[4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1],
[13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6],
[1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2],
[6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12]],
[[13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7],
[1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2],
[7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8],
[2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11]]
]
# Round count: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# Bits shifted:1 1 2 2 2 2 2 2 1 2 2 2 2 2 2 1
# Number of bit shifts
shift_table=[1, 1, 2, 2,
2, 2, 2, 2,
1, 2, 2, 2,
2, 2, 2, 1 ]
# Initial Permutation Table: (input of 64bit block size is pasesed: 64bit -> 64bit)
initial_perm = [58, 50, 42, 34, 26, 18, 10, 2,
60, 52, 44, 36, 28, 20, 12, 4,
62, 54, 46, 38, 30, 22, 14, 6,
64, 56, 48, 40, 32, 24, 16, 8,
57, 49, 41, 33, 25, 17, 9, 1,
59, 51, 43, 35, 27, 19, 11, 3,
61, 53, 45, 37, 29, 21, 13, 5,
63, 55, 47, 39, 31, 23, 15, 7]
# Permuted choice 1: (key is passed: 64bit -> 56bit)
# That is bit position 8, 16, 24, 32, 40, 48, 56 and 64 are discarded from the key.
perm_cho_1= [57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18,
10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36,
63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22,
14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4]
# Permuted choice 2: (key is passed into it after applying
# left shift to both halves: 56bit -> 56bit)
perm_cho_2= [14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10,
23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2,
41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48,
44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32]
# Expansion permutation table
expan_perm=[32, 1, 2, 3, 4, 5,
4, 5, 6, 7, 8, 9,
8, 9, 10, 11, 12, 13,
12, 13, 14, 15, 16, 17,
16, 17, 18, 19, 20, 21,
20, 21, 22, 23, 24, 25,
24, 25, 26, 27, 28, 29,
28, 29, 30, 31, 32, 1]
# Permutation table
perm_table=[16, 7, 20, 21, 29, 12, 28, 17,
1, 15, 23, 26, 5, 18, 31, 10,
2, 8, 24, 14, 32, 27, 3, 9,
19, 13, 30, 6, 22, 11, 4, 25]
# Final Permutaion Table
final_perm = [40, 8, 48, 16, 56, 24, 64, 32,
39, 7, 47, 15, 55, 23, 63, 31,
38, 6, 46, 14, 54, 22, 62, 30,
37, 5, 45, 13, 53, 21, 61, 29,
36, 4, 44, 12, 52, 20, 60, 28,
35, 3, 43, 11, 51, 19, 59, 27,
34, 2, 42, 10, 50, 18, 58, 26,
33, 1, 41, 9, 49, 17, 57, 25 ]
# XOR function
def xor(a,b):
# a and b should be in binary
ans=""
for i in range(len(a)):
if(a[i]==b[i]):
ans=ans+"0"
else:
ans=ans+"1"
return ans
# Hexadecimal to binary conversion
def hexa_to_bin(msg):
mp = {'0' : "0000",
'1' : "0001",
'2' : "0010",
'3' : "0011",
'4' : "0100",
'5' : "0101",
'6' : "0110",
'7' : "0111",
'8' : "1000",
'9' : "1001",
'A' : "1010",
'B' : "1011",
'C' : "1100",
'D' : "1101",
'E' : "1110",
'F' : "1111" }
bin = ""
for i in range(len(msg)):
bin = bin + mp[msg[i]]
return bin
# Binary to hexadecimal conversion
def bin_to_hexa(msg):
mp = {"0000" : '0',
"0001" : '1',
"0010" : '2',
"0011" : '3',
"0100" : '4',
"0101" : '5',
"0110" : '6',
"0111" : '7',
"1000" : '8',
"1001" : '9',
"1010" : 'A',
"1011" : 'B',
"1100" : 'C',
"1101" : 'D',
"1110" : 'E',
"1111" : 'F' }
hex=""
for i in range(0,len(msg),4):
ch=""
ch=ch+msg[i]
ch=ch+msg[i+1]
ch=ch+msg[i+2]
ch=ch+msg[i+3]
hex=hex+mp[ch]
return hex
# Binary to decimal conversion
def bin_to_dec(msg):
decimal,i=0,0
while(msg!=0):
dec=msg%10
decimal=decimal+dec*pow(2, i)
msg=msg//10
i+=1
return decimal
# Decimal to binary conversion
def dec_to_bin(num):
res=bin(num).replace("0b", "")
if(len(res)%4 != 0):
div=len(res) / 4
div=int(div)
counter=(4*(div+1))-len(res)
for i in range(0, counter):
res='0'+res
return res
# shifting the bits towards left by nth shifts
def shift_left(key,nth_shifts):
s=""
for i in range(nth_shifts):
for j in range(1,len(key)):
s=s+key[j]
s=s+key[0]
key=s
s=""
return key
# Step1: It is just rearranging the positions of all bits of plain text
# according to the initial_perm matrix(8x8)
def initial_permutation(plain_text,initial_perm, no_bits):
permutation=""
for i in range(0,no_bits):
permutation=permutation+plain_text[initial_perm[i]-1]
return permutation
# Encryption function is implemented here
def encrypt(msg,key):
print("Encryption")
msg=hexa_to_bin(msg)
msg = initial_permutation(msg, initial_perm, 64)
print("Message after initial permutation: ",bin_to_hexa(msg))
# converting from hexa to binary
key = hexa_to_bin(key)
key = initial_permutation(key, perm_cho_1, 56)
print("The converted 56bit key is: ",key)
# Halving the key
l=key[0:28]
r=key[28:56]
# Halving the message
left = msg[0:32]
right =msg[32:64]
# Key transformation
key_from_pc2_bin=[]
key_from_pc2_hex=[]
for k in range(16):
l=shift_left(l,shift_table[k])
r=shift_left(r,shift_table[k])
combine_key=l+r
# permuted choice 2
round_key=initial_permutation(combine_key,perm_cho_2,48)
key_from_pc2_bin.append(round_key)
key_from_pc2_hex.append(bin_to_hexa(round_key))
# For decryption, just uncomment below two lines
# key_from_pc2_bin=key_from_pc2_bin[::-1]
# key_from_pc2_hex=key_from_pc2_hex[::-1]
# Message transformation
# Encryption
print()
print("Round: Left key part: Right key part: SubKey used:")
for j in range(16):
# Expansion Permutation
right_expand=initial_permutation(right,expan_perm,48)
xor_x=xor(right_expand,key_from_pc2_bin[j])
# calculating row and column from s box
s_box_str=""
for i in range(0,8):
row=bin_to_dec(int(xor_x[i*6]+xor_x[i*6+5]))
col=bin_to_dec(int(xor_x[i*6+1]+xor_x[i*6+2]+xor_x[i*6+3]+xor_x[i*6+4]))
val=s_box[i][row][col]
s_box_str=s_box_str+dec_to_bin(val)
# towards permutation box
s_box_str=initial_permutation(s_box_str,perm_table,32)
# Now again XOR with left part and above
result=xor(left,s_box_str)
left=result
# Swapping
if(j!=15):
left, right=right, left
print(str(j+1).zfill(2)," ",bin_to_hexa(left)," ",bin_to_hexa(right)," ",key_from_pc2_hex[j])
# concatinating both left and right
combine=left+right
cipher_text=initial_permutation(combine,final_perm,64)
return cipher_text
# Padding function
def pad(msg):
if(len(msg)%16!=0):
print("Padding required")
for i in range(abs(16-(len(msg)%16))):
msg=msg+'0'
else:
print("No padding required")
return(msg)
# Main function
print("Enter the message to be encrypted: ")
plain_text=input()
plain_text=pad(plain_text)
print("Message after padding: ", plain_text)
print("Enter the 64bit key for encryption: ")
key=input()
key=pad(key)
print("Key after padding: ",key)
cipher_text=bin_to_hexa(encrypt(plain_text,key))
print("Cipher text is: ",cipher_text)
'''
----------OUTPUT----------
Enter the message to be encrypted:
536ABCD8910FF9
Padding required
Message after padding: 536ABCD8910FF900
Enter the 64bit key for encryption:
74631BBDCA8
Padding required
Key after padding: 74631BBDCA800000
Encryption
Message after initial permutation: 4B5D24715C466E23
The converted 56bit key is: 00111000000100110000101100000001011000001001000111001101
Round: Left key part: Right key part: SubKey used:
01 5C466E23 6E81D6DE A289056D34C0
02 6E81D6DE 8F2C919D 8A34034AB231
03 8F2C919D 7C74DB60 69064C734D28
04 7C74DB60 69DDF400 40D08808191A
05 69DDF400 44AE2868 108972C57034
06 44AE2868 B2467F7F A46803610AE8
07 B2467F7F 458145D1 23270490981F
08 458145D1 488D0D53 4814910716B4
09 488D0D53 62E16561 494060887282
10 62E16561 0A6342EC 80C9B8746225
11 0A6342EC EA0DAA35 942303B208CA
12 EA0DAA35 7669590A 231E0184B313
13 7669590A 5706FABD 4930C4372660
14 5706FABD 29B656BD 10C4D8788942
15 29B656BD 31FA5C5F 54412204E41E
16 6A1A9764 31FA5C5F 16AB20801DC9
Cipher text is: 86760F7ABEE16B24
>>>
'''
'''
For decryption, we have to add just two lines, which server the purpose of
reversing the array, which stores the sub keys for different rounds
For decryption, just we have to reverse the array which stores the sub keys:
key_from_pc2_bin=key_from_pc2_bin[::-1]
key_from_pc2_hex=key_from_pc2_hex[::-1]
'''
'''
----------OUTPUT----------
Enter the message to be decrypted:
86760F7ABEE16B24
No padding required
Message after padding: 86760F7ABEE16B24
Enter the 64bit key for decryption:
74631BBDCA8
Padding required
Key after padding: 74631BBDCA800000
Encryption
Message after initial permutation: 6A1A976431FA5C5F
The converted 56bit key is: 00111000000100110000101100000001011000001001000111001101
Round: Left key part: Right key part: SubKey used:
01 31FA5C5F 29B656BD 16AB20801DC9
02 29B656BD 5706FABD 54412204E41E
03 5706FABD 7669590A 10C4D8788942
04 7669590A EA0DAA35 4930C4372660
05 EA0DAA35 0A6342EC 231E0184B313
06 0A6342EC 62E16561 942303B208CA
07 62E16561 488D0D53 80C9B8746225
08 488D0D53 458145D1 494060887282
09 458145D1 B2467F7F 4814910716B4
10 B2467F7F 44AE2868 23270490981F
11 44AE2868 69DDF400 A46803610AE8
12 69DDF400 7C74DB60 108972C57034
13 7C74DB60 8F2C919D 40D08808191A
14 8F2C919D 6E81D6DE 69064C734D28
15 6E81D6DE 5C466E23 8A34034AB231
16 4B5D2471 5C466E23 A289056D34C0
Plain text is: 536ABCD8910FF900
>>>
'''
'''
Took help from: https://www.geeksforgeeks.org/data-encryption-standard-des-set-1
Thanks for the help !
'''
| s_box = [[[14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7], [0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8], [4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0], [15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13]], [[15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10], [3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5], [0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15], [13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9]], [[10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8], [13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1], [13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7], [1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12]], [[7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15], [13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9], [10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4], [3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14]], [[2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9], [14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6], [4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14], [11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3]], [[12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11], [10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8], [9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6], [4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13]], [[4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1], [13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6], [1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2], [6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12]], [[13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7], [1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2], [7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8], [2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11]]]
shift_table = [1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1]
initial_perm = [58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8, 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7]
perm_cho_1 = [57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4]
perm_cho_2 = [14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32]
expan_perm = [32, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13, 14, 15, 16, 17, 16, 17, 18, 19, 20, 21, 20, 21, 22, 23, 24, 25, 24, 25, 26, 27, 28, 29, 28, 29, 30, 31, 32, 1]
perm_table = [16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10, 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25]
final_perm = [40, 8, 48, 16, 56, 24, 64, 32, 39, 7, 47, 15, 55, 23, 63, 31, 38, 6, 46, 14, 54, 22, 62, 30, 37, 5, 45, 13, 53, 21, 61, 29, 36, 4, 44, 12, 52, 20, 60, 28, 35, 3, 43, 11, 51, 19, 59, 27, 34, 2, 42, 10, 50, 18, 58, 26, 33, 1, 41, 9, 49, 17, 57, 25]
def xor(a, b):
ans = ''
for i in range(len(a)):
if a[i] == b[i]:
ans = ans + '0'
else:
ans = ans + '1'
return ans
def hexa_to_bin(msg):
mp = {'0': '0000', '1': '0001', '2': '0010', '3': '0011', '4': '0100', '5': '0101', '6': '0110', '7': '0111', '8': '1000', '9': '1001', 'A': '1010', 'B': '1011', 'C': '1100', 'D': '1101', 'E': '1110', 'F': '1111'}
bin = ''
for i in range(len(msg)):
bin = bin + mp[msg[i]]
return bin
def bin_to_hexa(msg):
mp = {'0000': '0', '0001': '1', '0010': '2', '0011': '3', '0100': '4', '0101': '5', '0110': '6', '0111': '7', '1000': '8', '1001': '9', '1010': 'A', '1011': 'B', '1100': 'C', '1101': 'D', '1110': 'E', '1111': 'F'}
hex = ''
for i in range(0, len(msg), 4):
ch = ''
ch = ch + msg[i]
ch = ch + msg[i + 1]
ch = ch + msg[i + 2]
ch = ch + msg[i + 3]
hex = hex + mp[ch]
return hex
def bin_to_dec(msg):
(decimal, i) = (0, 0)
while msg != 0:
dec = msg % 10
decimal = decimal + dec * pow(2, i)
msg = msg // 10
i += 1
return decimal
def dec_to_bin(num):
res = bin(num).replace('0b', '')
if len(res) % 4 != 0:
div = len(res) / 4
div = int(div)
counter = 4 * (div + 1) - len(res)
for i in range(0, counter):
res = '0' + res
return res
def shift_left(key, nth_shifts):
s = ''
for i in range(nth_shifts):
for j in range(1, len(key)):
s = s + key[j]
s = s + key[0]
key = s
s = ''
return key
def initial_permutation(plain_text, initial_perm, no_bits):
permutation = ''
for i in range(0, no_bits):
permutation = permutation + plain_text[initial_perm[i] - 1]
return permutation
def encrypt(msg, key):
print('Encryption')
msg = hexa_to_bin(msg)
msg = initial_permutation(msg, initial_perm, 64)
print('Message after initial permutation: ', bin_to_hexa(msg))
key = hexa_to_bin(key)
key = initial_permutation(key, perm_cho_1, 56)
print('The converted 56bit key is: ', key)
l = key[0:28]
r = key[28:56]
left = msg[0:32]
right = msg[32:64]
key_from_pc2_bin = []
key_from_pc2_hex = []
for k in range(16):
l = shift_left(l, shift_table[k])
r = shift_left(r, shift_table[k])
combine_key = l + r
round_key = initial_permutation(combine_key, perm_cho_2, 48)
key_from_pc2_bin.append(round_key)
key_from_pc2_hex.append(bin_to_hexa(round_key))
print()
print('Round: Left key part: Right key part: SubKey used:')
for j in range(16):
right_expand = initial_permutation(right, expan_perm, 48)
xor_x = xor(right_expand, key_from_pc2_bin[j])
s_box_str = ''
for i in range(0, 8):
row = bin_to_dec(int(xor_x[i * 6] + xor_x[i * 6 + 5]))
col = bin_to_dec(int(xor_x[i * 6 + 1] + xor_x[i * 6 + 2] + xor_x[i * 6 + 3] + xor_x[i * 6 + 4]))
val = s_box[i][row][col]
s_box_str = s_box_str + dec_to_bin(val)
s_box_str = initial_permutation(s_box_str, perm_table, 32)
result = xor(left, s_box_str)
left = result
if j != 15:
(left, right) = (right, left)
print(str(j + 1).zfill(2), ' ', bin_to_hexa(left), ' ', bin_to_hexa(right), ' ', key_from_pc2_hex[j])
combine = left + right
cipher_text = initial_permutation(combine, final_perm, 64)
return cipher_text
def pad(msg):
if len(msg) % 16 != 0:
print('Padding required')
for i in range(abs(16 - len(msg) % 16)):
msg = msg + '0'
else:
print('No padding required')
return msg
print('Enter the message to be encrypted: ')
plain_text = input()
plain_text = pad(plain_text)
print('Message after padding: ', plain_text)
print('Enter the 64bit key for encryption: ')
key = input()
key = pad(key)
print('Key after padding: ', key)
cipher_text = bin_to_hexa(encrypt(plain_text, key))
print('Cipher text is: ', cipher_text)
'\n----------OUTPUT----------\nEnter the message to be encrypted: \n536ABCD8910FF9\nPadding required\nMessage after padding: 536ABCD8910FF900\nEnter the 64bit key for encryption: \n74631BBDCA8\nPadding required\nKey after padding: 74631BBDCA800000\nEncryption\nMessage after initial permutation: 4B5D24715C466E23\nThe converted 56bit key is: 00111000000100110000101100000001011000001001000111001101\n\nRound: Left key part: Right key part: SubKey used:\n01 5C466E23 6E81D6DE A289056D34C0\n02 6E81D6DE 8F2C919D 8A34034AB231\n03 8F2C919D 7C74DB60 69064C734D28\n04 7C74DB60 69DDF400 40D08808191A\n05 69DDF400 44AE2868 108972C57034\n06 44AE2868 B2467F7F A46803610AE8\n07 B2467F7F 458145D1 23270490981F\n08 458145D1 488D0D53 4814910716B4\n09 488D0D53 62E16561 494060887282\n10 62E16561 0A6342EC 80C9B8746225\n11 0A6342EC EA0DAA35 942303B208CA\n12 EA0DAA35 7669590A 231E0184B313\n13 7669590A 5706FABD 4930C4372660\n14 5706FABD 29B656BD 10C4D8788942\n15 29B656BD 31FA5C5F 54412204E41E\n16 6A1A9764 31FA5C5F 16AB20801DC9\nCipher text is: 86760F7ABEE16B24\n>>> \n'
'\nFor decryption, we have to add just two lines, which server the purpose of \nreversing the array, which stores the sub keys for different rounds\n\nFor decryption, just we have to reverse the array which stores the sub keys:\nkey_from_pc2_bin=key_from_pc2_bin[::-1]\nkey_from_pc2_hex=key_from_pc2_hex[::-1]\n'
'\n----------OUTPUT----------\nEnter the message to be decrypted: \n86760F7ABEE16B24\nNo padding required\nMessage after padding: 86760F7ABEE16B24\nEnter the 64bit key for decryption: \n74631BBDCA8\nPadding required\nKey after padding: 74631BBDCA800000\nEncryption\nMessage after initial permutation: 6A1A976431FA5C5F\nThe converted 56bit key is: 00111000000100110000101100000001011000001001000111001101\nRound: Left key part: Right key part: SubKey used:\n01 31FA5C5F 29B656BD 16AB20801DC9\n02 29B656BD 5706FABD 54412204E41E\n03 5706FABD 7669590A 10C4D8788942\n04 7669590A EA0DAA35 4930C4372660\n05 EA0DAA35 0A6342EC 231E0184B313\n06 0A6342EC 62E16561 942303B208CA\n07 62E16561 488D0D53 80C9B8746225\n08 488D0D53 458145D1 494060887282\n09 458145D1 B2467F7F 4814910716B4\n10 B2467F7F 44AE2868 23270490981F\n11 44AE2868 69DDF400 A46803610AE8\n12 69DDF400 7C74DB60 108972C57034\n13 7C74DB60 8F2C919D 40D08808191A\n14 8F2C919D 6E81D6DE 69064C734D28\n15 6E81D6DE 5C466E23 8A34034AB231\n16 4B5D2471 5C466E23 A289056D34C0\nPlain text is: 536ABCD8910FF900\n>>> \n'
'\nTook help from: https://www.geeksforgeeks.org/data-encryption-standard-des-set-1\nThanks for the help !\n' |
# Split target image into an MxN grid
def splitImage(image, size):
W, H = image.size[0], image.size[1]
m, n = size
w, h = int(W/n), int(H/m)
imgs = []
for j in range(m):
for i in range(n):
# append cropped image
imgs.append(image.crop((i*w, j*h, (i+1)*w, (j+1)*h)))
return imgs | def split_image(image, size):
(w, h) = (image.size[0], image.size[1])
(m, n) = size
(w, h) = (int(W / n), int(H / m))
imgs = []
for j in range(m):
for i in range(n):
imgs.append(image.crop((i * w, j * h, (i + 1) * w, (j + 1) * h)))
return imgs |
def is_vowel(s: str) -> bool:
if len(s) == 0 or len(s) > 1:
return False
vowel = ["a", "e", "i", "o", "u"]
for item in s:
if item.lower() in vowel:
return True
return False | def is_vowel(s: str) -> bool:
if len(s) == 0 or len(s) > 1:
return False
vowel = ['a', 'e', 'i', 'o', 'u']
for item in s:
if item.lower() in vowel:
return True
return False |
# content of test_sample.py
def func(x):
return x + 2
def test_answer():
assert func(3) == 5
def test_2():
assert func(10) == 12 | def func(x):
return x + 2
def test_answer():
assert func(3) == 5
def test_2():
assert func(10) == 12 |
'''
Created on Aug 7, 2017
@author: duncan
'''
class Subscriber(object):
def __init__(self, subscriber_id, subscriber_email):
self.subscriber_id = subscriber_id
self.subscriber_email = subscriber_email
class Site(object):
def __init__(self, site_id, site_name):
self.site_id = site_id
self.site_name = site_name
class Keyword(object):
def __init__(self, keyword_id, keyword_name):
self.keyword_id = keyword_id
self.keyword_name = keyword_name
class Subscription():
def __init__(self, site, keyword, subscription_group_id=None, subscriber=None, page_limit=1, minimum_alert=1):
'''
Constructor
'''
self.subscriber = subscriber
self.site = site
self.keyword = keyword
self.page_limit = page_limit
self.minimum_alert = minimum_alert
self.subscription_group_id = subscription_group_id
| """
Created on Aug 7, 2017
@author: duncan
"""
class Subscriber(object):
def __init__(self, subscriber_id, subscriber_email):
self.subscriber_id = subscriber_id
self.subscriber_email = subscriber_email
class Site(object):
def __init__(self, site_id, site_name):
self.site_id = site_id
self.site_name = site_name
class Keyword(object):
def __init__(self, keyword_id, keyword_name):
self.keyword_id = keyword_id
self.keyword_name = keyword_name
class Subscription:
def __init__(self, site, keyword, subscription_group_id=None, subscriber=None, page_limit=1, minimum_alert=1):
"""
Constructor
"""
self.subscriber = subscriber
self.site = site
self.keyword = keyword
self.page_limit = page_limit
self.minimum_alert = minimum_alert
self.subscription_group_id = subscription_group_id |
# 2. Use the function to compute the square of all numbers of a given list
def squares(a):
squared = a*a
return squared
li = [1, 2, 3, 4, 5]
lisq=[]
for el in li:
sq = squares(el)
lisq.append(sq)
print(lisq) | def squares(a):
squared = a * a
return squared
li = [1, 2, 3, 4, 5]
lisq = []
for el in li:
sq = squares(el)
lisq.append(sq)
print(lisq) |
# coding: utf-8
__author__ = 'Keita Tomochika'
__version__ = '0.0.1'
__license__ = 'MIT'
| __author__ = 'Keita Tomochika'
__version__ = '0.0.1'
__license__ = 'MIT' |
name = "openjpeg"
version = "2.3.1"
authors = [
"Image and Signal Processing Group, UCL"
]
description = \
"""
OpenJPEG is an open-source JPEG 2000 codec written in C language. It has been developed in order to promote the
use of JPEG 2000, a still-image compression standard from the Joint Photographic Experts Group.
"""
requires = [
"cmake-3+",
"gcc-6+",
"png-1.6+",
"tiff-4+",
"zlib-1.2+"
]
variants = [
["platform-linux"]
]
tools = [
"opj_compress",
"opj_decompress",
"opj_dump"
]
build_system = "cmake"
with scope("config") as config:
config.build_thread_count = "logical_cores"
uuid = "openjpeg-{version}".format(version=str(version))
def commands():
env.PATH.prepend("{root}/bin")
env.LD_LIBRARY_PATH.prepend("{root}/lib")
env.PKG_CONFIG_PATH.prepend("{root}/lib/pkgconfig")
# We know that the version numbers are separated by a ".", so we should safely be able to get the
# number we want through a split.
env.CMAKE_MODULE_PATH.prepend("{root}/lib/openjpeg-" + str(version).split(".")[0] + "." + str(version).split(".")[1])
# Helper environment variables.
env.OPENJPEG_BINARY_PATH.set("{root}/bin")
env.OPENJPEG_INCLUDE_PATH.set("{root}/include")
env.OPENJPEG_LIBRARY_PATH.set("{root}/lib")
| name = 'openjpeg'
version = '2.3.1'
authors = ['Image and Signal Processing Group, UCL']
description = '\n OpenJPEG is an open-source JPEG 2000 codec written in C language. It has been developed in order to promote the\n use of JPEG 2000, a still-image compression standard from the Joint Photographic Experts Group.\n '
requires = ['cmake-3+', 'gcc-6+', 'png-1.6+', 'tiff-4+', 'zlib-1.2+']
variants = [['platform-linux']]
tools = ['opj_compress', 'opj_decompress', 'opj_dump']
build_system = 'cmake'
with scope('config') as config:
config.build_thread_count = 'logical_cores'
uuid = 'openjpeg-{version}'.format(version=str(version))
def commands():
env.PATH.prepend('{root}/bin')
env.LD_LIBRARY_PATH.prepend('{root}/lib')
env.PKG_CONFIG_PATH.prepend('{root}/lib/pkgconfig')
env.CMAKE_MODULE_PATH.prepend('{root}/lib/openjpeg-' + str(version).split('.')[0] + '.' + str(version).split('.')[1])
env.OPENJPEG_BINARY_PATH.set('{root}/bin')
env.OPENJPEG_INCLUDE_PATH.set('{root}/include')
env.OPENJPEG_LIBRARY_PATH.set('{root}/lib') |
# Subject - the one to be observed
# Observers - the one monitoring or observing the subject for changes
class Subject:
def __init__(self):
self.__observers = []
def register(self, observer):
self.__observers.append(observer)
def notifyAll(self, *args, **kwargs):
for observer in self.__observers:
observer.notify(self, *args, **kwargs)
class Observer1:
def __init__(self, subject):
subject.register(self)
def notify(self, subject, *args):
pass
class Observer2:
def __init__(self, subject):
subject.register(self)
def notify(self, subject, *args):
pass
subject = Subject()
observer1 = Observer1(subject)
Observer2 = Observer2(subject)
subject.notifyAll("notification")
| class Subject:
def __init__(self):
self.__observers = []
def register(self, observer):
self.__observers.append(observer)
def notify_all(self, *args, **kwargs):
for observer in self.__observers:
observer.notify(self, *args, **kwargs)
class Observer1:
def __init__(self, subject):
subject.register(self)
def notify(self, subject, *args):
pass
class Observer2:
def __init__(self, subject):
subject.register(self)
def notify(self, subject, *args):
pass
subject = subject()
observer1 = observer1(subject)
observer2 = observer2(subject)
subject.notifyAll('notification') |
def galoisMult(a, b):
'''
The parameter b will be either 1, 2 or 3. Multiplication by 3 is defined as multiplication by 2 then adding the
original value. For example 3x6 is equivalent to 2x6+6. The multiplication by 2 is done with a left shift
(a <<= 1) and dropping the MSB. If that bit had been a 1 then remainder after dividing by the irreducible
polynomial 00011011 (1b). This polynomial is described in the literature as a 9 bit value 100011011, or in its
Galois form x8 + x4 + x3 + x1 + 1
:param a: the original value to be multiplied.
:param b: the value to be multiplied by
:return: the result
'''
result = 0
for i in range(b): # This needs to run once for x1, twice for x2 and thrice for x3
if b & 1 == 1: # If the LSB is 1. This will happen with x1 and x3
result ^= a # Add the original value to result. This is the + part of x3 = x2 +1
hiBitSet = a & 0x80 # Before doing x2 check to see if a is > 128
a <<= 1 # Do x2
a &= 0xff # reduce 9 bit numbers to 8 bit
if hiBitSet == 0x80: # If the original value of a was > 128 then the result is > 256 so reduce.
a ^= 0x1b # XOR with the irreducible polynomial
b >>= 1 # Rotate b
return result
if __name__ == '__main__':
#print(hex(galoisMult(0xa0, 1))) # a0
#print(hex(galoisMult(0xd4, 2))) # b3
#print(hex(galoisMult(0xbf, 3))) # da
print(hex(galoisMult(0x7f, 0)))
print(hex(galoisMult(0x7f, 1)))
print(hex(galoisMult(0x7f, 2)))
print(hex(galoisMult(0x7f, 3)))
| def galois_mult(a, b):
"""
The parameter b will be either 1, 2 or 3. Multiplication by 3 is defined as multiplication by 2 then adding the
original value. For example 3x6 is equivalent to 2x6+6. The multiplication by 2 is done with a left shift
(a <<= 1) and dropping the MSB. If that bit had been a 1 then remainder after dividing by the irreducible
polynomial 00011011 (1b). This polynomial is described in the literature as a 9 bit value 100011011, or in its
Galois form x8 + x4 + x3 + x1 + 1
:param a: the original value to be multiplied.
:param b: the value to be multiplied by
:return: the result
"""
result = 0
for i in range(b):
if b & 1 == 1:
result ^= a
hi_bit_set = a & 128
a <<= 1
a &= 255
if hiBitSet == 128:
a ^= 27
b >>= 1
return result
if __name__ == '__main__':
print(hex(galois_mult(127, 0)))
print(hex(galois_mult(127, 1)))
print(hex(galois_mult(127, 2)))
print(hex(galois_mult(127, 3))) |
diff_counter = 0
A = input()
B = input()
for i in range(len(A)):
if A[i] != B[i]:
diff_counter += 1
if diff_counter > 1:
print("LARRY IS DEAD!")
elif diff_counter == 1:
print("LARRY IS SAVED!")
else:
print("LARRY IS DEAD!")
| diff_counter = 0
a = input()
b = input()
for i in range(len(A)):
if A[i] != B[i]:
diff_counter += 1
if diff_counter > 1:
print('LARRY IS DEAD!')
elif diff_counter == 1:
print('LARRY IS SAVED!')
else:
print('LARRY IS DEAD!') |
"""
dir([object])
Without arguments, return the list of names in the current local scope. With an argument,
attempt to return a list of valid attributes for that object.
"""
class A:
name = "Derick"
age = 30
class Shape:
def __dir__(self):
return ['area', 'location', 'shape',]
def b():
c = 1
if __name__ == "__main__":
print("-------Calling dir with no arguments-------")
print(dir())
print("-------Calling dir on a class that does not implement the __dir__ method-------")
print(dir(A))
print("-------Calling dir on a class that implements the __dir__ method-------")
s = Shape()
print(dir(s))
print("-------Calling dir on a function-------")
print(dir(b))
| """
dir([object])
Without arguments, return the list of names in the current local scope. With an argument,
attempt to return a list of valid attributes for that object.
"""
class A:
name = 'Derick'
age = 30
class Shape:
def __dir__(self):
return ['area', 'location', 'shape']
def b():
c = 1
if __name__ == '__main__':
print('-------Calling dir with no arguments-------')
print(dir())
print('-------Calling dir on a class that does not implement the __dir__ method-------')
print(dir(A))
print('-------Calling dir on a class that implements the __dir__ method-------')
s = shape()
print(dir(s))
print('-------Calling dir on a function-------')
print(dir(b)) |
class Method:
CHAR = 'char'
WORD = 'word'
SPECTROGRAM = 'spectrogram'
AUDIO = 'audio'
FLOW = 'flow'
@staticmethod
def getall():
return [Method.CHAR, Method.WORD, Method.AUDIO, Method.SPECTROGRAM, Method.FLOW]
| class Method:
char = 'char'
word = 'word'
spectrogram = 'spectrogram'
audio = 'audio'
flow = 'flow'
@staticmethod
def getall():
return [Method.CHAR, Method.WORD, Method.AUDIO, Method.SPECTROGRAM, Method.FLOW] |
#!/usr/bin/env/python
inp = open('top-1m.csv', 'r')
out = open('top-1m__.csv', 'a+')
out.write('"domain_id,"domain_name"')
id = ''
domain = ''
while True:
line = inp.readline()
if len(line) > 0:
cPos = line.find(',')
id = line[:cPos]
domain = line[cPos+1:]
domain = '"'+domain.rstrip()+'"'
final = id+','+domain+'\n'
out.write(final)
else:
break
inp.close()
out.close() | inp = open('top-1m.csv', 'r')
out = open('top-1m__.csv', 'a+')
out.write('"domain_id,"domain_name"')
id = ''
domain = ''
while True:
line = inp.readline()
if len(line) > 0:
c_pos = line.find(',')
id = line[:cPos]
domain = line[cPos + 1:]
domain = '"' + domain.rstrip() + '"'
final = id + ',' + domain + '\n'
out.write(final)
else:
break
inp.close()
out.close() |
TINY_TEST = False
if TINY_TEST:
MIN_BOUND = -2
MAX_BOUND = 2
else:
MIN_BOUND = -200
MAX_BOUND = 200
WIDTH = (MAX_BOUND - MIN_BOUND) + 3
M = [["."] * WIDTH for i in range(WIDTH)]
def setMap(p, v):
x, y = p
M[y - MIN_BOUND + 1][x - MIN_BOUND + 1] = v
def getMap(p):
x, y = p
return M[y - MIN_BOUND + 1][x - MIN_BOUND + 1]
START = (0, 0)
if TINY_TEST:
GOAL = (2, 2)
setMap(START, "S")
setMap(GOAL, "G")
obstacles = [(1, 1)]
for p in obstacles:
setMap(p, "#")
else:
N, X, Y = [int(x) for x in input().split()]
setMap((X, Y), "G")
for i in range(N):
p = [int(x) for x in input().split()]
setMap(p, "#")
def pp(map):
for line in map:
print("".join(line))
def main():
def visit(x, y):
if getMap((x, y)) == "G":
return True
if getMap((x, y)) != ".":
return
if x < MIN_BOUND-1 or MAX_BOUND+1 < x:
return
if y < MIN_BOUND-1 or MAX_BOUND+1 < y:
return
newFront.append((x, y))
setMap((x, y), "v")
newFront = [START]
for numSteps in range(1, 1000):
front = set(newFront)
# print("len front,", len(front), numSteps)
# print(front)
newFront = []
for x, y in front:
isFinished = (
visit(x + 1, y + 1)
or visit(x, y + 1)
or visit(x - 1, y + 1)
or visit(x + 1, y)
or visit(x - 1, y)
or visit(x, y - 1))
if isFinished:
print(numSteps)
return
if not newFront:
print(-1)
return
main()
| tiny_test = False
if TINY_TEST:
min_bound = -2
max_bound = 2
else:
min_bound = -200
max_bound = 200
width = MAX_BOUND - MIN_BOUND + 3
m = [['.'] * WIDTH for i in range(WIDTH)]
def set_map(p, v):
(x, y) = p
M[y - MIN_BOUND + 1][x - MIN_BOUND + 1] = v
def get_map(p):
(x, y) = p
return M[y - MIN_BOUND + 1][x - MIN_BOUND + 1]
start = (0, 0)
if TINY_TEST:
goal = (2, 2)
set_map(START, 'S')
set_map(GOAL, 'G')
obstacles = [(1, 1)]
for p in obstacles:
set_map(p, '#')
else:
(n, x, y) = [int(x) for x in input().split()]
set_map((X, Y), 'G')
for i in range(N):
p = [int(x) for x in input().split()]
set_map(p, '#')
def pp(map):
for line in map:
print(''.join(line))
def main():
def visit(x, y):
if get_map((x, y)) == 'G':
return True
if get_map((x, y)) != '.':
return
if x < MIN_BOUND - 1 or MAX_BOUND + 1 < x:
return
if y < MIN_BOUND - 1 or MAX_BOUND + 1 < y:
return
newFront.append((x, y))
set_map((x, y), 'v')
new_front = [START]
for num_steps in range(1, 1000):
front = set(newFront)
new_front = []
for (x, y) in front:
is_finished = visit(x + 1, y + 1) or visit(x, y + 1) or visit(x - 1, y + 1) or visit(x + 1, y) or visit(x - 1, y) or visit(x, y - 1)
if isFinished:
print(numSteps)
return
if not newFront:
print(-1)
return
main() |
def even_numbers(func):
def wrapper(nums):
numbers = func(nums)
return [num for num in numbers if num % 2 == 0]
return wrapper
@even_numbers
def get_numbers(numbers):
return numbers
print(get_numbers([1, 2, 3, 4, 5]))
| def even_numbers(func):
def wrapper(nums):
numbers = func(nums)
return [num for num in numbers if num % 2 == 0]
return wrapper
@even_numbers
def get_numbers(numbers):
return numbers
print(get_numbers([1, 2, 3, 4, 5])) |
SEASONS = {
1: {
"TITLE" : "Destiny 2",
"EXPANSION" : "Destiny 2",
"ACTIVE" : False,
"YEAR" : "1",
"START" : '2017-09-06 17:00:00',
"END" : '2017-12-05 17:00:00',
},
2: {
"TITLE" : "Curse of Osiris",
"EXPANSION" : "Destiny 2",
"ACTIVE" : False,
"YEAR" : "1",
"START" : '2017-12-05 17:00:01',
"END" : '2018-05-08 17:00:00',
},
3: {
"TITLE" : "Warmind",
"EXPANSION" : "Destiny 2",
"ACTIVE" : False,
"YEAR" : "1",
"START" : '2018-05-08 17:00:01',
"END" : '2018-09-04 17:00:00',
},
4: {
"TITLE" : "Season of the Outlaw",
"EXPANSION" : "Forsaken",
"ACTIVE" : False,
"YEAR" : "2",
"START" : '2018-09-04 17:00:01',
"END" : '2018-12-04 17:00:00',
},
5: {
"TITLE" : "Season of the Forge",
"EXPANSION" : "Forsaken",
"ACTIVE" : False,
"YEAR" : "2",
"START" : '2018-12-04 17:00:01',
"END" : '2019-03-05 17:00:00',
},
6: {
"TITLE" : "Season of the Drifter",
"EXPANSION" : "Forsaken",
"ACTIVE" : False,
"YEAR" : "2",
"START" : '2019-03-05 17:00:01',
"END" : '2019-06-04 17:00:00',
},
7: {
"TITLE" : "Season of Opulence",
"EXPANSION" : "Forsaken",
"ACTIVE" : False,
"YEAR" : "2",
"START" : '2019-06-04 17:00:01',
"END" : '2019-09-30 17:00:00',
},
8: {
"TITLE" : "Season of the Undying",
"EXPANSION" : "Shadowkeep",
"ACTIVE" : False,
"YEAR" : "3",
"START" : '2019-09-30 17:00:01',
"END" : '2019-12-10 17:00:00',
},
9: {
"TITLE" : "Season of Dawn",
"EXPANSION" : "Shadowkeep",
"ACTIVE" : False,
"YEAR" : "3",
"START" : '2019-12-10 17:00:01',
"END" : '2020-03-09 17:00:00',
},
10: {
"TITLE" : "Season of the Worthy",
"ACTIVE" : False,
"EXPANSION" : "Shadowkeep",
"YEAR" : "3",
"START" : '2020-03-09 17:00:01',
"END" : '2020-06-09 17:00:00',
},
11: {
"TITLE" : "Season of Arrivals",
"ACTIVE" : False,
"EXPANSION" : "Shadowkeep",
"YEAR" : "3",
"START" : '2020-06-09 17:00:01',
"END" : '2020-10-10 17:00:00',
},
12: {
"TITLE" : "Season of the Hunt",
"ACTIVE" : False,
"EXPANSION" : "Beyond Light",
"YEAR" : "4",
"START" : '2020-10-10 17:00:01',
"END" : '2021-02-09 17:00:00',
},
13: {
"TITLE" : "Season of the Chosen",
"ACTIVE" : False,
"EXPANSION" : "Beyond Light",
"YEAR" : "4",
"START" : '2021-02-09 17:00:01',
"END" : '2021-05-11 17:00:00',
},
14: {
"TITLE" : 'Season of the Splicer',
"ACTIVE" : False,
"EXPANSION" : 'Beyond Light',
"YEAR" : '4',
"START" : '2021-05-11 17:00:01',
"END" : '2021-08-24 17:00:00',
},
15: {
"TITLE": 'Season of the Lost',
"ACTIVE": True,
"EXPANSION": 'Beyond Light',
"YEAR": '4',
"START": '2021-08-24 17:00:01',
"END": '2022-02-22 17:00:00',
},
}
CURRENT_SEASON = 15
# CURRENT_SEASON = list(SEASONS)[-1]
LAST_SEASON = CURRENT_SEASON - 1
| seasons = {1: {'TITLE': 'Destiny 2', 'EXPANSION': 'Destiny 2', 'ACTIVE': False, 'YEAR': '1', 'START': '2017-09-06 17:00:00', 'END': '2017-12-05 17:00:00'}, 2: {'TITLE': 'Curse of Osiris', 'EXPANSION': 'Destiny 2', 'ACTIVE': False, 'YEAR': '1', 'START': '2017-12-05 17:00:01', 'END': '2018-05-08 17:00:00'}, 3: {'TITLE': 'Warmind', 'EXPANSION': 'Destiny 2', 'ACTIVE': False, 'YEAR': '1', 'START': '2018-05-08 17:00:01', 'END': '2018-09-04 17:00:00'}, 4: {'TITLE': 'Season of the Outlaw', 'EXPANSION': 'Forsaken', 'ACTIVE': False, 'YEAR': '2', 'START': '2018-09-04 17:00:01', 'END': '2018-12-04 17:00:00'}, 5: {'TITLE': 'Season of the Forge', 'EXPANSION': 'Forsaken', 'ACTIVE': False, 'YEAR': '2', 'START': '2018-12-04 17:00:01', 'END': '2019-03-05 17:00:00'}, 6: {'TITLE': 'Season of the Drifter', 'EXPANSION': 'Forsaken', 'ACTIVE': False, 'YEAR': '2', 'START': '2019-03-05 17:00:01', 'END': '2019-06-04 17:00:00'}, 7: {'TITLE': 'Season of Opulence', 'EXPANSION': 'Forsaken', 'ACTIVE': False, 'YEAR': '2', 'START': '2019-06-04 17:00:01', 'END': '2019-09-30 17:00:00'}, 8: {'TITLE': 'Season of the Undying', 'EXPANSION': 'Shadowkeep', 'ACTIVE': False, 'YEAR': '3', 'START': '2019-09-30 17:00:01', 'END': '2019-12-10 17:00:00'}, 9: {'TITLE': 'Season of Dawn', 'EXPANSION': 'Shadowkeep', 'ACTIVE': False, 'YEAR': '3', 'START': '2019-12-10 17:00:01', 'END': '2020-03-09 17:00:00'}, 10: {'TITLE': 'Season of the Worthy', 'ACTIVE': False, 'EXPANSION': 'Shadowkeep', 'YEAR': '3', 'START': '2020-03-09 17:00:01', 'END': '2020-06-09 17:00:00'}, 11: {'TITLE': 'Season of Arrivals', 'ACTIVE': False, 'EXPANSION': 'Shadowkeep', 'YEAR': '3', 'START': '2020-06-09 17:00:01', 'END': '2020-10-10 17:00:00'}, 12: {'TITLE': 'Season of the Hunt', 'ACTIVE': False, 'EXPANSION': 'Beyond Light', 'YEAR': '4', 'START': '2020-10-10 17:00:01', 'END': '2021-02-09 17:00:00'}, 13: {'TITLE': 'Season of the Chosen', 'ACTIVE': False, 'EXPANSION': 'Beyond Light', 'YEAR': '4', 'START': '2021-02-09 17:00:01', 'END': '2021-05-11 17:00:00'}, 14: {'TITLE': 'Season of the Splicer', 'ACTIVE': False, 'EXPANSION': 'Beyond Light', 'YEAR': '4', 'START': '2021-05-11 17:00:01', 'END': '2021-08-24 17:00:00'}, 15: {'TITLE': 'Season of the Lost', 'ACTIVE': True, 'EXPANSION': 'Beyond Light', 'YEAR': '4', 'START': '2021-08-24 17:00:01', 'END': '2022-02-22 17:00:00'}}
current_season = 15
last_season = CURRENT_SEASON - 1 |
#Day 6 : Lets Review
for i in range(int(input())):
char = input()
print("".join(char[::2]),"".join(char[1::2])) | for i in range(int(input())):
char = input()
print(''.join(char[::2]), ''.join(char[1::2])) |
# Copyright 2017 Therp BV, ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Client side message boxes",
"version": "13.0.1.0.0",
"author": "Therp BV, " "ACSONE SA/NV, " "Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Hidden/Dependency",
"summary": "Show a message box to users",
"depends": ["web"],
"data": ["views/templates.xml"],
"qweb": ["static/src/xml/web_ir_actions_act_window_message.xml"],
}
| {'name': 'Client side message boxes', 'version': '13.0.1.0.0', 'author': 'Therp BV, ACSONE SA/NV, Odoo Community Association (OCA)', 'license': 'AGPL-3', 'category': 'Hidden/Dependency', 'summary': 'Show a message box to users', 'depends': ['web'], 'data': ['views/templates.xml'], 'qweb': ['static/src/xml/web_ir_actions_act_window_message.xml']} |
def linked_sort(a,b,kf=''):
mapped = sorted([(i,j) for i,j in zip(a,b)], key=kf or standard)
bsr=[j for i,j in mapped]
a.sort(key=(kf or standard))
b.sort(key=lambda x: bsr.index(x))
return a
standard = lambda x: str(x)
| def linked_sort(a, b, kf=''):
mapped = sorted([(i, j) for (i, j) in zip(a, b)], key=kf or standard)
bsr = [j for (i, j) in mapped]
a.sort(key=kf or standard)
b.sort(key=lambda x: bsr.index(x))
return a
standard = lambda x: str(x) |
def findDecision(obj): #obj[0]: Coupon, obj[1]: Education
# {"feature": "Education", "instances": 34, "metric_value": 0.9597, "depth": 1}
if obj[1]>1:
# {"feature": "Coupon", "instances": 19, "metric_value": 0.998, "depth": 2}
if obj[0]<=3:
return 'True'
elif obj[0]>3:
return 'False'
else: return 'False'
elif obj[1]<=1:
# {"feature": "Coupon", "instances": 15, "metric_value": 0.8366, "depth": 2}
if obj[0]>2:
return 'True'
elif obj[0]<=2:
return 'False'
else: return 'False'
else: return 'True'
| def find_decision(obj):
if obj[1] > 1:
if obj[0] <= 3:
return 'True'
elif obj[0] > 3:
return 'False'
else:
return 'False'
elif obj[1] <= 1:
if obj[0] > 2:
return 'True'
elif obj[0] <= 2:
return 'False'
else:
return 'False'
else:
return 'True' |
one = ['1']
two = ['3']
three = ['9']
a = '1'
b = '3'
c = '9'
v = [0,0,0]
for i in range(1000):
v[0] = int(a)
v[1] = int(b)
v[2] = int(c)
for i in range(len(a)) :
v[0] += int(a[i])
for i in range(len(b)) :
v[1] += int(b[i])
for i in range(len(a)) :
v[2] += int(c[i])
one.append(str(v[0]))
two.append(str(v[1]))
three.append(str(v[2]))
a = str(v[0])
b = str(v[1])
c = str(v[2])
n = input("N: ")
s = n
while True :
num = int(s)
for i in range(len(s)) :
num += int(s[i])
if str(num) in one :
print(f"1 {num}")
break
'''elif str(num) in two :
print(f"3 {num}")
break
elif str(num) in three :
print(f"9 {num}")
break'''
s = str(num)
| one = ['1']
two = ['3']
three = ['9']
a = '1'
b = '3'
c = '9'
v = [0, 0, 0]
for i in range(1000):
v[0] = int(a)
v[1] = int(b)
v[2] = int(c)
for i in range(len(a)):
v[0] += int(a[i])
for i in range(len(b)):
v[1] += int(b[i])
for i in range(len(a)):
v[2] += int(c[i])
one.append(str(v[0]))
two.append(str(v[1]))
three.append(str(v[2]))
a = str(v[0])
b = str(v[1])
c = str(v[2])
n = input('N: ')
s = n
while True:
num = int(s)
for i in range(len(s)):
num += int(s[i])
if str(num) in one:
print(f'1 {num}')
break
'elif str(num) in two :\n print(f"3 {num}")\n break\n elif str(num) in three :\n print(f"9 {num}")\n break'
s = str(num) |
class MovieTrackingCamera:
distortion_model = None
division_k1 = None
division_k2 = None
focal_length = None
focal_length_pixels = None
k1 = None
k2 = None
k3 = None
pixel_aspect = None
principal = None
sensor_width = None
units = None
| class Movietrackingcamera:
distortion_model = None
division_k1 = None
division_k2 = None
focal_length = None
focal_length_pixels = None
k1 = None
k2 = None
k3 = None
pixel_aspect = None
principal = None
sensor_width = None
units = None |
print("digite um numero para consultar seu intervalo")
x = int(input())
if 0 <= x <= 25:
print('Intervalo [0,25]')
if 25 < x <= 50:
print('Intervalo (25,50]')
if 50 < x <= 75:
print('Intervalo (50,75]')
if 75 < x <= 100:
print('Intervalo (75,100]')
else:
print('Fora de intervalo')
| print('digite um numero para consultar seu intervalo')
x = int(input())
if 0 <= x <= 25:
print('Intervalo [0,25]')
if 25 < x <= 50:
print('Intervalo (25,50]')
if 50 < x <= 75:
print('Intervalo (50,75]')
if 75 < x <= 100:
print('Intervalo (75,100]')
else:
print('Fora de intervalo') |
"""
Implement pow(x, n), which calculates x raised to the power n (i.e., xn).
source - https://leetcode.com/problems/powx-n
"""
"""
Time Complexity - O(Logn)
Space Complexity - 1
"""
# Faster
class Solution:
def myPow(self, x: float, n: int) -> float:
return pow(x, n)
"""
Time Complexity - O(Logn)
Space Complexity - 1
"""
class Solution:
def myPow(self, x: float, n: int) -> float:
if n < 0:
x = 1/x
n = -n
res = 1
while n:
if n & 1:
res *= x
n >>= 1
x *= x
return res
| """
Implement pow(x, n), which calculates x raised to the power n (i.e., xn).
source - https://leetcode.com/problems/powx-n
"""
'\nTime Complexity - O(Logn)\nSpace Complexity - 1\n'
class Solution:
def my_pow(self, x: float, n: int) -> float:
return pow(x, n)
'\nTime Complexity - O(Logn)\nSpace Complexity - 1\n'
class Solution:
def my_pow(self, x: float, n: int) -> float:
if n < 0:
x = 1 / x
n = -n
res = 1
while n:
if n & 1:
res *= x
n >>= 1
x *= x
return res |
"""
Shape Vertices.
How to iterate over the vertices of a shape.
When loading an obj or SVG, getVertexCount()
will typically return 0 since all the vertices
are in the child shapes.
You should iterate through the children and then
iterate through their vertices.
"""
def setup():
size(640, 360)
# Load the shape
global uk
uk = loadShape("uk.svg")
def draw():
background(51)
# Center where we will draw all the vertices
translate(width / 2 - uk.width / 2, height / 2 - uk.height / 2)
# Iterate over the children
children = uk.getChildCount()
for i in xrange(children):
child = uk.getChild(i)
total = child.getVertexCount()
# Now we can actually get the vertices from each child
for j in xrange(total):
v = child.getVertex(j)
# Cycling brightness for each vertex
stroke((frameCount + (i + 1) * j) % 255)
# Just a dot for each one
point(v.x, v.y)
| """
Shape Vertices.
How to iterate over the vertices of a shape.
When loading an obj or SVG, getVertexCount()
will typically return 0 since all the vertices
are in the child shapes.
You should iterate through the children and then
iterate through their vertices.
"""
def setup():
size(640, 360)
global uk
uk = load_shape('uk.svg')
def draw():
background(51)
translate(width / 2 - uk.width / 2, height / 2 - uk.height / 2)
children = uk.getChildCount()
for i in xrange(children):
child = uk.getChild(i)
total = child.getVertexCount()
for j in xrange(total):
v = child.getVertex(j)
stroke((frameCount + (i + 1) * j) % 255)
point(v.x, v.y) |
class HttpRequest():
def __init__(self, scope, body, receive, metadata=None, application=None):
self._application = application
self._scope = scope
self._body = body
self._cookies = None
self._receive = receive
self._subdomain, self._headers = metadata
self._params = None
def _parse_qs(self):
qs = self._scope.get('query_string')
qsd = {}
if not qs: return qsd
else: qs = qs.decode() if isinstance(qs, bytes) else qs
query_kv_pairs = qs.split('&')
for kv_pair in query_kv_pairs:
key, value = kv_pair.split('=')
current_value = qsd.get(key)
if not current_value:
qsd[key] = value
else:
if isinstance(current_value, list): current_value.append(value)
else: qsd[key] = [current_value, value]
return qsd
@property
def app(self):
return self._application
@property
def body(self):
return self._body.get('body')
@property
def cookies(self):
if not self._cookies:
csd = {}
cookiestring = self.headers.get('cookie')
if not cookiestring: self._cookies = csd; return self._cookies
cookies = cookiestring.split('; ')
for cookie in cookies:
k, v = cookie.split('=')
csd[k] = v
self._cookies = csd
return self._cookies
@property
def headers(self):
if not self._headers:
self._headers = {}
for header in self._scope.get('headers'):
self._headers[header[0]] = header[1]
return self._headers
@property
def method(self):
return self._scope.get('method')
@property
def params(self):
if not self._params:
self._params = self._parse_qs()
return self._params
@params.setter
def params(self, pair):
if not self._params:
self._params = {}
self._params[pair[0]] = pair[1]
@property
def querystring(self):
return self._scope.get('query_string', '')
@property
def subdomain(self):
return self._subdomain
@property
def url(self):
return self._scope.get('path')
async def stream(self):
"""TODO: Revisit and implement with appropriate testing"""
return await self._receive()
| class Httprequest:
def __init__(self, scope, body, receive, metadata=None, application=None):
self._application = application
self._scope = scope
self._body = body
self._cookies = None
self._receive = receive
(self._subdomain, self._headers) = metadata
self._params = None
def _parse_qs(self):
qs = self._scope.get('query_string')
qsd = {}
if not qs:
return qsd
else:
qs = qs.decode() if isinstance(qs, bytes) else qs
query_kv_pairs = qs.split('&')
for kv_pair in query_kv_pairs:
(key, value) = kv_pair.split('=')
current_value = qsd.get(key)
if not current_value:
qsd[key] = value
elif isinstance(current_value, list):
current_value.append(value)
else:
qsd[key] = [current_value, value]
return qsd
@property
def app(self):
return self._application
@property
def body(self):
return self._body.get('body')
@property
def cookies(self):
if not self._cookies:
csd = {}
cookiestring = self.headers.get('cookie')
if not cookiestring:
self._cookies = csd
return self._cookies
cookies = cookiestring.split('; ')
for cookie in cookies:
(k, v) = cookie.split('=')
csd[k] = v
self._cookies = csd
return self._cookies
@property
def headers(self):
if not self._headers:
self._headers = {}
for header in self._scope.get('headers'):
self._headers[header[0]] = header[1]
return self._headers
@property
def method(self):
return self._scope.get('method')
@property
def params(self):
if not self._params:
self._params = self._parse_qs()
return self._params
@params.setter
def params(self, pair):
if not self._params:
self._params = {}
self._params[pair[0]] = pair[1]
@property
def querystring(self):
return self._scope.get('query_string', '')
@property
def subdomain(self):
return self._subdomain
@property
def url(self):
return self._scope.get('path')
async def stream(self):
"""TODO: Revisit and implement with appropriate testing"""
return await self._receive() |
"""
Given an array of integers nums and an integer target, return indices
of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution,
and you may not use the same element twice.
You can return the answer in any order.
Example 1:
Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Output: Because nums[0] + nums[1] == 9, we return [0, 1].
Example 2:
Input: nums = [3,2,4], target = 6
Output: [1,2]
Example 3:
Input: nums = [3,3], target = 6
Output: [0,1]
Constraints:
2 <= nums.length <= 104
-109 <= nums[i] <= 109
-109 <= target <= 109
Only one valid answer exists.
"""
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
hashmap = {}
for idx in range(len(nums)):
diff = target-nums[idx]
if diff in hashmap:
return [idx, hashmap[diff]]
hashmap[nums[idx]] = idx
| """
Given an array of integers nums and an integer target, return indices
of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution,
and you may not use the same element twice.
You can return the answer in any order.
Example 1:
Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Output: Because nums[0] + nums[1] == 9, we return [0, 1].
Example 2:
Input: nums = [3,2,4], target = 6
Output: [1,2]
Example 3:
Input: nums = [3,3], target = 6
Output: [0,1]
Constraints:
2 <= nums.length <= 104
-109 <= nums[i] <= 109
-109 <= target <= 109
Only one valid answer exists.
"""
class Solution:
def two_sum(self, nums: List[int], target: int) -> List[int]:
hashmap = {}
for idx in range(len(nums)):
diff = target - nums[idx]
if diff in hashmap:
return [idx, hashmap[diff]]
hashmap[nums[idx]] = idx |
# This dict is built through the metaclass applied to ExternalProvider.
# It is intentionally empty here, and should remain empty.
PROVIDER_LOOKUP = dict()
def get_service(name):
"""Given a service name, return the provider class"""
return PROVIDER_LOOKUP[name]()
| provider_lookup = dict()
def get_service(name):
"""Given a service name, return the provider class"""
return PROVIDER_LOOKUP[name]() |
dbodydict = dict() # dtitle, dbody
fdbody = open("sample_alldoc_fake_body.dict")
while 1:
line = fdbody.readline()
if not line:
break
tks = line.strip().split(' ')
dbodydict[tks[0]]=tks[1]
fclean = open("sample_valid_cqexp.cleaned")
fexp = open("sample_valid_cqbody.cleaned",'w')
while 1:
line = fclean.readline()
if not line:
break
tks = line.strip().split(' ')
q = tks[0]
dp = tks[1]
dn = tks[2]
dpcq = tks[3]
dncq = tks[4]
dpbody = '0'
dnbody = '0'
if dp in dbodydict:
dpbody = dbodydict[dp]
if dn in dbodydict:
dnbody = dbodydict[dn]
out = str(q)+' '+str(dp)+' '+str(dn)+' '+str(dpcq)+' '+str(dncq)+' '+str(dpbody)+' '+str(dnbody)+'\n'
fexp.write(out)
| dbodydict = dict()
fdbody = open('sample_alldoc_fake_body.dict')
while 1:
line = fdbody.readline()
if not line:
break
tks = line.strip().split(' ')
dbodydict[tks[0]] = tks[1]
fclean = open('sample_valid_cqexp.cleaned')
fexp = open('sample_valid_cqbody.cleaned', 'w')
while 1:
line = fclean.readline()
if not line:
break
tks = line.strip().split(' ')
q = tks[0]
dp = tks[1]
dn = tks[2]
dpcq = tks[3]
dncq = tks[4]
dpbody = '0'
dnbody = '0'
if dp in dbodydict:
dpbody = dbodydict[dp]
if dn in dbodydict:
dnbody = dbodydict[dn]
out = str(q) + ' ' + str(dp) + ' ' + str(dn) + ' ' + str(dpcq) + ' ' + str(dncq) + ' ' + str(dpbody) + ' ' + str(dnbody) + '\n'
fexp.write(out) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.