content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
OBSTACLE_SIZE = 45
ROBOT_SIZE = 45
GOAL_SIZE = 45
GOAL_POS_X = 50
GOAL_POS_Y = 50
START_POS_X = 100
START_POS_Y = 700
BOARD_SIZE = 800
STEP = 10
INFINITY = 100000 | obstacle_size = 45
robot_size = 45
goal_size = 45
goal_pos_x = 50
goal_pos_y = 50
start_pos_x = 100
start_pos_y = 700
board_size = 800
step = 10
infinity = 100000 |
print("To find the number of vowles in a given string")
count = 0
string=input("enter the string:")
for i in string:
if i in "aeiouAEIOU":
count=count+1
print("the vowels in the given string are:",i)
print("the total numbr of vowles are:",count)
| print('To find the number of vowles in a given string')
count = 0
string = input('enter the string:')
for i in string:
if i in 'aeiouAEIOU':
count = count + 1
print('the vowels in the given string are:', i)
print('the total numbr of vowles are:', count) |
##Removal of collisions of knolls with large boulders=name
##layerofcliffspolygons=vector
##radiusofknoll=number3.0
##layerofsmallknollspoints=vector
##radiusoflargeboulders=number4.5
##knolls=output vector
outputs_QGISFIXEDDISTANCEBUFFER_2=processing.runalg('qgis:fixeddistancebuffer', layerofcliffspolygons,radiusoflargeboulders,5.0,False,None)
outputs_QGISFIXEDDISTANCEBUFFER_1=processing.runalg('qgis:fixeddistancebuffer', layerofsmallknollspoints,radiusofknoll,5.0,False,None)
outputs_QGISEXTRACTBYLOCATION_1=processing.runalg('qgis:extractbylocation', outputs_QGISFIXEDDISTANCEBUFFER_1['OUTPUT'],outputs_QGISFIXEDDISTANCEBUFFER_2['OUTPUT'],['intersects'],0.1,None)
outputs_QGISDIFFERENCE_1=processing.runalg('qgis:difference', outputs_QGISFIXEDDISTANCEBUFFER_1['OUTPUT'],outputs_QGISEXTRACTBYLOCATION_1['OUTPUT'],True,None)
outputs_QGISPOLYGONCENTROIDS_1=processing.runalg('qgis:polygoncentroids', outputs_QGISDIFFERENCE_1['OUTPUT'],knolls) | outputs_qgisfixeddistancebuffer_2 = processing.runalg('qgis:fixeddistancebuffer', layerofcliffspolygons, radiusoflargeboulders, 5.0, False, None)
outputs_qgisfixeddistancebuffer_1 = processing.runalg('qgis:fixeddistancebuffer', layerofsmallknollspoints, radiusofknoll, 5.0, False, None)
outputs_qgisextractbylocation_1 = processing.runalg('qgis:extractbylocation', outputs_QGISFIXEDDISTANCEBUFFER_1['OUTPUT'], outputs_QGISFIXEDDISTANCEBUFFER_2['OUTPUT'], ['intersects'], 0.1, None)
outputs_qgisdifference_1 = processing.runalg('qgis:difference', outputs_QGISFIXEDDISTANCEBUFFER_1['OUTPUT'], outputs_QGISEXTRACTBYLOCATION_1['OUTPUT'], True, None)
outputs_qgispolygoncentroids_1 = processing.runalg('qgis:polygoncentroids', outputs_QGISDIFFERENCE_1['OUTPUT'], knolls) |
# Copyright (c) Sandeep Mistry. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
{
'targets': [
{
'target_name': 'class',
'conditions': [
['OS=="mac"', {
'sources': [
'src/class.mm'
],
'xcode_settings': {
'CLANG_CXX_LIBRARY': 'libc++',
'MACOSX_DEPLOYMENT_TARGET': '10.8'
}
}]
],
'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"],
'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"],
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ],
"link_settings": {
"libraries": ["/System/Library/Frameworks/Foundation.framework"]
}
},
{
'target_name': 'dispatch',
'conditions': [
['OS=="mac"', {
'sources': [
'src/dispatch.cpp'
],
'xcode_settings': {
'CLANG_CXX_LIBRARY': 'libc++',
'MACOSX_DEPLOYMENT_TARGET': '10.8'
}
}]
],
'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"],
'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"],
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ]
},
{
'target_name': 'dl',
'conditions': [
['OS=="mac"', {
'sources': [
'src/dl.cpp'
],
'xcode_settings': {
'CLANG_CXX_LIBRARY': 'libc++',
'MACOSX_DEPLOYMENT_TARGET': '10.8'
}
}]
],
'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"],
'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"],
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ]
},
{
'target_name': 'objc',
'conditions': [
['OS=="mac"', {
'sources': [
'src/objc.mm'
],
'xcode_settings': {
'CLANG_CXX_LIBRARY': 'libc++',
'MACOSX_DEPLOYMENT_TARGET': '10.8'
}
}]
],
'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"],
'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"],
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ],
"link_settings": {
"libraries": ["/System/Library/Frameworks/Foundation.framework"]
}
},
{
'target_name': 'sel',
'conditions': [
['OS=="mac"', {
'sources': [
'src/sel.cpp'
],
'xcode_settings': {
'CLANG_CXX_LIBRARY': 'libc++',
'MACOSX_DEPLOYMENT_TARGET': '10.8'
}
}]
],
'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"],
'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"],
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ]
}
]
}
| {'targets': [{'target_name': 'class', 'conditions': [['OS=="mac"', {'sources': ['src/class.mm'], 'xcode_settings': {'CLANG_CXX_LIBRARY': 'libc++', 'MACOSX_DEPLOYMENT_TARGET': '10.8'}}]], 'include_dirs': ['<!@(node -p "require(\'node-addon-api\').include")'], 'dependencies': ['<!(node -p "require(\'node-addon-api\').gyp")'], 'defines': ['NAPI_DISABLE_CPP_EXCEPTIONS'], 'link_settings': {'libraries': ['/System/Library/Frameworks/Foundation.framework']}}, {'target_name': 'dispatch', 'conditions': [['OS=="mac"', {'sources': ['src/dispatch.cpp'], 'xcode_settings': {'CLANG_CXX_LIBRARY': 'libc++', 'MACOSX_DEPLOYMENT_TARGET': '10.8'}}]], 'include_dirs': ['<!@(node -p "require(\'node-addon-api\').include")'], 'dependencies': ['<!(node -p "require(\'node-addon-api\').gyp")'], 'defines': ['NAPI_DISABLE_CPP_EXCEPTIONS']}, {'target_name': 'dl', 'conditions': [['OS=="mac"', {'sources': ['src/dl.cpp'], 'xcode_settings': {'CLANG_CXX_LIBRARY': 'libc++', 'MACOSX_DEPLOYMENT_TARGET': '10.8'}}]], 'include_dirs': ['<!@(node -p "require(\'node-addon-api\').include")'], 'dependencies': ['<!(node -p "require(\'node-addon-api\').gyp")'], 'defines': ['NAPI_DISABLE_CPP_EXCEPTIONS']}, {'target_name': 'objc', 'conditions': [['OS=="mac"', {'sources': ['src/objc.mm'], 'xcode_settings': {'CLANG_CXX_LIBRARY': 'libc++', 'MACOSX_DEPLOYMENT_TARGET': '10.8'}}]], 'include_dirs': ['<!@(node -p "require(\'node-addon-api\').include")'], 'dependencies': ['<!(node -p "require(\'node-addon-api\').gyp")'], 'defines': ['NAPI_DISABLE_CPP_EXCEPTIONS'], 'link_settings': {'libraries': ['/System/Library/Frameworks/Foundation.framework']}}, {'target_name': 'sel', 'conditions': [['OS=="mac"', {'sources': ['src/sel.cpp'], 'xcode_settings': {'CLANG_CXX_LIBRARY': 'libc++', 'MACOSX_DEPLOYMENT_TARGET': '10.8'}}]], 'include_dirs': ['<!@(node -p "require(\'node-addon-api\').include")'], 'dependencies': ['<!(node -p "require(\'node-addon-api\').gyp")'], 'defines': ['NAPI_DISABLE_CPP_EXCEPTIONS']}]} |
class Solution:
def hammingWeight(self, n: int) -> int:
wt = 0
is_non_neg = n >= 0
offset = int(not is_non_neg)
n = abs(n)
for _ in range(32):
if is_non_neg and n == 0:
break
wt += (n + offset) & 1
n >>= 1
return wt
class Solution2:
def hammingWeight(self, n: int) -> int:
return "{0:032b}".format(abs(n)).count("1" if n >= 0 else "0")
if __name__ == "__main__":
solver = Solution()
solver2 = Solution2()
for num in range(-5, 5):
print(f"HammingWeight({bin(num)}): {solver.hammingWeight(num)}")
print(f"HammingWeight({bin(num)}): {solver2.hammingWeight(num)}")
| class Solution:
def hamming_weight(self, n: int) -> int:
wt = 0
is_non_neg = n >= 0
offset = int(not is_non_neg)
n = abs(n)
for _ in range(32):
if is_non_neg and n == 0:
break
wt += n + offset & 1
n >>= 1
return wt
class Solution2:
def hamming_weight(self, n: int) -> int:
return '{0:032b}'.format(abs(n)).count('1' if n >= 0 else '0')
if __name__ == '__main__':
solver = solution()
solver2 = solution2()
for num in range(-5, 5):
print(f'HammingWeight({bin(num)}): {solver.hammingWeight(num)}')
print(f'HammingWeight({bin(num)}): {solver2.hammingWeight(num)}') |
f = open("/share/Ecoli/GCA_000005845.2_ASM584v2_genomic.fna")
lines = f.readlines()
genome = ""
for i in range(1, len(lines)):
for j in range(len(lines[i]) - 1):
genome = genome + lines[i][j]
for i in range(0 , 3):
extra = len(genome) - i % 11
fragments = ""
fragcount = 0
fraglength = 0
for j in range(i, len(genome) - extra, 11):
site = genome[j:j+10]
| f = open('/share/Ecoli/GCA_000005845.2_ASM584v2_genomic.fna')
lines = f.readlines()
genome = ''
for i in range(1, len(lines)):
for j in range(len(lines[i]) - 1):
genome = genome + lines[i][j]
for i in range(0, 3):
extra = len(genome) - i % 11
fragments = ''
fragcount = 0
fraglength = 0
for j in range(i, len(genome) - extra, 11):
site = genome[j:j + 10] |
def test():
a = {'foo': 'bar'}
print(a)
print(a['foo'])
b = {'x':'y'}
a.update(b)
print(a)
keys = a.keys()
print(keys)
vals = a.values()
print(vals)
test()
| def test():
a = {'foo': 'bar'}
print(a)
print(a['foo'])
b = {'x': 'y'}
a.update(b)
print(a)
keys = a.keys()
print(keys)
vals = a.values()
print(vals)
test() |
def process(s):
n = s.find(";")
if n > 0:
left = s[:n]+(" " * 64)
s = left[:34]+s[n:]
return s
f = open("revenge.asm")
code = f.readlines()
f.close()
code = [process(c.rstrip()) for c in code]
print("\n".join(code)) | def process(s):
n = s.find(';')
if n > 0:
left = s[:n] + ' ' * 64
s = left[:34] + s[n:]
return s
f = open('revenge.asm')
code = f.readlines()
f.close()
code = [process(c.rstrip()) for c in code]
print('\n'.join(code)) |
def reindent(s, numSpaces):
leading_space = numSpaces * ' '
lines = [ leading_space + line.strip()
for line in s.splitlines() ]
return '\n'.join(lines)
| def reindent(s, numSpaces):
leading_space = numSpaces * ' '
lines = [leading_space + line.strip() for line in s.splitlines()]
return '\n'.join(lines) |
__author__ = "ricksy"
__email__ = "ricksy@mailbox.org"
__copyright__ = "(c) 2020 ricksy"
__version__ = "1.0.0"
__title__ = "py1"
__description__ = "have not idea"
__license__ = "MIT"
| __author__ = 'ricksy'
__email__ = 'ricksy@mailbox.org'
__copyright__ = '(c) 2020 ricksy'
__version__ = '1.0.0'
__title__ = 'py1'
__description__ = 'have not idea'
__license__ = 'MIT' |
initials = [
"b",
"c",
"ch",
"d",
"f",
"g",
"h",
"j",
"k",
"l",
"m",
"n",
"p",
"q",
"r",
"s",
"sh",
"t",
"w",
"x",
"y",
"z",
"zh",
]
finals = ['S', 'Sj', 'StS', 'StSj', 'Z', 'Zj', 'a', 'b', 'bj', 'd', 'dj', 'e', 'f', 'g', 'hrd', 'i', 'i2', 'j', 'jA', 'jE', 'jO', 'jU', 'k', 'l', 'lj', 'm', 'mj', 'n', 'nj', 'o', 'p', 'pj', 'r', 'rj', 's', 'sj', 't', 'tS', 'tSj', 'tj', 'ts', 'u', 'v', 'vj', 'x', 'z', 'zj']
valid_symbols = initials + finals + ["rr"]
| initials = ['b', 'c', 'ch', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 'sh', 't', 'w', 'x', 'y', 'z', 'zh']
finals = ['S', 'Sj', 'StS', 'StSj', 'Z', 'Zj', 'a', 'b', 'bj', 'd', 'dj', 'e', 'f', 'g', 'hrd', 'i', 'i2', 'j', 'jA', 'jE', 'jO', 'jU', 'k', 'l', 'lj', 'm', 'mj', 'n', 'nj', 'o', 'p', 'pj', 'r', 'rj', 's', 'sj', 't', 'tS', 'tSj', 'tj', 'ts', 'u', 'v', 'vj', 'x', 'z', 'zj']
valid_symbols = initials + finals + ['rr'] |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
class Student(object):
def __init__(self):
self.name = "Michael"
def __getattr__(self, attr):
if attr == "score":
return 99
if attr == "age":
return lambda: 25
raise AttributeError("'Student' object has no attribute '%s'" % attr)
s = Student()
print(s.name)
print(s.score)
print(s.age())
# AttributeError: 'Student' object has no attribute 'grade'
print(s.grade)
| class Student(object):
def __init__(self):
self.name = 'Michael'
def __getattr__(self, attr):
if attr == 'score':
return 99
if attr == 'age':
return lambda : 25
raise attribute_error("'Student' object has no attribute '%s'" % attr)
s = student()
print(s.name)
print(s.score)
print(s.age())
print(s.grade) |
while True:
try:
n = int(input())
app_list = input().strip().split()
tick_num = int(input())
tick_list = input().strip().split()
invalid = 0
tick_dict = {}
for app in app_list:
tick_dict[app] = 0
for tick in tick_list:
if tick in tick_dict:
tick_dict[tick] += 1
else:
invalid += 1
for app in app_list:
print(app+" : "+str(tick_dict[app]))
print("Invalid : "+str(invalid))
except:
break | while True:
try:
n = int(input())
app_list = input().strip().split()
tick_num = int(input())
tick_list = input().strip().split()
invalid = 0
tick_dict = {}
for app in app_list:
tick_dict[app] = 0
for tick in tick_list:
if tick in tick_dict:
tick_dict[tick] += 1
else:
invalid += 1
for app in app_list:
print(app + ' : ' + str(tick_dict[app]))
print('Invalid : ' + str(invalid))
except:
break |
SESSION_NAME = "researcher_username"
EXPIRY_NAME = "expiry"
SESSION_UUID = "session_uuid"
STUDY_ADMIN_RESTRICTION = "study_admin_restriction"
| session_name = 'researcher_username'
expiry_name = 'expiry'
session_uuid = 'session_uuid'
study_admin_restriction = 'study_admin_restriction' |
class Solution:
def addDigits(self, num: int) -> int:
while num > 9:
num = sum([int(x) for x in str(num)])
return num
| class Solution:
def add_digits(self, num: int) -> int:
while num > 9:
num = sum([int(x) for x in str(num)])
return num |
class Node:
def __init__(self, data):
self.data = data
self.left = self.right = None
class Solution:
def tiltOfBinaryTreeUtil(self, root):
if root is None:
return 0
left_tilt = self.tiltOfBinaryTreeUtil(root.left)
right_tilt = self.tiltOfBinaryTreeUtil(root.right)
currentNode_tilt = abs(left_tilt - right_tilt)
self.total_tilt += currentNode_tilt
return root.data + left_tilt + right_tilt
def tiltOfBinaryTree(self, root):
self.total_tilt = 0
self.tiltOfBinaryTreeUtil(root)
return self.total_tilt
if __name__ == '__main__':
root = Node(50)
root.left = Node(10)
root.right = Node(40)
root.left.left = Node(30)
root.left.right = Node(20)
print(Solution().tiltOfBinaryTree(root))
# 4
# / \
# 2 9
# / \ \
# 3 5 7
# Explanation:
# Tilt of node 3 : 0
# Tilt of node 5 : 0
# Tilt of node 7 : 0
# Tilt of node 2 : |3-5| = 2
# Tilt of node 9 : |0-7| = 7
# Tilt of node 4 : |(3+5+2)-(9+7)| = 6
# Tilt of binary tree : 0 + 0 + 0 + 2 + 7 + 6 = 15
root = Node(4)
root.left = Node(2)
root.right = Node(9)
root.right.right = Node(7)
root.left.left = Node(3)
root.left.right = Node(5)
print(Solution().tiltOfBinaryTree(root))
| class Node:
def __init__(self, data):
self.data = data
self.left = self.right = None
class Solution:
def tilt_of_binary_tree_util(self, root):
if root is None:
return 0
left_tilt = self.tiltOfBinaryTreeUtil(root.left)
right_tilt = self.tiltOfBinaryTreeUtil(root.right)
current_node_tilt = abs(left_tilt - right_tilt)
self.total_tilt += currentNode_tilt
return root.data + left_tilt + right_tilt
def tilt_of_binary_tree(self, root):
self.total_tilt = 0
self.tiltOfBinaryTreeUtil(root)
return self.total_tilt
if __name__ == '__main__':
root = node(50)
root.left = node(10)
root.right = node(40)
root.left.left = node(30)
root.left.right = node(20)
print(solution().tiltOfBinaryTree(root))
root = node(4)
root.left = node(2)
root.right = node(9)
root.right.right = node(7)
root.left.left = node(3)
root.left.right = node(5)
print(solution().tiltOfBinaryTree(root)) |
def getLongestPalindrome(start: int, end: int, s: str) -> str:
while start > -1 and end < len(s) and s[start] == s[end]:
start -= 1
end += 1
return s[start + 1:end]
def longestPalindrome(s: str) -> str:
if not s or len(s) == 0:
return ""
if len(s) == 1:
return s
result = ""
for index in range(len(s)):
odd = getLongestPalindrome(index, index, s)
even = getLongestPalindrome(index, index + 1, s)
if len(odd) > len(result):
result = odd
if len(even) > len(result):
result = even
return result
if __name__ == "__main__":
print(longestPalindrome("babad"))
print(longestPalindrome("cbbd"))
print(longestPalindrome("a"))
print(longestPalindrome("ac"))
print(longestPalindrome("bb")) | def get_longest_palindrome(start: int, end: int, s: str) -> str:
while start > -1 and end < len(s) and (s[start] == s[end]):
start -= 1
end += 1
return s[start + 1:end]
def longest_palindrome(s: str) -> str:
if not s or len(s) == 0:
return ''
if len(s) == 1:
return s
result = ''
for index in range(len(s)):
odd = get_longest_palindrome(index, index, s)
even = get_longest_palindrome(index, index + 1, s)
if len(odd) > len(result):
result = odd
if len(even) > len(result):
result = even
return result
if __name__ == '__main__':
print(longest_palindrome('babad'))
print(longest_palindrome('cbbd'))
print(longest_palindrome('a'))
print(longest_palindrome('ac'))
print(longest_palindrome('bb')) |
class WeatherItem:
def __init__(self, name, prefix="", suffix="", condition_type_list=[]):
self.__name = name
self.__prefix = prefix
self.__suffix = suffix
self.__condition_list = condition_type_list
def __eq__(self, other):
if isinstance(other, self.__class__):
return self.__name == other.name
return False
def __ne__(self, other):
return not self.__eq__(other)
def __str__(self):
return "{%s, %s, %s, %s}" % (self.__name, self.__prefix, self.__suffix, self.__condition_list)
__repr__ = __str__
@property
def name(self):
return self.__name
@property
def conditions(self):
return self.__condition_list
def is_for_condition_type(self, condition_type):
return condition_type in self.__condition_list
def format_for_output(self):
output = self.__name
if self.__prefix != "":
output = self.__prefix + " " + output
if self.__suffix != "":
output = output + " " + self.__suffix
return output
| class Weatheritem:
def __init__(self, name, prefix='', suffix='', condition_type_list=[]):
self.__name = name
self.__prefix = prefix
self.__suffix = suffix
self.__condition_list = condition_type_list
def __eq__(self, other):
if isinstance(other, self.__class__):
return self.__name == other.name
return False
def __ne__(self, other):
return not self.__eq__(other)
def __str__(self):
return '{%s, %s, %s, %s}' % (self.__name, self.__prefix, self.__suffix, self.__condition_list)
__repr__ = __str__
@property
def name(self):
return self.__name
@property
def conditions(self):
return self.__condition_list
def is_for_condition_type(self, condition_type):
return condition_type in self.__condition_list
def format_for_output(self):
output = self.__name
if self.__prefix != '':
output = self.__prefix + ' ' + output
if self.__suffix != '':
output = output + ' ' + self.__suffix
return output |
secondary_todo_list
| secondary_todo_list |
window = None
scene = 'title'
state = ''
class Cursor():
class Title():
menu = 0
class Save_Select():
save = 0
class Roguelike_Menu():
level = 0
character = 0
class Roguelike_Start():
select = 0
class Save():
data = {
0 : '',
1 : '',
2 : '',
}
class Select():
class Roguelike_Menu():
level = 0
character = 0
class Pool():
card = {
'all' : [],
'fire' : [],
'water' : [],
'nature' : [],
'earth' : [],
'light' : [],
'normal' : []
}
item = {
'common' : [],
}
class Field():
wall = []
thing = []
portal = []
class Player():
level = 0
exp = 0
exp_max = 0
life = 20
card = []
equip = []
item = []
class Player_Rogue():
level = 0
exp = 0
exp_max = 0
life = 20
deck = []
equip = []
item = []
| window = None
scene = 'title'
state = ''
class Cursor:
class Title:
menu = 0
class Save_Select:
save = 0
class Roguelike_Menu:
level = 0
character = 0
class Roguelike_Start:
select = 0
class Save:
data = {0: '', 1: '', 2: ''}
class Select:
class Roguelike_Menu:
level = 0
character = 0
class Pool:
card = {'all': [], 'fire': [], 'water': [], 'nature': [], 'earth': [], 'light': [], 'normal': []}
item = {'common': []}
class Field:
wall = []
thing = []
portal = []
class Player:
level = 0
exp = 0
exp_max = 0
life = 20
card = []
equip = []
item = []
class Player_Rogue:
level = 0
exp = 0
exp_max = 0
life = 20
deck = []
equip = []
item = [] |
in_file = open('occurrences.txt', 'r')
out_file = open('present.txt', 'w')
counter = 7740
for line in in_file:
row = line.split('\t')
country = row[5]
id = row[0]
ref = row[8]
if country == '':
country = row[6]
if country == '':
pass
else:
out_file.write('M' + str(counter) + '\t' + id + '\t\ttrue\t' + 'http://eol.org/schema/terms/Present' + '\t' + country + '\t\t\t\tCompiler: Anne E Thessen\t' + ref + '\n')
counter = counter + 1 | in_file = open('occurrences.txt', 'r')
out_file = open('present.txt', 'w')
counter = 7740
for line in in_file:
row = line.split('\t')
country = row[5]
id = row[0]
ref = row[8]
if country == '':
country = row[6]
if country == '':
pass
else:
out_file.write('M' + str(counter) + '\t' + id + '\t\ttrue\t' + 'http://eol.org/schema/terms/Present' + '\t' + country + '\t\t\t\tCompiler: Anne E Thessen\t' + ref + '\n')
counter = counter + 1 |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# This line will be programatically read/write by setup.py.
# Leave them at the bottom of this file and don't touch them.
__version__ = "0.1.1"
| __version__ = '0.1.1' |
# Create a dictionary of lists with new data
avocados_dict = {
"date": ["2019-11-17", "2019-12-01"],
"small_sold": [10859987, 9291631],
"large_sold": [7674135, 6238096]
}
# Convert dictionary into DataFrame
avocados_2019 = pd.DataFrame(avocados_dict)
# Print the new DataFrame
print(avocados_2019) | avocados_dict = {'date': ['2019-11-17', '2019-12-01'], 'small_sold': [10859987, 9291631], 'large_sold': [7674135, 6238096]}
avocados_2019 = pd.DataFrame(avocados_dict)
print(avocados_2019) |
Li = [ 22, 35 , 26 , 98 , 55 , 10 , 67 ]
Li.sort()
Li.reverse()
print(Li)
| li = [22, 35, 26, 98, 55, 10, 67]
Li.sort()
Li.reverse()
print(Li) |
class HsrpOutput(object):
# 'show hsrp detail' output
showHsrpDetailOutput = \
{
'GigabitEthernet0/0/0/0': {
'address_family': {
'ipv4': {
'version': {
1: {
'groups': {
0: {
'active_ip_address': 'unknown',
'active_router': 'unknown',
'bfd': {
'address': '10.1.1.1',
'interface_name': 'GigabitEthernet0/0/0/1',
'state': 'inactive'
},
'group_number': 0,
'hsrp_router_state': 'init',
'preempt': True,
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'stored',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': 'never',
'num_state_changes': 0
},
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0000.0c07.ac00'
},
10: {
'active_ip_address': 'local',
'active_priority': 63,
'active_router': 'local',
'authentication': 'cisco123',
'group_number': 10,
'hsrp_router_state': 'active',
'num_of_slaves': 1,
'preempt': True,
'primary_ipv4_address': {
'address': '10.1.1.254'
},
'priority': 63,
'session_name': 'group10',
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'reserving',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': '09:36:53',
'num_state_changes': 4
},
'timers': {
'cfgd_hello_msec': 10000,
'cfgd_hold_msec': 30000,
'hello_msec': 10000,
'hello_msec_flag': True,
'hold_msec': 30000,
'hold_msec_flag': True
},
'tracked_interfaces': {
'GigabitEthernet0/0/0/1': {
'interface_name': 'GigabitEthernet0/0/0/1',
'priority_decrement': 123
}
},
'tracked_objects': {
'1': {
'object_name': '1',
'priority_decrement': 25
},
'num_tracked_objects': 2,
'num_tracked_objects_up': 1
},
'virtual_mac_address': '0000.0c07.ac0a'
},
20: {
'active_ip_address': 'local',
'active_priority': 100,
'active_router': 'local',
'group_number': 20,
'hsrp_router_state': 'active',
'primary_ipv4_address': {
'address': '10.1.1.128'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'reserving',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': '09:37:52',
'num_state_changes': 4
},
'timers': {
'cfgd_hello_msec': 111,
'cfgd_hold_msec': 333,
'hello_msec': 111,
'hello_msec_flag': True,
'hold_msec': 333,
'hold_msec_flag': True
},
'tracked_interfaces': {
'GigabitEthernet0/0/0/1': {
'interface_name': 'GigabitEthernet0/0/0/1',
'priority_decrement': 251
}
},
'tracked_objects': {
'num_tracked_objects': 1,
'num_tracked_objects_up': 1
},
'virtual_mac_address': '0000.0c07.ac14'
}
},
'slave_groups': {
30: {
'follow': 'group10',
'group_number': 30,
'hsrp_router_state': 'init',
'primary_ipv4_address': {
'address': 'unknown'
},
'priority': 100,
'standby_state': 'stored',
'virtual_mac_address': '0000.0c07.ac1e'
}
}
}
}
},
'ipv6': {
'version': {
2: {
'groups': {
10: {
'active_ip_address': 'local',
'active_priority': 100,
'active_router': 'local',
'group_number': 10,
'hsrp_router_state': 'active',
'link_local_ipv6_address': {
'address': 'fe80::205:73ff:fea0:a'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'reserving',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': '09:37:18',
'num_state_changes': 4
},
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0005.73a0.000a'
},
20: {
'active_ip_address': 'local',
'active_priority': 100,
'active_router': 'local',
'group_number': 20,
'hsrp_router_state': 'active',
'link_local_ipv6_address': {
'address': 'fe80::205:73ff:fea0:14'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'reserving',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': '09:37:18',
'num_state_changes': 4
},
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0005.73a0.0014'
},
30: {
'active_ip_address': 'local',
'active_priority': 100,
'active_router': 'local',
'group_number': 30,
'hsrp_router_state': 'active',
'link_local_ipv6_address': {
'address': 'fe80::205:73ff:fea0:1e'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'reserving',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': '09:37:18',
'num_state_changes': 4
},
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0005.73a0.001e'
}
}
}
}
}
},
'bfd': {
'detection_multiplier': 3,
'enabled': True,
'interval': 15
},
'delay': {
'minimum_delay': 100,
'reload_delay': 1000
},
'interface': 'GigabitEthernet0/0/0/0',
'redirects_disable': True,
'use_bia': False
}
}
showHsrpDetailOutputIncomplete = \
{
'GigabitEthernet0/0/0/0': {
'address_family': {
'ipv4': {
'version': {
1: {
'groups': {
0: {
'active_ip_address': 'unknown',
'active_router': 'unknown',
'bfd': {
'address': '10.1.1.1',
'interface_name': 'GigabitEthernet0/0/0/1',
'state': 'inactive'
},
'group_number': 0,
'hsrp_router_state': 'init',
'preempt': True,
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'stored',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': 'never',
'num_state_changes': 0
},
'virtual_mac_address': '0000.0c07.ac00'
},
10: {
'active_ip_address': 'local',
'active_priority': 63,
'active_router': 'local',
'authentication': 'cisco123',
'group_number': 10,
'hsrp_router_state': 'active',
'num_of_slaves': 1,
'preempt': True,
'primary_ipv4_address': {
'address': '10.1.1.254'
},
'priority': 63,
'session_name': 'group10',
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'reserving',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': '09:36:53',
'num_state_changes': 4
},
'timers': {
'cfgd_hello_msec': 10000,
'cfgd_hold_msec': 30000,
'hello_msec': 10000,
'hello_msec_flag': True,
'hold_msec': 30000,
'hold_msec_flag': True
},
'tracked_interfaces': {
'GigabitEthernet0/0/0/1': {
'interface_name': 'GigabitEthernet0/0/0/1',
'priority_decrement': 123
}
},
'tracked_objects': {
'1': {
'object_name': '1',
'priority_decrement': 25
},
'num_tracked_objects': 2,
'num_tracked_objects_up': 1
},
'virtual_mac_address': '0000.0c07.ac0a'
},
20: {
'active_ip_address': 'local',
'active_priority': 100,
'active_router': 'local',
'group_number': 20,
'hsrp_router_state': 'active',
'primary_ipv4_address': {
'address': '10.1.1.128'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'reserving',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': '09:37:52',
'num_state_changes': 4
},
'timers': {
'cfgd_hello_msec': 111,
'cfgd_hold_msec': 333,
'hello_msec': 111,
'hello_msec_flag': True,
'hold_msec': 333,
'hold_msec_flag': True
},
'tracked_interfaces': {
'GigabitEthernet0/0/0/1': {
'interface_name': 'GigabitEthernet0/0/0/1',
'priority_decrement': 251
}
},
'tracked_objects': {
'num_tracked_objects': 1,
'num_tracked_objects_up': 1
},
'virtual_mac_address': '0000.0c07.ac14'
}
},
'slave_groups': {
30: {
'follow': 'group10',
'group_number': 30,
'hsrp_router_state': 'init',
'primary_ipv4_address': {
'address': 'unknown'
},
'priority': 100,
'standby_state': 'stored',
'virtual_mac_address': '0000.0c07.ac1e'
}
}
}
}
},
'ipv6': {
'version': {
2: {
'groups': {
10: {
'active_ip_address': 'local',
'active_priority': 100,
'active_router': 'local',
'group_number': 10,
'hsrp_router_state': 'active',
'link_local_ipv6_address': {
'address': 'fe80::205:73ff:fea0:a'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'reserving',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': '09:37:18',
'num_state_changes': 4
},
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0005.73a0.000a'
},
20: {
'active_ip_address': 'local',
'active_priority': 100,
'active_router': 'local',
'group_number': 20,
'hsrp_router_state': 'active',
'link_local_ipv6_address': {
'address': 'fe80::205:73ff:fea0:14'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'reserving',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': '09:37:18',
'num_state_changes': 4
},
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0005.73a0.0014'
},
30: {
'active_ip_address': 'local',
'active_priority': 100,
'active_router': 'local',
'group_number': 30,
'hsrp_router_state': 'active',
'link_local_ipv6_address': {
'address': 'fe80::205:73ff:fea0:1e'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'reserving',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': '09:37:18',
'num_state_changes': 4
},
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0005.73a0.001e'
}
}
}
}
}
},
'bfd': {
'detection_multiplier': 3,
'enabled': True,
'interval': 15
},
'delay': {
'minimum_delay': 100,
'reload_delay': 1000
},
'interface': 'GigabitEthernet0/0/0/0',
'redirects_disable': True,
'use_bia': False
}
}
# 'show hsrp summary' output
showHsrpSummaryOutput = \
{
'address_family': {
'ipv4': {
'intf_down': 0,
'intf_total': 1,
'intf_up': 1,
'state': {
'ACTIVE': {
'sessions': 2,
'slaves': 0,
'total': 2
},
'ALL': {
'sessions': 3,
'slaves': 1,
'total': 4
},
'INIT': {
'sessions': 1,
'slaves': 1,
'total': 2
},
'LEARN': {
'sessions': 0,
'slaves': 0,
'total': 0
},
'LISTEN': {
'sessions': 0,
'slaves': 0,
'total': 0
},
'SPEAK': {
'sessions': 0,
'slaves': 0,
'total': 0
},
'STANDBY': {
'sessions': 0,
'slaves': 0,
'total': 0
}
},
'virtual_addresses_active': 3,
'virtual_addresses_inactive': 0,
'vritual_addresses_total': 3
},
'ipv6': {
'intf_down': 0,
'intf_total': 1,
'intf_up': 1,
'state': {
'ACTIVE': {
'sessions': 3,
'slaves': 0,
'total': 3
},
'ALL': {
'sessions': 3,
'slaves': 0,
'total': 3
},
'INIT': {
'sessions': 0,
'slaves': 0,
'total': 0
},
'LEARN': {
'sessions': 0,
'slaves': 0,
'total': 0
},
'LISTEN': {
'sessions': 0,
'slaves': 0,
'total': 0
},
'SPEAK': {
'sessions': 0,
'slaves': 0,
'total': 0
},
'STANDBY': {
'sessions': 0,
'slaves': 0,
'total': 0
}
},
'virtual_addresses_active': 5,
'virtual_addresses_inactive': 0,
'vritual_addresses_total': 5
}
},
'bfd_sessions_down': 0,
'bfd_sessions_inactive': 1,
'bfd_sessions_up': 0,
'num_bfd_sessions': 1,
'num_tracked_objects': 2,
'tracked_objects_down': 1,
'tracked_objects_up': 1
}
# Hsrp Ops Object final output
hsrpOpsOutput = \
{
'GigabitEthernet0/0/0/0': {
'address_family': {
'ipv4': {
'version': {
1: {
'groups': {
0: {
'active_ip_address': 'unknown',
'active_router': 'unknown',
'bfd': {
'address': '10.1.1.1',
'interface_name': 'GigabitEthernet0/0/0/1'
},
'group_number': 0,
'hsrp_router_state': 'init',
'preempt': True,
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0000.0c07.ac00'
},
10: {
'active_ip_address': 'local',
'active_router': 'local',
'authentication': 'cisco123',
'group_number': 10,
'hsrp_router_state': 'active',
'preempt': True,
'primary_ipv4_address': {
'address': '10.1.1.254'
},
'priority': 63,
'session_name': 'group10',
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'timers': {
'hello_msec': 10000,
'hello_msec_flag': True,
'hold_msec': 30000,
'hold_msec_flag': True
},
'tracked_interfaces': {
'GigabitEthernet0/0/0/1': {
'interface_name': 'GigabitEthernet0/0/0/1',
'priority_decrement': 123
}
},
'tracked_objects': {
'1': {
'object_name': '1',
'priority_decrement': 25
}
},
'virtual_mac_address': '0000.0c07.ac0a'
},
20: {
'active_ip_address': 'local',
'active_router': 'local',
'group_number': 20,
'hsrp_router_state': 'active',
'primary_ipv4_address': {
'address': '10.1.1.128'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'timers': {
'hello_msec': 111,
'hello_msec_flag': True,
'hold_msec': 333,
'hold_msec_flag': True
},
'tracked_interfaces': {
'GigabitEthernet0/0/0/1': {
'interface_name': 'GigabitEthernet0/0/0/1',
'priority_decrement': 251
}
},
'virtual_mac_address': '0000.0c07.ac14'
}
},
'slave_groups': {
30: {
'follow': 'group10',
'primary_ipv4_address': {
'address': 'unknown'
},
'virtual_mac_address': '0000.0c07.ac1e'
}
}
}
}
},
'ipv6': {
'version': {
2: {
'groups': {
10: {
'active_ip_address': 'local',
'active_router': 'local',
'group_number': 10,
'hsrp_router_state': 'active',
'link_local_ipv6_address': {
'address': 'fe80::205:73ff:fea0:a'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0005.73a0.000a'
},
20: {
'active_ip_address': 'local',
'active_router': 'local',
'group_number': 20,
'hsrp_router_state': 'active',
'link_local_ipv6_address': {
'address': 'fe80::205:73ff:fea0:14'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0005.73a0.0014'
},
30: {
'active_ip_address': 'local',
'active_router': 'local',
'group_number': 30,
'hsrp_router_state': 'active',
'link_local_ipv6_address': {
'address': 'fe80::205:73ff:fea0:1e'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0005.73a0.001e'
}
}
}
}
}
},
'bfd': {
'detection_multiplier': 3,
'enabled': True,
'interval': 15
},
'delay': {
'minimum_delay': 100,
'reload_delay': 1000
},
'interface': 'GigabitEthernet0/0/0/0',
'redirects_disable': True,
'use_bia': False
}
}
# vim: ft=python et sw=4
| class Hsrpoutput(object):
show_hsrp_detail_output = {'GigabitEthernet0/0/0/0': {'address_family': {'ipv4': {'version': {1: {'groups': {0: {'active_ip_address': 'unknown', 'active_router': 'unknown', 'bfd': {'address': '10.1.1.1', 'interface_name': 'GigabitEthernet0/0/0/1', 'state': 'inactive'}, 'group_number': 0, 'hsrp_router_state': 'init', 'preempt': True, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'stored', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': 'never', 'num_state_changes': 0}, 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0000.0c07.ac00'}, 10: {'active_ip_address': 'local', 'active_priority': 63, 'active_router': 'local', 'authentication': 'cisco123', 'group_number': 10, 'hsrp_router_state': 'active', 'num_of_slaves': 1, 'preempt': True, 'primary_ipv4_address': {'address': '10.1.1.254'}, 'priority': 63, 'session_name': 'group10', 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:36:53', 'num_state_changes': 4}, 'timers': {'cfgd_hello_msec': 10000, 'cfgd_hold_msec': 30000, 'hello_msec': 10000, 'hello_msec_flag': True, 'hold_msec': 30000, 'hold_msec_flag': True}, 'tracked_interfaces': {'GigabitEthernet0/0/0/1': {'interface_name': 'GigabitEthernet0/0/0/1', 'priority_decrement': 123}}, 'tracked_objects': {'1': {'object_name': '1', 'priority_decrement': 25}, 'num_tracked_objects': 2, 'num_tracked_objects_up': 1}, 'virtual_mac_address': '0000.0c07.ac0a'}, 20: {'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 20, 'hsrp_router_state': 'active', 'primary_ipv4_address': {'address': '10.1.1.128'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:52', 'num_state_changes': 4}, 'timers': {'cfgd_hello_msec': 111, 'cfgd_hold_msec': 333, 'hello_msec': 111, 'hello_msec_flag': True, 'hold_msec': 333, 'hold_msec_flag': True}, 'tracked_interfaces': {'GigabitEthernet0/0/0/1': {'interface_name': 'GigabitEthernet0/0/0/1', 'priority_decrement': 251}}, 'tracked_objects': {'num_tracked_objects': 1, 'num_tracked_objects_up': 1}, 'virtual_mac_address': '0000.0c07.ac14'}}, 'slave_groups': {30: {'follow': 'group10', 'group_number': 30, 'hsrp_router_state': 'init', 'primary_ipv4_address': {'address': 'unknown'}, 'priority': 100, 'standby_state': 'stored', 'virtual_mac_address': '0000.0c07.ac1e'}}}}}, 'ipv6': {'version': {2: {'groups': {10: {'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 10, 'hsrp_router_state': 'active', 'link_local_ipv6_address': {'address': 'fe80::205:73ff:fea0:a'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:18', 'num_state_changes': 4}, 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0005.73a0.000a'}, 20: {'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 20, 'hsrp_router_state': 'active', 'link_local_ipv6_address': {'address': 'fe80::205:73ff:fea0:14'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:18', 'num_state_changes': 4}, 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0005.73a0.0014'}, 30: {'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 30, 'hsrp_router_state': 'active', 'link_local_ipv6_address': {'address': 'fe80::205:73ff:fea0:1e'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:18', 'num_state_changes': 4}, 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0005.73a0.001e'}}}}}}, 'bfd': {'detection_multiplier': 3, 'enabled': True, 'interval': 15}, 'delay': {'minimum_delay': 100, 'reload_delay': 1000}, 'interface': 'GigabitEthernet0/0/0/0', 'redirects_disable': True, 'use_bia': False}}
show_hsrp_detail_output_incomplete = {'GigabitEthernet0/0/0/0': {'address_family': {'ipv4': {'version': {1: {'groups': {0: {'active_ip_address': 'unknown', 'active_router': 'unknown', 'bfd': {'address': '10.1.1.1', 'interface_name': 'GigabitEthernet0/0/0/1', 'state': 'inactive'}, 'group_number': 0, 'hsrp_router_state': 'init', 'preempt': True, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'stored', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': 'never', 'num_state_changes': 0}, 'virtual_mac_address': '0000.0c07.ac00'}, 10: {'active_ip_address': 'local', 'active_priority': 63, 'active_router': 'local', 'authentication': 'cisco123', 'group_number': 10, 'hsrp_router_state': 'active', 'num_of_slaves': 1, 'preempt': True, 'primary_ipv4_address': {'address': '10.1.1.254'}, 'priority': 63, 'session_name': 'group10', 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:36:53', 'num_state_changes': 4}, 'timers': {'cfgd_hello_msec': 10000, 'cfgd_hold_msec': 30000, 'hello_msec': 10000, 'hello_msec_flag': True, 'hold_msec': 30000, 'hold_msec_flag': True}, 'tracked_interfaces': {'GigabitEthernet0/0/0/1': {'interface_name': 'GigabitEthernet0/0/0/1', 'priority_decrement': 123}}, 'tracked_objects': {'1': {'object_name': '1', 'priority_decrement': 25}, 'num_tracked_objects': 2, 'num_tracked_objects_up': 1}, 'virtual_mac_address': '0000.0c07.ac0a'}, 20: {'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 20, 'hsrp_router_state': 'active', 'primary_ipv4_address': {'address': '10.1.1.128'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:52', 'num_state_changes': 4}, 'timers': {'cfgd_hello_msec': 111, 'cfgd_hold_msec': 333, 'hello_msec': 111, 'hello_msec_flag': True, 'hold_msec': 333, 'hold_msec_flag': True}, 'tracked_interfaces': {'GigabitEthernet0/0/0/1': {'interface_name': 'GigabitEthernet0/0/0/1', 'priority_decrement': 251}}, 'tracked_objects': {'num_tracked_objects': 1, 'num_tracked_objects_up': 1}, 'virtual_mac_address': '0000.0c07.ac14'}}, 'slave_groups': {30: {'follow': 'group10', 'group_number': 30, 'hsrp_router_state': 'init', 'primary_ipv4_address': {'address': 'unknown'}, 'priority': 100, 'standby_state': 'stored', 'virtual_mac_address': '0000.0c07.ac1e'}}}}}, 'ipv6': {'version': {2: {'groups': {10: {'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 10, 'hsrp_router_state': 'active', 'link_local_ipv6_address': {'address': 'fe80::205:73ff:fea0:a'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:18', 'num_state_changes': 4}, 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0005.73a0.000a'}, 20: {'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 20, 'hsrp_router_state': 'active', 'link_local_ipv6_address': {'address': 'fe80::205:73ff:fea0:14'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:18', 'num_state_changes': 4}, 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0005.73a0.0014'}, 30: {'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 30, 'hsrp_router_state': 'active', 'link_local_ipv6_address': {'address': 'fe80::205:73ff:fea0:1e'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:18', 'num_state_changes': 4}, 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0005.73a0.001e'}}}}}}, 'bfd': {'detection_multiplier': 3, 'enabled': True, 'interval': 15}, 'delay': {'minimum_delay': 100, 'reload_delay': 1000}, 'interface': 'GigabitEthernet0/0/0/0', 'redirects_disable': True, 'use_bia': False}}
show_hsrp_summary_output = {'address_family': {'ipv4': {'intf_down': 0, 'intf_total': 1, 'intf_up': 1, 'state': {'ACTIVE': {'sessions': 2, 'slaves': 0, 'total': 2}, 'ALL': {'sessions': 3, 'slaves': 1, 'total': 4}, 'INIT': {'sessions': 1, 'slaves': 1, 'total': 2}, 'LEARN': {'sessions': 0, 'slaves': 0, 'total': 0}, 'LISTEN': {'sessions': 0, 'slaves': 0, 'total': 0}, 'SPEAK': {'sessions': 0, 'slaves': 0, 'total': 0}, 'STANDBY': {'sessions': 0, 'slaves': 0, 'total': 0}}, 'virtual_addresses_active': 3, 'virtual_addresses_inactive': 0, 'vritual_addresses_total': 3}, 'ipv6': {'intf_down': 0, 'intf_total': 1, 'intf_up': 1, 'state': {'ACTIVE': {'sessions': 3, 'slaves': 0, 'total': 3}, 'ALL': {'sessions': 3, 'slaves': 0, 'total': 3}, 'INIT': {'sessions': 0, 'slaves': 0, 'total': 0}, 'LEARN': {'sessions': 0, 'slaves': 0, 'total': 0}, 'LISTEN': {'sessions': 0, 'slaves': 0, 'total': 0}, 'SPEAK': {'sessions': 0, 'slaves': 0, 'total': 0}, 'STANDBY': {'sessions': 0, 'slaves': 0, 'total': 0}}, 'virtual_addresses_active': 5, 'virtual_addresses_inactive': 0, 'vritual_addresses_total': 5}}, 'bfd_sessions_down': 0, 'bfd_sessions_inactive': 1, 'bfd_sessions_up': 0, 'num_bfd_sessions': 1, 'num_tracked_objects': 2, 'tracked_objects_down': 1, 'tracked_objects_up': 1}
hsrp_ops_output = {'GigabitEthernet0/0/0/0': {'address_family': {'ipv4': {'version': {1: {'groups': {0: {'active_ip_address': 'unknown', 'active_router': 'unknown', 'bfd': {'address': '10.1.1.1', 'interface_name': 'GigabitEthernet0/0/0/1'}, 'group_number': 0, 'hsrp_router_state': 'init', 'preempt': True, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0000.0c07.ac00'}, 10: {'active_ip_address': 'local', 'active_router': 'local', 'authentication': 'cisco123', 'group_number': 10, 'hsrp_router_state': 'active', 'preempt': True, 'primary_ipv4_address': {'address': '10.1.1.254'}, 'priority': 63, 'session_name': 'group10', 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'timers': {'hello_msec': 10000, 'hello_msec_flag': True, 'hold_msec': 30000, 'hold_msec_flag': True}, 'tracked_interfaces': {'GigabitEthernet0/0/0/1': {'interface_name': 'GigabitEthernet0/0/0/1', 'priority_decrement': 123}}, 'tracked_objects': {'1': {'object_name': '1', 'priority_decrement': 25}}, 'virtual_mac_address': '0000.0c07.ac0a'}, 20: {'active_ip_address': 'local', 'active_router': 'local', 'group_number': 20, 'hsrp_router_state': 'active', 'primary_ipv4_address': {'address': '10.1.1.128'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'timers': {'hello_msec': 111, 'hello_msec_flag': True, 'hold_msec': 333, 'hold_msec_flag': True}, 'tracked_interfaces': {'GigabitEthernet0/0/0/1': {'interface_name': 'GigabitEthernet0/0/0/1', 'priority_decrement': 251}}, 'virtual_mac_address': '0000.0c07.ac14'}}, 'slave_groups': {30: {'follow': 'group10', 'primary_ipv4_address': {'address': 'unknown'}, 'virtual_mac_address': '0000.0c07.ac1e'}}}}}, 'ipv6': {'version': {2: {'groups': {10: {'active_ip_address': 'local', 'active_router': 'local', 'group_number': 10, 'hsrp_router_state': 'active', 'link_local_ipv6_address': {'address': 'fe80::205:73ff:fea0:a'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0005.73a0.000a'}, 20: {'active_ip_address': 'local', 'active_router': 'local', 'group_number': 20, 'hsrp_router_state': 'active', 'link_local_ipv6_address': {'address': 'fe80::205:73ff:fea0:14'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0005.73a0.0014'}, 30: {'active_ip_address': 'local', 'active_router': 'local', 'group_number': 30, 'hsrp_router_state': 'active', 'link_local_ipv6_address': {'address': 'fe80::205:73ff:fea0:1e'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0005.73a0.001e'}}}}}}, 'bfd': {'detection_multiplier': 3, 'enabled': True, 'interval': 15}, 'delay': {'minimum_delay': 100, 'reload_delay': 1000}, 'interface': 'GigabitEthernet0/0/0/0', 'redirects_disable': True, 'use_bia': False}} |
k=[]
for i in range(3):
#while True:
try:
a=input()
except:
break
k.append(a)
check = [True for i in range(len(k))]
check_three = False
three_s=(-1,-1)
three_e=(-1,-1)
remove_list = []
for num,i in enumerate(k):
for j in range(len(i)):
if j+2 <len(i):
if not check_three and (i[j],i[j+1],i[j+2]) == ('`','`','`'):
three_s=(num,j)
check_three=True
elif check_three and (i[j],i[j+1],i[j+2]) == ('`','`','`'):
three_e=(num,j+2)
remove_list.append((three_s,three_e))
three_s=(-1,-1)
three_e=(-1,-1)
check_three=False
print(remove_list)
| k = []
for i in range(3):
try:
a = input()
except:
break
k.append(a)
check = [True for i in range(len(k))]
check_three = False
three_s = (-1, -1)
three_e = (-1, -1)
remove_list = []
for (num, i) in enumerate(k):
for j in range(len(i)):
if j + 2 < len(i):
if not check_three and (i[j], i[j + 1], i[j + 2]) == ('`', '`', '`'):
three_s = (num, j)
check_three = True
elif check_three and (i[j], i[j + 1], i[j + 2]) == ('`', '`', '`'):
three_e = (num, j + 2)
remove_list.append((three_s, three_e))
three_s = (-1, -1)
three_e = (-1, -1)
check_three = False
print(remove_list) |
#
# Device Database and registry
#
# Need to be adapted to your local devices.
# And these are just default values, not my ones... :)
mqtt_ip = "192.168.178.10"
mqtt_port = 1883
influxdb_ip = "192.168.178.12"
influxdb_user = "myuser"
influxdb_pw = "mypw"
influxdb_db = "mydb"
fritz_ip = "192.168.17.1"
fritz_user = "fritzuser"
fritz_pw = "fritzpasswd"
fritz_evswitch = "11234 0134134"
gen24_ip = "192.168.178.13"
ipump_ip = "192.168.178.14"
| mqtt_ip = '192.168.178.10'
mqtt_port = 1883
influxdb_ip = '192.168.178.12'
influxdb_user = 'myuser'
influxdb_pw = 'mypw'
influxdb_db = 'mydb'
fritz_ip = '192.168.17.1'
fritz_user = 'fritzuser'
fritz_pw = 'fritzpasswd'
fritz_evswitch = '11234 0134134'
gen24_ip = '192.168.178.13'
ipump_ip = '192.168.178.14' |
def react_chat_red(eventType, GPIO):
RED_LED = 'P8_8'
if len(eventType) != 0:
if eventType[0] == "on":
GPIO.output(RED_LED, GPIO.HIGH)
elif eventType[0] == "off":
GPIO.output(RED_LED, GPIO.LOW)
elif eventType[0] == "toggle":
state = GPIO.input(RED_LED)
if state == 1:
GPIO.output(RED_LED, GPIO.LOW)
elif state == 0:
GPIO.output(RED_LED, GPIO.HIGH)
| def react_chat_red(eventType, GPIO):
red_led = 'P8_8'
if len(eventType) != 0:
if eventType[0] == 'on':
GPIO.output(RED_LED, GPIO.HIGH)
elif eventType[0] == 'off':
GPIO.output(RED_LED, GPIO.LOW)
elif eventType[0] == 'toggle':
state = GPIO.input(RED_LED)
if state == 1:
GPIO.output(RED_LED, GPIO.LOW)
elif state == 0:
GPIO.output(RED_LED, GPIO.HIGH) |
#%%
def numDistinctIslands(grid):
cnt_row, cnt_col = len(grid), len(grid[0])
def dfs(index_row, index_col, dir):
if (
index_row < 0
or index_row >= cnt_row
or index_col < 0
or index_col >= cnt_col
or not grid[index_row][index_col]
):
return ""
grid[index_row][index_col] = 0
return (
dir
+ dfs(index_row + 1, index_col, "1")
+ dfs(index_row - 1, index_col, "2")
+ dfs(index_row, index_col + 1, "3")
+ dfs(index_row, index_col - 1, "4")
+ "-"
+ dir
)
island_set = set()
for index_row in range(cnt_row):
for index_col in range(cnt_col):
if grid[index_row][index_col]:
island_set.add(dfs(index_row, index_col, "*"))
print(island_set)
return len(island_set)
grid = [[1, 1, 0, 1, 1], [1, 0, 0, 0, 0], [0, 0, 0, 0, 1], [1, 1, 0, 1, 1]]
print(numDistinctIslands(grid))
# %%
| def num_distinct_islands(grid):
(cnt_row, cnt_col) = (len(grid), len(grid[0]))
def dfs(index_row, index_col, dir):
if index_row < 0 or index_row >= cnt_row or index_col < 0 or (index_col >= cnt_col) or (not grid[index_row][index_col]):
return ''
grid[index_row][index_col] = 0
return dir + dfs(index_row + 1, index_col, '1') + dfs(index_row - 1, index_col, '2') + dfs(index_row, index_col + 1, '3') + dfs(index_row, index_col - 1, '4') + '-' + dir
island_set = set()
for index_row in range(cnt_row):
for index_col in range(cnt_col):
if grid[index_row][index_col]:
island_set.add(dfs(index_row, index_col, '*'))
print(island_set)
return len(island_set)
grid = [[1, 1, 0, 1, 1], [1, 0, 0, 0, 0], [0, 0, 0, 0, 1], [1, 1, 0, 1, 1]]
print(num_distinct_islands(grid)) |
with open('input') as f:
data = f.read().strip().split('\n')
initial = {(j, i, 0, 0) for i, s in enumerate(data) for j, c in enumerate(s) if c=='#'}
def fence(s):
min_x = min(s, key=lambda x: x[0])[0]
min_y = min(s, key=lambda x: x[1])[1]
min_z = min(s, key=lambda x: x[2])[2]
min_w = min(s, key=lambda x: x[3])[3]
max_x = max(s, key=lambda x: x[0])[0]
max_y = max(s, key=lambda x: x[1])[1]
max_z = max(s, key=lambda x: x[2])[2]
max_w = max(s, key=lambda x: x[3])[3]
return (min_x-1, max_x+2), (min_y-1, max_y+2), (min_z-1, max_z+2), (min_w-1, max_w+2)
def neighbours(s, x, y, z, w):
n=0
for _x in range(x-1, x+2):
for _y in range(y-1, y+2):
for _z in range(z-1, z+2):
for _w in range(w-1, w+2):
if not (_x==x and _y==y and _z==z and _w==w):
if (_x, _y, _z, _w) in s:
n+=1
return n
for _ in range(6):
new = set()
r_x, r_y, r_z, r_w = fence(initial)
for x in range(*r_x):
for y in range(*r_y):
for z in range(*r_z):
for w in range(*r_w):
n = neighbours(initial, x, y, z, w)
if (x,y,z, w) in initial:
if n==2 or n==3:
new.add((x,y,z,w))
else:
if n==3:
new.add((x,y,z,w))
initial = new
print(len(initial))
print('done')
| with open('input') as f:
data = f.read().strip().split('\n')
initial = {(j, i, 0, 0) for (i, s) in enumerate(data) for (j, c) in enumerate(s) if c == '#'}
def fence(s):
min_x = min(s, key=lambda x: x[0])[0]
min_y = min(s, key=lambda x: x[1])[1]
min_z = min(s, key=lambda x: x[2])[2]
min_w = min(s, key=lambda x: x[3])[3]
max_x = max(s, key=lambda x: x[0])[0]
max_y = max(s, key=lambda x: x[1])[1]
max_z = max(s, key=lambda x: x[2])[2]
max_w = max(s, key=lambda x: x[3])[3]
return ((min_x - 1, max_x + 2), (min_y - 1, max_y + 2), (min_z - 1, max_z + 2), (min_w - 1, max_w + 2))
def neighbours(s, x, y, z, w):
n = 0
for _x in range(x - 1, x + 2):
for _y in range(y - 1, y + 2):
for _z in range(z - 1, z + 2):
for _w in range(w - 1, w + 2):
if not (_x == x and _y == y and (_z == z) and (_w == w)):
if (_x, _y, _z, _w) in s:
n += 1
return n
for _ in range(6):
new = set()
(r_x, r_y, r_z, r_w) = fence(initial)
for x in range(*r_x):
for y in range(*r_y):
for z in range(*r_z):
for w in range(*r_w):
n = neighbours(initial, x, y, z, w)
if (x, y, z, w) in initial:
if n == 2 or n == 3:
new.add((x, y, z, w))
elif n == 3:
new.add((x, y, z, w))
initial = new
print(len(initial))
print('done') |
# import time
# #Indroduction to the game
# print("Hello there \nWelcome to TIC-TAC-TOE")
# time.sleep(1)
# #list of numbers
# num_list = [1,2,3,4,5,6,7,8,9]
# print(num_list)
# #Request for tutorial
# def tutorial():
# tutorial_list = ["=>This game is restricted to 2 players only",
# "=>There are two characters used to play this game 'X' and 'O'",
# "=>Whoever chooses 'X' would go first",
# "=>A board would be printed out every time a player makes a move",
# "=>Numbers 1-9 would be used to determine postions on the board",
# "=>The first player to get '3' of their characters to either horizontally, vertically or diagonally WINS!",
# "=>Goodluck and REMEMBER TO HAVE FUN"]
# for item in tutorial_list:
# print(item)
# time.sleep(5)
# #countdown to begin game
# def countdown():
# t = 3
# while t > 0:
# print(t)
# time.sleep(1)
# t -=1
# return "Lets Go!!!"
# def begin_game():
# start = 'no'
# if start == 'y':
# print(countdown())
# elif start == 'n':
# print('Closing Game')
# while start != 'y' or start !='n':
# start = input("Begin Game?(y/n)")
# start = start.lower()
boardlist = [" " for i in range(10)]
boardlist[0] = "nil"
def board(boardlist):
print(f"\n {boardlist[1]} | {boardlist[2]} | {boardlist[3]} ")
print("-----|-----|-----")
print(f" {boardlist[4]} | {boardlist[5]} | {boardlist[6]} ")
print("-----|-----|-----")
print(f" {boardlist[7]} | {boardlist[8]} | {boardlist[9]} ")
def insertLetter(pos, letter):
board[pos] = letter
def freeSpace(pos):
return boardlist[pos] == " "
def isBoardFull():
return " " not in boardlist
def playerMove():
a = True
while a:
position = input("Enter the position to place an 'X' (1-9): ")
try:
position = int(position)
if position in range(1,10):
if freeSpace(position):
insertLetter(position, 'X')
a = False
else:
print("Sorry, this spot is occupied!")
else:
print("Enter a number between 1-9!")
except:
print("Enter a number!")
def computerMove():
possiblePositions = []
for i, letter in enumerate(boardlist):
if letter == " ":
possiblePositions.append(i)
moves = ['X', 'O']
for _ in moves:
for i in possiblePositions:
sampleBoard = boardlist[:]
sampleBoard[i] = _
if checkWin(sampleBoard, _):
move = i
return move
# function to check who won the game
def checkWin(bod, let):
return (bod[1] == let and bod[2] == let and bod[3] == let) or (bod[4] == let and bod[5] == let and bod[6] == let) or (bod[7] == let and bod[8] == let and bod[9] == let) or (bod[1] == let and bod[4] == let and bod[7] == let) or (bod[2] == let and bod[5] == let and bod[8] == let) or (bod[3] == let and bod[6] == let and bod[9] == let) or (bod[1] == let and bod[5] == let and bod[9] == let) or (bod[3] == let and bod[5] == let and bod[7] == let)
def m():
game = 3
charCount = 1
while game > 0:
if charCount % 2 == 0:
char = 'O'
else:
char = 'X'
print(char)
charCount += 1
game -= 1
def preset():
new = 'none'
new = new.lower()
while new != 'y':
new = input('Do you wish to go through the tutorial?(y/n): ')
return tutorial()
print(begin_game())
def main():
board()
while not isBoardFull():
if checkWin(boardlist, 'X'):
print("X won!")
break
else:
computerMove()
board()
if checkWin(boardlist, 'O'):
print("O won!")
break
else:
playerMove()
board()
else:
print("Tie game")
#function to print the score board
def scoreboard(score_board):
print("------------------------------")
print(" SCOREBOARD ")
print("------------------------------")
players = [score_board.keys()]
for i in range(2):
print(f" {players[i]}, {score_board[players[i]]}")
print("------------------------------")
| boardlist = [' ' for i in range(10)]
boardlist[0] = 'nil'
def board(boardlist):
print(f'\n {boardlist[1]} | {boardlist[2]} | {boardlist[3]} ')
print('-----|-----|-----')
print(f' {boardlist[4]} | {boardlist[5]} | {boardlist[6]} ')
print('-----|-----|-----')
print(f' {boardlist[7]} | {boardlist[8]} | {boardlist[9]} ')
def insert_letter(pos, letter):
board[pos] = letter
def free_space(pos):
return boardlist[pos] == ' '
def is_board_full():
return ' ' not in boardlist
def player_move():
a = True
while a:
position = input("Enter the position to place an 'X' (1-9): ")
try:
position = int(position)
if position in range(1, 10):
if free_space(position):
insert_letter(position, 'X')
a = False
else:
print('Sorry, this spot is occupied!')
else:
print('Enter a number between 1-9!')
except:
print('Enter a number!')
def computer_move():
possible_positions = []
for (i, letter) in enumerate(boardlist):
if letter == ' ':
possiblePositions.append(i)
moves = ['X', 'O']
for _ in moves:
for i in possiblePositions:
sample_board = boardlist[:]
sampleBoard[i] = _
if check_win(sampleBoard, _):
move = i
return move
def check_win(bod, let):
return bod[1] == let and bod[2] == let and (bod[3] == let) or (bod[4] == let and bod[5] == let and (bod[6] == let)) or (bod[7] == let and bod[8] == let and (bod[9] == let)) or (bod[1] == let and bod[4] == let and (bod[7] == let)) or (bod[2] == let and bod[5] == let and (bod[8] == let)) or (bod[3] == let and bod[6] == let and (bod[9] == let)) or (bod[1] == let and bod[5] == let and (bod[9] == let)) or (bod[3] == let and bod[5] == let and (bod[7] == let))
def m():
game = 3
char_count = 1
while game > 0:
if charCount % 2 == 0:
char = 'O'
else:
char = 'X'
print(char)
char_count += 1
game -= 1
def preset():
new = 'none'
new = new.lower()
while new != 'y':
new = input('Do you wish to go through the tutorial?(y/n): ')
return tutorial()
print(begin_game())
def main():
board()
while not is_board_full():
if check_win(boardlist, 'X'):
print('X won!')
break
else:
computer_move()
board()
if check_win(boardlist, 'O'):
print('O won!')
break
else:
player_move()
board()
else:
print('Tie game')
def scoreboard(score_board):
print('------------------------------')
print(' SCOREBOARD ')
print('------------------------------')
players = [score_board.keys()]
for i in range(2):
print(f' {players[i]}, {score_board[players[i]]}')
print('------------------------------') |
#
# PySNMP MIB module HH3C-MIRRORGROUP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HH3C-MIRRORGROUP-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:15:33 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, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, SingleValueConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint", "SingleValueConstraint", "ConstraintsUnion")
hh3cCommon, = mibBuilder.importSymbols("HH3C-OID-MIB", "hh3cCommon")
ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup")
MibIdentifier, ObjectIdentity, ModuleIdentity, NotificationType, TimeTicks, iso, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter32, Bits, Unsigned32, IpAddress, Integer32, Gauge32, Counter64 = mibBuilder.importSymbols("SNMPv2-SMI", "MibIdentifier", "ObjectIdentity", "ModuleIdentity", "NotificationType", "TimeTicks", "iso", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter32", "Bits", "Unsigned32", "IpAddress", "Integer32", "Gauge32", "Counter64")
RowStatus, TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "RowStatus", "TextualConvention", "DisplayString")
hh3cMirrGroup = ModuleIdentity((1, 3, 6, 1, 4, 1, 25506, 2, 68))
hh3cMirrGroup.setRevisions(('2006-01-10 19:03',))
if mibBuilder.loadTexts: hh3cMirrGroup.setLastUpdated('200601131403Z')
if mibBuilder.loadTexts: hh3cMirrGroup.setOrganization('Hangzhou H3C Tech. Co., Ltd.')
hh3cMGInfoObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1))
hh3cMGObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1))
hh3cMGTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1), )
if mibBuilder.loadTexts: hh3cMGTable.setStatus('current')
hh3cMGEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1), ).setIndexNames((0, "HH3C-MIRRORGROUP-MIB", "hh3cMGID"))
if mibBuilder.loadTexts: hh3cMGEntry.setStatus('current')
hh3cMGID = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1, 1), Integer32())
if mibBuilder.loadTexts: hh3cMGID.setStatus('current')
hh3cMGType = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("local", 1), ("remoteSource", 2), ("remoteDestination", 3)))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: hh3cMGType.setStatus('current')
hh3cMGStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("active", 1), ("inactive", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: hh3cMGStatus.setStatus('current')
hh3cMGRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1, 4), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: hh3cMGRowStatus.setStatus('current')
hh3cMGMirrorIfObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2))
hh3cMGMirrorIfTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1), )
if mibBuilder.loadTexts: hh3cMGMirrorIfTable.setStatus('current')
hh3cMGMirrorIfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1, 1), ).setIndexNames((0, "HH3C-MIRRORGROUP-MIB", "hh3cMGID"), (0, "HH3C-MIRRORGROUP-MIB", "hh3cMGMirrorIfIndex"), (0, "HH3C-MIRRORGROUP-MIB", "hh3cMGMirrorDirection"))
if mibBuilder.loadTexts: hh3cMGMirrorIfEntry.setStatus('current')
hh3cMGMirrorIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1, 1, 1), Integer32())
if mibBuilder.loadTexts: hh3cMGMirrorIfIndex.setStatus('current')
hh3cMGMirrorDirection = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("inbound", 1), ("outbound", 2), ("both", 3))))
if mibBuilder.loadTexts: hh3cMGMirrorDirection.setStatus('current')
hh3cMGMirrorRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1, 1, 3), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: hh3cMGMirrorRowStatus.setStatus('current')
hh3cMGMonitorIfObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3))
hh3cMGMonitorIfTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3, 1), )
if mibBuilder.loadTexts: hh3cMGMonitorIfTable.setStatus('current')
hh3cMGMonitorIfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3, 1, 1), ).setIndexNames((0, "HH3C-MIRRORGROUP-MIB", "hh3cMGID"), (0, "HH3C-MIRRORGROUP-MIB", "hh3cMGMonitorIfIndex"))
if mibBuilder.loadTexts: hh3cMGMonitorIfEntry.setStatus('current')
hh3cMGMonitorIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3, 1, 1, 1), Integer32())
if mibBuilder.loadTexts: hh3cMGMonitorIfIndex.setStatus('current')
hh3cMGMonitorRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3, 1, 1, 2), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: hh3cMGMonitorRowStatus.setStatus('current')
hh3cMGReflectorIfObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4))
hh3cMGReflectorIfTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4, 1), )
if mibBuilder.loadTexts: hh3cMGReflectorIfTable.setStatus('current')
hh3cMGReflectorIfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4, 1, 1), ).setIndexNames((0, "HH3C-MIRRORGROUP-MIB", "hh3cMGID"), (0, "HH3C-MIRRORGROUP-MIB", "hh3cMGReflectorIfIndex"))
if mibBuilder.loadTexts: hh3cMGReflectorIfEntry.setStatus('current')
hh3cMGReflectorIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4, 1, 1, 1), Integer32())
if mibBuilder.loadTexts: hh3cMGReflectorIfIndex.setStatus('current')
hh3cMGReflectorRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4, 1, 1, 2), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: hh3cMGReflectorRowStatus.setStatus('current')
hh3cMGRprobeVlanObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5))
hh3cMGRprobeVlanTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5, 1), )
if mibBuilder.loadTexts: hh3cMGRprobeVlanTable.setStatus('current')
hh3cMGRprobeVlanEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5, 1, 1), ).setIndexNames((0, "HH3C-MIRRORGROUP-MIB", "hh3cMGID"), (0, "HH3C-MIRRORGROUP-MIB", "hh3cMGRprobeVlanID"))
if mibBuilder.loadTexts: hh3cMGRprobeVlanEntry.setStatus('current')
hh3cMGRprobeVlanID = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 4094)))
if mibBuilder.loadTexts: hh3cMGRprobeVlanID.setStatus('current')
hh3cMGRprobeVlanRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5, 1, 1, 2), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: hh3cMGRprobeVlanRowStatus.setStatus('current')
mibBuilder.exportSymbols("HH3C-MIRRORGROUP-MIB", hh3cMGMonitorRowStatus=hh3cMGMonitorRowStatus, hh3cMGRprobeVlanObjects=hh3cMGRprobeVlanObjects, hh3cMGMirrorRowStatus=hh3cMGMirrorRowStatus, hh3cMGRowStatus=hh3cMGRowStatus, hh3cMGObjects=hh3cMGObjects, hh3cMGMonitorIfIndex=hh3cMGMonitorIfIndex, hh3cMGRprobeVlanEntry=hh3cMGRprobeVlanEntry, hh3cMGMonitorIfObjects=hh3cMGMonitorIfObjects, hh3cMGReflectorIfTable=hh3cMGReflectorIfTable, hh3cMGReflectorIfObjects=hh3cMGReflectorIfObjects, hh3cMGMirrorIfTable=hh3cMGMirrorIfTable, hh3cMGReflectorIfIndex=hh3cMGReflectorIfIndex, hh3cMGRprobeVlanTable=hh3cMGRprobeVlanTable, hh3cMGRprobeVlanRowStatus=hh3cMGRprobeVlanRowStatus, hh3cMGMonitorIfEntry=hh3cMGMonitorIfEntry, hh3cMirrGroup=hh3cMirrGroup, hh3cMGMirrorIfIndex=hh3cMGMirrorIfIndex, hh3cMGMirrorIfEntry=hh3cMGMirrorIfEntry, PYSNMP_MODULE_ID=hh3cMirrGroup, hh3cMGID=hh3cMGID, hh3cMGInfoObjects=hh3cMGInfoObjects, hh3cMGTable=hh3cMGTable, hh3cMGMirrorIfObjects=hh3cMGMirrorIfObjects, hh3cMGReflectorIfEntry=hh3cMGReflectorIfEntry, hh3cMGReflectorRowStatus=hh3cMGReflectorRowStatus, hh3cMGType=hh3cMGType, hh3cMGStatus=hh3cMGStatus, hh3cMGEntry=hh3cMGEntry, hh3cMGMonitorIfTable=hh3cMGMonitorIfTable, hh3cMGMirrorDirection=hh3cMGMirrorDirection, hh3cMGRprobeVlanID=hh3cMGRprobeVlanID)
| (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_size_constraint, value_range_constraint, single_value_constraint, constraints_union) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsIntersection', 'ValueSizeConstraint', 'ValueRangeConstraint', 'SingleValueConstraint', 'ConstraintsUnion')
(hh3c_common,) = mibBuilder.importSymbols('HH3C-OID-MIB', 'hh3cCommon')
(module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup')
(mib_identifier, object_identity, module_identity, notification_type, time_ticks, iso, mib_scalar, mib_table, mib_table_row, mib_table_column, counter32, bits, unsigned32, ip_address, integer32, gauge32, counter64) = mibBuilder.importSymbols('SNMPv2-SMI', 'MibIdentifier', 'ObjectIdentity', 'ModuleIdentity', 'NotificationType', 'TimeTicks', 'iso', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Counter32', 'Bits', 'Unsigned32', 'IpAddress', 'Integer32', 'Gauge32', 'Counter64')
(row_status, textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'RowStatus', 'TextualConvention', 'DisplayString')
hh3c_mirr_group = module_identity((1, 3, 6, 1, 4, 1, 25506, 2, 68))
hh3cMirrGroup.setRevisions(('2006-01-10 19:03',))
if mibBuilder.loadTexts:
hh3cMirrGroup.setLastUpdated('200601131403Z')
if mibBuilder.loadTexts:
hh3cMirrGroup.setOrganization('Hangzhou H3C Tech. Co., Ltd.')
hh3c_mg_info_objects = mib_identifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1))
hh3c_mg_objects = mib_identifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1))
hh3c_mg_table = mib_table((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1))
if mibBuilder.loadTexts:
hh3cMGTable.setStatus('current')
hh3c_mg_entry = mib_table_row((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1)).setIndexNames((0, 'HH3C-MIRRORGROUP-MIB', 'hh3cMGID'))
if mibBuilder.loadTexts:
hh3cMGEntry.setStatus('current')
hh3c_mgid = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1, 1), integer32())
if mibBuilder.loadTexts:
hh3cMGID.setStatus('current')
hh3c_mg_type = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('local', 1), ('remoteSource', 2), ('remoteDestination', 3)))).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
hh3cMGType.setStatus('current')
hh3c_mg_status = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('active', 1), ('inactive', 2)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
hh3cMGStatus.setStatus('current')
hh3c_mg_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1, 4), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
hh3cMGRowStatus.setStatus('current')
hh3c_mg_mirror_if_objects = mib_identifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2))
hh3c_mg_mirror_if_table = mib_table((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1))
if mibBuilder.loadTexts:
hh3cMGMirrorIfTable.setStatus('current')
hh3c_mg_mirror_if_entry = mib_table_row((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1, 1)).setIndexNames((0, 'HH3C-MIRRORGROUP-MIB', 'hh3cMGID'), (0, 'HH3C-MIRRORGROUP-MIB', 'hh3cMGMirrorIfIndex'), (0, 'HH3C-MIRRORGROUP-MIB', 'hh3cMGMirrorDirection'))
if mibBuilder.loadTexts:
hh3cMGMirrorIfEntry.setStatus('current')
hh3c_mg_mirror_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1, 1, 1), integer32())
if mibBuilder.loadTexts:
hh3cMGMirrorIfIndex.setStatus('current')
hh3c_mg_mirror_direction = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('inbound', 1), ('outbound', 2), ('both', 3))))
if mibBuilder.loadTexts:
hh3cMGMirrorDirection.setStatus('current')
hh3c_mg_mirror_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1, 1, 3), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
hh3cMGMirrorRowStatus.setStatus('current')
hh3c_mg_monitor_if_objects = mib_identifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3))
hh3c_mg_monitor_if_table = mib_table((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3, 1))
if mibBuilder.loadTexts:
hh3cMGMonitorIfTable.setStatus('current')
hh3c_mg_monitor_if_entry = mib_table_row((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3, 1, 1)).setIndexNames((0, 'HH3C-MIRRORGROUP-MIB', 'hh3cMGID'), (0, 'HH3C-MIRRORGROUP-MIB', 'hh3cMGMonitorIfIndex'))
if mibBuilder.loadTexts:
hh3cMGMonitorIfEntry.setStatus('current')
hh3c_mg_monitor_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3, 1, 1, 1), integer32())
if mibBuilder.loadTexts:
hh3cMGMonitorIfIndex.setStatus('current')
hh3c_mg_monitor_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3, 1, 1, 2), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
hh3cMGMonitorRowStatus.setStatus('current')
hh3c_mg_reflector_if_objects = mib_identifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4))
hh3c_mg_reflector_if_table = mib_table((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4, 1))
if mibBuilder.loadTexts:
hh3cMGReflectorIfTable.setStatus('current')
hh3c_mg_reflector_if_entry = mib_table_row((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4, 1, 1)).setIndexNames((0, 'HH3C-MIRRORGROUP-MIB', 'hh3cMGID'), (0, 'HH3C-MIRRORGROUP-MIB', 'hh3cMGReflectorIfIndex'))
if mibBuilder.loadTexts:
hh3cMGReflectorIfEntry.setStatus('current')
hh3c_mg_reflector_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4, 1, 1, 1), integer32())
if mibBuilder.loadTexts:
hh3cMGReflectorIfIndex.setStatus('current')
hh3c_mg_reflector_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4, 1, 1, 2), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
hh3cMGReflectorRowStatus.setStatus('current')
hh3c_mg_rprobe_vlan_objects = mib_identifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5))
hh3c_mg_rprobe_vlan_table = mib_table((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5, 1))
if mibBuilder.loadTexts:
hh3cMGRprobeVlanTable.setStatus('current')
hh3c_mg_rprobe_vlan_entry = mib_table_row((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5, 1, 1)).setIndexNames((0, 'HH3C-MIRRORGROUP-MIB', 'hh3cMGID'), (0, 'HH3C-MIRRORGROUP-MIB', 'hh3cMGRprobeVlanID'))
if mibBuilder.loadTexts:
hh3cMGRprobeVlanEntry.setStatus('current')
hh3c_mg_rprobe_vlan_id = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5, 1, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 4094)))
if mibBuilder.loadTexts:
hh3cMGRprobeVlanID.setStatus('current')
hh3c_mg_rprobe_vlan_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5, 1, 1, 2), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
hh3cMGRprobeVlanRowStatus.setStatus('current')
mibBuilder.exportSymbols('HH3C-MIRRORGROUP-MIB', hh3cMGMonitorRowStatus=hh3cMGMonitorRowStatus, hh3cMGRprobeVlanObjects=hh3cMGRprobeVlanObjects, hh3cMGMirrorRowStatus=hh3cMGMirrorRowStatus, hh3cMGRowStatus=hh3cMGRowStatus, hh3cMGObjects=hh3cMGObjects, hh3cMGMonitorIfIndex=hh3cMGMonitorIfIndex, hh3cMGRprobeVlanEntry=hh3cMGRprobeVlanEntry, hh3cMGMonitorIfObjects=hh3cMGMonitorIfObjects, hh3cMGReflectorIfTable=hh3cMGReflectorIfTable, hh3cMGReflectorIfObjects=hh3cMGReflectorIfObjects, hh3cMGMirrorIfTable=hh3cMGMirrorIfTable, hh3cMGReflectorIfIndex=hh3cMGReflectorIfIndex, hh3cMGRprobeVlanTable=hh3cMGRprobeVlanTable, hh3cMGRprobeVlanRowStatus=hh3cMGRprobeVlanRowStatus, hh3cMGMonitorIfEntry=hh3cMGMonitorIfEntry, hh3cMirrGroup=hh3cMirrGroup, hh3cMGMirrorIfIndex=hh3cMGMirrorIfIndex, hh3cMGMirrorIfEntry=hh3cMGMirrorIfEntry, PYSNMP_MODULE_ID=hh3cMirrGroup, hh3cMGID=hh3cMGID, hh3cMGInfoObjects=hh3cMGInfoObjects, hh3cMGTable=hh3cMGTable, hh3cMGMirrorIfObjects=hh3cMGMirrorIfObjects, hh3cMGReflectorIfEntry=hh3cMGReflectorIfEntry, hh3cMGReflectorRowStatus=hh3cMGReflectorRowStatus, hh3cMGType=hh3cMGType, hh3cMGStatus=hh3cMGStatus, hh3cMGEntry=hh3cMGEntry, hh3cMGMonitorIfTable=hh3cMGMonitorIfTable, hh3cMGMirrorDirection=hh3cMGMirrorDirection, hh3cMGRprobeVlanID=hh3cMGRprobeVlanID) |
# 2020.07.26
# May not have time to do it on 27th, so...
# Problem Statement
# https://leetcode.com/problems/merge-k-sorted-lists/
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
# one by one compare
class Solution:
def mergeKLists(self, lists: List[ListNode]) -> ListNode:
# get rid of empty linked lists
lists = [i for i in lists if i]
# check empty case
if len(lists) == 0: return None
# initialize pointers
list_ptr = []
for list_head in lists:
list_ptr.append(list_head)
answer_ptr = ListNode()
answer_head = ListNode()
first_time = True
# loop until finish going through all the nodes
while len(list_ptr) != 0:
# pick the smallest value and add
smallest = inf
smallest_idx = 0
for i in range(0, len(list_ptr)):
if list_ptr[i] is not None and list_ptr[i].val < smallest:
smallest = list_ptr[i].val
smallest_idx = i
answer_ptr.val = smallest
if first_time:
answer_head = answer_ptr
first_time = False
# move the ptr which points to the smallest value to the next
if list_ptr[smallest_idx].next is not None:
list_ptr[smallest_idx] = list_ptr[smallest_idx].next
# if has been traversed, remove from the list
else:
list_ptr.remove(list_ptr[smallest_idx])
# if all have been traversed
if len(list_ptr) == 0:
return answer_head
else:
# should add other nodes
answer_ptr.next = ListNode()
answer_ptr = answer_ptr.next
# only one list left, can do early return
if len(list_ptr) == 1:
answer_ptr.val = list_ptr[0].val
answer_ptr.next = list_ptr[0].next
return answer_head
return answer_head | class Solution:
def merge_k_lists(self, lists: List[ListNode]) -> ListNode:
lists = [i for i in lists if i]
if len(lists) == 0:
return None
list_ptr = []
for list_head in lists:
list_ptr.append(list_head)
answer_ptr = list_node()
answer_head = list_node()
first_time = True
while len(list_ptr) != 0:
smallest = inf
smallest_idx = 0
for i in range(0, len(list_ptr)):
if list_ptr[i] is not None and list_ptr[i].val < smallest:
smallest = list_ptr[i].val
smallest_idx = i
answer_ptr.val = smallest
if first_time:
answer_head = answer_ptr
first_time = False
if list_ptr[smallest_idx].next is not None:
list_ptr[smallest_idx] = list_ptr[smallest_idx].next
else:
list_ptr.remove(list_ptr[smallest_idx])
if len(list_ptr) == 0:
return answer_head
else:
answer_ptr.next = list_node()
answer_ptr = answer_ptr.next
if len(list_ptr) == 1:
answer_ptr.val = list_ptr[0].val
answer_ptr.next = list_ptr[0].next
return answer_head
return answer_head |
class BalanceResponse(object):
def __init__(self, data):
self.exchangeId = data['exchangeId']
self.currencyId = data['currencyId']
self.availableBalance = data['availableBalance']
self.realizedBalance = data['realizedBalance']
self.currencySymbol = data['currencySymbol']
self.exchangeName = data['exchangeName']
| class Balanceresponse(object):
def __init__(self, data):
self.exchangeId = data['exchangeId']
self.currencyId = data['currencyId']
self.availableBalance = data['availableBalance']
self.realizedBalance = data['realizedBalance']
self.currencySymbol = data['currencySymbol']
self.exchangeName = data['exchangeName'] |
'''
Given a sorted, increasing-order array with unique integer elements,
write an algorithm to create a binary search tree with minimal height.
'''
class myBST():
def __init__(self,key = None, parent = None):
# quick BST structure
self.key = key
self.parent = parent
self.right = None
self.left = None
def insert(self,key):
# insertion to a tree
if self.key == None: # edge case: key of node is None
self.key = key
else:
node = self
if key > node.key:
if node.right: # if there is a right child, recurse right, else create new node
node.right.insert(key)
else:
self.right = self.__class__(key,node)
self.right.key = key
else:
if node.left:
node.left.insert(key)
else:
self.left = self.__class__(key,node)
self.left.key = key
def __str__(self):
"Returns ASCII drawing of the tree"
s = str(self.key)
if (self.left is not None) or (self.right is not None):
ws = len(s)
sl, wl, cl = [''], 0, 0
if self.left is not None:
sl = str(self.left).splitlines()
wl = len(sl[0])
cl = len(sl[0].lstrip(' _'))
sr, wr, cr = [''], 0, 0
if self.right is not None:
sr = str(self.right).splitlines()
wr = len(sr[0])
cr = len(sr[0].rstrip(' _'))
while len(sl) < len(sr):
sl.append(' ' * wl)
while len(sr) < len(sl):
sr.append(' ' * wr)
s = s.rjust(ws + cl, '_').ljust(ws + cl + cr, '_')
s = [s.rjust(ws + wl + cr).ljust(ws + wl + wr)]
s = '\n'.join(s + [l + (' ' * ws) + r for (l,r) in zip(sl, sr)])
return s
def create_minimal_tree(self,arr):
# takes sorted increasing array of unique elements and creates a minimal height tree.
mid = len(arr)//2
self.insert(arr[mid]) # insert middle element
left = [i for i in arr[:mid]]
right = [i for i in arr[mid+1:]]
#print(left,right)
if left: # recurse on the left half of array
self.create_minimal_tree(left)
if right: # recurse on the right half of the array
self.create_minimal_tree(right)
bst = myBST()
a = range(31)
bst.create_minimal_tree(a)
print(bst)
| """
Given a sorted, increasing-order array with unique integer elements,
write an algorithm to create a binary search tree with minimal height.
"""
class Mybst:
def __init__(self, key=None, parent=None):
self.key = key
self.parent = parent
self.right = None
self.left = None
def insert(self, key):
if self.key == None:
self.key = key
else:
node = self
if key > node.key:
if node.right:
node.right.insert(key)
else:
self.right = self.__class__(key, node)
self.right.key = key
elif node.left:
node.left.insert(key)
else:
self.left = self.__class__(key, node)
self.left.key = key
def __str__(self):
"""Returns ASCII drawing of the tree"""
s = str(self.key)
if self.left is not None or self.right is not None:
ws = len(s)
(sl, wl, cl) = ([''], 0, 0)
if self.left is not None:
sl = str(self.left).splitlines()
wl = len(sl[0])
cl = len(sl[0].lstrip(' _'))
(sr, wr, cr) = ([''], 0, 0)
if self.right is not None:
sr = str(self.right).splitlines()
wr = len(sr[0])
cr = len(sr[0].rstrip(' _'))
while len(sl) < len(sr):
sl.append(' ' * wl)
while len(sr) < len(sl):
sr.append(' ' * wr)
s = s.rjust(ws + cl, '_').ljust(ws + cl + cr, '_')
s = [s.rjust(ws + wl + cr).ljust(ws + wl + wr)]
s = '\n'.join(s + [l + ' ' * ws + r for (l, r) in zip(sl, sr)])
return s
def create_minimal_tree(self, arr):
mid = len(arr) // 2
self.insert(arr[mid])
left = [i for i in arr[:mid]]
right = [i for i in arr[mid + 1:]]
if left:
self.create_minimal_tree(left)
if right:
self.create_minimal_tree(right)
bst = my_bst()
a = range(31)
bst.create_minimal_tree(a)
print(bst) |
#! /usr/bin/env python3
# Load maze file into nested array:
with open('../inputs/input25.txt') as fp:
grid = [list(line.strip()) for line in fp.readlines()]
ydim = len(grid)
xdim = len(grid[0])
SYMBOLS = { 'east': '>', 'south': 'v', 'empty': '.'}
# Look up which coords a mover wants to move to
def target_cell(coords, type):
(x, y) = coords
if type == SYMBOLS['east']:
return ((x + 1) % xdim, y)
elif type == SYMBOLS['south']:
return (x, (y + 1) % ydim)
# Prepare the new grid after moving all of one type of symbol
def move_all_facers(grid, type):
# Count how many moved:
moves = 0
# Pre-fill with empties
grid1 = [[SYMBOLS['empty'] for _x in range(xdim)] for _y in range(ydim)]
# Map movers into grid1
for y in range(ydim):
for x in range(xdim):
if grid[y][x] == type:
(tx, ty) = target_cell((x,y), type)
if grid[ty][tx] == SYMBOLS['empty']:
# Make move
grid1[ty][tx] = type
grid1[y][x] = SYMBOLS['empty']
moves += 1
else:
# Stay put
grid1[y][x] = type
# Current movers all changed in grid from symbol to dot, in grid1 from dot to symbol
# Now backfill all non-movers:
for y in range(ydim):
for x in range(xdim):
if grid[y][x] != type and grid1[y][x] != type:
grid1[y][x] = grid[y][x]
return (grid1, moves)
def pgrid(grid):
for row in grid:
print("".join(row))
print("---")
# Do one step, moving all the symbols that have a space to move into
def step(grid):
# East moves first, then South
(grid, east_moves) = move_all_facers(grid, SYMBOLS['east'])
# pgrid(grid)
(grid, south_moves) = move_all_facers(grid, SYMBOLS['south'])
# pgrid(grid)
return (grid, east_moves + south_moves)
# How many steps before grid reaches a settled state?
steps = 0
while 1:
steps += 1
# print("Step {}".format(steps))
(grid, moves) = step(grid)
if moves == 0:
break
print("Part 1:", steps)
| with open('../inputs/input25.txt') as fp:
grid = [list(line.strip()) for line in fp.readlines()]
ydim = len(grid)
xdim = len(grid[0])
symbols = {'east': '>', 'south': 'v', 'empty': '.'}
def target_cell(coords, type):
(x, y) = coords
if type == SYMBOLS['east']:
return ((x + 1) % xdim, y)
elif type == SYMBOLS['south']:
return (x, (y + 1) % ydim)
def move_all_facers(grid, type):
moves = 0
grid1 = [[SYMBOLS['empty'] for _x in range(xdim)] for _y in range(ydim)]
for y in range(ydim):
for x in range(xdim):
if grid[y][x] == type:
(tx, ty) = target_cell((x, y), type)
if grid[ty][tx] == SYMBOLS['empty']:
grid1[ty][tx] = type
grid1[y][x] = SYMBOLS['empty']
moves += 1
else:
grid1[y][x] = type
for y in range(ydim):
for x in range(xdim):
if grid[y][x] != type and grid1[y][x] != type:
grid1[y][x] = grid[y][x]
return (grid1, moves)
def pgrid(grid):
for row in grid:
print(''.join(row))
print('---')
def step(grid):
(grid, east_moves) = move_all_facers(grid, SYMBOLS['east'])
(grid, south_moves) = move_all_facers(grid, SYMBOLS['south'])
return (grid, east_moves + south_moves)
steps = 0
while 1:
steps += 1
(grid, moves) = step(grid)
if moves == 0:
break
print('Part 1:', steps) |
def solve(arr):
n = len(arr)
lis = [1 for _ in range(n)]
for i in range(1, n):
for j in range(0, i):
if arr[j] < arr[i] and lis[i] < 1 + lis[j]:
lis[i] = 1 + lis[j]
return max(lis)
arr = [3, 10, 2, 1, 20]
assert 3 == solve(arr)
arr = [3, 2]
assert 1 == solve(arr)
arr = [50, 3, 10, 7, 40, 80]
assert 4 == solve(arr) | def solve(arr):
n = len(arr)
lis = [1 for _ in range(n)]
for i in range(1, n):
for j in range(0, i):
if arr[j] < arr[i] and lis[i] < 1 + lis[j]:
lis[i] = 1 + lis[j]
return max(lis)
arr = [3, 10, 2, 1, 20]
assert 3 == solve(arr)
arr = [3, 2]
assert 1 == solve(arr)
arr = [50, 3, 10, 7, 40, 80]
assert 4 == solve(arr) |
#pragma error
#pragma repy restrictions.badcallname
pass
| pass |
class TestAnomalyDetector(object):
# Lets make some dummy tests to test our Travis-CI configuration
def test_pass(self):
assert 1 == 1
def nothing(self):
print('This does nothing'); | class Testanomalydetector(object):
def test_pass(self):
assert 1 == 1
def nothing(self):
print('This does nothing') |
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load("@bazel_skylib//lib:paths.bzl", "paths")
load("//ocaml:providers.bzl",
"CompilationModeSettingProvider",
"OcamlProvider",
"OcamlNsResolverProvider",
"OcamlLibraryMarker",
"OcamlModuleMarker",
"OcamlNsMarker")
load("//ppx:providers.bzl",
"PpxCodepsProvider",
)
load(":impl_common.bzl", "dsorder", "module_sep", "resolver_suffix")
load(":impl_ccdeps.bzl", "dump_CcInfo")
# load("//ocaml/_functions:utils.bzl", "get_sdkpath")
## Plain Library targets do not produce anything, they just pass on
## their deps.
## NS Lib targets also do not directly produce anything, they just
## pass on their deps. The real work is done in the transition
## functions, which set the ConfigState that controls build actions of
## deps.
#################
def impl_library(ctx, mode, tool, tool_args):
debug = False
# print("**** NS_LIB {} ****************".format(ctx.label))
# env = {"PATH": get_sdkpath(ctx)}
# tc = ctx.toolchains["@rules_ocaml//ocaml:toolchain"]
# mode = ctx.attr._mode[CompilationModeSettingProvider].value
ns_resolver_depset = None
ns_resolver_module = None
ns_resolver = []
ns_resolver_files = []
the_ns_resolvers = []
# WARNING: due to transition processing, ns_resolver providers
# must be indexed by [0]
if ctx.attr._rule.startswith("ocaml_ns"):
# print("tgt: %s" % ctx.label)
# print("rule: %s" % ctx.attr._rule)
if ctx.attr.resolver:
# print("user-provided resolver")
ns_resolver = ctx.attr.resolver
ns_resolver_module = ctx.file.resolver
ns_name = ctx.attr.ns
else:
# print("generated resolver")
# print("NS RESOLVER FILECT: %s" % len(ctx.files._ns_resolver))
ns_resolver = ctx.attr._ns_resolver[0] # index by int
ns_resolver_module = ctx.files._ns_resolver[0]
# print("ns_resolver: %s" % ns_resolver)
# print("ns_resolver_module: %s" % ns_resolver_module)
if OcamlNsResolverProvider in ns_resolver:
# print("LBL: %s" % ctx.label)
# print("ns_resolver: %s" % ns_resolver[OcamlNsResolverProvider])
if hasattr(ns_resolver[OcamlNsResolverProvider], "ns_name"):
ns_name = ns_resolver[OcamlNsResolverProvider].ns_name
else:
# FIXME: when does this happen?
ns_name = ""
## if ns_resolver ends in __0Resolver, then we know that one
## of the submodules is a user-provided resolver; the
## __0Resolver was just used to compile the submodules. So we
## need to find the user-provided resolver (its name matches
## the ns name), and make all the other submodules depend on
## it.
## pathological case: ns contains a single user-provided
## resolver. in that case we have no aliases so no resolver.
## there would be no point in such an ns but its possible.
if ns_resolver_module:
# print("LBL: %s" % ctx.label)
(ns_resolver_mname, ext) = paths.split_extension(ns_resolver_module.basename)
# print("ns_resolver_mname: %s" % ns_resolver_mname)
if ns_resolver_mname == ns_name + resolver_suffix:
print("Resolver is user-provided")
user_provided_resolver = True
else:
user_provided_resolver = False
else:
user_provided_resolver = False
if user_provided_resolver:
##FIXME: efficiency
for submodule in ctx.files.submodules:
(bname, ext) = paths.split_extension(submodule.basename)
if bname == ns_name:
print("Found user-provided resolver submodule")
the_ns_resolvers.append(submodule)
# else:
if OcamlProvider in ns_resolver: ##ctx.attr._ns_resolver[0]:
# print("ns_resolver provider: %s" % ns_resolver[OcamlProvider])
ns_resolver_files = ns_resolver[OcamlProvider].inputs
ns_resolver_depset = ns_resolver[OcamlProvider].inputs
# the_ns_resolvers.append(ns_resolver_module[0])
# print("ns_resolver_depset: %s" % ns_resolver_depset)
# print("ns_name: %s" % ns_name)
################
## FIXME: does lib need to handle adjunct deps? they're carried by
## modules
indirect_adjunct_depsets = []
indirect_adjunct_path_depsets = []
################
paths_direct = []
# resolver_depsets_list = []
#######################
direct_deps_attr = None
if ctx.attr._rule == "ocaml_ns_archive":
direct_dep_files = ctx.files.submodules
direct_deps_attr = ctx.attr.submodules
elif ctx.attr._rule == "ocaml_ns_library":
direct_dep_files = ctx.files.submodules
direct_deps_attr = ctx.attr.submodules
elif ctx.attr._rule == "ocaml_archive":
direct_dep_files = ctx.files.manifest
direct_deps_attr = ctx.attr.manifest
elif ctx.attr._rule == "ocaml_library":
direct_dep_files = ctx.files.manifest
direct_deps_attr = ctx.attr.manifest
else:
fail("impl_library called by non-aggregator: %s" % ctx.attr._rule)
## FIXME: direct_dep_files (and direct_deps_attr) are in the order
## set by the submodule/modules attribute; they must be put in
## dependency-order.
for f in direct_dep_files:
paths_direct.append(f.dirname)
# if ctx.label.name == "tezos-shell":
# print("LBL: %s" % ctx.label)
# for dep in direct_deps_attr:
# print("DEP: %s" % dep[OcamlProvider].fileset)
#### INDIRECT DEPS first ####
# these are "indirect" from the perspective of the consumer
indirect_fileset_depsets = []
indirect_inputs_depsets = []
indirect_linkargs_depsets = []
indirect_paths_depsets = []
ccInfo_list = []
direct_module_deps_files = ctx.files.submodules if ctx.attr._rule.startswith("ocaml_ns") else ctx.files.manifest
direct_module_deps = ctx.attr.submodules if ctx.attr._rule.startswith("ocaml_ns") else ctx.attr.manifest
for dep in direct_module_deps:
# if ctx.label.name == 'tezos-base':
# print("DEPPP: %s" % dep)
# ignore DefaultInfo, its just for printing, not propagation
if OcamlProvider in dep: # should always be True
# if ctx.label.name == 'tezos-base':
# print("directdep: %s" % dep[OcamlProvider])
indirect_fileset_depsets.append(dep[OcamlProvider].fileset)
# linkargs: what goes on cmd line to build archive or
# executable FIXME: __excluding__ sibling modules! Why?
# because even if we put only indirect deps in linkargs,
# the head (direct) dep could still appear anywhere in the
# dep closure; in particular, we may have sibling deps, in
# which case omitting the head dep for linkargs would do
# us no good. So we need to filter to remove ALL
# (sub)modules from linkargs.
# if linkarg not in direct_module_deps_files:
indirect_linkargs_depsets.append(dep[OcamlProvider].linkargs)
# if ctx.label.name == "tezos-base":
# print("LIBDEP LINKARGS: %s" % dep[OcamlProvider].linkargs)
# indirect_linkargs_depsets.append(dep[OcamlProvider].files)
## inputs == all deps
indirect_inputs_depsets.append(dep[OcamlProvider].inputs)
indirect_paths_depsets.append(dep[OcamlProvider].paths)
indirect_linkargs_depsets.append(dep[DefaultInfo].files)
if CcInfo in dep:
## we do not need to do anything with ccdeps here,
## just pass them on in a provider
# if ctx.label.name == "tezos-legacy-store":
# dump_CcInfo(ctx, dep)
ccInfo_list.append(dep[CcInfo])
if PpxCodepsProvider in dep:
indirect_adjunct_path_depsets.append(dep[PpxCodepsProvider].paths)
indirect_adjunct_depsets.append(dep[PpxCodepsProvider].ppx_codeps)
# print("indirect_inputs_depsets: %s" % indirect_inputs_depsets)
# normalized_direct_dep_files = []
# for dep in direct_dep_files:
# print("direct dep: %s" % dep)
# print("the_ns_resolvers: %s" % the_ns_resolvers)
# # (bname, ext) = paths.split_extension(dep.basename)
# if dep.basename not in the_ns_resolvers: ## [0].basename:
# normalized_direct_dep_files.append(dep)
# else:
# print("removing %s" % dep)
inputs_depset = depset(
order = dsorder,
direct = direct_dep_files,
transitive = ([ns_resolver_depset] if ns_resolver_depset else []) + indirect_inputs_depsets
# + [depset(direct_dep_files)]
)
## To put direct deps in dep-order, we need to merge the linkargs
## deps and iterate over them:
new_linkargs = []
## start with ns_resolver:
if ctx.attr._rule.startswith("ocaml_ns"):
if ns_resolver:
for f in ns_resolver[DefaultInfo].files.to_list():
# for f in ns_resolver[0].files.to_list():
paths_direct.append(f.dirname)
new_linkargs.append(f)
linkargs_depset = depset(
order = dsorder,
## direct = ns_resolver_files,
transitive = indirect_linkargs_depsets
# transitive = ([ns_resolver_depset] if ns_resolver_depset else []) + indirect_linkargs_depsets
)
for dep in inputs_depset.to_list():
if dep in direct_dep_files:
new_linkargs.append(dep)
#######################
## Do we need to do this? Why?
ctx.actions.do_nothing(
mnemonic = "NS_LIB",
inputs = inputs_depset
)
#######################
# print("INPUTS_DEPSET: %s" % inputs_depset)
# print("the_ns_resolvers: %s" % the_ns_resolvers)
#### PROVIDERS ####
defaultDepset = depset(
order = dsorder,
# direct = normalized_direct_dep_files, # ns_resolver_module,
# transitive = [depset(direct = the_ns_resolvers)]
direct = the_ns_resolvers + [ns_resolver_module] if ns_resolver_module else [],
transitive = [depset(direct_dep_files)]
# transitive = [depset(normalized_direct_dep_files)]
)
defaultInfo = DefaultInfo(
files = defaultDepset
)
################ ppx codeps ################
ppx_codeps_depset = depset(
order = dsorder,
transitive = indirect_adjunct_depsets
)
ppxAdjunctsProvider = PpxCodepsProvider(
ppx_codeps = ppx_codeps_depset,
paths = depset(
order = dsorder,
transitive = indirect_adjunct_path_depsets
)
)
new_inputs_depset = depset(
order = dsorder,
## direct = ns_resolver_files,
transitive = ([ns_resolver_depset] if ns_resolver_depset else []) + [inputs_depset]
# + indirect_inputs_depsets
)
paths_depset = depset(
order = dsorder,
direct = paths_direct,
transitive = indirect_paths_depsets
)
# print("new_linkargs: %s" % new_linkargs)
ocamlProvider = OcamlProvider(
files = depset(direct=new_linkargs),
fileset = depset(
transitive=([ns_resolver_depset] if ns_resolver_depset else []) + indirect_fileset_depsets
),
inputs = new_inputs_depset,
linkargs = linkargs_depset,
paths = paths_depset,
ns_resolver = ns_resolver,
)
# print("ocamlProvider: %s" % ocamlProvider)
outputGroupInfo = OutputGroupInfo(
resolver = ns_resolver_files,
ppx_codeps = ppx_codeps_depset,
# cc = ... extract from CcInfo?
all = depset(
order = dsorder,
transitive=[
new_inputs_depset,
]
)
)
providers = [
defaultInfo,
ocamlProvider,
ppxAdjunctsProvider,
outputGroupInfo,
]
providers.append(
OcamlLibraryMarker(marker = "OcamlLibraryMarker")
)
if ctx.attr._rule.startswith("ocaml_ns"):
providers.append(
OcamlNsMarker(
marker = "OcamlNsMarker",
ns_name = ns_name if ns_resolver else ""
),
)
# if ctx.label.name == "tezos-legacy-store":
# print("ccInfo_list ct: %s" % len(ccInfo_list))
ccInfo_merged = cc_common.merge_cc_infos(cc_infos = ccInfo_list)
# if ctx.label.name == "tezos-legacy-store":
# print("ccInfo_merged: %s" % ccInfo_merged)
if ccInfo_list:
providers.append(ccInfo_merged)
return providers
| load('@bazel_skylib//rules:common_settings.bzl', 'BuildSettingInfo')
load('@bazel_skylib//lib:paths.bzl', 'paths')
load('//ocaml:providers.bzl', 'CompilationModeSettingProvider', 'OcamlProvider', 'OcamlNsResolverProvider', 'OcamlLibraryMarker', 'OcamlModuleMarker', 'OcamlNsMarker')
load('//ppx:providers.bzl', 'PpxCodepsProvider')
load(':impl_common.bzl', 'dsorder', 'module_sep', 'resolver_suffix')
load(':impl_ccdeps.bzl', 'dump_CcInfo')
def impl_library(ctx, mode, tool, tool_args):
debug = False
ns_resolver_depset = None
ns_resolver_module = None
ns_resolver = []
ns_resolver_files = []
the_ns_resolvers = []
if ctx.attr._rule.startswith('ocaml_ns'):
if ctx.attr.resolver:
ns_resolver = ctx.attr.resolver
ns_resolver_module = ctx.file.resolver
ns_name = ctx.attr.ns
else:
ns_resolver = ctx.attr._ns_resolver[0]
ns_resolver_module = ctx.files._ns_resolver[0]
if OcamlNsResolverProvider in ns_resolver:
if hasattr(ns_resolver[OcamlNsResolverProvider], 'ns_name'):
ns_name = ns_resolver[OcamlNsResolverProvider].ns_name
else:
ns_name = ''
if ns_resolver_module:
(ns_resolver_mname, ext) = paths.split_extension(ns_resolver_module.basename)
if ns_resolver_mname == ns_name + resolver_suffix:
print('Resolver is user-provided')
user_provided_resolver = True
else:
user_provided_resolver = False
else:
user_provided_resolver = False
if user_provided_resolver:
for submodule in ctx.files.submodules:
(bname, ext) = paths.split_extension(submodule.basename)
if bname == ns_name:
print('Found user-provided resolver submodule')
the_ns_resolvers.append(submodule)
if OcamlProvider in ns_resolver:
ns_resolver_files = ns_resolver[OcamlProvider].inputs
ns_resolver_depset = ns_resolver[OcamlProvider].inputs
indirect_adjunct_depsets = []
indirect_adjunct_path_depsets = []
paths_direct = []
direct_deps_attr = None
if ctx.attr._rule == 'ocaml_ns_archive':
direct_dep_files = ctx.files.submodules
direct_deps_attr = ctx.attr.submodules
elif ctx.attr._rule == 'ocaml_ns_library':
direct_dep_files = ctx.files.submodules
direct_deps_attr = ctx.attr.submodules
elif ctx.attr._rule == 'ocaml_archive':
direct_dep_files = ctx.files.manifest
direct_deps_attr = ctx.attr.manifest
elif ctx.attr._rule == 'ocaml_library':
direct_dep_files = ctx.files.manifest
direct_deps_attr = ctx.attr.manifest
else:
fail('impl_library called by non-aggregator: %s' % ctx.attr._rule)
for f in direct_dep_files:
paths_direct.append(f.dirname)
indirect_fileset_depsets = []
indirect_inputs_depsets = []
indirect_linkargs_depsets = []
indirect_paths_depsets = []
cc_info_list = []
direct_module_deps_files = ctx.files.submodules if ctx.attr._rule.startswith('ocaml_ns') else ctx.files.manifest
direct_module_deps = ctx.attr.submodules if ctx.attr._rule.startswith('ocaml_ns') else ctx.attr.manifest
for dep in direct_module_deps:
if OcamlProvider in dep:
indirect_fileset_depsets.append(dep[OcamlProvider].fileset)
indirect_linkargs_depsets.append(dep[OcamlProvider].linkargs)
indirect_inputs_depsets.append(dep[OcamlProvider].inputs)
indirect_paths_depsets.append(dep[OcamlProvider].paths)
indirect_linkargs_depsets.append(dep[DefaultInfo].files)
if CcInfo in dep:
ccInfo_list.append(dep[CcInfo])
if PpxCodepsProvider in dep:
indirect_adjunct_path_depsets.append(dep[PpxCodepsProvider].paths)
indirect_adjunct_depsets.append(dep[PpxCodepsProvider].ppx_codeps)
inputs_depset = depset(order=dsorder, direct=direct_dep_files, transitive=([ns_resolver_depset] if ns_resolver_depset else []) + indirect_inputs_depsets)
new_linkargs = []
if ctx.attr._rule.startswith('ocaml_ns'):
if ns_resolver:
for f in ns_resolver[DefaultInfo].files.to_list():
paths_direct.append(f.dirname)
new_linkargs.append(f)
linkargs_depset = depset(order=dsorder, transitive=indirect_linkargs_depsets)
for dep in inputs_depset.to_list():
if dep in direct_dep_files:
new_linkargs.append(dep)
ctx.actions.do_nothing(mnemonic='NS_LIB', inputs=inputs_depset)
default_depset = depset(order=dsorder, direct=the_ns_resolvers + [ns_resolver_module] if ns_resolver_module else [], transitive=[depset(direct_dep_files)])
default_info = default_info(files=defaultDepset)
ppx_codeps_depset = depset(order=dsorder, transitive=indirect_adjunct_depsets)
ppx_adjuncts_provider = ppx_codeps_provider(ppx_codeps=ppx_codeps_depset, paths=depset(order=dsorder, transitive=indirect_adjunct_path_depsets))
new_inputs_depset = depset(order=dsorder, transitive=([ns_resolver_depset] if ns_resolver_depset else []) + [inputs_depset])
paths_depset = depset(order=dsorder, direct=paths_direct, transitive=indirect_paths_depsets)
ocaml_provider = ocaml_provider(files=depset(direct=new_linkargs), fileset=depset(transitive=([ns_resolver_depset] if ns_resolver_depset else []) + indirect_fileset_depsets), inputs=new_inputs_depset, linkargs=linkargs_depset, paths=paths_depset, ns_resolver=ns_resolver)
output_group_info = output_group_info(resolver=ns_resolver_files, ppx_codeps=ppx_codeps_depset, all=depset(order=dsorder, transitive=[new_inputs_depset]))
providers = [defaultInfo, ocamlProvider, ppxAdjunctsProvider, outputGroupInfo]
providers.append(ocaml_library_marker(marker='OcamlLibraryMarker'))
if ctx.attr._rule.startswith('ocaml_ns'):
providers.append(ocaml_ns_marker(marker='OcamlNsMarker', ns_name=ns_name if ns_resolver else ''))
cc_info_merged = cc_common.merge_cc_infos(cc_infos=ccInfo_list)
if ccInfo_list:
providers.append(ccInfo_merged)
return providers |
def celsius_to_fahrenheit(Celsius):
F = (Celsius/5)*9 + 32
print(F)
def celsius_to_kelvin(Celsius):
K = Celsius + 273
print(K)
def kelvin_to_celsius(Kelvin):
C = Kelvin - 273
print(C)
def kelvin_to_fahrenheit(Kelvin):
F = (((Kelvin - 273) / 5) * 9) + 32
print(F)
def fahrenheit_to_kelvin(Fahrenheit):
K = (((Fahrenheit - 32) / 9) * 5) + 273
print(K)
def fahrenheit_to_celsius(Fahrenheit):
C = ((Fahrenheit - 32) / 9) * 5
print(C) | def celsius_to_fahrenheit(Celsius):
f = Celsius / 5 * 9 + 32
print(F)
def celsius_to_kelvin(Celsius):
k = Celsius + 273
print(K)
def kelvin_to_celsius(Kelvin):
c = Kelvin - 273
print(C)
def kelvin_to_fahrenheit(Kelvin):
f = (Kelvin - 273) / 5 * 9 + 32
print(F)
def fahrenheit_to_kelvin(Fahrenheit):
k = (Fahrenheit - 32) / 9 * 5 + 273
print(K)
def fahrenheit_to_celsius(Fahrenheit):
c = (Fahrenheit - 32) / 9 * 5
print(C) |
def add(x, y):
return x + y
a = 1
b = 2
result = add(a, b)
print("This is the sum: {}, {}, {}".format(a,b,result))
| def add(x, y):
return x + y
a = 1
b = 2
result = add(a, b)
print('This is the sum: {}, {}, {}'.format(a, b, result)) |
def regex(ref, char):
passed = True
for i in ref:
if char == i:
passed = False
return passed | def regex(ref, char):
passed = True
for i in ref:
if char == i:
passed = False
return passed |
'''
Created on Aug 30, 2018
@author: Manikandan.R
'''
print ('Running Fibonacci')
a, b = 0, 1
while a < 10:
print(a, end=',')
a, b = b, a + b
print ('Handling Strings')
alphas = "abcdefghijklmnopqrstuvwxyz"
index = len(alphas) // 2
alpha1 = alphas[: index]
alpha2 = alphas[index :]
print ('alphas: ' + alphas)
print ('alpha1: ' + alpha1)
print ('alpha2: ' + alpha2)
print ('Handling Lists')
lists = [1, 2, 3, 4, 5, 6, 7, 8, 9]
print ('My List: ', lists)
print ('4th element from start: ', lists[4])
print ('1st element from end: ', lists[-1]) | """
Created on Aug 30, 2018
@author: Manikandan.R
"""
print('Running Fibonacci')
(a, b) = (0, 1)
while a < 10:
print(a, end=',')
(a, b) = (b, a + b)
print('Handling Strings')
alphas = 'abcdefghijklmnopqrstuvwxyz'
index = len(alphas) // 2
alpha1 = alphas[:index]
alpha2 = alphas[index:]
print('alphas: ' + alphas)
print('alpha1: ' + alpha1)
print('alpha2: ' + alpha2)
print('Handling Lists')
lists = [1, 2, 3, 4, 5, 6, 7, 8, 9]
print('My List: ', lists)
print('4th element from start: ', lists[4])
print('1st element from end: ', lists[-1]) |
class Appointment():
def __init__(self):
self.patient_ID = 0
self.doctor_ID = 0
self.profession = ""
self.day = ""
self.confirm = 0
self.success = 0
| class Appointment:
def __init__(self):
self.patient_ID = 0
self.doctor_ID = 0
self.profession = ''
self.day = ''
self.confirm = 0
self.success = 0 |
class Solution:
def singleNumber(self, nums: List[int]) -> int:
result = 0
for n in nums:
result ^= n
return result | class Solution:
def single_number(self, nums: List[int]) -> int:
result = 0
for n in nums:
result ^= n
return result |
X_full = brca.data
X_train, X_test, y_train, y_test = train_test_split(X_full, y, test_size=0.2, random_state=0)
scaler.fit(X_train)
X_train = scaler.transform(X_train)
X_test = scaler.transform(X_test)
clf = neighbors.KNeighborsClassifier(n_neighbors=5)
clf.fit(X_train, y_train)
test_score = clf.score(X_test, y_test)
train_score = clf.score(X_train, y_train)
print(f"test score: {test_score} \ntrain score: {train_score}") | x_full = brca.data
(x_train, x_test, y_train, y_test) = train_test_split(X_full, y, test_size=0.2, random_state=0)
scaler.fit(X_train)
x_train = scaler.transform(X_train)
x_test = scaler.transform(X_test)
clf = neighbors.KNeighborsClassifier(n_neighbors=5)
clf.fit(X_train, y_train)
test_score = clf.score(X_test, y_test)
train_score = clf.score(X_train, y_train)
print(f'test score: {test_score} \ntrain score: {train_score}') |
# -*- coding: utf-8 -*-
def main():
s = input()
if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
print('Bad')
else:
print('Good')
if __name__ == '__main__':
main()
| def main():
s = input()
if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
print('Bad')
else:
print('Good')
if __name__ == '__main__':
main() |
#UNION
my_set1 = {3, 4, 5}
my_set2 = {5, 6, 7}
my_set3 = my_set1 | my_set2
print(my_set3)
# {3, 4, 5, 6, 7}
#INTERSECCION
my_set1 = {3, 4, 5}
my_set2 = {5, 6, 7}
my_set3 = my_set1 & my_set2
print(my_set3)
# {5}
#DIFERENCIA
my_set1 = {3, 4, 5}
my_set2 = {5, 6, 7}
my_set3 = my_set1 - my_set2
print(my_set3)
my_set4 = my_set2 - my_set1
print(my_set4)
# {3, 4}
# {6, 7}
# DIFERENCIA SIMETRICA
my_set1 = {3, 4, 5}
my_set2 = {5, 6, 7}
my_set3 = my_set1 ^ my_set2
print(my_set3)
# {3, 4, 6, 7}
| my_set1 = {3, 4, 5}
my_set2 = {5, 6, 7}
my_set3 = my_set1 | my_set2
print(my_set3)
my_set1 = {3, 4, 5}
my_set2 = {5, 6, 7}
my_set3 = my_set1 & my_set2
print(my_set3)
my_set1 = {3, 4, 5}
my_set2 = {5, 6, 7}
my_set3 = my_set1 - my_set2
print(my_set3)
my_set4 = my_set2 - my_set1
print(my_set4)
my_set1 = {3, 4, 5}
my_set2 = {5, 6, 7}
my_set3 = my_set1 ^ my_set2
print(my_set3) |
#!/usr/bin/env python
#
# description: Edit Distance
# difficulty: Hard
# leetcode_num: 72
# leetcode_url: https://leetcode.com/problems/edit-distance/
#
# Given two words word1 and word2, find the minimum number of operations
# required to convert word1 to word2.
#
# You have the following 3 operations permitted on a word:
#
# Insert a character
# Delete a character
# Replace a character
# Example 1:
#
# Input: word1 = "horse", word2 = "ros"
# Output: 3
# Explanation:
# horse -> rorse (replace 'h' with 'r')
# rorse -> rose (remove 'r')
# rose -> ros (remove 'e')
# Example 2:
#
# Input: word1 = "intention", word2 = "execution"
# Output: 5
# Explanation:
# intention -> inention (remove 't')
# inention -> enention (replace 'i' with 'e')
# enention -> exention (replace 'n' with 'x')
# exention -> exection (replace 'n' with 'c')
# exection -> execution (insert 'u')
def getMinEditDistance(source, dest, m, n):
if m == 0:
return n
if n == 0:
return m
if source[m-1] == dest[n-1]:
return getMinEditDistance(source, dest, m-1, n-1) # No edits
return 1 + min(
getMinEditDistance(source, dest, m, n-1), # Character addition
getMinEditDistance(source, dest, m-1, n), # Charater removal
getMinEditDistance(source, dest, m-1, n-1), # Charater replacement
)
# Recursive Solution
def MinEditDistanceRecursive(source, dest):
return getMinEditDistance(source, dest, len(source), len(dest))
# Solution using dynamic programming
def MinEditDistance(source, dest):
m = len(source)
n = len(dest)
dist = [[0 for _ in range(n+1)] for _ in range(m+1)]
for i in range(m+1):
for j in range(n+1):
if i == 0:
dist[i][j] = j
elif j == 0:
dist[i][j] = i
elif source[i-1] == dest[j-1]:
dist[i][j] = dist[i-1][j-1] # No edits
else:
dist[i][j] = 1 + min(
dist[i][j-1], # Character addition
dist[i-1][j], # Charater removal
dist[i-1][j-1] # Charater replacement
)
return dist[m][n]
if __name__ == '__main__':
test_cases = [
(('horse', 'ros'), 3),
(('intention', 'execution'), 5)
]
for args, res in test_cases:
assert MinEditDistanceRecursive(args[0], args[1]) == res, 'Test Failed'
assert MinEditDistance(args[0], args[1]) == res, 'Test Failed'
| def get_min_edit_distance(source, dest, m, n):
if m == 0:
return n
if n == 0:
return m
if source[m - 1] == dest[n - 1]:
return get_min_edit_distance(source, dest, m - 1, n - 1)
return 1 + min(get_min_edit_distance(source, dest, m, n - 1), get_min_edit_distance(source, dest, m - 1, n), get_min_edit_distance(source, dest, m - 1, n - 1))
def min_edit_distance_recursive(source, dest):
return get_min_edit_distance(source, dest, len(source), len(dest))
def min_edit_distance(source, dest):
m = len(source)
n = len(dest)
dist = [[0 for _ in range(n + 1)] for _ in range(m + 1)]
for i in range(m + 1):
for j in range(n + 1):
if i == 0:
dist[i][j] = j
elif j == 0:
dist[i][j] = i
elif source[i - 1] == dest[j - 1]:
dist[i][j] = dist[i - 1][j - 1]
else:
dist[i][j] = 1 + min(dist[i][j - 1], dist[i - 1][j], dist[i - 1][j - 1])
return dist[m][n]
if __name__ == '__main__':
test_cases = [(('horse', 'ros'), 3), (('intention', 'execution'), 5)]
for (args, res) in test_cases:
assert min_edit_distance_recursive(args[0], args[1]) == res, 'Test Failed'
assert min_edit_distance(args[0], args[1]) == res, 'Test Failed' |
'''
Contains all the modules that should be available when this folder is imported.
'''
__all__ = [
'google_search',
'bumble_help',
'clock_in',
'clock_out',
'chatbot',
'grepapp_search',
'send_email',
'open_notepad',
'wiki_search',
'wolfram_search',
'start_research_server',
'stop_research_server',
'store_research_data',
'silent_mode_on',
'voice_mode_on',
'youtube_search',
'add_zoom_link',
'open_zoom_link',
'sleep',
'stop_listening',
'add_contact',
'add_employer',
'set_default_speech_mode',
'load_routines',
'run_routine',
'internet_speed_test',
'run_online_tasks'
]
'''Essential Features that should be included in every custon list.'''
__essential__ = [
'sleep',
'stop_listening',
'silent_mode_on',
'voice_mode_on',
'set_default_speech_mode'
]
'''Contains cybersecurity specific features.'''
__cybersecurity__ = __essential__ + []
'''Contains geo specific features.'''
__geo__ = __essential__ + []
def create_feature_lists():
feature_lists = {}
feature_lists['all'] = __all__
feature_lists['cybersecurity'] = __cybersecurity__
feature_lists['geo'] = __geo__
return feature_lists
feature_lists = create_feature_lists()
| """
Contains all the modules that should be available when this folder is imported.
"""
__all__ = ['google_search', 'bumble_help', 'clock_in', 'clock_out', 'chatbot', 'grepapp_search', 'send_email', 'open_notepad', 'wiki_search', 'wolfram_search', 'start_research_server', 'stop_research_server', 'store_research_data', 'silent_mode_on', 'voice_mode_on', 'youtube_search', 'add_zoom_link', 'open_zoom_link', 'sleep', 'stop_listening', 'add_contact', 'add_employer', 'set_default_speech_mode', 'load_routines', 'run_routine', 'internet_speed_test', 'run_online_tasks']
'Essential Features that should be included in every custon list.'
__essential__ = ['sleep', 'stop_listening', 'silent_mode_on', 'voice_mode_on', 'set_default_speech_mode']
'Contains cybersecurity specific features.'
__cybersecurity__ = __essential__ + []
'Contains geo specific features.'
__geo__ = __essential__ + []
def create_feature_lists():
feature_lists = {}
feature_lists['all'] = __all__
feature_lists['cybersecurity'] = __cybersecurity__
feature_lists['geo'] = __geo__
return feature_lists
feature_lists = create_feature_lists() |
class Test():
def __init__(self, test_attr):
self.test_attr = test_attr
self.test_fn()
print(self.test_attr)
def test_fn(self):
self.test_attr = "goodbye world" | class Test:
def __init__(self, test_attr):
self.test_attr = test_attr
self.test_fn()
print(self.test_attr)
def test_fn(self):
self.test_attr = 'goodbye world' |
class Library:
def __init__(self,libraryname,booklist):
self.lend_book={}
self.library_name=libraryname
self.booklist=booklist
for book in self.booklist:
self.lend_book[book] = None
def add_books(self,book_name):
self.booklist.append(book_name)
self.lend_book[book_name]=None
def lendz_books(self,book,author):
if book in self.booklist:
if self.lend_book[book] is None:
self.lend_book[book]=author
else:
print("the book is already taken")
else:
print("wrong book name entered:")
def return_books(self,book,author):
if book in self.booklist:
if self.book[book] is not None:
self.booklist.append(book)
self.lend_book[book] = None
def delete_books(self,book_name):
if book_name in self.booklist:
self.booklist.remove(book_name)
self.lend_book.pop(book_name)
else:
print("the book is not the list")
def print_details(self):
return f"the book's list is {self.booklist} and library name is {self.library_name}"
if __name__ == "__main__":
list_books = ['Cookbook', 'Motu Patlu', 'Chacha_chaudhary', 'Rich Dad and Poor Dad']
Library_name = 'Harry'
secret_key = 123456
harry = Library( Library_name,list_books)
print("welcome to the library system\n There are various function in this library")
print("to add books 'a'\n to lend book 'l'\nto return the book 'r'\nto delete the book 'd'\to print the book list 'p' :")
Exit=False
while(Exit is not True):
input_1 = input("options:")
if input_1 == 'a':
input_2 = input("enter the book name you want to enter:")
harry.add_books(input_2)
elif input_1 == 'l':
input_2 = input("enter the book name you want to lend:")
input_3 = input("enter your name :")
harry.lendz_books(input_2, input_3)
elif input_1 == "r":
input_2 = input("enter the book name you want to return")
input_3 = input("enter your name :")
harry.return_books(input_2, input_3)
elif input_1 == 'd':
input_2 = input("enter the book you want to delete:")
secret = input("enter the secret key to get access:")
if secret == secret_key:
harry.delete_books(input_2)
else:
print("key is wrong")
elif input_1 == 'p':
print(harry.print_details())
| class Library:
def __init__(self, libraryname, booklist):
self.lend_book = {}
self.library_name = libraryname
self.booklist = booklist
for book in self.booklist:
self.lend_book[book] = None
def add_books(self, book_name):
self.booklist.append(book_name)
self.lend_book[book_name] = None
def lendz_books(self, book, author):
if book in self.booklist:
if self.lend_book[book] is None:
self.lend_book[book] = author
else:
print('the book is already taken')
else:
print('wrong book name entered:')
def return_books(self, book, author):
if book in self.booklist:
if self.book[book] is not None:
self.booklist.append(book)
self.lend_book[book] = None
def delete_books(self, book_name):
if book_name in self.booklist:
self.booklist.remove(book_name)
self.lend_book.pop(book_name)
else:
print('the book is not the list')
def print_details(self):
return f"the book's list is {self.booklist} and library name is {self.library_name}"
if __name__ == '__main__':
list_books = ['Cookbook', 'Motu Patlu', 'Chacha_chaudhary', 'Rich Dad and Poor Dad']
library_name = 'Harry'
secret_key = 123456
harry = library(Library_name, list_books)
print('welcome to the library system\n There are various function in this library')
print("to add books 'a'\n to lend book 'l'\nto return the book 'r'\nto delete the book 'd'\to print the book list 'p' :")
exit = False
while Exit is not True:
input_1 = input('options:')
if input_1 == 'a':
input_2 = input('enter the book name you want to enter:')
harry.add_books(input_2)
elif input_1 == 'l':
input_2 = input('enter the book name you want to lend:')
input_3 = input('enter your name :')
harry.lendz_books(input_2, input_3)
elif input_1 == 'r':
input_2 = input('enter the book name you want to return')
input_3 = input('enter your name :')
harry.return_books(input_2, input_3)
elif input_1 == 'd':
input_2 = input('enter the book you want to delete:')
secret = input('enter the secret key to get access:')
if secret == secret_key:
harry.delete_books(input_2)
else:
print('key is wrong')
elif input_1 == 'p':
print(harry.print_details()) |
class Solution:
# O(n) time | O(1) space where n is the length of the input array
def missingNumber(self, nums: List[int]) -> int:
missingNumber = 0
for i in range(len(nums)):
missingNumber ^= nums[i]
for i in range(len(nums) + 1):
missingNumber ^= i
return missingNumber
| class Solution:
def missing_number(self, nums: List[int]) -> int:
missing_number = 0
for i in range(len(nums)):
missing_number ^= nums[i]
for i in range(len(nums) + 1):
missing_number ^= i
return missingNumber |
# Write a program that prints the next 20 leap years (enter year or if not, get current year as default)
print('Type your year that you want to check:')
value = int(input())
count = 1
i = 0
def leap_years(year):
if year % 100 == 0:
if year % 400 == 0:
return True
else:
return False
elif year % 4 == 0:
return True
else:
return False
while count <= 20:
if not leap_years(value):
if leap_years(value + i):
print(value + i)
count += 1
i += 1
else:
if leap_years(value + i):
print(value + i)
count += 1
i += 4
# print(leap_years(value))
| print('Type your year that you want to check:')
value = int(input())
count = 1
i = 0
def leap_years(year):
if year % 100 == 0:
if year % 400 == 0:
return True
else:
return False
elif year % 4 == 0:
return True
else:
return False
while count <= 20:
if not leap_years(value):
if leap_years(value + i):
print(value + i)
count += 1
i += 1
else:
if leap_years(value + i):
print(value + i)
count += 1
i += 4 |
# Top fields
BANDIT_TYPE = 'bandit_type'
BANDIT_ID = 'bandit_id'
PRIORS = 'priors'
ARM_IDS = 'arm_ids'
PARAMETERS = 'parameters'
# Values
N = 'n'
REWARD_SUM = 'reward_sum'
SQUARED_REWARD_SUM = 'squared_reward_sum'
N_REWARDS = 'n_rewards'
# Parametres
EPSILON = 'epsilon'
| bandit_type = 'bandit_type'
bandit_id = 'bandit_id'
priors = 'priors'
arm_ids = 'arm_ids'
parameters = 'parameters'
n = 'n'
reward_sum = 'reward_sum'
squared_reward_sum = 'squared_reward_sum'
n_rewards = 'n_rewards'
epsilon = 'epsilon' |
class PyCrudException(Exception):
pass
class DBException(PyCrudException):
pass
class PermissionException(PyCrudException):
pass
class UnknownDatabaseException(PyCrudException):
pass
class InvalidQueryConditionColumn(PyCrudException):
pass
class InvalidQueryConditionOperator(PyCrudException):
pass
class InvalidQueryConditionValue(PyCrudException):
pass
class UnknownQueryOperator(PyCrudException):
pass
class InvalidQueryValue(PyCrudException):
pass
class InvalidOrderSyntax(PyCrudException):
pass
class UnsupportedQueryOperator(PyCrudException):
pass
| class Pycrudexception(Exception):
pass
class Dbexception(PyCrudException):
pass
class Permissionexception(PyCrudException):
pass
class Unknowndatabaseexception(PyCrudException):
pass
class Invalidqueryconditioncolumn(PyCrudException):
pass
class Invalidqueryconditionoperator(PyCrudException):
pass
class Invalidqueryconditionvalue(PyCrudException):
pass
class Unknownqueryoperator(PyCrudException):
pass
class Invalidqueryvalue(PyCrudException):
pass
class Invalidordersyntax(PyCrudException):
pass
class Unsupportedqueryoperator(PyCrudException):
pass |
# -*- coding: UTF-8 -*-
def formatMultiline(text, line_length):
return "\n".join(text[i - line_length: i] for i
in range(line_length,
len(text) + line_length,
line_length)
)
def breakByWords(text, max_len):
result = ""
words = text.split()
while len(words):
wordsInLine = len(words)
while sum(len(word) for word in words[0:wordsInLine]) > max_len:
wordsInLine = wordsInLine - 1
if wordsInLine == 0:
wordsInLine = 1
result += " ".join(words[0:wordsInLine]) + "\n"
del words[0:wordsInLine]
return result | def format_multiline(text, line_length):
return '\n'.join((text[i - line_length:i] for i in range(line_length, len(text) + line_length, line_length)))
def break_by_words(text, max_len):
result = ''
words = text.split()
while len(words):
words_in_line = len(words)
while sum((len(word) for word in words[0:wordsInLine])) > max_len:
words_in_line = wordsInLine - 1
if wordsInLine == 0:
words_in_line = 1
result += ' '.join(words[0:wordsInLine]) + '\n'
del words[0:wordsInLine]
return result |
if __name__ == '__main__':
string = "2018-11-13"
print(string.replace("-", ""))
string = "201812"
print(string.count("2"))
string = "12345678901234567890"
for i in range(len(string)):
print(string[i], end="")
if (i + 1) % 4 == 0:
print("\n")
string = "12345678901234567890"
column_num = 1
last_i = 0
for i in range(len(string)):
print(string[i], end="")
if (i - last_i) % column_num == 0:
last_i = i
column_num += 1
print("\n")
string = "123abcABCDE"
print("\n")
subline_num = 0
digit_num = 0
alpha_num = 0
for ch in string:
if ch.isdigit():
digit_num += 1
elif ch.isalpha():
alpha_num += 1
else:
subline_num += 1
print(subline_num)
print(digit_num)
print(alpha_num)
| if __name__ == '__main__':
string = '2018-11-13'
print(string.replace('-', ''))
string = '201812'
print(string.count('2'))
string = '12345678901234567890'
for i in range(len(string)):
print(string[i], end='')
if (i + 1) % 4 == 0:
print('\n')
string = '12345678901234567890'
column_num = 1
last_i = 0
for i in range(len(string)):
print(string[i], end='')
if (i - last_i) % column_num == 0:
last_i = i
column_num += 1
print('\n')
string = '123abcABCDE'
print('\n')
subline_num = 0
digit_num = 0
alpha_num = 0
for ch in string:
if ch.isdigit():
digit_num += 1
elif ch.isalpha():
alpha_num += 1
else:
subline_num += 1
print(subline_num)
print(digit_num)
print(alpha_num) |
UNK = 0
BOS = 1
EOS = 2
WORD = {
UNK: '<unk>',
BOS: '<s>',
EOS: '</s>'
}
| unk = 0
bos = 1
eos = 2
word = {UNK: '<unk>', BOS: '<s>', EOS: '</s>'} |
'''
Created on Feb 14, 2019
@author: jcorley
'''
PROTOCOL = "tcp"
IP_ADDRESS = "127.0.0.1"
PORT="5555"
KEY_REQUEST_TYPE = "request_type"
KEY_FAILURE_MESSAGE = "failure_message"
KEY_RECIPES = "recipes"
KEY_STATUS = "status"
SUCCESS_STATUS = 1
BAD_MESSAGE_STATUS = -1
UNSUPPORTED_OPERATION_STATUS = -1
LOAD_RECIPES_REQUEST_TYPE = "load_recipes"
| """
Created on Feb 14, 2019
@author: jcorley
"""
protocol = 'tcp'
ip_address = '127.0.0.1'
port = '5555'
key_request_type = 'request_type'
key_failure_message = 'failure_message'
key_recipes = 'recipes'
key_status = 'status'
success_status = 1
bad_message_status = -1
unsupported_operation_status = -1
load_recipes_request_type = 'load_recipes' |
CLI_OPTS = {
'data_path': {
'env': 'ELLIOTT_DATA_PATH',
'help': 'Git URL or File Path to build data'
},
'group': {
'env': 'ELLIOTT_GROUP',
'help': 'Sub-group directory or branch to pull build data'
},
'working_dir': {
'env': 'ELLIOTT_WORKING_DIR',
'help': 'Persistent working directory to use'
},
}
CLI_ENV_VARS = {k: v['env'] for (k, v) in CLI_OPTS.iteritems()}
CLI_CONFIG_TEMPLATE = '\n'.join(['#{}\n{}:\n'.format(v['help'], k) for (k, v) in CLI_OPTS.iteritems()]) | cli_opts = {'data_path': {'env': 'ELLIOTT_DATA_PATH', 'help': 'Git URL or File Path to build data'}, 'group': {'env': 'ELLIOTT_GROUP', 'help': 'Sub-group directory or branch to pull build data'}, 'working_dir': {'env': 'ELLIOTT_WORKING_DIR', 'help': 'Persistent working directory to use'}}
cli_env_vars = {k: v['env'] for (k, v) in CLI_OPTS.iteritems()}
cli_config_template = '\n'.join(['#{}\n{}:\n'.format(v['help'], k) for (k, v) in CLI_OPTS.iteritems()]) |
def show_sequence(n):
if n == 0:
return '0=0'
elif n < 0:
return '{}<0'.format(n)
return '{} = {}'.format(
'+'.join(str(a) for a in xrange(n + 1)), n * (n + 1) // 2
)
| def show_sequence(n):
if n == 0:
return '0=0'
elif n < 0:
return '{}<0'.format(n)
return '{} = {}'.format('+'.join((str(a) for a in xrange(n + 1))), n * (n + 1) // 2) |
class Pool:
__slots__ = ('_value', 'max_value', )
def __init__(self, value, max_value=None):
self._value = 0
value = int(value)
max_value = max_value and int(max_value)
self.max_value = max_value or value
self.value = value
@property
def value(self):
return self._value
@value.setter
def value(self, value):
self._value = max(0, min(value, self.max_value))
def __iadd__(self, value):
self._value += int(value)
return self
def __isub__(self, value):
self._value -= int(value)
return self
def __int__(self):
return self.value
class Attribute:
__slots__ = ('base', 'modifier')
def __init__(self, base, modifier=None):
self.base = base
self.modifier = modifier or 0
@property
def total(self):
return self.base + self.modifier
def __int__(self):
return self.total
| class Pool:
__slots__ = ('_value', 'max_value')
def __init__(self, value, max_value=None):
self._value = 0
value = int(value)
max_value = max_value and int(max_value)
self.max_value = max_value or value
self.value = value
@property
def value(self):
return self._value
@value.setter
def value(self, value):
self._value = max(0, min(value, self.max_value))
def __iadd__(self, value):
self._value += int(value)
return self
def __isub__(self, value):
self._value -= int(value)
return self
def __int__(self):
return self.value
class Attribute:
__slots__ = ('base', 'modifier')
def __init__(self, base, modifier=None):
self.base = base
self.modifier = modifier or 0
@property
def total(self):
return self.base + self.modifier
def __int__(self):
return self.total |
class ArticleTypeNotAllowed(Exception):
def __init__(self):
super().__init__("403 The article type is not allowed")
| class Articletypenotallowed(Exception):
def __init__(self):
super().__init__('403 The article type is not allowed') |
f=open("/home/pirl/darknet/train.txt",'a')
for i in range(1,801):
#data = 'data/green_light/green_light%d.jpg\n' % i
#data = 'data/red_light/ red_light%d.jpg\n' % i
#data = 'data/yellow_light/yellow_light%d.jpg\n' % i
#data = 'data/60_speed/60_speed%d.jpg\n' % i
#data = 'data/30_speed/30_speed%d.jpg\n' % i
#data = 'data/Nright_sign/Nright_sign%d.jpg\n' % i
#data = 'data/right_sign/right_sign%d.jpg\n' % i
f.write(data)
f.close()
| f = open('/home/pirl/darknet/train.txt', 'a')
for i in range(1, 801):
f.write(data)
f.close() |
# -*- coding: utf-8 -*-
class Processador(object):
def __init__(self):
self.processo_em_execucao = None
| class Processador(object):
def __init__(self):
self.processo_em_execucao = None |
USER_LOCK = []
PROCESS_LOCK = []
def user_lock(userid):
if userid in USER_LOCK: return False
else:
USER_LOCK.append(userid)
return True
def user_unlock(userid):
if userid in USER_LOCK: USER_LOCK.remove(userid)
def user_check(userid):
return userid in USER_LOCK
def process_lock(pid):
if pid in PROCESS_LOCK: return False
else:
PROCESS_LOCK.append(pid)
return True
def process_unlock(pid):
if pid in PROCESS_LOCK: PROCESS_LOCK.remove(pid)
def process_check(pid):
return pid in PROCESS_LOCK
| user_lock = []
process_lock = []
def user_lock(userid):
if userid in USER_LOCK:
return False
else:
USER_LOCK.append(userid)
return True
def user_unlock(userid):
if userid in USER_LOCK:
USER_LOCK.remove(userid)
def user_check(userid):
return userid in USER_LOCK
def process_lock(pid):
if pid in PROCESS_LOCK:
return False
else:
PROCESS_LOCK.append(pid)
return True
def process_unlock(pid):
if pid in PROCESS_LOCK:
PROCESS_LOCK.remove(pid)
def process_check(pid):
return pid in PROCESS_LOCK |
#!/usr/bin/env python
# Use local host when running locally
# port = 'localhost:50051'
# Use simple_server_app when running inside docker
port = 'simple_server_app:50051'
streaming_rate = 0.1 | port = 'simple_server_app:50051'
streaming_rate = 0.1 |
# the hardcoded key used in every mozi sample.
MOZI_XOR_KEY = b"\x4e\x66\x5a\x8f\x80\xc8\xac\x23\x8d\xac\x47\x06\xd5\x4f\x6f\x7e"
# the first 4 bytes of the XOR-ed config. It always begins with [ss].
MOZI_CONFIG_HEADER = b"\x15\x15\x29\xd2" # b"[ss]" ^ XOR_KEY[:4]
# the size of the Mozi config string
MOZI_CONFIG_TOTAL_SIZE = 524
# the size of the actual Mozi config
MOZI_CONFIG_SIZE = 428
# the first ECDSA384 signature, xored
MOZI_SIGNATURE_A = \
b"\x4C\xB3\x8F\x68\xC1\x26\x70\xEB\
\x9D\xC1\x68\x4E\xD8\x4B\x7D\x5F\
\x69\x5F\x9D\xCA\x8D\xE2\x7D\x63\
\xFF\xAD\x96\x8D\x18\x8B\x79\x1B\
\x38\x31\x9B\x12\x69\x73\xA9\x2E\
\xB6\x63\x29\x76\xAC\x2F\x9E\x94\xA1"
# the second ECDSA384 signature, xored
MOZI_SIGNATURE_B = \
b"\x4C\xA6\xFB\xCC\xF8\x9B\x12\x1F\
\x49\x64\x4D\x2F\x3C\x17\xD0\xB8\
\xE9\x7D\x24\x24\xF2\xDD\xB1\x47\
\xE9\x34\xD2\xC2\xBF\x07\xAC\x53\
\x22\x5F\xD8\x92\xFE\xED\x5F\xA3\
\xC9\x5B\x6A\x16\xBE\x84\x40\x77\x88"
# the magic UPX number that marks UPX data within the executable.
UPX_MAGIC = b"UPX!"
# name and size in bytes of the upx checksum
UPX_CHECKSUM = ("l_checksum", 4)
# name and size in bytes of the upx magic number
UPX_MAGIC_SIZE = ("l_magic", 4)
# name and size in bytes of the l_lsize field
UPX_LSIZE = ("l_lsize", 2)
# name and size in bytes of the l_version field
UPX_LVERSION = ("l_version", 1)
# name and size in bytes of the l_format field
UPX_LFORMAT = ("l_format", 1)
# name and size in bytes of the p_progid field
UPX_PPROGID = ("p_progid", 4)
# name and size in bytes of the p_filesize field
UPX_PFILESIZE = ("p_filesize", 4)
# name and size in bytes of the p_blocksize field
UPX_PBLOCKSIZE = ("p_blocksize", 4)
# the offset from the UPX trailer magic number to read the data from
# 6 doublewords (4 bytes) away from the start of the magic number
UPX_TRAILER_OFFSET = 6 * 4
# (name, has_suffix) e.g. [ss], [/ss]
# taken from https://blog.netlab.360.com/mozi-another-botnet-using-dht/
CONFIG_FIELDS = {
# declaration
"ss" : "bot role",
"cpu" : "cpu arch",
"nd" : "new DHT node",
"count" : "url to report to",
# control
"atk" : "ddos attack type",
"ver" : "verify",
"sv" : "update config",
"hp" : "DHT id prefix",
"dip" : "address to get new sample",
# subtasks
"dr" : "download and exec payload",
"ud" : "update bot",
"rn" : "execute command",
"idp" : "report bot info", # bot id, ip, port, file name, gateway, cpu arch
}
DHT_BOOTSTRAP_NODES = [
"dht.transmissionbt.com:6881",
"router.bittorrent.com:6881",
"router.utorrent.com:6881",
"bttracker.debian.org:6881",
"212.129.33.59:6881",
"82.221.103.244:6881",
"130.239.18.159:6881",
"87.98.162.88:6881",
] | mozi_xor_key = b'NfZ\x8f\x80\xc8\xac#\x8d\xacG\x06\xd5Oo~'
mozi_config_header = b'\x15\x15)\xd2'
mozi_config_total_size = 524
mozi_config_size = 428
mozi_signature_a = b'L\xb3\x8fh\xc1&p\xeb\x9d\xc1hN\xd8K}_i_\x9d\xca\x8d\xe2}c\xff\xad\x96\x8d\x18\x8by\x1b81\x9b\x12is\xa9.\xb6c)v\xac/\x9e\x94\xa1'
mozi_signature_b = b'L\xa6\xfb\xcc\xf8\x9b\x12\x1fIdM/<\x17\xd0\xb8\xe9}$$\xf2\xdd\xb1G\xe94\xd2\xc2\xbf\x07\xacS"_\xd8\x92\xfe\xed_\xa3\xc9[j\x16\xbe\x84@w\x88'
upx_magic = b'UPX!'
upx_checksum = ('l_checksum', 4)
upx_magic_size = ('l_magic', 4)
upx_lsize = ('l_lsize', 2)
upx_lversion = ('l_version', 1)
upx_lformat = ('l_format', 1)
upx_pprogid = ('p_progid', 4)
upx_pfilesize = ('p_filesize', 4)
upx_pblocksize = ('p_blocksize', 4)
upx_trailer_offset = 6 * 4
config_fields = {'ss': 'bot role', 'cpu': 'cpu arch', 'nd': 'new DHT node', 'count': 'url to report to', 'atk': 'ddos attack type', 'ver': 'verify', 'sv': 'update config', 'hp': 'DHT id prefix', 'dip': 'address to get new sample', 'dr': 'download and exec payload', 'ud': 'update bot', 'rn': 'execute command', 'idp': 'report bot info'}
dht_bootstrap_nodes = ['dht.transmissionbt.com:6881', 'router.bittorrent.com:6881', 'router.utorrent.com:6881', 'bttracker.debian.org:6881', '212.129.33.59:6881', '82.221.103.244:6881', '130.239.18.159:6881', '87.98.162.88:6881'] |
#!/usr/bin/python3
# maximizing_xor.py
# Author : Rajat Mhetre
# follow and drop me a line at @rajat_mhetre
def max_xor(l,r):
return max(x^y for x in range(l,r+1) for y in range(l,r+1))
if __name__ == '__main__':
l = int(input())
r = int(input())
print(max_xor(l,r))
| def max_xor(l, r):
return max((x ^ y for x in range(l, r + 1) for y in range(l, r + 1)))
if __name__ == '__main__':
l = int(input())
r = int(input())
print(max_xor(l, r)) |
def main():
combined_rect = set()
overlapped_rect = set()
f = open("input")
lines = f.readlines()
for line in lines:
id_, x, y, size_x, size_y = parse(line)
for coord in generate_coord(x, y, size_x, size_y):
if coord in combined_rect:
overlapped_rect.add(coord)
combined_rect.add(coord)
for line in lines:
id_, x, y, size_x, size_y = parse(line)
temp = set()
for coord in generate_coord(x, y, size_x, size_y):
temp.add(coord)
t = temp.intersection(overlapped_rect)
if not t:
print(id_)
def parse(line):
id_, _, start_point, size = line.split()
x, y = start_point.split(",")
y = y[:-1]
size_x, size_y = size.split("x")
return id_, int(x), int(y), int(size_x), int(size_y)
def generate_coord(x, y, size_x, size_y):
for x_ in range(x, x + size_x):
for y_ in range(y, y + size_y):
yield (x_, y_)
if __name__ == "__main__":
main()
| def main():
combined_rect = set()
overlapped_rect = set()
f = open('input')
lines = f.readlines()
for line in lines:
(id_, x, y, size_x, size_y) = parse(line)
for coord in generate_coord(x, y, size_x, size_y):
if coord in combined_rect:
overlapped_rect.add(coord)
combined_rect.add(coord)
for line in lines:
(id_, x, y, size_x, size_y) = parse(line)
temp = set()
for coord in generate_coord(x, y, size_x, size_y):
temp.add(coord)
t = temp.intersection(overlapped_rect)
if not t:
print(id_)
def parse(line):
(id_, _, start_point, size) = line.split()
(x, y) = start_point.split(',')
y = y[:-1]
(size_x, size_y) = size.split('x')
return (id_, int(x), int(y), int(size_x), int(size_y))
def generate_coord(x, y, size_x, size_y):
for x_ in range(x, x + size_x):
for y_ in range(y, y + size_y):
yield (x_, y_)
if __name__ == '__main__':
main() |
class B(object):
b:int =1
a:int =1
d:int =1
class C(object):
c:int =1
class A(B):
a:int = 1 #attr redefined in B
b:int = 1 #attr redefined in B
# this declaration will be ignore
class A(C):
a:int = 1 #ok,check attr in C
c:int = 1 #attr redefined
class D(A):
a:int = 1 #attr redefined
b:int = 1 #attr redefined
c:int = 1 #no problem
d:int = 1 #attr redefined in B | class B(object):
b: int = 1
a: int = 1
d: int = 1
class C(object):
c: int = 1
class A(B):
a: int = 1
b: int = 1
class A(C):
a: int = 1
c: int = 1
class D(A):
a: int = 1
b: int = 1
c: int = 1
d: int = 1 |
class Solution:
# O(n) time | O(n) space
def maxProfit(self, prices: List[int]) -> int:
n = len(prices)
if n <= 1: return 0
diff = [prices[i+1] - prices[i] for i in range(n-1)]
dp, dp_max = [0]*(n + 1), [0]*(n + 1)
for i in range(n-1):
dp[i] = diff[i] + max(dp_max[i-3], dp[i-1])
dp_max[i] = max(dp_max[i-1], dp[i])
return dp_max[-3] | class Solution:
def max_profit(self, prices: List[int]) -> int:
n = len(prices)
if n <= 1:
return 0
diff = [prices[i + 1] - prices[i] for i in range(n - 1)]
(dp, dp_max) = ([0] * (n + 1), [0] * (n + 1))
for i in range(n - 1):
dp[i] = diff[i] + max(dp_max[i - 3], dp[i - 1])
dp_max[i] = max(dp_max[i - 1], dp[i])
return dp_max[-3] |
#coding=utf-8
# email
smtp_server = "smtp.exmail.qq.com"
from_addr = "test@qq.com"
mail_username = "test2@qq.com"
mail_password = "admin"
mail_port = 465
# sms
SmsUrl = ""
SmsPath = ""
AppCode = ""
SignName = "" | smtp_server = 'smtp.exmail.qq.com'
from_addr = 'test@qq.com'
mail_username = 'test2@qq.com'
mail_password = 'admin'
mail_port = 465
sms_url = ''
sms_path = ''
app_code = ''
sign_name = '' |
#
# PySNMP MIB module ChrComPmSonetSNT-P-Day-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ChrComPmSonetSNT-P-Day-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:20:38 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
Integer, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ValueSizeConstraint, ConstraintsIntersection, SingleValueConstraint, ConstraintsUnion, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "ConstraintsIntersection", "SingleValueConstraint", "ConstraintsUnion", "ValueRangeConstraint")
chrComIfifIndex, = mibBuilder.importSymbols("ChrComIfifTable-MIB", "chrComIfifIndex")
TruthValue, = mibBuilder.importSymbols("ChrTyp-MIB", "TruthValue")
chrComPmSonet, = mibBuilder.importSymbols("Chromatis-MIB", "chrComPmSonet")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
NotificationType, MibScalar, MibTable, MibTableRow, MibTableColumn, Integer32, iso, TimeTicks, Bits, IpAddress, ObjectIdentity, Unsigned32, ModuleIdentity, MibIdentifier, Gauge32, Counter64, Counter32 = mibBuilder.importSymbols("SNMPv2-SMI", "NotificationType", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Integer32", "iso", "TimeTicks", "Bits", "IpAddress", "ObjectIdentity", "Unsigned32", "ModuleIdentity", "MibIdentifier", "Gauge32", "Counter64", "Counter32")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
chrComPmSonetSNT_P_DayTable = MibTable((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12), ).setLabel("chrComPmSonetSNT-P-DayTable")
if mibBuilder.loadTexts: chrComPmSonetSNT_P_DayTable.setStatus('current')
chrComPmSonetSNT_P_DayEntry = MibTableRow((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1), ).setLabel("chrComPmSonetSNT-P-DayEntry").setIndexNames((0, "ChrComIfifTable-MIB", "chrComIfifIndex"), (0, "ChrComPmSonetSNT-P-Day-MIB", "chrComPmSonetDayNumber"))
if mibBuilder.loadTexts: chrComPmSonetSNT_P_DayEntry.setStatus('current')
chrComPmSonetDayNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 1), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 2))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chrComPmSonetDayNumber.setStatus('current')
chrComPmSonetSuspectedInterval = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 2), TruthValue()).setMaxAccess("readonly")
if mibBuilder.loadTexts: chrComPmSonetSuspectedInterval.setStatus('current')
chrComPmSonetElapsedTime = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 3), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967295))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chrComPmSonetElapsedTime.setStatus('current')
chrComPmSonetSuppressedIntrvls = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 4), Gauge32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967295))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chrComPmSonetSuppressedIntrvls.setStatus('current')
chrComPmSonetES = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 5), Gauge32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967295))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chrComPmSonetES.setStatus('current')
chrComPmSonetSES = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 6), Gauge32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967295))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chrComPmSonetSES.setStatus('current')
chrComPmSonetCV = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 7), Gauge32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967295))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chrComPmSonetCV.setStatus('current')
chrComPmSonetUAS = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 8), Gauge32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967295))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chrComPmSonetUAS.setStatus('current')
chrComPmSonetPS = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 9), Gauge32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967295))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chrComPmSonetPS.setStatus('current')
chrComPmSonetThresholdProfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 10), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967295))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chrComPmSonetThresholdProfIndex.setStatus('current')
chrComPmSonetResetPmCountersAction = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 11), TruthValue()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: chrComPmSonetResetPmCountersAction.setStatus('current')
mibBuilder.exportSymbols("ChrComPmSonetSNT-P-Day-MIB", chrComPmSonetSNT_P_DayTable=chrComPmSonetSNT_P_DayTable, chrComPmSonetResetPmCountersAction=chrComPmSonetResetPmCountersAction, chrComPmSonetThresholdProfIndex=chrComPmSonetThresholdProfIndex, chrComPmSonetES=chrComPmSonetES, chrComPmSonetPS=chrComPmSonetPS, chrComPmSonetSNT_P_DayEntry=chrComPmSonetSNT_P_DayEntry, chrComPmSonetSuppressedIntrvls=chrComPmSonetSuppressedIntrvls, chrComPmSonetElapsedTime=chrComPmSonetElapsedTime, chrComPmSonetDayNumber=chrComPmSonetDayNumber, chrComPmSonetSuspectedInterval=chrComPmSonetSuspectedInterval, chrComPmSonetCV=chrComPmSonetCV, chrComPmSonetSES=chrComPmSonetSES, chrComPmSonetUAS=chrComPmSonetUAS)
| (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_intersection, single_value_constraint, constraints_union, value_range_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueSizeConstraint', 'ConstraintsIntersection', 'SingleValueConstraint', 'ConstraintsUnion', 'ValueRangeConstraint')
(chr_com_ifif_index,) = mibBuilder.importSymbols('ChrComIfifTable-MIB', 'chrComIfifIndex')
(truth_value,) = mibBuilder.importSymbols('ChrTyp-MIB', 'TruthValue')
(chr_com_pm_sonet,) = mibBuilder.importSymbols('Chromatis-MIB', 'chrComPmSonet')
(notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance')
(notification_type, mib_scalar, mib_table, mib_table_row, mib_table_column, integer32, iso, time_ticks, bits, ip_address, object_identity, unsigned32, module_identity, mib_identifier, gauge32, counter64, counter32) = mibBuilder.importSymbols('SNMPv2-SMI', 'NotificationType', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Integer32', 'iso', 'TimeTicks', 'Bits', 'IpAddress', 'ObjectIdentity', 'Unsigned32', 'ModuleIdentity', 'MibIdentifier', 'Gauge32', 'Counter64', 'Counter32')
(display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention')
chr_com_pm_sonet_snt_p__day_table = mib_table((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12)).setLabel('chrComPmSonetSNT-P-DayTable')
if mibBuilder.loadTexts:
chrComPmSonetSNT_P_DayTable.setStatus('current')
chr_com_pm_sonet_snt_p__day_entry = mib_table_row((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1)).setLabel('chrComPmSonetSNT-P-DayEntry').setIndexNames((0, 'ChrComIfifTable-MIB', 'chrComIfifIndex'), (0, 'ChrComPmSonetSNT-P-Day-MIB', 'chrComPmSonetDayNumber'))
if mibBuilder.loadTexts:
chrComPmSonetSNT_P_DayEntry.setStatus('current')
chr_com_pm_sonet_day_number = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 1), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 2))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chrComPmSonetDayNumber.setStatus('current')
chr_com_pm_sonet_suspected_interval = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 2), truth_value()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chrComPmSonetSuspectedInterval.setStatus('current')
chr_com_pm_sonet_elapsed_time = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 3), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 4294967295))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chrComPmSonetElapsedTime.setStatus('current')
chr_com_pm_sonet_suppressed_intrvls = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 4), gauge32().subtype(subtypeSpec=value_range_constraint(0, 4294967295))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chrComPmSonetSuppressedIntrvls.setStatus('current')
chr_com_pm_sonet_es = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 5), gauge32().subtype(subtypeSpec=value_range_constraint(0, 4294967295))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chrComPmSonetES.setStatus('current')
chr_com_pm_sonet_ses = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 6), gauge32().subtype(subtypeSpec=value_range_constraint(0, 4294967295))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chrComPmSonetSES.setStatus('current')
chr_com_pm_sonet_cv = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 7), gauge32().subtype(subtypeSpec=value_range_constraint(0, 4294967295))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chrComPmSonetCV.setStatus('current')
chr_com_pm_sonet_uas = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 8), gauge32().subtype(subtypeSpec=value_range_constraint(0, 4294967295))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chrComPmSonetUAS.setStatus('current')
chr_com_pm_sonet_ps = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 9), gauge32().subtype(subtypeSpec=value_range_constraint(0, 4294967295))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chrComPmSonetPS.setStatus('current')
chr_com_pm_sonet_threshold_prof_index = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 10), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 4294967295))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chrComPmSonetThresholdProfIndex.setStatus('current')
chr_com_pm_sonet_reset_pm_counters_action = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 11), truth_value()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
chrComPmSonetResetPmCountersAction.setStatus('current')
mibBuilder.exportSymbols('ChrComPmSonetSNT-P-Day-MIB', chrComPmSonetSNT_P_DayTable=chrComPmSonetSNT_P_DayTable, chrComPmSonetResetPmCountersAction=chrComPmSonetResetPmCountersAction, chrComPmSonetThresholdProfIndex=chrComPmSonetThresholdProfIndex, chrComPmSonetES=chrComPmSonetES, chrComPmSonetPS=chrComPmSonetPS, chrComPmSonetSNT_P_DayEntry=chrComPmSonetSNT_P_DayEntry, chrComPmSonetSuppressedIntrvls=chrComPmSonetSuppressedIntrvls, chrComPmSonetElapsedTime=chrComPmSonetElapsedTime, chrComPmSonetDayNumber=chrComPmSonetDayNumber, chrComPmSonetSuspectedInterval=chrComPmSonetSuspectedInterval, chrComPmSonetCV=chrComPmSonetCV, chrComPmSonetSES=chrComPmSonetSES, chrComPmSonetUAS=chrComPmSonetUAS) |
#Class Inheritance
#Feline class
class Feline:
def __init__(self,name):
self.name = name
print('Creating a feline')
def meow(self):
print(f'{self.name}: meow')
def setName(self, name):
print(f'{self} setting name: {name}')
self.name = name
#Lion class
class Lion(Feline):
def roar(self):
print(f'{self.name} roar')
#Tiger class
class Tiger(Feline):
#override the contructor is a BAD idea
def __init__(self):
#Super alows is to access the parent
#if we forget this we will have a bad time later
super().__init__('No Name')
print('Creating a tiger')
def stalk(self):
#have to make sure name is set in the parent
#this is considered -LBYL (look before you leap)
#here we are dynamically adding the attribute
#If we did not init the super we will have to be careful
#if not hasattr(self,'name'): super().setName('No Name')
print(f'{self.name}: stalking')
def rename(self,name):
super().setName(name)
c = Feline('kitty')
print(c)
c.meow()
l = Lion('Leo')
print(l)
l.meow()
l.roar()
t = Tiger() #is a Feline, but with a different constructor
print(t)
t.stalk()
t.rename('Tony')
t.meow()
t.stalk() | class Feline:
def __init__(self, name):
self.name = name
print('Creating a feline')
def meow(self):
print(f'{self.name}: meow')
def set_name(self, name):
print(f'{self} setting name: {name}')
self.name = name
class Lion(Feline):
def roar(self):
print(f'{self.name} roar')
class Tiger(Feline):
def __init__(self):
super().__init__('No Name')
print('Creating a tiger')
def stalk(self):
print(f'{self.name}: stalking')
def rename(self, name):
super().setName(name)
c = feline('kitty')
print(c)
c.meow()
l = lion('Leo')
print(l)
l.meow()
l.roar()
t = tiger()
print(t)
t.stalk()
t.rename('Tony')
t.meow()
t.stalk() |
#snapshot parameters
snapshot_num = 77
galaxy_num = 0
galaxy_num_str = str(galaxy_num)
snapnum_str = '{:03d}'.format(snapshot_num)
hydro_dir = '/orange/narayanan/desika.narayanan/gizmo_runs/simba/m12_n256_active_boxes/output_m12n256_7/'
snapshot_name = 'snapshot_'+snapnum_str+'.hdf5'
#where the files should go
PD_output_dir = '/home/desika.narayanan/pd_git/tests/SKIRT/m12_extinction/'
Auto_TF_file = 'snap'+snapnum_str+'.logical'
Auto_dustdens_file = 'snap'+snapnum_str+'.dustdens'
#===============================================
#FILE I/O
#===============================================
inputfile = PD_output_dir+'/pd_skirt_comparison.'+snapnum_str+'.rtin'
outputfile = PD_output_dir+'/pd_skirt_comparison.'+snapnum_str+'.rtout'
#===============================================
#GRID POSITIONS
#===============================================
#x_cent=7791.04289063
#y_cent=11030.12925781
#z_cent=4567.8734375
x_cent = 5527.42349609
y_cent = 4680.46623047
z_cent = 10704.73
#x_cent = 5.00925088e+03
#y_cent = 1.22012878e+04
#z_cent = 8.88592731e+00
#x_cent = 10898.06515625
#y_cent = 10868.67308594
#z_cent = 4419.96082031
#===============================================
#CMB
#===============================================
TCMB = 2.73
| snapshot_num = 77
galaxy_num = 0
galaxy_num_str = str(galaxy_num)
snapnum_str = '{:03d}'.format(snapshot_num)
hydro_dir = '/orange/narayanan/desika.narayanan/gizmo_runs/simba/m12_n256_active_boxes/output_m12n256_7/'
snapshot_name = 'snapshot_' + snapnum_str + '.hdf5'
pd_output_dir = '/home/desika.narayanan/pd_git/tests/SKIRT/m12_extinction/'
auto_tf_file = 'snap' + snapnum_str + '.logical'
auto_dustdens_file = 'snap' + snapnum_str + '.dustdens'
inputfile = PD_output_dir + '/pd_skirt_comparison.' + snapnum_str + '.rtin'
outputfile = PD_output_dir + '/pd_skirt_comparison.' + snapnum_str + '.rtout'
x_cent = 5527.42349609
y_cent = 4680.46623047
z_cent = 10704.73
tcmb = 2.73 |
#!/usr/bin/env python3
################################################################
# From an imported list, this will sort and return a string
# pg 202
################################################################
def alphalist( orginal_list=[] ):
# Create working copy of list passed in
sorted_list = orginal_list.copy()
sorted_list.sort()
final_list = ''
for name in sorted_list:
final_list += name + ', '
# strip the ending comma and space
final_list = final_list[:-2]
# To return a list instead of a string, uncomment these lines and comment out the original return statement
# new_list = []
# splitOrig = final_list.split(', ')
# for item in splitOrig:
# new_list.append(item)
# return new_list
return final_list
# Call function
list = [ 'a', 'q', 'b']
new_list = alphalist(list)
print(new_list)
print('new list type = ')
print(type(new_list))
# preferred, single line
print('new list type = ',end='')
print(type(new_list))
| def alphalist(orginal_list=[]):
sorted_list = orginal_list.copy()
sorted_list.sort()
final_list = ''
for name in sorted_list:
final_list += name + ', '
final_list = final_list[:-2]
return final_list
list = ['a', 'q', 'b']
new_list = alphalist(list)
print(new_list)
print('new list type = ')
print(type(new_list))
print('new list type = ', end='')
print(type(new_list)) |
# -*- coding: utf-8 -*-
class Numbers:
def __init__(self, dct):
self.date = dct["date"]
self.numbers = dct["balls"]
self.stars = dct["stars"]
self.draw = dct["draw"]
def factory(dct):
return Numbers(dct)
def __repr__(self):
return f"date: {self.date}, draw: {self.draw}, numbers: {self.numbers}, stars: {self.stars}"
| class Numbers:
def __init__(self, dct):
self.date = dct['date']
self.numbers = dct['balls']
self.stars = dct['stars']
self.draw = dct['draw']
def factory(dct):
return numbers(dct)
def __repr__(self):
return f'date: {self.date}, draw: {self.draw}, numbers: {self.numbers}, stars: {self.stars}' |
#!/usr/bin/env python3
# creates a function add_one() from the lambda x: x + 1
add_one = lambda x: x + 1
print(add_one(2))
| add_one = lambda x: x + 1
print(add_one(2)) |
#!/usr/bin/python
# SPDX-License-Identifier: MIT
with open("input", "r") as file:
depths = list(map(int, file))
differences = [j - i for i, j in zip(depths[:-1], depths[1:])]
increases = len([i for i in differences if i > 0])
print(f"number of depth increases: {increases}")
| with open('input', 'r') as file:
depths = list(map(int, file))
differences = [j - i for (i, j) in zip(depths[:-1], depths[1:])]
increases = len([i for i in differences if i > 0])
print(f'number of depth increases: {increases}') |
test_str="Codility we test coders"
k=14
for i in range(len(test_str)):
if len(test_str)==14:
print(test_str)
elif len(test_str)<14:
print(test_str.strip())
else:
test_str1=test_str.split()
print(test_str1)
lenth=len(test_str1)
print(lenth)
new_array=[]
for element in test_str:
if len(element)==14:
print(test_str)
break
elif len(element)<14:
new_array.append(element)
print(new_array)
else:
print('')
| test_str = 'Codility we test coders'
k = 14
for i in range(len(test_str)):
if len(test_str) == 14:
print(test_str)
elif len(test_str) < 14:
print(test_str.strip())
else:
test_str1 = test_str.split()
print(test_str1)
lenth = len(test_str1)
print(lenth)
new_array = []
for element in test_str:
if len(element) == 14:
print(test_str)
break
elif len(element) < 14:
new_array.append(element)
print(new_array)
else:
print('') |
#
# PySNMP MIB module PDN-DNS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/PDN-DNS-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:38:29 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsIntersection, ValueRangeConstraint, ConstraintsUnion, SingleValueConstraint, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueRangeConstraint", "ConstraintsUnion", "SingleValueConstraint", "ValueSizeConstraint")
pdn_dns, = mibBuilder.importSymbols("PDN-HEADER-MIB", "pdn-dns")
DomainName, DNSServerType = mibBuilder.importSymbols("PDN-TC", "DomainName", "DNSServerType")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
Counter64, iso, Bits, ModuleIdentity, Gauge32, Unsigned32, Integer32, MibIdentifier, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter32, ObjectIdentity, TimeTicks, IpAddress, NotificationType = mibBuilder.importSymbols("SNMPv2-SMI", "Counter64", "iso", "Bits", "ModuleIdentity", "Gauge32", "Unsigned32", "Integer32", "MibIdentifier", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter32", "ObjectIdentity", "TimeTicks", "IpAddress", "NotificationType")
RowStatus, DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "RowStatus", "DisplayString", "TextualConvention")
pdnDNSMIBObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1))
pdnDNSMIBTraps = MibIdentifier((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 2))
devDNSDefaultDomainName = MibScalar((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 1), DomainName()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: devDNSDefaultDomainName.setStatus('mandatory')
if mibBuilder.loadTexts: devDNSDefaultDomainName.setDescription('the object allows the NMS to configure the default domain name for the device')
devDNSRetryTimeout = MibScalar((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 2), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: devDNSRetryTimeout.setStatus('mandatory')
if mibBuilder.loadTexts: devDNSRetryTimeout.setDescription('the object allows the NMS to configure in seconds the time to wait for a response from a DNS server. The default value for this object is 5')
devDNSMaxRetries = MibScalar((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 3), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: devDNSMaxRetries.setStatus('mandatory')
if mibBuilder.loadTexts: devDNSMaxRetries.setDescription('the object allows the NMS to configure the number of maximum number of retires by the device before giving up or trying one of the secondary DNS servers if they have been configured. The default value for this object is 2')
devDNSServerTable = MibTable((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 4), )
if mibBuilder.loadTexts: devDNSServerTable.setStatus('mandatory')
if mibBuilder.loadTexts: devDNSServerTable.setDescription('A Table that contains information about the DNS server IP addresses')
devDNSServerEntry = MibTableRow((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 4, 1), ).setIndexNames((0, "PDN-DNS-MIB", "devDNSServerIP"))
if mibBuilder.loadTexts: devDNSServerEntry.setStatus('mandatory')
if mibBuilder.loadTexts: devDNSServerEntry.setDescription('A Table that contains information about the DNS server IP addresses')
devDNSServerIP = MibTableColumn((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 4, 1, 1), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: devDNSServerIP.setStatus('mandatory')
if mibBuilder.loadTexts: devDNSServerIP.setDescription('This Objects allows an NMS to configure a DNS server IP address Default value is 1')
devDNSServerType = MibTableColumn((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 4, 1, 2), DNSServerType()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: devDNSServerType.setStatus('mandatory')
if mibBuilder.loadTexts: devDNSServerType.setDescription('This Objects allows an NMS to specify whether the Server IP address is the primary DNS server or the secondary DNS server. Only One Primary DNS server is allowed to be configured.')
devDNSRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 4, 1, 3), RowStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: devDNSRowStatus.setStatus('mandatory')
if mibBuilder.loadTexts: devDNSRowStatus.setDescription('Use CreateAndGo to Create a new object. use Destroy to remove an entry from this table')
devHostMappingTable = MibTable((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 5), )
if mibBuilder.loadTexts: devHostMappingTable.setStatus('mandatory')
if mibBuilder.loadTexts: devHostMappingTable.setDescription('A Table that contains information about host names for devices')
devHostMappingEntry = MibTableRow((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 5, 1), ).setIndexNames((0, "PDN-DNS-MIB", "devHostMappingIpAddress"))
if mibBuilder.loadTexts: devHostMappingEntry.setStatus('mandatory')
if mibBuilder.loadTexts: devHostMappingEntry.setDescription('An entry that contains information about a device host name')
devHostMappingIpAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 5, 1, 1), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: devHostMappingIpAddress.setStatus('mandatory')
if mibBuilder.loadTexts: devHostMappingIpAddress.setDescription('This object contains the IP Address of the host')
devHostMappingHostName = MibTableColumn((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 5, 1, 2), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(1, 64))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: devHostMappingHostName.setStatus('mandatory')
if mibBuilder.loadTexts: devHostMappingHostName.setDescription('This object contains the name of the host')
devHostMappingRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 5, 1, 3), RowStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: devHostMappingRowStatus.setStatus('mandatory')
if mibBuilder.loadTexts: devHostMappingRowStatus.setDescription('This object is used to create or delete a row from the table')
mibBuilder.exportSymbols("PDN-DNS-MIB", devDNSServerEntry=devDNSServerEntry, devDNSRowStatus=devDNSRowStatus, devDNSServerType=devDNSServerType, pdnDNSMIBObjects=pdnDNSMIBObjects, devHostMappingIpAddress=devHostMappingIpAddress, devHostMappingHostName=devHostMappingHostName, pdnDNSMIBTraps=pdnDNSMIBTraps, devDNSMaxRetries=devDNSMaxRetries, devDNSServerIP=devDNSServerIP, devHostMappingTable=devHostMappingTable, devDNSRetryTimeout=devDNSRetryTimeout, devHostMappingEntry=devHostMappingEntry, devHostMappingRowStatus=devHostMappingRowStatus, devDNSServerTable=devDNSServerTable, devDNSDefaultDomainName=devDNSDefaultDomainName)
| (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_range_constraint, constraints_union, single_value_constraint, value_size_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsIntersection', 'ValueRangeConstraint', 'ConstraintsUnion', 'SingleValueConstraint', 'ValueSizeConstraint')
(pdn_dns,) = mibBuilder.importSymbols('PDN-HEADER-MIB', 'pdn-dns')
(domain_name, dns_server_type) = mibBuilder.importSymbols('PDN-TC', 'DomainName', 'DNSServerType')
(notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance')
(counter64, iso, bits, module_identity, gauge32, unsigned32, integer32, mib_identifier, mib_scalar, mib_table, mib_table_row, mib_table_column, counter32, object_identity, time_ticks, ip_address, notification_type) = mibBuilder.importSymbols('SNMPv2-SMI', 'Counter64', 'iso', 'Bits', 'ModuleIdentity', 'Gauge32', 'Unsigned32', 'Integer32', 'MibIdentifier', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Counter32', 'ObjectIdentity', 'TimeTicks', 'IpAddress', 'NotificationType')
(row_status, display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'RowStatus', 'DisplayString', 'TextualConvention')
pdn_dnsmib_objects = mib_identifier((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1))
pdn_dnsmib_traps = mib_identifier((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 2))
dev_dns_default_domain_name = mib_scalar((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 1), domain_name()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
devDNSDefaultDomainName.setStatus('mandatory')
if mibBuilder.loadTexts:
devDNSDefaultDomainName.setDescription('the object allows the NMS to configure the default domain name for the device')
dev_dns_retry_timeout = mib_scalar((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 2), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
devDNSRetryTimeout.setStatus('mandatory')
if mibBuilder.loadTexts:
devDNSRetryTimeout.setDescription('the object allows the NMS to configure in seconds the time to wait for a response from a DNS server. The default value for this object is 5')
dev_dns_max_retries = mib_scalar((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 3), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
devDNSMaxRetries.setStatus('mandatory')
if mibBuilder.loadTexts:
devDNSMaxRetries.setDescription('the object allows the NMS to configure the number of maximum number of retires by the device before giving up or trying one of the secondary DNS servers if they have been configured. The default value for this object is 2')
dev_dns_server_table = mib_table((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 4))
if mibBuilder.loadTexts:
devDNSServerTable.setStatus('mandatory')
if mibBuilder.loadTexts:
devDNSServerTable.setDescription('A Table that contains information about the DNS server IP addresses')
dev_dns_server_entry = mib_table_row((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 4, 1)).setIndexNames((0, 'PDN-DNS-MIB', 'devDNSServerIP'))
if mibBuilder.loadTexts:
devDNSServerEntry.setStatus('mandatory')
if mibBuilder.loadTexts:
devDNSServerEntry.setDescription('A Table that contains information about the DNS server IP addresses')
dev_dns_server_ip = mib_table_column((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 4, 1, 1), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
devDNSServerIP.setStatus('mandatory')
if mibBuilder.loadTexts:
devDNSServerIP.setDescription('This Objects allows an NMS to configure a DNS server IP address Default value is 1')
dev_dns_server_type = mib_table_column((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 4, 1, 2), dns_server_type()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
devDNSServerType.setStatus('mandatory')
if mibBuilder.loadTexts:
devDNSServerType.setDescription('This Objects allows an NMS to specify whether the Server IP address is the primary DNS server or the secondary DNS server. Only One Primary DNS server is allowed to be configured.')
dev_dns_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 4, 1, 3), row_status()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
devDNSRowStatus.setStatus('mandatory')
if mibBuilder.loadTexts:
devDNSRowStatus.setDescription('Use CreateAndGo to Create a new object. use Destroy to remove an entry from this table')
dev_host_mapping_table = mib_table((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 5))
if mibBuilder.loadTexts:
devHostMappingTable.setStatus('mandatory')
if mibBuilder.loadTexts:
devHostMappingTable.setDescription('A Table that contains information about host names for devices')
dev_host_mapping_entry = mib_table_row((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 5, 1)).setIndexNames((0, 'PDN-DNS-MIB', 'devHostMappingIpAddress'))
if mibBuilder.loadTexts:
devHostMappingEntry.setStatus('mandatory')
if mibBuilder.loadTexts:
devHostMappingEntry.setDescription('An entry that contains information about a device host name')
dev_host_mapping_ip_address = mib_table_column((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 5, 1, 1), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
devHostMappingIpAddress.setStatus('mandatory')
if mibBuilder.loadTexts:
devHostMappingIpAddress.setDescription('This object contains the IP Address of the host')
dev_host_mapping_host_name = mib_table_column((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 5, 1, 2), display_string().subtype(subtypeSpec=value_size_constraint(1, 64))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
devHostMappingHostName.setStatus('mandatory')
if mibBuilder.loadTexts:
devHostMappingHostName.setDescription('This object contains the name of the host')
dev_host_mapping_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 1795, 2, 24, 2, 17, 1, 5, 1, 3), row_status()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
devHostMappingRowStatus.setStatus('mandatory')
if mibBuilder.loadTexts:
devHostMappingRowStatus.setDescription('This object is used to create or delete a row from the table')
mibBuilder.exportSymbols('PDN-DNS-MIB', devDNSServerEntry=devDNSServerEntry, devDNSRowStatus=devDNSRowStatus, devDNSServerType=devDNSServerType, pdnDNSMIBObjects=pdnDNSMIBObjects, devHostMappingIpAddress=devHostMappingIpAddress, devHostMappingHostName=devHostMappingHostName, pdnDNSMIBTraps=pdnDNSMIBTraps, devDNSMaxRetries=devDNSMaxRetries, devDNSServerIP=devDNSServerIP, devHostMappingTable=devHostMappingTable, devDNSRetryTimeout=devDNSRetryTimeout, devHostMappingEntry=devHostMappingEntry, devHostMappingRowStatus=devHostMappingRowStatus, devDNSServerTable=devDNSServerTable, devDNSDefaultDomainName=devDNSDefaultDomainName) |
hexnum = input()
number = int(hexnum,16)
if(number % 2 == 0):
print(0)
else:
print(1)
| hexnum = input()
number = int(hexnum, 16)
if number % 2 == 0:
print(0)
else:
print(1) |
class Solution:
def wordPatternMatch(self, pattern: str, str: str) -> bool:
table = {}
mapped = set()
def dfs(pstart, sstart):
if pstart == len(pattern):
return sstart == len(str)
for i in range(sstart, len(str)):
if len(str) - i < len(pattern) - pstart:
break
temp = str[sstart : i + 1]
if temp in table:
if table[temp] != pattern[pstart]:
continue
elif dfs(pstart + 1, i + 1):
return True
elif pattern[pstart] not in mapped:
table[temp] = pattern[pstart]
mapped.add(pattern[pstart])
if dfs(pstart + 1, i + 1):
return True
del table[temp]
mapped.remove(pattern[pstart])
return False
return dfs(0, 0)
| class Solution:
def word_pattern_match(self, pattern: str, str: str) -> bool:
table = {}
mapped = set()
def dfs(pstart, sstart):
if pstart == len(pattern):
return sstart == len(str)
for i in range(sstart, len(str)):
if len(str) - i < len(pattern) - pstart:
break
temp = str[sstart:i + 1]
if temp in table:
if table[temp] != pattern[pstart]:
continue
elif dfs(pstart + 1, i + 1):
return True
elif pattern[pstart] not in mapped:
table[temp] = pattern[pstart]
mapped.add(pattern[pstart])
if dfs(pstart + 1, i + 1):
return True
del table[temp]
mapped.remove(pattern[pstart])
return False
return dfs(0, 0) |
def quick_sort(given_list):
if len(given_list) < 1:
return given_list
else:
pivot_element = given_list[0] #here I am choosing the first element to be a pivot
left = quick_sort([element for element in given_list[1:] if element < pivot_element]) # moving smaller to left
right = quick_sort([element for element in given_list[1:] if element > pivot_element]) #moving greater to right
return left + [pivot_element] + right
#usage
mylist=[8,5,9,4,3,7,2,12,10]
print (quick_sort(mylist))
| def quick_sort(given_list):
if len(given_list) < 1:
return given_list
else:
pivot_element = given_list[0]
left = quick_sort([element for element in given_list[1:] if element < pivot_element])
right = quick_sort([element for element in given_list[1:] if element > pivot_element])
return left + [pivot_element] + right
mylist = [8, 5, 9, 4, 3, 7, 2, 12, 10]
print(quick_sort(mylist)) |
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'variables': {
'chromium_code': 1,
},
'includes': [
'ui_resources.gypi',
],
'targets': [
{
'target_name': 'ui',
'type': '<(component)',
'variables': { 'enable_wexit_time_destructors': 1, },
'includes': [
'base/ime/ime.gypi',
],
'dependencies': [
'../base/base.gyp:base',
'../base/base.gyp:base_i18n',
'../base/base.gyp:base_static',
'../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
'../build/temp_gyp/googleurl.gyp:googleurl',
'../net/net.gyp:net',
'../skia/skia.gyp:skia',
'../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc',
'../third_party/libpng/libpng.gyp:libpng',
'../third_party/zlib/zlib.gyp:zlib',
'base/strings/ui_strings.gyp:ui_strings',
'ui_resources_standard',
'<(libjpeg_gyp_path):libjpeg',
],
'defines': [
'UI_IMPLEMENTATION',
],
# Export these dependencies since text_elider.h includes ICU headers.
'export_dependent_settings': [
'../net/net.gyp:net',
'../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc',
],
'sources': [
'base/accelerators/accelerator.cc',
'base/accelerators/accelerator.h',
'base/accelerators/accelerator_cocoa.h',
'base/accelerators/accelerator_cocoa.mm',
'base/accelerators/accelerator_gtk.cc',
'base/accelerators/accelerator_gtk.h',
'base/accelerators/accelerator_manager.cc',
'base/accelerators/accelerator_manager.h',
'base/accessibility/accessibility_types.h',
'base/accessibility/accessible_text_utils.cc',
'base/accessibility/accessible_text_utils.h',
'base/accessibility/accessible_view_state.cc',
'base/accessibility/accessible_view_state.h',
'base/animation/animation.cc',
'base/animation/animation.h',
'base/animation/animation_container.cc',
'base/animation/animation_container.h',
'base/animation/animation_container_element.h',
'base/animation/animation_container_observer.h',
'base/animation/animation_delegate.h',
'base/animation/linear_animation.cc',
'base/animation/linear_animation.h',
'base/animation/multi_animation.cc',
'base/animation/multi_animation.h',
'base/animation/slide_animation.cc',
'base/animation/slide_animation.h',
'base/animation/throb_animation.cc',
'base/animation/throb_animation.h',
'base/animation/tween.cc',
'base/animation/tween.h',
'base/clipboard/clipboard.cc',
'base/clipboard/clipboard.h',
'base/clipboard/clipboard_android.cc',
'base/clipboard/clipboard_aurax11.cc',
'base/clipboard/clipboard_gtk.cc',
'base/clipboard/clipboard_mac.mm',
'base/clipboard/clipboard_util_win.cc',
'base/clipboard/clipboard_util_win.h',
'base/clipboard/clipboard_win.cc',
'base/clipboard/custom_data_helper.cc',
'base/clipboard/custom_data_helper.h',
'base/clipboard/custom_data_helper_mac.mm',
'base/clipboard/custom_data_helper_x.cc',
'base/clipboard/scoped_clipboard_writer.cc',
'base/clipboard/scoped_clipboard_writer.h',
'base/cocoa/base_view.h',
'base/cocoa/base_view.mm',
'base/cocoa/events_mac.mm',
'base/cocoa/find_pasteboard.h',
'base/cocoa/find_pasteboard.mm',
'base/cocoa/focus_tracker.h',
'base/cocoa/focus_tracker.mm',
'base/cocoa/fullscreen_window_manager.h',
'base/cocoa/fullscreen_window_manager.mm',
'base/cocoa/nib_loading.h',
'base/cocoa/nib_loading.mm',
'base/cocoa/underlay_opengl_hosting_window.h',
'base/cocoa/underlay_opengl_hosting_window.mm',
'base/cocoa/window_size_constants.h',
'base/cocoa/window_size_constants.mm',
'base/cursor/cursor.cc',
'base/cursor/cursor.h',
'base/cursor/cursor_win.cc',
'base/cursor/cursor_x11.cc',
'base/dragdrop/cocoa_dnd_util.h',
'base/dragdrop/cocoa_dnd_util.mm',
'base/dragdrop/drag_drop_types_gtk.cc',
'base/dragdrop/drag_drop_types.h',
'base/dragdrop/drag_drop_types_win.cc',
'base/dragdrop/drag_source.cc',
'base/dragdrop/drag_source.h',
'base/dragdrop/drop_target.cc',
'base/dragdrop/drop_target.h',
'base/dragdrop/drag_utils.cc',
'base/dragdrop/drag_utils.h',
'base/dragdrop/drag_utils_aura.cc',
'base/dragdrop/drag_utils_gtk.cc',
'base/dragdrop/drag_utils_win.cc',
'base/dragdrop/gtk_dnd_util.cc',
'base/dragdrop/gtk_dnd_util.h',
'base/dragdrop/os_exchange_data.cc',
'base/dragdrop/os_exchange_data.h',
'base/dragdrop/os_exchange_data_provider_aura.cc',
'base/dragdrop/os_exchange_data_provider_aura.h',
'base/dragdrop/os_exchange_data_provider_gtk.cc',
'base/dragdrop/os_exchange_data_provider_gtk.h',
'base/dragdrop/os_exchange_data_provider_win.cc',
'base/dragdrop/os_exchange_data_provider_win.h',
'base/events.h',
'base/gestures/gesture_configuration.cc',
'base/gestures/gesture_configuration.h',
'base/gestures/gesture_point.cc',
'base/gestures/gesture_point.h',
'base/gestures/gesture_recognizer.h',
'base/gestures/gesture_recognizer_impl.cc',
'base/gestures/gesture_recognizer_impl.h',
'base/gestures/gesture_sequence.cc',
'base/gestures/gesture_sequence.h',
'base/gestures/velocity_calculator.cc',
'base/gestures/velocity_calculator.h',
'base/gtk/event_synthesis_gtk.cc',
'base/gtk/event_synthesis_gtk.h',
'base/gtk/focus_store_gtk.cc',
'base/gtk/focus_store_gtk.h',
'base/gtk/g_object_destructor_filo.cc',
'base/gtk/g_object_destructor_filo.h',
'base/gtk/gtk_expanded_container.cc',
'base/gtk/gtk_expanded_container.h',
'base/gtk/gtk_floating_container.cc',
'base/gtk/gtk_floating_container.h',
'base/gtk/gtk_im_context_util.cc',
'base/gtk/gtk_im_context_util.h',
'base/gtk/gtk_hig_constants.h',
'base/gtk/gtk_screen_util.cc',
'base/gtk/gtk_screen_util.h',
'base/gtk/gtk_signal.h',
'base/gtk/gtk_signal_registrar.cc',
'base/gtk/gtk_signal_registrar.h',
'base/gtk/gtk_windowing.cc',
'base/gtk/gtk_windowing.h',
'base/gtk/menu_label_accelerator_util.cc',
'base/gtk/menu_label_accelerator_util.h',
'base/gtk/owned_widget_gtk.cc',
'base/gtk/owned_widget_gtk.h',
'base/gtk/scoped_gobject.h',
'base/gtk/scoped_region.cc',
'base/gtk/scoped_region.h',
'base/hit_test.h',
'base/keycodes/keyboard_code_conversion.cc',
'base/keycodes/keyboard_code_conversion.h',
'base/keycodes/keyboard_code_conversion_gtk.cc',
'base/keycodes/keyboard_code_conversion_gtk.h',
'base/keycodes/keyboard_code_conversion_mac.h',
'base/keycodes/keyboard_code_conversion_mac.mm',
'base/keycodes/keyboard_code_conversion_win.cc',
'base/keycodes/keyboard_code_conversion_win.h',
'base/keycodes/keyboard_code_conversion_x.cc',
'base/keycodes/keyboard_code_conversion_x.h',
'base/keycodes/keyboard_codes.h',
'base/l10n/l10n_font_util.cc',
'base/l10n/l10n_font_util.h',
'base/l10n/l10n_util.cc',
'base/l10n/l10n_util.h',
'base/l10n/l10n_util_collator.h',
'base/l10n/l10n_util_mac.h',
'base/l10n/l10n_util_mac.mm',
'base/l10n/l10n_util_posix.cc',
'base/l10n/l10n_util_win.cc',
'base/l10n/l10n_util_win.h',
'base/layout.cc',
'base/layout.h',
'base/models/button_menu_item_model.cc',
'base/models/button_menu_item_model.h',
'base/models/combobox_model.h',
'base/models/list_model.h',
'base/models/list_model_observer.h',
'base/models/menu_model.cc',
'base/models/menu_model.h',
'base/models/menu_model_delegate.h',
'base/models/simple_menu_model.cc',
'base/models/simple_menu_model.h',
'base/models/table_model.cc',
'base/models/table_model.h',
'base/models/table_model_observer.h',
'base/models/tree_model.cc',
'base/models/tree_model.h',
'base/models/tree_node_iterator.h',
'base/models/tree_node_model.h',
'base/native_theme/native_theme.cc',
'base/native_theme/native_theme.h',
'base/native_theme/native_theme_android.cc',
'base/native_theme/native_theme_android.h',
'base/native_theme/native_theme_aura.cc',
'base/native_theme/native_theme_aura.h',
'base/native_theme/native_theme_base.cc',
'base/native_theme/native_theme_base.h',
'base/native_theme/native_theme_gtk.cc',
'base/native_theme/native_theme_gtk.h',
'base/native_theme/native_theme_win.cc',
'base/native_theme/native_theme_win.h',
'base/range/range.cc',
'base/range/range.h',
'base/range/range_mac.mm',
'base/range/range_win.cc',
'base/resource/data_pack.cc',
'base/resource/data_pack.h',
'base/resource/resource_bundle.cc',
'base/resource/resource_bundle.h',
'base/resource/resource_bundle_android.cc',
'base/resource/resource_bundle_aurax11.cc',
'base/resource/resource_bundle_gtk.cc',
'base/resource/resource_bundle_mac.mm',
'base/resource/resource_bundle_win.cc',
'base/resource/resource_bundle_win.h',
'base/resource/resource_data_dll_win.cc',
'base/resource/resource_data_dll_win.h',
'base/resource/resource_handle.h',
'base/text/bytes_formatting.cc',
'base/text/bytes_formatting.h',
'base/text/text_elider.cc',
'base/text/text_elider.h',
'base/text/utf16_indexing.cc',
'base/text/utf16_indexing.h',
'base/theme_provider.cc',
'base/theme_provider.h',
'base/touch/touch_factory.cc',
'base/touch/touch_factory.h',
'base/ui_base_exports.cc',
'base/ui_base_paths.cc',
'base/ui_base_paths.h',
'base/ui_base_switches.cc',
'base/ui_base_switches.h',
'base/ui_base_types.h',
'base/ui_export.h',
'base/view_prop.cc',
'base/view_prop.h',
'base/win/accessibility_misc_utils.h',
'base/win/accessibility_misc_utils.cc',
'base/win/atl_module.h',
'base/win/dpi.cc',
'base/win/dpi.h',
'base/win/events_win.cc',
'base/win/extra_sdk_defines.h',
'base/win/foreground_helper.cc',
'base/win/foreground_helper.h',
'base/win/hwnd_util.cc',
'base/win/hwnd_util.h',
'base/win/hwnd_subclass.cc',
'base/win/hwnd_subclass.h',
'base/win/ime_input.cc',
'base/win/ime_input.h',
'base/win/message_box_win.cc',
'base/win/message_box_win.h',
'base/win/mouse_wheel_util.cc',
'base/win/mouse_wheel_util.h',
'base/win/scoped_ole_initializer.cc',
'base/win/scoped_ole_initializer.h',
'base/win/scoped_set_map_mode.h',
'base/win/shell.cc',
'base/win/shell.h',
'base/win/singleton_hwnd.cc',
'base/win/singleton_hwnd.h',
'base/win/window_impl.cc',
'base/win/window_impl.h',
'base/work_area_watcher_observer.h',
'base/x/active_window_watcher_x.cc',
'base/x/active_window_watcher_x.h',
'base/x/active_window_watcher_x_observer.h',
'base/x/events_x.cc',
'base/x/root_window_property_watcher_x.cc',
'base/x/root_window_property_watcher_x.h',
'base/x/valuators.cc',
'base/x/valuators.h',
'base/x/work_area_watcher_x.cc',
'base/x/work_area_watcher_x.h',
'base/x/x11_util.cc',
'base/x/x11_util.h',
'base/x/x11_util_internal.h',
'gfx/blit.cc',
'gfx/blit.h',
'gfx/canvas.cc',
'gfx/canvas.h',
'gfx/canvas_android.cc',
'gfx/canvas_linux.cc',
'gfx/canvas_mac.mm',
'gfx/canvas_paint.h',
'gfx/canvas_paint_win.cc',
'gfx/canvas_skia.cc',
'gfx/canvas_skia_paint.h',
'gfx/canvas_win.cc',
'gfx/codec/jpeg_codec.cc',
'gfx/codec/jpeg_codec.h',
'gfx/codec/png_codec.cc',
'gfx/codec/png_codec.h',
'gfx/color_analysis.cc',
'gfx/color_analysis.h',
'gfx/color_utils.cc',
'gfx/color_utils.h',
'gfx/favicon_size.cc',
'gfx/favicon_size.h',
'gfx/font.h',
'gfx/font.cc',
'gfx/font_list.h',
'gfx/font_list.cc',
'gfx/font_smoothing_win.cc',
'gfx/font_smoothing_win.h',
'gfx/gfx_paths.cc',
'gfx/gfx_paths.h',
'gfx/image/image.cc',
'gfx/image/image.h',
'gfx/image/image_mac.mm',
'gfx/image/image_skia.cc',
'gfx/image/image_skia.h',
'gfx/image/image_util.cc',
'gfx/image/image_util.h',
'gfx/insets.cc',
'gfx/insets.h',
'gfx/interpolated_transform.h',
'gfx/interpolated_transform.cc',
'gfx/mac/nsimage_cache.h',
'gfx/mac/nsimage_cache.mm',
'gfx/mac/scoped_ns_disable_screen_updates.h',
'gfx/monitor.cc',
'gfx/monitor.h',
'gfx/native_widget_types.h',
'gfx/pango_util.h',
'gfx/pango_util.cc',
'gfx/path.cc',
'gfx/path.h',
'gfx/path_aura.cc',
'gfx/path_gtk.cc',
'gfx/path_win.cc',
'gfx/platform_font.h',
'gfx/platform_font_android.cc',
'gfx/platform_font_pango.h',
'gfx/platform_font_pango.cc',
'gfx/platform_font_mac.h',
'gfx/platform_font_mac.mm',
'gfx/platform_font_win.h',
'gfx/platform_font_win.cc',
'gfx/point.cc',
'gfx/point.h',
'gfx/point_base.h',
'gfx/rect.cc',
'gfx/rect.h',
'gfx/rect_base.h',
'gfx/rect_base_impl.h',
'gfx/render_text.cc',
'gfx/render_text.h',
'gfx/render_text_linux.cc',
'gfx/render_text_linux.h',
'gfx/render_text_win.cc',
'gfx/render_text_win.h',
'gfx/screen.h',
'gfx/screen_android.cc',
'gfx/screen_aura.cc',
'gfx/screen_gtk.cc',
'gfx/screen_impl.h',
'gfx/screen_mac.mm',
'gfx/screen_win.cc',
'gfx/scoped_cg_context_save_gstate_mac.h',
'gfx/scoped_ns_graphics_context_save_gstate_mac.h',
'gfx/scoped_ns_graphics_context_save_gstate_mac.mm',
'gfx/scrollbar_size.cc',
'gfx/scrollbar_size.h',
'gfx/selection_model.cc',
'gfx/selection_model.h',
'gfx/shadow_value.cc',
'gfx/shadow_value.h',
'gfx/size.cc',
'gfx/size.h',
'gfx/size_base.h',
'gfx/size_base_impl.h',
'gfx/skbitmap_operations.cc',
'gfx/skbitmap_operations.h',
'gfx/skia_util.cc',
'gfx/skia_util.h',
'gfx/skia_utils_gtk.cc',
'gfx/skia_utils_gtk.h',
'gfx/sys_color_change_listener.cc',
'gfx/sys_color_change_listener.h',
'gfx/transform.cc',
'gfx/transform.h',
'gfx/transform_util.cc',
'gfx/transform_util.h',
'gfx/video_decode_acceleration_support_mac.h',
'gfx/video_decode_acceleration_support_mac.mm',
'ui_controls/ui_controls.h',
'ui_controls/ui_controls_aura.cc',
'ui_controls/ui_controls_internal_win.h',
'ui_controls/ui_controls_internal_win.cc',
'ui_controls/ui_controls_gtk.cc',
'ui_controls/ui_controls_mac.mm',
'ui_controls/ui_controls_win.cc',
],
'conditions': [
# TODO(asvitkine): Switch all platforms to use canvas_skia.cc.
# http://crbug.com/105550
['use_canvas_skia==1', {
'sources!': [
'gfx/canvas_android.cc',
'gfx/canvas_linux.cc',
'gfx/canvas_mac.mm',
'gfx/canvas_win.cc',
],
}, { # use_canvas_skia!=1
'sources!': [
'gfx/canvas_skia.cc',
],
}],
['use_aura==1', {
'sources/': [
['exclude', 'gfx/gtk_'],
['exclude', 'gfx/gtk_util.cc'],
['exclude', 'gfx/gtk_util.h'],
['exclude', 'gfx/screen_gtk.cc'],
['exclude', 'gfx/screen_win.cc'],
['exclude', 'base/dragdrop/drag_utils_win.cc'],
['exclude', 'base/win/mouse_wheel_util.cc'],
['exclude', 'base/win/mouse_wheel_util.h'],
['exclude', 'base/work_area_watcher_observer.h'],
['exclude', 'base/x/active_window_watcher_x.cc'],
['exclude', 'base/x/active_window_watcher_x.h'],
['exclude', 'base/x/active_window_watcher_x_observer.h'],
['exclude', 'base/x/root_window_property_watcher_x.cc'],
['exclude', 'base/x/root_window_property_watcher_x.h'],
['exclude', 'base/x/work_area_watcher_x.cc'],
['exclude', 'base/x/work_area_watcher_x.h'],
['exclude', 'ui_controls_win.cc'],
],
}, { # use_aura!=1
'sources!': [
'base/cursor/cursor.cc',
'base/cursor/cursor.h',
'base/cursor/cursor_win.cc',
'base/cursor/cursor_x11.cc',
'base/native_theme/native_theme_aura.cc',
'base/native_theme/native_theme_aura.h',
]
}],
['use_aura==1 and OS=="win"', {
'sources/': [
['exclude', 'base/dragdrop/os_exchange_data_provider_win.cc'],
['exclude', 'base/dragdrop/os_exchange_data_provider_win.h'],
['exclude', 'base/native_theme/native_theme_win.cc'],
['exclude', 'base/native_theme/native_theme_win.h'],
['exclude', 'gfx/path_win.cc'],
],
}],
['use_aura==0 and toolkit_views==0', {
'sources/': [
['exclude', '^base/gestures/*'],
]
}],
['use_ibus==1', {
'dependencies': [
'../build/linux/system.gyp:ibus',
],
}],
['use_glib == 1', {
'dependencies': [
# font_gtk.cc uses fontconfig.
'../build/linux/system.gyp:fontconfig',
'../build/linux/system.gyp:glib',
'../build/linux/system.gyp:pangocairo',
'../build/linux/system.gyp:x11',
'../build/linux/system.gyp:xext',
'../build/linux/system.gyp:xfixes',
],
'link_settings': {
'libraries': [
'-lXcursor', # For XCursor* function calls in x11_util.cc.
'-lXrender', # For XRender* function calls in x11_util.cc.
],
},
'conditions': [
['toolkit_views==0', {
# Note: because of gyp predence rules this has to be defined as
# 'sources/' rather than 'sources!'.
'sources/': [
['exclude', '^base/dragdrop/drag_drop_types_gtk.cc'],
['exclude', '^base/dragdrop/drag_utils_gtk.cc'],
['exclude', '^base/dragdrop/drag_utils.cc'],
['exclude', '^base/dragdrop/drag_utils.h'],
['exclude', '^base/dragdrop/os_exchange_data.cc'],
['exclude', '^base/dragdrop/os_exchange_data.h'],
['exclude', '^base/dragdrop/os_exchange_data_provider_gtk.cc'],
['exclude', '^base/dragdrop/os_exchange_data_provider_gtk.h'],
],
}, {
# Note: because of gyp predence rules this has to be defined as
# 'sources/' rather than 'sources!'.
'sources/': [
['include', '^base/dragdrop/os_exchange_data.cc'],
],
}],
],
}],
['toolkit_uses_gtk == 1', {
'dependencies': [
'../build/linux/system.gyp:gtk',
],
'sources': [
'gfx/gtk_native_view_id_manager.cc',
'gfx/gtk_native_view_id_manager.h',
'gfx/gtk_preserve_window.cc',
'gfx/gtk_preserve_window.h',
'gfx/gtk_util.cc',
'gfx/gtk_util.h',
'gfx/image/cairo_cached_surface.cc',
'gfx/image/cairo_cached_surface.h',
],
}, { # toolkit_uses_gtk != 1
'sources!': [
'base/native_theme/native_theme_gtk.cc',
'base/native_theme/native_theme_gtk.h',
]
}],
['OS=="win"', {
'sources': [
'gfx/gdi_util.cc',
'gfx/gdi_util.h',
'gfx/icon_util.cc',
'gfx/icon_util.h',
'base/native_theme/native_theme_win.cc',
'base/native_theme/native_theme_win.h',
],
'sources!': [
'base/touch/touch_factory.cc',
'base/touch/touch_factory.h',
'gfx/pango_util.h',
'gfx/pango_util.cc',
'gfx/platform_font_pango.cc',
'gfx/platform_font_pango.h',
],
'include_dirs': [
'../',
'../third_party/wtl/include',
],
'msvs_settings': {
'VCLinkerTool': {
'DelayLoadDLLs': [
'd2d1.dll',
'd3d10_1.dll',
],
'AdditionalDependencies': [
'd2d1.lib',
'd3d10_1.lib',
],
},
},
'link_settings': {
'libraries': [
'-limm32.lib',
'-ld2d1.lib',
'-loleacc.lib',
],
},
},{ # OS!="win"
'conditions': [
['use_aura==0', {
'sources!': [
'base/view_prop.cc',
'base/view_prop.h',
],
}],
],
'sources!': [
'base/dragdrop/drag_source.cc',
'base/dragdrop/drag_source.h',
'base/dragdrop/drag_drop_types.h',
'base/dragdrop/drop_target.cc',
'base/dragdrop/drop_target.h',
'base/dragdrop/os_exchange_data.cc',
'base/native_theme/native_theme_win.cc',
'base/native_theme/native_theme_win.h',
],
'sources/': [
['exclude', '^base/win/*'],
],
}],
['OS=="mac"', {
'sources!': [
'base/dragdrop/drag_utils.cc',
'base/dragdrop/drag_utils.h',
'base/touch/touch_factory.cc',
'base/touch/touch_factory.h',
'gfx/pango_util.h',
'gfx/pango_util.cc',
'gfx/platform_font_pango.h',
'gfx/platform_font_pango.cc',
],
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/Accelerate.framework',
'$(SDKROOT)/System/Library/Frameworks/AudioUnit.framework',
'$(SDKROOT)/System/Library/Frameworks/CoreVideo.framework',
],
},
}],
['OS=="android"', {
'sources!': [
'gfx/pango_util.h',
'gfx/pango_util.cc',
'gfx/platform_font_pango.h',
'gfx/platform_font_pango.cc',
],
}],
['use_x11==1', {
'all_dependent_settings': {
'ldflags': [
'-L<(PRODUCT_DIR)',
],
'link_settings': {
'libraries': [
'-lX11 -lXcursor',
],
},
},
}, { # use_x11==0
'sources/': [
['exclude', 'base/keycodes/keyboard_code_conversion_x.*'],
['exclude', 'base/x/*'],
],
}],
['toolkit_views==0', {
'sources!': [
'base/x/events_x.cc',
],
}],
['toolkit_views==0 and use_canvas_skia==0', {
'sources!': [
'gfx/render_text.cc',
'gfx/render_text.h',
'gfx/render_text_linux.cc',
'gfx/render_text_linux.h',
'gfx/render_text_win.cc',
'gfx/render_text_win.h',
],
}],
['OS=="android"', {
'sources!': [
'base/touch/touch_factory.cc',
'base/touch/touch_factory.h',
'gfx/pango_util.h',
'gfx/pango_util.cc',
'gfx/platform_font_pango.cc',
'gfx/platform_font_pango.h',
],
}],
['OS=="linux"', {
'libraries': [
'-ldl',
],
}],
['os_bsd==1 and use_system_libjpeg==1', {
'include_dirs': [
'/usr/local/include',
],
}],
['inside_chromium_build==0', {
'dependencies': [
'<(DEPTH)/webkit/support/setup_third_party.gyp:third_party_headers',
],
}],
],
},
],
'conditions': [
['inside_chromium_build==1', {
'includes': [
'ui_unittests.gypi',
],
'targets': [
{
# TODO(rsesek): Remove this target once ui_unittests is run on the
# waterfall instead of gfx_unittests.
'target_name': 'gfx_unittests',
'type': 'none',
'dependencies': [
'ui_unittests',
],
'actions': [
{
'message': 'TEMPORARY: Copying ui_unittests to gfx_unittests',
'variables': {
'ui_copy_target': '<(PRODUCT_DIR)/ui_unittests<(EXECUTABLE_SUFFIX)',
'ui_copy_dest': '<(PRODUCT_DIR)/gfx_unittests<(EXECUTABLE_SUFFIX)',
},
'inputs': ['<(ui_copy_target)'],
'outputs': ['<(ui_copy_dest)'],
'action_name': 'TEMP_copy_ui_unittests',
'action': [
'python', '-c',
'import os, shutil; ' \
'shutil.copyfile(\'<(ui_copy_target)\', \'<(ui_copy_dest)\'); ' \
'os.chmod(\'<(ui_copy_dest)\', 0700)'
]
}
],
},
],
}],
],
}
| {'variables': {'chromium_code': 1}, 'includes': ['ui_resources.gypi'], 'targets': [{'target_name': 'ui', 'type': '<(component)', 'variables': {'enable_wexit_time_destructors': 1}, 'includes': ['base/ime/ime.gypi'], 'dependencies': ['../base/base.gyp:base', '../base/base.gyp:base_i18n', '../base/base.gyp:base_static', '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', '../build/temp_gyp/googleurl.gyp:googleurl', '../net/net.gyp:net', '../skia/skia.gyp:skia', '../third_party/icu/icu.gyp:icui18n', '../third_party/icu/icu.gyp:icuuc', '../third_party/libpng/libpng.gyp:libpng', '../third_party/zlib/zlib.gyp:zlib', 'base/strings/ui_strings.gyp:ui_strings', 'ui_resources_standard', '<(libjpeg_gyp_path):libjpeg'], 'defines': ['UI_IMPLEMENTATION'], 'export_dependent_settings': ['../net/net.gyp:net', '../third_party/icu/icu.gyp:icui18n', '../third_party/icu/icu.gyp:icuuc'], 'sources': ['base/accelerators/accelerator.cc', 'base/accelerators/accelerator.h', 'base/accelerators/accelerator_cocoa.h', 'base/accelerators/accelerator_cocoa.mm', 'base/accelerators/accelerator_gtk.cc', 'base/accelerators/accelerator_gtk.h', 'base/accelerators/accelerator_manager.cc', 'base/accelerators/accelerator_manager.h', 'base/accessibility/accessibility_types.h', 'base/accessibility/accessible_text_utils.cc', 'base/accessibility/accessible_text_utils.h', 'base/accessibility/accessible_view_state.cc', 'base/accessibility/accessible_view_state.h', 'base/animation/animation.cc', 'base/animation/animation.h', 'base/animation/animation_container.cc', 'base/animation/animation_container.h', 'base/animation/animation_container_element.h', 'base/animation/animation_container_observer.h', 'base/animation/animation_delegate.h', 'base/animation/linear_animation.cc', 'base/animation/linear_animation.h', 'base/animation/multi_animation.cc', 'base/animation/multi_animation.h', 'base/animation/slide_animation.cc', 'base/animation/slide_animation.h', 'base/animation/throb_animation.cc', 'base/animation/throb_animation.h', 'base/animation/tween.cc', 'base/animation/tween.h', 'base/clipboard/clipboard.cc', 'base/clipboard/clipboard.h', 'base/clipboard/clipboard_android.cc', 'base/clipboard/clipboard_aurax11.cc', 'base/clipboard/clipboard_gtk.cc', 'base/clipboard/clipboard_mac.mm', 'base/clipboard/clipboard_util_win.cc', 'base/clipboard/clipboard_util_win.h', 'base/clipboard/clipboard_win.cc', 'base/clipboard/custom_data_helper.cc', 'base/clipboard/custom_data_helper.h', 'base/clipboard/custom_data_helper_mac.mm', 'base/clipboard/custom_data_helper_x.cc', 'base/clipboard/scoped_clipboard_writer.cc', 'base/clipboard/scoped_clipboard_writer.h', 'base/cocoa/base_view.h', 'base/cocoa/base_view.mm', 'base/cocoa/events_mac.mm', 'base/cocoa/find_pasteboard.h', 'base/cocoa/find_pasteboard.mm', 'base/cocoa/focus_tracker.h', 'base/cocoa/focus_tracker.mm', 'base/cocoa/fullscreen_window_manager.h', 'base/cocoa/fullscreen_window_manager.mm', 'base/cocoa/nib_loading.h', 'base/cocoa/nib_loading.mm', 'base/cocoa/underlay_opengl_hosting_window.h', 'base/cocoa/underlay_opengl_hosting_window.mm', 'base/cocoa/window_size_constants.h', 'base/cocoa/window_size_constants.mm', 'base/cursor/cursor.cc', 'base/cursor/cursor.h', 'base/cursor/cursor_win.cc', 'base/cursor/cursor_x11.cc', 'base/dragdrop/cocoa_dnd_util.h', 'base/dragdrop/cocoa_dnd_util.mm', 'base/dragdrop/drag_drop_types_gtk.cc', 'base/dragdrop/drag_drop_types.h', 'base/dragdrop/drag_drop_types_win.cc', 'base/dragdrop/drag_source.cc', 'base/dragdrop/drag_source.h', 'base/dragdrop/drop_target.cc', 'base/dragdrop/drop_target.h', 'base/dragdrop/drag_utils.cc', 'base/dragdrop/drag_utils.h', 'base/dragdrop/drag_utils_aura.cc', 'base/dragdrop/drag_utils_gtk.cc', 'base/dragdrop/drag_utils_win.cc', 'base/dragdrop/gtk_dnd_util.cc', 'base/dragdrop/gtk_dnd_util.h', 'base/dragdrop/os_exchange_data.cc', 'base/dragdrop/os_exchange_data.h', 'base/dragdrop/os_exchange_data_provider_aura.cc', 'base/dragdrop/os_exchange_data_provider_aura.h', 'base/dragdrop/os_exchange_data_provider_gtk.cc', 'base/dragdrop/os_exchange_data_provider_gtk.h', 'base/dragdrop/os_exchange_data_provider_win.cc', 'base/dragdrop/os_exchange_data_provider_win.h', 'base/events.h', 'base/gestures/gesture_configuration.cc', 'base/gestures/gesture_configuration.h', 'base/gestures/gesture_point.cc', 'base/gestures/gesture_point.h', 'base/gestures/gesture_recognizer.h', 'base/gestures/gesture_recognizer_impl.cc', 'base/gestures/gesture_recognizer_impl.h', 'base/gestures/gesture_sequence.cc', 'base/gestures/gesture_sequence.h', 'base/gestures/velocity_calculator.cc', 'base/gestures/velocity_calculator.h', 'base/gtk/event_synthesis_gtk.cc', 'base/gtk/event_synthesis_gtk.h', 'base/gtk/focus_store_gtk.cc', 'base/gtk/focus_store_gtk.h', 'base/gtk/g_object_destructor_filo.cc', 'base/gtk/g_object_destructor_filo.h', 'base/gtk/gtk_expanded_container.cc', 'base/gtk/gtk_expanded_container.h', 'base/gtk/gtk_floating_container.cc', 'base/gtk/gtk_floating_container.h', 'base/gtk/gtk_im_context_util.cc', 'base/gtk/gtk_im_context_util.h', 'base/gtk/gtk_hig_constants.h', 'base/gtk/gtk_screen_util.cc', 'base/gtk/gtk_screen_util.h', 'base/gtk/gtk_signal.h', 'base/gtk/gtk_signal_registrar.cc', 'base/gtk/gtk_signal_registrar.h', 'base/gtk/gtk_windowing.cc', 'base/gtk/gtk_windowing.h', 'base/gtk/menu_label_accelerator_util.cc', 'base/gtk/menu_label_accelerator_util.h', 'base/gtk/owned_widget_gtk.cc', 'base/gtk/owned_widget_gtk.h', 'base/gtk/scoped_gobject.h', 'base/gtk/scoped_region.cc', 'base/gtk/scoped_region.h', 'base/hit_test.h', 'base/keycodes/keyboard_code_conversion.cc', 'base/keycodes/keyboard_code_conversion.h', 'base/keycodes/keyboard_code_conversion_gtk.cc', 'base/keycodes/keyboard_code_conversion_gtk.h', 'base/keycodes/keyboard_code_conversion_mac.h', 'base/keycodes/keyboard_code_conversion_mac.mm', 'base/keycodes/keyboard_code_conversion_win.cc', 'base/keycodes/keyboard_code_conversion_win.h', 'base/keycodes/keyboard_code_conversion_x.cc', 'base/keycodes/keyboard_code_conversion_x.h', 'base/keycodes/keyboard_codes.h', 'base/l10n/l10n_font_util.cc', 'base/l10n/l10n_font_util.h', 'base/l10n/l10n_util.cc', 'base/l10n/l10n_util.h', 'base/l10n/l10n_util_collator.h', 'base/l10n/l10n_util_mac.h', 'base/l10n/l10n_util_mac.mm', 'base/l10n/l10n_util_posix.cc', 'base/l10n/l10n_util_win.cc', 'base/l10n/l10n_util_win.h', 'base/layout.cc', 'base/layout.h', 'base/models/button_menu_item_model.cc', 'base/models/button_menu_item_model.h', 'base/models/combobox_model.h', 'base/models/list_model.h', 'base/models/list_model_observer.h', 'base/models/menu_model.cc', 'base/models/menu_model.h', 'base/models/menu_model_delegate.h', 'base/models/simple_menu_model.cc', 'base/models/simple_menu_model.h', 'base/models/table_model.cc', 'base/models/table_model.h', 'base/models/table_model_observer.h', 'base/models/tree_model.cc', 'base/models/tree_model.h', 'base/models/tree_node_iterator.h', 'base/models/tree_node_model.h', 'base/native_theme/native_theme.cc', 'base/native_theme/native_theme.h', 'base/native_theme/native_theme_android.cc', 'base/native_theme/native_theme_android.h', 'base/native_theme/native_theme_aura.cc', 'base/native_theme/native_theme_aura.h', 'base/native_theme/native_theme_base.cc', 'base/native_theme/native_theme_base.h', 'base/native_theme/native_theme_gtk.cc', 'base/native_theme/native_theme_gtk.h', 'base/native_theme/native_theme_win.cc', 'base/native_theme/native_theme_win.h', 'base/range/range.cc', 'base/range/range.h', 'base/range/range_mac.mm', 'base/range/range_win.cc', 'base/resource/data_pack.cc', 'base/resource/data_pack.h', 'base/resource/resource_bundle.cc', 'base/resource/resource_bundle.h', 'base/resource/resource_bundle_android.cc', 'base/resource/resource_bundle_aurax11.cc', 'base/resource/resource_bundle_gtk.cc', 'base/resource/resource_bundle_mac.mm', 'base/resource/resource_bundle_win.cc', 'base/resource/resource_bundle_win.h', 'base/resource/resource_data_dll_win.cc', 'base/resource/resource_data_dll_win.h', 'base/resource/resource_handle.h', 'base/text/bytes_formatting.cc', 'base/text/bytes_formatting.h', 'base/text/text_elider.cc', 'base/text/text_elider.h', 'base/text/utf16_indexing.cc', 'base/text/utf16_indexing.h', 'base/theme_provider.cc', 'base/theme_provider.h', 'base/touch/touch_factory.cc', 'base/touch/touch_factory.h', 'base/ui_base_exports.cc', 'base/ui_base_paths.cc', 'base/ui_base_paths.h', 'base/ui_base_switches.cc', 'base/ui_base_switches.h', 'base/ui_base_types.h', 'base/ui_export.h', 'base/view_prop.cc', 'base/view_prop.h', 'base/win/accessibility_misc_utils.h', 'base/win/accessibility_misc_utils.cc', 'base/win/atl_module.h', 'base/win/dpi.cc', 'base/win/dpi.h', 'base/win/events_win.cc', 'base/win/extra_sdk_defines.h', 'base/win/foreground_helper.cc', 'base/win/foreground_helper.h', 'base/win/hwnd_util.cc', 'base/win/hwnd_util.h', 'base/win/hwnd_subclass.cc', 'base/win/hwnd_subclass.h', 'base/win/ime_input.cc', 'base/win/ime_input.h', 'base/win/message_box_win.cc', 'base/win/message_box_win.h', 'base/win/mouse_wheel_util.cc', 'base/win/mouse_wheel_util.h', 'base/win/scoped_ole_initializer.cc', 'base/win/scoped_ole_initializer.h', 'base/win/scoped_set_map_mode.h', 'base/win/shell.cc', 'base/win/shell.h', 'base/win/singleton_hwnd.cc', 'base/win/singleton_hwnd.h', 'base/win/window_impl.cc', 'base/win/window_impl.h', 'base/work_area_watcher_observer.h', 'base/x/active_window_watcher_x.cc', 'base/x/active_window_watcher_x.h', 'base/x/active_window_watcher_x_observer.h', 'base/x/events_x.cc', 'base/x/root_window_property_watcher_x.cc', 'base/x/root_window_property_watcher_x.h', 'base/x/valuators.cc', 'base/x/valuators.h', 'base/x/work_area_watcher_x.cc', 'base/x/work_area_watcher_x.h', 'base/x/x11_util.cc', 'base/x/x11_util.h', 'base/x/x11_util_internal.h', 'gfx/blit.cc', 'gfx/blit.h', 'gfx/canvas.cc', 'gfx/canvas.h', 'gfx/canvas_android.cc', 'gfx/canvas_linux.cc', 'gfx/canvas_mac.mm', 'gfx/canvas_paint.h', 'gfx/canvas_paint_win.cc', 'gfx/canvas_skia.cc', 'gfx/canvas_skia_paint.h', 'gfx/canvas_win.cc', 'gfx/codec/jpeg_codec.cc', 'gfx/codec/jpeg_codec.h', 'gfx/codec/png_codec.cc', 'gfx/codec/png_codec.h', 'gfx/color_analysis.cc', 'gfx/color_analysis.h', 'gfx/color_utils.cc', 'gfx/color_utils.h', 'gfx/favicon_size.cc', 'gfx/favicon_size.h', 'gfx/font.h', 'gfx/font.cc', 'gfx/font_list.h', 'gfx/font_list.cc', 'gfx/font_smoothing_win.cc', 'gfx/font_smoothing_win.h', 'gfx/gfx_paths.cc', 'gfx/gfx_paths.h', 'gfx/image/image.cc', 'gfx/image/image.h', 'gfx/image/image_mac.mm', 'gfx/image/image_skia.cc', 'gfx/image/image_skia.h', 'gfx/image/image_util.cc', 'gfx/image/image_util.h', 'gfx/insets.cc', 'gfx/insets.h', 'gfx/interpolated_transform.h', 'gfx/interpolated_transform.cc', 'gfx/mac/nsimage_cache.h', 'gfx/mac/nsimage_cache.mm', 'gfx/mac/scoped_ns_disable_screen_updates.h', 'gfx/monitor.cc', 'gfx/monitor.h', 'gfx/native_widget_types.h', 'gfx/pango_util.h', 'gfx/pango_util.cc', 'gfx/path.cc', 'gfx/path.h', 'gfx/path_aura.cc', 'gfx/path_gtk.cc', 'gfx/path_win.cc', 'gfx/platform_font.h', 'gfx/platform_font_android.cc', 'gfx/platform_font_pango.h', 'gfx/platform_font_pango.cc', 'gfx/platform_font_mac.h', 'gfx/platform_font_mac.mm', 'gfx/platform_font_win.h', 'gfx/platform_font_win.cc', 'gfx/point.cc', 'gfx/point.h', 'gfx/point_base.h', 'gfx/rect.cc', 'gfx/rect.h', 'gfx/rect_base.h', 'gfx/rect_base_impl.h', 'gfx/render_text.cc', 'gfx/render_text.h', 'gfx/render_text_linux.cc', 'gfx/render_text_linux.h', 'gfx/render_text_win.cc', 'gfx/render_text_win.h', 'gfx/screen.h', 'gfx/screen_android.cc', 'gfx/screen_aura.cc', 'gfx/screen_gtk.cc', 'gfx/screen_impl.h', 'gfx/screen_mac.mm', 'gfx/screen_win.cc', 'gfx/scoped_cg_context_save_gstate_mac.h', 'gfx/scoped_ns_graphics_context_save_gstate_mac.h', 'gfx/scoped_ns_graphics_context_save_gstate_mac.mm', 'gfx/scrollbar_size.cc', 'gfx/scrollbar_size.h', 'gfx/selection_model.cc', 'gfx/selection_model.h', 'gfx/shadow_value.cc', 'gfx/shadow_value.h', 'gfx/size.cc', 'gfx/size.h', 'gfx/size_base.h', 'gfx/size_base_impl.h', 'gfx/skbitmap_operations.cc', 'gfx/skbitmap_operations.h', 'gfx/skia_util.cc', 'gfx/skia_util.h', 'gfx/skia_utils_gtk.cc', 'gfx/skia_utils_gtk.h', 'gfx/sys_color_change_listener.cc', 'gfx/sys_color_change_listener.h', 'gfx/transform.cc', 'gfx/transform.h', 'gfx/transform_util.cc', 'gfx/transform_util.h', 'gfx/video_decode_acceleration_support_mac.h', 'gfx/video_decode_acceleration_support_mac.mm', 'ui_controls/ui_controls.h', 'ui_controls/ui_controls_aura.cc', 'ui_controls/ui_controls_internal_win.h', 'ui_controls/ui_controls_internal_win.cc', 'ui_controls/ui_controls_gtk.cc', 'ui_controls/ui_controls_mac.mm', 'ui_controls/ui_controls_win.cc'], 'conditions': [['use_canvas_skia==1', {'sources!': ['gfx/canvas_android.cc', 'gfx/canvas_linux.cc', 'gfx/canvas_mac.mm', 'gfx/canvas_win.cc']}, {'sources!': ['gfx/canvas_skia.cc']}], ['use_aura==1', {'sources/': [['exclude', 'gfx/gtk_'], ['exclude', 'gfx/gtk_util.cc'], ['exclude', 'gfx/gtk_util.h'], ['exclude', 'gfx/screen_gtk.cc'], ['exclude', 'gfx/screen_win.cc'], ['exclude', 'base/dragdrop/drag_utils_win.cc'], ['exclude', 'base/win/mouse_wheel_util.cc'], ['exclude', 'base/win/mouse_wheel_util.h'], ['exclude', 'base/work_area_watcher_observer.h'], ['exclude', 'base/x/active_window_watcher_x.cc'], ['exclude', 'base/x/active_window_watcher_x.h'], ['exclude', 'base/x/active_window_watcher_x_observer.h'], ['exclude', 'base/x/root_window_property_watcher_x.cc'], ['exclude', 'base/x/root_window_property_watcher_x.h'], ['exclude', 'base/x/work_area_watcher_x.cc'], ['exclude', 'base/x/work_area_watcher_x.h'], ['exclude', 'ui_controls_win.cc']]}, {'sources!': ['base/cursor/cursor.cc', 'base/cursor/cursor.h', 'base/cursor/cursor_win.cc', 'base/cursor/cursor_x11.cc', 'base/native_theme/native_theme_aura.cc', 'base/native_theme/native_theme_aura.h']}], ['use_aura==1 and OS=="win"', {'sources/': [['exclude', 'base/dragdrop/os_exchange_data_provider_win.cc'], ['exclude', 'base/dragdrop/os_exchange_data_provider_win.h'], ['exclude', 'base/native_theme/native_theme_win.cc'], ['exclude', 'base/native_theme/native_theme_win.h'], ['exclude', 'gfx/path_win.cc']]}], ['use_aura==0 and toolkit_views==0', {'sources/': [['exclude', '^base/gestures/*']]}], ['use_ibus==1', {'dependencies': ['../build/linux/system.gyp:ibus']}], ['use_glib == 1', {'dependencies': ['../build/linux/system.gyp:fontconfig', '../build/linux/system.gyp:glib', '../build/linux/system.gyp:pangocairo', '../build/linux/system.gyp:x11', '../build/linux/system.gyp:xext', '../build/linux/system.gyp:xfixes'], 'link_settings': {'libraries': ['-lXcursor', '-lXrender']}, 'conditions': [['toolkit_views==0', {'sources/': [['exclude', '^base/dragdrop/drag_drop_types_gtk.cc'], ['exclude', '^base/dragdrop/drag_utils_gtk.cc'], ['exclude', '^base/dragdrop/drag_utils.cc'], ['exclude', '^base/dragdrop/drag_utils.h'], ['exclude', '^base/dragdrop/os_exchange_data.cc'], ['exclude', '^base/dragdrop/os_exchange_data.h'], ['exclude', '^base/dragdrop/os_exchange_data_provider_gtk.cc'], ['exclude', '^base/dragdrop/os_exchange_data_provider_gtk.h']]}, {'sources/': [['include', '^base/dragdrop/os_exchange_data.cc']]}]]}], ['toolkit_uses_gtk == 1', {'dependencies': ['../build/linux/system.gyp:gtk'], 'sources': ['gfx/gtk_native_view_id_manager.cc', 'gfx/gtk_native_view_id_manager.h', 'gfx/gtk_preserve_window.cc', 'gfx/gtk_preserve_window.h', 'gfx/gtk_util.cc', 'gfx/gtk_util.h', 'gfx/image/cairo_cached_surface.cc', 'gfx/image/cairo_cached_surface.h']}, {'sources!': ['base/native_theme/native_theme_gtk.cc', 'base/native_theme/native_theme_gtk.h']}], ['OS=="win"', {'sources': ['gfx/gdi_util.cc', 'gfx/gdi_util.h', 'gfx/icon_util.cc', 'gfx/icon_util.h', 'base/native_theme/native_theme_win.cc', 'base/native_theme/native_theme_win.h'], 'sources!': ['base/touch/touch_factory.cc', 'base/touch/touch_factory.h', 'gfx/pango_util.h', 'gfx/pango_util.cc', 'gfx/platform_font_pango.cc', 'gfx/platform_font_pango.h'], 'include_dirs': ['../', '../third_party/wtl/include'], 'msvs_settings': {'VCLinkerTool': {'DelayLoadDLLs': ['d2d1.dll', 'd3d10_1.dll'], 'AdditionalDependencies': ['d2d1.lib', 'd3d10_1.lib']}}, 'link_settings': {'libraries': ['-limm32.lib', '-ld2d1.lib', '-loleacc.lib']}}, {'conditions': [['use_aura==0', {'sources!': ['base/view_prop.cc', 'base/view_prop.h']}]], 'sources!': ['base/dragdrop/drag_source.cc', 'base/dragdrop/drag_source.h', 'base/dragdrop/drag_drop_types.h', 'base/dragdrop/drop_target.cc', 'base/dragdrop/drop_target.h', 'base/dragdrop/os_exchange_data.cc', 'base/native_theme/native_theme_win.cc', 'base/native_theme/native_theme_win.h'], 'sources/': [['exclude', '^base/win/*']]}], ['OS=="mac"', {'sources!': ['base/dragdrop/drag_utils.cc', 'base/dragdrop/drag_utils.h', 'base/touch/touch_factory.cc', 'base/touch/touch_factory.h', 'gfx/pango_util.h', 'gfx/pango_util.cc', 'gfx/platform_font_pango.h', 'gfx/platform_font_pango.cc'], 'link_settings': {'libraries': ['$(SDKROOT)/System/Library/Frameworks/Accelerate.framework', '$(SDKROOT)/System/Library/Frameworks/AudioUnit.framework', '$(SDKROOT)/System/Library/Frameworks/CoreVideo.framework']}}], ['OS=="android"', {'sources!': ['gfx/pango_util.h', 'gfx/pango_util.cc', 'gfx/platform_font_pango.h', 'gfx/platform_font_pango.cc']}], ['use_x11==1', {'all_dependent_settings': {'ldflags': ['-L<(PRODUCT_DIR)'], 'link_settings': {'libraries': ['-lX11 -lXcursor']}}}, {'sources/': [['exclude', 'base/keycodes/keyboard_code_conversion_x.*'], ['exclude', 'base/x/*']]}], ['toolkit_views==0', {'sources!': ['base/x/events_x.cc']}], ['toolkit_views==0 and use_canvas_skia==0', {'sources!': ['gfx/render_text.cc', 'gfx/render_text.h', 'gfx/render_text_linux.cc', 'gfx/render_text_linux.h', 'gfx/render_text_win.cc', 'gfx/render_text_win.h']}], ['OS=="android"', {'sources!': ['base/touch/touch_factory.cc', 'base/touch/touch_factory.h', 'gfx/pango_util.h', 'gfx/pango_util.cc', 'gfx/platform_font_pango.cc', 'gfx/platform_font_pango.h']}], ['OS=="linux"', {'libraries': ['-ldl']}], ['os_bsd==1 and use_system_libjpeg==1', {'include_dirs': ['/usr/local/include']}], ['inside_chromium_build==0', {'dependencies': ['<(DEPTH)/webkit/support/setup_third_party.gyp:third_party_headers']}]]}], 'conditions': [['inside_chromium_build==1', {'includes': ['ui_unittests.gypi'], 'targets': [{'target_name': 'gfx_unittests', 'type': 'none', 'dependencies': ['ui_unittests'], 'actions': [{'message': 'TEMPORARY: Copying ui_unittests to gfx_unittests', 'variables': {'ui_copy_target': '<(PRODUCT_DIR)/ui_unittests<(EXECUTABLE_SUFFIX)', 'ui_copy_dest': '<(PRODUCT_DIR)/gfx_unittests<(EXECUTABLE_SUFFIX)'}, 'inputs': ['<(ui_copy_target)'], 'outputs': ['<(ui_copy_dest)'], 'action_name': 'TEMP_copy_ui_unittests', 'action': ['python', '-c', "import os, shutil; shutil.copyfile('<(ui_copy_target)', '<(ui_copy_dest)'); os.chmod('<(ui_copy_dest)', 0700)"]}]}]}]]} |
first = int (input ('First term '))
ratio = int (input ('Ratio '))
tenth = first + (10-1) * ratio
for c in range (first, tenth + ratio, ratio):
print (c, end = '') | first = int(input('First term '))
ratio = int(input('Ratio '))
tenth = first + (10 - 1) * ratio
for c in range(first, tenth + ratio, ratio):
print(c, end='') |
#!/usr/bin/python
# -*- coding: UTF-8 -*-
fo_src = open("src/cv.tex", "r")
fo_rev = open("REVISION", "r")
fo_print = open("build/cv_print.tex", "w")
fo_screen = open("build/cv_screen.tex", "w")
try:
content = fo_src.read().replace('__REVISION__', fo_rev.read().strip())
fo_print.write(content.replace('__VERSION__', ',print'))
fo_screen.write(content.replace('__VERSION__', ''))
finally:
fo_src.close()
fo_print.close()
fo_screen.close()
| fo_src = open('src/cv.tex', 'r')
fo_rev = open('REVISION', 'r')
fo_print = open('build/cv_print.tex', 'w')
fo_screen = open('build/cv_screen.tex', 'w')
try:
content = fo_src.read().replace('__REVISION__', fo_rev.read().strip())
fo_print.write(content.replace('__VERSION__', ',print'))
fo_screen.write(content.replace('__VERSION__', ''))
finally:
fo_src.close()
fo_print.close()
fo_screen.close() |
# https://atcoder.jp/contests/math-and-algorithm/tasks/abc145_d
M = 10 ** 6 + 1
MOD = 10 ** 9 + 7
f = [0] * M
fi = [0] * M
iv = [0] * M
f[0] = f[1] = 1
fi[0] = fi[1] = 1
iv[1] = 1
for i in range(2, M):
f[i] = f[i - 1] * i % MOD
iv[i] = MOD - iv[MOD % i] * (MOD // i) % MOD
fi[i] = fi[i - 1] * iv[i] % MOD
def comb(n, k):
if n < k or n < 0 or k < 0:
return 0
return f[n] * (fi[k] * fi[n - k] % MOD) % MOD
x, y = map(int, input().split())
if (x + y) % 3 == 0:
a = (x + y) // 3
b = 2 * a - x
print(comb(a, b))
else:
print(0) | m = 10 ** 6 + 1
mod = 10 ** 9 + 7
f = [0] * M
fi = [0] * M
iv = [0] * M
f[0] = f[1] = 1
fi[0] = fi[1] = 1
iv[1] = 1
for i in range(2, M):
f[i] = f[i - 1] * i % MOD
iv[i] = MOD - iv[MOD % i] * (MOD // i) % MOD
fi[i] = fi[i - 1] * iv[i] % MOD
def comb(n, k):
if n < k or n < 0 or k < 0:
return 0
return f[n] * (fi[k] * fi[n - k] % MOD) % MOD
(x, y) = map(int, input().split())
if (x + y) % 3 == 0:
a = (x + y) // 3
b = 2 * a - x
print(comb(a, b))
else:
print(0) |
class Ugly:
def isUgly(self, num: int) -> bool:
num=int(num)
while num:
if num==0:
return False
while num%2 ==0:
num=num/2
while num%3 ==0:
num=num/3
while num%5==0:
num=num/5
if num==1:
return True
elif num!=1:
return False
print(Ugly().isUgly(14))
print(Ugly().isUgly(1))
print(Ugly().isUgly(5))
print(Ugly().isUgly(1928263))
print(Ugly().isUgly(900)) | class Ugly:
def is_ugly(self, num: int) -> bool:
num = int(num)
while num:
if num == 0:
return False
while num % 2 == 0:
num = num / 2
while num % 3 == 0:
num = num / 3
while num % 5 == 0:
num = num / 5
if num == 1:
return True
elif num != 1:
return False
print(ugly().isUgly(14))
print(ugly().isUgly(1))
print(ugly().isUgly(5))
print(ugly().isUgly(1928263))
print(ugly().isUgly(900)) |
class Solution:
def peakIndexInMountainArray(self, A: List[int]) -> int:
if not A:
return None
return A.index(max(A)) | class Solution:
def peak_index_in_mountain_array(self, A: List[int]) -> int:
if not A:
return None
return A.index(max(A)) |
class TreeNode:
def __init__(self,key):
self.left = None
self.right = None
self.data = key
# Function to insert node in tree recursively
def insertNode(root,node):
if root is None:
root = node
else:
if root.data < node.data:
if root.right is None:
root.right = node
else:
insertNode(root.right, node)
else:
if root.left is None:
root.left = node
else:
insertNode(root.left, node)
# Function to print inorder traversal recursively
def inOrderTraversal(root, li):
if root:
inOrderTraversal(root.left, li)
li.append(root.data)
inOrderTraversal(root.right, li)
# Creating a new BST with root as 50
r = TreeNode(55)
insertNode(r,TreeNode(35))
insertNode(r,TreeNode(25))
insertNode(r,TreeNode(45))
insertNode(r,TreeNode(75))
insertNode(r,TreeNode(65))
insertNode(r,TreeNode(85))
# Print inoder traversal of the BST
ll =[]
inOrderTraversal(r, ll)
print(ll) | class Treenode:
def __init__(self, key):
self.left = None
self.right = None
self.data = key
def insert_node(root, node):
if root is None:
root = node
elif root.data < node.data:
if root.right is None:
root.right = node
else:
insert_node(root.right, node)
elif root.left is None:
root.left = node
else:
insert_node(root.left, node)
def in_order_traversal(root, li):
if root:
in_order_traversal(root.left, li)
li.append(root.data)
in_order_traversal(root.right, li)
r = tree_node(55)
insert_node(r, tree_node(35))
insert_node(r, tree_node(25))
insert_node(r, tree_node(45))
insert_node(r, tree_node(75))
insert_node(r, tree_node(65))
insert_node(r, tree_node(85))
ll = []
in_order_traversal(r, ll)
print(ll) |
# Search in a list
def contains(items:[int], x:int) -> bool:
i:int = 0
while i < len(items):
if items[i] == x:
return True
i = i + 1
return False
if contains([4, 8, 15, 16, 23], 15):
print("Item found!") # Prints this
else:
print("Item not found.")
| def contains(items: [int], x: int) -> bool:
i: int = 0
while i < len(items):
if items[i] == x:
return True
i = i + 1
return False
if contains([4, 8, 15, 16, 23], 15):
print('Item found!')
else:
print('Item not found.') |
__title__ = 'sec-edgar-financials'
__description__ = 'Extract financial data from the SEC EDGAR database'
__url__ = 'https://github.com/farhadab/sec-edgar-financials'
__version__ = '0.0.1'
__author__ = 'Farhad Abdolhosseini'
__author_email__ = 'farhadab15@gmail.com'
__license__ = 'MIT'
# __copyright__ = 'Copyright 2019 Farhad Abdolhosseini' | __title__ = 'sec-edgar-financials'
__description__ = 'Extract financial data from the SEC EDGAR database'
__url__ = 'https://github.com/farhadab/sec-edgar-financials'
__version__ = '0.0.1'
__author__ = 'Farhad Abdolhosseini'
__author_email__ = 'farhadab15@gmail.com'
__license__ = 'MIT' |
def binary_search(a,x):
first_pos=0
last_pos=len(a)-1
flag=0
count=0
while(first_pos<=last_pos and flag==0):
count=count+1
mid=(first_pos+last_pos)//2
if(x==a[mid]):
flag==1
print("The element is present at position:",str(mid))
print("Number of iterations:",str(count))
return
else:
if(x<a[mid]):
last_pos=mid-1
else:
first_pos=mid+1
print("The number is not present")
a=[]
for i in range(1,1001):
a.append(i)
binary_search(a,1000) | def binary_search(a, x):
first_pos = 0
last_pos = len(a) - 1
flag = 0
count = 0
while first_pos <= last_pos and flag == 0:
count = count + 1
mid = (first_pos + last_pos) // 2
if x == a[mid]:
flag == 1
print('The element is present at position:', str(mid))
print('Number of iterations:', str(count))
return
elif x < a[mid]:
last_pos = mid - 1
else:
first_pos = mid + 1
print('The number is not present')
a = []
for i in range(1, 1001):
a.append(i)
binary_search(a, 1000) |
#
# PySNMP MIB module Juniper-REDUNDANCY-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Juniper-REDUNDANCY-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:53:26 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, ConstraintsIntersection, SingleValueConstraint, ConstraintsUnion, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ConstraintsIntersection", "SingleValueConstraint", "ConstraintsUnion", "ValueSizeConstraint")
juniMibs, = mibBuilder.importSymbols("Juniper-MIBs", "juniMibs")
NotificationGroup, ObjectGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ObjectGroup", "ModuleCompliance")
sysUpTime, = mibBuilder.importSymbols("SNMPv2-MIB", "sysUpTime")
MibScalar, MibTable, MibTableRow, MibTableColumn, Unsigned32, Gauge32, TimeTicks, IpAddress, iso, ObjectIdentity, Counter32, Integer32, Bits, ModuleIdentity, Counter64, MibIdentifier, NotificationType = mibBuilder.importSymbols("SNMPv2-SMI", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Unsigned32", "Gauge32", "TimeTicks", "IpAddress", "iso", "ObjectIdentity", "Counter32", "Integer32", "Bits", "ModuleIdentity", "Counter64", "MibIdentifier", "NotificationType")
TextualConvention, RowStatus, DisplayString, DateAndTime, TruthValue = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "RowStatus", "DisplayString", "DateAndTime", "TruthValue")
juniRedundancyMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74))
juniRedundancyMIB.setRevisions(('2003-12-12 00:00',))
if mibBuilder.loadTexts: juniRedundancyMIB.setLastUpdated('200312122104Z')
if mibBuilder.loadTexts: juniRedundancyMIB.setOrganization('Juniper Networks, Inc.')
class JuniRedundancyState(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6))
namedValues = NamedValues(("notKnown", 1), ("fileSystemSyncing", 2), ("disabled", 3), ("initializing", 4), ("pending", 5), ("active", 6))
class JuniRedundancyMode(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2))
namedValues = NamedValues(("fileSystemSynchronization", 1), ("highAvailability", 2))
class JuniRedundancyResetReason(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3))
namedValues = NamedValues(("none", 1), ("notKnown", 2), ("userInitiated", 3))
class JuniRedundancySystemActivationType(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3))
namedValues = NamedValues(("reload", 1), ("coldSwitch", 2), ("warmSwitch", 3))
class JuniRedundancyResetType(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))
namedValues = NamedValues(("notKnown", 1), ("srpReload", 2), ("srpSwitchover", 3), ("linecardReload", 4), ("linecardSwitchover", 5))
class JuniRedundancyHistoryCommand(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2))
namedValues = NamedValues(("keep", 1), ("clear", 2))
juniRedundancyNotifications = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 0))
juniRedundancyObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1))
juniRedundancyMIBConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 2))
juniRedundancyStatus = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 1))
juniRedundancyCfg = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 2))
juniRedundancyHistory = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3))
juniRedundancyActiveSlot = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess("readonly")
if mibBuilder.loadTexts: juniRedundancyActiveSlot.setStatus('current')
juniRedundancyActiveSlotState = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 1, 2), JuniRedundancyState()).setMaxAccess("readonly")
if mibBuilder.loadTexts: juniRedundancyActiveSlotState.setStatus('current')
juniRedundancyStandbySlot = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess("readonly")
if mibBuilder.loadTexts: juniRedundancyStandbySlot.setStatus('current')
juniRedundancyStandbySlotState = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 1, 4), JuniRedundancyState()).setMaxAccess("readonly")
if mibBuilder.loadTexts: juniRedundancyStandbySlotState.setStatus('current')
juniRedundancyLastResetReason = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 1, 5), JuniRedundancyResetReason()).setMaxAccess("readonly")
if mibBuilder.loadTexts: juniRedundancyLastResetReason.setStatus('current')
juniRedundancyLastSystemActivationTime = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 1, 6), TimeTicks()).setMaxAccess("readonly")
if mibBuilder.loadTexts: juniRedundancyLastSystemActivationTime.setStatus('current')
juniRedundancyLastSystemActivationType = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 1, 7), JuniRedundancySystemActivationType()).setMaxAccess("readonly")
if mibBuilder.loadTexts: juniRedundancyLastSystemActivationType.setStatus('current')
juniRedundancyHaActiveTime = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 1, 8), TimeTicks()).setMaxAccess("readonly")
if mibBuilder.loadTexts: juniRedundancyHaActiveTime.setStatus('current')
juniRedundancyNotifsEnabled = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 2, 1), TruthValue().clone('true')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: juniRedundancyNotifsEnabled.setStatus('current')
juniRedundancyCfgRedundancyMode = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 2, 2), JuniRedundancyMode().clone('fileSystemSynchronization')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: juniRedundancyCfgRedundancyMode.setStatus('current')
juniRedundancySystemActivationHistoryTableMaxLength = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 50))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: juniRedundancySystemActivationHistoryTableMaxLength.setStatus('current')
juniRedundancySystemActivationHistoryCommand = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 2), JuniRedundancyHistoryCommand().clone('keep')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: juniRedundancySystemActivationHistoryCommand.setStatus('current')
juniRedundancySystemActivationHistoryTable = MibTable((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3), )
if mibBuilder.loadTexts: juniRedundancySystemActivationHistoryTable.setStatus('current')
juniRedundancySystemActivationHistoryEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3, 1), ).setIndexNames((0, "Juniper-REDUNDANCY-MIB", "juniRedundancySystemActivationHistoryIndex"))
if mibBuilder.loadTexts: juniRedundancySystemActivationHistoryEntry.setStatus('current')
juniRedundancySystemActivationHistoryIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3, 1, 1), Integer32())
if mibBuilder.loadTexts: juniRedundancySystemActivationHistoryIndex.setStatus('current')
juniRedundancyHistoryResetType = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3, 1, 2), JuniRedundancyResetType()).setMaxAccess("readonly")
if mibBuilder.loadTexts: juniRedundancyHistoryResetType.setStatus('current')
juniRedundancyHistoryActivationType = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3, 1, 3), JuniRedundancySystemActivationType()).setMaxAccess("readonly")
if mibBuilder.loadTexts: juniRedundancyHistoryActivationType.setStatus('current')
juniRedundancyHistoryPrevActiveSlot = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess("readonly")
if mibBuilder.loadTexts: juniRedundancyHistoryPrevActiveSlot.setStatus('current')
juniRedundancyHistoryPrevActiveRelease = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3, 1, 5), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: juniRedundancyHistoryPrevActiveRelease.setStatus('current')
juniRedundancyHistoryCurrActiveSlot = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3, 1, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess("readonly")
if mibBuilder.loadTexts: juniRedundancyHistoryCurrActiveSlot.setStatus('current')
juniRedundancyHistoryCurrActiveRelease = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3, 1, 7), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: juniRedundancyHistoryCurrActiveRelease.setStatus('current')
juniRedundancyHistoryResetReason = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3, 1, 8), JuniRedundancyResetReason()).setMaxAccess("readonly")
if mibBuilder.loadTexts: juniRedundancyHistoryResetReason.setStatus('current')
juniRedundancyHistoryActivationTime = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3, 1, 9), DateAndTime()).setMaxAccess("readonly")
if mibBuilder.loadTexts: juniRedundancyHistoryActivationTime.setStatus('current')
juniRedundancyHistoryReloads = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 4), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: juniRedundancyHistoryReloads.setStatus('current')
juniRedundancyHistoryColdSwitchovers = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 5), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: juniRedundancyHistoryColdSwitchovers.setStatus('current')
juniRedundancyHistoryWarmSwitchovers = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 6), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: juniRedundancyHistoryWarmSwitchovers.setStatus('current')
juniRedundancyColdSwitchoverNotification = NotificationType((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 0, 1)).setObjects(("Juniper-REDUNDANCY-MIB", "juniRedundancyActiveSlot"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyLastResetReason"))
if mibBuilder.loadTexts: juniRedundancyColdSwitchoverNotification.setStatus('current')
juniRedundancyWarmSwitchoverNotification = NotificationType((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 0, 2)).setObjects(("Juniper-REDUNDANCY-MIB", "juniRedundancyActiveSlot"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyLastResetReason"))
if mibBuilder.loadTexts: juniRedundancyWarmSwitchoverNotification.setStatus('current')
juniRedundancyStateEnabledNotification = NotificationType((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 0, 3)).setObjects(("Juniper-REDUNDANCY-MIB", "juniRedundancyActiveSlot"))
if mibBuilder.loadTexts: juniRedundancyStateEnabledNotification.setStatus('current')
juniRedundancyStateDisabledNotification = NotificationType((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 0, 4)).setObjects(("Juniper-REDUNDANCY-MIB", "juniRedundancyActiveSlot"))
if mibBuilder.loadTexts: juniRedundancyStateDisabledNotification.setStatus('current')
juniRedundancyStatePendingNotification = NotificationType((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 0, 5)).setObjects(("Juniper-REDUNDANCY-MIB", "juniRedundancyActiveSlot"))
if mibBuilder.loadTexts: juniRedundancyStatePendingNotification.setStatus('current')
juniRedundancyModeNotification = NotificationType((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 0, 6)).setObjects(("Juniper-REDUNDANCY-MIB", "juniRedundancyActiveSlot"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyCfgRedundancyMode"))
if mibBuilder.loadTexts: juniRedundancyModeNotification.setStatus('current')
juniRedundancyMIBCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 2, 1))
juniRedundancyMIBGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 2, 2))
juniRedundancyMIBCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 2, 1, 1)).setObjects(("Juniper-REDUNDANCY-MIB", "juniRedundancyStatusGroup"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyCfgGroup"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyHistoryGroup"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyNotificationGroup"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juniRedundancyMIBCompliance = juniRedundancyMIBCompliance.setStatus('current')
juniRedundancyStatusGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 2, 2, 1)).setObjects(("Juniper-REDUNDANCY-MIB", "juniRedundancyActiveSlot"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyActiveSlotState"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyStandbySlot"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyStandbySlotState"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyLastResetReason"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyLastSystemActivationTime"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyLastSystemActivationType"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyHaActiveTime"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juniRedundancyStatusGroup = juniRedundancyStatusGroup.setStatus('current')
juniRedundancyCfgGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 2, 2, 2)).setObjects(("Juniper-REDUNDANCY-MIB", "juniRedundancyNotifsEnabled"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyCfgRedundancyMode"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juniRedundancyCfgGroup = juniRedundancyCfgGroup.setStatus('current')
juniRedundancyHistoryGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 2, 2, 3)).setObjects(("Juniper-REDUNDANCY-MIB", "juniRedundancySystemActivationHistoryTableMaxLength"), ("Juniper-REDUNDANCY-MIB", "juniRedundancySystemActivationHistoryCommand"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyHistoryResetType"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyHistoryActivationType"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyHistoryPrevActiveSlot"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyHistoryPrevActiveRelease"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyHistoryCurrActiveSlot"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyHistoryCurrActiveRelease"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyHistoryResetReason"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyHistoryActivationTime"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyHistoryReloads"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyHistoryColdSwitchovers"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyHistoryWarmSwitchovers"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juniRedundancyHistoryGroup = juniRedundancyHistoryGroup.setStatus('current')
juniRedundancyNotificationGroup = NotificationGroup((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 2, 2, 4)).setObjects(("Juniper-REDUNDANCY-MIB", "juniRedundancyColdSwitchoverNotification"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyWarmSwitchoverNotification"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyStateEnabledNotification"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyStateDisabledNotification"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyStatePendingNotification"), ("Juniper-REDUNDANCY-MIB", "juniRedundancyModeNotification"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juniRedundancyNotificationGroup = juniRedundancyNotificationGroup.setStatus('current')
mibBuilder.exportSymbols("Juniper-REDUNDANCY-MIB", juniRedundancyStatusGroup=juniRedundancyStatusGroup, juniRedundancyHistoryGroup=juniRedundancyHistoryGroup, JuniRedundancyHistoryCommand=JuniRedundancyHistoryCommand, juniRedundancyStatePendingNotification=juniRedundancyStatePendingNotification, juniRedundancySystemActivationHistoryCommand=juniRedundancySystemActivationHistoryCommand, juniRedundancyStateEnabledNotification=juniRedundancyStateEnabledNotification, juniRedundancySystemActivationHistoryIndex=juniRedundancySystemActivationHistoryIndex, PYSNMP_MODULE_ID=juniRedundancyMIB, juniRedundancyMIBCompliance=juniRedundancyMIBCompliance, JuniRedundancyState=JuniRedundancyState, juniRedundancyStateDisabledNotification=juniRedundancyStateDisabledNotification, juniRedundancyMIBConformance=juniRedundancyMIBConformance, juniRedundancyNotifsEnabled=juniRedundancyNotifsEnabled, juniRedundancySystemActivationHistoryTable=juniRedundancySystemActivationHistoryTable, juniRedundancyCfgGroup=juniRedundancyCfgGroup, juniRedundancyModeNotification=juniRedundancyModeNotification, juniRedundancyCfg=juniRedundancyCfg, juniRedundancyHistoryColdSwitchovers=juniRedundancyHistoryColdSwitchovers, juniRedundancyLastSystemActivationTime=juniRedundancyLastSystemActivationTime, juniRedundancyColdSwitchoverNotification=juniRedundancyColdSwitchoverNotification, juniRedundancyActiveSlotState=juniRedundancyActiveSlotState, juniRedundancyHistoryActivationType=juniRedundancyHistoryActivationType, JuniRedundancyMode=JuniRedundancyMode, juniRedundancyHistoryCurrActiveRelease=juniRedundancyHistoryCurrActiveRelease, juniRedundancyHistoryPrevActiveSlot=juniRedundancyHistoryPrevActiveSlot, juniRedundancyStatus=juniRedundancyStatus, juniRedundancyHistoryResetType=juniRedundancyHistoryResetType, juniRedundancyNotificationGroup=juniRedundancyNotificationGroup, juniRedundancyHistoryReloads=juniRedundancyHistoryReloads, juniRedundancyNotifications=juniRedundancyNotifications, juniRedundancyObjects=juniRedundancyObjects, juniRedundancyMIB=juniRedundancyMIB, juniRedundancyHistory=juniRedundancyHistory, juniRedundancySystemActivationHistoryEntry=juniRedundancySystemActivationHistoryEntry, JuniRedundancyResetReason=JuniRedundancyResetReason, juniRedundancyCfgRedundancyMode=juniRedundancyCfgRedundancyMode, juniRedundancySystemActivationHistoryTableMaxLength=juniRedundancySystemActivationHistoryTableMaxLength, juniRedundancyHistoryWarmSwitchovers=juniRedundancyHistoryWarmSwitchovers, juniRedundancyLastResetReason=juniRedundancyLastResetReason, juniRedundancyStandbySlot=juniRedundancyStandbySlot, juniRedundancyHistoryResetReason=juniRedundancyHistoryResetReason, juniRedundancyMIBGroups=juniRedundancyMIBGroups, JuniRedundancyResetType=JuniRedundancyResetType, juniRedundancyMIBCompliances=juniRedundancyMIBCompliances, JuniRedundancySystemActivationType=JuniRedundancySystemActivationType, juniRedundancyHistoryCurrActiveSlot=juniRedundancyHistoryCurrActiveSlot, juniRedundancyHaActiveTime=juniRedundancyHaActiveTime, juniRedundancyHistoryPrevActiveRelease=juniRedundancyHistoryPrevActiveRelease, juniRedundancyHistoryActivationTime=juniRedundancyHistoryActivationTime, juniRedundancyWarmSwitchoverNotification=juniRedundancyWarmSwitchoverNotification, juniRedundancyLastSystemActivationType=juniRedundancyLastSystemActivationType, juniRedundancyStandbySlotState=juniRedundancyStandbySlotState, juniRedundancyActiveSlot=juniRedundancyActiveSlot)
| (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_intersection, single_value_constraint, constraints_union, value_size_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueRangeConstraint', 'ConstraintsIntersection', 'SingleValueConstraint', 'ConstraintsUnion', 'ValueSizeConstraint')
(juni_mibs,) = mibBuilder.importSymbols('Juniper-MIBs', 'juniMibs')
(notification_group, object_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ObjectGroup', 'ModuleCompliance')
(sys_up_time,) = mibBuilder.importSymbols('SNMPv2-MIB', 'sysUpTime')
(mib_scalar, mib_table, mib_table_row, mib_table_column, unsigned32, gauge32, time_ticks, ip_address, iso, object_identity, counter32, integer32, bits, module_identity, counter64, mib_identifier, notification_type) = mibBuilder.importSymbols('SNMPv2-SMI', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Unsigned32', 'Gauge32', 'TimeTicks', 'IpAddress', 'iso', 'ObjectIdentity', 'Counter32', 'Integer32', 'Bits', 'ModuleIdentity', 'Counter64', 'MibIdentifier', 'NotificationType')
(textual_convention, row_status, display_string, date_and_time, truth_value) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'RowStatus', 'DisplayString', 'DateAndTime', 'TruthValue')
juni_redundancy_mib = module_identity((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74))
juniRedundancyMIB.setRevisions(('2003-12-12 00:00',))
if mibBuilder.loadTexts:
juniRedundancyMIB.setLastUpdated('200312122104Z')
if mibBuilder.loadTexts:
juniRedundancyMIB.setOrganization('Juniper Networks, Inc.')
class Juniredundancystate(TextualConvention, Integer32):
status = 'current'
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6))
named_values = named_values(('notKnown', 1), ('fileSystemSyncing', 2), ('disabled', 3), ('initializing', 4), ('pending', 5), ('active', 6))
class Juniredundancymode(TextualConvention, Integer32):
status = 'current'
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2))
named_values = named_values(('fileSystemSynchronization', 1), ('highAvailability', 2))
class Juniredundancyresetreason(TextualConvention, Integer32):
status = 'current'
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3))
named_values = named_values(('none', 1), ('notKnown', 2), ('userInitiated', 3))
class Juniredundancysystemactivationtype(TextualConvention, Integer32):
status = 'current'
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3))
named_values = named_values(('reload', 1), ('coldSwitch', 2), ('warmSwitch', 3))
class Juniredundancyresettype(TextualConvention, Integer32):
status = 'current'
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5))
named_values = named_values(('notKnown', 1), ('srpReload', 2), ('srpSwitchover', 3), ('linecardReload', 4), ('linecardSwitchover', 5))
class Juniredundancyhistorycommand(TextualConvention, Integer32):
status = 'current'
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2))
named_values = named_values(('keep', 1), ('clear', 2))
juni_redundancy_notifications = mib_identifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 0))
juni_redundancy_objects = mib_identifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1))
juni_redundancy_mib_conformance = mib_identifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 2))
juni_redundancy_status = mib_identifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 1))
juni_redundancy_cfg = mib_identifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 2))
juni_redundancy_history = mib_identifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3))
juni_redundancy_active_slot = mib_scalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(0, 255))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
juniRedundancyActiveSlot.setStatus('current')
juni_redundancy_active_slot_state = mib_scalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 1, 2), juni_redundancy_state()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
juniRedundancyActiveSlotState.setStatus('current')
juni_redundancy_standby_slot = mib_scalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 1, 3), integer32().subtype(subtypeSpec=value_range_constraint(0, 255))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
juniRedundancyStandbySlot.setStatus('current')
juni_redundancy_standby_slot_state = mib_scalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 1, 4), juni_redundancy_state()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
juniRedundancyStandbySlotState.setStatus('current')
juni_redundancy_last_reset_reason = mib_scalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 1, 5), juni_redundancy_reset_reason()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
juniRedundancyLastResetReason.setStatus('current')
juni_redundancy_last_system_activation_time = mib_scalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 1, 6), time_ticks()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
juniRedundancyLastSystemActivationTime.setStatus('current')
juni_redundancy_last_system_activation_type = mib_scalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 1, 7), juni_redundancy_system_activation_type()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
juniRedundancyLastSystemActivationType.setStatus('current')
juni_redundancy_ha_active_time = mib_scalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 1, 8), time_ticks()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
juniRedundancyHaActiveTime.setStatus('current')
juni_redundancy_notifs_enabled = mib_scalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 2, 1), truth_value().clone('true')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
juniRedundancyNotifsEnabled.setStatus('current')
juni_redundancy_cfg_redundancy_mode = mib_scalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 2, 2), juni_redundancy_mode().clone('fileSystemSynchronization')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
juniRedundancyCfgRedundancyMode.setStatus('current')
juni_redundancy_system_activation_history_table_max_length = mib_scalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 1), integer32().subtype(subtypeSpec=value_range_constraint(0, 50))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
juniRedundancySystemActivationHistoryTableMaxLength.setStatus('current')
juni_redundancy_system_activation_history_command = mib_scalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 2), juni_redundancy_history_command().clone('keep')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
juniRedundancySystemActivationHistoryCommand.setStatus('current')
juni_redundancy_system_activation_history_table = mib_table((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3))
if mibBuilder.loadTexts:
juniRedundancySystemActivationHistoryTable.setStatus('current')
juni_redundancy_system_activation_history_entry = mib_table_row((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3, 1)).setIndexNames((0, 'Juniper-REDUNDANCY-MIB', 'juniRedundancySystemActivationHistoryIndex'))
if mibBuilder.loadTexts:
juniRedundancySystemActivationHistoryEntry.setStatus('current')
juni_redundancy_system_activation_history_index = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3, 1, 1), integer32())
if mibBuilder.loadTexts:
juniRedundancySystemActivationHistoryIndex.setStatus('current')
juni_redundancy_history_reset_type = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3, 1, 2), juni_redundancy_reset_type()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
juniRedundancyHistoryResetType.setStatus('current')
juni_redundancy_history_activation_type = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3, 1, 3), juni_redundancy_system_activation_type()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
juniRedundancyHistoryActivationType.setStatus('current')
juni_redundancy_history_prev_active_slot = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3, 1, 4), integer32().subtype(subtypeSpec=value_range_constraint(0, 255))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
juniRedundancyHistoryPrevActiveSlot.setStatus('current')
juni_redundancy_history_prev_active_release = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3, 1, 5), display_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
juniRedundancyHistoryPrevActiveRelease.setStatus('current')
juni_redundancy_history_curr_active_slot = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3, 1, 6), integer32().subtype(subtypeSpec=value_range_constraint(0, 255))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
juniRedundancyHistoryCurrActiveSlot.setStatus('current')
juni_redundancy_history_curr_active_release = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3, 1, 7), display_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
juniRedundancyHistoryCurrActiveRelease.setStatus('current')
juni_redundancy_history_reset_reason = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3, 1, 8), juni_redundancy_reset_reason()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
juniRedundancyHistoryResetReason.setStatus('current')
juni_redundancy_history_activation_time = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 3, 1, 9), date_and_time()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
juniRedundancyHistoryActivationTime.setStatus('current')
juni_redundancy_history_reloads = mib_scalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 4), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
juniRedundancyHistoryReloads.setStatus('current')
juni_redundancy_history_cold_switchovers = mib_scalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 5), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
juniRedundancyHistoryColdSwitchovers.setStatus('current')
juni_redundancy_history_warm_switchovers = mib_scalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 1, 3, 6), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
juniRedundancyHistoryWarmSwitchovers.setStatus('current')
juni_redundancy_cold_switchover_notification = notification_type((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 0, 1)).setObjects(('Juniper-REDUNDANCY-MIB', 'juniRedundancyActiveSlot'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyLastResetReason'))
if mibBuilder.loadTexts:
juniRedundancyColdSwitchoverNotification.setStatus('current')
juni_redundancy_warm_switchover_notification = notification_type((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 0, 2)).setObjects(('Juniper-REDUNDANCY-MIB', 'juniRedundancyActiveSlot'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyLastResetReason'))
if mibBuilder.loadTexts:
juniRedundancyWarmSwitchoverNotification.setStatus('current')
juni_redundancy_state_enabled_notification = notification_type((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 0, 3)).setObjects(('Juniper-REDUNDANCY-MIB', 'juniRedundancyActiveSlot'))
if mibBuilder.loadTexts:
juniRedundancyStateEnabledNotification.setStatus('current')
juni_redundancy_state_disabled_notification = notification_type((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 0, 4)).setObjects(('Juniper-REDUNDANCY-MIB', 'juniRedundancyActiveSlot'))
if mibBuilder.loadTexts:
juniRedundancyStateDisabledNotification.setStatus('current')
juni_redundancy_state_pending_notification = notification_type((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 0, 5)).setObjects(('Juniper-REDUNDANCY-MIB', 'juniRedundancyActiveSlot'))
if mibBuilder.loadTexts:
juniRedundancyStatePendingNotification.setStatus('current')
juni_redundancy_mode_notification = notification_type((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 0, 6)).setObjects(('Juniper-REDUNDANCY-MIB', 'juniRedundancyActiveSlot'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyCfgRedundancyMode'))
if mibBuilder.loadTexts:
juniRedundancyModeNotification.setStatus('current')
juni_redundancy_mib_compliances = mib_identifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 2, 1))
juni_redundancy_mib_groups = mib_identifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 2, 2))
juni_redundancy_mib_compliance = module_compliance((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 2, 1, 1)).setObjects(('Juniper-REDUNDANCY-MIB', 'juniRedundancyStatusGroup'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyCfgGroup'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyHistoryGroup'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyNotificationGroup'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juni_redundancy_mib_compliance = juniRedundancyMIBCompliance.setStatus('current')
juni_redundancy_status_group = object_group((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 2, 2, 1)).setObjects(('Juniper-REDUNDANCY-MIB', 'juniRedundancyActiveSlot'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyActiveSlotState'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyStandbySlot'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyStandbySlotState'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyLastResetReason'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyLastSystemActivationTime'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyLastSystemActivationType'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyHaActiveTime'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juni_redundancy_status_group = juniRedundancyStatusGroup.setStatus('current')
juni_redundancy_cfg_group = object_group((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 2, 2, 2)).setObjects(('Juniper-REDUNDANCY-MIB', 'juniRedundancyNotifsEnabled'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyCfgRedundancyMode'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juni_redundancy_cfg_group = juniRedundancyCfgGroup.setStatus('current')
juni_redundancy_history_group = object_group((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 2, 2, 3)).setObjects(('Juniper-REDUNDANCY-MIB', 'juniRedundancySystemActivationHistoryTableMaxLength'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancySystemActivationHistoryCommand'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyHistoryResetType'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyHistoryActivationType'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyHistoryPrevActiveSlot'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyHistoryPrevActiveRelease'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyHistoryCurrActiveSlot'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyHistoryCurrActiveRelease'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyHistoryResetReason'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyHistoryActivationTime'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyHistoryReloads'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyHistoryColdSwitchovers'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyHistoryWarmSwitchovers'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juni_redundancy_history_group = juniRedundancyHistoryGroup.setStatus('current')
juni_redundancy_notification_group = notification_group((1, 3, 6, 1, 4, 1, 4874, 2, 2, 74, 2, 2, 4)).setObjects(('Juniper-REDUNDANCY-MIB', 'juniRedundancyColdSwitchoverNotification'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyWarmSwitchoverNotification'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyStateEnabledNotification'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyStateDisabledNotification'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyStatePendingNotification'), ('Juniper-REDUNDANCY-MIB', 'juniRedundancyModeNotification'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juni_redundancy_notification_group = juniRedundancyNotificationGroup.setStatus('current')
mibBuilder.exportSymbols('Juniper-REDUNDANCY-MIB', juniRedundancyStatusGroup=juniRedundancyStatusGroup, juniRedundancyHistoryGroup=juniRedundancyHistoryGroup, JuniRedundancyHistoryCommand=JuniRedundancyHistoryCommand, juniRedundancyStatePendingNotification=juniRedundancyStatePendingNotification, juniRedundancySystemActivationHistoryCommand=juniRedundancySystemActivationHistoryCommand, juniRedundancyStateEnabledNotification=juniRedundancyStateEnabledNotification, juniRedundancySystemActivationHistoryIndex=juniRedundancySystemActivationHistoryIndex, PYSNMP_MODULE_ID=juniRedundancyMIB, juniRedundancyMIBCompliance=juniRedundancyMIBCompliance, JuniRedundancyState=JuniRedundancyState, juniRedundancyStateDisabledNotification=juniRedundancyStateDisabledNotification, juniRedundancyMIBConformance=juniRedundancyMIBConformance, juniRedundancyNotifsEnabled=juniRedundancyNotifsEnabled, juniRedundancySystemActivationHistoryTable=juniRedundancySystemActivationHistoryTable, juniRedundancyCfgGroup=juniRedundancyCfgGroup, juniRedundancyModeNotification=juniRedundancyModeNotification, juniRedundancyCfg=juniRedundancyCfg, juniRedundancyHistoryColdSwitchovers=juniRedundancyHistoryColdSwitchovers, juniRedundancyLastSystemActivationTime=juniRedundancyLastSystemActivationTime, juniRedundancyColdSwitchoverNotification=juniRedundancyColdSwitchoverNotification, juniRedundancyActiveSlotState=juniRedundancyActiveSlotState, juniRedundancyHistoryActivationType=juniRedundancyHistoryActivationType, JuniRedundancyMode=JuniRedundancyMode, juniRedundancyHistoryCurrActiveRelease=juniRedundancyHistoryCurrActiveRelease, juniRedundancyHistoryPrevActiveSlot=juniRedundancyHistoryPrevActiveSlot, juniRedundancyStatus=juniRedundancyStatus, juniRedundancyHistoryResetType=juniRedundancyHistoryResetType, juniRedundancyNotificationGroup=juniRedundancyNotificationGroup, juniRedundancyHistoryReloads=juniRedundancyHistoryReloads, juniRedundancyNotifications=juniRedundancyNotifications, juniRedundancyObjects=juniRedundancyObjects, juniRedundancyMIB=juniRedundancyMIB, juniRedundancyHistory=juniRedundancyHistory, juniRedundancySystemActivationHistoryEntry=juniRedundancySystemActivationHistoryEntry, JuniRedundancyResetReason=JuniRedundancyResetReason, juniRedundancyCfgRedundancyMode=juniRedundancyCfgRedundancyMode, juniRedundancySystemActivationHistoryTableMaxLength=juniRedundancySystemActivationHistoryTableMaxLength, juniRedundancyHistoryWarmSwitchovers=juniRedundancyHistoryWarmSwitchovers, juniRedundancyLastResetReason=juniRedundancyLastResetReason, juniRedundancyStandbySlot=juniRedundancyStandbySlot, juniRedundancyHistoryResetReason=juniRedundancyHistoryResetReason, juniRedundancyMIBGroups=juniRedundancyMIBGroups, JuniRedundancyResetType=JuniRedundancyResetType, juniRedundancyMIBCompliances=juniRedundancyMIBCompliances, JuniRedundancySystemActivationType=JuniRedundancySystemActivationType, juniRedundancyHistoryCurrActiveSlot=juniRedundancyHistoryCurrActiveSlot, juniRedundancyHaActiveTime=juniRedundancyHaActiveTime, juniRedundancyHistoryPrevActiveRelease=juniRedundancyHistoryPrevActiveRelease, juniRedundancyHistoryActivationTime=juniRedundancyHistoryActivationTime, juniRedundancyWarmSwitchoverNotification=juniRedundancyWarmSwitchoverNotification, juniRedundancyLastSystemActivationType=juniRedundancyLastSystemActivationType, juniRedundancyStandbySlotState=juniRedundancyStandbySlotState, juniRedundancyActiveSlot=juniRedundancyActiveSlot) |
# -*- coding: utf-8 -*-
# AtCoder Beginner Contest
if __name__ == '__main__':
n = int(input())
if n == 100:
print('Perfect')
elif 90 <= n <= 99:
print('Great')
elif 60 <= n <= 89:
print('Good')
else:
print('Bad')
| if __name__ == '__main__':
n = int(input())
if n == 100:
print('Perfect')
elif 90 <= n <= 99:
print('Great')
elif 60 <= n <= 89:
print('Good')
else:
print('Bad') |
MCTS_CONFIG = {
"c_puct": 5.0,
"c_iterations": 400,
}
DATA_CONFIG = {
# one of "random", "botzone", "mcts", "alpha_zero"
"schedule": {
"supervisor": ("traditional_mcts", {
"c_puct": MCTS_CONFIG["c_puct"],
"c_iterations": 20000
}),
"candidates": [
("random_mcts", MCTS_CONFIG),
("rave_mcts", MCTS_CONFIG),
("botzone", {"program": "deeeeep"}),
("botzone", {"program": "genm"}),
None
]
},
"process_num": 2,
"buffer_size": 10000,
"data_path": "./data/training_data",
"data_files": [
# after read out,
# file name will be marked ".consumed"
]
}
TRAINING_CONFIG = {
"num_epoches": 5,
"batch_size": 512,
"learning_rate": 2e-3,
"momentum": 0.9,
"kl_target": 0.02,
"eval_period": 100,
"eval_rounds": 11,
"model_file": "latest",
"model_path": "./data/trained_models"
}
| mcts_config = {'c_puct': 5.0, 'c_iterations': 400}
data_config = {'schedule': {'supervisor': ('traditional_mcts', {'c_puct': MCTS_CONFIG['c_puct'], 'c_iterations': 20000}), 'candidates': [('random_mcts', MCTS_CONFIG), ('rave_mcts', MCTS_CONFIG), ('botzone', {'program': 'deeeeep'}), ('botzone', {'program': 'genm'}), None]}, 'process_num': 2, 'buffer_size': 10000, 'data_path': './data/training_data', 'data_files': []}
training_config = {'num_epoches': 5, 'batch_size': 512, 'learning_rate': 0.002, 'momentum': 0.9, 'kl_target': 0.02, 'eval_period': 100, 'eval_rounds': 11, 'model_file': 'latest', 'model_path': './data/trained_models'} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.