content
stringlengths 7
1.05M
|
---|
test_data = """
939
7,13,x,x,59,x,31,19
""".strip()
data = """
1001612
19,x,x,x,x,x,x,x,x,41,x,x,x,37,x,x,x,x,x,821,x,x,x,x,x,x,x,x,x,x,x,x,13,x,x,x,17,x,x,x,x,x,x,x,x,x,x,x,29,x,463,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,23
""".strip()
def test_aoc13_p1t():
time, schedule = test_data.splitlines()
time = int(time)
schedule = [int(bus) for bus in schedule.split(",") if bus != "x"]
print(time)
print(schedule)
departures = []
for bus in schedule:
departure = (bus - (time % bus)) if time % bus else 0
departures.append((departure, bus))
departures.sort()
print(departures[0])
print(departures[0][0] * departures[0][1])
assert departures[0][0] * departures[0][1] == 295
def test_aoc13_p1():
time, schedule = data.splitlines()
time = int(time)
schedule = [int(bus) for bus in schedule.split(",") if bus != "x"]
print(time)
print(schedule)
departures = []
for bus in schedule:
departure = (bus - (time % bus)) if time % bus else 0
departures.append((departure, bus))
departures.sort()
print(departures[0])
print(departures[0][0] * departures[0][1])
assert departures[0][0] * departures[0][1] == 6568
def find_common(offset, a, b):
print()
print(offset, a, b)
for i in range(2000):
print(
f"a = {a}, n = {offset + a * i} remainder {(offset + a * i) % b}"
)
if (offset + a * i) % b == b - 1:
return offset + a * i + 1, a * b
def test_find_common():
assert find_common(0, 3, 7) == (7, 21)
assert find_common(0, 7, 3) == (15, 21)
assert find_common(7, 21, 13) == (260, 21 * 13)
assert find_common(7, 21, 1) == (8, 21)
def get_timestamp(departures):
print("-" * 100)
print(departures)
schedule = [1 if bus == "x" else int(bus) for bus in departures.split(",")]
offset = 0
a = schedule[0]
for b in schedule[1:]:
offset, a = find_common(offset, a, b)
return offset - len(schedule) + 1
def test_part2():
assert get_timestamp("3,7,13") == 258
assert get_timestamp("3,7,13") == 258
assert get_timestamp("17,x,13") == 102
assert get_timestamp(test_data.splitlines()[1]) == 1068781
assert get_timestamp("17,x,13,19") == 3417
assert get_timestamp("67,7,59,61") == 754018
assert get_timestamp("67,x,7,59,61") == 779210
assert get_timestamp("67,7,x,59,61") == 1261476
assert get_timestamp("1789,37,47,1889") == 1202161486
assert get_timestamp(data.splitlines()[1]) == 554865447501099
|
#
# @lc app=leetcode id=485 lang=python3
#
# [485] Max Consecutive Ones
#
# https://leetcode.com/problems/max-consecutive-ones/description/
#
# algorithms
# Easy (55.74%)
# Likes: 573
# Dislikes: 349
# Total Accepted: 200.8K
# Total Submissions: 360.6K
# Testcase Example: '[1,0,1,1,0,1]'
#
# Given a binary array, find the maximum number of consecutive 1s in this
# array.
#
# Example 1:
#
# Input: [1,1,0,1,1,1]
# Output: 3
# Explanation: The first two digits or the last three digits are consecutive
# 1s.
# The maximum number of consecutive 1s is 3.
#
#
#
# Note:
#
# The input array will only contain 0 and 1.
# The length of input array is a positive integer and will not exceed 10,000
#
#
#
# @lc code=start
class Solution:
def findMaxConsecutiveOnes(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
max_consecutives = 0
current_consecutives = 0
for n in nums:
if n:
current_consecutives += 1
elif current_consecutives:
max_consecutives = max(max_consecutives, current_consecutives)
current_consecutives = 0
return max(max_consecutives, current_consecutives)
# @lc code=end
|
class Solution(object):
def searchMatrix(self, matrix, target):
"""
:type matrix: List[List[int]]
:type target: int
:rtype: bool
"""
x = 0
y = 0
xx = len(matrix) - 1
yy = len(matrix[0]) - 1
rows = xx + 1
cols = yy + 1
while True:
row = matrix[x][y : yy + 1]
py = bisect.bisect_left(row, target)
if py < len(row) and row[py] == target:
return True
if py == 0:
return False
col = [matrix[r][y] for r in range(x, xx + 1)]
px = bisect.bisect_left(col, target)
if px < len(col) and col[px] == target:
return True
if px == 0:
return False
xx = x + px - 1
yy = y + py - 1
x = x + 1
y = y + 1
if x > xx or y > yy:
return False
|
# Sanitize a dependency so that it works correctly from code that includes
# QCraft as a submodule.
def clean_dep(dep):
return str(Label(dep))
|
def unatrag(s):
if len(s)==0:
return s
else:
return unatrag(s[1:]) + s[0]
s=input("Unesite rijec: ")
print(unatrag(s))
|
file_obj = open("squares.txt", "w") #Usar w de writing
for number in range (13):
square = number * number
file_obj.write(str(square))
file_obj.write('\n')
file_obj.close()
|
# Exercise 4: Assume that we execute the following assignment statements:
# width = 17
# height = 12.0
# For each of the following expressions, write the value of the expression and the type (of the value of the expression).
# 1. width//2
# 2. width/2.0
# 3. height/3
# 4. 1 + 2 * 5
width = 17;
height = 12.0;
one = width//2; # result: 8 - type: int
two = width/2.0; # result: 8.5 - type: float
three = height/3; # result: 4.0 - type: float
four = 1 + 2 * 5; # result: 11 - type: int
print(four, type(four)) |
altitude = int(input("Enter Altitude in ft:"))
if altitude<=1000:
print("Safe to land")
elif altitude< 5000:
print("Bring down to 1000")
else:
print("Turn Around and Try Again") |
# -*- coding: utf-8 -*-
def test_dummy(cmd, initproj, monkeypatch):
monkeypatch.delenv(str("TOXENV"), raising=False)
path = initproj(
'envreport_123',
filedefs={
'tox.ini': """
[tox]
envlist = a
[testenv]
deps=tox-envreport
commands=echo "yehaaa"
"""
})
assert path
result = cmd('all')
assert result
|
# -*- coding: utf-8 -*-
'''
File name: code\comfortable_distance\sol_364.py
Author: Vaidic Joshi
Date created: Oct 20, 2018
Python Version: 3.x
'''
# Solution to Project Euler Problem #364 :: Comfortable distance
#
# For more information see:
# https://projecteuler.net/problem=364
# Problem Statement
'''
There are N seats in a row. N people come after each other to fill the seats according to the following rules:
If there is any seat whose adjacent seat(s) are not occupied take such a seat.
If there is no such seat and there is any seat for which only one adjacent seat is occupied take such a seat.
Otherwise take one of the remaining available seats.
Let T(N) be the number of possibilities that N seats are occupied by N people with the given rules. The following figure shows T(4)=8.
We can verify that T(10) = 61632 and T(1 000) mod 100 000 007 = 47255094.
Find T(1 000 000) mod 100 000 007.
'''
# Solution
# Solution Approach
'''
'''
|
class Water():
regions = None
outline_points = None
def __init__(self):
self.regions = []
self.outline_points = [] |
1
"test"
"equality" == "equality"
1.5 * 10
int |
class Classe:
atributo_da_classe = 0
print(Classe.atributo_da_classe)
Classe.atributo_da_classe = 5
print(Classe.atributo_da_classe)
|
# 917. Reverse Only Letters
def reverseOnlyLetters(S):
def isLetter(c):
if (ord(c) >= 65 and ord(c) < 91) or (ord(c) >= 97 and ord(c) < 123):
return True
return False
A = list(S)
i, j = 0, len(A) - 1
while i < j:
if isLetter(A[i]) and isLetter(A[j]):
A[i], A[j] = A[j], A[i]
i = i + 1
j = j - 1
if not isLetter(A[i]):
i = i + 1
if not isLetter(A[j]):
j = j - 1
return ''.join(A)
print(reverseOnlyLetters("a-bC-dEf-ghIj"))
def reverseOnlyLetters2(S):
letter = [c for c in S if c.isalpha()]
ans = []
for c in S:
if c.isalpha():
ans.append(letter.pop())
else:
ans.append(c)
return ''.join(ans)
def reverseOnlyLetters3(S):
ans = []
j = len(S) - 1
for i, c in enumerate(S):
if c.isalpha():
while not S[j].isalpha():
j -= 1
ans.append(S[j])
j -= 1
else:
ans.append(c)
return ''.join(ans)
|
a=str(input('Enter string'))
if(a==a[::-1]):
print('palindrome')
else:
print('not a palindrome')
|
#
# PySNMP MIB module CTRON-SSR-SMI-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CTRON-SSR-SMI-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:15:44 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
Integer, ObjectIdentifier, OctetString = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueRangeConstraint, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueRangeConstraint", "ValueSizeConstraint")
cabletron, = mibBuilder.importSymbols("CTRON-OIDS", "cabletron")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
Counter32, MibScalar, MibTable, MibTableRow, MibTableColumn, ModuleIdentity, iso, Gauge32, Bits, Unsigned32, ObjectIdentity, NotificationType, TimeTicks, Counter64, IpAddress, Integer32, MibIdentifier = mibBuilder.importSymbols("SNMPv2-SMI", "Counter32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ModuleIdentity", "iso", "Gauge32", "Bits", "Unsigned32", "ObjectIdentity", "NotificationType", "TimeTicks", "Counter64", "IpAddress", "Integer32", "MibIdentifier")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
ssr = ModuleIdentity((1, 3, 6, 1, 4, 1, 52, 2501))
ssr.setRevisions(('2000-07-15 00:00',))
if mibBuilder.loadTexts: ssr.setLastUpdated('200007150000Z')
if mibBuilder.loadTexts: ssr.setOrganization('Cabletron Systems, Inc')
ssrMibs = ObjectIdentity((1, 3, 6, 1, 4, 1, 52, 2501, 1))
if mibBuilder.loadTexts: ssrMibs.setStatus('current')
ssrTraps = ObjectIdentity((1, 3, 6, 1, 4, 1, 52, 2501, 10))
if mibBuilder.loadTexts: ssrTraps.setStatus('current')
mibBuilder.exportSymbols("CTRON-SSR-SMI-MIB", PYSNMP_MODULE_ID=ssr, ssr=ssr, ssrTraps=ssrTraps, ssrMibs=ssrMibs)
|
PROCESSOR_VERSION = "0.7.0"
# Entities
AREAS = "areas"
CAMERAS = "cameras"
ALL_AREAS = "ALL"
# Metrics
OCCUPANCY = "occupancy"
SOCIAL_DISTANCING = "social-distancing"
FACEMASK_USAGE = "facemask-usage"
IN_OUT = "in-out"
DWELL_TIME = "dwell-time"
|
print('Digite um número entre 1 e 7, para ver o dia da semana')
diaSemana = ['1-Domingo', '2-Segunda-feira', '3-Terça-feira', '4-Quarta-feira', '5-Quinta-feira', '6-Sexta-feira', '7-Sábado']
dia = int(input('Número: '))
if 1 < dia < 7:
print('Dia da semana inválido')
else:
print(f'O dia da semana é: {diaSemana[dia - 1]}') |
class Solution(object):
def climbStairs(self, n):
"""
:type n: int
:rtype: int
"""
if n == 1:
return 1
if n == 2:
return 2
a = 1
b = 2
for i in range(3, n + 1):
c = a + b
a = b
b = c
return c
|
'''
URL: https://leetcode.com/problems/delete-columns-to-make-sorted/
Difficulty: Easy
Description: Delete Columns to Make Sorted
We are given an array A of N lowercase letter strings, all of the same length.
Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices.
For example, if we have an array A = ["abcdef","uvwxyz"] and deletion indices {0, 2, 3}, then the final array after deletions is ["bef", "vyz"], and the remaining columns of A are ["b","v"], ["e","y"], and ["f","z"]. (Formally, the c-th column is [A[0][c], A[1][c], ..., A[A.length-1][c]]).
Suppose we chose a set of deletion indices D such that after deletions, each remaining column in A is in non-decreasing sorted order.
Return the minimum possible value of D.length.
Example 1:
Input: A = ["cba","daf","ghi"]
Output: 1
Explanation:
After choosing D = {1}, each column ["c","d","g"] and ["a","f","i"] are in non-decreasing sorted order.
If we chose D = {}, then a column ["b","a","h"] would not be in non-decreasing sorted order.
Example 2:
Input: A = ["a","b"]
Output: 0
Explanation: D = {}
Example 3:
Input: A = ["zyx","wvu","tsr"]
Output: 3
Explanation: D = {0, 1, 2}
Constraints:
1 <= A.length <= 100
1 <= A[i].length <= 1000
'''
class Solution:
def minDeletionSize(self, A):
if len(A[0]) == 1:
return 0
count = 0
for i in range(len(A[0])):
for j in range(len(A)-1):
if A[j][i] > A[j+1][i]:
count += 1
break
return count
|
ACTIVE_CLASS = 'active'
SELECTED_CLASS = 'selected'
class MenuItem:
def __init__(self, label, url, css_classes='', submenu=None):
self.label = label
self.url = url
self.css_classes = css_classes
self.submenu = submenu
def status_class(self, request):
css_class = ''
if self.url == request.path:
css_class = ACTIVE_CLASS
if (
self.url != '/' and
self.url in request.path and
not self.url == request.path
):
css_class = SELECTED_CLASS
return css_class
def get_css_classes(self):
return self.css_classes
def get_all_css_classes(self, request):
return '%s %s' % \
(self.get_css_classes(), self.status_class(request))
|
class Hyparams:
user_count= 192403
item_count= 63001
cate_count= 801
predict_batch_size = 120
predict_ads_num = 100
batch_size = 128
hidden_units = 64
train_batch_size = 32
test_batch_size = 512
predict_batch_size = 32
predict_users_num = 1000
predict_ads_num = 100
save_dir = './save_path_fancy' |
'''
Created on 1.12.2016
@author: Darren
''''''
Follow up for problem "Populating Next Right Pointers in Each Node".
What if the given tree could be any binary tree? Would your previous solution still work?
Note:
You may only use constant extra space.
For example,
Given the following binary tree,
1
/ \
2 3
/ \ \
4 5 7
After calling your function, the tree should look like:
1 -> NULL
/ \
2 -> 3 -> NULL
/ \ \
4-> 5 -> 7 -> NULL
"
'''
|
def set_template(args):
# task category
args.task = 'VideoBDE'
# network parameters
args.n_feat = 32
# loss
args.loss = '1*L1+2*HEM'
# learning rata strategy
args.lr = 1e-4
args.lr_decay = 100
args.gamma = 0.1
# data parameters
args.data_train = 'SDR4K'
args.data_test = 'SDR4K'
args.n_sequence = 3
args.n_frames_per_video = 100
args.rgb_range = 65535
args.size_must_mode = 4
args.patch_size = 256
args.dir_data = "/home/medialab/workspace/hdd/zhen/EDVR/datasets/SDR4k/train/"
args.dir_data_test = "/home/medialab/workspace/hdd/zhen/EDVR/datasets/SDR4k/val/"
args.lbd = 4
args.hbd = 16
# train
args.epochs = 500
# test
args.test_every = 1000
args.print_every = 10
if args.template == 'CDVD_TSP':
args.model = "CDVD_TSP"
args.n_sequence = 5
args.n_resblock = 3
args.lr_decay = 200
elif args.template == 'VBDE':
args.model = 'VBDE'
args.n_resblock = 2
elif args.template == 'VBDE_DOWNFLOW':
args.model = 'VBDE_DOWNFLOW'
args.n_resblock = 3
args.lr_decay = 200
elif args.template == 'VBDE_QM':
args.model = 'VBDE_QM'
args.n_resblock = 3
args.lr_decay = 200
# bit-depth parameters
args.low_bitdepth = 4
args.high_bitdepth = 16
elif args.template == 'VBDE_LAP':
args.model = 'VBDE_LAP'
args.n_resblock = 3
args.lr_decay = 50
elif args.template == 'MOTION_NET':
args.task = 'OpticalFlow'
args.model = 'MOTION_NET'
args.n_sequence = 2
args.size_must_mode = 32
args.loss = '1*MNL'
# small learning rate for training optical flow
args.lr = 1e-5
args.lr_decay = 200
args.gamma = 0.5
args.data_train = 'SDR4K_FLOW'
args.data_test = 'SDR4K_FLOW'
args.video_samples = 500
elif args.template == 'C3D':
args.task = 'VideoBDE'
args.model = 'C3D'
args.n_resblock = 3
args.loss = '1*L1+2*HEM+0.1*QCC'
elif args.template == 'HYBRID_C3D':
args.model = 'HYBRID_C3D'
args.n_resblock = 4
args.scheduler = 'plateau'
else:
raise NotImplementedError('Template [{:s}] is not found'.format(args.template))
|
"""
Write a program by the following:
1. Define a function that accepts a string and prints every other word
2. Define a function that accepts a string and translates it into pig latin
3. If time, implement them into a main loop
""" |
#
# PySNMP MIB module UNCDZ-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/UNCDZ-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:28:43 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsIntersection, ValueSizeConstraint, SingleValueConstraint, ValueRangeConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueSizeConstraint", "SingleValueConstraint", "ValueRangeConstraint", "ConstraintsUnion")
NotificationGroup, ModuleCompliance, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup")
sysName, sysContact, sysLocation = mibBuilder.importSymbols("SNMPv2-MIB", "sysName", "sysContact", "sysLocation")
iso, NotificationType, Bits, MibScalar, MibTable, MibTableRow, MibTableColumn, IpAddress, MibIdentifier, Integer32, Counter64, TimeTicks, Unsigned32, enterprises, Gauge32, ModuleIdentity, ObjectIdentity, Counter32 = mibBuilder.importSymbols("SNMPv2-SMI", "iso", "NotificationType", "Bits", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "IpAddress", "MibIdentifier", "Integer32", "Counter64", "TimeTicks", "Unsigned32", "enterprises", "Gauge32", "ModuleIdentity", "ObjectIdentity", "Counter32")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
uncdz_MIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 9839, 2, 1)).setLabel("uncdz-MIB")
uncdz_MIB.setRevisions(('2004-08-12 15:52',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts: uncdz_MIB.setRevisionsDescriptions(('This is the original version of the MIB.',))
if mibBuilder.loadTexts: uncdz_MIB.setLastUpdated('200408121552Z')
if mibBuilder.loadTexts: uncdz_MIB.setOrganization('CAREL SpA')
if mibBuilder.loadTexts: uncdz_MIB.setContactInfo(" Simone Ravazzolo Carel SpA Via dell'Industria, 11 35020 Brugine (PD) Italy Tel: +39 049 9716611 E-mail: [email protected] ")
if mibBuilder.loadTexts: uncdz_MIB.setDescription('This is the MIB module for the UNIFLAIR UNCDZ device.')
carel = MibIdentifier((1, 3, 6, 1, 4, 1, 9839))
systm = MibIdentifier((1, 3, 6, 1, 4, 1, 9839, 1))
agentRelease = MibScalar((1, 3, 6, 1, 4, 1, 9839, 1, 1), Integer32()).setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: agentRelease.setStatus('current')
if mibBuilder.loadTexts: agentRelease.setDescription('Release of the Agent.')
agentCode = MibScalar((1, 3, 6, 1, 4, 1, 9839, 1, 2), Integer32()).setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: agentCode.setStatus('current')
if mibBuilder.loadTexts: agentCode.setDescription('Code of the Agent. 2=pCOWeb.')
instruments = MibIdentifier((1, 3, 6, 1, 4, 1, 9839, 2))
pCOWebInfo = MibIdentifier((1, 3, 6, 1, 4, 1, 9839, 2, 0))
pCOStatusgroup = MibIdentifier((1, 3, 6, 1, 4, 1, 9839, 2, 0, 10))
pCOId1_Status = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 0, 10, 1), Integer32()).setLabel("pCOId1-Status").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: pCOId1_Status.setStatus('current')
if mibBuilder.loadTexts: pCOId1_Status.setDescription('Status of pCOId1. 0=Offline, 1=Init, 2=Online')
pCOErrorsNumbergroup = MibIdentifier((1, 3, 6, 1, 4, 1, 9839, 2, 0, 11))
pCOId1_ErrorsNumber = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 0, 11, 1), Integer32()).setLabel("pCOId1-ErrorsNumber").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: pCOId1_ErrorsNumber.setStatus('current')
if mibBuilder.loadTexts: pCOId1_ErrorsNumber.setDescription('Number of Communication Errors from pCOId1 to pCOWeb.')
digitalObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1))
vent_on = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 1), Integer32()).setLabel("vent-on").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: vent_on.setStatus('current')
if mibBuilder.loadTexts: vent_on.setDescription('System On (Fan)')
compressore1 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 2), Integer32()).setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: compressore1.setStatus('current')
if mibBuilder.loadTexts: compressore1.setDescription('Compressor 1')
compressore2 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 3), Integer32()).setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: compressore2.setStatus('current')
if mibBuilder.loadTexts: compressore2.setDescription('Compressor 2')
compressore3 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 4), Integer32()).setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: compressore3.setStatus('current')
if mibBuilder.loadTexts: compressore3.setDescription('Compressor 3')
compressore4 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 5), Integer32()).setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: compressore4.setStatus('current')
if mibBuilder.loadTexts: compressore4.setDescription('Compressor 4')
out_h1 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 6), Integer32()).setLabel("out-h1").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: out_h1.setStatus('current')
if mibBuilder.loadTexts: out_h1.setDescription('Heating 1')
out_h2 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 7), Integer32()).setLabel("out-h2").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: out_h2.setStatus('current')
if mibBuilder.loadTexts: out_h2.setDescription('Heating 2')
out_h3 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 8), Integer32()).setLabel("out-h3").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: out_h3.setStatus('current')
if mibBuilder.loadTexts: out_h3.setDescription('Heating 3')
gas_caldo_on = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 9), Integer32()).setLabel("gas-caldo-on").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: gas_caldo_on.setStatus('current')
if mibBuilder.loadTexts: gas_caldo_on.setDescription('Hot Gas Coil')
on_deum = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 10), Integer32()).setLabel("on-deum").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: on_deum.setStatus('current')
if mibBuilder.loadTexts: on_deum.setDescription('Dehumidification')
power = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 11), Integer32()).setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: power.setStatus('current')
if mibBuilder.loadTexts: power.setDescription('Humidification')
mal_access = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 12), Integer32()).setLabel("mal-access").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_access.setStatus('current')
if mibBuilder.loadTexts: mal_access.setDescription('Tampering Alarm')
mal_ata = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 13), Integer32()).setLabel("mal-ata").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_ata.setStatus('current')
if mibBuilder.loadTexts: mal_ata.setDescription('Alarm: Room High Temperature')
mal_bta = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 14), Integer32()).setLabel("mal-bta").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_bta.setStatus('current')
if mibBuilder.loadTexts: mal_bta.setDescription('Alarm: Room Low Temperature')
mal_aua = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 15), Integer32()).setLabel("mal-aua").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_aua.setStatus('current')
if mibBuilder.loadTexts: mal_aua.setDescription('Alarm: Room High Humidity')
mal_bua = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 16), Integer32()).setLabel("mal-bua").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_bua.setStatus('current')
if mibBuilder.loadTexts: mal_bua.setDescription('Alarm: Room Low Humidity')
mal_eap = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 17), Integer32()).setLabel("mal-eap").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_eap.setStatus('current')
if mibBuilder.loadTexts: mal_eap.setDescription('Alarm: Room High/Low Temp./Humid.(Ext. Devices)')
mal_filter = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 18), Integer32()).setLabel("mal-filter").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_filter.setStatus('current')
if mibBuilder.loadTexts: mal_filter.setDescription('Alarm: Clogged Filter')
mal_flood = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 19), Integer32()).setLabel("mal-flood").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_flood.setStatus('current')
if mibBuilder.loadTexts: mal_flood.setDescription('Alarm: Water Leakage Detected')
mal_flux = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 20), Integer32()).setLabel("mal-flux").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_flux.setStatus('current')
if mibBuilder.loadTexts: mal_flux.setDescription('Alarm: Loss of Air Flow')
mal_heater = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 21), Integer32()).setLabel("mal-heater").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_heater.setStatus('current')
if mibBuilder.loadTexts: mal_heater.setDescription('Alarm: Heater Overheating')
mal_hp1 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 22), Integer32()).setLabel("mal-hp1").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_hp1.setStatus('current')
if mibBuilder.loadTexts: mal_hp1.setDescription('Alarm: High Pressure 1')
mal_hp2 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 23), Integer32()).setLabel("mal-hp2").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_hp2.setStatus('current')
if mibBuilder.loadTexts: mal_hp2.setDescription('Alarm: High Pressure 2')
mal_lp1 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 24), Integer32()).setLabel("mal-lp1").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_lp1.setStatus('current')
if mibBuilder.loadTexts: mal_lp1.setDescription('Alarm: Low Pressure 1')
mal_lp2 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 25), Integer32()).setLabel("mal-lp2").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_lp2.setStatus('current')
if mibBuilder.loadTexts: mal_lp2.setDescription('Alarm: Low Pressure 2')
mal_phase = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 26), Integer32()).setLabel("mal-phase").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_phase.setStatus('current')
if mibBuilder.loadTexts: mal_phase.setDescription('Alarm: Wrong phase sequence')
mal_smoke = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 27), Integer32()).setLabel("mal-smoke").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_smoke.setStatus('current')
if mibBuilder.loadTexts: mal_smoke.setDescription('Alarm: SMOKE-FIRE DETECTED')
mal_lan = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 28), Integer32()).setLabel("mal-lan").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_lan.setStatus('current')
if mibBuilder.loadTexts: mal_lan.setDescription('Alarm: Interrupted LAN')
mal_hcurr = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 29), Integer32()).setLabel("mal-hcurr").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_hcurr.setStatus('current')
if mibBuilder.loadTexts: mal_hcurr.setDescription('Humidifier Alarm: High Current')
mal_nopower = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 30), Integer32()).setLabel("mal-nopower").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_nopower.setStatus('current')
if mibBuilder.loadTexts: mal_nopower.setDescription('Humidifier Alarm: Power Loss')
mal_nowater = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 31), Integer32()).setLabel("mal-nowater").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_nowater.setStatus('current')
if mibBuilder.loadTexts: mal_nowater.setDescription('Humidifier Alarm: Water Loss')
mal_cw_dh = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 32), Integer32()).setLabel("mal-cw-dh").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_cw_dh.setStatus('current')
if mibBuilder.loadTexts: mal_cw_dh.setDescription('Alarm: Chilled Water Temp. too High for Dehumidification')
mal_tc_cw = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 33), Integer32()).setLabel("mal-tc-cw").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_tc_cw.setStatus('current')
if mibBuilder.loadTexts: mal_tc_cw.setDescription('Alarm: CW Valve Failure or Water Flow too Low')
mal_wflow = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 34), Integer32()).setLabel("mal-wflow").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_wflow.setStatus('current')
if mibBuilder.loadTexts: mal_wflow.setDescription('Alarm: Loss of Water flow')
mal_wht = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 35), Integer32()).setLabel("mal-wht").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_wht.setStatus('current')
if mibBuilder.loadTexts: mal_wht.setDescription('Alarm: High chilled water temp.')
mal_sonda_ta = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 36), Integer32()).setLabel("mal-sonda-ta").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_sonda_ta.setStatus('current')
if mibBuilder.loadTexts: mal_sonda_ta.setDescription('Alarm: Room air Sensor Failure/Disconnected')
mal_sonda_tac = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 37), Integer32()).setLabel("mal-sonda-tac").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_sonda_tac.setStatus('current')
if mibBuilder.loadTexts: mal_sonda_tac.setDescription('Alarm: Hot water Sensor Failure/Disconnected')
mal_sonda_tc = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 38), Integer32()).setLabel("mal-sonda-tc").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_sonda_tc.setStatus('current')
if mibBuilder.loadTexts: mal_sonda_tc.setDescription('Alarm: Condensing water Sensor Failure/Disconnect.')
mal_sonda_te = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 39), Integer32()).setLabel("mal-sonda-te").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_sonda_te.setStatus('current')
if mibBuilder.loadTexts: mal_sonda_te.setDescription('Alarm: Outdoor temp. Sensor Failure/Disconnected')
mal_sonda_tm = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 40), Integer32()).setLabel("mal-sonda-tm").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_sonda_tm.setStatus('current')
if mibBuilder.loadTexts: mal_sonda_tm.setDescription('Alarm: Delivery temp. Sensor Failure/Disconnected')
mal_sonda_ua = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 41), Integer32()).setLabel("mal-sonda-ua").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_sonda_ua.setStatus('current')
if mibBuilder.loadTexts: mal_sonda_ua.setDescription('Alarm: Rel. Humidity Sensor Failure/Disconnected')
mal_ore_compr1 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 42), Integer32()).setLabel("mal-ore-compr1").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_ore_compr1.setStatus('current')
if mibBuilder.loadTexts: mal_ore_compr1.setDescription('Service Alarm: Compressor 1 hour counter threshold')
mal_ore_compr2 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 43), Integer32()).setLabel("mal-ore-compr2").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_ore_compr2.setStatus('current')
if mibBuilder.loadTexts: mal_ore_compr2.setDescription('Service Alarm: Compressor 2 hour counter threshold')
mal_ore_compr3 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 44), Integer32()).setLabel("mal-ore-compr3").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_ore_compr3.setStatus('current')
if mibBuilder.loadTexts: mal_ore_compr3.setDescription('Service Alarm: Compressor 3 hour counter threshold')
mal_ore_compr4 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 45), Integer32()).setLabel("mal-ore-compr4").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_ore_compr4.setStatus('current')
if mibBuilder.loadTexts: mal_ore_compr4.setDescription('Service Alarm: Compressor 4 hour counter threshold')
mal_ore_filtro = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 46), Integer32()).setLabel("mal-ore-filtro").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_ore_filtro.setStatus('current')
if mibBuilder.loadTexts: mal_ore_filtro.setDescription('Service Alarm: Air Filter hour counter threshold')
mal_ore_risc1 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 47), Integer32()).setLabel("mal-ore-risc1").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_ore_risc1.setStatus('current')
if mibBuilder.loadTexts: mal_ore_risc1.setDescription('Service Alarm: Heater 1 hour counter threshold')
mal_ore_risc2 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 48), Integer32()).setLabel("mal-ore-risc2").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_ore_risc2.setStatus('current')
if mibBuilder.loadTexts: mal_ore_risc2.setDescription('Service Alarm: Heater 2 hour counter threshold')
mal_ore_umid = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 49), Integer32()).setLabel("mal-ore-umid").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_ore_umid.setStatus('current')
if mibBuilder.loadTexts: mal_ore_umid.setDescription('Service Alarm: Humidifier hour counter threshold')
mal_ore_unit = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 50), Integer32()).setLabel("mal-ore-unit").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: mal_ore_unit.setStatus('current')
if mibBuilder.loadTexts: mal_ore_unit.setDescription('Service Alarm: Unit hour counter threshold')
glb_al = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 51), Integer32()).setLabel("glb-al").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: glb_al.setStatus('current')
if mibBuilder.loadTexts: glb_al.setDescription('General Alarm')
or_al_2lev = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 52), Integer32()).setLabel("or-al-2lev").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: or_al_2lev.setStatus('current')
if mibBuilder.loadTexts: or_al_2lev.setDescription('2nd Level Alarm')
range_t_ext = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 53), Integer32()).setLabel("range-t-ext").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: range_t_ext.setStatus('current')
if mibBuilder.loadTexts: range_t_ext.setDescription('Outdoor Temp. Sensor Fitted')
range_t_circ = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 54), Integer32()).setLabel("range-t-circ").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: range_t_circ.setStatus('current')
if mibBuilder.loadTexts: range_t_circ.setDescription('Closed Circuit (or Chilled) Water Temperature Sensor Fitted')
range_t_man = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 55), Integer32()).setLabel("range-t-man").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: range_t_man.setStatus('current')
if mibBuilder.loadTexts: range_t_man.setDescription('Delivery Temp. Sensor Fitted')
range_t_ac = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 56), Integer32()).setLabel("range-t-ac").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: range_t_ac.setStatus('current')
if mibBuilder.loadTexts: range_t_ac.setDescription('Hot water temp. Sensor Fitted')
umid_al = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 57), Integer32()).setLabel("umid-al").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: umid_al.setStatus('current')
if mibBuilder.loadTexts: umid_al.setDescription('Humidifier general alarm')
range_u_amb = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 58), Integer32()).setLabel("range-u-amb").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: range_u_amb.setStatus('current')
if mibBuilder.loadTexts: range_u_amb.setDescription('Relative Humidity Sensor Fitted')
k_syson = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 60), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 1))).setLabel("k-syson").setUnits('N/A').setMaxAccess("readwrite")
if mibBuilder.loadTexts: k_syson.setStatus('current')
if mibBuilder.loadTexts: k_syson.setDescription('Unit Remote Switch-On/Off Control')
xs_res_al = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 61), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 1))).setLabel("xs-res-al").setUnits('N/A').setMaxAccess("readwrite")
if mibBuilder.loadTexts: xs_res_al.setStatus('current')
if mibBuilder.loadTexts: xs_res_al.setDescription('Buzzer and Alarm Remote Reset Control')
sleep_mode = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 63), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 1))).setLabel("sleep-mode").setUnits('N/A').setMaxAccess("readwrite")
if mibBuilder.loadTexts: sleep_mode.setStatus('current')
if mibBuilder.loadTexts: sleep_mode.setDescription('Set Back Mode (Sleep Mode)')
test_sm = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 64), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 1))).setLabel("test-sm").setUnits('N/A').setMaxAccess("readwrite")
if mibBuilder.loadTexts: test_sm.setStatus('current')
if mibBuilder.loadTexts: test_sm.setDescription('Set Back mode: Cyclical Start of Fan')
ab_mediath = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 65), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 1))).setLabel("ab-mediath").setUnits('N/A').setMaxAccess("readwrite")
if mibBuilder.loadTexts: ab_mediath.setStatus('current')
if mibBuilder.loadTexts: ab_mediath.setDescription('Usage of T+ H Values: Local (0) / Mean (1)')
ustdby1_2 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 66), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 1))).setLabel("ustdby1-2").setUnits('N/A').setMaxAccess("readwrite")
if mibBuilder.loadTexts: ustdby1_2.setStatus('current')
if mibBuilder.loadTexts: ustdby1_2.setDescription('No. Of Stand-by Units: one (0) / two (1)')
emerg = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 67), Integer32()).setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: emerg.setStatus('current')
if mibBuilder.loadTexts: emerg.setDescription('Unit in Emergency operation')
analogObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2))
temp_amb = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 1), Integer32()).setLabel("temp-amb").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: temp_amb.setStatus('current')
if mibBuilder.loadTexts: temp_amb.setDescription('Room Temperature')
temp_ext = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 2), Integer32()).setLabel("temp-ext").setUnits('deg.C x 10').setMaxAccess("readonly")
if mibBuilder.loadTexts: temp_ext.setStatus('current')
if mibBuilder.loadTexts: temp_ext.setDescription('Outdoor Temperature')
temp_mand = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 3), Integer32()).setLabel("temp-mand").setUnits('deg.C x 10').setMaxAccess("readonly")
if mibBuilder.loadTexts: temp_mand.setStatus('current')
if mibBuilder.loadTexts: temp_mand.setDescription('Delivery Air Temperature')
temp_circ = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 4), Integer32()).setLabel("temp-circ").setUnits('deg.C x 10').setMaxAccess("readonly")
if mibBuilder.loadTexts: temp_circ.setStatus('current')
if mibBuilder.loadTexts: temp_circ.setDescription('Closed Circuit (or Chilled) Water Temperature')
temp_ac = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 5), Integer32()).setLabel("temp-ac").setUnits('deg.C x 10').setMaxAccess("readonly")
if mibBuilder.loadTexts: temp_ac.setStatus('current')
if mibBuilder.loadTexts: temp_ac.setDescription('Hot Water Temperature')
umid_amb = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 6), Integer32()).setLabel("umid-amb").setUnits('rH% x 10').setMaxAccess("readonly")
if mibBuilder.loadTexts: umid_amb.setStatus('current')
if mibBuilder.loadTexts: umid_amb.setDescription('Room Relative Humidity')
t_set = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 7), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-set").setUnits('deg.C x 10').setMaxAccess("readwrite")
if mibBuilder.loadTexts: t_set.setStatus('current')
if mibBuilder.loadTexts: t_set.setDescription('Cooling Set Point')
t_diff = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-diff").setUnits('deg.C x 10').setMaxAccess("readwrite")
if mibBuilder.loadTexts: t_diff.setStatus('current')
if mibBuilder.loadTexts: t_diff.setDescription('Cooling Prop.Band')
t_set_c = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-set-c").setUnits('deg.C x 10').setMaxAccess("readwrite")
if mibBuilder.loadTexts: t_set_c.setStatus('current')
if mibBuilder.loadTexts: t_set_c.setDescription('Heating Set point')
t_diff_c = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 10), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-diff-c").setUnits('deg.C x 10').setMaxAccess("readwrite")
if mibBuilder.loadTexts: t_diff_c.setStatus('current')
if mibBuilder.loadTexts: t_diff_c.setDescription('Heating Prop.Band')
ht_set = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 11), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("ht-set").setUnits('deg.C').setMaxAccess("readwrite")
if mibBuilder.loadTexts: ht_set.setStatus('current')
if mibBuilder.loadTexts: ht_set.setDescription('Room High Temp. Alarm Threshold')
lt_set = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 12), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("lt-set").setUnits('deg.C').setMaxAccess("readwrite")
if mibBuilder.loadTexts: lt_set.setStatus('current')
if mibBuilder.loadTexts: lt_set.setDescription('Room Low Temp. Alarm Threshold')
t_set_sm = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 13), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-set-sm").setUnits('N/A').setMaxAccess("readwrite")
if mibBuilder.loadTexts: t_set_sm.setStatus('current')
if mibBuilder.loadTexts: t_set_sm.setDescription('Setback Mode: Cooling Set Point')
t_set_c_sm = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 14), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-set-c-sm").setUnits('N/A').setMaxAccess("readwrite")
if mibBuilder.loadTexts: t_set_c_sm.setStatus('current')
if mibBuilder.loadTexts: t_set_c_sm.setDescription('Setback Mode: Heating Set Point')
t_cw_dh = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 15), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-cw-dh").setUnits('N/A').setMaxAccess("readwrite")
if mibBuilder.loadTexts: t_cw_dh.setStatus('current')
if mibBuilder.loadTexts: t_cw_dh.setDescription('CW Set Point to Start Dehumidification Cycle')
htset_cw = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 16), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("htset-cw").setUnits('N/A').setMaxAccess("readwrite")
if mibBuilder.loadTexts: htset_cw.setStatus('current')
if mibBuilder.loadTexts: htset_cw.setDescription('CW High Temperature Alarm Threshold')
t_set_cw = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 17), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-set-cw").setUnits('N/A').setMaxAccess("readwrite")
if mibBuilder.loadTexts: t_set_cw.setStatus('current')
if mibBuilder.loadTexts: t_set_cw.setDescription('CW Set Point to Start CW Operating Mode (TC only)')
t_rc_es = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 18), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-rc-es").setUnits('N/A').setMaxAccess("readwrite")
if mibBuilder.loadTexts: t_rc_es.setStatus('current')
if mibBuilder.loadTexts: t_rc_es.setDescription('Rad-cooler Set Point in E.S. Mode (ES Only)')
t_rc_est = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 19), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-rc-est").setUnits('N/A').setMaxAccess("readwrite")
if mibBuilder.loadTexts: t_rc_est.setStatus('current')
if mibBuilder.loadTexts: t_rc_est.setDescription('Rad-cooler Set Point in DX Mode (ES Only)')
rampa_valv = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 20), Integer32()).setLabel("rampa-valv").setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: rampa_valv.setStatus('current')
if mibBuilder.loadTexts: rampa_valv.setDescription('0-10V Ramp 1 Value (CW Valve Ramp)')
anaout2 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 21), Integer32()).setUnits('N/A').setMaxAccess("readonly")
if mibBuilder.loadTexts: anaout2.setStatus('current')
if mibBuilder.loadTexts: anaout2.setDescription('0-10V Ramp 2 Value (HW Valve/Rad Cooler Ramp)')
steam_production = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 22), Integer32()).setLabel("steam-production").setUnits('kg/h x 10').setMaxAccess("readonly")
if mibBuilder.loadTexts: steam_production.setStatus('current')
if mibBuilder.loadTexts: steam_production.setDescription('Humidifier: steam capacity')
t_set_lm = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 23), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-set-lm").setUnits('deg.C').setMaxAccess("readwrite")
if mibBuilder.loadTexts: t_set_lm.setStatus('current')
if mibBuilder.loadTexts: t_set_lm.setDescription('Delivery Air Temperature Limit Set Point ')
delta_lm = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 24), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("delta-lm").setUnits('deg.C x 10').setMaxAccess("readwrite")
if mibBuilder.loadTexts: delta_lm.setStatus('current')
if mibBuilder.loadTexts: delta_lm.setDescription('T+H Values: Mean/Local Diff. (aut. Changeover)')
integerObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3))
ore_filtro = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 1), Integer32()).setLabel("ore-filtro").setUnits('h').setMaxAccess("readonly")
if mibBuilder.loadTexts: ore_filtro.setStatus('current')
if mibBuilder.loadTexts: ore_filtro.setDescription('Air Filter Working Houres')
ore_unit = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 2), Integer32()).setLabel("ore-unit").setUnits('h').setMaxAccess("readonly")
if mibBuilder.loadTexts: ore_unit.setStatus('current')
if mibBuilder.loadTexts: ore_unit.setDescription('Unit Working Houres')
ore_compr1 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 3), Integer32()).setLabel("ore-compr1").setUnits('h').setMaxAccess("readonly")
if mibBuilder.loadTexts: ore_compr1.setStatus('current')
if mibBuilder.loadTexts: ore_compr1.setDescription('Compressor 1 Working Houres')
ore_compr2 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 4), Integer32()).setLabel("ore-compr2").setUnits('h').setMaxAccess("readonly")
if mibBuilder.loadTexts: ore_compr2.setStatus('current')
if mibBuilder.loadTexts: ore_compr2.setDescription('Compressor 2 Working Houres')
ore_compr3 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 5), Integer32()).setLabel("ore-compr3").setUnits('h').setMaxAccess("readonly")
if mibBuilder.loadTexts: ore_compr3.setStatus('current')
if mibBuilder.loadTexts: ore_compr3.setDescription('Compressor 3 Working Houres')
ore_compr4 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 6), Integer32()).setLabel("ore-compr4").setUnits('h').setMaxAccess("readonly")
if mibBuilder.loadTexts: ore_compr4.setStatus('current')
if mibBuilder.loadTexts: ore_compr4.setDescription('Compressor 4 Working Houres')
ore_heat1 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 7), Integer32()).setLabel("ore-heat1").setUnits('h').setMaxAccess("readonly")
if mibBuilder.loadTexts: ore_heat1.setStatus('current')
if mibBuilder.loadTexts: ore_heat1.setDescription('Heater 1 Working Houres')
ore_heat2 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 8), Integer32()).setLabel("ore-heat2").setUnits('h').setMaxAccess("readonly")
if mibBuilder.loadTexts: ore_heat2.setStatus('current')
if mibBuilder.loadTexts: ore_heat2.setDescription('Heater 2 Working Houres')
ore_umid = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 9), Integer32()).setLabel("ore-umid").setUnits('h').setMaxAccess("readonly")
if mibBuilder.loadTexts: ore_umid.setStatus('current')
if mibBuilder.loadTexts: ore_umid.setDescription('Humidifier Working Houres')
hdiff = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 12), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setUnits('rH%').setMaxAccess("readwrite")
if mibBuilder.loadTexts: hdiff.setStatus('current')
if mibBuilder.loadTexts: hdiff.setDescription('Dehumidification Proportional Band')
hu_diff = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 13), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("hu-diff").setUnits('rH%').setMaxAccess("readwrite")
if mibBuilder.loadTexts: hu_diff.setStatus('current')
if mibBuilder.loadTexts: hu_diff.setDescription('Humidification Proportional Band')
hh_set = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 14), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("hh-set").setUnits('rH%').setMaxAccess("readwrite")
if mibBuilder.loadTexts: hh_set.setStatus('current')
if mibBuilder.loadTexts: hh_set.setDescription('High Relative Humidity Alarm Threshold')
lh_set = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 15), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("lh-set").setUnits('rH%').setMaxAccess("readwrite")
if mibBuilder.loadTexts: lh_set.setStatus('current')
if mibBuilder.loadTexts: lh_set.setDescription('Low Relative Humidity Alarm Threshold')
hset = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 16), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setUnits('rH%').setMaxAccess("readwrite")
if mibBuilder.loadTexts: hset.setStatus('current')
if mibBuilder.loadTexts: hset.setDescription('Dehumidification Set Point')
hset_sm = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 17), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("hset-sm").setUnits('rH%').setMaxAccess("readwrite")
if mibBuilder.loadTexts: hset_sm.setStatus('current')
if mibBuilder.loadTexts: hset_sm.setDescription('Setback Mode: Dehumidification Set Point')
hu_set = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 18), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("hu-set").setUnits('rH%').setMaxAccess("readwrite")
if mibBuilder.loadTexts: hu_set.setStatus('current')
if mibBuilder.loadTexts: hu_set.setDescription('Humidification Set Point')
hu_set_sm = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 19), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("hu-set-sm").setUnits('rH%').setMaxAccess("readwrite")
if mibBuilder.loadTexts: hu_set_sm.setStatus('current')
if mibBuilder.loadTexts: hu_set_sm.setDescription('Setback Mode: Humidification Set Point')
restart_delay = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 20), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("restart-delay").setUnits('sec').setMaxAccess("readwrite")
if mibBuilder.loadTexts: restart_delay.setStatus('current')
if mibBuilder.loadTexts: restart_delay.setDescription('Restart Delay')
regul_delay = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 21), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("regul-delay").setUnits('sec').setMaxAccess("readwrite")
if mibBuilder.loadTexts: regul_delay.setStatus('current')
if mibBuilder.loadTexts: regul_delay.setDescription('Regulation Start Transitory ')
time_lowp = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 22), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("time-lowp").setUnits('sec').setMaxAccess("readwrite")
if mibBuilder.loadTexts: time_lowp.setStatus('current')
if mibBuilder.loadTexts: time_lowp.setDescription('Low Pressure Delay')
alarm_delay = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 23), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("alarm-delay").setUnits('m').setMaxAccess("readwrite")
if mibBuilder.loadTexts: alarm_delay.setStatus('current')
if mibBuilder.loadTexts: alarm_delay.setDescription('Room T+H Alarm Delay')
exc_time = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 24), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("exc-time").setUnits('m').setMaxAccess("readwrite")
if mibBuilder.loadTexts: exc_time.setStatus('current')
if mibBuilder.loadTexts: exc_time.setDescription('Anti-Hunting Constant of Room Regulation ')
t_std_by = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 25), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-std-by").setUnits('h').setMaxAccess("readwrite")
if mibBuilder.loadTexts: t_std_by.setStatus('current')
if mibBuilder.loadTexts: t_std_by.setDescription('Stand-by Cycle Base Time')
lan_unit = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 27), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("lan-unit").setUnits('n').setMaxAccess("readwrite")
if mibBuilder.loadTexts: lan_unit.setStatus('current')
if mibBuilder.loadTexts: lan_unit.setDescription('Total of units connected in LAN')
ciclo_sm = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 28), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("ciclo-sm").setUnits('m').setMaxAccess("readwrite")
if mibBuilder.loadTexts: ciclo_sm.setStatus('current')
if mibBuilder.loadTexts: ciclo_sm.setDescription('Set Back Mode: Fan Cyclical Start Interval')
mibBuilder.exportSymbols("UNCDZ-MIB", ore_compr3=ore_compr3, out_h3=out_h3, mal_smoke=mal_smoke, hset_sm=hset_sm, mal_lp1=mal_lp1, regul_delay=regul_delay, vent_on=vent_on, ore_umid=ore_umid, hset=hset, k_syson=k_syson, t_set_cw=t_set_cw, compressore1=compressore1, lh_set=lh_set, ore_filtro=ore_filtro, out_h2=out_h2, sleep_mode=sleep_mode, mal_sonda_tac=mal_sonda_tac, hu_set=hu_set, umid_al=umid_al, pCOStatusgroup=pCOStatusgroup, mal_wht=mal_wht, ore_compr4=ore_compr4, emerg=emerg, steam_production=steam_production, temp_ac=temp_ac, mal_ore_umid=mal_ore_umid, temp_mand=temp_mand, mal_hp2=mal_hp2, mal_ore_compr3=mal_ore_compr3, pCOId1_ErrorsNumber=pCOId1_ErrorsNumber, temp_circ=temp_circ, mal_aua=mal_aua, mal_cw_dh=mal_cw_dh, mal_ore_unit=mal_ore_unit, t_std_by=t_std_by, mal_ore_compr1=mal_ore_compr1, compressore3=compressore3, range_t_ac=range_t_ac, mal_flux=mal_flux, compressore2=compressore2, mal_sonda_ua=mal_sonda_ua, temp_amb=temp_amb, htset_cw=htset_cw, mal_ore_compr4=mal_ore_compr4, ciclo_sm=ciclo_sm, hh_set=hh_set, out_h1=out_h1, pCOId1_Status=pCOId1_Status, mal_eap=mal_eap, time_lowp=time_lowp, mal_phase=mal_phase, pCOWebInfo=pCOWebInfo, t_diff_c=t_diff_c, power=power, ustdby1_2=ustdby1_2, t_diff=t_diff, mal_flood=mal_flood, mal_sonda_tc=mal_sonda_tc, uncdz_MIB=uncdz_MIB, mal_nopower=mal_nopower, ore_heat2=ore_heat2, mal_tc_cw=mal_tc_cw, t_set_c=t_set_c, integerObjects=integerObjects, ore_compr1=ore_compr1, t_set=t_set, t_rc_est=t_rc_est, compressore4=compressore4, carel=carel, t_set_c_sm=t_set_c_sm, ht_set=ht_set, mal_ore_risc2=mal_ore_risc2, hu_diff=hu_diff, mal_access=mal_access, mal_ore_compr2=mal_ore_compr2, digitalObjects=digitalObjects, pCOErrorsNumbergroup=pCOErrorsNumbergroup, alarm_delay=alarm_delay, mal_heater=mal_heater, on_deum=on_deum, mal_lp2=mal_lp2, rampa_valv=rampa_valv, agentCode=agentCode, t_set_lm=t_set_lm, ore_compr2=ore_compr2, mal_hp1=mal_hp1, mal_ata=mal_ata, ab_mediath=ab_mediath, analogObjects=analogObjects, delta_lm=delta_lm, anaout2=anaout2, mal_lan=mal_lan, gas_caldo_on=gas_caldo_on, exc_time=exc_time, mal_ore_filtro=mal_ore_filtro, test_sm=test_sm, systm=systm, umid_amb=umid_amb, PYSNMP_MODULE_ID=uncdz_MIB, mal_bua=mal_bua, hu_set_sm=hu_set_sm, mal_ore_risc1=mal_ore_risc1, ore_unit=ore_unit, lt_set=lt_set, agentRelease=agentRelease, mal_sonda_ta=mal_sonda_ta, ore_heat1=ore_heat1, range_u_amb=range_u_amb, xs_res_al=xs_res_al, glb_al=glb_al, or_al_2lev=or_al_2lev, mal_bta=mal_bta, t_set_sm=t_set_sm, range_t_man=range_t_man, temp_ext=temp_ext, mal_hcurr=mal_hcurr, mal_wflow=mal_wflow, hdiff=hdiff, lan_unit=lan_unit, restart_delay=restart_delay, mal_nowater=mal_nowater, t_cw_dh=t_cw_dh, mal_filter=mal_filter, range_t_circ=range_t_circ, range_t_ext=range_t_ext, mal_sonda_te=mal_sonda_te, mal_sonda_tm=mal_sonda_tm, instruments=instruments, t_rc_es=t_rc_es)
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat May 23 17:49:24 2020
@author: ahmad
"""
x = [5, 9, 8, -8, 7, 8, 10]
#print(x[4])
#for i in range(0,len(x)):
# print(x[i])
# write a code to show the sum og the numbers in the Array
sum = 0
for i in range(0,len(x)):
sum += x[i]
print("array sum = " + str(sum))
# write a code to print the max number in the array
max = x[0]
for i in range(1, len(x)):
if max < x[i]:
max = x[i]
print("array max = " + str(max))
# homework
# write a code to print the min number in the array
# write a code to print the array avg
|
"""
600. Smallest Rectangle Enclosing Black Pixels
https://www.lintcode.com/problem/smallest-rectangle-enclosing-black-pixels/description
九章算法课上的方法
"""
class Solution:
"""
@param image: a binary matrix with '0' and '1'
@param x: the location of one of the black pixels
@param y: the location of one of the black pixels
@return: an integer
"""
def minArea(self, image, x, y):
# write your code here
if not image or not image[0]:
return 0
n = len(image)
m = len(image[0])
left = self.binary_search_first(image, 0, y, self.check_col)
right = self.binary_search_last(image, y, m - 1, self.check_col)
up = self.binary_search_first(image, 0, x, self.check_row)
down = self.binary_search_last(image, x, n - 1, self.check_row)
print(left, right, up, down)
return (right - left + 1) * (down - up + 1)
def binary_search_first(self, image, start, end, check_func):
while start + 1 < end:
mid = (start + end) // 2
if check_func(image, mid):
end = mid
else:
start = mid
if check_func(image, start):
return start
return end
def binary_search_last(self, image, start, end, check_func):
while start + 1 < end:
mid = (start + end) // 2
if check_func(image, mid):
start = mid
else:
end = mid
if check_func(image, end):
return end
return start
def check_row(self, image, mid):
m = len(image[0])
for i in range(m):
if image[mid][i] == '1':
return True
return False
def check_col(self, image, mid):
n = len(image)
for i in range(n):
if image[i][mid] == '1':
return True
return False
|
"""State: Abstract class that
defines the desired state of inventory in a target system"""
class State(object):
def __init__(self):
self.logger = None
self.verify_connectivity()
def verify_connectivity(self):
raise NotImplementedError
def set_logger(self):
raise NotImplementedError
def debug_log(self, log_string):
"""Pass positional logger arguments to a logger.debug method
if a logger instance was instantiated"""
if self.logger is not None:
self.logger.debug(log_string)
def info_log(self, log_string):
"""Pass positional logger arguments to a loger.info method
if a logger instance was instantiated"""
if self.logger is not None:
self.logger.info(log_string)
def __eq__(self, other):
raise NotImplementedError("Method not properly implemented")
def __ne__(self, other):
raise NotImplementedError("Method not properly implemented")
def set_state_from_source(self):
"""Set this state of this instance based on the actual
configuration of the target."""
raise NotImplementedError("Method not properly implemented")
def set_state_from_config_object(other):
"""Set the state of this instance and the actual configuration
at a target based on a another config object as a model."""
raise NotImplementedError("Method not properly implemented") |
class BaseBuilding(object):
"""
boilder-plate class used to initiale the various building in
municipality
"""
def __init__(self, location=None, land_rate=500):
if not isinstance(location, str) and location is not None:
raise TypeError("Location should be of type str")
if not isinstance(land_rate, (float, int, long)):
raise TypeError("Land rate should be of type numeric")
self.__location = location
self.__land_rate = land_rate
def set_location(self, location):
if not isinstance(location, str):
raise TypeError("Location should be of type str")
self.__location = location
def set_land_rate(self, land_rate):
if not isinstance(land_rate, (float, int, long)):
raise TypeError("Land rate should be of type numeric")
self.__land_rate = land_rate
def get_location(self):
return self.__location
def get_land_rate(self):
return self.__land_rate
class CommercialBuilding(BaseBuilding):
"""
This building provides space for offices and warehouses
Land rate is based on the available floor space
"""
def __init__(self, location=None, floor_space=0):
if not isinstance(floor_space, (float, int, long)):
raise TypeError("Floor Space should be of type numeric")
super(self.__class__, self).__init__(location)
self.__floor_space = floor_space
def set_floor_space(self, floor_space):
self.__floor_space = floor_space
def get_floor_space(self):
return self.__floor_space
def get_land_rate(self):
return self.__floor_space * 30
class ResidentialBuilding(BaseBuilding):
"""
This building that provide space for housing
Land rate depends on the numver of availabe units
"""
def __init__(self, location=None, num_units=0):
if not isinstance(num_units, (float, int, long)):
raise TypeError("Land rate should be of type numeric")
super(self.__class__, self).__init__(location)
self.__num_units = num_units
def set_num_units(self, num_units):
self.__num_units == num_units
def get_num_units(self):
return self.__num_units
def get_land_rate(self):
"""land rate = num_unit * 20"""
return self.__num_units * 20
class Utilities(BaseBuilding):
"""
This building are owned by the municipality hence pay
no land rate
"""
def __init__(self, location=None, utility_name=None):
if not isinstance(utility_name, str) and utility_name is not None:
raise TypeError("Utlity hould be of type str")
super(self.__class__, self).__init__(location)
self.__utility_name = utility_name
def set_land_rate(self, land_rate):
raise NotImplementedError("Utility Building owned pay no land rate")
def set_utility(self, utility_name):
self.__utility_name = utility_name
def get_utility(self):
return self.__utility_name
def get_land_rate(self):
return 0
|
"""adds Buffer functionality to Loader"""
class BufferMixin(object):
"""stuff"""
def __init__(self, *args, **kwargs):
"""initializes base data loader"""
super(BufferMixin, self).__init__(*args, **kwargs)
self._buffered_values = None
#set _buffered_values
self._reset_buffered_values()
def load_buffered(self):
"""runs load for BufferedMixin"""
raise NotImplementedError
def flush_buffer(self):
"""helper method to run statement with set buffered values"""
#run statement if there are buffered_values
if self._buffered_values:
self.load_buffered()
self._reset_buffered_values()
def write_to_buffer(self, next_values):
"""appends to buffered values and writes to db when _buffer_size is reached"""
self._buffered_values.append(next_values)
if len(self._buffered_values) >= self.config.get_buffer_size():
self.flush_buffer()
def _reset_buffered_values(self):
"""resets values to empty tuple"""
self._buffered_values = list()
|
'''
Exercício Python 26: Faça um programa que leia uma frase pelo teclado e mostre quantas vezes aparece a letra “A”,
em que posição ela aparece a primeira vez e em que posição ela aparece a última vez.
'''
frase = str(input('Digite uma frase: ')).upper().strip()
print('A letra "A" aparece {} vezes na frase'.format(frase.count('A')))
print('A primeira letra "A" apareceu na posição {}'.format(frase.find('A') + 1))
print('A ultima letra "A" apareceu na posição {}'.format(frase.rfind('A') + 1))
|
NB_GRADER_CONFIG_TEMPLATE = """
c = get_config()
c.CourseDirectory.root = '/home/{grader_name}/{course_id}'
c.CourseDirectory.course_id = '{course_id}'
"""
|
class Settings:
def __init__(
self,
workdir: str,
outdir: str,
threads: int,
debug: bool):
self.workdir = workdir
self.outdir = outdir
self.threads = threads
self.debug = debug
class Logger:
def __init__(self, name: str):
self.name = name
def info(self, msg: str):
print(msg, flush=True)
class Processor:
settings: Settings
workdir: str
outdir: str
threads: int
debug: bool
logger: Logger
def __init__(self, settings: Settings):
self.settings = settings
self.workdir = settings.workdir
self.outdir = settings.outdir
self.threads = settings.threads
self.debug = settings.debug
self.logger = Logger(name=self.__class__.__name__)
|
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 15 01:40:25 2018
@author: kennedy
"""
#sample --> 'kennedy':'ify1', 'andy': 'best56', 'great': 'op3'
#create new user
system = {} #database system
option = ""
def newusers():
uname= input("Enter a username: ")
if uname in system:
print("User already exit: Create new user")
else:
pw = input("Enter password: ")
system[uname] = pw
print("\nUser created: welcome to the network")
#login for old users
def oldusers():
uname = input("Enter your username:")
pw = input("Enter your password: ")
if uname in system and system[uname] == pw:
print(uname, 'Welcome back')
else:
print('Login incorrect')
#login
def login():
#option = {'New': 1, 'Old': 2, 'Exit': 3}
option = input("Enter an option: N --> New User, O-->OldUser,E-->Exit ")
if option == "N":
newusers()
elif option == "O":
oldusers()
elif option == "E":
exit
#we call the main function
if __name__ == "__main__":
login() |
"""Cached evaluation of integrals of monomials over the unit simplex.
"""
# Integrals of all monomial basis polynomials for the space P_r(R^n) over the n-dimensional unit simplex,
# given as a list.
monomial_integrals_unit_simplex_all_cache = {
# (n, r) = (1, 1)
(1, 1): [
1,
1 / 2
],
# (n, r) = (1, 2)
(1, 2): [
1,
1 / 2,
1 / 3
],
# (n, r) = (1, 3)
(1, 3): [
1,
1 / 2,
1 / 3,
1 / 4
],
# (n, r) = (1, 4)
(1, 4): [
1,
1 / 2,
1 / 3,
1 / 4,
1 / 5
],
# (n, r) = (1, 5)
(1, 5): [
1,
1 / 2,
1 / 3,
1 / 4,
1 / 5,
1 / 6
],
# (n, r) = (1, 6)
(1, 6): [
1,
1 / 2,
1 / 3,
1 / 4,
1 / 5,
1 / 6,
1 / 7
],
# (n, r) = (2, 1)
(2, 1): [
1 / 2,
1 / 6,
1 / 6
],
# (n, r) = (2, 2)
(2, 2): [
1 / 2,
1 / 6,
1 / 12,
1 / 6,
1 / 24,
1 / 12
],
# (n, r) = (2, 3)
(2, 3): [
1 / 2,
1 / 6,
1 / 12,
1 / 20,
1 / 6,
1 / 24,
1 / 60,
1 / 12,
1 / 60,
1 / 20
],
# (n, r) = (2, 4)
(2, 4): [
1 / 2,
1 / 6,
1 / 12,
1 / 20,
1 / 30,
1 / 6,
1 / 24,
1 / 60,
1 / 120,
1 / 12,
1 / 60,
1 / 180,
1 / 20,
1 / 120,
1 / 30
],
# (n, r) = (2, 5)
(2, 5): [
1 / 2,
1 / 6,
1 / 12,
1 / 20,
1 / 30,
1 / 42,
1 / 6,
1 / 24,
1 / 60,
1 / 120,
1 / 210,
1 / 12,
1 / 60,
1 / 180,
1 / 420,
1 / 20,
1 / 120,
1 / 420,
1 / 30,
1 / 210,
1 / 42
],
# (n, r) = (2, 6)
(2, 6): [
1 / 2,
1 / 6,
1 / 12,
1 / 20,
1 / 30,
1 / 42,
1 / 56,
1 / 6,
1 / 24,
1 / 60,
1 / 120,
1 / 210,
1 / 336,
1 / 12,
1 / 60,
1 / 180,
1 / 420,
1 / 840,
1 / 20,
1 / 120,
1 / 420,
1 / 1120,
1 / 30,
1 / 210,
1 / 840,
1 / 42,
1 / 336,
1 / 56
],
# (n, r) = (3, 1)
(3, 1): [
1 / 6,
1 / 24,
1 / 24,
1 / 24
],
# (n, r) = (3, 2)
(3, 2): [
1 / 6,
1 / 24,
1 / 60,
1 / 24,
1 / 120,
1 / 60,
1 / 24,
1 / 120,
1 / 120,
1 / 60
],
# (n, r) = (3, 3)
(3, 3): [
1 / 6,
1 / 24,
1 / 60,
1 / 120,
1 / 24,
1 / 120,
1 / 360,
1 / 60,
1 / 360,
1 / 120,
1 / 24,
1 / 120,
1 / 360,
1 / 120,
1 / 720,
1 / 360,
1 / 60,
1 / 360,
1 / 360,
1 / 120
],
# (n, r) = (3, 4)
(3, 4): [
1 / 6,
1 / 24,
1 / 60,
1 / 120,
1 / 210,
1 / 24,
1 / 120,
1 / 360,
1 / 840,
1 / 60,
1 / 360,
1 / 1260,
1 / 120,
1 / 840,
1 / 210,
1 / 24,
1 / 120,
1 / 360,
1 / 840,
1 / 120,
1 / 720,
1 / 2520,
1 / 360,
1 / 2520,
1 / 840,
1 / 60,
1 / 360,
1 / 1260,
1 / 360,
1 / 2520,
1 / 1260,
1 / 120,
1 / 840,
1 / 840,
1 / 210
],
# (n, r) = (3, 5)
(3, 5): [
1 / 6,
1 / 24,
1 / 60,
1 / 120,
1 / 210,
1 / 336,
1 / 24,
1 / 120,
1 / 360,
1 / 840,
1 / 1680,
1 / 60,
1 / 360,
1 / 1260,
1 / 3360,
1 / 120,
1 / 840,
1 / 3360,
1 / 210,
1 / 1680,
1 / 336,
1 / 24,
1 / 120,
1 / 360,
1 / 840,
1 / 1680,
1 / 120,
1 / 720,
1 / 2520,
1 / 6720,
1 / 360,
1 / 2520,
1 / 10080,
1 / 840,
1 / 6720,
1 / 1680,
1 / 60,
1 / 360,
1 / 1260,
1 / 3360,
1 / 360,
1 / 2520,
1 / 10080,
1 / 1260,
1 / 10080,
1 / 3360,
1 / 120,
1 / 840,
1 / 3360,
1 / 840,
1 / 6720,
1 / 3360,
1 / 210,
1 / 1680,
1 / 1680,
1 / 336
],
# (n, r) = (3, 6)
(3, 6): [
1 / 6,
1 / 24,
1 / 60,
1 / 120,
1 / 210,
1 / 336,
1 / 504,
1 / 24,
1 / 120,
1 / 360,
1 / 840,
1 / 1680,
1 / 3024,
1 / 60,
1 / 360,
1 / 1260,
1 / 3360,
1 / 7560,
1 / 120,
1 / 840,
1 / 3360,
1 / 10080,
1 / 210,
1 / 1680,
1 / 7560,
1 / 336,
1 / 3024,
1 / 504,
1 / 24,
1 / 120,
1 / 360,
1 / 840,
1 / 1680,
1 / 3024,
1 / 120,
1 / 720,
1 / 2520,
1 / 6720,
1 / 15120,
1 / 360,
1 / 2520,
1 / 10080,
1 / 30240,
1 / 840,
1 / 6720,
1 / 30240,
1 / 1680,
1 / 15120,
1 / 3024,
1 / 60,
1 / 360,
1 / 1260,
1 / 3360,
1 / 7560,
1 / 360,
1 / 2520,
1 / 10080,
1 / 30240,
1 / 1260,
1 / 10080,
1 / 45360,
1 / 3360,
1 / 30240,
1 / 7560,
1 / 120,
1 / 840,
1 / 3360,
1 / 10080,
1 / 840,
1 / 6720,
1 / 30240,
1 / 3360,
1 / 30240,
1 / 10080,
1 / 210,
1 / 1680,
1 / 7560,
1 / 1680,
1 / 15120,
1 / 7560,
1 / 336,
1 / 3024,
1 / 3024,
1 / 504
]
}
# Integrals of monomial basis polynomials for the space P_r(R^n) over the n-dimensional unit simplex,
# given as a dictionary with monomial exponent as key.
monomial_integrals_unit_simplex_individual_cache = {
# (n, r) = (1, 1)
(1, 1): {
(0,): 1,
(1,): 1 / 2
},
# (n, r) = (1, 2)
(1, 2): {
(0,): 1,
(1,): 1 / 2,
(2,): 1 / 3
},
# (n, r) = (1, 3)
(1, 3): {
(0,): 1,
(1,): 1 / 2,
(2,): 1 / 3,
(3,): 1 / 4
},
# (n, r) = (1, 4)
(1, 4): {
(0,): 1,
(1,): 1 / 2,
(2,): 1 / 3,
(3,): 1 / 4,
(4,): 1 / 5
},
# (n, r) = (1, 5)
(1, 5): {
(0,): 1,
(1,): 1 / 2,
(2,): 1 / 3,
(3,): 1 / 4,
(4,): 1 / 5,
(5,): 1 / 6
},
# (n, r) = (1, 6)
(1, 6): {
(0,): 1,
(1,): 1 / 2,
(2,): 1 / 3,
(3,): 1 / 4,
(4,): 1 / 5,
(5,): 1 / 6,
(6,): 1 / 7
},
# (n, r) = (2, 1)
(2, 1): {
(0, 0): 1 / 2,
(1, 0): 1 / 6,
(0, 1): 1 / 6
},
# (n, r) = (2, 2)
(2, 2): {
(0, 0): 1 / 2,
(1, 0): 1 / 6,
(2, 0): 1 / 12,
(0, 1): 1 / 6,
(1, 1): 1 / 24,
(0, 2): 1 / 12
},
# (n, r) = (2, 3)
(2, 3): {
(0, 0): 1 / 2,
(1, 0): 1 / 6,
(2, 0): 1 / 12,
(3, 0): 1 / 20,
(0, 1): 1 / 6,
(1, 1): 1 / 24,
(2, 1): 1 / 60,
(0, 2): 1 / 12,
(1, 2): 1 / 60,
(0, 3): 1 / 20
},
# (n, r) = (2, 4)
(2, 4): {
(0, 0): 1 / 2,
(1, 0): 1 / 6,
(2, 0): 1 / 12,
(3, 0): 1 / 20,
(4, 0): 1 / 30,
(0, 1): 1 / 6,
(1, 1): 1 / 24,
(2, 1): 1 / 60,
(3, 1): 1 / 120,
(0, 2): 1 / 12,
(1, 2): 1 / 60,
(2, 2): 1 / 180,
(0, 3): 1 / 20,
(1, 3): 1 / 120,
(0, 4): 1 / 30
},
# (n, r) = (2, 5)
(2, 5): {
(0, 0): 1 / 2,
(1, 0): 1 / 6,
(2, 0): 1 / 12,
(3, 0): 1 / 20,
(4, 0): 1 / 30,
(5, 0): 1 / 42,
(0, 1): 1 / 6,
(1, 1): 1 / 24,
(2, 1): 1 / 60,
(3, 1): 1 / 120,
(4, 1): 1 / 210,
(0, 2): 1 / 12,
(1, 2): 1 / 60,
(2, 2): 1 / 180,
(3, 2): 1 / 420,
(0, 3): 1 / 20,
(1, 3): 1 / 120,
(2, 3): 1 / 420,
(0, 4): 1 / 30,
(1, 4): 1 / 210,
(0, 5): 1 / 42
},
# (n, r) = (2, 6)
(2, 6): {
(0, 0): 1 / 2,
(1, 0): 1 / 6,
(2, 0): 1 / 12,
(3, 0): 1 / 20,
(4, 0): 1 / 30,
(5, 0): 1 / 42,
(6, 0): 1 / 56,
(0, 1): 1 / 6,
(1, 1): 1 / 24,
(2, 1): 1 / 60,
(3, 1): 1 / 120,
(4, 1): 1 / 210,
(5, 1): 1 / 336,
(0, 2): 1 / 12,
(1, 2): 1 / 60,
(2, 2): 1 / 180,
(3, 2): 1 / 420,
(4, 2): 1 / 840,
(0, 3): 1 / 20,
(1, 3): 1 / 120,
(2, 3): 1 / 420,
(3, 3): 1 / 1120,
(0, 4): 1 / 30,
(1, 4): 1 / 210,
(2, 4): 1 / 840,
(0, 5): 1 / 42,
(1, 5): 1 / 336,
(0, 6): 1 / 56
},
# (n, r) = (3, 1)
(3, 1): {
(0, 0, 0): 1 / 6,
(1, 0, 0): 1 / 24,
(0, 1, 0): 1 / 24,
(0, 0, 1): 1 / 24
},
# (n, r) = (3, 2)
(3, 2): {
(0, 0, 0): 1 / 6,
(1, 0, 0): 1 / 24,
(2, 0, 0): 1 / 60,
(0, 1, 0): 1 / 24,
(1, 1, 0): 1 / 120,
(0, 2, 0): 1 / 60,
(0, 0, 1): 1 / 24,
(1, 0, 1): 1 / 120,
(0, 1, 1): 1 / 120,
(0, 0, 2): 1 / 60
},
# (n, r) = (3, 3)
(3, 3): {
(0, 0, 0): 1 / 6,
(1, 0, 0): 1 / 24,
(2, 0, 0): 1 / 60,
(3, 0, 0): 1 / 120,
(0, 1, 0): 1 / 24,
(1, 1, 0): 1 / 120,
(2, 1, 0): 1 / 360,
(0, 2, 0): 1 / 60,
(1, 2, 0): 1 / 360,
(0, 3, 0): 1 / 120,
(0, 0, 1): 1 / 24,
(1, 0, 1): 1 / 120,
(2, 0, 1): 1 / 360,
(0, 1, 1): 1 / 120,
(1, 1, 1): 1 / 720,
(0, 2, 1): 1 / 360,
(0, 0, 2): 1 / 60,
(1, 0, 2): 1 / 360,
(0, 1, 2): 1 / 360,
(0, 0, 3): 1 / 120
},
# (n, r) = (3, 4)
(3, 4): {
(0, 0, 0): 1 / 6,
(1, 0, 0): 1 / 24,
(2, 0, 0): 1 / 60,
(3, 0, 0): 1 / 120,
(4, 0, 0): 1 / 210,
(0, 1, 0): 1 / 24,
(1, 1, 0): 1 / 120,
(2, 1, 0): 1 / 360,
(3, 1, 0): 1 / 840,
(0, 2, 0): 1 / 60,
(1, 2, 0): 1 / 360,
(2, 2, 0): 1 / 1260,
(0, 3, 0): 1 / 120,
(1, 3, 0): 1 / 840,
(0, 4, 0): 1 / 210,
(0, 0, 1): 1 / 24,
(1, 0, 1): 1 / 120,
(2, 0, 1): 1 / 360,
(3, 0, 1): 1 / 840,
(0, 1, 1): 1 / 120,
(1, 1, 1): 1 / 720,
(2, 1, 1): 1 / 2520,
(0, 2, 1): 1 / 360,
(1, 2, 1): 1 / 2520,
(0, 3, 1): 1 / 840,
(0, 0, 2): 1 / 60,
(1, 0, 2): 1 / 360,
(2, 0, 2): 1 / 1260,
(0, 1, 2): 1 / 360,
(1, 1, 2): 1 / 2520,
(0, 2, 2): 1 / 1260,
(0, 0, 3): 1 / 120,
(1, 0, 3): 1 / 840,
(0, 1, 3): 1 / 840,
(0, 0, 4): 1 / 210
},
# (n, r) = (3, 5)
(3, 5): {
(0, 0, 0): 1 / 6,
(1, 0, 0): 1 / 24,
(2, 0, 0): 1 / 60,
(3, 0, 0): 1 / 120,
(4, 0, 0): 1 / 210,
(5, 0, 0): 1 / 336,
(0, 1, 0): 1 / 24,
(1, 1, 0): 1 / 120,
(2, 1, 0): 1 / 360,
(3, 1, 0): 1 / 840,
(4, 1, 0): 1 / 1680,
(0, 2, 0): 1 / 60,
(1, 2, 0): 1 / 360,
(2, 2, 0): 1 / 1260,
(3, 2, 0): 1 / 3360,
(0, 3, 0): 1 / 120,
(1, 3, 0): 1 / 840,
(2, 3, 0): 1 / 3360,
(0, 4, 0): 1 / 210,
(1, 4, 0): 1 / 1680,
(0, 5, 0): 1 / 336,
(0, 0, 1): 1 / 24,
(1, 0, 1): 1 / 120,
(2, 0, 1): 1 / 360,
(3, 0, 1): 1 / 840,
(4, 0, 1): 1 / 1680,
(0, 1, 1): 1 / 120,
(1, 1, 1): 1 / 720,
(2, 1, 1): 1 / 2520,
(3, 1, 1): 1 / 6720,
(0, 2, 1): 1 / 360,
(1, 2, 1): 1 / 2520,
(2, 2, 1): 1 / 10080,
(0, 3, 1): 1 / 840,
(1, 3, 1): 1 / 6720,
(0, 4, 1): 1 / 1680,
(0, 0, 2): 1 / 60,
(1, 0, 2): 1 / 360,
(2, 0, 2): 1 / 1260,
(3, 0, 2): 1 / 3360,
(0, 1, 2): 1 / 360,
(1, 1, 2): 1 / 2520,
(2, 1, 2): 1 / 10080,
(0, 2, 2): 1 / 1260,
(1, 2, 2): 1 / 10080,
(0, 3, 2): 1 / 3360,
(0, 0, 3): 1 / 120,
(1, 0, 3): 1 / 840,
(2, 0, 3): 1 / 3360,
(0, 1, 3): 1 / 840,
(1, 1, 3): 1 / 6720,
(0, 2, 3): 1 / 3360,
(0, 0, 4): 1 / 210,
(1, 0, 4): 1 / 1680,
(0, 1, 4): 1 / 1680,
(0, 0, 5): 1 / 336
},
# (n, r) = (3, 6)
(3, 6): {
(0, 0, 0): 1 / 6,
(1, 0, 0): 1 / 24,
(2, 0, 0): 1 / 60,
(3, 0, 0): 1 / 120,
(4, 0, 0): 1 / 210,
(5, 0, 0): 1 / 336,
(6, 0, 0): 1 / 504,
(0, 1, 0): 1 / 24,
(1, 1, 0): 1 / 120,
(2, 1, 0): 1 / 360,
(3, 1, 0): 1 / 840,
(4, 1, 0): 1 / 1680,
(5, 1, 0): 1 / 3024,
(0, 2, 0): 1 / 60,
(1, 2, 0): 1 / 360,
(2, 2, 0): 1 / 1260,
(3, 2, 0): 1 / 3360,
(4, 2, 0): 1 / 7560,
(0, 3, 0): 1 / 120,
(1, 3, 0): 1 / 840,
(2, 3, 0): 1 / 3360,
(3, 3, 0): 1 / 10080,
(0, 4, 0): 1 / 210,
(1, 4, 0): 1 / 1680,
(2, 4, 0): 1 / 7560,
(0, 5, 0): 1 / 336,
(1, 5, 0): 1 / 3024,
(0, 6, 0): 1 / 504,
(0, 0, 1): 1 / 24,
(1, 0, 1): 1 / 120,
(2, 0, 1): 1 / 360,
(3, 0, 1): 1 / 840,
(4, 0, 1): 1 / 1680,
(5, 0, 1): 1 / 3024,
(0, 1, 1): 1 / 120,
(1, 1, 1): 1 / 720,
(2, 1, 1): 1 / 2520,
(3, 1, 1): 1 / 6720,
(4, 1, 1): 1 / 15120,
(0, 2, 1): 1 / 360,
(1, 2, 1): 1 / 2520,
(2, 2, 1): 1 / 10080,
(3, 2, 1): 1 / 30240,
(0, 3, 1): 1 / 840,
(1, 3, 1): 1 / 6720,
(2, 3, 1): 1 / 30240,
(0, 4, 1): 1 / 1680,
(1, 4, 1): 1 / 15120,
(0, 5, 1): 1 / 3024,
(0, 0, 2): 1 / 60,
(1, 0, 2): 1 / 360,
(2, 0, 2): 1 / 1260,
(3, 0, 2): 1 / 3360,
(4, 0, 2): 1 / 7560,
(0, 1, 2): 1 / 360,
(1, 1, 2): 1 / 2520,
(2, 1, 2): 1 / 10080,
(3, 1, 2): 1 / 30240,
(0, 2, 2): 1 / 1260,
(1, 2, 2): 1 / 10080,
(2, 2, 2): 1 / 45360,
(0, 3, 2): 1 / 3360,
(1, 3, 2): 1 / 30240,
(0, 4, 2): 1 / 7560,
(0, 0, 3): 1 / 120,
(1, 0, 3): 1 / 840,
(2, 0, 3): 1 / 3360,
(3, 0, 3): 1 / 10080,
(0, 1, 3): 1 / 840,
(1, 1, 3): 1 / 6720,
(2, 1, 3): 1 / 30240,
(0, 2, 3): 1 / 3360,
(1, 2, 3): 1 / 30240,
(0, 3, 3): 1 / 10080,
(0, 0, 4): 1 / 210,
(1, 0, 4): 1 / 1680,
(2, 0, 4): 1 / 7560,
(0, 1, 4): 1 / 1680,
(1, 1, 4): 1 / 15120,
(0, 2, 4): 1 / 7560,
(0, 0, 5): 1 / 336,
(1, 0, 5): 1 / 3024,
(0, 1, 5): 1 / 3024,
(0, 0, 6): 1 / 504
}
}
|
#import base64
#
#data = "abc123!?$*&()'-=@~"
#
## Standard Base64 Encoding
#encodedBytes = base64.b64encode(data.encode("utf-8"))
#encodedStr = str(encodedBytes, "utf-8")
#
#print(encodedStr)
#
l = [x for x in range(10)]
for x in range(10):
l.pop(0)
print(l) |
load(":collection_results.bzl", "collection_results")
load(":collect_module_members.bzl", "collect_module_members")
load(":declarations.bzl", "declarations")
load(":errors.bzl", "errors")
load(":tokens.bzl", "tokens", rws = "reserved_words", tts = "token_types")
# MARK: - Attribute Collection
def _collect_attribute(parsed_tokens):
"""Collect a module attribute.
Spec: https://clang.llvm.org/docs/Modules.html#attributes
Syntax:
attributes:
attribute attributesopt
attribute:
'[' identifier ']'
Args:
parsed_tokens: A `list` of tokens.
Returns:
A `tuple` where the first item is the collection result and the second is an
error `struct` as returned from errors.create().
"""
tlen = len(parsed_tokens)
open_token, err = tokens.get_as(parsed_tokens, 0, tts.square_bracket_open, count = tlen)
if err != None:
return None, err
attrib_token, err = tokens.get_as(parsed_tokens, 1, tts.identifier, count = tlen)
if err != None:
return None, err
open_token, err = tokens.get_as(parsed_tokens, 2, tts.square_bracket_close, count = tlen)
if err != None:
return None, err
return collection_results.new([attrib_token.value], 3), None
# MARK: - Module Collection
def collect_module(parsed_tokens, is_submodule = False, prefix_tokens = []):
"""Collect a module declaration.
Spec: https://clang.llvm.org/docs/Modules.html#module-declaration
Syntax:
explicitopt frameworkopt module module-id attributesopt '{' module-member* '}'
Args:
parsed_tokens: A `list` of tokens.
is_submodule: A `bool` that designates whether the module is a child of another module.
prefix_tokens: A `list` of tokens that have already been collected, but not applied.
Returns:
A `tuple` where the first item is the collection result and the second is an
error `struct` as returned from errors.create().
"""
explicit = False
framework = False
attributes = []
members = []
consumed_count = 0
tlen = len(parsed_tokens)
# Process the prefix tokens
for token in prefix_tokens:
if token.type == tts.reserved and token.value == rws.explicit:
if not is_submodule:
return None, errors.new("The explicit qualifier can only exist on submodules.")
explicit = True
elif token.type == tts.reserved and token.value == rws.framework:
framework = True
else:
return None, errors.new(
"Unexpected prefix token collecting module declaration. token: %s" % (token),
)
module_token, err = tokens.get_as(parsed_tokens, 0, tts.reserved, rws.module, count = tlen)
if err != None:
return None, err
consumed_count += 1
module_id_token, err = tokens.get_as(parsed_tokens, 1, tts.identifier, count = tlen)
if err != None:
return None, err
consumed_count += 1
# Collect the attributes and module members
skip_ahead = 0
collect_result = None
for idx in range(consumed_count, tlen - consumed_count):
consumed_count += 1
if skip_ahead > 0:
skip_ahead -= 1
continue
collect_result = None
err = None
# Get next token
token, err = tokens.get(parsed_tokens, idx, count = tlen)
if err != None:
return None, err
# Process the token
if tokens.is_a(token, tts.curly_bracket_open):
collect_result, err = collect_module_members(parsed_tokens[idx:])
if err != None:
return None, err
members.extend(collect_result.declarations)
elif tokens.is_a(token, tts.square_bracket_open):
collect_result, err = _collect_attribute(parsed_tokens[idx:])
if err != None:
return None, err
attributes.extend(collect_result.declarations)
else:
return None, errors.new(
"Unexpected token collecting attributes and module members. token: %s" % (token),
)
# Handle index advancement.
if collect_result:
skip_ahead = collect_result.count - 1
# Create the declaration
decl = declarations.module(
module_id = module_id_token.value,
explicit = explicit,
framework = framework,
attributes = attributes,
members = members,
)
return collection_results.new([decl], consumed_count), None
|
f = open('input.txt')
adapters = []
for line in f:
adapters.append(int(line[:-1]))
adapters.sort()
adapters.append(adapters[-1] + 3)
differences = {}
previous = 0
for adapter in adapters:
current_difference = adapter - previous
if not current_difference in differences: differences[current_difference] = 0
differences[current_difference] += 1
previous = adapter
print(differences[1] * differences[3])
|
class Solution:
def peakIndexInMountainArray(self, A):
"""
:type A: List[int]
:rtype: int
"""
A_new = sorted(A)
return A.index(A_new[-1])
# # other solutions
# # 1.
# class Solution:
# def peakIndexInMountainArray(self, A):
# """
# :type A: List[int]
# :rtype: int
# """
# for i in range(len(A)-1):
# if A[i]>A[i+1]:
# return i
#
#
#
# # 2. binary search
# class Solution:
# def peakIndexInMountainArray(self, A):
# """
# :type A: List[int]
# :rtype: int
# """
# l=0
# r=len(A)-1
# while l<r:
# mid = int((l+r)/2)
# if A[mid-1]>A[mid]:
# r = mid
# elif A[mid]<A[mid+1]:
# l = mid
# else:
# return mid
#
#
# # 3. one line python
# class Solution:
# def peakIndexInMountainArray(self, A):
# """
# :type A: List[int]
# :rtype: int
# """
# return A.index(max(A))
A = [0, 1, 0]
A = [0, 2, 1, 0]
sol = Solution()
res = sol.peakIndexInMountainArray(A)
print(res) |
# LinkNode/Marker ID Table
# -1: Unassigned (Temporary)
# 0 ~ 50: Reserved for Joint ID
#
FRAME_ID = 'viz_frame'
|
"""
strategy_observer.py
Copyright 2015 Andres Riancho
This file is part of w3af, http://w3af.org/ .
w3af is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation version 2 of the License.
w3af is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with w3af; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""
class StrategyObserver(object):
"""
When you want to listen to the activity inside the CoreStrategy simply
inherit from this class and call CoreStrategy.add_observer(). When the scan
runs the methods in this class are called.
"""
def crawl(self, craw_consumer, fuzzable_request):
pass
def audit(self, audit_consumer, fuzzable_request):
pass
def bruteforce(self, bruteforce_consumer, fuzzable_request):
pass
def grep(self, grep_consumer, request, response):
pass
def end(self):
"""
Called when the strategy is about to end, useful for clearing
memory, removing temp files, stopping threads, etc.
:return: None
"""
pass
|
students = ['Lilly', 'Olivia', 'Emily', 'Sophia']
students.pop() # ['Lilly', 'Olivia', 'Emily'] (пособие)
print(students) # ['Lilly', 'Olivia', 'Emily']
students.pop(1) # ['Lilly', 'Emily', 'Sophia'] (пособие)
print(students) # ['Lilly', 'Emily']
|
VBA = \
r"""
Function ExecuteCmdSync(targetPath As String)
'Run a shell command, returning the output as a string'
' Using a hidden window, pipe the output of the command to the CLIP.EXE utility...
' Necessary because normal usage with oShell.Exec("cmd.exe /C " & sCmd) always pops a windows
Dim instruction As String
instruction = "cmd.exe /c " & targetPath & " | clip"
On Error Resume Next
Err.Clear
CreateObject("WScript.Shell").Run instruction, 0, True
On Error Goto 0
' Read the clipboard text using htmlfile object
ExecuteCmdSync = CreateObject("htmlfile").ParentWindow.ClipboardData.GetData("text")
End Function
"""
|
'''
Statement
Given a list of numbers, find and print the elements that appear in it only once. Such elements should be printed in the order in which they occur in the original list.
Example input
4 3 5 2 5 1 3 5
Example output
4 2 1
'''
arr = input().split()
for i in arr:
if arr.count(i) == 1:
print(i, end=" ")
|
# Matrix Tracing
# How many ways can you trace a given matrix? - 30 Points
#
# https://www.hackerrank.com/challenges/matrix-tracing/problem
#
MOD = 1000000007
def fact(n):
""" calcule n! mod MOD """
f = 1
for i in range(2, n + 1):
f = (f * i) % MOD
return f
def pow(a, b):
""" calcule a^b mod MOD """
a %= MOD
# exponentiation rapide
p = 1
while b > 0:
if b % 2 == 1:
p = (p * a) % MOD
a = (a * a) % MOD
b //= 2
return p
for _ in range(int(input())):
m, n = map(int, input().split())
# la solution est C(m+n-2, m-1) ou C(m+n-2, n-1)
# soit (m+n-2)! / (m-1)! / (n-1)!
# compte tenu des valeurs de m et n, le calcul direct est impossible
# on va utiliser le petit théorème de Fermat:
# a^(p-1) = 1 mod p si p est premier et gcd(a,p)=1
# => a^(p-2) = a^(-1) mod p
# => a^(-1) = a^(p-2) mod p
# le résultat modulo MOD est donc:
# (m+n-2)! * [ (m-1)! * (n-1)!) ^ (MOD-2) ]
r = fact(n + m - 2) * pow(fact(n - 1) * fact(m - 1), MOD - 2)
print(r % MOD)
|
age = 17
name = 'Nicolay'
print('Возраст {0} - - {1} лет.'.format(name, age))
print('Почему {0} забавляется с этим Python?'.format(name))
# второй способ
age =100
name = 'Nicolay'
print('Возраст {} - - {} лет.'.format(name,age))
print('Почему {} забавляется с этим Python?'.format(name))
|
class Source:
pass
class URL(Source):
def __init__(self, url, method="GET", data=None):
self.url = url
self.method = method
self.data = data
def get_data(self, scraper):
return scraper.request(method=self.method, url=self.url, data=self.data).content
def __str__(self):
return self.url
class NullSource(Source):
def get_data(self, scraper):
return None
def __str__(self):
return self.__class__.__name__
|
fs = 44100.
dt = 1. / fs
def rawsco_to_ndf(rawsco):
clock, rate, nsamps, score = rawsco
if rate == 44100:
ar = True
else:
ar = False
max_i = score.shape[0]
samp = 0
t = 0.
# ('apu', ch, func, func_val, natoms, offset)
ndf = [
('clock', int(clock)),
('apu', 'ch', 'p1', 0, 0, 0),
('apu', 'ch', 'p2', 0, 0, 0),
('apu', 'ch', 'tr', 0, 0, 0),
('apu', 'ch', 'no', 0, 0, 0),
('apu', 'p1', 'du', 0, 1, 0),
('apu', 'p1', 'lh', 1, 1, 0),
('apu', 'p1', 'cv', 1, 1, 0),
('apu', 'p1', 'vo', 0, 1, 0),
('apu', 'p1', 'ss', 7, 2, 1), # This is necessary to prevent channel silence for low notes
('apu', 'p2', 'du', 0, 3, 0),
('apu', 'p2', 'lh', 1, 3, 0),
('apu', 'p2', 'cv', 1, 3, 0),
('apu', 'p2', 'vo', 0, 3, 0),
('apu', 'p2', 'ss', 7, 4, 1), # This is necessary to prevent channel silence for low notes
('apu', 'tr', 'lh', 1, 5, 0),
('apu', 'tr', 'lr', 127, 5, 0),
('apu', 'no', 'lh', 1, 6, 0),
('apu', 'no', 'cv', 1, 6, 0),
('apu', 'no', 'vo', 0, 6, 0),
]
ch_to_last_tl = {ch:0 for ch in ['p1', 'p2']}
ch_to_last_th = {ch:0 for ch in ['p1', 'p2']}
ch_to_last_timer = {ch:0 for ch in ['p1', 'p2', 'tr']}
ch_to_last_du = {ch:0 for ch in ['p1', 'p2']}
ch_to_last_volume = {ch:0 for ch in ['p1', 'p2', 'no']}
last_no_np = 0
last_no_nl = 0
for i in range(max_i):
for j, ch in enumerate(['p1', 'p2']):
th, tl, volume, du = score[i, j]
timer = (th << 8) + tl
last_timer = ch_to_last_timer[ch]
# NOTE: This will never be perfect reconstruction because phase is not incremented when the channel is off
retrigger = False
if last_timer == 0 and timer != 0:
ndf.append(('apu', 'ch', ch, 1, 0, 0))
retrigger = True
elif last_timer != 0 and timer == 0:
ndf.append(('apu', 'ch', ch, 0, 0, 0))
if du != ch_to_last_du[ch]:
ndf.append(('apu', ch, 'du', du, 0, 0))
ch_to_last_du[ch] = du
if volume > 0 and volume != ch_to_last_volume[ch]:
ndf.append(('apu', ch, 'vo', volume, 0, 0))
ch_to_last_volume[ch] = volume
if tl != ch_to_last_tl[ch]:
ndf.append(('apu', ch, 'tl', tl, 0, 2))
ch_to_last_tl[ch] = tl
if retrigger or th != ch_to_last_th[ch]:
ndf.append(('apu', ch, 'th', th, 0, 3))
ch_to_last_th[ch] = th
ch_to_last_timer[ch] = timer
j = 2
ch = 'tr'
th, tl, _, _ = score[i, j]
timer = (th << 8) + tl
last_timer = ch_to_last_timer[ch]
if last_timer == 0 and timer != 0:
ndf.append(('apu', 'ch', ch, 1, 0, 0))
elif last_timer != 0 and timer == 0:
ndf.append(('apu', 'ch', ch, 0, 0, 0))
if timer != last_timer:
ndf.append(('apu', ch, 'tl', tl, 0, 2))
ndf.append(('apu', ch, 'th', th, 0, 3))
ch_to_last_timer[ch] = timer
j = 3
ch = 'no'
_, np, volume, nl = score[i, j]
if last_no_np == 0 and np != 0:
ndf.append(('apu', 'ch', ch, 1, 0, 0))
elif last_no_np != 0 and np == 0:
ndf.append(('apu', 'ch', ch, 0, 0, 0))
if volume > 0 and volume != ch_to_last_volume[ch]:
ndf.append(('apu', ch, 'vo', volume, 0, 0))
ch_to_last_volume[ch] = volume
if nl != last_no_nl:
ndf.append(('apu', ch, 'nl', nl, 0, 2))
last_no_nl = nl
if np > 0 and np != last_no_np:
ndf.append(('apu', ch, 'np', 16 - np, 0, 2))
ndf.append(('apu', ch, 'll', 0, 0, 3))
last_no_np = np
if ar:
wait_amt = 1
else:
t += 1. / rate
wait_amt = min(int(fs * t) - samp, nsamps - samp)
ndf.append(('wait', wait_amt))
samp += wait_amt
remaining = nsamps - samp
assert remaining >= 0
if remaining > 0:
ndf.append(('wait', remaining))
return ndf
|
#Write a program to input a string and check if it is a palindrome or not.
#This solution is in python programing language
str = input("Enter the string: ")
if str == str[::-1]:
print("String is Palindrome")
else:
print("String is not Palindrome")
|
buddy= "extremely loyal and cute"
print(len(buddy))
print(buddy[0])
print(buddy[0:10])
print(buddy[0:])
print(buddy[:15])
print(buddy[:])
# len gives you the length or number of characters of the string.
# So (len(buddy)) when printed = 24 as even spaces are counted.
# [] these brackets help to dissect the components of the string.
# so (buddy[0]) = e
# so (buddy[0:10]) = extremely
# so (buddy[0:]) = extremely loyal and cute
# so (buddy[:15]) = extremely loyal
# so (buddy[:]) = extremely loyal and
print(buddy[-1])
# so print(buddy[-1]) = e
print(buddy[-2])
print(buddy[-5:2])
# so print(buddy[-2]) = t |
class Secret:
# Dajngo secret key
SECRET_KEY = ''
# Amazone S3
AWS_STORAGE_BUCKET_NAME = ''
AWS_ACCESS_KEY_ID = ''
AWS_SECRET_ACCESS_KEY = ''
|
"""
leetcode 232
Stack implementation Queue
"""
def __init__(self):
self.instack = []
self.outstack = []
def push(self, x: int) -> None:
self.instack.append(x)
def pop(self) -> int:
if not self.outstack:
while self.instack:
self.outstack.append(self.instack.pop())
return self.outstack.pop()
def peek(self) -> int:
if not self.outstack:
while self.instack:
self.outstack.append(self.instack.pop())
return self.outstack[-1]
def empty(self) -> bool:
if not self.instack and not self.outstack:
return True
return False
|
class MessageHandler:
def __init__(self, name: str):
self.name = name
self.broker = None
def process_message(self, data: bytes):
pass
|
self.description = "Sysupgrade with same version, different epochs"
sp = pmpkg("dummy", "2:2.0-1")
sp.files = ["bin/dummynew"]
self.addpkg2db("sync", sp)
lp = pmpkg("dummy", "1:2.0-1")
lp.files = ["bin/dummyold"]
self.addpkg2db("local", lp)
self.args = "-Su"
self.addrule("PACMAN_RETCODE=0")
self.addrule("PKG_VERSION=dummy|2:2.0-1")
self.addrule("FILE_EXIST=bin/dummynew")
self.addrule("!FILE_EXIST=bin/dummyold")
|
a = int(input('Digite um número: '))
b = int(input('Digite outro número: '))
c = int(input('Digite mais um número: '))
d = int(input('Digite o último número: '))
n = a,b,c,d
print(f'Você digitou os valores: {n}')
print(f'O valor 9 apareceu {n.count(9)} vezes.')
if 3 in n:
print(f'O valor 3 apareceu na {n.index(3)+1}ª posição.')
else:
print('O valor 3 não foi digitado em nenhuma posição.')
print('Os valores pares digitados foram: ', end='')
for num in n:
if num%2 == 0:
print(num, end=', ')
|
def commonCharacterCount(s1, s2):
dic1 = {}
dic2 = {}
sums = 0
for letter in s1:
dic1[letter] = dic1.get(letter,0) + 1
for letter in s2:
dic2[letter] = dic2.get(letter,0) + 1
for letter in dic1:
if letter in dic2:
sums = sums + min(dic1[letter],dic2[letter])
return sums
|
class QuickReplyButton:
def __init__(self, title: str, payload: str):
if not isinstance(title, str):
raise TypeError("QuickReplyButton.title must be an instance of str")
if not isinstance(payload, str):
raise TypeError("QuickReplyButton.payload must be an instance of str")
self.title = title
self.payload = payload
def to_dict(self):
return {
"content_type": "text",
"title": self.title,
"payload": self.payload
}
class QuickReply:
def __init__(self):
self.buttons = []
def add(self, button: QuickReplyButton):
if not isinstance(button, QuickReplyButton):
raise TypeError("button must be an instance of QuickReplyButton")
self.buttons.append(button)
def to_dict(self):
return [button.to_dict() for button in self.buttons]
class Button:
def __init__(self, type: str, title: str, **kwargs):
if not isinstance(title, str):
raise TypeError("Button.title must be an instance of str")
if not isinstance(type, str):
raise TypeError("Button.type must be an instance of str")
self.title = title
self.type = type
for k in kwargs:
setattr(self, k, kwargs[k])
def to_dict(self):
return dict(vars(self))
class Template:
def __init__(self, type: str, text: str, **kwargs):
if not isinstance(type, str):
raise TypeError("Template.type must be an instance of str")
if not isinstance(text, str):
raise TypeError("Template.text must be an instance of str")
self.type = type
self.text = text
for k in kwargs:
setattr(self, k, kwargs[k])
def to_dict(self):
res = {
"type": "template",
"payload": {
"template_type": self.type,
"text": self.text
}
}
if hasattr(self, 'buttons'):
res['payload'].update({"buttons": [b.to_dict() for b in self.buttons]})
return res
class Message:
def __init__(self, text: str = None, quick_reply: QuickReply = None, attachment=None):
if text and not isinstance(text, str):
raise TypeError("Message.text must be an instance of str")
if quick_reply and not isinstance(quick_reply, QuickReply):
raise TypeError("Message.quick_reply must be an instance of QuickReply")
self.text = text
self.quick_reply = quick_reply
self.attachment = attachment
def set_quick_reply(self, quick_reply):
if not isinstance(quick_reply, QuickReply):
raise TypeError("Message.quick_reply must be an instance of QuickReply")
self.quick_reply = quick_reply
def to_dict(self):
msg = {}
if self.text:
msg['text'] = self.text
if self.quick_reply:
msg['quick_replies'] = self.quick_reply.to_dict()
if self.attachment:
msg['attachment'] = self.attachment.to_dict()
return msg
|
class EnigmaException(Exception):
pass
class PlugboardException(EnigmaException):
pass
class ReflectorException(EnigmaException):
pass
class RotorException(EnigmaException):
pass
|
def checks_in_string(string, check_list):
for check in check_list:
if check in string:
return True
return False
|
def find_strongest_eggs(*args):
eggs = args[0]
div = args[1]
res = []
strongest = []
is_strong = True
n = div
for _ in range(n):
res.append([])
for i in range(1):
if div == 1:
res.append(eggs)
break
else:
for j in range(len(eggs)):
if j % 2 == 0:
res[0].append(eggs[j])
else:
res[1].append(eggs[j])
if div == 1:
middle = len(res[1]) // 2
mid = res[1][middle]
left = list(res[1][:middle])
right = list(reversed(res[1][middle + 1:]))
while left and right:
is_strong = True
l = left.pop()
r = right.pop()
if mid <= l or mid <= r or r <= l:
is_strong = False
break
if is_strong:
strongest.append(mid)
else:
for el in res:
middle = len(el) // 2
mid = el[middle]
left = list(el[:middle])
right = list(reversed(el[middle+1:]))
while left and right:
is_strong = True
l = left.pop()
r = right.pop()
if mid <= l or mid <= r or r <= l:
is_strong = False
break
if is_strong:
strongest.append(mid)
return strongest
test = ([-1, 7, 3, 15, 2, 12], 2)
print(find_strongest_eggs(*test))
|
###############################################################################################
# 因为边权一样,可以用广搜;一下时间复杂度分析可见非常unreasonable
# 但由于n的范围不大于12,所以总的时间消耗小于10^6,可接收
###########
# 时间复杂度:O((n^2)*(2^n)),广搜常规本来是n+m,对每个点循环其所有边,但此题不一样;看循环次数,不止是循环n次
# 因为增加了状态的维度,到达每个点,状态可能有2^n种,所以一共可走的点有n*2^n种,而每次走一个点,边和点同一数量级
# 所以总的就是O((n^2)*(2^n))
# 空间复杂度:O(n*(2^n)),存储所有状态的seen哈希和queue
###############################################################################################
class Solution:
def shortestPathLength(self, graph: List[List[int]]) -> int:
N, n = 15, len(graph)
final = sum([1<<i for i in range(n)])
seen = set()
queue = []
res = float("inf")
def bfs():
nonlocal res
hh, tt = -1, 0
for i in range(n):
queue.append((i, 1<<i, 0))
seen.add((i, 1<<i))
tt += 1
while tt - hh > 1:
hh += 1
t, s, d = queue[hh]
if s == final:
res = min(res, d)
continue
for ne in graph[t]:
if (ne, s|(1<<ne)) not in seen: # 允许重复走一个点,但到达相同的点时状态不能一样,这样就能剔除重复点了
queue.append((ne, s|(1<<ne), d+1))
seen.add((ne, s|(1<<ne)))
tt += 1
bfs()
return res
###############################################################################################
# 硬核!状态压缩DP,和acwing上的题很像,又有点不一样
# 1、首先是图不是全连通的,需要使用floyd计算每两个点之间的最短路
# 2、我们的DP计算的不是0到某个点的Hamilton最短路,而是任一点到某个点的Hamilton最短路,所以初始化不一样
# 3、题目要求的不是0~n-1的Hamilton最短路,而是全局的hamilton最短路,所以还要取每个终点的hamilton最短路的最小值
###########
# 时间复杂度:O((n^2)*(2^n)),floyd的n^3看起来已经微不足道,直接三个大循环就很大
# 空间复杂度:O(n*(2^n)), DP状态消耗,每个点为终点的状态都有2^n个
###############################################################################################
class Solution:
def shortestPathLength(self, graph: List[List[int]]) -> int:
n = len(graph)
g = [[float("inf")] * n for _ in range(n)] # 便于floyd计算最短路,因此变成邻接矩阵
for i in range(n):
for j in graph[i]:
g[i][j] = 1 # 不带权图,因此默认为1
# floyd 算法预处理出所有点对之间的最短路径长度
# 因为此题和acwing上的那道【最短Hamilton路径】不一样,那个是全连接图,此题不是,所以要找最短的
for k in range(n):
for i in range(n):
for j in range(n):
g[i][j] = min(g[i][j], g[i][k] + g[k][j])
dp = [[float("inf")] * (1 << n) for _ in range(n)] # dp[i][j]: 任一点到达i点,经过的点是j,所经过的最短路径长度;这里和acwing那题定义也不一样,acwing是说从0到i点
# 因此初始化时,不能只初始化0点了,每个点都要
for i in range(n):
dp[i][1<<i] = 0 # 任一点到自己,经过的状态中只有自己一个点,那最短路径长度就是0
# 同acwing,先遍历每个状态;这里也同区间dp先遍历区间,状态dp先遍历状态
for j in range(1, 1 << n): # 0就不要了,什么点都没走,什么也到不了,距离无穷大
for i in range(n): # 到达i点
if j & (1 << i): # 必须要状态里包含i点,到达i点的路径计算才有意义
for k in range(n): # 枚举从哪个点过来的
if (j-(1<<i)>>k & 1): # 去掉i这个点后还要包含k这个点,才可能从k转移到i
dp[i][j] = min(dp[i][j], dp[k][j ^ (1 << i)] + g[k][i])
# 因为我们求的从任一点到i点的Hamilton最短路,所以要遍历所有点作为终点的Hamilton最短路,并取最小
res = min(dp[i][(1 << n) - 1] for i in range(n))
return res |
##PUT ALL INFO BETWEEN QUOTES BELOW AND RENAME THIS FILE TO 'creds.py'
#Twilio API Account info
ACCOUNT_SID = ""
AUTH_TOKEN = ""
# your cell phone number below (must begin with '+', example: "+15555555555")
TO_PHONE = ""
# your Twilio phone number below (must begin with '+', example: "+15555555555")
FROM_PHONE = ""
# Imgur ID
CLIENT_ID = "" |
class ModeException(Exception):
def __init__(self, message: str):
super().__init__(message)
class SizeException(Exception):
def __init__(self, message: str):
super().__init__(message)
class PaddingException(Exception):
def __init__(self, message: str):
super().__init__(message)
class ReshapingException(Exception):
def __init__(self, message: str):
super().__init__(message)
class ShapeMismatch(Exception):
def __init__(self, message: str):
super().__init__(message)
|
#!/usr/bin/env python
""" Aluguel de carro
Escreva um programa que pergunte a quantidade de km percorridos por um carro alugado pelo
usuario, assim como a quantidade de dias pelos quais o carro foi alugado. Calcule o preco a pagar,
sabendo que o carro custa R$ 60,00 por dia e R$ 0,15 por km rodado.
"""
def pay(km, days):
return (days*60 + km*0.15)
if __name__ == "__main__":
km = float (input(" The value of Km: "))
days = int (input(" Amount of days: "))
print("The value pay is: ", pay(km,days))
|
def function(a):
pass
function(10) |
"""
Datos de entrada
P-->p-->int
Q-->q-->int
Datos de salida
mensaje-->m-->float
"""
p=int(input("Ingrese el valor de p "))
q=int(input("Ingrese el valor de q "))
if(p**3+q**4-2*p**2>680):
print(str(p)+" y "+ str(q)+" satisfacen la expresión")
else:
(p**3+q**4-2*p**2<680)
print(str(p)+" y "+ str(q)+" no satisfacen la expresión")
|
sal = float(input('Digite seu salário: R$'))
if sal <= 1250:
novo = sal * 1.15
else:
novo = sal * 1.1
print(f'Seu antigo salário era \033[1;37m{sal}\033[m e o seu novo salário é \033[36;1m{novo:.2f}')
|
# To use the tinypng API you must provide your API key.
# https://tinypng.com/developers
API_KEY = "key"
# Raw-images directory
USER_INPUT_PATH = r"C:\raw_images"
# Save directory
USER_OUTPUT_PATH = r"C:\compressed_images"
# METADATA ———————————————————————————————————————————————————————————
# Copyright information and the creation date are currently supported.
# Preserving metadata adds to the compressed file size,
# so you should only preserve metadata that is important to keep.
# (True/False)
METADATA = False
# Delete all uncompressed images after compression
# (True/False)
DELETE_RAW_AFTER_COMPRESS = False
|
class NullAttributeException(Exception):
"""Raised when the attribute which is not nullable is missing."""
pass
class ItemNotFoundException(Exception):
"""Raised when the item is not found"""
pass
class ConditionNotRecognizedException(Exception):
"""Raised when the condition is not found"""
pass
|
[
{
'date': '2014-01-01',
'description': 'Nový rok',
'locale': 'cs-CZ',
'notes': '',
'region': '',
'type': 'NF'
},
{
'date': '2014-01-01',
'description': 'Den obnovy samostatného českého státu',
'locale': 'cs-CZ',
'notes': '',
'region': '',
'type': 'NF'
},
{
'date': '2014-04-21',
'description': 'Velikonoční pondělí',
'locale': 'cs-CZ',
'notes': '',
'region': '',
'type': 'NRV'
},
{
'date': '2014-05-01',
'description': 'Svátek práce',
'locale': 'cs-CZ',
'notes': '',
'region': '',
'type': 'NF'
},
{
'date': '2014-05-08',
'description': 'Den vítězství',
'locale': 'cs-CZ',
'notes': '',
'region': '',
'type': 'NF'
},
{
'date': '2014-07-05',
'description': 'Den slovanských věrozvěstů Cyrila a Metoděje',
'locale': 'cs-CZ',
'notes': '',
'region': '',
'type': 'NRF'
},
{
'date': '2014-07-06',
'description': 'Den upálení mistra Jana Husa',
'locale': 'cs-CZ',
'notes': '',
'region': '',
'type': 'NRF'
},
{
'date': '2014-09-28',
'description': 'Den české státnosti',
'locale': 'cs-CZ',
'notes': '',
'region': '',
'type': 'NRF'
},
{
'date': '2014-10-28',
'description': 'Den vzniku samostatného československého státu',
'locale': 'cs-CZ',
'notes': '',
'region': '',
'type': 'NF'
},
{
'date': '2014-11-17',
'description': 'Den boje za svobodu a demokracii',
'locale': 'cs-CZ',
'notes': '',
'region': '',
'type': 'NF'
},
{
'date': '2014-12-24',
'description': 'Štědrý den',
'locale': 'cs-CZ',
'notes': '',
'region': '',
'type': 'NRF'
},
{
'date': '2014-12-25',
'description': '1. svátek vánoční',
'locale': 'cs-CZ',
'notes': '',
'region': '',
'type': 'NRF'
},
{
'date': '2014-12-26',
'description': '2. svátek vánoční',
'locale': 'cs-CZ',
'notes': '',
'region': '',
'type': 'NRF'
}
] |
class Base1:
def __init__(self, *args):
print("Base1.__init__",args)
class Clist1(Base1, list):
pass
class Ctuple1(Base1, tuple):
pass
a = Clist1()
print(len(a))
a = Clist1([1, 2, 3])
print(len(a))
a = Ctuple1()
print(len(a))
a = Ctuple1([1, 2, 3])
# TODO: Faults
#print(len(a))
print("---")
class Clist2(list, Base1):
pass
class Ctuple2(tuple, Base1):
pass
a = Clist2()
print(len(a))
a = Clist2([1, 2, 3])
print(len(a))
#a = Ctuple2()
#print(len(a))
#a = Ctuple2([1, 2, 3])
#print(len(a))
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
_credential_properties = {
'blob': {
'type': 'string'
},
'project_id': {
'type': 'string'
},
'type': {
'type': 'string'
},
'user_id': {
'type': 'string'
}
}
credential_create = {
'type': 'object',
'properties': _credential_properties,
'additionalProperties': True,
'oneOf': [
{
'title': 'ec2 credential requires project_id',
'required': ['blob', 'type', 'user_id', 'project_id'],
'properties': {
'type': {
'enum': ['ec2']
}
}
},
{
'title': 'non-ec2 credential does not require project_id',
'required': ['blob', 'type', 'user_id'],
'properties': {
'type': {
'not': {
'enum': ['ec2']
}
}
}
}
]
}
credential_update = {
'type': 'object',
'properties': _credential_properties,
'minProperties': 1,
'additionalProperties': True
}
|
def hash_function(s=b''):
a, b, c, d = 0xa0, 0xb1, 0x11, 0x4d
for byte in bytearray(s):
a ^= byte
b = b ^ a ^ 0x55
c = b ^ 0x94
d = c ^ byte ^ 0x74
return format(d << 24 | c << 16 | a << 8 | b, '08x')
|
# -*- coding: utf-8 -*-
"""
lswifi.constants
~~~~~~~~~~~~~~~~
define app constant values
"""
APNAMEACKFILE = "apnames.ack"
APNAMEJSONFILE = "apnames.json"
CIPHER_SUITE_DICT = {
0: "Use group cipher suite",
1: "WEP-40", # WEP
2: "TKIP", # WPA-Personal (TKIP is limited to 54 Mbps)
3: "Reserved",
4: "AES", # CCMP-128 WPA2-Enterprise 00-0F-AC:4 / WPA2-Personal 00-0F-AC:4
5: "WEP-104",
6: "BIP-CMAC-128",
7: "Group addressed traffic not allowed",
8: "GCMP-128",
9: "GCMP-256", # WPA3-Enterprise 00-0F-AC:9 / WPA3-Personal 00-0F-AC:9
10: "CMAC-256",
11: "BIP-GMAC-128",
12: "BIP-GMAC-256",
13: "BIP-CMAC-256",
14: "Reserved",
15: "Reserved",
}
AKM_SUITE_DICT = {
0: "Reserved",
1: "802.1X",
2: "PSK",
3: "FT-802.1X",
4: "FT-PSK",
5: "802.1X",
6: "PSK",
7: "TDLS",
8: "SAE",
9: "FT-SAE",
10: "APPeerKey",
11: "802.1X-Suite-B-SHA-256",
12: "802.1X 192-bit", # WPA3 - Enterprise
13: "FT-802.1X-SHA-384",
18: "OWE",
}
INTERWORKING_NETWORK_TYPE = {
0: "Private network",
1: "Private network with guest access",
2: "Chargeable public network",
3: "Free public network",
4: "Personal device network",
5: "Emergency services only network",
6: "Reserved",
7: "Reserved",
8: "Reserved",
9: "Reserved",
10: "Reserved",
11: "Reserved",
12: "Reserved",
13: "Reserved",
14: "Test or experimental",
15: "Wildcard",
}
IE_DICT = {
0: "SSID",
1: "Supported Rates",
2: "Reserved",
3: "DSSS Parameter Set",
4: "Reserved",
5: "Traffic Indication Map",
6: "IBSS",
7: "Country", # 802.11d
10: "Request",
11: "BSS Load", # 802.11e
12: "EDCA",
13: "TSPEC",
32: "Power Constraint", # 802.11h
33: "Power Capability",
34: "TPC Request",
35: "TPC Report", # 802.11h
36: "Supported Channels",
37: "Channel Switch Announcement",
38: "Measurement Request",
39: "Measurement Report",
40: "Quiet Element", # 802.11h
41: "IBSS DFS",
42: "ERP",
45: "HT Capabilities",
47: "Reserved",
48: "RSN Information",
50: "Extended Supported Rates",
51: "AP Channel Report",
54: "Mobility Domain",
55: "FTE",
59: "Supported Operating Classes",
61: "HT Operation",
62: "Secondary Channel Offest",
66: "Measurement Pilot Transmission",
67: "BSS Available Admission Capacity",
69: "Time Advertisement",
70: "RM Enabled Capabilities", # 802.11r
71: "Multiple BSSID",
72: "20/40 BSS Coexistence",
74: "Overlapping BSS Scan Parameters",
84: "SSID List",
107: "Interworking",
108: "Advertisement Protocol",
111: "Roaming Consortium",
113: "Mesh Configuration", # 802.11s
114: "Mesh ID",
127: "Extended Capabilities",
133: "Cisco CCX1 CKIP + Device Name",
148: "DMG Capabilities",
149: "Cisco Unknown 95",
150: "Cisco",
151: "DMG Operation",
158: "Multi-band",
159: "ADDBA Extension",
173: "Symbol Proprietary",
191: "VHT Capabilities",
192: "VHT Operation",
193: "Extended BSS Load",
195: "Tx Power Envelope",
197: "AID",
198: "Quiet Channel",
201: "Reduced Neighbor Report",
202: "TVHT Operation",
216: "TWT",
221: "Vendor",
244: "RSN eXtension",
255: "Extension",
}
VENDOR_SPECIFIC_DICT = {
"00-0B-86": ["Aruba", "Aruba Networks Inc."],
"00-50-F2": ["Microsoft", "Microsoft Corporation"],
"00-03-7F": ["Atheros", "Atheros Communications Inc."],
"00-10-18": ["Broadcom", "Broadcom"],
"00-17-F2": ["Apple", "Apple Inc."],
"00-15-6D": ["Ubiquiti", "Ubiquiti Networks Inc."],
"00-26-86": ["Quantenna", "Quantenna"],
}
EXTENSION_IE_DICT = {
35: "(35) HE Capabilities",
36: "(36) HE Operation",
37: "(37) UORA Parameter Set",
38: "(38) MU EDCA Parameter Set",
39: "(39) Spatial Reuse Parameter",
41: "(41) NDP Feedback Report",
42: "(42) BSS Color Change Announcement",
43: "(43) Quiet Time Period Setup",
45: "(45) ESS Report",
46: "(46) OPS",
47: "(47) HE BSS Load",
55: "(55) Multiple BSSID Configuration",
57: "(57) Known BSSID",
58: "(58) Short SSID List",
59: "(59) HE 6 GHz Band Capabilities",
60: "(60) UL MU Power Capabilities",
}
_40MHZ_CHANNEL_LIST = {
"13-": ["13", "(9)"],
"9+": ["9", "(13)"],
"12-": ["12", "(8)"],
"8+": ["8", "(12)"],
"11-": ["11", "(7)"],
"7+": ["7", "(11)"],
"10-": ["10", "(6)"],
"6+": ["6", "(10)"],
"9-": ["9", "(5)"],
"5+": ["5", "(9)"],
"8-": ["8", "(4)"],
"4+": ["4", "(8)"],
"7-": ["7", "(3)"],
"3+": ["3", "(7)"],
"6-": ["6", "(2)"],
"2+": ["2", "(6)"],
"5-": ["5", "(1)"],
"1+": ["1", "(5)"],
"32+": ["32", "(36)"],
"36-": ["36", "(32)"],
"36+": ["36", "(40)"],
"40-": ["40", "(36)"],
"44+": ["44", "(48)"],
"48-": ["48", "(44)"],
"52+": ["52", "(56)"],
"56-": ["56", "(52)"],
"60+": ["60", "(64)"],
"64-": ["64", "(60)"],
"100+": ["100", "(104)"],
"104-": ["104", "(100)"],
"108+": ["108", "(112)"],
"112-": ["112", "(108)"],
"116+": ["116", "(120)"],
"120-": ["120", "(116)"],
"124+": ["124", "(128)"],
"128-": ["128", "(124)"],
"132+": ["132", "(136)"],
"136-": ["136", "(132)"],
"140+": ["140", "(144)"],
"144-": ["144", "(140)"],
"149+": ["149", "(153)"],
"153-": ["153", "(149)"],
"157+": ["157", "(161)"],
"161-": ["161", "(157)"],
}
_80MHZ_CHANNEL_LIST = {
"42": ["36", "40", "44", "48"],
"58": ["52", "56", "60", "64"],
"106": ["100", "104", "108", "112"],
"122": ["116", "120", "124", "128"],
"138": ["132", "136", "140", "144"],
"155": ["149", "153", "157", "161"],
}
_160MHZ_CHANNEL_LIST = {
"50": ["36", "40", "44", "48", "52", "56", "60", "64"],
"114": ["100", "104", "108", "112", "116", "120", "124", "128"],
}
_20MHZ_CHANNEL_LIST = {
"2412": "1",
"2417": "2",
"2422": "3",
"2427": "4",
"2432": "5",
"2437": "6",
"2442": "7",
"2447": "8",
"2452": "9",
"2457": "10",
"2462": "11",
"2467": "12",
"2472": "13",
"2484": "14",
"5160": "32",
"5170": "34",
"5180": "36",
"5190": "38",
"5200": "40",
"5210": "42",
"5220": "44",
"5230": "46",
"5240": "48",
"5250": "50",
"5260": "52",
"5270": "54",
"5280": "56",
"5290": "58",
"5300": "60",
"5310": "62",
"5320": "64",
"5340": "68",
"5480": "96",
"5500": "100",
"5510": "102",
"5520": "104",
"5530": "106",
"5540": "108",
"5550": "110",
"5560": "112",
"5570": "114",
"5580": "116",
"5590": "118",
"5600": "120",
"5610": "122",
"5620": "124",
"5630": "126",
"5640": "128",
"5660": "132",
"5670": "134",
"5680": "136",
"5700": "140",
"5710": "142",
"5720": "144",
"5745": "149",
"5755": "151",
"5765": "153",
"5775": "155",
"5785": "157",
"5795": "159",
"5805": "161",
"5825": "165",
"5845": "169",
"5865": "173",
"4915": "183",
"4920": "184",
"4925": "185",
"4935": "187",
"4940": "188",
"4945": "189",
"4960": "192",
"4980": "196",
"5955": "1",
"5975": "5",
"5995": "9",
"6015": "13",
"6035": "17",
"6055": "21",
"6075": "25",
"6095": "29",
"6115": "33",
"6135": "37",
"6155": "41",
"6175": "45",
"6195": "49",
"6215": "53",
"6235": "57",
"6255": "61",
"6275": "65",
"6295": "69",
"6315": "73",
"6335": "77",
"6355": "81",
"6375": "85",
"6395": "89",
"6415": "93",
"6435": "97",
"6455": "101",
"6475": "105",
"6495": "109",
"6515": "113",
"6535": "117",
"6555": "121",
"6575": "125",
"6595": "129",
"6615": "133",
"6635": "137",
"6655": "141",
"6675": "145",
"6695": "149",
"6715": "153",
"6735": "157",
"6755": "161",
"6775": "165",
"6795": "169",
"6815": "173",
"6835": "177",
"6855": "181",
"6875": "185",
"6895": "189",
"6915": "193",
"6935": "197",
"6955": "201",
"6975": "205",
"6995": "209",
"7015": "213",
"7035": "217",
"7055": "221",
"7075": "225",
"7095": "229",
"7115": "233",
}
|
#!/usr/bin/env python3
# coding: utf8
"""
constants.py
Date: 08-21-2019
Description: Defines the codes required for ansi code generation
"""
START = "\033["
END = "\033[0m"
COLOR_CODES = {
"k": "black",
"b": "blue",
"r": "red",
"g": "green",
"p": "purple",
"y": "yellow",
"c": "cyan",
"w": "white",
"lg": "light green",
"dg": "dark gray",
"lr": "light red",
"ly": "light yellow",
"lb": "light blue",
"lm": "light magenta",
"lc": "light cyan",
"n": "none",
"db": "dodger blue"
}
COLORS = {
"black": ("30m", "40;"),
"red": ("31m", "41;"),
"green": ("32m", "42;"),
"yellow": ("33m", "43;"),
"blue": ("34m", "44;"),
"purple": ("35m", "45;"),
"cyan": ("36m", "46;"),
"light gray": ("37m", "47;"),
"dark gray": ("90m", "100;"),
"light red": ("91m", "101;"),
"light green": ("92m", "102;"),
"light yellow": ("93m", "103;"),
"light blue": ("94m", "104;"),
"light purple": ("95m", "105;"),
"light cyan": ("96m", "106;"),
"white": ("97m", "107;"),
"none": ("39m", "49;"),
"dodger blue": ("38;5;33m", "48;5;33m")
}
STYLES = {
"NONE": "0;",
"BOLD": "1;",
"FADE": "2;",
"UNDERLINE": "4;",
"BLINK": "5;",
}
if __name__ == "__main__":
pass
|
def buy_card(n: int, p: list):
d = [0]*(n+1)
for i in range(1, n+1):
for j in range(1, i+1):
d[i] = max(d[i], d[i-j] + p[j-1])
return d[n]
def test_buy_card():
assert buy_card(4, [1, 5, 6, 7]) == 10
assert buy_card(5, [10, 9, 8, 7, 6]) == 50
assert buy_card(10, [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]) == 55
assert buy_card(10, [5, 10, 11, 12, 13, 30, 35, 40, 45, 47]) == 50
assert buy_card(4, [5, 2, 8, 10]) == 20
assert buy_card(4, [3, 5, 15, 16]) == 18
if __name__ == "__main__":
n = int(input())
p = list(map(int, input().split(' ')))
print(buy_card(n, p))
|
class Item:
item_id = 1
def __init__(self, name):
self.name = name
self.item_id = Item.item_id
Item.item_id += 1
tv = Item('LG 42')
computer = Item('Dell XPS')
print(tv.item_id)
print(computer.item_id)
# prints:
# 1
# 2 |
#!/usr/bin/env python3
"""Remove vowels and whitespace from a string and put the vowels at the end.
Title:
Disemvoweler
Description:
Make a program that removes every vowel and whitespace found in a string.
It should output the resulting disemvoweled string
with the removed vowels concatenated to the end of it.
For example 'Hello world' outputs 'Hllwrld eoo'.
"""
VOWELS = ("a", "e", "i", "o", "u")
def disemvowel(string: str) -> str:
"""Return disemvoweled version of string."""
new_string = ""
extra_chars = " "
for char in string:
if char.lower() in VOWELS:
extra_chars += char
elif char.isspace():
pass
else:
new_string += char
new_string += extra_chars
return new_string
def _start_interactively():
"""Start the program interactively through the command line."""
while True:
string = input("Please input a string: ")
print(disemvowel(string) + "\n")
if __name__ == "__main__":
_start_interactively()
|
# Dit is weer een encoder, dus gebruik instellinen die daarbij horen.
real_encoder = tf.keras.models.Sequential([
tf.keras.layers.Dense(784, activation=tf.nn.relu),
tf.keras.layers.Dense(128, activation=tf.nn.relu),
tf.keras.layers.Dense(2, activation=tf.nn.relu),
tf.keras.layers.Dense(128, activation=tf.nn.relu),
tf.keras.layers.Dense(784, activation=tf.nn.relu)
])
real_encoder.compile(loss=tf.keras.losses.mean_squared_error,
optimizer=tf.keras.optimizers.RMSprop(lr=0.0001, rho=0.9, epsilon=None, decay=0.0),
metrics = ['accuracy'])
# Dus ook: trainen op de input.
real_encoder.fit(xtr, xtr, epochs=10, batch_size=256)
print("Training performance:", real_encoder.evaluate(xtr, xtr))
# Zoals wellicht verwacht wanneer er niet wordt getraind op de labels,
# is het veel moeilijker de verschillend gelabelde plaatjes te onderscheiden
# in de bottleneck-laag. De performance van het model lijkt ook heel laag.
# Dit is echter niet zo'n betekenisvol getal: het is een maat voor hoe goed
# afzonderlijke pixels worden gereconstrueerd, en voor het eventueel kunnen
# herkennen van een plaatje kunnen die nog behoorlijk anders zijn, zoals we
# hieronder zullen zien.
# Predict de output, gegeven de input en laat ze beiden naast elkaar zien.
real_constructed = real_encoder.predict(xtr)
imsize = 28
aantal_im = len(xtr)
deze = np.random.randint(0, aantal_im)
plt.figure(figsize=(12, 24))
pp = plt.subplot(121)
number = np.reshape(real_constructed[deze], [imsize, imsize])
pp.imshow(number, cmap='Greys')
pp.set_xticklabels([])
pp.set_yticklabels([])
pp.set_title("Gereconstrueerd")
pp = plt.subplot(122)
number = np.reshape(xtr[deze], [imsize, imsize])
pp.imshow(number, cmap='Greys')
pp.set_xticklabels([])
pp.set_yticklabels([])
pp.set_title("Oorspronkelijke digit");
print("Nog lang zo slecht niet!")
|
SLOTS = [
[
0,
5460,
["172.17.0.2", 7000, "cf0da23bbea0ac65fd93d272358b59cd7ce3af25"],
["172.17.0.2", 7003, "ab35b1210fcae1010a463c65e1616b51d3d7a00b"],
],
[
9995,
9995,
["172.17.0.2", 7000, "cf0da23bbea0ac65fd93d272358b59cd7ce3af25"],
["172.17.0.2", 7003, "ab35b1210fcae1010a463c65e1616b51d3d7a00b"],
],
[
12182,
12182,
["172.17.0.2", 7000, "cf0da23bbea0ac65fd93d272358b59cd7ce3af25"],
["172.17.0.2", 7003, "ab35b1210fcae1010a463c65e1616b51d3d7a00b"],
],
[
5461,
9994,
["172.17.0.2", 7001, "d0299b606a9f2634ddbfc321e4164c1fc1601dc4"],
["172.17.0.2", 7004, "8e691f344dbf1b398792a7bca48ec7f012a2cc35"],
],
[
9996,
10922,
["172.17.0.2", 7001, "d0299b606a9f2634ddbfc321e4164c1fc1601dc4"],
["172.17.0.2", 7004, "8e691f344dbf1b398792a7bca48ec7f012a2cc35"],
],
[10923, 12181, ["172.17.0.2", 7002, "c80666a77621a0061a3af77a1fda46c94c2abcb9"]],
[12183, 16383, ["172.17.0.2", 7002, "c80666a77621a0061a3af77a1fda46c94c2abcb9"]],
]
INFO = {
"cluster_state": "ok",
"cluster_current_epoch": "1",
"cluster_slots_assigned": "16384",
"cluster_slots_ok": "16384",
"cluster_slots_pfail": "0",
"cluster_slots_fail": "0",
"cluster_known_nodes": "6",
"cluster_size": "3",
"cluster_current_epoch": "1",
"cluster_my_epoch": "1",
}
|
def emulate_catchup(replica, ppSeqNo=100):
if replica.isMaster:
replica.caught_up_till_3pc((replica.viewNo, ppSeqNo))
else:
replica.catchup_clear_for_backup()
def emulate_select_primaries(replica):
replica.primaryName = 'SomeAnotherNode'
replica._setup_for_non_master_after_view_change(replica.viewNo)
|
# this is the module which i will be
#calling and using again and again
def kolar():
print("I am a new module which will work i am call")
# this file save with same python path with new file name
|
f = open('Log-A.strace')
lines = f.readlines()
term = ' read('
term2 = 'pipe'
term3 = 'tty'
def extract_name(line, start_delimiter, end_delimiter):
name_start = line.find(start_delimiter)
name_end = line.find(end_delimiter, name_start + 1)
name = line[name_start + 1 : name_end]
return name
names = []
counts = []
for line in lines:
if 'read(' in line and 'pipe' not in line and 'tty' not in line:
name = extract_name(line, '<', '>')
if name not in names:
names.append(name)
counts.append(1)
else:
idx = names.index(name)
counts[idx] += 1
for i in range(len(names)):
name = names[i]
count = counts[i]
#print(name, count)
print(name + '\t' + str(count))
# example output
# ('/lib/x86_64-linux-gnu/libc-2.23.so', 4)
# ('/etc/nsswitch.conf', 4)
# ('/lib/x86_64-linux-gnu/libnss_compat-2.23.so', 2)
# ('/lib/x86_64-linux-gnu/libnsl-2.23.so', 2)
# ('/lib/x86_64-linux-gnu/libnss_nis-2.23.so', 2)
# ('/lib/x86_64-linux-gnu/libnss_files-2.23.so', 2)
# ('/lib/x86_64-linux-gnu/libselinux.so.1', 1)
# ('/lib/x86_64-linux-gnu/libpcre.so.3.13.2', 1)
# ('/lib/x86_64-linux-gnu/libdl-2.23.so', 1)
# ('/lib/x86_64-linux-gnu/libpthread-2.23.so', 1)
# ('/proc/filesystems', 2)
# ('/etc/locale.alias', 2)
# ('/proc/sys/kernel/ngroups_max', 2) |
TEMPLATE_SOURCE_TYPE = "TemplateSourceType"
# stairlight.yaml
STAIRLIGHT_CONFIG_FILE_PREFIX = "stairlight"
STAIRLIGHT_CONFIG_INCLUDE_SECTION = "Include"
STAIRLIGHT_CONFIG_EXCLUDE_SECTION = "Exclude"
STAIRLIGHT_CONFIG_SETTING_SECTION = "Settings"
DEFAULT_TABLE_PREFIX = "DefaultTablePrefix"
FILE_SYSTEM_PATH = "FileSystemPath"
REGEX = "Regex"
# mapping.yaml
MAPPING_CONFIG_FILE_PREFIX = "mapping"
MAPPING_CONFIG_GLOBAL_SECTION = "Global"
MAPPING_CONFIG_MAPPING_SECTION = "Mapping"
MAPPING_CONFIG_METADATA_SECTION = "Metadata"
FILE_SUFFIX = "FileSuffix"
LABELS = "Labels"
MAPPING_PREFIX = "MappingPrefix"
PARAMETERS = "Parameters"
TABLE_NAME = "TableName"
TABLES = "Tables"
# GCS
BUCKET_NAME = "BucketName"
PROJECT_ID = "ProjectId"
URI = "Uri"
# Redash
DATABASE_URL_ENVIRONMENT_VARIABLE = "DatabaseUrlEnvironmentVariable"
DATA_SOURCE_NAME = "DataSourceName"
QUERY_IDS = "QueryIds"
QUERY_ID = "QueryId"
|
#
# @lc app=leetcode id=696 lang=python3
#
# [696] Count Binary Substrings
#
# https://leetcode.com/problems/count-binary-substrings/description/
#
# algorithms
# Easy (61.31%)
# Total Accepted: 81.6K
# Total Submissions: 132.8K
# Testcase Example: '"00110011"'
#
# Give a binary string s, return the number of non-empty substrings that have
# the same number of 0's and 1's, and all the 0's and all the 1's in these
# substrings are grouped consecutively.
#
# Substrings that occur multiple times are counted the number of times they
# occur.
#
#
# Example 1:
#
#
# Input: s = "00110011"
# Output: 6
# Explanation: There are 6 substrings that have equal number of consecutive 1's
# and 0's: "0011", "01", "1100", "10", "0011", and "01".
# Notice that some of these substrings repeat and are counted the number of
# times they occur.
# Also, "00110011" is not a valid substring because all the 0's (and 1's) are
# not grouped together.
#
#
# Example 2:
#
#
# Input: s = "10101"
# Output: 4
# Explanation: There are 4 substrings: "10", "01", "10", "01" that have equal
# number of consecutive 1's and 0's.
#
#
#
# Constraints:
#
#
# 1 <= s.length <= 10^5
# s[i] is either '0' or '1'.
#
#
#
class Solution:
def countBinarySubstrings(self, s: str) -> int:
temp = []
current_length = 1
for i in range(1, len(s)):
if s[i] != s[i - 1]:
temp.append(current_length)
current_length = 1
else:
current_length += 1
temp.append(current_length)
total = 0
for i in range(1, len(temp)):
total += min(temp[i], temp[i - 1])
return total
if __name__ == '__main__':
print(Solution().countBinarySubstrings('10101')) |
#Desenvolva um programa que leia o primeiro termo e a razão de uma PA.
# No final mostre os 10 prmeiros termos dessa progressão.
n = int(input('Digite um numero: '))
razao = int(input('Digite uma razao: '))
dec = n + (10-1) * razao
for c in range (n, dec+razao, razao):
print(c, end=' ')
|
def reverse(s):
target = list(s)
for i in range(int(len(s) / 2)):
swap = target[i]
target[i] = target[len(s) - i - 1]
target[len(s) - i - 1] = swap
return ''.join(target)
if __name__ == '__main__':
s = 'abcdef'
print(reverse(s))
print(s[::-1])
|
"""피보나치 수열 Memoization"""
def fib_memo(n, cache):
if n < 3:
return 1
if n in cache:
return cache[n]
cache[n] = fib_memo(n - 2, cache) + fib_memo(n - 1, cache)
return cache[n]
def fib(n):
# n번째 피보나치 수를 담는 사전
fib_cache = {}
return fib_memo(n, fib_cache)
if __name__ == '__main__':
assert fib(10) == 55, 'fib(10) error'
assert fib(50) == 12586269025, 'fib(50) error'
assert fib(100) == 354224848179261915075, 'fib(100) error' |
valor_casa = float(input("Qual o valor do imovel? "))
salario = float(input("Qual salário do comprador? "))
anos = int(input("Em quantos anos deseja pagar? "))
print(f"{'ANALISANDO DADOS':~^50}")
print(f"Valor do imóvel: R$ {valor_casa:.2f}")
prestacao = valor_casa / (anos*12)
print(f"Valor da prestação: {prestacao:.2f}")
print("Emprestimo aceito. Valor da parcela inferior a 30% do salario do contratante") if prestacao <= (salario * .3) else print("Infelizmente o valor do emprestimo supera 30% do salario do contratante.") |
# -*- coding: utf-8 -*-
def bubble_sort(arr):
""" Sorts the input array using the bubble sort method.
The idea is to raise each value to it's final position through successive
swaps.
Complexity: O(n^2) in time, O(n) in space (sorting is done in place)
Args:
arr: list of keys to sort
Return:
list
"""
for i in range(len(arr) - 1, 0, -1):
for j in range(i):
if arr[j] > arr[j+1]:
(arr[j], arr[j+1]) = (arr[j+1], arr[j])
|
### Build String ###
class Solution1:
def backspaceCompare(self, S: str, T: str) -> bool:
def check(S):
S_new = []
for w in S:
if w != "#":
S_new.append(w)
elif len(S_new):
S_new.pop()
return S_new
return check(S) == check(T)
### Two Pointer ###
|
class DiGraph:
def __init__(self):
self.nodes = dict()
self.edges = []
def copy(self):
H_ = __class__()
H_.add_edges_from(self.edges)
return H_
def __eq__(self, other):
return len(set(self.edges) ^ set(other.edges)) == 0
def __str__(self):
return str(self.edges)
__repr__ = __str__
def maximal_non_branching_paths(self):
# return list of paths (made up of graph nodes)
paths = []
visited_edges = set()
for node in self.nodes:
if not self.is_1_in_1_out(node):
if self.out_degree(node) > 0:
out_edges = self.nodes[node]['out_edges']
for edge in out_edges:
visited_edges.add(edge)
to_node = edge.node_b
non_branching_path = [edge]
while self.is_1_in_1_out(to_node):
out_edge = self.nodes[to_node]['out_edges'][0]
non_branching_path.append(out_edge)
visited_edges.add(out_edge)
to_node = out_edge.node_b
paths.append(non_branching_path)
# everything left must be in a cycle
cycle_edges = set(
filter(
lambda edge: edge not in visited_edges,
self.edges))
while len(cycle_edges) > 0:
edge = cycle_edges.pop()
non_branching_path = [edge]
start_node = edge.node_a
to_node = edge.node_b
while to_node != start_node:
out_edge = self.nodes[to_node]['out_edges'][0]
non_branching_path.append(out_edge)
cycle_edges.remove(out_edge)
visited_edges.add(out_edge)
to_node = out_edge.node_b
paths.append(non_branching_path)
return paths
def neighbor_graphs(self, sub_graph, super_graph, k):
# generator for the k-plus neighbors
if k >= 0:
yield sub_graph
for neighbor in sub_graph.plus_neighbors(super_graph):
yield from neighbor.neighbor_graphs(neighbor, super_graph, k - 1)
def adjacent_graphs(self, sub_graph, super_graph, k):
if k >= 0:
yield sub_graph
for neighbor in sub_graph.plus_neighbors(super_graph):
yield from neighbor.adjacent_graphs(neighbor, super_graph, k - 1)
for neighbor in sub_graph.minus_neighbors():
yield from neighbor.adjacent_graphs(neighbor, super_graph, k - 1)
def plus_neighbor_edges(self, super_graph):
# TODO this is ugly, make neater
paths = list()
# first generate paths
for edge in self.edges:
from_, to = edge.node_a, edge.node_b
from_super_edges = super_graph.nodes[to]['out_edges']
to_super_edges = super_graph.nodes[from_]['in_edges']
def not_in_H(edge): return edge not in self.edges
from_super_edges = filter(not_in_H, from_super_edges)
to_super_edges = filter(not_in_H, to_super_edges)
paths.extend(from_super_edges)
paths.extend(to_super_edges)
from_super_edges = super_graph.nodes[from_]['out_edges']
to_super_edges = super_graph.nodes[to]['in_edges']
def not_in_H(edge): return edge not in self.edges
from_super_edges = filter(not_in_H, from_super_edges)
to_super_edges = filter(not_in_H, to_super_edges)
paths.extend(from_super_edges)
paths.extend(to_super_edges)
paths = set(paths)
return paths
def plus_neighbors(self, super_graph):
paths = self.plus_neighbor_edges(super_graph)
# then generate a graph for each unique path
for path in paths:
H_ = self.copy()
H_.add_edge(path)
yield H_
def minus_neighbors(self):
for edge in self.edges:
H_ = self.copy()
H_.remove_edge(edge)
yield H_
def add_edge(self, edge):
node_a, node_b = edge.node_a, edge.node_b
self.add_node(node_a)
self.add_node(node_b)
self.nodes[node_a]['out_edges'].append(edge)
self.nodes[node_b]['in_edges'].append(edge)
self.edges.append(edge)
def add_node(self, node):
if node not in self.nodes:
self.nodes[node] = {'in_edges': [], 'out_edges': []}
def in_degree(self, node):
return len(self.nodes[node]['in_edges'])
def out_degree(self, node):
return len(self.nodes[node]['out_edges'])
def is_1_in_1_out(self, node):
return self.in_degree(node) == 1 and self.out_degree(node) == 1
def add_edges_from(self, edges):
for edge in edges:
self.add_edge(edge)
def add_nodes_from(self, nodes):
for node in nodes:
self.add_node(node)
def remove_edge(self, edge):
node_a, node_b = edge.node_a, edge.node_b
self.nodes[node_a]['out_edges'].remove(edge)
self.nodes[node_b]['in_edges'].remove(edge)
self.edges.remove(edge)
if len(self.nodes[node_a]['out_edges']) + \
len(self.nodes[node_a]['in_edges']) == 0:
self.nodes.pop(node_a)
if len(self.nodes[node_b]['out_edges']) + \
len(self.nodes[node_b]['in_edges']) == 0:
self.nodes.pop(node_b)
def remove_node(self, node):
for edge in self.nodes[node]['in_edges']:
self.remove_edge(edge)
for edge in self.nodes[node]['out_edges']:
self.remove_edge(edge)
assert node not in self.nodes
def remove_edges_from(self, edges):
for edge in edges:
self.remove_edge(edge)
def remove_nodes_from(self, nodes):
for node in nodes:
self.remove_node(node)
def subgraph_from_edgelist(self, edges):
# TODO assert edges are in graph
pass
class RedBlueDiGraph(DiGraph):
RED = 'red'
BLUE = 'blue'
def __init__(self):
super(RedBlueDiGraph, self).__init__()
self.coverage = 0
self.color = dict()
def __str__(self):
return str([(edge, self.color[edge]) for edge in self.edges])
def copy(self):
H_ = __class__()
colors = [self.color[edge] for edge in self.edges]
H_.add_edges_from(self.edges, colors=colors)
H_.coverage = self.coverage
#H_.color = dict(self.color)
return H_
def score(self, alpha):
paths = self.maximal_non_branching_paths()
total_path_length = sum([len(path) for path in paths])
avg_path_length = total_path_length / \
len(paths) if len(paths) > 0 else 0
return alpha * self.coverage + (1 - alpha) * avg_path_length
def add_edge(self, edge, color):
super(RedBlueDiGraph, self).add_edge(edge)
if color == self.RED:
self.color[edge] = self.RED
self.coverage += 1
else:
self.coverage -= 1
self.color[edge] = self.BLUE
def add_edges_from(self, edges, colors=None):
if colors is not None:
assert len(colors) == len(edges)
for i, edge in enumerate(edges):
self.add_edge(edge, color=colors[i])
else:
super(RedBlueDiGraph, self).add_edges_from(edges)
def plus_neighbors(self, super_graph):
paths = self.plus_neighbor_edges(super_graph)
# then generate a graph for each unique path
for path in paths:
H_ = self.copy()
H_.add_edge(path, color=super_graph.color[path])
yield H_
def calculate_coverage(self):
return self.coverage
def remove_edge(self, edge):
if self.color[edge] == self.RED:
self.coverage -= 1
else:
self.coverage += 1
super(RedBlueDiGraph, self).remove_edge(edge)
if edge not in self.edges:
self.color.pop(edge)
|
'''
Problem 34
@author: Kevin Ji
'''
FACTORIALS = [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800]
def factorial(number):
return FACTORIALS[number]
def is_curious_num(number):
temp_num = number
curious_sum = 0
while temp_num > 0:
curious_sum += factorial(temp_num % 10)
temp_num //= 10
return number == curious_sum
# Tests
#print(is_curious_num(145)) # True
#print(is_curious_num(100)) # False
cur_sum = 0
for num in range(3, 1000000):
if is_curious_num(num):
cur_sum += num
print(cur_sum)
|
n= int(input("Digite o valor de n: "))
sub = n - 1
fat = n
while n != 0:
while sub != 1:
fat = fat * sub
sub = sub -1
print(fat)
|
class Neuron:
# TODO: Create abstraction of generic unsupervised neuron
pass
|
""" Melhore o desafio061, perguntando para o usuário se ele quer
mostrar mais alguns termos. O programa encerra quando ele disser
que quer mostrar 0 termos."""
pr_termo = int(input('Primeiro termo: '))
razao = int(input('Razão: '))
print('PROGRESSÃO ARITMETICA =', end=' ')
c = 1
total = 0
mais = 10
while mais != 0:
total += mais
while c <= total:
pa = pr_termo + (c - 1) * razao
print(f'{pa}..', end=' ')
c += 1
print('*')
mais = int(input('Quantos termos você quer mostrar mais?'))
print('FIM') |
expected_output = {
'switch': {
"1": {
'system_temperature_state': 'ok',
}
}
}
|
def addition(x: int, y: int) -> int:
"""Adds two integers together and returns the result."""
return x + y
if __name__ == '__main__':
a, b = 1, 2
result = addition(a, b)
print(result) |
# 9093 단어 뒤집기
line = int(input())
sentances = [input() for _ in range(line)]
print("\n".join([" ".join([s[::-1] for s in sentance.split()])
for sentance in sentances]))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.