content
stringlengths 7
1.05M
|
---|
"""
Codemonk link: https://www.hackerearth.com/practice/algorithms/dynamic-programming/introduction-to-dynamic-programming-1/practice-problems/algorithm/once-upon-a-time-in-time-land/
In a mystical TimeLand, a person's health and wealth is measured in terms of time(seconds) left. Suppose a person there
has 24x60x60 = 86400 seconds left, then he would live for another 1 day. A person dies when his time left becomes 0.
Some time-amount can be borrowed from other person, or time-banks. Some time-amount can also be lend to another person,
or can be used to buy stuffs. Our hero Mr X, is in critical condition, has very less time left. Today's the inaugural
day of a new time-bank. So they are giving away free time-amount worth 1000 years. Bank released N slips, A[1],
A[2], .... A[N]. Each slip has a time-amount(can be +ve as well as -ve). A person can pick any number of slips (even
none, or all of them, or some of them) out of the N slips. But bank introduced a restriction, they announced one more
number K. Restriction is that, if a person picks a slip A[i], then the next slip that he can choose to pick will be
A[i+K+1]. It means there should be a difference of at least K between the indices of slips picked. Now slip(s) should be
picked in such a way that their sum results in maximum positive time-amount sum possible with the given restriction. If
you predict the maximum positive sum possible, then you win. Mr X has asked for your help. Help him win the lottery, and
make it quick!
Input - Output:
First line of the test file contains single number T, the number of test cases to follow.
Each test case consists of two lines.
First line contains two numbers N and K, separated by a space. Second line contains the N
numbers A[1], A[2] ..... A[N] separated by space.
For every test case, output in a single line the maximum positive sum possible, that is output for the case.
Sample input:
2
10 1
1 2 -3 -5 4 6 -3 2 -1 2
10 2
1 2 -3 -5 4 6 -3 2 -1 2
Sample Output:
12
10
"""
"""
We are either going to pick the previous or the current money plus the k+1 previous. The answer is given by the
expression dp[i] = max(dp[i-1], dp[i-k-1] + bank[i]). That's a linear solution.
Final complexity: O(N)
"""
t = int(input())
for _ in range(t):
n, k = map(int, input().split())
bank = list(map(int, input().split()))
dp = [0] * n
if n == 0:
print(0)
elif n == 1:
print((max(bank[0], bank[1])), 0)
elif k > n:
print(max(bank))
else:
for j in range(n):
if j <= k:
if bank[j] < 0:
if j == 0:
dp[j] = 0
else:
dp[j] = dp[j-1]
else:
if j == 0:
dp[j] = bank[j]
else:
dp[j] = max(bank[j], dp[j-1])
else:
dp[j] = max(bank[j] + dp[j-k-1], dp[j-1])
if dp[n-1] > 0:
print(dp[n-1])
else:
print(0)
|
class TreeNode:
def __init__(self, data):
self.data = data
self.parent = None
self.children = []
self.__length = 0
def add_child(self, children):
self.__length += len(children)
for child in children:
child.parent = self
self.children.append(child)
def __len__(self):
return self.__length
def get_level(self):
level = 0
parent = self.parent
while parent:
level += 1
parent = parent.parent
return level
def print_tree(self, properties, level="DEEPEST"):
space_levels = self.get_level()
if level != "DEEPEST" and space_levels > level:
return
if level == "DEEPEST":
level = len(self)+1
spaces = " " * space_levels * 3
prefix = spaces + "|__" if space_levels > 0 else ""
print_this = ""
if properties == "all":
properties = list(self.data.keys())
for property in properties:
print_this += self.data[property] + " "
print (prefix + print_this.strip())
if self.children:
for child in self.children:
child.print_tree(properties, level)
if __name__ == "__main__":
root = TreeNode(data={"name": "Nilpul", "designation": "(CEO)"})
cto = TreeNode(data={"name": "Chinmay", "designation": "(CTO)"})
it_head = TreeNode(data={"name": "Vishwa", "designation": "(Infrastructure Head)"})
it_head.add_child([
TreeNode(data={"name": "Dhaval", "designation": "(Cloud Manager)"}),
TreeNode(data={"name": "Abhijit", "designation": "(App Manager)"}),
])
app_head = TreeNode(data={"name": "Aamir", "designation": "(Application Head)"})
cto.add_child([it_head, app_head])
hr_head = TreeNode(data={"name": "Gels", "designation": "(HR Head)"})
hr_head.add_child([
TreeNode(data={"name": "Peter", "designation": "(Recruitment Manager)"}),
TreeNode(data={"name": "George", "designation": "(Policy Manager)"}),
])
root.add_child([cto, hr_head])
print ("-"*20+"all"+"-"*20)
root.print_tree("all")
print ("-"*20+"name"+"-"*20)
root.print_tree(("name",))
print ("-"*20+"designation"+"-"*20)
root.print_tree(("designation",))
print ("-"*20+"name, designation"+"-"*20)
root.print_tree(("name", "designation"))
print ("-"*20+"name, level=0"+"-"*20)
root.print_tree("all", level=0)
print ("-"*20+"name, level=1"+"-"*20)
root.print_tree("all", level=1)
print ("-"*20+"name, level=2"+"-"*20)
root.print_tree("all", level=2)
print ("-"*20+"name, level=3"+"-"*20)
root.print_tree("all", level=3)
|
# Copyright (C) 2020-Present the hyssop authors and contributors.
#
# This module is part of hyssop and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
'''
File created: September 4th 2020
Modified By: hsky77
Last Updated: April 6th 2021 22:26:59 pm
'''
Version = '0.0.7'
|
class Extractor(object):
def __init__(self, transcript):
self.transcript = transcript
def get_location(self):
return "TBD"
def get_date(self):
return "TBD"
|
"""fglib -- Factor Graph Library.
The factor graph library (fglib) is a Python package
to simulate message passing on factor graphs.
Modules:
inference: Module for inference algorithms.
graphs: Module for factor graphs.
nodes: Module for nodes of factor graphs.
edges: Module for edges of factor graphs.
rv: Module for random variables.
utils: Module for utilities.
"""
__all__ = ["inference", "graphs", "nodes", "edges", "rv", "utils"]
__version__ = "0.2.4"
|
class Car:
def __init__(self, speed_input, angle_input, direction, radius, target,brake):
self.speed = speed_input #float, speed input
self.angle = angle_input #integer, servomotor input
self.direction = direction #1 if right, -1 if left
self.radius = radius #curvature radius
self.target = target #[xt,yt], coordinates of the targeted point
self.brake = brake #booléen (1 si décélération)
class Lidar:
def __init__(self, data, temp, vrel):
self.data = data #array, data collected at t=k*delta_t
self.prev_data = temp #array, data collected at t=(k-1)*delta_t
self.vrel = vrel #detected points relative speed for each Lidar angle index |
# 🚨 Don't change the code below 👇
age = input("What is your current age?")
# 🚨 Don't change the code above 👆
#Write your code below this line 👇
#Casts variable age as an integer
age = int(age)
#Computes years left to live to ease next calculations
years_remaining = (90 - age)
#Computes years, months, weeks and days left to live
months_remaining = years_remaining * 12
weeks_remaining = years_remaining * 52
days_remaining = years_remaining * 365
#Prints the result
print(f"You have {days_remaining} days, {weeks_remaining} weeks, and {months_remaining} months left.") |
def test_all_function(numeric_state):
state = numeric_state
state["subtracted"] = state["amount"] - state["amount"]
space = state.space[1]
all_events = space.all()
assert len(all_events) == 3 |
#input: data from communties_data.txt
#output: data useful for predictive analysis (ie: excluding first 5 attributes) in 2D Array
def clean_raw_data(data):
rows = (row.strip().split() for row in data)
leaveLoop = 0
cleaned_data = []
for row in rows:
tmp = [stat.strip() for stat in row[0].split(',')]
cleaned_data.append(tmp[5:])
return cleaned_data
#input: data from summary.txt
#output: data in 2D Array
def clean_sum_data(data):
# Summary data contains the Attribute, Min, Max, Mean, SD, Correl, Median, Mode, Missing
sum_rows = (row.strip().split() for row in data)
new_list = []
for row in sum_rows:
new_list.append(row)
return new_list
#input: output of clean_raw_data, clean_sum_data, use median value
#output clean_raw_data with the '?' values replaced with the median value if True or mean if False
def replace_null_data(old_replacee, replacer, median=True):
replacee = list(old_replacee)
for row in replacee:
replaced = False
old_row = list(row)
for col in range(len(row)):
if row[col] == '?':
replaced = True
if median:
row[col] = replacer[col][6]
else:
row[col] = replacer[col][3]
return replacee
# Looks funny but this makes sure it runs when called by a python file in a different directory and still work when run locally
summary_data = open("../Data/summary.txt", "r")
raw_data = open("../Data/communities_data.txt", "r")
cleaned_data = clean_raw_data(raw_data)
sumarized_data = clean_sum_data(summary_data)
usable_data = replace_null_data(cleaned_data, sumarized_data) |
with open("testFile/read.txt") as file:
# print(len(file.read().strip().split()))
for line in file:
print(line.strip().split(","))
# r :只读 ,w:只写,文件若存在则清空内容,不存在则创建,a:追加,不会清空内容,r+ :读写模式
""""
r 以只读方式打开文件。文件的指针将会放在文件的开头。这是默认模式。
rb 以二进制格式打开一个文件用于只读。文件指针将会放在文件的开头。
r+ 打开一个文件用于读写。文件指针将会放在文件的开头。
rb+ 以二进制格式打开一个文件用于读写。文件指针将会放在文件的开头。
w 打开一个文件只用于写入。如果该文件已存在则打开文件,并从开头开始编辑,即原有内容会被删除。如果该文件不存在,创建新文件。
wb 以二进制格式打开一个文件只用于写入。如果该文件已存在则打开文件,并从开头开始编辑,即原有内容会被删除。如果该文件不存在,创建新文件。
w+ 打开一个文件用于读写。如果该文件已存在则打开文件,并从开头开始编辑,即原有内容会被删除。如果该文件不存在,创建新文件。
wb+ 以二进制格式打开一个文件用于读写。如果该文件已存在则打开文件,并从开头开始编辑,即原有内容会被删除。如果该文件不存在,创建新文件。
a 打开一个文件用于追加。如果该文件已存在,文件指针将会放在文件的结尾。也就是说,新的内容将会被写入到已有内容之后。如果该文件不存在,创建新文件进行写入。
ab 以二进制格式打开一个文件用于追加。如果该文件已存在,文件指针将会放在文件的结尾。也就是说,新的内容将会被写入到已有内容之后。如果该文件不存在,创建新文件进行写入。
a+ 打开一个文件用于读写。如果该文件已存在,文件指针将会放在文件的结尾。文件打开时会是追加模式。如果该文件不存在,创建新文件用于读写。
ab+ 以二进制格式打开一个文件用于追加。如果该文件已存在,文件指针将会放在文件的结尾。如果该文件不存在,创建新文件用于读写。
"""
with open("testFile/write.txt", "a") as file_object:
file_object.write("write object 1\n")
file_object.write("write object 2\n")
file_object.write("write object 3\n")
file_object.write("write object 5\n")
file_object.write("write object 6\n\n")
|
marcador = 30 * '\033[1;34m=\033[m'
print(marcador)
l = float(input('Informe o primeiro lado'))
l2 = float(input('Informe o segundo lado'))
l3 = float(input('Informe o terceiro lado'))
if l + l2 > l3 and l + l3 > l2 and l2 + l3 > l:
print('As medidas \033[1;32mFORMAM\033[m um triângulo')
if l == l2 == l3:
print('Esse é um triângulo \033[1;36mEQUILATERO\033[m')
elif l == l2 or l == l3 or l2 == l3:
print('Esse é um triângulo \033[1;36mISOSCELES\033[m')
else:
print('Esse é um triângulo \033[1;36mESCALENO\033[m')
else:
print('As medidas \033[1;31mNÃO\033[m formam um triângulo')
print(marcador)
|
"""
entrada
distancia=>int=>km
salida
deuda por pagar
"""
km=int(input("distancia recorrida "))
if (km<300):
print("se cancela 50.000 ")
elif(km>=300) and (km<=1000):
total=(km-300)*30000+70000
print(" su deuda es de: "+str(total))
elif(km>1000):
total=(km-300)*9000+150000
print(" su deuda es de: "+str(total))
|
"""
Starts a game against the computer
"""
# TODO |
#
# PySNMP MIB module Juniper-DS3-CONF (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Juniper-DS3-CONF
# Produced by pysmi-0.3.4 at Mon Apr 29 19:51:33 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
SingleValueConstraint, ConstraintsUnion, ConstraintsIntersection, ValueRangeConstraint, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ConstraintsUnion", "ConstraintsIntersection", "ValueRangeConstraint", "ValueSizeConstraint")
juniAgents, = mibBuilder.importSymbols("Juniper-Agents", "juniAgents")
NotificationGroup, ModuleCompliance, AgentCapabilities = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "AgentCapabilities")
MibScalar, MibTable, MibTableRow, MibTableColumn, Unsigned32, MibIdentifier, Counter64, Bits, TimeTicks, Integer32, NotificationType, ModuleIdentity, IpAddress, Counter32, Gauge32, ObjectIdentity, iso = mibBuilder.importSymbols("SNMPv2-SMI", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Unsigned32", "MibIdentifier", "Counter64", "Bits", "TimeTicks", "Integer32", "NotificationType", "ModuleIdentity", "IpAddress", "Counter32", "Gauge32", "ObjectIdentity", "iso")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
juniDs3Agent = ModuleIdentity((1, 3, 6, 1, 4, 1, 4874, 5, 2, 11))
juniDs3Agent.setRevisions(('2003-09-29 21:05', '2003-01-30 19:08', '2003-01-30 16:37', '2002-08-27 18:48', '2001-04-18 19:41',))
if mibBuilder.loadTexts: juniDs3Agent.setLastUpdated('200309292105Z')
if mibBuilder.loadTexts: juniDs3Agent.setOrganization('Juniper Networks, Inc.')
juniDs3AgentV1 = AgentCapabilities((1, 3, 6, 1, 4, 1, 4874, 5, 2, 11, 1))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juniDs3AgentV1 = juniDs3AgentV1.setProductRelease('Version 1 of the DS3 component of the JUNOSe SNMP agent. This version\n of the DS3 component was supported in JUNOSe 1.0 system releases.')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juniDs3AgentV1 = juniDs3AgentV1.setStatus('obsolete')
juniDs3AgentV2 = AgentCapabilities((1, 3, 6, 1, 4, 1, 4874, 5, 2, 11, 2))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juniDs3AgentV2 = juniDs3AgentV2.setProductRelease('Version 2 of the DS3 component of the JUNOSe SNMP agent. This version\n of the DS3 component was supported in JUNOSe 1.1 thru JUNOSe 2.5 system\n releases.')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juniDs3AgentV2 = juniDs3AgentV2.setStatus('obsolete')
juniDs3AgentV3 = AgentCapabilities((1, 3, 6, 1, 4, 1, 4874, 5, 2, 11, 3))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juniDs3AgentV3 = juniDs3AgentV3.setProductRelease('Version 3 of the DS3 component of the JUNOSe SNMP agent. This version\n of the DS3 component was supported in JUNOSe 2.6 and subsequent JUNOSe\n 2.x system releases.')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juniDs3AgentV3 = juniDs3AgentV3.setStatus('obsolete')
juniDs3AgentV4 = AgentCapabilities((1, 3, 6, 1, 4, 1, 4874, 5, 2, 11, 4))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juniDs3AgentV4 = juniDs3AgentV4.setProductRelease('Version 4 of the DS3 component of the JUNOSe SNMP agent. This version\n of the DS3 component was supported in JUNOSe 3.x system releases.')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juniDs3AgentV4 = juniDs3AgentV4.setStatus('obsolete')
juniDs3AgentV5 = AgentCapabilities((1, 3, 6, 1, 4, 1, 4874, 5, 2, 11, 5))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juniDs3AgentV5 = juniDs3AgentV5.setProductRelease('Version 5 of the DS3 component of the JUNOSe SNMP agent. This version\n of the DS3 component was supported in JUNOSe 4.0 system releases.')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juniDs3AgentV5 = juniDs3AgentV5.setStatus('obsolete')
juniDs3AgentV6 = AgentCapabilities((1, 3, 6, 1, 4, 1, 4874, 5, 2, 11, 6))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juniDs3AgentV6 = juniDs3AgentV6.setProductRelease('Version 6 of the DS3 component of the JUNOSe SNMP agent. This version\n of the DS3 component is supported in JUNOSe 4.1 and subsequent system\n releases.')
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
juniDs3AgentV6 = juniDs3AgentV6.setStatus('current')
mibBuilder.exportSymbols("Juniper-DS3-CONF", juniDs3Agent=juniDs3Agent, juniDs3AgentV5=juniDs3AgentV5, juniDs3AgentV2=juniDs3AgentV2, juniDs3AgentV6=juniDs3AgentV6, juniDs3AgentV3=juniDs3AgentV3, PYSNMP_MODULE_ID=juniDs3Agent, juniDs3AgentV1=juniDs3AgentV1, juniDs3AgentV4=juniDs3AgentV4)
|
"""pessoa.py em 2021-03-01. Projeto pythonbirds.
"""
class Pessoa:
olhos = 2 # atributo default ou atributo de classe
def __init__(self, *filhos, nome=None, idade=35):
self.nome = nome
self.idade = idade
self.filhos = list(filhos)
def cumprimentar(self):
return f'Olá, meu nome é {self.nome}'
@staticmethod
def metodo_estatico():
return 42
@classmethod
def nome_e_atributos_de_classe(cls):
return f'{cls} - olhos {cls.olhos}'
class Homem(Pessoa):
def cumprimentar(self):
cumprimentar_classe_pai = super().cumprimentar()
return f'{cumprimentar_classe_pai}. Aperto de mão.'
class Mutante(Pessoa):
olhos = 3
if __name__ == '__main__':
renzo = Mutante(nome='Renzo')
cicero = Homem(renzo, nome='Cícero')
print(Pessoa.cumprimentar(cicero))
print(id(cicero))
print(cicero.cumprimentar())
print(cicero.nome)
print(cicero.idade)
for filho in cicero.filhos:
print(filho.nome)
cicero.sobrenome = 'Rodrigues' # atributo criado dinamicamente para esta instancia
print(cicero.__dict__)
print(renzo.__dict__)
del cicero.filhos
cicero.olhos = 1
print(cicero.__dict__)
print(renzo.__dict__)
print(Pessoa.olhos)
print(cicero.olhos)
print(renzo.olhos)
print(id(Pessoa.olhos), id(cicero.olhos), id(renzo.olhos))
print(Pessoa.metodo_estatico(), cicero.metodo_estatico())
print(Pessoa.nome_e_atributos_de_classe(), cicero.nome_e_atributos_de_classe())
pessoa = Pessoa('Anonimo')
print(isinstance(pessoa, Pessoa))
print(isinstance(pessoa, Homem))
print(isinstance(renzo, Pessoa))
print(isinstance(renzo, Homem))
print(renzo.olhos)
print(cicero.cumprimentar())
print(renzo.cumprimentar())
|
def newman_conway(num):
""" Returns a list of the Newman Conway numbers for the given value.
Time Complexity: O(n)
Space Complexity: O(n)
"""
if num == 0:
raise ValueError
if num == 1:
return '1'
if num == 2:
return '1 1'
sequence = [0, 1, 1]
for i in range(3, num + 1):
next_num = sequence[sequence[i - 1]] + sequence[i - sequence[i - 1]]
sequence.append(next_num)
string_sequence = [str(number) for number in sequence[1:]]
string_sequence = ' '.join(string_sequence)
return string_sequence
|
# -*- coding: utf-8 -*-
#
# Copyright (C) 2019 Edward Lau <[email protected]>
# Licensed under the MIT License.
#
__version__ = '0.1.0'
|
"""
1.Faça um Programa que mostre a mensagem "Alo mundo" na tela.
"""
print("Faça um Programa que mostre a mensagem 'Alo mundo' na tela.")
print("Olá mundo!")
|
class Solution(object):
def searchMatrix(self, matrix, target):
"""
:type matrix: List[List[int]]
:type target: int
:rtype: bool
"""
if len(matrix) == 0:
return False
n, m = len(matrix), len(matrix[0])
start, end = 0, n * m - 1
while start + 1 < end:
mid = start + (end - start) / 2
x, y = mid // m, mid % m
if matrix[x][y] < target:
start = mid
else:
end = mid
if m:
x, y = start // m, start % m
if matrix[x][y] == target:
return True
x, y = end // m, end % m
if matrix[x][y] == target:
return True
return False
|
# -*- coding: utf-8 -*-
"""Custom exceptions."""
# Part of StackMUD (https://github.com/whutch/stackmud)
# :copyright: (c) 2020 Will Hutcheson
# :license: MIT (https://github.com/whutch/stackmud/blob/master/LICENSE.txt)
class AlreadyExists(Exception):
"""Exception for adding an item to a collection it is already in."""
def __init__(self, key, old, new=None):
self.key = key
self.old = old
self.new = new
|
expected_output = {
"controller_config": {
"group_name": "default",
"ipv4": "10.9.3.4",
"mac_address": "AAAA.BBFF.8888",
"multicast_ipv4": "0.0.0.0",
"multicast_ipv6": "::",
"pmtu": "N/A",
"public_ip": "N/A",
"status": "N/A",
},
"mobility_summary": {
"domain_id": "0x34ac",
"dscp_value": "48",
"group_name": "default",
"keepalive": "10/3",
"mac_addr": "687d.b4ff.b9e9",
"mgmt_ipv4": "10.20.30.40",
"mgmt_ipv6": "",
"mgmt_vlan": "143",
"multi_ipv4": "0.0.0.0",
"multi_ipv6": "::",
},
} |
'''
# Sample code to perform I/O:
name = input() # Reading input from STDIN
print('Hi, %s.' % name) # Writing output to STDOUT
# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
'''
# Write your code here
def right(a,b):
r=a
for i in range(b):
r=r[-1:]+r[:-1]
r=''.join(r)
return int(r)
def left(a,b):
r=a
for i in range(b):
r.append(a.pop(0))
r=''.join(r)
return int(r)
def btod(n):
if n==0:
return 0
return n%10+2*(btod(n//10))
for i in range(int(input())):
a,b,c=input().split()
a=int(a)
b=int(b)
a=bin(a)
a=a[2:]
a=str(a)
if (16-len(a))!=0:
a="0"*(16-len(a))+a
a=list(a)
if c=='L':
res=left(a,b)
res=btod(res)
print(res)
if c=='R':
res=right(a,b)
res=btod(res)
print(res)
|
ESCAPE_CODE = "\033["
COLORS = {'black': 30, 'red': 31, 'green':32, 'yellow': 33, 'blue': 34, 'purple': 35, 'cyan': 36, 'white': 37}
BRIGHTS = {"bright "+color: value + 60 for color, value, in COLORS.items()}
TEXT_COLOR = {'reset': 0, **COLORS, **BRIGHTS}
TEXT_STYLE = {'reset': 0, 'no effect': 0, 'bold': 1, 'underline': 2, 'negative1': 3, 'negative2': 5}
BACKGROUND_COLOR = {color: value+10 for color, value in TEXT_COLOR.items()}
BACKGROUND_COLOR['reset'] = 0
RESET = (ESCAPE_CODE + "0;0;0m")
def highlight(text_, color='reset', style='reset', background='reset'):
""" Decorate text using colors and other styles
Parameters
----------
text_ : str
The text to be decorated
color : str
Code of the text color
style : str
Code of the text style
background : str
Code of the background style
Returns
-------
str
Decorated text
"""
"""
Use color and other highlights
:param text_: text to be highlighted
:param color: text color
:param style: text style (reset==no effect |b old | underline | etc.)
:param background: background color
:return: escape-coded highlighted string, rest-code in the end
"""
return (ESCAPE_CODE
+ str(TEXT_STYLE.get(style.lower(), 'no_effect')) + ";"
+ str(TEXT_COLOR.get(color.lower(), 'red')) + ";"
+ str(BACKGROUND_COLOR.get(background.lower(), 'black')) + "m"
+ str(text_)
+ RESET)
|
# Write a function to check if the array is sorted or not
arr = [1,2,3,5,9]
n = len(arr)
i = 0
def isSortedArray(arr,i, n):
if (i==n-1):
return True
if arr[i] < arr[i+1] and isSortedArray(arr,i+1,n):
return True
else:
return False
print(isSortedArray(arr,i,n))
|
dict = {
"__open_crash__": 'Crash save {} exists, do you want to recover it?',
"__about__": "Simple route designer using BSicon",
"__export_fail__": 'Failed to export {}',
"__open_fail__": 'Failed to open {}',
"__paste_no_valid_blocks__": "No valid blocks to paste",
"__paste_filter_invalid_blocks__": "Invalid blocks have been filtered ({} remain)",
"__export_success__": 'Successfully exported to {}',
"__download_icons__": "Downloading missing blocks from wikimedia",
"__block_dir__": "No blocks available, please install 7-zip / p7zip and unpack blocks.7z to {}",
}
|
def fact(n):
ans = 1
for i in range(1,n+1):
ans = ans*i
return ans
T = int(input())
while T:
n = input()
n = int(n)
print(fact(n))
T = T-1
|
"""
Definition of Interval.
class Interval(object):
def __init__(self, start, end):
self.start = start
self.end = end
"""
class Solution:
"""
@param A: An integer list
@param queries: An query list
@return: The result list
"""
def intervalSum(self, A, queries):
self.segmentTree = [0 for i in range(4*len(A))]
if A :
self.buildSegmentTree(0,0,len(A)-1,A)
result = []
for query in queries :
result.append(self.query(0,0,len(A)-1,query.start,query.end))
return result
def buildSegmentTree(self,treeIndex,left,right,A):
if left == right :
self.segmentTree[treeIndex] = A[left]
return
mid = (left+right) >> 1
leftIndex = 2*treeIndex+1
rightIndex = 2*treeIndex+2
self.buildSegmentTree(leftIndex,left,mid,A)
self.buildSegmentTree(rightIndex,mid+1,right,A)
self.segmentTree[treeIndex] = self.segmentTree[leftIndex]+self.segmentTree[rightIndex]
def query(self,treeIndex,treeLeft,treeRight,queryLeft,queryRight):
if treeLeft == queryLeft and treeRight == queryRight :
return self.segmentTree[treeIndex]
mid = (treeLeft+treeRight) >> 1
leftIndex = 2*treeIndex+1
rightIndex = 2*treeIndex+2
if queryLeft>mid :
return self.query(rightIndex,mid+1,treeRight,queryLeft,queryRight)
elif queryRight<mid+1 :
return self.query(leftIndex,treeLeft,mid,queryLeft,queryRight)
else :
return self.query(leftIndex,treeLeft,mid,queryLeft,mid) + self.query(rightIndex,mid+1,treeRight,mid+1,queryRight) |
BOARDS = {
'arduino' : {
'digital' : tuple(x for x in range(14)),
'analog' : tuple(x for x in range(6)),
'pwm' : (3, 5, 6, 9, 10, 11),
'use_ports' : True,
'disabled' : (0, 1) # Rx, Tx, Crystal
},
'arduino_mega' : {
'digital' : tuple(x for x in range(54)),
'analog' : tuple(x for x in range(16)),
'pwm' : tuple(x for x in range(2,14)),
'use_ports' : True,
'disabled' : (0, 1) # Rx, Tx, Crystal
},
'duinobot' : {
'digital' : tuple(x for x in range(19)),
'analog' : tuple(x for x in range(7)),
'pwm' : (5, 6, 9),
'use_ports' : True,
'disabled' : (0, 1, 3, 4, 8)
}
}
|
# This code should store "codewa.rs" as a variable called name but it's not working.
# Can you figure out why?
a = "code"
b = "wa.rs"
name = a + b
def test():
assert name == "codewa.rs"
|
# @Title: 搜索二维矩阵 (Search a 2D Matrix)
# @Author: KivenC
# @Date: 2018-07-30 21:19:34
# @Runtime: 60 ms
# @Memory: N/A
class Solution:
def searchMatrix(self, matrix, target):
"""
:type matrix: List[List[int]]
:type target: int
:rtype: bool
"""
if not matrix:
return False
R, C = len(matrix), len(matrix[0])
if C < 1 or target < matrix[0][0] or target > matrix[R-1][C-1]:
return False
left, right = 0, R*C-1
while left <= right:
mid = (left + right) // 2
if matrix[mid//C][mid%C] == target:
return True
elif matrix[mid//C][mid%C] < target:
left += 1
else:
right -= 1
return False
|
#brute force
T= int(input())
while T!=0:
T-=1
n = int(input())
if n>3:
k1=0
k2=0
value1 , value2 , value3 , value4 =0,0,0,0
'''
#---------------------------------------
value1 = 14*(n-1) + 20
#----------------------------------------
k1=n//2
k2 = n % 2
if k2 ==0:
#value2 = 28*(k1-1) + 40
value2 = 26*(k1-1) + 18+18
elif k2 ==1:
#value2 = 28*(k1-1) + 54
value2 = 26*(k1-1) + 18 + 33
#-------------------------------------------
k1 = n//3
k2= n%3
if k2==0:
value3 = 37*(k1-1) + 51
elif k2==1:
value3 = 37*(k1-1) + 47
elif k2==2:
value3 = 37*(k1-1) + 78
'''
#--------------------------------------------
k1 = n//4
k2 = n % 4
value4=0
if k1>0:
if k2==0:
value4 = 44*(k1-1) + 60
elif k2==1:
value4 = 44*(k1-1) + 56 +20
elif k2==2:
value4 = 44*(k1-1) + 88
elif k2==3:
value4 = 44*(k1-1) + 48 + 51
value= max(value1 , value2 , value3 , value4)
elif n==1:
value = 20
elif n==3:
value = 51
else:
value = 36
print(value)
'''
if n%3==0:
k = n//3
value = 37*(k-1) +51
elif n%4==0:
k= n//4
value = 44*(k-1) + 60
else:
k1 = n//4
k2 = n%4
if k2==1:
value = 44*(k1-1) + 56 +20
elif k2==2:
value = 44*(k1-1) + 52 + 40
elif k2==3:
value = 44*(k1-1) + 48 + 51
else:
print('wrong')
'''
|
class ZebrokNotImplementedError(NotImplementedError):
"""
Custom exception to be thrown when a derived class
fails to implement an abstract method of a base class
"""
pass
|
'''
pyatmos jb2008 subpackage
This subpackage defines the following functions:
JB2008_subfunc.py - subfunctions that implement the atmospheric model JB2008
jb2008.py - Input interface of JB2008
spaceweather.py
download_sw_jb2008 - Download or update the space weather file for JB2008 from https://sol.spacenvironment.net/JB2008/indices/
read_sw_jb2008 - Read the space weather file for JB2008
''' |
"""
백준 1016번 : 제곱 ㄴㄴ 수
에라토스테네스의 체 심화 응용
"""
min, max = map(int, input().split())
seive = [1 for _ in range(max-min+1)]
i = 2
while i**2 <= max:
mul = min // (i**2)
while mul * (i**2) <= max:
if 0 <= mul * (i**2) - min <= max-min:
seive[mul * (i**2) - min] = 0
mul += 1
i += 1
print(sum(seive)) |
class GameContainer:
def __init__(self, lowest_level, high_score, stat_diffs, points_available):
self.lowest_level = lowest_level
self.high_score = high_score
self.stat_diffs = stat_diffs
self.points_available = points_available
|
class Foo:
class Bar:
def baz(self):
pass
|
def main():
return "foo"
def failure():
raise RuntimeError("This is an error")
|
"""
Model Synoptic Module
"""
simple_tree_model_sklearn = (
"<class 'sklearn.ensemble._forest.ExtraTreesClassifier'>",
"<class 'sklearn.ensemble._forest.ExtraTreesRegressor'>",
"<class 'sklearn.ensemble._forest.RandomForestClassifier'>",
"<class 'sklearn.ensemble._forest.RandomForestRegressor'>",
"<class 'sklearn.ensemble._gb.GradientBoostingClassifier'>",
"<class 'sklearn.ensemble._gb.GradientBoostingRegressor'>"
)
xgboost_model = (
"<class 'xgboost.sklearn.XGBClassifier'>",
"<class 'xgboost.sklearn.XGBRegressor'>",
"<class 'xgboost.core.Booster'>")
lightgbm_model = (
"<class 'lightgbm.sklearn.LGBMClassifier'>",
"<class 'lightgbm.sklearn.LGBMRegressor'>"
)
catboost_model = (
"<class 'catboost.core.CatBoostClassifier'>",
"<class 'catboost.core.CatBoostRegressor'>")
linear_model = (
"<class 'sklearn.linear_model._logistic.LogisticRegression'>",
"<class 'sklearn.linear_model._base.LinearRegression'>")
svm_model = (
"<class 'sklearn.svm._classes.SVC'>",
"<class 'sklearn.svm._classes.SVR'>")
simple_tree_model = simple_tree_model_sklearn + xgboost_model + lightgbm_model
dict_model_feature = {"<class 'sklearn.ensemble._forest.ExtraTreesClassifier'>": ['length'],
"<class 'sklearn.ensemble._forest.ExtraTreesRegressor'>": ['length'],
"<class 'sklearn.ensemble._forest.RandomForestClassifier'>": ['length'],
"<class 'sklearn.ensemble._forest.RandomForestRegressor'>": ['length'],
"<class 'sklearn.ensemble._gb.GradientBoostingClassifier'>": ['length'],
"<class 'sklearn.ensemble._gb.GradientBoostingRegressor'>": ['length'],
"<class 'sklearn.linear_model._logistic.LogisticRegression'>": ['length'],
"<class 'sklearn.linear_model._base.LinearRegression'>": ['length'],
"<class 'sklearn.svm._classes.SVC'>": ['length'],
"<class 'sklearn.svm._classes.SVR'>": ['length'],
"<class 'lightgbm.sklearn.LGBMClassifier'>": ["booster_","feature_name"],
"<class 'lightgbm.sklearn.LGBMRegressor'>": ["booster_","feature_name"],
"<class 'xgboost.sklearn.XGBClassifier'>": ["get_booster","feature_names"],
"<class 'xgboost.sklearn.XGBRegressor'>": ["get_booster","feature_names"],
"<class 'xgboost.core.Booster'>": ["feature_names"],
"<class 'catboost.core.CatBoostClassifier'>": ["feature_names_"],
"<class 'catboost.core.CatBoostRegressor'>": ["feature_names_"],
}
|
def lily_format(seq):
return " ".join(point["lilypond"] for point in seq)
def output(seq):
return "{ %s }" % lily_format(seq)
def write(filename, seq):
with open(filename, "w") as f:
f.write(output(seq))
|
print("Iterando sobre o arquivo")
with open("dados.txt", "r") as arquivo:
for linha in arquivo:
print(linha)
print("Fim do arquivo", arquivo.name)
|
power = {'BUSES': {'Area': 1.33155,
'Bus/Area': 1.33155,
'Bus/Gate Leakage': 0.00662954,
'Bus/Peak Dynamic': 0.0,
'Bus/Runtime Dynamic': 0.0,
'Bus/Subthreshold Leakage': 0.0691322,
'Bus/Subthreshold Leakage with power gating': 0.0259246,
'Gate Leakage': 0.00662954,
'Peak Dynamic': 0.0,
'Runtime Dynamic': 0.0,
'Subthreshold Leakage': 0.0691322,
'Subthreshold Leakage with power gating': 0.0259246},
'Core': [{'Area': 32.6082,
'Execution Unit/Area': 8.2042,
'Execution Unit/Complex ALUs/Area': 0.235435,
'Execution Unit/Complex ALUs/Gate Leakage': 0.0132646,
'Execution Unit/Complex ALUs/Peak Dynamic': 0.063025,
'Execution Unit/Complex ALUs/Runtime Dynamic': 0.252192,
'Execution Unit/Complex ALUs/Subthreshold Leakage': 0.20111,
'Execution Unit/Complex ALUs/Subthreshold Leakage with power gating': 0.0754163,
'Execution Unit/Floating Point Units/Area': 4.6585,
'Execution Unit/Floating Point Units/Gate Leakage': 0.0656156,
'Execution Unit/Floating Point Units/Peak Dynamic': 0.336758,
'Execution Unit/Floating Point Units/Runtime Dynamic': 0.304033,
'Execution Unit/Floating Point Units/Subthreshold Leakage': 0.994829,
'Execution Unit/Floating Point Units/Subthreshold Leakage with power gating': 0.373061,
'Execution Unit/Gate Leakage': 0.122718,
'Execution Unit/Instruction Scheduler/Area': 2.17927,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Area': 0.328073,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Gate Leakage': 0.00115349,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Peak Dynamic': 1.20978,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Runtime Dynamic': 0.28979,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Subthreshold Leakage': 0.017004,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Subthreshold Leakage with power gating': 0.00962066,
'Execution Unit/Instruction Scheduler/Gate Leakage': 0.00730101,
'Execution Unit/Instruction Scheduler/Instruction Window/Area': 1.00996,
'Execution Unit/Instruction Scheduler/Instruction Window/Gate Leakage': 0.00529112,
'Execution Unit/Instruction Scheduler/Instruction Window/Peak Dynamic': 2.07911,
'Execution Unit/Instruction Scheduler/Instruction Window/Runtime Dynamic': 0.501812,
'Execution Unit/Instruction Scheduler/Instruction Window/Subthreshold Leakage': 0.0800117,
'Execution Unit/Instruction Scheduler/Instruction Window/Subthreshold Leakage with power gating': 0.0455351,
'Execution Unit/Instruction Scheduler/Peak Dynamic': 4.84781,
'Execution Unit/Instruction Scheduler/ROB/Area': 0.841232,
'Execution Unit/Instruction Scheduler/ROB/Gate Leakage': 0.000856399,
'Execution Unit/Instruction Scheduler/ROB/Peak Dynamic': 1.55892,
'Execution Unit/Instruction Scheduler/ROB/Runtime Dynamic': 0.287803,
'Execution Unit/Instruction Scheduler/ROB/Subthreshold Leakage': 0.0178624,
'Execution Unit/Instruction Scheduler/ROB/Subthreshold Leakage with power gating': 0.00897339,
'Execution Unit/Instruction Scheduler/Runtime Dynamic': 1.07941,
'Execution Unit/Instruction Scheduler/Subthreshold Leakage': 0.114878,
'Execution Unit/Instruction Scheduler/Subthreshold Leakage with power gating': 0.0641291,
'Execution Unit/Integer ALUs/Area': 0.47087,
'Execution Unit/Integer ALUs/Gate Leakage': 0.0265291,
'Execution Unit/Integer ALUs/Peak Dynamic': 0.234815,
'Execution Unit/Integer ALUs/Runtime Dynamic': 0.101344,
'Execution Unit/Integer ALUs/Subthreshold Leakage': 0.40222,
'Execution Unit/Integer ALUs/Subthreshold Leakage with power gating': 0.150833,
'Execution Unit/Peak Dynamic': 5.93592,
'Execution Unit/Register Files/Area': 0.570804,
'Execution Unit/Register Files/Floating Point RF/Area': 0.208131,
'Execution Unit/Register Files/Floating Point RF/Gate Leakage': 0.000232788,
'Execution Unit/Register Files/Floating Point RF/Peak Dynamic': 0.0636208,
'Execution Unit/Register Files/Floating Point RF/Runtime Dynamic': 0.0105051,
'Execution Unit/Register Files/Floating Point RF/Subthreshold Leakage': 0.00399698,
'Execution Unit/Register Files/Floating Point RF/Subthreshold Leakage with power gating': 0.00176968,
'Execution Unit/Register Files/Gate Leakage': 0.000622708,
'Execution Unit/Register Files/Integer RF/Area': 0.362673,
'Execution Unit/Register Files/Integer RF/Gate Leakage': 0.00038992,
'Execution Unit/Register Files/Integer RF/Peak Dynamic': 0.0997069,
'Execution Unit/Register Files/Integer RF/Runtime Dynamic': 0.0776918,
'Execution Unit/Register Files/Integer RF/Subthreshold Leakage': 0.00614175,
'Execution Unit/Register Files/Integer RF/Subthreshold Leakage with power gating': 0.00246675,
'Execution Unit/Register Files/Peak Dynamic': 0.163328,
'Execution Unit/Register Files/Runtime Dynamic': 0.0881969,
'Execution Unit/Register Files/Subthreshold Leakage': 0.0101387,
'Execution Unit/Register Files/Subthreshold Leakage with power gating': 0.00423643,
'Execution Unit/Results Broadcast Bus/Area Overhead': 0.0442632,
'Execution Unit/Results Broadcast Bus/Gate Leakage': 0.00607074,
'Execution Unit/Results Broadcast Bus/Peak Dynamic': 0.258199,
'Execution Unit/Results Broadcast Bus/Runtime Dynamic': 0.653394,
'Execution Unit/Results Broadcast Bus/Subthreshold Leakage': 0.0920413,
'Execution Unit/Results Broadcast Bus/Subthreshold Leakage with power gating': 0.0345155,
'Execution Unit/Runtime Dynamic': 2.47857,
'Execution Unit/Subthreshold Leakage': 1.83518,
'Execution Unit/Subthreshold Leakage with power gating': 0.709678,
'Gate Leakage': 0.372997,
'Instruction Fetch Unit/Area': 5.86007,
'Instruction Fetch Unit/Branch Predictor/Area': 0.138516,
'Instruction Fetch Unit/Branch Predictor/Chooser/Area': 0.0435221,
'Instruction Fetch Unit/Branch Predictor/Chooser/Gate Leakage': 0.000278362,
'Instruction Fetch Unit/Branch Predictor/Chooser/Peak Dynamic': 0.0168831,
'Instruction Fetch Unit/Branch Predictor/Chooser/Runtime Dynamic': 0.00171471,
'Instruction Fetch Unit/Branch Predictor/Chooser/Subthreshold Leakage': 0.00759719,
'Instruction Fetch Unit/Branch Predictor/Chooser/Subthreshold Leakage with power gating': 0.0039236,
'Instruction Fetch Unit/Branch Predictor/Gate Leakage': 0.000757657,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Area': 0.0435221,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Gate Leakage': 0.000278362,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Peak Dynamic': 0.0168831,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Runtime Dynamic': 0.00171471,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Subthreshold Leakage': 0.00759719,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Subthreshold Leakage with power gating': 0.0039236,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Area': 0.0257064,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Gate Leakage': 0.000154548,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Peak Dynamic': 0.0142575,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Runtime Dynamic': 0.00149793,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Subthreshold Leakage': 0.00384344,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Subthreshold Leakage with power gating': 0.00198631,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Area': 0.0151917,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Gate Leakage': 8.00196e-05,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Peak Dynamic': 0.00527447,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Runtime Dynamic': 0.000582287,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Subthreshold Leakage': 0.00181347,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Subthreshold Leakage with power gating': 0.000957045,
'Instruction Fetch Unit/Branch Predictor/Peak Dynamic': 0.0597838,
'Instruction Fetch Unit/Branch Predictor/RAS/Area': 0.0105732,
'Instruction Fetch Unit/Branch Predictor/RAS/Gate Leakage': 4.63858e-05,
'Instruction Fetch Unit/Branch Predictor/RAS/Peak Dynamic': 0.0117602,
'Instruction Fetch Unit/Branch Predictor/RAS/Runtime Dynamic': 0.00111605,
'Instruction Fetch Unit/Branch Predictor/RAS/Subthreshold Leakage': 0.000932505,
'Instruction Fetch Unit/Branch Predictor/RAS/Subthreshold Leakage with power gating': 0.000494733,
'Instruction Fetch Unit/Branch Predictor/Runtime Dynamic': 0.00604339,
'Instruction Fetch Unit/Branch Predictor/Subthreshold Leakage': 0.0199703,
'Instruction Fetch Unit/Branch Predictor/Subthreshold Leakage with power gating': 0.0103282,
'Instruction Fetch Unit/Branch Target Buffer/Area': 0.64954,
'Instruction Fetch Unit/Branch Target Buffer/Gate Leakage': 0.00272758,
'Instruction Fetch Unit/Branch Target Buffer/Peak Dynamic': 0.177867,
'Instruction Fetch Unit/Branch Target Buffer/Runtime Dynamic': 0.0162826,
'Instruction Fetch Unit/Branch Target Buffer/Subthreshold Leakage': 0.0811682,
'Instruction Fetch Unit/Branch Target Buffer/Subthreshold Leakage with power gating': 0.0435357,
'Instruction Fetch Unit/Gate Leakage': 0.0590479,
'Instruction Fetch Unit/Instruction Buffer/Area': 0.0226323,
'Instruction Fetch Unit/Instruction Buffer/Gate Leakage': 6.83558e-05,
'Instruction Fetch Unit/Instruction Buffer/Peak Dynamic': 0.606827,
'Instruction Fetch Unit/Instruction Buffer/Runtime Dynamic': 0.0746871,
'Instruction Fetch Unit/Instruction Buffer/Subthreshold Leakage': 0.00151885,
'Instruction Fetch Unit/Instruction Buffer/Subthreshold Leakage with power gating': 0.000701682,
'Instruction Fetch Unit/Instruction Cache/Area': 3.14635,
'Instruction Fetch Unit/Instruction Cache/Gate Leakage': 0.029931,
'Instruction Fetch Unit/Instruction Cache/Peak Dynamic': 4.75074,
'Instruction Fetch Unit/Instruction Cache/Runtime Dynamic': 0.220284,
'Instruction Fetch Unit/Instruction Cache/Subthreshold Leakage': 0.367022,
'Instruction Fetch Unit/Instruction Cache/Subthreshold Leakage with power gating': 0.180386,
'Instruction Fetch Unit/Instruction Decoder/Area': 1.85799,
'Instruction Fetch Unit/Instruction Decoder/Gate Leakage': 0.0222493,
'Instruction Fetch Unit/Instruction Decoder/Peak Dynamic': 1.37404,
'Instruction Fetch Unit/Instruction Decoder/Runtime Dynamic': 0.253671,
'Instruction Fetch Unit/Instruction Decoder/Subthreshold Leakage': 0.442943,
'Instruction Fetch Unit/Instruction Decoder/Subthreshold Leakage with power gating': 0.166104,
'Instruction Fetch Unit/Peak Dynamic': 7.20335,
'Instruction Fetch Unit/Runtime Dynamic': 0.570969,
'Instruction Fetch Unit/Subthreshold Leakage': 0.932587,
'Instruction Fetch Unit/Subthreshold Leakage with power gating': 0.408542,
'L2/Area': 4.53318,
'L2/Gate Leakage': 0.015464,
'L2/Peak Dynamic': 0.0912664,
'L2/Runtime Dynamic': 0.0149542,
'L2/Subthreshold Leakage': 0.834142,
'L2/Subthreshold Leakage with power gating': 0.401066,
'Load Store Unit/Area': 8.80969,
'Load Store Unit/Data Cache/Area': 6.84535,
'Load Store Unit/Data Cache/Gate Leakage': 0.0279261,
'Load Store Unit/Data Cache/Peak Dynamic': 3.91288,
'Load Store Unit/Data Cache/Runtime Dynamic': 1.30685,
'Load Store Unit/Data Cache/Subthreshold Leakage': 0.527675,
'Load Store Unit/Data Cache/Subthreshold Leakage with power gating': 0.25085,
'Load Store Unit/Gate Leakage': 0.0351387,
'Load Store Unit/LoadQ/Area': 0.0836782,
'Load Store Unit/LoadQ/Gate Leakage': 0.00059896,
'Load Store Unit/LoadQ/Peak Dynamic': 0.0865673,
'Load Store Unit/LoadQ/Runtime Dynamic': 0.0865674,
'Load Store Unit/LoadQ/Subthreshold Leakage': 0.00941961,
'Load Store Unit/LoadQ/Subthreshold Leakage with power gating': 0.00536918,
'Load Store Unit/Peak Dynamic': 4.32334,
'Load Store Unit/Runtime Dynamic': 1.82034,
'Load Store Unit/StoreQ/Area': 0.322079,
'Load Store Unit/StoreQ/Gate Leakage': 0.00329971,
'Load Store Unit/StoreQ/Peak Dynamic': 0.21346,
'Load Store Unit/StoreQ/Runtime Dynamic': 0.426921,
'Load Store Unit/StoreQ/Subthreshold Leakage': 0.0345621,
'Load Store Unit/StoreQ/Subthreshold Leakage with power gating': 0.0197004,
'Load Store Unit/Subthreshold Leakage': 0.591622,
'Load Store Unit/Subthreshold Leakage with power gating': 0.283406,
'Memory Management Unit/Area': 0.434579,
'Memory Management Unit/Dtlb/Area': 0.0879726,
'Memory Management Unit/Dtlb/Gate Leakage': 0.00088729,
'Memory Management Unit/Dtlb/Peak Dynamic': 0.0757577,
'Memory Management Unit/Dtlb/Runtime Dynamic': 0.0770213,
'Memory Management Unit/Dtlb/Subthreshold Leakage': 0.0155699,
'Memory Management Unit/Dtlb/Subthreshold Leakage with power gating': 0.00887485,
'Memory Management Unit/Gate Leakage': 0.00813591,
'Memory Management Unit/Itlb/Area': 0.301552,
'Memory Management Unit/Itlb/Gate Leakage': 0.00393464,
'Memory Management Unit/Itlb/Peak Dynamic': 0.295384,
'Memory Management Unit/Itlb/Runtime Dynamic': 0.0364302,
'Memory Management Unit/Itlb/Subthreshold Leakage': 0.0413758,
'Memory Management Unit/Itlb/Subthreshold Leakage with power gating': 0.0235842,
'Memory Management Unit/Peak Dynamic': 0.584853,
'Memory Management Unit/Runtime Dynamic': 0.113451,
'Memory Management Unit/Subthreshold Leakage': 0.0769113,
'Memory Management Unit/Subthreshold Leakage with power gating': 0.0399462,
'Peak Dynamic': 22.7004,
'Renaming Unit/Area': 0.369768,
'Renaming Unit/FP Front End RAT/Area': 0.168486,
'Renaming Unit/FP Front End RAT/Gate Leakage': 0.00489731,
'Renaming Unit/FP Front End RAT/Peak Dynamic': 3.33511,
'Renaming Unit/FP Front End RAT/Runtime Dynamic': 0.221959,
'Renaming Unit/FP Front End RAT/Subthreshold Leakage': 0.0437281,
'Renaming Unit/FP Front End RAT/Subthreshold Leakage with power gating': 0.024925,
'Renaming Unit/Free List/Area': 0.0414755,
'Renaming Unit/Free List/Gate Leakage': 4.15911e-05,
'Renaming Unit/Free List/Peak Dynamic': 0.0401324,
'Renaming Unit/Free List/Runtime Dynamic': 0.0174892,
'Renaming Unit/Free List/Subthreshold Leakage': 0.000670426,
'Renaming Unit/Free List/Subthreshold Leakage with power gating': 0.000377987,
'Renaming Unit/Gate Leakage': 0.00863632,
'Renaming Unit/Int Front End RAT/Area': 0.114751,
'Renaming Unit/Int Front End RAT/Gate Leakage': 0.00038343,
'Renaming Unit/Int Front End RAT/Peak Dynamic': 0.86945,
'Renaming Unit/Int Front End RAT/Runtime Dynamic': 0.146944,
'Renaming Unit/Int Front End RAT/Subthreshold Leakage': 0.00611897,
'Renaming Unit/Int Front End RAT/Subthreshold Leakage with power gating': 0.00348781,
'Renaming Unit/Peak Dynamic': 4.56169,
'Renaming Unit/Runtime Dynamic': 0.386393,
'Renaming Unit/Subthreshold Leakage': 0.070483,
'Renaming Unit/Subthreshold Leakage with power gating': 0.0362779,
'Runtime Dynamic': 5.38467,
'Subthreshold Leakage': 6.21877,
'Subthreshold Leakage with power gating': 2.58311},
{'Area': 32.0201,
'Execution Unit/Area': 7.68434,
'Execution Unit/Complex ALUs/Area': 0.235435,
'Execution Unit/Complex ALUs/Gate Leakage': 0.0132646,
'Execution Unit/Complex ALUs/Peak Dynamic': 0.0248217,
'Execution Unit/Complex ALUs/Runtime Dynamic': 0.222185,
'Execution Unit/Complex ALUs/Subthreshold Leakage': 0.20111,
'Execution Unit/Complex ALUs/Subthreshold Leakage with power gating': 0.0754163,
'Execution Unit/Floating Point Units/Area': 4.6585,
'Execution Unit/Floating Point Units/Gate Leakage': 0.0656156,
'Execution Unit/Floating Point Units/Peak Dynamic': 0.132187,
'Execution Unit/Floating Point Units/Runtime Dynamic': 0.304033,
'Execution Unit/Floating Point Units/Subthreshold Leakage': 0.994829,
'Execution Unit/Floating Point Units/Subthreshold Leakage with power gating': 0.373061,
'Execution Unit/Gate Leakage': 0.120359,
'Execution Unit/Instruction Scheduler/Area': 1.66526,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Area': 0.275653,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Gate Leakage': 0.000977433,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Peak Dynamic': 1.04181,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Runtime Dynamic': 0.123111,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Subthreshold Leakage': 0.0143453,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Subthreshold Leakage with power gating': 0.00810519,
'Execution Unit/Instruction Scheduler/Gate Leakage': 0.00568913,
'Execution Unit/Instruction Scheduler/Instruction Window/Area': 0.805223,
'Execution Unit/Instruction Scheduler/Instruction Window/Gate Leakage': 0.00414562,
'Execution Unit/Instruction Scheduler/Instruction Window/Peak Dynamic': 1.6763,
'Execution Unit/Instruction Scheduler/Instruction Window/Runtime Dynamic': 0.198574,
'Execution Unit/Instruction Scheduler/Instruction Window/Subthreshold Leakage': 0.0625755,
'Execution Unit/Instruction Scheduler/Instruction Window/Subthreshold Leakage with power gating': 0.0355964,
'Execution Unit/Instruction Scheduler/Peak Dynamic': 3.82262,
'Execution Unit/Instruction Scheduler/ROB/Area': 0.584388,
'Execution Unit/Instruction Scheduler/ROB/Gate Leakage': 0.00056608,
'Execution Unit/Instruction Scheduler/ROB/Peak Dynamic': 1.10451,
'Execution Unit/Instruction Scheduler/ROB/Runtime Dynamic': 0.100234,
'Execution Unit/Instruction Scheduler/ROB/Subthreshold Leakage': 0.00906853,
'Execution Unit/Instruction Scheduler/ROB/Subthreshold Leakage with power gating': 0.00364446,
'Execution Unit/Instruction Scheduler/Runtime Dynamic': 0.421919,
'Execution Unit/Instruction Scheduler/Subthreshold Leakage': 0.0859892,
'Execution Unit/Instruction Scheduler/Subthreshold Leakage with power gating': 0.047346,
'Execution Unit/Integer ALUs/Area': 0.47087,
'Execution Unit/Integer ALUs/Gate Leakage': 0.0265291,
'Execution Unit/Integer ALUs/Peak Dynamic': 0.120538,
'Execution Unit/Integer ALUs/Runtime Dynamic': 0.101344,
'Execution Unit/Integer ALUs/Subthreshold Leakage': 0.40222,
'Execution Unit/Integer ALUs/Subthreshold Leakage with power gating': 0.150833,
'Execution Unit/Peak Dynamic': 4.29263,
'Execution Unit/Register Files/Area': 0.570804,
'Execution Unit/Register Files/Floating Point RF/Area': 0.208131,
'Execution Unit/Register Files/Floating Point RF/Gate Leakage': 0.000232788,
'Execution Unit/Register Files/Floating Point RF/Peak Dynamic': 0.0249729,
'Execution Unit/Register Files/Floating Point RF/Runtime Dynamic': 0.00516385,
'Execution Unit/Register Files/Floating Point RF/Subthreshold Leakage': 0.00399698,
'Execution Unit/Register Files/Floating Point RF/Subthreshold Leakage with power gating': 0.00176968,
'Execution Unit/Register Files/Gate Leakage': 0.000622708,
'Execution Unit/Register Files/Integer RF/Area': 0.362673,
'Execution Unit/Register Files/Integer RF/Gate Leakage': 0.00038992,
'Execution Unit/Register Files/Integer RF/Peak Dynamic': 0.0467096,
'Execution Unit/Register Files/Integer RF/Runtime Dynamic': 0.0381898,
'Execution Unit/Register Files/Integer RF/Subthreshold Leakage': 0.00614175,
'Execution Unit/Register Files/Integer RF/Subthreshold Leakage with power gating': 0.00246675,
'Execution Unit/Register Files/Peak Dynamic': 0.0716825,
'Execution Unit/Register Files/Runtime Dynamic': 0.0433536,
'Execution Unit/Register Files/Subthreshold Leakage': 0.0101387,
'Execution Unit/Register Files/Subthreshold Leakage with power gating': 0.00423643,
'Execution Unit/Results Broadcast Bus/Area Overhead': 0.0390912,
'Execution Unit/Results Broadcast Bus/Gate Leakage': 0.00537402,
'Execution Unit/Results Broadcast Bus/Peak Dynamic': 0.104611,
'Execution Unit/Results Broadcast Bus/Runtime Dynamic': 0.268124,
'Execution Unit/Results Broadcast Bus/Subthreshold Leakage': 0.081478,
'Execution Unit/Results Broadcast Bus/Subthreshold Leakage with power gating': 0.0305543,
'Execution Unit/Runtime Dynamic': 1.36096,
'Execution Unit/Subthreshold Leakage': 1.79543,
'Execution Unit/Subthreshold Leakage with power gating': 0.688821,
'Gate Leakage': 0.368936,
'Instruction Fetch Unit/Area': 5.85939,
'Instruction Fetch Unit/Branch Predictor/Area': 0.138516,
'Instruction Fetch Unit/Branch Predictor/Chooser/Area': 0.0435221,
'Instruction Fetch Unit/Branch Predictor/Chooser/Gate Leakage': 0.000278362,
'Instruction Fetch Unit/Branch Predictor/Chooser/Peak Dynamic': 0.0168831,
'Instruction Fetch Unit/Branch Predictor/Chooser/Runtime Dynamic': 0.00096861,
'Instruction Fetch Unit/Branch Predictor/Chooser/Subthreshold Leakage': 0.00759719,
'Instruction Fetch Unit/Branch Predictor/Chooser/Subthreshold Leakage with power gating': 0.0039236,
'Instruction Fetch Unit/Branch Predictor/Gate Leakage': 0.000757657,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Area': 0.0435221,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Gate Leakage': 0.000278362,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Peak Dynamic': 0.0168831,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Runtime Dynamic': 0.00096861,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Subthreshold Leakage': 0.00759719,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Subthreshold Leakage with power gating': 0.0039236,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Area': 0.0257064,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Gate Leakage': 0.000154548,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Peak Dynamic': 0.0142575,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Runtime Dynamic': 0.000870559,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Subthreshold Leakage': 0.00384344,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Subthreshold Leakage with power gating': 0.00198631,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Area': 0.0151917,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Gate Leakage': 8.00196e-05,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Peak Dynamic': 0.00527447,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Runtime Dynamic': 0.00035172,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Subthreshold Leakage': 0.00181347,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Subthreshold Leakage with power gating': 0.000957045,
'Instruction Fetch Unit/Branch Predictor/Peak Dynamic': 0.0597838,
'Instruction Fetch Unit/Branch Predictor/RAS/Area': 0.0105732,
'Instruction Fetch Unit/Branch Predictor/RAS/Gate Leakage': 4.63858e-05,
'Instruction Fetch Unit/Branch Predictor/RAS/Peak Dynamic': 0.0117602,
'Instruction Fetch Unit/Branch Predictor/RAS/Runtime Dynamic': 0.000548599,
'Instruction Fetch Unit/Branch Predictor/RAS/Subthreshold Leakage': 0.000932505,
'Instruction Fetch Unit/Branch Predictor/RAS/Subthreshold Leakage with power gating': 0.000494733,
'Instruction Fetch Unit/Branch Predictor/Runtime Dynamic': 0.00335638,
'Instruction Fetch Unit/Branch Predictor/Subthreshold Leakage': 0.0199703,
'Instruction Fetch Unit/Branch Predictor/Subthreshold Leakage with power gating': 0.0103282,
'Instruction Fetch Unit/Branch Target Buffer/Area': 0.64954,
'Instruction Fetch Unit/Branch Target Buffer/Gate Leakage': 0.00272758,
'Instruction Fetch Unit/Branch Target Buffer/Peak Dynamic': 0.177867,
'Instruction Fetch Unit/Branch Target Buffer/Runtime Dynamic': 0.00832581,
'Instruction Fetch Unit/Branch Target Buffer/Subthreshold Leakage': 0.0811682,
'Instruction Fetch Unit/Branch Target Buffer/Subthreshold Leakage with power gating': 0.0435357,
'Instruction Fetch Unit/Gate Leakage': 0.0589979,
'Instruction Fetch Unit/Instruction Buffer/Area': 0.0226323,
'Instruction Fetch Unit/Instruction Buffer/Gate Leakage': 6.83558e-05,
'Instruction Fetch Unit/Instruction Buffer/Peak Dynamic': 0.606827,
'Instruction Fetch Unit/Instruction Buffer/Runtime Dynamic': 0.0367128,
'Instruction Fetch Unit/Instruction Buffer/Subthreshold Leakage': 0.00151885,
'Instruction Fetch Unit/Instruction Buffer/Subthreshold Leakage with power gating': 0.000701682,
'Instruction Fetch Unit/Instruction Cache/Area': 3.14635,
'Instruction Fetch Unit/Instruction Cache/Gate Leakage': 0.029931,
'Instruction Fetch Unit/Instruction Cache/Peak Dynamic': 2.33525,
'Instruction Fetch Unit/Instruction Cache/Runtime Dynamic': 0.106878,
'Instruction Fetch Unit/Instruction Cache/Subthreshold Leakage': 0.367022,
'Instruction Fetch Unit/Instruction Cache/Subthreshold Leakage with power gating': 0.180386,
'Instruction Fetch Unit/Instruction Decoder/Area': 1.85799,
'Instruction Fetch Unit/Instruction Decoder/Gate Leakage': 0.0222493,
'Instruction Fetch Unit/Instruction Decoder/Peak Dynamic': 1.37404,
'Instruction Fetch Unit/Instruction Decoder/Runtime Dynamic': 0.124693,
'Instruction Fetch Unit/Instruction Decoder/Subthreshold Leakage': 0.442943,
'Instruction Fetch Unit/Instruction Decoder/Subthreshold Leakage with power gating': 0.166104,
'Instruction Fetch Unit/Peak Dynamic': 4.6671,
'Instruction Fetch Unit/Runtime Dynamic': 0.279967,
'Instruction Fetch Unit/Subthreshold Leakage': 0.932286,
'Instruction Fetch Unit/Subthreshold Leakage with power gating': 0.40843,
'L2/Area': 4.53318,
'L2/Gate Leakage': 0.015464,
'L2/Peak Dynamic': 0.0412946,
'L2/Runtime Dynamic': 0.00689639,
'L2/Subthreshold Leakage': 0.834142,
'L2/Subthreshold Leakage with power gating': 0.401066,
'Load Store Unit/Area': 8.80901,
'Load Store Unit/Data Cache/Area': 6.84535,
'Load Store Unit/Data Cache/Gate Leakage': 0.0279261,
'Load Store Unit/Data Cache/Peak Dynamic': 2.56248,
'Load Store Unit/Data Cache/Runtime Dynamic': 0.647909,
'Load Store Unit/Data Cache/Subthreshold Leakage': 0.527675,
'Load Store Unit/Data Cache/Subthreshold Leakage with power gating': 0.25085,
'Load Store Unit/Gate Leakage': 0.0350888,
'Load Store Unit/LoadQ/Area': 0.0836782,
'Load Store Unit/LoadQ/Gate Leakage': 0.00059896,
'Load Store Unit/LoadQ/Peak Dynamic': 0.0428786,
'Load Store Unit/LoadQ/Runtime Dynamic': 0.0428785,
'Load Store Unit/LoadQ/Subthreshold Leakage': 0.00941961,
'Load Store Unit/LoadQ/Subthreshold Leakage with power gating': 0.00536918,
'Load Store Unit/Peak Dynamic': 2.76496,
'Load Store Unit/Runtime Dynamic': 0.902249,
'Load Store Unit/StoreQ/Area': 0.322079,
'Load Store Unit/StoreQ/Gate Leakage': 0.00329971,
'Load Store Unit/StoreQ/Peak Dynamic': 0.105731,
'Load Store Unit/StoreQ/Runtime Dynamic': 0.211462,
'Load Store Unit/StoreQ/Subthreshold Leakage': 0.0345621,
'Load Store Unit/StoreQ/Subthreshold Leakage with power gating': 0.0197004,
'Load Store Unit/Subthreshold Leakage': 0.591321,
'Load Store Unit/Subthreshold Leakage with power gating': 0.283293,
'Memory Management Unit/Area': 0.4339,
'Memory Management Unit/Dtlb/Area': 0.0879726,
'Memory Management Unit/Dtlb/Gate Leakage': 0.00088729,
'Memory Management Unit/Dtlb/Peak Dynamic': 0.0375244,
'Memory Management Unit/Dtlb/Runtime Dynamic': 0.0380905,
'Memory Management Unit/Dtlb/Subthreshold Leakage': 0.0155699,
'Memory Management Unit/Dtlb/Subthreshold Leakage with power gating': 0.00887485,
'Memory Management Unit/Gate Leakage': 0.00808595,
'Memory Management Unit/Itlb/Area': 0.301552,
'Memory Management Unit/Itlb/Gate Leakage': 0.00393464,
'Memory Management Unit/Itlb/Peak Dynamic': 0.145197,
'Memory Management Unit/Itlb/Runtime Dynamic': 0.0176811,
'Memory Management Unit/Itlb/Subthreshold Leakage': 0.0413758,
'Memory Management Unit/Itlb/Subthreshold Leakage with power gating': 0.0235842,
'Memory Management Unit/Peak Dynamic': 0.365766,
'Memory Management Unit/Runtime Dynamic': 0.0557716,
'Memory Management Unit/Subthreshold Leakage': 0.0766103,
'Memory Management Unit/Subthreshold Leakage with power gating': 0.0398333,
'Peak Dynamic': 15.7212,
'Renaming Unit/Area': 0.303608,
'Renaming Unit/FP Front End RAT/Area': 0.131045,
'Renaming Unit/FP Front End RAT/Gate Leakage': 0.00351123,
'Renaming Unit/FP Front End RAT/Peak Dynamic': 2.51468,
'Renaming Unit/FP Front End RAT/Runtime Dynamic': 0.0656927,
'Renaming Unit/FP Front End RAT/Subthreshold Leakage': 0.0308571,
'Renaming Unit/FP Front End RAT/Subthreshold Leakage with power gating': 0.0175885,
'Renaming Unit/Free List/Area': 0.0340654,
'Renaming Unit/Free List/Gate Leakage': 2.5481e-05,
'Renaming Unit/Free List/Peak Dynamic': 0.0306032,
'Renaming Unit/Free List/Runtime Dynamic': 0.00635391,
'Renaming Unit/Free List/Subthreshold Leakage': 0.000370144,
'Renaming Unit/Free List/Subthreshold Leakage with power gating': 0.000201064,
'Renaming Unit/Gate Leakage': 0.00708398,
'Renaming Unit/Int Front End RAT/Area': 0.0941223,
'Renaming Unit/Int Front End RAT/Gate Leakage': 0.000283242,
'Renaming Unit/Int Front End RAT/Peak Dynamic': 0.731965,
'Renaming Unit/Int Front End RAT/Runtime Dynamic': 0.0618182,
'Renaming Unit/Int Front End RAT/Subthreshold Leakage': 0.00435488,
'Renaming Unit/Int Front End RAT/Subthreshold Leakage with power gating': 0.00248228,
'Renaming Unit/Peak Dynamic': 3.58947,
'Renaming Unit/Runtime Dynamic': 0.133865,
'Renaming Unit/Subthreshold Leakage': 0.0552466,
'Renaming Unit/Subthreshold Leakage with power gating': 0.0276461,
'Runtime Dynamic': 2.73971,
'Subthreshold Leakage': 6.16288,
'Subthreshold Leakage with power gating': 2.55328},
{'Area': 32.0201,
'Execution Unit/Area': 7.68434,
'Execution Unit/Complex ALUs/Area': 0.235435,
'Execution Unit/Complex ALUs/Gate Leakage': 0.0132646,
'Execution Unit/Complex ALUs/Peak Dynamic': 0.0146909,
'Execution Unit/Complex ALUs/Runtime Dynamic': 0.214227,
'Execution Unit/Complex ALUs/Subthreshold Leakage': 0.20111,
'Execution Unit/Complex ALUs/Subthreshold Leakage with power gating': 0.0754163,
'Execution Unit/Floating Point Units/Area': 4.6585,
'Execution Unit/Floating Point Units/Gate Leakage': 0.0656156,
'Execution Unit/Floating Point Units/Peak Dynamic': 0.0762629,
'Execution Unit/Floating Point Units/Runtime Dynamic': 0.304033,
'Execution Unit/Floating Point Units/Subthreshold Leakage': 0.994829,
'Execution Unit/Floating Point Units/Subthreshold Leakage with power gating': 0.373061,
'Execution Unit/Gate Leakage': 0.120359,
'Execution Unit/Instruction Scheduler/Area': 1.66526,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Area': 0.275653,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Gate Leakage': 0.000977433,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Peak Dynamic': 1.04181,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Runtime Dynamic': 0.103046,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Subthreshold Leakage': 0.0143453,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Subthreshold Leakage with power gating': 0.00810519,
'Execution Unit/Instruction Scheduler/Gate Leakage': 0.00568913,
'Execution Unit/Instruction Scheduler/Instruction Window/Area': 0.805223,
'Execution Unit/Instruction Scheduler/Instruction Window/Gate Leakage': 0.00414562,
'Execution Unit/Instruction Scheduler/Instruction Window/Peak Dynamic': 1.6763,
'Execution Unit/Instruction Scheduler/Instruction Window/Runtime Dynamic': 0.166209,
'Execution Unit/Instruction Scheduler/Instruction Window/Subthreshold Leakage': 0.0625755,
'Execution Unit/Instruction Scheduler/Instruction Window/Subthreshold Leakage with power gating': 0.0355964,
'Execution Unit/Instruction Scheduler/Peak Dynamic': 3.82262,
'Execution Unit/Instruction Scheduler/ROB/Area': 0.584388,
'Execution Unit/Instruction Scheduler/ROB/Gate Leakage': 0.00056608,
'Execution Unit/Instruction Scheduler/ROB/Peak Dynamic': 1.10451,
'Execution Unit/Instruction Scheduler/ROB/Runtime Dynamic': 0.0838969,
'Execution Unit/Instruction Scheduler/ROB/Subthreshold Leakage': 0.00906853,
'Execution Unit/Instruction Scheduler/ROB/Subthreshold Leakage with power gating': 0.00364446,
'Execution Unit/Instruction Scheduler/Runtime Dynamic': 0.353152,
'Execution Unit/Instruction Scheduler/Subthreshold Leakage': 0.0859892,
'Execution Unit/Instruction Scheduler/Subthreshold Leakage with power gating': 0.047346,
'Execution Unit/Integer ALUs/Area': 0.47087,
'Execution Unit/Integer ALUs/Gate Leakage': 0.0265291,
'Execution Unit/Integer ALUs/Peak Dynamic': 0.106162,
'Execution Unit/Integer ALUs/Runtime Dynamic': 0.101344,
'Execution Unit/Integer ALUs/Subthreshold Leakage': 0.40222,
'Execution Unit/Integer ALUs/Subthreshold Leakage with power gating': 0.150833,
'Execution Unit/Peak Dynamic': 4.16664,
'Execution Unit/Register Files/Area': 0.570804,
'Execution Unit/Register Files/Floating Point RF/Area': 0.208131,
'Execution Unit/Register Files/Floating Point RF/Gate Leakage': 0.000232788,
'Execution Unit/Register Files/Floating Point RF/Peak Dynamic': 0.0144077,
'Execution Unit/Register Files/Floating Point RF/Runtime Dynamic': 0.00432221,
'Execution Unit/Register Files/Floating Point RF/Subthreshold Leakage': 0.00399698,
'Execution Unit/Register Files/Floating Point RF/Subthreshold Leakage with power gating': 0.00176968,
'Execution Unit/Register Files/Gate Leakage': 0.000622708,
'Execution Unit/Register Files/Integer RF/Area': 0.362673,
'Execution Unit/Register Files/Integer RF/Gate Leakage': 0.00038992,
'Execution Unit/Register Files/Integer RF/Peak Dynamic': 0.0368798,
'Execution Unit/Register Files/Integer RF/Runtime Dynamic': 0.0319654,
'Execution Unit/Register Files/Integer RF/Subthreshold Leakage': 0.00614175,
'Execution Unit/Register Files/Integer RF/Subthreshold Leakage with power gating': 0.00246675,
'Execution Unit/Register Files/Peak Dynamic': 0.0512875,
'Execution Unit/Register Files/Runtime Dynamic': 0.0362876,
'Execution Unit/Register Files/Subthreshold Leakage': 0.0101387,
'Execution Unit/Register Files/Subthreshold Leakage with power gating': 0.00423643,
'Execution Unit/Results Broadcast Bus/Area Overhead': 0.0390912,
'Execution Unit/Results Broadcast Bus/Gate Leakage': 0.00537402,
'Execution Unit/Results Broadcast Bus/Peak Dynamic': 0.081369,
'Execution Unit/Results Broadcast Bus/Runtime Dynamic': 0.218818,
'Execution Unit/Results Broadcast Bus/Subthreshold Leakage': 0.081478,
'Execution Unit/Results Broadcast Bus/Subthreshold Leakage with power gating': 0.0305543,
'Execution Unit/Runtime Dynamic': 1.22786,
'Execution Unit/Subthreshold Leakage': 1.79543,
'Execution Unit/Subthreshold Leakage with power gating': 0.688821,
'Gate Leakage': 0.368936,
'Instruction Fetch Unit/Area': 5.85939,
'Instruction Fetch Unit/Branch Predictor/Area': 0.138516,
'Instruction Fetch Unit/Branch Predictor/Chooser/Area': 0.0435221,
'Instruction Fetch Unit/Branch Predictor/Chooser/Gate Leakage': 0.000278362,
'Instruction Fetch Unit/Branch Predictor/Chooser/Peak Dynamic': 0.0168831,
'Instruction Fetch Unit/Branch Predictor/Chooser/Runtime Dynamic': 0.000754142,
'Instruction Fetch Unit/Branch Predictor/Chooser/Subthreshold Leakage': 0.00759719,
'Instruction Fetch Unit/Branch Predictor/Chooser/Subthreshold Leakage with power gating': 0.0039236,
'Instruction Fetch Unit/Branch Predictor/Gate Leakage': 0.000757657,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Area': 0.0435221,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Gate Leakage': 0.000278362,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Peak Dynamic': 0.0168831,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Runtime Dynamic': 0.000754142,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Subthreshold Leakage': 0.00759719,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Subthreshold Leakage with power gating': 0.0039236,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Area': 0.0257064,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Gate Leakage': 0.000154548,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Peak Dynamic': 0.0142575,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Runtime Dynamic': 0.000672222,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Subthreshold Leakage': 0.00384344,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Subthreshold Leakage with power gating': 0.00198631,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Area': 0.0151917,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Gate Leakage': 8.00196e-05,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Peak Dynamic': 0.00527447,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Runtime Dynamic': 0.000268632,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Subthreshold Leakage': 0.00181347,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Subthreshold Leakage with power gating': 0.000957045,
'Instruction Fetch Unit/Branch Predictor/Peak Dynamic': 0.0597838,
'Instruction Fetch Unit/Branch Predictor/RAS/Area': 0.0105732,
'Instruction Fetch Unit/Branch Predictor/RAS/Gate Leakage': 4.63858e-05,
'Instruction Fetch Unit/Branch Predictor/RAS/Peak Dynamic': 0.0117602,
'Instruction Fetch Unit/Branch Predictor/RAS/Runtime Dynamic': 0.000459186,
'Instruction Fetch Unit/Branch Predictor/RAS/Subthreshold Leakage': 0.000932505,
'Instruction Fetch Unit/Branch Predictor/RAS/Subthreshold Leakage with power gating': 0.000494733,
'Instruction Fetch Unit/Branch Predictor/Runtime Dynamic': 0.00263969,
'Instruction Fetch Unit/Branch Predictor/Subthreshold Leakage': 0.0199703,
'Instruction Fetch Unit/Branch Predictor/Subthreshold Leakage with power gating': 0.0103282,
'Instruction Fetch Unit/Branch Target Buffer/Area': 0.64954,
'Instruction Fetch Unit/Branch Target Buffer/Gate Leakage': 0.00272758,
'Instruction Fetch Unit/Branch Target Buffer/Peak Dynamic': 0.177867,
'Instruction Fetch Unit/Branch Target Buffer/Runtime Dynamic': 0.00668167,
'Instruction Fetch Unit/Branch Target Buffer/Subthreshold Leakage': 0.0811682,
'Instruction Fetch Unit/Branch Target Buffer/Subthreshold Leakage with power gating': 0.0435357,
'Instruction Fetch Unit/Gate Leakage': 0.0589979,
'Instruction Fetch Unit/Instruction Buffer/Area': 0.0226323,
'Instruction Fetch Unit/Instruction Buffer/Gate Leakage': 6.83558e-05,
'Instruction Fetch Unit/Instruction Buffer/Peak Dynamic': 0.606827,
'Instruction Fetch Unit/Instruction Buffer/Runtime Dynamic': 0.0307292,
'Instruction Fetch Unit/Instruction Buffer/Subthreshold Leakage': 0.00151885,
'Instruction Fetch Unit/Instruction Buffer/Subthreshold Leakage with power gating': 0.000701682,
'Instruction Fetch Unit/Instruction Cache/Area': 3.14635,
'Instruction Fetch Unit/Instruction Cache/Gate Leakage': 0.029931,
'Instruction Fetch Unit/Instruction Cache/Peak Dynamic': 1.95464,
'Instruction Fetch Unit/Instruction Cache/Runtime Dynamic': 0.0862819,
'Instruction Fetch Unit/Instruction Cache/Subthreshold Leakage': 0.367022,
'Instruction Fetch Unit/Instruction Cache/Subthreshold Leakage with power gating': 0.180386,
'Instruction Fetch Unit/Instruction Decoder/Area': 1.85799,
'Instruction Fetch Unit/Instruction Decoder/Gate Leakage': 0.0222493,
'Instruction Fetch Unit/Instruction Decoder/Peak Dynamic': 1.37404,
'Instruction Fetch Unit/Instruction Decoder/Runtime Dynamic': 0.10437,
'Instruction Fetch Unit/Instruction Decoder/Subthreshold Leakage': 0.442943,
'Instruction Fetch Unit/Instruction Decoder/Subthreshold Leakage with power gating': 0.166104,
'Instruction Fetch Unit/Peak Dynamic': 4.26802,
'Instruction Fetch Unit/Runtime Dynamic': 0.230703,
'Instruction Fetch Unit/Subthreshold Leakage': 0.932286,
'Instruction Fetch Unit/Subthreshold Leakage with power gating': 0.40843,
'L2/Area': 4.53318,
'L2/Gate Leakage': 0.015464,
'L2/Peak Dynamic': 0.0400426,
'L2/Runtime Dynamic': 0.0100873,
'L2/Subthreshold Leakage': 0.834142,
'L2/Subthreshold Leakage with power gating': 0.401066,
'Load Store Unit/Area': 8.80901,
'Load Store Unit/Data Cache/Area': 6.84535,
'Load Store Unit/Data Cache/Gate Leakage': 0.0279261,
'Load Store Unit/Data Cache/Peak Dynamic': 2.34645,
'Load Store Unit/Data Cache/Runtime Dynamic': 0.549699,
'Load Store Unit/Data Cache/Subthreshold Leakage': 0.527675,
'Load Store Unit/Data Cache/Subthreshold Leakage with power gating': 0.25085,
'Load Store Unit/Gate Leakage': 0.0350888,
'Load Store Unit/LoadQ/Area': 0.0836782,
'Load Store Unit/LoadQ/Gate Leakage': 0.00059896,
'Load Store Unit/LoadQ/Peak Dynamic': 0.0358894,
'Load Store Unit/LoadQ/Runtime Dynamic': 0.0358894,
'Load Store Unit/LoadQ/Subthreshold Leakage': 0.00941961,
'Load Store Unit/LoadQ/Subthreshold Leakage with power gating': 0.00536918,
'Load Store Unit/Peak Dynamic': 2.51592,
'Load Store Unit/Runtime Dynamic': 0.762582,
'Load Store Unit/StoreQ/Area': 0.322079,
'Load Store Unit/StoreQ/Gate Leakage': 0.00329971,
'Load Store Unit/StoreQ/Peak Dynamic': 0.0884971,
'Load Store Unit/StoreQ/Runtime Dynamic': 0.176994,
'Load Store Unit/StoreQ/Subthreshold Leakage': 0.0345621,
'Load Store Unit/StoreQ/Subthreshold Leakage with power gating': 0.0197004,
'Load Store Unit/Subthreshold Leakage': 0.591321,
'Load Store Unit/Subthreshold Leakage with power gating': 0.283293,
'Memory Management Unit/Area': 0.4339,
'Memory Management Unit/Dtlb/Area': 0.0879726,
'Memory Management Unit/Dtlb/Gate Leakage': 0.00088729,
'Memory Management Unit/Dtlb/Peak Dynamic': 0.0314079,
'Memory Management Unit/Dtlb/Runtime Dynamic': 0.0319777,
'Memory Management Unit/Dtlb/Subthreshold Leakage': 0.0155699,
'Memory Management Unit/Dtlb/Subthreshold Leakage with power gating': 0.00887485,
'Memory Management Unit/Gate Leakage': 0.00808595,
'Memory Management Unit/Itlb/Area': 0.301552,
'Memory Management Unit/Itlb/Gate Leakage': 0.00393464,
'Memory Management Unit/Itlb/Peak Dynamic': 0.121532,
'Memory Management Unit/Itlb/Runtime Dynamic': 0.0142383,
'Memory Management Unit/Itlb/Subthreshold Leakage': 0.0413758,
'Memory Management Unit/Itlb/Subthreshold Leakage with power gating': 0.0235842,
'Memory Management Unit/Peak Dynamic': 0.331594,
'Memory Management Unit/Runtime Dynamic': 0.046216,
'Memory Management Unit/Subthreshold Leakage': 0.0766103,
'Memory Management Unit/Subthreshold Leakage with power gating': 0.0398333,
'Peak Dynamic': 14.9117,
'Renaming Unit/Area': 0.303608,
'Renaming Unit/FP Front End RAT/Area': 0.131045,
'Renaming Unit/FP Front End RAT/Gate Leakage': 0.00351123,
'Renaming Unit/FP Front End RAT/Peak Dynamic': 2.51468,
'Renaming Unit/FP Front End RAT/Runtime Dynamic': 0.0378998,
'Renaming Unit/FP Front End RAT/Subthreshold Leakage': 0.0308571,
'Renaming Unit/FP Front End RAT/Subthreshold Leakage with power gating': 0.0175885,
'Renaming Unit/Free List/Area': 0.0340654,
'Renaming Unit/Free List/Gate Leakage': 2.5481e-05,
'Renaming Unit/Free List/Peak Dynamic': 0.0306032,
'Renaming Unit/Free List/Runtime Dynamic': 0.00511039,
'Renaming Unit/Free List/Subthreshold Leakage': 0.000370144,
'Renaming Unit/Free List/Subthreshold Leakage with power gating': 0.000201064,
'Renaming Unit/Gate Leakage': 0.00708398,
'Renaming Unit/Int Front End RAT/Area': 0.0941223,
'Renaming Unit/Int Front End RAT/Gate Leakage': 0.000283242,
'Renaming Unit/Int Front End RAT/Peak Dynamic': 0.731965,
'Renaming Unit/Int Front End RAT/Runtime Dynamic': 0.0524499,
'Renaming Unit/Int Front End RAT/Subthreshold Leakage': 0.00435488,
'Renaming Unit/Int Front End RAT/Subthreshold Leakage with power gating': 0.00248228,
'Renaming Unit/Peak Dynamic': 3.58947,
'Renaming Unit/Runtime Dynamic': 0.0954601,
'Renaming Unit/Subthreshold Leakage': 0.0552466,
'Renaming Unit/Subthreshold Leakage with power gating': 0.0276461,
'Runtime Dynamic': 2.37291,
'Subthreshold Leakage': 6.16288,
'Subthreshold Leakage with power gating': 2.55328},
{'Area': 32.0201,
'Execution Unit/Area': 7.68434,
'Execution Unit/Complex ALUs/Area': 0.235435,
'Execution Unit/Complex ALUs/Gate Leakage': 0.0132646,
'Execution Unit/Complex ALUs/Peak Dynamic': 0.0118559,
'Execution Unit/Complex ALUs/Runtime Dynamic': 0.212,
'Execution Unit/Complex ALUs/Subthreshold Leakage': 0.20111,
'Execution Unit/Complex ALUs/Subthreshold Leakage with power gating': 0.0754163,
'Execution Unit/Floating Point Units/Area': 4.6585,
'Execution Unit/Floating Point Units/Gate Leakage': 0.0656156,
'Execution Unit/Floating Point Units/Peak Dynamic': 0.060521,
'Execution Unit/Floating Point Units/Runtime Dynamic': 0.304033,
'Execution Unit/Floating Point Units/Subthreshold Leakage': 0.994829,
'Execution Unit/Floating Point Units/Subthreshold Leakage with power gating': 0.373061,
'Execution Unit/Gate Leakage': 0.120359,
'Execution Unit/Instruction Scheduler/Area': 1.66526,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Area': 0.275653,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Gate Leakage': 0.000977433,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Peak Dynamic': 1.04181,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Runtime Dynamic': 0.0715576,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Subthreshold Leakage': 0.0143453,
'Execution Unit/Instruction Scheduler/FP Instruction Window/Subthreshold Leakage with power gating': 0.00810519,
'Execution Unit/Instruction Scheduler/Gate Leakage': 0.00568913,
'Execution Unit/Instruction Scheduler/Instruction Window/Area': 0.805223,
'Execution Unit/Instruction Scheduler/Instruction Window/Gate Leakage': 0.00414562,
'Execution Unit/Instruction Scheduler/Instruction Window/Peak Dynamic': 1.6763,
'Execution Unit/Instruction Scheduler/Instruction Window/Runtime Dynamic': 0.11542,
'Execution Unit/Instruction Scheduler/Instruction Window/Subthreshold Leakage': 0.0625755,
'Execution Unit/Instruction Scheduler/Instruction Window/Subthreshold Leakage with power gating': 0.0355964,
'Execution Unit/Instruction Scheduler/Peak Dynamic': 3.82262,
'Execution Unit/Instruction Scheduler/ROB/Area': 0.584388,
'Execution Unit/Instruction Scheduler/ROB/Gate Leakage': 0.00056608,
'Execution Unit/Instruction Scheduler/ROB/Peak Dynamic': 1.10451,
'Execution Unit/Instruction Scheduler/ROB/Runtime Dynamic': 0.05826,
'Execution Unit/Instruction Scheduler/ROB/Subthreshold Leakage': 0.00906853,
'Execution Unit/Instruction Scheduler/ROB/Subthreshold Leakage with power gating': 0.00364446,
'Execution Unit/Instruction Scheduler/Runtime Dynamic': 0.245237,
'Execution Unit/Instruction Scheduler/Subthreshold Leakage': 0.0859892,
'Execution Unit/Instruction Scheduler/Subthreshold Leakage with power gating': 0.047346,
'Execution Unit/Integer ALUs/Area': 0.47087,
'Execution Unit/Integer ALUs/Gate Leakage': 0.0265291,
'Execution Unit/Integer ALUs/Peak Dynamic': 0.0725621,
'Execution Unit/Integer ALUs/Runtime Dynamic': 0.101344,
'Execution Unit/Integer ALUs/Subthreshold Leakage': 0.40222,
'Execution Unit/Integer ALUs/Subthreshold Leakage with power gating': 0.150833,
'Execution Unit/Peak Dynamic': 4.07335,
'Execution Unit/Register Files/Area': 0.570804,
'Execution Unit/Register Files/Floating Point RF/Area': 0.208131,
'Execution Unit/Register Files/Floating Point RF/Gate Leakage': 0.000232788,
'Execution Unit/Register Files/Floating Point RF/Peak Dynamic': 0.0114337,
'Execution Unit/Register Files/Floating Point RF/Runtime Dynamic': 0.00300145,
'Execution Unit/Register Files/Floating Point RF/Subthreshold Leakage': 0.00399698,
'Execution Unit/Register Files/Floating Point RF/Subthreshold Leakage with power gating': 0.00176968,
'Execution Unit/Register Files/Gate Leakage': 0.000622708,
'Execution Unit/Register Files/Integer RF/Area': 0.362673,
'Execution Unit/Register Files/Integer RF/Gate Leakage': 0.00038992,
'Execution Unit/Register Files/Integer RF/Peak Dynamic': 0.0262853,
'Execution Unit/Register Files/Integer RF/Runtime Dynamic': 0.0221975,
'Execution Unit/Register Files/Integer RF/Subthreshold Leakage': 0.00614175,
'Execution Unit/Register Files/Integer RF/Subthreshold Leakage with power gating': 0.00246675,
'Execution Unit/Register Files/Peak Dynamic': 0.037719,
'Execution Unit/Register Files/Runtime Dynamic': 0.025199,
'Execution Unit/Register Files/Subthreshold Leakage': 0.0101387,
'Execution Unit/Register Files/Subthreshold Leakage with power gating': 0.00423643,
'Execution Unit/Results Broadcast Bus/Area Overhead': 0.0390912,
'Execution Unit/Results Broadcast Bus/Gate Leakage': 0.00537402,
'Execution Unit/Results Broadcast Bus/Peak Dynamic': 0.0583403,
'Execution Unit/Results Broadcast Bus/Runtime Dynamic': 0.160581,
'Execution Unit/Results Broadcast Bus/Subthreshold Leakage': 0.081478,
'Execution Unit/Results Broadcast Bus/Subthreshold Leakage with power gating': 0.0305543,
'Execution Unit/Runtime Dynamic': 1.0484,
'Execution Unit/Subthreshold Leakage': 1.79543,
'Execution Unit/Subthreshold Leakage with power gating': 0.688821,
'Gate Leakage': 0.368936,
'Instruction Fetch Unit/Area': 5.85939,
'Instruction Fetch Unit/Branch Predictor/Area': 0.138516,
'Instruction Fetch Unit/Branch Predictor/Chooser/Area': 0.0435221,
'Instruction Fetch Unit/Branch Predictor/Chooser/Gate Leakage': 0.000278362,
'Instruction Fetch Unit/Branch Predictor/Chooser/Peak Dynamic': 0.0168831,
'Instruction Fetch Unit/Branch Predictor/Chooser/Runtime Dynamic': 0.000374453,
'Instruction Fetch Unit/Branch Predictor/Chooser/Subthreshold Leakage': 0.00759719,
'Instruction Fetch Unit/Branch Predictor/Chooser/Subthreshold Leakage with power gating': 0.0039236,
'Instruction Fetch Unit/Branch Predictor/Gate Leakage': 0.000757657,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Area': 0.0435221,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Gate Leakage': 0.000278362,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Peak Dynamic': 0.0168831,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Runtime Dynamic': 0.000374453,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Subthreshold Leakage': 0.00759719,
'Instruction Fetch Unit/Branch Predictor/Global Predictor/Subthreshold Leakage with power gating': 0.0039236,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Area': 0.0257064,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Gate Leakage': 0.000154548,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Peak Dynamic': 0.0142575,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Runtime Dynamic': 0.000332464,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Subthreshold Leakage': 0.00384344,
'Instruction Fetch Unit/Branch Predictor/L1_Local Predictor/Subthreshold Leakage with power gating': 0.00198631,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Area': 0.0151917,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Gate Leakage': 8.00196e-05,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Peak Dynamic': 0.00527447,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Runtime Dynamic': 0.000132157,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Subthreshold Leakage': 0.00181347,
'Instruction Fetch Unit/Branch Predictor/L2_Local Predictor/Subthreshold Leakage with power gating': 0.000957045,
'Instruction Fetch Unit/Branch Predictor/Peak Dynamic': 0.0597838,
'Instruction Fetch Unit/Branch Predictor/RAS/Area': 0.0105732,
'Instruction Fetch Unit/Branch Predictor/RAS/Gate Leakage': 4.63858e-05,
'Instruction Fetch Unit/Branch Predictor/RAS/Peak Dynamic': 0.0117602,
'Instruction Fetch Unit/Branch Predictor/RAS/Runtime Dynamic': 0.000318869,
'Instruction Fetch Unit/Branch Predictor/RAS/Subthreshold Leakage': 0.000932505,
'Instruction Fetch Unit/Branch Predictor/RAS/Subthreshold Leakage with power gating': 0.000494733,
'Instruction Fetch Unit/Branch Predictor/Runtime Dynamic': 0.00140024,
'Instruction Fetch Unit/Branch Predictor/Subthreshold Leakage': 0.0199703,
'Instruction Fetch Unit/Branch Predictor/Subthreshold Leakage with power gating': 0.0103282,
'Instruction Fetch Unit/Branch Target Buffer/Area': 0.64954,
'Instruction Fetch Unit/Branch Target Buffer/Gate Leakage': 0.00272758,
'Instruction Fetch Unit/Branch Target Buffer/Peak Dynamic': 0.177867,
'Instruction Fetch Unit/Branch Target Buffer/Runtime Dynamic': 0.00336457,
'Instruction Fetch Unit/Branch Target Buffer/Subthreshold Leakage': 0.0811682,
'Instruction Fetch Unit/Branch Target Buffer/Subthreshold Leakage with power gating': 0.0435357,
'Instruction Fetch Unit/Gate Leakage': 0.0589979,
'Instruction Fetch Unit/Instruction Buffer/Area': 0.0226323,
'Instruction Fetch Unit/Instruction Buffer/Gate Leakage': 6.83558e-05,
'Instruction Fetch Unit/Instruction Buffer/Peak Dynamic': 0.606827,
'Instruction Fetch Unit/Instruction Buffer/Runtime Dynamic': 0.0213391,
'Instruction Fetch Unit/Instruction Buffer/Subthreshold Leakage': 0.00151885,
'Instruction Fetch Unit/Instruction Buffer/Subthreshold Leakage with power gating': 0.000701682,
'Instruction Fetch Unit/Instruction Cache/Area': 3.14635,
'Instruction Fetch Unit/Instruction Cache/Gate Leakage': 0.029931,
'Instruction Fetch Unit/Instruction Cache/Peak Dynamic': 1.35735,
'Instruction Fetch Unit/Instruction Cache/Runtime Dynamic': 0.0530035,
'Instruction Fetch Unit/Instruction Cache/Subthreshold Leakage': 0.367022,
'Instruction Fetch Unit/Instruction Cache/Subthreshold Leakage with power gating': 0.180386,
'Instruction Fetch Unit/Instruction Decoder/Area': 1.85799,
'Instruction Fetch Unit/Instruction Decoder/Gate Leakage': 0.0222493,
'Instruction Fetch Unit/Instruction Decoder/Peak Dynamic': 1.37404,
'Instruction Fetch Unit/Instruction Decoder/Runtime Dynamic': 0.0724771,
'Instruction Fetch Unit/Instruction Decoder/Subthreshold Leakage': 0.442943,
'Instruction Fetch Unit/Instruction Decoder/Subthreshold Leakage with power gating': 0.166104,
'Instruction Fetch Unit/Peak Dynamic': 3.64174,
'Instruction Fetch Unit/Runtime Dynamic': 0.151584,
'Instruction Fetch Unit/Subthreshold Leakage': 0.932286,
'Instruction Fetch Unit/Subthreshold Leakage with power gating': 0.40843,
'L2/Area': 4.53318,
'L2/Gate Leakage': 0.015464,
'L2/Peak Dynamic': 0.0384802,
'L2/Runtime Dynamic': 0.00959312,
'L2/Subthreshold Leakage': 0.834142,
'L2/Subthreshold Leakage with power gating': 0.401066,
'Load Store Unit/Area': 8.80901,
'Load Store Unit/Data Cache/Area': 6.84535,
'Load Store Unit/Data Cache/Gate Leakage': 0.0279261,
'Load Store Unit/Data Cache/Peak Dynamic': 2.0509,
'Load Store Unit/Data Cache/Runtime Dynamic': 0.406273,
'Load Store Unit/Data Cache/Subthreshold Leakage': 0.527675,
'Load Store Unit/Data Cache/Subthreshold Leakage with power gating': 0.25085,
'Load Store Unit/Gate Leakage': 0.0350888,
'Load Store Unit/LoadQ/Area': 0.0836782,
'Load Store Unit/LoadQ/Gate Leakage': 0.00059896,
'Load Store Unit/LoadQ/Peak Dynamic': 0.0263276,
'Load Store Unit/LoadQ/Runtime Dynamic': 0.0263275,
'Load Store Unit/LoadQ/Subthreshold Leakage': 0.00941961,
'Load Store Unit/LoadQ/Subthreshold Leakage with power gating': 0.00536918,
'Load Store Unit/Peak Dynamic': 2.17522,
'Load Store Unit/Runtime Dynamic': 0.562439,
'Load Store Unit/StoreQ/Area': 0.322079,
'Load Store Unit/StoreQ/Gate Leakage': 0.00329971,
'Load Store Unit/StoreQ/Peak Dynamic': 0.0649195,
'Load Store Unit/StoreQ/Runtime Dynamic': 0.129838,
'Load Store Unit/StoreQ/Subthreshold Leakage': 0.0345621,
'Load Store Unit/StoreQ/Subthreshold Leakage with power gating': 0.0197004,
'Load Store Unit/Subthreshold Leakage': 0.591321,
'Load Store Unit/Subthreshold Leakage with power gating': 0.283293,
'Memory Management Unit/Area': 0.4339,
'Memory Management Unit/Dtlb/Area': 0.0879726,
'Memory Management Unit/Dtlb/Gate Leakage': 0.00088729,
'Memory Management Unit/Dtlb/Peak Dynamic': 0.0230401,
'Memory Management Unit/Dtlb/Runtime Dynamic': 0.0236093,
'Memory Management Unit/Dtlb/Subthreshold Leakage': 0.0155699,
'Memory Management Unit/Dtlb/Subthreshold Leakage with power gating': 0.00887485,
'Memory Management Unit/Gate Leakage': 0.00808595,
'Memory Management Unit/Itlb/Area': 0.301552,
'Memory Management Unit/Itlb/Gate Leakage': 0.00393464,
'Memory Management Unit/Itlb/Peak Dynamic': 0.0843949,
'Memory Management Unit/Itlb/Runtime Dynamic': 0.00871477,
'Memory Management Unit/Itlb/Subthreshold Leakage': 0.0413758,
'Memory Management Unit/Itlb/Subthreshold Leakage with power gating': 0.0235842,
'Memory Management Unit/Peak Dynamic': 0.280083,
'Memory Management Unit/Runtime Dynamic': 0.0323241,
'Memory Management Unit/Subthreshold Leakage': 0.0766103,
'Memory Management Unit/Subthreshold Leakage with power gating': 0.0398333,
'Peak Dynamic': 13.7983,
'Renaming Unit/Area': 0.303608,
'Renaming Unit/FP Front End RAT/Area': 0.131045,
'Renaming Unit/FP Front End RAT/Gate Leakage': 0.00351123,
'Renaming Unit/FP Front End RAT/Peak Dynamic': 2.51468,
'Renaming Unit/FP Front End RAT/Runtime Dynamic': 0.0300766,
'Renaming Unit/FP Front End RAT/Subthreshold Leakage': 0.0308571,
'Renaming Unit/FP Front End RAT/Subthreshold Leakage with power gating': 0.0175885,
'Renaming Unit/Free List/Area': 0.0340654,
'Renaming Unit/Free List/Gate Leakage': 2.5481e-05,
'Renaming Unit/Free List/Peak Dynamic': 0.0306032,
'Renaming Unit/Free List/Runtime Dynamic': 0.00359451,
'Renaming Unit/Free List/Subthreshold Leakage': 0.000370144,
'Renaming Unit/Free List/Subthreshold Leakage with power gating': 0.000201064,
'Renaming Unit/Gate Leakage': 0.00708398,
'Renaming Unit/Int Front End RAT/Area': 0.0941223,
'Renaming Unit/Int Front End RAT/Gate Leakage': 0.000283242,
'Renaming Unit/Int Front End RAT/Peak Dynamic': 0.731965,
'Renaming Unit/Int Front End RAT/Runtime Dynamic': 0.0366169,
'Renaming Unit/Int Front End RAT/Subthreshold Leakage': 0.00435488,
'Renaming Unit/Int Front End RAT/Subthreshold Leakage with power gating': 0.00248228,
'Renaming Unit/Peak Dynamic': 3.58947,
'Renaming Unit/Runtime Dynamic': 0.070288,
'Renaming Unit/Subthreshold Leakage': 0.0552466,
'Renaming Unit/Subthreshold Leakage with power gating': 0.0276461,
'Runtime Dynamic': 1.87462,
'Subthreshold Leakage': 6.16288,
'Subthreshold Leakage with power gating': 2.55328}],
'DRAM': {'Area': 0,
'Gate Leakage': 0,
'Peak Dynamic': 6.7133013220344875,
'Runtime Dynamic': 6.7133013220344875,
'Subthreshold Leakage': 4.252,
'Subthreshold Leakage with power gating': 4.252},
'L3': [{'Area': 61.9075,
'Gate Leakage': 0.0484137,
'Peak Dynamic': 0.334987,
'Runtime Dynamic': 0.0855449,
'Subthreshold Leakage': 6.80085,
'Subthreshold Leakage with power gating': 3.32364}],
'Processor': {'Area': 191.908,
'Gate Leakage': 1.53485,
'Peak Dynamic': 67.4667,
'Peak Power': 100.579,
'Runtime Dynamic': 12.4575,
'Subthreshold Leakage': 31.5774,
'Subthreshold Leakage with power gating': 13.9484,
'Total Cores/Area': 128.669,
'Total Cores/Gate Leakage': 1.4798,
'Total Cores/Peak Dynamic': 67.1317,
'Total Cores/Runtime Dynamic': 12.3719,
'Total Cores/Subthreshold Leakage': 24.7074,
'Total Cores/Subthreshold Leakage with power gating': 10.2429,
'Total L3s/Area': 61.9075,
'Total L3s/Gate Leakage': 0.0484137,
'Total L3s/Peak Dynamic': 0.334987,
'Total L3s/Runtime Dynamic': 0.0855449,
'Total L3s/Subthreshold Leakage': 6.80085,
'Total L3s/Subthreshold Leakage with power gating': 3.32364,
'Total Leakage': 33.1122,
'Total NoCs/Area': 1.33155,
'Total NoCs/Gate Leakage': 0.00662954,
'Total NoCs/Peak Dynamic': 0.0,
'Total NoCs/Runtime Dynamic': 0.0,
'Total NoCs/Subthreshold Leakage': 0.0691322,
'Total NoCs/Subthreshold Leakage with power gating': 0.0259246}} |
# Definition for a binary tree node.
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
sum = 0
def DFS(self,node: TreeNode, path: str):
if node is None:
return
if node.left is None and node.right is None:
self.sum+= int(path+str(node.val))
return
path = path+str(node.val)
self.DFS(node.left, path)
self.DFS(node.right, path)
def sumNumbers(self, root: TreeNode) -> int:
if root is None:
return []
self.DFS(root, "")
return self.sum
|
N=int(input())
count=0
for i in range(1,N+1):
if len(str(i))%2==1:count+=1
print(count) |
#
# PySNMP MIB module CXCFG-IPX-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CXCFG-IPX-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:32:22 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
ObjectIdentifier, Integer, OctetString = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "Integer", "OctetString")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsIntersection, SingleValueConstraint, ValueRangeConstraint, ConstraintsUnion, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "SingleValueConstraint", "ValueRangeConstraint", "ConstraintsUnion", "ValueSizeConstraint")
cxIpx, Alias = mibBuilder.importSymbols("CXProduct-SMI", "cxIpx", "Alias")
ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup")
iso, MibIdentifier, Counter64, ModuleIdentity, Counter32, Unsigned32, MibScalar, MibTable, MibTableRow, MibTableColumn, ObjectIdentity, Bits, NotificationType, TimeTicks, Gauge32, Integer32, IpAddress = mibBuilder.importSymbols("SNMPv2-SMI", "iso", "MibIdentifier", "Counter64", "ModuleIdentity", "Counter32", "Unsigned32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ObjectIdentity", "Bits", "NotificationType", "TimeTicks", "Gauge32", "Integer32", "IpAddress")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
cxCfgIpx = MibIdentifier((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1))
class NetNumber(OctetString):
subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(4, 4)
fixedLength = 4
cxCfgIpxNumClockTicksPerSecond = MibScalar((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 1), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxNumClockTicksPerSecond.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxNumClockTicksPerSecond.setDescription('Identifies the number of clock ticks per second. Range of Values: None Default Value: The value is always 1 ')
cxCfgIpxPortTable = MibTable((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2), )
if mibBuilder.loadTexts: cxCfgIpxPortTable.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortTable.setDescription('Provides configuration information for each IPX port. The table contains three default entries (rows); each row corresponds to a particular IPX port. Some of the values in a row can be modified. If more than three IPX ports are required, additional entries can be added.')
cxCfgIpxPortEntry = MibTableRow((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1), ).setIndexNames((0, "CXCFG-IPX-MIB", "cxCfgIpxPort"))
if mibBuilder.loadTexts: cxCfgIpxPortEntry.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortEntry.setDescription('Provides configuration information for a particular IPX port. Some of the parameters can be modified.')
cxCfgIpxPort = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly")
if mibBuilder.loadTexts: cxCfgIpxPort.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPort.setDescription('Identifies the number of the IPX Port. The number is used as local index for this and the ipxStatsTable. Range of Values: From 1 to 32 Default Value: None Note: The system defines three default entries; their respective values are 1, 2, and 3.')
cxCfgIpxPortIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: cxCfgIpxPortIfIndex.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortIfIndex.setDescription('Identifies the table row that contains configuration or monitoring objects for a specific type of physical interface. Range of Values: From 1 to the number of entries in the interface table. Default value: None ')
cxCfgIpxPortSubnetworkSAPAlias = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 3), Alias()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxPortSubnetworkSAPAlias.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortSubnetworkSAPAlias.setDescription('Determines the name which uniquely defines the cxCfgIpxPortSubnetworkSap. Range of Values: 0 to 16 alphanumeric characters. The first character must be a letter, spaces are not allowed. Default Values: None Note: The system defines three default entries; their respective values are LAN-PORT1, CNV-PORT1, and CNV-PORT2. Related Parameter: The object must be the same as cxLanIoPortAlias of the cxLanIoPortTable, and cxFwkDestAlias in cxFwkCircuitTable. Configuration Changed: Administrative')
cxCfgIpxPortState = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("on", 1), ("off", 2))).clone('off')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxPortState.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortState.setDescription('Determines the initialization state of the IPX port. Options: on (1): The port is active, transmission is possible. off (2): The port is inactive, transmission is not possible. Default Values: (1) On. For LAN ports (2) Off. For convergence ports Configuration Changed: Administrative')
cxCfgIpxPortRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("invalid", 1), ("valid", 2))).clone('valid')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxPortRowStatus.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortRowStatus.setDescription('Determines the status of the objects in a table row. Options: valid (1): Values are enabled. invalid (2): Row is flagged, after next reset the values will be disabled and the row will be deleted from the table. Default Value: (1) Valid. Values are enabled Configuration Changed: Administrative ')
cxCfgIpxPortTransportTime = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 30)).clone(1)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxPortTransportTime.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortTransportTime.setDescription('Determines the transport time, in clock ticks, for LAN or WAN links. This value is set to 1 for LAN links. WAN links may have a value of 1 or higher. One clock tick is 55 ms. Range of Values: From 1 to 30 Default Value: 1 Configuration Changed: Administrative')
cxCfgIpxPortMaxHops = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 7), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 16)).clone(16)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxPortMaxHops.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortMaxHops.setDescription('Determines the maximum number of hops a packet may take before it is discarded. Range of Values: From 1 to 16 Default Value: 16 Configuration Changed: Administrative ')
cxCfgIpxPortIntNetNum = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 8), NetNumber()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxPortIntNetNum.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortIntNetNum.setDescription('Determines the IPX internal network number associated with the port. The number must be entered as 8 hexadecimal characters, for example 0xAB12CD34. The x must be lowercase; the others are not case sensitive. Range of Values: 4 octets, each character ranging from 00 to FF Default Value: None Note: The system defines three default entries; their respective values are 00 00 00 0xa2, 00 00 00 0xf1, and 00 00 00 0xf2. Configuration Changed: Administrative ')
cxCfgIpxPortPerSapBcast = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("on", 1), ("off", 2))).clone('on')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxPortPerSapBcast.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortPerSapBcast.setDescription('Determines whether periodic SAP broadcasting is active. Options: On (1): SAP broadcasting is active, and the router sends periodic SAP broadcasts to advertise its services to other locally attached networks. Off (2): SAP broadcasting is inactive. Default Value: (1) Related parameter: The frequency of the broadcast is determined by cxCfgIpxPortPerSAPTxTimer. Configuration Changed: Administrative')
cxCfgIpxPortPerRipBcast = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("on", 1), ("off", 2))).clone('on')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxPortPerRipBcast.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortPerRipBcast.setDescription('Determines whether periodic RIP broadcasting is active. Options: on (1): RIP broadcasting is active, and the router sends periodic RIP broadcasts to advertise its services to other locally attached networks. off (2): RIP broadcasting is inactive. Default Value: on (1) Related Parameter: The frequency of the broadcast is determined by cxCfgIpxPortPerRipTxTimer. Configuration Changed: Administrative')
cxCfgIpxPortSapBcast = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 11), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("on", 1), ("off", 2))).clone('on')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxPortSapBcast.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortSapBcast.setDescription('Determines whether the port sends a SAP broadcast in response to a SAP query sent by another router. Options: on (1): The port will respond to SAP queries. off (2): The port will not respond to SAP queries. Default Value: on (1) Configuration Changed: Administrative')
cxCfgIpxPortRipBcast = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 12), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("on", 1), ("off", 2))).clone('on')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxPortRipBcast.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortRipBcast.setDescription('Determines whether the port sends a RIP broadcast in response to a RIP query sent by another router. When the value is set to on, the port responds to RIP queries. Options: On (1): The port will respond to RIP queries. Off (2): The port will not respond to RIP queries. Default Value: on (1) Configuration Changed: Administrative')
cxCfgIpxPortDiagPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 13), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("on", 1), ("off", 2))).clone('off')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxPortDiagPackets.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortDiagPackets.setDescription('Determines whether the IPX port will respond to diagnostic packets. Options: On (1): The port will respond, and will transmit a diagnostic response packet. Off (2): The port will not respond. Default Value: off (2) Configuration Changed: Administrative. ')
cxCfgIpxPortPerRipTxTimer = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 14), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 3600)).clone(60)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxPortPerRipTxTimer.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortPerRipTxTimer.setDescription('Determines the length of time, in seconds, between periodic RIP broadcasts. Range of Values: From 1 to 3600 Default Value: 60 Configuration Changed: Administrative ')
cxCfgIpxPortPerSapTxTimer = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 15), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 3600)).clone(60)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxPortPerSapTxTimer.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortPerSapTxTimer.setDescription('Determines the length of time, in seconds, between periodic SAP broadcasts. Range of Values: From 1 to 3600 Default Value: 60 Configuration Changed: Administrative')
cxCfgIpxPortRipAgeTimer = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 16), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 3600)).clone(180)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxPortRipAgeTimer.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortRipAgeTimer.setDescription("Determines the length of time, in seconds, that an entry can remain in the IPX port's RIP table without being updated. When the value (number of seconds) expires the entry in the RIP table is deleted. A value of 0 means aging is not used. Range of Values: From 1 to 3600 Default Value: 180 Configuration Changed: Administrative ")
cxCfgIpxPortSapAgeTimer = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 17), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 3600)).clone(180)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxPortSapAgeTimer.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortSapAgeTimer.setDescription("Determines the length of time (aging), in seconds, that an entry can remain in the IPX port's SAP table without being updated. When the value (number of seconds) expires the entry in the SAP table is deleted. A value of 0 means aging is not used. Range of Values: From 1 to 3600 Default Value: 180 Configuration Changed: Administrative ")
cxCfgIpxPortFrameType = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 18), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("raw-802-3", 1), ("ethernet-II", 2), ("llc-802-2", 3), ("snap", 4))).clone('raw-802-3')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxPortFrameType.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortFrameType.setDescription('Determines which type of framing is used for IPX header information. Framing refers to the way the header information is formatted. The format is determined by the destination IPX number. Upon receipt of data, the IPX router checks its address tables to determine which header format is used by the destination address. The first three options are used for LAN data; the fourth option is used for WAN (frame relay) destinations. Options: raw- 802-3 (1): Used for LAN data. ethernet-II (2): Used for LAN data. LLC-802-3 (3): Used for LAN data. snap (4): Used for WAN (frame relay). Default Value: raw- 802-3 (1) Configuration Changed: Administrative')
cxCfgIpxPortWatchSpoof = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 19), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("on", 1), ("off", 2))).clone('off')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxPortWatchSpoof.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortWatchSpoof.setDescription('Determines whether IPX Watchdog Spoofing is enabled (on). IPX Watchdog Spoofing is a software technique that limits the number of IPX Watchdog frames that are sent over a WAN; the technique is intended to decrease the use of expensive WAN lines without disturbing overall network use. If IPX Watchdog Spoofing is desired, the remote peer must also have this parameter enabled. Options: on (1): IPX Watchdog Spoofing is enabled. off (2): IPX Watchdog Spoofing is disabled. Default Value: off (2) Configuration Changed: Administrative ')
cxCfgIpxPortSpxWatchSpoof = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 20), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("on", 1), ("off", 2))).clone('off')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxPortSpxWatchSpoof.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortSpxWatchSpoof.setDescription('Determines whether SPX Watchdog Spoofing is enabled (on). SPX Watchdog Spoofing is a software technique that limits the number of SPX Watchdog frames that are sent over a WAN; the technique is intended to decrease the use of expensive WAN lines without disturbing overall network use. If SPX Watchdog Spoofing is desired, the remote peer must also have this parameter on. Options: On (1): SPX Watchdog Spoofing is enabled. Off (2): SPX Watchdog Spoofing is disabled. Default Value: off (2) Configuration Changed: Administrative')
cxCfgIpxPortSerialSpoof = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 21), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("on", 1), ("off", 2))).clone('off')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxPortSerialSpoof.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortSerialSpoof.setDescription('Determines whether Serialization Spoofing is (enabled) on. Serialization Spoofing is a software technique that limits the number of Serialization frames (they test the legal version of Novell software) that are sent over a WAN; the technique is intended to decrease the use of expensive WAN lines without disturbing overall network use. Options: on (1): Serialization Spoofing is enabled. off (2): Serialization Spoofing is disabled. Default Value: off (2) Configuration Changed: Administrative ')
cxCfgIpxPortSRSupport = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 2, 1, 22), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2))).clone('disabled')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cxCfgIpxPortSRSupport.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxPortSRSupport.setDescription('Determines whether the port should support Source Routing packet. If it is enabled, the physical infterface of the port must be Token-Ring. If it is disabled, any Source Routing packet will be discarded. Default Value: disabled (2) Configuration Changed: administrative')
cxCfgIpxMibLevel = MibScalar((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 13, 1, 20), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: cxCfgIpxMibLevel.setStatus('mandatory')
if mibBuilder.loadTexts: cxCfgIpxMibLevel.setDescription('Used to determine current MIB module release supported by the agent. Object is in decimal.')
mibBuilder.exportSymbols("CXCFG-IPX-MIB", cxCfgIpxPortFrameType=cxCfgIpxPortFrameType, cxCfgIpxPortRowStatus=cxCfgIpxPortRowStatus, cxCfgIpxPortIfIndex=cxCfgIpxPortIfIndex, cxCfgIpxPortSubnetworkSAPAlias=cxCfgIpxPortSubnetworkSAPAlias, cxCfgIpxPortSpxWatchSpoof=cxCfgIpxPortSpxWatchSpoof, cxCfgIpxPortPerSapTxTimer=cxCfgIpxPortPerSapTxTimer, cxCfgIpxNumClockTicksPerSecond=cxCfgIpxNumClockTicksPerSecond, cxCfgIpxPortRipAgeTimer=cxCfgIpxPortRipAgeTimer, cxCfgIpxPortTransportTime=cxCfgIpxPortTransportTime, cxCfgIpxPortRipBcast=cxCfgIpxPortRipBcast, cxCfgIpxPortMaxHops=cxCfgIpxPortMaxHops, cxCfgIpxPortState=cxCfgIpxPortState, cxCfgIpxPortEntry=cxCfgIpxPortEntry, NetNumber=NetNumber, cxCfgIpxMibLevel=cxCfgIpxMibLevel, cxCfgIpxPortSerialSpoof=cxCfgIpxPortSerialSpoof, cxCfgIpxPortSapBcast=cxCfgIpxPortSapBcast, cxCfgIpxPortSapAgeTimer=cxCfgIpxPortSapAgeTimer, cxCfgIpxPortIntNetNum=cxCfgIpxPortIntNetNum, cxCfgIpxPortSRSupport=cxCfgIpxPortSRSupport, cxCfgIpxPortPerRipTxTimer=cxCfgIpxPortPerRipTxTimer, cxCfgIpx=cxCfgIpx, cxCfgIpxPortWatchSpoof=cxCfgIpxPortWatchSpoof, cxCfgIpxPortPerSapBcast=cxCfgIpxPortPerSapBcast, cxCfgIpxPortTable=cxCfgIpxPortTable, cxCfgIpxPortPerRipBcast=cxCfgIpxPortPerRipBcast, cxCfgIpxPortDiagPackets=cxCfgIpxPortDiagPackets, cxCfgIpxPort=cxCfgIpxPort)
|
#
# PySNMP MIB module RBN-ENVMON-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RBN-ENVMON-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:44:20 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
ObjectIdentifier, Integer, OctetString = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "Integer", "OctetString")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsUnion, ValueSizeConstraint, SingleValueConstraint, ConstraintsIntersection, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "ValueSizeConstraint", "SingleValueConstraint", "ConstraintsIntersection", "ValueRangeConstraint")
rbnMgmt, = mibBuilder.importSymbols("RBN-SMI", "rbnMgmt")
NotificationGroup, ModuleCompliance, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup")
MibIdentifier, MibScalar, MibTable, MibTableRow, MibTableColumn, iso, Counter64, Counter32, TimeTicks, IpAddress, NotificationType, ModuleIdentity, Unsigned32, Gauge32, ObjectIdentity, Bits, Integer32 = mibBuilder.importSymbols("SNMPv2-SMI", "MibIdentifier", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "iso", "Counter64", "Counter32", "TimeTicks", "IpAddress", "NotificationType", "ModuleIdentity", "Unsigned32", "Gauge32", "ObjectIdentity", "Bits", "Integer32")
TruthValue, TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TruthValue", "TextualConvention", "DisplayString")
rbnEnvMonMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 2352, 2, 4))
if mibBuilder.loadTexts: rbnEnvMonMIB.setLastUpdated('9901272300Z')
if mibBuilder.loadTexts: rbnEnvMonMIB.setOrganization('RedBack Networks, Inc.')
rbnEnvMonMIBNotifications = MibIdentifier((1, 3, 6, 1, 4, 1, 2352, 2, 4, 0))
rbnEnvMonMIBObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 2352, 2, 4, 1))
rbnEnvMonMIBConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 2352, 2, 4, 2))
rbnFanStatusTable = MibTable((1, 3, 6, 1, 4, 1, 2352, 2, 4, 1, 1), )
if mibBuilder.loadTexts: rbnFanStatusTable.setStatus('current')
rbnFanStatusEntry = MibTableRow((1, 3, 6, 1, 4, 1, 2352, 2, 4, 1, 1, 1), ).setIndexNames((0, "RBN-ENVMON-MIB", "rbnFanIndex"))
if mibBuilder.loadTexts: rbnFanStatusEntry.setStatus('current')
rbnFanIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 2352, 2, 4, 1, 1, 1, 1), Integer32())
if mibBuilder.loadTexts: rbnFanIndex.setStatus('current')
rbnFanDescr = MibTableColumn((1, 3, 6, 1, 4, 1, 2352, 2, 4, 1, 1, 1, 2), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rbnFanDescr.setStatus('current')
rbnFanFail = MibTableColumn((1, 3, 6, 1, 4, 1, 2352, 2, 4, 1, 1, 1, 3), TruthValue()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rbnFanFail.setStatus('current')
rbnPowerStatusTable = MibTable((1, 3, 6, 1, 4, 1, 2352, 2, 4, 1, 2), )
if mibBuilder.loadTexts: rbnPowerStatusTable.setStatus('current')
rbnPowerStatusEntry = MibTableRow((1, 3, 6, 1, 4, 1, 2352, 2, 4, 1, 2, 1), ).setIndexNames((0, "RBN-ENVMON-MIB", "rbnPowerIndex"))
if mibBuilder.loadTexts: rbnPowerStatusEntry.setStatus('current')
rbnPowerIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 2352, 2, 4, 1, 2, 1, 1), Integer32())
if mibBuilder.loadTexts: rbnPowerIndex.setStatus('current')
rbnPowerDescr = MibTableColumn((1, 3, 6, 1, 4, 1, 2352, 2, 4, 1, 2, 1, 2), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rbnPowerDescr.setStatus('current')
rbnPowerFail = MibTableColumn((1, 3, 6, 1, 4, 1, 2352, 2, 4, 1, 2, 1, 3), TruthValue()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rbnPowerFail.setStatus('current')
rbnFanFailChange = NotificationType((1, 3, 6, 1, 4, 1, 2352, 2, 4, 0, 1)).setObjects(("RBN-ENVMON-MIB", "rbnFanFail"))
if mibBuilder.loadTexts: rbnFanFailChange.setStatus('current')
rbnPowerFailChange = NotificationType((1, 3, 6, 1, 4, 1, 2352, 2, 4, 0, 2)).setObjects(("RBN-ENVMON-MIB", "rbnPowerFail"))
if mibBuilder.loadTexts: rbnPowerFailChange.setStatus('current')
rbnEnvMonMIBGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 2352, 2, 4, 2, 1))
rbnEnvMonMIBCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 2352, 2, 4, 2, 2))
rbnEnvMonMIBObjectGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 2352, 2, 4, 2, 1, 1)).setObjects(("RBN-ENVMON-MIB", "rbnFanDescr"), ("RBN-ENVMON-MIB", "rbnFanFail"), ("RBN-ENVMON-MIB", "rbnPowerDescr"), ("RBN-ENVMON-MIB", "rbnPowerFail"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
rbnEnvMonMIBObjectGroup = rbnEnvMonMIBObjectGroup.setStatus('current')
rbnEnvMonMIBNotificationGroup = NotificationGroup((1, 3, 6, 1, 4, 1, 2352, 2, 4, 2, 1, 2)).setObjects(("RBN-ENVMON-MIB", "rbnFanFailChange"), ("RBN-ENVMON-MIB", "rbnPowerFailChange"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
rbnEnvMonMIBNotificationGroup = rbnEnvMonMIBNotificationGroup.setStatus('current')
rbnEnvMonMIBCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 2352, 2, 4, 2, 2, 1)).setObjects(("RBN-ENVMON-MIB", "rbnEnvMonMIBObjectGroup"), ("RBN-ENVMON-MIB", "rbnEnvMonMIBNotificationGroup"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
rbnEnvMonMIBCompliance = rbnEnvMonMIBCompliance.setStatus('current')
mibBuilder.exportSymbols("RBN-ENVMON-MIB", rbnFanFail=rbnFanFail, rbnFanStatusEntry=rbnFanStatusEntry, rbnFanDescr=rbnFanDescr, rbnEnvMonMIBGroups=rbnEnvMonMIBGroups, rbnPowerIndex=rbnPowerIndex, rbnEnvMonMIB=rbnEnvMonMIB, rbnPowerFail=rbnPowerFail, rbnPowerStatusTable=rbnPowerStatusTable, rbnPowerStatusEntry=rbnPowerStatusEntry, rbnEnvMonMIBNotificationGroup=rbnEnvMonMIBNotificationGroup, rbnEnvMonMIBCompliances=rbnEnvMonMIBCompliances, PYSNMP_MODULE_ID=rbnEnvMonMIB, rbnPowerDescr=rbnPowerDescr, rbnEnvMonMIBObjects=rbnEnvMonMIBObjects, rbnEnvMonMIBObjectGroup=rbnEnvMonMIBObjectGroup, rbnPowerFailChange=rbnPowerFailChange, rbnFanFailChange=rbnFanFailChange, rbnFanIndex=rbnFanIndex, rbnEnvMonMIBCompliance=rbnEnvMonMIBCompliance, rbnFanStatusTable=rbnFanStatusTable, rbnEnvMonMIBNotifications=rbnEnvMonMIBNotifications, rbnEnvMonMIBConformance=rbnEnvMonMIBConformance)
|
# -*- coding: utf-8 -*-
"""
Strukture za grafe in funkcije na njih.
V ocenah časovne zahtevnosti je n število vozlišč v grafu,
m število povezav v grafu,
d(u) = d+(u) število (izhodnih) sosedov vozlišča u,
d-(u) pa število vhodnih sosedov vozlišča u.
Pri tem predpostavljamo, da velja n = O(m)
(graf ima O(1) povezanih komponent).
"""
def nothing(u, v = None):
"""
Visit funkcija, ki ne naredi nič.
Časovna zahtevnost: O(1)
"""
return True
class Graf:
"""
Abstraktni razred za grafe.
"""
def __init__(self):
"""
Inicializacija - ni implementirana.
"""
raise NotImplementedError("Ni mogoče narediti objekta abstraktnega razreda!")
def __len__(self):
"""
Število vozlišč v grafu.
Časovna zahtevnost: O(1)
"""
return self.n
def BFS(self, koreni = None, visit = nothing):
"""
Iskanje v širino.
Časovna zahtevnost: iskanje sosedov vsakega vozlišča
+ O(n) klicev funkcije visit
"""
if koreni is None:
koreni = self.vozlisca()
globina = {}
stars = {}
uspeh = True
for w in koreni:
if w in globina:
continue
nivo = [w]
globina[w] = 0
stars[w] = None
i = 1
while len(nivo) > 0:
naslednji = []
for u in nivo:
if not visit(u, stars[u]):
uspeh = False
break
for v in self.sosedi(u):
if v not in globina:
globina[v] = i
stars[v] = u
naslednji.append(v)
nivo = naslednji
i += 1
for u in self.vozlisca():
if u not in globina:
globina[u] = None
stars[u] = None
return (uspeh, globina, stars)
def DFS(self, koreni = None, previsit = nothing, postvisit = nothing):
"""
Iskanje v globino.
Časovna zahtevnost: iskanje sosedov vsakega vozlišča
+ O(n) klicev funkcij previsit in postvisit
"""
if koreni is None:
koreni = self.vozlisca()
globina = {}
stars = {}
uspeh = False
def obisci(u, v):
if u in globina:
return True
globina[u] = 0 if v is None else (globina[v] + 1)
stars[u] = v
if not previsit(u, v):
return False
for w in self.sosedi(u):
if not obisci(w, u):
return False
return postvisit(u, v)
for w in koreni:
if not obisci(w, None):
break
else:
uspeh = True
for u in self.vozlisca():
if u not in globina:
globina[u] = None
stars[u] = None
return (uspeh, globina, stars)
def premer(self):
"""
Premer grafa.
Časovna zahtevnost: O(n) iskanj v širino.
"""
inf = float('inf')
return max(inf if x is None else x
for u in self.vozlisca()
for x in self.BFS(koreni = [u])[1].values())
class Digraf(Graf):
"""
Abstraktni razred za digrafe.
"""
def izhodniSosedi(self, u):
"""
Seznam izhodnih sosedov obstoječega vozlišča.
"""
return self.sosedi(u)
def utezeniIzhodniSosedi(self, u):
"""
Slovar uteži povezav iz obstoječega vozlišča.
"""
return self.utezeniSosedi(u)
class MatricniGraf(Graf):
"""
Graf, predstavljen z matriko sosednosti.
Prostorska zahtevnost: O(n^2)
"""
def __init__(self):
"""
Inicializacija prazenga grafa.
Časovna zahtevnost: O(1)
"""
self.voz = []
self.indeksi = {}
self.A = []
self.n = 0
def __repr__(self):
"""
Znakovna predstavitev grafa.
Časovna zahtevnost: O(n^2)
"""
if self.n == 0:
return "Prazen graf"
return '\n'.join('%s\t[%s]' %
(self.voz[i], ' '.join('*' if x is None else str(x)
for x in r)) for i, r in enumerate(self.A))
def dodajVozlisce(self, u):
"""
Dodajanje novega vozlišča (če še ne obstaja).
Časovna zahtevnost: O(n)
"""
if u in self.indeksi:
return
self.voz.append(u)
self.indeksi[u] = self.n
self.n += 1
for r in self.A:
r.append(None)
self.A.append([None] * self.n)
def dodajPovezavo(self, u, v, utez = 1):
"""
Dodajanje povezave med vozliščema.
Časovna zahtevnost: O(1) + cena dodajanja novih vozlišč
"""
assert utez is not None, "Utež mora biti določena!"
self.dodajVozlisce(u)
self.dodajVozlisce(v)
i = self.indeksi[u]
j = self.indeksi[v]
self.A[i][j] = utez
self.A[j][i] = utez
def tezaPovezave(self, u, v):
"""
Teža povezave med podanima vozliščema.
"""
return self.A[self.indeksi[u]][self.indeksi[v]]
def brisiPovezavo(self, u, v):
"""
Brisanje povezave med obstoječima vozliščema.
Časovna zahtevnost: O(1)
"""
i = self.indeksi[u]
j = self.indeksi[v]
self.A[i][j] = None
self.A[j][i] = None
def brisiVozlisce(self, u):
"""
Brisanje obstoječega vozlišča.
Časovna zahtevnost: O(n)
"""
i = self.indeksi[u]
del self.indeksi[u]
del self.voz[i]
del self.A[i]
for r in self.A:
del r[i]
for v, j in self.indeksi.items():
if j > i:
self.indeksi[v] -= 1
self.n -= 1
def sosedi(self, u):
"""
Seznam sosedov obstoječega vozlišča.
Časovna zahtevnost: O(n)
"""
return [self.voz[j] for j, x in enumerate(self.A[self.indeksi[u]])
if x is not None]
def utezeniSosedi(self, u):
"""
Slovar uteži povezav na obstoječem vozlišču.
Časovna zahtevnost: O(n)
"""
return {self.voz[j]: x for j, x in enumerate(self.A[self.indeksi[u]])
if x is not None}
def vozlisca(self):
"""
Vrne seznam vozlišč grafa.
Časovna zahtevnost: O(n)
"""
return self.voz[:]
def trikotnik(self):
"""
Določi, ali ima graf trikotnik.
Časovna zahtevnost: O(mn)
"""
try:
return next([self.voz[k] for k in (i, j, h)]
for i in range(self.n)
for j in range(i+1, self.n)
if self.A[i][j] is not None
for h in range(j+1, self.n)
if self.A[j][h] is not None
and self.A[h][i] is not None)
except StopIteration:
return None
class MatricniDigraf(MatricniGraf, Digraf):
"""
Graf, predstavljen z matriko sosednosti.
Prostorska zahtevnost: O(n^2)
"""
def dodajPovezavo(self, u, v, utez = 1):
"""
Dodajanje povezave med obstoječima vozliščema.
Časovna zahtevnost: O(1) + cena dodajanja novih vozlišč
"""
assert utez is not None, "Utež mora biti določena!"
self.dodajVozlisce(u)
self.dodajVozlisce(v)
self.A[self.indeksi[u]][self.indeksi[v]] = utez
def brisiPovezavo(self, u, v):
"""
Brisanje povezave med obstoječima vozliščema.
Časovna zahtevnost: O(1)
"""
self.A[self.indeksi[u]][self.indeksi[v]] = None
def vhodniSosedi(self, u):
"""
Seznam vhodnih sosedov obstoječega vozlišča.
Časovna zahtevnost: O(n)
"""
i = self.indeksi[u]
return [self.voz[j] for j, r in enumerate(A)
if r[i] is not None]
def utezeniVhodniSosedi(self, u):
"""
Slovar uteži povezav v obstoječe vozlišče.
Časovna zahtevnost: O(n)
"""
i = self.indeksi[u]
return {self.voz[j]: r[i] for j, r in enumerate(A)
if r[i] is not None}
def zvezda(self):
"""
Poišče zvezdno vozlišče, če obstaja.
Časovna zahtevnost: O(n^2)
"""
z = None
for i, r in enumerate(self.A):
if all((x is None) == (i == j) for j, x in enumerate(r)):
if z is not None:
return None
z = self.voz[i]
elif not all(x is None for x in r):
return None
return z
class MnozicniGraf(Graf):
"""
Graf, predstavljen z množicami sosedov.
Prostorska zahtevnost: O(m)
"""
def __init__(self):
"""
Inicializacija prazenga grafa.
Časovna zahtevnost: O(1)
"""
self.sos = {}
self.n = 0
def __repr__(self):
"""
Znakovna predstavitev grafa.
Časovna zahtevnost: O(m)
"""
return str(self.sos)
def dodajVozlisce(self, u):
"""
Dodajanje novega vozlišča (če še ne obstaja).
Časovna zahtevnost: O(1)
"""
if u in self.sos:
return
self.n += 1
self.sos[u] = {}
def dodajPovezavo(self, u, v, utez = 1):
"""
Dodajanje povezave med obstoječima vozliščema.
Časovna zahtevnost: O(1)
"""
assert utez is not None, "Utež mora biti določena!"
self.dodajVozlisce(u)
self.dodajVozlisce(v)
self.sos[u][v] = utez
self.sos[v][u] = utez
def brisiPovezavo(self, u, v):
"""
Brisanje povezave med obstoječima vozliščema.
Časovna zahtevnost: O(1)
"""
del self.sos[u][v]
if u != v:
del self.sos[v][u]
def brisiVozlisce(self, u):
"""
Brisanje obstoječega vozlišča.
Časovna zahtevnost: O(d(u))
"""
for v in self.sos[u]:
del self.sos[v][u]
del self.sos[u]
self.n -= 1
def sosedi(self, u):
"""
Seznam sosedov obstoječega vozlišča.
Časovna zahtevnost: O(d(u))
"""
return self.sos[u].keys()
def utezeniSosedi(self, u):
"""
Slovar uteži povezav na obstoječem vozlišču.
Časovna zahtevnost: O(d(u))
"""
return dict(self.sos[u])
def vozlisca(self):
"""
Vrne seznam vozlišč grafa.
Časovna zahtevnost: O(n)
"""
return self.sos.keys()
def trikotnik(self):
"""
Določi, ali ima graf trikotnik.
Časovna zahtevnost: O(mD),
kjer je D največja stopnja vozlišča v grafu.
"""
try:
return next([u, v, w] for u, a in self.sos.items()
for v in a for w in self.sos[v]
if u in self.sos[w])
except StopIteration:
return None
class MnozicniDigraf(MnozicniGraf, Digraf):
"""
Digraf, predstavljen z množicami sosedov.
Prostorska zahtevnost: O(m)
"""
def __init__(self):
"""
Inicializacija prazenga grafa.
Časovna zahtevnost: O(1)
"""
MnozicniGraf.__init__(self)
self.vhodni = {}
def dodajVozlisce(self, u):
"""
Dodajanje novega vozlišča (če še ne obstaja).
Časovna zahtevnost: O(1)
"""
MnozicniGraf.dodajVozlisce(self, u)
if u not in self.vhodni:
self.vhodni[u] = {}
def dodajPovezavo(self, u, v, utez = 1):
"""
Dodajanje povezave med obstoječima vozliščema.
Časovna zahtevnost: O(1)
"""
assert utez is not None, "Utež mora biti določena!"
self.dodajVozlisce(u)
self.dodajVozlisce(v)
self.sos[u][v] = utez
self.vhodni[v][u] = utez
def brisiPovezavo(self, u, v):
"""
Brisanje povezave med obstoječima vozliščema.
Časovna zahtevnost: O(1)
"""
del self.sos[u][v]
del self.vhodni[v][u]
def brisiVozlisce(self, u):
"""
Brisanje obstoječega vozlišča.
Časovna zahtevnost: O(d+(u) + d-(u))
"""
for v in self.sos[u]:
del self.vhodni[v][u]
for v in self.vhodni[u]:
del self.sos[v][u]
del self.sos[u]
del self.vhodni[u]
self.n -= 1
def vhodniSosedi(self, u):
"""
Seznam vhodnih sosedov obstoječega vozlišča.
Časovna zahtevnost: O(d-(u))
"""
return self.vhodni.keys()
def utezeniVhodniSosedi(self, u):
"""
Slovar uteži povezav v obstoječe vozlišče.
Časovna zahtevnost: O(d-(u))
"""
return dict(self.vhodni)
def zvezda(self):
"""
Poišče zvezdno vozlišče, če obstaja.
Časovna zahtevnost: O(n)
"""
z = None
for u, a in self.sos.items():
if len(a) == self.n - 1 and u not in a:
if z is not None:
return None
z = u
elif len(a) != 0:
return None
return z
|
# https://www.codechef.com/problems/MNMX
for T in range(int(input())):
n,a=int(input()),list(map(int,input().split()))
print((n-1)*min(a))
# If order matters
# s=0
# for z in range(n-1):
# if(a[0]>=a[1]):
# s+=a[1]
# a.pop(0)
# else:
# s+=a[0]
# a.pop(1)
# print(s) |
class NoLastBookException (Exception):
pass
class OpenLastBookFileFailed (Exception):
pass
|
"""
Contains custom core exceptions
"""
class UnsupportedNews(Exception):
"""
Custom exception for raising when a news type is unsupported
"""
pass
|
fruta = []
fruta.append('Banana')
fruta.append('Tangerina')
fruta.append('uva')
fruta.append('Laranja')
fruta.append('Melancia')
for f,p in enumerate(fruta):
print(f'Na prateleira {f} temos {p}')
|
rows_count = int(input())
def get_snake_pos(matrix):
for i, row in enumerate(matrix):
if "S" in row:
j = row.index("S")
snake_pos = [i, j]
return snake_pos
def get_food_pos(matrix):
food_positions = []
for i, row in enumerate(matrix):
for j, _ in enumerate(row):
if matrix[i][j] == "*":
food_positions.append([i, j])
return food_positions
def get_lair(matrix):
lair_positions = []
for i, row in enumerate(matrix):
for j, _ in enumerate(row):
if matrix[i][j] == "B":
lair_positions.append([i, j])
return lair_positions
def move_left(snake_pos):
(i, j) = snake_pos
new_snake_pos = [i, j - 1]
return new_snake_pos
def move_right(snake_pos):
(i, j) = snake_pos
new_snake_pos = [i, j + 1]
return new_snake_pos
def move_up(snake_pos):
(i, j) = snake_pos
new_snake_pos = [i - 1, j]
return new_snake_pos
def move_down(snake_pos):
(i, j) = snake_pos
new_snake_pos = [i + 1, j]
return new_snake_pos
def on_food(snake_pos, food):
flag = False
for food_pos in food:
if snake_pos == food_pos:
flag = True
return flag
def on_lair(snake_pos, lairs):
flag = False
for lair_pos in lairs:
if snake_pos == lair_pos:
flag = True
return flag
def leave_trail(matrix, snake_pos):
(i, j) = snake_pos
matrix[i][j] = "."
def out_of_field(snake_pos, rows_count):
flag = False
(i, j) = snake_pos
if not (0 <= i <= rows_count - 1) or not (0 <= j <= rows_count - 1):
flag = True
return flag
field = [input() for _ in range(rows_count)]
# Get initial coords fo pieces
food = get_food_pos(field)
snake_pos = get_snake_pos(field)
lairs = get_lair(field)
food_count = 0
field = [list(row) for row in field]
while True:
command = input()
if command == "left":
leave_trail(field, snake_pos)
snake_pos = move_left(snake_pos)
elif command == "right":
leave_trail(field, snake_pos)
snake_pos = move_right(snake_pos)
elif command == "up":
leave_trail(field, snake_pos)
snake_pos = move_up(snake_pos)
elif command == "down":
leave_trail(field, snake_pos)
snake_pos = move_down(snake_pos)
if out_of_field(snake_pos, rows_count):
print("Game over!")
break
elif on_food(snake_pos, food):
food_count += 1
food.remove(snake_pos)
elif on_lair(snake_pos, lairs):
lairs.remove(snake_pos)
leave_trail(field, snake_pos)
snake_pos = lairs[0]
lairs = []
if food_count >= 10:
print("You won! You fed the snake.")
(i, j) = snake_pos
field[i][j] = "S"
break
print(f"Food eaten: {food_count}")
[print(''.join(row)) for row in field] |
#!python3
class Map:
"""
Map
A Map class.
"""
def __init__(self, map_list):
"""
Map(map_list ::= 2D list of MapObjects)
Example:
a = MapObject("Path", " ", True)
b = MapObject("Rock", "X", False)
map_list = [[a, a, a, a, a]
[a, b, b, a, b]]
"""
if isinstance(map_list, list):
for x in map_list:
if not isinstance(x, list):
raise TypeError()
else:
for o in x:
if not isinstance(o, MapObject):
raise TypeError()
else:
raise TypeError()
self.map_list = map_list
def __getitem__(self, coords):
x = coords[0]
y = coords[1]
return self.map_list[y][x]
def check_collision(self, coord):
left_bound = -1
top_bound = -1
right_bound = len(self.map_list[0])
bottom_bound = len(self.map_list)
if coord[0] <= left_bound or coord[0] >= right_bound:
return True
if coord[1] <= top_bound or coord[1] >= bottom_bound:
return True
obj_at_point = self.map_list[coord[1]][coord[0]]
if obj_at_point.is_passable is False:
return True
return False
class MapObject:
"""
MapObject
Object type for Map legends
"""
def __init__(self, name, symbol, is_passable=False):
if isinstance(symbol, str) and len(symbol) > 1:
raise ValueError()
if not isinstance(symbol, str) or not isinstance(name, str):
raise TypeError()
self.name = name
self.symbol = symbol
self.is_passable = is_passable
|
#!/usr/bin/env python
# TODO: import the random module
# This function parses both the player
# and monster files
def parse_file(filename):
members = {}
file = open(filename,"r")
lines = file.readlines()
for line in lines:
name, diff = line.split(";")
members[name] = {"str": int(diff)}
return members
# MONSTER FIGHT!
def fight_monster(diff, roll):
if diff > roll:
return -1
return 1
# Performs rolls for groups
def do_roll(entities):
roll = 0
for entity in entities:
e_name = entity
e_str = entities[entity]["str"]
e_roll = roll_dice(e_str)
roll += e_roll
print(f"{entity} rolls a {e_roll}!")
return roll
# Roll an individual die
def roll_dice(sides):
return random.randint(1, sides)
# Initialze points
points = 0
# TODO: Load files to parse for player and
# monster data
# Create loop to move from challenge to challenge
for monster in monsters:
# TODO: "Appear" the monster and do the monster's
# die roll
# TODO: Get players' team roll
print(f"The group rolled a total of: {group_roll}!")
# TODO: Get the result of this single fight
if result > 0:
print(f"The players beat the {m_name}!\n")
else:
print(f"The players failed to beat the {m_name}!\n")
# TODO: if statement to report the final outcome of all
# battles! |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2020/2/12 16:25
# @Author : Baimohan/PH
# @Site : https://github.com/BaiMoHan
# @File : setdefault.py
# @Software: PyCharm
cars = {'BMW': 8.5, 'BENS': 8.3, 'AUDI': 7.9}
print(cars.setdefault('PORSCHE', 9.2))
print(cars)
print(cars.setdefault('BMW', 4.5))
print(cars) |
NUMBER_OF_ROWS = 8
NUMBER_OF_COLUMNS = 8
DIMENSION_OF_EACH_SQUARE = 64
BOARD_COLOR_1 = "#DDB88C"
BOARD_COLOR_2 = "#A66D4F"
X_AXIS_LABELS = ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H')
Y_AXIS_LABELS = (1, 2, 3, 4, 5, 6, 7, 8)
SHORT_NAME = {
'R':'Rook', 'N':'Knight', 'B':'Bishop',
'Q':'Queen', 'K':'King', 'P':'Pawn'
}
# remember capital letters - White pieces, Small letters - Black pieces
START_PIECES_POSITION = {
"A8": "r", "B8": "n", "C8": "b", "D8": "q", "E8": "k", "F8": "b", "G8": "n", "H8": "r",
"A7": "p", "B7": "p", "C7": "p", "D7": "p", "E7": "p", "F7": "p", "G7": "p", "H7": "p",
"A2": "P", "B2": "P", "C2": "P", "D2": "P", "E2": "P", "F2": "P", "G2": "P", "H2": "P",
"A1": "R", "B1": "N", "C1": "B", "D1": "Q", "E1": "K", "F1": "B", "G1": "N", "H1": "R"
}
ORTHOGONAL_POSITIONS = ((-1,0),(0,1),(1,0),(0, -1))
DIAGONAL_POSITIONS = ((-1,-1),(-1,1),(1,-1),(1,1))
KNIGHT_POSITIONS = ((-2,-1),(-2,1),(-1,-2),(-1,2),(1,-2),(1,2),(2,-1),(2,1))
|
def power(x, y, p) :
res = 1 # Initialize result
# Update x if it is more
# than or equal to p
x = x % p
if (x == 0) :
return 0
while (y > 0) :
# If y is odd, multiply
# x with result
if ((y & 1) == 1) :
res = (res * x) % p
# y must be even now
y = y >> 1 # y = y/2
x = (x * x) % p
return res
mod = int(1e9)+7
for i in range(int(input())):
n,a = [int(j) for j in input().split()]
c = a%mod
p = (a**2)%mod
for j in range(n-1):
q = power(p,(j+2)**2-(j+1)**2,mod)
c = (c+q)%mod
p = (q*p)%mod
print(c)
|
"""
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
For example, given n = 3, a solution set is:
[
"((()))",
"(()())",
"(())()",
"()(())",
"()()()"
]
"""
# back tracking
# Runtime: 40 ms, faster than 26.72% of Python3 online submissions for Generate Parentheses.
# Memory Usage: 12.9 MB, less than 100.00% of Python3 online submissions for Generate Parentheses.
class Solution:
def generateParenthesis(self, n: int) -> List[str]:
target = {"left":n, "right":n}
curr = {"left":0, "right":0}
res = set([])
self.dfs(res, [], target, curr)
return res
def dfs(self, res, tmp, target, current):
# print("target:", target, "current:", current)
# print("tmp:", tmp)
if target["left"] < 0 or target["right"] < 0:
return
if target["left"] == 0 and target["right"] == 0:
res.add("".join(tmp))
return
target["left"] -= 1
current["left"] += 1
tmp.append("(")
self.dfs(res, tmp, target, current)
target["left"] += 1
current["left"] -= 1
tmp.pop()
if current["left"] < current["right"] + 1:
return
target["right"] -= 1
current["right"] += 1
tmp.append(")")
self.dfs(res, tmp, target, current)
target["right"] += 1
current["right"] -= 1
tmp.pop()
|
nota1 = float(input('Digite a nota da 1ª avaliação= '))
nota2 = float(input('Digite a nota da 2ª avaliaçao= '))
media = (nota1+nota2)/2
print('A sua média é {:.2f}'.format(media)) |
class Solution:
def isPalindrome(self, s: str) -> bool:
l, r = 0, len(s) - 1
while(l < r):
while(l < r and s[l].isalnum() == False):
l+=1
while(l < r and s[r].isalnum() == False):
r-=1
if(s[l].lower() != s[r].lower()):
return False
l += 1
r -= 1
return True
# Time Complexity - O(n)
# Space Complexity - O(1)
|
class Solution:
def solve(self, nums):
if len(nums) <= 2: return 0
l_maxes = []
l_max = -inf
for num in nums:
l_max = max(l_max,num)
l_maxes.append(l_max)
r_maxes = []
r_max = -inf
for num in nums[::-1]:
r_max = max(r_max,num)
r_maxes.append(r_max)
r_maxes.reverse()
return sum(max(0,min(l_maxes[i-1],r_maxes[i+1])-nums[i]) for i in range(1,len(nums)-1))
|
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def swapPairs(self, head: ListNode) -> ListNode:
return self.swap(head)
def swap(self, head: ListNode) -> ListNode:
if head == None:
return None
if head.next == None:
return head
temp = head
head = head.next
temp.next = self.swap(head.next)
head.next = temp
return head |
#!/usr/bin/env python
# Created by Bruce yuan on 18-2-7.
class Solution:
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
if not s:
return 0
tmp = {}
max_ = 0
start = 0
for i in range(len(s)):
# 如果开始是大于我们要的那个,其实没有意义了。不需要重新弄开始
if s[i] in tmp and start <= tmp.get(s[i]):
start = tmp.get(s[i]) + 1
else:
max_ = max(max_, i - start + 1)
tmp[s[i]] = i
return max_
def main():
s = Solution()
r = s.lengthOfLongestSubstring("pwwkew")
print(r)
if __name__ == '__main__':
main()
|
def FermatPrimalityTest(number):
''' if number != 1 '''
if (number > 1):
''' repeat the test few times '''
for time in range(3):
''' Draw a RANDOM number in range of number ( Z_number ) '''
randomNumber = random.randint(2, number)-1
''' Test if a^(n-1) = 1 mod n '''
if ( pow(randomNumber, number-1, number) != 1 ):
return False
return True
else:
''' case number == 1 '''
return False
|
# Using Array slicing in python to reverse arrays
# defining reverse function
def reversedArray(array):
print(array[::-1])
# Creating a Template Array
array = [1, 2, 3, 4, 5]
print("Current Array Order:")
print(array)
print("Reversed Array Order:")
reversedArray(array)
|
# -*- coding: utf-8 -*-
# author: ysoftman
# python version : 2.x 3.x
# desc : set 테스트
data = ['aaa', 'bbb', 'aaa', 'ccc']
print(list(data))
# set 은 중복 데이터를 제거한다.
set_data = set(data)
print(set_data)
# element 추가
set_data.add("lemon")
set_data.add("banana")
set_data.add("lemon") # 중복 추가 안된다.
print(set_data)
# element 제거
set_data.remove('banana')
print(set_data)
# set 을 추가
set_data.update(set(['aaa', 'zzz']))
print(set_data)
# y, o 를 원소하는 set 을 추가
set_data.update('yo')
print(set_data)
# subset 여부 확인
if (set(['aaa', 'ccc']).issubset(set_data)):
print('issubset == true')
else:
print('issubset == false')
print(set_data)
# 임의의 element 제거
set_data.pop()
set_data.pop()
print(set_data)
# element 모두 제거
set_data.clear()
print(set_data)
seta = set([1, 3, 5])
setb = set([1, 2, 4])
print(seta)
print(setb)
# 합집합
setc = seta | setb
print(setc)
setc = seta.union(setb)
print(setc)
# 차집합
setc = seta - setb
print(setc)
setc = seta.difference(setb)
print(setc)
# 교집합
setc = seta & setb
print(setc)
setc = seta.intersection(setb)
print(setc)
|
#Get a left position and a right
# iterative uses a loop
def is_palindrome(string):
left_index = 0
right_index = len(string) - 1
#repeat, or loop
while left_index < right_index:
#check if dismatch
if string[left_index] != string[right_index]:
return False
#move to the next characters to check
# with the left we wanna move forward, so we add 1
left_index += 1
# with right we need to substract
right_index -= 1
return True
#recursive
def is_palindrome_recursive(string, left_index, right_index):
print(left_index)
print(right_index)
#base case, it's when we stop
if left_index == right_index:
return True
if string[left_index] != string[right_index]:
return False
#recursive case, when we call the function within itself
if left_index < right_index:
return is_palindrome_recursive(string, left_index + 1, right_index - 1)
return True
print(is_palindrome_recursive("talo", 0, len("deed")-1))
# print(is_palindrome_recursive("tacocat"))
# print(is_palindrome_recursive("tasdfklajdf"))
|
#!/usr/bin/env python3
def char_frequency(filename):
"""
Counts the frequency of each character in the given file.
"""
# First try to open the file
try:
f = open(filename)
# code in the except block is only executed if one of the instructions in the try block raise an error of the matching type
except OSError:
return None
# Now process the file
characters = {}
for line in f:
for char in line:
characters[char] = characters.get(char, 0) + 1
f.close()
return characters |
def distributeCandies(self, candies: int, num_people: int) -> List[int]:
r = [0 for _ in range(num_people)]
i = 0
c = 1
while candies != 0:
if i > num_people - 1:
i = 0
if c > candies:
r[i] += candies
break
r[i] += c
candies -= c
i += 1
c += 1
return r
|
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
FIRST_LETTER = LETTERS[0]
def get_sequence(column, count, step=1):
column = validate(column)
count = max(abs(count), 1)
sequence = []
if column:
sequence.append(column)
count = count - 1
for i in range(count):
previous = sequence[-1] if sequence else column
sequence.append(next(previous, step))
return sequence
def next(column, step=1):
column = validate(column)
if not column:
return FIRST_LETTER
step = max(abs(step), 1)
base = column[0:-1] if len(column) > 1 else ''
next_char = column[-1] if len(column) > 1 else column
for i in range(step):
next_char = get_next_char(next_char)
if next_char == FIRST_LETTER:
base = rollover(base)
return base + next_char
def rollover(column):
if not column:
return FIRST_LETTER
base = column[0:-1]
next_char = get_next_char(column[-1])
if next_char == FIRST_LETTER:
return rollover(base) + next_char
return base + next_char
def get_next_char(char):
index = LETTERS.index(char) + 1
return FIRST_LETTER if index >= len(LETTERS) else LETTERS[index]
def validate(column):
if not column:
return None
column = column.strip().upper()
invalid_chars = [c for c in column if c not in LETTERS]
return None if invalid_chars else column |
def evalRec(env, rec):
"""hearing_loss_genes"""
return (len(set(rec.Symbol) &
{
'ABCD1',
'ABHD12',
'ABHD5',
'ACOT13',
'ACTB',
'ACTG1',
'ADCY1',
'ADGRV1',
'ADK',
'AIFM1',
'AK2',
'ALMS1',
'AMMECR1',
'ANKH',
'ARSB',
'ATP13A4',
'ATP2B2',
'ATP2C2',
'ATP6V1B1',
'ATP6V1B2',
'BCAP31',
'BCS1L',
'BDNF',
'BDP1',
'BSND',
'BTD',
'CABP2',
'CACNA1C',
'CACNA1D',
'CATSPER2',
'CCDC50',
'CD151',
'CD164',
'CDC14A',
'CDC42',
'CDH23',
'CDKN1C',
'CEACAM16',
'CEP78',
'CEP152',
'CFTR',
'CHD7',
'CHSY1',
'CIB2',
'CISD2',
'CLCNKA',
'CLCNKB',
'CLDN14',
'CLIC5',
'CLPP',
'CLRN1',
'CMIP',
'CNTNAP2',
'COCH',
'COL11A1',
'COL11A2',
'COL2A1',
'COL4A3',
'COL4A4',
'COL4A5',
'COL4A6',
'COL9A1',
'COL9A2',
'COL9A3',
'CRYL1',
'CRYM',
'CYP19A1',
'DCAF17',
'DCDC2',
'DCDC2',
'DIABLO',
'DIAPH1',
'DIAPH3',
'DLX5',
'DMXL2',
'DNMT1',
'DOCK4',
'DRD2',
'DSPP',
'DYX1C1',
'EDN3',
'EDNRB',
'ELMOD3',
'EPS8',
'EPS8L2',
'ERCC2',
'ERCC3',
'ESPN',
'ESRP1',
'ESRRB',
'EYA1',
'EYA4',
'FAM189A2',
'FDXR',
'FGF3',
'FGFR1',
'FGFR2',
'FGFR3',
'FKBP14',
'FOXC1',
'FOXF2',
'FOXI1',
'FOXP1',
'FOXP2',
'FOXRED1',
'FRMPD4',
'GAA',
'GATA3',
'GCFC2',
'GIPC3',
'GJA1',
'GJB1',
'GJB2',
'GJB3',
'GJB6',
'GNPTAB',
'GNPTG',
'GPLD1',
'GPSM2',
'GRAP',
'GREB1L',
'GRHL2',
'GRXCR1',
'GRXCR2',
'GSDME',
'GSTP1',
'GTPBP3',
'HAAO',
'HARS',
'HARS2',
'HGF',
'HOMER1',
'HOMER2',
'HOXA2',
'HOXB1',
'HSD17B4',
'HTRA2',
'IARS2',
'IDS',
'IGF1',
'ILDR1',
'JAG1',
'KARS',
'KCNE1',
'KCNJ10',
'KCNQ1',
'KCNQ4',
'KIAA0319',
'KIT',
'KITLG',
'LARS2',
'LHFPL5',
'LHX3',
'LMX1A',
'LOXHD1',
'LOXL3',
'LRP2',
'LRTOMT',
'MANBA',
'MARVELD2',
'MASP1',
'MCM2',
'MET',
'MFN2',
'MIR182',
'MIR183',
'MIR96',
'MITF',
'MPZL2',
'MRPL19',
'MSRB3',
'MTAP',
'MTO1',
'MTRNR1',
'MTTK',
'MTTL1',
'MTTS1',
'MYH14',
'MYH9',
'MYO15A',
'MYO1A',
'MYO1C',
'MYO1F',
'MYO3A',
'MYO6',
'MYO7A',
'NAGPA',
'NARS2',
'NDP',
'NDUFA1',
'NDUFA11',
'NDUFAF1',
'NDUFAF2',
'NDUFAF3',
'NDUFAF4',
'NDUFAF5',
'NDUFB11',
'NDUFB3',
'NDUFB9',
'NDUFS1',
'NDUFS2',
'NDUFS3',
'NDUFS4',
'NDUFS6',
'NDUFV1',
'NDUFV2',
'NF2',
'NLRP3',
'NOTCH2',
'NRSN1',
'NUBPL',
'OPA1',
'ORC1',
'OSBPL2',
'OTOA',
'OTOF',
'OTOG',
'OTOGL',
'P2RX2',
'PAX2',
'PAX3',
'PCDH15',
'PDE1C',
'PDZD7',
'PEX1',
'PEX6',
'PITX2',
'PJVK',
'PMP22',
'PNPT1',
'POLG',
'POLR1C',
'POLR1D',
'POU3F4',
'POU4F3',
'PRPS1',
'PTPRQ',
'RDX',
'RIPOR2',
'RMND1',
'ROBO1',
'ROR1',
'RPS6KA3',
'S1PR2',
'SALL1',
'SALL4',
'SEMA3E',
'SERAC1',
'SERPINB6',
'SETBP1',
'SGPL1',
'SF3B4',
'SIX1',
'SIX5',
'SLC12A1',
'SLC17A8',
'SLC19A2',
'SLC22A4',
'SLC26A4',
'SLC26A5',
'SLC29A3',
'SLC33A1',
'SLC4A11',
'SLC52A2',
'SLC52A3',
'SLC9A1',
'SLITRK6',
'SMAD4',
'SMPX',
'SNAI2',
'SOX10',
'SOX2',
'SPATC1L',
'SPINK5',
'SRPX2',
'STRC',
'STXBP2',
'STXBP3',
'SUCLA2',
'SUCLG1',
'SYNE4',
'TACO1',
'TBC1D24',
'TBL1X',
'TBX1',
'TCF21',
'TCOF1',
'TDP2',
'TECTA',
'TECTB',
'TFAP2A',
'TFB1M',
'TIMM8A',
'TIMMDC1',
'TJP2',
'TMC1',
'TMC2',
'TMEM126B',
'TMEM132E',
'TMIE',
'TMPRSS3',
'TMPRSS5',
'TNC',
'TPRN',
'TRIOBP',
'TRMU',
'TSPEAR',
'TUBB4B',
'TWNK',
'TYR',
'USH1C',
'USH1G',
'USH2A',
'VCAN',
'WBP2',
'WFS1',
'WHRN',
}
) > 0) |
# Copyright 2017 The Forseti Security Authors. All rights reserved.
#
# 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.
"""Test data for firewall rules scanners."""
FAKE_FIREWALL_RULE_FOR_TEST_PROJECT = {
'name': 'policy1',
'full_name': ('organization/org/folder/folder1/'
'project/project0/firewall/policy1/'),
'network': 'network1',
'direction': 'ingress',
'allowed': [{'IPProtocol': 'tcp', 'ports': ['1', '3389']}],
'sourceRanges': ['0.0.0.0/0'],
'targetTags': ['linux'],
}
FAKE_FIREWALL_RULE_FOR_PROJECT1 = {
'name': 'policy1',
'full_name':
('organization/org/folder/test_instances/'
'project/project1/firewall/policy1/'),
'network': 'network1',
'direction': 'ingress',
'allowed': [{'IPProtocol': 'tcp', 'ports': ['22']}],
'sourceRanges': ['11.0.0.1'],
'targetTags': ['test'],
} |
# ToDo: Make it configurable
DEFAULT_PARAMS = {
"os_api": "23",
"device_type": "Pixel",
"ssmix": "a",
"manifest_version_code": "2018111632",
"dpi": 420,
"app_name": "musical_ly",
"version_name": "9.1.0",
"is_my_cn": 0,
"ac": "wifi",
"update_version_code": "2018111632",
"channel": "googleplay",
"device_platform": "android",
"build_number": "9.9.0",
"version_code": 910,
"timezone_name": "America/New_York",
"timezone_offset": 36000,
"resolution": "1080*1920",
"os_version": "7.1.2",
"device_brand": "Google",
"mcc_mnc": "23001",
"is_my_cn": 0,
"fp": "",
"app_language": "en",
"language": "en",
"region": "US",
"sys_region": "US",
"account_region": "US",
"carrier_region": "US",
"carrier_region_v2": "505",
"aid": "1233",
"pass-region": 1,
"pass-route": 1,
"app_type": "normal",
# "iid": "6742828344465966597",
# "device_id": "6746627788566021893",
# ToDo: Make it dynamic
"iid": "6749111388298184454",
"device_id": "6662384847253865990",
}
DEFAULT_HEADERS = {
"Host": "api2.musical.ly",
"X-SS-TC": "0",
"User-Agent": f"com.zhiliaoapp.musically/{DEFAULT_PARAMS['manifest_version_code']}"
+ f" (Linux; U; Android {DEFAULT_PARAMS['os_version']};"
+ f" {DEFAULT_PARAMS['language']}_{DEFAULT_PARAMS['region']};"
+ f" {DEFAULT_PARAMS['device_type']};"
+ f" Build/NHG47Q; Cronet/58.0.2991.0)",
"Accept-Encoding": "gzip",
"Accept": "*/*",
"Connection": "keep-alive",
"X-Tt-Token": "",
"sdk-version": "1",
"Cookie": "null = 1;",
}
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
定制类
__getattr__
"""
class Student(object):
def __init__(self):
self._name = 'Walker'
def __getattr__(self, item):
if item == 'score':
return 99
raise AttributeError('Student object has no attribute %s' % item)
s = Student()
print(s.score) |
def Ispalindrome(usrname):
return usrname==usrname[::-1]
def main():
usrname=input("Enter the String :")
#temp=usrname[::-1]
if Ispalindrome(usrname):
print("String %s is palindrome"%(usrname))
else:
print("String %s is not palindrome"%(usrname))
if __name__ == '__main__':
main()
|
# Advent of Code 2015
#
# From https://adventofcode.com/2015/day/3
#
inputs = [data.strip() for data in open('../inputs/Advent2015_03.txt', 'r')][0]
move = {'^': 0 + 1j, ">": 1, "v": 0 - 1j, "<": -1}
def visit(inputs):
position = 0 + 0j
visited = {position}
for x in inputs:
position = position + move[x]
visited.add(position)
return visited
print(f"AoC 2015 Day 3, Part 1 answer is {len(visit(inputs))}")
print(f"AoC 2015 Day 3, Part 2 answer is {len(visit(inputs[0::2]) | visit(inputs[1::2]))}")
|
def bisect(f, a, b, tol=10e-5):
"""
Implements the bisection root finding algorithm, assuming that f is a
real-valued function on [a, b] satisfying f(a) < 0 < f(b).
"""
lower, upper = a, b
while upper - lower > tol:
middle = 0.5 * (upper + lower)
# === if root is between lower and middle === #
if f(middle) > 0:
lower, upper = lower, middle
# === if root is between middle and upper === #
else:
lower, upper = middle, upper
return 0.5 * (upper + lower)
|
# -*- coding: utf-8 -*-
"""Products are standard objects that Loaders add to the data store."""
# For now Products are simple dictionaries.
class Product(dict):
"""Standardised product data."""
pass |
age1 = 12
age2 = 18
print("age1 + age2")
print(age1 + age2)
print("age1 - age2")
print(age1 - age2)
print("age1 * age2")
print(age1 * age2)
print("age1 / age2")
print(age1 / age2)
print("age1 % age2")
print(age1 % age2)
sent1 = "Today is a beautiful day"
firstName = "Marlon"
lastName = "Monzon"
print(firstName + " " + lastName)
print ("HI" * 10)
sentence = "Marlon was playing basketball.";
# Splicing
print(sentence[0:6])
print(sentence[:-12]) |
a = input()
s = [int(x) for x in input().split()]
ans = [str(x) for x in sorted(s)]
print(' '.join(ans))
|
"""
백준 21591번 : Laptop Sticker
"""
a, b, c, d = map(int, input().split())
if a-2 >= c and b-2 >= d:
print(1)
else:
print(0) |
# Equations (c) Baltasar 2019 MIT License <[email protected]>
class TDS:
def __init__(self):
self._vbles = {}
def __iadd__(self, other):
self._vbles[other[0]] = other[1]
return self
def __getitem__(self, item):
return self._vbles[item]
def __setitem__(self, item, value):
self._vbles[item] = value
def get_vble_names(self):
return list(self._vbles.keys())
def __len__(self):
return len(self._vbles)
def get(self, vble):
return self._vbles[vble]
def __str__(self):
toret = ""
delim = ""
for key in self._vbles.keys():
toret += delim
toret += str(key) + " = " + str(self._vbles[key])
delim = ", "
return toret
|
x = int(input("enter percentage\n"))
if(x>=65):
print("Excellent")
elif(x>=55 and x<65):
print("Good")
elif(x>=40 and x<55):
print("Fair")
else:
print("Failed")
|
WORK_PATH = "/tmp/posts"
PORT = 8000
AUTHOR = "@asadiyan"
TITLE = "fsBlog"
DESCRIPTION = "<h3></h3>"
|
"""
written and developed by Daniel Temkin
please refer to LICENSE for ownership and reference information
"""
|
def TwosComplementOf(n):
if isinstance(n,str) == True:
binintnum = int(n)
binmun = int("{0:08b}".format(binintnum))
strnum = str(binmun)
size = len(strnum)
idx = size -1
while idx >= 0:
if strnum[idx] == '1':
break
idx = idx - 1
if idx == -1:
return '1'+strnum
position = idx-1
while position >= 0:
if strnum[position] == '1':
strnum = list(strnum)
strnum[position] ='0'
strnum = ''.join(strnum)
else:
strnum = list(strnum)
strnum[position] = '1'
strnum = ''.join(strnum)
position = position-1
return strnum
else:
binmun = int("{0:08b}".format(n))
strnum = str(binmun)
size = len(strnum)
idx = size - 1
while idx >= 0:
if strnum[idx] == '1':
break
idx = idx - 1
if idx == -1:
return '1' + strnum
position = idx - 1
while position >= 0:
if strnum[position] == '1':
strnum = list(strnum)
strnum[position] = '0'
strnum = ''.join(strnum)
else:
strnum = list(strnum)
strnum[position] = '1'
strnum = ''.join(strnum)
position = position - 1
return strnum
|
# pylint: skip-file
# pylint: disable=too-many-instance-attributes
class GcloudComputeZones(GcloudCLI):
''' Class to wrap the gcloud compute zones command'''
# pylint allows 5
# pylint: disable=too-many-arguments
def __init__(self, region=None, verbose=False):
''' Constructor for gcloud resource '''
super(GcloudComputeZones, self).__init__()
self._region = region
self.verbose = verbose
@property
def region(self):
'''property for region'''
return self._region
def list_zones(self):
'''return a list of zones'''
results = self._list_zones()
if results['returncode'] == 0 and self.region:
zones = []
for zone in results['results']:
if self.region == zone['region']:
zones.append(zone)
results['results'] = zones
return results
|
class Stack:
def __init__(self, *objects):
self.stack = []
if len(objects) > 0:
for obj in objects:
self.stack.append(obj)
def push(self, *objects):
for obj in objects:
self.stack.append(obj)
def pop(self, obj):
if self.stack != []:
self.stack.pop()
def top_item(self):
if self.stack != []:
return self.stack[len(self.stack) - 1]
def isempty(self):
return self.stack == 0
def dimension(self):
return len(self.stack)
def clear(self):
self.stack.clear()
def __str__(self):
return self.stack.__str__()
def __repr__(self):
return self.stack.__repr__()
def __eq__(self, Stack_instance):
return self.stack == Stack_instance.stack
# usage
if __name__ == '__main__':
q = Stack()
q2 = Stack(1, 2, 3, 4, 5, 6, 7, 8)
print(q)
print(q2)
q3 = Stack(1, 2, 3, 4, *[1, 2, 3, 4, 5], Stack(1, 2, 3, 4))
print(q3)
print(q == q3) |
class CalcError(Exception):
def __init__(self, error):
self.message = error
super().__init__(self.message)
|
#Binary to Decimal conversion
def binDec(n):
num = int(n);
value = 0;
base = 1;
flag = num;
while(flag):
l = flag%10;
flag = int(flag/10);
print(flag);
value = value+l*base;
base = base*2;
return value
num = input();
a = binDec(num);
print(a)
|
{
'targets': [
{
'target_name': 'lb_shell_package',
'type': 'none',
'default_project': 1,
'dependencies': [
'lb_shell_contents',
],
'conditions': [
['target_arch=="android"', {
'dependencies': [
'lb_shell_android.gyp:lb_shell_apk',
],
}, {
'dependencies': [
'lb_shell_exe.gyp:lb_shell',
],
}],
['target_arch not in ["linux", "android", "wiiu"]', {
'dependencies': [
'../platforms/<(target_arch)_deploy.gyp:lb_shell_deploy',
],
}],
],
},
{
'target_name': 'lb_layout_tests_package',
'type': 'none',
'dependencies': [
'lb_shell_exe.gyp:lb_layout_tests',
'lb_shell_contents',
],
},
{
'target_name': 'lb_unit_tests_package',
'type': 'none',
'dependencies': [
'lb_shell_exe.gyp:unit_tests_base',
'lb_shell_exe.gyp:unit_tests_crypto',
'lb_shell_exe.gyp:unit_tests_media',
'lb_shell_exe.gyp:unit_tests_net',
'lb_shell_exe.gyp:unit_tests_sql',
'lb_shell_exe.gyp:lb_unit_tests',
'lb_shell_exe.gyp:unit_tests_image_decoder',
'lb_shell_exe.gyp:unit_tests_xml_parser',
'lb_shell_contents',
'<@(platform_contents_unit_tests)',
],
'conditions': [
['target_arch not in ["linux", "android", "wiiu"]', {
'dependencies': [
'../platforms/<(target_arch)_deploy.gyp:unit_tests_base_deploy',
'../platforms/<(target_arch)_deploy.gyp:unit_tests_media_deploy',
'../platforms/<(target_arch)_deploy.gyp:unit_tests_net_deploy',
'../platforms/<(target_arch)_deploy.gyp:unit_tests_sql_deploy',
'../platforms/<(target_arch)_deploy.gyp:lb_unit_tests_deploy',
],
}],
],
},
{
'target_name': 'lb_shell_contents',
'type': 'none',
'dependencies': [
'<@(platform_contents_lbshell)',
],
},
],
'conditions': [
['target_arch == "android"', {
'targets': [
{
'target_name': 'lb_unit_tests_package_apks',
'type': 'none',
'dependencies': [
'lb_shell_exe.gyp:unit_tests_base_apk',
'lb_shell_exe.gyp:unit_tests_crypto_apk',
'lb_shell_exe.gyp:unit_tests_media_apk',
'lb_shell_exe.gyp:unit_tests_net_apk',
'lb_shell_exe.gyp:unit_tests_sql_apk',
'lb_shell_exe.gyp:lb_unit_tests_apk',
'lb_shell_exe.gyp:unit_tests_image_decoder_apk',
'lb_shell_exe.gyp:unit_tests_xml_parser_apk',
'lb_shell_contents',
'<@(platform_contents_unit_tests)',
],
},
],
}],
],
}
|
# PRINT OUT A WELCOME MESSAGE.
print('Welcome to Food Funhouse!')
# LOOP UNTIL THE USER CHOOSES TO EXIT.
order_total_in_dollars_and_cents = 0.0
while True:
# PRINT OUT THE MENU OPTIONS.
print('1. Cheeseburger - $5.50')
print('2. Pizza - $5.00')
print('3. Taco - $3.00')
print('4. Cookie - $1.99')
print('5. Milk - $0.99')
print('6. Pay for Order/Exit')
print('7. Cancel Order/Exit')
# LET THE USER SELECT A MENU OPTION.
selected_menu_option = int(input('Select an item to order: '))
# PRINT OUT THE OPTION THE USER SELECTED.
if 1 == selected_menu_option:
order_total_in_dollars_and_cents += 5.50
print('You ordered a cheeseburger. Order total: $' + str(order_total_in_dollars_and_cents))
elif 2 == selected_menu_option:
order_total_in_dollars_and_cents += 5.00
print('You ordered a pizza. Order total: $' + str(order_total_in_dollars_and_cents))
elif 3 == selected_menu_option:
order_total_in_dollars_and_cents += 3.00
print('You ordered a taco. Order total: $' + str(order_total_in_dollars_and_cents))
elif 4 == selected_menu_option:
order_total_in_dollars_and_cents += 1.99
print('You ordered a cookie. Order total: $' + str(order_total_in_dollars_and_cents))
elif 5 == selected_menu_option:
order_total_in_dollars_and_cents += 0.99
print('You ordered milk. Order total: $' + str(order_total_in_dollars_and_cents))
elif 6 == selected_menu_option:
# PRINT THE ORDER TOTAL.
print('Your order total is $' + str(order_total_in_dollars_and_cents))
# WAIT UNTIL THE USER INPUTS ENOUGH MONEY TO PAY FOR THE ORDER.
payment_amount_in_dollars_and_cents = 0.0
while payment_amount_in_dollars_and_cents < order_total_in_dollars_and_cents:
# GET THE PAYMENT AMOUNT FROM THE USER.
payment_amount_in_dollars_and_cents = float(input('Enter payment amount: '))
# INFORM THE USER IF THE PAYMENT AMOUNT ISN'T ENOUGH.
payment_amount_enough = payment_amount_in_dollars_and_cents >= order_total_in_dollars_and_cents
if not payment_amount_enough:
print('Not enough to pay for order.')
# CALCULATE THE CHANGE FOR THE ORDER.
change_in_dollars_and_cents = payment_amount_in_dollars_and_cents - order_total_in_dollars_and_cents
# INFORM THE USER OF THEIR CHANGE.
print('Thanks for paying!')
print('Your change is $' + str(change_in_dollars_and_cents))
break
elif 7 == selected_menu_option:
print('Exiting...')
break
else:
print('Invalid selection. Please try again.')
|
# Simple Calculator
def calculate(x,y,operator):
if operator == "*":
result = float(x * y)
print(f"The answer is {result} ")
elif operator == "/":
result = float(x / y)
print(f"The answer is {result} ")
elif operator == "+":
result = float(x + y)
print(f"The answer is {result} ")
elif operator == "-":
result = float(x - y)
print(f"The answer is {result} ")
else:
print("Try Again")
x = int(input("Enter First Number: \n"))
y = int(input("Enter Second Number: \n"))
operator = (input("What do we do with these? \n"))
calculate(x,y,operator)
|
# 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.
"""
List resources from the Key Manager service.
"""
def create_secret(conn):
print("Create a secret:")
conn.key_manager.create_secret(name="My public key",
secret_type="public",
expiration="2020-02-28T23:59:59",
payload="ssh rsa...",
payload_content_type="text/plain")
|
# Outputs string representation of a unicode hex representation
def uc(hex):
return chr(int(hex))
'''CONSONANTS. Format: Place_Manner_Voicing;
Place:
L=labial, LD=labiodental, D=dental, A=alveolar, R=retroflex,
PA=postalveolar, P=palatal, V=velar, U=uvular, PH=pharyngeal, G=glottal;
Manner:
P=plosive, N=nasal, TR=trill, TF=tap/flap, F=fricative,
LF=lateral fricative, A=approximant, LA=lateral approximant;
Voicing:
VL=voiceless, V=voiced
'''
R_P_VL=uc(0x0288)
R_P_V=uc(0x0256)
P_P_V=uc(0x025F)
G_P_VL=uc(0x0294)
LD_N_V=uc(0x0271)
R_N_V=uc(0x0273)
P_N_V=uc(0x0272)
V_N_V=uc(0x014B)
A_TF_V=uc(0x027E)
R_TF_V=uc(0x027D)
L_F_VL=uc(0x0278)
L_F_V=uc(0x03B2)
D_F_VL=uc(0x03B8)
D_F_V=uc(0x00F0)
R_F_VL=uc(0x0282)
R_F_V=uc(0x0290)
P_F_VL=uc(0x00E7)
P_F_V=uc(0x029D)
V_F_V=uc(0x0263)
U_F_VL=uc(0x03C7)
U_F_V=uc(0x0281)
PH_F_VL=uc(0x0127)
PH_F_V=uc(0x0295)
G_F_V=uc(0x0266)
A_LF_VL=uc(0x026C)
A_LF_V=uc(0x026E)
PA_LF_VL=uc(0x0283)
PA_LF_V=uc(0x0292)
LD_A_V=uc(0x028B)
A_A_V=uc(0x0279)
R_A_V=uc(0x027B)
V_A_V=uc(0x0270)
R_LA_V=uc(0x026D)
P_LA_V=uc(0x028E)
# To print in help menu
cons_as_dict = {
'R_P_VL':R_P_VL,
'R_P_V': R_P_V,
'P_P_V': P_P_V,
'G_P_VL': G_P_VL,
'LD_N_V': LD_N_V,
'R_N_V': R_N_V,
'P_N_V': P_N_V,
'V_N_V': V_N_V,
'A_TF_V': A_TF_V,
'R_TF_V': R_TF_V,
'L_F_VL': L_F_VL,
'L_F_V': L_F_V,
'D_F_VL': D_F_VL,
'D_F_V': D_F_V,
'R_F_VL': R_F_VL,
'R_F_V': R_F_V,
'P_F_VL': P_F_VL,
'P_F_V': P_F_V,
'V_F_V': V_F_V,
'U_F_VL': U_F_VL,
'U_F_V': U_F_V,
'PH_F_VL': PH_F_VL,
'PH_F_V': PH_F_V,
'G_F_V': G_F_V,
'A_LF_VL': A_LF_VL,
'A_LF_V': A_LF_V,
'PA_LF_VL': PA_LF_VL,
'PA_LF_V': PA_LF_V,
'LD_A_V': LD_A_V,
'A_A_V': A_A_V,
'R_A_V': R_A_V,
'V_A_V': V_A_V,
'R_LA_V': R_LA_V,
'P_LA_V': P_LA_V,
}
'''VOWELS. (long/)front/back_high/low_rounding_tense;long:Long=long;
front/back: F=+front,-back, B=-front,+back, C=-front,-back;
high/low: H=+high,-low, M=-high,-low, L=-high,+low;
rounding: R=rounded, U=unrounded;
tense: T=+tense, NT=lax
'''
C_H_U_T=uc(0x0268)
C_H_R_T=uc(0x0289)
B_H_U_T=uc(0x026F)
B_H_R_NT=uc(0x028A)
F_M_R_T=uc(0x00F8)
C_M_U_T=uc(0x0258)
C_M_R_T=uc(0x0275)
B_M_U_T=uc(0x0264)
schwa=uc(0x0259)
F_M_U_NT=uc(0x025B)
F_M_R_NT=uc(0x0153)
C_M_U_NT=uc(0x025C)
C_M_R_NT=uc(0x025E)
B_M_U_NT=uc(0x028C)
B_M_R_NT=uc(0x0254)
F_L_U_T=uc(0x00E6)
C_L_U_T=uc(0x0250)
C_L_R_NT=uc(0x0276)
B_L_U_NT=uc(0x0251)
B_L_R_NT=uc(0x0252)
Long_F_H_U_T='i'+uc(0x02D0)
Long_F_H_R_T='y'+uc(0x02D0)
Long_B_H_R_T='u'+uc(0x02D0)
Long_F_M_U_T='e'+uc(0x02D0)
Long_F_M_R_T=uc(0x00F8)+uc(0x02D0)
Long_B_M_R_T='o'+uc(0x02D0)
Long_C_L_U_NT='a'+uc(0x02D0) #a:
Long_C_L_U_T=uc(0x0250)+uc(0x02D0)
Long_F_H_U_NT='I'+uc(0x02D0)
Long_B_H_R_NT=uc(0x028A)+uc(0x02D0)
Long_F_M_U_NT=uc(0x025B)+uc(0x02D0)
Long_B_M_R_NT=uc(0x0254)+uc(0x02D0)
Cent_B_H_R_T='u'+uc(0x0308)
Cent_B_M_R_T='o'+uc(0x0308)
Cent_F_H_U_T='i'+uc(0x0308)
Cent_C_L_U_NT='a'+uc(0x0308)
# To print in help menu
vowels_as_dict = {
'C_H_U_T': C_H_U_T,
'C_H_R_T': C_H_R_T,
'B_H_U_T': B_H_U_T,
'B_H_R_NT': B_H_R_NT,
'F_M_R_T': F_M_R_T,
'C_M_U_T': C_M_U_T,
'C_M_R_T': C_M_R_T,
'B_M_U_T': B_M_U_T,
'schwa': schwa,
'F_M_U_NT': F_M_U_NT,
'F_M_R_NT': F_M_R_NT,
'C_M_U_NT': C_M_U_NT,
'C_M_R_NT': C_M_R_NT,
'B_M_U_NT': B_M_U_NT,
'B_M_R_NT': B_M_R_NT,
'F_L_U_T': F_L_U_T,
'C_L_U_T': C_L_U_T,
'C_L_R_NT': C_L_R_NT,
'B_L_U_NT': B_L_U_NT,
'B_L_R_NT': B_L_R_NT,
'Long_F_H_U_T':Long_F_H_U_T,
'Long_F_H_R_T':Long_F_H_R_T,
'Long_B_H_R_T':Long_B_H_R_T,
'Long_F_M_U_T':Long_F_M_U_T,
'Long_F_M_R_T':Long_F_M_R_T,
'Long_B_M_R_T':Long_B_M_R_T,
'Long_C_L_U_NT':Long_C_L_U_NT,
'Long_C_L_U_T':Long_C_L_U_T,
'Long_F_H_U_NT':Long_F_H_U_NT,
'Long_B_H_R_NT':Long_B_H_R_NT,
'Long_F_M_U_NT':Long_F_M_U_NT,
'Long_B_M_R_NT':Long_B_M_R_NT,
'Cent_B_H_R_T':Cent_B_H_R_T,
'Cent_B_M_R_T':Cent_B_M_R_T,
'Cent_F_H_U_T':Cent_F_H_U_T,
'Cent_C_L_U_NT':Cent_C_L_U_NT
}
|
#Faça um programa que mostre a tabuada de vários números, um de cada vez, para cada valor digitado pelo usuário. O programa será
#interrompido quando o número solicitado for negativo.
tabuada = 1
c = 1
while True:
tabuada = int(input('Quer ver a tabuada de que valor: '))
while c < 11 and tabuada > 0:
print(tabuada, ' x ', c, ' = ', tabuada * c)
c += 1
if c == 11:
c = 1
if tabuada < 0:
break
print('Fim')
|
# 8.2) find path to robot in a c*r grid, robot can only move right and down.
def find_path(c, r, off_limits):
path = []
move_robot(0, 0, c, r, off_limits, path)
return path
def move_robot(x, y, c, r, off_limits, path):
if x == (c - 1) and y == (r - 1):
return
elif [x + 1, y] not in off_limits and (x + 1) < c:
path.append([x + 1, y])
move_robot(x + 1, y, c, r, off_limits, path)
elif [x, y + 1] not in off_limits and (y + 1) < r:
path.append([x, y + 1])
move_robot(x, y + 1, c, r, off_limits, path)
else:
raise Exception('No path')
# test code
columns = 4
rows = 3
limits = [[1, 0], [2, 1], [3, 1]]
print(find_path(columns, rows, limits))
|
test_cases = int(input().strip())
for t in range(1, test_cases + 1):
s = input().strip()
stack = []
bracket = {'}': '{', ')': '('}
result = 1
for letter in s:
if letter == '{' or letter == '(':
stack.append(letter)
elif letter == '}' or letter == ')':
if not stack or stack[-1] != bracket.get(letter):
result = 0
break
else:
stack.pop()
if stack:
result = 0
print('#{} {}'.format(t, result))
|
# Tristan Protzman
# Created 2019-02-07
# Holds the note patters
class Pattern:
def __init__(self, beats, subdivisions, notes):
self.beats = beats # How many beats per measure
self.subdivisions = subdivisions # How many divisions per beat
self.divisions = self.beats * self.subdivisions # Total divisions in pattern
self.notes = notes # How many different notes are in the patters
self.pattern = [set() for _ in range(self.divisions)] # Top level list, one entry per division
def __str__(self):
"""
Returns a printable representation of the current pattern state.
A # represents the slot is active, a - means it isn't.
Prints 1 line per pitch, doesn't print a line if it contains no active notes.
Guaranteed to print at least one line if no notes are present in pattern
:return: A multiline string representing the state
:rtype: str
"""
representation = ""
for i in range(self.notes):
line = "{:0=3d}| ".format(i)
for j in range(self.divisions):
if i in self.pattern[j]:
line += "# "
else:
line += "- "
if "#" in line:
representation += line + "\n"
if representation == "":
representation = "000| " + self.divisions * "- "
else:
representation = representation[:-1]
return representation
def __repr__(self):
"""
Returns a printable representation of the current pattern state.
A # represents the slot is active, a - means it isn't.
Prints 1 line per pitch, doesn't print a line if it contains no active notes.
Guaranteed to print at least one line if no notes are present in pattern
:return: A multiline string representing the state
:rtype: str
"""
return str(self)
def add_note(self, note, div):
"""
Adds the given note to the pattern. Returns true if the note is allowed to be added, false otherwise.
A note may be prevented from being added if it is outside the division range, outside the note range,
or already exists.
:param note: The note to add
:param div: The division to place the note at
:type note: int
:type div: int
:return: True if successful
:rtype: bool
"""
if note >= self.notes or note < 0:
return False
if div >= self.divisions or div < 0:
return False
if note in self.pattern[div]:
return False
self.pattern[div].add(note)
return True
def remove_note(self, note, div):
"""
Removes the specified note from the pattern. True if note is removed, false if it doesn't
xists/can't be removed.
:param note: The note to remove
:param div: The division to remove it from
:type note: int
:type div: int
:return: True if successful
:rtype: bool
"""
if note >= self.notes:
return False
if div >= self.divisions:
return False
if note not in self.pattern[div]:
return False
self.pattern[div].remove(note)
return True
def notes_at_div(self, div):
"""
Returns the notes active at the specified division
:param div: The division we want the active notes at
:type div: int
:return: The set of notes active at div
:rtype: set
"""
if self.divisions > div >= 0:
return self.pattern[div]
return None
|
class Chat:
START_TEXT = """This is a Telegram Bot to Mux subtitle into a video
<b>Send me a Telegram file to begin</b>
/help for more details..
Credits :- @mohdsabahat
"""
HELP_USER = "??"
HELP_TEXT ="""<b>Welcome to the Help Menu</b>
1.) Send a Video file or url.
2.) Send a subtitle file (ass or srt)
3.) Choose you desired type of muxing!
To give custom name to file send it with url seperated with |
<i>url|custom_name.mp4</i>
<b>Note : </b><i>Please note that only english type fonts are supported in hardmux other scripts will be shown as empty blocks on the video!</i>
<a href="https://github.com/mohdsabahat/sub-muxer">Repo URL</a>"""
NO_AUTH_USER = "You are not authorised to use this bot.\nContact the bot owner!"
DOWNLOAD_SUCCESS = """File downloaded successfully!
Time taken : {} seconds."""
FILE_SIZE_ERROR = "ERROR : Cannot Extract File Size from URL!"
MAX_FILE_SIZE = "File size is greater than 2Gb. Which is the limit imposed by telegram!"
LONG_CUS_FILENAME = """Filename you provided is greater than 60 characters.
Please provide a shorter name."""
UNSUPPORTED_FORMAT = "ERROR : File format {} Not supported!"
CHOOSE_CMD = "Subtitle file downloaded successfully.\nChoose your desired muxing!\n[ /softremove , /softmux , /hardmux ]"
|
# To Find an algorithm for giving selected attributes in a formal concept analysis acc to given conditions
a,arr= [],[]
start,end = 3,5
with open('Naive Algo/Input/test2.txt') as file:
for line in file:
line = line.strip()
for c in line:
if c != ' ':
# print(int(c))
a.append(int(c))
# print(a)
arr.append(a)
a = []
# print(arr)
s = set()
for st in range(start, end+1):
for i in range(len(arr)):
for j in range(len(arr[i])):
if j == st - 1 and arr[i][j] == 1:
s.add(i + 1)
#if j == end - 1 and arr[i][j] == 1:
#s.add(i + 1)
print(s) # Gr
s1 = set()
coun = 0
k = 0
ans = 0
for r in range(start):
for i in range(len(arr)):
for j in range(len(arr[i])):
if j == r - 1 and arr[i][j] == 1:
#print(r,i+1)
# k = 0
coun += 1
if i+1 in s:
k+=1
ans = j+1
# print(coun,k)
if coun == k and k!=0 and coun !=0:
s1.add(ans)
coun = 0
k = 0
print(s1) # attributes
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.