content
stringlengths 7
1.05M
|
|---|
class Solution:
def convertToBase7(self, num: int) -> str:
result = ''
n = abs(num)
while n:
n, curr = divmod(n, 7)
result = str(curr) + result
return '-' * (num < 0) + result or '0'
|
########import random
abcd=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
k=list(input("Enter your String"))
key="HACK"
scn=[['']*4 for i in range(0,4)]
p=sorted(list(key))
ci=[key.index(i) for i in p]
print(ci,p)
i,j=0,0
for m in k:
if j>3:
i+=1
j=0
scn[i][j]=m
j+=1
#enc
ec=[]
i=0
for i in range(0,4):
for j in range(0,4):
ec.append(scn[j][ci[i]])
print(ec)
#dcd
dc=[]
dcdm=[['']*4 for i in range(0,4)]
i,j=0,0
c=-1
for i in range(0,4):
for j in range(0,4):
c+=1
dcdm[ci[i]][j]=ec[c]
for m in range(0,4):
for f in range(0,4):
dc.append(dcdm[f][m])
dc=dc[:len(k)]
print("Key used=",key),print("ec",ec),print("dc",dc)
"""
while a<len(k):
a+=1;
a=a*a;
scn=[['']*a for i in range(0,a)]
key=[random.randint(0,26) for x in range(0,a)]
skey=[abcd[a] for a in key]
order=sorted(skey)
ci=[key.index(i) for i in order]
i,j=0,0
for m in k:
scn[i][j]=m
i+=1
j+=1
"""
"""
if len(k)>16:
print("length should be less than 16")
quit()
#enc
ec=[]
i=0
for i in range(0,a):
for j in range(0,len(ci)):
ec.append([ci[j]][i])
print(ec)
#dec
dc=[]
i=0
for i in range(0,a):
ci[i]
for j in range(0,a):
dc.append([ci[j]][i])
print("Key used=",[abcd.index()])
print(rf,len(rf))
"""
|
start = int(input())
stop = int(input())
result = ""
for number in range(start, stop + 1):
print(chr(number), end=" ")
|
H, W = map(int, input().split())
field = [[str(i) for i in input()] for _ in range(H)]
count = 0
for x in range(W-1):
for y in range(H-1):
black_num = 0
for x1, y1 in [(x, y), (x+1, y), (x, y+1), (x+1, y+1)]:
if field[y1][x1] == '#':
black_num += 1
if black_num % 2 == 1:
count += 1
print(count)
|
"""
test:
"""
def sum_function(a, b, c):
"""
returns sum of a and b
:param a: array
:param b: integer
:return: sum of a and b
change
"""
c = a
return c
def average_function(a, b):
"""
returns the average of the squares of a and b
:param a: integer
:param b: integer
:return: average of a and b
"""
c = (a**2 + b**2) / 2
return c
def no_docs(c):
return c
|
GET_REPOS = [
{
'name': 'sample_repo',
'nameWithOwner': 'example_org/sample_repo',
'primaryLanguage': {
'name': 'Python',
},
'url': 'https://github.com/example_org/sample_repo',
'sshUrl': 'git@github.com:example_org/sample_repo.git',
'createdAt': '2011-02-15T18:40:15Z',
'description': 'My description',
'updatedAt': '2020-01-02T20:10:09Z',
'homepageUrl': '',
'languages': {
'totalCount': 1,
'nodes': [
{'name': 'Python'},
],
},
'defaultBranchRef': {
'name': 'master',
'id': 'branch_ref_id==',
},
'isPrivate': True,
'isArchived': False,
'isDisabled': False,
'isLocked': True,
'owner': {
'url': 'https://github.com/example_org',
'login': 'example_org',
'__typename': 'Organization',
},
'collaborators': {'edges': [], 'nodes': []},
'requirements': {'text': 'cartography\nhttplib2<0.7.0\njinja2\nlxml\n-e git+https://example.com#egg=foobar\nhttps://example.com/foobar.tar.gz\npip @ https://github.com/pypa/pip/archive/1.3.1.zip#sha1=da9234ee9982d4bbb3c72346a6de940a148ea686\n'}, # noqa
}, {
'name': 'SampleRepo2',
'nameWithOwner': 'example_org/SampleRepo2',
'primaryLanguage': {
'name': 'Python',
},
'url': 'https://github.com/example_org/SampleRepo2',
'sshUrl': 'git@github.com:example_org/SampleRepo2.git',
'createdAt': '2011-09-21T18:55:16Z',
'description': 'Some other description',
'updatedAt': '2020-07-03T00:25:25Z',
'homepageUrl': 'http://example.com/',
'languages': {
'totalCount': 1,
'nodes': [
{'name': 'Python'},
],
},
'defaultBranchRef': {
'name': 'master',
'id': 'other_branch_ref_id==',
},
'isPrivate': False,
'isArchived': False,
'isDisabled': False,
'isLocked': False,
'owner': {
'url': 'https://github.com/example_org',
'login': 'example_org', '__typename': 'Organization',
},
'collaborators': None,
'requirements': None,
},
{
'name': 'cartography',
'nameWithOwner': 'lyft/cartography',
'primaryLanguage': {'name': 'Python'},
'url': 'https://github.com/lyft/cartography',
'sshUrl': 'git@github.com:lyft/cartography.git',
'createdAt': '2019-02-27T00:16:29Z',
'description': 'One graph to rule them all',
'updatedAt': '2020-09-02T18:35:17Z',
'homepageUrl': '',
'languages': {
'totalCount': 2,
'nodes': [{'name': 'Python'}, {'name': 'Makefile'}],
},
'defaultBranchRef': {
'name': 'master',
'id': 'putsomethinghere',
},
'isPrivate': False,
'isArchived': False,
'isDisabled': False,
'isLocked': False,
'owner': {
'url': 'https://github.com/example_org',
'login': 'example_org',
'__typename': 'Organization',
},
'collaborators': {
'edges': [
{'permission': 'WRITE'},
{'permission': 'WRITE'},
{'permission': 'WRITE'},
{'permission': 'WRITE'},
{'permission': 'WRITE'},
],
'nodes': [
{
'url': 'https://github.com/marco-lancini',
'login': 'marco-lancini',
'name': 'Marco Lancini',
'email': 'm@example.com',
'company': 'ExampleCo',
},
{
'url': 'https://github.com/sachafaust',
'login': 'sachafaust',
'name': 'Sacha Faust',
'email': 's@example.com',
'company': 'ExampleCo',
},
{
'url': 'https://github.com/SecPrez',
'login': 'SecPrez',
'name': 'SecPrez',
'email': 'sec@example.com',
'company': 'ExampleCo',
},
{
'url': 'https://github.com/ramonpetgrave64',
'login': 'ramonpetgrave64',
'name': 'Ramon Petgrave',
'email': 'r@example.com',
'company': 'ExampleCo',
},
{
'url': 'https://github.com/roshinis78',
'login': 'roshinis78',
'name': 'Roshini Saravanakumar',
'email': 'ro@example.com',
'company': 'ExampleCo',
},
],
},
'requirements': {
'text': 'cartography==0.1.0\nhttplib2>=0.7.0\njinja2\nlxml\n# This is a comment line to be ignored\n',
},
},
]
|
class Node():
def __init__(self, valor):
self.valor = valor
self.next = None
class Stack:
def __init__(self):
self.head = Node("head")
self.size = 0
def __str__(self):
actual = self.head.next
str1 = "["
while actual:
str1 += str(actual.valor) + ", "
actual = actual.next
str1 = str1[:-2] + "]"
if(self.size == 0):
return "[]"
return str1
def lenght(self):
return self.size
def isEmpty(self):
return self.size == 0
def push(self, valor):
node = Node(valor)
node.next = self.head.next
self.head.next = node
self.size += 1
def peek(self):
if self.isEmpty():
raise Exception("Error la pila esta vacia...")
return self.head.next.valor
def pop(self):
if self.isEmpty():
raise Exception("Error la pila esta vacia...")
remove = self.head.next
self.head.next = self.head.next.next
self.size -= 1
return remove.valor
|
sexo=str
while (sexo != 'F') and (sexo != 'M'):
sexo = (input("Digite o sexo: "))
if (sexo != 'F') and (sexo != 'M'):
print('Opção inválida, tente novamente')
|
"""This settings module defines the benchmark driver settings"""
EXPORT_GRAPHVIZ = False
EXPORT_JSON = False
REPEATS = 1
LOGICAL_DOT = ''
FRAGMENTED_DOT = ''
LOGICAL_JSON = ''
FRAGMENTED_JSON = ''
PRESTO_SETTINGS = {}
|
# Дележ яблок-1
def apple_sharing(n, k):
return print(k // n)
n = int(input())
k = int(input())
apple_sharing(n, k)
|
# encoding: utf-8
class Translator(object):
"""翻译器抽象类"""
user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " \
"Chrome/73.0.3683.86 Safari/537.36 "
def __init__(self):
self.trans_from = 'zh'
self.trans_to = 'en'
def get_result(self, *args, **kwargs):
"""获取翻译后的结果,类型如'字典(dict)'"""
raise MethodNotImplementedException("subclass of AbstractRequest method get_result not implemented.")
def query(self, *args, **kwargs):
"""单词或文本翻译接口
@return self
"""
return self
def serialize(self, *args, **kwargs):
"""序列化"""
raise MethodNotImplementedException("subclass of AbstractRequest method serialize not implemented.")
def format(self, verbose=0):
"""格式化, 返回格式化的文本"""
raise MethodNotImplementedException("subclass of AbstractRequest method view not implemented.")
def set_trans_from(self, trans_from):
"""待翻译文字语种"""
self.trans_from = trans_from
def set_trans_to(self, trans_to):
"""翻译到哪个语种"""
self.trans_to = trans_to
def get_name(self):
return ""
class MethodNotImplementedException(Exception):
pass
|
# Databricks notebook source
# MAGIC %run ./includes/utils
# COMMAND ----------
mountDataLake(clientId="64492359-3450-4f1e-be01-8717789fd01e",
clientSecret=dbutils.secrets.get(scope="dpdatalake",key="adappsecret"),
tokenEndPoint="https://login.microsoftonline.com/0b55e01a-573a-4060-b656-d1a3d5815791/oauth2/token",
storageAccountName="dpdatalake",
containerName="data")
# COMMAND ----------
# MAGIC %sql
# MAGIC CREATE DATABASE IF NOT EXISTS nyctaxi;
# MAGIC USE nyctaxi;
# MAGIC CREATE TABLE IF NOT EXISTS fact_zone_summary
# MAGIC USING DELTA
# MAGIC LOCATION '/mnt/data/curated/fact_zone_summary';
# MAGIC CREATE TABLE IF NOT EXISTS dim_zone_lookup
# MAGIC USING DELTA
# MAGIC LOCATION '/mnt/data/curated/dim_zone_lookup';
|
class Artist:
def __init__(self, artist_id, uri, title):
self.id = artist_id
self.uri = uri
self.title = title
def __str__(self):
return '{} (id={})'.format(self.title, self.id)
def to_tuple(self):
return (self.id, self.uri, self.title)
|
description = 'Actuators and feedback of the shutter, detector, and valves'
group = 'lowlevel'
excludes = ['IOcard']
devices = dict(
I1_pnCCD_Active = device('nicos.devices.generic.ManualSwitch',
description = 'high: Detector is turned on',
states = [0, 1],
),
I2_Shutter_safe = device('nicos.devices.generic.ManualSwitch',
description = 'high: Detector is turned on',
states = [0, 1],
),
I3_Det_chamber_vent_open = device('nicos.devices.generic.ManualSwitch',
description = 'high: Detector Chamber venting gauge open',
states = [0, 1],
),
I4_Exp_ch_vent_open = device('nicos.devices.generic.ManualSwitch',
description = 'high: Experiment Chamber venting gauge open',
states = [0, 1],
),
I5_Det_ch_pump_open = device('nicos.devices.generic.ManualSwitch',
description = 'high: Detector Chamber pumping gauge open',
states = [0, 1],
),
I6_Exp_ch_pump_open = device('nicos.devices.generic.ManualSwitch',
description = 'high: Experiment Chamber pumping gauge open',
states = [0, 1],
),
I7_Exp_ch_vent_gas_selection = device('nicos.devices.generic.ManualSwitch',
description = 'Venting either with air or nitrogen',
states = [0, 1],
),
I8_unused = device('nicos.devices.generic.ManualSwitch',
description = '1 Bit wide digital input starting at E8',
states = [0, 1],
),
O1_pnCCD_Trigger = device('nicos.devices.generic.ManualSwitch',
description = 'Send Trigger to detector to start collecting data',
states = [0, 1],
),
O2_Shutter_open = device('nicos.devices.generic.ManualSwitch',
description = 'Open the shutter from LMJ',
states = [0, 1],
),
O3_Det_ch_vent = device('nicos.devices.generic.ManualSwitch',
description = 'Vent Detector Chamber',
states = [0, 1],
),
O4_Exp_ch_vent= device('nicos.devices.generic.ManualSwitch',
description = 'Vent Experiment Chamber',
states = [0, 1],
),
O5_Det_ch_pump = device('nicos.devices.generic.ManualSwitch',
description = 'Open gauge from pump to Detector Chamber',
states = [0, 1],
),
O6_Exp_ch_pump = device('nicos.devices.generic.ManualSwitch',
description = 'Open gauge from pump to Experiment Chamber',
states = [0, 1],
),
O7_Exp_ch_vent_gas = device('nicos.devices.generic.ManualSwitch',
description = 'Choose either air or Nitrogen for venting',
states = [0, 1],
),
O8_unused = device('nicos.devices.generic.ManualSwitch',
description = '1 Bit wide digital output starting at A8',
states = [0, 1],
),
)
|
def multiple_of(num, multiple):
return num % multiple == 0
def sum_of_multiples(limit):
return sum(x for x in range(limit) if multiple_of(x, 3) or multiple_of(x, 5))
if __name__ == "__main__":
print(sum_of_multiples(1000))
|
# nobully.py
# Metadata
NAME = 'nobully'
ENABLE = True
PATTERN = r'^!nobully (?P<nick>[^\s]+)'
USAGE = '''Usage: !nobully <nick>
This informs the user identified by nick that they should no longer bully other (innocent) users.
'''
# Constants
NOBULLY_URL = 'https://www.stop-irc-bullying.info/'
# Command
async def nobully(bot, message, nick):
if nick not in bot.users:
return message.with_body(f'Unknown nick: {nick}')
else:
return message.with_body(f'{message.nick} thinks that you should stop bullying other users, {nick}. Please refer to {NOBULLY_URL} for more information.')
# Register
def register(bot):
return (
('command', PATTERN, nobully),
)
# vim: set sts=4 sw=4 ts=8 expandtab ft=python:
|
'''print('Ajuda Interativa')
print('Usando o help(e o comando)')
#help(print)'''
#exemplo DOCTRINGS**
'''def contador(i, f, p):
"""
-> faz uma contagem e mostra na tela.
:param i: Inicio da contagem
:param f: Fim da contagem
:param p: Passo da contagem
:return: sem retorno
"""
c = i
while c <= f:
print(f'{c} ', end='')
c += p
print('FIM!')
resp = notas(10, 9, 8, sit=True)# Notas mostra a doctrings
help(contador)'''
#Exemplo parametros opcionais
'''def soma(a=0, b=0, c=0):
"""
-> Faz a soma de três valores e mostra o resultado na tela.
:param a: primeiro valor
:param b: Segundo valor
:param c: terceiro valor
:return:
"""
s = a + b + c
print(f'A soma vale {s}')
soma(3, 2, 9)'''
#Escopo de Variavel
'''def teste(b):
global a # faz o A valer oq ta dentro da função
a = 8
b += 4
c = 2
print(f'A dentro vale {a}')
print(f'B dentro vale {b}')
print(f'C dentro vale {c}')
a = 5
teste(a)
print(f'A fora vale {a}')'''
#Retornando Valores
'''def soma(a=0, b=0, c=0):
s = a + b + c
return s
r1 = soma(3, 2, 5)
r2 = soma(2, 2)
r3 = soma(6)
print(f'Os resultados foram {r1}, {r2}, {r3}')'''
#Exercicio aula
print('Fatorial')
def fatorial(num=1):
f = 1
for c in range(num, 0, -1):
f *= c
return f
f1 = fatorial(5)
f2 = fatorial(4)
f3 = fatorial()
print(f'Os resultados são {f1}, {f2}, {f3}')
print('Par e impar')
def par(n=0):
if n % 2 == 0:
return True
else:
return False
num = int(input('Digite um numero: '))
if par(num):
print('É par!')
else:
print('Não é par!')
|
"""
Misc. imported libs.
"""
load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
#############################################
def eigen():
new_git_repository(
name = "eigen",
commit = "954879183b1e008d7f0fefb97e48a925c4e3fb16", # current as of 2021/06/15
remote = "https://gitlab.com/libeigen/eigen.git",
build_file = "@bazel_rules//repositories:BUILD.eigen",
shallow_since = "1623784629 -0700",
)
#############################################
def libcurl():
new_git_repository(
name = "com_github_curl_curl",
commit = "55a13f500e3897c6b640757786c02d989a10f2e2", # current as of 2021/06/15
remote = "git://github.com/curl/curl.git",
build_file = "@bazel_rules//repositories:BUILD.libcurl",
shallow_since = "1623770030 +0200",
)
#############################################
def libidn2():
new_git_repository(
name = "com_gitlab_libidn_libidn2",
commit = "807b5dfef35a1aad0e0ebc5360af0accff1325ab", # current as of 2021/06/10
remote = "https://gitlab.com/libidn/libidn2.git",
recursive_init_submodules = True,
build_file = "@bazel_rules//repositories:BUILD.libidn2",
shallow_since = "1621340058 +0200",
)
#############################################
def zlib():
http_archive(
name = "zlib",
build_file = "@bazel_rules//repositories:BUILD.zlib",
sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1",
strip_prefix = "zlib-1.2.11",
urls = [
"https://mirror.bazel.build/zlib.net/zlib-1.2.11.tar.gz",
"https://zlib.net/zlib-1.2.11.tar.gz",
],
)
#############################################
def jsoncpp():
new_git_repository(
name = "com_github_open_source_parsers_jsoncpp",
commit = "375a1119f8bbbf42e5275f31b281b5d87f2e17f2", # current as of 2021/06/10
remote = "git://github.com/open-source-parsers/jsoncpp.git",
build_file = "@bazel_rules//repositories:BUILD.jsoncpp",
shallow_since = "1620266582 -0500",
)
#############################################
def libgnutls():
new_git_repository(
name = "com_gitlab_gnutls",
commit = "70f8edd864b69f05d93c1b31ca4abc5e049078c4", # current as of 2021/06/15
remote = "https://gitlab.com/gnutls/gnutls.git",
recursive_init_submodules = True,
patch_cmds = [
"rm devel/libtasn1/gtk-doc.make", # broken symlink in some builds.
],
build_file = "@bazel_rules//repositories:BUILD.gnutls",
shallow_since = "1623426704 +0000",
)
#############################################
def libhttpserver():
new_git_repository(
name = "com_github_etr_libhttpserver",
build_file = "@bazel_rules//repositories:BUILD.libhttpserver",
commit = "c5cf5eaa89830ad2aa706a161a647705661bd671", # current as of 2021/06/09
remote = "git://github.com/etr/libhttpserver.git",
shallow_since = "1623266851 -0700",
)
#############################################
def libnettle():
new_git_repository(
name = "se_liu_lysator_nettle_nettle",
commit = "a46a17e9f57c64984d5246aa3475e45f8c562ec7", # current as of 2021/06/10
remote = "https://git.lysator.liu.se/nettle/nettle.git",
recursive_init_submodules = True,
build_file = "@bazel_rules//repositories:BUILD.nettle",
shallow_since = "1621875492 +0200",
)
#############################################
def libev():
new_git_repository(
name = "com_github_enki_libev",
remote = "git://github.com/enki/libev.git",
commit = "93823e6ca699df195a6c7b8bfa6006ec40ee0003",
shallow_since = "1463172876 -0700",
build_file = "@bazel_rules//repositories:BUILD.libev",
patch_cmds = [
"chmod 755 autogen.sh",
],
)
#############################################
def microhttpd():
DOMAINS = [
# GNU mirrors
"ftp.wayne.edu",
"mirrors.tripadvisor.com",
"mirrors.kernel.org",
"mirror.clarkson.edu",
"mirrors.syringanetworks.net",
"mirror.us-midwest-1.nexcess.net",
"mirrors.ocf.berkeley.edu",
# primary
"ftp.gnu.org",
]
http_archive(
name = "org_gnu_microhttpd",
build_file = "@bazel_rules//repositories:BUILD.microhttpd",
sha256 = "e8f445e85faf727b89e9f9590daea4473ae00ead38b237cf1eda55172b89b182",
strip_prefix = "libmicrohttpd-0.9.71",
urls = ["https://%s/gnu/libmicrohttpd/libmicrohttpd-0.9.71.tar.gz" % domain for domain in DOMAINS],
)
#############################################
def openssl():
new_git_repository(
name = "com_github_openssl_openssl",
commit = "4832560be3b2a709557497cd881f8c390ba7ec34", # current as of 2021/06/15
remote = "https://github.com/openssl/openssl.git",
#recursive_init_submodules = True,
build_file = "@bazel_rules//repositories:BUILD.openssl",
shallow_since = "1623788074 +0200",
)
|
# Copyright (c) 2018, WSO2 Inc. (http://wso2.com) 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.
NS = {'d': 'http://maven.apache.org/POM/4.0.0'}
ZIP_FILE_EXTENSION = ".zip"
CARBON_NAME = "carbon.zip"
VALUE_TAG = "{http://maven.apache.org/POM/4.0.0}value"
SURFACE_PLUGIN_ARTIFACT_ID = "maven-surefire-plugin"
DATASOURCE_PATHS = {"product-iots": {
"CORE": ["conf/datasources/master-datasources.xml", "conf/datasources/cdm-datasources.xml",
"conf/datasources/android-datasources.xml"],
"BROKER": [],
"ANALYTICS": []},
}
M2_PATH = {"product-iots": "iot/wso2iot"}
DIST_POM_PATH = {"product-is": "modules/distribution/pom.xml", "product-apim": "modules/distribution/product/pom.xml",
"product-ei": "distribution/pom.xml"}
LIB_PATH = "lib"
DISTRIBUTION_PATH = {"product-apim": "modules/distribution/product/target",
"product-is": "modules/distribution/target",
"product-ei": "distribution/target"}
PRODUCT_STORAGE_DIR_NAME = "product"
TEST_PLAN_PROPERTY_FILE_NAME = "testplan-props.properties"
INFRA_PROPERTY_FILE_NAME = "infrastructure.properties"
LOG_FILE_NAME = "integration.log"
ORACLE_DB_ENGINE = "ORACLE-SE2"
MSSQL_DB_ENGINE = "SQLSERVER-SE"
MYSQL_DB_ENGINE = "MYSQL"
DEFAULT_ORACLE_SID = "orcl"
DEFAULT_DB_USERNAME = "wso2carbon"
LOG_STORAGE = "logs"
LOG_FILE_PATHS = {"product-apim": [],
"product-is": [],
"product-ei": []}
DB_META_DATA = {
"MYSQL": {"prefix": "jdbc:mysql://", "driverClassName": "com.mysql.jdbc.Driver", "jarName": "mysql.jar",
"DB_SETUP": {
"product-apim": {},
"product-is": {},
"product-ei": {},
"product-iots": {"WSO2_CARBON_DB_CORE": ['dbscripts/mysql5.7.sql'],
"WSO2APPM_DB_CORE": ['dbscripts/appmgt/mysql5.7.sql'],
"WSO2AM_DB_CORE": ['dbscripts/apimgt/mysql5.7.sql'],
"WSO2_MB_STORE_DB_CORE": ['wso2/broker/dbscripts/mb-store/mysql-mb.sql'],
"JAGH2_CORE": ['dbscripts/mysql5.7.sql'],
"WSO2_SOCIAL_DB_CORE": ['dbscripts/social/mysql/resource.sql'],
"DM_DS_CORE": ['dbscripts/cdm/mysql.sql'],
"DM_ARCHIVAL_DS_CORE": ['dbscripts/cdm/mysql.sql'],
"Android_DB_CORE": ['dbscripts/cdm/plugins/android/mysql.sql']}}},
"SQLSERVER-SE": {"prefix": "jdbc:sqlserver://",
"driverClassName": "com.microsoft.sqlserver.jdbc.SQLServerDriver", "jarName": "sqlserver-ex.jar",
"DB_SETUP": {
"product-apim": {},
"product-is": {},
"product-ei": {"WSO2_CARBON_DB_CORE": ['dbscripts/mssql.sql'],
"WSO2_CARBON_DB_BROKER": ['wso2/broker/dbscripts/mssql.sql'],
"WSO2_CARBON_DB_BPS": ['wso2/business-process/dbscripts/mssql.sql'],
"WSO2_MB_STORE_DB_BROKER": ['wso2/broker/dbscripts/mb-store/mssql-mb.sql'],
"WSO2_METRICS_DB_BROKER": ['wso2/broker/dbscripts/metrics/mssql.sql'],
"BPS_DS_BPS": ['wso2/business-process/dbscripts/bps/bpel/create/mssql.sql'],
"ACTIVITI_DB_BPS": [
'wso2/business-process/dbscripts/bps/bpmn/create/activiti.mssql.create.identity.sql']}}},
"ORACLE-SE2": {"prefix": "jdbc:oracle:thin:@", "driverClassName": "oracle.jdbc.OracleDriver",
"jarName": "oracle-se.jar",
"DB_SETUP": {
"product-apim": {},
"product-is": {},
"product-ei": {"WSO2_CARBON_DB_CORE": ['dbscripts/oracle.sql'],
"WSO2_CARBON_DB_BROKER": ['wso2/broker/dbscripts/oracle.sql'],
"WSO2_CARBON_DB_BPS": ['wso2/business-process/dbscripts/oracle.sql'],
"WSO2_MB_STORE_DB_BROKER": ['wso2/broker/dbscripts/mb-store/oracle-mb.sql'],
"WSO2_METRICS_DB_BROKER": ['wso2/broker/dbscripts/metrics/oracle.sql'],
"BPS_DS_BPS": ['wso2/business-process/dbscripts/bps/bpel/create/oracle.sql'],
"ACTIVITI_DB_BPS": [
'wso2/business-process/dbscripts/bps/bpmn/create/activiti.oracle.create.identity.sql']}}},
"POSTGRESQL": {"prefix": "jdbc:postgresql://", "driverClassName": "org.postgresql.Driver",
"jarName": "postgres.jar",
"DB_SETUP": {"product-apim": {},
"product-is": {},
"product-ei": {}}
}}
|
name = "Angela"
letters_list = [x for x in name]
print(letters_list)
doubled = [x * 2 for x in range(1, 5)]
print(doubled)
maybe_tripled = [x * 3 for x in range(1, 10) if x > 5]
print(maybe_tripled)
def foo(value):
if value > 5:
return True
return False
with_fn = [x * 3 for x in range(1, 10) if foo(x)]
print(with_fn)
squared = [x * x for x in range(1, 51)]
print(squared)
even = [x for x in [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] if x % 2 == 0]
print(even)
|
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def reverseBetween(self, head: ListNode, left: int, right: int) -> ListNode:
left -= 1
right -= 1
newHead = ListNode(-1)
newHead.next = head
deque = collections.deque()
current = newHead.next
for index in range(right + 1):
if left <= index <= right:
deque.append(current)
current = current.next
while len(deque) >= 2:
front = deque.popleft()
back = deque.pop()
front.val, back.val = back.val, front.val
return newHead.next
|
# entrada 3 float
A = float(input())
B = float(input())
C = float(input())
# variaveis (pesos)
P1 = 2
P2 = 3
P3 = 5
# calculo da media
MEDIA = ((A * P1) + (B*P2) + (C*P3)) / (P1+P2+P3)
print('MEDIA = {:.1f}'.format(MEDIA))
|
def get_CUDA(vectorSize = 10, func = "sin(2*pi*X/Lx)", px = "0.", py = "0.", pz = "0.", **kwargs):
return '''__global__ void initialize(dcmplx *QField, int* lattice, int* gpu_params){
int deviceNum = gpu_params[0];
int numGPUs = gpu_params[2];
int xSize = lattice[0]*numGPUs;
int ySize = lattice[2];
int zSize = lattice[4];
int vectorSize = ''' + str(vectorSize) + ''';
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
int z = blockIdx.z * blockDim.z + threadIdx.z;
double this_x = double(x+deviceNum*lattice[0]);
int n;
dcmplx i(0.,1.);
double X = (double)(this_x);
double Y = (double)(y);
double Z = (double)(z);
double Lx = (double) xSize;
double Ly = (double) ySize;
double Lz = (double) zSize;
dcmplx phaseKickX = exp(i*(-('''+str(px)+''')*2.*pi)*(X)/Lx);
dcmplx phaseKickY = exp(i*(-('''+str(py)+''')*2.*pi)*(Y)/Ly);
dcmplx phaseKickZ = exp(i*(-('''+str(pz)+''')*2.*pi)*(Z)/Lz);
dcmplx field = ''' + func + '''*phaseKickX*phaseKickY*phaseKickZ;
for (n=0; n<vectorSize; n=n+1){
QField[n+z*vectorSize+y*vectorSize*zSize+x*zSize*ySize*vectorSize] = field/2.;
}
}'''
|
"""
Empty files are not supported by Signed VSO Builds. Adding dummy file
@author: shagup
"""
|
answer1 = widget_inputs["radio1"]
answer2 = widget_inputs["radio2"]
answer3 = widget_inputs["radio3"]
answer4 = widget_inputs["radio4"]
is_correct = False
comments = []
def commentizer(new):
if new not in comments:
comments.append(new)
if answer2 == True:
is_correct = True
else:
is_correct = is_correct and False
commentizer("Open the site and try changing `cover` to `contain` in DevTools to see the difference.")
commentizer("Check the first one.")
if answer3 == True:
is_correct = is_correct and True
else:
is_correct = is_correct and False
commentizer("Open the site and try changing `cover` to `contain` in DevTools to see the difference.")
commentizer("Check the second one.")
if is_correct:
commentizer("Great job! You're starting to learn how to decide between raster and vector options.")
grade_result["comment"] = "\n\n".join(comments)
grade_result["correct"] = is_correct
|
#
# Copyright (c) 2016, Prometheus Research, LLC
#
__import__('pkg_resources').declare_namespace(__name__)
|
num = int(input('Insira um num inteiro: '))
if num % 2 == 0:
print('O numero {} é par'.format(num))
else:
print('O numero {} é impar'.format(num))
|
class Solution:
def uniquePaths(self, m: int, n: int) -> int:
"""initialize a n * m array"""
paths = [[0 for col in range(m)] for row in range(n)]
""" init all item in last row to 1"""
for col in range(m):
paths[n - 1][col] = 1
""" init all item in last col to 1"""
for row in range(n):
paths[row][m - 1] = 1
for row in range(n - 2, -1, -1):
for col in range(m - 2, -1, -1):
paths[row][col] = paths[row][col + 1] + paths[row + 1][col]
return paths[0][0]
s = Solution()
print(s.uniquePaths(23, 18))
|
#task1: print the \\ double backslash
print("This is \\\\ double backslash")
#task2: print the mountains
print ("this is /\\/\\/\\/\\/\\ mountain")
#task3:he is awesome(using escape sequence)
print ("he is \t awesome")
#task4: \" \n \t \'
print ("\\\" \\n \\t \\\'")
|
class TaskError(Exception):
pass
class StrategyError(Exception):
pass
|
# 1 = Ace, 10 = Jack, 10 = Queen, 10 = King
deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]
deck = deck * 4
# TODO: Add cut-card functionality
def initiate_deck():
"""Asks the user how many decks are in play and generates the shoe"""
while True:
try:
deck_count = int(input("How many decks in play? (Max: 8)"))
if not 0 < deck_count < 9:
raise ValueError
break
except ValueError:
print("Insert a valid count between 0 and 9")
return sorted(deck * deck_count)
|
class Controller:
def __init__(self, period, init_cores, st=0.8):
self.period = period
self.init_cores = init_cores
self.st = st
self.name = type(self).__name__
def setName(self, name):
self.name = name
def setSLA(self, sla):
self.sla = sla
self.setpoint = sla*self.st
def setMonitoring(self, monitoring):
self.monitoring = monitoring
def setGenerator(self, generator):
self.generator = generator
def tick(self, t):
if not t:
self.reset()
if t and not (t % self.period):
self.control(t)
return self.cores
def control(self, t):
pass
def reset(self):
self.cores = self.init_cores
def __str__(self):
return "%s - period: %d init_cores: %.2f" % (self.name, self.period, self.init_cores)
|
r"""
Utility functions for building Sage
"""
# ****************************************************************************
# Copyright (C) 2017 Jeroen Demeyer <J.Demeyer@UGent.be>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# https://www.gnu.org/licenses/
# ****************************************************************************
def stable_uniq(L):
"""
Given an iterable L, remove duplicate items from L by keeping only
the last occurrence of any item.
The items must be hashable.
EXAMPLES::
sage: from sage_setup.util import stable_uniq
sage: stable_uniq( (1, 2, 3, 4, 5, 6, 3, 7, 5, 1, 5, 9) )
[2, 4, 6, 3, 7, 1, 5, 9]
"""
D = {}
for pos, item in enumerate(L):
D[item] = pos # Store the last position where an item appears
return sorted(D, key=lambda item: D[item])
def have_module(name):
"""
Check whether a Python module named ``name`` can be imported.
This is done by trying to import that module and returning ``True``
if that import succeeded. So, as a side effect, the module is
actually imported if possible.
EXAMPLES::
sage: from sage_setup.util import have_module
sage: have_module("itertools")
True
sage: have_module("sage.rings.integer")
True
sage: have_module("no.such.module")
False
"""
try:
__import__(name, {}, {}, [], 0)
return True
except ImportError:
return False
|
# ***************************************************************************************
# ***************************************************************************************
#
# Name : democodegenerator.py
# Author : Paul Robson (paul@robsons.org.uk)
# Date : 17th December 2018
# Purpose : Imaginary language code generator.
#
# ***************************************************************************************
# ***************************************************************************************
# ***************************************************************************************
#
# Code generator for an imaginary CPU, for testing
#
# ***************************************************************************************
class DemoCodeGenerator(object):
def __init__(self,optimise = False):
self.addr = 0x1000 # code space
self.memoryAddr = 0x3000 # uninitialised data
self.opNames = {}
for op in "+add;-sub;*mult;/div;%mod;∧|or;^xor".split(";"):
self.opNames[op[0]] = op[1:]
self.jumpTypes = { "":"jmp","#":"jnz","=":"jz","+":"jpe","-":"jmi" }
#
# Get current address in code space.
#
def getAddress(self):
return self.addr
#
# Allocate memory for a variable.
#
def allocate(self,count = 1):
address = self.memoryAddr
for i in range(0,count):
print("${0:06x} : dw 0".format(self.memoryAddr))
self.memoryAddr += 2
return address
#
# Place an ASCIIZ string constant ... somewhere .... return its address
#
def stringConstant(self,str):
print("${0:06x} : db '{1}',0".format(self.addr,str)) # can be inline, or elsewhere
addr = self.addr
self.addr = self.addr + len(str) + 1
return addr
#
# Load Accumulator with constant or term.
#
def loadARegister(self,term):
if term[0]:
print("${0:06x} : ldr a,(${1:04x})".format(self.addr,term[1]))
else:
print("${0:06x} : ldr a,#${1:04x}".format(self.addr,term[1]))
self.addr += 1
#
# Perform a binary operation with a constant/term on the accumulator.
#
def binaryOperation(self,operator,term):
if operator == "!" or operator == "?": # indirect, we do add then read
self.binaryOperation("+",term) # add will optimise a bit
print("${0:06x} : ldr.{1} a,[a]".format(self.addr,"w" if operator == "!" else "b"))
self.addr += 1
return
operator = self.opNames[operator] # convert op to opcode name
if term[0]:
print("${0:06x} : {1:4} a,(${2:04x})".format(self.addr,operator,term[1]))
self.addr += 1
else:
print("${0:06x} : {1:4} a,#${2:04x}".format(self.addr,operator,term[1]))
self.addr += 1
#
# Save A at the address given
#
def saveDirect(self,address):
print("${0:06x} : str a,(${1:04x})".format(self.addr,address))
self.addr += 1
#
# Save temp register indirect through A, byte or word, and put temp back in A
#
def saveTempIndirect(self,isWord):
print("${0:06x} : str.{1} b,[a]".format(self.addr," " if isWord else "b"))
print("${0:06x} : tba".format(self.addr+1))
self.addr += 2
#
# Copy A to the temp register, A value unknown after this.
#
def copyToTemp(self):
print("${0:06x} : tab".format(self.addr))
self.addr += 1
#
# Compile a call to a procedure (call should protect 'A')
#
def callProcedure(self,address):
print("${0:06x} : call ${1:06x}".format(self.addr,address))
self.addr += 1
#
# Return from procedure (should protect A)
#
def returnProcedure(self):
print("${0:06x} : ret".format(self.addr))
self.addr += 1
#
# Compile a jump with the given condition ( "", "=", "#", "+" "-""). The
# target address is not known yet.
#
def compileJump(self,condition):
assert condition in self.jumpTypes
print("${0:06x} : {1:3} ?????".format(self.addr,self.jumpTypes[condition]))
jumpAddr = self.addr
self.addr += 1
return jumpAddr
#
# Patch a jump given its base addres
#
def patchJump(self,jumpAddr,target):
print("${0:06x} : (Set target to ${1:06x})".format(jumpAddr,target))
#
# Compile the top of a for loop.
#
def forTopCode(self,indexVar):
loop = self.getAddress()
print("${0:06x} : dec a".format(self.addr)) # decrement count
print("${0:06x} : push a".format(self.addr+1)) # push on stack
self.addr += 2
if indexVar is not None: # if index exists put it there
self.saveDirect(indexVar.getValue())
return loop
#
# Compile the bottom of a for loop
#
def forBottomCode(self,loopAddress):
print("${0:06x} : pop a".format(self.addr)) # pop off stack, jump if not done
print("${0:06x} : jnz ${1:06x}".format(self.addr+1,loopAddress))
self.addr += 2
|
# Sphinx helper for Django-specific references
def setup(app):
app.add_crossref_type(
directivename = "label",
rolename = "djterm",
indextemplate = "pair: %s; label",
)
app.add_crossref_type(
directivename = "setting",
rolename = "setting",
indextemplate = "pair: %s; setting",
)
app.add_crossref_type(
directivename = "templatetag",
rolename = "ttag",
indextemplate = "pair: %s; template tag",
)
app.add_crossref_type(
directivename = "templatefilter",
rolename = "tfilter",
indextemplate = "pair: %s; template filter",
)
app.add_crossref_type(
directivename = "fieldlookup",
rolename = "lookup",
indextemplate = "pair: %s; field lookup type",
)
|
"""
Contains utility functions to works with learning-object get many.
"""
def get_many(db_client, filter_, range_, sorted_, user, learning_object_format):
"""Get learning objects with query."""
start, end = range_
field, order = sorted_
user_role = user.get('role')
user_id = user.get('id')
# Role level permissions
user_role_permissions_handler = {
'oai': [
{'status': 'accepted', 'deleted': {
'$in': [True, False]
}}
],
'external': [
{'status': 'accepted', 'deleted': False},
],
'creator': [
{
'creator_id': user_id,
'status': {
'$in': ['pending', 'evaluated', 'accepted', 'rejected']
}
},
{'status': 'accepted', 'deleted': False},
],
'expert': [
{
'expert_ids': user_id,
'status': {
'$in': ['pending', 'evaluated', 'accepted', 'rejected']
}
},
{
'creator_id': user_id,
'status': {
'$in': ['pending', 'evaluated', 'accepted', 'rejected']
}
},
{'status': 'accepted', 'deleted': False}
],
'administrator': [
{}
],
}
initial_query = {'$or': user_role_permissions_handler.get(user_role)}
if filter_.get('q'):
query = {'$text': {
'$search': filter_.get('q'),
'$diacriticSensitive': False,
'$caseSensitive': False,
}}
query = {**initial_query, **query}
cursor = db_client.learning_objects.find(
query
)
learning_objects = list(
cursor
.skip(start)
.limit((end - start) + 1)
)
else:
query = {**initial_query, **filter_}
cursor = db_client.learning_objects.find(query)
learning_objects = list(
cursor
.sort([(field, -1 if order == 'DESC' else 1)])
.skip(start)
.limit((end - start) + 1)
)
if learning_object_format:
format_handler = {
'xml': lambda lo: lo.get('metadata_xml'),
}
for index_lo in range(len(learning_objects)):
learning_objects[index_lo]['metadata'] = format_handler[learning_object_format](
learning_objects[index_lo])
return learning_objects, cursor.count()
|
#
# PySNMP MIB module SMON2-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SMON2-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:59:43 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
smon, = mibBuilder.importSymbols("APPLIC-MIB", "smon")
ObjectIdentifier, Integer, OctetString = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "Integer", "OctetString")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsIntersection, ValueSizeConstraint, ConstraintsUnion, SingleValueConstraint, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueSizeConstraint", "ConstraintsUnion", "SingleValueConstraint", "ValueRangeConstraint")
OwnerString, = mibBuilder.importSymbols("RMON-MIB", "OwnerString")
DataSource, LastCreateTime, TimeFilter, hlMatrixControlIndex, ZeroBasedCounter32, protocolDirLocalIndex = mibBuilder.importSymbols("RMON2-MIB", "DataSource", "LastCreateTime", "TimeFilter", "hlMatrixControlIndex", "ZeroBasedCounter32", "protocolDirLocalIndex")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
Counter32, Unsigned32, IpAddress, MibScalar, MibTable, MibTableRow, MibTableColumn, Bits, ObjectIdentity, MibIdentifier, Integer32, TimeTicks, iso, NotificationType, Counter64, Bits, ModuleIdentity, Gauge32 = mibBuilder.importSymbols("SNMPv2-SMI", "Counter32", "Unsigned32", "IpAddress", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Bits", "ObjectIdentity", "MibIdentifier", "Integer32", "TimeTicks", "iso", "NotificationType", "Counter64", "Bits", "ModuleIdentity", "Gauge32")
TimeStamp, TextualConvention, RowStatus, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TimeStamp", "TextualConvention", "RowStatus", "DisplayString")
xsSmon = MibIdentifier((1, 3, 6, 1, 4, 1, 81, 30, 2))
xsSmonResourceAllocation = MibScalar((1, 3, 6, 1, 4, 1, 81, 30, 2, 1), OctetString().subtype(subtypeSpec=ValueSizeConstraint(4, 4)).setFixedLength(4)).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsSmonResourceAllocation.setStatus('current')
xsHostTopN = MibIdentifier((1, 3, 6, 1, 4, 1, 81, 30, 2, 2))
xsHostTopNControlTable = MibTable((1, 3, 6, 1, 4, 1, 81, 30, 2, 2, 1), )
if mibBuilder.loadTexts: xsHostTopNControlTable.setStatus('current')
xsHostTopNControlEntry = MibTableRow((1, 3, 6, 1, 4, 1, 81, 30, 2, 2, 1, 1), ).setIndexNames((0, "SMON2-MIB", "xsHostTopNControlIndex"))
if mibBuilder.loadTexts: xsHostTopNControlEntry.setStatus('current')
xsHostTopNControlIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 2, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535)))
if mibBuilder.loadTexts: xsHostTopNControlIndex.setStatus('current')
xsHostTopNControlHostIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 2, 1, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: xsHostTopNControlHostIndex.setStatus('current')
xsHostTopNControlRateBase = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 2, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("xsHostTopNInPkts", 1), ("xsHostTopNOutPkts", 2), ("xsHostTopNInOctets", 3), ("xsHostTopNOutOctets", 4)))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: xsHostTopNControlRateBase.setStatus('current')
xsHostTopNControlTimeRemaining = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 2, 1, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: xsHostTopNControlTimeRemaining.setStatus('current')
xsHostTopNControlDuration = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 2, 1, 1, 5), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsHostTopNControlDuration.setStatus('current')
xsHostTopNControlRequestedSize = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 2, 1, 1, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647)).clone(150)).setMaxAccess("readcreate")
if mibBuilder.loadTexts: xsHostTopNControlRequestedSize.setStatus('current')
xsHostTopNControlGrantedSize = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 2, 1, 1, 7), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsHostTopNControlGrantedSize.setStatus('current')
xsHostTopNControlStartTime = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 2, 1, 1, 8), TimeStamp()).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsHostTopNControlStartTime.setStatus('current')
xsHostTopNControlOwner = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 2, 1, 1, 9), OwnerString()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: xsHostTopNControlOwner.setStatus('current')
xsHostTopNControlStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 2, 1, 1, 10), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: xsHostTopNControlStatus.setStatus('current')
xsHostTopNTable = MibTable((1, 3, 6, 1, 4, 1, 81, 30, 2, 2, 2), )
if mibBuilder.loadTexts: xsHostTopNTable.setStatus('current')
xsHostTopNEntry = MibTableRow((1, 3, 6, 1, 4, 1, 81, 30, 2, 2, 2, 1), ).setIndexNames((0, "SMON2-MIB", "xsHostTopNControlIndex"), (0, "SMON2-MIB", "xsHostTopNIndex"))
if mibBuilder.loadTexts: xsHostTopNEntry.setStatus('current')
xsHostTopNIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 2, 2, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535)))
if mibBuilder.loadTexts: xsHostTopNIndex.setStatus('current')
xsHostTopNProtocolDirLocalIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 2, 2, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsHostTopNProtocolDirLocalIndex.setStatus('current')
xsHostTopNNlAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 2, 2, 1, 3), OctetString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsHostTopNNlAddress.setStatus('current')
xsHostTopNRate = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 2, 2, 1, 4), Gauge32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsHostTopNRate.setStatus('current')
xsFilter = MibIdentifier((1, 3, 6, 1, 4, 1, 81, 30, 2, 3))
xsHostFilterTable = MibTable((1, 3, 6, 1, 4, 1, 81, 30, 2, 3, 1), )
if mibBuilder.loadTexts: xsHostFilterTable.setStatus('current')
xsHostFilterEntry = MibTableRow((1, 3, 6, 1, 4, 1, 81, 30, 2, 3, 1, 1), ).setIndexNames((0, "SMON2-MIB", "xsHostFilterIpAddress"))
if mibBuilder.loadTexts: xsHostFilterEntry.setStatus('current')
xsHostFilterType = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 3, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("ipHost", 1), ("ipSubnet", 2), ("ipxNet", 3)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: xsHostFilterType.setStatus('current')
xsHostFilterIpAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 3, 1, 1, 2), OctetString()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: xsHostFilterIpAddress.setStatus('current')
xsHostFilterIpSubnet = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 3, 1, 1, 3), OctetString()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: xsHostFilterIpSubnet.setStatus('current')
xsHostFilterIpMask = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 3, 1, 1, 4), OctetString()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: xsHostFilterIpMask.setStatus('current')
xsHostFilterIpxAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 3, 1, 1, 5), OctetString()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: xsHostFilterIpxAddress.setStatus('current')
xsHostFilterStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 3, 1, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 4))).clone(namedValues=NamedValues(("valid", 1), ("invalid", 4)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: xsHostFilterStatus.setStatus('current')
xsHostFilterTableClear = MibScalar((1, 3, 6, 1, 4, 1, 81, 30, 2, 3, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("idle", 1), ("clear", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: xsHostFilterTableClear.setStatus('current')
xsSubnet = MibIdentifier((1, 3, 6, 1, 4, 1, 81, 30, 2, 4))
xsSubnetControlTable = MibTable((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 1), )
if mibBuilder.loadTexts: xsSubnetControlTable.setStatus('current')
xsSubnetControlEntry = MibTableRow((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 1, 1), ).setIndexNames((0, "SMON2-MIB", "xsSubnetControlIndex"))
if mibBuilder.loadTexts: xsSubnetControlEntry.setStatus('current')
xsSubnetControlIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535)))
if mibBuilder.loadTexts: xsSubnetControlIndex.setStatus('current')
xsSubnetControlDataSource = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 1, 1, 2), DataSource()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: xsSubnetControlDataSource.setStatus('current')
xsSubnetControlInserts = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 1, 1, 3), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsSubnetControlInserts.setStatus('current')
xsSubnetControlDeletes = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 1, 1, 4), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsSubnetControlDeletes.setStatus('current')
xsSubnetControlMaxDesiredEntries = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 1, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 2147483647))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: xsSubnetControlMaxDesiredEntries.setStatus('current')
xsSubnetControlOwner = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 1, 1, 6), OwnerString()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: xsSubnetControlOwner.setStatus('current')
xsSubnetControlStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 1, 1, 7), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: xsSubnetControlStatus.setStatus('current')
xsSubnetTable = MibTable((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 2), )
if mibBuilder.loadTexts: xsSubnetTable.setStatus('current')
xsSubnetEntry = MibTableRow((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 2, 1), ).setIndexNames((0, "SMON2-MIB", "xsSubnetControlIndex"), (0, "SMON2-MIB", "xsSubnetTimeMark"), (0, "RMON2-MIB", "protocolDirLocalIndex"), (0, "SMON2-MIB", "xsSubnetAddress"), (0, "SMON2-MIB", "xsSubnetMask"), (0, "RMON2-MIB", "protocolDirLocalIndex"))
if mibBuilder.loadTexts: xsSubnetEntry.setStatus('current')
xsSubnetTimeMark = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 2, 1, 1), TimeFilter())
if mibBuilder.loadTexts: xsSubnetTimeMark.setStatus('current')
xsSubnetAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 2, 1, 2), OctetString())
if mibBuilder.loadTexts: xsSubnetAddress.setStatus('current')
xsSubnetMask = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 2, 1, 3), OctetString())
if mibBuilder.loadTexts: xsSubnetMask.setStatus('current')
xsSubnetInPkts = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 2, 1, 4), ZeroBasedCounter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsSubnetInPkts.setStatus('current')
xsSubnetOutPkts = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 2, 1, 5), ZeroBasedCounter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsSubnetOutPkts.setStatus('current')
xsSubnetCreateTime = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 2, 1, 6), LastCreateTime()).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsSubnetCreateTime.setStatus('current')
xsSubnetMatrixControlTable = MibTable((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 3), )
if mibBuilder.loadTexts: xsSubnetMatrixControlTable.setStatus('current')
xsSubnetMatrixControlEntry = MibTableRow((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 3, 1), ).setIndexNames((0, "SMON2-MIB", "xsSubnetMatrixControlIndex"))
if mibBuilder.loadTexts: xsSubnetMatrixControlEntry.setStatus('current')
xsSubnetMatrixControlIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 3, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535)))
if mibBuilder.loadTexts: xsSubnetMatrixControlIndex.setStatus('current')
xsSubnetMatrixControlDataSource = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 3, 1, 2), DataSource()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: xsSubnetMatrixControlDataSource.setStatus('current')
xsSubnetMatrixControlInserts = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 3, 1, 4), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsSubnetMatrixControlInserts.setStatus('current')
xsSubnetMatrixControlDeletes = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 3, 1, 5), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsSubnetMatrixControlDeletes.setStatus('current')
xsSubnetMatrixControlMaxDesiredEntries = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 3, 1, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 2147483647))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: xsSubnetMatrixControlMaxDesiredEntries.setStatus('current')
xsSubnetMatrixControlOwner = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 3, 1, 7), OwnerString()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: xsSubnetMatrixControlOwner.setStatus('current')
xsSubnetMatrixControlStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 3, 1, 8), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: xsSubnetMatrixControlStatus.setStatus('current')
xsSubnetMatrixSDTable = MibTable((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 4), )
if mibBuilder.loadTexts: xsSubnetMatrixSDTable.setStatus('current')
xsSubnetMatrixSDEntry = MibTableRow((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 4, 1), ).setIndexNames((0, "SMON2-MIB", "xsSubnetMatrixControlIndex"), (0, "SMON2-MIB", "xsSubnetMatrixSDTimeMark"), (0, "RMON2-MIB", "protocolDirLocalIndex"), (0, "SMON2-MIB", "xsSubnetMatrixSDSourceAddress"), (0, "SMON2-MIB", "xsSubnetMatrixSDSourceMask"), (0, "SMON2-MIB", "xsSubnetMatrixSDDestAddress"), (0, "SMON2-MIB", "xsSubnetMatrixSDDestMask"), (0, "RMON2-MIB", "protocolDirLocalIndex"))
if mibBuilder.loadTexts: xsSubnetMatrixSDEntry.setStatus('current')
xsSubnetMatrixSDTimeMark = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 4, 1, 1), TimeFilter())
if mibBuilder.loadTexts: xsSubnetMatrixSDTimeMark.setStatus('current')
xsSubnetMatrixSDSourceAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 4, 1, 2), OctetString())
if mibBuilder.loadTexts: xsSubnetMatrixSDSourceAddress.setStatus('current')
xsSubnetMatrixSDSourceMask = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 4, 1, 3), OctetString())
if mibBuilder.loadTexts: xsSubnetMatrixSDSourceMask.setStatus('current')
xsSubnetMatrixSDDestAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 4, 1, 4), OctetString())
if mibBuilder.loadTexts: xsSubnetMatrixSDDestAddress.setStatus('current')
xsSubnetMatrixSDDestMask = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 4, 1, 5), OctetString())
if mibBuilder.loadTexts: xsSubnetMatrixSDDestMask.setStatus('current')
xsSubnetMatrixSDPkts = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 4, 1, 6), ZeroBasedCounter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsSubnetMatrixSDPkts.setStatus('current')
xsSubnetMatrixSDCreateTime = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 4, 1, 7), LastCreateTime()).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsSubnetMatrixSDCreateTime.setStatus('current')
xsSubnetMatrixDSTable = MibTable((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 5), )
if mibBuilder.loadTexts: xsSubnetMatrixDSTable.setStatus('current')
xsSubnetMatrixDSEntry = MibTableRow((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 5, 1), ).setIndexNames((0, "RMON2-MIB", "hlMatrixControlIndex"), (0, "SMON2-MIB", "xsSubnetMatrixDSTimeMark"), (0, "RMON2-MIB", "protocolDirLocalIndex"), (0, "SMON2-MIB", "xsSubnetMatrixDSDestAddress"), (0, "SMON2-MIB", "xsSubnetMatrixDSDestMask"), (0, "SMON2-MIB", "xsSubnetMatrixDSSourceAddress"), (0, "SMON2-MIB", "xsSubnetMatrixDSSourceMask"), (0, "RMON2-MIB", "protocolDirLocalIndex"))
if mibBuilder.loadTexts: xsSubnetMatrixDSEntry.setStatus('current')
xsSubnetMatrixDSTimeMark = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 5, 1, 1), TimeFilter())
if mibBuilder.loadTexts: xsSubnetMatrixDSTimeMark.setStatus('current')
xsSubnetMatrixDSSourceAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 5, 1, 2), OctetString())
if mibBuilder.loadTexts: xsSubnetMatrixDSSourceAddress.setStatus('current')
xsSubnetMatrixDSSourceMask = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 5, 1, 3), OctetString())
if mibBuilder.loadTexts: xsSubnetMatrixDSSourceMask.setStatus('current')
xsSubnetMatrixDSDestAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 5, 1, 4), OctetString())
if mibBuilder.loadTexts: xsSubnetMatrixDSDestAddress.setStatus('current')
xsSubnetMatrixDSDestMask = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 5, 1, 5), OctetString())
if mibBuilder.loadTexts: xsSubnetMatrixDSDestMask.setStatus('current')
xsSubnetMatrixDSPkts = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 5, 1, 6), ZeroBasedCounter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsSubnetMatrixDSPkts.setStatus('current')
xsSubnetMatrixDSCreateTime = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 4, 5, 1, 7), LastCreateTime()).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsSubnetMatrixDSCreateTime.setStatus('current')
xsNumberOfProtocols = MibScalar((1, 3, 6, 1, 4, 1, 81, 30, 2, 5), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsNumberOfProtocols.setStatus('current')
xsProtocolDistStatsTimeStamp = MibScalar((1, 3, 6, 1, 4, 1, 81, 30, 2, 6), TimeTicks()).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsProtocolDistStatsTimeStamp.setStatus('current')
xsNlHostTimeStamp = MibScalar((1, 3, 6, 1, 4, 1, 81, 30, 2, 7), TimeTicks()).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsNlHostTimeStamp.setStatus('current')
xsSubnetStatsTimeStamp = MibScalar((1, 3, 6, 1, 4, 1, 81, 30, 2, 8), TimeTicks()).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsSubnetStatsTimeStamp.setStatus('current')
xsActiveApplications = MibIdentifier((1, 3, 6, 1, 4, 1, 81, 30, 2, 9))
xsActiveApplicationsBitMask = MibScalar((1, 3, 6, 1, 4, 1, 81, 30, 2, 9, 1), OctetString().subtype(subtypeSpec=ValueSizeConstraint(128, 128)).setFixedLength(128)).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsActiveApplicationsBitMask.setStatus('current')
xsActiveApplicationsTable = MibTable((1, 3, 6, 1, 4, 1, 81, 30, 2, 9, 2), )
if mibBuilder.loadTexts: xsActiveApplicationsTable.setStatus('current')
xsActiveApplicationsEntry = MibTableRow((1, 3, 6, 1, 4, 1, 81, 30, 2, 9, 2, 1), ).setIndexNames((0, "SMON2-MIB", "xsActiveApplicationsIndex"))
if mibBuilder.loadTexts: xsActiveApplicationsEntry.setStatus('current')
xsActiveApplicationsIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 9, 2, 1, 1), Integer32())
if mibBuilder.loadTexts: xsActiveApplicationsIndex.setStatus('current')
xsActiveApplicationsPkts = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 2, 9, 2, 1, 2), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: xsActiveApplicationsPkts.setStatus('current')
xsSmonStatus = MibScalar((1, 3, 6, 1, 4, 1, 81, 30, 2, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("operate", 1), ("paused", 2))).clone('paused')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: xsSmonStatus.setStatus('current')
drSmon = MibIdentifier((1, 3, 6, 1, 4, 1, 81, 30, 4))
drSmonConfiguration = MibIdentifier((1, 3, 6, 1, 4, 1, 81, 30, 4, 1))
drSmonControlTable = MibTable((1, 3, 6, 1, 4, 1, 81, 30, 4, 1, 1), )
if mibBuilder.loadTexts: drSmonControlTable.setStatus('current')
drSmonControlEntry = MibTableRow((1, 3, 6, 1, 4, 1, 81, 30, 4, 1, 1, 1), ).setIndexNames((0, "SMON2-MIB", "drSmonControlModuleID"))
if mibBuilder.loadTexts: drSmonControlEntry.setStatus('current')
drSmonControlModuleID = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 1, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255)))
if mibBuilder.loadTexts: drSmonControlModuleID.setStatus('current')
drSmonControlRowAddressAutoLearnMode = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 1, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 255))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2), ("notSupported", 255)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: drSmonControlRowAddressAutoLearnMode.setStatus('current')
drSmonControlRoutedPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 1, 1, 1, 3), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: drSmonControlRoutedPackets.setStatus('current')
drSmonControlProtocolDistStatsTimeStamp = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 1, 1, 1, 4), TimeTicks()).setMaxAccess("readonly")
if mibBuilder.loadTexts: drSmonControlProtocolDistStatsTimeStamp.setStatus('current')
drSmonControlMatrixRows = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 1, 1, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: drSmonControlMatrixRows.setStatus('current')
drSmonControlMatrixCols = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 1, 1, 1, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: drSmonControlMatrixCols.setStatus('current')
drSmonEntityPlacementTable = MibTable((1, 3, 6, 1, 4, 1, 81, 30, 4, 1, 2), )
if mibBuilder.loadTexts: drSmonEntityPlacementTable.setStatus('current')
drSmonEntityPlacementEntry = MibTableRow((1, 3, 6, 1, 4, 1, 81, 30, 4, 1, 2, 1), ).setIndexNames((0, "SMON2-MIB", "drSmonEntityPlacementModuleID"), (0, "SMON2-MIB", "drSmonEntityPlacementIndex"))
if mibBuilder.loadTexts: drSmonEntityPlacementEntry.setStatus('current')
drSmonEntityPlacementModuleID = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 1, 2, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255)))
if mibBuilder.loadTexts: drSmonEntityPlacementModuleID.setStatus('current')
drSmonEntityPlacementIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 1, 2, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647)))
if mibBuilder.loadTexts: drSmonEntityPlacementIndex.setStatus('current')
drSmonEntityPlacementAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 1, 2, 1, 3), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: drSmonEntityPlacementAddress.setStatus('current')
drSmonEntityPlacementMask = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 1, 2, 1, 4), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: drSmonEntityPlacementMask.setStatus('current')
drSmonEntityPlacementType = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 1, 2, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("empty", 1), ("autoLearn", 2), ("filter", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: drSmonEntityPlacementType.setStatus('current')
drSmonProtocolDir = MibIdentifier((1, 3, 6, 1, 4, 1, 81, 30, 4, 2))
drSmonProtocolDirLCTable = MibTable((1, 3, 6, 1, 4, 1, 81, 30, 4, 2, 1), )
if mibBuilder.loadTexts: drSmonProtocolDirLCTable.setStatus('current')
drSmonProtocolDirLCEntry = MibTableRow((1, 3, 6, 1, 4, 1, 81, 30, 4, 2, 1, 1), ).setIndexNames((0, "SMON2-MIB", "drSmonProtocolDirLCModuleID"))
if mibBuilder.loadTexts: drSmonProtocolDirLCEntry.setStatus('current')
drSmonProtocolDirLCModuleID = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 2, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255)))
if mibBuilder.loadTexts: drSmonProtocolDirLCModuleID.setStatus('current')
drSmonProtocolDirLCLastChange = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 2, 1, 1, 2), TimeStamp()).setMaxAccess("readonly")
if mibBuilder.loadTexts: drSmonProtocolDirLCLastChange.setStatus('current')
drSmonProtocolDirTable = MibTable((1, 3, 6, 1, 4, 1, 81, 30, 4, 2, 2), )
if mibBuilder.loadTexts: drSmonProtocolDirTable.setStatus('current')
drSmonProtocolDirEntry = MibTableRow((1, 3, 6, 1, 4, 1, 81, 30, 4, 2, 2, 1), ).setIndexNames((0, "SMON2-MIB", "drSmonProtocolDirModuleID"), (0, "SMON2-MIB", "drSmonProtocolDirID"), (0, "SMON2-MIB", "drSmonProtocolDirParameters"))
if mibBuilder.loadTexts: drSmonProtocolDirEntry.setStatus('current')
drSmonProtocolDirModuleID = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 2, 2, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255)))
if mibBuilder.loadTexts: drSmonProtocolDirModuleID.setStatus('current')
drSmonProtocolDirID = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 2, 2, 1, 2), OctetString())
if mibBuilder.loadTexts: drSmonProtocolDirID.setStatus('current')
drSmonProtocolDirParameters = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 2, 2, 1, 3), OctetString())
if mibBuilder.loadTexts: drSmonProtocolDirParameters.setStatus('current')
drSmonProtocolDirLocalIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 2, 2, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: drSmonProtocolDirLocalIndex.setStatus('current')
drSmonProtocolDirDescr = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 2, 2, 1, 5), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(1, 64))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: drSmonProtocolDirDescr.setStatus('current')
drSmonProtocolDirType = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 2, 2, 1, 6), Bits().clone(namedValues=NamedValues(("extensible", 0), ("addressRecognitionCapable", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: drSmonProtocolDirType.setStatus('current')
drSmonProtocolDirAddressMapConfig = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 2, 2, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("notSupported", 1), ("supportedOff", 2), ("supportedOn", 3)))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: drSmonProtocolDirAddressMapConfig.setStatus('current')
drSmonProtocolDirHostConfig = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 2, 2, 1, 8), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("notSupported", 1), ("supportedOff", 2), ("supportedOn", 3)))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: drSmonProtocolDirHostConfig.setStatus('current')
drSmonProtocolDirMatrixConfig = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 2, 2, 1, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("notSupported", 1), ("supportedOff", 2), ("supportedOn", 3)))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: drSmonProtocolDirMatrixConfig.setStatus('current')
drSmonProtocolDirOwner = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 2, 2, 1, 10), OwnerString()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: drSmonProtocolDirOwner.setStatus('current')
drSmonProtocolDirStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 2, 2, 1, 11), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: drSmonProtocolDirStatus.setStatus('current')
drSmonFilter = MibIdentifier((1, 3, 6, 1, 4, 1, 81, 30, 4, 3))
drSmonFilterTable = MibTable((1, 3, 6, 1, 4, 1, 81, 30, 4, 3, 1), )
if mibBuilder.loadTexts: drSmonFilterTable.setStatus('current')
drSmonFilterEntry = MibTableRow((1, 3, 6, 1, 4, 1, 81, 30, 4, 3, 1, 1), ).setIndexNames((0, "SMON2-MIB", "drSmonFilterModuleID"), (0, "SMON2-MIB", "drSmonFilterIndex"))
if mibBuilder.loadTexts: drSmonFilterEntry.setStatus('current')
drSmonFilterModuleID = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 3, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255)))
if mibBuilder.loadTexts: drSmonFilterModuleID.setStatus('current')
drSmonFilterIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 3, 1, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647)))
if mibBuilder.loadTexts: drSmonFilterIndex.setStatus('current')
drSmonFilterAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 3, 1, 1, 3), IpAddress()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: drSmonFilterAddress.setStatus('current')
drSmonFilterMask = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 3, 1, 1, 4), IpAddress()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: drSmonFilterMask.setStatus('current')
drSmonFilterStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 3, 1, 1, 5), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: drSmonFilterStatus.setStatus('current')
drSmonActiveApplications = MibIdentifier((1, 3, 6, 1, 4, 1, 81, 30, 4, 4))
drSmonActiveApplicationsTable = MibTable((1, 3, 6, 1, 4, 1, 81, 30, 4, 4, 1), )
if mibBuilder.loadTexts: drSmonActiveApplicationsTable.setStatus('current')
drSmonActiveApplicationsEntry = MibTableRow((1, 3, 6, 1, 4, 1, 81, 30, 4, 4, 1, 1), ).setIndexNames((0, "SMON2-MIB", "drSmonActiveApplicationsModuleID"), (0, "SMON2-MIB", "drSmonActiveApplicationsType"), (0, "SMON2-MIB", "drSmonActiveApplicationsSubType"))
if mibBuilder.loadTexts: drSmonActiveApplicationsEntry.setStatus('current')
drSmonActiveApplicationsModuleID = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 4, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255)))
if mibBuilder.loadTexts: drSmonActiveApplicationsModuleID.setStatus('current')
drSmonActiveApplicationsType = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 4, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("ethertype", 1), ("ipProtocol", 2), ("udpProtocol", 3), ("tcpProtocol", 4))))
if mibBuilder.loadTexts: drSmonActiveApplicationsType.setStatus('current')
drSmonActiveApplicationsSubType = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 4, 1, 1, 3), Integer32())
if mibBuilder.loadTexts: drSmonActiveApplicationsSubType.setStatus('current')
drSmonActiveApplicationsPkts = MibTableColumn((1, 3, 6, 1, 4, 1, 81, 30, 4, 4, 1, 1, 4), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: drSmonActiveApplicationsPkts.setStatus('current')
mibBuilder.exportSymbols("SMON2-MIB", xsSubnetMatrixDSSourceAddress=xsSubnetMatrixDSSourceAddress, xsActiveApplications=xsActiveApplications, drSmonProtocolDir=drSmonProtocolDir, drSmonControlRoutedPackets=drSmonControlRoutedPackets, xsFilter=xsFilter, xsHostTopNControlStatus=xsHostTopNControlStatus, xsSmon=xsSmon, drSmonProtocolDirHostConfig=drSmonProtocolDirHostConfig, drSmonFilter=drSmonFilter, xsSubnetMatrixControlMaxDesiredEntries=xsSubnetMatrixControlMaxDesiredEntries, xsSubnetMatrixDSSourceMask=xsSubnetMatrixDSSourceMask, xsSubnetControlEntry=xsSubnetControlEntry, xsSubnetEntry=xsSubnetEntry, xsSubnetMatrixSDTable=xsSubnetMatrixSDTable, drSmonConfiguration=drSmonConfiguration, drSmonControlMatrixRows=drSmonControlMatrixRows, drSmonProtocolDirStatus=drSmonProtocolDirStatus, xsHostFilterEntry=xsHostFilterEntry, drSmonControlModuleID=drSmonControlModuleID, drSmonEntityPlacementEntry=drSmonEntityPlacementEntry, xsSubnetControlTable=xsSubnetControlTable, drSmonProtocolDirAddressMapConfig=drSmonProtocolDirAddressMapConfig, drSmonActiveApplications=drSmonActiveApplications, drSmonEntityPlacementAddress=drSmonEntityPlacementAddress, xsSubnetControlMaxDesiredEntries=xsSubnetControlMaxDesiredEntries, xsSubnetAddress=xsSubnetAddress, xsSubnetMask=xsSubnetMask, drSmonProtocolDirID=drSmonProtocolDirID, drSmonProtocolDirModuleID=drSmonProtocolDirModuleID, drSmonControlEntry=drSmonControlEntry, drSmonActiveApplicationsSubType=drSmonActiveApplicationsSubType, drSmonEntityPlacementIndex=drSmonEntityPlacementIndex, drSmonProtocolDirMatrixConfig=drSmonProtocolDirMatrixConfig, xsHostTopNControlEntry=xsHostTopNControlEntry, drSmonActiveApplicationsEntry=drSmonActiveApplicationsEntry, drSmonProtocolDirParameters=drSmonProtocolDirParameters, xsSubnetControlOwner=xsSubnetControlOwner, xsSubnetMatrixSDPkts=xsSubnetMatrixSDPkts, drSmonProtocolDirLCLastChange=drSmonProtocolDirLCLastChange, drSmonEntityPlacementTable=drSmonEntityPlacementTable, drSmonControlProtocolDistStatsTimeStamp=drSmonControlProtocolDistStatsTimeStamp, drSmonEntityPlacementModuleID=drSmonEntityPlacementModuleID, xsHostTopNControlTimeRemaining=xsHostTopNControlTimeRemaining, drSmonFilterTable=drSmonFilterTable, drSmonEntityPlacementType=drSmonEntityPlacementType, xsSubnetMatrixControlInserts=xsSubnetMatrixControlInserts, xsHostFilterIpSubnet=xsHostFilterIpSubnet, xsHostTopNControlHostIndex=xsHostTopNControlHostIndex, xsSubnetControlInserts=xsSubnetControlInserts, xsSubnetMatrixSDTimeMark=xsSubnetMatrixSDTimeMark, xsHostFilterTableClear=xsHostFilterTableClear, xsSubnetInPkts=xsSubnetInPkts, xsHostFilterType=xsHostFilterType, drSmon=drSmon, xsHostTopNControlGrantedSize=xsHostTopNControlGrantedSize, xsHostTopNControlRequestedSize=xsHostTopNControlRequestedSize, xsActiveApplicationsEntry=xsActiveApplicationsEntry, drSmonActiveApplicationsTable=drSmonActiveApplicationsTable, drSmonFilterAddress=drSmonFilterAddress, xsHostTopNProtocolDirLocalIndex=xsHostTopNProtocolDirLocalIndex, xsProtocolDistStatsTimeStamp=xsProtocolDistStatsTimeStamp, drSmonFilterModuleID=drSmonFilterModuleID, drSmonControlMatrixCols=drSmonControlMatrixCols, xsSubnetMatrixDSTable=xsSubnetMatrixDSTable, xsHostTopNControlIndex=xsHostTopNControlIndex, xsSubnet=xsSubnet, xsHostTopNControlOwner=xsHostTopNControlOwner, xsSubnetMatrixDSCreateTime=xsSubnetMatrixDSCreateTime, xsHostTopNIndex=xsHostTopNIndex, xsSubnetTimeMark=xsSubnetTimeMark, xsSubnetMatrixDSPkts=xsSubnetMatrixDSPkts, drSmonProtocolDirLCModuleID=drSmonProtocolDirLCModuleID, xsSubnetMatrixSDSourceMask=xsSubnetMatrixSDSourceMask, drSmonProtocolDirLCEntry=drSmonProtocolDirLCEntry, xsHostTopNControlDuration=xsHostTopNControlDuration, drSmonControlRowAddressAutoLearnMode=drSmonControlRowAddressAutoLearnMode, xsSubnetMatrixSDDestAddress=xsSubnetMatrixSDDestAddress, xsSubnetMatrixSDDestMask=xsSubnetMatrixSDDestMask, xsHostTopNNlAddress=xsHostTopNNlAddress, xsSubnetMatrixDSTimeMark=xsSubnetMatrixDSTimeMark, drSmonActiveApplicationsPkts=drSmonActiveApplicationsPkts, drSmonProtocolDirDescr=drSmonProtocolDirDescr, xsHostFilterIpMask=xsHostFilterIpMask, drSmonProtocolDirLocalIndex=drSmonProtocolDirLocalIndex, xsHostFilterStatus=xsHostFilterStatus, xsSubnetMatrixControlEntry=xsSubnetMatrixControlEntry, drSmonEntityPlacementMask=drSmonEntityPlacementMask, xsHostFilterIpxAddress=xsHostFilterIpxAddress, drSmonActiveApplicationsType=drSmonActiveApplicationsType, xsNlHostTimeStamp=xsNlHostTimeStamp, xsSubnetMatrixControlStatus=xsSubnetMatrixControlStatus, xsSubnetMatrixControlDataSource=xsSubnetMatrixControlDataSource, xsHostTopNControlStartTime=xsHostTopNControlStartTime, xsSubnetMatrixControlIndex=xsSubnetMatrixControlIndex, xsSubnetMatrixDSDestMask=xsSubnetMatrixDSDestMask, xsNumberOfProtocols=xsNumberOfProtocols, xsActiveApplicationsBitMask=xsActiveApplicationsBitMask, xsActiveApplicationsIndex=xsActiveApplicationsIndex, xsHostTopNEntry=xsHostTopNEntry, drSmonProtocolDirTable=drSmonProtocolDirTable, xsSubnetControlStatus=xsSubnetControlStatus, xsSubnetMatrixControlOwner=xsSubnetMatrixControlOwner, xsSubnetMatrixControlTable=xsSubnetMatrixControlTable, xsSmonStatus=xsSmonStatus, xsSubnetControlIndex=xsSubnetControlIndex, drSmonFilterEntry=drSmonFilterEntry, drSmonProtocolDirEntry=drSmonProtocolDirEntry, drSmonFilterStatus=drSmonFilterStatus, xsHostTopN=xsHostTopN, xsSubnetControlDataSource=xsSubnetControlDataSource, xsSmonResourceAllocation=xsSmonResourceAllocation, drSmonProtocolDirLCTable=drSmonProtocolDirLCTable, drSmonFilterIndex=drSmonFilterIndex, xsSubnetMatrixSDSourceAddress=xsSubnetMatrixSDSourceAddress, xsSubnetMatrixSDCreateTime=xsSubnetMatrixSDCreateTime, xsHostTopNRate=xsHostTopNRate, xsHostFilterIpAddress=xsHostFilterIpAddress, xsSubnetOutPkts=xsSubnetOutPkts, xsSubnetMatrixControlDeletes=xsSubnetMatrixControlDeletes, drSmonProtocolDirOwner=drSmonProtocolDirOwner, xsSubnetMatrixDSDestAddress=xsSubnetMatrixDSDestAddress, xsSubnetControlDeletes=xsSubnetControlDeletes, xsSubnetCreateTime=xsSubnetCreateTime, xsActiveApplicationsTable=xsActiveApplicationsTable, drSmonControlTable=drSmonControlTable, xsHostTopNTable=xsHostTopNTable, drSmonProtocolDirType=drSmonProtocolDirType, drSmonActiveApplicationsModuleID=drSmonActiveApplicationsModuleID, xsSubnetTable=xsSubnetTable, drSmonFilterMask=drSmonFilterMask, xsActiveApplicationsPkts=xsActiveApplicationsPkts, xsSubnetStatsTimeStamp=xsSubnetStatsTimeStamp, xsSubnetMatrixDSEntry=xsSubnetMatrixDSEntry, xsHostTopNControlRateBase=xsHostTopNControlRateBase, xsSubnetMatrixSDEntry=xsSubnetMatrixSDEntry, xsHostFilterTable=xsHostFilterTable, xsHostTopNControlTable=xsHostTopNControlTable)
|
delta_vector = [(1, 0), (0, -1), (-1, 0), (0, 1)]
current_east_pos = 0
current_north_pos = 0
current_delta = 0
for _ in range(747):
instruction = input()
movement = instruction[0]
value = int(instruction[1:])
if movement == 'N':
current_north_pos += value
if movement == 'S':
current_north_pos -= value
if movement == 'E':
current_east_pos += value
if movement == 'W':
current_east_pos -= value
if movement == 'L':
current_delta = (current_delta - (value // 90)) % 4
if movement == 'R':
current_delta = (current_delta + (value // 90)) % 4
if movement == 'F':
current_east_pos += delta_vector[current_delta][0] * value
current_north_pos += delta_vector[current_delta][1] * value
manhattan_distance = abs(current_east_pos) + abs(current_north_pos)
print(manhattan_distance)
|
"""
Creating some co-ordinates with nested loops.
Output will be something like
(0,1)
(0,2)
(0,3)
(1,0)
(1,1) and so on.
"""
#Initiationg the loop
for x in range(3):
for y in range(3):
print(f"({x}, {y})")
|
# input
n = int(input())
cont1 = int(input())
conttot = 1
# grafo
contador = 0
g = [[0 for i in range(n)] for j in range(n)]
lista = input().split()
for col in range(n):
for linha in range(n):
g[col][linha] = int(lista[contador])
contador += 1
if col == linha:
g[col][linha] = 0
# Lista De Contaminados
contaminados = []
contaminados.append(cont1)
# Descobrindo Contaminados
for linha in range(n):
if g[cont1][linha] == 1:
contaminados.append(linha)
g[cont1][linha] = 0
conttot += 1
while True:
for y in range(n):
if g[linha][y] == 1 and y != cont1 and linha not in contaminados:
contaminados.append(linha)
conttot += 1
print(conttot)
|
class gbXMLConditionType(Enum,IComparable,IFormattable,IConvertible):
"""
This enumeration corresponds to the conditionType attribute in gbXML.
The enumerated attribute identifies the type of heating,cooling,
or ventilation the space has.
enum gbXMLConditionType,values: Cooled (1),Heated (0),HeatedAndCooled (2),NaturallyVentedOnly (5),NoConditionType (-1),NoOfConditionTypes (6),Unconditioned (3),Vented (4)
"""
def __eq__(self,*args):
""" x.__eq__(y) <==> x==yx.__eq__(y) <==> x==yx.__eq__(y) <==> x==y """
pass
def __format__(self,*args):
""" __format__(formattable: IFormattable,format: str) -> str """
pass
def __ge__(self,*args):
pass
def __gt__(self,*args):
pass
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
def __le__(self,*args):
pass
def __lt__(self,*args):
pass
def __ne__(self,*args):
pass
def __reduce_ex__(self,*args):
pass
def __str__(self,*args):
pass
Cooled=None
Heated=None
HeatedAndCooled=None
NaturallyVentedOnly=None
NoConditionType=None
NoOfConditionTypes=None
Unconditioned=None
value__=None
Vented=None
|
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def maxDepth(self, root):
"""
:type root: TreeNode
:rtype: int
"""
if root is None:
return 0
current_level, depth = [root], 0
while current_level:
next_level = []
while current_level:
top = current_level.pop()
if top.left:
next_level.append(top.left)
if top.right:
next_level.append(top.right)
current_level = next_level
depth += 1
return depth
|
with open("Actions.txt") as f:
print(f)
lines = f.readlines()
trim_list = list(map(lambda line: line.strip(), lines))
sig = "-- HERE --"
sig_indx = trim_list.index(sig)
pure_inst = trim_list[sig_indx:]
print(pure_inst)
res = []
for p in pure_inst:
split = p.split(" ", 1)
if split[0].isdigit():
res.append(split[1])
print(res)
|
# Contains dictionaries that map braille to English letters.
letters = {chr(10241): 'a',
chr(10243): 'b',
chr(10249): 'c',
chr(10265): 'd',
chr(10257): 'e',
chr(10251): 'f',
chr(10267): 'g',
chr(10259): 'h',
chr(10250): 'i',
chr(10266): 'j',
chr(10245): 'k',
chr(10247): 'l',
chr(10253): 'm',
chr(10269): 'n',
chr(10261): 'o',
chr(10255): 'p',
chr(10271): 'q',
chr(10263): 'r',
chr(10254): 's',
chr(10270): 't',
chr(10277): 'u',
chr(10279): 'v',
chr(10298): 'w',
chr(10285): 'x',
chr(10301): 'y',
chr(10293): 'z'}
contractions = {chr(10243): 'but',
chr(10249): 'can',
chr(10265): 'do',
chr(10257): 'every',
chr(10251): 'from',
chr(10267): 'go',
chr(10259): 'have',
chr(10266): 'just',
chr(10280): 'knowledge',
chr(10296): 'like',
chr(10253): 'more',
chr(10269): 'not',
chr(10255): 'people',
chr(10271): 'quite',
chr(10263): 'rather',
chr(10254): 'so',
chr(10270): 'that',
chr(10277): 'us',
chr(10279): 'very',
chr(10285): 'it',
chr(10301): 'you',
chr(10293): 'as',
chr(10287): 'and',
chr(10303): 'for',
chr(10295): 'of',
chr(10286): 'the',
chr(10302): 'with',
chr(10298): 'will',
chr(10278): 'his',
chr(10260): 'in',
chr(10292): 'was',
chr(10262): 'to'}
punctuation = {chr(10242): ',',
chr(10246): ';',
chr(10258): ':',
chr(10290): '.',
chr(10262): '!',
chr(10294): '()',
chr(10278): '“',
chr(10292): '”',
chr(10252): '/',
chr(10300): '#',
chr(10244): '\'',
chr(10276): '-'}
numbers = {chr(10241): '1',
chr(10243): '2',
chr(10249): '3',
chr(10265): '4',
chr(10257): '5',
chr(10251): '6',
chr(10267): '7',
chr(10259): '8',
chr(10250): '9',
chr(10266): '0'}
|
c = int()
def hanoi(discs, main, target, aux):
global c
if discs >= 1:
c = c + 1
hanoi(discs - 1, main, aux, target)
print("[{}] -> Move disc {} from {} to {}".format(c, discs, main, target))
hanoi(discs - 1, aux, target, main)
if __name__ == "__main__":
discs = int(input())
hanoi(discs, "main", "target", "aux")
|
passagemAreiaDiurno=19
passagemAreiaNoturno=24
passagemPilarNoturno=26
passagemPilarDiurno=22
destino=str(input('digite o destino: ')).upper()
horario=str(input('digite se o horário é diurno ou noturno: ')).upper()
idade=int(input('digite sua idade: '))
if destino=='AREIA':
if horario=='DIURNO':
print('o valor a ser pago é {}'.format(passagemAreiaDiurno))
else:
print('o valor a ser pago é {}'.format(passagemAreiaNoturno))
else:
if horario=='DIURNO':
if idade==10 or idade==65:
print('o valor a ser pago é {}'.format(passagemPilarDiurno/2))
else:
print('o valor a ser pago é {}'.format(passagemPilarDiurno))
else:
if idade==10 or idade==65:
print('o valor a ser pago é {}'.format(passagemPilarNoturno/2))
else:
print('o valor a ser pago é {}'.format(passagemPilarNoturno))
print()
|
def f():
def g():
pass
if __name__ == '__main__':
g()
print(1)
f()
|
lst = [int(x) for x in input().split()]
k = int(input())
lst.sort()
print(lst[-k], end="")
|
n,k=map(int,input().split());a=[int(i) for i in input().split()];m=sum(a[:k]);s=m
for i in range(k,n):
s+=(a[i]-a[i-k])
if s>m:m=s
print(m)
|
with open("day-02/input.txt", "r") as file:
puzzle_input = [i.split() for i in file.readlines()]
def part_1(puzzle_input):
depth = 0
horizontal = 0
for command, value in puzzle_input:
value = int(value)
if command == "forward":
horizontal += value
elif command == "up":
depth -= value
elif command == "down":
depth += value
return depth * horizontal
def part_2(puzzle_input):
aim = 0
depth = 0
horizontal = 0
for command, value in puzzle_input:
value = int(value)
if command == "forward":
horizontal += value
depth += aim * value
elif command == "up":
aim -= value
elif command == "down":
aim += value
return depth * horizontal
print(part_1(puzzle_input))
print(part_2(puzzle_input))
|
obj = {
'Profiles' : [ {
'Source' : 'sfmc_sg10004_programmes_genrelevel1fan548day_oc_uas_dae',
'Media': ['audio','video'],
'Preferences' : [ {
'Score' : 1,
'Label' : 'Religion & Ethics'
}, {
'Score' : 4,
'Label' : 'Entertainment'
}, {
'Score' : 5,
'Label' : 'Music'
}, {
'Score' : 5,
'Label' : 'Comedy'
}, {
'Score' : 5,
'Label' : 'News'
}, {
'Score' : 4,
'Label' : 'Drama'
}, {
'Score' : 1,
'Label' : 'Learning'
}, {
'Score' : 5,
'Label' : 'Factual'
}, {
'Score' : 5,
'Label' : 'Sport'
} ]
}, {
'Source' : 'sfmc_sg10004a_programmes_genrelevel1fan548day_oc_uas_dae',
'Media': ['audio'],
'Preferences' : [ {
'Score' : 4,
'Label' : 'News'
}, {
'Score' : 2,
'Label' : 'Sport'
}, {
'Score' : 1,
'Label' : 'Religion & Ethics'
}, {
'Score' : 1,
'Label' : 'Learning'
}, {
'Score' : 5,
'Label' : 'Music'
}, {
'Score' : 5,
'Label' : 'Comedy'
}, {
'Score' : 1,
'Label' : 'Entertainment'
}, {
'Score' : 5,
'Label' : 'Factual'
}, {
'Score' : 2,
'Label' : 'Drama'
} ]
}, {
'Source' : 'sfmc_sg10004v_programmes_genrelevel1fan548day_oc_uas_dae',
'Media': ['video'],
'Preferences' : [ {
'Score' : 2,
'Label' : 'Entertainment'
}, {
'Score' : 5,
'Label' : 'Music'
}, {
'Score' : 1,
'Label' : 'Comedy'
}, {
'Score' : 4,
'Label' : 'Drama'
}, {
'Score' : 2,
'Label' : 'News'
}, {
'Score' : 5,
'Label' : 'Factual'
}, {
'Score' : 5,
'Label' : 'Sport'
} ]
}, {
'Source' : 'sfmc_sg10005_programmes_genrelevel2fan548day_oc_uas_dae',
'Media': ['audio','video'],
'Preferences' : [ {
'Score' : 2,
'Label' : 'Comedy-Sitcoms'
}, {
'Score' : 2,
'Label' : 'Comedy-Music'
}, {
'Score' : 5,
'Label' : 'Factual-null'
}, {
'Score' : 5,
'Label' : 'Factual-Politics'
}, {
'Score' : 1,
'Label' : 'Music-Dance & Electronica'
}, {
'Score' : 1,
'Label' : 'Entertainment-null'
}, {
'Score' : 5,
'Label' : 'Music-Easy Listening, Soundtracks & Musicals'
}, {
'Score' : 1,
'Label' : 'Music-Folk'
}, {
'Score' : 5,
'Label' : 'Factual-Arts, Culture & the Media'
}, {
'Score' : 1,
'Label' : 'Religion & Ethics-null'
}, {
'Score' : 5,
'Label' : 'Music-Pop & Chart'
}, {
'Score' : 2,
'Label' : 'Sport-Cricket'
}, {
'Score' : 5,
'Label' : 'Music-Classical'
}, {
'Score' : 4,
'Label' : 'News-null'
}, {
'Score' : 5,
'Label' : 'Music-null'
}, {
'Score' : 2,
'Label' : 'Comedy-Standup'
}, {
'Score' : 5,
'Label' : 'Factual-Life Stories'
}, {
'Score' : 4,
'Label' : 'Music-Rock & Indie'
}, {
'Score' : 1,
'Label' : 'Comedy-Satire'
}, {
'Score' : 1,
'Label' : 'Factual-Science & Nature'
}, {
'Score' : 1,
'Label' : 'Music-Hip Hop, RnB & Dancehall'
}, {
'Score' : 5,
'Label' : 'Music-Classic Pop & Rock'
}, {
'Score' : 1,
'Label' : 'Drama-Biographical'
}, {
'Score' : 2,
'Label' : 'Factual-History'
}, {
'Score' : 1,
'Label' : 'Factual-Rock & Indie'
}, {
'Score' : 1,
'Label' : 'Drama-null'
}, {
'Score' : 4,
'Label' : 'Comedy-null'
}, {
'Score' : 2,
'Label' : 'Drama-Soaps'
}, {
'Score' : 1,
'Label' : 'Drama-SciFi & Fantasy'
}, {
'Score' : 1,
'Label' : 'Factual-Health & Wellbeing'
}, {
'Score' : 2,
'Label' : 'Comedy-Impressionists'
}, {
'Score' : 1,
'Label' : 'Comedy-Character'
}, {
'Score' : 1,
'Label' : 'Factual-Travel'
}, {
'Score' : 1,
'Label' : 'Learning-Adults'
} ]
}, {
'Source' : 'sfmc_sg10006_products_productfanpageviews548day_oc_cs_dae',
'Media': [],
'Preferences' : [ {
'Score' : 5,
'Label' : 'iplayerradio'
}, {
'Score' : 5,
'Label' : 'ideas'
}, {
'Score' : 5,
'Label' : 'aboutthebbc'
}, {
'Score' : 1,
'Label' : 'newsbeat'
}, {
'Score' : 4,
'Label' : 'kl-bitesize'
}, {
'Score' : 3,
'Label' : 'cbeebies'
}, {
'Score' : 5,
'Label' : 'news-v2-nonws'
}, {
'Score' : 5,
'Label' : 'weather'
}, {
'Score' : 5,
'Label' : 'homepageandsearch'
}, {
'Score' : 3,
'Label' : 'news-v2-ws'
}, {
'Score' : 5,
'Label' : 'tvandiplayer'
}, {
'Score' : 5,
'Label' : 'sport'
}, {
'Score' : 3,
'Label' : 'bbcthree'
}, {
'Score' : 5,
'Label' : 'music'
}, {
'Score' : 5,
'Label' : 'kl-iwonder'
}, {
'Score' : 5,
'Label' : 'news'
}, {
'Score' : 4,
'Label' : 'cbbc'
} ]
} ]
}
|
def kb_ids2known_facts(kb_ids):
"""
:param kb_ids: a knowledge base of facts that are already mapped to ids
:return: a set of all known facts (used later for negative sampling)
"""
facts = set()
for struct in kb_ids:
arrays = kb_ids[struct][0]
num_facts = len(arrays[0])
for i in range(num_facts):
fact = [x[i] for x in arrays]
facts.add(tuple(fact))
return facts
|
"""
1025. Divisor Game
Easy
Alice and Bob take turns playing a game, with Alice starting first.
Initially, there is a number N on the chalkboard. On each player's turn, that player makes a move consisting of:
Choosing any x with 0 < x < N and N % x == 0.
Replacing the number N on the chalkboard with N - x.
Also, if a player cannot make a move, they lose the game.
Return True if and only if Alice wins the game, assuming both players play optimally.
Example 1:
Input: 2
Output: true
Explanation: Alice chooses 1, and Bob has no more moves.
Example 2:
Input: 3
Output: false
Explanation: Alice chooses 1, Bob chooses 1, and Alice has no more moves.
Note:
1 <= N <= 1000
"""
class Solution:
def divisorGame(self, N: int) -> bool:
return N % 2 == 0
|
'''
Created on 05.03.2018
@author: Alex
'''
class ImageSorterException(Exception):
pass
|
# Copyright 2017 OpenStack Foundation
# 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.
# Define supported virtual NIC types. VNIC_TYPE_DIRECT and VNIC_TYPE_MACVTAP
# are used for SR-IOV ports
VNIC_TYPE_NORMAL = 'normal'
VNIC_TYPE_DIRECT = 'direct'
VNIC_TYPE_MACVTAP = 'macvtap'
VNIC_TYPE_DIRECT_PHYSICAL = 'direct-physical'
VNIC_TYPE_BAREMETAL = 'baremetal'
VNIC_TYPE_VIRTIO_FORWARDER = 'virtio-forwarder'
# Define list of ports which needs pci request.
# Note: The macvtap port needs a PCI request as it is a tap interface
# with VF as the lower physical interface.
# Note: Currently, VNIC_TYPE_VIRTIO_FORWARDER assumes a 1:1
# relationship with a VF. This is expected to change in the future.
VNIC_TYPES_SRIOV = (VNIC_TYPE_DIRECT, VNIC_TYPE_MACVTAP,
VNIC_TYPE_DIRECT_PHYSICAL, VNIC_TYPE_VIRTIO_FORWARDER)
# Define list of ports which are passthrough to the guest
# and need a special treatment on snapshot and suspend/resume
VNIC_TYPES_DIRECT_PASSTHROUGH = (VNIC_TYPE_DIRECT,
VNIC_TYPE_DIRECT_PHYSICAL)
|
# coding=utf-8
"""
Some utilities related to numbers.
"""
def is_even(num: int) -> bool:
"""Is num even?
:param num: number to check.
:type num: int
:returns: True if num is even.
:rtype: bool
:raises: ``TypeError`` if num is not an int.
"""
if not isinstance(num, int):
raise TypeError("{} is not an int".format(num))
return num % 2 == 0
def is_odd(num: int) -> bool:
"""Is num odd?
:param num: number to check.
:type num: int
:returns: True if num is odd.
:rtype: bool
:raises: ``TypeError`` if num is not an int.
"""
if not isinstance(num, int):
raise TypeError("{} is not an int".format(num))
return num % 2 == 1
|
# writing a function to find the maximum and minmimum integer in a list
numbers = []
while True:
inp = (input('Please enter a number: '))
if inp == 'done!':
break
try:
val = int(inp)
except:
print('Invalid input')
print('Please provide a number')
continue
numbers.append(val)
print(numbers)
# the problem with this loop is this would not work when creating a loop for smallest
"""
largest = 0
for i in numbers:
print('Before the largest is: ', largest, i)
if i > largest:
largest = i
"""
largest = None
for i in numbers:
if largest is None or i > largest:
largest = i
"""
smallest = 0
for i in numbers:
print('Before the smallest is: ', smallest, i)
if i < smallest:
smallest = i
else:
smallest = smallest
"""
smallest = None
for i in numbers:
if smallest is None or i < smallest:
smallest = i
print('After the loop, largest: ', largest)
print('After the loop, smallest: ', smallest)
|
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def pathSum(self, root: TreeNode, sum: int) -> int:
if not root:
return 0
return self.dfs(root, sum) + self.pathSum(root.left, sum) + self.pathSum(root.right, sum)
def dfs(self, root, sum):
# 要特判为空,否则下面 sum == root.val 会报错
if not root:
return 0
res = 0
if sum == root.val:
res += 1
res += self.dfs(root.left, sum - root.val)
res += self.dfs(root.right, sum - root.val)
return res
|
class Animal:
nombre: str
edad: int
nPatas: int
raza: str
ruido: str
color: str
def __init__(self, nombre, edad, nPatas, raza, ruido, color):
self.nombre = nombre
self.edad = edad
self.nPatas = nPatas
self.raza = raza
self.ruido = ruido
self.color = color
def hacerRuido(self):
print(self.ruido)
def comer(self):
print(f'El animal va a comer')
|
n1 = int(input('Um valor: '))
n2 = int(input('Outro valor: '))
soma = n1+n2
produto = n1*n2
quociente = n1/n2
resto = n1%n2
div_exata = n1//n2
potencia = n1**n2
print('A soma é {} \nO produto é {} \nO quociente é {} \nO resto é {} \nA divisão exata é {} \nA potência é {}'
.format(soma, produto, quociente, resto, div_exata, potencia))
|
# This file is part of the Pygame SGE.
#
# The Pygame SGE is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# The Pygame SGE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with the Pygame SGE. If not, see <http://www.gnu.org/licenses/>.
"""
This module provides input event classes. Input event objects are used
to consolidate all necessary information about input events in a clean
way.
You normally don't need to use input event objects directly. Input
events are handled automatically in each frame of the SGE's main loop.
You only need to use input event objects directly if you take control
away from the SGE's main loop, e.g. to create your own loop.
"""
__all__ = ["KeyPress", "KeyRelease", "MouseMove", "MouseButtonPress",
"MouseButtonRelease", "JoystickAxisMove", "JoystickHatMove",
"JoystickTrackballMove", "JoystickButtonPress",
"JoystickButtonRelease", "JoystickEvent", "KeyboardFocusGain",
"KeyboardFocusLose", "MouseFocusGain", "MouseFocusLose",
"QuitRequest"]
class KeyPress:
"""
This input event represents a key on the keyboard being pressed.
.. attribute:: key
The identifier string of the key that was pressed. See the
table in the documentation for :mod:`sge.keyboard`.
.. attribute:: char
The unicode string associated with the key press, or an empty
unicode string if no text is associated with the key press.
See the table in the documentation for :mod:`sge.keyboard`.
"""
def __init__(self, key, char):
self.key = key
self.char = char
class KeyRelease:
"""
This input event represents a key on the keyboard being released.
.. attribute:: key
The identifier string of the key that was released. See the
table in the documentation for :class:`sge.input.KeyPress`.
"""
def __init__(self, key):
self.key = key
class MouseMove:
"""
This input event represents the mouse being moved.
.. attribute:: x
The horizontal relative movement of the mouse.
.. attribute:: y
The vertical relative movement of the mouse.
"""
def __init__(self, x, y):
self.x = x
self.y = y
class MouseButtonPress:
"""
This input event represents a mouse button being pressed.
.. attribute:: button
The identifier string of the mouse button that was pressed. See
the table below.
====================== =================
Mouse Button Name Identifier String
====================== =================
Left mouse button ``"left"``
Right mouse button ``"right"``
Middle mouse button ``"middle"``
Extra mouse button 1 ``"extra1"``
Extra mouse button 2 ``"extra2"``
====================== =================
"""
def __init__(self, button):
self.button = button
class MouseButtonRelease:
"""
This input event represents a mouse button being released.
.. attribute:: button
The identifier string of the mouse button that was released. See
the table in the documentation for
:class:`sge.input.MouseButtonPress`.
"""
def __init__(self, button):
self.button = button
class MouseWheelMove:
"""
This input event represents a mouse wheel moving.
.. attribute:: x
The horizontal scroll amount, where ``-1`` is to the left, ``1``
is to the right, and ``0`` is no horizontal scrolling.
.. attribute:: y
The vertical scroll amount, where ``-1`` is up, ``1`` is down,
and ``0`` is no vertical scrolling.
"""
def __init__(self, x, y):
self.x = x
self.y = y
class JoystickAxisMove:
"""
This input event represents a joystick axis moving.
.. attribute:: js_name
The name of the joystick.
.. attribute:: js_id
The number of the joystick, where ``0`` is the first joystick.
.. attribute:: axis
The number of the axis that moved, where ``0`` is the first axis
on the joystick.
.. attribute:: value
The tilt of the axis as a float from ``-1`` to ``1``, where ``0``
is centered, ``-1`` is all the way to the left or up, and ``1``
is all the way to the right or down.
"""
def __init__(self, js_name, js_id, axis, value):
self.js_name = js_name
self.js_id = js_id
self.axis = axis
self.value = max(-1.0, min(value, 1.0))
class JoystickHatMove:
"""
This input event represents a joystick hat moving.
.. attribute:: js_name
The name of the joystick.
.. attribute:: js_id
The number of the joystick, where ``0`` is the first joystick.
.. attribute:: hat
The number of the hat that moved, where ``0`` is the first axis
on the joystick.
.. attribute:: x
The horizontal position of the hat, where ``0`` is centered,
``-1`` is left, and ``1`` is right.
.. attribute:: y
The vertical position of the hat, where ``0`` is centered, ``-1``
is up, and ``1`` is down.
"""
def __init__(self, js_name, js_id, hat, x, y):
self.js_name = js_name
self.js_id = js_id
self.hat = hat
self.x = x
self.y = y
class JoystickTrackballMove:
"""
This input event represents a joystick trackball moving.
.. attribute:: js_name
The name of the joystick.
.. attribute:: js_id
The number of the joystick, where ``0`` is the first joystick.
.. attribute:: ball
The number of the trackball that moved, where ``0`` is the first
trackball on the joystick.
.. attribute:: x
The horizontal relative movement of the trackball.
.. attribute:: y
The vertical relative movement of the trackball.
"""
def __init__(self, js_name, js_id, ball, x, y):
self.js_name = js_name
self.js_id = js_id
self.ball = ball
self.x = x
self.y = y
class JoystickButtonPress:
"""
This input event represents a joystick button being pressed.
.. attribute:: js_name
The name of the joystick.
.. attribute:: js_id
The number of the joystick, where ``0`` is the first joystick.
.. attribute:: button
The number of the button that was pressed, where ``0`` is the
first button on the joystick.
"""
def __init__(self, js_name, js_id, button):
self.js_name = js_name
self.js_id = js_id
self.button = button
class JoystickButtonRelease:
"""
This input event represents a joystick button being released.
.. attribute:: js_name
The name of the joystick.
.. attribute:: js_id
The number of the joystick, where ``0`` is the first joystick.
.. attribute:: button
The number of the button that was released, where ``0`` is the
first button on the joystick.
"""
def __init__(self, js_name, js_id, button):
self.js_name = js_name
self.js_id = js_id
self.button = button
class JoystickEvent:
"""
This input event represents the movement of any joystick input.
This makes it possible to treat all joystick inputs the same way,
which can be used to simplify things like control customization.
.. attribute:: js_name
The name of the joystick.
.. attribute:: js_id
The number of the joystick, where ``0`` is the first joystick.
.. attribute:: input_type
The type of joystick control that was moved. Can be one of the
following:
- ``"axis-"`` -- The tilt of a joystick axis to the left or up
changes.
- ``"axis+"`` -- The tilt of a joystick axis to the right or down
changes.
- ``"axis0"`` -- The tilt of a joystick axis changes.
- ``"hat_left"`` -- Whether or not a joystick hat's position is
to the left changes.
- ``"hat_right"`` -- Whether or not a joystick hat's position is
to the right changes.
- ``"hat_center_x"`` -- Whether or not a joystick hat is
horizontally centered changes.
- ``"hat_up"`` -- Whether or not a joystick hat's position is up
changes.
- ``"hat_down"`` -- Whether or not a joystick hat's position is
down changes.
- ``"hat_center_y"`` -- Whether or not a joystick hat is
vertically centered changes.
- ``"trackball_left"`` -- A joystick trackball is moved left.
- ``"trackball_right"`` -- A joystick trackball is moved right.
- ``"trackball_up"`` -- A joystick trackball is moved up.
- ``"trackball_down"`` -- A joystick trackball is moved down.
- ``"button"`` -- Whether or not a joystick button is pressed
changes.
.. attribute:: input_id
The number of the joystick control that was moved, where ``0`` is
the first control of its type on the joystick.
.. attribute:: value
The value of the event, which is different depending on the value
of :attr:`input_type`. If :attr:`input_type` is
``"trackball_left"``, ``"trackball_right"``, ``"trackball_up"``,
or ``"trackball_down"``, this is the relative movement of the
trackball in the respective direction. Otherwise, this is the
new value of the respective control. See the documentation for
:func:`sge.joystick.get_value` for more information.
"""
def __init__(self, js_name, js_id, input_type, input_id, value):
self.js_name = js_name
self.js_id = js_id
self.input_type = input_type
self.input_id = input_id
self.value = value
class KeyboardFocusGain:
"""
This input event represents the game window gaining keyboard focus.
Keyboard focus is normally needed for keyboard input to be received.
.. note::
On some window systems, such as the one used by Windows, no
distinction is made between keyboard and mouse focus, but on
some other window systems, such as the X Window System, a
distinction is made: one window can have keyboard focus while
another has mouse focus. Be careful to observe the
difference; failing to do so may result in annoying bugs,
and you won't notice these bugs if you are testing on a
window manager that doesn't recognize the difference.
"""
class KeyboardFocusLose:
"""
This input event represents the game window losing keyboard focus.
Keyboard focus is normally needed for keyboard input to be received.
.. note::
See the note in the documentation for
:class:`sge.input.KeyboardFocusGain`.
"""
class MouseFocusGain:
"""
This input event represents the game window gaining mouse focus.
Mouse focus is normally needed for mouse input to be received.
.. note::
See the note in the documentation for
:class:`sge.input.KeyboardFocusGain`.
"""
class MouseFocusLose:
"""
This input event represents the game window losing mouse focus.
Mouse focus is normally needed for mouse input to be received.
.. note::
See the note in the documentation for
:class:`sge.input.KeyboardFocusGain`.
"""
class WindowResize:
"""
This input event represents the player resizing the window.
"""
class QuitRequest:
"""
This input event represents the OS requesting for the program to
close (e.g. when the user presses a "close" button on the window
border).
"""
|
# lab 1
# дан целочисленный массив А из N элементов. проверьте,
# есть ли в нем элементы, равные нулю. если есть, найдите
# номер первого из них, т. е. наименьшее i, при котором
# элемент ai = 0.
if __name__ == '__main__':
lists = [
[1, 2, 3, 4],
[4, 5, 1, 0, 22],
[0, 1, 2],
[42, 1, 2],
[5, 2, 0],
]
for arr in lists:
try:
print(f'index of zero element is: {arr.index(0)}')
except ValueError:
print(f'{arr} does not have zero')
|
"""
solution Adventofcode 2019 day 4 part 1.
https://adventofcode.com/2019/day/4
author: pca
"""
def valid_pw(pw_str: int) -> bool:
has_double = False
if len(pw_str) != 6:
return False
max_digit = 0
prev_digit = -1
for ch in pw_str:
cur_digit = int(ch)
# decreasing
if cur_digit < max_digit:
return False
else:
max_digit = cur_digit
if cur_digit == prev_digit:
has_double = True
prev_digit = cur_digit
return has_double
def main(args=None):
puzzle_input = [int(ch) for ch in '245318-765747'.split('-')]
cnt = 0
for val in range(puzzle_input[0], puzzle_input[1]):
if valid_pw(str(val)):
cnt += 1
print(cnt)
if __name__ == "__main__":
main()
|
#A function to show the list of trait with categorial data
def categorial_trait(dataframe):
numeric, categorial = classifying_column(dataframe)
print('Traits with categorial data : ','\n',categorial, '\n')
print('Total count : ' ,len(categorial) , 'Traits')
|
ENDC = '\033[0m'
OKGREEN = '\033[92m'
def print_play_my_playlist(playlist_name, name_song, artist, total_time, prefix, bar, percent, suffix):
print("\033[F"*13)
print(
f'{playlist_name} | {name_song} | {artist} | {total_time[:7]}',
f'{prefix}|{OKGREEN}{bar}{ENDC}|{percent[:7]} {suffix}',
f'',
f'p : Pause',
f'l : Play',
f'+ / - : Volume',
f's : Shuffle',
f'n : Next Song',
f'b : Previous Song',
f'x : exit',
f'',
f'',
sep="\n"
)
def print_play_one_song(name_song, artist, total_time, prefix, bar, percent, suffix):
print("\033[F"*13)
print(
f'{name_song} | {artist} | {total_time[:7]}',
f'{prefix}|{OKGREEN}{bar}{ENDC}|{percent[:7]} {suffix}',
f'',
f'p : Pause',
f'l : Play',
f'+ : Up Volume',
f'- : Down Volume',
f'r : Add to a playlist',
f'x : exit',
f'',
f'',
f'',
sep="\n"
)
def print_play_playlist(playlist_name, name_song, artist, total_time, prefix, bar, percent, suffix):
print("\033[F"*13)
print(
f'{playlist_name} | {name_song} | {artist} | {total_time[:7]}',
f'{prefix}|{OKGREEN}{bar}{ENDC}|{percent[:7]} {suffix}',
f'',
f'p : Pause',
f'l : Play',
f'+ / - : Volume',
f's : Shuffle',
f'n : Next Song',
f'b : Previous Song',
f'a : Follow this playlist',
f'x : exit',
f'',
sep="\n"
)
|
"""
Constants
"""
MONGO_DOCKER_SERVICE = "db"
MONGO_HOST = "192.168.99.100"
MONGO_PORT = 27017
RABBIT_DOCKER_SERVICE = "rabbit"
RABBIT_HOST = "192.168.99.100"
RABBIT_PORT = 5672
|
"""
texto = [x for x in input("Input: ") if x in "{}[]()"]
if len(texto) % 2 != 0 or len(texto) == 0:
validacion = False
else:
validacion = True
i = 0
while 0 < len(texto) and validacion == "YES":
if texto[i] in "{[(":
i += 1
else:
if texto[i - 1] + texto[i] in '{}' or \
texto[i - 1] + texto[i] in '[]' or \
texto[i - 1] + texto[i] in '()':
texto = texto[:i - 1] + texto[i + 1:]
i -= 1
else:
validacion = False
print(validacion)
"""
"""
def validacion(texto):
lista = list(texto)
comprobacion = []
contador1 = lista.count('(')
contador2 = lista.count(')')
if contador1 != contador2:
return False
else:
for i in lista:
if i == "(":
comprobacion.append(i)
elif i == ")" and len(comprobacion) > 0:
comprobacion.pop()
if len(comprobacion) == 0:
return True
def main():
ingreso = input("Input: ")
print(validacion(ingreso))
main()
"""
"""
#EL MEJOR
def main():
print(
(
lambda expr, stack: all(
len(stack) == 0 if char is None else
stack.append(char) or True if char in '([{' else
len(stack) > 0 and {'(': ')', '[': ']', '{': '}'}[stack.pop()] == char if char in ')]}' else
True
for char in expr
)
)(
list(input("Input: ")) + [None], []
)
)
main()
"""
#easy
def es_valida(texto):
def validacion(izq,der):
if izq=='[' and der==']':
return True
if izq=='{' and der=='}':
return True
if izq=='(' and der==')':
return True
return False
lista=[]
for i in range(len(texto)):
if texto[i]=='[' or texto[i]=='{' or texto[i]=='(':
lista.append(texto[i])
elif texto[i] == ']' or texto[i] == '}' or texto[i] == ')':
if validacion(lista[-1],texto[i] or len(lista)!=0):
lista.pop()
else:
return False
if len(lista)==0:
return True
else:
return False
def main():
text = input("Input: ")
print(es_valida(text))
main()
|
# -*- coding: utf-8 -*-
"""
pyglobi.config
~~~~~~~~~~~~
Configuration used by pyglobi
:copyright: (c) 2019 by Chris Nicholas.
:license: MIT, see LICENSE for more details.
"""
# Base URL's
globi_neo_url = "https://neo4j.globalbioticinteractions.org/db/data/cypher"
eol_url = "https://eol.org/pages"
eol_geo_url = "https://eol.org/data/map_data_dwca"
|
class Stock():
def __init__(self,code,name,price):
self.code = code
self.name = name
self.price = price
def __str__(self):
return 'code{},name{},price{}'.format(self.code,self.name,self.price)
|
"""Convert a Decimal Number to a Binary Number."""
def decimal_to_binary(decimal: int) -> str:
rem , bin , c = 0 , 0 , 0
is_negative = '-' if decimal < 0 else ''
decimal = abs(decimal)
while decimal > 0:
rem = decimal % 2
bin += rem * pow(10 , c)
c += 1
decimal //= 2
return f'{is_negative}0b{bin}'
def decimal_to_binary_v2(decimal: int) ->str:
if not isinstance(decimal , int):
raise TypeError("You must enter integer value")
if decimal == 0:
return '0b0'
is_negative = False
if decimal < 0:
is_negative = True
decimal = -decimal
binary: list[int] = []
while decimal > 0:
binary.insert(0 , decimal % 2)
decimal >>= 1 # or num //= 2
if is_negative:
return '-0b' + ''.join( str(n) for n in binary )
else:
return '0b' + ''.join( str(n) for n in binary )
def binary_recursive(decimal: int) ->str:
if decimal in (0 , 1):
return str(decimal)
div , mod = divmod(decimal , 2)
return binary_recursive(div) + str(mod)
if __name__ == '__main__':
print( decimal_to_binary(-900) )
print( binary_recursive(900) )
print( decimal_to_binary_v2(-900) )
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Объявите функцию, которая возвращает переданную ей строку в нижнем регистре (с
# малыми буквами). Определите декоратор для этой функции, который имеет один параметр
# tag , определяющий строку с названием тега (начальное значение параметра tag равно
# h1 ). Этот декоратор должен заключать возвращенную функцией строку в тег tag и
# возвращать результат. Пример заключения строки "python" в тег h1: <h1>python</h1> .
# Примените декоратор со значением tag="div" к функции и вызовите декорированную
# функцию. Результат отобразите на экране.
def wrap(teg):
def wraper(function):
def gift_wrap(*args, **kwargs):
print("<", teg, function(*args, **kwargs), "</", teg, sep='')
return gift_wrap
return wraper
@wrap("div>")
def gift(something):
return(something.lower())
if __name__ == '__main__':
gift("HI")
|
line = input().split()
a = int(line[0])
b = int(line[1])
hour = 0
total = a
burned = 0
while(total > 0):
total -= 1
burned += 1
if(burned % b == 0):
total += 1
hour += 1
print(str(hour))
|
class Solution(object):
def merge(self, intervals):
"""
:type intervals: List[List[int]]
:rtype: List[List[int]]
"""
length = len(intervals)
if length == 0 or not intervals[0]:
return intervals
intervals = sorted(intervals, key=lambda x: x[0])
op = []
tmp = intervals[0]
for i in range(1, length):
if intervals[i][0] > tmp[1]:
op.append(tmp)
tmp = intervals[i]
else:
tmp = [tmp[0], max(tmp[1], intervals[i][1])]
op.append(tmp)
return op
|
# coding=utf-8
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
class Export:
def __init__(self, export: dict):
self.id = export.get("id")
self.display_name = export.get("displayName")
self.enabled = export.get("enabled")
self.source = export.get("source")
self.filter = export.get("filter")
self.destinations = export.get("destinations")
self.errors = export.get("errors")
self.status = export.get("status")
self.enrichment = export.get("enrichments")
|
text = 2
try:
print(text)
except NameError as error:
print("NameError - Esse nome não existe:", error)
except Exception as error:
print("Exception - Vixi:", error)
else:
text +=1
print("Else:", text)
finally:
text = []
print("Finally:", text)
print("Fora do bloco!")
|
# -*- coding: utf-8 -*-
"""
Resource module
"""
# pylint: disable=too-few-public-methods
class Resource:
"""
Used for representing Conjur resources
"""
def __init__(self, type_:type, name:str):
self.type = type_
self.name = name
def full_id(self):
"""
Method for building the full resource ID in the format 'user:someuser' for example
"""
return f"{self.type}:{self.name}"
def __eq__(self, other):
"""
Method for comparing resources by their values and not by reference
"""
return self.type == other.type and self.name == other.name
def __repr__(self):
return f"'type': '{self.type}', 'name': '{self.name}'"
|
__package__ = 'tkgeom'
__title__ = 'tkgeom'
__description__ = '2D geometry module as an example for the TK workshop'
__copyright__ = '2019, Zs. Elter'
__version__ = '1.0.0'
|
'''
Copyright (c) 2014, Aaron Westendorf All rights reserved.
https://github.com/agoragames/pluto/blob/master/LICENSE.txt
'''
|
def id(message):
# Define empty variables
fu_userid = False
rt_userid = False
rf_userid = False
gp_groupid = False
# the 'From User' data
fu_username = message.from_user.username
fu_userid = message.from_user.id
fu_fullname = message.from_user.first_name.encode("utf-8")
# check for 'Replied to' message
if message.reply_to_message:
# the 'Replied To' data
rt_userid = message.reply_to_message.from_user.id
rt_fullname = message.reply_to_message.from_user.first_name.encode("utf-8")
rt_username = message.reply_to_message.from_user.username
if message.reply_to_message.forward_from:
# the 'Replied to, Forwarded' data
rf_userid = message.reply_to_message.forward_from.id
rf_fullname = message.reply_to_message.forward_from.first_name.encode("utf-8")
rf_username = message.reply_to_message.forward_from.username
if "group" in message.chat.type:
# the 'Group' data
gp_groupid = message.chat.id
gp_fullname = message.chat.title.encode("utf-8")
# Send message
text = "<code>Your data:</code> \n- <b>Username:</b> @{0}\n- <b>Full name:</b> {1}\n- <b>UserID:</b> {2}".format(fu_username, fu_fullname, fu_userid)
if rt_userid:
text = text + "\n\n<code>Replied-to-message data:</code> \n- <b>It's username:</b> @{0}\n- <b>It's fullname:</b> {1}\n- <b>Its userID:</b> {2}".format(rt_username, rt_fullname, rt_userid)
if rf_userid:
text = text + "\n\n<code>Replied-to-forwarded-message data:</code> \n- <b>It's username:</b> @{0}\n- <b>It's fullname:</b> {1}\n- <b>Its userID:</b> {2}".format(rf_username, rf_fullname, rf_userid)
if gp_groupid:
text = text + "\n\n<code>Group data:</code> \n- <b>Group's title:</b> {1}\n- <b>Group's ID:</b> {0}".format(gp_groupid, gp_fullname)
bot.send_message(message.chat.id, text, parse_mode="HTML")
class plid:
patterns=["^[/!]id(.*)$"]
|
txt = "banana"
x = txt.ljust(20)
print(x, "is my favorite fruit.")
|
class Solution:
def count_l(self, a_list: list):
a, b = a_list
return a*a + b*b
def kClosest(self, points, K):
"""
:type points: List[List[int]]
:type K: int
:rtype: List[List[int]]
"""
m = list()
tmp = dict()
for point in points:
l = self.count_l(point)
if not tmp.get(l):
m.append(l)
tmp[l] = [point]
else:
tmp[l].append(point)
m.sort()
res = []
for x in m:
if len(res) == K:
break
for a in tmp[x]:
res.append(a)
if len(res) == K:
break
return res
if __name__ == '__main__':
s = Solution()
print(s.kClosest(points = [[1,3],[-2,2]], K = 1))
|
pkgname = "gnome-menus"
pkgver = "3.36.0"
pkgrel = 0
build_style = "gnu_configure"
configure_args = ["--disable-static"]
make_cmd = "gmake"
hostmakedepends = [
"gmake", "pkgconf", "gobject-introspection", "glib-devel", "gettext-tiny"
]
makedepends = ["libglib-devel"]
pkgdesc = "GNOME menu definitions"
maintainer = "q66 <q66@chimera-linux.org>"
license = "GPL-2.0-or-later AND LGPL-2.0-or-later"
url = "https://gitlab.gnome.org/GNOME/gnome-menus"
source = f"$(GNOME_SITE)/{pkgname}/{pkgver[:-2]}/{pkgname}-{pkgver}.tar.xz"
sha256 = "d9348f38bde956fc32753b28c1cde19c175bfdbf1f4d5b06003b3aa09153bb1f"
@subpackage("gnome-menus-devel")
def _devel(self):
return self.default_devel()
|
#!/usr/bin/env python3
class BaseError(Exception):
def __init__(self, message):
self.message = message
class LoggedOutError(BaseError):
def __init__(self):
super(LoggedOutError, self).__init__("User is currently not logged In")
# self.message = "User is currently not logged In"
class LoginExpiredError(BaseError):
def __init__(self):
super(LoginExpiredError, self).__init__("User's logged has expired")
class LoginRevokedError(BaseError):
def __init__(self):
super(LoginRevokedError, self).__init__(
"User's logged access has been revoked")
class InvalidReviewerPositionError(BaseError):
def __init__(self):
message = (
"The position of the reviewer you provided is not "
"allowed to review payment voucher at this review stage"
)
super(InvalidReviewerPositionError, self).__init__(message)
class DeletedReviewerError(BaseError):
def __init__(self):
message = (
"The reviewer you selected has been deleted so they can't be "
"selected as a reviewer for any payment vouchers"
)
super(DeletedReviewerError, self).__init__(message)
class ReviewerNotFoundError(BaseError):
def __init__(self):
message = (
"The reviewer you selected doesn't exist check and try again"
)
super(ReviewerNotFoundError, self).__init__(message)
class InvalidReviewerError(BaseError):
def __init__(self):
message = (
"Reviewer is not authorized to review this payment voucher"
)
super(InvalidReviewerError, self).__init__(message)
class EndPaymentReviewProcessError(BaseError):
def __init__(self):
message = (
"Payment voucher has reach the end of the review process. "
"So you might want to pay or reject the payment"
)
super(EndPaymentReviewProcessError, self).__init__(message)
class InvalidVoucherStageError(BaseError):
def __init__(self, message):
super(InvalidVoucherStageError, self).__init__(message)
class InvalidPayingOfficer(BaseError):
def __init__(self):
super(InvalidPayingOfficer, self).__init__(
'You are not the authorized cashier for this transaction')
|
# Copyright 2019 The TensorFlow 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.
# ==============================================================================
"""Config to train MobileNet."""
MOBILENET_CFG = {
'use_tpu': True,
'train_batch_size': 1024,
'train_steps': 8000000,
'eval_batch_size': 1024,
'iterations_per_loop': 100,
'num_cores': 8,
'eval_total_size': 0,
'train_steps_per_eval': 2000,
'min_eval_interval': 180,
'learning_rate': 0.165,
'depth_multiplier': 1.0,
'optimizer': 'RMS',
'num_classes': 1001,
'use_fused_batchnorm': True,
'moving_average': True,
'learning_rate_decay': 0.94,
'learning_rate_decay_epochs': 3,
'use_logits': True,
'clear_update_collections': True,
'transpose_enabled': False,
'serving_image_size': 224,
'post_quantize': True,
'num_train_images': 1281167,
'num_eval_images': 50000,
}
MOBILENET_RESTRICTIONS = [
]
|
pkgname = "python-py"
pkgver = "1.11.0"
pkgrel = 0
build_style = "python_module"
hostmakedepends = ["python-setuptools_scm"]
checkdepends = ["python-pytest"]
depends = ["python"]
pkgdesc = "Python development support library"
maintainer = "q66 <q66@chimera-linux.org>"
license = "MIT"
url = "https://github.com/pytest-dev/py"
source = f"$(PYPI_SITE)/p/py/py-{pkgver}.tar.gz"
sha256 = "51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"
# dependency of pytest
options = ["!check"]
def post_install(self):
self.install_license("LICENSE")
|
test_input = """35
20
15
25
47
40
62
55
65
95
102
117
150
182
127
219
299
277
309
576
"""
def find_number(numbers, preamble_size):
for number_index in range(preamble_size, len(numbers)):
number = numbers[number_index]
breaked = False
start = number_index - preamble_size
for first_number_index in range(start, start + preamble_size):
for second_number_index in range(first_number_index + 1, start + preamble_size):
first = int(numbers[first_number_index])
second = int(numbers[second_number_index])
# print(f"{first} + {second} == {number} {first+second}")
if (first + second == int(number)):
breaked = True
break
if breaked:
break
if not breaked:
print(f"Did not find a pattern for {number}")
return number
def find_number_set(numbers, number_to_find):
found_first_number_index = 0
found_second_number_index = 0
for number_index in range(0, len(numbers)):
breaked = False
start = number_index
for first_number_index in range(start, len(numbers)-1):
total = int(numbers[first_number_index])
for second_number_index in range(first_number_index + 1, len(numbers)):
total += int(numbers[second_number_index])
if total == int(number_to_find):
found_first_number_index = first_number_index
found_second_number_index = second_number_index
#print(f"{total} == {number_to_find}")
breaked = True
break
elif total > int(number_to_find):
breaked = False
break
if breaked:
break
if breaked:
# print(
# f"{found_first_number_index} {found_second_number_index} {number}")
return (found_first_number_index, found_second_number_index)
return (0, 0)
def find_crypt_weakness(input, start_index, end_index):
numbers = []
total = 0
for index in range(start_index, end_index + 1):
total += int(input[index])
numbers.append(int(input[index]))
print(total)
numbers.sort()
return int(numbers[0]) + int(numbers[-1])
number = find_number(test_input.splitlines(), 5)
(start_index, end_index) = find_number_set(test_input.splitlines(), number)
weakness = find_crypt_weakness(test_input.splitlines(), start_index, end_index)
print(weakness)
with open("input.txt", "r") as file:
input = file.readlines()
number = find_number(input, 25)
(start_index, end_index) = find_number_set(input, number)
weakness = find_crypt_weakness(input, start_index, end_index)
print(weakness)
|
class Entrada:
quantidade_de_recursos = 3
quantidade_de_processos = 5
# coluna recurso alocados + qntd recurso disponível
quantidade_total_de_cada_recurso = [10, 5, 7]
matriz_de_recursos_ja_alocados = [
[0, 1, 0],
[2, 0, 0],
[3, 0, 2],
[2, 1, 1],
[0, 0, 2]
]
matriz_de_recursos_solicitados_por_cada_processo = [ # Max - qntd recurso alocado por processo
[7, 4, 3],
[1, 2, 2],
[6, 0, 0],
[0, 1, 1],
[4, 10, 1]
]
|
n = int(input())
nums = list(map(int, input().strip().split()))
print(min(nums) * max(nums))
|
line = Line()
line.xValues = [2, 1, 3, 4, 0]
line.yValues = [2, 1, 3, 4, 0]
plot = Plot()
plot.add(line)
plot.save("unordered.png")
|
'''
Created on Oct 31, 2013/.>"
@author: rgeorgi
'''
class TextParser(object):
'''
classdocs
'''
def parse(self):
pass
def __init__(self):
'''
Constructor
'''
class ParserException(Exception):
pass
|
# -*- coding: utf-8 -*-
"""
999. Available Captures for Rook
On an 8 x 8 chessboard, there is one white rook. There also may be empty squares, white bishops, and black pawns.
These are given as characters 'R', '.', 'B', and 'p' respectively.
Uppercase characters represent white pieces, and lowercase characters represent black pieces.
The rook moves as in the rules of Chess: it chooses one of four cardinal directions (north, east, west, and south),
then moves in that direction until it chooses to stop, reaches the edge of the board,
or captures an opposite colored pawn by moving to the same square it occupies.
Also, rooks cannot move into the same square as other friendly bishops.
Return the number of pawns the rook can capture in one move.
Note:
board.length == board[i].length == 8
board[i][j] is either 'R', '.', 'B', or 'p'
There is exactly one cell with board[i][j] == 'R'
"""
class Solution:
def numRookCaptures(self, board) -> int:
res = 0
for r_ind, row in enumerate(board):
try:
c_ind = row.index("R")
except ValueError:
continue
# left
cur_c = c_ind - 1
while cur_c >= 0:
if row[cur_c] == ".":
pass
else:
if row[cur_c] == "p":
res += 1
break
cur_c -= 1
# right
cur_c = c_ind + 1
while cur_c <= 7:
if row[cur_c] == ".":
pass
else:
if row[cur_c] == "p":
res += 1
break
cur_c += 1
# up
cur_r = r_ind - 1
while cur_r >= 0:
if board[cur_r][c_ind] == ".":
pass
else:
if board[cur_r][c_ind] == "p":
res += 1
break
cur_r -= 1
# down
cur_r = r_ind + 1
while cur_r <= 7:
if board[cur_r][c_ind] == ".":
pass
else:
if board[cur_r][c_ind] == "p":
res += 1
break
cur_r += 1
return res
|
class UIColors:
"color indices for UI (c64 original) palette"
white = 2
lightgrey = 16
medgrey = 13
darkgrey = 12
black = 1
yellow = 8
red = 3
brightred = 11
|
# Time: O (N ^ 2) | Space: O(N)
def arrayOfProducts(array):
output = []
for i in range(len(array)):
product = 1
for j in range(len(array)):
if i != j:
product = product * array[j]
output.append(product)
return output
# Time: O(N) | Space: O(N)
def arrayOfProductsN(array):
left = [1 for i in range(len(array))]
right = [1 for i in range(len(array))]
output = [1 for i in range(len(array))]
prodL = 1
prodR = 1
idx = len(array) - 1
# Make left product array
for i in range(len(array)):
left[i] = prodL
prodL = prodL * array[i]
# Make right product array
while idx >= 0:
right[idx] = prodR
prodR = prodR * array[idx]
idx -= 1
# Merge
for i in range(len(array)):
output[i] = left[i] * right[i]
return output
|
# -*- coding = utf-8 -*-
# @Time:2021/2/2821:58
# @Author:Linyu
# @Software:PyCharm
def response(flow):
print(flow.request.url)
print(flow.response.text)
|
# example of how to display octal and hexa values
a = 0o25
b = 0x1af
print('Value of a in decimal is ', a)
c = 19
print('19 in octal is %o and in hex is %x' % (c, c))
d = oct(c)
e = hex(c)
print('19 in octal is', d, ' and in hex is ', e)
|
states_in_order_of_founding = ("Delaware", "Pennsylvania", "New Jersey", "Georgia")
# You use parentheses instead of square brackets.
print(states_in_order_of_founding)
second_state_founded = states_in_order_of_founding[1]
print("The second state founded was " + second_state_founded)
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
nitram_micro_mono_CP437 = [
0, 0, 0, 0, 0,
10, 0, 4, 17, 14,
10, 0, 0, 14, 17,
27, 31, 31, 14, 4,
0, 0, 0, 0, 0,
0, 4, 10, 4, 14,
4, 14, 14, 4, 14,
0, 14, 14, 14, 0,
0, 0, 0, 0, 0,
0, 4, 10, 4, 0,
0, 0, 0, 0, 0,
30, 28, 31, 21, 7,
5, 13, 31, 12, 4,
20, 22, 31, 6, 4,
15, 10, 10, 10, 5,
21, 14, 27, 14, 21,
4, 12, 28, 12, 4,
4, 6, 7, 6, 4,
4, 14, 4, 14, 4,
10, 10, 10, 0, 10,
12, 11, 10, 10, 10,
0, 0, 0, 0, 0,
0, 0, 0, 31, 31,
0, 0, 0, 0, 0,
4, 14, 21, 4, 4,
4, 4, 21, 14, 4,
4, 8, 31, 8, 4,
4, 2, 31, 2, 4,
0, 2, 2, 30, 0,
0, 14, 14, 14, 0,
4, 14, 31, 0, 0,
0, 0, 31, 14, 4,
0, 0, 0, 0, 0,
4, 4, 4, 0, 4,
10, 10, 0, 0, 0,
10, 31, 10, 31, 10,
31, 5, 31, 20, 31,
17, 8, 4, 2, 17,
6, 9, 22, 9, 22,
8, 4, 0, 0, 0,
8, 4, 4, 4, 8,
2, 4, 4, 4, 2,
21, 14, 31, 14, 21,
0, 4, 14, 4, 0,
0, 0, 0, 4, 2,
0, 0, 14, 0, 0,
0, 0, 0, 0, 2,
8, 4, 4, 4, 2,
14, 25, 21, 19, 14,
4, 6, 4, 4, 14,
14, 8, 14, 2, 14,
14, 8, 12, 8, 14,
2, 2, 10, 14, 8,
14, 2, 14, 8, 14,
6, 2, 14, 10, 14,
14, 8, 12, 8, 8,
14, 10, 14, 10, 14,
14, 10, 14, 8, 14,
0, 4, 0, 4, 0,
0, 4, 0, 4, 2,
8, 4, 2, 4, 8,
0, 14, 0, 14, 0,
2, 4, 8, 4, 2,
14, 17, 12, 0, 4,
14, 9, 5, 1, 14,
6, 9, 17, 31, 17,
7, 9, 15, 17, 15,
14, 17, 1, 17, 14,
15, 25, 17, 17, 15,
31, 1, 15, 1, 31,
31, 1, 15, 1, 1,
14, 1, 25, 17, 14,
9, 17, 31, 17, 17,
14, 4, 4, 4, 14,
12, 8, 8, 10, 14,
9, 5, 3, 5, 9,
1, 1, 1, 1, 15,
17, 27, 21, 17, 17,
17, 19, 21, 25, 17,
14, 25, 17, 17, 14,
7, 9, 7, 1, 1,
14, 17, 17, 25, 30,
7, 9, 7, 5, 9,
30, 1, 14, 16, 15,
31, 4, 4, 4, 4,
9, 17, 17, 17, 14,
10, 10, 10, 10, 4,
9, 17, 21, 21, 10,
17, 10, 4, 10, 17,
17, 10, 4, 4, 4,
31, 8, 4, 2, 31,
12, 4, 4, 4, 12,
2, 4, 4, 4, 8,
6, 4, 4, 4, 6,
4, 10, 0, 0, 0,
0, 0, 0, 0, 14,
4, 8, 0, 0, 0,
6, 9, 17, 31, 17,
7, 9, 15, 17, 15,
14, 17, 1, 17, 14,
15, 25, 17, 17, 15,
31, 1, 15, 1, 31,
31, 1, 15, 1, 1,
14, 1, 25, 17, 14,
9, 17, 31, 17, 17,
14, 4, 4, 4, 14,
12, 8, 8, 10, 14,
18, 10, 6, 10, 18,
1, 1, 1, 1, 15,
17, 27, 21, 17, 17,
17, 19, 21, 25, 17,
14, 25, 17, 17, 14,
7, 9, 7, 1, 1,
14, 17, 17, 25, 30,
7, 9, 7, 5, 9,
30, 1, 14, 16, 15,
31, 4, 4, 4, 4,
9, 17, 17, 17, 14,
10, 10, 10, 10, 4,
9, 17, 21, 21, 10,
17, 10, 4, 10, 17,
17, 10, 4, 4, 4,
31, 8, 4, 2, 31,
12, 4, 2, 4, 12,
4, 4, 4, 4, 4,
6, 4, 8, 4, 6,
10, 5, 0, 0, 0,
0, 4, 10, 10, 14,
0, 0, 0, 0, 0,
10, 0, 10, 10, 14,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
10, 0, 14, 10, 30,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
31, 17, 17, 17, 31,
0, 14, 10, 14, 0,
0, 0, 4, 0, 0,
0, 0, 0, 0, 0,
0, 0, 4, 0, 0,
0, 14, 10, 14, 0,
0, 0, 0, 0, 0,
10, 0, 14, 10, 30,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
10, 0, 14, 10, 14,
0, 0, 0, 0, 0,
3, 25, 11, 9, 11,
28, 23, 21, 21, 29,
0, 3, 1, 1, 1,
10, 0, 14, 10, 14,
10, 0, 10, 10, 14,
0, 0, 0, 0, 31,
0, 0, 0, 0, 0,
0, 0, 0, 0, 31,
0, 0, 0, 0, 0,
0, 0, 0, 0, 31,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
4, 0, 6, 17, 14,
0, 0, 28, 4, 4,
0, 0, 7, 4, 4,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
4, 0, 4, 4, 4,
4, 18, 9, 18, 4,
4, 9, 18, 9, 4,
0, 10, 0, 10, 0,
10, 21, 10, 21, 10,
21, 10, 21, 10, 21,
4, 4, 4, 4, 4,
4, 4, 7, 4, 4,
4, 7, 4, 7, 4,
10, 10, 11, 10, 10,
0, 0, 15, 10, 10,
0, 7, 4, 7, 4,
10, 11, 8, 11, 10,
10, 10, 10, 10, 10,
0, 15, 8, 11, 10,
10, 11, 8, 15, 0,
10, 10, 15, 0, 0,
4, 7, 4, 7, 0,
0, 0, 7, 4, 4,
4, 4, 28, 0, 0,
4, 4, 31, 0, 0,
0, 0, 31, 4, 4,
4, 4, 28, 4, 4,
0, 0, 31, 0, 0,
4, 4, 31, 4, 4,
4, 28, 4, 28, 4,
10, 10, 26, 10, 10,
10, 26, 2, 30, 0,
0, 30, 2, 26, 10,
10, 27, 0, 31, 0,
0, 31, 0, 27, 10,
10, 26, 2, 26, 10,
0, 31, 0, 31, 0,
10, 27, 0, 27, 10,
4, 31, 0, 31, 0,
10, 10, 31, 0, 0,
0, 31, 0, 31, 4,
0, 0, 31, 10, 10,
10, 10, 30, 0, 0,
4, 28, 4, 28, 0,
0, 28, 4, 28, 4,
0, 0, 30, 10, 10,
10, 10, 31, 10, 10,
4, 31, 4, 31, 4,
4, 4, 7, 0, 0,
0, 0, 28, 4, 4,
31, 31, 31, 31, 31,
0, 0, 31, 31, 31,
3, 3, 3, 3, 3,
24, 24, 24, 24, 24,
31, 31, 31, 0, 0,
0, 0, 0, 0, 0,
6, 9, 13, 17, 13,
0, 0, 0, 0, 0,
14, 17, 17, 17, 14,
0, 4, 10, 4, 0,
0, 0, 4, 0, 0,
0, 0, 0, 0, 0,
0, 0, 4, 0, 0,
0, 4, 10, 4, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 14, 31, 14, 0,
16, 14, 10, 14, 1,
12, 2, 14, 2, 12,
6, 9, 9, 9, 9,
14, 0, 14, 0, 14,
4, 14, 4, 0, 14,
2, 4, 8, 4, 14,
8, 4, 2, 4, 14,
8, 20, 4, 4, 4,
4, 4, 4, 5, 2,
4, 0, 14, 0, 4,
10, 5, 0, 10, 5,
4, 14, 4, 0, 0,
0, 14, 14, 14, 0,
0, 0, 4, 0, 0,
24, 8, 11, 10, 4,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0
]
|
def is_same_string(string1, string2):
if len(string1) != len(string2):
return False
else:
for i in range(len(string1)):
if string1[i] != string2[i]:
return False
return True
def reverse_string(string):
gnirts = ''
for i in range(len(string)):
gnirts += string[-1-i]
return gnirts
def is_palindrome(string):
gnirts = reverse_string(string)
return(is_same_string(string, gnirts))
n = 0
for i in range(100, 1000):
for j in range(i, 1000):
if is_palindrome(str(i*j)) and i*j > n:
n = i*j
print(n)
|
class AccessKeyEventArgs(EventArgs):
""" Provides information for access keys events. """
IsMultiple=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets a value that indicates whether other elements are invoked by the key.
Get: IsMultiple(self: AccessKeyEventArgs) -> bool
"""
Key=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets the access keys that was pressed.
Get: Key(self: AccessKeyEventArgs) -> str
"""
|
class PretreatedQuery:
'''
DBpedia resultat
'''
def __init__(self, mentions_list, detected_ne):
'''
Constructor
'''
self.mentions_list=mentions_list
self.detected_ne=detected_ne
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.