content stringlengths 7 1.05M |
|---|
"""
http://adventofcode.com/2017/day/9
"""
def cleanStream(stream):
streamToClean = stream[:]
isCleaned = False
while not isCleaned:
idx = [i for i,item in enumerate(streamToClean) if item=="!"]
if len(idx)<1:
isCleaned = True
break
streamToClean = streamToClean[:idx[0]]+streamToClean[idx[0]+2:]
return streamToClean
def cleanGarbage(stream):
streamToClean = cleanStream(stream)
garbage = ""
hasGarbage = True
while hasGarbage:
idxOpen = [i for i,item in enumerate(streamToClean) if item=="<"]
idxClose = [i for i,item in enumerate(streamToClean) if item==">"]
if len(idxOpen)<1 and len(idxClose)<1:
hasGarbage = False
break
elif len(idxOpen)<1 or len(idxClose)<1:
print("Mismatch in garbage parentheses")
break
garbage = garbage + streamToClean[idxOpen[0]+1:idxClose[0]]
streamToClean = streamToClean[:idxOpen[0]]+streamToClean[idxClose[0]+1:]
return streamToClean, garbage
assert cleanGarbage("{<<<<>}") == ("{}","<<<")
assert cleanGarbage("{<{!>}>}") == ("{}","{}")
assert cleanGarbage("{<!!>}") == ("{}","")
assert cleanGarbage("{<random characters>}") == ("{}","random characters")
assert cleanGarbage("{<>}") == ("{}","")
assert cleanGarbage("{<!!!>>}") == ("{}","")
assert cleanGarbage('{<{o"i!a,<{i<a>}') == ("{}",'{o"i,<{i<a')
def calculateScore(stream):
streamToScore,garbage = cleanGarbage(stream)
score = 0
currentPoint = 0
for bracket in streamToScore:
if bracket == "{":
currentPoint += 1
score += currentPoint
elif bracket =="}":
currentPoint -= 1
if currentPoint != 0:
print("Mismatch in parentheses")
return score
assert calculateScore(cleanGarbage('{}')[0]) == 1
assert calculateScore(cleanGarbage('{{{}}}')[0]) == 6
assert calculateScore(cleanGarbage('{{},{}}')[0]) == 5
assert calculateScore(cleanGarbage('{{{},{},{{}}}}')[0]) == 16
assert calculateScore(cleanGarbage('{<a>,<a>,<a>,<a>}')[0]) == 1
assert calculateScore(cleanGarbage('{{<ab>},{<ab>},{<ab>},{<ab>}}')[0]) == 9
assert calculateScore(cleanGarbage('{{<!!>},{<!!>},{<!!>},{<!!>}}')[0]) == 9
assert calculateScore(cleanGarbage('{{<a!>},{<a!>},{<a!>},{<ab>}}')[0]) == 3
if __name__ == "__main__":
with open("day09_input.txt") as f:
# part 1
cleanedStream,garbage = cleanGarbage(f.read())
print(calculateScore(cleanedStream))
# part 2
print(len(garbage))
|
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 14 20:08:32 2019
@author: Parikshith.H
"""
class Date:
def __init__(self,day,month,year):
self.__day=day
self.__month=month
self.__year=year
def get_day(self):
return self.__day
def get_month(self):
return self.__month
def get_year(self):
return self.__year
def set_day(self,value):
self.__day=value
def set_month(self,value):
self.__month=value
def set_year(self,value):
self.__year=value
class customer:
def __init__(self,name,num,dob):
self.__name=name
self.__num=num
self.__dob=dob
def get_name(self):
return self.__name
def get_num(self):
return self.__num
def get_dob(self):
return self.__dob
def set_name(self,value):
self.__name=value
def set_num(self,value):
self.__num=value
def set_dob(self,value):
self.__dob=value
d=Date(13,11,1998)
c1=customer("Manoj",7204444566,d)
print(c1.get_name(),c1.get_num(),c1.get_dob().get_day()) #Manoj 7203344566 13
temp=c1.get_dob()
print(temp.get_day()) #13
temp.set_year(1999)
print(temp.get_day(),temp.get_month(),temp.get_year()) #13 11 1999
c1.get_dob().set_year(2000)
# =============================================================================
# #output:
# Manoj 7204444566 13
# 13
# 13 11 1999
# =============================================================================
|
class Book():
def __init__(self, name) -> None:
self._name = name
def get_name(self):
return self._name
class BookShelf():
def __init__(self) -> None:
self._books: list[Book] = []
def append(self, book: Book):
self._books.append(book)
def get_book_at(self, index):
return self._books[index]
def is_valid(self, index):
return 0 <= index < len(self._books)
bookShelf = BookShelf()
bookShelf.append(Book("Around the World in 80 days"))
bookShelf.append(Book("Bible"))
bookShelf.append(Book("Cinderella"))
bookShelf.append(Book("Daddy-Long-Legs"))
index = 0
while bookShelf.is_valid(index):
book = bookShelf.get_book_at(index)
print(book.get_name())
index += 1
|
'''
在一条环路上有 N 个加油站,其中第 i 个加油站有汽油gas[i],并且从第_i_个加油站前往第_i_+1个加油站需要消耗汽油cost[i]。
你有一辆油箱容量无限大的汽车,现在要从某一个加油站出发绕环路一周,一开始油箱为空。
求可环绕环路一周时出发的加油站的编号,若不存在环绕一周的方案,则返回-1。
Example
样例 1:
输入:gas[i]=[1,1,3,1],cost[i]=[2,2,1,1]
输出:2
样例 2:
输入:gas[i]=[1,1,3,1],cost[i]=[2,2,10,1]
输出:-1
Challenge
O(n)时间和O(1)额外空间
Notice
数据保证答案唯一。
'''
class Solution:
"""
@param gas: An array of integers
@param cost: An array of integers
@return: An integer
https://www.bilibili.com/video/BV13k4y1o7SU?from=search&seid=5073604284006055839
"""
def canCompleteCircuit(self, gas, cost):
# write your code here
sum=0
spend=0
for i in range(len(gas)):
sum+=gas[i]
sum-=cost[0]
if sum>=0:
continue
sum=0
|
"""from random import random
class TestDocTrackingMlflow:
def test_doc(self):
#### DOC START
from dbnd import task
from mlflow import start_run, end_run
from mlflow import log_metric, log_param
@task
def calculate_alpha():
start_run()
# params
log_param("alpha", random())
log_param("beta", random())
# metrics
log_metric("accuracy", random())
log_metric("coefficient", random())
end_run()
#### DOC END
calculate_alpha.dbnd_run()"""
|
# -*- coding: utf-8 -*-
def main():
s = input()
k = int(input())
count = 0
for si in s:
if si == '1':
count += 1
else:
break
if s[0] != '1':
print(s[0])
else:
if k <= count:
print(1)
else:
print(s[count])
if __name__ == '__main__':
main()
|
values = input("please fill value: ")
previous = []
result = []
def isAEIOU(value):
# value = str(value)
if value.upper() == 'A':
return True
elif value.upper() == 'E':
return True
elif value.upper() == 'I':
return True
elif value.upper() == 'O':
return True
elif value.upper() == 'U':
return True
return False
for value in values :
if isAEIOU(value) :
previous.append(value)
if len(previous) > 1:
result.append(''.join(previous))
else :
previous.clear()
print(len(result))
print(result) |
'''Faça um programa que leia o sexo de uma pessoa, mas só aceite os valores 'M' ou 'F'.
caso esteja errado, peça a digitação novamente até ter um valor correto.'''
s = 0
r = '\nOpção inválida! Digite novamente por favor\n'
while s != 'M' and s != 'F':
s = str(input('Por favor informe seu sexo: [F/M]: ')).upper().strip()[0] # as [] com o zero no meio é um fatiamento de string. irá pegar apenas a primeira letra.
if s == 'F':
print('\n\033[32mFeminino')
elif s == 'M':
print('\n\033[32mMasculino')
else:
print('{}'.format(r))
print('\n\033[mFim')
# Jeito Guanabara
'''sexo = str(input('Informe seu sexo: [M/F] ')).strip().upper()[0]
while sexo not in 'MmFf':
sexo = str(input('Dados inválidos. Por favor, informe seu sexo: ')).strip.upper()[0]
print('Sexo {} registrado com Sucesso!!'.format(sexo))'''
|
__author__ = 'Shane'
class ClassToPass:
def __init__(self, int1=int(), int2=int()):
self.int1 = int1
self.int2 = int2
def gimmeTheSum(self, a, b) -> int:
return a + b |
"""Utility functions for the cargo rules"""
load("//rust/platform:triple_mappings.bzl", "system_to_binary_ext")
def _resolve_repository_template(
template,
abi = None,
arch = None,
system = None,
tool = None,
triple = None,
vendor = None,
version = None):
"""Render values into a repository template string
Args:
template (str): The template to use for rendering
abi (str, optional): The host ABI
arch (str, optional): The host CPU architecture
system (str, optional): The host system name
tool (str, optional): The tool to expect in the particular repository.
Eg. `cargo`, `rustc`, `stdlib`.
triple (str, optional): The host triple
vendor (str, optional): The host vendor name
version (str, optional): The Rust version used in the toolchain.
Returns:
string: The resolved template string based on the given parameters
"""
if abi:
template = template.replace("{abi}", abi)
if arch:
template = template.replace("{arch}", arch)
if system:
template = template.replace("{system}", system)
if tool:
template = template.replace("{tool}", tool)
if triple:
template = template.replace("{triple}", triple)
if vendor:
template = template.replace("{vendor}", vendor)
if version:
template = template.replace("{version}", version)
return template
def get_rust_tools(cargo_template, rustc_template, host_triple, version):
"""Retrieve `cargo` and `rustc` labels based on the host triple.
Args:
cargo_template (str): A template used to identify the label of the host `cargo` binary.
rustc_template (str): A template used to identify the label of the host `rustc` binary.
host_triple (struct): The host's triple. See `@rules_rust//rust/platform:triple.bzl`.
version (str): The version of Cargo+Rustc to use.
Returns:
struct: A struct containing the labels of expected tools
"""
extension = system_to_binary_ext(host_triple.system)
cargo_label = Label(_resolve_repository_template(
template = cargo_template,
version = version,
triple = host_triple.str,
arch = host_triple.arch,
vendor = host_triple.vendor,
system = host_triple.system,
abi = host_triple.abi,
tool = "cargo" + extension,
))
rustc_label = Label(_resolve_repository_template(
template = rustc_template,
version = version,
triple = host_triple.str,
arch = host_triple.arch,
vendor = host_triple.vendor,
system = host_triple.system,
abi = host_triple.abi,
tool = "rustc" + extension,
))
return struct(
cargo = cargo_label,
rustc = rustc_label,
)
|
N = input()
N = '0' + N
result = 0
carry = 0
for i in range(len(N) - 1, 0, -1):
c = int(N[i]) + carry
n = int(N[i - 1])
if c < 5 or (c == 5 and n < 5):
result += c
carry = 0
else:
result += 10 - c
carry = 1
result += carry
print(result)
|
#Victor Gabriel Castão da Cruz
#Lendo valor
N = int(input())
#Calculando dias
dias = int(N/86400)
N = N % 86400
#Calculando horas
horas = int(N/3600)
N = N % 3600
#Calculando minutos
minutos = int(N/60)
N = N % 60
#Calculando segundos
segundos = N
#Imprimindo resposta
print(dias, "dia(s),", horas, "hora(s),", minutos, "minuto(s) e", segundos, "segundo(s).")
|
class Demo:
def __init__(self, name):
self.name = name
print("Started!")
def hello(self):
print("Hey " + self.name + "!")
def goodbye(self):
print("Good-bye " + self.name + "!")
m = Demo("Alexa")
m.hello()
m.goodbye()
|
assert set([1,2]) == set([1,2])
assert not set([1,2,3]) == set([1,2])
assert set([1,2,3]) >= set([1,2])
assert set([1,2]) >= set([1,2])
assert not set([1,3]) >= set([1,2])
assert set([1,2,3]).issuperset(set([1,2]))
assert set([1,2]).issuperset(set([1,2]))
assert not set([1,3]).issuperset(set([1,2]))
assert set([1,2,3]) > set([1,2])
assert not set([1,2]) > set([1,2])
assert not set([1,3]) > set([1,2])
assert set([1,2]) <= set([1,2,3])
assert set([1,2]) <= set([1,2])
assert not set([1,3]) <= set([1,2])
assert set([1,2]).issubset(set([1,2,3]))
assert set([1,2]).issubset(set([1,2]))
assert not set([1,3]).issubset(set([1,2]))
assert set([1,2]) < set([1,2,3])
assert not set([1,2]) < set([1,2])
assert not set([1,3]) < set([1,2])
class Hashable(object):
def __init__(self, obj):
self.obj = obj
def __repr__(self):
return repr(self.obj)
def __hash__(self):
return id(self)
recursive = set()
recursive.add(Hashable(recursive))
assert repr(recursive) == "{set(...)}"
a = set([1, 2, 3])
assert len(a) == 3
a.clear()
assert len(a) == 0
assert set([1,2,3]).union(set([4,5])) == set([1,2,3,4,5])
assert set([1,2,3]).union(set([1,2,3,4,5])) == set([1,2,3,4,5])
assert set([1,2,3]) | set([4,5]) == set([1,2,3,4,5])
assert set([1,2,3]) | set([1,2,3,4,5]) == set([1,2,3,4,5])
assert set([1,2,3]).intersection(set([1,2])) == set([1,2])
assert set([1,2,3]).intersection(set([5,6])) == set([])
assert set([1,2,3]) & set([4,5]) == set([])
assert set([1,2,3]) & set([1,2,3,4,5]) == set([1,2,3])
assert set([1,2,3]).difference(set([1,2])) == set([3])
assert set([1,2,3]).difference(set([5,6])) == set([1,2,3])
assert set([1,2,3]) - set([4,5]) == set([1,2,3])
assert set([1,2,3]) - set([1,2,3,4,5]) == set([])
assert set([1,2,3]).symmetric_difference(set([1,2])) == set([3])
assert set([1,2,3]).symmetric_difference(set([5,6])) == set([1,2,3,5,6])
assert set([1,2,3]) ^ set([4,5]) == set([1,2,3,4,5])
assert set([1,2,3]) ^ set([1,2,3,4,5]) == set([4,5])
try:
set([[]])
except TypeError:
pass
else:
assert False, "TypeError was not raised"
try:
set().add([])
except TypeError:
pass
else:
assert False, "TypeError was not raised"
|
def makeGood(s: str) -> str:
stack = []
for i in range(len(s)):
if stack and ((s[i].isupper() and stack[-1] == s[i].lower()) or
(s[i].islower() and stack[-1] == s[i].upper())):
stack.pop()
else:
stack.append(s[i])
return ''.join(stack) |
"""
# Definition for a Node.
class Node(object):
def __init__(self, val, children):
self.val = val
self.children = children
"""
class Solution(object):
def levelOrder(self, root):
"""
:type root: Node
:rtype: List[List[int]]
"""
if not root:
return []
res = []
stack = [root]
while stack:
tmp = []
res.append([node.val for node in stack])
for node in stack:
for child_node in node.children:
tmp.append(child_node)
stack = tmp
return res
|
#Given a binary tree, return all root-to-leaf paths.
# dfs+stack, bfs+queue, dfs recursively
class Solution:
def binaryTreePaths1(self, root):
if not root:
return []
res, stack = [], [(root, "")]
while stack:
node, ls = stack.pop()
if not node.left and not node.right:
res.append(ls+str(node.val))
if node.right:
stack.append((node.right, ls+str(node.val)+"->"))
if node.left:
stack.append((node.left, ls+str(node.val)+"->"))
return res
# bfs + queue
def binaryTreePaths2(self, root):
if not root:
return []
res, queue = [], collections.deque([(root, "")])
while queue:
node, ls = queue.popleft()
if not node.left and not node.right:
res.append(ls+str(node.val))
if node.left:
queue.append((node.left, ls+str(node.val)+"->"))
if node.right:
queue.append((node.right, ls+str(node.val)+"->"))
return res
# dfs recursively
def binaryTreePaths(self, root):
if not root:
return []
res = []
self.dfs(root, "", res)
return res
def dfs(self, root, ls, res):
if not root.left and not root.right:
res.append(ls+str(root.val))
if root.left:
self.dfs(root.left, ls+str(root.val)+"->", res)
if root.right:
self.dfs(root.right, ls+str(root.val)+"->", res) |
class Solution:
def diagonalSum(self, mat: List[List[int]]) -> int:
sum = 0
n = len(mat)
for i in range(n):
sum += mat[i][i]
if i != n - 1 - i:
sum += mat[i][n - 1 - i]
return sum
|
def courses_list(user=None):
user = auth.user if not user else db(db.users.id==user).select().first()
if user.type_==1:
courses = db(db.registered_courses.professor==user.id).select(db.registered_courses.course_id)
courses = map(lambda x: x.course_id, courses)
else:
courses = db(db.student_registrations.student_id==user.id).select(db.student_registrations.registered_course_id)
courses = map(lambda x: x.registered_course_id, courses)
courses = db(db.courses.id.belongs(courses)).select()
return dict(current_year=get_current_year(), current_sem=get_current_sem(), courses=courses, user=user)
|
def check_inners(rule):
if target in rules[rule]:
return 1
for bag in rules[rule]:
if check_inners(bag):
return 1
return 0
def part1():
count = 0
for rule in rules:
#print(rule)
if rule == target:
next
else:
count += check_inners(rule)
print('part 1 = ',count)
#########################
def counting(rule):
count = 0
for bag in rules[rule]:
count += rules[rule][bag]
count += rules[rule][bag] * counting(bag)
return count
def part2():
print('part 2 = ',counting(target))
##############################
target = "shiny gold"
rules = dict()
for line in open("input.txt"):
main = line.split("bags contain")[0].strip()
rules[main] = dict()
inside = line.split("bags contain")[1].split(',')
for bag in inside:
if not "no other bags" in bag:
bag = bag.replace('bags','').replace('bag','').replace('.','').strip()
rules[main][' '.join(bag.split(' ')[1:] )] = int(bag.split(' ')[0])
part1()
part2()
|
#practice using data structures and several algorithms
#compiled all classes into one
class Node:
def __init__(self, data):
self.data = data
self.next = None
class BinaryNode:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
self.val = data
class GraphNode:
def __init__(self, data, adj=[], visited=0):
self.data = data
self.adj = adj
self.next = None
self.visited = visited
def print_node(self):
return self.data
def print_adj(self):
return self.adj
def update_adj(self, arr):
self.adj = arr
class LinkedList:
def __init__(self):
self.head = None
def getNodeValue(self, node):
return node.data
def deleteNode(self, key):
headnode = self.head
if headnode.data == key:
headnode.data = None
self.head = headnode.next
else:
prevnode = headnode
headnode = headnode.next
while headnode != None:
#print(prevnode.data, headnode.data)
if headnode.data == key:
prevnode.next = headnode.next
headnode = None
else:
prevnode = headnode
headnode = headnode.next
def insertNode(self, key, placement):
insertnode = Node(key)
headnode = self.head
if placement == "start":
insertnode.next = self.head
self.head = insertnode
if placement == "end":
while headnode != None:
#print(headnode.data)
if headnode.next == None:
headnode.next = insertnode
break
else:
headnode = headnode.next
def insertNodeBtwn(self, key, front, back):
frontnode = self.head
backnode = self.head.next
while backnode != None:
if frontnode.data == front and backnode.data == back:
insertnode = Node(key)
frontnode.next = insertnode
insertnode.next = backnode
break
else:
backnode = backnode.next
frontnode = frontnode.next
def printLList(self):
nodeList = []
headnode = self.head
while headnode != None:
#print(headnode.data)
nodeList.append(headnode.data)
#print(headnode.data)
headnode = headnode.next
return nodeList
class BinaryTree:
def __init__(self):
self.root = None
#def rebalance(self, currNode):
#while
def visitTree(self, currNode):
if currNode != None:
self.visitTree(currNode.left)
print(currNode.data)
self.visitTree(currNode.right)
def insertNode(self, nodeRoot, data):
if self.root == None:
self.root = BinaryNode(data)
elif nodeRoot == None:
#return nodeRoot(data)
return BinaryNode(data)
else:
if nodeRoot.data == data:
return nodeRoot
elif nodeRoot.data < data:
nodeRoot.right = self.insertNode(nodeRoot.right, data)
else:
nodeRoot.left = self.insertNode(nodeRoot.left, data)
return nodeRoot
def updateRoot(self, data):
self.root = BinaryNode(data)
def peek(self):
return self.root.data
class MinHeap:
def __init__(self):
self.arr = []
self.root = None
def insert_node(self, val):
self.arr.append(val)
self.sift_up(val)
def sift_up(self, curr_node):
parent_pos = self.arr.index(curr_node)//2
child_pos = self.arr.index(curr_node)
while self.arr[child_pos] < self.arr[parent_pos]:
self.swap(self.arr.index(curr_node),(self.arr.index(curr_node)//2))
child_pos = parent_pos
parent_pos = parent_pos//2
def swap(self, first_pos, second_pos):
self.arr[first_pos], self.arr[second_pos] = self.arr[second_pos], self.arr[first_pos]
def print_heap(self):
print(self.arr)
class Queue:
def __init__(self):
self.frontNode = None
self.backNode = None
def queueNode(self, newNode):
#newNode = Node(key)
if isinstance(newNode, GraphNode) or isinstance(newNode, Node):
if self.backNode != None:
self.backNode.next = newNode
self.backNode = newNode
if self.frontNode is None:
self.frontNode = self.backNode
else:
return
def dequeueNode(self):
if self.frontNode is None:
return
data = self.frontNode
self.frontNode = self.frontNode.next
if self.frontNode is None:
self.backNode = None
return data
def peek(self):
return self.frontNode.data
def isEmpty(self):
if self.frontNode == None:
return True
else:
return False
def printQueue(self, currNode):
arr = []
while currNode != None:
arr.append(currNode.data)
currNode = currNode.next
print(arr)
class Stack:
def __init__(self):
self.topNode = None
def pushNode(self, newNode):
if isinstance(newNode, Node):
if self.topNode == None:
self.topNode = newNode
else:
newNode.next = self.topNode
self.topNode = newNode
else:
return
def popNode(self):
if self.topNode == None:
return
self.topNode = self.topNode.next
def peek(self):
return self.topNode.data
def dfs(curr_node):
if curr_node == None:
return
print(curr_node.print_node())
curr_node.visited = 1
for n in curr_node.adj:
if n.visited == 0:
dfs(n)
def bfs(curr_node):
order = Queue()
#print(order.isEmpty())
curr_node.visited = 1
order.queueNode(curr_node)
print(curr_node.data)
#order.printQueue(curr_node)
#print(order.isEmpty())
#print(curr_node.data)
#print(order.frontNode.data)
while order.isEmpty() != True:
#print(order.isEmpty())
#print(curr_node.data)
next_node = order.dequeueNode()
next_node.visited = 1
order.printQueue(next_node)
print("Dequeued " + str(next_node.data))
#print(order.isEmpty())
#print(next_node.adj)
for n in next_node.adj:
#print(n.visited)
if n.visited == 0:
print("Adding " + str(n.data) + " to queue")
n.visited = 1
#print("Node " + str(n.data) + " visited " + str(n.visited))
order.queueNode(n)
#print(order.peek())
|
valores = list()
print('\033[30m-' * 50)
for p in range(0, 5):
valor = (int(input('Digite um valor: ')))
if p == 0 or valor > max(valores):
valores.append(valor)
print(f'Adicionado o valor \033[34m{valor}\033[30m no '
f'\033[33mfinal\033[30m da lista...')
else:
for c in range(0, len(valores)):
if valor <= valores[c]:
valores.insert(c, valor)
print(f'Adicionado o valor \033[34m{valor}\033[30m na '
f'\033[33m{c + 1}ª\033[30m posição na lista...')
break
print('-' * 50)
print(f'Os valores digitados em ordem foram \033[33m{valores}\033[30m')
print('-' * 50)
'''lista = []
for c in range(0, 5):
n = int(input('Digite um valor: '))
if c == 0 or n > lista[-1]:
lista.append(n)
print('Adicionado ao final da lista...')
else:
pos = 0
while pos < len(lista):
if n <= lista[pos]:
lista.insert(pos, n)
print(f'Adicionado na posição {pos} da lista...')
break
pos += 1
print('-'*50)
print(f'Os valores digitados em ordem foram {lista}')'''
|
# list(map(int, input().split()))
# int(input())
def main(X, Y):
cand = Y // 4
for i in range(cand, -1, -1):
if i * 4 + (X - i) * 2 == Y:
print('Yes')
exit()
else:
print('No')
if __name__ == '__main__':
X, Y = list(map(int, input().split()))
main(X, Y)
|
class Solution:
def peakIndexInMountainArray(self, arr: List[int]) -> int:
count = 0
for i in range(len(arr)-1):
if arr[i] < arr[i+1]:
count += 1
return count
|
def mutate_kernel_size(kernel):
return None
def mutate_stride(stride):
return None
def mutate_padding(padding):
return None
def mutate_filter(filter):
return None |
# Check a number for prime....
a = int(input("Enter Number: "))
c = 0
for i in range(1, a+1):
if a % i == 0:
c += 1
if c == 2:
print("Prime")
else:
print("Not Prime")
|
def readint(msg):
ok = False
value = 0
while True:
n1 = str(input(msg))
if n1.isnumeric():
value = int(n1)
ok = True
else:
print('\033[0;31mError! Please enter a valid number. \033[m')
if ok:
break
return value
n = readint('Enter a number: ')
print(f'You just typed the number {n}')
|
"""
Siguiendo el ejercicio anterior, vamos a añadirle un apartado donde
nos muestra un mensaje “Seleccione la opción deseada”
(sin NINGÚN SALTO DE LÍNEA) y leer mediante teclado lo que introducimos.
Preguntamos mediante el operador relacional: ¿Está entre 1 y 4 (incluidos)?
¿Es igual a 5?
"""
print("===========================================================")
print("\t\tAHORCADO - OPCIONES DEL JUEGO")
print("===========================================================")
print("1) Jugar a acertar una palabra aleatoria.")
print("2) Jugar a acertar cinco palabras aleatorias.")
print("3) Jugar a acertar una palabra de un tema seleccionado")
print("4) Jugar a acertar cincos palabras de un tema seleccionado")
print("5) Salir.")
print("===========================================================")
select_option = int(input("Seleccione la opción deseada: "))
check_one = select_option >= 1 and select_option <= 4
print("¿Está entre 1 y 4 (incluidos)? {}".format(check_one))
check_two = select_option == 5
print("¿Hemos seleccionado salir? {}".format(check_two)) |
# https://leetcode.com/problems/keys-and-rooms/
class Solution:
def canVisitAllRooms(self, rooms: List[List[int]]) -> bool:
return self.dfs(rooms, 0, set())
def dfs(self, rooms: List[List[int]], node: int, visited: set[int]) -> bool:
if node in visited:
return False
visited.add(node)
if len(visited) == len(rooms):
return True
for key in rooms[node]:
if self.dfs(rooms, key, visited):
return True
return False
|
# -*- coding: utf-8 -*-
# El code_menu debe ser único y se configurará como un permiso del sistema
MENU_DEFAULT = [
{'code_menu': 'acceso_faqs',
'texto_menu': 'Preguntas frecuentes',
'href': '',
'nivel': 1,
'tipo': 'Accesible',
'pos': 1
},
{'code_menu': 'acceso_configura_faqs',
'texto_menu': 'Configuración de FAQs',
'href': 'configura_faqs',
'nivel': 2,
'tipo': 'Accesible',
'pos': 1,
'parent': 'acceso_faqs'
},
{'code_menu': 'acceso_faqs_gauss',
'texto_menu': 'Preguntas sobre GAUSS',
'href': 'faqs_gauss',
'nivel': 2,
'tipo': 'Accesible',
'pos': 2,
'parent': 'acceso_faqs'
},
{'code_menu': 'acceso_faqs_entidad',
'texto_menu': 'Preguntas de la entidad',
'href': 'faqs_entidad',
'nivel': 2,
'tipo': 'Accesible',
'pos': 3,
'parent': 'acceso_faqs'
},
{'code_menu': 'acceso_faqs_borradas',
'texto_menu': 'Preguntas borradas',
'href': 'faqs_borradas',
'nivel': 2,
'tipo': 'Accesible',
'pos': 4,
'parent': 'acceso_faqs'
},
{'code_menu': 'acceso_faqs_sugeridas',
'texto_menu': 'Buzón de sugerencias',
'href': 'faqs_sugeridas',
'nivel': 2,
'tipo': 'Accesible',
'pos': 5,
'parent': 'acceso_faqs'
}
]
# Se añaden otros permisos para el usuario
PERMISOS = [
{'code_nombre': 'crea_faqs_gauss',
'nombre': 'Tiene permiso para crear preguntas frecuentes sobre gauss',
'menu': 'acceso_configura_faqs'
},
{'code_nombre': 'crea_secciones_faqs',
'nombre': 'Tiene permiso para crear secciones para las preguntas frecuentes',
'menu': 'acceso_configura_faqs'
},
{'code_nombre': 'crea_faqs_entidad',
'nombre': 'Tiene permiso para crear preguntas frecuentes de la entidad',
'menu': 'acceso_configura_faqs'
},
{'code_nombre': 'edita_faqs_entidad',
'nombre': 'Tiene permiso para editar las preguntas frecuentes de la entidad',
'menu': 'acceso_configura_faqs'
},
{'code_nombre': 'acepta_faqs_sugeridas',
'nombre': 'Tiene permiso para aceptar las preguntas sugeridas a la entidad',
'menu': 'acceso_faqs_sugeridas'
}
]
|
c = float(input())
n = int(input())
t=0
for each in range(n):
h,w = list(map(float, input().split()))
t+= h*w*c
print("{:.8f}".format(t))
|
class Dsu:
def __init__(self, n, ranked):
self.parents = [i for i in range(n)]
self.ranked = ranked
self.ranks = [0 for i in range(n)]
self.messages = [0 for i in range(n)]
self.read = [0 for i in range(n)]
def find(self, v):
if v == self.parents[v]:
return v
else:
head = self.find(self.parents[v])
if head != self.parents[v]:
self.messages[v] += self.messages[self.parents[v]]
self.parents[v] = head
return self.parents[v]
def check(self, v):
self.find(v)
value = self.messages[v] - self.read[v]
if self.parents[v] != v:
value += self.messages[self.parents[v]]
self.read[v] += value
return value
def send(self, v):
a = self.find(v)
self.messages[a] += 1
def union(self, a, b):
a = self.find(a)
b = self.find(b)
if a != b:
if self.ranked:
if self.ranks[a] < self.ranks[b]:
a, b = b, a
self.parents[b] = a
self.messages[b] -= self.messages[a]
if self.ranks[a] == self.ranks[b]:
self.ranks[a] += 1
else:
self.parents[a] = b
return True
return False
def getX(i):
# return i
return (i+zerg)%n
n, m = map(int, input().split())
dsu = Dsu(n, True)
p = int(1e6+3)
zerg = 0
for i in range(m):
line = input().split()
if line[0] == '1':
i = int(line[1])
dsu.send(getX(i))
zerg = (30 * zerg + 239) % p
elif line[0] == '2':
i = int(line[1])
j = int(line[2])
if dsu.union(getX(i), getX(j)):
zerg = (13*zerg+11) % p
else:
i = int(line[1])
read = dsu.check(getX(i))
print(read)
zerg = (100500*zerg+read) % p
|
"""
Exceptions
~~~~~~~~~~
Custom exceptions raised by the phenotype service.
"""
class PhenotypeError(Exception):
pass
|
'''
A simple exercie sript to find out total pay by multiplying hours worked with
rate per hour.
'''
hr1 = input('Enter Hours: ')
rate1 = input('Enter Rate: ')
# made failure proof so if user inputs values other than number it won't crash
# and through an error. so the program will just quit with following warning
# to the user
try:
hrs = float(hr1)
rate = float(rate1)
# scrip can be made much better by adding 'continue' instead of 'quit()' in a
# while loop so that by printing failure message it just asks user for other
# input instead of quiting
except:
print('Failure: Enter Integers Only')
quit()
pay = float(hrs * rate)
print('Pay:', pay)
|
# input
var = input()
# process
'''
앞에서부터 하나씩 읽으면서 처리.
만약 첫번째 알파벳이 대문자면 잘못된 변수명.
중간에 대문자가 나올 경우 자바임.
>> 밑줄 추가하고 소문자로 바꿔줌.
중간에 밑줄이 나올 경우 cpp임.
>> 밑줄 지우고 다음 단어 대문자로 바꿈.
>> 밑줄이 두 번 연속으로 나오면 잘못된 변수명.
>> 마지막 글자가 밑줄이면 잘못된 변수명.
만약 자바와 cpp 조건 둘 다 만족하면 잘못된 변수명.
'''
isJava = isCpp = next2Upper = False
isValid = True
result = [var[0]]
if 'A' <= var[0] <= 'Z' or var[0] == '_': isValid = False
for i in range(1, len(var)):
ch = var[i]
if 'A' <= ch <= 'Z':
isJava = True
result.append('_%s' % ch.lower())
if isCpp: isValid = False
elif ch == '_':
if next2Upper: isValid = False
next2Upper = isCpp = True
if isJava: isValid = False
else:
if next2Upper:
ch = ch.upper()
next2Upper = False
result.append(ch)
if not isValid: break
if next2Upper: isValid = False
# output
print("".join(result)) if isValid else print("Error!") |
spark = SparkSession \
.builder \
.appName("exercise_eighteen") \
.getOrCreate()
(df.select("id", "first_name", "last_name", "gender", "country", "birthdate", "salary")
.filter(df["country"] == "United States")
.orderBy(df["gender"].asc(), df["salary"].asc())
.show())
df.select("id", "first_name", "last_name", "gender", "country", "birthdate", "salary") \
.filter(df["country"] == "United States") \
.orderBy(df["gender"].asc(), df["salary"].asc()) \
.show()
|
"""utils.py"""
def param_dict(param_list):
"""param_dict"""
dct = {}
for param in param_list:
dct[param.key] = param
return dct
|
#personaldetails
print("NAME: Jaskeerat Singh \nE-MAIL: jsing322@uwo.ca \nSLACK USERNAME: @jass \nBIOSTACK: Genomics \nTwitter Handle: @jsin")
def hamming_distance(a,b):
count=0
for i in range(len(a)):
if a[i] != b[i]:
count +=1
return count
print(hamming_distance('@jass','@jsin'))
|
class persona:
#clase que representa a una pérsona
cedula = "8-123-123"
nombre = "rodriguez"
sexo = "I"
def hablar(self, mensaje):
#mostrar mensaje de persona
return mensaje
something = persona
print("el objeto de la clase" + something._name_+","+something._doc_)
print("el nombre es: " + something.nombre)
|
# autogenerated by /home/astivala/phd/ptgraph/buildversion.sh
# Fri Aug 10 09:43:43 EST 2012
def get_version():
"""
Return version string containing global version number and 'build' date
"""
return "Revision 4288:4291, Fri Aug 10 09:43:43 EST 2012"
|
"""Role testing files using testinfra."""
def test_lvm_package_shall_be_installed(host):
assert host.package("lvm2").is_installed
def test_non_persistent_volume_group_is_created(host):
command = """sudo vgdisplay | grep -c 'non-persistent'"""
cmd = host.run(command)
assert '1' in cmd.stdout
def test_thinpool_logical_volume_is_created(host):
command = """sudo lvs -o lv_name non-persistent --separator='|' \
--noheadings | grep -c 'thinpool'"""
cmd = host.run(command)
assert int(cmd.stdout.rstrip()) >= 1
def test_thinpoolmeta_logical_volume_is_created(host):
command = """sudo lvs -o metadata_lv non-persistent --separator='|' \
--noheadings | grep -c 'thinpool_tmeta'"""
cmd = host.run(command)
assert '1' in cmd.stdout
def test_thinpool_profile_autoextends_treshold_is_set(host):
command = """cat /etc/lvm/profile/non-persistent-thinpool.profile \
| grep -c 'thin_pool_autoextend_threshold=80'"""
cmd = host.run(command)
assert '1' in cmd.stdout
def test_thinpool_profile_autoextends_percent_is_set(host):
command = """cat /etc/lvm/profile/non-persistent-thinpool.profile \
| grep -c 'thin_pool_autoextend_percent=20'"""
cmd = host.run(command)
assert '1' in cmd.stdout
def test_thinpool_is_monitored(host):
command = """sudo lvs -o+seg_monitor | grep -c 'monitored'"""
cmd = host.run(command)
assert '1' in cmd.stdout
# Don't know how to test autoextend
def test_formating_is_xfs(host):
command = """sudo xfs_info /dev/non-persistent/thinpool \
| grep -c 'ftype=1'"""
cmd = host.run(command)
assert '1' in cmd.stdout
def test_xfs_volume_is_mounted(host):
host.file("/var/lib/docker").mode == 0o731
|
"""
Get Height of Binary Tree
"""
class Node:
def __init__(self, data, left=None, right=None):
self.data = data
self.left = left
self.right = right
def get_height(root):
"""
>>> assert(get_height(None) == -1)
>>> root = Node(1)
>>> assert(get_height(root) == 0)
>>> root = Node(1, Node(2))
>>> assert(get_height(root) == 1)
>>> root = Node(1, Node(2, Node(3)))
>>> assert(get_height(root) == 2)
"""
if root is None:
return -1
height_left = get_height(root.left)
height_right = get_height(root.right)
return 1 + max(height_left, height_right)
|
# Time: O(logn)
# Space: O(1)
class Solution(object):
def toHex(self, num):
"""
:type num: int
:rtype: str
"""
if not num:
return "0"
result = []
while num and len(result) != 8:
h = num & 15
if h < 10:
result.append(str(chr(ord('0') + h)))
else:
result.append(str(chr(ord('a') + h-10)))
num >>= 4
result.reverse()
return "".join(result)
|
class Interface(object):
def __init__(self, name, idx, addrwidth, datawidth, lite=False):
self.name = name
self.idx = idx
self.datawidth = datawidth
self.addrwidth = addrwidth
self.lite = lite
def __repr__(self):
ret = []
ret.append('(')
ret.append(self.__class__.__name__)
ret.append(' ')
ret.append('NAME:')
ret.append(str(self.name))
ret.append(' ')
ret.append('ID:')
ret.append(str(self.idx))
ret.append(' ')
ret.append('ADDR_WIDTH:')
ret.append(str(self.addrwidth))
ret.append(' ')
ret.append('DATA_WIDTH:')
ret.append(str(self.datawidth))
ret.append(' ')
ret.append('LITE:')
ret.append(str(self.lite))
ret.append(')')
return ''.join(ret)
class MasterMemory(Interface): pass
class SlaveMemory(Interface): pass
|
class HierarchicalDataTemplate(DataTemplate,INameScope,ISealable,IHaveResources,IQueryAmbient):
"""
Represents a System.Windows.DataTemplate that supports System.Windows.Controls.HeaderedItemsControl,such as System.Windows.Controls.TreeViewItem or System.Windows.Controls.MenuItem.
HierarchicalDataTemplate()
HierarchicalDataTemplate(dataType: object)
"""
def ValidateTemplatedParent(self,*args):
"""
ValidateTemplatedParent(self: DataTemplate,templatedParent: FrameworkElement)
Checks the templated parent against a set of rules.
templatedParent: The element this template is applied to.
"""
pass
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
@staticmethod
def __new__(self,dataType=None):
"""
__new__(cls: type)
__new__(cls: type,dataType: object)
"""
pass
AlternationCount=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets or sets the number of alternating item containers for the child items.
Get: AlternationCount(self: HierarchicalDataTemplate) -> int
Set: AlternationCount(self: HierarchicalDataTemplate)=value
"""
ItemBindingGroup=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets or sets the System.Windows.Data.BindingGroup that is copied to each child item.
Get: ItemBindingGroup(self: HierarchicalDataTemplate) -> BindingGroup
Set: ItemBindingGroup(self: HierarchicalDataTemplate)=value
"""
ItemContainerStyle=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets or sets the System.Windows.Style that is applied to the item container for each child item.
Get: ItemContainerStyle(self: HierarchicalDataTemplate) -> Style
Set: ItemContainerStyle(self: HierarchicalDataTemplate)=value
"""
ItemContainerStyleSelector=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets or sets custom style-selection logic for a style that can be applied to each item container.
Get: ItemContainerStyleSelector(self: HierarchicalDataTemplate) -> StyleSelector
Set: ItemContainerStyleSelector(self: HierarchicalDataTemplate)=value
"""
ItemsSource=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets or sets the binding for this data template,which indicates where to find the collection that represents the next level in the data hierarchy.
Get: ItemsSource(self: HierarchicalDataTemplate) -> BindingBase
Set: ItemsSource(self: HierarchicalDataTemplate)=value
"""
ItemStringFormat=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets or sets a composite string that specifies how to format the items in the next level in the data hierarchy if they are displayed as strings.
Get: ItemStringFormat(self: HierarchicalDataTemplate) -> str
Set: ItemStringFormat(self: HierarchicalDataTemplate)=value
"""
ItemTemplate=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets or sets the System.Windows.DataTemplate to apply to the System.Windows.Controls.ItemsControl.ItemTemplate property on a generated System.Windows.Controls.HeaderedItemsControl (such as a System.Windows.Controls.MenuItem or a System.Windows.Controls.TreeViewItem),to indicate how to display items from the next level in the data hierarchy.
Get: ItemTemplate(self: HierarchicalDataTemplate) -> DataTemplate
Set: ItemTemplate(self: HierarchicalDataTemplate)=value
"""
ItemTemplateSelector=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets or sets the System.Windows.Controls.DataTemplateSelector to apply to the System.Windows.Controls.ItemsControl.ItemTemplateSelector property on a generated System.Windows.Controls.HeaderedItemsControl (such as a System.Windows.Controls.MenuItem or a System.Windows.Controls.TreeViewItem),to indicate how to select a template to display items from the next level in the data hierarchy.
Get: ItemTemplateSelector(self: HierarchicalDataTemplate) -> DataTemplateSelector
Set: ItemTemplateSelector(self: HierarchicalDataTemplate)=value
"""
|
{
'includes': [
'deps/common.gypi',
],
'variables': {
'gtest%': 0,
'gtest_static_libs%': [],
'glfw%': 0,
'glfw_static_libs%': [],
'mason_platform': 'osx',
},
'targets': [
{ 'target_name': 'geojsonvt',
'product_name': 'geojsonvt',
'type': 'static_library',
'standalone_static_library': 1,
'include_dirs': [
'include',
],
'sources': [
'include/mapbox/geojsonvt.hpp',
'include/mapbox/geojsonvt/clip.hpp',
'include/mapbox/geojsonvt/convert.hpp',
'include/mapbox/geojsonvt/simplify.hpp',
'include/mapbox/geojsonvt/transform.hpp',
'include/mapbox/geojsonvt/tile.hpp',
'include/mapbox/geojsonvt/types.hpp',
'include/mapbox/geojsonvt/wrap.hpp',
'src/geojsonvt.cpp',
'src/clip.cpp',
'src/convert.cpp',
'src/simplify.cpp',
'src/transform.cpp',
'src/tile.cpp',
'src/wrap.cpp',
],
'variables': {
'cflags_cc': [
'<@(variant_cflags)',
'<@(rapidjson_cflags)',
],
'ldflags': [],
'libraries': [],
},
'conditions': [
['OS == "mac"', {
'xcode_settings': {
'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ],
},
}, {
'cflags_cc': [ '<@(cflags_cc)' ],
}],
],
'link_settings': {
'conditions': [
['OS == "mac"', {
'libraries': [ '<@(libraries)' ],
'xcode_settings': { 'OTHER_LDFLAGS': [ '<@(ldflags)' ] }
}, {
'libraries': [ '<@(libraries)', '<@(ldflags)' ],
}]
],
},
'direct_dependent_settings': {
'include_dirs': [
'include',
],
},
},
{ 'target_name': 'install',
'type': 'none',
'hard_dependency': 1,
'dependencies': [
'geojsonvt',
],
'copies': [
{ 'files': [ '<(PRODUCT_DIR)/libgeojsonvt.a' ], 'destination': '<(install_prefix)/lib' },
{ 'files': [ '<!@(find include/mapbox/geojsonvt -name "*.hpp")' ], 'destination': '<(install_prefix)/include/mapbox/geojsonvt' },
{ 'files': [ 'include/mapbox/geojsonvt.hpp' ], 'destination': '<(install_prefix)/include/mapbox' },
],
},
],
'conditions': [
['gtest', {
'targets': [
{ 'target_name': 'test',
'product_name': 'test',
'type': 'executable',
'dependencies': [
'geojsonvt',
],
'include_dirs': [
'src',
],
'sources': [
'test/test.cpp',
'test/util.hpp',
'test/util.cpp',
'test/test_clip.cpp',
'test/test_full.cpp',
'test/test_get_tile.cpp',
'test/test_simplify.cpp',
],
'variables': {
'cflags_cc': [
'<@(rapidjson_cflags)',
'<@(variant_cflags)',
'<@(gtest_cflags)',
],
'ldflags': [
'<@(gtest_ldflags)'
],
'libraries': [
'<@(gtest_static_libs)',
],
},
'conditions': [
['OS == "mac"', {
'libraries': [ '<@(libraries)' ],
'xcode_settings': {
'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ],
'OTHER_LDFLAGS': [ '<@(ldflags)' ],
}
}, {
'cflags_cc': [ '<@(cflags_cc)' ],
'libraries': [ '<@(libraries)', '<@(ldflags)' ],
}]
],
},
],
}],
['glfw', {
'targets': [
{ 'target_name': 'debug',
'product_name': 'debug',
'type': 'executable',
'dependencies': [
'geojsonvt',
],
'include_dirs': [
'src',
],
'sources': [
'debug/debug.cpp',
],
'variables': {
'cflags_cc': [
'<@(variant_cflags)',
'<@(glfw_cflags)',
],
'ldflags': [
'<@(glfw_ldflags)'
],
'libraries': [
'<@(glfw_static_libs)',
],
},
'conditions': [
['OS == "mac"', {
'libraries': [ '<@(libraries)' ],
'xcode_settings': {
'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ],
'OTHER_LDFLAGS': [ '<@(ldflags)' ],
}
}, {
'cflags_cc': [ '<@(cflags_cc)' ],
'libraries': [ '<@(libraries)', '<@(ldflags)' ],
}]
],
},
],
}],
],
}
|
print(True)
print(False)
print("True")
print("False")
print(5 == 1)
print(5 != 1)
print("Ham" == "Ham")
print("ham " == "ham")
print(5 == 5.0)
print(5 < 1)
print(5 >= 5)
print(5 < 8 <= 7) |
cidades = {'rio de janeiro': {'pais': 'brasil',
'populacao': 16718956,
'fato': 'É o terceiro estado mais populoso do Brasil'},
'paris': {'pais': 'frança',
'populacao': 2206488,
'fato': 'É considerada uma das mais importantes do mundo'},
'washington': {'pais': 'estados unidos',
'populacao': 7405743,
'fato': 'A primeira escola de Washington foi fundada em 1832'},
}
for cidade, info in cidades.items():
print(f'\nCidade: {cidade.title()}')
print(f'\tPaís: {info["pais"].title()}\n'
f'\tPopulação: {info["populacao"]:,} de habitantes aproximadamente.\n'
f'\tFato: {info["fato"]}.')
|
#!/usr/bin/python3
# Basic constants for constructing stuff
alphabet = 'אבגדהוזחטיכלמנסעפצקרשת'
salphabet = 'אבגדהוזחטיךלםןסעףץקרשת' # with sofits instead
values = [1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100,200,300,400]
sofits = 'ךםןףץ'
replace_sofits = 'כמנפצ'
yudheh = 'יה'
heh = 'ה'
yudvav = 'יו'
taf = 'ת'
tet = 'ט'
vav = 'ו'
zayin = 'ז'
tetvav = 'טו'
tvq = 'ט"ו'
tetzayin = 'טז'
tzq = 'ט"ז'
sq = "'"
char_to_num_mapper = dict(zip(alphabet + salphabet, values + values))
numtogem_map = dict(zip(values, alphabet))
numtogem_map[0] = '' # allows some computational shortcuts
snumtogem_map = dict(zip(values, salphabet))
snumtogem_map[0] = '' # allows some computational shortcuts
def Gematria (req_string):
total = 0
for c in req_string:
total += char_to_num_mapper.get(c, 0)
return total
# Change: May 30th, 2018: add number to gematria (formatted)
# Format is whether to insert " or ' in string
# if disabled, will return letters only
# List creation routine:
_plain_map = [''] * 1000 # start off with the alphabet
for k, v in numtogem_map.items():
_plain_map[k] = v
for i in range(500, 1000, 100):
_plain_map[i] = taf + _plain_map[i - 400]
for i in range(11, 100):
_plain_map[i] = _plain_map[i - i % 10] + _plain_map[i % 10]
_plain_map[15] = tetvav
_plain_map[16] = tetzayin
for i in range(101, 1000):
_plain_map[i] = _plain_map[i - i % 100] + _plain_map[i % 100]
_sofit_map = _plain_map.copy()
for i in range(0, 1000, 100):
for j in [20, 40, 50, 80, 90]:
_sofit_map[i + j] = _sofit_map[i] + snumtogem_map[j]
# Change: January 1st, 2020: allow prepend heh, and change the whole thing to precalculated
# For now: no prepend w/o format quotes
def NumberToGematria (number, sofit=True, format_quotes=True, prepend_heh=False, quote_heh=False):
base = _sofit_map[number] if sofit else _plain_map[number]
if format_quotes:
if len(base) > 1:
base = f'{base[:-1]}"{base[-1]}'
else:
base = f"{base}'"
return f'{prepend_heh * heh}{quote_heh * sq}{base}'
# # Change: January 1st, 2020: allow prepend heh, and change the whole thing to precalculated
# def NumberToGematria (number, sofit=True, format_quotes=True, prepend_heh=False):
# singles = number % 10
# hundreds = number // 100 % 4
# tens = number // 10 % 10
# ntafs = number // 400
# char_ct = ntafs + (singles is not 0) + (tens is not 0) + (hundreds is not 0)
# tens *= 10
# hundreds *= 100
# usofit = snumtogem_map if sofit else numtogem_map
# if format_quotes:
# if char_ct >= 2:
# if number % 100 in (15, 16):
# return f'{ntafs * taf}{numtogem_map[hundreds]}{tet}"{numtogem_map[singles+1]}'
# elif singles:
# return f'{ntafs * taf}{numtogem_map[hundreds]}{numtogem_map[tens]}"{numtogem_map[singles]}'
# elif tens:
# return f'{ntafs * taf}{numtogem_map[hundreds]}"{usofit[tens]}'
# elif hundreds:
# return f'{ntafs * taf}"{numtogem_map[hundreds]}'
# return f'{(ntafs-1)*taf}"{taf}'
# return f'{ntafs * taf}{numtogem_map[hundreds]}{numtogem_map[tens]}{numtogem_map[singles]}'
# elif number % 100 in (15, 16):
# return f'{ntafs * taf}{numtogem_map[hundreds]}{tet}{numtogem_map[singles+1]}'
# elif singles or not tens:
# return f'{ntafs * taf}{numtogem_map[hundreds]}{numtogem_map[tens]}{numtogem_map[singles]}'
# return f'{ntafs * taf}{numtogem_map[hundreds]}{usofit[tens]}'
# Old recursive method -- simpler to read, much slower
# def _NumGemRecursive (number):
# for val in rvals:
# if val <= number:
# return numtogem_map[val] + _NumGemRecursive(number-val)
# return '
def YearNoToGematria (number, sofit=True, format_quotes=True, prepend_heh=False, quote_heh=False):
return NumberToGematria(number % 1000, sofit, format_quotes, prepend_heh, quote_heh)
|
class Animal:
def __init__(self, leg_count=4): # Constructor, initializes the new obj
# Print("constructor called!")
self.leg_count = leg_count
self.likes_food = True
def get_leg_count(self): # getter
return self.leg_count
def set_leg_count(self, leg_count): # setter
self.leg_count = leg_count
# Objects, AKA instances
cat = Animal() # Construct a new Animal, Instantiate a new Animal
dog = Animal() # Construct a new Animal
centipede = Animal(100)
# Make a list of Animals
rabbits = [
Animal(4),
Animal(4),
Animal(4)
]
rabbits[1].leg_count = 3 # leg_count is an "attribute" on the object
print(f"rabbit 0's leg count: {rabbits[0].leg_count}")
print(f"rabbit 1's leg count: {rabbits[1].leg_count}")
print(f"rabbit 2's leg count: {rabbits[2].leg_count}")
# "cat" is an instance of an Animal
# "cat" is an Animal
# print(f"cat's leg count: {cat.leg_count}")
# cat.leg_count = 4
# print(f"cat's leg count: {cat.leg_count}")
# print(f"dog's leg count: {dog.leg_count}")
print(cat.get_leg_count())
cat.set_leg_count(3)
print(cat.get_leg_count())
|
def check(x):
""" Checking for password format
Format::: (min)-(max) (letter): password
"""
count = 0
dashIndex = x.find('-')
colonIndex = x.find(':')
minCount = int(x[:dashIndex]) - 1
maxCount = int(x[(dashIndex + 1):(colonIndex - 2)]) - 1
letter = x[colonIndex - 1]
password = x[(colonIndex + 2):]
check = ((password[minCount] == letter and password[maxCount] != letter) or (
password[maxCount] == letter and password[minCount] != letter))
return check
valid = 0
f = open("input.txt", "r")
fl = f.readlines()
for x in fl:
if (check(x)):
valid += 1
print(valid)
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Exporting modules of Clastering Algorithms Benchmarking Framework
algorithms/ - evaluating algorithms
utils/ - evaluation utilities
benchapps - evaluating algorithms executors
benchevals - evaluation utilities (and measures) executors
benchmark - the benchmarking framework
benchutils - [internal] accessory Python routings of the benchmarking
"""
__all__ = ['algorithms', 'utils', # dirs
'benchapps', 'benchevals', 'benchmark', 'benchutils'] # modules
|
a = float(input())
b = float(input())
peso_nota_a = 3.5
peso_nota_b = 7.5
media = (a * peso_nota_a + b * peso_nota_b) / (peso_nota_a + peso_nota_b)
print(f"MEDIA = {media:.5f}")
|
class Node(object):
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def __str__(self):
return str(self.data)
class AVL_Tree(object):
def height(self,root):
if not root:
return -1
else:
hl = self.height(root.left)
hr = self.height(root.right)
if hl>hr:
return hl+1
else:
return hr+1
def insert(self,root,data):
if root is None:
root = Node(data)
else:
fp = None
p = root
while p :
fp = p
p = p.left if data<p.data else p.right
if data < fp.data:
fp.left = Node(data)
else:
fp.right = Node(data)
# printTree90(root)
if not self.isBalance(root):
print("Not Balance, Rebalance!")
root = self.reBalance(root)
return root
def isBalance(self,root):
out = self._isBalance(root)
return True if out == 1 else False
def _isBalance(self,root):
if not root :
return 1
else:
if abs(self.height(root.left)-self.height(root.right))>=2:
return 0
else:
return 1*self._isBalance(root.left)*self._isBalance(root.right)
def reBalance(self,root):
if not root :
pass
# print("basecase reached")
else:
print("recurrrr")
printTree90(root)
if self.height(root.left)-self.height(root.right)<=-2:
root.right = self.reBalance(root.right)
if self.height(root.left)-self.height(root.right)<=-2:
root = self.Rleftchild(root)
elif self.height(root.left)-self.height(root.right)>=2:
root = self.Rrightchild(root)
elif self.height(root.left)-self.height(root.right)>=2:
root.left = self.reBalance(root.left)
if self.height(root.left)-self.height(root.right)<=-2:
root = self.Rleftchild(root)
elif self.height(root.left)-self.height(root.right)>=2:
root = self.Rrightchild(root)
if not self.isBalance(root):
root.right = self.reBalance(root.right)
root.left = self.reBalance(root.left)
return root
def Rleftchild(self,root):
newr = root.right
root.right = newr.left
newr.left = root
return newr
def Rrightchild(self,root):
newr = root.left
root.left = newr.right
newr.right = root
return newr
def printTree90(node, level = 0):
if node != None:
printTree90(node.right, level + 1)
print(' ' * level, node)
printTree90(node.left, level + 1)
myTree = AVL_Tree()
root = None
data = input("Enter Input : ").split()
for e in data:
print("insert :",e)
root = myTree.insert(root, int(e))
printTree90(root)
print("===============") |
# enter the Chocolate Rooom
ownername = "Daw Hla"
playerlives = 2
chocolate = 2
print("Welcome to the Chocolate Room. I am the owner of this sweet shop, my name is " + ownername)
print("You must answer this question.")
# add an input statement to ask the question on the next line and store the response in a variable called answer
# "Which of the following could be used as a good password"
# "1. Your pet's name. 2. Password123 3. A random collection of numbers and letters?"
# HINT : User answer = int(input(.......))
print("Which of the following could be used as a good password")
print("1. Your pet's name. 2. Password123 3. A random collection of numbers and letters?")
answer = int(input("Please Choose 1,2,3: "))
if answer == 3:
chocolatebar = int(input("Do you want chocolate bar 1 or 2? "))
if chocolatebar == 1:
print("Hard luck, you lse a life and there is no information in the wrapper")
playerlives = playerlives - 1
# add code to check if the chocolate bar is equal to 1
# ---> add code to print this message to the user "Hard luck, you lse a life and there is no information in the wrapper"
# ---> add code to subtract 1 from the player lives
elif chocolatebar == 2:
print("OK - you can have the chocolate bar and the letter in the wrapper is T")
else:
print("Wrong answer - you lose a life and all of your chocolate")
chocolate = 0
playerlives = playerlives - 1
# add code to set the chocolate value to 0
# add code to subtract 1 from player lives
|
'''
https://leetcode.com/contest/weekly-contest-150/problems/as-far-from-land-as-possible/
'''
diffs = [(1, 0), (0, 1), (-1, 0), (0, -1)]
class Cell:
def __init__(self, x, y, dist=0):
self.dist = dist
self.x, self.y = x, y
class Solver:
def __init__(self, grid):
self.g = grid
self.l, self.w = len(self.g), len(self.g[0])
self.inf = 1000
self.dists = [[Cell(j, i, dist=self.inf) for i in range(self.w)] for j in range(self.l)]
def solve(self):
q, qi = [], 0
lands = 0
for i in range(self.l):
for j in range(self.w):
if self.g[i][j] == 1:
self.dists[i][j].dist = 0
q.append(self.dists[i][j])
lands += 1
if lands == 0 or lands == self.l * self.w: return -1
while len(q) - qi > 0:
f = q[qi]; qi += 1
for diff in diffs:
x, y = f.x + diff[0], f.y + diff[1]
if self.valid_xy(x, y) and self.makes_sense_to_q(x, y, f.dist + 1):
c = self.dists[x][y]
c.dist = f.dist + 1
q.append(c)
return self.find_farthest_water()
def find_farthest_water(self):
max_dist = 0
for i in range(self.l):
for j in range(self.w):
if self.g[i][j] == 0: # water
max_dist = max(max_dist, self.dists[i][j].dist)
if max_dist == self.inf: return -1
return max_dist
def makes_sense_to_q(self, x, y, d):
return self.dists[x][y].dist > d
def valid_xy(self, x, y):
return x >= 0 and y >= 0 and x < self.l and y < self.w
class Solution:
def maxDistance(self, grid: List[List[int]]) -> int:
return Solver(grid).solve()
|
f=str(input('Digite uma frase: ')).strip().upper()
print('Tem {} A na frase.'.format(f.count('A')))
print('O primeiro A esta em {} letra.'.format(f.find('A')+1))
print('O ultimo A esta em {} letra.'.format(f.rfind('A')+1))
|
def start_room():
return "room1"
|
node = S(input, "application/json")
childNode = node.prop("orderDetails")
property = childNode.prop("article")
value = property.stringValue()
|
bit_list = [19, 17, 16, 18, 26, 24, 22, 21, 23, 25]
value = 5808
for bit in bit_list:
new_value = value + 2 ** bit
print(value, new_value-1)
value = new_value
|
# 노드의 합
test_cases = int(input())
for t in range(1, test_cases + 1):
N, M, L = map(int, input().split())
tree = [0] * (N + 1)
for _ in range(M):
node, value = map(int, input().split())
tree[node] = value
for i in range(N - M, 0, -1):
tree[i] = tree[i * 2]
if i * 2 + 1 <= N:
tree[i] += tree[i * 2 + 1]
print('#{} {}'.format(t, tree[L]))
|
nome = input("Digite o nome: ")
idade = int(input("Digite a idade: "))
doenca_infectocontagiosa = input("Suspeita de doença-infectocontagiosa?").upper()
if idade >= 65:
print("Paciente COM prioridade")
if doenca_infectocontagiosa == "SIM":
print("Encaminhe o paciente para sala AMARELA")
elif doenca_infectocontagiosa == "NAO":
print("Encaminhe o paciente para sala BRANCA")
else:
print("Responda a suspeita de doença infectocontagiosa com SIM ou NAO")
else:
print("Paciente SEM prioridade")
if doenca_infectocontagiosa == "SIM":
print("Encaminhe o paciente para sala AMARELA")
elif doenca_infectocontagiosa == "NAO":
print("Encaminhe o paciente para sala BRANCA")
else:
print("Responda a suspeita de doença infectocontagiosa com SIM ou NAO") |
# Реши задачу Иосифа Флавия:
# где n - число солдат, k - шаг (2 - каждый второй (сосед), 3 - каждый третий и т.д.)
#
# 1. survive(n, k) - используя массив.
# 2. survive_num(n, k) - без использования массива
def survive(n, k):
return []
def survive_num(n, k):
pos = 0
return pos |
class Solution:
# @return a string
def minWindow(self, S, T):
s = S
t = T
d = {}
td = {}
for c in t:
td[c] = td.get(c, 0) + 1
left = 0
right = 0
lefts = []
rights = []
for i, c in enumerate(s):
if c in td:
d[c] = d.get(c, 0) + 1
if self.contains(d, td): # Contains all characters
right = i
# Move left pointers
cc = s[left]
while left <= right and (cc not in d or d[cc] > td[cc]):
if cc in d:
d[cc] -= 1
left += 1
cc = s[left]
lefts.append(left)
rights.append(right)
if not lefts:
return ''
res_left = lefts[0]
res_right = rights[0]
n = len(lefts)
for i in range(1, n):
if rights[i] - lefts[i] < res_right - res_left:
res_left = lefts[i]
res_right = rights[i]
return s[res_left:res_right + 1]
def contains(self, d, td):
for k in td:
if k not in d or d[k] < td[k]:
return False
return True
|
class Solution:
def canJump(self, nums: List[int]) -> bool:
if not nums or len(nums) == 0:
return False
target = len(nums) - 1
for i in range(len(nums) - 1, -1, -1):
if (nums[i] + i >= target):
target = i
return target == 0 |
print ("How old are you?"),
age = input()
print ("How tall are you?"),
height = input()
print ("How much do you weigh?"),
weight = input()
print ("So you are %r old, %r tall and %r heavy!"%(age,weight,height) )
|
# Crie um programa que leia quatro notas de um aluno e calcule
# a sua média, mostrando uma mensagem no final, de acordo com
# a média atingida:
# - Média abaixo de 5.0: "Reprovado!"
# - Média entre 5.0 e 6.9: "Recuperação!"
# - Média 7.0 ou superior: "Aprovado!"
nota1 = float(input('\033[36mNota do 1° bimestre:\033[m '))
nota2 = float(input('\033[31mNota do 2° bimestre:\033[m '))
nota3 = float(input('\033[34mNota do 3° bimestre:\033[m '))
nota4 = float(input('\033[30mNota do 4° bimestre:\033[m '))
média = (nota1 + nota2 + nota3 + nota4) / 4
if média < 5.0:
print(f'Sua média é {média:.1f}... \n\033[31mVOCÊ FOI REPROVADO!\033[m')
elif 5.0 <= média <= 6.9:
print(f'Sua média é {média:.1f}... \n\033[31mVOCÊ ESTÁ DE RECUPERAÇÃO!\033[m')
elif média > 7.0:
print(f'Sua média é {média:.1f}... \n\033[36mVOCÊ FOI APROVADO!\033[m')
|
"""
Formatando valores com modificadores:
:s = texto strings
:d = inteiros(int)
:f = numeros ponto flutuante
:.(número)f - quantidade de casas decimais
> - direita
< - esquerda
^ - centro
"""
nome = 'luis'
print(f'{nome:#^15}')
|
# 두 자연수 A와 B가 주어진다. 이때, A+B, A-B, A*B, A/B(몫), A%B(나머지)를 출력하는 프로그램을 작성하시오.
(a,b) = map(int,input().split())
print(a+b)
print(a-b)
print(a*b)
print(a//b)
print(a%b)
# //는 소수점 버림 |
a=int(input("enter number:"))
b=int(input("enter number:"))
c=int(input("enter number:"))
d=int(input("enter number:"))
total=a+b+c+d
average=total/4
print("total=",total)
print("average=",average)
|
# test decorators
def dec(f):
print('dec')
return f
def dec_arg(x):
print(x)
return lambda f:f
# plain decorator
@dec
def f():
pass
# decorator with arg
@dec_arg('dec_arg')
def g():
pass
# decorator of class
@dec
class A:
pass
print("PASS") |
def read_E_matrix():
# # physical distance
# E = [[1, 1, 0, 0, 1, 1],
# [1, 1, 1, 1, 1, 0],
# [0, 1, 1, 1, 0, 0],
# [0, 1, 1, 1, 0, 0],
# [1, 1, 0, 0, 1, 0],
# [1, 0, 0, 0, 0, 1]
# ]
# fully connected
# E = [[1, 1, 1, 1, 1, 1],
# [1, 1, 1, 1, 1, 1],
# [1, 1, 1, 1, 1, 1],
# [1, 1, 1, 1, 1, 1],
# [1, 1, 1, 1, 1, 1],
# [1, 1, 1, 1, 1, 1]
# ]
# view similarity connections.
# E = [[1, 0, 0, 0, 0, 1],
# [0, 1, 0, 1, 0, 0],
# [0, 0, 1, 1, 0, 1],
# [0, 1, 1, 1, 0, 0],
# [0, 0, 0, 0, 1, 1],
# [1, 0, 1, 0, 1, 1]
# ]
# view sim new graph
E= [[1, 0, 1, 0, 1, 1],
[0, 1, 0, 0, 0, 1],
[1, 0, 1, 0, 0, 1],
[0, 0, 0, 1, 1, 0],
[1, 0, 0, 1, 1, 0],
[1, 1, 1, 0, 0, 1]]
# E = graph_p2(5)
# E = graph_p3(5)
# E = graph_p4(5)
# E = graph_p5(5)
# E = graph_p6(5)
# E = graph_p7(5)
# E = graph_p8(5)
# E = graph_p9(5)
# E = graph_random(14)
return E
def graph_random(i):
if i == 6:
E= [[1, 1, 1, 0, 0, 0],
[1, 1, 1, 0, 0, 1],
[1, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 0],
[0, 0, 0, 1, 1, 1],
[0, 1, 0, 0, 1, 1]]
if i == 7:
E= [[1, 1, 1, 0, 0, 0],
[1, 1, 1, 0, 0, 1],
[1, 1, 1, 1, 0, 0],
[0, 0, 1, 1, 1, 0],
[0, 0, 0, 1, 1, 1],
[0, 1, 0, 0, 1, 1]]
if i == 8:
E= [[1, 1, 1, 0, 1, 0],
[1, 1, 1, 0, 0, 1],
[1, 1, 1, 1, 0, 0],
[0, 0, 1, 1, 1, 0],
[1, 0, 0, 1, 1, 1],
[0, 1, 0, 0, 1, 1]]
if i == 9:
E= [[1, 1, 1, 0, 1, 0],
[1, 1, 1, 1, 0, 1],
[1, 1, 1, 1, 0, 0],
[0, 1, 1, 1, 1, 0],
[1, 0, 0, 1, 1, 1],
[0, 1, 0, 0, 1, 1]]
if i == 10:
E= [[1, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 0, 1],
[1, 1, 1, 1, 0, 0],
[1, 1, 1, 1, 1, 0],
[1, 0, 0, 1, 1, 1],
[0, 1, 0, 0, 1, 1]]
if i == 11:
E= [[1, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 0, 1],
[1, 1, 1, 1, 0, 0],
[1, 1, 1, 1, 1, 1],
[1, 0, 0, 1, 1, 1],
[0, 1, 0, 1, 1, 1]]
if i == 12:
E= [[1, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 0, 0],
[1, 1, 1, 1, 1, 1],
[1, 1, 0, 1, 1, 1],
[0, 1, 0, 1, 1, 1]]
if i == 13:
E= [[1, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 0, 1],
[1, 1, 1, 1, 1, 1],
[1, 1, 0, 1, 1, 1],
[0, 1, 1, 1, 1, 1]]
if i == 14:
E= [[1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 0, 1],
[1, 1, 1, 1, 1, 1],
[1, 1, 0, 1, 1, 1],
[1, 1, 1, 1, 1, 1]]
return E
def graph_p9(i):
if i == 1: # 0510
E= [[1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 0, 0],
[1, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 1, 1],
[1, 0, 1, 1, 1, 1],
[1, 0, 0, 1, 1, 1]]
if i == 2: # 0511
E= [[0, 1, 1, 1, 1, 1],
[1, 0, 1, 1, 0, 1],
[1, 1, 0, 1, 1, 1],
[1, 1, 1, 0, 1, 1],
[1, 0, 1, 1, 0, 1],
[1, 1, 1, 1, 1, 0]]
if i == 3: # 0511
E= [[0, 1, 1, 1, 1, 0],
[1, 0, 1, 0, 1, 1],
[1, 1, 0, 1, 1, 1],
[1, 0, 1, 0, 1, 1],
[1, 1, 1, 1, 0, 1],
[0, 1, 1, 1, 1, 0]]
if i == 4: # 0511
E= [[0, 1, 1, 1, 1, 1],
[1, 0, 1, 1, 1, 1],
[1, 1, 0, 1, 1, 1],
[1, 1, 1, 0, 0, 1],
[1, 1, 1, 0, 0, 0],
[1, 1, 1, 1, 0, 0]]
if i == 5: # 0511
E= [[0, 1, 0, 1, 1, 1],
[1, 0, 1, 1, 1, 1],
[0, 1, 0, 1, 1, 1],
[1, 1, 1, 0, 1, 1],
[1, 1, 1, 1, 0, 1],
[1, 1, 1, 1, 1, 0]]
return E
def graph_p8(i):
if i == 1: # 0510
E = [[1, 0, 1, 1, 1, 0],
[0, 1, 0, 1, 0, 1],
[1, 0, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1],
[1, 0, 1, 1, 1, 1],
[0, 1, 1, 1, 1, 1]]
if i == 2: # 0511
E= [[1, 1, 1, 1, 0, 0],
[1, 1, 0, 1, 1, 1],
[1, 0, 1, 1, 1, 1],
[1, 1, 1, 1, 0, 1],
[0, 1, 1, 0, 1, 1],
[0, 1, 1, 1, 1, 1]]
if i == 3: # 0511
E= [[1, 0, 1, 1, 1, 0],
[0, 1, 1, 0, 1, 1],
[1, 1, 1, 1, 1, 1],
[1, 0, 1, 1, 0, 1],
[1, 1, 1, 0, 1, 0],
[0, 1, 1, 1, 0, 1]]
if i == 4: # 0511
E= [[0, 1, 0, 0, 1, 1],
[1, 0, 1, 1, 1, 1],
[0, 1, 0, 1, 1, 1],
[0, 1, 1, 0, 1, 1],
[1, 1, 1, 1, 0, 1],
[1, 1, 1, 1, 1, 0]]
if i == 5: # 0511
E= [[0, 1, 1, 1, 1, 0],
[1, 0, 1, 1, 0, 1],
[1, 1, 0, 1, 1, 1],
[1, 1, 1, 0, 1, 1],
[1, 0, 1, 1, 0, 0],
[0, 1, 1, 1, 0, 0]]
return E
def graph_p7(i):
if i == 1: # 0510
E= [[1, 1, 1, 1, 0, 0],
[1, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 0, 1],
[1, 1, 1, 1, 1, 0],
[0, 1, 0, 1, 1, 1],
[0, 0, 1, 0, 1, 1]]
if i == 2: # 0511
E= [[1, 0, 0, 1, 1, 0],
[0, 1, 1, 1, 0, 1],
[0, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1],
[1, 0, 1, 1, 1, 1],
[0, 1, 1, 1, 1, 1]]
if i == 3: # 0511
E= [[1, 0, 1, 1, 0, 1],
[0, 1, 1, 0, 0, 1],
[1, 1, 1, 0, 1, 0],
[1, 0, 0, 1, 1, 1],
[0, 0, 1, 1, 1, 0],
[1, 1, 0, 1, 0, 1]]
if i == 4: # 0511
E= [[1, 1, 0, 1, 0, 0],
[1, 1, 0, 1, 1, 1],
[0, 0, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1],
[0, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 0, 1]]
if i == 5: # 0511
E= [[1, 1, 0, 1, 1, 1],
[1, 1, 1, 1, 0, 1],
[0, 1, 1, 0, 1, 1],
[1, 1, 0, 1, 0, 0],
[1, 0, 1, 0, 1, 0],
[1, 1, 1, 0, 0, 1]]
return E
def graph_p6(i):
if i == 1: # 0510
E= [[1, 0, 1, 1, 1, 0],
[0, 1, 0, 0, 1, 0],
[1, 0, 1, 1, 1, 0],
[1, 0, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1],
[0, 0, 0, 1, 1, 1]]
if i == 2: # 0511
E= [[1, 0, 1, 1, 1, 1],
[0, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 0, 1],
[1, 1, 1, 0, 1, 0],
[1, 0, 0, 1, 0, 1]]
if i == 3: # 0511
E= [[1, 0, 1, 1, 0, 1],
[0, 1, 0, 0, 1, 1],
[1, 0, 1, 0, 1, 1],
[1, 0, 0, 1, 1, 0],
[0, 1, 1, 1, 1, 0],
[1, 1, 1, 0, 0, 1]]
if i == 4: # 0511
E= [[1, 1, 1, 0, 1, 0],
[1, 1, 0, 1, 1, 1],
[1, 0, 1, 1, 0, 1],
[0, 1, 1, 1, 0, 0],
[1, 1, 0, 0, 1, 1],
[0, 1, 1, 0, 1, 1]]
if i == 5: # 0511
E= [[1, 1, 1, 1, 1, 1],
[1, 1, 1, 0, 1, 1],
[1, 1, 1, 0, 1, 1],
[1, 0, 0, 1, 0, 1],
[1, 1, 1, 0, 1, 1],
[1, 1, 1, 1, 1, 1]]
return E
def graph_p5(i):
if i == 1: # 0510
E= [[1, 1, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 1],
[0, 1, 1, 1, 1, 1],
[0, 0, 1, 1, 1, 1],
[0, 0, 1, 1, 1, 0],
[0, 1, 1, 1, 0, 1]]
if i == 2: # 0511
E= [[1, 1, 0, 0, 1, 0],
[1, 1, 1, 0, 1, 1],
[0, 1, 1, 1, 1, 0],
[0, 0, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 0],
[0, 1, 0, 1, 0, 1]]
if i == 3: # 0511
E= [[1, 1, 1, 1, 0, 0],
[1, 1, 1, 0, 1, 1],
[1, 1, 1, 0, 1, 0],
[1, 0, 0, 1, 0, 1],
[0, 1, 1, 0, 1, 0],
[0, 1, 0, 1, 0, 1]]
if i == 4: # 0511
E= [[1, 0, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 0, 0],
[1, 1, 1, 1, 0, 0],
[1, 1, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 1]]
if i == 5: # 0511
E= [[1, 0, 0, 0, 1, 1],
[0, 1, 1, 0, 0, 0],
[0, 1, 1, 1, 1, 1],
[0, 0, 1, 1, 1, 1],
[1, 0, 1, 1, 1, 1],
[1, 0, 1, 1, 1, 1]]
return E
def graph_p4(i):
if i == 1: # 0510
E= [[1, 0, 1, 1, 1, 0],
[0, 1, 1, 0, 1, 0],
[1, 1, 1, 1, 0, 1],
[1, 0, 1, 1, 0, 0],
[1, 1, 0, 0, 1, 0],
[0, 0, 1, 0, 0, 1]]
if i == 2: # 0511
E= [[1, 1, 0, 1, 1, 0],
[1, 1, 1, 1, 0, 0],
[0, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 0, 0],
[1, 0, 1, 0, 1, 1],
[0, 0, 0, 0, 1, 1]]
if i == 3: # 0511
E= [[1, 0, 0, 0, 0, 1],
[0, 1, 1, 1, 0, 0],
[0, 1, 1, 0, 1, 0],
[0, 1, 0, 1, 1, 1],
[0, 0, 1, 1, 1, 1],
[1, 0, 0, 1, 1, 1]]
if i == 4: # 0511
E= [[1, 1, 1, 0, 1, 1],
[1, 1, 1, 0, 0, 0],
[1, 1, 1, 0, 0, 1],
[0, 0, 0, 1, 1, 0],
[1, 0, 0, 1, 1, 0],
[1, 0, 1, 0, 0, 1]]
if i == 5: # 0511
E= [[1, 1, 0, 1, 1, 1],
[1, 1, 0, 1, 0, 1],
[0, 0, 1, 0, 0, 1],
[1, 1, 0, 1, 0, 0],
[1, 0, 0, 0, 1, 0],
[1, 1, 1, 0, 0, 1]]
return E
def graph_p3(i):
if i == 1: # 0510
E= [[1, 0, 1, 0, 0, 1],
[0, 1, 0, 0, 1, 1],
[1, 0, 1, 1, 0, 0],
[0, 0, 1, 1, 0, 1],
[0, 1, 0, 0, 1, 0],
[1, 1, 0, 1, 0, 1]]
if i == 2: # 0511
E= [[1, 0, 1, 0, 1, 1],
[0, 1, 0, 0, 0, 1],
[1, 0, 1, 0, 0, 1],
[0, 0, 0, 1, 1, 0],
[1, 0, 0, 1, 1, 0],
[1, 1, 1, 0, 0, 1]]
if i == 3: # 0511
E= [[1, 1, 0, 1, 0, 0],
[1, 1, 0, 0, 1, 0],
[0, 0, 1, 1, 0, 1],
[1, 0, 1, 1, 1, 0],
[0, 1, 0, 1, 1, 1],
[0, 0, 1, 0, 1, 1]]
if i == 4: # 0511
E= [[1, 1, 1, 0, 1, 0],
[1, 1, 1, 0, 0, 1],
[1, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 0],
[1, 0, 0, 1, 1, 0],
[0, 1, 0, 0, 0, 1]]
if i == 5: # 0511
E= [[1, 0, 0, 0, 0, 1],
[0, 1, 1, 1, 0, 0],
[0, 1, 1, 0, 1, 1],
[0, 1, 0, 1, 0, 1],
[0, 0, 1, 0, 1, 0],
[1, 0, 1, 1, 0, 1]]
return E
def graph_p2(i):
if i == 1: # 0510
E= [[1, 1, 1, 0, 1, 0],
[1, 1, 0, 0, 0, 0],
[1, 0, 1, 1, 0, 1],
[0, 0, 1, 1, 0, 0],
[1, 0, 0, 0, 1, 0],
[0, 0, 1, 0, 0, 1]]
if i == 2: # 0511
E= [[1, 0, 0, 0, 0, 1],
[0, 1, 0, 1, 0, 0],
[0, 0, 1, 1, 1, 0],
[0, 1, 1, 1, 0, 0],
[0, 0, 1, 0, 1, 1],
[1, 0, 0, 0, 1, 1]]
if i == 3: # 0511
E= [[1, 0, 1, 0, 0, 0],
[0, 1, 1, 0, 1, 1],
[1, 1, 1, 1, 0, 0],
[0, 0, 1, 1, 0, 0],
[0, 1, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 1]]
if i == 4: # 0511
E= [[1, 1, 1, 0, 0, 0],
[1, 1, 1, 0, 0, 0],
[1, 1, 1, 0, 1, 1],
[0, 0, 0, 1, 0, 1],
[0, 0, 1, 0, 1, 0],
[0, 0, 1, 1, 0, 1]]
if i == 5: # 0511
E= [[1, 0, 0, 1, 0, 0],
[0, 1, 0, 1, 0, 0],
[0, 0, 1, 1, 1, 0],
[1, 1, 1, 1, 0, 1],
[0, 0, 1, 0, 1, 0],
[0, 0, 0, 1, 0, 1]]
return E |
# Databricks notebook source
# MAGIC %run ./_utility-methods $lesson="dlt_lab_82"
# COMMAND ----------
# MAGIC %run ./mount-datasets
# COMMAND ----------
# def print_sql(rows, sql):
# displayHTML(f"""<body><textarea style="width:100%" rows={rows}> \n{sql.strip()}</textarea></body>""")
# COMMAND ----------
# generate_register_dlt_event_metrics_sql_string = ""
# def _generate_register_dlt_event_metrics_sql():
# global generate_register_dlt_event_metrics_sql_string
# generate_register_dlt_event_metrics_sql_string = f"""
# CREATE TABLE IF NOT EXISTS {DA.db_name}.dlt_events
# LOCATION '{DA.paths.working_dir}/storage/system/events';
# CREATE VIEW IF NOT EXISTS {DA.db_name}.dlt_success AS
# SELECT * FROM {DA.db_name}.dlt_events
# WHERE details:flow_progress:metrics IS NOT NULL;
# CREATE VIEW IF NOT EXISTS {DA.db_name}.dlt_metrics AS
# SELECT timestamp, origin.flow_name, details
# FROM {DA.db_name}.dlt_success
# ORDER BY timestamp DESC;""".strip()
# print_sql(13, generate_register_dlt_event_metrics_sql_string)
# DA.generate_register_dlt_event_metrics_sql = _generate_register_dlt_event_metrics_sql
# COMMAND ----------
# def _generate_daily_patient_avg():
# sql = f"SELECT * FROM {DA.db_name}.daily_patient_avg"
# print_sql(3, sql)
# DA.generate_daily_patient_avg = _generate_daily_patient_avg
# COMMAND ----------
# def _generate_visualization_query():
# sql = f"""
# SELECT flow_name, timestamp, int(details:flow_progress:metrics:num_output_rows) num_output_rows
# FROM {DA.db_name}.dlt_metrics
# ORDER BY timestamp DESC;"""
# print_sql(5, sql)
# DA.generate_visualization_query = _generate_visualization_query
# COMMAND ----------
def print_pipeline_config():
displayHTML(f"""<table>
<tr><td>Pipeline Name:</td><td><b>DLT-Lab-82L-{DA.username}</b></td></tr>
<tr><td>Source:</td><td><b>{DA.paths.working_dir}/source/tracker</b></td></tr>
<tr><td>Target:</td><td><b>{DA.db_name}</b></td></tr>
<tr><td>Storage Location:</td><td><b>{DA.paths.working_dir}/storage</b></td></tr>
</table>""")
# COMMAND ----------
DA.cleanup()
DA.init()
# DA.paths.data_source = "/mnt/training/healthcare"
# DA.paths.storage_location = f"{DA.paths.working_dir}/storage"
# DA.paths.data_landing_location = f"{DA.paths.working_dir}/source/tracker"
DA.data_factory = DltDataFactory()
DA.conclude_setup()
|
# color mixer
print("Red, blue, and yellow are primary colors.")
print()
# ask user to choose two primary colors to mix
color1 = input("Enter the primary color 1 (red,blue, or yellow): ")
color2 = input("Enter the primary color 2 (red,blue, or yellow): ")
if color1 == "red" and color2 == "blue":
print("The secondary color is purple.")
elif color1 == "blue" and color2 == "red":
print("The secondary color is purple.")
elif color1 == "red" and color2 == "yellow":
print("The secondary color is orange.")
elif color1 == "red" and color2 == "yellow":
print("The secondary color is orange.")
elif color1 == "blue" and color2 == "yellow":
print("The secondary color is green.")
elif color1 == "yellow" and color2 == "blue":
print("The secondary color is green.")
else:
print("ERROR")
|
# Non-MacOS users can change it to Chrome/Firefox.
BROWSER = "Chrome" # can be Chrome/Safari/Firefox
MATCH_URL = "http://www.espncricinfo.com/series/8039/commentary/1144506/afghanistan-vs-england-24th-match-icc-cricket-world-cup-2019"
MESSAGE_BOX_CLASS_NAME = "_3u328"
SEND_BUTTON_CLASS_NAME = "_3M-N-"
# Match start timings according to where the script is being run.
MATCH_START_HOURS = 13
MATCH_START_MINUTES = 30
MATCH_END_HOURS = 23
MATCH_END_MINUTES = 0
SCRIPT_LOG_FILE_NAME = '../logs/script_logs.log'
ERROR_LOG_FILE_NAME = '../logs/error_logs.log'
# This tells whether the script is running in test mode or not. If yes, the actual data sent is less, for better debugging.
IS_TEST_MODE = False
|
# REST API server related constants
USERNAME = "asdfg"
PASSWORD = "asdfg"
HOST = "http://127.0.0.1:8000"
AUTH_URL: str = f"{HOST}/auth/"
LOCATIONS_URL: str = f"{HOST}/api/locations/"
PANIC_URL: str = f"{HOST}/api/panic/"
# Format constants
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"
PRECISION = 6
# Job scheduling constants
TIME_PANIC = 1 # TODO: Change to 60
TIME_NO_PANIC = 5 # TODO: Change to 1800
TIME_CHECK_PANIC = 3 # TODO: Change to 300
# Logging constants
LOG_FILE = "gps_tracker.log" # TODO: move to /var/log/
LOG_FORMAT = "%(asctime)s - %(levelname)s - %(message)s"
PENDING_FILE = "pending_locations.json" # TODO: move to /usr/local/share/gps_tracker/
|
numOne = int(input("Первое число: "))
numTwo = int(input("Второе число: "))
numThree = int(input("Третье число: "))
numFour = int(input("Четвертое число: "))
res = (numOne + numTwo)/(numThree + numFour)
print(f"Ваш ответ: {res}") |
LOCK = False
RELEASE = True
VERSION = "19.99.0"
VERSION_AGAIN = "19.99.0"
STRICT_VERSION = "19.99.0"
UNRELATED_STRING = "apple"
|
def dec_to_bin(dec):
bin_num = ''
while dec > 0:
bin_num = str(dec % 2) + bin_num
dec //= 2
return bin_num
if __name__ == "__main__":
dec_num = int(input())
print(dec_to_bin(dec_num))
|
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# author: ouyangshaokun
# date:
print(44444444444)
print("fsfasfaa")
print(22222222)
print("fsfasfa")
print(123214)
print(22222222)
print(22222222)
print(22222222)
print(22222222)
print(22222222)
print(22222222)
print(42342) |
class Solution(object):
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
pre = None
i = 0
while i < len(nums):
if pre is None:
pre = nums[0]
i += 1
elif nums[i] == pre:
pre = nums[i]
nums.pop(i)
else:
pre = nums[i]
i += 1
return len(nums)
nums = [1, 1, 2]
s = Solution()
print(s.removeDuplicates(nums))
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
print('中文 English')
# ord()函数获取字符的整数表示
print(ord('A'))
print(ord('中'))
# chr()函数把编码转换为对应的字符
print(chr(66))
print(chr(25991))
# 使用16进制表示汉字
print('16进制', '\u4e2d\u6587')
# 16进制 中文
# 字符串的 encode
print('bytes', b'ABC')
# bytes b'ABC'
print('str encode to bytes:', 'ABC'.encode('ascii'))
# str encode to bytes: b'ABC'
print('中文 encode to utf-8:', '中文'.encode('utf-8'))
# 中文 encode to utf-8: b'\xe4\xb8\xad\xe6\x96\x87'
# 字符串的 decode
print('bytes to ascii:', b'ABC'.decode('ascii'))
# bytes to ascii: ABC
print('bytes to ascii:', b'ABC'.decode('utf-8'))
# bytes to ascii: ABC
print('中文bytes to utf-8:', b'\xe4\xb8\xad\xe6\x96\x87'.decode('utf-8'))
# 中文bytes to utf-8: 中文
print('错误的中文bytes to utf-8:', b'\xe4\xb8\xad\xe6\x87'.decode('utf-8', errors='ignore'))
# 错误的中文bytes to utf-8: 中
# str len 计算str包含多少个字符,用len()函数
print(len('ABC'))
# 3
print(len('中文'))
# 2
# bytes,len()函数就计算字节数
print(len(b'ABC'))
# 3
print(len(b'\xe4\xb8\xad\xe6\x96\x87'))
# 6
print(len('中文'.encode('utf-8')))
# 6
# 字符串格式化, 字符串里面的%是一个普通字符怎么办?这个时候就需要转义,用%%来表示一个%
print("Hello, %s" % "World")
# Hello, World
print("Hi, %s, you are %s" % ("LiYong", "Good"))
# Hi, LiYong, you are Good
# 使用format格式化字符串
print("Hello, {0}, 工资为 {1:.1f}".format("yong", 100.2350))
# Hello, yong, 工资为 100.2
# f-string,可以通过参数名进行替换
name = 'li.yong'
salary = 100.231
print(f'Hi, {name}, salary is {salary:.1f}')
# Hi, li.yong, salary is 100.2
|
"""[0 - ally ranks, 1 - enemy ranks, 2 - stun skill chance or blight damage, 3 - move distance]"""
AttackSkills = {
# highwayman
'wicked_slice': [[1, 2, 3], [1, 2]],
'opened_vein': [[1, 2, 3], [1, 2]],
'pistol_shot': [[2, 3, 4], [2, 3, 4]],
'duelist_advance': [[2, 3, 4], [1, 2, 3], None, 1],
'point_blank_shot': [[1], [1], None, -1],
# crusader
'smite': [[1, 2], [1, 2]],
'stunning_blow': [[1, 2], [1, 2], [100, 110, 120, 130, 140]],
'holy_lance': [[3, 4], [2, 3, 4], None, 1],
'inspiring_cry': [[1, 2, 3, 4], [1, 2, 3, 4]],
# plague_doctor
'noxious_blast': [[2, 3, 4], [1, 2], [5, 5, 6, 6, 7]],
'plague_grenade': [[3, 4], [3, 4], [4, 4, 5, 5, 6]],
'blinding_gas': [[3, 4], [3, 4], [100, 110, 120, 130, 140]],
'incision': [[1, 2, 3], [1, 2]],
'battlefield_medicine': [[3, 4], [1, 2, 3, 4]],
'emboldening_vapors': [[3, 4], [1, 2, 3, 4]],
'disorienting_blast': [[2, 3, 4], [2, 3, 4], [100, 110, 120, 130, 140]],
# vestal
'judgement': [[3, 4], [1, 2, 3, 4]],
'dazzling_light': [[2, 3, 4], [1, 2, 3], [100, 110, 120, 130, 140]],
'divine_grace': [[3, 4], [1, 2, 3, 4]],
'gods_comfort': [[2, 3, 4], [0]], # divine comfort
'gods_hand': [[1, 2], [1, 2, 3]], # hand of light
'gods_illumination': [[1, 2, 3], [1, 2, 3, 4]], # illumination
# hellion
'wicked_hack': [[1, 2], [1, 2]],
'iron_swan': [[1], [4]],
'barbaric_yawp': [[1, 2], [1, 2], [110, 120, 130, 140, 150]], # yawp
'if_it_bleeds': [[1, 2, 3], [2, 3]],
# houndmaster
'hounds_rush': [[2, 3, 4], [1, 2, 3, 4]],
'howl': [[3, 4], [0]], # cry_havoc
'guard_dog': [[1, 2, 3, 4], [1, 2, 3, 4]],
'lick_wounds': [[2, 3, 4], [0]],
'hounds_harry': [[1, 2, 3, 4], [0]],
'blackjack': [[1, 2], [1, 2, 3], [110, 120, 130, 140, 150]],
# jester
'dirk_stab': [[1, 2, 3, 4], [1, 2, 3], None, 1],
'harvest': [[2, 3], [2, 3]],
'slice_off': [[2, 3], [2, 3]],
'battle_ballad': [[3, 4], [0]],
'inspiring_tune': [[3, 4], [1, 2, 3, 4]],
# man-at-arms
'crush': [[1, 2], [1, 2, 3]],
'rampart': [[1, 2, 3], [1, 2], [100, 110, 120, 130, 140], 1],
'defender': [[1, 2, 3, 4], [1, 2, 3, 4]],
'retribution': [[1, 2, 3], [1, 2, 3]],
'command': [[1, 2, 3, 4], [1, 2, 3, 4]],
'bolster': [[1, 2, 3, 4], [0]],
# occultist
'bloodlet': [[1, 2, 3], [1, 2, 3]], # sacrificial_stab
'abyssal_artillery': [[3, 4], [3, 4]],
'weakening_curse': [[1, 2, 3, 4], [1, 2, 3, 4]],
'wyrd_reconstruction': [[1, 2, 3, 4], [1, 2, 3, 4]],
'vulnerability_hex': [[1, 2, 3, 4], [1, 2, 3, 4]],
'hands_from_abyss': [[1, 2], [1, 2, 3], [110, 120, 130, 140, 150]], # hands_from_the_abyss
'daemons_pull': [[2, 3, 4], [3, 4]],
# shieldbreaker
'pierce': [[1, 2, 3], [1, 2, 3, 4], None, 1],
'break_guard': [[1, 2, 3, 4], [1, 2, 3, 4], None, 1], # puncture
'adders_kiss': [[1], [1, 2], None, -1],
'impale': [[1], [0], None, -1],
'expose': [[1, 2, 3], [1, 2, 3], None, -1],
'single_out': [[2, 3], [2, 3]], # captivate
'serpent_sway': [[1, 2, 3], [0], None, 1],
}
|
class AbstractCredentialValidator(object):
"""An abstract CredentialValidator, when inherited it must validate self.user credentials
agains self.action"""
def __init__(self, action, user):
self.action = action
self.user = user
def updatePDUWithUserDefaults(self, PDU):
"""Must update PDU.params from User credential defaults whenever a
PDU.params item is None"""
raise NotImplementedError()
def validate(self):
"Must validate requests through Authorizations and ValueFilters credential check"
raise NotImplementedError()
|
def add_elem(lst,ele):
lst.append(ele)
my_lst=[1,2,3]
print(my_lst)
add_elem(my_lst,5)
print(my_lst)
|
print("Welcome to the GPA calculator")
print("Please enter all your letter grades, one per line.")
print("Enter a blank line to designate the end.")
# map from letter grade to point value
points = {
'A+': 4.0,
'A': 3.8,
'A-': 3.67,
'B+': 3.33,
'B': 3.0,
'B-': 2.67,
'C+': 2.33,
'C': 2.0,
'C-': 1.67,
'D': 1.0,
'F': 0.0,
}
num_courses = 0
total_points = 0
done = False
while not done:
# readline from user input
grade = input()
if grade == '': # empty line was entered
done = True
elif grade not in points:
print("Unknow grade '{0}' being ignored".format(grade))
else:
num_courses += 1
total_points += points[grade]
if num_courses > 0: # avoid division by
print("Your GPA is {0:.3}".format(total_points / num_courses)) |
class Logger(object):
def log(self, str):
print("Log: {}".format(str))
def error(self, str):
print("Error: {}".format(str))
def message(self, str):
print("Message: {}".format(str))
|
FAIL_ON_ANY = 'any'
FAIL_ON_NEW = 'new'
# Identifies that a comment came from Lintly. This is used to aid in automatically
# deleting old PR comments/reviews. This is valid Markdown that is hidden from
# users in GitHub and GitLab.
LINTLY_IDENTIFIER = '<!-- Automatically posted by Lintly -->'
|
#
# PySNMP MIB module ADSL-LINE-EXT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ADSL-LINE-EXT-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:13:46 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)
#
adslLineConfProfileEntry, adslAturPerfDataEntry, adslLineAlarmConfProfileEntry, adslLineEntry, adslAturIntervalEntry, adslAtucPerfDataEntry, adslAtucIntervalEntry, adslMIB = mibBuilder.importSymbols("ADSL-LINE-MIB", "adslLineConfProfileEntry", "adslAturPerfDataEntry", "adslLineAlarmConfProfileEntry", "adslLineEntry", "adslAturIntervalEntry", "adslAtucPerfDataEntry", "adslAtucIntervalEntry", "adslMIB")
AdslPerfPrevDayCount, AdslPerfCurrDayCount = mibBuilder.importSymbols("ADSL-TC-MIB", "AdslPerfPrevDayCount", "AdslPerfCurrDayCount")
OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsIntersection, ValueRangeConstraint, SingleValueConstraint, ConstraintsUnion, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueRangeConstraint", "SingleValueConstraint", "ConstraintsUnion", "ValueSizeConstraint")
PerfCurrentCount, PerfIntervalCount = mibBuilder.importSymbols("PerfHist-TC-MIB", "PerfCurrentCount", "PerfIntervalCount")
SnmpAdminString, = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString")
NotificationGroup, ModuleCompliance, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup")
Counter32, Bits, MibIdentifier, TimeTicks, ModuleIdentity, Integer32, IpAddress, Unsigned32, MibScalar, MibTable, MibTableRow, MibTableColumn, ObjectIdentity, iso, NotificationType, Counter64, Gauge32 = mibBuilder.importSymbols("SNMPv2-SMI", "Counter32", "Bits", "MibIdentifier", "TimeTicks", "ModuleIdentity", "Integer32", "IpAddress", "Unsigned32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ObjectIdentity", "iso", "NotificationType", "Counter64", "Gauge32")
TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString")
adslExtMIB = ModuleIdentity((1, 3, 6, 1, 2, 1, 10, 94, 3))
adslExtMIB.setRevisions(('2002-12-10 00:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts: adslExtMIB.setRevisionsDescriptions(('Initial Version, published as RFC 3440. This MIB module supplements the ADSL-LINE-MIB [RFC2662].',))
if mibBuilder.loadTexts: adslExtMIB.setLastUpdated('200212100000Z')
if mibBuilder.loadTexts: adslExtMIB.setOrganization('IETF ADSL MIB Working Group')
if mibBuilder.loadTexts: adslExtMIB.setContactInfo(' Faye Ly Pedestal Networks 6503 Dumbarton Circle, Fremont, CA 94555 Tel: +1 510-578-0158 Fax: +1 510-744-5152 E-Mail: faye@pedestalnetworks.com Gregory Bathrick Nokia Networks 2235 Mercury Way, Fax: +1 707-535-7300 E-Mail: greg.bathrick@nokia.com General Discussion:adslmib@ietf.org To Subscribe: https://www1.ietf.org/mailman/listinfo/adslmib Archive: https://www1.ietf.org/mailman/listinfo/adslmib ')
if mibBuilder.loadTexts: adslExtMIB.setDescription('Copyright (C) The Internet Society (2002). This version of this MIB module is part of RFC 3440; see the RFC itself for full legal notices. This MIB Module is a supplement to the ADSL-LINE-MIB [RFC2662].')
adslExtMibObjects = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 94, 3, 1))
class AdslTransmissionModeType(TextualConvention, Bits):
description = 'A set of ADSL line transmission modes, with one bit per mode. The notes (F) and (L) denote Full-Rate and G.Lite respectively: Bit 00 : Regional Std. (ANSI T1.413) (F) Bit 01 : Regional Std. (ETSI DTS/TM06006) (F) Bit 02 : G.992.1 POTS non-overlapped (F) Bit 03 : G.992.1 POTS overlapped (F) Bit 04 : G.992.1 ISDN non-overlapped (F) Bit 05 : G.992.1 ISDN overlapped (F) Bit 06 : G.992.1 TCM-ISDN non-overlapped (F) Bit 07 : G.992.1 TCM-ISDN overlapped (F) Bit 08 : G.992.2 POTS non-overlapped (L) Bit 09 : G.992.2 POTS overlapped (L) Bit 10 : G.992.2 with TCM-ISDN non-overlapped (L) Bit 11 : G.992.2 with TCM-ISDN overlapped (L) Bit 12 : G.992.1 TCM-ISDN symmetric (F) '
status = 'current'
namedValues = NamedValues(("ansit1413", 0), ("etsi", 1), ("q9921PotsNonOverlapped", 2), ("q9921PotsOverlapped", 3), ("q9921IsdnNonOverlapped", 4), ("q9921isdnOverlapped", 5), ("q9921tcmIsdnNonOverlapped", 6), ("q9921tcmIsdnOverlapped", 7), ("q9922potsNonOverlapeed", 8), ("q9922potsOverlapped", 9), ("q9922tcmIsdnNonOverlapped", 10), ("q9922tcmIsdnOverlapped", 11), ("q9921tcmIsdnSymmetric", 12))
adslLineExtTable = MibTable((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 17), )
if mibBuilder.loadTexts: adslLineExtTable.setStatus('current')
if mibBuilder.loadTexts: adslLineExtTable.setDescription("This table is an extension of RFC 2662. It contains ADSL line configuration and monitoring information. This includes the ADSL line's capabilities and actual ADSL transmission system.")
adslLineExtEntry = MibTableRow((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 17, 1), )
adslLineEntry.registerAugmentions(("ADSL-LINE-EXT-MIB", "adslLineExtEntry"))
adslLineExtEntry.setIndexNames(*adslLineEntry.getIndexNames())
if mibBuilder.loadTexts: adslLineExtEntry.setStatus('current')
if mibBuilder.loadTexts: adslLineExtEntry.setDescription('An entry extends the adslLineEntry defined in [RFC2662]. Each entry corresponds to an ADSL line.')
adslLineTransAtucCap = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 17, 1, 1), AdslTransmissionModeType()).setMaxAccess("readonly")
if mibBuilder.loadTexts: adslLineTransAtucCap.setReference('Section 7.3.2 ITU G.997.1')
if mibBuilder.loadTexts: adslLineTransAtucCap.setStatus('current')
if mibBuilder.loadTexts: adslLineTransAtucCap.setDescription('The transmission modes, represented by a bitmask that the ATU-C is capable of supporting. The modes available are limited by the design of the equipment.')
adslLineTransAtucConfig = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 17, 1, 2), AdslTransmissionModeType()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: adslLineTransAtucConfig.setReference('Section 7.3.2 ITU G.997.1')
if mibBuilder.loadTexts: adslLineTransAtucConfig.setStatus('current')
if mibBuilder.loadTexts: adslLineTransAtucConfig.setDescription("The transmission modes, represented by a bitmask, currently enabled by the ATU-C. The manager can only set those modes that are supported by the ATU-C. An ATU-C's supported modes are provided by AdslLineTransAtucCap.")
adslLineTransAtucActual = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 17, 1, 3), AdslTransmissionModeType()).setMaxAccess("readonly")
if mibBuilder.loadTexts: adslLineTransAtucActual.setReference('Section 7.3.2 ITU G.997.1 ')
if mibBuilder.loadTexts: adslLineTransAtucActual.setStatus('current')
if mibBuilder.loadTexts: adslLineTransAtucActual.setDescription("The actual transmission mode of the ATU-C. During ADSL line initialization, the ADSL Transceiver Unit - Remote terminal end (ATU-R) will determine the mode used for the link. This value will be limited a single transmission mode that is a subset of those modes enabled by the ATU-C and denoted by adslLineTransAtucConfig. After an initialization has occurred, its mode is saved as the 'Current' mode and is persistence should the link go down. This object returns 0 (i.e. BITS with no mode bit set) if the mode is not known.")
adslLineGlitePowerState = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 17, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("none", 1), ("l0", 2), ("l1", 3), ("l3", 4)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: adslLineGlitePowerState.setStatus('current')
if mibBuilder.loadTexts: adslLineGlitePowerState.setDescription('The value of this object specifies the power state of this interface. L0 is power on, L1 is power on but reduced and L3 is power off. Power state cannot be configured by an operator but it can be viewed via the ifOperStatus object for the managed ADSL interface. The value of the object ifOperStatus is set to down(2) if the ADSL interface is in power state L3 and is set to up(1) if the ADSL line interface is in power state L0 or L1. If the object adslLineTransAtucActual is set to a G.992.2 (G.Lite)-type transmission mode, the value of this object will be one of the valid power states: L0(2), L1(3), or L3(4). Otherwise, its value will be none(1).')
adslLineConfProfileDualLite = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 17, 1, 5), SnmpAdminString()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: adslLineConfProfileDualLite.setReference('Section 5.4 Profiles, RFC 2662')
if mibBuilder.loadTexts: adslLineConfProfileDualLite.setStatus('current')
if mibBuilder.loadTexts: adslLineConfProfileDualLite.setDescription("This object extends the definition an ADSL line and associated channels (when applicable) for cases when it is configured in dual mode, and operating in a G.Lite-type mode as denoted by adslLineTransAtucActual. Dual mode exists when the object, adslLineTransAtucConfig, is configured with one or more full-rate modes and one or more G.Lite modes simultaneously. When 'dynamic' profiles are implemented, the value of object is equal to the index of the applicable row in the ADSL Line Configuration Profile Table, AdslLineConfProfileTable defined in ADSL-MIB [RFC2662]. In the case when dual-mode has not been enabled, the value of the object will be equal to the value of the object adslLineConfProfile [RFC2662]. When `static' profiles are implemented, in much like the case of the object, adslLineConfProfileName [RFC2662], this object's value will need to algorithmically represent the characteristics of the line. In this case, the value of the line's ifIndex plus a value indicating the line mode type (e.g., G.Lite, Full-rate) will be used. Therefore, the profile's name is a string concatenating the ifIndex and one of the follow values: Full or Lite. This string will be fixed-length (i.e., 14) with leading zero(s). For example, the profile name for ifIndex that equals '15' and is a full rate line, it will be '0000000015Full'.")
adslAtucPerfDataExtTable = MibTable((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18), )
if mibBuilder.loadTexts: adslAtucPerfDataExtTable.setStatus('current')
if mibBuilder.loadTexts: adslAtucPerfDataExtTable.setDescription('This table extends adslAtucPerfDataTable [RFC2662] with additional ADSL physical line counter information such as unavailable seconds-line and severely errored seconds-line.')
adslAtucPerfDataExtEntry = MibTableRow((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1), )
adslAtucPerfDataEntry.registerAugmentions(("ADSL-LINE-EXT-MIB", "adslAtucPerfDataExtEntry"))
adslAtucPerfDataExtEntry.setIndexNames(*adslAtucPerfDataEntry.getIndexNames())
if mibBuilder.loadTexts: adslAtucPerfDataExtEntry.setStatus('current')
if mibBuilder.loadTexts: adslAtucPerfDataExtEntry.setDescription('An entry extends the adslAtucPerfDataEntry defined in [RFC2662]. Each entry corresponds to an ADSL line.')
adslAtucPerfStatFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 1), Counter32()).setUnits('line retrains').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAtucPerfStatFastR.setReference('ITU G.997.1 Section 7.4.15.1 ')
if mibBuilder.loadTexts: adslAtucPerfStatFastR.setStatus('current')
if mibBuilder.loadTexts: adslAtucPerfStatFastR.setDescription('The value of this object reports the count of the number of fast line bs since last agent reset.')
adslAtucPerfStatFailedFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 2), Counter32()).setUnits('line retrains').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAtucPerfStatFailedFastR.setReference('ITU G.997.1 Section 7.4.15.2 ')
if mibBuilder.loadTexts: adslAtucPerfStatFailedFastR.setStatus('current')
if mibBuilder.loadTexts: adslAtucPerfStatFailedFastR.setDescription('The value of this object reports the count of the number of failed fast line retrains since last agent reset.')
adslAtucPerfStatSesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 3), Counter32()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAtucPerfStatSesL.setReference('ITU G.997.1 Section 7.2.1.1.7 ')
if mibBuilder.loadTexts: adslAtucPerfStatSesL.setStatus('current')
if mibBuilder.loadTexts: adslAtucPerfStatSesL.setDescription('The value of this object reports the count of the number of severely errored seconds-line since last agent reset.')
adslAtucPerfStatUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 4), Counter32()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAtucPerfStatUasL.setReference('ITU G.997.1 Section 7.2.1.1.9 ')
if mibBuilder.loadTexts: adslAtucPerfStatUasL.setStatus('current')
if mibBuilder.loadTexts: adslAtucPerfStatUasL.setDescription('The value of this object reports the count of the number of unavailable seconds-line since last agent reset.')
adslAtucPerfCurr15MinFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 5), PerfCurrentCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAtucPerfCurr15MinFastR.setReference('ITU G.997.1 Section 7.4.15.1 ')
if mibBuilder.loadTexts: adslAtucPerfCurr15MinFastR.setStatus('current')
if mibBuilder.loadTexts: adslAtucPerfCurr15MinFastR.setDescription('For the current 15-minute interval, adslAtucPerfCurr15MinFastR reports the current number of seconds during which there have been fast retrains.')
adslAtucPerfCurr15MinFailedFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 6), PerfCurrentCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAtucPerfCurr15MinFailedFastR.setReference('ITU G.997.1 Section 7.4.15.2 ')
if mibBuilder.loadTexts: adslAtucPerfCurr15MinFailedFastR.setStatus('current')
if mibBuilder.loadTexts: adslAtucPerfCurr15MinFailedFastR.setDescription('For the current 15-minute interval, adslAtucPerfCurr15MinFailedFastR reports the current number of seconds during which there have been failed fast retrains.')
adslAtucPerfCurr15MinSesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 7), PerfCurrentCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAtucPerfCurr15MinSesL.setReference('ITU G.997.1 Section 7.2.1.1.7 ')
if mibBuilder.loadTexts: adslAtucPerfCurr15MinSesL.setStatus('current')
if mibBuilder.loadTexts: adslAtucPerfCurr15MinSesL.setDescription('For the current 15-minute interval, adslAtucPerfCurr15MinSesL reports the current number of seconds during which there have been severely errored seconds-line.')
adslAtucPerfCurr15MinUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 8), PerfCurrentCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAtucPerfCurr15MinUasL.setReference('ITU G.997.1 Section 7.2.1.1.9 ')
if mibBuilder.loadTexts: adslAtucPerfCurr15MinUasL.setStatus('current')
if mibBuilder.loadTexts: adslAtucPerfCurr15MinUasL.setDescription('For the current 15-minute interval, adslAtucPerfCurr15MinUasL reports the current number of seconds during which there have been unavailable seconds-line.')
adslAtucPerfCurr1DayFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 9), AdslPerfCurrDayCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAtucPerfCurr1DayFastR.setReference('ITU G.997.1 Section 7.4.15.1 ')
if mibBuilder.loadTexts: adslAtucPerfCurr1DayFastR.setStatus('current')
if mibBuilder.loadTexts: adslAtucPerfCurr1DayFastR.setDescription('For the current day as measured by adslAtucPerfCurr1DayTimeElapsed [RFC2662], adslAtucPerfCurr1DayFastR reports the number of seconds during which there have been fast retrains.')
adslAtucPerfCurr1DayFailedFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 10), AdslPerfCurrDayCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAtucPerfCurr1DayFailedFastR.setReference('ITU G.997.1 Section 7.4.15.2 ')
if mibBuilder.loadTexts: adslAtucPerfCurr1DayFailedFastR.setStatus('current')
if mibBuilder.loadTexts: adslAtucPerfCurr1DayFailedFastR.setDescription('For the current day as measured by adslAtucPerfCurr1DayTimeElapsed [RFC2662], adslAtucPerfCurr1DayFailedFastR reports the number of seconds during which there have been failed fast retrains.')
adslAtucPerfCurr1DaySesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 11), AdslPerfCurrDayCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAtucPerfCurr1DaySesL.setReference('ITU G.997.1 Section 7.2.1.1.7 ')
if mibBuilder.loadTexts: adslAtucPerfCurr1DaySesL.setStatus('current')
if mibBuilder.loadTexts: adslAtucPerfCurr1DaySesL.setDescription('For the current day as measured by adslAtucPerfCurr1DayTimeElapsed [RFC2662], adslAtucPerfCurr1DaySesL reports the number of seconds during which there have been severely errored seconds-line.')
adslAtucPerfCurr1DayUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 12), AdslPerfCurrDayCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAtucPerfCurr1DayUasL.setReference('ITU G.997.1 Section 7.2.1.1.9 ')
if mibBuilder.loadTexts: adslAtucPerfCurr1DayUasL.setStatus('current')
if mibBuilder.loadTexts: adslAtucPerfCurr1DayUasL.setDescription('For the current day as measured by adslAtucPerfCurr1DayTimeElapsed [RFC2662], adslAtucPerfCurr1DayUasL reports the number of seconds during which there have been unavailable seconds-line.')
adslAtucPerfPrev1DayFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 13), AdslPerfPrevDayCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAtucPerfPrev1DayFastR.setReference('ITU G.997.1 Section 7.4.15.1 ')
if mibBuilder.loadTexts: adslAtucPerfPrev1DayFastR.setStatus('current')
if mibBuilder.loadTexts: adslAtucPerfPrev1DayFastR.setDescription('For the previous day, adslAtucPerfPrev1DayFastR reports the number of seconds during which there were fast retrains.')
adslAtucPerfPrev1DayFailedFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 14), AdslPerfPrevDayCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAtucPerfPrev1DayFailedFastR.setReference('ITU G.997.1 Section 7.4.15.2 ')
if mibBuilder.loadTexts: adslAtucPerfPrev1DayFailedFastR.setStatus('current')
if mibBuilder.loadTexts: adslAtucPerfPrev1DayFailedFastR.setDescription('For the previous day, adslAtucPerfPrev1DayFailedFastR reports the number of seconds during which there were failed fast retrains.')
adslAtucPerfPrev1DaySesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 15), AdslPerfPrevDayCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAtucPerfPrev1DaySesL.setReference('ITU G.997.1 Section 7.2.1.1.7 ')
if mibBuilder.loadTexts: adslAtucPerfPrev1DaySesL.setStatus('current')
if mibBuilder.loadTexts: adslAtucPerfPrev1DaySesL.setDescription('For the previous day, adslAtucPerfPrev1DaySesL reports the number of seconds during which there were severely errored seconds-line.')
adslAtucPerfPrev1DayUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 16), AdslPerfPrevDayCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAtucPerfPrev1DayUasL.setReference('ITU G.997.1 Section 7.2.1.1.9 ')
if mibBuilder.loadTexts: adslAtucPerfPrev1DayUasL.setStatus('current')
if mibBuilder.loadTexts: adslAtucPerfPrev1DayUasL.setDescription('For the previous day, adslAtucPerfPrev1DayUasL reports the number of seconds during which there were unavailable seconds-line.')
adslAtucIntervalExtTable = MibTable((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 19), )
if mibBuilder.loadTexts: adslAtucIntervalExtTable.setStatus('current')
if mibBuilder.loadTexts: adslAtucIntervalExtTable.setDescription("This table provides one row for each ATU-C performance data collection interval for ADSL physical interfaces whose IfEntries' ifType is equal to adsl(94).")
adslAtucIntervalExtEntry = MibTableRow((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 19, 1), )
adslAtucIntervalEntry.registerAugmentions(("ADSL-LINE-EXT-MIB", "adslAtucIntervalExtEntry"))
adslAtucIntervalExtEntry.setIndexNames(*adslAtucIntervalEntry.getIndexNames())
if mibBuilder.loadTexts: adslAtucIntervalExtEntry.setStatus('current')
if mibBuilder.loadTexts: adslAtucIntervalExtEntry.setDescription('An entry in the adslAtucIntervalExtTable.')
adslAtucIntervalFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 19, 1, 1), PerfIntervalCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAtucIntervalFastR.setStatus('current')
if mibBuilder.loadTexts: adslAtucIntervalFastR.setDescription('For the current interval, adslAtucIntervalFastR reports the current number of seconds during which there have been fast retrains.')
adslAtucIntervalFailedFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 19, 1, 2), PerfIntervalCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAtucIntervalFailedFastR.setStatus('current')
if mibBuilder.loadTexts: adslAtucIntervalFailedFastR.setDescription('For the each interval, adslAtucIntervalFailedFastR reports the number of seconds during which there have been failed fast retrains.')
adslAtucIntervalSesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 19, 1, 3), PerfIntervalCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAtucIntervalSesL.setStatus('current')
if mibBuilder.loadTexts: adslAtucIntervalSesL.setDescription('For the each interval, adslAtucIntervalSesL reports the number of seconds during which there have been severely errored seconds-line.')
adslAtucIntervalUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 19, 1, 4), PerfIntervalCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAtucIntervalUasL.setStatus('current')
if mibBuilder.loadTexts: adslAtucIntervalUasL.setDescription('For the each interval, adslAtucIntervalUasL reports the number of seconds during which there have been unavailable seconds-line.')
adslAturPerfDataExtTable = MibTable((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 20), )
if mibBuilder.loadTexts: adslAturPerfDataExtTable.setStatus('current')
if mibBuilder.loadTexts: adslAturPerfDataExtTable.setDescription('This table contains ADSL physical line counters not defined in the adslAturPerfDataTable from the ADSL-LINE-MIB [RFC2662].')
adslAturPerfDataExtEntry = MibTableRow((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 20, 1), )
adslAturPerfDataEntry.registerAugmentions(("ADSL-LINE-EXT-MIB", "adslAturPerfDataExtEntry"))
adslAturPerfDataExtEntry.setIndexNames(*adslAturPerfDataEntry.getIndexNames())
if mibBuilder.loadTexts: adslAturPerfDataExtEntry.setStatus('current')
if mibBuilder.loadTexts: adslAturPerfDataExtEntry.setDescription('An entry extends the adslAturPerfDataEntry defined in [RFC2662]. Each entry corresponds to an ADSL line.')
adslAturPerfStatSesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 20, 1, 1), Counter32()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAturPerfStatSesL.setReference('ITU G.997.1 Section 7.2.1.1.7 ')
if mibBuilder.loadTexts: adslAturPerfStatSesL.setStatus('current')
if mibBuilder.loadTexts: adslAturPerfStatSesL.setDescription('The value of this object reports the count of severely errored second-line since the last agent reset.')
adslAturPerfStatUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 20, 1, 2), Counter32()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAturPerfStatUasL.setReference('ITU G.997.1 Section 7.2.1.2.9 ')
if mibBuilder.loadTexts: adslAturPerfStatUasL.setStatus('current')
if mibBuilder.loadTexts: adslAturPerfStatUasL.setDescription('The value of this object reports the count of unavailable seconds-line since the last agent reset.')
adslAturPerfCurr15MinSesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 20, 1, 3), PerfCurrentCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAturPerfCurr15MinSesL.setReference('ITU G.997.1 Section 7.2.1.2.7 ')
if mibBuilder.loadTexts: adslAturPerfCurr15MinSesL.setStatus('current')
if mibBuilder.loadTexts: adslAturPerfCurr15MinSesL.setDescription('For the current 15-minute interval, adslAturPerfCurr15MinSesL reports the current number of seconds during which there have been severely errored seconds-line.')
adslAturPerfCurr15MinUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 20, 1, 4), PerfCurrentCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAturPerfCurr15MinUasL.setReference('ITU G.997.1 Section 7.2.1.2.9 ')
if mibBuilder.loadTexts: adslAturPerfCurr15MinUasL.setStatus('current')
if mibBuilder.loadTexts: adslAturPerfCurr15MinUasL.setDescription('For the current 15-minute interval, adslAturPerfCurr15MinUasL reports the current number of seconds during which there have been available seconds-line.')
adslAturPerfCurr1DaySesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 20, 1, 5), AdslPerfCurrDayCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAturPerfCurr1DaySesL.setReference('ITU G.997.1 Section 7.2.1.2.7 ')
if mibBuilder.loadTexts: adslAturPerfCurr1DaySesL.setStatus('current')
if mibBuilder.loadTexts: adslAturPerfCurr1DaySesL.setDescription('For the current day as measured by adslAturPerfCurr1DayTimeElapsed [RFC2662], adslAturPerfCurr1DaySesL reports the number of seconds during which there have been severely errored seconds-line.')
adslAturPerfCurr1DayUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 20, 1, 6), AdslPerfCurrDayCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAturPerfCurr1DayUasL.setReference('ITU G.997.1 Section 7.2.1.2.9 ')
if mibBuilder.loadTexts: adslAturPerfCurr1DayUasL.setStatus('current')
if mibBuilder.loadTexts: adslAturPerfCurr1DayUasL.setDescription('For the current day as measured by adslAturPerfCurr1DayTimeElapsed [RFC2662], adslAturPerfCurr1DayUasL reports the number of seconds during which there have been unavailable seconds-line.')
adslAturPerfPrev1DaySesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 20, 1, 7), AdslPerfPrevDayCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAturPerfPrev1DaySesL.setReference('ITU G.997.1 Section 7.2.1.2.7 ')
if mibBuilder.loadTexts: adslAturPerfPrev1DaySesL.setStatus('current')
if mibBuilder.loadTexts: adslAturPerfPrev1DaySesL.setDescription('For the previous day, adslAturPerfPrev1DaySesL reports the number of seconds during which there were severely errored seconds-line.')
adslAturPerfPrev1DayUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 20, 1, 8), AdslPerfPrevDayCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAturPerfPrev1DayUasL.setReference('ITU G.997.1 Section 7.2.1.2.9 ')
if mibBuilder.loadTexts: adslAturPerfPrev1DayUasL.setStatus('current')
if mibBuilder.loadTexts: adslAturPerfPrev1DayUasL.setDescription('For the previous day, adslAturPerfPrev1DayUasL reports the number of seconds during which there were severely errored seconds-line.')
adslAturIntervalExtTable = MibTable((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 21), )
if mibBuilder.loadTexts: adslAturIntervalExtTable.setStatus('current')
if mibBuilder.loadTexts: adslAturIntervalExtTable.setDescription("This table provides one row for each ATU-R performance data collection interval for ADSL physical interfaces whose IfEntries' ifType is equal to adsl(94).")
adslAturIntervalExtEntry = MibTableRow((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 21, 1), )
adslAturIntervalEntry.registerAugmentions(("ADSL-LINE-EXT-MIB", "adslAturIntervalExtEntry"))
adslAturIntervalExtEntry.setIndexNames(*adslAturIntervalEntry.getIndexNames())
if mibBuilder.loadTexts: adslAturIntervalExtEntry.setStatus('current')
if mibBuilder.loadTexts: adslAturIntervalExtEntry.setDescription('An entry in the adslAturIntervalExtTable.')
adslAturIntervalSesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 21, 1, 1), PerfIntervalCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAturIntervalSesL.setStatus('current')
if mibBuilder.loadTexts: adslAturIntervalSesL.setDescription('For the each interval, adslAturIntervalSesL reports the number of seconds during which there have been severely errored seconds-line.')
adslAturIntervalUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 21, 1, 2), PerfIntervalCount()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: adslAturIntervalUasL.setStatus('current')
if mibBuilder.loadTexts: adslAturIntervalUasL.setDescription('For the each interval, adslAturIntervalUasL reports the number of seconds during which there have been unavailable seconds-line.')
adslConfProfileExtTable = MibTable((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 22), )
if mibBuilder.loadTexts: adslConfProfileExtTable.setStatus('current')
if mibBuilder.loadTexts: adslConfProfileExtTable.setDescription('The adslConfProfileExtTable extends the ADSL line profile configuration information in the adslLineConfProfileTable from the ADSL-LINE-MIB [RFC2662] by adding the ability to configure the ADSL physical line mode.')
adslConfProfileExtEntry = MibTableRow((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 22, 1), )
adslLineConfProfileEntry.registerAugmentions(("ADSL-LINE-EXT-MIB", "adslConfProfileExtEntry"))
adslConfProfileExtEntry.setIndexNames(*adslLineConfProfileEntry.getIndexNames())
if mibBuilder.loadTexts: adslConfProfileExtEntry.setStatus('current')
if mibBuilder.loadTexts: adslConfProfileExtEntry.setDescription('An entry extends the adslLineConfProfileEntry defined in [RFC2662]. Each entry corresponds to an ADSL line profile.')
adslConfProfileLineType = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 22, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("noChannel", 1), ("fastOnly", 2), ("interleavedOnly", 3), ("fastOrInterleaved", 4), ("fastAndInterleaved", 5))).clone('fastOnly')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: adslConfProfileLineType.setStatus('current')
if mibBuilder.loadTexts: adslConfProfileLineType.setDescription('This object is used to configure the ADSL physical line mode. It has following valid values: noChannel(1), when no channels exist. fastOnly(2), when only fast channel exists. interleavedOnly(3), when only interleaved channel exist. fastOrInterleaved(4), when either fast or interleaved channels can exist, but only one at any time. fastAndInterleaved(5), when both the fast channel and the interleaved channel exist. In the case when no value has been set, the default Value is noChannel(1). ')
adslAlarmConfProfileExtTable = MibTable((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 23), )
if mibBuilder.loadTexts: adslAlarmConfProfileExtTable.setStatus('current')
if mibBuilder.loadTexts: adslAlarmConfProfileExtTable.setDescription('This table extends the adslLineAlarmConfProfileTable and provides threshold parameters for all the counters defined in this MIB module.')
adslAlarmConfProfileExtEntry = MibTableRow((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 23, 1), )
adslLineAlarmConfProfileEntry.registerAugmentions(("ADSL-LINE-EXT-MIB", "adslAlarmConfProfileExtEntry"))
adslAlarmConfProfileExtEntry.setIndexNames(*adslLineAlarmConfProfileEntry.getIndexNames())
if mibBuilder.loadTexts: adslAlarmConfProfileExtEntry.setStatus('current')
if mibBuilder.loadTexts: adslAlarmConfProfileExtEntry.setDescription('An entry extends the adslLineAlarmConfProfileTable defined in [RFC2662]. Each entry corresponds to an ADSL alarm profile.')
adslAtucThreshold15MinFailedFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 23, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 900))).setUnits('seconds').setMaxAccess("readcreate")
if mibBuilder.loadTexts: adslAtucThreshold15MinFailedFastR.setStatus('current')
if mibBuilder.loadTexts: adslAtucThreshold15MinFailedFastR.setDescription("The first time the value of the corresponding instance of adslAtucPerfCurr15MinFailedFastR reaches or exceeds this value within a given 15-minute performance data collection period, an adslAtucFailedFastRThreshTrap notification will be generated. The value '0' will disable the notification. The default value of this object is '0'.")
adslAtucThreshold15MinSesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 23, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 900))).setUnits('seconds').setMaxAccess("readcreate")
if mibBuilder.loadTexts: adslAtucThreshold15MinSesL.setStatus('current')
if mibBuilder.loadTexts: adslAtucThreshold15MinSesL.setDescription("The first time the value of the corresponding instance of adslAtucPerf15MinSesL reaches or exceeds this value within a given 15-minute performance data collection period, an adslAtucSesLThreshTrap notification will be generated. The value '0' will disable the notification. The default value of this object is '0'.")
adslAtucThreshold15MinUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 23, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 900))).setUnits('seconds').setMaxAccess("readcreate")
if mibBuilder.loadTexts: adslAtucThreshold15MinUasL.setStatus('current')
if mibBuilder.loadTexts: adslAtucThreshold15MinUasL.setDescription("The first time the value of the corresponding instance of adslAtucPerf15MinUasL reaches or exceeds this value within a given 15-minute performance data collection period, an adslAtucUasLThreshTrap notification will be generated. The value '0' will disable the notification. The default value of this object is '0'.")
adslAturThreshold15MinSesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 23, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 900))).setUnits('seconds').setMaxAccess("readcreate")
if mibBuilder.loadTexts: adslAturThreshold15MinSesL.setStatus('current')
if mibBuilder.loadTexts: adslAturThreshold15MinSesL.setDescription("The first time the value of the corresponding instance of adslAturPerf15MinSesL reaches or exceeds this value within a given 15-minute performance data collection period, an adslAturSesLThreshTrap notification will be generated. The value '0' will disable the notification. The default value of this object is '0'.")
adslAturThreshold15MinUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 23, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 900))).setUnits('seconds').setMaxAccess("readcreate")
if mibBuilder.loadTexts: adslAturThreshold15MinUasL.setStatus('current')
if mibBuilder.loadTexts: adslAturThreshold15MinUasL.setDescription("The first time the value of the corresponding instance of adslAturPerf15MinUasL reaches or exceeds this value within a given 15-minute performance data collection period, an adslAturUasLThreshTrap notification will be generated. The value '0' will disable the notification. The default value of this object is '0'.")
adslExtTraps = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 24))
adslExtAtucTraps = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 24, 1))
adslExtAtucTrapsPrefix = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 24, 1, 0))
adslAtucFailedFastRThreshTrap = NotificationType((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 24, 1, 0, 1)).setObjects(("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr15MinFailedFastR"))
if mibBuilder.loadTexts: adslAtucFailedFastRThreshTrap.setStatus('current')
if mibBuilder.loadTexts: adslAtucFailedFastRThreshTrap.setDescription('Failed Fast Retrains 15-minute threshold reached.')
adslAtucSesLThreshTrap = NotificationType((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 24, 1, 0, 2)).setObjects(("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr15MinSesL"))
if mibBuilder.loadTexts: adslAtucSesLThreshTrap.setStatus('current')
if mibBuilder.loadTexts: adslAtucSesLThreshTrap.setDescription('Severely errored seconds-line 15-minute threshold reached.')
adslAtucUasLThreshTrap = NotificationType((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 24, 1, 0, 3)).setObjects(("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr15MinUasL"))
if mibBuilder.loadTexts: adslAtucUasLThreshTrap.setStatus('current')
if mibBuilder.loadTexts: adslAtucUasLThreshTrap.setDescription('Unavailable seconds-line 15-minute threshold reached.')
adslExtAturTraps = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 24, 2))
adslExtAturTrapsPrefix = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 24, 2, 0))
adslAturSesLThreshTrap = NotificationType((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 24, 2, 0, 1)).setObjects(("ADSL-LINE-EXT-MIB", "adslAturPerfCurr15MinSesL"))
if mibBuilder.loadTexts: adslAturSesLThreshTrap.setStatus('current')
if mibBuilder.loadTexts: adslAturSesLThreshTrap.setDescription('Severely errored seconds-line 15-minute threshold reached.')
adslAturUasLThreshTrap = NotificationType((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 24, 2, 0, 2)).setObjects(("ADSL-LINE-EXT-MIB", "adslAturPerfCurr15MinUasL"))
if mibBuilder.loadTexts: adslAturUasLThreshTrap.setStatus('current')
if mibBuilder.loadTexts: adslAturUasLThreshTrap.setDescription('Unavailable seconds-line 15-minute threshold reached.')
adslExtConformance = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 94, 3, 2))
adslExtGroups = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 94, 3, 2, 1))
adslExtCompliances = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 94, 3, 2, 2))
adslExtLineMibAtucCompliance = ModuleCompliance((1, 3, 6, 1, 2, 1, 10, 94, 3, 2, 2, 1)).setObjects(("ADSL-LINE-EXT-MIB", "adslExtLineGroup"), ("ADSL-LINE-EXT-MIB", "adslExtLineConfProfileControlGroup"), ("ADSL-LINE-EXT-MIB", "adslExtLineAlarmConfProfileGroup"), ("ADSL-LINE-EXT-MIB", "adslExtAtucPhysPerfCounterGroup"), ("ADSL-LINE-EXT-MIB", "adslExtAturPhysPerfCounterGroup"), ("ADSL-LINE-EXT-MIB", "adslExtNotificationsGroup"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
adslExtLineMibAtucCompliance = adslExtLineMibAtucCompliance.setStatus('current')
if mibBuilder.loadTexts: adslExtLineMibAtucCompliance.setDescription('The compliance statement for SNMP entities which represent ADSL ATU-C interfaces.')
adslExtLineGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 10, 94, 3, 2, 1, 1)).setObjects(("ADSL-LINE-EXT-MIB", "adslLineConfProfileDualLite"), ("ADSL-LINE-EXT-MIB", "adslLineTransAtucCap"), ("ADSL-LINE-EXT-MIB", "adslLineTransAtucConfig"), ("ADSL-LINE-EXT-MIB", "adslLineTransAtucActual"), ("ADSL-LINE-EXT-MIB", "adslLineGlitePowerState"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
adslExtLineGroup = adslExtLineGroup.setStatus('current')
if mibBuilder.loadTexts: adslExtLineGroup.setDescription('A collection of objects providing extended configuration information about an ADSL Line.')
adslExtAtucPhysPerfCounterGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 10, 94, 3, 2, 1, 2)).setObjects(("ADSL-LINE-EXT-MIB", "adslAtucPerfStatFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfStatFailedFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr15MinFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr15MinFailedFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr1DayFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr1DayFailedFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfPrev1DayFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfPrev1DayFailedFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfStatSesL"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfStatUasL"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr15MinSesL"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr15MinUasL"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr1DaySesL"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr1DayUasL"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfPrev1DaySesL"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfPrev1DayUasL"), ("ADSL-LINE-EXT-MIB", "adslAtucIntervalFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucIntervalFailedFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucIntervalSesL"), ("ADSL-LINE-EXT-MIB", "adslAtucIntervalUasL"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
adslExtAtucPhysPerfCounterGroup = adslExtAtucPhysPerfCounterGroup.setStatus('current')
if mibBuilder.loadTexts: adslExtAtucPhysPerfCounterGroup.setDescription('A collection of objects providing raw performance counts on an ADSL Line (ATU-C end).')
adslExtAturPhysPerfCounterGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 10, 94, 3, 2, 1, 3)).setObjects(("ADSL-LINE-EXT-MIB", "adslAturPerfStatSesL"), ("ADSL-LINE-EXT-MIB", "adslAturPerfStatUasL"), ("ADSL-LINE-EXT-MIB", "adslAturPerfCurr15MinSesL"), ("ADSL-LINE-EXT-MIB", "adslAturPerfCurr15MinUasL"), ("ADSL-LINE-EXT-MIB", "adslAturPerfCurr1DaySesL"), ("ADSL-LINE-EXT-MIB", "adslAturPerfCurr1DayUasL"), ("ADSL-LINE-EXT-MIB", "adslAturPerfPrev1DaySesL"), ("ADSL-LINE-EXT-MIB", "adslAturPerfPrev1DayUasL"), ("ADSL-LINE-EXT-MIB", "adslAturIntervalSesL"), ("ADSL-LINE-EXT-MIB", "adslAturIntervalUasL"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
adslExtAturPhysPerfCounterGroup = adslExtAturPhysPerfCounterGroup.setStatus('current')
if mibBuilder.loadTexts: adslExtAturPhysPerfCounterGroup.setDescription('A collection of objects providing raw performance counts on an ADSL Line (ATU-C end).')
adslExtLineConfProfileControlGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 10, 94, 3, 2, 1, 4)).setObjects(("ADSL-LINE-EXT-MIB", "adslConfProfileLineType"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
adslExtLineConfProfileControlGroup = adslExtLineConfProfileControlGroup.setStatus('current')
if mibBuilder.loadTexts: adslExtLineConfProfileControlGroup.setDescription('A collection of objects providing profile control for the ADSL system.')
adslExtLineAlarmConfProfileGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 10, 94, 3, 2, 1, 5)).setObjects(("ADSL-LINE-EXT-MIB", "adslAtucThreshold15MinFailedFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucThreshold15MinSesL"), ("ADSL-LINE-EXT-MIB", "adslAtucThreshold15MinUasL"), ("ADSL-LINE-EXT-MIB", "adslAturThreshold15MinSesL"), ("ADSL-LINE-EXT-MIB", "adslAturThreshold15MinUasL"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
adslExtLineAlarmConfProfileGroup = adslExtLineAlarmConfProfileGroup.setStatus('current')
if mibBuilder.loadTexts: adslExtLineAlarmConfProfileGroup.setDescription('A collection of objects providing alarm profile control for the ADSL system.')
adslExtNotificationsGroup = NotificationGroup((1, 3, 6, 1, 2, 1, 10, 94, 3, 2, 1, 6)).setObjects(("ADSL-LINE-EXT-MIB", "adslAtucFailedFastRThreshTrap"), ("ADSL-LINE-EXT-MIB", "adslAtucSesLThreshTrap"), ("ADSL-LINE-EXT-MIB", "adslAtucUasLThreshTrap"), ("ADSL-LINE-EXT-MIB", "adslAturSesLThreshTrap"), ("ADSL-LINE-EXT-MIB", "adslAturUasLThreshTrap"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
adslExtNotificationsGroup = adslExtNotificationsGroup.setStatus('current')
if mibBuilder.loadTexts: adslExtNotificationsGroup.setDescription('The collection of ADSL extension notifications.')
mibBuilder.exportSymbols("ADSL-LINE-EXT-MIB", adslAturPerfDataExtTable=adslAturPerfDataExtTable, adslExtAturTraps=adslExtAturTraps, AdslTransmissionModeType=AdslTransmissionModeType, adslAturIntervalExtTable=adslAturIntervalExtTable, adslAtucIntervalSesL=adslAtucIntervalSesL, adslAturPerfStatUasL=adslAturPerfStatUasL, adslAturThreshold15MinSesL=adslAturThreshold15MinSesL, adslAtucPerfPrev1DayFastR=adslAtucPerfPrev1DayFastR, adslAtucFailedFastRThreshTrap=adslAtucFailedFastRThreshTrap, adslExtLineConfProfileControlGroup=adslExtLineConfProfileControlGroup, adslAtucPerfPrev1DayUasL=adslAtucPerfPrev1DayUasL, adslAturPerfCurr15MinSesL=adslAturPerfCurr15MinSesL, adslExtAtucTrapsPrefix=adslExtAtucTrapsPrefix, adslAtucPerfStatFastR=adslAtucPerfStatFastR, adslAturUasLThreshTrap=adslAturUasLThreshTrap, adslAtucPerfPrev1DaySesL=adslAtucPerfPrev1DaySesL, adslAtucPerfDataExtTable=adslAtucPerfDataExtTable, adslAturSesLThreshTrap=adslAturSesLThreshTrap, adslExtMibObjects=adslExtMibObjects, adslAtucPerfStatFailedFastR=adslAtucPerfStatFailedFastR, adslAturPerfPrev1DaySesL=adslAturPerfPrev1DaySesL, adslExtAturPhysPerfCounterGroup=adslExtAturPhysPerfCounterGroup, PYSNMP_MODULE_ID=adslExtMIB, adslLineConfProfileDualLite=adslLineConfProfileDualLite, adslConfProfileExtEntry=adslConfProfileExtEntry, adslConfProfileLineType=adslConfProfileLineType, adslExtTraps=adslExtTraps, adslLineTransAtucConfig=adslLineTransAtucConfig, adslAtucIntervalFastR=adslAtucIntervalFastR, adslExtNotificationsGroup=adslExtNotificationsGroup, adslExtLineGroup=adslExtLineGroup, adslLineExtTable=adslLineExtTable, adslAtucPerfCurr1DayFailedFastR=adslAtucPerfCurr1DayFailedFastR, adslAtucPerfCurr15MinSesL=adslAtucPerfCurr15MinSesL, adslAturThreshold15MinUasL=adslAturThreshold15MinUasL, adslAtucIntervalExtTable=adslAtucIntervalExtTable, adslLineExtEntry=adslLineExtEntry, adslAtucPerfCurr1DaySesL=adslAtucPerfCurr1DaySesL, adslExtMIB=adslExtMIB, adslLineTransAtucActual=adslLineTransAtucActual, adslExtConformance=adslExtConformance, adslLineTransAtucCap=adslLineTransAtucCap, adslAturPerfPrev1DayUasL=adslAturPerfPrev1DayUasL, adslExtAtucTraps=adslExtAtucTraps, adslAturPerfDataExtEntry=adslAturPerfDataExtEntry, adslAlarmConfProfileExtEntry=adslAlarmConfProfileExtEntry, adslAturPerfCurr15MinUasL=adslAturPerfCurr15MinUasL, adslAtucPerfStatSesL=adslAtucPerfStatSesL, adslLineGlitePowerState=adslLineGlitePowerState, adslAtucIntervalUasL=adslAtucIntervalUasL, adslAtucThreshold15MinUasL=adslAtucThreshold15MinUasL, adslAtucIntervalExtEntry=adslAtucIntervalExtEntry, adslExtAtucPhysPerfCounterGroup=adslExtAtucPhysPerfCounterGroup, adslAtucPerfCurr15MinUasL=adslAtucPerfCurr15MinUasL, adslAlarmConfProfileExtTable=adslAlarmConfProfileExtTable, adslAtucThreshold15MinSesL=adslAtucThreshold15MinSesL, adslAturPerfCurr1DayUasL=adslAturPerfCurr1DayUasL, adslExtLineMibAtucCompliance=adslExtLineMibAtucCompliance, adslExtGroups=adslExtGroups, adslAtucIntervalFailedFastR=adslAtucIntervalFailedFastR, adslAturIntervalExtEntry=adslAturIntervalExtEntry, adslAtucThreshold15MinFailedFastR=adslAtucThreshold15MinFailedFastR, adslAtucPerfCurr1DayUasL=adslAtucPerfCurr1DayUasL, adslAtucPerfCurr15MinFastR=adslAtucPerfCurr15MinFastR, adslAtucUasLThreshTrap=adslAtucUasLThreshTrap, adslAturPerfStatSesL=adslAturPerfStatSesL, adslExtAturTrapsPrefix=adslExtAturTrapsPrefix, adslAtucPerfPrev1DayFailedFastR=adslAtucPerfPrev1DayFailedFastR, adslAturIntervalUasL=adslAturIntervalUasL, adslConfProfileExtTable=adslConfProfileExtTable, adslAturIntervalSesL=adslAturIntervalSesL, adslAtucPerfDataExtEntry=adslAtucPerfDataExtEntry, adslAtucPerfStatUasL=adslAtucPerfStatUasL, adslAturPerfCurr1DaySesL=adslAturPerfCurr1DaySesL, adslAtucPerfCurr1DayFastR=adslAtucPerfCurr1DayFastR, adslAtucSesLThreshTrap=adslAtucSesLThreshTrap, adslExtLineAlarmConfProfileGroup=adslExtLineAlarmConfProfileGroup, adslExtCompliances=adslExtCompliances, adslAtucPerfCurr15MinFailedFastR=adslAtucPerfCurr15MinFailedFastR)
|
errors_find = {
'ServerError': {
'response': "Some thing went wrong. Please try after some time.",
'status': 500,
},
'BadRequest': {
'response': "Request must be valid",
'status': 400
},
}
#Code to store error types based on status code. |
# fml_parsetab.py
# This file is automatically generated. Do not edit.
_tabversion = '3.10'
_lr_method = 'LALR'
_lr_signature = 'bofx eofx newline tab interpolant lce rce string\n\tstart \t: \tbofx\n\t\t\t|\tstart eofx\n\t\t\t|\tstart code\n\t\n\tcode \t: \tnewline \n\t\n\tcode \t: \ttab\n\t\n\tcode \t: \tstring\n\t\n\tcode \t: \tlce\n\t\n\tcode \t: \trce\n\t\n\tcode \t: \tinterpolant\n\t'
_lr_action_items = {'bofx':([0,],[1,]),'$end':([1,2,3,4,5,6,7,8,9,10,],[-1,0,-9,-6,-2,-7,-3,-8,-5,-4,]),'interpolant':([1,2,3,4,5,6,7,8,9,10,],[-1,3,-9,-6,-2,-7,-3,-8,-5,-4,]),'tab':([1,2,3,4,5,6,7,8,9,10,],[-1,9,-9,-6,-2,-7,-3,-8,-5,-4,]),'lce':([1,2,3,4,5,6,7,8,9,10,],[-1,6,-9,-6,-2,-7,-3,-8,-5,-4,]),'string':([1,2,3,4,5,6,7,8,9,10,],[-1,4,-9,-6,-2,-7,-3,-8,-5,-4,]),'rce':([1,2,3,4,5,6,7,8,9,10,],[-1,8,-9,-6,-2,-7,-3,-8,-5,-4,]),'eofx':([1,2,3,4,5,6,7,8,9,10,],[-1,5,-9,-6,-2,-7,-3,-8,-5,-4,]),'newline':([1,2,3,4,5,6,7,8,9,10,],[-1,10,-9,-6,-2,-7,-3,-8,-5,-4,]),}
_lr_action = {}
for _k, _v in _lr_action_items.items():
for _x,_y in zip(_v[0],_v[1]):
if not _x in _lr_action: _lr_action[_x] = {}
_lr_action[_x][_k] = _y
del _lr_action_items
_lr_goto_items = {'start':([0,],[2,]),'code':([2,],[7,]),}
_lr_goto = {}
for _k, _v in _lr_goto_items.items():
for _x, _y in zip(_v[0], _v[1]):
if not _x in _lr_goto: _lr_goto[_x] = {}
_lr_goto[_x][_k] = _y
del _lr_goto_items
_lr_productions = [
("S' -> start","S'",1,None,None,None),
('start -> bofx','start',1,'p_bofx','fml_yacc.py',7),
('start -> start eofx','start',2,'p_bofx','fml_yacc.py',8),
('start -> start code','start',2,'p_bofx','fml_yacc.py',9),
('code -> newline','code',1,'p_newline','fml_yacc.py',15),
('code -> tab','code',1,'p_tab','fml_yacc.py',22),
('code -> string','code',1,'p_string','fml_yacc.py',29),
('code -> lce','code',1,'p_lce','fml_yacc.py',36),
('code -> rce','code',1,'p_rce','fml_yacc.py',43),
('code -> interpolant','code',1,'p_interpolant','fml_yacc.py',50),
]
|
RAW_SUBTOMOGRAMS = "volumes/raw"
LABELED_SUBTOMOGRAMS = "volumes/labels/"
PREDICTED_SEGMENTATION_SUBTOMOGRAMS = "volumes/predictions/"
CLUSTERING_LABELS = "volumes/cluster_labels/"
HDF_INTERNAL_PATH = "MDF/images/0/image"
|
fp=open("list-11\\readme.txt","r")
sentence=fp.read()
words=sentence.split()
d = dict()
for c in words:
if c not in d:
d[c] = 1
else:
d[c] += 1
#dictionary values
a=d.values()
b=max(a)
for i in d:
if(d[i]==b):
print("frequent word:",i,";","count:",b) |
class fracao(object):
def __init__(self, num, den):
self.num = num
self.den = den
def somar_fracao(self, b):
f = fracao(self.num*b.den + b.num*self.den, self.den*b.den)
#f.num =
#f.den =
fracao.simplificar_fracao(f)
return f
def subtrair_fracao(self, b):
pass
def multiplicar_fracao(self, b):
pass
def dividir_fracao(self, b):
pass
def simplifica_fracao(self):
m = fracao.mdc(self.num, self.den)
self.num=self.num/m
self.den=self.den/m
print('Resultado: ', self.num, ' / ' , self.den)
#input()
return
@staticmethod
def simplificar_fracao(self):
m = fracao.mdc(self.num, self.den)
self.num=self.num/m
self.den=self.den/m
print('Resultado: ', self.num, ' / ' , self.den)
input()
return
def exibir_fracao(self):
print(self.num, ' / ' , self.den)
return
@staticmethod
def mdc(a,b):
if a<b:
return fracao.mdc(b,a)
else:
if b==0:
return a
else:
return fracao.mdc(b, a % b)
a = fracao(2,3)
b = fracao(3,4)
c = fracao(12,24)
c.simplifica_fracao()
a.exibir_fracao()
b.exibir_fracao()
c.exibir_fracao()
c = a.somar_fracao(b)
c.exibir_fracao()
d = a.somar_fracao(fracao(1,3))
|
# Day2 of my 100DaysOfCode Challenge
# I was reading this article by Tim Urban -
# Your Life in Weeks and realised just how little
# time we actually have.
# https://waitbutwhy.com/2014/05/life-weeks.html
# Create a program using maths and f-Strings that tells us
# how many days, weeks, months we have left if we live until
# 90 years old.
# It will take your current age as the input and output a
# message with our time left in this format:
# You have x days, y weeks, and z months left.
# Where x, y and z are replaced with the actual calculated numbers.
# Warning your output should match the Example Output format exactly,
# even the positions of the commas and full stops.
# 🚨 Don't change the code below 👇
age = input("What is your current age?")
# 🚨 Don't change the code above 👆
#Write your code below this line 👇
age_as_int = int(age)
years_remaining = 90 - age_as_int
days_remaining = years_remaining * 365
weeks_remaining = years_remaining * 52
months_remaining = years_remaining * 12
print(f"You have {days_remaining} days, {weeks_remaining} weeks, and {months_remaining} months left.")
|
#!/usr/bin/python3
def inherits_from(obj, a_class):
if isinstance(obj, a_class) and type(obj) is not a_class:
return True
else:
return False
|
#
# A Rangoli Generator
#
# Author: Jeremy Pedersen
# Date: 2019-02-18
# License: "the unlicense" (Google it)
#
# Define letters for use in rangoli
alphabet = 'a b c d e f g h i j k l m n o p q r s t u v w x y z'.split()
# Read in rangoli size
size = int(input("Set size of rangoli: "))
# Calculate maximum linewidth (how much fill do we need per line)
maxWidth = size*2 - 1 + (size - 1)*2
# Generate rangoli
for i in list(range(size-1,0,-1)) + list(range(0,size)):
left = alphabet[1+i:size]
left.reverse()
right = alphabet[0+i:size]
center = '-'.join(left + right)
padding = '-'*((maxWidth - len(center))//2)
print(padding+center+padding)
|
calls = 0
def call():
global calls
calls += 1
def reset():
global calls
calls = 0
|
#crie um programa que tenha a funcao chamada escreva(), que receba um texto qualquer como parametro e mostre
# uma mensagem com tamanho adaptavel.
#Ex. escreva('Ola Mundo!')
# Saida ˜˜˜˜˜˜˜˜˜˜
# Olá Mundo!
# ˜˜˜˜˜˜˜˜˜
#minha resposta
def escreva(msg):
print('~' * (len(msg) + 4)) # pra ficar com 2 ~ na esquerda e 2 ~ na direita sobrando
print(f' {msg}')
print('~' * (len(msg) + 4))
#programa principal
escreva('Mario Lima')
escreva('Lactobacilos vivos')
escreva('Oi')
#resposta do Gustavo
def escreva(msg):
tam = len(msg) + 4
print('~' * tam) # pra ficar com 2 ~ na esquerda e 2 ~ na direita sobrando
print(f' {msg}')
print('~' * tam)
#programa principal
escreva('Gustavo Guanabara')
escreva('Curso em Python no YouTube')
escreva('CeV')
|
# print()函数也可以接受多个字符串,用逗号“,”隔开,就可以连成一串输出:
print('You jump', 'I jump')
# print()会依次打印每个字符串,遇到逗号输出一个空格
print(100 + 200)
print('100 + 200 =', 100 + 200)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.