content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class Command(object):
def __init__(self, command, description, callback):
"""
Construct command
:param command: The command
:param description: The description
:param callback: The callback
"""
self.command = command
self.description = description
self.callback = callback
self.given = False
self.arguments = None
def reset(self):
"""
Reset option
:return: void
"""
self.given = False
self.arguments = None
| class Command(object):
def __init__(self, command, description, callback):
"""
Construct command
:param command: The command
:param description: The description
:param callback: The callback
"""
self.command = command
self.description = description
self.callback = callback
self.given = False
self.arguments = None
def reset(self):
"""
Reset option
:return: void
"""
self.given = False
self.arguments = None |
# List
dog_names = ["tom", "sean", "sally", "mark"]
print(type(dog_names))
print(dog_names)
# Adding Item On Last Position
dog_names.append("sam")
print(dog_names)
# Adding Item On First Position
dog_names.insert(0, "bruz")
print(dog_names)
# Delete Items
del(dog_names[0])
print(dog_names)
# Length Of List
print('Length Of List: ',len(dog_names)) | dog_names = ['tom', 'sean', 'sally', 'mark']
print(type(dog_names))
print(dog_names)
dog_names.append('sam')
print(dog_names)
dog_names.insert(0, 'bruz')
print(dog_names)
del dog_names[0]
print(dog_names)
print('Length Of List: ', len(dog_names)) |
class BTNode:
def __init__(self, data = -1, left = None, right = None):
self.data = data
self.left = left
self.right = right
class BTree:
def __init__(self):
self.root = None
self.found = False
def is_empty(self):
return self.root is None
def build(self, vals):
self.root = BTNode(int(vals.pop(0)))
queue = [self.root]
while len(queue) != 0:
node = queue.pop(0)
if len(vals) != 0:
val = vals.pop(0)
if val != "None":
node.left = BTNode(int(val))
queue.append(node.left)
if len(vals) != 0:
val = vals.pop(0)
if val != "None":
node.right = BTNode(int(val))
queue.append(node.right)
def find(self, num):
self.dfs(self.root, 0, num)
if self.found:
print("True")
else:
print("False")
def dfs(self, node, val, num):
val += node.data
if val == num:
self.found = True
if node.left:
self.dfs(node.left, val, num)
if node.right:
self.dfs(node.right, val, num)
def main():
n = int(input())
s = input().split()
tree = BTree()
tree.build(s)
tree.find(n)
main() | class Btnode:
def __init__(self, data=-1, left=None, right=None):
self.data = data
self.left = left
self.right = right
class Btree:
def __init__(self):
self.root = None
self.found = False
def is_empty(self):
return self.root is None
def build(self, vals):
self.root = bt_node(int(vals.pop(0)))
queue = [self.root]
while len(queue) != 0:
node = queue.pop(0)
if len(vals) != 0:
val = vals.pop(0)
if val != 'None':
node.left = bt_node(int(val))
queue.append(node.left)
if len(vals) != 0:
val = vals.pop(0)
if val != 'None':
node.right = bt_node(int(val))
queue.append(node.right)
def find(self, num):
self.dfs(self.root, 0, num)
if self.found:
print('True')
else:
print('False')
def dfs(self, node, val, num):
val += node.data
if val == num:
self.found = True
if node.left:
self.dfs(node.left, val, num)
if node.right:
self.dfs(node.right, val, num)
def main():
n = int(input())
s = input().split()
tree = b_tree()
tree.build(s)
tree.find(n)
main() |
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 13 11:30:05 2019
@author: Jongmin Sung
import functions and variables into our notebooks and scripts:
from projectname import something
"""
| """
Created on Wed Mar 13 11:30:05 2019
@author: Jongmin Sung
import functions and variables into our notebooks and scripts:
from projectname import something
""" |
"""Module with bad __all__
To test https://github.com/ipython/ipython/issues/9678
"""
def evil():
pass
def puppies():
pass
__all__ = [evil, # Bad
'puppies', # Good
]
| """Module with bad __all__
To test https://github.com/ipython/ipython/issues/9678
"""
def evil():
pass
def puppies():
pass
__all__ = [evil, 'puppies'] |
# -- Project information -----------------------------------------------------
project = "Test"
copyright = "Test"
author = "Test"
# -- General configuration ---------------------------------------------------
master_doc = "index"
# -- Options for HTML output -------------------------------------------------
html_theme = "pydata_sphinx_theme"
| project = 'Test'
copyright = 'Test'
author = 'Test'
master_doc = 'index'
html_theme = 'pydata_sphinx_theme' |
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def countUnivalSubtrees(self, root):
"""
:type root: TreeNode
:rtype: int
"""
self.count = 0
def helper(node, val):
if not node:
return True
left = helper(node.left, node.val)
right = helper(node.right, node.val)
if not left or not right:
return False
self.count += 1
return node.val == val
helper(root, 0)
return self.count | class Solution(object):
def count_unival_subtrees(self, root):
"""
:type root: TreeNode
:rtype: int
"""
self.count = 0
def helper(node, val):
if not node:
return True
left = helper(node.left, node.val)
right = helper(node.right, node.val)
if not left or not right:
return False
self.count += 1
return node.val == val
helper(root, 0)
return self.count |
# Reads the UA list from the file "ua_list.txt"
# Refer this site for list of UAs: https://developers.whatismybrowser.com/useragents/explore/
ua_file = open("ua_list.txt", "r")
lines = ua_file.readlines()
ua_list = []
for line in lines:
line_cleaned = line.replace("\n","").lower()
ua_list.append(line_cleaned)
ua_list.sort()
ua_list = list(dict.fromkeys(ua_list))
ua_list_count = len(ua_list)
print(ua_list)
print("Identified ",ua_list_count," UAs in the file.")
ua_file.close()
# Write the sorted list back to the file "ua_list.txt"
ua_file_sorted = open("ua_list.txt", "w")
for ua in ua_list:
ua_line = ua + "\n"
ua_file_sorted.write(ua_line)
ua_file_sorted.close
# Generate Cloudflare configuration in the string "ua_list_cf"
# Using Cloudflare case insensitive matching lower()
ua_list_cf = ""
i = 0
for ua in ua_list:
if (i < ua_list_count - 1):
cf_single_rule = "(lower(http.user_agent) contains \"" + ua + "\") or "
else:
cf_single_rule = "(lower(http.user_agent) contains \"" + ua + "\")"
ua_list_cf = ua_list_cf + cf_single_rule
i += 1
# Write Cloudflare configuration to the file "ua_list_cf.txt"
ua_file_cf = open("ua_list_cf.txt", "w")
ua_file_cf.write(ua_list_cf)
ua_file_cf.close
print("Cloudflare firewall rules generated in the file 'ua_list_cf.txt'")
# Generate nginx configuration in the string "ua_list_nginx"
# Using nginx case insensitive matching
ua_list_nginx = "if ($http_user_agent ~* ("
i = 0
for ua in ua_list:
ua_escaped = ua.replace(" ","\ ")
if (i < ua_list_count - 1):
nginx_single_rule = ua_escaped + "|"
else:
nginx_single_rule = ua_escaped
i += 1
ua_list_nginx = ua_list_nginx + nginx_single_rule
ua_list_nginx = ua_list_nginx + ")) {\n return 403;\n}"
# Write nginx configuration to the file "ua_list_nginx.conf"
ua_file_nginx = open("ua_list_nginx.conf", "w")
ua_file_nginx.write(ua_list_nginx)
ua_file_nginx.close
print("Nginx file generated in the file 'ua_list_nginx.conf', please insert this into your Nginx configuration within server{} block")
| ua_file = open('ua_list.txt', 'r')
lines = ua_file.readlines()
ua_list = []
for line in lines:
line_cleaned = line.replace('\n', '').lower()
ua_list.append(line_cleaned)
ua_list.sort()
ua_list = list(dict.fromkeys(ua_list))
ua_list_count = len(ua_list)
print(ua_list)
print('Identified ', ua_list_count, ' UAs in the file.')
ua_file.close()
ua_file_sorted = open('ua_list.txt', 'w')
for ua in ua_list:
ua_line = ua + '\n'
ua_file_sorted.write(ua_line)
ua_file_sorted.close
ua_list_cf = ''
i = 0
for ua in ua_list:
if i < ua_list_count - 1:
cf_single_rule = '(lower(http.user_agent) contains "' + ua + '") or '
else:
cf_single_rule = '(lower(http.user_agent) contains "' + ua + '")'
ua_list_cf = ua_list_cf + cf_single_rule
i += 1
ua_file_cf = open('ua_list_cf.txt', 'w')
ua_file_cf.write(ua_list_cf)
ua_file_cf.close
print("Cloudflare firewall rules generated in the file 'ua_list_cf.txt'")
ua_list_nginx = 'if ($http_user_agent ~* ('
i = 0
for ua in ua_list:
ua_escaped = ua.replace(' ', '\\ ')
if i < ua_list_count - 1:
nginx_single_rule = ua_escaped + '|'
else:
nginx_single_rule = ua_escaped
i += 1
ua_list_nginx = ua_list_nginx + nginx_single_rule
ua_list_nginx = ua_list_nginx + ')) {\n return 403;\n}'
ua_file_nginx = open('ua_list_nginx.conf', 'w')
ua_file_nginx.write(ua_list_nginx)
ua_file_nginx.close
print("Nginx file generated in the file 'ua_list_nginx.conf', please insert this into your Nginx configuration within server{} block") |
# greatest of three
def greatest(a,b,c):
return max(a,b,c)
print(greatest(2,4,3)) | def greatest(a, b, c):
return max(a, b, c)
print(greatest(2, 4, 3)) |
def LCSBackTrack(v, w):
v = '-' + v
w = '-' + w
S = [[0 for i in range(len(w))] for j in range(len(v))]
Backtrack = [[0 for i in range(len(w))] for j in range(len(v))]
for i in range(1, len(v)):
for j in range(1, len(w)):
tmp = S[i - 1][j - 1] + (1 if v[i] == w[j] else 0)
S[i][j] = max([S[i - 1][j], S[i][j - 1], tmp])
if S[i][j] == S[i - 1][j]:
Backtrack[i][j] = 1
elif S[i][j] == S[i][j - 1]:
Backtrack[i][j] = 2
else:
Backtrack[i][j] = 4
LCS = []
while i > 0 and j > 0:
if Backtrack[i][j] == 4:
LCS.append(v[i])
i -= 1
j -= 1
elif Backtrack[i][j] == 2:
j -= 1
else:
i -= 1
return Backtrack
# def OutputLCS(Backtrack, V, i, j):
# # print(str(i) + ' ' + str(j))
# if i == 0 or j == 0:
# return V[i]
# if Backtrack[i][j] == 1:
# return OutputLCS(Backtrack, V, i - 1, j)
# elif Backtrack[i][j] == 2:
# return OutputLCS(Backtrack, V, i, j - 1)
# else:
# return OutputLCS(Backtrack, V, i - 1, j - 1) + V[i]
def OutputLCS(Backtrack, V, i, j):
LCS = []
while i > 0 and j > 0:
if Backtrack[i][j] == 4:
LCS.append(V[i])
i -= 1
j -= 1
elif Backtrack[i][j] == 2:
j -= 1
else:
i -= 1
return LCS
if __name__ == "__main__":
v = input().rstrip()
w = input().rstrip()
Backtrack = LCSBackTrack(v, w)
i = len(Backtrack) - 1
j = len(Backtrack[0]) - 1
res = OutputLCS(Backtrack, v, i, j)
print(''.join(res[::-1])) | def lcs_back_track(v, w):
v = '-' + v
w = '-' + w
s = [[0 for i in range(len(w))] for j in range(len(v))]
backtrack = [[0 for i in range(len(w))] for j in range(len(v))]
for i in range(1, len(v)):
for j in range(1, len(w)):
tmp = S[i - 1][j - 1] + (1 if v[i] == w[j] else 0)
S[i][j] = max([S[i - 1][j], S[i][j - 1], tmp])
if S[i][j] == S[i - 1][j]:
Backtrack[i][j] = 1
elif S[i][j] == S[i][j - 1]:
Backtrack[i][j] = 2
else:
Backtrack[i][j] = 4
lcs = []
while i > 0 and j > 0:
if Backtrack[i][j] == 4:
LCS.append(v[i])
i -= 1
j -= 1
elif Backtrack[i][j] == 2:
j -= 1
else:
i -= 1
return Backtrack
def output_lcs(Backtrack, V, i, j):
lcs = []
while i > 0 and j > 0:
if Backtrack[i][j] == 4:
LCS.append(V[i])
i -= 1
j -= 1
elif Backtrack[i][j] == 2:
j -= 1
else:
i -= 1
return LCS
if __name__ == '__main__':
v = input().rstrip()
w = input().rstrip()
backtrack = lcs_back_track(v, w)
i = len(Backtrack) - 1
j = len(Backtrack[0]) - 1
res = output_lcs(Backtrack, v, i, j)
print(''.join(res[::-1])) |
{
"targets": [
{
"target_name": "boost-parameter",
"type": "none",
"include_dirs": [
"1.57.0/parameter-boost-1.57.0/include"
],
"all_dependent_settings": {
"include_dirs": [
"1.57.0/parameter-boost-1.57.0/include"
]
},
"dependencies": [
"../boost-config/boost-config.gyp:*",
"../boost-detail/boost-detail.gyp:*",
"../boost-optional/boost-optional.gyp:*",
"../boost-core/boost-core.gyp:*",
"../boost-preprocessor/boost-preprocessor.gyp:*",
"../boost-mpl/boost-mpl.gyp:*"
#"../boost-python/boost-python.gyp:*"
]
},
{
"target_name": "boost-parameter_test_deduced",
"type": "executable",
"test": {},
"sources": [ "1.57.0/parameter-boost-1.57.0/test/deduced.cpp" ],
"dependencies": [ "boost-parameter" ],
# this disables building the example on iOS
"conditions": [
["OS=='iOS'",
{
"type": "none"
}
]
]
},
{
"target_name": "boost-parameter_tutorial",
"type": "executable",
"test": {},
"sources": [ "1.57.0/parameter-boost-1.57.0/test/tutorial.cpp" ],
"dependencies": [ "boost-parameter"],
# this disables building the example on iOS
"conditions": [
["OS=='iOS'",
{
"type": "none"
}
]
]
}
]
}
| {'targets': [{'target_name': 'boost-parameter', 'type': 'none', 'include_dirs': ['1.57.0/parameter-boost-1.57.0/include'], 'all_dependent_settings': {'include_dirs': ['1.57.0/parameter-boost-1.57.0/include']}, 'dependencies': ['../boost-config/boost-config.gyp:*', '../boost-detail/boost-detail.gyp:*', '../boost-optional/boost-optional.gyp:*', '../boost-core/boost-core.gyp:*', '../boost-preprocessor/boost-preprocessor.gyp:*', '../boost-mpl/boost-mpl.gyp:*']}, {'target_name': 'boost-parameter_test_deduced', 'type': 'executable', 'test': {}, 'sources': ['1.57.0/parameter-boost-1.57.0/test/deduced.cpp'], 'dependencies': ['boost-parameter'], 'conditions': [["OS=='iOS'", {'type': 'none'}]]}, {'target_name': 'boost-parameter_tutorial', 'type': 'executable', 'test': {}, 'sources': ['1.57.0/parameter-boost-1.57.0/test/tutorial.cpp'], 'dependencies': ['boost-parameter'], 'conditions': [["OS=='iOS'", {'type': 'none'}]]}]} |
# -*- coding: utf-8 -*-
{
'name': "WooCommerce Connector",
'summary': """This module enables users to connect woocommerce api to odoo modules of sales, partners and inventory""",
'description': """
Following are the steps to use this module effectively:
1) Put in the KEY and SECRET in the connection menu.
2) Click Sync Button on the list.
3) Orders, Customers and Products will be Imported from WooCommerce to Odoo.
Data will be displayed on the WooCommerce Connector App as well as the odoo modules.
More updates will be pushed frequently. Contributors are invited and appreciated.
This is a free module and for more information contact on WhatsApp +923340239555.
""",
'author': "Saad Mujeeb - ISAA TECH",
'website': "https://www.isaatech.com",
'category': 'Connectors',
'version': '0.1',
# any module necessary for this one to work correctly
'depends': [],
'images': ['static/description/banner.png'],
# always loaded
'data': [
'security/ir.model.access.csv',
'data/sequence.xml',
'views/views.xml',
'views/orders.xml',
'views/products.xml',
'views/customers.xml',
],
'installable': True,
'application': True,
'auto_install': False
}
| {'name': 'WooCommerce Connector', 'summary': 'This module enables users to connect woocommerce api to odoo modules of sales, partners and inventory', 'description': '\n Following are the steps to use this module effectively:\n 1) Put in the KEY and SECRET in the connection menu.\n 2) Click Sync Button on the list.\n 3) Orders, Customers and Products will be Imported from WooCommerce to Odoo.\n Data will be displayed on the WooCommerce Connector App as well as the odoo modules.\n \n More updates will be pushed frequently. Contributors are invited and appreciated.\n This is a free module and for more information contact on WhatsApp +923340239555.\n ', 'author': 'Saad Mujeeb - ISAA TECH', 'website': 'https://www.isaatech.com', 'category': 'Connectors', 'version': '0.1', 'depends': [], 'images': ['static/description/banner.png'], 'data': ['security/ir.model.access.csv', 'data/sequence.xml', 'views/views.xml', 'views/orders.xml', 'views/products.xml', 'views/customers.xml'], 'installable': True, 'application': True, 'auto_install': False} |
class AbstractBatchifier(object):
def filter(self, games):
return games
def apply(self, games):
return games
| class Abstractbatchifier(object):
def filter(self, games):
return games
def apply(self, games):
return games |
"""https://leetcode.com/problems/permutations-ii/
47. Permutations II
Medium
Given a collection of numbers, nums, that might contain duplicates,
return all possible unique permutations in any order.
Examples:
>>> Solution().permuteUnique([])
[[]]
Constraints:
1 <= nums.length <= 8
-10 <= nums[i] <= 10
Restrict insertion past the first occurrence of a duplicate value (if one exists)
To prevent adding a duplicate permutation,
we only allow insertion of a duplicate element once,
immediately to the left of the first already-existing duplicate value in the permutation
and break out of the loop since further iterations will create duplicate permutations.
---
Very smart way to eliminate the duplicate.
Here is my understanding about the eliminate process.
After several times of append and other operations,
#here I just pay attention to one element, 2's position in the inner list
We get the current list like below:
[2,x,x,x]
[x,2,x,x]
[x,x,2,x]
[x,x,x,2]
Of course if we replace the "x" with other elements,
there should be several other lists in each row,
but the position of "2" should just be same,
[0],[1],[2],[3] for each row.
The approach will traverse each list and insert the new element.
If the new element is "2", the current "for loop" will break.
Therefor,after the two loops,the "2" 's position in the list should be:
[0,1]
[0,2],[1,2]
[0,3],[1,3],[2,3]
[0,4],[1,4],[2,4],[3,4]
It will actually cover all the situation of the two 2's distribution.
subsets = [[]]
for num in [1,2,1,1]:
[] start
[(1)] ins(1)
[(2),1],[1,(2)] ins(2)
implicit break => avoids [1,(1),2]
v v
[(1),2,1],[2,(1),1],[(1),1,2] ins(1)
=> avoids [1,(1),2,1]... => avoids [2,1,(1),1]... => avoids [1,(1),1,2]...
v v v
[(1),1,2,1],[(1),2,1,1],[2,(1),1,1], [(1),1,1,2] ins(1)
return [1,1,2,1],[1,2,1,1],[2,1,1,1],[1,1,1,2]
---
Great solution! Here is a short (casual) proof about why break can avoid the duplication.
Argument: Assume curr_unique_permutations is a list of unique permutations
with each item length k,
then new_unique_permutations is a list of unique permutation with length k+1.
When k=0, it holds.
Then we prove it will also holds in each iteration using proof by contradiction.
Suppose duplicate happens when inserting num into the jth location,
the result is [l2[:char_idx], num, l2[char_idx:]],
and it duplicates with the item [l1[:j], num, l1[j:]]
- Suppose char_idx < j,
then we have l1[char_idx]==num,
however, we will break when l1[char_idx]==num,
and thus num will not be inserted after l1[:j] -> contradiction,
- Suppose char_idx > j,
then we have l2[j] == num,
however we will break when l2[j] == num,
and thus num will not be inserted after l2[:char_idx] -> contradiction.
- Suppose char_idx==j,
then we have l1==l2,
which contradicts the assumption that curr_unique_permutations is a list of unique permutations.
Thus the argument hold.
---
See Also:
- https://leetcode.com/problems/permutations-ii/discuss/18602/9-line-python-solution-with-1-line-to-handle-duplication-beat-99-of-others-%3A-)
- [Permutations Involving Repeated Symbols - Example 1](https://www.youtube.com/watch?v=3VBdsNCSBXM)
- [Permutations II - Backtracking - Leetcode 47](https://www.youtube.com/watch?v=qhBVWf0YafA)
- https://leetcode.com/problems/permutations-ii/discuss/189116/summarization-of-permutations-I-and-II-(Python)
"""
class Solution:
def permuteUnique(self, nums: list[int]) -> list[list[int]]:
return permute_unique(nums)
def permute_unique(nums: list[int]) -> list[list[int]]:
"""Compute all the *unique* permutations of the elements in a given input array
Args:
nums: array of possibly non-distinct elements
Returns: all *unique* permutations of elements in `nums`
Examples:
>>> sorted(permute_unique([1,1,2]))
[[1, 1, 2], [1, 2, 1], [2, 1, 1]]
>>> sorted(permute_unique([1,2,1,1]))
[[1, 1, 1, 2], [1, 1, 2, 1], [1, 2, 1, 1], [2, 1, 1, 1]]
>>> sorted(permute_unique([1,2,3]))
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
"""
"""ALGORITHM"""
def get_last_valid_insertion_idx(perm, item):
"""Restrict insertion past the first occurrence of a duplicate value (if one exists)"""
# equivalent to `(perm + [item]).index(item)`
try:
return perm.index(item)
except ValueError:
return len(perm)
# DS's/res
uniq_perms = [[]]
# Build unique permutations
# increasing the permutation size by 1 at each iteration
for curr_num in nums:
uniq_perms = [
perm[:insertion_idx] + [curr_num] + perm[insertion_idx:]
for perm in uniq_perms
for insertion_idx in range(get_last_valid_insertion_idx(perm, curr_num) + 1)
]
return uniq_perms
def permute_unique_i(nums: list[int]) -> list[list[int]]:
"""Compute all the *unique* permutations of the elements in a given input array
Args:
nums: array of possibly non-distinct elements
Returns: all *unique* permutations of elements in `nums`
Examples:
>>> sorted(permute_unique_i([1,1,2]))
[[1, 1, 2], [1, 2, 1], [2, 1, 1]]
>>> sorted(permute_unique_i([1,2,1,1]))
[[1, 1, 1, 2], [1, 1, 2, 1], [1, 2, 1, 1], [2, 1, 1, 1]]
>>> sorted(permute_unique_i([1,2,3]))
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
"""
"""ALGORITHM"""
def get_last_valid_insertion_idx(perm, item): # nosemgrep
"""Restrict insertion past the first occurrence of a duplicate value (if one exists)"""
# equivalent to `(perm + [item]).index(item)`
try:
return perm.index(item)
except ValueError:
return len(perm)
# DS's/res
uniq_perms = [[]]
# Build unique permutations
# increasing the permutation size by 1 at each iteration
for curr_num in nums:
np = []
for perm in uniq_perms:
for insertion_idx in range(
get_last_valid_insertion_idx(perm, curr_num) + 1
):
new_perm = perm.copy()
new_perm.insert(insertion_idx, curr_num)
np.append(new_perm)
uniq_perms = np
return uniq_perms
def permute_unique_long(nums: list[int]) -> list[list[int]]:
"""Compute all the *unique* permutations of the elements in a given
input array
Args:
nums: array of possibly non-distinct elements
Returns: all *unique* permutations of elements in `nums`
Examples:
>>> sorted(permute_unique_long([1,1,2]))
[[1, 1, 2], [1, 2, 1], [2, 1, 1]]
>>> sorted(permute_unique_long([1,2,1,1]))
[[1, 1, 1, 2], [1, 1, 2, 1], [1, 2, 1, 1], [2, 1, 1, 1]]
>>> sorted(permute_unique_long([1,2,3]))
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
"""
"""ALGORITHM"""
uniq_perms = [[]] # Initialized with the empty set
# for each iteration, size of current permutations will increase by 1
# => at the end of the algorithm, size of each permutation will be equal to len(nums)
for curr_num in nums:
new_uniq_perms = []
for perm in uniq_perms:
# Insert element at each position in existing permutation to create new permutation
for insertion_idx in range(len(perm) + 1):
# Bisect-left: Insert `curr_num` to the left of insertion_idx in perm
# increases size of permutation by 1
new_perm = perm[:insertion_idx] + [curr_num] + perm[insertion_idx:]
new_uniq_perms.append(new_perm)
# Prevents duplicates
# equivalent to setting the for loop as:
# `for insertion_idx in range(get_last_valid_insertion_idx(perm,curr_num) + 1):`
if insertion_idx < len(perm) and perm[insertion_idx] == curr_num:
break
uniq_perms = new_uniq_perms
return uniq_perms
def permute_unique_set(nums: list[int]) -> list[list[int]]:
"""Compute all the *unique* permutations of the elements in a given input array
Args:
nums: array of possibly non-distinct elements
Returns: all *unique* permutations of elements in `nums`
Examples:
>>> sorted(permute_unique_set([1,1,2]))
[[1, 1, 2], [1, 2, 1], [2, 1, 1]]
>>> sorted(permute_unique_set([1,2,1,1]))
[[1, 1, 1, 2], [1, 1, 2, 1], [1, 2, 1, 1], [2, 1, 1, 1]]
>>> sorted(permute_unique_set([1,2,3]))
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
"""
uniq_perms = {tuple()} # Initialized with the empty set
# for each iteration, size of current permutations will increase by 1
# => at the end of the algorithm, size of each permutation will be equal to len(nums)
for curr_num in nums:
# Bisect-left: Insert `curr_num` to the left of insertion_idx in perm
# (increases size of permutation by 1)
uniq_perms = {
# tuples for hashability
(*perm[:insertion_idx], curr_num, *perm[insertion_idx:])
for perm in uniq_perms
for insertion_idx in range(len(perm) + 1)
}
return [list(permutation) for permutation in uniq_perms]
def permute_unique_backtrack(nums: list[int]) -> list[list[int]]:
"""Compute all the *unique* permutations of the elements in a given input array
Args:
nums: array of possibly non-distinct elements
Returns: all *unique* permutations of elements in `nums`
Examples:
>>> sorted(permute_unique_backtrack([1,1,2]))
[[1, 1, 2], [1, 2, 1], [2, 1, 1]]
>>> sorted(permute_unique_backtrack([1,2,1,1]))
[[1, 1, 1, 2], [1, 1, 2, 1], [1, 2, 1, 1], [2, 1, 1, 1]]
>>> sorted(permute_unique_backtrack([1,2,3]))
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
"""
## INITIALIZE VARS ##
# DS's/res
nums_counts = {}
for num in nums:
nums_counts[num] = nums_counts.get(num, 0) + 1
res = []
# Populate res
def compute_possible_permutations(sub_permutation):
# BASE CASE
if len(sub_permutation) == len(nums):
res.append(sub_permutation.copy())
else:
for curr_num in nums_counts: # iterate over *distinct* elements
# If there are remaining instances of `curr_num` left to choose
# => Select curr_num at this position
# and continue building permutation from remaining elements
if nums_counts[curr_num] > 0:
## BACKTRACK
# Save space by in-place appending/popping
nums_counts[curr_num] -= 1 # Select `curr_num` at current position
sub_permutation.append(curr_num)
compute_possible_permutations(sub_permutation)
sub_permutation.pop()
nums_counts[
curr_num
] += 1 # Deselect `curr_num` at current position
compute_possible_permutations(sub_permutation=[]) # initialize with empty list
return res
def permute_unique_backtrack_stack(nums: list[int]) -> list[list[int]]:
"""Compute all the *unique* permutations of the elements in a given input array
Args:
nums: array of possibly non-distinct elements
Returns: all *unique* permutations of elements in `nums`
Examples:
# >>> sorted(permute_unique_backtrack_stack([1,1,2]))
# [[1, 1, 2], [1, 2, 1], [2, 1, 1]]
>>> sorted(permute_unique_backtrack_stack([1,2,1,1]))
[[1, 1, 1, 2], [1, 1, 2, 1], [1, 2, 1, 1], [2, 1, 1, 1]]
>>> sorted(permute_unique_backtrack_stack([1,2,3]))
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
"""
# TODO stack-based backtracking
# 2. Your implementation is allowed to use a Stack, a Queue
# Hint: Use the stack to store the elements
# yet to be used to generate the permutations,
# and use the queue to store the (partial) collection of permutations
# generated so far.
## INITIALIZE VARS ##
# DS's/res
nums_counts = {}
for num in nums:
nums_counts[num] = nums_counts.get(num, 0) + 1
res = []
stack = [[]] # empty set on stack
# stack2 = [[[]]] # empty set on stack
while stack:
sub_permutation = stack.pop()
# sub_perms = stack2.pop()
# track state?
# BASE CASE
if len(sub_permutation) == len(nums):
res.append(sub_permutation)
else:
# TODO: find a way to avoid nums_count updates every time
# without passing in a a dict
for used_num in sub_permutation:
nums_counts[used_num] -= 1 # Select `curr_num` at current position
children = [
sub_permutation + [curr_num]
for curr_num in nums_counts
if nums_counts[curr_num] > 0
]
stack.extend(children)
# stack2.append(children)
# cats = 2
# for curr_num in nums_counts:
#
# # If there are remaining instances of `curr_num` left to choose
# # => Select curr_num at this position
# # and continue building permutation from remaining elements
# if nums_counts[curr_num] > 0:
# stack.append(sub_permutation + [curr_num])
for used_num in sub_permutation:
nums_counts[used_num] += 1 # Deselect `curr_num` at current position
return res
def permute_unique_matt(nums: list[int]) -> list[list[int]]:
"""Compute all the *unique* permutations of the elements in a given input array
Args:
nums: array of possibly non-distinct elements
Returns: all *unique* permutations of elements in `nums`
Examples:
>>> sorted(permute_unique_matt([1,1,2]))
[[1, 1, 2], [1, 2, 1], [2, 1, 1]]
>>> sorted(permute_unique_matt([1,2,1,1]))
[[1, 1, 1, 2], [1, 1, 2, 1], [1, 2, 1, 1], [2, 1, 1, 1]]
>>> sorted(permute_unique_matt([1,2,3]))
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
"""
if len(nums) == 1:
return [nums]
uniq_perms = []
already_used_set_of_elements_at_curr_pos = set()
for curr_num in nums:
# Since we are selecting elements at the current pos,
# skip repeated elements we had already explored once before
if curr_num not in already_used_set_of_elements_at_curr_pos:
nums_tmp = nums.copy()
nums_tmp.remove(curr_num)
uniq_perms.extend(
[
[curr_num] + sub_permutation
for sub_permutation in permute_unique_matt(nums_tmp)
]
)
already_used_set_of_elements_at_curr_pos.add(curr_num)
return uniq_perms
def permute_unique_matt_teo(nums: list[int]) -> list[list[int]]:
"""Compute all the *unique* permutations of the elements in a given input array
Args:
nums: array of possibly non-distinct elements
Returns: all *unique* permutations of elements in `nums`
Examples:
>>> sorted(permute_unique_matt_teo([1,1,2]))
[[1, 1, 2], [1, 2, 1], [2, 1, 1]]
>>> sorted(permute_unique_matt_teo([1,2,1,1]))
[[1, 1, 1, 2], [1, 1, 2, 1], [1, 2, 1, 1], [2, 1, 1, 1]]
>>> sorted(permute_unique_matt_teo([1,2,3]))
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
"""
if len(nums) == 1:
return [nums]
distinct_nums = {num for num in nums}
uniq_perms = []
for curr_num in distinct_nums:
nums_tmp = nums.copy()
nums_tmp.remove(curr_num)
uniq_perms.extend(
[
[curr_num] + sub_permutation
for sub_permutation in permute_unique_matt_teo(nums_tmp)
]
)
return uniq_perms
| """https://leetcode.com/problems/permutations-ii/
47. Permutations II
Medium
Given a collection of numbers, nums, that might contain duplicates,
return all possible unique permutations in any order.
Examples:
>>> Solution().permuteUnique([])
[[]]
Constraints:
1 <= nums.length <= 8
-10 <= nums[i] <= 10
Restrict insertion past the first occurrence of a duplicate value (if one exists)
To prevent adding a duplicate permutation,
we only allow insertion of a duplicate element once,
immediately to the left of the first already-existing duplicate value in the permutation
and break out of the loop since further iterations will create duplicate permutations.
---
Very smart way to eliminate the duplicate.
Here is my understanding about the eliminate process.
After several times of append and other operations,
#here I just pay attention to one element, 2's position in the inner list
We get the current list like below:
[2,x,x,x]
[x,2,x,x]
[x,x,2,x]
[x,x,x,2]
Of course if we replace the "x" with other elements,
there should be several other lists in each row,
but the position of "2" should just be same,
[0],[1],[2],[3] for each row.
The approach will traverse each list and insert the new element.
If the new element is "2", the current "for loop" will break.
Therefor,after the two loops,the "2" 's position in the list should be:
[0,1]
[0,2],[1,2]
[0,3],[1,3],[2,3]
[0,4],[1,4],[2,4],[3,4]
It will actually cover all the situation of the two 2's distribution.
subsets = [[]]
for num in [1,2,1,1]:
[] start
[(1)] ins(1)
[(2),1],[1,(2)] ins(2)
implicit break => avoids [1,(1),2]
v v
[(1),2,1],[2,(1),1],[(1),1,2] ins(1)
=> avoids [1,(1),2,1]... => avoids [2,1,(1),1]... => avoids [1,(1),1,2]...
v v v
[(1),1,2,1],[(1),2,1,1],[2,(1),1,1], [(1),1,1,2] ins(1)
return [1,1,2,1],[1,2,1,1],[2,1,1,1],[1,1,1,2]
---
Great solution! Here is a short (casual) proof about why break can avoid the duplication.
Argument: Assume curr_unique_permutations is a list of unique permutations
with each item length k,
then new_unique_permutations is a list of unique permutation with length k+1.
When k=0, it holds.
Then we prove it will also holds in each iteration using proof by contradiction.
Suppose duplicate happens when inserting num into the jth location,
the result is [l2[:char_idx], num, l2[char_idx:]],
and it duplicates with the item [l1[:j], num, l1[j:]]
- Suppose char_idx < j,
then we have l1[char_idx]==num,
however, we will break when l1[char_idx]==num,
and thus num will not be inserted after l1[:j] -> contradiction,
- Suppose char_idx > j,
then we have l2[j] == num,
however we will break when l2[j] == num,
and thus num will not be inserted after l2[:char_idx] -> contradiction.
- Suppose char_idx==j,
then we have l1==l2,
which contradicts the assumption that curr_unique_permutations is a list of unique permutations.
Thus the argument hold.
---
See Also:
- https://leetcode.com/problems/permutations-ii/discuss/18602/9-line-python-solution-with-1-line-to-handle-duplication-beat-99-of-others-%3A-)
- [Permutations Involving Repeated Symbols - Example 1](https://www.youtube.com/watch?v=3VBdsNCSBXM)
- [Permutations II - Backtracking - Leetcode 47](https://www.youtube.com/watch?v=qhBVWf0YafA)
- https://leetcode.com/problems/permutations-ii/discuss/189116/summarization-of-permutations-I-and-II-(Python)
"""
class Solution:
def permute_unique(self, nums: list[int]) -> list[list[int]]:
return permute_unique(nums)
def permute_unique(nums: list[int]) -> list[list[int]]:
"""Compute all the *unique* permutations of the elements in a given input array
Args:
nums: array of possibly non-distinct elements
Returns: all *unique* permutations of elements in `nums`
Examples:
>>> sorted(permute_unique([1,1,2]))
[[1, 1, 2], [1, 2, 1], [2, 1, 1]]
>>> sorted(permute_unique([1,2,1,1]))
[[1, 1, 1, 2], [1, 1, 2, 1], [1, 2, 1, 1], [2, 1, 1, 1]]
>>> sorted(permute_unique([1,2,3]))
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
"""
'ALGORITHM'
def get_last_valid_insertion_idx(perm, item):
"""Restrict insertion past the first occurrence of a duplicate value (if one exists)"""
try:
return perm.index(item)
except ValueError:
return len(perm)
uniq_perms = [[]]
for curr_num in nums:
uniq_perms = [perm[:insertion_idx] + [curr_num] + perm[insertion_idx:] for perm in uniq_perms for insertion_idx in range(get_last_valid_insertion_idx(perm, curr_num) + 1)]
return uniq_perms
def permute_unique_i(nums: list[int]) -> list[list[int]]:
"""Compute all the *unique* permutations of the elements in a given input array
Args:
nums: array of possibly non-distinct elements
Returns: all *unique* permutations of elements in `nums`
Examples:
>>> sorted(permute_unique_i([1,1,2]))
[[1, 1, 2], [1, 2, 1], [2, 1, 1]]
>>> sorted(permute_unique_i([1,2,1,1]))
[[1, 1, 1, 2], [1, 1, 2, 1], [1, 2, 1, 1], [2, 1, 1, 1]]
>>> sorted(permute_unique_i([1,2,3]))
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
"""
'ALGORITHM'
def get_last_valid_insertion_idx(perm, item):
"""Restrict insertion past the first occurrence of a duplicate value (if one exists)"""
try:
return perm.index(item)
except ValueError:
return len(perm)
uniq_perms = [[]]
for curr_num in nums:
np = []
for perm in uniq_perms:
for insertion_idx in range(get_last_valid_insertion_idx(perm, curr_num) + 1):
new_perm = perm.copy()
new_perm.insert(insertion_idx, curr_num)
np.append(new_perm)
uniq_perms = np
return uniq_perms
def permute_unique_long(nums: list[int]) -> list[list[int]]:
"""Compute all the *unique* permutations of the elements in a given
input array
Args:
nums: array of possibly non-distinct elements
Returns: all *unique* permutations of elements in `nums`
Examples:
>>> sorted(permute_unique_long([1,1,2]))
[[1, 1, 2], [1, 2, 1], [2, 1, 1]]
>>> sorted(permute_unique_long([1,2,1,1]))
[[1, 1, 1, 2], [1, 1, 2, 1], [1, 2, 1, 1], [2, 1, 1, 1]]
>>> sorted(permute_unique_long([1,2,3]))
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
"""
'ALGORITHM'
uniq_perms = [[]]
for curr_num in nums:
new_uniq_perms = []
for perm in uniq_perms:
for insertion_idx in range(len(perm) + 1):
new_perm = perm[:insertion_idx] + [curr_num] + perm[insertion_idx:]
new_uniq_perms.append(new_perm)
if insertion_idx < len(perm) and perm[insertion_idx] == curr_num:
break
uniq_perms = new_uniq_perms
return uniq_perms
def permute_unique_set(nums: list[int]) -> list[list[int]]:
"""Compute all the *unique* permutations of the elements in a given input array
Args:
nums: array of possibly non-distinct elements
Returns: all *unique* permutations of elements in `nums`
Examples:
>>> sorted(permute_unique_set([1,1,2]))
[[1, 1, 2], [1, 2, 1], [2, 1, 1]]
>>> sorted(permute_unique_set([1,2,1,1]))
[[1, 1, 1, 2], [1, 1, 2, 1], [1, 2, 1, 1], [2, 1, 1, 1]]
>>> sorted(permute_unique_set([1,2,3]))
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
"""
uniq_perms = {tuple()}
for curr_num in nums:
uniq_perms = {(*perm[:insertion_idx], curr_num, *perm[insertion_idx:]) for perm in uniq_perms for insertion_idx in range(len(perm) + 1)}
return [list(permutation) for permutation in uniq_perms]
def permute_unique_backtrack(nums: list[int]) -> list[list[int]]:
"""Compute all the *unique* permutations of the elements in a given input array
Args:
nums: array of possibly non-distinct elements
Returns: all *unique* permutations of elements in `nums`
Examples:
>>> sorted(permute_unique_backtrack([1,1,2]))
[[1, 1, 2], [1, 2, 1], [2, 1, 1]]
>>> sorted(permute_unique_backtrack([1,2,1,1]))
[[1, 1, 1, 2], [1, 1, 2, 1], [1, 2, 1, 1], [2, 1, 1, 1]]
>>> sorted(permute_unique_backtrack([1,2,3]))
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
"""
nums_counts = {}
for num in nums:
nums_counts[num] = nums_counts.get(num, 0) + 1
res = []
def compute_possible_permutations(sub_permutation):
if len(sub_permutation) == len(nums):
res.append(sub_permutation.copy())
else:
for curr_num in nums_counts:
if nums_counts[curr_num] > 0:
nums_counts[curr_num] -= 1
sub_permutation.append(curr_num)
compute_possible_permutations(sub_permutation)
sub_permutation.pop()
nums_counts[curr_num] += 1
compute_possible_permutations(sub_permutation=[])
return res
def permute_unique_backtrack_stack(nums: list[int]) -> list[list[int]]:
"""Compute all the *unique* permutations of the elements in a given input array
Args:
nums: array of possibly non-distinct elements
Returns: all *unique* permutations of elements in `nums`
Examples:
# >>> sorted(permute_unique_backtrack_stack([1,1,2]))
# [[1, 1, 2], [1, 2, 1], [2, 1, 1]]
>>> sorted(permute_unique_backtrack_stack([1,2,1,1]))
[[1, 1, 1, 2], [1, 1, 2, 1], [1, 2, 1, 1], [2, 1, 1, 1]]
>>> sorted(permute_unique_backtrack_stack([1,2,3]))
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
"""
nums_counts = {}
for num in nums:
nums_counts[num] = nums_counts.get(num, 0) + 1
res = []
stack = [[]]
while stack:
sub_permutation = stack.pop()
if len(sub_permutation) == len(nums):
res.append(sub_permutation)
else:
for used_num in sub_permutation:
nums_counts[used_num] -= 1
children = [sub_permutation + [curr_num] for curr_num in nums_counts if nums_counts[curr_num] > 0]
stack.extend(children)
for used_num in sub_permutation:
nums_counts[used_num] += 1
return res
def permute_unique_matt(nums: list[int]) -> list[list[int]]:
"""Compute all the *unique* permutations of the elements in a given input array
Args:
nums: array of possibly non-distinct elements
Returns: all *unique* permutations of elements in `nums`
Examples:
>>> sorted(permute_unique_matt([1,1,2]))
[[1, 1, 2], [1, 2, 1], [2, 1, 1]]
>>> sorted(permute_unique_matt([1,2,1,1]))
[[1, 1, 1, 2], [1, 1, 2, 1], [1, 2, 1, 1], [2, 1, 1, 1]]
>>> sorted(permute_unique_matt([1,2,3]))
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
"""
if len(nums) == 1:
return [nums]
uniq_perms = []
already_used_set_of_elements_at_curr_pos = set()
for curr_num in nums:
if curr_num not in already_used_set_of_elements_at_curr_pos:
nums_tmp = nums.copy()
nums_tmp.remove(curr_num)
uniq_perms.extend([[curr_num] + sub_permutation for sub_permutation in permute_unique_matt(nums_tmp)])
already_used_set_of_elements_at_curr_pos.add(curr_num)
return uniq_perms
def permute_unique_matt_teo(nums: list[int]) -> list[list[int]]:
"""Compute all the *unique* permutations of the elements in a given input array
Args:
nums: array of possibly non-distinct elements
Returns: all *unique* permutations of elements in `nums`
Examples:
>>> sorted(permute_unique_matt_teo([1,1,2]))
[[1, 1, 2], [1, 2, 1], [2, 1, 1]]
>>> sorted(permute_unique_matt_teo([1,2,1,1]))
[[1, 1, 1, 2], [1, 1, 2, 1], [1, 2, 1, 1], [2, 1, 1, 1]]
>>> sorted(permute_unique_matt_teo([1,2,3]))
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
"""
if len(nums) == 1:
return [nums]
distinct_nums = {num for num in nums}
uniq_perms = []
for curr_num in distinct_nums:
nums_tmp = nums.copy()
nums_tmp.remove(curr_num)
uniq_perms.extend([[curr_num] + sub_permutation for sub_permutation in permute_unique_matt_teo(nums_tmp)])
return uniq_perms |
#coding:utf-8
'''
filename:clsmethod.py
learn class method
'''
class Message:
msg = 'Python is a smart language.'
def get_msg(self):
print('self :',self)
print('attrs of class(Message.msg):',Message.msg)
print('use type(self).msg:',type(self).msg)
cls = type(self)
print('[cls = type(self)] cls:',cls)
print('attrs of class(cls.msg):',cls.msg)
@classmethod
def get_cls_msg(cls):
print('cls :',cls)
print('attrs of class(cls.msg):',cls.msg)
mess = Message()
mess.get_msg()
print('-'*50)
mess.get_cls_msg()
| """
filename:clsmethod.py
learn class method
"""
class Message:
msg = 'Python is a smart language.'
def get_msg(self):
print('self :', self)
print('attrs of class(Message.msg):', Message.msg)
print('use type(self).msg:', type(self).msg)
cls = type(self)
print('[cls = type(self)] cls:', cls)
print('attrs of class(cls.msg):', cls.msg)
@classmethod
def get_cls_msg(cls):
print('cls :', cls)
print('attrs of class(cls.msg):', cls.msg)
mess = message()
mess.get_msg()
print('-' * 50)
mess.get_cls_msg() |
class Solution:
def findNumbers(self, nums: List[int]) -> int:
if len(nums) == 0:
return 0
return len(list(filter(lambda x:len(str(x))%2==0,nums))) | class Solution:
def find_numbers(self, nums: List[int]) -> int:
if len(nums) == 0:
return 0
return len(list(filter(lambda x: len(str(x)) % 2 == 0, nums))) |
"""
This module contains methods that model the properties of galaxy cluster
populations.
"""
| """
This module contains methods that model the properties of galaxy cluster
populations.
""" |
# 231 - Power Of Two (Easy)
# https://leetcode.com/problems/power-of-two/submissions/
class Solution:
def isPowerOfTwo(self, n: int) -> bool:
return n and (n & (n-1)) == 0
| class Solution:
def is_power_of_two(self, n: int) -> bool:
return n and n & n - 1 == 0 |
random_test_iterations = 64
def repeat(fn):
"""Decorator for running the function's body multiple times."""
def repeated():
i = 0
while i < random_test_iterations:
fn()
i += 1
# nosetest runs functions that start with 'test_'
repeated.__name__ = fn.__name__
return repeated
| random_test_iterations = 64
def repeat(fn):
"""Decorator for running the function's body multiple times."""
def repeated():
i = 0
while i < random_test_iterations:
fn()
i += 1
repeated.__name__ = fn.__name__
return repeated |
# Some sites give IR codes in this weird pronto format
# Cut off the preamble and footer and find which value represents a 1 in the spacing
code = "0000 0016 0000 0016 0000 0016 0000 003F 0000 003F 0000 003F 0000 0016 0000 003F 0000 0016 0000 0016 0000 0016 0000 0016 0000 0016 0000 0016 0000 0016 0000 0016 0000 0016 0000 003F 0000 0016 0000 003F 0000 003F 0000 0016 0000 0016 0000 003F 0000 003F 0000 0016 0000 003F 0000 0016 0000 0016 0000 003F 0000 003F 0000 0016 0000"
print(int(''.join(list(map(lambda x: "1" if x == '003F' else "0", code.split(' ')[1::2]))), 2)) | code = '0000 0016 0000 0016 0000 0016 0000 003F 0000 003F 0000 003F 0000 0016 0000 003F 0000 0016 0000 0016 0000 0016 0000 0016 0000 0016 0000 0016 0000 0016 0000 0016 0000 0016 0000 003F 0000 0016 0000 003F 0000 003F 0000 0016 0000 0016 0000 003F 0000 003F 0000 0016 0000 003F 0000 0016 0000 0016 0000 003F 0000 003F 0000 0016 0000'
print(int(''.join(list(map(lambda x: '1' if x == '003F' else '0', code.split(' ')[1::2]))), 2)) |
# ----------------------------------------------------------------------------
# This software is in the public domain, furnished "as is", without technical
# support, and with no warranty, express or implied, as to its usefulness for
# any purpose.
#
# iscSendSampleDef
#
# Author: mathewson
# ----------------------------------------------------------------------------
##
# This is an absolute override file, indicating that a higher priority version
# of the file will completely replace a lower priority version of the file.
##
# The configuration interval file is an optional capability of ifpnetCDF.
# It can be used to select certain grids to be placed in the ifpnetCDF
# output file, rather than all grids in the inventory. For example, you can
# choose to only include 3-hrly temperature grids out to 24 hours, then
# 6-hrly temperature grids out to 72 hours, and then no temperature grids
# past 72 hours. You can control this capability on a per weather element
# basis. The definition determines a set of explicit times. If there
# is a grid that contains that explicit time, then the grid is included in
# the output.
# The configuration interval file is a python file and must reside in the
# ifpServer's TEXT/Utility directory. You can create the file through the
# use of the GFE, with the GFE->Define Text Products menu, or by using
# a conventional text editor and the ifpServerText utility.
# This is the default for ifpnetCDF with regard to its use with ISC traffic.
# The data is sent from -24h to the future in 1 hour intervals.
HR=3600
SampleDef = {}
SampleDef['default'] = (
[0*HR], #first tuple is basetimes
[ #2nd tuple is list of offset from basetime, interval
(-24*HR, 1*HR), #start at basetime, take every hour
])
| hr = 3600
sample_def = {}
SampleDef['default'] = ([0 * HR], [(-24 * HR, 1 * HR)]) |
#Write a program (using functions!) that asks the user for a long string containing multiple words.
# Print back to the user the same string, except with the words in backwards order. For example, say I type the string:
# My name is Michele
#Then I would see the string:
# Michele is name My
#shown back to me.
def reverse(strng: str):
list = strng.split(' ')
list.reverse()
return list
print(reverse("My name is Michele")) | def reverse(strng: str):
list = strng.split(' ')
list.reverse()
return list
print(reverse('My name is Michele')) |
# coding: utf-8
def test_index(admin_client):
"""
Basic test to see if it even works.
"""
url = "/nothing-to-see-here/"
HTTP_OK_200 = 200
respnse = admin_client.get(url)
assert respnse.status_code == HTTP_OK_200
| def test_index(admin_client):
"""
Basic test to see if it even works.
"""
url = '/nothing-to-see-here/'
http_ok_200 = 200
respnse = admin_client.get(url)
assert respnse.status_code == HTTP_OK_200 |
def strategy(history, memory):
if memory is None or 1 == memory:
return 0, 0
else:
return 1, 1
| def strategy(history, memory):
if memory is None or 1 == memory:
return (0, 0)
else:
return (1, 1) |
with open("promote.in") as input_file:
input_lst = [[*map(int, line.split())] for line in input_file]
promotions = [
promotion[1] - promotion[0] for promotion in input_lst
]
output = []
for promotion in promotions[::-1]:
output.append(sum([]))
with open("promote.out", "w") as output_file:
for promotion in promotions:
print(promotion, file=output_file)
# print(input_lst)
| with open('promote.in') as input_file:
input_lst = [[*map(int, line.split())] for line in input_file]
promotions = [promotion[1] - promotion[0] for promotion in input_lst]
output = []
for promotion in promotions[::-1]:
output.append(sum([]))
with open('promote.out', 'w') as output_file:
for promotion in promotions:
print(promotion, file=output_file) |
sample_text = '''
The textwrap module can be used to format text for output in
situations where pretty-printing is desired. It offers
programmatic functionality similar to the paragraph wrapping
or filling features found in many text editors.
''' | sample_text = '\n The textwrap module can be used to format text for output in\n situations where pretty-printing is desired. It offers\n programmatic functionality similar to the paragraph wrapping\n or filling features found in many text editors.\n ' |
# Write your solutions for 1.5 here!
class Superheros:
def __init__(self, name, superpower, strength):
self.name = name
self.superpower = superpower
self.strength = strength
def hero (self):
print(self.name)
print(self.strength)
def save_civilian (self, work):
if work > self.strength:
print("Superhero is not strong enough! :(")
else:
self.strength = self.strength - work
superman = Superheros("Super Man", "strong", 8)
hero(superman)
save_civilian(superman, 9)
hero(superman)
| class Superheros:
def __init__(self, name, superpower, strength):
self.name = name
self.superpower = superpower
self.strength = strength
def hero(self):
print(self.name)
print(self.strength)
def save_civilian(self, work):
if work > self.strength:
print('Superhero is not strong enough! :(')
else:
self.strength = self.strength - work
superman = superheros('Super Man', 'strong', 8)
hero(superman)
save_civilian(superman, 9)
hero(superman) |
# Copyright (c) 2011 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'targets': [
{
'target_name': 'prefix_header',
'type': 'static_library',
'sources': [ 'file.c', ],
'xcode_settings': {
'GCC_PREFIX_HEADER': 'header.h',
},
},
{
'target_name': 'precompiled_prefix_header',
'type': 'shared_library',
'mac_bundle': 1,
'sources': [ 'file.c', ],
'xcode_settings': {
'GCC_PREFIX_HEADER': 'header.h',
'GCC_PRECOMPILE_PREFIX_HEADER': 'YES',
},
},
],
}
| {'targets': [{'target_name': 'prefix_header', 'type': 'static_library', 'sources': ['file.c'], 'xcode_settings': {'GCC_PREFIX_HEADER': 'header.h'}}, {'target_name': 'precompiled_prefix_header', 'type': 'shared_library', 'mac_bundle': 1, 'sources': ['file.c'], 'xcode_settings': {'GCC_PREFIX_HEADER': 'header.h', 'GCC_PRECOMPILE_PREFIX_HEADER': 'YES'}}]} |
#FACTORIAL OF A NUMBER
a = input("Enter number1")
a=int(a)
factorial=1
if a==1:
print('Factorial is 1')
elif a<1:
print('Please enter a valid number')
else:
for i in range(1, a+1):
factorial *= i
print(f'The factorial is {factorial}') | a = input('Enter number1')
a = int(a)
factorial = 1
if a == 1:
print('Factorial is 1')
elif a < 1:
print('Please enter a valid number')
else:
for i in range(1, a + 1):
factorial *= i
print(f'The factorial is {factorial}') |
# Copyright 2020 Q-CTRL Pty Ltd & Q-CTRL Inc
#
# 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.
"""
Defines constants for driven controls module.
"""
# Maximum allowed rabi rate
UPPER_BOUND_RABI_RATE = 1e10
# Maximum allowed detuning rate
UPPER_BOUND_DETUNING_RATE = UPPER_BOUND_RABI_RATE
# Maximum allowed duration of a control
UPPER_BOUND_DURATION = 1e6
# Minimum allowed duration of a control
LOWER_BOUND_DURATION = 1e-12
# Maximum number of segments allowed in a control
UPPER_BOUND_SEGMENTS = 10000
# Primitive control
PRIMITIVE = "primitive"
# First-order Wimperis control, also known as BB1
BB1 = "BB1"
# First-order Solovay-Kitaev control
SK1 = "SK1"
# First-order Walsh sequence control
WAMF1 = "WAMF1"
# Dynamically corrected control - Compensating for Off-Resonance with a Pulse Sequence (COPRSE)
CORPSE = "CORPSE"
# Concatenated dynamically corrected control - BB1 inside COPRSE
CORPSE_IN_BB1 = "CORPSE in BB1"
# Concatenated dynamically corrected control - First order Solovay-Kitaev inside COPRSE
CORPSE_IN_SK1 = "CORPSE in SK1"
# Dynamically corrected control
# Short Composite Rotation For Undoing Length Over and Under Shoot (SCROFULOUS)
SCROFULOUS = "SCROFULOUS"
# Concatenated dynamically corrected control - CORPSE inside SCROFULOUS
CORPSE_IN_SCROFULOUS = "CORPSE in SCROFULOUS"
| """
Defines constants for driven controls module.
"""
upper_bound_rabi_rate = 10000000000.0
upper_bound_detuning_rate = UPPER_BOUND_RABI_RATE
upper_bound_duration = 1000000.0
lower_bound_duration = 1e-12
upper_bound_segments = 10000
primitive = 'primitive'
bb1 = 'BB1'
sk1 = 'SK1'
wamf1 = 'WAMF1'
corpse = 'CORPSE'
corpse_in_bb1 = 'CORPSE in BB1'
corpse_in_sk1 = 'CORPSE in SK1'
scrofulous = 'SCROFULOUS'
corpse_in_scrofulous = 'CORPSE in SCROFULOUS' |
class Node:
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
self.right = right
node = Node("root", Node("left", Node("left.left")), Node("right"))
s = ""
def serialize(node, s=""):
if not node:
s += "# "
return s
s += str(node.val) + " "
s = serialize(node.left, s=s)
s = serialize(node.right, s=s)
return s
i = 0
def deserialize(s):
global i
if s[i] == "#":
if i < len(s) - 2:
i += 2
return None
else:
space = s[i:].find(" ")
sp = space + i
node = Node(s[i:sp])
i = sp + 1
node.left = deserialize(s)
node.right = deserialize(s)
return node
if __name__ == "__main__":
"""
from timeit import timeit
print(timeit(lambda: serialize(node), number=10000)) # 0.017630080999879283
print(timeit(lambda: deserialize(serialize(node)), number=10000)) # 0.020570166999732464
"""
| class Node:
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
self.right = right
node = node('root', node('left', node('left.left')), node('right'))
s = ''
def serialize(node, s=''):
if not node:
s += '# '
return s
s += str(node.val) + ' '
s = serialize(node.left, s=s)
s = serialize(node.right, s=s)
return s
i = 0
def deserialize(s):
global i
if s[i] == '#':
if i < len(s) - 2:
i += 2
return None
else:
space = s[i:].find(' ')
sp = space + i
node = node(s[i:sp])
i = sp + 1
node.left = deserialize(s)
node.right = deserialize(s)
return node
if __name__ == '__main__':
'\n from timeit import timeit\n\n print(timeit(lambda: serialize(node), number=10000)) # 0.017630080999879283\n print(timeit(lambda: deserialize(serialize(node)), number=10000)) # 0.020570166999732464\n ' |
# -*- coding: utf-8 -*-
class Job:
def __init__(self, job_id, name, status, start_date, end_date,
source_records, processed_records, price):
self.id = job_id
self.name = name
self.status = status
self.start_date = start_date
self.end_date = end_date
self.source_records = source_records
self.processed_records = processed_records
self.price = price
def __repr__(self):
return str(vars(self))
class JobReport:
def __new__(cls, *args, **kwargs):
if 'code' in kwargs:
return None
return super().__new__(cls)
def __init__(self, quality_issues, quality_names, results):
self.quality_issues = quality_issues
self.quality_names = quality_names
self.results = results
def __repr__(self):
return str(vars(self))
class JobConfig:
def __init__(self, name):
self.name = name
self._input_format = {
"field_separator": ",",
"text_delimiter": "\"",
"code_page": "utf-8"
}
self._input_columns = {}
self._extend = {
"teryt": 0,
"gus": 0,
"geocode": 0,
"building_info": 0,
"diagnostic": 0,
"area_characteristic": 0
}
self._module_std = {
"address": 0,
"names": 0,
"contact": 0,
"id_numbers": 0
}
self._client = {
"name": "",
"mode": ""
}
self._deduplication = {
"on": 0,
"incremental": 0
}
def input_format(self, field_separator=",", text_delimiter="\"",
code_page="utf-8"):
self._input_format["field_separator"] = field_separator
self._input_format["text_delimiter"] = text_delimiter
self._input_format["code_page"] = code_page
def input_column(self, idx, name, function):
self._input_columns[idx] = {"no": idx, "name": name,
"function": function}
def extend(self, teryt=False, gus=False, geocode=False,
building_info=False, diagnostic=False,
area_characteristic=False):
self._extend["teryt"] = self.__boolean_to_num(teryt)
self._extend["gus"] = self.__boolean_to_num(gus)
self._extend["geocode"] = self.__boolean_to_num(geocode)
self._extend["building_info"] = self.__boolean_to_num(building_info)
self._extend["diagnostic"] = self.__boolean_to_num(diagnostic)
self._extend["area_characteristic"] = \
self.__boolean_to_num(area_characteristic)
def module_std(self, address = False, names = False, contact = False, id_numbers = False):
self._module_std["address"] = self.__boolean_to_num(address)
self._module_std["names"] = self.__boolean_to_num(names)
self._module_std["contact"] = self.__boolean_to_num(contact)
self._module_std["id_numbers"] = self.__boolean_to_num(id_numbers)
def deduplication(self, on = False, incremental = False):
self._deduplication["on"] = self.__boolean_to_num(on)
self._deduplication["incremental"] = self.__boolean_to_num(incremental)
def client(self, name, mode):
self._client["name"] = name
self._client["mode"] = mode
@staticmethod
def __boolean_to_num(value):
return 1 if value else 0
def data(self):
return {
"job_name": self.name,
"input_format": self._input_format,
"input_columns": list(self._input_columns.values()),
"extend": self._extend,
"module_std": self._module_std,
"deduplication": self._deduplication,
"client": self._client
}
| class Job:
def __init__(self, job_id, name, status, start_date, end_date, source_records, processed_records, price):
self.id = job_id
self.name = name
self.status = status
self.start_date = start_date
self.end_date = end_date
self.source_records = source_records
self.processed_records = processed_records
self.price = price
def __repr__(self):
return str(vars(self))
class Jobreport:
def __new__(cls, *args, **kwargs):
if 'code' in kwargs:
return None
return super().__new__(cls)
def __init__(self, quality_issues, quality_names, results):
self.quality_issues = quality_issues
self.quality_names = quality_names
self.results = results
def __repr__(self):
return str(vars(self))
class Jobconfig:
def __init__(self, name):
self.name = name
self._input_format = {'field_separator': ',', 'text_delimiter': '"', 'code_page': 'utf-8'}
self._input_columns = {}
self._extend = {'teryt': 0, 'gus': 0, 'geocode': 0, 'building_info': 0, 'diagnostic': 0, 'area_characteristic': 0}
self._module_std = {'address': 0, 'names': 0, 'contact': 0, 'id_numbers': 0}
self._client = {'name': '', 'mode': ''}
self._deduplication = {'on': 0, 'incremental': 0}
def input_format(self, field_separator=',', text_delimiter='"', code_page='utf-8'):
self._input_format['field_separator'] = field_separator
self._input_format['text_delimiter'] = text_delimiter
self._input_format['code_page'] = code_page
def input_column(self, idx, name, function):
self._input_columns[idx] = {'no': idx, 'name': name, 'function': function}
def extend(self, teryt=False, gus=False, geocode=False, building_info=False, diagnostic=False, area_characteristic=False):
self._extend['teryt'] = self.__boolean_to_num(teryt)
self._extend['gus'] = self.__boolean_to_num(gus)
self._extend['geocode'] = self.__boolean_to_num(geocode)
self._extend['building_info'] = self.__boolean_to_num(building_info)
self._extend['diagnostic'] = self.__boolean_to_num(diagnostic)
self._extend['area_characteristic'] = self.__boolean_to_num(area_characteristic)
def module_std(self, address=False, names=False, contact=False, id_numbers=False):
self._module_std['address'] = self.__boolean_to_num(address)
self._module_std['names'] = self.__boolean_to_num(names)
self._module_std['contact'] = self.__boolean_to_num(contact)
self._module_std['id_numbers'] = self.__boolean_to_num(id_numbers)
def deduplication(self, on=False, incremental=False):
self._deduplication['on'] = self.__boolean_to_num(on)
self._deduplication['incremental'] = self.__boolean_to_num(incremental)
def client(self, name, mode):
self._client['name'] = name
self._client['mode'] = mode
@staticmethod
def __boolean_to_num(value):
return 1 if value else 0
def data(self):
return {'job_name': self.name, 'input_format': self._input_format, 'input_columns': list(self._input_columns.values()), 'extend': self._extend, 'module_std': self._module_std, 'deduplication': self._deduplication, 'client': self._client} |
def median(iterable):
items = sorted(iterable)
if len(items) == 0:
raise ValueError("median() arg is an empty series")
median_index = (len(items) - 1) // 2
if len(items) % 2 != 0:
return items[median_index]
return (items[median_index] + items[median_index + 1]) / 2
print(median([5, 2, 1, 4, 3]))
def main():
try:
median([])
except ValueError as e:
print("Payload", e.args)
main()
| def median(iterable):
items = sorted(iterable)
if len(items) == 0:
raise value_error('median() arg is an empty series')
median_index = (len(items) - 1) // 2
if len(items) % 2 != 0:
return items[median_index]
return (items[median_index] + items[median_index + 1]) / 2
print(median([5, 2, 1, 4, 3]))
def main():
try:
median([])
except ValueError as e:
print('Payload', e.args)
main() |
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
# Copyright (C) 2011-2019 German Aerospace Center (DLR) and others.
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v2.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v20.html
# SPDX-License-Identifier: EPL-2.0
# @file node.py
# @author Daniel Krajzewicz
# @author Laura Bieker
# @author Karol Stosiek
# @author Michael Behrisch
# @author Jakob Erdmann
# @date 2011-11-28
# @version $Id$
class Node:
""" Nodes from a sumo network """
def __init__(self, id, type, coord, incLanes, intLanes=None):
self._id = id
self._type = type
self._coord = coord
self._incoming = []
self._outgoing = []
self._foes = {}
self._prohibits = {}
self._incLanes = incLanes
self._intLanes = intLanes
self._shape3D = None
self._shape = None
self._params = {}
def getID(self):
return self._id
def setShape(self, shape):
"""Set the shape of the node.
Shape must be a list containing x,y,z coords as numbers
to represent the shape of the node.
"""
for pp in shape:
if len(pp) != 3:
raise ValueError('shape point must consist of x,y,z')
self._shape3D = shape
self._shape = [(x, y) for x, y, z in shape]
def getShape(self):
"""Returns the shape of the node in 2d.
This function returns the shape of the node, as defined in the net.xml
file. The returned shape is a list containing numerical
2-tuples representing the x,y coordinates of the shape points.
If no shape is defined in the xml, an empty list will be returned.
"""
return self._shape
def getShape3D(self):
"""Returns the shape of the node in 3d.
This function returns the shape of the node, as defined in the net.xml
file. The returned shape is a list containing numerical
3-tuples representing the x,y,z coordinates of the shape points.
If no shape is defined in the xml, an empty list will be returned.
"""
return self._shape3D
def addOutgoing(self, edge):
self._outgoing.append(edge)
def getOutgoing(self):
return self._outgoing
def addIncoming(self, edge):
self._incoming.append(edge)
def getIncoming(self):
return self._incoming
def getInternal(self):
return self._intLanes
def setFoes(self, index, foes, prohibits):
self._foes[index] = foes
self._prohibits[index] = prohibits
def areFoes(self, link1, link2):
return self._foes[link1][len(self._foes[link1]) - link2 - 1] == '1'
def getLinkIndex(self, conn):
ret = 0
for lane_id in self._incLanes:
lastUnderscore = lane_id.rfind("_")
if lastUnderscore > 0:
edge_id = lane_id[:lastUnderscore]
index = lane_id[lastUnderscore+1:]
edge = [e for e in self._incoming if e.getID() == edge_id][0]
for candidate_conn in edge.getLane(int(index)).getOutgoing():
if candidate_conn == conn:
return ret
ret += 1
return -1
def forbids(self, possProhibitor, possProhibited):
possProhibitorIndex = self.getLinkIndex(possProhibitor)
possProhibitedIndex = self.getLinkIndex(possProhibited)
if possProhibitorIndex < 0 or possProhibitedIndex < 0:
return False
ps = self._prohibits[possProhibitedIndex]
return ps[-(possProhibitorIndex - 1)] == '1'
def getCoord(self):
return tuple(self._coord[:2])
def getCoord3D(self):
return self._coord
def getType(self):
return self._type
def getConnections(self, source=None, target=None):
if source:
incoming = [source]
else:
incoming = list(self._incoming)
conns = []
for e in incoming:
if (hasattr(e, "getLanes")):
lanes = e.getLanes()
else:
# assuming source is a lane
lanes = [e]
for l in lanes:
all_outgoing = l.getOutgoing()
outgoing = []
if target:
if hasattr(target, "getLanes"):
for o in all_outgoing:
if o.getTo() == target:
outgoing.append(o)
else:
# assuming target is a lane
for o in all_outgoing:
if o.getToLane() == target:
outgoing.append(o)
else:
outgoing = all_outgoing
conns.extend(outgoing)
return conns
def setParam(self, key, value):
self._params[key] = value
def getParam(self, key, default=None):
return self._params.get(key, default)
def getParams(self):
return self._params
def getNeighboringNodes(self, outgoingNodes=True, incomingNodes=True):
neighboring = []
if incomingNodes:
edges = self._incoming
for e in edges:
if not (e.getFromNode() in neighboring) and not(e.getFromNode().getID() == self.getID()):
neighboring.append(e.getFromNode())
if outgoingNodes:
edges = self._outgoing
for e in edges:
if not (e.getToNode() in neighboring)and not(e.getToNode().getID() == self.getID()):
neighboring.append(e.getToNode())
return neighboring
| class Node:
""" Nodes from a sumo network """
def __init__(self, id, type, coord, incLanes, intLanes=None):
self._id = id
self._type = type
self._coord = coord
self._incoming = []
self._outgoing = []
self._foes = {}
self._prohibits = {}
self._incLanes = incLanes
self._intLanes = intLanes
self._shape3D = None
self._shape = None
self._params = {}
def get_id(self):
return self._id
def set_shape(self, shape):
"""Set the shape of the node.
Shape must be a list containing x,y,z coords as numbers
to represent the shape of the node.
"""
for pp in shape:
if len(pp) != 3:
raise value_error('shape point must consist of x,y,z')
self._shape3D = shape
self._shape = [(x, y) for (x, y, z) in shape]
def get_shape(self):
"""Returns the shape of the node in 2d.
This function returns the shape of the node, as defined in the net.xml
file. The returned shape is a list containing numerical
2-tuples representing the x,y coordinates of the shape points.
If no shape is defined in the xml, an empty list will be returned.
"""
return self._shape
def get_shape3_d(self):
"""Returns the shape of the node in 3d.
This function returns the shape of the node, as defined in the net.xml
file. The returned shape is a list containing numerical
3-tuples representing the x,y,z coordinates of the shape points.
If no shape is defined in the xml, an empty list will be returned.
"""
return self._shape3D
def add_outgoing(self, edge):
self._outgoing.append(edge)
def get_outgoing(self):
return self._outgoing
def add_incoming(self, edge):
self._incoming.append(edge)
def get_incoming(self):
return self._incoming
def get_internal(self):
return self._intLanes
def set_foes(self, index, foes, prohibits):
self._foes[index] = foes
self._prohibits[index] = prohibits
def are_foes(self, link1, link2):
return self._foes[link1][len(self._foes[link1]) - link2 - 1] == '1'
def get_link_index(self, conn):
ret = 0
for lane_id in self._incLanes:
last_underscore = lane_id.rfind('_')
if lastUnderscore > 0:
edge_id = lane_id[:lastUnderscore]
index = lane_id[lastUnderscore + 1:]
edge = [e for e in self._incoming if e.getID() == edge_id][0]
for candidate_conn in edge.getLane(int(index)).getOutgoing():
if candidate_conn == conn:
return ret
ret += 1
return -1
def forbids(self, possProhibitor, possProhibited):
poss_prohibitor_index = self.getLinkIndex(possProhibitor)
poss_prohibited_index = self.getLinkIndex(possProhibited)
if possProhibitorIndex < 0 or possProhibitedIndex < 0:
return False
ps = self._prohibits[possProhibitedIndex]
return ps[-(possProhibitorIndex - 1)] == '1'
def get_coord(self):
return tuple(self._coord[:2])
def get_coord3_d(self):
return self._coord
def get_type(self):
return self._type
def get_connections(self, source=None, target=None):
if source:
incoming = [source]
else:
incoming = list(self._incoming)
conns = []
for e in incoming:
if hasattr(e, 'getLanes'):
lanes = e.getLanes()
else:
lanes = [e]
for l in lanes:
all_outgoing = l.getOutgoing()
outgoing = []
if target:
if hasattr(target, 'getLanes'):
for o in all_outgoing:
if o.getTo() == target:
outgoing.append(o)
else:
for o in all_outgoing:
if o.getToLane() == target:
outgoing.append(o)
else:
outgoing = all_outgoing
conns.extend(outgoing)
return conns
def set_param(self, key, value):
self._params[key] = value
def get_param(self, key, default=None):
return self._params.get(key, default)
def get_params(self):
return self._params
def get_neighboring_nodes(self, outgoingNodes=True, incomingNodes=True):
neighboring = []
if incomingNodes:
edges = self._incoming
for e in edges:
if not e.getFromNode() in neighboring and (not e.getFromNode().getID() == self.getID()):
neighboring.append(e.getFromNode())
if outgoingNodes:
edges = self._outgoing
for e in edges:
if not e.getToNode() in neighboring and (not e.getToNode().getID() == self.getID()):
neighboring.append(e.getToNode())
return neighboring |
def get():
return int(input())
def get_num():
return get()
def get_line():
return get_num()
print(get_line())
| def get():
return int(input())
def get_num():
return get()
def get_line():
return get_num()
print(get_line()) |
# ### Problem 1
# ```
# # Start with this List
# list_of_many_numbers = [12, 24, 1, 34, 10, 2, 7]
# ```
# Example Input/Output if the user enters the number 9:
# ```
# The User entered 9
# 1 2 7 are smaller than 9
# 12 24 34 10 are larger than 9
# ```
# Ask the user to enter a number.
userInput = int(input("Enter a number "))
# Using the provided list of numbers, use a for loop to iterate the array and
# print out all the values that are smaller than the user input and print out
# all the values that are larger than the number entered by the user.
list_of_many_numbers = [12, 24, 1, 34, 10, 2, 7]
for x in list_of_many_numbers:
# print out all the values that are smaller than the user input
if (userInput > x):
print('the value that is smaller than the user input ', x)
# print out all the values that are larger than the number entered by the user
if (userInput < x):
print('the value that is greater than the user input ', x)
| user_input = int(input('Enter a number '))
list_of_many_numbers = [12, 24, 1, 34, 10, 2, 7]
for x in list_of_many_numbers:
if userInput > x:
print('the value that is smaller than the user input ', x)
if userInput < x:
print('the value that is greater than the user input ', x) |
class Scheduler(object):
def __init__(self, env, cpu_list=[], task_list=[]):
self.env = env
self.cpu_list = cpu_list
self.task_list = []
self._lock = False
self.overhead = 0
def run(self):
pass
def on_activate(self, job):
pass
def on_terminated(self, job):
pass
def schedule(self, cpu):
raise NotImplementedError("You need to everride the schedule method!")
def add_task(self, task):
self.task_list.append(task)
def add_processor(self, cpu):
self.cpu_list.append(cpu) | class Scheduler(object):
def __init__(self, env, cpu_list=[], task_list=[]):
self.env = env
self.cpu_list = cpu_list
self.task_list = []
self._lock = False
self.overhead = 0
def run(self):
pass
def on_activate(self, job):
pass
def on_terminated(self, job):
pass
def schedule(self, cpu):
raise not_implemented_error('You need to everride the schedule method!')
def add_task(self, task):
self.task_list.append(task)
def add_processor(self, cpu):
self.cpu_list.append(cpu) |
"""
This is a sample program to demonstrate string concatenation
"""
if __name__ == "__main__":
alice_name = "Alice"
bob_name = "Bob"
print(alice_name + bob_name) | """
This is a sample program to demonstrate string concatenation
"""
if __name__ == '__main__':
alice_name = 'Alice'
bob_name = 'Bob'
print(alice_name + bob_name) |
# test 0
# correct answer
# [0]
num_topics, num_themes = 1, 1
lst = [0]
with open('input.txt', 'w') as f:
f.write("{} {}\n".format(num_topics, num_themes))
for l in lst:
f.write(str(l) + '\n')
| (num_topics, num_themes) = (1, 1)
lst = [0]
with open('input.txt', 'w') as f:
f.write('{} {}\n'.format(num_topics, num_themes))
for l in lst:
f.write(str(l) + '\n') |
class Stack():
def __init__(self):
self.items = []
def push(self, item):
return self.items.append(item)
def pop(self):
return self.items.pop()
def IsEmpty(self):
return self.items == []
def length(self):
return len(self.items)
def peek(self):
return self.items[len(self.items) - 1]
s = Stack()
s.IsEmpty()
s.push(10)
s.length()
s.push(20)
s.push(30)
s.length()
s.peek()
s.pop()
s.IsEmpty()
s.pop()
s.pop()
s.IsEmpty() | class Stack:
def __init__(self):
self.items = []
def push(self, item):
return self.items.append(item)
def pop(self):
return self.items.pop()
def is_empty(self):
return self.items == []
def length(self):
return len(self.items)
def peek(self):
return self.items[len(self.items) - 1]
s = stack()
s.IsEmpty()
s.push(10)
s.length()
s.push(20)
s.push(30)
s.length()
s.peek()
s.pop()
s.IsEmpty()
s.pop()
s.pop()
s.IsEmpty() |
# User input
percentage = float(input("Enter your marks: "))
# Program operation & Computer output
if (percentage >= 90):
print("Your grade is A1 !")
elif (percentage >= 80):
print("Your grade is A !")
elif (percentage >= 70):
print("Your grade is B1 !")
elif (percentage >= 60):
print("Your grade is B !")
elif (percentage >= 50):
print("Your grade is C, try better next time!")
elif (percentage >= 33):
print("Your grade is D, try better next time!")
else:
print("Your grade is E, try better next time!")
| percentage = float(input('Enter your marks: '))
if percentage >= 90:
print('Your grade is A1 !')
elif percentage >= 80:
print('Your grade is A !')
elif percentage >= 70:
print('Your grade is B1 !')
elif percentage >= 60:
print('Your grade is B !')
elif percentage >= 50:
print('Your grade is C, try better next time!')
elif percentage >= 33:
print('Your grade is D, try better next time!')
else:
print('Your grade is E, try better next time!') |
#!/usr/bin/env python
# -*- coding:utf-8 -*-
def q_s(v):
if len(v) <=1:
return v
left, right = 0, len(v) - 1
item = v[int((left+right))/2]
left_value = [i for i in v if i < item]
right_value = [i for i in v if i > item]
return q_s(left_value) + [item] + q_s(right_value)
if __name__ == "__main__":
v = [1, 2, 4, 3, 6, 7, 8, 5, 9]
q_v = q_s(v)
print(q_v)
| def q_s(v):
if len(v) <= 1:
return v
(left, right) = (0, len(v) - 1)
item = v[int(left + right) / 2]
left_value = [i for i in v if i < item]
right_value = [i for i in v if i > item]
return q_s(left_value) + [item] + q_s(right_value)
if __name__ == '__main__':
v = [1, 2, 4, 3, 6, 7, 8, 5, 9]
q_v = q_s(v)
print(q_v) |
#
# PySNMP MIB module WWP-LEOS-OAM-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/WWP-LEOS-OAM-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:31:22 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
ObjectIdentifier, Integer, OctetString = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "Integer", "OctetString")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint")
NotificationGroup, ModuleCompliance, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup")
iso, Counter64, MibIdentifier, TimeTicks, Gauge32, Integer32, ObjectIdentity, ModuleIdentity, Unsigned32, Counter32, NotificationType, IpAddress, Bits, MibScalar, MibTable, MibTableRow, MibTableColumn = mibBuilder.importSymbols("SNMPv2-SMI", "iso", "Counter64", "MibIdentifier", "TimeTicks", "Gauge32", "Integer32", "ObjectIdentity", "ModuleIdentity", "Unsigned32", "Counter32", "NotificationType", "IpAddress", "Bits", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn")
DisplayString, TimeStamp, TextualConvention, TruthValue = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TimeStamp", "TextualConvention", "TruthValue")
wwpLeosEtherPortOperStatus, wwpLeosEtherPortDesc = mibBuilder.importSymbols("WWP-LEOS-PORT-MIB", "wwpLeosEtherPortOperStatus", "wwpLeosEtherPortDesc")
wwpModulesLeos, = mibBuilder.importSymbols("WWP-SMI", "wwpModulesLeos")
wwpLeosOamMibModule = ModuleIdentity((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400))
wwpLeosOamMibModule.setRevisions(('2008-01-03 00:00',))
if mibBuilder.loadTexts: wwpLeosOamMibModule.setLastUpdated('200801030000Z')
if mibBuilder.loadTexts: wwpLeosOamMibModule.setOrganization('Ciena, Inc')
wwpLeosOamMIB = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1))
wwpLeosOamConf = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 1))
wwpLeosOamGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 1, 1))
wwpLeosOamCompls = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 1, 2))
wwpLeosOamObjs = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2))
wwpLeosOamTable = MibTable((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1), )
if mibBuilder.loadTexts: wwpLeosOamTable.setStatus('current')
wwpLeosOamEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1), ).setIndexNames((0, "WWP-LEOS-OAM-MIB", "wwpLeosOamPort"))
if mibBuilder.loadTexts: wwpLeosOamEntry.setStatus('current')
wwpLeosOamAdminState = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("disabled", 1), ("enabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamAdminState.setStatus('current')
wwpLeosOamOperStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9))).clone(namedValues=NamedValues(("disabled", 1), ("linkfault", 2), ("passiveWait", 3), ("activeSendLocal", 4), ("sendLocalAndRemote", 5), ("sendLocalAndRemoteOk", 6), ("oamPeeringLocallyRejected", 7), ("oamPeeringRemotelyRejected", 8), ("operational", 9)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamOperStatus.setStatus('current')
wwpLeosOamMode = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("active", 1), ("passive", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamMode.setStatus('current')
wwpLeosMaxOamPduSize = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 4), Integer32()).setUnits('bytes').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosMaxOamPduSize.setStatus('current')
wwpLeosOamConfigRevision = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 5), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamConfigRevision.setStatus('current')
wwpLeosOamFunctionsSupported = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 6), Bits().clone(namedValues=NamedValues(("unidirectionalSupport", 0), ("loopbackSupport", 1), ("eventSupport", 2), ("variableSupport", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamFunctionsSupported.setStatus('current')
wwpLeosOamPort = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 7), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamPort.setStatus('current')
wwpLeosOamPduTimer = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(100, 1000))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamPduTimer.setStatus('current')
wwpLeosOamLinkLostTimer = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(500, 5000))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamLinkLostTimer.setStatus('current')
wwpLeosOamPeerStatusNotifyState = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("on", 1), ("off", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamPeerStatusNotifyState.setStatus('current')
wwpLeosOamPeerTable = MibTable((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2), )
if mibBuilder.loadTexts: wwpLeosOamPeerTable.setStatus('current')
wwpLeosOamPeerEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1), ).setIndexNames((0, "WWP-LEOS-OAM-MIB", "wwpLeosOamLocalPort"))
if mibBuilder.loadTexts: wwpLeosOamPeerEntry.setStatus('current')
wwpLeosOamPeerStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("active", 1), ("inactive", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamPeerStatus.setStatus('current')
wwpLeosOamPeerMacAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 2), OctetString().subtype(subtypeSpec=ValueSizeConstraint(6, 6)).setFixedLength(6)).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamPeerMacAddress.setStatus('current')
wwpLeosOamPeerVendorOui = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 3), OctetString().subtype(subtypeSpec=ValueSizeConstraint(3, 3)).setFixedLength(3)).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamPeerVendorOui.setStatus('current')
wwpLeosOamPeerVendorInfo = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 4), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamPeerVendorInfo.setStatus('current')
wwpLeosOamPeerMode = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("active", 1), ("passive", 2), ("unknown", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamPeerMode.setStatus('current')
wwpLeosOamPeerMaxOamPduSize = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 6), Integer32()).setUnits('bytes').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamPeerMaxOamPduSize.setStatus('current')
wwpLeosOamPeerConfigRevision = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 7), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamPeerConfigRevision.setStatus('current')
wwpLeosOamPeerFunctionsSupported = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 8), Bits().clone(namedValues=NamedValues(("unidirectionalSupport", 0), ("loopbackSupport", 1), ("eventSupport", 2), ("variableSupport", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamPeerFunctionsSupported.setStatus('current')
wwpLeosOamLocalPort = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamLocalPort.setStatus('current')
wwpLeosOamLoopbackTable = MibTable((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3), )
if mibBuilder.loadTexts: wwpLeosOamLoopbackTable.setStatus('current')
wwpLeosOamLoopbackEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1), ).setIndexNames((0, "WWP-LEOS-OAM-MIB", "wwpLeosOamLoopbackPort"))
if mibBuilder.loadTexts: wwpLeosOamLoopbackEntry.setStatus('current')
wwpLeosOamLoopbackCommand = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("noLoopback", 1), ("startRemoteLoopback", 2), ("stopRemoteLoopback", 3)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamLoopbackCommand.setStatus('current')
wwpLeosOamLoopbackStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6))).clone(namedValues=NamedValues(("noLoopback", 1), ("initiatingLoopback", 2), ("remoteLoopback", 3), ("terminatingLoopback", 4), ("localLoopback", 5), ("unknown", 6)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamLoopbackStatus.setStatus('current')
wwpLeosOamLoopbackIgnoreRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("ignore", 1), ("process", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamLoopbackIgnoreRx.setStatus('current')
wwpLeosOamLoopbackPort = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamLoopbackPort.setStatus('current')
wwpLeosOamStatsTable = MibTable((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4), )
if mibBuilder.loadTexts: wwpLeosOamStatsTable.setStatus('current')
wwpLeosOamStatsEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1), ).setIndexNames((0, "WWP-LEOS-OAM-MIB", "wwpLeosOamStatsPort"))
if mibBuilder.loadTexts: wwpLeosOamStatsEntry.setStatus('current')
wwpLeosOamInformationTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 1), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamInformationTx.setStatus('current')
wwpLeosOamInformationRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 2), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamInformationRx.setStatus('current')
wwpLeosOamUniqueEventNotificationTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 3), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamUniqueEventNotificationTx.setStatus('current')
wwpLeosOamUniqueEventNotificationRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 4), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamUniqueEventNotificationRx.setStatus('current')
wwpLeosOamLoopbackControlTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 5), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamLoopbackControlTx.setStatus('current')
wwpLeosOamLoopbackControlRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 6), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamLoopbackControlRx.setStatus('current')
wwpLeosOamVariableRequestTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 7), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamVariableRequestTx.setStatus('current')
wwpLeosOamVariableRequestRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 8), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamVariableRequestRx.setStatus('current')
wwpLeosOamVariableResponseTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 9), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamVariableResponseTx.setStatus('current')
wwpLeosOamVariableResponseRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 10), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamVariableResponseRx.setStatus('current')
wwpLeosOamOrgSpecificTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 11), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamOrgSpecificTx.setStatus('current')
wwpLeosOamOrgSpecificRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 12), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamOrgSpecificRx.setStatus('current')
wwpLeosOamUnsupportedCodesTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 13), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamUnsupportedCodesTx.setStatus('current')
wwpLeosOamUnsupportedCodesRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 14), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamUnsupportedCodesRx.setStatus('current')
wwpLeosOamframesLostDueToOam = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 15), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamframesLostDueToOam.setStatus('current')
wwpLeosOamStatsPort = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 16), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamStatsPort.setStatus('current')
wwpLeosOamDuplicateEventNotificationTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 17), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamDuplicateEventNotificationTx.setStatus('current')
wwpLeosOamDuplicateEventNotificationRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 18), Counter32()).setUnits('frames').setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamDuplicateEventNotificationRx.setStatus('current')
wwpLeosOamSystemEnableDisable = MibScalar((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamSystemEnableDisable.setStatus('current')
wwpLeosOamEventConfigTable = MibTable((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6), )
if mibBuilder.loadTexts: wwpLeosOamEventConfigTable.setStatus('current')
wwpLeosOamEventConfigEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1), ).setIndexNames((0, "WWP-LEOS-OAM-MIB", "wwpLeosOamEventPort"))
if mibBuilder.loadTexts: wwpLeosOamEventConfigEntry.setStatus('current')
wwpLeosOamEventPort = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventPort.setStatus('current')
wwpLeosOamErrFramePeriodWindow = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 2), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(14880, 8928000))).setUnits('frames').setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamErrFramePeriodWindow.setStatus('current')
wwpLeosOamErrFramePeriodThreshold = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 3), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967293))).setUnits('frames').setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamErrFramePeriodThreshold.setStatus('current')
wwpLeosOamErrFramePeriodEvNotifEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamErrFramePeriodEvNotifEnable.setStatus('current')
wwpLeosOamErrFrameWindow = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 5), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(10, 600))).setUnits('tenths of a second').setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamErrFrameWindow.setStatus('current')
wwpLeosOamErrFrameThreshold = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 6), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967293))).setUnits('frames').setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamErrFrameThreshold.setStatus('current')
wwpLeosOamErrFrameEvNotifEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamErrFrameEvNotifEnable.setStatus('current')
wwpLeosOamErrFrameSecsSummaryWindow = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(100, 9000))).setUnits('tenths of a second').setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamErrFrameSecsSummaryWindow.setStatus('current')
wwpLeosOamErrFrameSecsSummaryThreshold = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setUnits('errored frame seconds').setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamErrFrameSecsSummaryThreshold.setStatus('current')
wwpLeosOamErrFrameSecsEvNotifEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamErrFrameSecsEvNotifEnable.setStatus('current')
wwpLeosOamDyingGaspEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 11), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamDyingGaspEnable.setStatus('current')
wwpLeosOamCriticalEventEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 12), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamCriticalEventEnable.setStatus('current')
wwpLeosOamEventLogTable = MibTable((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7), )
if mibBuilder.loadTexts: wwpLeosOamEventLogTable.setStatus('current')
wwpLeosOamEventLogEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1), ).setIndexNames((0, "WWP-LEOS-OAM-MIB", "wwpLeosOamEventLogPort"), (0, "WWP-LEOS-OAM-MIB", "wwpLeosOamEventLogIndex"))
if mibBuilder.loadTexts: wwpLeosOamEventLogEntry.setStatus('current')
wwpLeosOamEventLogPort = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogPort.setStatus('current')
wwpLeosOamEventLogIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 2), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogIndex.setStatus('current')
wwpLeosOamEventLogTimestamp = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 3), TimeStamp()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogTimestamp.setStatus('current')
wwpLeosOamEventLogOui = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 4), OctetString().subtype(subtypeSpec=ValueSizeConstraint(3, 3)).setFixedLength(3)).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogOui.setStatus('current')
wwpLeosOamEventLogType = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 5), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogType.setStatus('current')
wwpLeosOamEventLogLocation = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("local", 1), ("remote", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogLocation.setStatus('current')
wwpLeosOamEventLogWindowHi = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 7), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogWindowHi.setStatus('current')
wwpLeosOamEventLogWindowLo = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 8), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogWindowLo.setStatus('current')
wwpLeosOamEventLogThresholdHi = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 9), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogThresholdHi.setStatus('current')
wwpLeosOamEventLogThresholdLo = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 10), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogThresholdLo.setStatus('current')
wwpLeosOamEventLogValue = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 11), Counter64()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogValue.setStatus('current')
wwpLeosOamEventLogRunningTotal = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 12), Counter64()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogRunningTotal.setStatus('current')
wwpLeosOamEventLogEventTotal = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 13), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: wwpLeosOamEventLogEventTotal.setStatus('current')
wwpLeosOamGlobal = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 8))
wwpLeosOamStatsClear = MibScalar((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 8, 1), TruthValue()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: wwpLeosOamStatsClear.setStatus('current')
wwpLeosOamNotifMIBNotificationPrefix = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3))
wwpLeosOamNotifMIBNotification = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3, 0))
wwpLeosOamLinkEventTrap = NotificationType((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3, 0, 1)).setObjects(("WWP-LEOS-OAM-MIB", "wwpLeosOamEventLogPort"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamEventLogType"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamEventLogLocation"))
if mibBuilder.loadTexts: wwpLeosOamLinkEventTrap.setStatus('current')
wwpLeosOamLinkLostTimerActiveTrap = NotificationType((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3, 0, 2)).setObjects(("WWP-LEOS-OAM-MIB", "wwpLeosOamPort"), ("WWP-LEOS-PORT-MIB", "wwpLeosEtherPortDesc"), ("WWP-LEOS-PORT-MIB", "wwpLeosEtherPortOperStatus"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamOperStatus"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamPeerStatus"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamPeerMacAddress"))
if mibBuilder.loadTexts: wwpLeosOamLinkLostTimerActiveTrap.setStatus('current')
wwpLeosOamLinkLostTimerExpiredTrap = NotificationType((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3, 0, 3)).setObjects(("WWP-LEOS-OAM-MIB", "wwpLeosOamPort"), ("WWP-LEOS-PORT-MIB", "wwpLeosEtherPortDesc"), ("WWP-LEOS-PORT-MIB", "wwpLeosEtherPortOperStatus"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamOperStatus"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamPeerStatus"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamPeerMacAddress"))
if mibBuilder.loadTexts: wwpLeosOamLinkLostTimerExpiredTrap.setStatus('current')
mibBuilder.exportSymbols("WWP-LEOS-OAM-MIB", wwpLeosOamErrFrameSecsSummaryWindow=wwpLeosOamErrFrameSecsSummaryWindow, wwpLeosOamLoopbackIgnoreRx=wwpLeosOamLoopbackIgnoreRx, wwpLeosOamEventLogEntry=wwpLeosOamEventLogEntry, wwpLeosOamEventLogWindowHi=wwpLeosOamEventLogWindowHi, wwpLeosOamInformationRx=wwpLeosOamInformationRx, wwpLeosOamMode=wwpLeosOamMode, wwpLeosOamPort=wwpLeosOamPort, wwpLeosOamVariableRequestRx=wwpLeosOamVariableRequestRx, wwpLeosOamSystemEnableDisable=wwpLeosOamSystemEnableDisable, wwpLeosOamErrFramePeriodWindow=wwpLeosOamErrFramePeriodWindow, wwpLeosOamErrFramePeriodEvNotifEnable=wwpLeosOamErrFramePeriodEvNotifEnable, wwpLeosOamEventLogTable=wwpLeosOamEventLogTable, wwpLeosOamLinkLostTimerActiveTrap=wwpLeosOamLinkLostTimerActiveTrap, wwpLeosOamEventPort=wwpLeosOamEventPort, wwpLeosOamEventLogWindowLo=wwpLeosOamEventLogWindowLo, wwpLeosOamLoopbackControlTx=wwpLeosOamLoopbackControlTx, wwpLeosOamStatsClear=wwpLeosOamStatsClear, wwpLeosOamLoopbackCommand=wwpLeosOamLoopbackCommand, wwpLeosOamPeerMode=wwpLeosOamPeerMode, wwpLeosOamEventLogTimestamp=wwpLeosOamEventLogTimestamp, wwpLeosOamEventConfigEntry=wwpLeosOamEventConfigEntry, wwpLeosOamErrFrameThreshold=wwpLeosOamErrFrameThreshold, wwpLeosOamEventLogType=wwpLeosOamEventLogType, wwpLeosOamLoopbackControlRx=wwpLeosOamLoopbackControlRx, wwpLeosOamCriticalEventEnable=wwpLeosOamCriticalEventEnable, wwpLeosOamAdminState=wwpLeosOamAdminState, wwpLeosOamPeerFunctionsSupported=wwpLeosOamPeerFunctionsSupported, wwpLeosOamPeerMacAddress=wwpLeosOamPeerMacAddress, wwpLeosOamNotifMIBNotificationPrefix=wwpLeosOamNotifMIBNotificationPrefix, wwpLeosOamLinkEventTrap=wwpLeosOamLinkEventTrap, wwpLeosOamPeerStatusNotifyState=wwpLeosOamPeerStatusNotifyState, wwpLeosOamEventLogIndex=wwpLeosOamEventLogIndex, wwpLeosOamErrFrameWindow=wwpLeosOamErrFrameWindow, wwpLeosOamLinkLostTimerExpiredTrap=wwpLeosOamLinkLostTimerExpiredTrap, wwpLeosOamUnsupportedCodesTx=wwpLeosOamUnsupportedCodesTx, wwpLeosOamPeerVendorOui=wwpLeosOamPeerVendorOui, wwpLeosOamEventLogEventTotal=wwpLeosOamEventLogEventTotal, wwpLeosOamPeerVendorInfo=wwpLeosOamPeerVendorInfo, wwpLeosOamVariableRequestTx=wwpLeosOamVariableRequestTx, wwpLeosOamframesLostDueToOam=wwpLeosOamframesLostDueToOam, wwpLeosOamLocalPort=wwpLeosOamLocalPort, wwpLeosOamFunctionsSupported=wwpLeosOamFunctionsSupported, wwpLeosOamUniqueEventNotificationTx=wwpLeosOamUniqueEventNotificationTx, wwpLeosOamConf=wwpLeosOamConf, wwpLeosOamGroups=wwpLeosOamGroups, wwpLeosOamPeerEntry=wwpLeosOamPeerEntry, wwpLeosOamErrFrameSecsSummaryThreshold=wwpLeosOamErrFrameSecsSummaryThreshold, wwpLeosOamObjs=wwpLeosOamObjs, wwpLeosOamErrFrameEvNotifEnable=wwpLeosOamErrFrameEvNotifEnable, wwpLeosOamLoopbackTable=wwpLeosOamLoopbackTable, wwpLeosOamErrFrameSecsEvNotifEnable=wwpLeosOamErrFrameSecsEvNotifEnable, wwpLeosOamPeerStatus=wwpLeosOamPeerStatus, wwpLeosOamCompls=wwpLeosOamCompls, wwpLeosOamNotifMIBNotification=wwpLeosOamNotifMIBNotification, wwpLeosOamPeerTable=wwpLeosOamPeerTable, wwpLeosOamEventLogOui=wwpLeosOamEventLogOui, wwpLeosOamPeerConfigRevision=wwpLeosOamPeerConfigRevision, wwpLeosOamLinkLostTimer=wwpLeosOamLinkLostTimer, wwpLeosOamPeerMaxOamPduSize=wwpLeosOamPeerMaxOamPduSize, wwpLeosOamErrFramePeriodThreshold=wwpLeosOamErrFramePeriodThreshold, wwpLeosOamDuplicateEventNotificationRx=wwpLeosOamDuplicateEventNotificationRx, wwpLeosOamGlobal=wwpLeosOamGlobal, wwpLeosOamDyingGaspEnable=wwpLeosOamDyingGaspEnable, wwpLeosOamStatsEntry=wwpLeosOamStatsEntry, wwpLeosOamDuplicateEventNotificationTx=wwpLeosOamDuplicateEventNotificationTx, wwpLeosOamConfigRevision=wwpLeosOamConfigRevision, wwpLeosOamLoopbackStatus=wwpLeosOamLoopbackStatus, wwpLeosOamOrgSpecificRx=wwpLeosOamOrgSpecificRx, wwpLeosOamEventLogRunningTotal=wwpLeosOamEventLogRunningTotal, wwpLeosOamMIB=wwpLeosOamMIB, wwpLeosOamStatsTable=wwpLeosOamStatsTable, wwpLeosOamOperStatus=wwpLeosOamOperStatus, wwpLeosOamInformationTx=wwpLeosOamInformationTx, wwpLeosOamEventLogLocation=wwpLeosOamEventLogLocation, wwpLeosOamVariableResponseTx=wwpLeosOamVariableResponseTx, wwpLeosOamEventConfigTable=wwpLeosOamEventConfigTable, wwpLeosOamLoopbackPort=wwpLeosOamLoopbackPort, wwpLeosOamEventLogThresholdLo=wwpLeosOamEventLogThresholdLo, wwpLeosOamTable=wwpLeosOamTable, wwpLeosOamLoopbackEntry=wwpLeosOamLoopbackEntry, wwpLeosOamMibModule=wwpLeosOamMibModule, wwpLeosOamOrgSpecificTx=wwpLeosOamOrgSpecificTx, wwpLeosOamStatsPort=wwpLeosOamStatsPort, wwpLeosOamVariableResponseRx=wwpLeosOamVariableResponseRx, wwpLeosOamUnsupportedCodesRx=wwpLeosOamUnsupportedCodesRx, wwpLeosMaxOamPduSize=wwpLeosMaxOamPduSize, wwpLeosOamEventLogValue=wwpLeosOamEventLogValue, wwpLeosOamEventLogPort=wwpLeosOamEventLogPort, wwpLeosOamEventLogThresholdHi=wwpLeosOamEventLogThresholdHi, wwpLeosOamPduTimer=wwpLeosOamPduTimer, wwpLeosOamUniqueEventNotificationRx=wwpLeosOamUniqueEventNotificationRx, wwpLeosOamEntry=wwpLeosOamEntry, PYSNMP_MODULE_ID=wwpLeosOamMibModule)
| (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, single_value_constraint, constraints_intersection, value_size_constraint, value_range_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsUnion', 'SingleValueConstraint', 'ConstraintsIntersection', 'ValueSizeConstraint', 'ValueRangeConstraint')
(notification_group, module_compliance, object_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance', 'ObjectGroup')
(iso, counter64, mib_identifier, time_ticks, gauge32, integer32, object_identity, module_identity, unsigned32, counter32, notification_type, ip_address, bits, mib_scalar, mib_table, mib_table_row, mib_table_column) = mibBuilder.importSymbols('SNMPv2-SMI', 'iso', 'Counter64', 'MibIdentifier', 'TimeTicks', 'Gauge32', 'Integer32', 'ObjectIdentity', 'ModuleIdentity', 'Unsigned32', 'Counter32', 'NotificationType', 'IpAddress', 'Bits', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn')
(display_string, time_stamp, textual_convention, truth_value) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TimeStamp', 'TextualConvention', 'TruthValue')
(wwp_leos_ether_port_oper_status, wwp_leos_ether_port_desc) = mibBuilder.importSymbols('WWP-LEOS-PORT-MIB', 'wwpLeosEtherPortOperStatus', 'wwpLeosEtherPortDesc')
(wwp_modules_leos,) = mibBuilder.importSymbols('WWP-SMI', 'wwpModulesLeos')
wwp_leos_oam_mib_module = module_identity((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400))
wwpLeosOamMibModule.setRevisions(('2008-01-03 00:00',))
if mibBuilder.loadTexts:
wwpLeosOamMibModule.setLastUpdated('200801030000Z')
if mibBuilder.loadTexts:
wwpLeosOamMibModule.setOrganization('Ciena, Inc')
wwp_leos_oam_mib = mib_identifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1))
wwp_leos_oam_conf = mib_identifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 1))
wwp_leos_oam_groups = mib_identifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 1, 1))
wwp_leos_oam_compls = mib_identifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 1, 2))
wwp_leos_oam_objs = mib_identifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2))
wwp_leos_oam_table = mib_table((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1))
if mibBuilder.loadTexts:
wwpLeosOamTable.setStatus('current')
wwp_leos_oam_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1)).setIndexNames((0, 'WWP-LEOS-OAM-MIB', 'wwpLeosOamPort'))
if mibBuilder.loadTexts:
wwpLeosOamEntry.setStatus('current')
wwp_leos_oam_admin_state = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('disabled', 1), ('enabled', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
wwpLeosOamAdminState.setStatus('current')
wwp_leos_oam_oper_status = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9))).clone(namedValues=named_values(('disabled', 1), ('linkfault', 2), ('passiveWait', 3), ('activeSendLocal', 4), ('sendLocalAndRemote', 5), ('sendLocalAndRemoteOk', 6), ('oamPeeringLocallyRejected', 7), ('oamPeeringRemotelyRejected', 8), ('operational', 9)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamOperStatus.setStatus('current')
wwp_leos_oam_mode = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('active', 1), ('passive', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
wwpLeosOamMode.setStatus('current')
wwp_leos_max_oam_pdu_size = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 4), integer32()).setUnits('bytes').setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosMaxOamPduSize.setStatus('current')
wwp_leos_oam_config_revision = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 5), unsigned32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamConfigRevision.setStatus('current')
wwp_leos_oam_functions_supported = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 6), bits().clone(namedValues=named_values(('unidirectionalSupport', 0), ('loopbackSupport', 1), ('eventSupport', 2), ('variableSupport', 3)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamFunctionsSupported.setStatus('current')
wwp_leos_oam_port = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 7), integer32().subtype(subtypeSpec=value_range_constraint(1, 1000))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamPort.setStatus('current')
wwp_leos_oam_pdu_timer = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 8), integer32().subtype(subtypeSpec=value_range_constraint(100, 1000))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
wwpLeosOamPduTimer.setStatus('current')
wwp_leos_oam_link_lost_timer = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 9), integer32().subtype(subtypeSpec=value_range_constraint(500, 5000))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
wwpLeosOamLinkLostTimer.setStatus('current')
wwp_leos_oam_peer_status_notify_state = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 10), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('on', 1), ('off', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
wwpLeosOamPeerStatusNotifyState.setStatus('current')
wwp_leos_oam_peer_table = mib_table((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2))
if mibBuilder.loadTexts:
wwpLeosOamPeerTable.setStatus('current')
wwp_leos_oam_peer_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1)).setIndexNames((0, 'WWP-LEOS-OAM-MIB', 'wwpLeosOamLocalPort'))
if mibBuilder.loadTexts:
wwpLeosOamPeerEntry.setStatus('current')
wwp_leos_oam_peer_status = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('active', 1), ('inactive', 2)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamPeerStatus.setStatus('current')
wwp_leos_oam_peer_mac_address = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 2), octet_string().subtype(subtypeSpec=value_size_constraint(6, 6)).setFixedLength(6)).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamPeerMacAddress.setStatus('current')
wwp_leos_oam_peer_vendor_oui = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 3), octet_string().subtype(subtypeSpec=value_size_constraint(3, 3)).setFixedLength(3)).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamPeerVendorOui.setStatus('current')
wwp_leos_oam_peer_vendor_info = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 4), unsigned32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamPeerVendorInfo.setStatus('current')
wwp_leos_oam_peer_mode = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('active', 1), ('passive', 2), ('unknown', 3)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamPeerMode.setStatus('current')
wwp_leos_oam_peer_max_oam_pdu_size = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 6), integer32()).setUnits('bytes').setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamPeerMaxOamPduSize.setStatus('current')
wwp_leos_oam_peer_config_revision = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 7), unsigned32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamPeerConfigRevision.setStatus('current')
wwp_leos_oam_peer_functions_supported = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 8), bits().clone(namedValues=named_values(('unidirectionalSupport', 0), ('loopbackSupport', 1), ('eventSupport', 2), ('variableSupport', 3)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamPeerFunctionsSupported.setStatus('current')
wwp_leos_oam_local_port = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 9), integer32().subtype(subtypeSpec=value_range_constraint(1, 1000))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamLocalPort.setStatus('current')
wwp_leos_oam_loopback_table = mib_table((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3))
if mibBuilder.loadTexts:
wwpLeosOamLoopbackTable.setStatus('current')
wwp_leos_oam_loopback_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1)).setIndexNames((0, 'WWP-LEOS-OAM-MIB', 'wwpLeosOamLoopbackPort'))
if mibBuilder.loadTexts:
wwpLeosOamLoopbackEntry.setStatus('current')
wwp_leos_oam_loopback_command = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('noLoopback', 1), ('startRemoteLoopback', 2), ('stopRemoteLoopback', 3)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
wwpLeosOamLoopbackCommand.setStatus('current')
wwp_leos_oam_loopback_status = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6))).clone(namedValues=named_values(('noLoopback', 1), ('initiatingLoopback', 2), ('remoteLoopback', 3), ('terminatingLoopback', 4), ('localLoopback', 5), ('unknown', 6)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamLoopbackStatus.setStatus('current')
wwp_leos_oam_loopback_ignore_rx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('ignore', 1), ('process', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
wwpLeosOamLoopbackIgnoreRx.setStatus('current')
wwp_leos_oam_loopback_port = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1, 4), integer32().subtype(subtypeSpec=value_range_constraint(1, 1000))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamLoopbackPort.setStatus('current')
wwp_leos_oam_stats_table = mib_table((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4))
if mibBuilder.loadTexts:
wwpLeosOamStatsTable.setStatus('current')
wwp_leos_oam_stats_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1)).setIndexNames((0, 'WWP-LEOS-OAM-MIB', 'wwpLeosOamStatsPort'))
if mibBuilder.loadTexts:
wwpLeosOamStatsEntry.setStatus('current')
wwp_leos_oam_information_tx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 1), counter32()).setUnits('frames').setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamInformationTx.setStatus('current')
wwp_leos_oam_information_rx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 2), counter32()).setUnits('frames').setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamInformationRx.setStatus('current')
wwp_leos_oam_unique_event_notification_tx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 3), counter32()).setUnits('frames').setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamUniqueEventNotificationTx.setStatus('current')
wwp_leos_oam_unique_event_notification_rx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 4), counter32()).setUnits('frames').setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamUniqueEventNotificationRx.setStatus('current')
wwp_leos_oam_loopback_control_tx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 5), counter32()).setUnits('frames').setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamLoopbackControlTx.setStatus('current')
wwp_leos_oam_loopback_control_rx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 6), counter32()).setUnits('frames').setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamLoopbackControlRx.setStatus('current')
wwp_leos_oam_variable_request_tx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 7), counter32()).setUnits('frames').setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamVariableRequestTx.setStatus('current')
wwp_leos_oam_variable_request_rx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 8), counter32()).setUnits('frames').setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamVariableRequestRx.setStatus('current')
wwp_leos_oam_variable_response_tx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 9), counter32()).setUnits('frames').setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamVariableResponseTx.setStatus('current')
wwp_leos_oam_variable_response_rx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 10), counter32()).setUnits('frames').setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamVariableResponseRx.setStatus('current')
wwp_leos_oam_org_specific_tx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 11), counter32()).setUnits('frames').setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamOrgSpecificTx.setStatus('current')
wwp_leos_oam_org_specific_rx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 12), counter32()).setUnits('frames').setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamOrgSpecificRx.setStatus('current')
wwp_leos_oam_unsupported_codes_tx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 13), counter32()).setUnits('frames').setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamUnsupportedCodesTx.setStatus('current')
wwp_leos_oam_unsupported_codes_rx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 14), counter32()).setUnits('frames').setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamUnsupportedCodesRx.setStatus('current')
wwp_leos_oamframes_lost_due_to_oam = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 15), counter32()).setUnits('frames').setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamframesLostDueToOam.setStatus('current')
wwp_leos_oam_stats_port = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 16), integer32().subtype(subtypeSpec=value_range_constraint(1, 1000))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamStatsPort.setStatus('current')
wwp_leos_oam_duplicate_event_notification_tx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 17), counter32()).setUnits('frames').setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamDuplicateEventNotificationTx.setStatus('current')
wwp_leos_oam_duplicate_event_notification_rx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 18), counter32()).setUnits('frames').setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamDuplicateEventNotificationRx.setStatus('current')
wwp_leos_oam_system_enable_disable = mib_scalar((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enable', 1), ('disable', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
wwpLeosOamSystemEnableDisable.setStatus('current')
wwp_leos_oam_event_config_table = mib_table((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6))
if mibBuilder.loadTexts:
wwpLeosOamEventConfigTable.setStatus('current')
wwp_leos_oam_event_config_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1)).setIndexNames((0, 'WWP-LEOS-OAM-MIB', 'wwpLeosOamEventPort'))
if mibBuilder.loadTexts:
wwpLeosOamEventConfigEntry.setStatus('current')
wwp_leos_oam_event_port = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 1000))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamEventPort.setStatus('current')
wwp_leos_oam_err_frame_period_window = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 2), unsigned32().subtype(subtypeSpec=value_range_constraint(14880, 8928000))).setUnits('frames').setMaxAccess('readwrite')
if mibBuilder.loadTexts:
wwpLeosOamErrFramePeriodWindow.setStatus('current')
wwp_leos_oam_err_frame_period_threshold = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 3), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 4294967293))).setUnits('frames').setMaxAccess('readwrite')
if mibBuilder.loadTexts:
wwpLeosOamErrFramePeriodThreshold.setStatus('current')
wwp_leos_oam_err_frame_period_ev_notif_enable = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enabled', 1), ('disabled', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
wwpLeosOamErrFramePeriodEvNotifEnable.setStatus('current')
wwp_leos_oam_err_frame_window = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 5), unsigned32().subtype(subtypeSpec=value_range_constraint(10, 600))).setUnits('tenths of a second').setMaxAccess('readwrite')
if mibBuilder.loadTexts:
wwpLeosOamErrFrameWindow.setStatus('current')
wwp_leos_oam_err_frame_threshold = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 6), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 4294967293))).setUnits('frames').setMaxAccess('readwrite')
if mibBuilder.loadTexts:
wwpLeosOamErrFrameThreshold.setStatus('current')
wwp_leos_oam_err_frame_ev_notif_enable = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enabled', 1), ('disabled', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
wwpLeosOamErrFrameEvNotifEnable.setStatus('current')
wwp_leos_oam_err_frame_secs_summary_window = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 8), integer32().subtype(subtypeSpec=value_range_constraint(100, 9000))).setUnits('tenths of a second').setMaxAccess('readwrite')
if mibBuilder.loadTexts:
wwpLeosOamErrFrameSecsSummaryWindow.setStatus('current')
wwp_leos_oam_err_frame_secs_summary_threshold = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 9), integer32().subtype(subtypeSpec=value_range_constraint(0, 65535))).setUnits('errored frame seconds').setMaxAccess('readwrite')
if mibBuilder.loadTexts:
wwpLeosOamErrFrameSecsSummaryThreshold.setStatus('current')
wwp_leos_oam_err_frame_secs_ev_notif_enable = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 10), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enabled', 1), ('disabled', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
wwpLeosOamErrFrameSecsEvNotifEnable.setStatus('current')
wwp_leos_oam_dying_gasp_enable = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 11), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enabled', 1), ('disabled', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
wwpLeosOamDyingGaspEnable.setStatus('current')
wwp_leos_oam_critical_event_enable = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 12), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enabled', 1), ('disabled', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
wwpLeosOamCriticalEventEnable.setStatus('current')
wwp_leos_oam_event_log_table = mib_table((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7))
if mibBuilder.loadTexts:
wwpLeosOamEventLogTable.setStatus('current')
wwp_leos_oam_event_log_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1)).setIndexNames((0, 'WWP-LEOS-OAM-MIB', 'wwpLeosOamEventLogPort'), (0, 'WWP-LEOS-OAM-MIB', 'wwpLeosOamEventLogIndex'))
if mibBuilder.loadTexts:
wwpLeosOamEventLogEntry.setStatus('current')
wwp_leos_oam_event_log_port = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 1000))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamEventLogPort.setStatus('current')
wwp_leos_oam_event_log_index = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 2), unsigned32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamEventLogIndex.setStatus('current')
wwp_leos_oam_event_log_timestamp = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 3), time_stamp()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamEventLogTimestamp.setStatus('current')
wwp_leos_oam_event_log_oui = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 4), octet_string().subtype(subtypeSpec=value_size_constraint(3, 3)).setFixedLength(3)).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamEventLogOui.setStatus('current')
wwp_leos_oam_event_log_type = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 5), unsigned32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamEventLogType.setStatus('current')
wwp_leos_oam_event_log_location = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('local', 1), ('remote', 2)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamEventLogLocation.setStatus('current')
wwp_leos_oam_event_log_window_hi = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 7), unsigned32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamEventLogWindowHi.setStatus('current')
wwp_leos_oam_event_log_window_lo = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 8), unsigned32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamEventLogWindowLo.setStatus('current')
wwp_leos_oam_event_log_threshold_hi = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 9), unsigned32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamEventLogThresholdHi.setStatus('current')
wwp_leos_oam_event_log_threshold_lo = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 10), unsigned32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamEventLogThresholdLo.setStatus('current')
wwp_leos_oam_event_log_value = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 11), counter64()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamEventLogValue.setStatus('current')
wwp_leos_oam_event_log_running_total = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 12), counter64()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamEventLogRunningTotal.setStatus('current')
wwp_leos_oam_event_log_event_total = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 13), unsigned32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
wwpLeosOamEventLogEventTotal.setStatus('current')
wwp_leos_oam_global = mib_identifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 8))
wwp_leos_oam_stats_clear = mib_scalar((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 8, 1), truth_value()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
wwpLeosOamStatsClear.setStatus('current')
wwp_leos_oam_notif_mib_notification_prefix = mib_identifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3))
wwp_leos_oam_notif_mib_notification = mib_identifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3, 0))
wwp_leos_oam_link_event_trap = notification_type((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3, 0, 1)).setObjects(('WWP-LEOS-OAM-MIB', 'wwpLeosOamEventLogPort'), ('WWP-LEOS-OAM-MIB', 'wwpLeosOamEventLogType'), ('WWP-LEOS-OAM-MIB', 'wwpLeosOamEventLogLocation'))
if mibBuilder.loadTexts:
wwpLeosOamLinkEventTrap.setStatus('current')
wwp_leos_oam_link_lost_timer_active_trap = notification_type((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3, 0, 2)).setObjects(('WWP-LEOS-OAM-MIB', 'wwpLeosOamPort'), ('WWP-LEOS-PORT-MIB', 'wwpLeosEtherPortDesc'), ('WWP-LEOS-PORT-MIB', 'wwpLeosEtherPortOperStatus'), ('WWP-LEOS-OAM-MIB', 'wwpLeosOamOperStatus'), ('WWP-LEOS-OAM-MIB', 'wwpLeosOamPeerStatus'), ('WWP-LEOS-OAM-MIB', 'wwpLeosOamPeerMacAddress'))
if mibBuilder.loadTexts:
wwpLeosOamLinkLostTimerActiveTrap.setStatus('current')
wwp_leos_oam_link_lost_timer_expired_trap = notification_type((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3, 0, 3)).setObjects(('WWP-LEOS-OAM-MIB', 'wwpLeosOamPort'), ('WWP-LEOS-PORT-MIB', 'wwpLeosEtherPortDesc'), ('WWP-LEOS-PORT-MIB', 'wwpLeosEtherPortOperStatus'), ('WWP-LEOS-OAM-MIB', 'wwpLeosOamOperStatus'), ('WWP-LEOS-OAM-MIB', 'wwpLeosOamPeerStatus'), ('WWP-LEOS-OAM-MIB', 'wwpLeosOamPeerMacAddress'))
if mibBuilder.loadTexts:
wwpLeosOamLinkLostTimerExpiredTrap.setStatus('current')
mibBuilder.exportSymbols('WWP-LEOS-OAM-MIB', wwpLeosOamErrFrameSecsSummaryWindow=wwpLeosOamErrFrameSecsSummaryWindow, wwpLeosOamLoopbackIgnoreRx=wwpLeosOamLoopbackIgnoreRx, wwpLeosOamEventLogEntry=wwpLeosOamEventLogEntry, wwpLeosOamEventLogWindowHi=wwpLeosOamEventLogWindowHi, wwpLeosOamInformationRx=wwpLeosOamInformationRx, wwpLeosOamMode=wwpLeosOamMode, wwpLeosOamPort=wwpLeosOamPort, wwpLeosOamVariableRequestRx=wwpLeosOamVariableRequestRx, wwpLeosOamSystemEnableDisable=wwpLeosOamSystemEnableDisable, wwpLeosOamErrFramePeriodWindow=wwpLeosOamErrFramePeriodWindow, wwpLeosOamErrFramePeriodEvNotifEnable=wwpLeosOamErrFramePeriodEvNotifEnable, wwpLeosOamEventLogTable=wwpLeosOamEventLogTable, wwpLeosOamLinkLostTimerActiveTrap=wwpLeosOamLinkLostTimerActiveTrap, wwpLeosOamEventPort=wwpLeosOamEventPort, wwpLeosOamEventLogWindowLo=wwpLeosOamEventLogWindowLo, wwpLeosOamLoopbackControlTx=wwpLeosOamLoopbackControlTx, wwpLeosOamStatsClear=wwpLeosOamStatsClear, wwpLeosOamLoopbackCommand=wwpLeosOamLoopbackCommand, wwpLeosOamPeerMode=wwpLeosOamPeerMode, wwpLeosOamEventLogTimestamp=wwpLeosOamEventLogTimestamp, wwpLeosOamEventConfigEntry=wwpLeosOamEventConfigEntry, wwpLeosOamErrFrameThreshold=wwpLeosOamErrFrameThreshold, wwpLeosOamEventLogType=wwpLeosOamEventLogType, wwpLeosOamLoopbackControlRx=wwpLeosOamLoopbackControlRx, wwpLeosOamCriticalEventEnable=wwpLeosOamCriticalEventEnable, wwpLeosOamAdminState=wwpLeosOamAdminState, wwpLeosOamPeerFunctionsSupported=wwpLeosOamPeerFunctionsSupported, wwpLeosOamPeerMacAddress=wwpLeosOamPeerMacAddress, wwpLeosOamNotifMIBNotificationPrefix=wwpLeosOamNotifMIBNotificationPrefix, wwpLeosOamLinkEventTrap=wwpLeosOamLinkEventTrap, wwpLeosOamPeerStatusNotifyState=wwpLeosOamPeerStatusNotifyState, wwpLeosOamEventLogIndex=wwpLeosOamEventLogIndex, wwpLeosOamErrFrameWindow=wwpLeosOamErrFrameWindow, wwpLeosOamLinkLostTimerExpiredTrap=wwpLeosOamLinkLostTimerExpiredTrap, wwpLeosOamUnsupportedCodesTx=wwpLeosOamUnsupportedCodesTx, wwpLeosOamPeerVendorOui=wwpLeosOamPeerVendorOui, wwpLeosOamEventLogEventTotal=wwpLeosOamEventLogEventTotal, wwpLeosOamPeerVendorInfo=wwpLeosOamPeerVendorInfo, wwpLeosOamVariableRequestTx=wwpLeosOamVariableRequestTx, wwpLeosOamframesLostDueToOam=wwpLeosOamframesLostDueToOam, wwpLeosOamLocalPort=wwpLeosOamLocalPort, wwpLeosOamFunctionsSupported=wwpLeosOamFunctionsSupported, wwpLeosOamUniqueEventNotificationTx=wwpLeosOamUniqueEventNotificationTx, wwpLeosOamConf=wwpLeosOamConf, wwpLeosOamGroups=wwpLeosOamGroups, wwpLeosOamPeerEntry=wwpLeosOamPeerEntry, wwpLeosOamErrFrameSecsSummaryThreshold=wwpLeosOamErrFrameSecsSummaryThreshold, wwpLeosOamObjs=wwpLeosOamObjs, wwpLeosOamErrFrameEvNotifEnable=wwpLeosOamErrFrameEvNotifEnable, wwpLeosOamLoopbackTable=wwpLeosOamLoopbackTable, wwpLeosOamErrFrameSecsEvNotifEnable=wwpLeosOamErrFrameSecsEvNotifEnable, wwpLeosOamPeerStatus=wwpLeosOamPeerStatus, wwpLeosOamCompls=wwpLeosOamCompls, wwpLeosOamNotifMIBNotification=wwpLeosOamNotifMIBNotification, wwpLeosOamPeerTable=wwpLeosOamPeerTable, wwpLeosOamEventLogOui=wwpLeosOamEventLogOui, wwpLeosOamPeerConfigRevision=wwpLeosOamPeerConfigRevision, wwpLeosOamLinkLostTimer=wwpLeosOamLinkLostTimer, wwpLeosOamPeerMaxOamPduSize=wwpLeosOamPeerMaxOamPduSize, wwpLeosOamErrFramePeriodThreshold=wwpLeosOamErrFramePeriodThreshold, wwpLeosOamDuplicateEventNotificationRx=wwpLeosOamDuplicateEventNotificationRx, wwpLeosOamGlobal=wwpLeosOamGlobal, wwpLeosOamDyingGaspEnable=wwpLeosOamDyingGaspEnable, wwpLeosOamStatsEntry=wwpLeosOamStatsEntry, wwpLeosOamDuplicateEventNotificationTx=wwpLeosOamDuplicateEventNotificationTx, wwpLeosOamConfigRevision=wwpLeosOamConfigRevision, wwpLeosOamLoopbackStatus=wwpLeosOamLoopbackStatus, wwpLeosOamOrgSpecificRx=wwpLeosOamOrgSpecificRx, wwpLeosOamEventLogRunningTotal=wwpLeosOamEventLogRunningTotal, wwpLeosOamMIB=wwpLeosOamMIB, wwpLeosOamStatsTable=wwpLeosOamStatsTable, wwpLeosOamOperStatus=wwpLeosOamOperStatus, wwpLeosOamInformationTx=wwpLeosOamInformationTx, wwpLeosOamEventLogLocation=wwpLeosOamEventLogLocation, wwpLeosOamVariableResponseTx=wwpLeosOamVariableResponseTx, wwpLeosOamEventConfigTable=wwpLeosOamEventConfigTable, wwpLeosOamLoopbackPort=wwpLeosOamLoopbackPort, wwpLeosOamEventLogThresholdLo=wwpLeosOamEventLogThresholdLo, wwpLeosOamTable=wwpLeosOamTable, wwpLeosOamLoopbackEntry=wwpLeosOamLoopbackEntry, wwpLeosOamMibModule=wwpLeosOamMibModule, wwpLeosOamOrgSpecificTx=wwpLeosOamOrgSpecificTx, wwpLeosOamStatsPort=wwpLeosOamStatsPort, wwpLeosOamVariableResponseRx=wwpLeosOamVariableResponseRx, wwpLeosOamUnsupportedCodesRx=wwpLeosOamUnsupportedCodesRx, wwpLeosMaxOamPduSize=wwpLeosMaxOamPduSize, wwpLeosOamEventLogValue=wwpLeosOamEventLogValue, wwpLeosOamEventLogPort=wwpLeosOamEventLogPort, wwpLeosOamEventLogThresholdHi=wwpLeosOamEventLogThresholdHi, wwpLeosOamPduTimer=wwpLeosOamPduTimer, wwpLeosOamUniqueEventNotificationRx=wwpLeosOamUniqueEventNotificationRx, wwpLeosOamEntry=wwpLeosOamEntry, PYSNMP_MODULE_ID=wwpLeosOamMibModule) |
# https://leetcode.com/problems/longest-palindromic-subsequence/
class Solution:
def longestPalindromeSubseq(self, s: str) -> int:
dp = [[0 for _ in range(len(s))] for _ in range(len(s))]
for row in range(len(s)):
for col in range(len(s)):
# Find len of longest common subsequence of s and reversed(s).
if s[row] == s[-1 - col]:
diagonal_top_left = (
dp[row - 1][col - 1] if row > 0 and col > 0 else 0)
dp[row][col] = diagonal_top_left + 1
else:
top = dp[row - 1][col] if row > 0 else 0
left = dp[row][col - 1] if col > 0 else 0
dp[row][col] = max(top, left)
return dp[-1][-1]
| class Solution:
def longest_palindrome_subseq(self, s: str) -> int:
dp = [[0 for _ in range(len(s))] for _ in range(len(s))]
for row in range(len(s)):
for col in range(len(s)):
if s[row] == s[-1 - col]:
diagonal_top_left = dp[row - 1][col - 1] if row > 0 and col > 0 else 0
dp[row][col] = diagonal_top_left + 1
else:
top = dp[row - 1][col] if row > 0 else 0
left = dp[row][col - 1] if col > 0 else 0
dp[row][col] = max(top, left)
return dp[-1][-1] |
# Time: O(n)
# Space: O(1)
class Solution(object):
def findSubstringInWraproundString(self, p):
"""
:type p: str
:rtype: int
"""
letters = [0] * 26
result, length = 0, 0
for i in xrange(len(p)):
curr = ord(p[i]) - ord('a')
if i > 0 and ord(p[i-1]) != (curr-1)%26 + ord('a'):
length = 0
length += 1
if length > letters[curr]:
result += length - letters[curr]
letters[curr] = length
return result
| class Solution(object):
def find_substring_in_wrapround_string(self, p):
"""
:type p: str
:rtype: int
"""
letters = [0] * 26
(result, length) = (0, 0)
for i in xrange(len(p)):
curr = ord(p[i]) - ord('a')
if i > 0 and ord(p[i - 1]) != (curr - 1) % 26 + ord('a'):
length = 0
length += 1
if length > letters[curr]:
result += length - letters[curr]
letters[curr] = length
return result |
# This file is intended for use by the drake_py_test macro defined in
# //tools/skylark:drake_py.bzl and should NOT be used by anything else.
"""A drake_py_test should not `import unittest`. In most cases, your
BUILD.bazel file should use `drake_py_unittest` to declare such tests, which
provides an appropriate main() routine (and will disable this warning).
In the unlikely event that you actually have a unittest and need to write your
own main, set `allow_import_unittest = True` in the drake_py_test rule.
"""
raise RuntimeError(__doc__)
| """A drake_py_test should not `import unittest`. In most cases, your
BUILD.bazel file should use `drake_py_unittest` to declare such tests, which
provides an appropriate main() routine (and will disable this warning).
In the unlikely event that you actually have a unittest and need to write your
own main, set `allow_import_unittest = True` in the drake_py_test rule.
"""
raise runtime_error(__doc__) |
# -- Project information -----------------------------------------------------
project = "PyData Tests"
copyright = "2020, Pydata community"
author = "Pydata community"
master_doc = "index"
# -- General configuration ---------------------------------------------------
html_theme = "pydata_sphinx_theme"
html_copy_source = True
html_sourcelink_suffix = ""
| project = 'PyData Tests'
copyright = '2020, Pydata community'
author = 'Pydata community'
master_doc = 'index'
html_theme = 'pydata_sphinx_theme'
html_copy_source = True
html_sourcelink_suffix = '' |
test = { 'name': 'q5g',
'points': 1,
'suites': [ { 'cases': [ { 'code': ">>> 'result_q5g' in globals()\n"
'True',
'hidden': False,
'locked': False},
{ 'code': '>>> '
'result_q5g.to_string(index=False) '
'== '
'df_usa.fillna(value=0).head().to_string(index=False)\n'
'True',
'hidden': False,
'locked': False}],
'scored': True,
'setup': '',
'teardown': '',
'type': 'doctest'}]}
| test = {'name': 'q5g', 'points': 1, 'suites': [{'cases': [{'code': ">>> 'result_q5g' in globals()\nTrue", 'hidden': False, 'locked': False}, {'code': '>>> result_q5g.to_string(index=False) == df_usa.fillna(value=0).head().to_string(index=False)\nTrue', 'hidden': False, 'locked': False}], 'scored': True, 'setup': '', 'teardown': '', 'type': 'doctest'}]} |
# ========================
# Information
# ========================
# Direct Link: https://www.hackerrank.com/challenges/s10-poisson-distribution-2/problem
# Difficulty: Easy
# Max Score: 30
# Language: Python
# ========================
# Solution
# ========================
AVERAGE_X, AVERAGE_Y = [float(num) for num in input().split(" ")]
# Cost
COST_X = 160 + 40*(AVERAGE_X + AVERAGE_X**2)
COST_Y = 128 + 40*(AVERAGE_Y + AVERAGE_Y**2)
print(round(COST_X, 3))
print(round(COST_Y, 3))
| (average_x, average_y) = [float(num) for num in input().split(' ')]
cost_x = 160 + 40 * (AVERAGE_X + AVERAGE_X ** 2)
cost_y = 128 + 40 * (AVERAGE_Y + AVERAGE_Y ** 2)
print(round(COST_X, 3))
print(round(COST_Y, 3)) |
def cap_11(packet):
# your code here
try:
if packet["RTMPT"]["string"] == '_result':
packet["RTMPT"]["string"] = '_123456'
print("cambiado")
return packet
except:
print("fallo")
return None
| def cap_11(packet):
try:
if packet['RTMPT']['string'] == '_result':
packet['RTMPT']['string'] = '_123456'
print('cambiado')
return packet
except:
print('fallo')
return None |
'''
Hardcoded string input
no filtering
sink: check if a file exists
'''
class Class_351:
def __init__(self, param):
self.var_351 = param
def get_var_351(self):
return self.var_351 | """
Hardcoded string input
no filtering
sink: check if a file exists
"""
class Class_351:
def __init__(self, param):
self.var_351 = param
def get_var_351(self):
return self.var_351 |
class LiveDataFeed(object):
""" A simple "live data feed" abstraction that allows a reader
to read the most recent data and find out whether it was
updated since the last read.
Interface to data writer:
add_data(data):
Add new data to the feed.
Interface to reader:
read_data():
Returns the most recent data.
has_new_data:
A boolean attribute telling the reader whether the
data was updated since the last read.
"""
def __init__(self):
self.cur_data = None
self.has_new_data = False
def add_data(self, data):
self.cur_data = data
self.has_new_data = True
def read_data(self):
self.has_new_data = False
return self.cur_data
if __name__ == "__main__":
pass
| class Livedatafeed(object):
""" A simple "live data feed" abstraction that allows a reader
to read the most recent data and find out whether it was
updated since the last read.
Interface to data writer:
add_data(data):
Add new data to the feed.
Interface to reader:
read_data():
Returns the most recent data.
has_new_data:
A boolean attribute telling the reader whether the
data was updated since the last read.
"""
def __init__(self):
self.cur_data = None
self.has_new_data = False
def add_data(self, data):
self.cur_data = data
self.has_new_data = True
def read_data(self):
self.has_new_data = False
return self.cur_data
if __name__ == '__main__':
pass |
inv_count = 0
def sorter(l_res , r_res):
global inv_count
i = 0
r = 0
results = []
while i < len(l_res) and r < len(r_res):
if l_res[i] > r_res[r]:
results.append(r_res[r])
inv_count += len(l_res) - i
r += 1
else:
results.append(l_res[i])
i += 1
while i < len(l_res):
results.append(l_res[i])
i += 1
while r < len(r_res):
results.append(r_res[r])
r += 1
return results
def divider(arr):
if len(arr) == 1:
return arr
mid = len(arr)//2
l_arr = arr[0:mid]
r_arr = arr[mid:]
l_res = divider(l_arr)
r_res = divider(r_arr)
arr = sorter(l_res, r_res)
return arr
A = [6, 5, 2, 1, 5, 6]
res = divider(A)
print(inv_count)
#
# def brute_force(arr):
# arr = A
# lent = len(arr)
# inv_c = 0
# for i in range(lent):
# for j in range(i+1, lent):
# if arr[i] > arr[j]:
# inv_c += 1
# return inv_c % (10**7 + 7)
#
#
# A = [1, 2, 3, 4, 5, 6]
# res = brute_force(A)
# print(res)
| inv_count = 0
def sorter(l_res, r_res):
global inv_count
i = 0
r = 0
results = []
while i < len(l_res) and r < len(r_res):
if l_res[i] > r_res[r]:
results.append(r_res[r])
inv_count += len(l_res) - i
r += 1
else:
results.append(l_res[i])
i += 1
while i < len(l_res):
results.append(l_res[i])
i += 1
while r < len(r_res):
results.append(r_res[r])
r += 1
return results
def divider(arr):
if len(arr) == 1:
return arr
mid = len(arr) // 2
l_arr = arr[0:mid]
r_arr = arr[mid:]
l_res = divider(l_arr)
r_res = divider(r_arr)
arr = sorter(l_res, r_res)
return arr
a = [6, 5, 2, 1, 5, 6]
res = divider(A)
print(inv_count) |
# -*- coding: utf-8 -*-
"""
ENERPIPLOT - Common constants & color palettes
"""
ROUND_W = 500
ROUND_KWH = .5
COLOR_REF_RMS = '#FF0077'
# summary (consumption) var plots
COLS_DATA_KWH = ['kWh', 'p_max', 'p_min', 't_ref']
COLORS_DATA_KWH = ['#8C27D3', '#972625', '#f4af38', '#8C27D3']
UNITS_DATA_KWH = ['kWh', 'W', 'W', '']
LABELS_DATA_KWH = ['Consumption', 'Max Power', 'Min Power', 'Sampled']
FMT_TOOLTIP_DATA_KWH = ['{0.000}', '{0}', '{0}', '{0.000}']
def _gen_tableau20():
# These are the "Tableau 20" colors as RGB.
tableau = [(31, 119, 180), (174, 199, 232), (255, 127, 14), (255, 187, 120),
(44, 160, 44), (152, 223, 138), (214, 39, 40), (255, 152, 150),
(148, 103, 189), (197, 176, 213), (140, 86, 75), (196, 156, 148),
(227, 119, 194), (247, 182, 210), (127, 127, 127), (199, 199, 199),
(188, 189, 34), (219, 219, 141), (23, 190, 207), (158, 218, 229)]
# Scale the RGB values to the [0, 1] range, which is the format matplotlib accepts.
for i in range(len(tableau)):
r, g, b = tableau[i]
tableau[i] = (r / 255., g / 255., b / 255.)
return tableau
# These are the "Tableau 20" colors as RGB.
tableau20 = _gen_tableau20()
| """
ENERPIPLOT - Common constants & color palettes
"""
round_w = 500
round_kwh = 0.5
color_ref_rms = '#FF0077'
cols_data_kwh = ['kWh', 'p_max', 'p_min', 't_ref']
colors_data_kwh = ['#8C27D3', '#972625', '#f4af38', '#8C27D3']
units_data_kwh = ['kWh', 'W', 'W', '']
labels_data_kwh = ['Consumption', 'Max Power', 'Min Power', 'Sampled']
fmt_tooltip_data_kwh = ['{0.000}', '{0}', '{0}', '{0.000}']
def _gen_tableau20():
tableau = [(31, 119, 180), (174, 199, 232), (255, 127, 14), (255, 187, 120), (44, 160, 44), (152, 223, 138), (214, 39, 40), (255, 152, 150), (148, 103, 189), (197, 176, 213), (140, 86, 75), (196, 156, 148), (227, 119, 194), (247, 182, 210), (127, 127, 127), (199, 199, 199), (188, 189, 34), (219, 219, 141), (23, 190, 207), (158, 218, 229)]
for i in range(len(tableau)):
(r, g, b) = tableau[i]
tableau[i] = (r / 255.0, g / 255.0, b / 255.0)
return tableau
tableau20 = _gen_tableau20() |
#
# @lc app=leetcode.cn id=133 lang=python3
#
# [133] clone-graph
#
None
# @lc code=end | None |
def add_node(v):
if v in graph:
print(v,"already present")
else:
graph[v]=[]
def add_edge(v1,v2):
if v1 not in graph:
print(v1," not present in graph")
elif v2 not in graph:
print(v2,"not present in graph")
else:
graph[v1].append(v2)
graph[v2].append(v1)
def delete_edge(v1,v2):
if v1 not in graph:
print(v1,"not present in graph")
elif v2 not in graph:
print(v2,"not present in graph")
else:
if v2 in graph[v1]:
graph[v1].remove(v2)
graph[v2].remove(v1)
graph={}
add_node('A')
add_node('B')
add_node('C')
add_node('D')
add_edge('A','D')
add_edge('A','C')
add_edge('C','D')
add_edge('C','E')
delete_edge('C','D') #Op=>> {'A': ['D', 'C'], 'B': [], 'C': ['A'], 'D': ['A']}
print(graph)
| def add_node(v):
if v in graph:
print(v, 'already present')
else:
graph[v] = []
def add_edge(v1, v2):
if v1 not in graph:
print(v1, ' not present in graph')
elif v2 not in graph:
print(v2, 'not present in graph')
else:
graph[v1].append(v2)
graph[v2].append(v1)
def delete_edge(v1, v2):
if v1 not in graph:
print(v1, 'not present in graph')
elif v2 not in graph:
print(v2, 'not present in graph')
elif v2 in graph[v1]:
graph[v1].remove(v2)
graph[v2].remove(v1)
graph = {}
add_node('A')
add_node('B')
add_node('C')
add_node('D')
add_edge('A', 'D')
add_edge('A', 'C')
add_edge('C', 'D')
add_edge('C', 'E')
delete_edge('C', 'D')
print(graph) |
# ================================================================
def total_packet_size_bytes (s):
return (s ['packet_len'] +
s ['num_credits'] +
s ['channel_id'] +
s ['payload'])
def this_packet_size_bytes (s, n):
return (s ['packet_len'] +
s ['num_credits'] +
s ['channel_id'] +
n)
# ================================================================
# Substitution function to expand a template into code.
# 'template' is a list of strings
# Each string represents a line of text,
# and may contain '@FOO' variables to be substituted.
# 'substs' is list of (@FOO, string) substitutions.
# Returns a string which concatenates the lines and substitutes the vars.
def subst (template, substs):
s = "\n".join (template)
for (var, val) in substs:
s = s.replace (var, val)
return s
# ================================================================
| def total_packet_size_bytes(s):
return s['packet_len'] + s['num_credits'] + s['channel_id'] + s['payload']
def this_packet_size_bytes(s, n):
return s['packet_len'] + s['num_credits'] + s['channel_id'] + n
def subst(template, substs):
s = '\n'.join(template)
for (var, val) in substs:
s = s.replace(var, val)
return s |
class S(str):
# Symbol class: the only important difference between S and str is that S has a __substitute__ method
# Note that S('a') == 'a' is True. This lets us use strings as shorthand in certain places.
def __str__(self):
return "S('" + super(S, self).__str__() + "')"
def __repr__(self):
return "S(" + super(S, self).__repr__() + ")"
def __substitute__(self, values):
return values[self]
def identity(x):
return x
class TransSymbol(object):
# A Symbol or SymbolicAddress with a transformation applied
# TODO: reverse transformation currently not applied during match. Use it.
def __init__(self, symbol, forward=identity, reverse=identity):
# Can either pass a single dict, or a pair of functions
self._symbol = symbol
self._map = None
if type(forward) == dict:
reverse = {v:k for k,v in forward.items()}
# TODO: add option to fail on map miss
self._forward_func = lambda k: forward.get(k, None)
self._reverse = lambda k: reverse.get(k, None)
self._map = forward
else:
self._forward_func = forward
self._reverse = reverse
# Note that there is no corresponding wrapper for _reverse. This is a minor hack, and I haven't decided what behavior
# I actually want here.
def _forward(self, inner):
try:
return self._forward_func(inner)
except TypeError:
# Hit if either forward function is None, or forward function receives None but doesn't handle it. Both ok.
# TODO: figure out what I actually want the default behavior to be
return inner
except AttributeError:
# Same story
return inner
# TODO: proper equality & hashing for TransSymbols.
def __str__(self):
return 'Trans(' + str(self._symbol) + ')'
def __repr__(self):
if self._map:
return 'Trans(' + self._symbol.__repr__() + ', ' + self._map.__repr__() + ')'
return 'Trans(' + self._symbol.__repr__() + ')'
class Nullable(object):
# A simple wrapper class to mark part of a template as optional, i.e. match is allowed to fail.
def __init__(self, contents):
self.contents = contents
| class S(str):
def __str__(self):
return "S('" + super(S, self).__str__() + "')"
def __repr__(self):
return 'S(' + super(S, self).__repr__() + ')'
def __substitute__(self, values):
return values[self]
def identity(x):
return x
class Transsymbol(object):
def __init__(self, symbol, forward=identity, reverse=identity):
self._symbol = symbol
self._map = None
if type(forward) == dict:
reverse = {v: k for (k, v) in forward.items()}
self._forward_func = lambda k: forward.get(k, None)
self._reverse = lambda k: reverse.get(k, None)
self._map = forward
else:
self._forward_func = forward
self._reverse = reverse
def _forward(self, inner):
try:
return self._forward_func(inner)
except TypeError:
return inner
except AttributeError:
return inner
def __str__(self):
return 'Trans(' + str(self._symbol) + ')'
def __repr__(self):
if self._map:
return 'Trans(' + self._symbol.__repr__() + ', ' + self._map.__repr__() + ')'
return 'Trans(' + self._symbol.__repr__() + ')'
class Nullable(object):
def __init__(self, contents):
self.contents = contents |
def randomized_partition(arr, low, high):
"""Partition the array into two halfs according to the last element (pivot)
loop invariant:
[low, i] <= pivot
[i+1, j) > pivot
"""
i = low - 1
j = low
pivot = arr[high]
while j < high:
if arr[j] <= pivot:
i = i + 1
arr[i], arr[j] = arr[j], arr[i]
j = j + 1
i = i + 1
arr[i], arr[high] = pivot, arr[i]
return i
def qsort(arr, low, high):
if low < high:
pivot_loc = randomized_partition(arr, low, high)
qsort(arr, low, pivot_loc - 1)
qsort(arr, pivot_loc + 1, high)
def merge(arr, low, mid, high):
left = arr[low:mid + 1]
right = arr[mid + 1:high + 1]
i = 0
j = 0
k = low
while i <= mid - low and j <= high - mid - 1:
if left[i] <= right[j]:
arr[k] = left[i]
i += 1
else:
arr[k] = right[j]
j += 1
k += 1
while i <= mid - low:
arr[k] = left[i]
i += 1
k += 1
while j <= high - mid - 1:
arr[k] = right[j]
j += 1
k += 1
def merge_sort(arr, low, high):
if low < high:
mid = int((low + high) / 2)
merge_sort(arr, low, mid)
merge_sort(arr, mid + 1, high)
merge(arr, low, mid, high)
def left_child(index):
return 2 * index + 1
def right_child(index):
return 2 * index + 2
def min_heapify(arr, index, size):
left = left_child(index)
right = right_child(index)
# find smallest among children, swap and heapify children
if left < size and arr[left] < arr[index]:
smallest_idx = left
else:
smallest_idx = index
if right < size and arr[right] < arr[smallest_idx]:
smallest_idx = right
if smallest_idx != index:
arr[index], arr[smallest_idx] = arr[smallest_idx], arr[index]
min_heapify(arr, smallest_idx, size)
def build_heap(arr, size):
for i in reversed(range(int(size / 2))):
min_heapify(arr, i, size)
def heap_sort(arr, low, high):
copy = arr[low:high + 1]
size = high - low + 1
build_heap(copy, size)
for i in reversed(range(1, size)):
copy[0], copy[i] = copy[i], copy[0]
size = size - 1
min_heapify(copy, 0, size)
arr[low:high + 1] = [x for x in reversed(copy)]
def radix_sort(arr, low, high, digit, base=10):
def sort_digit(arr, low, high, pos, base):
buckets = [[] for _ in range(base)]
for val in arr[low:high + 1]:
digit = (val // base**pos) % base
buckets[digit].append(val)
return [item for digit_list in buckets for item in digit_list]
for i in range(digit):
arr[low:high + 1] = sort_digit(arr, low, high, i, base)
arr = [2, 1, 2, 4, 7, 5, 2, 6, 10, 8]
size = len(arr)
# qsort(arr, 0, size-1)
# heap_sort(arr, 0, size - 1)
radix_sort(arr, 0, size - 1, 1, 10)
print(arr)
| def randomized_partition(arr, low, high):
"""Partition the array into two halfs according to the last element (pivot)
loop invariant:
[low, i] <= pivot
[i+1, j) > pivot
"""
i = low - 1
j = low
pivot = arr[high]
while j < high:
if arr[j] <= pivot:
i = i + 1
(arr[i], arr[j]) = (arr[j], arr[i])
j = j + 1
i = i + 1
(arr[i], arr[high]) = (pivot, arr[i])
return i
def qsort(arr, low, high):
if low < high:
pivot_loc = randomized_partition(arr, low, high)
qsort(arr, low, pivot_loc - 1)
qsort(arr, pivot_loc + 1, high)
def merge(arr, low, mid, high):
left = arr[low:mid + 1]
right = arr[mid + 1:high + 1]
i = 0
j = 0
k = low
while i <= mid - low and j <= high - mid - 1:
if left[i] <= right[j]:
arr[k] = left[i]
i += 1
else:
arr[k] = right[j]
j += 1
k += 1
while i <= mid - low:
arr[k] = left[i]
i += 1
k += 1
while j <= high - mid - 1:
arr[k] = right[j]
j += 1
k += 1
def merge_sort(arr, low, high):
if low < high:
mid = int((low + high) / 2)
merge_sort(arr, low, mid)
merge_sort(arr, mid + 1, high)
merge(arr, low, mid, high)
def left_child(index):
return 2 * index + 1
def right_child(index):
return 2 * index + 2
def min_heapify(arr, index, size):
left = left_child(index)
right = right_child(index)
if left < size and arr[left] < arr[index]:
smallest_idx = left
else:
smallest_idx = index
if right < size and arr[right] < arr[smallest_idx]:
smallest_idx = right
if smallest_idx != index:
(arr[index], arr[smallest_idx]) = (arr[smallest_idx], arr[index])
min_heapify(arr, smallest_idx, size)
def build_heap(arr, size):
for i in reversed(range(int(size / 2))):
min_heapify(arr, i, size)
def heap_sort(arr, low, high):
copy = arr[low:high + 1]
size = high - low + 1
build_heap(copy, size)
for i in reversed(range(1, size)):
(copy[0], copy[i]) = (copy[i], copy[0])
size = size - 1
min_heapify(copy, 0, size)
arr[low:high + 1] = [x for x in reversed(copy)]
def radix_sort(arr, low, high, digit, base=10):
def sort_digit(arr, low, high, pos, base):
buckets = [[] for _ in range(base)]
for val in arr[low:high + 1]:
digit = val // base ** pos % base
buckets[digit].append(val)
return [item for digit_list in buckets for item in digit_list]
for i in range(digit):
arr[low:high + 1] = sort_digit(arr, low, high, i, base)
arr = [2, 1, 2, 4, 7, 5, 2, 6, 10, 8]
size = len(arr)
radix_sort(arr, 0, size - 1, 1, 10)
print(arr) |
class SwampyException(Exception):
pass
class ExWelcomeTimeout(SwampyException):
pass
class ExAbort(SwampyException):
pass
class ExInvocationError(SwampyException):
pass
| class Swampyexception(Exception):
pass
class Exwelcometimeout(SwampyException):
pass
class Exabort(SwampyException):
pass
class Exinvocationerror(SwampyException):
pass |
"""
aiida_abinit
The AiiDA plugin for ABINIT.
"""
__version__ = "0.1.0a0"
| """
aiida_abinit
The AiiDA plugin for ABINIT.
"""
__version__ = '0.1.0a0' |
class CableTrayConduitBase(MEPCurve,IDisposable):
""" The CableTrayConduitBase class is implemented as the base class for cable tray or conduit """
def Dispose(self):
""" Dispose(self: Element,A_0: bool) """
pass
def getBoundingBox(self,*args):
""" getBoundingBox(self: Element,view: View) -> BoundingBoxXYZ """
pass
@staticmethod
def IsValidEndPoints(startPoint,endPoint):
"""
IsValidEndPoints(startPoint: XYZ,endPoint: XYZ) -> bool
Identifies if two end points are valid.
startPoint: The start point of the location line.
endPoint: The end point of the location line.
Returns: True if the two end points are valid,false otherwise.
"""
pass
@staticmethod
def IsValidLevelId(document,levelId):
"""
IsValidLevelId(document: Document,levelId: ElementId) -> bool
Identifies if a level id is valid.
document: The document.
levelId: The level id.
Returns: True if the level id is valid,false otherwise.
"""
pass
def IsWithFitting(self):
"""
IsWithFitting(self: CableTrayConduitBase) -> bool
Return whether its cable tray/conduit type is with fitting
Returns: return true if its type is with fitting type.
"""
pass
def ReleaseUnmanagedResources(self,*args):
""" ReleaseUnmanagedResources(self: Element,disposing: bool) """
pass
def setElementType(self,*args):
""" setElementType(self: Element,type: ElementType,incompatibleExceptionMessage: str) """
pass
def __enter__(self,*args):
""" __enter__(self: IDisposable) -> object """
pass
def __exit__(self,*args):
""" __exit__(self: IDisposable,exc_type: object,exc_value: object,exc_back: object) """
pass
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
RunId=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""The id of the run to which this element belongs.
Get: RunId(self: CableTrayConduitBase) -> ElementId
"""
| class Cabletrayconduitbase(MEPCurve, IDisposable):
""" The CableTrayConduitBase class is implemented as the base class for cable tray or conduit """
def dispose(self):
""" Dispose(self: Element,A_0: bool) """
pass
def get_bounding_box(self, *args):
""" getBoundingBox(self: Element,view: View) -> BoundingBoxXYZ """
pass
@staticmethod
def is_valid_end_points(startPoint, endPoint):
"""
IsValidEndPoints(startPoint: XYZ,endPoint: XYZ) -> bool
Identifies if two end points are valid.
startPoint: The start point of the location line.
endPoint: The end point of the location line.
Returns: True if the two end points are valid,false otherwise.
"""
pass
@staticmethod
def is_valid_level_id(document, levelId):
"""
IsValidLevelId(document: Document,levelId: ElementId) -> bool
Identifies if a level id is valid.
document: The document.
levelId: The level id.
Returns: True if the level id is valid,false otherwise.
"""
pass
def is_with_fitting(self):
"""
IsWithFitting(self: CableTrayConduitBase) -> bool
Return whether its cable tray/conduit type is with fitting
Returns: return true if its type is with fitting type.
"""
pass
def release_unmanaged_resources(self, *args):
""" ReleaseUnmanagedResources(self: Element,disposing: bool) """
pass
def set_element_type(self, *args):
""" setElementType(self: Element,type: ElementType,incompatibleExceptionMessage: str) """
pass
def __enter__(self, *args):
""" __enter__(self: IDisposable) -> object """
pass
def __exit__(self, *args):
""" __exit__(self: IDisposable,exc_type: object,exc_value: object,exc_back: object) """
pass
def __init__(self, *args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
run_id = property(lambda self: object(), lambda self, v: None, lambda self: None)
'The id of the run to which this element belongs.\n\n\n\nGet: RunId(self: CableTrayConduitBase) -> ElementId\n\n\n\n' |
#!/usr/bin/python3
def new_in_list(my_list, idx, element):
new_list = my_list[:]
if idx >= 0 and idx < len(my_list):
new_list[idx] = element
return new_list
| def new_in_list(my_list, idx, element):
new_list = my_list[:]
if idx >= 0 and idx < len(my_list):
new_list[idx] = element
return new_list |
# https://leetcode.com/problems/bitwise-ors-of-subarrays/
#
# algorithms
# Medium (32.02%)
# Total Accepted: 5,616
# Total Submissions: 17,538
class Solution(object):
def subarrayBitwiseORs(self, A):
"""
:type A: List[int]
:rtype: int
"""
cur, res = set(), set()
for n in A:
cur = {i | n for i in cur} | {n}
res |= cur
return len(res)
| class Solution(object):
def subarray_bitwise_o_rs(self, A):
"""
:type A: List[int]
:rtype: int
"""
(cur, res) = (set(), set())
for n in A:
cur = {i | n for i in cur} | {n}
res |= cur
return len(res) |
"""
Class to parse and validate command-line arguments required by train, classify and evaluate.
"""
class ArgumentHandler:
def __init__(self):
#I/O
#data.py: DataHandler
self.logdir = None
self.max_tokens = 200
self.labels = ""
self.num_labels = 3
self.feature_input_dims = self.num_labels + 1 #turn no + context bow
self.context_size = 3
#model.py: Net
self.text_encoder = True
self.text_encoder_dims = 768
self.text_output_dims = 64
self.bert = True
self.feature_encoder = False
self.feature_encoder_dims = 64
self.dropout = 0.1
self.activation = 'relu'
#model.py: ModelHandler
self.batch_size = 8
self.load_from_ckpt = False
self.ckpt_file = None #"best_ckpt.pt"
self.learning_rate = 2e-5
self.weight_decay = 0.01
self.max_grad_norm = 1.0
self.num_epochs = 500 #only using num_iters, essentially.
self.num_iters=100
self.print_iter_no_after = 25#print iter number after.
self.ckpt_after = 50
self.freeze = False
self.oversample = False
self.have_attn = True
self.pretraining = False
self.pretrained_dir = ""
self.store_preds = False
self.majority_prediction = False
def update_hyps(self, hyps):
"""
Update the params
"""
for key, value in hyps.items():
setattr(self, key, value) | """
Class to parse and validate command-line arguments required by train, classify and evaluate.
"""
class Argumenthandler:
def __init__(self):
self.logdir = None
self.max_tokens = 200
self.labels = ''
self.num_labels = 3
self.feature_input_dims = self.num_labels + 1
self.context_size = 3
self.text_encoder = True
self.text_encoder_dims = 768
self.text_output_dims = 64
self.bert = True
self.feature_encoder = False
self.feature_encoder_dims = 64
self.dropout = 0.1
self.activation = 'relu'
self.batch_size = 8
self.load_from_ckpt = False
self.ckpt_file = None
self.learning_rate = 2e-05
self.weight_decay = 0.01
self.max_grad_norm = 1.0
self.num_epochs = 500
self.num_iters = 100
self.print_iter_no_after = 25
self.ckpt_after = 50
self.freeze = False
self.oversample = False
self.have_attn = True
self.pretraining = False
self.pretrained_dir = ''
self.store_preds = False
self.majority_prediction = False
def update_hyps(self, hyps):
"""
Update the params
"""
for (key, value) in hyps.items():
setattr(self, key, value) |
class Body(object):
"""An class which is used to store basic properties about a body"""
def __init__(self, xPos, yPos, xVel, yVel, mass):
"""Create a new body
xPos - The x component of the position
yPos - The y component of the position
xVel - The x component of the velocity
yVel - The y component of the velocity
mass - The mass of the body"""
self.xPos = xPos
self.yPos = yPos
self.xVel = xVel
self.yVel = yVel
self.xAcl = 0.0
self.yAcl = 0.0
self.mass = mass
| class Body(object):
"""An class which is used to store basic properties about a body"""
def __init__(self, xPos, yPos, xVel, yVel, mass):
"""Create a new body
xPos - The x component of the position
yPos - The y component of the position
xVel - The x component of the velocity
yVel - The y component of the velocity
mass - The mass of the body"""
self.xPos = xPos
self.yPos = yPos
self.xVel = xVel
self.yVel = yVel
self.xAcl = 0.0
self.yAcl = 0.0
self.mass = mass |
def main(type):
x = 0
print(type)
if type=="wl":
#a while loop
while (x <5):
print(x)
x = x + 1
elif type=="fl":
#a for loop
for x in range(5,10):
print(x)
elif type=="cl":
#a for loop over a collection
days = ["Mon", "Tue", "Wed", "Thurs", "Fri", "Sat", "Sun"]
for d in days:
print(d)
elif type=="en":
# enumerate() function to get index
directions = ["East", "West", "North", "South", "SouthWest", "NorthEast", "NorthWest"]
for i, d in enumerate(directions):
print (i,d)
else:
print("Invalid loop type specified")
if __name__ == "__main__":
main('wl')
| def main(type):
x = 0
print(type)
if type == 'wl':
while x < 5:
print(x)
x = x + 1
elif type == 'fl':
for x in range(5, 10):
print(x)
elif type == 'cl':
days = ['Mon', 'Tue', 'Wed', 'Thurs', 'Fri', 'Sat', 'Sun']
for d in days:
print(d)
elif type == 'en':
directions = ['East', 'West', 'North', 'South', 'SouthWest', 'NorthEast', 'NorthWest']
for (i, d) in enumerate(directions):
print(i, d)
else:
print('Invalid loop type specified')
if __name__ == '__main__':
main('wl') |
# Constants in FlexRay spec
cdCycleMax = 16000
cCycleCountMax = 63
cStaticSlotIDMax = 1023
cSlotIDMax = 2047
cPayloadLengthMax = 127
cSamplesPerBit = 8
cSyncFrameIDCountMax = 15
cMicroPerMacroNomMin = 40
cdMinMTNom = 1
cdMaxMTNom = 6
cdFES = 2
cdFSS = 1
cChannelIdleDelimiter = 11
cClockDeviationMax = 0.0015
cStrobeOffset = 5
cVotingSamples = 5
cVotingDelay = (cVotingSamples - 1) / 2
cdBSS = 2
cdWakeupSymbolTxIdle = 18
cdWakeupSymbolTxLow = 6
cdCAS = 30
cMicroPerMacroMin = 20
cdMaxOffsetCalculation = 1350
cdMaxRateCalculation = 1500
SIZEOF_UINT16 = 2
SIZEOF_PACKET_HEADER = SIZEOF_UINT16 * 2
PACKET_TYPE_START_DRIVER = 0
PACKET_TYPE_FLEXRAY_FRAME = 1
PACKET_TYPE_HEALTH = 2
PACKET_TYPE_FLEXRAY_JOINED_CLUSTER = 3
PACKET_TYPE_FLEXRAY_JOIN_CLUSTER_FAILED = 4
PACKET_TYPE_FLEXRAY_DISCONNECTED_FROM_CLUSTER = 5
PACKET_TYPE_FLEXRAY_FATAL_ERROR = 6
PACKET_TYPE_MONIOR_SLOTS = 7
# MPC5748g registers bits
FR_PIFR0_TBVA_IF_U16 = 0x0008
FR_PIFR0_TBVB_IF_U16 = 0x0010
FR_PIFR0_LTXA_IF_U16 = 0x0020
FR_PIFR0_LTXB_IF_U16 = 0x0040
FR_PIER0_CCL_IF_U16 = 0x0200
FR_PIFR0_MOC_IF_U16 = 0x0400
FR_PIFR0_MRC_IF_U16 = 0x0800
FR_PIFR0_FATL_IF_U16 = 0x8000
FR_PIFR0_INTL_IF_U16 = 0x4000
FR_PIFR0_ILCF_IF_U16 = 0x2000
FR_PIFR0_CSA_IF_U16 = 0x1000
FR_PIER0_TI2_IE_U16 = 0x0004
FR_PIER0_TI1_IE_U16 = 0x0002
FR_PSR0_ERRMODE_MASK_U16 = 0xC000
FR_PSR0_SLOTMODE_MASK_U16 = 0x3000
FR_PSR0_PROTSTATE_MASK_U16 = 0x0700
FR_PSR0_STARTUP_MASK_U16 = 0x00F0
FR_PSR0_WUP_MASK_U16 = 0x0007
FR_PSR0_SLOTMODE_SINGLE_U16 = 0x0000
FR_PSR0_SLOTMODE_ALL_PENDING_U16 = 0x1000
FR_PSR0_SLOTMODE_ALL_U16 = 0x2000
FR_PSR0_ERRMODE_ACTIVE_U16 = 0x0000
FR_PSR0_ERRMODE_PASSIVE_U16 = 0x4000
FR_PSR0_ERRMODE_COMM_HALT_U16 = 0x8000
FR_PSR0_PROTSTATE_DEFAULT_CONFIG_U16 = 0x0000
FR_PSR0_PROTSTATE_CONFIG_U16 = 0x0100
FR_PSR0_PROTSTATE_WAKEUP_U16 = 0x0200
FR_PSR0_PROTSTATE_READY_U16 = 0x0300
FR_PSR0_PROTSTATE_NORMAL_PASSIVE_U16 = 0x0400
FR_PSR0_PROTSTATE_NORMAL_ACTIVE_U16 = 0x0500
FR_PSR0_PROTSTATE_HALT_U16 = 0x0600
FR_PSR0_PROTSTATE_STARTUP_U16 = 0x0700
FR_PSR0_STARTUP_CCR_U16 = 0x0020
FR_PSR0_STARTUP_CL_U16 = 0x0030
FR_PSR0_STARTUP_ICOC_U16 = 0x0040
FR_PSR0_STARTUP_IL_U16 = 0x0050
FR_PSR0_STARTUP_IS_U16 = 0x0070
FR_PSR0_STARTUP_CCC_U16 = 0x00A0
FR_PSR0_STARTUP_ICLC_U16 = 0x00D0
FR_PSR0_STARTUP_CG_U16 = 0x00E0
FR_PSR0_STARTUP_CJ_U16 = 0x00F0
FR_PSR1_CPN_U16 = 0x0080
FR_PSR1_HHR_U16 = 0x0040
FR_PSR1_FRZ_U16 = 0x0020
FR_PSR2_NBVB_MASK_U16 = 0x8000
FR_PSR2_NSEB_MASK_U16 = 0x4000
FR_PSR2_STCB_MASK_U16 = 0x2000
FR_PSR2_SBVB_MASK_U16 = 0x1000
FR_PSR2_SSEB_MASK_U16 = 0x0800
FR_PSR2_MTB_MASK_U16 = 0x0400
FR_PSR2_NBVA_MASK_U16 = 0x0200
FR_PSR2_NSEA_MASK_U16 = 0x0100
FR_PSR2_STCA_MASK_U16 = 0x0080
FR_PSR2_SBVA_MASK_U16 = 0x0040
FR_PSR2_SSEA_MASK_U16 = 0x0020
FR_PSR2_MTA_MASK_U16 = 0x0010
FR_PSR2_CKCORFCNT_MASK_U16 = 0x000F
FR_PSR3_ABVB_U16 = 0x1000
FR_PSR3_AACB_U16 = 0x0800
FR_PSR3_ACEB_U16 = 0x0400
FR_PSR3_ASEB_U16 = 0x0200
FR_PSR3_AVFB_U16 = 0x0100
FR_PSR3_ABVA_U16 = 0x0010
FR_PSR3_AACA_U16 = 0x0008
FR_PSR3_ACEA_U16 = 0x0004
FR_PSR3_ASEA_U16 = 0x0002
FR_PSR3_AVFA_U16 = 0x0001
FR_SSR_VFB = 0x8000
FR_SSR_SYB = 0x4000
FR_SSR_NFB = 0x2000
FR_SSR_SUB = 0x1000
FR_SSR_SEB = 0x0800
FR_SSR_CEB = 0x0400
FR_SSR_BVB = 0x0200
FR_SSR_TCB = 0x0100
FR_SSR_VFA = 0x0080
FR_SSR_SYA = 0x0040
FR_SSR_NFA = 0x0020
FR_SSR_SUA = 0x0010
FR_SSR_SEA = 0x0008
FR_SSR_CEA = 0x0004
FR_SSR_BVA = 0x0002
FR_SSR_TCA = 0x0001
| cd_cycle_max = 16000
c_cycle_count_max = 63
c_static_slot_id_max = 1023
c_slot_id_max = 2047
c_payload_length_max = 127
c_samples_per_bit = 8
c_sync_frame_id_count_max = 15
c_micro_per_macro_nom_min = 40
cd_min_mt_nom = 1
cd_max_mt_nom = 6
cd_fes = 2
cd_fss = 1
c_channel_idle_delimiter = 11
c_clock_deviation_max = 0.0015
c_strobe_offset = 5
c_voting_samples = 5
c_voting_delay = (cVotingSamples - 1) / 2
cd_bss = 2
cd_wakeup_symbol_tx_idle = 18
cd_wakeup_symbol_tx_low = 6
cd_cas = 30
c_micro_per_macro_min = 20
cd_max_offset_calculation = 1350
cd_max_rate_calculation = 1500
sizeof_uint16 = 2
sizeof_packet_header = SIZEOF_UINT16 * 2
packet_type_start_driver = 0
packet_type_flexray_frame = 1
packet_type_health = 2
packet_type_flexray_joined_cluster = 3
packet_type_flexray_join_cluster_failed = 4
packet_type_flexray_disconnected_from_cluster = 5
packet_type_flexray_fatal_error = 6
packet_type_monior_slots = 7
fr_pifr0_tbva_if_u16 = 8
fr_pifr0_tbvb_if_u16 = 16
fr_pifr0_ltxa_if_u16 = 32
fr_pifr0_ltxb_if_u16 = 64
fr_pier0_ccl_if_u16 = 512
fr_pifr0_moc_if_u16 = 1024
fr_pifr0_mrc_if_u16 = 2048
fr_pifr0_fatl_if_u16 = 32768
fr_pifr0_intl_if_u16 = 16384
fr_pifr0_ilcf_if_u16 = 8192
fr_pifr0_csa_if_u16 = 4096
fr_pier0_ti2_ie_u16 = 4
fr_pier0_ti1_ie_u16 = 2
fr_psr0_errmode_mask_u16 = 49152
fr_psr0_slotmode_mask_u16 = 12288
fr_psr0_protstate_mask_u16 = 1792
fr_psr0_startup_mask_u16 = 240
fr_psr0_wup_mask_u16 = 7
fr_psr0_slotmode_single_u16 = 0
fr_psr0_slotmode_all_pending_u16 = 4096
fr_psr0_slotmode_all_u16 = 8192
fr_psr0_errmode_active_u16 = 0
fr_psr0_errmode_passive_u16 = 16384
fr_psr0_errmode_comm_halt_u16 = 32768
fr_psr0_protstate_default_config_u16 = 0
fr_psr0_protstate_config_u16 = 256
fr_psr0_protstate_wakeup_u16 = 512
fr_psr0_protstate_ready_u16 = 768
fr_psr0_protstate_normal_passive_u16 = 1024
fr_psr0_protstate_normal_active_u16 = 1280
fr_psr0_protstate_halt_u16 = 1536
fr_psr0_protstate_startup_u16 = 1792
fr_psr0_startup_ccr_u16 = 32
fr_psr0_startup_cl_u16 = 48
fr_psr0_startup_icoc_u16 = 64
fr_psr0_startup_il_u16 = 80
fr_psr0_startup_is_u16 = 112
fr_psr0_startup_ccc_u16 = 160
fr_psr0_startup_iclc_u16 = 208
fr_psr0_startup_cg_u16 = 224
fr_psr0_startup_cj_u16 = 240
fr_psr1_cpn_u16 = 128
fr_psr1_hhr_u16 = 64
fr_psr1_frz_u16 = 32
fr_psr2_nbvb_mask_u16 = 32768
fr_psr2_nseb_mask_u16 = 16384
fr_psr2_stcb_mask_u16 = 8192
fr_psr2_sbvb_mask_u16 = 4096
fr_psr2_sseb_mask_u16 = 2048
fr_psr2_mtb_mask_u16 = 1024
fr_psr2_nbva_mask_u16 = 512
fr_psr2_nsea_mask_u16 = 256
fr_psr2_stca_mask_u16 = 128
fr_psr2_sbva_mask_u16 = 64
fr_psr2_ssea_mask_u16 = 32
fr_psr2_mta_mask_u16 = 16
fr_psr2_ckcorfcnt_mask_u16 = 15
fr_psr3_abvb_u16 = 4096
fr_psr3_aacb_u16 = 2048
fr_psr3_aceb_u16 = 1024
fr_psr3_aseb_u16 = 512
fr_psr3_avfb_u16 = 256
fr_psr3_abva_u16 = 16
fr_psr3_aaca_u16 = 8
fr_psr3_acea_u16 = 4
fr_psr3_asea_u16 = 2
fr_psr3_avfa_u16 = 1
fr_ssr_vfb = 32768
fr_ssr_syb = 16384
fr_ssr_nfb = 8192
fr_ssr_sub = 4096
fr_ssr_seb = 2048
fr_ssr_ceb = 1024
fr_ssr_bvb = 512
fr_ssr_tcb = 256
fr_ssr_vfa = 128
fr_ssr_sya = 64
fr_ssr_nfa = 32
fr_ssr_sua = 16
fr_ssr_sea = 8
fr_ssr_cea = 4
fr_ssr_bva = 2
fr_ssr_tca = 1 |
"""
1. 187_XXX -> Self define exception
"""
class NameIsError(Exception):
pass
class AgeIsError(Exception):
pass
class HahaIsError(Exception):
pass
def check_name(name):
if name.find("li") >= 0:
raise NameIsError("Collision with my king's ", name)
def check_age(age):
if age >= 50 or age <= 18:
raise NameIsError("Age is either too young or old.")
try:
name = "I am feng"
check_name(name)
age = 19
check_age(age)
print(a)
except NameIsError as e:
print(str(e))
except AgeIsError as e:
print(str(e))
except Exception as e:
print("---------")
print(str(e))
| """
1. 187_XXX -> Self define exception
"""
class Nameiserror(Exception):
pass
class Ageiserror(Exception):
pass
class Hahaiserror(Exception):
pass
def check_name(name):
if name.find('li') >= 0:
raise name_is_error("Collision with my king's ", name)
def check_age(age):
if age >= 50 or age <= 18:
raise name_is_error('Age is either too young or old.')
try:
name = 'I am feng'
check_name(name)
age = 19
check_age(age)
print(a)
except NameIsError as e:
print(str(e))
except AgeIsError as e:
print(str(e))
except Exception as e:
print('---------')
print(str(e)) |
class Triple:
def __init__(self, subject, predicate, object):
self.subject = subject
self.predicate = predicate
self.object = object
| class Triple:
def __init__(self, subject, predicate, object):
self.subject = subject
self.predicate = predicate
self.object = object |
def main():
return 0
if __name__ == "__main__":
for case in range(1, int(input()) + 1):
print(f"Case #{case}:", main())
| def main():
return 0
if __name__ == '__main__':
for case in range(1, int(input()) + 1):
print(f'Case #{case}:', main()) |
file = open('input.txt', 'r')
Lines = file.readlines()
count = 0
# Strips the newline character
for line in Lines:
line_parts = line.strip().split(' ')
rule_part = line_parts[0].split('-')
min_rule = int(rule_part[0])
max_rule = int(rule_part[1])
password = line_parts[2]
char = line_parts[1][0]
char_count = password.count(char)
if max_rule >= char_count >= min_rule:
count += 1
print(count)
| file = open('input.txt', 'r')
lines = file.readlines()
count = 0
for line in Lines:
line_parts = line.strip().split(' ')
rule_part = line_parts[0].split('-')
min_rule = int(rule_part[0])
max_rule = int(rule_part[1])
password = line_parts[2]
char = line_parts[1][0]
char_count = password.count(char)
if max_rule >= char_count >= min_rule:
count += 1
print(count) |
# Roman numeral/Decimal converter
# Roman to decimal conversion table
RomanValue = { 'I' : 1, 'V' : 5, 'X' : 10, 'L' : 50, 'C' : 100, 'D' : 500, 'M' : 1000 }
def RomanValueList (RomanNumber):
number = []
for i in RomanNumber:
number.append(RomanValue[i])
return number
# Convert Roman number string to list of decimal conversion values
def ToDecimal (number): # Expects a list from RomanValueList()
answer = number[-1] # Start with the rightmost digit
for i in range(len(number)-1,0,-1): # Digits offered in reverse
right = i
left = i-1
if left < 0: # Don't overrun the beginning of the list
break # This should never happen anyway.
else:
# Process every pair of roman digits with a simple rule.
if number[left] < number[right]:
answer -= number[left]
else:
answer += number[left]
return answer
# Decimal to Roman conversion table
ones = { 0: '', 1: 'I', 2: 'II', 3: 'III', 4: 'IV', 5: 'V', 6: 'VI', 7: 'VII', 8: 'VIII', 9: 'IX' }
tens = { 0: '', 1: 'X', 2: 'XX', 3: 'XXX', 4: 'XL', 5: 'L', 6: 'LX', 7: 'LXX', 8: 'LXXX', 9: 'XC' }
huns = { 0: '', 1: 'C', 2: 'CC', 3: 'CCC', 4: 'CD', 5: 'D', 6: 'DC', 7: 'DCC', 8: 'DCCC', 9: 'CM' }
thous = { 0: '', 1: 'M', 2: 'MM', 3: 'MMM' }
# Convert decimal int to Roman number string
def ToRoman (x): # Expects an int 1 to 3999
one = x//1 % 10 # separate the place values
ten = x//10 % 10
hun = x//100 % 10
thou = x//1000 % 10
return thous[thou] + huns[hun] + tens[ten] + ones[one]
# Main code starts here
# accepts improper Roman numbers such as IVMX.
# may give unexpected conversions for improper Roman numbers.
# IVMX converts to 1004. 1004 should be MIV in modern standard notation.
# Does not accept 0, or over large or fractional decimal numbers.
stop = False
while not stop:
baddata = False
while not baddata:
number = ''
while number == '':
number = input ("Enter number to convert: ")
number = number.upper()
# Anything other than decimal digits, decimal point, or Roman digits is rejected.
decimal = Roman = True
for i in number:
if i not in {'0','1','2','3','4','5','6','7','8','9'}:
decimal = False
if i not in {'I','V','X','L','C','D','M'}: # 2 Sets of acceptable chars.
Roman = False
if not decimal and not Roman: # Neither type entered.
if number == 'Q':
stop = True # Trying to end the prog here.
break # Breaks baddata loop.
else:
print ("Decimal (1 to 3999) or Roman numbers only, please.")
continue # Get another input. Continues baddata loop.
else: # Process the number input
if decimal:
if (int(number) < 1) or (int(number) > 3999):
print ("Decimal (1 to 3999) or Roman numbers only, please.")
continue
answer = ToRoman(int(number))
elif Roman:
answer = ToDecimal(RomanValueList (number))
print (number, " converts to ", answer)
# Main code stops here
| roman_value = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
def roman_value_list(RomanNumber):
number = []
for i in RomanNumber:
number.append(RomanValue[i])
return number
def to_decimal(number):
answer = number[-1]
for i in range(len(number) - 1, 0, -1):
right = i
left = i - 1
if left < 0:
break
elif number[left] < number[right]:
answer -= number[left]
else:
answer += number[left]
return answer
ones = {0: '', 1: 'I', 2: 'II', 3: 'III', 4: 'IV', 5: 'V', 6: 'VI', 7: 'VII', 8: 'VIII', 9: 'IX'}
tens = {0: '', 1: 'X', 2: 'XX', 3: 'XXX', 4: 'XL', 5: 'L', 6: 'LX', 7: 'LXX', 8: 'LXXX', 9: 'XC'}
huns = {0: '', 1: 'C', 2: 'CC', 3: 'CCC', 4: 'CD', 5: 'D', 6: 'DC', 7: 'DCC', 8: 'DCCC', 9: 'CM'}
thous = {0: '', 1: 'M', 2: 'MM', 3: 'MMM'}
def to_roman(x):
one = x // 1 % 10
ten = x // 10 % 10
hun = x // 100 % 10
thou = x // 1000 % 10
return thous[thou] + huns[hun] + tens[ten] + ones[one]
stop = False
while not stop:
baddata = False
while not baddata:
number = ''
while number == '':
number = input('Enter number to convert: ')
number = number.upper()
decimal = roman = True
for i in number:
if i not in {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}:
decimal = False
if i not in {'I', 'V', 'X', 'L', 'C', 'D', 'M'}:
roman = False
if not decimal and (not Roman):
if number == 'Q':
stop = True
break
else:
print('Decimal (1 to 3999) or Roman numbers only, please.')
continue
elif decimal:
if int(number) < 1 or int(number) > 3999:
print('Decimal (1 to 3999) or Roman numbers only, please.')
continue
answer = to_roman(int(number))
elif Roman:
answer = to_decimal(roman_value_list(number))
print(number, ' converts to ', answer) |
# Python Program To Handle Multiple Exceptions
def avg(list):
tot = 0
for x in list:
tot += x
avg = tot/len(list)
return tot, avg
# Call The avg() And Pass A List
try:
t, a = avg([1,2,3,4,5,'a']) # Here Give Empty List And try
print('Total = {}, Average = {}'.format(t, a))
except TypeError:
print('Type Error, Please Provide Numbers.')
except ZeroDivisionError:
print('ZeroDivisionError, Please Do Not Give Empty List. ')
| def avg(list):
tot = 0
for x in list:
tot += x
avg = tot / len(list)
return (tot, avg)
try:
(t, a) = avg([1, 2, 3, 4, 5, 'a'])
print('Total = {}, Average = {}'.format(t, a))
except TypeError:
print('Type Error, Please Provide Numbers.')
except ZeroDivisionError:
print('ZeroDivisionError, Please Do Not Give Empty List. ') |
# -*- coding: utf-8 -*-
#
# Copyright 2014-2022 BigML
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Options for BigMLer test files processing
"""
def get_test_options(defaults=None):
"""Test files-related options
"""
if defaults is None:
defaults = {}
options = {
# Path to the test set.
"--test": {
'action': 'store',
'dest': 'test_set',
'nargs': '?',
'default': defaults.get('test', None),
'help': "Test set path."},
# Name of the file to output predictions.
"--output": {
'action': 'store',
'dest': 'output',
'default': defaults.get('output', None),
'help': "Path to the file to output predictions."},
# Set when the test set file doesn't include a header on the first
# line.
'--no-test-header': {
'action': 'store_false',
'dest': 'test_header',
'default': defaults.get('test_header', True),
'help': "The test set file hasn't a header."},
# Test set field separator. Defaults to the locale csv
# separator.
'--test-separator': {
'action': 'store',
'dest': 'test_separator',
'default': defaults.get('test_separator', None),
'help': "Test set field separator."},
# The path to a file containing attributes if you want to alter BigML's
# default field attributes or the ones provided by the test file
# header.
'--test-field-attributes': {
'action': 'store',
'dest': 'test_field_attributes',
'default': defaults.get('test_field_attributes', None),
'help': ("Path to a csv file describing field attributes."
" One definition per line"
" (e.g., 0,'Last Name').")},
# The path to a file containing types if you want to alter BigML's
# type auto-detect.
'--test-types': {
'action': 'store',
'dest': 'test_types',
'default': defaults.get('test_types', None),
'help': ("Path to a file describing field types. One"
" definition per line (e.g., 0, 'numeric').")},
# If a BigML test source is provided, the script won't create a new one
'--test-source': {
'action': 'store',
'dest': 'test_source',
'default': defaults.get('test_source', None),
'help': "BigML test source Id."},
# If a BigML test dataset is provided, the script won't create a new
# one
'--test-dataset': {
'action': 'store',
'dest': 'test_dataset',
'default': defaults.get('test_dataset', None),
'help': "BigML test dataset Id."},
# The path to a file containing dataset ids.
'--test-datasets': {
'action': 'store',
'dest': 'test_datasets',
'default': defaults.get('test_datasets', None),
'help': ("Path to a file containing dataset/ids. Just"
" one dataset per line"
" (e.g., dataset/50a20697035d0706da0004a4).")},
# Set when the test set file does include a header on the first
# line. (opposed to --no-test-header)
'--test-header': {
'action': 'store_true',
'dest': 'test_header',
'default': defaults.get('test_header', True),
'help': "The test set file has a header."}}
return options
| """Options for BigMLer test files processing
"""
def get_test_options(defaults=None):
"""Test files-related options
"""
if defaults is None:
defaults = {}
options = {'--test': {'action': 'store', 'dest': 'test_set', 'nargs': '?', 'default': defaults.get('test', None), 'help': 'Test set path.'}, '--output': {'action': 'store', 'dest': 'output', 'default': defaults.get('output', None), 'help': 'Path to the file to output predictions.'}, '--no-test-header': {'action': 'store_false', 'dest': 'test_header', 'default': defaults.get('test_header', True), 'help': "The test set file hasn't a header."}, '--test-separator': {'action': 'store', 'dest': 'test_separator', 'default': defaults.get('test_separator', None), 'help': 'Test set field separator.'}, '--test-field-attributes': {'action': 'store', 'dest': 'test_field_attributes', 'default': defaults.get('test_field_attributes', None), 'help': "Path to a csv file describing field attributes. One definition per line (e.g., 0,'Last Name')."}, '--test-types': {'action': 'store', 'dest': 'test_types', 'default': defaults.get('test_types', None), 'help': "Path to a file describing field types. One definition per line (e.g., 0, 'numeric')."}, '--test-source': {'action': 'store', 'dest': 'test_source', 'default': defaults.get('test_source', None), 'help': 'BigML test source Id.'}, '--test-dataset': {'action': 'store', 'dest': 'test_dataset', 'default': defaults.get('test_dataset', None), 'help': 'BigML test dataset Id.'}, '--test-datasets': {'action': 'store', 'dest': 'test_datasets', 'default': defaults.get('test_datasets', None), 'help': 'Path to a file containing dataset/ids. Just one dataset per line (e.g., dataset/50a20697035d0706da0004a4).'}, '--test-header': {'action': 'store_true', 'dest': 'test_header', 'default': defaults.get('test_header', True), 'help': 'The test set file has a header.'}}
return options |
# coding: utf-8
#
# Copyright 2022 :Barry-Thomas-Paul: Moss
#
# Licensed under the Apache License, Version 2.0 (the "License")
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http: // www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Const Class
# this is a auto generated file generated by Cheetah
# Libre Office Version: 7.3
# Namespace: com.sun.star.util
class MeasureUnit(object):
"""
Const Class
These constants are used to specify a measure.
A component using these constants may not support all units.
See Also:
`API MeasureUnit <https://api.libreoffice.org/docs/idl/ref/namespacecom_1_1sun_1_1star_1_1util_1_1MeasureUnit.html>`_
"""
__ooo_ns__: str = 'com.sun.star.util'
__ooo_full_ns__: str = 'com.sun.star.util.MeasureUnit'
__ooo_type_name__: str = 'const'
MM_100TH = 0
"""
all measures for this component are in 100th millimeter
"""
MM_10TH = 1
"""
all measures for this component are in 10th millimeter
"""
MM = 2
"""
all measures for this component are in millimeter
"""
CM = 3
"""
all measures for this component are in centimeters
"""
INCH_1000TH = 4
"""
all measures for this component are in 1000th inch
"""
INCH_100TH = 5
"""
all measures for this component are in 100th inch
"""
INCH_10TH = 6
"""
all measures for this component are in 10th inch
"""
INCH = 7
"""
all measures for this component are in inch
"""
POINT = 8
"""
all measures for this component are in points
"""
TWIP = 9
"""
all measures for this component are in twips
"""
M = 10
"""
all measures for this component are in meters
"""
KM = 11
"""
all measures for this component are in kilometers
"""
PICA = 12
"""
all measures for this component are in pica
"""
FOOT = 13
"""
all measures for this component are in foot
"""
MILE = 14
"""
all measures for this component are in miles
"""
PERCENT = 15
"""
all measures for this component are in percentage
"""
PIXEL = 16
"""
all measures for this component are in pixel
"""
APPFONT = 17
"""
all measures for this component are in APPFONT
"""
SYSFONT = 18
"""
all measures for this component are in SYSFONT
"""
__all__ = ['MeasureUnit']
| class Measureunit(object):
"""
Const Class
These constants are used to specify a measure.
A component using these constants may not support all units.
See Also:
`API MeasureUnit <https://api.libreoffice.org/docs/idl/ref/namespacecom_1_1sun_1_1star_1_1util_1_1MeasureUnit.html>`_
"""
__ooo_ns__: str = 'com.sun.star.util'
__ooo_full_ns__: str = 'com.sun.star.util.MeasureUnit'
__ooo_type_name__: str = 'const'
mm_100_th = 0
'\n all measures for this component are in 100th millimeter\n '
mm_10_th = 1
'\n all measures for this component are in 10th millimeter\n '
mm = 2
'\n all measures for this component are in millimeter\n '
cm = 3
'\n all measures for this component are in centimeters\n '
inch_1000_th = 4
'\n all measures for this component are in 1000th inch\n '
inch_100_th = 5
'\n all measures for this component are in 100th inch\n '
inch_10_th = 6
'\n all measures for this component are in 10th inch\n '
inch = 7
'\n all measures for this component are in inch\n '
point = 8
'\n all measures for this component are in points\n '
twip = 9
'\n all measures for this component are in twips\n '
m = 10
'\n all measures for this component are in meters\n '
km = 11
'\n all measures for this component are in kilometers\n '
pica = 12
'\n all measures for this component are in pica\n '
foot = 13
'\n all measures for this component are in foot\n '
mile = 14
'\n all measures for this component are in miles\n '
percent = 15
'\n all measures for this component are in percentage\n '
pixel = 16
'\n all measures for this component are in pixel\n '
appfont = 17
'\n all measures for this component are in APPFONT\n '
sysfont = 18
'\n all measures for this component are in SYSFONT\n '
__all__ = ['MeasureUnit'] |
def dataset():
pass
def model():
pass
def loss():
pass
def opt():
pass | def dataset():
pass
def model():
pass
def loss():
pass
def opt():
pass |
class Response:
def __init__(self, message=None, data=None):
self.message = message
self.data = data
def build(self):
return {
"message": self.message,
"data": self.data
}
| class Response:
def __init__(self, message=None, data=None):
self.message = message
self.data = data
def build(self):
return {'message': self.message, 'data': self.data} |
def main():
double_letters = 0
triple_letters = 0
input_file = open('input', 'r')
for line in input_file:
double_letters_found = False
triple_letters_found = False
characters = set(line.replace('\n', ''))
for character in characters:
if not double_letters_found and (line.count(character) == 2):
double_letters += 1
double_letters_found = True
elif not triple_letters_found and (line.count(character) == 3):
triple_letters += 1
triple_letters_found = True
if double_letters_found and triple_letters_found:
break
checksum = double_letters * triple_letters
print(checksum)
if __name__ == "__main__":
main()
| def main():
double_letters = 0
triple_letters = 0
input_file = open('input', 'r')
for line in input_file:
double_letters_found = False
triple_letters_found = False
characters = set(line.replace('\n', ''))
for character in characters:
if not double_letters_found and line.count(character) == 2:
double_letters += 1
double_letters_found = True
elif not triple_letters_found and line.count(character) == 3:
triple_letters += 1
triple_letters_found = True
if double_letters_found and triple_letters_found:
break
checksum = double_letters * triple_letters
print(checksum)
if __name__ == '__main__':
main() |
coordinates_E0E1E1 = ((129, 120),
(129, 122), (129, 124), (130, 124), (131, 124), (132, 124), (133, 124), (134, 124), (135, 124), (136, 123), (136, 132), (137, 119), (137, 123), (138, 119), (138, 122), (139, 120), (139, 122), (140, 121), (140, 123), (141, 121), (141, 126), (142, 113), (142, 115), (142, 121), (142, 123), (143, 112), (143, 116), (143, 117), (143, 118), (143, 119), (143, 120), (143, 121), (143, 122), (143, 124), (144, 113), (144, 114), (144, 115), (144, 121), (144, 122), (144, 124), (145, 110), (145, 113), (145, 114), (145, 115), (145, 116), (145, 117), (145, 118), (145, 119), (145, 120), (145, 121), (145, 133), (146, 111), (146, 113), (146, 114), (146, 115), (146, 116), (146, 117), (146, 118), (146, 119), (146, 120), (146, 121), (146, 122), (146, 123), (146, 124), (146, 125), (146, 126), (146, 127), (146, 128), (146, 129), (146, 130), (146, 131), (146, 133), (147, 112),
(147, 114), (147, 115), (147, 116), (147, 117), (147, 118), (147, 120), (147, 127), (147, 131), (147, 132), (148, 113), (148, 115), (148, 116), (148, 117), (148, 118), (148, 119), (148, 121), (148, 127), (148, 129), (149, 114), (149, 117), (149, 118), (149, 119), (149, 120), (149, 122), (149, 128), (150, 115), (150, 116), (150, 119), (150, 120), (150, 121), (150, 124), (150, 125), (150, 127), (151, 117), (151, 122), (151, 126), (152, 120), (152, 123), (152, 125), (153, 125), (154, 123), (154, 125), (155, 124), (155, 125), )
coordinates_E1E1E1 = ((99, 118),
(100, 118), (101, 118), (101, 119), (102, 118), (102, 119), (102, 126), (102, 128), (102, 134), (103, 117), (103, 119), (103, 126), (103, 129), (103, 130), (103, 131), (103, 132), (103, 133), (103, 135), (104, 117), (104, 120), (104, 127), (104, 130), (104, 135), (105, 118), (105, 120), (105, 128), (105, 130), (105, 135), (106, 119), (106, 121), (106, 128), (106, 131), (106, 134), (107, 120), (107, 121), (107, 127), (107, 131), (108, 122), (108, 124), (108, 125), (108, 128), (108, 130), (109, 123), (109, 126), (110, 112), (110, 125), (111, 111), (111, 125), (112, 110), (113, 125), (113, 126), (114, 120), (114, 124), (114, 126), (115, 125), (115, 127), (116, 128), (117, 128), )
coordinates_016400 = ((126, 134),
(127, 134), (127, 136), (128, 134), (128, 137), (129, 134), (129, 137), (130, 134), (130, 136), (130, 138), (131, 133), (131, 134), (131, 136), (131, 138), (132, 133), (132, 135), (132, 136), (132, 138), (133, 134), (133, 136), (133, 137), (133, 139), (134, 134), (134, 136), (134, 137), (134, 138), (134, 141), (135, 134), (135, 136), (135, 137), (135, 138), (135, 140), (136, 135), (136, 137), (136, 138), (136, 140), (137, 140), (138, 132), (138, 134), (138, 135), (138, 136), (138, 137), (139, 133), (139, 139), (139, 140), (140, 131), (141, 130), (142, 128), (142, 129), )
coordinates_006400 = ((105, 133),
(109, 132), (110, 135), (110, 136), (110, 137), (110, 138), (110, 139), (110, 140), (110, 142), (111, 133), (111, 142), (112, 134), (112, 139), (112, 140), (112, 142), (113, 137), (113, 138), (113, 139), (113, 140), (113, 141), (113, 143), (114, 139), (114, 142), (115, 138), (115, 139), (116, 138), (116, 141), (117, 138), (117, 140), (118, 138), (118, 139), (119, 137), (119, 138), )
coordinates_6395ED = ((125, 131),
(126, 129), (126, 131), (127, 128), (127, 132), (128, 127), (128, 129), (128, 130), (128, 132), (129, 126), (129, 128), (129, 129), (129, 130), (129, 132), (130, 126), (130, 127), (130, 128), (130, 129), (130, 130), (130, 132), (131, 126), (131, 128), (131, 129), (131, 131), (132, 126), (132, 128), (132, 129), (132, 131), (133, 126), (133, 128), (133, 129), (133, 131), (134, 126), (134, 128), (134, 129), (134, 131), (135, 126), (135, 128), (135, 130), (136, 126), (136, 128), (136, 130), (137, 125), (137, 130), (138, 124), (138, 127), (138, 129), (139, 125), )
coordinates_00FFFE = ((140, 137),
(141, 137), (141, 139), (142, 137), (142, 141), (143, 138), (143, 142), (144, 138), (144, 140), (144, 142), (145, 138), (145, 140), (145, 142), (146, 138), (146, 142), (147, 139), )
coordinates_F98072 = ((124, 114),
(124, 116), (124, 117), (124, 118), (124, 119), (124, 120), (124, 121), (125, 113), (125, 122), (125, 123), (125, 124), (125, 125), (125, 127), (126, 112), (126, 114), (126, 115), (126, 116), (127, 112), (127, 114), (127, 115), (127, 118), (127, 119), (127, 120), (127, 121), (127, 122), (127, 123), (127, 125), (128, 112), (128, 114), (129, 111), (129, 113), (129, 115), (130, 111), (130, 114), (131, 111), (131, 113), (132, 112), (133, 104), (133, 106), (133, 107), (133, 108), (133, 109), (134, 106), (134, 108), (134, 109), )
coordinates_97FB98 = ((140, 135),
(141, 133), (141, 135), (142, 132), (142, 135), (143, 126), (143, 127), (143, 130), (143, 131), (143, 132), (143, 133), (143, 135), (144, 126), (144, 128), (144, 129), (144, 130), (144, 135), (145, 135), (145, 136), (146, 136), (147, 135), (147, 137), (148, 134), (148, 136), (148, 138), (149, 131), (149, 133), (149, 135), (149, 137), (149, 138), (150, 130), (150, 134), (150, 136), (151, 131), (151, 133), (151, 135), (152, 131), (152, 133), (152, 135), (153, 131), (153, 133), (153, 135), (154, 131), (154, 133), (154, 135), (154, 136), (155, 131), (155, 132), (155, 133), (155, 134), (155, 136), (156, 131), (156, 133), (156, 134), (156, 137), (157, 131), (157, 136), (158, 131), (158, 133), (158, 134), )
coordinates_6495ED = ((110, 128),
(110, 130), (111, 127), (111, 131), (112, 128), (112, 131), (113, 128), (113, 130), (114, 129), (114, 131), (114, 134), (115, 129), (115, 131), (115, 132), (115, 133), (115, 136), (116, 130), (116, 132), (116, 133), (116, 134), (116, 136), (117, 130), (117, 132), (117, 133), (117, 134), (117, 136), (118, 131), (118, 133), (118, 135), (119, 132), (119, 135), (120, 133), (120, 135), )
coordinates_FA8072 = ((111, 113),
(112, 113), (112, 115), (113, 111), (113, 117), (114, 109), (114, 113), (114, 114), (114, 115), (114, 118), (115, 108), (115, 111), (115, 112), (115, 113), (115, 114), (115, 115), (115, 116), (115, 118), (116, 107), (116, 109), (116, 110), (116, 111), (116, 112), (116, 113), (116, 114), (116, 115), (116, 116), (116, 117), (116, 118), (116, 119), (117, 106), (117, 113), (117, 114), (117, 115), (117, 116), (117, 117), (117, 118), (117, 121), (117, 122), (117, 123), (117, 125), (118, 106), (118, 108), (118, 109), (118, 110), (118, 111), (118, 112), (118, 115), (118, 116), (118, 117), (118, 118), (118, 119), (118, 126), (119, 113), (119, 114), (119, 119), (119, 120), (119, 121), (119, 122), (119, 123), (119, 124), (119, 125), (119, 129), (120, 116), (120, 117), (120, 118), (120, 123), (120, 124), (120, 125), (120, 126), (120, 130), (121, 119), (121, 120),
(121, 121), (121, 122), (121, 123), (121, 131), (122, 124), (122, 125), (122, 126), (122, 127), (122, 128), (122, 130), )
coordinates_98FB98 = ((88, 135),
(89, 134), (89, 136), (90, 133), (90, 136), (91, 132), (91, 134), (91, 135), (91, 137), (92, 131), (92, 133), (92, 134), (92, 135), (92, 136), (92, 141), (93, 131), (93, 133), (93, 134), (93, 135), (93, 136), (93, 137), (93, 139), (93, 140), (93, 142), (94, 130), (94, 132), (94, 133), (94, 134), (94, 135), (94, 136), (94, 137), (94, 138), (94, 143), (95, 130), (95, 132), (95, 133), (95, 136), (95, 137), (95, 138), (95, 139), (95, 140), (95, 141), (95, 143), (96, 131), (96, 133), (96, 134), (96, 135), (96, 136), (96, 137), (96, 138), (96, 139), (96, 140), (96, 141), (96, 143), (97, 131), (97, 133), (97, 136), (97, 138), (97, 139), (97, 140), (97, 141), (97, 143), (98, 132), (98, 133), (98, 136), (98, 138), (98, 139), (98, 140), (98, 141), (98, 143), (99, 132), (99, 135), (99, 136),
(99, 137), (99, 138), (99, 139), (99, 140), (99, 141), (99, 143), (100, 133), (100, 137), (100, 138), (100, 139), (100, 140), (100, 141), (100, 143), (101, 136), (101, 138), (101, 139), (101, 140), (101, 141), (101, 143), (102, 137), (102, 139), (102, 140), (102, 142), (103, 137), (103, 139), (103, 140), (103, 142), (104, 137), (104, 138), (104, 139), (104, 140), (104, 142), (105, 137), (105, 139), (105, 140), (105, 142), (106, 137), (106, 139), (106, 140), (106, 142), (107, 136), (107, 142), (108, 135), (108, 137), (108, 138), (108, 139), (108, 140), (108, 142), )
coordinates_FEC0CB = ((130, 117),
(130, 119), (131, 115), (131, 121), (132, 114), (132, 117), (132, 118), (132, 119), (132, 122), (133, 113), (133, 116), (133, 117), (133, 118), (133, 119), (133, 120), (133, 122), (134, 111), (134, 114), (134, 115), (134, 116), (134, 117), (134, 118), (134, 122), (135, 104), (135, 110), (135, 113), (135, 114), (135, 115), (135, 116), (135, 117), (135, 119), (135, 120), (136, 104), (136, 106), (136, 107), (136, 108), (136, 109), (136, 111), (136, 112), (136, 113), (136, 114), (136, 115), (136, 116), (136, 117), (137, 104), (137, 110), (137, 111), (137, 112), (137, 113), (137, 114), (137, 115), (137, 117), (138, 105), (138, 108), (138, 109), (138, 110), (138, 111), (138, 112), (138, 113), (138, 114), (138, 115), (138, 117), (139, 109), (139, 111), (139, 117), (140, 109), (140, 111), (140, 113), (140, 114), (140, 115), (140, 118), (141, 109), (141, 111),
(141, 117), (141, 119), (142, 109), (142, 111), (143, 109), (143, 110), (144, 109), (145, 108), (147, 109), (148, 109), (148, 110), (148, 125), (149, 111), (150, 110), (151, 111), (151, 114), (152, 113), (152, 115), (152, 128), (152, 129), (153, 115), (153, 117), (153, 118), (153, 129), (154, 118), (154, 120), (154, 127), (154, 129), (155, 120), (155, 121), (155, 127), (155, 129), (156, 121), (156, 122), (156, 126), (156, 127), (156, 129), (157, 122), (157, 124), (157, 125), (157, 127), (157, 129), (158, 123), (158, 126), (158, 129), (159, 124), (159, 127), (160, 126), )
coordinates_333287 = ((88, 125),
(88, 127), (89, 124), (89, 128), (90, 123), (90, 125), (90, 126), (90, 127), (90, 129), (91, 123), (91, 125), (91, 126), (91, 127), (91, 129), (92, 124), (92, 126), (92, 127), (92, 129), (93, 124), (93, 126), (93, 128), (94, 124), (94, 126), (94, 128), (95, 125), (95, 128), (96, 126), (96, 128), )
coordinates_FFC0CB = ((92, 115),
(92, 116), (92, 117), (92, 119), (93, 112), (93, 114), (93, 120), (94, 111), (94, 115), (94, 116), (94, 117), (94, 118), (94, 119), (94, 121), (95, 110), (95, 112), (95, 113), (95, 114), (95, 115), (95, 116), (95, 117), (95, 118), (95, 119), (95, 121), (96, 109), (96, 111), (96, 112), (96, 113), (96, 114), (96, 115), (96, 116), (96, 117), (96, 120), (97, 109), (97, 111), (97, 112), (97, 113), (97, 114), (97, 115), (97, 116), (97, 118), (97, 120), (97, 121), (97, 124), (98, 108), (98, 110), (98, 111), (98, 112), (98, 113), (98, 114), (98, 115), (98, 116), (98, 117), (98, 120), (98, 122), (98, 126), (98, 127), (98, 129), (99, 108), (99, 110), (99, 111), (99, 112), (99, 113), (99, 114), (99, 116), (99, 120), (99, 122), (99, 123), (99, 124), (99, 126), (99, 130), (100, 108), (100, 110),
(100, 111), (100, 112), (100, 113), (100, 114), (100, 116), (100, 121), (100, 124), (100, 127), (100, 129), (100, 131), (101, 108), (101, 110), (101, 111), (101, 112), (101, 113), (101, 114), (101, 116), (101, 121), (101, 123), (101, 130), (101, 132), (102, 108), (102, 111), (102, 112), (102, 113), (102, 115), (102, 121), (102, 123), (103, 109), (103, 110), (103, 112), (103, 113), (103, 115), (103, 122), (103, 124), (104, 110), (104, 112), (104, 113), (104, 115), (104, 122), (104, 125), (105, 110), (105, 112), (105, 113), (105, 114), (105, 116), (105, 122), (105, 125), (106, 110), (106, 112), (106, 113), (106, 114), (106, 116), (106, 123), (106, 125), (107, 108), (107, 110), (107, 114), (107, 115), (107, 117), (108, 106), (108, 112), (108, 115), (108, 116), (108, 119), (109, 108), (109, 110), (109, 114), (109, 117), (109, 120), (110, 106), (110, 109),
(110, 115), (110, 119), (110, 122), (111, 106), (111, 108), (111, 117), (111, 123), (112, 107), (112, 108), (112, 119), (112, 123), (113, 107), (113, 121), (113, 122), (115, 105), )
| coordinates_e0_e1_e1 = ((129, 120), (129, 122), (129, 124), (130, 124), (131, 124), (132, 124), (133, 124), (134, 124), (135, 124), (136, 123), (136, 132), (137, 119), (137, 123), (138, 119), (138, 122), (139, 120), (139, 122), (140, 121), (140, 123), (141, 121), (141, 126), (142, 113), (142, 115), (142, 121), (142, 123), (143, 112), (143, 116), (143, 117), (143, 118), (143, 119), (143, 120), (143, 121), (143, 122), (143, 124), (144, 113), (144, 114), (144, 115), (144, 121), (144, 122), (144, 124), (145, 110), (145, 113), (145, 114), (145, 115), (145, 116), (145, 117), (145, 118), (145, 119), (145, 120), (145, 121), (145, 133), (146, 111), (146, 113), (146, 114), (146, 115), (146, 116), (146, 117), (146, 118), (146, 119), (146, 120), (146, 121), (146, 122), (146, 123), (146, 124), (146, 125), (146, 126), (146, 127), (146, 128), (146, 129), (146, 130), (146, 131), (146, 133), (147, 112), (147, 114), (147, 115), (147, 116), (147, 117), (147, 118), (147, 120), (147, 127), (147, 131), (147, 132), (148, 113), (148, 115), (148, 116), (148, 117), (148, 118), (148, 119), (148, 121), (148, 127), (148, 129), (149, 114), (149, 117), (149, 118), (149, 119), (149, 120), (149, 122), (149, 128), (150, 115), (150, 116), (150, 119), (150, 120), (150, 121), (150, 124), (150, 125), (150, 127), (151, 117), (151, 122), (151, 126), (152, 120), (152, 123), (152, 125), (153, 125), (154, 123), (154, 125), (155, 124), (155, 125))
coordinates_e1_e1_e1 = ((99, 118), (100, 118), (101, 118), (101, 119), (102, 118), (102, 119), (102, 126), (102, 128), (102, 134), (103, 117), (103, 119), (103, 126), (103, 129), (103, 130), (103, 131), (103, 132), (103, 133), (103, 135), (104, 117), (104, 120), (104, 127), (104, 130), (104, 135), (105, 118), (105, 120), (105, 128), (105, 130), (105, 135), (106, 119), (106, 121), (106, 128), (106, 131), (106, 134), (107, 120), (107, 121), (107, 127), (107, 131), (108, 122), (108, 124), (108, 125), (108, 128), (108, 130), (109, 123), (109, 126), (110, 112), (110, 125), (111, 111), (111, 125), (112, 110), (113, 125), (113, 126), (114, 120), (114, 124), (114, 126), (115, 125), (115, 127), (116, 128), (117, 128))
coordinates_016400 = ((126, 134), (127, 134), (127, 136), (128, 134), (128, 137), (129, 134), (129, 137), (130, 134), (130, 136), (130, 138), (131, 133), (131, 134), (131, 136), (131, 138), (132, 133), (132, 135), (132, 136), (132, 138), (133, 134), (133, 136), (133, 137), (133, 139), (134, 134), (134, 136), (134, 137), (134, 138), (134, 141), (135, 134), (135, 136), (135, 137), (135, 138), (135, 140), (136, 135), (136, 137), (136, 138), (136, 140), (137, 140), (138, 132), (138, 134), (138, 135), (138, 136), (138, 137), (139, 133), (139, 139), (139, 140), (140, 131), (141, 130), (142, 128), (142, 129))
coordinates_006400 = ((105, 133), (109, 132), (110, 135), (110, 136), (110, 137), (110, 138), (110, 139), (110, 140), (110, 142), (111, 133), (111, 142), (112, 134), (112, 139), (112, 140), (112, 142), (113, 137), (113, 138), (113, 139), (113, 140), (113, 141), (113, 143), (114, 139), (114, 142), (115, 138), (115, 139), (116, 138), (116, 141), (117, 138), (117, 140), (118, 138), (118, 139), (119, 137), (119, 138))
coordinates_6395_ed = ((125, 131), (126, 129), (126, 131), (127, 128), (127, 132), (128, 127), (128, 129), (128, 130), (128, 132), (129, 126), (129, 128), (129, 129), (129, 130), (129, 132), (130, 126), (130, 127), (130, 128), (130, 129), (130, 130), (130, 132), (131, 126), (131, 128), (131, 129), (131, 131), (132, 126), (132, 128), (132, 129), (132, 131), (133, 126), (133, 128), (133, 129), (133, 131), (134, 126), (134, 128), (134, 129), (134, 131), (135, 126), (135, 128), (135, 130), (136, 126), (136, 128), (136, 130), (137, 125), (137, 130), (138, 124), (138, 127), (138, 129), (139, 125))
coordinates_00_fffe = ((140, 137), (141, 137), (141, 139), (142, 137), (142, 141), (143, 138), (143, 142), (144, 138), (144, 140), (144, 142), (145, 138), (145, 140), (145, 142), (146, 138), (146, 142), (147, 139))
coordinates_f98072 = ((124, 114), (124, 116), (124, 117), (124, 118), (124, 119), (124, 120), (124, 121), (125, 113), (125, 122), (125, 123), (125, 124), (125, 125), (125, 127), (126, 112), (126, 114), (126, 115), (126, 116), (127, 112), (127, 114), (127, 115), (127, 118), (127, 119), (127, 120), (127, 121), (127, 122), (127, 123), (127, 125), (128, 112), (128, 114), (129, 111), (129, 113), (129, 115), (130, 111), (130, 114), (131, 111), (131, 113), (132, 112), (133, 104), (133, 106), (133, 107), (133, 108), (133, 109), (134, 106), (134, 108), (134, 109))
coordinates_97_fb98 = ((140, 135), (141, 133), (141, 135), (142, 132), (142, 135), (143, 126), (143, 127), (143, 130), (143, 131), (143, 132), (143, 133), (143, 135), (144, 126), (144, 128), (144, 129), (144, 130), (144, 135), (145, 135), (145, 136), (146, 136), (147, 135), (147, 137), (148, 134), (148, 136), (148, 138), (149, 131), (149, 133), (149, 135), (149, 137), (149, 138), (150, 130), (150, 134), (150, 136), (151, 131), (151, 133), (151, 135), (152, 131), (152, 133), (152, 135), (153, 131), (153, 133), (153, 135), (154, 131), (154, 133), (154, 135), (154, 136), (155, 131), (155, 132), (155, 133), (155, 134), (155, 136), (156, 131), (156, 133), (156, 134), (156, 137), (157, 131), (157, 136), (158, 131), (158, 133), (158, 134))
coordinates_6495_ed = ((110, 128), (110, 130), (111, 127), (111, 131), (112, 128), (112, 131), (113, 128), (113, 130), (114, 129), (114, 131), (114, 134), (115, 129), (115, 131), (115, 132), (115, 133), (115, 136), (116, 130), (116, 132), (116, 133), (116, 134), (116, 136), (117, 130), (117, 132), (117, 133), (117, 134), (117, 136), (118, 131), (118, 133), (118, 135), (119, 132), (119, 135), (120, 133), (120, 135))
coordinates_fa8072 = ((111, 113), (112, 113), (112, 115), (113, 111), (113, 117), (114, 109), (114, 113), (114, 114), (114, 115), (114, 118), (115, 108), (115, 111), (115, 112), (115, 113), (115, 114), (115, 115), (115, 116), (115, 118), (116, 107), (116, 109), (116, 110), (116, 111), (116, 112), (116, 113), (116, 114), (116, 115), (116, 116), (116, 117), (116, 118), (116, 119), (117, 106), (117, 113), (117, 114), (117, 115), (117, 116), (117, 117), (117, 118), (117, 121), (117, 122), (117, 123), (117, 125), (118, 106), (118, 108), (118, 109), (118, 110), (118, 111), (118, 112), (118, 115), (118, 116), (118, 117), (118, 118), (118, 119), (118, 126), (119, 113), (119, 114), (119, 119), (119, 120), (119, 121), (119, 122), (119, 123), (119, 124), (119, 125), (119, 129), (120, 116), (120, 117), (120, 118), (120, 123), (120, 124), (120, 125), (120, 126), (120, 130), (121, 119), (121, 120), (121, 121), (121, 122), (121, 123), (121, 131), (122, 124), (122, 125), (122, 126), (122, 127), (122, 128), (122, 130))
coordinates_98_fb98 = ((88, 135), (89, 134), (89, 136), (90, 133), (90, 136), (91, 132), (91, 134), (91, 135), (91, 137), (92, 131), (92, 133), (92, 134), (92, 135), (92, 136), (92, 141), (93, 131), (93, 133), (93, 134), (93, 135), (93, 136), (93, 137), (93, 139), (93, 140), (93, 142), (94, 130), (94, 132), (94, 133), (94, 134), (94, 135), (94, 136), (94, 137), (94, 138), (94, 143), (95, 130), (95, 132), (95, 133), (95, 136), (95, 137), (95, 138), (95, 139), (95, 140), (95, 141), (95, 143), (96, 131), (96, 133), (96, 134), (96, 135), (96, 136), (96, 137), (96, 138), (96, 139), (96, 140), (96, 141), (96, 143), (97, 131), (97, 133), (97, 136), (97, 138), (97, 139), (97, 140), (97, 141), (97, 143), (98, 132), (98, 133), (98, 136), (98, 138), (98, 139), (98, 140), (98, 141), (98, 143), (99, 132), (99, 135), (99, 136), (99, 137), (99, 138), (99, 139), (99, 140), (99, 141), (99, 143), (100, 133), (100, 137), (100, 138), (100, 139), (100, 140), (100, 141), (100, 143), (101, 136), (101, 138), (101, 139), (101, 140), (101, 141), (101, 143), (102, 137), (102, 139), (102, 140), (102, 142), (103, 137), (103, 139), (103, 140), (103, 142), (104, 137), (104, 138), (104, 139), (104, 140), (104, 142), (105, 137), (105, 139), (105, 140), (105, 142), (106, 137), (106, 139), (106, 140), (106, 142), (107, 136), (107, 142), (108, 135), (108, 137), (108, 138), (108, 139), (108, 140), (108, 142))
coordinates_fec0_cb = ((130, 117), (130, 119), (131, 115), (131, 121), (132, 114), (132, 117), (132, 118), (132, 119), (132, 122), (133, 113), (133, 116), (133, 117), (133, 118), (133, 119), (133, 120), (133, 122), (134, 111), (134, 114), (134, 115), (134, 116), (134, 117), (134, 118), (134, 122), (135, 104), (135, 110), (135, 113), (135, 114), (135, 115), (135, 116), (135, 117), (135, 119), (135, 120), (136, 104), (136, 106), (136, 107), (136, 108), (136, 109), (136, 111), (136, 112), (136, 113), (136, 114), (136, 115), (136, 116), (136, 117), (137, 104), (137, 110), (137, 111), (137, 112), (137, 113), (137, 114), (137, 115), (137, 117), (138, 105), (138, 108), (138, 109), (138, 110), (138, 111), (138, 112), (138, 113), (138, 114), (138, 115), (138, 117), (139, 109), (139, 111), (139, 117), (140, 109), (140, 111), (140, 113), (140, 114), (140, 115), (140, 118), (141, 109), (141, 111), (141, 117), (141, 119), (142, 109), (142, 111), (143, 109), (143, 110), (144, 109), (145, 108), (147, 109), (148, 109), (148, 110), (148, 125), (149, 111), (150, 110), (151, 111), (151, 114), (152, 113), (152, 115), (152, 128), (152, 129), (153, 115), (153, 117), (153, 118), (153, 129), (154, 118), (154, 120), (154, 127), (154, 129), (155, 120), (155, 121), (155, 127), (155, 129), (156, 121), (156, 122), (156, 126), (156, 127), (156, 129), (157, 122), (157, 124), (157, 125), (157, 127), (157, 129), (158, 123), (158, 126), (158, 129), (159, 124), (159, 127), (160, 126))
coordinates_333287 = ((88, 125), (88, 127), (89, 124), (89, 128), (90, 123), (90, 125), (90, 126), (90, 127), (90, 129), (91, 123), (91, 125), (91, 126), (91, 127), (91, 129), (92, 124), (92, 126), (92, 127), (92, 129), (93, 124), (93, 126), (93, 128), (94, 124), (94, 126), (94, 128), (95, 125), (95, 128), (96, 126), (96, 128))
coordinates_ffc0_cb = ((92, 115), (92, 116), (92, 117), (92, 119), (93, 112), (93, 114), (93, 120), (94, 111), (94, 115), (94, 116), (94, 117), (94, 118), (94, 119), (94, 121), (95, 110), (95, 112), (95, 113), (95, 114), (95, 115), (95, 116), (95, 117), (95, 118), (95, 119), (95, 121), (96, 109), (96, 111), (96, 112), (96, 113), (96, 114), (96, 115), (96, 116), (96, 117), (96, 120), (97, 109), (97, 111), (97, 112), (97, 113), (97, 114), (97, 115), (97, 116), (97, 118), (97, 120), (97, 121), (97, 124), (98, 108), (98, 110), (98, 111), (98, 112), (98, 113), (98, 114), (98, 115), (98, 116), (98, 117), (98, 120), (98, 122), (98, 126), (98, 127), (98, 129), (99, 108), (99, 110), (99, 111), (99, 112), (99, 113), (99, 114), (99, 116), (99, 120), (99, 122), (99, 123), (99, 124), (99, 126), (99, 130), (100, 108), (100, 110), (100, 111), (100, 112), (100, 113), (100, 114), (100, 116), (100, 121), (100, 124), (100, 127), (100, 129), (100, 131), (101, 108), (101, 110), (101, 111), (101, 112), (101, 113), (101, 114), (101, 116), (101, 121), (101, 123), (101, 130), (101, 132), (102, 108), (102, 111), (102, 112), (102, 113), (102, 115), (102, 121), (102, 123), (103, 109), (103, 110), (103, 112), (103, 113), (103, 115), (103, 122), (103, 124), (104, 110), (104, 112), (104, 113), (104, 115), (104, 122), (104, 125), (105, 110), (105, 112), (105, 113), (105, 114), (105, 116), (105, 122), (105, 125), (106, 110), (106, 112), (106, 113), (106, 114), (106, 116), (106, 123), (106, 125), (107, 108), (107, 110), (107, 114), (107, 115), (107, 117), (108, 106), (108, 112), (108, 115), (108, 116), (108, 119), (109, 108), (109, 110), (109, 114), (109, 117), (109, 120), (110, 106), (110, 109), (110, 115), (110, 119), (110, 122), (111, 106), (111, 108), (111, 117), (111, 123), (112, 107), (112, 108), (112, 119), (112, 123), (113, 107), (113, 121), (113, 122), (115, 105)) |
num = int(input('digite um numero pra daber sua tabuada: '))
for rep in range(0, 11):
print('{} x {:2} = {}'.format(rep, num, num*rep))
| num = int(input('digite um numero pra daber sua tabuada: '))
for rep in range(0, 11):
print('{} x {:2} = {}'.format(rep, num, num * rep)) |
class Solution:
def bstFromPreorder(self, preorder: List[int]) -> TreeNode:
if len(preorder)==0:
return None
tn=TreeNode(preorder[0])
l=[]
r=[]
for i in preorder:
if i<preorder[0]:
l.append(i)
elif i>preorder[0]:
r.append(i)
tn.left=self.bstFromPreorder(l)
tn.right=self.bstFromPreorder(r)
return tn
| class Solution:
def bst_from_preorder(self, preorder: List[int]) -> TreeNode:
if len(preorder) == 0:
return None
tn = tree_node(preorder[0])
l = []
r = []
for i in preorder:
if i < preorder[0]:
l.append(i)
elif i > preorder[0]:
r.append(i)
tn.left = self.bstFromPreorder(l)
tn.right = self.bstFromPreorder(r)
return tn |
n = int(input('digite um numero de 1 a 9999: '))
u = n % 10
d = n // 10 % 10
c = n // 100 % 10
m = n // 1000 % 10
print('A unidade', u)
print('A dezena', d)
print('A centena', c)
print('A milhar', m)
| n = int(input('digite um numero de 1 a 9999: '))
u = n % 10
d = n // 10 % 10
c = n // 100 % 10
m = n // 1000 % 10
print('A unidade', u)
print('A dezena', d)
print('A centena', c)
print('A milhar', m) |
def stair(n):
if n == 0 or n == 1:
return 1
elif n == 2:
return 2
elif n == 3:
return 4
else:
return stair(n-3) + stair(n-2) + stair(n-1)
n = int(input())
print(stair(n))
| def stair(n):
if n == 0 or n == 1:
return 1
elif n == 2:
return 2
elif n == 3:
return 4
else:
return stair(n - 3) + stair(n - 2) + stair(n - 1)
n = int(input())
print(stair(n)) |
#
# PySNMP MIB module CADANT-CMTS-EXPORTIMPORT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CADANT-CMTS-EXPORTIMPORT-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:27:10 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ValueRangeConstraint, SingleValueConstraint, ValueSizeConstraint, ConstraintsIntersection, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "SingleValueConstraint", "ValueSizeConstraint", "ConstraintsIntersection", "ConstraintsUnion")
trapSeverity, trapCounter = mibBuilder.importSymbols("CADANT-CMTS-EQUIPMENT-MIB", "trapSeverity", "trapCounter")
cadExperimental, = mibBuilder.importSymbols("CADANT-PRODUCTS-MIB", "cadExperimental")
InterfaceIndexOrZero, = mibBuilder.importSymbols("IF-MIB", "InterfaceIndexOrZero")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
Integer32, Unsigned32, MibScalar, MibTable, MibTableRow, MibTableColumn, ModuleIdentity, Counter64, iso, TimeTicks, Gauge32, ObjectIdentity, IpAddress, Bits, MibIdentifier, Counter32, NotificationType = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "Unsigned32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ModuleIdentity", "Counter64", "iso", "TimeTicks", "Gauge32", "ObjectIdentity", "IpAddress", "Bits", "MibIdentifier", "Counter32", "NotificationType")
TextualConvention, DisplayString, TruthValue = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString", "TruthValue")
cadExportImportMib = ModuleIdentity((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1))
cadExportImportMib.setRevisions(('2001-03-09 00:00', '2004-02-13 00:00', '2004-02-16 00:00',))
if mibBuilder.loadTexts: cadExportImportMib.setLastUpdated('200402160000Z')
if mibBuilder.loadTexts: cadExportImportMib.setOrganization('Arris International Inc.')
class ExportImportAction(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4))
namedValues = NamedValues(("noop", 0), ("export", 1), ("import", 2), ("pCmCertExport", 3), ("caCertExport", 4))
class ExportResult(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4, 5))
namedValues = NamedValues(("unknown", 0), ("success", 1), ("fileNameTooLong", 2), ("invalidCharactersInFilename", 3), ("fileSystemFull", 4), ("otherError", 5))
class ImportResult(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4))
namedValues = NamedValues(("unknown", 0), ("success", 1), ("fileNotFound", 2), ("fileDecodingError", 3), ("otherError", 4))
cadCmtsExportImportGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1))
cadCmtsExportImportFilename = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 1), DisplayString().clone('update:/export.txt')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cadCmtsExportImportFilename.setStatus('current')
cadCmtsExportImportAction = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 2), ExportImportAction().clone('noop')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cadCmtsExportImportAction.setStatus('current')
cadCmtsExportResult = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 3), ExportResult().clone('unknown')).setMaxAccess("readonly")
if mibBuilder.loadTexts: cadCmtsExportResult.setStatus('current')
cadCmtsImportResult = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 4), ImportResult().clone('unknown')).setMaxAccess("readonly")
if mibBuilder.loadTexts: cadCmtsImportResult.setStatus('current')
cadCmtsExportImportWithLineNums = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 5), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cadCmtsExportImportWithLineNums.setStatus('current')
cadCmtsExportImportWithDefaults = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 6), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cadCmtsExportImportWithDefaults.setStatus('current')
cadCmtsExportImportNested = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 7), TruthValue().clone('true')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cadCmtsExportImportNested.setStatus('current')
cadCmtsExportImportWithCertificates = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 8), TruthValue().clone('true')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cadCmtsExportImportWithCertificates.setStatus('current')
cadCmtsExportImportIfIndex = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 9), InterfaceIndexOrZero()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cadCmtsExportImportIfIndex.setStatus('current')
cadCmtsExportImportTraps = MibIdentifier((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 0))
cadCmtsExportNotification = NotificationType((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 0, 1)).setObjects(("CADANT-CMTS-EQUIPMENT-MIB", "trapCounter"), ("CADANT-CMTS-EQUIPMENT-MIB", "trapSeverity"), ("CADANT-CMTS-EXPORTIMPORT-MIB", "cadCmtsExportResult"))
if mibBuilder.loadTexts: cadCmtsExportNotification.setStatus('current')
cadCmtsImportNotification = NotificationType((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 0, 2)).setObjects(("CADANT-CMTS-EQUIPMENT-MIB", "trapCounter"), ("CADANT-CMTS-EQUIPMENT-MIB", "trapSeverity"), ("CADANT-CMTS-EXPORTIMPORT-MIB", "cadCmtsImportResult"))
if mibBuilder.loadTexts: cadCmtsImportNotification.setStatus('current')
mibBuilder.exportSymbols("CADANT-CMTS-EXPORTIMPORT-MIB", cadCmtsExportImportNested=cadCmtsExportImportNested, cadCmtsExportImportWithDefaults=cadCmtsExportImportWithDefaults, ImportResult=ImportResult, cadCmtsExportImportWithCertificates=cadCmtsExportImportWithCertificates, ExportResult=ExportResult, cadCmtsImportNotification=cadCmtsImportNotification, cadExportImportMib=cadExportImportMib, cadCmtsExportImportIfIndex=cadCmtsExportImportIfIndex, PYSNMP_MODULE_ID=cadExportImportMib, cadCmtsExportImportTraps=cadCmtsExportImportTraps, cadCmtsExportNotification=cadCmtsExportNotification, cadCmtsExportImportFilename=cadCmtsExportImportFilename, cadCmtsExportResult=cadCmtsExportResult, cadCmtsExportImportAction=cadCmtsExportImportAction, cadCmtsImportResult=cadCmtsImportResult, ExportImportAction=ExportImportAction, cadCmtsExportImportGroup=cadCmtsExportImportGroup, cadCmtsExportImportWithLineNums=cadCmtsExportImportWithLineNums)
| (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, single_value_constraint, value_size_constraint, constraints_intersection, constraints_union) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueRangeConstraint', 'SingleValueConstraint', 'ValueSizeConstraint', 'ConstraintsIntersection', 'ConstraintsUnion')
(trap_severity, trap_counter) = mibBuilder.importSymbols('CADANT-CMTS-EQUIPMENT-MIB', 'trapSeverity', 'trapCounter')
(cad_experimental,) = mibBuilder.importSymbols('CADANT-PRODUCTS-MIB', 'cadExperimental')
(interface_index_or_zero,) = mibBuilder.importSymbols('IF-MIB', 'InterfaceIndexOrZero')
(notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance')
(integer32, unsigned32, mib_scalar, mib_table, mib_table_row, mib_table_column, module_identity, counter64, iso, time_ticks, gauge32, object_identity, ip_address, bits, mib_identifier, counter32, notification_type) = mibBuilder.importSymbols('SNMPv2-SMI', 'Integer32', 'Unsigned32', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'ModuleIdentity', 'Counter64', 'iso', 'TimeTicks', 'Gauge32', 'ObjectIdentity', 'IpAddress', 'Bits', 'MibIdentifier', 'Counter32', 'NotificationType')
(textual_convention, display_string, truth_value) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString', 'TruthValue')
cad_export_import_mib = module_identity((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1))
cadExportImportMib.setRevisions(('2001-03-09 00:00', '2004-02-13 00:00', '2004-02-16 00:00'))
if mibBuilder.loadTexts:
cadExportImportMib.setLastUpdated('200402160000Z')
if mibBuilder.loadTexts:
cadExportImportMib.setOrganization('Arris International Inc.')
class Exportimportaction(TextualConvention, Integer32):
status = 'current'
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(0, 1, 2, 3, 4))
named_values = named_values(('noop', 0), ('export', 1), ('import', 2), ('pCmCertExport', 3), ('caCertExport', 4))
class Exportresult(TextualConvention, Integer32):
status = 'current'
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(0, 1, 2, 3, 4, 5))
named_values = named_values(('unknown', 0), ('success', 1), ('fileNameTooLong', 2), ('invalidCharactersInFilename', 3), ('fileSystemFull', 4), ('otherError', 5))
class Importresult(TextualConvention, Integer32):
status = 'current'
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(0, 1, 2, 3, 4))
named_values = named_values(('unknown', 0), ('success', 1), ('fileNotFound', 2), ('fileDecodingError', 3), ('otherError', 4))
cad_cmts_export_import_group = mib_identifier((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1))
cad_cmts_export_import_filename = mib_scalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 1), display_string().clone('update:/export.txt')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
cadCmtsExportImportFilename.setStatus('current')
cad_cmts_export_import_action = mib_scalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 2), export_import_action().clone('noop')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
cadCmtsExportImportAction.setStatus('current')
cad_cmts_export_result = mib_scalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 3), export_result().clone('unknown')).setMaxAccess('readonly')
if mibBuilder.loadTexts:
cadCmtsExportResult.setStatus('current')
cad_cmts_import_result = mib_scalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 4), import_result().clone('unknown')).setMaxAccess('readonly')
if mibBuilder.loadTexts:
cadCmtsImportResult.setStatus('current')
cad_cmts_export_import_with_line_nums = mib_scalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 5), truth_value().clone('false')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
cadCmtsExportImportWithLineNums.setStatus('current')
cad_cmts_export_import_with_defaults = mib_scalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 6), truth_value().clone('false')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
cadCmtsExportImportWithDefaults.setStatus('current')
cad_cmts_export_import_nested = mib_scalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 7), truth_value().clone('true')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
cadCmtsExportImportNested.setStatus('current')
cad_cmts_export_import_with_certificates = mib_scalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 8), truth_value().clone('true')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
cadCmtsExportImportWithCertificates.setStatus('current')
cad_cmts_export_import_if_index = mib_scalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 9), interface_index_or_zero()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
cadCmtsExportImportIfIndex.setStatus('current')
cad_cmts_export_import_traps = mib_identifier((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 0))
cad_cmts_export_notification = notification_type((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 0, 1)).setObjects(('CADANT-CMTS-EQUIPMENT-MIB', 'trapCounter'), ('CADANT-CMTS-EQUIPMENT-MIB', 'trapSeverity'), ('CADANT-CMTS-EXPORTIMPORT-MIB', 'cadCmtsExportResult'))
if mibBuilder.loadTexts:
cadCmtsExportNotification.setStatus('current')
cad_cmts_import_notification = notification_type((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 0, 2)).setObjects(('CADANT-CMTS-EQUIPMENT-MIB', 'trapCounter'), ('CADANT-CMTS-EQUIPMENT-MIB', 'trapSeverity'), ('CADANT-CMTS-EXPORTIMPORT-MIB', 'cadCmtsImportResult'))
if mibBuilder.loadTexts:
cadCmtsImportNotification.setStatus('current')
mibBuilder.exportSymbols('CADANT-CMTS-EXPORTIMPORT-MIB', cadCmtsExportImportNested=cadCmtsExportImportNested, cadCmtsExportImportWithDefaults=cadCmtsExportImportWithDefaults, ImportResult=ImportResult, cadCmtsExportImportWithCertificates=cadCmtsExportImportWithCertificates, ExportResult=ExportResult, cadCmtsImportNotification=cadCmtsImportNotification, cadExportImportMib=cadExportImportMib, cadCmtsExportImportIfIndex=cadCmtsExportImportIfIndex, PYSNMP_MODULE_ID=cadExportImportMib, cadCmtsExportImportTraps=cadCmtsExportImportTraps, cadCmtsExportNotification=cadCmtsExportNotification, cadCmtsExportImportFilename=cadCmtsExportImportFilename, cadCmtsExportResult=cadCmtsExportResult, cadCmtsExportImportAction=cadCmtsExportImportAction, cadCmtsImportResult=cadCmtsImportResult, ExportImportAction=ExportImportAction, cadCmtsExportImportGroup=cadCmtsExportImportGroup, cadCmtsExportImportWithLineNums=cadCmtsExportImportWithLineNums) |
class Problem:
"""
Given a string of different arrows designating to four directions.
Then we can rotate arrows so that they designate the same direction.
Example
"^^<>vvv" -> "^^^^^^^" -> 5 operations
"^^<>vvv" -> "vvvvvvv" -> 4 operations
"^^<>vvv" -> ">>>>>>>" -> 6 operations
Find the minimum number of operations that can rotate them into the same direction.
Hash Map
O(N)
O(1)
"""
def find_minimum_ope(self, s):
if not s:
raise Exception("Empty String")
d = {
"^": 0,
"<": 0,
"v": 0,
">": 0,
}
for ch in s:
if ch in d:
d[ch] += 1
else:
raise Exception("Invalid Character {}".format(ch))
return len(s) - max(d.values())
if __name__ == "__main__":
p = Problem()
s = "^^<>vvv"
print(p.find_minimum_ope(s))
| class Problem:
"""
Given a string of different arrows designating to four directions.
Then we can rotate arrows so that they designate the same direction.
Example
"^^<>vvv" -> "^^^^^^^" -> 5 operations
"^^<>vvv" -> "vvvvvvv" -> 4 operations
"^^<>vvv" -> ">>>>>>>" -> 6 operations
Find the minimum number of operations that can rotate them into the same direction.
Hash Map
O(N)
O(1)
"""
def find_minimum_ope(self, s):
if not s:
raise exception('Empty String')
d = {'^': 0, '<': 0, 'v': 0, '>': 0}
for ch in s:
if ch in d:
d[ch] += 1
else:
raise exception('Invalid Character {}'.format(ch))
return len(s) - max(d.values())
if __name__ == '__main__':
p = problem()
s = '^^<>vvv'
print(p.find_minimum_ope(s)) |
#!/home/jepoy/anaconda3/bin/python
## at terminal which python
#simple fibonacci series
# the sum of two elements defines the next set
a, b = 0, 1
while b < 1000:
print(b, end = ' ', flush = True)
a, b = b, a + b
print() # line ending | (a, b) = (0, 1)
while b < 1000:
print(b, end=' ', flush=True)
(a, b) = (b, a + b)
print() |
def create(type):
switcher = {
"L": LPiece(),
"O": OPiece(),
"I": IPiece(),
"J": JPiece(),
"S": SPiece(),
"T": TPiece(),
"Z": ZPiece()
}
return switcher.get(type.upper())
class Piece:
def __init__(self):
self._rotateIndex = 0
self._rotations = []
def turnLeft(self, times=1):
if self._rotateIndex > times-1:
self._rotateIndex -= times
return True
return False
def turnRight(self, times=1):
if self._rotateIndex < len(self._rotations) - times:
self._rotateIndex += times
return True
return False
def rotateCount(self):
return self._rotateIndex
def positions(self):
return self._rotations[self._rotateIndex]
def appendRotation(self, rotation):
self._rotations.append(rotation)
class LPiece(Piece):
def __init__(self):
Piece.__init__(self)
# rotations ordered by their rotation to the right
self._rotations.append([[2, 0], [0, 1], [1, 1], [2, 1]])
self._rotations.append([[1, 0], [1, 1], [1, 2], [2, 2]])
self._rotations.append([[0, 1], [1, 1], [2, 1], [0, 2]])
self._rotations.append([[0, 0], [1, 0], [1, 1], [1, 2]])
class OPiece(Piece):
def __init__(self):
Piece.__init__(self)
self._rotations.append([[0, 0], [1, 0], [0, 1], [1, 1]])
class IPiece(Piece):
def __init__(self):
Piece.__init__(self)
# rotations ordered by their rotation to the right
self._rotations.append([[0, 1], [1, 1], [2, 1], [3, 1]])
self._rotations.append([[2, 0], [2, 1], [2, 2], [2, 3]])
# self._rotations.append([[0, 2], [1, 2], [2, 2], [3, 2]])
# self._rotations.append([[1, 0], [1, 1], [1, 2], [1, 3]])
class JPiece(Piece):
def __init__(self):
Piece.__init__(self)
# rotations ordered by their rotation to the right
self._rotations.append([[0, 0], [0, 1], [1, 1], [2, 1]])
self._rotations.append([[1, 0], [2, 0], [1, 1], [1, 2]])
self._rotations.append([[0, 1], [1, 1], [2, 1], [2, 2]])
self._rotations.append([[1, 0], [1, 1], [0, 2], [1, 2]])
class SPiece(Piece):
def __init__(self):
Piece.__init__(self)
# rotations ordered by their rotation to the right
self._rotations.append([[1, 0], [2, 0], [0, 1], [1, 1]])
self._rotations.append([[1, 0], [1, 1], [2, 1], [2, 2]])
# self._rotations.append([[1, 1], [2, 1], [0, 2], [1, 2]])
# self._rotations.append([[0, 0], [0, 1], [1, 1], [1, 2]])
class TPiece(Piece):
def __init__(self):
Piece.__init__(self)
# rotations ordered by their rotation to the right
self._rotations.append([[1, 0], [0, 1], [1, 1], [2, 1]])
self._rotations.append([[1, 0], [1, 1], [2, 1], [1, 2]])
self._rotations.append([[0, 1], [1, 1], [2, 1], [1, 2]])
self._rotations.append([[1, 0], [0, 1], [1, 1], [1, 2]])
class ZPiece(Piece):
def __init__(self):
Piece.__init__(self)
self._rotations.append([[0, 0], [1, 0], [1, 1], [2, 1]])
self._rotations.append([[2, 0], [1, 1], [2, 1], [1, 2]])
# self._rotations.append([[0, 1], [1, 1], [1, 2], [2, 2]])
# self._rotations.append([[1, 0], [0, 1], [1, 1], [0, 2]])
| def create(type):
switcher = {'L': l_piece(), 'O': o_piece(), 'I': i_piece(), 'J': j_piece(), 'S': s_piece(), 'T': t_piece(), 'Z': z_piece()}
return switcher.get(type.upper())
class Piece:
def __init__(self):
self._rotateIndex = 0
self._rotations = []
def turn_left(self, times=1):
if self._rotateIndex > times - 1:
self._rotateIndex -= times
return True
return False
def turn_right(self, times=1):
if self._rotateIndex < len(self._rotations) - times:
self._rotateIndex += times
return True
return False
def rotate_count(self):
return self._rotateIndex
def positions(self):
return self._rotations[self._rotateIndex]
def append_rotation(self, rotation):
self._rotations.append(rotation)
class Lpiece(Piece):
def __init__(self):
Piece.__init__(self)
self._rotations.append([[2, 0], [0, 1], [1, 1], [2, 1]])
self._rotations.append([[1, 0], [1, 1], [1, 2], [2, 2]])
self._rotations.append([[0, 1], [1, 1], [2, 1], [0, 2]])
self._rotations.append([[0, 0], [1, 0], [1, 1], [1, 2]])
class Opiece(Piece):
def __init__(self):
Piece.__init__(self)
self._rotations.append([[0, 0], [1, 0], [0, 1], [1, 1]])
class Ipiece(Piece):
def __init__(self):
Piece.__init__(self)
self._rotations.append([[0, 1], [1, 1], [2, 1], [3, 1]])
self._rotations.append([[2, 0], [2, 1], [2, 2], [2, 3]])
class Jpiece(Piece):
def __init__(self):
Piece.__init__(self)
self._rotations.append([[0, 0], [0, 1], [1, 1], [2, 1]])
self._rotations.append([[1, 0], [2, 0], [1, 1], [1, 2]])
self._rotations.append([[0, 1], [1, 1], [2, 1], [2, 2]])
self._rotations.append([[1, 0], [1, 1], [0, 2], [1, 2]])
class Spiece(Piece):
def __init__(self):
Piece.__init__(self)
self._rotations.append([[1, 0], [2, 0], [0, 1], [1, 1]])
self._rotations.append([[1, 0], [1, 1], [2, 1], [2, 2]])
class Tpiece(Piece):
def __init__(self):
Piece.__init__(self)
self._rotations.append([[1, 0], [0, 1], [1, 1], [2, 1]])
self._rotations.append([[1, 0], [1, 1], [2, 1], [1, 2]])
self._rotations.append([[0, 1], [1, 1], [2, 1], [1, 2]])
self._rotations.append([[1, 0], [0, 1], [1, 1], [1, 2]])
class Zpiece(Piece):
def __init__(self):
Piece.__init__(self)
self._rotations.append([[0, 0], [1, 0], [1, 1], [2, 1]])
self._rotations.append([[2, 0], [1, 1], [2, 1], [1, 2]]) |
class HelperBase:
def __init__(self, app):
self.app = app
def type(self, locator, text):
wd = self.app.wd
if text is not None:
wd.find_element_by_name(locator).click()
wd.find_element_by_name(locator).clear()
wd.find_element_by_name(locator).send_keys(text)
def is_valid(self):
wd = self.app.wd
try:
wd.current_url
return True
except:
return False | class Helperbase:
def __init__(self, app):
self.app = app
def type(self, locator, text):
wd = self.app.wd
if text is not None:
wd.find_element_by_name(locator).click()
wd.find_element_by_name(locator).clear()
wd.find_element_by_name(locator).send_keys(text)
def is_valid(self):
wd = self.app.wd
try:
wd.current_url
return True
except:
return False |
#!/usr/bin/python3
print("Hello World")
x=4
y="ok,google"
z=[4,77,x,y]
print(y)
print(z)
print(x,y)
| print('Hello World')
x = 4
y = 'ok,google'
z = [4, 77, x, y]
print(y)
print(z)
print(x, y) |
major = 1
minor = 0
micro = None
pre_release = ".alpha"
post_release = None
dev_release = None
__version__ = '{}'.format(major)
if minor is not None:
__version__ += '.{}'.format(minor)
if micro is not None:
__version__ += '.{}'.format(micro)
if pre_release is not None:
__version__ += '{}'.format(pre_release)
if post_release is not None:
__version__ += '.post{}'.format(post_release)
if dev_release is not None:
__version__ += '.dev{}'.format(dev_release)
| major = 1
minor = 0
micro = None
pre_release = '.alpha'
post_release = None
dev_release = None
__version__ = '{}'.format(major)
if minor is not None:
__version__ += '.{}'.format(minor)
if micro is not None:
__version__ += '.{}'.format(micro)
if pre_release is not None:
__version__ += '{}'.format(pre_release)
if post_release is not None:
__version__ += '.post{}'.format(post_release)
if dev_release is not None:
__version__ += '.dev{}'.format(dev_release) |
#############################
#PROJECT : ENCODER-DECODER
#Language :English
#basic encode and decode
#Contact me on ;
#Telegram : Zafiyetsiz0
#Instagram : Zafiyetsiz
#Discord : Zafiyetsiz#4172
##############################
print("1-Encoder ; 2-Decoder")
choise=int(input("Please type the number of transaction you want :"))
print("-----------------------------------------------------------------------------")
if choise==1:
letters=("abcdefghijklmnopqrstuvwxyz")
print("key should be between 1-9999 and do not forget it ;")
key=int(input("Choose a number for your encode key:"))
text=input("Enter text for encode:")
x= len(letters)
encoded=" "
for i in text:
for ii in letters:
if i == ii:
number=letters.index(ii)
number += key
encoded +=letters[number % x]
print("Do not forget your key :", key )
print("Your encoded text :")
print(encoded)
elif choise==2:
letters=("abcdefghijklmnopqrstuvwxyz")
key=int(input("Choose a number for your decode key:"))
text=input("Enter text for decode:")
while key==key:
if key > 26:
key=key-26
print(key)
else:
break
print("--------------------------------------------------")
decoded_key = 26 - key
x= len(letters)
decoded=" "
for i in text:
for ii in letters:
if i == ii:
number=letters.index(ii)
number += decoded_key
decoded +=letters[number % x]
print("Your decoded text :")
print(decoded)
else:
print("ERROR : type 1 or 2")
| print('1-Encoder ; 2-Decoder')
choise = int(input('Please type the number of transaction you want :'))
print('-----------------------------------------------------------------------------')
if choise == 1:
letters = 'abcdefghijklmnopqrstuvwxyz'
print('key should be between 1-9999 and do not forget it ;')
key = int(input('Choose a number for your encode key:'))
text = input('Enter text for encode:')
x = len(letters)
encoded = ' '
for i in text:
for ii in letters:
if i == ii:
number = letters.index(ii)
number += key
encoded += letters[number % x]
print('Do not forget your key :', key)
print('Your encoded text :')
print(encoded)
elif choise == 2:
letters = 'abcdefghijklmnopqrstuvwxyz'
key = int(input('Choose a number for your decode key:'))
text = input('Enter text for decode:')
while key == key:
if key > 26:
key = key - 26
print(key)
else:
break
print('--------------------------------------------------')
decoded_key = 26 - key
x = len(letters)
decoded = ' '
for i in text:
for ii in letters:
if i == ii:
number = letters.index(ii)
number += decoded_key
decoded += letters[number % x]
print('Your decoded text :')
print(decoded)
else:
print('ERROR : type 1 or 2') |
def fib(a,b,n):
if(n==1):
return a
elif(n==2):
return b
else:
return fib(a,b,n-2)+fib(a,b,n-1)*fib(a,b,n-1)
r = input();
r = r.split(' ')
a = int(r[0])
b = int(r[1])
n = int(r[2])
print(fib(a,b,n)) | def fib(a, b, n):
if n == 1:
return a
elif n == 2:
return b
else:
return fib(a, b, n - 2) + fib(a, b, n - 1) * fib(a, b, n - 1)
r = input()
r = r.split(' ')
a = int(r[0])
b = int(r[1])
n = int(r[2])
print(fib(a, b, n)) |
#Actividad 2
a=1+2**-53
print(a)
b=a-1
print(b)
a=1+2**-52
print(a)
b=a-1 | a = 1 + 2 ** (-53)
print(a)
b = a - 1
print(b)
a = 1 + 2 ** (-52)
print(a)
b = a - 1 |
a = [{'001': '001', '002': '002'}]
print(a, type(a))
a = a.__str__()
print(a, type(a))
print(['------------------'])
init_list = [0 for n in range(10)]
init_list2 = [0] * 10
print(init_list)
print(init_list2)
# list - replace
a = ['110', '111', '112', '113']
for i in a:
print(i, a.index(i))
if i == '112':
id = a.index(i)
print(a[id])
i = i.replace('112', '000')
a[id] = '000'
print(a)
| a = [{'001': '001', '002': '002'}]
print(a, type(a))
a = a.__str__()
print(a, type(a))
print(['------------------'])
init_list = [0 for n in range(10)]
init_list2 = [0] * 10
print(init_list)
print(init_list2)
a = ['110', '111', '112', '113']
for i in a:
print(i, a.index(i))
if i == '112':
id = a.index(i)
print(a[id])
i = i.replace('112', '000')
a[id] = '000'
print(a) |
# Check whether the string is palindrome or not considering
# only Alpha-Numeric Characters ignoring cases
s = input();
t = ''.join([i.lower() if i.isalnum() else '' for i in s])
if t==''.join(reversed(t)): print("It is a Palindrome String")
else: print("It is not a Palindrome String")
| s = input()
t = ''.join([i.lower() if i.isalnum() else '' for i in s])
if t == ''.join(reversed(t)):
print('It is a Palindrome String')
else:
print('It is not a Palindrome String') |
# cannot be changed by user:
coinbaseReward = 5000000000 #50 bitcoins
halvingInterval = 150
maxOutputsPerTx = 1000
scalingUnits = .000001 # units of cap
confirmations = 6
onchainSatoshiMinimum = 100
maxTxPerBlock = 20 # 200 transactions in a block plus coinbase (which is at index 0)
iCoinbasePriv = 100000000 # some private key that is completely insecure. Doesn't matter what it is.
bCoinbasePriv = bytearray(iCoinbasePriv.to_bytes(32, "big"))
| coinbase_reward = 5000000000
halving_interval = 150
max_outputs_per_tx = 1000
scaling_units = 1e-06
confirmations = 6
onchain_satoshi_minimum = 100
max_tx_per_block = 20
i_coinbase_priv = 100000000
b_coinbase_priv = bytearray(iCoinbasePriv.to_bytes(32, 'big')) |
"""Formatter to extract the output files from a target."""
def format(target):
provider_map = providers(target)
if not provider_map:
return ""
outputs = dict()
# Try to resolve in order.
files_to_run = provider_map.get("FilesToRunProvider", None)
default_info = provider_map.get("DefaultInfo", None)
output_group_info = provider_map.get("OutputGroupInfo", None)
if files_to_run and files_to_run.executable:
outputs[files_to_run.executable.path] = True
elif default_info:
for x in default_info.files:
outputs[x.path] = True
elif output_group_info:
for entry in dir(output_group_info):
# Filter out all built-ins and anything that is not a depset.
if entry.startswith("_") or not hasattr(getattr(output_group_info, entry), "to_list"):
continue
for x in getattr(output_group_info, entry).to_list():
outputs[x.path] = True
# Return all found files.
return "\n".join(outputs.keys())
| """Formatter to extract the output files from a target."""
def format(target):
provider_map = providers(target)
if not provider_map:
return ''
outputs = dict()
files_to_run = provider_map.get('FilesToRunProvider', None)
default_info = provider_map.get('DefaultInfo', None)
output_group_info = provider_map.get('OutputGroupInfo', None)
if files_to_run and files_to_run.executable:
outputs[files_to_run.executable.path] = True
elif default_info:
for x in default_info.files:
outputs[x.path] = True
elif output_group_info:
for entry in dir(output_group_info):
if entry.startswith('_') or not hasattr(getattr(output_group_info, entry), 'to_list'):
continue
for x in getattr(output_group_info, entry).to_list():
outputs[x.path] = True
return '\n'.join(outputs.keys()) |
__all__ = [
'base_controller',
'basic_api_controller',
'advanced_api_controller',
'enterprise_only_controller',
]
| __all__ = ['base_controller', 'basic_api_controller', 'advanced_api_controller', 'enterprise_only_controller'] |
"""
Definition of exceptions thrown by arrus functions.
"""
class ArrusError(Exception):
pass
class IllegalArgumentError(ArrusError, ValueError):
pass
class DeviceNotFoundError(ArrusError, ValueError):
pass
class IllegalStateError(ArrusError, RuntimeError):
pass
class TimeoutError(ArrusError, TimeoutError):
pass | """
Definition of exceptions thrown by arrus functions.
"""
class Arruserror(Exception):
pass
class Illegalargumenterror(ArrusError, ValueError):
pass
class Devicenotfounderror(ArrusError, ValueError):
pass
class Illegalstateerror(ArrusError, RuntimeError):
pass
class Timeouterror(ArrusError, TimeoutError):
pass |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.