content
stringlengths 7
1.05M
|
|---|
# -*- coding: utf-8 -*-
# 文章的状态
STATUS_CHOICES = (
('d', '延迟发布'), # delay
('p', '发布'), # publish
)
|
filename = "myFile1.py"
with open(filename, "r") as f:
for line in f:
print(f)
|
"""
domonic.constants
====================================
"""
namespaces = {'xml': 'http://www.w3.org/XML/1998/namespace', 'svg': 'http://www.w3.org/2000/svg', 'xlink': 'http://www.w3.org/1999/xlink',
'xmlns': 'http://www.w3.org/2000/xmlns/', 'xm': 'http://www.w3.org/2001/xml-events', 'xh': 'http://www.w3.org/1999/xhtml'}
# gravitational_constant = 6.67384e-11
# planck_constant = 6.62606957e-34
# speed_of_light = 299792458
# electron_charge = 1.602176565e-19
# electron_mass = 9.10938291e-31
# proton_mass = 1.672621777e-27
# neutron_mass = 1.674927351e-27
# atomic_mass_unit = 1.660539040e-24
# avogadro_constant = 6.02214129e23
# boltzmann_constant = 1.3806488e-23
# gas_constant = 8.3144621
# i love #copilot
|
m = 35.0 / 8.0
n = int(35/8)
print(m)
print(n)
|
class Dealer:
def __init__(self):
self.__hand = None
def select_action(self):
if self.hand_total() < 17:
return 1
else:
return 0
def give_card(self, card):
self.__hand.add_card(card)
def revealed_card(self):
cards = self.__hand.cards()
return cards[0]
def is_busted(self):
return self.__hand.is_busted()
def new_hand(self, hand):
self.__hand = hand
def hand(self):
return self.__hand
def hand_total(self):
return self.__hand.total()
|
# https://cses.fi/problemset/task/1083
d = [False for _ in range(int(input()))]
for i in input().split(' '):
d[int(i) - 1] = True
for i, b in enumerate(d):
if not b:
print(i + 1)
exit()
|
#crie um programa que leia um valor em
#metros e exiba convertido em centímetros
#e em milímetros
m=float(input('Digite uma distância em metros: '))
cm=m*100
mm=m*1000
print ('A distância de {} metros, corresponde a {:.0f} cm e {:.0f} mm '.format (m,cm,mm))
|
{
"targets": [
{
"target_name": "lib/daemon",
"sources": [ "src/daemon.cc" ]
}
]
}
|
class CommandTools:
@staticmethod
def get_token():
""" Simple helper that will return the token stored in the text file.
:return: Your Robinhood API token
"""
robinhood_token_file = open('robinhood_token.txt')
current_token = robinhood_token_file.read()
return current_token
|
def main():
st = input("")
print(st[0])
print(end="")
main()
|
# 题目描述:
# M 队和 T 队将要进行射箭比赛,M 队的队长是小美,T 队的队长是小团。
# 这场射箭比赛的规则是,每个队员都可以选择一个距离进行射击,
# 若射中靶心且距离小于等于 d 则团队得 1 分,若射中靶心且距离大于 d 则团队得 2 分。
# 小团对敌我情况了如指掌,他知道接下来 M 队将会有 n 名队员射中靶心,
# 且知道这些队员选择的射箭距离,
# 以及自己所带领的 T 队会有 m 名队员射中靶心和他们选择的射箭距离。
# 假定 d 的值可以由小团确定(d 的范围恒为 [1,1000]),
# 小团想知道自己的队伍最多能赢小美的队伍多少分(T 队得分减去 M 队得分的最大值)。
# 输入描述
# 第一行两个正整数 n,m,分别表示 M 队射中靶心的队员个数和 T 队射中靶心的队员个数。
# 接下来一行n个整数a1,a2,...,an表示M队中n个队员的射箭距离。
# 在接下来一行m个整数b1,b2,...,bm表示T队中m个队员的射箭距离。
# 输出描述
# 一行一个整数,表示 T 队最多能赢 M 队的分数。
# 样例输入
"""
2 3
585 375
936 317 185
"""
# 样例输出
# 2
# 提示
# 1≤n,m≤100000,1≤ai,bi≤1000
# 复杂度没过
n, m = map(int, input().split())
an = list(map(int, input().split()))
bn = list(map(int, input().split()))
def get_a(d: int):
return sum(1 if ai <= d else 2 for ai in an)
def get_b(d: int):
return sum(1 if bi <= d else 2 for bi in bn)
print(max(get_b(d) - get_a(d) for d in range(1, 1001)))
|
# This program demonstrates how to use the remove
# method to remove an item from a list.
def main():
# Create a list with some items.
food = ['Pizza', 'Burgers', 'Chips']
# Display the list.
print('Here are the items in the food list:')
print(food)
# Get the item to change.
item = input('Which item should I remove? ')
try:
# Remove the item.
food.remove(item)
# Display the list.
print('Here is the revised list:')
print(food)
except ValueError:
print('That item was not found in the list.')
# Call the main function.
main()
|
#coding:utf-8
# log into your home router and create a port forward to point to this server
# use the external port number 911 and direct it to port 80 on this machine
#leave these alone unles you absolutely have to touch them
PIR_PIN_1 = 23 # Right hand PIR - outside
PIR_PIN_2 = 24 # Left hand PIR - inside - sends emergency message
PIR_PIN_3 = 25 # not used
PIR_PIN_4 = 8 # not used
# ----------------
# locations of PIR devices
# change the string values to match desired location
# put "Not Used " in any variable where no sensor is present
PIR_PIN_1_LOCATION = "Outside Garage"
PIR_PIN_2_LOCATION = "Inside Garage"
PIR_PIN_3_LOCATION = "Not Used"
PIR_PIN_4_LOCATION = "Not Used"
# set the priority of action for each PIR
#
# set to 2 for emergency and log
# Message priority: Sound, vibration, and banner regardless of user’s quiet hours,
# and re-alerts until acknowledged
# set to 1 for high message and log
# Message priority: Sound, vibration, and banner regardless of user’s quiet hours.
# set to 0 for normal message and log
# Message priority: Sound, vibration, and banner if outside of user’s quiet hours
# set to 9 if PIR not used
#
PIR_PIN_1_PRIORITY = 0
PIR_PIN_2_PRIORITY = 2
PIR_PIN_3_PRIORITY = 9
PIR_PIN_4_PRIORITY = 9
# the following two keys are for pushover
# you get them when you sign up and create an app
AppKey = "blahblahblah"
UserKey = "BrianNowThatsaGoodName"
# put the filename or fullpath and filename
# for the logfile into the next variable
MyLogFile = "watchman_logfile.text"
|
class TeamNotFound(Exception):
"""Raise when the team is not found in the database"""
class NoMatchData(Exception):
"""Raise when data for match cant be created"""
|
def computepay(h, r):
print("In computepay")
if h>40:
pay = 40 * r + (h - 40) * 1.5 * r
else:
pay = h * r
return pay
hrs = input("Enter Hours:")
h = float(hrs)
rate = input("Enter Rate:")
r = float(rate)
pay = computepay(h,r)
print(pay)
|
"""Scheduling errors."""
class AssignmentError(Exception):
"""Raised for errors when generating assignments."""
def __init__(self, message: str):
self.message = message
|
'''
MIT License
Name cs225sp20_env Python Package
URL https://github.com/Xiwei-Wang/cs225sp20_env
Version 1.0
Creation Date 26 April 2020
Copyright(c) 2020 Instructors, TAs and Some Students of UIUC CS 225 SP20 ZJUI Course
Instructorts: Prof. Dr. Klaus-Dieter Schewe
TAs: Tingou Liang, Run Zhang, Enyi Jiang, Xiang Li
Group 1 Students: Shen Zheng, Haozhe Chen, Ruiqi Li, Xiwei Wang
Other Students: Zhongbo Zhu
Above all, due to academic integrity, students who will take UIUC CS 225 ZJUI Course
taught with Python later than Spring 2020 semester are NOT authorized with the access
to this package.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---------
File cs225sp20_env/Tree/Trie.py
Version 1.0
'''
# %%
class Trie:
class TrieNode:
def __init__(self,item,next=None,follows=None):
self.item = item
self.next = next
self.follows = follows
def __init__(self):
self.start = None
def insert(self,item):
if type(item) == str: item = list(item)
self.start = Trie.__insert(self.start,item)
def __contains__(self,item):
if type(item) == str: item = list(item)
return Trie.__contains(self.start,item+["#"])
def __insert(node,item):
if item == []: # end condition
if node != None:
newnode = Trie.TrieNode('#',next=node)
else:
newnode = Trie.TrieNode("#")
return newnode
if node == None: # if trie is empty
key = item.pop(0) # one letter per node
newnode = Trie.TrieNode(key)
newnode.follows = Trie.__insert(newnode.follows,item)
return newnode
else:
key = item[0]
if node.item == key: # letter already in the trie
key = item.pop(0)
node.follows = Trie.__insert(node.follows,item)
else:
node.next = Trie.__insert(node.next,item)
return node
def __contains(node,item):
if type(item) == str: item = list(item)
if item == []:
return True
if node == None:
return False
key = item[0]
if node.item == key:
key = item.pop(0)
return Trie.__contains(node.follows,item)
return Trie.__contains(node.next,item)
# a print function which can print out structure of tries
# to help better understand
def print_trie(self,show_start = False):
if show_start:
print('start\n |\n ',end='')
self.__print_trie(self.start,1)
else:
self.__print_trie(self.start,0)
def __print_trie(self, root, level_f):
if(root == None):
return
if(root.item != '#'):
print(root.item, '-', end='')
else:
# print(root.item, end='') # modified
print(root.item, end='\n')
self.__print_trie(root.follows, level_f+1)
if(root.next!=None):
# print('\n') # commented
str_sp = ' '*level_f*3
print(str_sp+'|')
print(str_sp, end='')
self.__print_trie(root.next,level_f)
return
# %%
if __name__ == '__main__':
trie = Trie()
for word in [ 'cow','cowboy',
'cat','rat','rabbit','dog',
'pear','peer','pier']:
trie.insert(word)
assert 'cow' in trie
assert 'cowboy' in trie
assert 'pear' in trie
assert 'peer' in trie
assert 'pier' in trie
trie.print_trie()
|
def merge(list0,list1):
result = []
while len(list1) and len(list0):
if list0[0]<list1[0]:
result.append(list0.pop(0))
else:
result.append(list1.pop(0))
result.extend(list0)
result.extend(list1)
return result
def mergesort(item):
if len(item)<=1:
return item
mid = int(len(item)/2)
left = item[0:mid]
right = item[mid:len(item)]
left = mergesort(left)
right = mergesort(right)
result = merge(left,right)
return result
if __name__ == '__main__':
print('Enter a list of numbrt saperated by space.')
arr = list(map(int,input().split()))
print(mergesort(arr))
|
# Link - https://leetcode.com/problems/unique-morse-code-words/
'''
Runtime: 28 ms, faster than 95.58% of Python3 online submissions for Unique Morse Code Words.
Memory Usage: 13.6 MB, less than 99.77% of Python3 online submissions for Unique Morse Code Words.
'''
class Solution:
def uniqueMorseRepresentations(self, words: List[str]) -> int:
morse = [".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."]
answers = []
for i in words:
z = ''
for j in i:
z += morse[ord(j) - 97]
answers.append(z)
return len(set(answers))
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# services - Waqas Bhatti (wbhatti@astro.princeton.edu) - Oct 2017
# License: MIT. See the LICENSE file for more details.
'''This contains various modules to query online data services. These are not
exhaustive and are meant to support other astrobase modules.
- :py:mod:`astrobase.services.dust`: interface to the 2MASS DUST
extinction/emission service.
- :py:mod:`astrobase.services.gaia`: interface to the GAIA TAP+ ADQL query
service.
- :py:mod:`astrobase.services.lccs`: interface to the `LCC-Server
<https://github.com/waqasbhatti/lcc-server>`_ API.
- :py:mod:`astrobase.services.mast`: interface to the MAST catalogs at STScI and
the TESS Input Catalog in particular.
- :py:mod:`astrobase.services.simbad`: interface to the CDS SIMBAD service.
- :py:mod:`astrobase.services.skyview`: interface to the NASA SkyView
finder-chart and cutout service.
- :py:mod:`astrobase.services.trilegal`: interface to the Girardi TRILEGAL
galaxy model forms and service.
- :py:mod:`astrobase.services.limbdarkening`: utilities to get stellar limb
darkening coefficients for use during transit fitting.
- :py:mod:`astrobase.services.identifiers`: utilities to convert from SIMBAD
object names to GAIA DR2 source identifiers and TESS Input Catalogs IDs.
- :py:mod:`astrobase.services.tesslightcurves`: utilities to download various
TESS light curve products from MAST.
- :py:mod:`astrobase.services.alltesslightcurves`: utilities to download all
TESS light curve products from MAST for a given TIC ID.
For a much broader interface to online data services, use the astroquery package
by A. Ginsburg, B. Sipocz, et al.:
http://astroquery.readthedocs.io
'''
|
vacation_cost = float(input())
available_money = float(input())
spending_counter = 0
days_passed = 0
saved = True
while available_money < vacation_cost:
#spend or save
action_type = input()
current_sum = float(input())
days_passed += 1
if action_type == 'spend':
spending_counter += 1
available_money -= current_sum
if available_money < 0:
available_money = 0
elif action_type == 'save':
available_money += current_sum
if spending_counter == 5:
print("You can't save the money.")
print(days_passed)
saved = False
break
if saved:
print(f'You saved the money for {days_passed} days.')
|
NOT_FOUND = -1
class Search(object):
def __init__(self, sample):
self.sample = sample
|
def convHatoAlq(n):
alq = n / 2.42
return alq
def convHatoM2(n):
m2 = n * 10000
return m2
def convAlqtoHa(n):
ha = n * 2.42
return ha
def convAlqtoM2(n):
m2 = n * 24200
return m2
def convM2toHa(n):
ha = n / 10000
return ha
def convM2toAlq(n):
alq = n / 24200
return alq
def M2Format(n):
res = f'{n:_.2f} m²'.replace(".",",")
return res.replace("_",".")
def HaFormat(n):
return f'{n:.4f} Ha'.replace(".",",")
def AlqFormat(n):
return f'{n:.2f} Alq. Pta.'.replace(".",",")
|
__all__ = 'MissingContextVariable',
class MissingContextVariable(KeyError):
pass
|
# [카카오] 기둥과 보 설치
def check(board, y, x, a):
if a == 0:
if x == 0:
return True
if y - 1 >= 0 and board[y - 1][x][1] or board[y][x][1]:
return True
if x - 1 >= 0 and board[y][x - 1][0]:
return True
else:
if x - 1 >= 0 and board[y][x - 1][0]:
return True
if x - 1 >= 0 and y + 1 < len(board) and board[y + 1][x - 1][0]:
return True
if (
y - 1 >= 0
and board[y - 1][x][1]
and y + 1 < len(board)
and board[y + 1][x][1]
):
return True
return False
def solution(n, build_frame):
answer = []
board = [[[0, 0] for _ in range(n + 1)] for _ in range(n + 1)]
for y, x, a, b in build_frame:
if b == 1:
if check(board, y, x, a):
board[y][x][a] = 1
else:
board[y][x][a] = 0
can_remove = True
for i in range(len(board)):
for j in range(len(board)):
for k in range(2):
if board[i][j][k] and not check(board, i, j, k):
can_remove = False
break
if not can_remove:
board[y][x][a] = 1
for i in range(len(board)):
for j in range(len(board)):
for k in range(2):
if board[i][j][k]:
answer.append([i, j, k])
return answer
if __name__ == "__main__":
n = 5
build_frame = [
[0, 0, 0, 1],
[2, 0, 0, 1],
[4, 0, 0, 1],
[0, 1, 1, 1],
[1, 1, 1, 1],
[2, 1, 1, 1],
[3, 1, 1, 1],
[2, 0, 0, 0],
[1, 1, 1, 0],
[2, 2, 0, 1],
]
print(solution(n, build_frame))
|
# with-Statement
def setup():
size(400, 400)
background(255)
def draw():
fill(color(255, 153, 0))
ellipse(100, 100, 50, 50)
with pushStyle():
fill(color(255, 51, 51))
strokeWeight(5)
ellipse(200, 200, 50, 50)
ellipse(300, 300, 50, 50)
|
# Develop a program that calculates the sum between all the odd numbers
# that are multiples of three and are in the range of 1 to 500.
sum = 0
for i in range(1,501):
if (i % 2 != 0 ) and (i % 3 == 0):
sum += i
print(sum)
|
# https://www.codewars.com/kata/526571aae218b8ee490006f4/
'''
Instructions :
Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number. You can guarantee that input is non-negative.
Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
'''
def countBits(n):
return bin(n).replace('0b', '').count('1')
|
# this is a part of binary search tree class.
# The right, left and parent functions can be found in the binary search tree implementation.
def TreeSearch(T,p,k):
if k == p.key():
return p # successful search
elif k < p.key() and T.left(p) is not None:
return TreeSearch(T,T.left(p),k) # recur on the left subtree
elif k > p.key() and T.right(p) is not None:
return TreeSearch(T,T.right(p),k) # recur on the right subtree
return p # unsuccessful search
|
def isNode(data):
if type(data) == Node:
return True
else:
return False
class Node:
def __init__(self, data=None) -> None:
self.data = data
self.previous = None
self.next = None
def __str__(self) -> str:
if self.previous == None and self.next == None:
return (
f"Previous Node: None <---Current Node: {self.data}--->Next Node: None"
)
elif self.next == None:
return f"Previous Node: {self.previous.data}<---Current Node: {self.data}--->Next Node: Tail"
elif self.previous == None:
return f"Previous Node: Beginning <---Current Node: {self.data}--->Next Node: {self.next.data}"
return f"Previous Node: {self.previous.data}<---Current Node: {self.data}--->Next Node: {self.next.data}"
class DoublyLinkedList:
def __init__(self) -> None:
self.head = None
self.tail = None
self.count = 0
def create_a_Node(self, data):
self.count += 1
if self.head == None:
newNode = Node(data)
self.head = newNode
self.tail = newNode
else:
newNode = Node(data)
return newNode
def add_at_begin(self, data):
currentNode = self.head
newNode = DoublyLinkedList.create_a_Node(self, data)
currentNode.previous = newNode
newNode.next = currentNode
self.head = newNode
def add_at_end(self, data):
currentNode = self.tail
newNode = DoublyLinkedList.create_a_Node(self, data)
currentNode.next = newNode
newNode.previous = currentNode
self.tail = newNode
def insert_in_middle(self, data, num):
index = 1
currentNode = self.head
while index < num:
currentNode = currentNode.next
index += 1
nextNode = currentNode.next
newNode = DoublyLinkedList.create_a_Node(self, data)
newNode.previous = currentNode
newNode.next = currentNode.next
nextNode.previous = newNode
currentNode.next = newNode
def print_node_in_list(self):
currentNode = self.head
while currentNode.next != None:
print(currentNode)
currentNode = currentNode.next
print(currentNode)
def delNode(self, num ):
if num == 1:
currentNode = self.head
currentNode.next.previous = None
self.head = currentNode.next
elif num == -1:
currentNode = self.tail
currentNode.previous.next = None
self.tail = currentNode.previous
else:
index = 1
currentNode = self.head
while index < num:
currentNode = currentNode.next
index += 1
connectnext = currentNode.previous
connectprevious = currentNode.next
connectnext.next = connectprevious
connectprevious.previous = connectnext
self.count -= 1
def searchNode(self,data,isdel = 0 ):
isfound = False
foundNode = None
currentNode1 = self.head
currentNode2 = self.tail
while currentNode1 !=currentNode2 :
if currentNode1.data == data:
isfound = True
foundNode = currentNode1
print(f'Found it {foundNode}')
break
elif currentNode2.data == data:
isfound = True
foundNode = currentNode2
print(f'Found it {foundNode}')
break
else:
currentNode1 = currentNode1.next
currentNode2 = currentNode2.previous
if isfound == False:
if currentNode1.data == data:
foundNode = currentNode1
print(f'Found it {foundNode}')
isfound = True
if isdel == 1:
self.count -=1
connectpre = foundNode.next
connectnext = foundNode.previous
connectpre.previous = connectnext
connectnext.next = connectpre
print(f'{foundNode} Deleted')
return foundNode
else:
return foundNode
else:
print(f'Not found')
return None
if __name__ == "__main__":
myDoublyLinkedlist = DoublyLinkedList()
myDoublyLinkedlist.create_a_Node("Elaine")
myDoublyLinkedlist.add_at_end("Kyle")
myDoublyLinkedlist.add_at_end("Ming")
myDoublyLinkedlist.add_at_begin("Meimei")
myDoublyLinkedlist.add_at_begin("Jenny")
myDoublyLinkedlist.insert_in_middle("Kerwin", 2)
myDoublyLinkedlist.delNode(2)
myDoublyLinkedlist.print_node_in_list()
myDoublyLinkedlist.searchNode('Elaine',1)
print(myDoublyLinkedlist.count)
myDoublyLinkedlist.print_node_in_list()
# initcialNode = Node("Elaine")
# initcialNode2 = Node("Kyle")
# initcialNode3 = Node('2')
# myDoublyLinkedlist.head = initcialNode
# initcialNode.next = initcialNode2
# initcialNode2.previous = initcialNode
# initcialNode3.previous = initcialNode2
# initcialNode2.next = initcialNode3
# print(initcialNode2)
# print(initcialNode)
# print(initcialNode3)
|
"""test too short name
"""
__revision__ = 1
A = None
def a():
"""yo"""
pass
|
N = int(input())
ans = 1e12
# 約数を求める。N**.5までで十分
for n in range(1, int(N ** 0.5) + 1):
if N % n == 0:
ans = min(ans, n + N // n - 2)
print(ans)
|
# -*- coding: utf-8 -*-
'''
XlPy/Peptide_Database/sequencing
________________________________
Contains data for generating theoretical mass tables for
searching peptide sequencing ions.
:copyright: (c) 2015 The Regents of the University of California.
:license: GNU GPL, see licenses/GNU GPLv3.txt for more details.
'''
# contains remenants for sequencing ions by CID or ECD
# http://biochem.ncsu.edu/MassSpec/docs/PeptideSequencingMS.pdf
# Collision Induced Dissociation
# Base off mascot
# b, y, a
# H2O and NH3 loss?
# If precursor 2+, look for 2+ ion series as well
# ESI + Ion Trap
# Looks only at y/b-ions
# qqTOF
# MALDI PSD
# http://www.matrixscience.com/msparser/help/classmatrix__science_1_1ms__fragmentationrules.html#aa512e562f208dfbdbbfe781884c22df9
# http://www.matrixscience.com/help/fragmentation_help.html
# ECD
# c, z
# What are the different ion series?
# a [N]+[M]-CHO
# a* a-NH3
# a° a-H2O
# b [N]+[M]-H
# b* b-NH3
# b° b-H2O
# c [N]+[M]+NH2
# d a – partial side chain
# v y – complete side chain
# w z – partial side chain
# x [C]+[M]+CO-H
# y [C]+[M]+H
# y* y-NH3
# y° y-H2O
# z [C]+[M]-NH2
# INTERNAL FRAGMENTATION
# min_internal_mass 0.0
# max_internal_mass 700.0
# FRAG_INTERNAL_YB
# Internal series, caused by double backbone cleavage. Combination of b type and y type cleavage.
#
# FRAG_INTERNAL_YA
# Internal series, caused by double backbone cleavage. Combination of a type and y type cleavage.
#
|
# weight = [3, 5, 7]
# n = len(weight)
# a = 6
#
# for i in range(n):
# print(weight)
# if weight[i] < a:
# weight.remove(weight[i])
#
# print(weight)
# arr8 = [4, 3, 4, 4, 4, 2]
#
# print('start')
# for i in range(len(arr8) - 1):
# print(arr8[:i+1], arr8[i+1:], " - ", i)
def solution(arr):
size = 0
value = 0
for i in range(len(arr)):
if size == 0:
value = arr[i]
size += 1
else:
if value != arr[i] and size != 0:
size -= 1
else:
size += 1
leader = value
if arr.count(leader) <= len(arr) // 2:
return 0
print("Leader - ", leader)
print("Count - ", arr.count(leader))
equi_leaders = 0
leader_count_so_far = 0
for index in range(len(arr)):
if arr[index] == leader:
leader_count_so_far += 1
if leader_count_so_far > (index + 1) // 2 and \
arr.count(leader) - leader_count_so_far > (len(arr) - index - 1) // 2:
equi_leaders += 1
return equi_leaders
a = [2, 5, 5, 4, 4, 4]
b = [3, 4]
arr4 = [4, 3, 4, 4, 4, 2]
print(solution(arr4), "Answer - 2")
print(solution([1, 2, 3, 4, 5]), "Andwer - 0")
print(solution([1, 2]), "Answer - 0")
|
"""Demo assignment with separate test files."""
def square(x):
"""Return x squared."""
return x * x
def double(x):
"""Return x doubled."""
return x # Incorrect
|
class GeometryBase(CommonObject,IDisposable,ISerializable):
# no doc
def ComponentIndex(self):
""" ComponentIndex(self: GeometryBase) -> ComponentIndex """
pass
def ConstructConstObject(self,*args):
""" ConstructConstObject(self: CommonObject,parentObject: object,subobject_index: int) """
pass
def Dispose(self):
""" Dispose(self: CommonObject,disposing: bool) """
pass
def Duplicate(self):
""" Duplicate(self: GeometryBase) -> GeometryBase """
pass
def DuplicateShallow(self):
""" DuplicateShallow(self: GeometryBase) -> GeometryBase """
pass
def GetBoundingBox(self,*__args):
"""
GetBoundingBox(self: GeometryBase,plane: Plane) -> BoundingBox
GetBoundingBox(self: GeometryBase,plane: Plane) -> (BoundingBox,Box)
GetBoundingBox(self: GeometryBase,accurate: bool) -> BoundingBox
GetBoundingBox(self: GeometryBase,xform: Transform) -> BoundingBox
"""
pass
def GetUserString(self,key):
""" GetUserString(self: GeometryBase,key: str) -> str """
pass
def GetUserStrings(self):
""" GetUserStrings(self: GeometryBase) -> NameValueCollection """
pass
def MakeDeformable(self):
""" MakeDeformable(self: GeometryBase) -> bool """
pass
def MemoryEstimate(self):
""" MemoryEstimate(self: GeometryBase) -> UInt32 """
pass
def NonConstOperation(self,*args):
""" NonConstOperation(self: CommonObject) """
pass
def OnSwitchToNonConst(self,*args):
""" OnSwitchToNonConst(self: GeometryBase) """
pass
def Rotate(self,angleRadians,rotationAxis,rotationCenter):
""" Rotate(self: GeometryBase,angleRadians: float,rotationAxis: Vector3d,rotationCenter: Point3d) -> bool """
pass
def Scale(self,scaleFactor):
""" Scale(self: GeometryBase,scaleFactor: float) -> bool """
pass
def SetUserString(self,key,value):
""" SetUserString(self: GeometryBase,key: str,value: str) -> bool """
pass
def Transform(self,xform):
""" Transform(self: GeometryBase,xform: Transform) -> bool """
pass
def Translate(self,*__args):
"""
Translate(self: GeometryBase,x: float,y: float,z: float) -> bool
Translate(self: GeometryBase,translationVector: Vector3d) -> bool
"""
pass
def __enter__(self,*args):
""" __enter__(self: IDisposable) -> object """
pass
def __exit__(self,*args):
""" __exit__(self: IDisposable,exc_type: object,exc_value: object,exc_back: object) """
pass
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
@staticmethod
def __new__(self,*args): #cannot find CLR constructor
""" __new__(cls: type,info: SerializationInfo,context: StreamingContext) """
pass
def __reduce_ex__(self,*args):
pass
HasBrepForm=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Get: HasBrepForm(self: GeometryBase) -> bool
"""
IsDeformable=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Get: IsDeformable(self: GeometryBase) -> bool
"""
IsDocumentControlled=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Get: IsDocumentControlled(self: GeometryBase) -> bool
"""
ObjectType=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Get: ObjectType(self: GeometryBase) -> ObjectType
"""
UserStringCount=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Get: UserStringCount(self: GeometryBase) -> int
"""
|
def sort(elements):
while True:
swapped = False
for i in range(len(elements)-1):
if elements[i] > elements[i+1]:
# swap
temp = elements[i]
elements[i] = elements[i+1]
elements[i+1] = temp
swapped = True
if not swapped:
break
return elements
|
# D. Заботливая мама
# ID успешной посылки 65663041
class Node:
def __init__(self, value, next_item=None):
self.value = value
self.next_item = next_item
def solution(node, elem):
count = 0
while node.value != elem:
if node.value != elem and node.next_item is None:
count = -1
break
else:
count = count + 1
node = node.next_item
return count
def test():
node3 = Node("node3", None)
node2 = Node("node2", node3)
node1 = Node("node1", node2)
node0 = Node("node0", node1)
solution(node0, "node4")
# result is idx == 2
if __name__ == '__main__':
test()
|
PORT = 8000
URL = "http://localhost:{}".format(PORT)
SITE_LOCATION = 'test_site/index.html'
csv_log_single_site_init = [(False, False, True), (False, False, False)]
# TODO: Add logs and csv tests
# (True, False, True), (False, False, True), (True, True, True)]
variations = [{
'element': 'id',
'element_id': 'header',
'expected_amount': 1,
}, {
'element': 'id',
'element_id': 'headerLeft',
'expected_amount': 1,
}, {
'element': 'id',
'element_id': 'headerRight',
'expected_amount': 1,
}, {
'element': 'id',
'element_id': 'wrapall',
'expected_amount': 1,
}, {
'element': 'id',
'element_id': 'sidebar',
'expected_amount': 1,
}, {
'element': 'id',
'element_id': 'logo',
'expected_amount': 1,
}, {
'element': 'id',
'element_id': 'sidebarContent',
'expected_amount': 1,
}, {
'element': 'id',
'element_id': 'main',
'expected_amount': 1,
}
]
TESTS = list()
for variation in variations:
for options in csv_log_single_site_init:
init_params = dict()
init_params['url'] = URL
init_params['element_id'] = variation['element_id']
init_params['csv'] = options[0]
init_params['debug'] = options[1]
init_params['single_site'] = options[2]
TESTS.append(
(init_params, variation['element'], variation['element_id'], URL, options[0], options[1], options[2], variation['expected_amount']))
|
#
# PySNMP MIB module ELTEX-MES-HWENVIROMENT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ELTEX-MES-HWENVIROMENT-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:01:22 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsIntersection, ValueSizeConstraint, SingleValueConstraint, ValueRangeConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueSizeConstraint", "SingleValueConstraint", "ValueRangeConstraint", "ConstraintsUnion")
eltMes, = mibBuilder.importSymbols("ELTEX-MES", "eltMes")
RlEnvMonState, = mibBuilder.importSymbols("RADLAN-HWENVIROMENT", "RlEnvMonState")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
Unsigned32, TimeTicks, Gauge32, MibIdentifier, ObjectIdentity, Counter32, NotificationType, MibScalar, MibTable, MibTableRow, MibTableColumn, ModuleIdentity, Integer32, IpAddress, Bits, iso, Counter64 = mibBuilder.importSymbols("SNMPv2-SMI", "Unsigned32", "TimeTicks", "Gauge32", "MibIdentifier", "ObjectIdentity", "Counter32", "NotificationType", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ModuleIdentity", "Integer32", "IpAddress", "Bits", "iso", "Counter64")
TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString")
eltMesEnv = ModuleIdentity((1, 3, 6, 1, 4, 1, 35265, 1, 23, 11))
eltMesEnv.setRevisions(('2016-03-04 00:00', '2015-06-11 00:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts: eltMesEnv.setRevisionsDescriptions(('Add eltEnvResetButtonMode scalar.', 'Initial revision.',))
if mibBuilder.loadTexts: eltMesEnv.setLastUpdated('201603040000Z')
if mibBuilder.loadTexts: eltMesEnv.setOrganization('Eltex Enterprise Co, Ltd.')
if mibBuilder.loadTexts: eltMesEnv.setContactInfo('www.eltex.nsk.ru')
if mibBuilder.loadTexts: eltMesEnv.setDescription("This private MIB module contains Eltex's hardware enviroment definition.")
eltEnvMonBatteryStatusTable = MibTable((1, 3, 6, 1, 4, 1, 35265, 1, 23, 11, 1), )
if mibBuilder.loadTexts: eltEnvMonBatteryStatusTable.setStatus('current')
if mibBuilder.loadTexts: eltEnvMonBatteryStatusTable.setDescription('The table of battery status maintained by the environmental monitor card.')
eltEnvMonBatteryStatusEntry = MibTableRow((1, 3, 6, 1, 4, 1, 35265, 1, 23, 11, 1, 1), ).setIndexNames((0, "ELTEX-MES-HWENVIROMENT-MIB", "eltEnvMonBatteryStatusIndex"))
if mibBuilder.loadTexts: eltEnvMonBatteryStatusEntry.setStatus('current')
if mibBuilder.loadTexts: eltEnvMonBatteryStatusEntry.setDescription('An entry in the battery status table, representing the status of the associated battery maintained by the environmental monitor.')
eltEnvMonBatteryStatusIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 35265, 1, 23, 11, 1, 1, 1), Integer32())
if mibBuilder.loadTexts: eltEnvMonBatteryStatusIndex.setStatus('current')
if mibBuilder.loadTexts: eltEnvMonBatteryStatusIndex.setDescription('Unique index for the battery being instrumented. This index is for SNMP purposes only, and has no intrinsic meaning.')
eltEnvMonBatteryState = MibTableColumn((1, 3, 6, 1, 4, 1, 35265, 1, 23, 11, 1, 1, 2), RlEnvMonState()).setMaxAccess("readonly")
if mibBuilder.loadTexts: eltEnvMonBatteryState.setStatus('current')
if mibBuilder.loadTexts: eltEnvMonBatteryState.setDescription('The mandatory state of the battery being instrumented.')
eltEnvMonBatteryStatusCharge = MibTableColumn((1, 3, 6, 1, 4, 1, 35265, 1, 23, 11, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(0, 100), ValueRangeConstraint(255, 255), ))).setMaxAccess("readonly")
if mibBuilder.loadTexts: eltEnvMonBatteryStatusCharge.setStatus('current')
if mibBuilder.loadTexts: eltEnvMonBatteryStatusCharge.setDescription('Remaining percentage of battery charge. Value of 255 means that this parameter is undefined due to battery not supporting this feature or because it cannot be obtained in current state.')
eltEnvResetButtonMode = MibScalar((1, 3, 6, 1, 4, 1, 35265, 1, 23, 11, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2))).clone(namedValues=NamedValues(("enable", 0), ("disable", 1), ("reset-only", 2))).clone('enable')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: eltEnvResetButtonMode.setStatus('current')
if mibBuilder.loadTexts: eltEnvResetButtonMode.setDescription('Mode of reset button: 0 - Enable, 1 - disable, 2 - reset-only mode')
mibBuilder.exportSymbols("ELTEX-MES-HWENVIROMENT-MIB", eltEnvMonBatteryStatusEntry=eltEnvMonBatteryStatusEntry, eltEnvMonBatteryStatusIndex=eltEnvMonBatteryStatusIndex, eltEnvMonBatteryStatusCharge=eltEnvMonBatteryStatusCharge, PYSNMP_MODULE_ID=eltMesEnv, eltEnvResetButtonMode=eltEnvResetButtonMode, eltMesEnv=eltMesEnv, eltEnvMonBatteryState=eltEnvMonBatteryState, eltEnvMonBatteryStatusTable=eltEnvMonBatteryStatusTable)
|
class Solution:
def levelOrder(self, root: 'Node') -> List[List[int]]:
if root==None:
return []
list_trans=[]
queue=[root]
while queue:
child=[]
nodes=[]
for node in queue:
child.append(node.val)
if node.children:
nodes+=node.children
list_trans.append(child)
queue=nodes
return list_trans
|
def contador(* núm):
tam = len(núm)
print(f'Recebí os valores {núm} e são ao todo {tam} números')
contador(2, 1, 7)
contador(8, 0)
contador(4, 4, 7, 6, 2)
|
MAP_SIZE = 24
TILE_SIZE = 16
ENTITY_ID = 1
ARROW_SPEED = 9999
ENTITYMAP = {}
PLAYER_ENTITIES = []
TILEMAP = {}
GAMEINFO = {} # playerid, gameinstance
# REMOVE = []
|
# coding: utf-8
"""
author: Olivier Chabrol
updated by: Louai KB
"""
class Node:
""" Node of a list """
def __init__(self, data):
"""constructor
Args:
data (float): the data of the node
"""
self.data = data
self.next = None
def __str__(self):
"""string method
Returns:
string
"""
return str(self.data)
def __repr__(self):
"""representative method
Returns:
the data of the object
"""
return self.data
class LinkedList:
""" Linked list """
def __init__(self, nodes=None):
"""constructor
Args:
nodes (list, optional): a list of data to be converted into a linked list.
Defaults to None.
"""
self.head = None
if nodes is not None and len(nodes) != 0:
node = Node(data=nodes.pop(0))
self.head = node
for elem in nodes:
node.next = Node(data=elem)
node = node.next
def is_empty(self):
"""method to check if the linked list is empty or not
Returns:
a boolean
"""
return self.head is None
def get(self, index):
"""method to get the node from the index
Args:
index (int): the index of the node
Raises:
Exception: if the node is empty
Returns:
Node
"""
if self.is_empty():
raise Exception('empty node')
self.recursion(index, self.head)
def recursion(self, index, node):
"""recursive method to get the node from the index
Args:
index (int): the index of the node
node (Node): the head node
Returns:
the searched Node
"""
if node is None:
return node
elif index == 0:
return node
return self.recursion(index - 1, node.next)
def add_after(self, data, new_node):
"""a method to insert a node after a given node
Args:
data (float): data of the node which we will insert the new node after it
new_node (Node): new node to be inserted
Raises:
Exception: list is empty
Exception: Node with data not found
"""
if not self.head:
raise Exception("List is empty")
for node in self:
if node.data == data:
new_node.next = node.next
node.next = new_node
return
raise Exception("Node with data '{}' not found".format(data))
def add_before(self, data, new_node):
"""a method to insert a node before a given node
Args:
data (float): data of the node which we will insert the new node before it
new_node (Node): the new node to be inserted
Raises:
Exception: list is empty
Exception: Node with data not found
Returns:
Node
"""
if not self.head:
raise Exception("List is empty")
if self.head.data == data:
return self.add_first(new_node)
prev_node = self.head
for node in self:
if node.data == data:
prev_node.next = new_node
new_node.next = node
return
prev_node = node
raise Exception("Node with data '{}' not found".format(data))
def remove_node(self, data):
"""Method that allows to delete all node(s) where value == data.
Args:
data (float): data of the nodes
Raises:
Exception: list is empty
Exception: Node with data not found
"""
if not self.head:
raise Exception("List is empty")
if self.head.data == data:
self.head = self.head.next
return
previous_node = self.head
for node in self:
if node.data == data:
previous_node.next = node.next
return
previous_node = node
raise Exception("Node with data '{}' not found".format(data))
def add_first(self, node_to_add):
"""Method that inserts a node at the first element of the list.
Args:
node_to_add (Node)
"""
node_to_add.next = self.head
self.head = node_to_add
def add_last(self, node_to_add):
"""Method that inserts a node at the last element of the list.
Args:
node_to_add (Node)
"""
if self.head is None:
self.head = node_to_add
return
node = self.head
# while node.next is not None:*
while node.next is not None:
node = node.next
node.next = node_to_add
def __repr__(self):
"""representative method
Returns:
the data of the object
"""
node = self.head
nodes = []
while node is not None:
nodes.append(node.data)
node = node.next
#return "a"
return "{}".format(nodes)
def __iter__(self):
"""Iteration method
"""
node = self.head
while node is not None:
yield node
node = node.next
|
'''
* Tuplas
* Repositório: Lógica de Programação e Algoritmos em Python
* GitHub: @michelelozada
'''
# 1 - Declaração inicial
livro = (
'O Hobbit',
'The Hobbit',
'J.R.R. Tolkien',
'Ficção',
'HarperCollins',
'5a.edição',
2019,
'336 p.',
)
# 2 - Retorno do tipo da estrutura de dados acima
print(type(livro)) # <class 'tuple'>
# 3 - Impressão da tupla
print(livro)
# ('O Hobbit', 'The Hobbit', 'J.R.R. Tolkien', 'Ficção', 'HarperCollins', '5a.edição', 2019, '336 p.')
# 4 - Número de elementos que esta tupla contém
print(len(livro),'elementos') # 8 elementos
# 5 - Indicar qual o número do índice que autor ocupa na tupla
print(livro.index('J.R.R. Tolkien')) # 2
# 6 - Associe cada elemento da tupla a uma etiqueta e imprima três delas:
titulo, tituloOriginal, autor, genero, editora, edicao, ano,paginas = livro # desempacotar uma tupla
print(titulo) # O Hobbit
print(genero) # Ficção
print(ano) # 2019
# 7 - Verificação de se as editoras 'HarperCollins' ou 'Oxford' constam nesta tupla
print('HarperCollins' in livro) # True
print('Oxford' in livro) # False
# 8 - Selecionar primeiro e último elementos da tupla:
print('Primeiro elemento:',livro[0]) # Primeiro elemento: O Hobbit
print('Último elemento:',livro[-1]) # Último elemento: 336 p.
# 9 - Imprimir apenas os valores referentes à edição deste livro:
print(livro[4:7]) # ('HarperCollins', '5a.edição', 2019)
# 10 - Considerando a nova estrutura abaixo, fazer a a concatenação das duas tuplas
livro_extra_info = (
'Brochura',
'Português',
'Reinaldo José Lopes'
)
livro_tuplanova = livro + livro_extra_info
print(livro_tuplanova)
# ('O Hobbit', 'The Hobbit', 'J.R.R. Tolkien', 'Ficção', 'HarperCollins', '5a.edição', 2019, '336 p.', 'Brochura',
# 'Português', 'Reinaldo José Lopes')
# 11 - Converter esta nova tupla em uma lista
print(list(livro_tuplanova))
# ['O Hobbit', 'The Hobbit', 'J.R.R. Tolkien', 'Ficção', 'HarperCollins', '5a.edição', 2019, '336 p.', 'Brochura', 'Português', 'Reinaldo José Lopes']
# 12 - Impressão desta nova tupla, com elementos dispostos linha a linha:
for value in livro_tuplanova:
print(value)
'''
O Hobbit
The Hobbit
J.R.R. Tolkien
Ficção
HarperCollins
5a.edição
2019
336 p.
Brochura
Português
Reinaldo José Lopes
'''
# 13 - Considerando a nova estrutura apresentada abaixo, criar um dicionário com as chaves e valores correspondentes
livro_keys = (
'Título:',
'Título original:',
'Autor:',
'Gênero:',
'Editora:',
'Edição:',
'Ano de edição:',
'Número de páginas:',
'Acabamento:',
'Idioma:',
'Tradutor:'
)
dicionario = dict(zip(livro_keys,livro_tuplanova))
print(dicionario)
# {'Título:': 'O Hobbit', 'Título original:': 'The Hobbit', 'Autor:': 'J.R.R. Tolkien', 'Gênero:': 'Ficção',
# 'Editora:': 'HarperCollins', 'Edição:': '5a.edição', 'Ano de edição:': 2019, 'Número de páginas:': '336 p.',
# 'Acabamento:': 'Brochura', 'Idioma:': 'Português', 'Tradutor:': 'Reinaldo José Lopes'}
|
# 1) O que uma pessoa Tem? Quais as caracteristicas?
''' Atributos ---- variaveis globais ou unicas da class
nome | idade | telefone | sexo
'''
# 2) O que uma pessoa faz?
''' metodos (função/procedimento)
respira | dorme | corre | bebe | come | multiplica
'''
# 3) Como a pessoa está agora?
''' (Atributos de estado) - variaveis
divida | cansada | viva | morta | fome | sede
'''
#(atributos, metodos, atributos estado)
class Pessoa:
'''
Classe demonstrativo para compreenção de como
montar uma classe pessoa
'''
def __init__ (self,nome1,cpf1,data_de_nascimento1,altura1,salario1,endereço1):
'''
__init__ é o construtor da classe. Ela é responsável por
inicializar as variáveis impostantes para poder trabalhar com classe.
'''
################################ Atributos
self.nome = nome1
self.cpf = cpf1
self.data_de_nascimento = data_de_nascimento1
self.altura = altura1
self.salario = salario1
self.endereço = endereço1
############################### Atributos de estado
# Estado da pessoa
self.fome = None
self.sede = None
self.exausta = None
def correr(self,distancia):
'''
Adicione a distância em metros percorrida
'''
if distancia <= 50:
self.exausta = 'não'
elif distancia > 50 and distancia < 200:
self.exausta = 'levemente exausta'
self.sede = 'pouca'
self.fomr = 'pouca'
else:
self.exausta = 'exausta'
self.sede = 'muita'
self.fome = 'muita'
def beber(self,litro):
'''
Metodo para melhorar o status de sede
'''
if litro > 0.5 and litro < 1:
if self.sede == None or 'não':
self.sede = 'não'
elif self.sede == 'pouca':
self.sede = 'não'
elif self.sede == 'muita':
self.sede = 'pouca'
elif litro >= 1:
if self.sede == None or 'não':
self.sede = 'não'
elif self.sede == 'pouca':
self.sede = 'não'
elif self.sede == 'muita':
self.sede = 'não'
def comer(self):
self.fome = 'não'
def descansar(self,tempo):
if tempo < 5:
if self.exausta == None or 'não':
self.exausta = 'não'
elif self.exausta == 'levemente exausta':
self.exausta = 'não'
elif self.exausta == 'exausta':
self.exausta = 'levemente exausta'
elif tempo >=5 :
if self.exausta == None or 'não':
self.exausta = 'não'
elif self.exausta == 'levemente exausta':
self.exausta = 'não'
elif self.exausta == 'exausta':
self.exausta = 'não'
def jantar_noitesono(self):
self.exausta = 'não'
self.fome = 'não'
self.sede = 'não'
### Exemplo de uso de classe...
pessoa1 = Pessoa('Alberto','04304304322','22/06/2001',198,1500.00,'R. Itapé, 20')
# print(f'Exausta: {pessoa1.exausta}')
# print(f'Sede: {pessoa1.sede}')
# print(f'fome: {pessoa1.fome}')
pessoa1.correr(300)
print(f'Exausta: {pessoa1.exausta}')
print(f'Sede: {pessoa1.sede}')
print(f'fome: {pessoa1.fome}')
#pessoa1.beber(1)
# print(f'Exausta: {pessoa1.exausta}')
# print(f'Sede: {pessoa1.sede}')
# print(f'fome: {pessoa1.fome}')
#pessoa1.comer()
# print('\n')
# print(f'Exausta: {pessoa1.exausta}')
# print(f'Sede: {pessoa1.sede}')
# print(f'fome: {pessoa1.fome}')
#pessoa1.descansar(4)
pessoa1.jantar_noitesono()
print('\n')
print(f'Exausta: {pessoa1.exausta}')
print(f'Sede: {pessoa1.sede}')
print(f'fome: {pessoa1.fome}')
|
obstacleSet = set([(10, 2, 4, 5), (3, 4), (4, 4), (5, 4)])
print((2, 4) in obstacleSet)
print(obstacleSet)
print(set([(1, 2), (3, 4)]))
|
def quickSort(array, head, tail):
# an implementation of quicksort algorithm
if head >= tail:
return
else:
pivot = partition(array, head, tail)
quickSort(array, head, pivot)
quickSort(array, pivot+1, tail)
def partition(array, head, tail):
pivot = array[head]
i = head + 1
for j in range(head+1, tail):
if array[j] < pivot:
swap(array, i, j)
i += 1
swap(array, i-1, head)
return i-1
def swap(A, x, y ):
A[x],A[y]=A[y],A[x]
|
passports = []
x=0
vCount=0
keys = {"byr",
"iyr",
"eyr",
"hgt",
"hcl",
"ecl",
"pid"}
with open("Day4\\test2.txt", "r") as data:
passports = [i.replace('\n', ' ').split()
for i in data.read().split('\n\n')]
for i in passports:
print(i)
print(i[0:1])
print(keys)
# for i in passports:
# #print(passports[x])
# x+=1
# print(vCount)
|
'''
Vanir OS exception hierarchy
'''
class VanirException(Exception):
'''Exception that can be shown to the user'''
class VanirVMNotFoundError(VanirException, KeyError):
'''Domain cannot be found in the system'''
def __init__(self, vmname):
super(VanirVMNotFoundError, self).__init__(
'No such domain: {!r}'.format(vmname))
self.vmname = vmname
class VanirVMError(VanirException):
'''Some problem with domain state.'''
def __init__(self, vm, msg):
super(VanirVMError, self).__init__(msg)
self.vm = vm
class VanirVMInUseError(VanirVMError):
'''VM is in use, cannot remove.'''
def __init__(self, vm, msg=None):
super(VanirVMInUseError, self).__init__(vm,
msg or 'Domain is in use: {!r}'.format(vm.name))
class VanirVMNotStartedError(VanirVMError):
'''Domain is not started.
This exception is thrown when machine is halted, but should be started
(that is, either running or paused).
'''
def __init__(self, vm, msg=None):
super(VanirVMNotStartedError, self).__init__(vm,
msg or 'Domain is powered off: {!r}'.format(vm.name))
class VanirVMNotRunningError(VanirVMNotStartedError):
'''Domain is not running.
This exception is thrown when machine should be running but is either
halted or paused.
'''
def __init__(self, vm, msg=None):
super(VanirVMNotRunningError, self).__init__(vm,
msg or 'Domain not running (either powered off or paused): {!r}' \
.format(vm.name))
class VanirVMNotPausedError(VanirVMNotStartedError):
'''Domain is not paused.
This exception is thrown when machine should be paused, but is not.
'''
def __init__(self, vm, msg=None):
super(VanirVMNotPausedError, self).__init__(vm,
msg or 'Domain is not paused: {!r}'.format(vm.name))
class VanirVMNotSuspendedError(VanirVMError):
'''Domain is not suspended.
This exception is thrown when machine should be suspended but is either
halted or running.
'''
def __init__(self, vm, msg=None):
super(VanirVMNotSuspendedError, self).__init__(vm,
msg or 'Domain is not suspended: {!r}'.format(vm.name))
class VanirVMNotHaltedError(VanirVMError):
'''Domain is not halted.
This exception is thrown when machine should be halted, but is not (either
running or paused).
'''
def __init__(self, vm, msg=None):
super(VanirVMNotHaltedError, self).__init__(vm,
msg or 'Domain is not powered off: {!r}'.format(vm.name))
class VanirVMShutdownTimeoutError(VanirVMError):
'''Domain shutdown timed out.
'''
def __init__(self, vm, msg=None):
super(VanirVMShutdownTimeoutError, self).__init__(vm,
msg or 'Domain shutdown timed out: {!r}'.format(vm.name))
class VanirNoTemplateError(VanirVMError):
'''Cannot start domain, because there is no template'''
def __init__(self, vm, msg=None):
super(VanirNoTemplateError, self).__init__(vm,
msg or 'Template for the domain {!r} not found'.format(vm.name))
class VanirPoolInUseError(VanirException):
'''VM is in use, cannot remove.'''
def __init__(self, pool, msg=None):
super(VanirPoolInUseError, self).__init__(
msg or 'Storage pool is in use: {!r}'.format(pool.name))
class VanirValueError(VanirException, ValueError):
'''Cannot set some value, because it is invalid, out of bounds, etc.'''
class VanirPropertyValueError(VanirValueError):
'''Cannot set value of vanir.property, because user-supplied value is wrong.
'''
def __init__(self, holder, prop, value, msg=None):
super(VanirPropertyValueError, self).__init__(
msg or 'Invalid value {!r} for property {!r} of {!r}'.format(
value, prop.__name__, holder))
self.holder = holder
self.prop = prop
self.value = value
class VanirNoSuchPropertyError(VanirException, AttributeError):
'''Requested property does not exist
'''
def __init__(self, holder, prop_name, msg=None):
super(VanirNoSuchPropertyError, self).__init__(
msg or 'Invalid property {!r} of {!s}'.format(
prop_name, holder))
self.holder = holder
self.prop = prop_name
class VanirNotImplementedError(VanirException, NotImplementedError):
'''Thrown at user when some feature is not implemented'''
def __init__(self, msg=None):
super(VanirNotImplementedError, self).__init__(
msg or 'This feature is not available')
class BackupCancelledError(VanirException):
'''Thrown at user when backup was manually cancelled'''
def __init__(self, msg=None):
super(BackupCancelledError, self).__init__(
msg or 'Backup cancelled')
class VanirMemoryError(VanirVMError, MemoryError):
'''Cannot start domain, because not enough memory is available'''
def __init__(self, vm, msg=None):
super(VanirMemoryError, self).__init__(vm,
msg or 'Not enough memory to start domain {!r}'.format(vm.name))
class VanirFeatureNotFoundError(VanirException, KeyError):
'''Feature not set for a given domain'''
def __init__(self, domain, feature):
super(VanirFeatureNotFoundError, self).__init__(
'Feature not set for domain {}: {}'.format(domain, feature))
self.feature = feature
self.vm = domain
class VanirTagNotFoundError(VanirException, KeyError):
'''Tag not set for a given domain'''
def __init__(self, domain, tag):
super().__init__('Tag not set for domain {}: {}'.format(
domain, tag))
self.vm = domain
self.tag = tag
|
# Média de notas por inicial do nome
# Existe uma suspeita do laboratório SpuriousCorrelations de que a letra inicial do nome de um aluno influencia em seu desempenho acadêmico. Faça uma função que recebe um dicionário de notas cujas chaves são os nomes dos alunos. A função deve devolver um novo dicionário com as médias das notas dos alunos para cada letra inicial. Exemplo:
# Entrada: {'Andrew Ayres': 6, 'Fábio Ikeda': 10, 'Fábio Kurauchi': 9, 'Raul Hage': 8}
# Saída: {'A': 6, 'F': 9.5, 'R': 8}
# O nome da sua função deve ser 'medias_por_inicial'.
def grades_in_initial (students):
grades = {}
for name, student_grades in students.items():
initial = name[0]
if not initial in grades:
grades[initial] = [student_grades]
else:
grades[initial].append(student_grades)
return grades
def medias_por_inicial (students):
grades_avegare = {}
for initial, grades in grades_in_initial(students).items():
grade_average = sum(grades) / len(grades)
grades_avegare[initial] = grade_average
return grades_avegare
|
def entrada():
n,l = map(int,input().split())
return n,l
def perimetro(n,lado):
return n*lado
def main():
n,l=entrada()
print(perimetro(n,l))
main()
|
#
# PySNMP MIB module DES-1228p-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DES-1228P-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:23:55 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsIntersection, SingleValueConstraint, ValueRangeConstraint, ConstraintsUnion, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "SingleValueConstraint", "ValueRangeConstraint", "ConstraintsUnion", "ValueSizeConstraint")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
ModuleIdentity, enterprises, ObjectIdentity, Counter32, MibScalar, MibTable, MibTableRow, MibTableColumn, Integer32, MibIdentifier, NotificationType, Unsigned32, TimeTicks, Bits, mib_2, IpAddress, iso, Counter64, Gauge32 = mibBuilder.importSymbols("SNMPv2-SMI", "ModuleIdentity", "enterprises", "ObjectIdentity", "Counter32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Integer32", "MibIdentifier", "NotificationType", "Unsigned32", "TimeTicks", "Bits", "mib-2", "IpAddress", "iso", "Counter64", "Gauge32")
TextualConvention, DisplayString, PhysAddress = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString", "PhysAddress")
d_link = MibIdentifier((1, 3, 6, 1, 4, 1, 171)).setLabel("d-link")
dlink_products = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 10)).setLabel("dlink-products")
dlink_DES12XXSeriesProd = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 10, 75)).setLabel("dlink-DES12XXSeriesProd")
des_1228pa1 = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 10, 75, 3)).setLabel("des-1228pa1")
class OwnerString(DisplayString):
pass
class MacAddress(OctetString):
subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(6, 6)
fixedLength = 6
class PortList(TextualConvention, OctetString):
status = 'current'
subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(6, 6)
fixedLength = 6
class RowStatus(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6))
namedValues = NamedValues(("active", 1), ("notInService", 2), ("notReady", 3), ("createAndGo", 4), ("createAndWait", 5), ("destroy", 6))
companyCommGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1))
companyMiscGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 3))
companySpanGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 4))
companyConfigGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11))
companyTVlanGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 13))
companyPortTrunkGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 14))
companyPoEGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 15))
companyStaticGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 21))
companyIgsGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22))
companyDot1xGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23))
companyLLDPExtnGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 24))
commSetTable = MibTable((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 1), )
if mibBuilder.loadTexts: commSetTable.setStatus('mandatory')
commSetEntry = MibTableRow((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 1, 1), ).setIndexNames((0, "DES-1228p-MIB", "commSetIndex"))
if mibBuilder.loadTexts: commSetEntry.setStatus('mandatory')
commSetIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2))).setMaxAccess("readonly")
if mibBuilder.loadTexts: commSetIndex.setStatus('mandatory')
commSetName = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 1, 1, 2), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 20))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: commSetName.setStatus('mandatory')
commSetStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 1, 1, 3), RowStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: commSetStatus.setStatus('mandatory')
commGetTable = MibTable((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 2), )
if mibBuilder.loadTexts: commGetTable.setStatus('mandatory')
commGetEntry = MibTableRow((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 2, 1), ).setIndexNames((0, "DES-1228p-MIB", "commGetIndex"))
if mibBuilder.loadTexts: commGetEntry.setStatus('mandatory')
commGetIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 2, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2))).setMaxAccess("readonly")
if mibBuilder.loadTexts: commGetIndex.setStatus('mandatory')
commGetName = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 2, 1, 2), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 20))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: commGetName.setStatus('mandatory')
commGetStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 2, 1, 3), RowStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: commGetStatus.setStatus('mandatory')
commTrapTable = MibTable((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 3), )
if mibBuilder.loadTexts: commTrapTable.setStatus('mandatory')
commTrapEntry = MibTableRow((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 3, 1), ).setIndexNames((0, "DES-1228p-MIB", "commTrapIndex"))
if mibBuilder.loadTexts: commTrapEntry.setStatus('mandatory')
commTrapIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 3, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2))).setMaxAccess("readonly")
if mibBuilder.loadTexts: commTrapIndex.setStatus('mandatory')
commTrapName = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 3, 1, 2), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 20))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: commTrapName.setStatus('mandatory')
commTrapIpAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 3, 1, 3), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: commTrapIpAddress.setStatus('mandatory')
commTrapSNMPBootup = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 3, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: commTrapSNMPBootup.setStatus('mandatory')
commTrapSNMPTPLinkUpDown = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 3, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: commTrapSNMPTPLinkUpDown.setStatus('mandatory')
commTrapSNMPFiberLinkUpDown = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 3, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: commTrapSNMPFiberLinkUpDown.setStatus('mandatory')
commTrapTrapAbnormalTPRXError = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 3, 1, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: commTrapTrapAbnormalTPRXError.setStatus('mandatory')
commTrapTrapAbnormalTPTXError = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 3, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: commTrapTrapAbnormalTPTXError.setStatus('mandatory')
commTrapTrapAbnormalFiberRXError = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 3, 1, 11), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: commTrapTrapAbnormalFiberRXError.setStatus('mandatory')
commTrapTrapAbnormalFiberTXError = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 3, 1, 12), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: commTrapTrapAbnormalFiberTXError.setStatus('mandatory')
commTrapTrapPOEPowerFail = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 3, 1, 13), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: commTrapTrapPOEPowerFail.setStatus('mandatory')
commTrapTrapPOEPortOvercurrent = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 3, 1, 14), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: commTrapTrapPOEPortOvercurrent.setStatus('mandatory')
commTrapTrapPOEPortShort = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 3, 1, 15), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: commTrapTrapPOEPortShort.setStatus('mandatory')
commTrapStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 1, 3, 1, 16), RowStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: commTrapStatus.setStatus('mandatory')
miscReset = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 3, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("reset", 1), ("noop", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: miscReset.setStatus('mandatory')
miscStatisticsReset = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 3, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("reset", 1), ("noop", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: miscStatisticsReset.setStatus('mandatory')
spanOnOff = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 4, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: spanOnOff.setStatus('mandatory')
configVerSwPrimary = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 1), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 31))).setMaxAccess("readonly")
if mibBuilder.loadTexts: configVerSwPrimary.setStatus('mandatory')
configVerHwChipSet = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 2), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 31))).setMaxAccess("readonly")
if mibBuilder.loadTexts: configVerHwChipSet.setStatus('mandatory')
configBootTftpOperation = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("download", 1), ("upload", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: configBootTftpOperation.setStatus('mandatory')
configBootTftpServerIp = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 4), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: configBootTftpServerIp.setStatus('mandatory')
configBootImageFileName = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 5), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 63))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: configBootImageFileName.setStatus('mandatory')
configPortTable = MibTable((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 6), )
if mibBuilder.loadTexts: configPortTable.setStatus('mandatory')
configPortEntry = MibTableRow((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 6, 1), ).setIndexNames((0, "DES-1228p-MIB", "configPort"))
if mibBuilder.loadTexts: configPortEntry.setStatus('mandatory')
configPort = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 6, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: configPort.setStatus('mandatory')
configPortSpeed = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 6, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7))).clone(namedValues=NamedValues(("disable", 1), ("auto", 2), ("rate10M-Half", 3), ("rate10M-Full", 4), ("rate100M-Half", 5), ("rate100M-Full", 6), ("rate1000M-Full", 7)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: configPortSpeed.setStatus('mandatory')
configPortOperStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 6, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6))).clone(namedValues=NamedValues(("down", 1), ("rate10M-Half", 2), ("rate10M-Full", 3), ("rate100M-Half", 4), ("rate100M-Full", 5), ("rate1000M-Full", 6)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: configPortOperStatus.setStatus('mandatory')
configPortPriority = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 6, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("low", 1), ("middle", 2), ("high", 3), ("highest", 4)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: configPortPriority.setStatus('mandatory')
configVLANMode = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1))).clone(namedValues=NamedValues(("modeTagBased", 1)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: configVLANMode.setStatus('mandatory')
configMirrorTable = MibTable((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 8), )
if mibBuilder.loadTexts: configMirrorTable.setStatus('mandatory')
configMirrorEntry = MibTableRow((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 8, 1), ).setIndexNames((0, "DES-1228p-MIB", "configMirrorId"))
if mibBuilder.loadTexts: configMirrorEntry.setStatus('mandatory')
configMirrorId = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 8, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1))).setMaxAccess("readonly")
if mibBuilder.loadTexts: configMirrorId.setStatus('mandatory')
configMirrorMon = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 8, 1, 2), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: configMirrorMon.setStatus('mandatory')
configMirrorTXSrc = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 8, 1, 3), PortList()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: configMirrorTXSrc.setStatus('mandatory')
configMirrorRXSrc = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 8, 1, 4), PortList()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: configMirrorRXSrc.setStatus('mandatory')
configMirrorStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 8, 1, 5), RowStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: configMirrorStatus.setStatus('mandatory')
configSNMPEnable = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: configSNMPEnable.setStatus('mandatory')
configIpAssignmentMode = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 12), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("manual", 1), ("dhcp", 2), ("other", 3)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: configIpAssignmentMode.setStatus('mandatory')
configPhysAddress = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 13), MacAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: configPhysAddress.setStatus('mandatory')
configPasswordAdmin = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 15), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 20))).setMaxAccess("writeonly")
if mibBuilder.loadTexts: configPasswordAdmin.setStatus('mandatory')
configIpAddress = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 16), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: configIpAddress.setStatus('mandatory')
configNetMask = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 17), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: configNetMask.setStatus('mandatory')
configGateway = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 18), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: configGateway.setStatus('mandatory')
configSave = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 19), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("save", 1), ("noop", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: configSave.setStatus('mandatory')
configRestoreDefaults = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 22), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("restore", 1), ("noop", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: configRestoreDefaults.setStatus('mandatory')
configTftpServerIpAddress = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 32), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: configTftpServerIpAddress.setStatus('mandatory')
configTftpServerFileName = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 33), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 64))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: configTftpServerFileName.setStatus('mandatory')
configTftpOperation = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 11, 34), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("download", 1), ("upload", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: configTftpOperation.setStatus('mandatory')
tvlanTable = MibTable((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 13, 1), )
if mibBuilder.loadTexts: tvlanTable.setStatus('mandatory')
tvlanEntry = MibTableRow((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 13, 1, 1), ).setIndexNames((0, "DES-1228p-MIB", "tvlanId"))
if mibBuilder.loadTexts: tvlanEntry.setStatus('mandatory')
tvlanId = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 13, 1, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: tvlanId.setStatus('mandatory')
tvlanName = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 13, 1, 1, 2), DisplayString()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: tvlanName.setStatus('mandatory')
tvlanMember = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 13, 1, 1, 3), PortList()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: tvlanMember.setStatus('mandatory')
tvlanUntaggedPorts = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 13, 1, 1, 4), PortList()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: tvlanUntaggedPorts.setStatus('mandatory')
tvlanStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 13, 1, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 3, 5, 6))).clone(namedValues=NamedValues(("active", 1), ("notready", 3), ("createAndwait", 5), ("destroy", 6)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: tvlanStatus.setStatus('mandatory')
tvlanManagementOnOff = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 13, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: tvlanManagementOnOff.setStatus('mandatory')
tvlanManagementid = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 13, 3), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: tvlanManagementid.setStatus('mandatory')
tvlanPortTable = MibTable((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 13, 4), )
if mibBuilder.loadTexts: tvlanPortTable.setStatus('mandatory')
tvlanPortEntry = MibTableRow((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 13, 4, 1), ).setIndexNames((0, "DES-1228p-MIB", "tvlanPortPortId"))
if mibBuilder.loadTexts: tvlanPortEntry.setStatus('mandatory')
tvlanPortPortId = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 13, 4, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: tvlanPortPortId.setStatus('mandatory')
tvlanPortVlanId = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 13, 4, 1, 2), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: tvlanPortVlanId.setStatus('mandatory')
tvlanAsyOnOff = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 13, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: tvlanAsyOnOff.setStatus('mandatory')
portTrunkTable = MibTable((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 14, 1), )
if mibBuilder.loadTexts: portTrunkTable.setStatus('mandatory')
portTrunkEntry = MibTableRow((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 14, 1, 1), ).setIndexNames((0, "DES-1228p-MIB", "portTrunkId"), (0, "DES-1228p-MIB", "portTrunkMember"))
if mibBuilder.loadTexts: portTrunkEntry.setStatus('mandatory')
portTrunkId = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 14, 1, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: portTrunkId.setStatus('mandatory')
portTrunkName = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 14, 1, 1, 2), DisplayString()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: portTrunkName.setStatus('mandatory')
portTrunkMember = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 14, 1, 1, 3), PortList()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: portTrunkMember.setStatus('mandatory')
poePortTable = MibTable((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 15, 1), )
if mibBuilder.loadTexts: poePortTable.setStatus('mandatory')
poePortEntry = MibTableRow((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 15, 1, 1), ).setIndexNames((0, "DES-1228p-MIB", "poeportgroup"), (0, "DES-1228p-MIB", "poeportid"))
if mibBuilder.loadTexts: poePortEntry.setStatus('mandatory')
poeportgroup = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 15, 1, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: poeportgroup.setStatus('mandatory')
poeportid = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 15, 1, 1, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: poeportid.setStatus('mandatory')
poeportpowerlimit = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 15, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3))).clone(namedValues=NamedValues(("auto", 0), ("class1", 1), ("class2", 2), ("class3", 3)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: poeportpowerlimit.setStatus('mandatory')
staticOnOff = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 21, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: staticOnOff.setStatus('mandatory')
staticAutoLearning = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 21, 2), PortList()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: staticAutoLearning.setStatus('mandatory')
staticTable = MibTable((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 21, 3), )
if mibBuilder.loadTexts: staticTable.setStatus('mandatory')
staticEntry = MibTableRow((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 21, 3, 1), ).setIndexNames((0, "DES-1228p-MIB", "staticId"))
if mibBuilder.loadTexts: staticEntry.setStatus('mandatory')
staticId = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 21, 3, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: staticId.setStatus('mandatory')
staticMac = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 21, 3, 1, 2), MacAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: staticMac.setStatus('mandatory')
staticPort = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 21, 3, 1, 3), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: staticPort.setStatus('mandatory')
staticVlanID = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 21, 3, 1, 4), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: staticVlanID.setStatus('mandatory')
staticStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 21, 3, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 3, 5, 6))).clone(namedValues=NamedValues(("active", 1), ("notready", 3), ("createAndwait", 5), ("destroy", 6)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: staticStatus.setStatus('mandatory')
igsSystem = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 1))
igsVlan = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 3))
igsStatus = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2))).clone(2)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: igsStatus.setStatus('mandatory')
igsv3Processing = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2))).clone(1)).setMaxAccess("readonly")
if mibBuilder.loadTexts: igsv3Processing.setStatus('mandatory')
igsRouterPortPurgeInterval = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(60, 600)).clone(260)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: igsRouterPortPurgeInterval.setStatus('mandatory')
igsHostPortPurgeInterval = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(130, 153025)).clone(260)).setMaxAccess("readonly")
if mibBuilder.loadTexts: igsHostPortPurgeInterval.setStatus('mandatory')
igsReportForwardInterval = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 1, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 25)).clone(5)).setMaxAccess("readonly")
if mibBuilder.loadTexts: igsReportForwardInterval.setStatus('mandatory')
igsLeaveProcessInterval = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 1, 7), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 25)).clone(1)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: igsLeaveProcessInterval.setStatus('mandatory')
igsMcastEntryAgeingInterval = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 1, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(60, 600)).clone(600)).setMaxAccess("readonly")
if mibBuilder.loadTexts: igsMcastEntryAgeingInterval.setStatus('mandatory')
igsSharedSegmentAggregationInterval = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 60)).clone(30)).setMaxAccess("readonly")
if mibBuilder.loadTexts: igsSharedSegmentAggregationInterval.setStatus('mandatory')
igsGblReportFwdOnAllPorts = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("allports", 1), ("rtrports", 2))).clone(2)).setMaxAccess("readonly")
if mibBuilder.loadTexts: igsGblReportFwdOnAllPorts.setStatus('mandatory')
igsNextMcastFwdMode = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 1, 13), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("ipbased", 1), ("macbased", 2))).clone(1)).setMaxAccess("readonly")
if mibBuilder.loadTexts: igsNextMcastFwdMode.setStatus('mandatory')
igsQueryInterval = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 1, 14), Integer32().subtype(subtypeSpec=ValueRangeConstraint(60, 600)).clone(125)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: igsQueryInterval.setStatus('mandatory')
igsQueryMaxResponseTime = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 1, 15), Integer32().subtype(subtypeSpec=ValueRangeConstraint(10, 25)).clone(10)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: igsQueryMaxResponseTime.setStatus('mandatory')
igsRobustnessValue = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 1, 16), Integer32().subtype(subtypeSpec=ValueRangeConstraint(2, 255)).clone(2)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: igsRobustnessValue.setStatus('mandatory')
igsLastMembQueryInterval = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 1, 17), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 25)).clone(1)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: igsLastMembQueryInterval.setStatus('mandatory')
igsVlanMcastFwdTable = MibTable((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 3, 1), )
if mibBuilder.loadTexts: igsVlanMcastFwdTable.setStatus('mandatory')
igsVlanMcastFwdEntry = MibTableRow((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 3, 1, 1), ).setIndexNames((0, "DES-1228p-MIB", "igsVlanMcastFwdVlanIdMac"), (0, "DES-1228p-MIB", "igsVlanMcastFwdGroupAddress"))
if mibBuilder.loadTexts: igsVlanMcastFwdEntry.setStatus('mandatory')
igsVlanMcastFwdVlanIdMac = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 3, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 4094)))
if mibBuilder.loadTexts: igsVlanMcastFwdVlanIdMac.setStatus('mandatory')
igsVlanMcastFwdGroupAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 3, 1, 1, 2), MacAddress())
if mibBuilder.loadTexts: igsVlanMcastFwdGroupAddress.setStatus('mandatory')
igsVlanMcastFwdPortListMac = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 3, 1, 1, 3), PortList()).setMaxAccess("readonly")
if mibBuilder.loadTexts: igsVlanMcastFwdPortListMac.setStatus('mandatory')
igsVlanRouterPortListTable = MibTable((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 3, 3), )
if mibBuilder.loadTexts: igsVlanRouterPortListTable.setStatus('mandatory')
igsVlanRouterPortListEntry = MibTableRow((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 3, 3, 1), ).setIndexNames((0, "DES-1228p-MIB", "igsVlanRouterPortListVlanId"))
if mibBuilder.loadTexts: igsVlanRouterPortListEntry.setStatus('mandatory')
igsVlanRouterPortListVlanId = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 3, 3, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 4094)))
if mibBuilder.loadTexts: igsVlanRouterPortListVlanId.setStatus('mandatory')
igsVlanRouterPortList = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 3, 3, 1, 2), PortList()).setMaxAccess("readonly")
if mibBuilder.loadTexts: igsVlanRouterPortList.setStatus('mandatory')
igsVlanFilterTable = MibTable((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 3, 4), )
if mibBuilder.loadTexts: igsVlanFilterTable.setStatus('mandatory')
igsVlanFilterEntry = MibTableRow((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 3, 4, 1), ).setIndexNames((0, "DES-1228p-MIB", "igsVlanId"))
if mibBuilder.loadTexts: igsVlanFilterEntry.setStatus('mandatory')
igsVlanId = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 3, 4, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 4094)))
if mibBuilder.loadTexts: igsVlanId.setStatus('mandatory')
igsVlanFilterStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 22, 3, 4, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: igsVlanFilterStatus.setStatus('mandatory')
radius = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23, 1))
dot1xAuth = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23, 2))
radiusServerAddress = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23, 1, 1), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: radiusServerAddress.setStatus('mandatory')
radiusServerPort = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: radiusServerPort.setStatus('mandatory')
radiusServerSharedSecret = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23, 1, 3), DisplayString()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: radiusServerSharedSecret.setStatus('mandatory')
dot1xAuthSystemControl = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23, 2, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dot1xAuthSystemControl.setStatus('mandatory')
dot1xAuthQuietPeriod = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23, 2, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535)).clone(60)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dot1xAuthQuietPeriod.setStatus('mandatory')
dot1xAuthTxPeriod = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23, 2, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535)).clone(30)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dot1xAuthTxPeriod.setStatus('mandatory')
dot1xAuthSuppTimeout = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23, 2, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535)).clone(30)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dot1xAuthSuppTimeout.setStatus('mandatory')
dot1xAuthServerTimeout = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23, 2, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535)).clone(30)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dot1xAuthServerTimeout.setStatus('mandatory')
dot1xAuthMaxReq = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23, 2, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 10)).clone(2)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dot1xAuthMaxReq.setStatus('mandatory')
dot1xAuthReAuthPeriod = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23, 2, 7), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 4294967295)).clone(3600)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dot1xAuthReAuthPeriod.setStatus('mandatory')
dot1xAuthReAuthEnabled = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23, 2, 8), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dot1xAuthReAuthEnabled.setStatus('mandatory')
dot1xAuthConfigPortTable = MibTable((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23, 2, 9), )
if mibBuilder.loadTexts: dot1xAuthConfigPortTable.setStatus('mandatory')
dot1xAuthConfigPortEntry = MibTableRow((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23, 2, 9, 1), ).setIndexNames((0, "DES-1228p-MIB", "dot1xAuthConfigPortNumber"))
if mibBuilder.loadTexts: dot1xAuthConfigPortEntry.setStatus('mandatory')
dot1xAuthConfigPortNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23, 2, 9, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dot1xAuthConfigPortNumber.setStatus('mandatory')
dot1xAuthConfigPortControl = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23, 2, 9, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: dot1xAuthConfigPortControl.setStatus('mandatory')
dot1xAuthConfigPortStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23, 2, 9, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2))).clone(namedValues=NamedValues(("authnull", 0), ("authorized", 1), ("unauthorized", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: dot1xAuthConfigPortStatus.setStatus('mandatory')
dot1xAuthConfigPortSessionTime = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23, 2, 9, 1, 4), TimeTicks()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dot1xAuthConfigPortSessionTime.setStatus('mandatory')
dot1xAuthConfigPortSessionUserName = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 23, 2, 9, 1, 5), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: dot1xAuthConfigPortSessionUserName.setStatus('mandatory')
lldpSysMACDigest = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 24, 1), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(32, 32)).setFixedLength(32)).setMaxAccess("readonly")
if mibBuilder.loadTexts: lldpSysMACDigest.setStatus('mandatory')
lldpAntiRoguePortControl = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 24, 2), PortList()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: lldpAntiRoguePortControl.setStatus('mandatory')
lldpRemOrgDefInfoTable = MibTable((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 24, 3), )
if mibBuilder.loadTexts: lldpRemOrgDefInfoTable.setStatus('mandatory')
lldpAntiRogueKey = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 24, 4), OctetString().subtype(subtypeSpec=ValueSizeConstraint(20, 20)).setFixedLength(20)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: lldpAntiRogueKey.setStatus('mandatory')
lldpSysConfigChecksum = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 24, 5), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: lldpSysConfigChecksum.setStatus('mandatory')
lldpGalobalEnable = MibScalar((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 24, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: lldpGalobalEnable.setStatus('mandatory')
lldpRemOrgDefInfoEntry = MibTableRow((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 24, 3, 1), ).setIndexNames((0, "DES-1228p-MIB", "lldpAntiRoguePortIndex"))
if mibBuilder.loadTexts: lldpRemOrgDefInfoEntry.setStatus('mandatory')
lldpAntiRoguePortIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 24, 3, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: lldpAntiRoguePortIndex.setStatus('mandatory')
lldpAntiRoguePortStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 24, 3, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2))).clone(namedValues=NamedValues(("authentication_disabled", 0), ("authentication_enabled", 1), ("authentication_successful", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: lldpAntiRoguePortStatus.setStatus('mandatory')
lldpRemOrgDefInfoOUI = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 10, 75, 3, 24, 3, 1, 3), OctetString().subtype(subtypeSpec=ValueSizeConstraint(3, 3)).setFixedLength(3)).setMaxAccess("readonly")
if mibBuilder.loadTexts: lldpRemOrgDefInfoOUI.setStatus('mandatory')
swFiberInsert = NotificationType((1, 3, 6, 1, 4, 1, 171, 10, 75, 3) + (0,1))
swFiberRemove = NotificationType((1, 3, 6, 1, 4, 1, 171, 10, 75, 3) + (0,2))
swFiberAbnormalRXError = NotificationType((1, 3, 6, 1, 4, 1, 171, 10, 75, 3) + (0,3))
swFiberAbnormalTXError = NotificationType((1, 3, 6, 1, 4, 1, 171, 10, 75, 3) + (0,4))
swTPAbnormalRXError = NotificationType((1, 3, 6, 1, 4, 1, 171, 10, 75, 3) + (0,5))
swTPAbnormalTXError = NotificationType((1, 3, 6, 1, 4, 1, 171, 10, 75, 3) + (0,6))
mibBuilder.exportSymbols("DES-1228p-MIB", igsVlanFilterTable=igsVlanFilterTable, des_1228pa1=des_1228pa1, configMirrorEntry=configMirrorEntry, lldpAntiRoguePortStatus=lldpAntiRoguePortStatus, poeportgroup=poeportgroup, igsVlanRouterPortList=igsVlanRouterPortList, commSetTable=commSetTable, dot1xAuthConfigPortStatus=dot1xAuthConfigPortStatus, configPort=configPort, commTrapIpAddress=commTrapIpAddress, tvlanPortTable=tvlanPortTable, dot1xAuthTxPeriod=dot1xAuthTxPeriod, igsVlanRouterPortListVlanId=igsVlanRouterPortListVlanId, commTrapSNMPTPLinkUpDown=commTrapSNMPTPLinkUpDown, staticId=staticId, configVerSwPrimary=configVerSwPrimary, swTPAbnormalTXError=swTPAbnormalTXError, igsLeaveProcessInterval=igsLeaveProcessInterval, commTrapSNMPBootup=commTrapSNMPBootup, spanOnOff=spanOnOff, commTrapTrapPOEPortShort=commTrapTrapPOEPortShort, igsVlanMcastFwdVlanIdMac=igsVlanMcastFwdVlanIdMac, tvlanManagementid=tvlanManagementid, miscReset=miscReset, dot1xAuthSystemControl=dot1xAuthSystemControl, companyMiscGroup=companyMiscGroup, configVLANMode=configVLANMode, portTrunkId=portTrunkId, dot1xAuthConfigPortSessionTime=dot1xAuthConfigPortSessionTime, configBootTftpServerIp=configBootTftpServerIp, PortList=PortList, igsMcastEntryAgeingInterval=igsMcastEntryAgeingInterval, configMirrorRXSrc=configMirrorRXSrc, companyDot1xGroup=companyDot1xGroup, igsVlanFilterStatus=igsVlanFilterStatus, configPortEntry=configPortEntry, configMirrorStatus=configMirrorStatus, commGetIndex=commGetIndex, configMirrorId=configMirrorId, lldpAntiRogueKey=lldpAntiRogueKey, poeportpowerlimit=poeportpowerlimit, dot1xAuthReAuthEnabled=dot1xAuthReAuthEnabled, igsVlanId=igsVlanId, configNetMask=configNetMask, staticOnOff=staticOnOff, tvlanTable=tvlanTable, companyCommGroup=companyCommGroup, staticMac=staticMac, staticEntry=staticEntry, tvlanEntry=tvlanEntry, commSetName=commSetName, swFiberAbnormalTXError=swFiberAbnormalTXError, commTrapEntry=commTrapEntry, configBootTftpOperation=configBootTftpOperation, commGetStatus=commGetStatus, commTrapTrapAbnormalFiberTXError=commTrapTrapAbnormalFiberTXError, igsHostPortPurgeInterval=igsHostPortPurgeInterval, igsVlanMcastFwdTable=igsVlanMcastFwdTable, dlink_products=dlink_products, tvlanId=tvlanId, igsSystem=igsSystem, dot1xAuthConfigPortControl=dot1xAuthConfigPortControl, dot1xAuthConfigPortNumber=dot1xAuthConfigPortNumber, configIpAddress=configIpAddress, lldpGalobalEnable=lldpGalobalEnable, commTrapTrapPOEPortOvercurrent=commTrapTrapPOEPortOvercurrent, swTPAbnormalRXError=swTPAbnormalRXError, configSNMPEnable=configSNMPEnable, igsQueryMaxResponseTime=igsQueryMaxResponseTime, igsReportForwardInterval=igsReportForwardInterval, dot1xAuthQuietPeriod=dot1xAuthQuietPeriod, radiusServerPort=radiusServerPort, configPasswordAdmin=configPasswordAdmin, swFiberAbnormalRXError=swFiberAbnormalRXError, igsSharedSegmentAggregationInterval=igsSharedSegmentAggregationInterval, lldpAntiRoguePortControl=lldpAntiRoguePortControl, commTrapTrapAbnormalTPTXError=commTrapTrapAbnormalTPTXError, commTrapTrapPOEPowerFail=commTrapTrapPOEPowerFail, lldpRemOrgDefInfoEntry=lldpRemOrgDefInfoEntry, companySpanGroup=companySpanGroup, tvlanPortEntry=tvlanPortEntry, igsStatus=igsStatus, radius=radius, tvlanUntaggedPorts=tvlanUntaggedPorts, configVerHwChipSet=configVerHwChipSet, igsVlanFilterEntry=igsVlanFilterEntry, configTftpOperation=configTftpOperation, dot1xAuthConfigPortTable=dot1xAuthConfigPortTable, configBootImageFileName=configBootImageFileName, commTrapTrapAbnormalFiberRXError=commTrapTrapAbnormalFiberRXError, tvlanAsyOnOff=tvlanAsyOnOff, configPhysAddress=configPhysAddress, tvlanPortVlanId=tvlanPortVlanId, dlink_DES12XXSeriesProd=dlink_DES12XXSeriesProd, RowStatus=RowStatus, igsNextMcastFwdMode=igsNextMcastFwdMode, staticTable=staticTable, staticAutoLearning=staticAutoLearning, configPortSpeed=configPortSpeed, poePortEntry=poePortEntry, configPortTable=configPortTable, companyPortTrunkGroup=companyPortTrunkGroup, staticStatus=staticStatus, igsVlanRouterPortListTable=igsVlanRouterPortListTable, commGetName=commGetName, lldpRemOrgDefInfoOUI=lldpRemOrgDefInfoOUI, portTrunkName=portTrunkName, companyIgsGroup=companyIgsGroup, commSetStatus=commSetStatus, dot1xAuthMaxReq=dot1xAuthMaxReq, commTrapTrapAbnormalTPRXError=commTrapTrapAbnormalTPRXError, igsv3Processing=igsv3Processing, tvlanMember=tvlanMember, companyLLDPExtnGroup=companyLLDPExtnGroup, tvlanPortPortId=tvlanPortPortId, dot1xAuthSuppTimeout=dot1xAuthSuppTimeout, portTrunkTable=portTrunkTable, dot1xAuthConfigPortEntry=dot1xAuthConfigPortEntry, dot1xAuthConfigPortSessionUserName=dot1xAuthConfigPortSessionUserName, configPortPriority=configPortPriority, tvlanManagementOnOff=tvlanManagementOnOff, configTftpServerIpAddress=configTftpServerIpAddress, d_link=d_link, companyConfigGroup=companyConfigGroup, lldpSysConfigChecksum=lldpSysConfigChecksum, portTrunkMember=portTrunkMember, lldpAntiRoguePortIndex=lldpAntiRoguePortIndex, configGateway=configGateway, poePortTable=poePortTable, configPortOperStatus=configPortOperStatus, swFiberRemove=swFiberRemove, igsVlan=igsVlan, igsVlanMcastFwdGroupAddress=igsVlanMcastFwdGroupAddress, configMirrorTXSrc=configMirrorTXSrc, dot1xAuth=dot1xAuth, commTrapStatus=commTrapStatus, igsGblReportFwdOnAllPorts=igsGblReportFwdOnAllPorts, radiusServerAddress=radiusServerAddress, configMirrorTable=configMirrorTable, staticVlanID=staticVlanID, commGetTable=commGetTable, MacAddress=MacAddress, commTrapTable=commTrapTable, miscStatisticsReset=miscStatisticsReset, igsVlanRouterPortListEntry=igsVlanRouterPortListEntry, configTftpServerFileName=configTftpServerFileName, lldpRemOrgDefInfoTable=lldpRemOrgDefInfoTable, staticPort=staticPort, tvlanStatus=tvlanStatus, companyPoEGroup=companyPoEGroup, igsVlanMcastFwdEntry=igsVlanMcastFwdEntry, commTrapName=commTrapName, swFiberInsert=swFiberInsert, tvlanName=tvlanName, configIpAssignmentMode=configIpAssignmentMode, companyTVlanGroup=companyTVlanGroup, dot1xAuthServerTimeout=dot1xAuthServerTimeout, lldpSysMACDigest=lldpSysMACDigest, commTrapIndex=commTrapIndex, configMirrorMon=configMirrorMon, igsLastMembQueryInterval=igsLastMembQueryInterval, radiusServerSharedSecret=radiusServerSharedSecret, OwnerString=OwnerString, commTrapSNMPFiberLinkUpDown=commTrapSNMPFiberLinkUpDown, commSetIndex=commSetIndex, companyStaticGroup=companyStaticGroup, poeportid=poeportid, commGetEntry=commGetEntry, igsRobustnessValue=igsRobustnessValue, configSave=configSave, igsRouterPortPurgeInterval=igsRouterPortPurgeInterval, configRestoreDefaults=configRestoreDefaults, portTrunkEntry=portTrunkEntry, igsVlanMcastFwdPortListMac=igsVlanMcastFwdPortListMac, igsQueryInterval=igsQueryInterval, dot1xAuthReAuthPeriod=dot1xAuthReAuthPeriod, commSetEntry=commSetEntry)
|
BOT_PREFIX = '[bot] '
BOT_SUFFIX = '\n'
class BotReply:
def send_reply(self, dest, tg_socket):
raise NotImplementedError
|
products = [
{
'id': 1,
'name': 'Apple',
'price': 200,
'quantity': 20
},
{
'id': 2,
'name': 'Milk',
'price': 20,
'quantity': 100
},
{
'id': 3,
'name': 'Rice',
'price': 500,
'quantity': 20
},
{
'id': 4,
'name': 'Pepsi',
'price': 55,
'quantity': 20
},
]
print('-----------------------------------------------')
print('\t\tSuper Market')
print('-----------------------------------------------')
print('SNo\tName\tPrice\tQuantity')
print('-----------------------------------------------')
for product in products:
print(product['id'],'\t', product['name'],'\t', product['price'], '\t',product['quantity'])
print('-----------------------------------------------')
total_bill = 0
while True:
item = int(input('Add item to cart: '))
quant = int(input('How much: '))
for product in products:
if item == product['id']:
total_bill = product['price'] * quant + total_bill
choice = input('do you want add another item(y/n): ')
if choice.lower() == 'n':
if total_bill >=2000:
total_bill = total_bill - (total_bill * 5 / 100 )
print('congrats, you got 5 % discount')
print('Total Bill Amount: ', total_bill)
break
# item_1 = input('enter your product name: ')
# price_1 = 200
# quan_1 = int(input('enter the quantity: '))
# item_2 = input('enter your product name: ')
# price_2 = 16.50
# quan_2 = int(input('enter the quantity: '))
# item_3 = input('enter your product name: ')
# price_3= 1300
# quan_3 = int(input('enter the quantity: '))
# total_amount = price_1 * quan_1 + price_2 * quan_2 + price_3 * quan_3
# if total_amount >= 2000:
# discount_amount = int(total_amount * 5 / 100)
# print('-----------------------------------------------')
# print('\t\tSuper Market')
# print('-----------------------------------------------')
# print('SNO\tProduct\tPrice\tQuantity\tAmount')
# print('-----------------------------------------------')
# print('1.\t', item_1,'\t',price_1, '\t', quan_1, '\t\t', price_1 * quan_1 )
# print('2.\t', item_2,'\t',price_2, '\t', quan_2, '\t\t', price_2 * quan_2 )
# print('3.\t', item_3,'\t',price_3, '\t', quan_3, '\t\t', price_3 * quan_3 )
# print('------------------------------------------------')
# print('\t\tActual Amount = ', total_amount)
# print('\t\tDiscount Amount(5%) = ', discount_amount)
# print('-----------------------------------------------')
# print('\t\tTotal Bill Amount = ', total_amount - discount_amount)
|
class Node(object):
def __init__(self, data=None, next_node=None):
self.data = data
self.next = next_node
|
TITLE = "Hex and Xor"
STATEMENT_TEMPLATE = '''
Дан код, шифрующий флаг, и результат его работы. Получите флаг.
`flag = 'some string'
key = '' # one byte key was removed for security reasons
output = ""
for character in flag:
temp = ord(character) ^ ord(key)
output += (hex(temp))[2:] + ' '
key = chr(temp)
print(output)`
stdout:
```{0}```
'''
def generate(context):
participant = context['participant']
token = tokens[participant.id % len(tokens)]
return TaskStatement(TITLE, STATEMENT_TEMPLATE.format(token))
tokens = ['9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c f 7f 1b 6d 5e 6b 1b 4a 37 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 8 5d 1a 52 38 40 32 64 19 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 36 59 6b 19 63 a 78 10 6d ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c a 7a 3 6e 4 49 2e 47 3a ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 4 70 21 57 65 e 62 34 49 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7c b 6a 2f 65 3f 5a 1f 62 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 29 1a 6f 8 69 2a 53 64 19 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3e 75 39 57 15 41 24 55 28 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 2d 43 2b 1f 67 1d 2a 1a 67 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3c 79 2b 7a 3d 5c 28 6c 11 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 26 41 19 5c 18 6c 39 78 5 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 38 6f 26 7e 12 43 34 42 3f ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 74 16 54 27 6d 20 4a 1b 66 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 79 2a 7f 34 71 17 55 65 18 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7d 39 7b 18 60 38 5c 39 44 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 1a 56 30 5b 16 79 0 69 14 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 2b 60 30 7e 12 26 11 46 3b ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 2a 46 24 6a 3d 7e 13 55 28 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 26 72 33 7a f 3f 5b 34 49 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3 47 31 79 29 78 1c 6f 12 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 29 1f 47 35 59 1f 26 61 1c ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 1d 72 47 10 76 31 0 68 15 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3f 7c 4b 7d 8 4f 21 49 34 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 2a 66 a 5e 3d 72 16 61 1c ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3d f 7a 2e 57 3a 40 15 68 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 22 45 33 79 1c 64 20 47 3a ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 2a 48 2a 52 1c 2f 69 1c 61 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c d 4f 1 43 28 40 78 15 68 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 74 1 47 15 41 33 5e 6d 10 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7a f 39 5d 2b 71 1 6a 17 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c d 45 24 6a 7 4c 75 1d 60 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3c 8 3b 5a 2f 41 38 5a 27 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c f 4a 25 49 28 42 23 57 2a ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 78 2f 18 2a 62 29 43 7 7a ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7e 2a 6d 26 43 20 4a 7a 7 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7 50 34 6d 39 78 0 6e 13 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7c 14 78 1c 56 0 46 24 59 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3e 6 69 1d 55 17 5c 2d 50 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c f 62 7 51 28 5f 67 a 77 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3d 74 2d 5d 27 73 17 20 5d ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 20 42 c 3c 4d 39 73 30 4d ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7e 13 5e 12 63 a 64 1 7c ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7b c 55 25 4d 3b 6c 35 48 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 2e 42 1a 5e 16 5b 30 5a 27 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 1 30 69 59 3f 47 2e 77 a ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c d 47 26 1e 6a 5b e 3b 46 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 15 22 47 3f 5c 2a 47 f 72 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c b 78 36 5d 11 7b 19 73 e ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7e 39 7f 4e f 3b 71 38 45 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7a 4b 5 57 6e 1c 69 1a 67 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3b 79 4e 14 22 46 32 5f 22 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 16 46 77 26 74 2c 68 11 6c ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 34 6 62 23 76 37 67 3f 42 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 26 74 4d c 3d 67 55 32 4f ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c a 39 51 26 17 25 44 2e 53 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 79 20 6a 0 45 2b 72 1e 63 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 1c 75 11 63 35 4c 7c 2e 53 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7a 2f 6a 8 49 30 55 10 6d ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 35 4d 37 44 72 2 5b 1d 60 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3 30 6a 32 5d 1e 4b 7e 3 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 1e 4c 6 4f 76 4e 0 34 49 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 0 41 4 3d 45 3d 4e 19 64 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 2e 48 30 48 3 36 5e 17 6a ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7d d 3e 78 4b 3f 68 5a 27 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3e 53 1e 29 4a 23 72 7 7a ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 78 13 47 76 1f 27 6a 5a 27 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7 64 c 7c 48 21 52 2a 57 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7a 4e 77 11 4b 28 4f 37 4a ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 0 30 5c 5 50 17 72 19 64 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 14 42 29 1c 59 15 7d 1b 66 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 27 51 1e 51 34 77 35 5f 22 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 20 55 5 42 34 60 23 53 2e ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7 52 3f 50 7 69 19 20 5d ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 2 43 13 62 6 6d 54 1f 62 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 2f 5f 6f 19 2d 40 e 62 1f ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 2a 69 51 1c 71 2 30 66 1b ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7a 35 4d 8 50 1b 2b 13 6e ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7d 5 31 70 12 67 32 59 24 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 19 7a 4d 38 61 3 47 29 54 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7c 2e 56 c 4f 1d 57 31 4c ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3d e 6d 1c 4e b 7b 33 4e ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 36 50 15 2c 67 55 62 57 2a ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 5 55 37 7a 38 57 d 3d 40 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 1a 55 1a 4c 3b 4b 9 42 3f ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 27 14 46 22 67 20 10 7f 2 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 2f 62 53 1f 6a 21 4a 10 6d ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3f d 45 3f 54 63 28 6b 16 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7c a 47 c 59 1e 2c 18 65 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 34 56 1c 6c 2b 60 24 6e 13 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 14 73 0 6d 2c 5a 6e f 72 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 36 67 8 43 2f 6e 3f 4d 30 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 5 34 43 6 7f 48 9 7c 1 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 35 6 5f 10 51 7 46 8 75 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 26 42 2a 6e 2c 4e 18 28 55 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7f 35 4c 1c 66 2f 58 3a 47 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 36 66 30 66 9 48 4 6e 13 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 8 40 d 46 1e 53 31 7 7a ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 22 7b 39 8 6e 5c 3a 78 5 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 36 6 4d 79 1d 78 1c 53 2e ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 1e 6b 29 5b 21 10 46 3c 41 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 14 4e 3f 6d 3f 79 37 4 79 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 74 17 50 5 33 5e 37 5a 27 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 19 6d 21 75 0 75 26 52 2f ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c d 5c 3b 4b c 7e b 66 1b ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 75 2 73 45 21 62 23 44 39 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 0 49 2c 1b 77 22 46 21 5c ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3c 8 7b 2f 65 b 7e 18 65 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 74 37 7a 2d 7a f 64 34 49 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 25 77 4 46 2 56 3d 57 2a ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 26 6a 2d 74 1e 49 21 68 15 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 4 6d 15 61 35 5 41 75 8 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 18 6d 3a 9 3e 6c 1c 55 28 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 25 52 15 67 e 54 63 37 4a ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c f 5b 8 47 2b 5a 34 5c 21 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 1f 70 3 46 8 6a 3a 7f 2 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7e 2b 78 48 38 49 4 56 2b ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 1e 74 1 57 65 54 62 38 45 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c b 66 1c 52 61 2 45 8 75 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 19 28 11 24 7c 31 5b 29 54 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 18 6f 29 7c 12 68 39 6e 13 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7c 29 5f 34 7d 38 f 6e 13 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7b 4e 18 2a 5b b 73 38 45 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 14 7d 44 32 68 b 7c 1f 62 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 1e 54 61 25 5f c 58 35 48 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 16 4e 3e 5b 1a 7e 4f 19 64 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 15 42 10 4a 0 74 11 43 3e ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7c 1e 6b 26 7e 9 70 1c 61 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 79 17 2e 6f 22 64 8 5d 20 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c f 44 71 45 30 67 3f 9 74 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c d 46 1e 64 3c 4f 19 58 25 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 75 1a 70 1b 49 22 49 78 5 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7a 4e 7d 13 6a 1e 46 35 48 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 75 d 6c 5f 15 7e 4b 5 78 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 5 69 10 7d 19 58 2e 69 14 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 2b 49 3b 4d 2c 43 15 59 24 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 2 64 36 40 6 73 3d c 71 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7 37 75 36 47 2b 6e f 72 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7d 32 56 12 4b 25 17 71 c ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 18 69 25 51 37 4e 27 73 e ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 8 5a 14 4d 2c 43 73 35 48 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7c 2f 6a 24 6e 23 6c 59 24 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 9 3c 7f 3a 4f 23 5b 6a 17 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 1f 7d 28 70 13 76 17 54 29 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 1 38 48 4 63 8 4d 34 49 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3d 49 25 16 2e 7e 14 44 39 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 21 4b 72 41 74 10 60 d 70 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 75 1a 56 21 68 5c 4 46 3b ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 2a 4d 6 4d 38 48 22 17 6a ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 27 4f 0 61 7 40 3a 4b 36 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 8 6e 37 76 4e 7b 11 6b 16 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3c 5 6c 36 72 7 65 4 79 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7f d 3f 54 30 66 35 5b 26 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 1c 79 a 32 41 77 2e 7e 3 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 39 7e 1f 6b 32 40 25 76 b ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c d 49 7b 30 79 2e 79 35 48 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 5 4d b 41 27 16 27 4e 33 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 8 47 1e 5d 29 4d 7a d 70 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 20 17 66 34 c 7c a 65 18 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c d 40 18 53 3c 79 34 42 3f ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 25 50 35 d 43 8 3b 6e 13 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3d 4 62 17 47 28 51 3d 40 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7c 4c 1a 6f 3b 7a 2 56 2b ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 28 7b 1f 2a 42 38 71 7 7a ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 1 4d 3c 70 1e 5b 6b 6 7b ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c a 3d 64 1c 4a 7c 30 42 3f ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3 6c 2a 68 3c 58 6c 1 7c ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 0 70 6 4a c 7c 4c 5 78 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 25 5f d 5c 24 57 63 e 73 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 26 62 51 1b 50 5 40 3a 47 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 24 69 1e 4e 3e 44 3c 50 2d ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c b 5b 1a 4a 5 76 17 4f 32 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 1b 50 26 15 6f 3 56 1b 66 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3f e 43 16 6c 6 75 4d 30 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 38 53 3a 50 65 2c 40 c 71 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3f 6d 6 43 30 7 5e 66 1b ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3e 4e 18 5a 3f 7d 4d 17 6a ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 2b 46 1 72 25 13 41 72 f ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 2 76 1b 7e 6 77 43 9 74 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 1f 48 3d 50 2 7b 23 66 1b ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 29 7a 9 5e 33 71 44 d 70 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 14 47 6 53 9 30 9 45 38 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 8 30 65 f 3e 8 67 3e 43 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c f 65 f 4c 21 78 b 68 15 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 1c 74 3a 73 19 5e 35 40 3d ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c d 6a 33 49 1 63 12 4b 36 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 29 4a 7c 49 a 61 0 6f 12 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 1c 4f 19 54 39 71 36 72 f ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 8 7e 4b 7b 31 64 10 5b 26 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 3 5a 1c 71 43 e 67 15 68 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 79 20 48 23 48 32 47 a 77 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 36 6f 5b 3c 69 2c 4f 4 79 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7c 31 66 12 48 1e 7f f 72 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 9 4d 8 49 b 4d 22 78 5 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7b 11 73 9 7f 4e 7e 10 6d ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 21 11 21 42 7b 32 60 d 70 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 20 4f 19 52 19 70 5 66 1b ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 1a 7c 3d 6b 22 51 3d 58 25 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 34 43 8 6f 1c 2c 46 72 f ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 7 57 6f 19 75 42 70 3d 40 ', '9 42 e 75 1d 2e 56 9 3d 53 37 68 10 20 52 d 39 4b 78 27 53 63 13 4c 0 71 30 6a 3e 9 3a 3 7e ']
|
"""
CSCI-603: Trees (week 10)
Author: Sean Strout @ RIT CS
This is an implementation of a binary tree node.
"""
class BTNode:
"""
A binary tree node contains:
:slot val: A user defined value
:slot left: A left child (BTNode or None)
:slot right: A right child (BTNode or None)
"""
__slots__ = 'val', 'left', 'right'
def __init__(self, val, left=None, right=None):
"""
Initialize a node.
:param val: The value to store in the node
:param left: The left child (BTNode or None)
:param right: The right child (BTNode or None)
:return: None
"""
self.val = val
self.left = left
self.right = right
def testBTNode():
"""
A test function for BTNode.
:return: None
"""
parent = BTNode(10)
left = BTNode(20)
right = BTNode(30)
parent.left = left
parent.right = right
print('parent (30):', parent.val)
print('left (10):', parent.left.val)
print('right (20):', parent.right.val)
if __name__ == '__main__':
testBTNode()
|
def load(file = "data.txt"):
data = []
for line in open(file):
data.append(line)
return data
|
"""
[2017-05-26] Challenge #316 [Hard] Longest Uncrossed Knight's Path
https://www.reddit.com/r/dailyprogrammer/comments/6dgiig/20170526_challenge_316_hard_longest_uncrossed/
# Description
The longest uncrossed (or nonintersecting) knight's path is a mathematical problem involving a knight on the standard
8×8 chessboard or, more generally, on a square *n×n* board. The problem is to find the longest path the knight can take
on the given board, such that the path does not intersect itself. When calculating the path length, you count the
*moves* you make and not the number of squares you touch.
A further distinction can be made between a closed path, which ends on the same field as where it begins, and an open
path, which ends on a different field from where it begins.
For this challenge, assume the following:
* You can make an open path
* You can start (and end) on any legal square
* Just like real chess, you're bounded by legal squares on the board
* The path is constructed from line segments between the start and end points of any of the knight's moves;
intermediate squares it jumps over don't matter
This problem is intimately related to the knight's tour, a self-intersecting knight's path visiting all fields of the
board. The key difference with this challenge is that the path may not intersect itself. Variants use fairy chess
pieces like the camel ((3,1)-leaper), giraffe ((4,1)-leaper) and zebra ((3,2)-leaper) lead to problems of comparable
complexity.
# Input Description
You'll be given the size *n* of the board representing the number of squares per side - it's a square board. Example:
5
# Output Description
Your program should emit the length of the longest open tour, measured in line segments (e.g. moves). Example:
10
# Challenge Input
4
7
8
# Challenge Output
5
24
35
"""
def main():
pass
if __name__ == "__main__":
main()
|
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def diameterOfBinaryTree(self, root: TreeNode) -> int:
if root is None:
return 0
diameter = 0
def getTreeHeight(node):
nonlocal diameter
if node.left is None and node.right is None:
return 0
leftHeight = 0 if node.left is None else getTreeHeight(node.left) + 1
rightHeight = 0 if node.right is None else getTreeHeight(node.right) + 1
diameter = max(leftHeight + rightHeight, diameter)
return max(leftHeight, rightHeight)
getTreeHeight(root)
return diameter
|
def listToString(s):
"""
Description: Need to build function because argparse function returns list, not string. Called from main.
:param s: argparse output
:return: string of url
"""
# initialize an empty string
url_string = ""
# traverse in the string
for ele in s:
url_string += ele
# return string
return url_string
if __name__ == "__main__":
url = 'https://www.basketball-reference.com/leagues/NBA_2019_per_game.html'
result = listToString(url)
|
def prefix_prefix(w, m):
def naive_scan(i, j):
r = 0
while i + r <= m and j + r <= m and w[i + r] == w[j + r]:
r += 1
return r
PREF, s = [-1] * 2 + [0] * (m - 1), 1
for i in range(2, m + 1):
# niezmiennik: s jest takie, ze s + PREF[s] - 1 jest maksymalne i PREF[s] > 0
k = i - s + 1
s_max = s + PREF[s] - 1
if s_max < i:
PREF[i] = naive_scan(i, 1)
if PREF[i] > 0:
s = i
elif PREF[k] + k - 1 < PREF[s]:
PREF[i] = PREF[k]
else:
PREF[i] = (s_max - i + 1) + naive_scan(s_max + 1, s_max - i + 2)
s = i
PREF[1] = m
return PREF
|
class lz78(object):
@staticmethod
def name():
return 'LZ78'
@staticmethod
def compress(data, *args, **kwargs):
'''LZ78 compression
'''
d, word = {0: ''}, 0
dyn_d = (
lambda d, key: d.get(key) or d.__setitem__(key, len(d)) or 0
)
return [
token for
char in
data for
token in
[(word, char)] for
word in [dyn_d(d, token)] if not word
] + [(word, '')]
@staticmethod
def decompress(data, *args, **kwargs):
'''LZ78 decompression
'''
d, j = {0: ''}, ''.join
dyn_d = (
lambda d, value: d.__setitem__(len(d), value) or value
)
return j([dyn_d(d, d[codeword] + char) for (codeword, char) in data])
|
def insideBoard(board, x, y):
"""detecta si la ficha que quieres poner esta dentro de los limites del tablero
Args:
board (list): lista que contiene el tablero
x (int): posicion x en la que quieres poner en el tablero
y (int): posicion y en la que quieres poner en el tablero
Returns:
boolean: si esta dentro true si no false
"""
columns = len(board[0])
rows = len(board)
if x in range(columns) and y in range(rows):
return True
else:
return False
def legalMove(board, x, y):
"""Comprueba si el movimiento es valido, que no se superponga sobre otras fichas,
este dentro del tablero y que no este flotando la ficha
Args:
board (list): lista que contiene el tablero
x (int): posicion x en la que quieres poner en el tablero
y (int): posicion y en la que quieres poner en el tablero
Returns:
boolean: si el movimiento es valido
"""
if insideBoard(board, x, y) == False:
return False
cond1 = board[y][x] == ''
cond2 = (board[y-1][x] == 'x') or (board[y-1][x] == 'o')
cond3 = (y == 0)
if (cond1 and cond2) or (cond3):
return True
else:
return False
def win(board, x, y, turn):
"""detecta si en ese movimiento hay victoria
Args:
board (list): lista que contiene el tablero
x (int): posicion x en la que quieres poner en el tablero
y (int): posicion y en la que quieres poner en el tablero
turn (string): que jugador ha puesto, ej: 'X'/'O' o 'red'/'yellow'
Returns:
boolean: true si hay victoria, false si no hay victoria
"""
directions = [[[0, 1], [0, -1]], [[1, 1], [-1, -1]],
[[1, 0], [-1, 0]], [[1, -1], [-1, 1]]]
for direction in directions:
counter = 0
for vector in direction:
loop = 0
x_ = x
y_ = y
for loop in range(4):
loop = loop + 1
x_ = x_ + vector[0]
y_ = y_ + vector[1]
cond = insideBoard(board, x_, y_) and board[y_][x_] == turn
if cond:
counter = counter + 1
else:
break
if counter == 3:
return True
return False
board1 = [['', '', '', '', '', '', ''],
['', '', '', '', '', '', ''],
['', '', '', '', '', '', ''],
['', '', '', '', '', '', ''],
['', '', '', '', '', '', ''],
['', '', '', '', '', '', '']]
board2 = [['', 'x', '', 'x', 'x', '', ''],
['', '', '', 'o', 'x', '', ''],
['', '', '', 'x', 'x', '', ''],
['', '', '', '', '', '', ''],
['', '', '', '', '', '', ''],
['', '', '', '', '', '', '']]
board4 = [['o', 'o', 'o', 'x', 'x', 'o', 'o'],
['o', 'o', '', 'o', 'x', 'o', 'o'],
['o', 'x', '', 'x', 'o', 'x', 'o'],
['x', '', '', '', '', 'x', ''],
['x', '', '', '', '', '', ''],
['', '', '', '', '', '', '']]
board3 = [['00', '10', '20', '30', '40', '50', '60'],
['01', '11', '21', '31', '41', '51', '61'],
['02', '12', '22', '32', '42', '52', '62'],
['03', '13', '23', '33', '43', '53', '63'],
['04', '14', '24', '34', '44', '54', '64'],
['05', '15', '25', '35', '45', '55', '65']]
def test_win():
assert win(board2, 4, 3, 'x') == True
assert win(board2, 2, 0, 'x') == True
assert win(board2, 6, 0, 'x') == False
assert win(board2, 8, 8, 'x') == False
assert win(board2, 5, 5, 'x') == False
assert win(board4, 6, 3, 'x') == True
assert win(board4, 2, 1, 'x') == True
assert win(board4, 2, 3, 'x') == False
assert win(board4, 0, 5, 'o') == False
|
longname = {'S': 'Susceptible',
'E': 'Exposed',
'I': 'Infected (symptomatic)',
'A': 'Asymptomatically Infected',
'R': 'Recovered',
'H': 'Hospitalised',
'C': 'Critical',
'D': 'Deaths',
'O': 'Offsite',
'Q': 'Quarantined',
'U': 'No ICU Care',
'CS': 'Change in Susceptible',
'CE': 'Change in Exposed',
'CI': 'Change in Infected (symptomatic)',
'CA': 'Change in Asymptomatically Infected',
'CR': 'Change in Recovered',
'CH': 'Change in Hospitalised',
'CC': 'Change in Critical',
'CD': 'Change in Deaths',
'CO': 'Change in Offsite',
'CQ': 'Change in Quarantined',
'CU': 'Change in No ICU Care',
'Ninf': 'Change in total active infections', # sum of E, I, A
}
shortname = {'S': 'Sus.',
'E': 'Exp.',
'I': 'Inf. (symp.)',
'A': 'Asym.',
'R': 'Rec.',
'H': 'Hosp.',
'C': 'Crit.',
'D': 'Deaths',
'O': 'Offsite',
'Q': 'Quar.',
'U': 'No ICU',
'CS': 'Change in Sus.',
'CE': 'Change in Exp.',
'CI': 'Change in Inf. (symp.)',
'CA': 'Change in Asym.',
'CR': 'Change in Rec.',
'CH': 'Change in Hosp.',
'CC': 'Change in Crit.',
'CD': 'Change in Deaths',
'CO': 'Change in Offsite',
'CQ': 'Change in Quar.',
'CU': 'Change in No ICU',
'Ninf': 'New Infected', # newly exposed to the disease = - change in susceptibles
}
index = {'S': 0,
'E': 1,
'I': 2,
'A': 3,
'R': 4,
'H': 5,
'C': 6,
'D': 7,
'O': 8,
'Q': 9,
'U': 10,
'CS': 11,
'CE': 12,
'CI': 13,
'CA': 14,
'CR': 15,
'CH': 16,
'CC': 17,
'CD': 18,
'CO': 19,
'CQ': 20,
'CU': 21,
'Ninf': 22,
}
# This is for the plotter and will be deprecated soon
colour = {'S': 'rgb(0,0,255)', #'blue',
'E': 'rgb(255,150,255)', #'pink',
'I': 'rgb(255,150,50)', #'orange',
'A': 'rgb(255,50,50)', #'dunno',
'R': 'rgb(0,255,0)', #'green',
'H': 'rgb(255,0,0)', #'red',
'C': 'rgb(50,50,50)', #'black',
'D': 'rgb(130,0,255)', #'purple',
'O': 'rgb(130,100,150)', #'dunno',
'Q': 'rgb(150,130,100)', #'dunno',
'U': 'rgb(150,100,150)', #'dunno',
'CS': 'rgb(0,0,255)', #'blue',
'CE': 'rgb(255,150,255)', #'pink',
'CI': 'rgb(255,150,50)', #'orange',
'CA': 'rgb(255,50,50)', #'dunno',
'CR': 'rgb(0,255,0)', #'green',
'CH': 'rgb(255,0,0)', #'red',
'CC': 'rgb(50,50,50)', #'black',
'CD': 'rgb(130,0,255)', #'purple',
'CO': 'rgb(130,100,150)', #'dunno',
'CQ': 'rgb(150,130,100)', #'dunno',
'CU': 'rgb(150,100,150)', #'dunno',
'Ninf': 'rgb(255,125,100)', #
}
# This is for the plotter and will be deprecated soon
fill_colour = {'S': 'rgba(0,0,255),0.1', #'blue',
'E': 'rgba(255,150,255),0.1', #'pink',
'I': 'rgba(255,150,50),0.1', #'orange',
'A': 'rgba(255,50,50),0.1', #'dunno',
'R': 'rgba(0,255,0),0.1', #'green',
'H': 'rgba(255,0,0),0.1', #'red',
'C': 'rgba(50,50,50),0.1', #'black',
'D': 'rgba(130,0,255),0.1', #'purple',
'O': 'rgba(130,100,150),0.1', #'dunno',
'Q': 'rgba(150,130,100),0.1', #'dunno',
'U': 'rgba(150,100,150),0.1', #'dunno',
'CS': 'rgba(0,0,255),0.1', #'blue',
'CE': 'rgba(255,150,255),0.1', #'pink',
'CI': 'rgba(255,150,50),0.1', #'orange',
'CA': 'rgba(255,50,50),0.1', #'dunno',
'CR': 'rgba(0,255,0),0.1', #'green',
'CH': 'rgba(255,0,0),0.1', #'red',
'CC': 'rgba(50,50,50),0.1', #'black',
'CD': 'rgba(130,0,255),0.1', #'purple',
'CO': 'rgba(130,100,150),0.1', #'dunno',
'CQ': 'rgba(150,130,100),0.1', #'dunno',
'CU': 'rgba(150,100,150),0.1', #'dunno',
'Ninf': 'rgba(255,125,100),0.1', #
}
|
l = [0]*101
for i in range(1, 10):
for j in range(1, 10):
l[i*j] = 1
n = int(input())
if l[n] == 1:
print("Yes")
else:
print("No")
|
"""
@date: 2021/7/5
@description:
"""
|
class RomanNumerals:
def to_roman(val):
result = ''
symbols = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
nums = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
nums_len = len(nums)
i = 0
while i < nums_len:
if nums[i] <= val:
val -= nums[i]
result += symbols[i]
i -= 1
i += 1
return result
def from_roman(roman_num):
symbols_to_nums = {
"I": 1,
"IV": 4,
"V": 5,
"IX": 9,
"X": 10,
"XL": 40,
"L": 50,
"XC": 90,
"C": 100,
"CD": 400,
"D": 500,
"CM": 900,
"M": 1000,
}
result = 0
input_len = len(roman_num)
i = 0
while i < input_len:
search = symbols_to_nums.get(roman_num[i:i+2], None)
if search is None:
search = symbols_to_nums.get(roman_num[i:i+1], None)
i -= 1
result += search
i += 2
return result
def main():
print(RomanNumerals.to_roman(1000) == "M")
print(RomanNumerals.to_roman(4) == "IV")
print(RomanNumerals.to_roman(1) == "I")
print(RomanNumerals.to_roman(9) == "IX")
print(RomanNumerals.to_roman(1990) == "MCMXC")
print(RomanNumerals.to_roman(2008) == "MMVIII")
print(RomanNumerals.to_roman(3999) == "MMMCMXCIX")
print(RomanNumerals.from_roman("XXI") == 21)
print(RomanNumerals.from_roman("I") == 1)
print(RomanNumerals.from_roman("IX") == 9)
print(RomanNumerals.from_roman("IV") == 4)
print(RomanNumerals.from_roman("MMVIII") == 2008)
print(RomanNumerals.from_roman("MDCLXVI") == 1666)
if __name__ == '__main__':
main()
|
'''
Write an algorithm Sums-One-Two-Three(n) that takes an integer n and, in
time O(n), returns the number of possible ways to write n as a sum of 1, 2, and 3. For
example, Sums-One-Two-Three(4) must return 7 because there are 7 ways to write 4 as a
sum of ones, twos, and threes (1+1+1+1, 1+1+2, 1+2+1, 2+1+1, 2+2, 1+3, 3+1).
Analyze the complexity of your solution. Hint: use dynamic programming.
'''
def sumOneTwoThree(n):
return sumOneTwoThree_(n, {})
def sumOneTwoThree_(n, memo):
if n in memo:
#print("yo")
return memo[n]
else:
if n <= 0:
res = 0
elif n == 1:
res = 1
elif n == 2:
res = 2
elif n == 3:
res =4
else:
res = sumOneTwoThree_(n-1, memo) + \
sumOneTwoThree_(n-2, memo) + \
sumOneTwoThree_(n-3, memo)
memo[n] = res
return res
def sumOneTwoThreeIterative(n):
# base cases
if n == 0:
return 0
if n == 1:
return 1
if n == 2:
return 2
if n == 3:
return 4
# iteration
a = 1 # solution for n-3
b = 2 # solution for n-2
c = 4 # solution for n-1
res = a + b + c # solution for n
i = 4
while i < n:
a = b
b = c
c = res
res = a + b + c
i += 1
return res
print(sumOneTwoThree(4))
print(sumOneTwoThree(60))
print(sumOneTwoThree(900))
print("")
print(sumOneTwoThreeIterative(4))
print(sumOneTwoThreeIterative(60))
print(sumOneTwoThreeIterative(900))
# this is not possible with the recursive solution !!
# its a huge number
print(sumOneTwoThreeIterative(6000))
|
# Write your solution for 1.3 here!
a=0
i=1
while a < 10000:
a+=i
i+=1
print(i)
#####
a=0
i=2
while a<10000:
a+=i
i+=2
print(i)
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2017/11/6 16:45
# @File : leetCode_657.py
'''
思路,
U,D,L,R
分布对应+1, -1操作,最后比较值即可
'''
class Solution(object):
def judgeCircle(self, moves):
"""
:type moves: str
:rtype: bool
"""
steps = {
"U": 1,
"D": -1,
"L": -1,
"R": 1
}
a, b = 0
for m in moves:
if m in ("U", "D"):
a += steps[m]
if m in ("L", "R"):
b += steps[m]
return a == 0 and b == 0
# 充分利用str的库的方法,经典
# return moves.count('L') == moves.count('R') and moves.count('U') == moves.count('D')
|
class account:
def check_password_length(self, password):
if len(password) > 8:
return True
else:
return False
if __name__ == '__main__':
accVerify = account()
print('The password length is ' + str(accVerify.check_password_length('offtoschool')))
|
"""
Some useful data sets to be used in the analysis
The command :func:`sequana.sequana_data` may be used to retrieved data from
this package. For example, a small but standard reference (phix) is used in
some NGS experiments. The file is small enough that it is provided within
sequana and its filename (full path) can be retrieved as follows::
from sequana import sequana_data
fullpath = sequana_data("phiX174.fa", "data")
Other files stored in this directory will be documented here.
"""
#: List of adapters used in various sequencing platforms
adapters = {
"adapters_netflex_pcr_free_1_fwd": "adapters_netflex_pcr_free_1_fwd.fa",
"adapters_netflex_pcr_free_1_rev": "adapters_netflex_pcr_free_1_rev.fa"
}
|
class Node:
def __init__(self, init_data, pointer = None):
self.data = init_data
self.pointer = pointer
def get_data(self):
return self.data
def get_next(self):
return self.pointer
def set_data(self, data):
self.data = data
def set_next(self, data):
self.pointer = data
class LinkedList:
def __init__(self):
self.root = None
self.size = 0
def get_size(self):
return str(self.size)
def add(self, data):
new = Node(data, self.root)
self.root = new
self.size += 1
def remove(self, data):
current = self.root
prev_node = None
while current:
if current.get_data() == data:
if prev_node:
prev_node.set_next(current.get_next())
else:
self.root = current
self.size -= 1
return
else:
prev_node = current
current = current.get_next()
print("Data not in linked list")
def search(self, data):
current = self.root
while current:
if current.get_data == data:
return data
else:
current = current.get_next()
return None
|
#--- Exercicio 1 - Variávies e impressão com interpolacão de string
#--- Crie 5 variávies para armazenar os dados de um funcionário
#--- Funcionario: Nome, Sobrenome, Cpf, Rg, Salário
#--- Os dados devem ser impressos utilizando a funcao format()
#--- Deve ser usado apenas uma vez a função print(), porem os dados devem ser apresentados um em cada linha
#--- O salario deve ser de tipo flutuante e na impressão deve apesentar apenas duas casas após a vírgula
nome = input('Insita o nome do funcionário: ')
sobrenome = input('Insita o sobrenome do funcionário: ')
cpf = input('Insita o CPF do funcionário: ')
rg = input('Insita o RG do funcionário: ')
salario = round(float(input('Insita o salário do funcionário: ')),2)
print('\nNome: {}\nSobrenome: {}\nCPF: {}\nRG: {}\nSalário: {}\n'.format(nome,sobrenome,cpf,rg,salario))
|
def tennis_set(s1, s2):
n1 = min(s1, s2)
n2 = max(s1, s2)
if n2 == 6:
return n1 < 5
return n2 == 7 and n1 >= 5 and n1 < n2
|
class people:
def __init__(self):
self.nick_name = ""
self.qq_number = ""
self.topic_name = ""
def display(self):
print("------------------------topic_name = %s------------------------" % self.topic_name)
print("nick_name = ", self.nick_name)
print("%-13s%s" % ("qq_number = ", self.qq_number))
|
def get_object_or_none(model, *args, **kwargs):
try:
return model._default_manager.get(*args, **kwargs)
except model.DoesNotExist:
return None
def get_object_or_this(model, this, *args, **kwargs):
return get_object_or_none(model, *args, **kwargs) or this
|
class Solution:
def merge(self, nums1, m, nums2, n):
i=m-1
j=n-1
tmp=m+n-1
while i>=0 and j>=0:
if nums1[i]<nums2[j]:
nums1[tmp]=nums2[j]
tmp-=1
j-=1
else:
nums1[tmp]=nums1[i]
tmp-=1
i-=1
while j>=0:
nums1[tmp]=nums2[j]
tmp-=1
j-=1
|
# -*- coding: utf-8 -*-
# {name: (aka, width, height, aspect ratio)}
HIGH_DEFINITION_MAP = {
"NHD": ("nHD", 640, 360, (16, 9)),
"QHD": ("qHD", 960, 540, (16, 9)),
"HD": ("HD", 1280, 720, (16, 9)),
"HD PLUS": ("HD+", 1600, 900, (16, 9)),
"FHD": ("FHD", 1920, 1080, (16, 9)),
"WQHD": ("WQHD", 2560, 1440, (16, 9)),
"QHD PLUS": ("QHD+", 3200, 1800, (16, 9)),
"UHD 4K": ("4K UHD", 3840, 2160, (16, 9)),
"UHD PLUS 5K": ("5K UHD+", 5120, 2880, (16, 9)),
"UHD 8K": ("8K UHD", 7680, 4320, (16, 9)),
}
VIDEO_GRAPHICS_ARRAY_MAP = {
"QQVGA": ("QQVGA", 160, 120, (4, 3)),
"HQVGA 240 160": ("HQVGA", 240, 160, (3, 2)),
"HQVGA 256 160": ("HQVGA", 256, 160, (16, 10)),
"QVGA": ("QVGA", 320, 240, (4, 3)),
"WQVGA 384 240": ("WQVGA", 384, 240, (16, 10)),
"WQVGA 360 240": ("WQVGA", 360, 240, (3, 2)),
"WQVGA 400 240": ("WQVGA", 400, 240, (5, 3)),
"HVGA": ("HVGA", 480, 320, (3, 2)),
"VGA": ("VGA", 640, 480, (4, 3)),
"WVGA 768 480": ("WVGA", 768, 480, (16, 10)),
"WVGA 720 480": ("WVGA", 720, 480, (3, 2)),
"WVGA 800 480": ("WVGA", 800, 480, (5, 3)),
"FWVGA": ("FWVGA", 854, 480, (16, 9)),
"SVGA": ("SVGA", 800, 600, (4, 3)),
"DVGA": ("DVGA", 960, 640, (3, 2)),
"WSVGA 1024 576": ("WSVGA", 1024, 576, (16, 9)),
"WSVGA 1024 600": ("WSVGA", 1024, 600, (128, 75)),
}
EXTENDED_GRAPHICS_ARRAY_MAP = {
"XGA": ("XGA", 1024, 768, (4, 3)),
"WXGA 1152 768": ("WXGA", 1152, 768, (3, 2)),
"WXGA 1280 768": ("WXGA", 1280, 768, (5, 3)),
"WXGA 1280 800": ("WXGA", 1280, 800, (16, 10)),
"WXGA 1360 768": ("WXGA", 1360, 768, (16, 9)),
"FWXGA": ("FWXGA", 1366, 768, (16, 9)),
"XGA PLUS": ("XGA+", 1152, 864, (4, 3)),
"WXGA PLUS": ("WXGA+", 1440, 900, (16, 10)),
"WSXGA": ("WSXGA", 1440, 960, (3, 2)),
"SXGA": ("SXGA", 1280, 1024, (5, 4)),
"SXGA PLUS": ("SXGA+", 1400, 1050, (4, 3)),
"WSXGA PLUS": ("WSXGA+", 1680, 1050, (16, 10)),
"UXGA": ("UXGA", 1600, 1200, (4, 3)),
"WUXGA": ("WUXGA", 1920, 1200, (16, 10)),
}
QUAD_EXTENDED_GRAPHICS_ARRAY_MAP = {
"QWXGA": ("QWXGA", 2048, 1152, (16, 9)),
"QXGA": ("QXGA", 2048, 1536, (4, 3)),
"WQXGA 2560 1600": ("WQXGA", 2560, 1600, (16, 10)),
"WQXGA 2880 1800": ("WQXGA", 2880, 1800, (16, 10)),
"QSXGA": ("QSXGA", 2560, 2048, (5, 4)),
"WQSXGA": ("WQSXGA", 3200, 2048, (25, 16)),
"QUXGA": ("QUXGA", 3200, 2400, (4, 3)),
"WQUXGA": ("WQUXGA", 3840, 2400, (16, 10)),
}
HYPER_EXTENDED_GRAPHICS_ARRAY_MAP = {
"HXGA": ("HXGA", 4096, 3072, (4, 3)),
"WHXGA": ("WHXGA", 5120, 3200, (16, 10)),
"HSXGA": ("HSXGA", 5120, 4096, (5, 4)),
"WHSXGA": ("WHSXGA", 6400, 4096, (25, 16)),
"HUXGA": ("HUXGA", 6400, 4800, (4, 3)),
"WHUXGA": ("WHUXGA", 7680, 4800, (16, 10)),
}
STANDARD_DISPLAY_RESOLUTIONS_MAP = (
(160, 120, (4, 3)),
(320, 200, (8, 5)),
(640, 200, (16, 5)),
(640, 350, (64, 35)),
(640, 480, (4, 3)),
(720, 348, (60, 29)),
(800, 600, (4, 3)),
(1024, 768, (4, 3)),
(1152, 864, (4, 3)),
(1280, 1024, (5, 4)),
(1400, 1050, (4, 3)),
(1600, 1200, (4, 3)),
(2048, 1536, (4, 3)),
(2560, 2048, (5, 4)),
(3200, 2400, (4, 3)),
(4096, 3072, (4, 3)),
(5120, 4096, (5, 4)),
(6400, 4800, (4, 3)),
)
WIDESCREEN_DISPLAY_RESOLUTIONS_MAP = (
(240, 160, (3, 2)),
(320, 240, (4, 3)),
(432, 240, (9, 5)),
(480, 270, (16, 9)),
(480, 320, (3, 2)),
(640, 400, (8, 5)),
(800, 480, (5, 3)),
(854, 480, (427, 240)),
(1024, 576, (16, 9)),
(1280, 720, (16, 9)),
(1280, 768, (5, 3)),
(1280, 800, (8, 5)),
(1366, 768, (683, 384)),
(1366, 900, (683, 450)),
(1440, 900, (8, 5)),
(1600, 900, (16, 9)),
(1680, 945, (16, 9)),
(1680, 1050, (8, 5)),
(1920, 1080, (16, 9)),
(1920, 1200, (8, 5)),
(2048, 1152, (16, 9)),
(2560, 1440, (16, 9)),
(2560, 1600, (8, 5)),
(3200, 2048, (25, 16)),
(3840, 2160, (16, 9)),
(3200, 2400, (4, 3)),
(5120, 2880, (16, 9)),
(5120, 3200, (8, 5)),
(5760, 3240, (16, 9)),
(6400, 4096, (25, 16)),
(7680, 4320, (16, 9)),
(7680, 4800, (8, 5)),
)
|
def shape_legend(node, ax, handles, labels, reverse=False, **kwargs):
"""Plot legend manipulation. This code is copied from the oemof example script
see link here: https://github.com/oemof/oemof-examples/tree/master/oemof_examples/oemof.solph/v0.3.x/plotting_examples
"""
handels = handles
labels = labels
axes = ax
parameter = {}
new_labels = []
for label in labels:
label = label.replace('(', '')
label = label.replace('), flow)', '')
label = label.replace(node, '')
label = label.replace(',', '')
label = label.replace(' ', '')
new_labels.append(label)
labels = new_labels
parameter['bbox_to_anchor'] = kwargs.get('bbox_to_anchor', (1, 0.5))
parameter['loc'] = kwargs.get('loc', 'center left')
parameter['ncol'] = kwargs.get('ncol', 1)
plotshare = kwargs.get('plotshare', 0.9)
if reverse:
handels = handels.reverse()
labels = labels.reverse()
box = axes.get_position()
axes.set_position([box.x0, box.y0, box.width * plotshare, box.height])
parameter['handles'] = handels
parameter['labels'] = labels
axes.legend(**parameter)
return axes
|
'''
Windows OS
В операционной системе Windows полное имя файла состоит из буквы диска,
после которого ставится двоеточие и символ "\", затем через такой же
символ перечисляются подкаталоги (папки), в которых находится файл,
в конце пишется имя файла (C:\Windows\System32\calc.exe).
На вход программе подается одна строка с корректным именем файла
в операционной системе Windows. Напишите программу, которая разбирает
строку на части, разделенные символом "\". Каждую часть вывести
в отдельной строке.
Формат входных данных
На вход программе подается одна строка.
Формат выходных данных
Программа должна вывести текст в соответствии с условием задачи.
Sample Input:
C:\Windows\System32\calc.exe
Sample Output:
C:
Windows
System32
calc.exe
'''
s = input()
s1 = s.split('\\')
for i in s1:
print(i)
|
def remove_background(frame):
fgbg = cv2.createBackgroundSubtractorMOG2(history=20)
fgmask = fgbg.apply(frame)
kernel = np.ones((3, 3), np.uint8)
fgmask = cv2.erode(fgmask, kernel, iterations=1)
res = cv2.bitwise_and(frame, frame, mask=fgmask)
return res
# gamma transfer
def gamma_trans(img,gamma):
gamma_table=[np.power(x/255.0,gamma)*255.0 for x in range(256)]
gamma_table=np.round(np.array(gamma_table)).astype(np.uint8)
return cv2.LUT(img,gamma_table)
def adjusted_skin_detection(frame):
ycrcb = cv2.cvtColor(frame, cv2.COLOR_BGR2YCrCb)
B = frame[:,:,0]
G = frame[:,:,1]
R = frame[:,:,2]
Y = 0.299*R + 0.587*G + 0.114*B
Y_value = np.mean(Y)
print(Y_value)
if Y_value<200:
cr0 = (R-Y)*0.713 + 128
else:
cr0 = np.multiply(((R-Y)**2*0.713),((-5000/91)*(Y-200)**(-2)+7)) + 128
cr = np.array(cr0, dtype=np.uint8)
cr1 = cv2.GaussianBlur(cr, _blurKernel, 0)
_, skin = cv2.threshold(cr1, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
kernel = np.ones(_erodeKernel, np.uint8)
skin = cv2.erode(skin, kernel, iterations=1)
skin = cv2.dilate(skin, kernel, iterations=1)
return skin
# calculate center coordinate of contour
def get_center(largecont):
M = cv2.moments(largecont)
center = (int(M['m10'] / M['m00']), int(M['m01'] / M['m00']))
return center
|
def urlify(str, length=None):
"""Write a method to replace all spaces with '%20'.
Args:
str - String whose spaces should be replaced by '%20'
length - length of str minus any spaces padded at the beginning or end
Returns:
A string similar to str except whose spaces have been replaced.
"""
return str.strip().replace(' ', '%20')
|
class ElectricalDemandFactorRule(Enum, IComparable, IFormattable, IConvertible):
"""
This enum describes the different demand factor rule types available to the application.
Within a demand factor a rule will be referenced and the user will have to enter values
corresponding to that rule.
enum ElectricalDemandFactorRule,values: Constant (0),LoadTable (2),LoadTablePerPortion (4),QuantityTable (1),QuantityTablePerPortion (3)
"""
def __eq__(self, *args):
""" x.__eq__(y) <==> x==yx.__eq__(y) <==> x==yx.__eq__(y) <==> x==y """
pass
def __format__(self, *args):
""" __format__(formattable: IFormattable,format: str) -> str """
pass
def __ge__(self, *args):
pass
def __gt__(self, *args):
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
def __le__(self, *args):
pass
def __lt__(self, *args):
pass
def __ne__(self, *args):
pass
def __reduce_ex__(self, *args):
pass
def __str__(self, *args):
pass
Constant = None
LoadTable = None
LoadTablePerPortion = None
QuantityTable = None
QuantityTablePerPortion = None
value__ = None
|
#as a list:
l=[3,4]
l+=[5,6]
print(l)
#as a stack:
#top input
#lifo
l.append(10)
print(l)
l.pop()#pops the ele that is inserted at last
#as a queue
#fifo
l.insert(0,5)
l.pop()
|
print('Hello World!')
long_mssg = """
.................................................
This script should be replaced for an AI-script
of your own which has an output of some sort that
you are interested in getting
................................................
"""
print(long_mssg)
|
#--------------------------------------------#
# My Solution #
#--------------------------------------------#
def checkio(words: str):
count = 0
for word in words.split():
if word.isalpha():
count += 1
else:
count = 0
if count == 3:
return True
return False
#--------------------------------------------#
# Better Solutions #
#--------------------------------------------#
#import re
#def checkio(words):
#return bool(re.search('\D+ \D+ \D+', words))
#or
#return bool(re.compile("([a-zA-Z]+ ){2}[a-zA-Z]+").search(words))
#def checkio(x):
#counter = 0
#for e in x.split():
#try:
#int(e)
#counter = 0
#except ValueError:
#counter += 1
#if counter >= 3: return True
#return False
#--------------------------------------------#
# Test #
#--------------------------------------------#
a = checkio("Hello World hello") #== True, "Hello"
b = checkio("He is 123 man") #== False, "123 man"
c = checkio("1 2 3 4") #== False, "Digits"
d = checkio("bla bla bla bla") #== True, "Bla Bla"
e = checkio("Hi") #== False, "Hi"
print(a, b, c, d, e, sep= "\n")
|
def render_vehicle(vehicle):
msg_pattern = u"""
<a href=\'%(tankopedia)s\'>%(name)s (%(nation)s)</a>
%(prem)s%(type)s %(level)s уровня
Цена: %(cost)s
<i>%(descr)s</i>
<a href=\'%(image_url)s\'> </a>
"""
context = {
'tankopedia': vehicle.tankopedia_url,
'name': vehicle.get_loc_name(),
'nation': vehicle.get_loc_nation(),
'image_url': vehicle.image_normal,
'descr': vehicle.description,
'cost': vehicle.get_loc_cost(),
'prem': u'Премиум ' if vehicle.is_premium else u'',
'level': vehicle.tier,
'type': vehicle.get_loc_type(),
}
msg = msg_pattern % context
return msg
def render_player(player):
msg_pattern = u"""
<b>{nickname}</b>
Account id {account_id}
Win rate {winrate}
"""
return msg_pattern.format(nickname=player.raw.nickname,
account_id=player.raw.account_id,
winrate=player.win_rate_str())
|
class Player:
def __init__(self, type_):
self.hp = 200
self.type = type_
def combat_simulation(f):
map = []
players = []
for line in f.readlines():
row = []
for c in line.strip():
if c == '#':
row.append(False)
elif c == '.':
row.append(True)
elif c == 'G':
p = Player('G')
row.append(p)
players.append(p)
elif c == 'E':
p = Player('E')
row.append(p)
players.append(p)
map.append(row)
print_map(map)
def move_to(map, source, type_):
queue = [source]
visited = {}
while queue:
x, y = queue.pop(0)
if y not in visited:
visited[y] = {}
if x in visited[y]:
continue
visited[y][x] = True
if y > 1:
val = map[y-1][x]
if val is True:
queue.append((x, y - 1))
elif isinstance(val, Player) and val.type != type_:
# we have a possible location to consider
pass
if y < (len(map) - 1):
if map[y+1][x] is True:
queue.append((x, y + 1))
if x > 1:
if map[y][x-1] is True:
queue.append((x - 1, y))
if x < (len(map[0]) - 1):
if map[y+1][x] is True:
queue.append((x + 1, y))
def print_map(map):
for row in map:
for cell in row:
if cell is False:
print('#', end='')
elif cell is True:
print('.', end='')
elif isinstance(cell, Player):
print(cell.type, end='')
print()
def test_combat_simulation():
assert combat_simulation(open('input/15.demo')) == 27730
assert combat_simulation(open('input/15.test')) == 27730
assert combat_simulation(open('input/15-1.test')) == 36334
assert combat_simulation(open('input/15-2.test')) == 39514
assert combat_simulation(open('input/15-3.test')) == 27755
assert combat_simulation(open('input/15-4.test')) == 28944
assert combat_simulation(open('input/15-5.test')) == 18740
|
# a=int(input('Enter a No.: '))
# s=0
# for i in range(1,a):
# if a%i==0:
# s+=i
# if s==a:
# print('Perfect No.')
# else:
# print('Not a perfest No.')
# a=9
# b=7
# c='12'
# print((c*(a*b))*'\n'
# for i in range(1,183):
# print(chr(i),end="")
# a='·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇ'
# print(len(a))
a={23:34, 23:23}
print(a[23])
|
"""Constants for testclient."""
# these have different places than in the gateway
PLUTO_PSK = '/tmp/psk.txt'
PLUTO_PIDFILE = '/tmp/pluto.pid'
OPENL2TP_PIDFILE = '/tmp/openl2tp.pid'
POOL_SIZE=5
|
# created by RomaOkorosso at 21.03.2021
# config.py
db_url = "postgres://USER:PASSWORD@IP:PORT/DATABASE_NAME"
|
def tree_transplant(self, u, v):
if(u.pai == None):
self.raiz = v
elif(u.pai.left == u):
u.pai.left = v
else:
u.pai.right = v
if(v != None):
v.pai = u.pai
|
"""
Baseline training file used in app production
----------------OBSOLETE----------------
import os
import sqlite3
from sklearn.linear_model import LogisticRegression
from basilica import Connection
import psycopg2
# Load in basilica api key
API_KEY = "d3c5e936-18b0-3aac-8a2c-bf95511eaaa5"
# Filepath for database
DATABASE_URL = "postgres://khqrpuidioocyy:28306f6ac214b8c5ff675ab1e38ed6007d0b810d0a538df3e0db3da0f3cde717@ec2-18-210-214-86.compute-1.amazonaws.com:5432/d1jb037n8m5r20"
# Heroku postgresql credentials
DB_NAME = "d1jb037n8m5r20"
DB_USER = "khqrpuidioocyy"
DB_PASSWORD = "28306f6ac214b8c5ff675ab1e38ed6007d0b810d0a538df3e0db3da0f3cde717"
DB_HOST = "ec2-18-210-214-86.compute-1.amazonaws.com"
# Connect to basilica for embedding text
basilica_connection = Connection(API_KEY)
sql_connection = psycopg2.connect(dbname=DB_NAME, user=DB_USER, password=DB_PASSWORD, host=DB_HOST)
sql_cursor = sql_connection.cursor()
def train_model():
# SQL commands to select all and delete null
select_data =
SELECT
*
FROM
"postgresql-shallow-75985";
# breakpoint()
# print(data)
# Execute select all commands
sql_cursor.execute(select_data)
data = sql_cursor.fetchall()
# Ensure the select command is working
# for row in data:
# print(f"\nSubreddits: {row['subreddit']}")
# print(f"\nTest: {row['Text']}")
print("TRAINING THE MODEL...")
subreddits = []
text_embeddings = []
# breakpoint()
for row in data:
subreddits.append(row[1])
embedding = basilica_connection.embed_sentence(row[2], model="reddit")
text_embeddings.append(embedding)
# breakpoint()
# print(subreddits, text_embeddings)
classifier = LogisticRegression()
classifier.fit(text_embeddings, subreddits)
return classifier
if __name__ == "__main__":
classifier = train_model()
# breakpoint()
"""
|
"""Test case for variable redefined in inner loop."""
for item in range(0, 5):
print("hello")
for item in range(5, 10): #[redefined-outer-name]
print(item)
print("yay")
print(item)
print("done")
|
def longestWord(sentence):
wordArray = sentence.split(" ")
longest = ""
for word in wordArray:
if(len(word) >= len(longest)):
longest = word
return longest
print(longestWord("Hello World"))
|
c = str(input())
if c[0] == c[1] == c[2]:
print("Won")
else:
print("Lost")
|
class Node:
def __init__(self,data=None):
self.data=data
self.next=None
class LinkedList:
def __init__(self):
self.head=None
def showlist(self):
while self.head is not None:
print(self.head.data)
self.head=self.head.next
list=LinkedList()
list.head=Node("Jan")
e1=Node("Feb")
e2=Node("Mar")
e3=Node("Apr")
#linking first node to second node
list.head.next=e1
e1.next=e2
e2.next=e3
list.showlist()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.