content
stringlengths 7
1.05M
| fixed_cases
stringlengths 1
1.28M
|
|---|---|
pm = sm.getChr().getPotentialMan()
pm.addPotential(pm.generateRandomPotential(1))
sm.completeQuestNoRewards(12394)
sm.dispose()
|
pm = sm.getChr().getPotentialMan()
pm.addPotential(pm.generateRandomPotential(1))
sm.completeQuestNoRewards(12394)
sm.dispose()
|
class UpdateIpExclusionObject:
def __init__(self, filterIp, ipFilterId):
self.filterIp = filterIp
self.ipFilterId = ipFilterId
self.memo = None
|
class Updateipexclusionobject:
def __init__(self, filterIp, ipFilterId):
self.filterIp = filterIp
self.ipFilterId = ipFilterId
self.memo = None
|
class PsKeyCode:
def __init__(self):
pass
def keycode_in_alpha_upper(self, code):
return 65 <= code <= 90
def keycode_in_alpha_lower(self, code):
return 97 <= code <= 122
def keycode_in_alpha(self, code):
return self.keycode_in_alpha_lower(
code
) or self.keycode_in_alpha_upper(code)
def keycode_in_num_neg(self, code):
return self.keycode_in_pure_num(code) or self.keycode_in_hyphen(code)
def keycode_in_num_float(self, code):
return self.keycode_in_pure_num(code) or self.keycode_in_dot(code)
def keycode_in_pure_num(self, code):
return 48 <= code <= 57
def keycode_in_num(self, code):
return (
self.keycode_in_pure_num(code)
or self.keycode_in_hyphen(code)
or self.keycode_in_dot(code)
)
def keycode_in_dot(self, code):
return code == 46
def keycode_in_alpha_num(self, code):
return self.keycode_in_num(code) or self.keycode_in_alpha(code)
def keycode_in_space(self, code):
return code == 32
def keycode_in_hyphen(self, code):
return code == 45
def keycode_in_return(self, code):
return code == 0xD
|
class Pskeycode:
def __init__(self):
pass
def keycode_in_alpha_upper(self, code):
return 65 <= code <= 90
def keycode_in_alpha_lower(self, code):
return 97 <= code <= 122
def keycode_in_alpha(self, code):
return self.keycode_in_alpha_lower(code) or self.keycode_in_alpha_upper(code)
def keycode_in_num_neg(self, code):
return self.keycode_in_pure_num(code) or self.keycode_in_hyphen(code)
def keycode_in_num_float(self, code):
return self.keycode_in_pure_num(code) or self.keycode_in_dot(code)
def keycode_in_pure_num(self, code):
return 48 <= code <= 57
def keycode_in_num(self, code):
return self.keycode_in_pure_num(code) or self.keycode_in_hyphen(code) or self.keycode_in_dot(code)
def keycode_in_dot(self, code):
return code == 46
def keycode_in_alpha_num(self, code):
return self.keycode_in_num(code) or self.keycode_in_alpha(code)
def keycode_in_space(self, code):
return code == 32
def keycode_in_hyphen(self, code):
return code == 45
def keycode_in_return(self, code):
return code == 13
|
def get_grandma(clause_atom, api):
"""Return a wayyiqtol/yiqtol/imperative from a clause tree.
Recursively climbs up a clause's ancestorial tree.
Stops upon identifying either wayyiqtol
or a yiqtol|impv grand(mother).
Returns:
a string of the ancestor's tense, or None.
"""
F, E, L = api.F, api.E, api.L
this_verb = next((F.vt.v(w) for w in L.d(clause_atom) if F.pdp.v(w)=='verb'), '')
mother = next((m for m in E.mother.f(clause_atom)), 0)
mom_verb = next((F.vt.v(w) for w in L.d(mother) if F.pdp.v(w)=='verb'), '')
if mom_verb in {'wayq', 'impf', 'impv'}:
return mom_verb
elif not mother:
return this_verb
else:
return get_grandma(mother, api)
def convert_tense(word, api):
"""Convert weqatal tenses where present.
If not weqatal, return the tense.
"""
F, L = api.F, api.L
tense_map = {
'impf': 'yqtl',
'perf': 'qtl',
'wayq': 'wyqtl',
}
tense = F.vt.v(word)
# check for weqatal
if tense == 'perf' and F.lex.v(word-1) == 'W':
# get tense of the ancestor of the verb's clause
clause = L.u(word, 'clause_atom')[0]
qatal_ancestor = get_grandma(clause, api)
# check for whether ancestor triggers weqatal analysis
if qatal_ancestor in {'impf', 'impv'}:
return 'wqtl' # change tense to weqt
else:
return tense_map.get(tense, tense)
# return tense as-is
else:
return tense_map.get(tense, tense)
|
def get_grandma(clause_atom, api):
"""Return a wayyiqtol/yiqtol/imperative from a clause tree.
Recursively climbs up a clause's ancestorial tree.
Stops upon identifying either wayyiqtol
or a yiqtol|impv grand(mother).
Returns:
a string of the ancestor's tense, or None.
"""
(f, e, l) = (api.F, api.E, api.L)
this_verb = next((F.vt.v(w) for w in L.d(clause_atom) if F.pdp.v(w) == 'verb'), '')
mother = next((m for m in E.mother.f(clause_atom)), 0)
mom_verb = next((F.vt.v(w) for w in L.d(mother) if F.pdp.v(w) == 'verb'), '')
if mom_verb in {'wayq', 'impf', 'impv'}:
return mom_verb
elif not mother:
return this_verb
else:
return get_grandma(mother, api)
def convert_tense(word, api):
"""Convert weqatal tenses where present.
If not weqatal, return the tense.
"""
(f, l) = (api.F, api.L)
tense_map = {'impf': 'yqtl', 'perf': 'qtl', 'wayq': 'wyqtl'}
tense = F.vt.v(word)
if tense == 'perf' and F.lex.v(word - 1) == 'W':
clause = L.u(word, 'clause_atom')[0]
qatal_ancestor = get_grandma(clause, api)
if qatal_ancestor in {'impf', 'impv'}:
return 'wqtl'
else:
return tense_map.get(tense, tense)
else:
return tense_map.get(tense, tense)
|
class AnalysisElement:
def __init__(self, validationResult, validationMessage):
self.validation_result = validationResult
self.validation_message = validationMessage
class AnalysisResult:
def __init__(self):
self.elements = []
def add_element(self, element: AnalysisElement):
self.elements.append(element)
class DataSetEntry:
def __init__(self, index, classification):
self.index = index
self.classification = classification
class DataSetEntries:
def __init__(self):
self.entries = []
def add_element(self, entry: DataSetEntry):
self.entries.append(entry)
|
class Analysiselement:
def __init__(self, validationResult, validationMessage):
self.validation_result = validationResult
self.validation_message = validationMessage
class Analysisresult:
def __init__(self):
self.elements = []
def add_element(self, element: AnalysisElement):
self.elements.append(element)
class Datasetentry:
def __init__(self, index, classification):
self.index = index
self.classification = classification
class Datasetentries:
def __init__(self):
self.entries = []
def add_element(self, entry: DataSetEntry):
self.entries.append(entry)
|
lim = 10000000
num = [True for _ in range(lim)]
for i in range(4, lim, 2):
num[i] = False
for i in range(3, lim, 2):
if num[i]:
for j in range(i * i, lim, i):
num[j] = False
oa = 0
ob = 0
mnp = 0
size = 1000
for a in range(-size + 1, size):
for b in range(1, size, 2):
np = 0
for n in range(0, lim):
if num[n * n + a * n + b]:
np += 1
else:
break
if np > mnp:
mnp = np
oa = a
ob = b
print(oa * ob)
|
lim = 10000000
num = [True for _ in range(lim)]
for i in range(4, lim, 2):
num[i] = False
for i in range(3, lim, 2):
if num[i]:
for j in range(i * i, lim, i):
num[j] = False
oa = 0
ob = 0
mnp = 0
size = 1000
for a in range(-size + 1, size):
for b in range(1, size, 2):
np = 0
for n in range(0, lim):
if num[n * n + a * n + b]:
np += 1
else:
break
if np > mnp:
mnp = np
oa = a
ob = b
print(oa * ob)
|
# -*- coding: utf-8 -*-
"""Tests package for Script Venv."""
__author__ = """Struan Lyall Judd"""
__email__ = 'sv@scifi.geek.nz'
|
"""Tests package for Script Venv."""
__author__ = 'Struan Lyall Judd'
__email__ = 'sv@scifi.geek.nz'
|
# coding=utf-8
"""
Package init file
"""
__all__ = ["catch_event_type", "end_event_type", "event_type", "intermediate_catch_event_type",
"intermediate_throw_event_type", "start_event_type", "throw_event_type"]
|
"""
Package init file
"""
__all__ = ['catch_event_type', 'end_event_type', 'event_type', 'intermediate_catch_event_type', 'intermediate_throw_event_type', 'start_event_type', 'throw_event_type']
|
STATS = [
{
"num_node_expansions": 0,
"search_time": 0.0260686,
"total_time": 0.161712,
"plan_length": 64,
"plan_cost": 64,
"objects_used": 261,
"objects_total": 379,
"neural_net_time": 0.10646533966064453,
"num_replanning_steps": 3,
"wall_time": 2.435692071914673
},
{
"num_node_expansions": 0,
"search_time": 0.0279492,
"total_time": 0.17491,
"plan_length": 52,
"plan_cost": 52,
"objects_used": 276,
"objects_total": 379,
"neural_net_time": 0.058258056640625,
"num_replanning_steps": 4,
"wall_time": 3.361152410507202
},
{
"num_node_expansions": 0,
"search_time": 0.0313502,
"total_time": 0.245342,
"plan_length": 61,
"plan_cost": 61,
"objects_used": 273,
"objects_total": 379,
"neural_net_time": 0.06083822250366211,
"num_replanning_steps": 4,
"wall_time": 4.374004602432251
},
{
"num_node_expansions": 0,
"search_time": 0.0462309,
"total_time": 0.237932,
"plan_length": 59,
"plan_cost": 59,
"objects_used": 243,
"objects_total": 379,
"neural_net_time": 0.05759286880493164,
"num_replanning_steps": 3,
"wall_time": 2.5270650386810303
},
{
"num_node_expansions": 0,
"search_time": 0.0368982,
"total_time": 0.233488,
"plan_length": 54,
"plan_cost": 54,
"objects_used": 272,
"objects_total": 379,
"neural_net_time": 0.05734562873840332,
"num_replanning_steps": 4,
"wall_time": 3.6436092853546143
},
{
"num_node_expansions": 0,
"search_time": 0.0155738,
"total_time": 0.0682826,
"plan_length": 73,
"plan_cost": 73,
"objects_used": 117,
"objects_total": 217,
"neural_net_time": 0.029698610305786133,
"num_replanning_steps": 1,
"wall_time": 0.906505823135376
},
{
"num_node_expansions": 0,
"search_time": 0.0171021,
"total_time": 0.0927101,
"plan_length": 63,
"plan_cost": 63,
"objects_used": 122,
"objects_total": 217,
"neural_net_time": 0.05449986457824707,
"num_replanning_steps": 1,
"wall_time": 1.0803697109222412
},
{
"num_node_expansions": 0,
"search_time": 0.020779,
"total_time": 0.09933,
"plan_length": 55,
"plan_cost": 55,
"objects_used": 124,
"objects_total": 217,
"neural_net_time": 0.03200268745422363,
"num_replanning_steps": 1,
"wall_time": 1.2762155532836914
},
{
"num_node_expansions": 0,
"search_time": 0.116974,
"total_time": 0.160087,
"plan_length": 118,
"plan_cost": 118,
"objects_used": 113,
"objects_total": 217,
"neural_net_time": 0.032900094985961914,
"num_replanning_steps": 1,
"wall_time": 0.9846065044403076
},
{
"num_node_expansions": 0,
"search_time": 0.00864599,
"total_time": 0.0618746,
"plan_length": 51,
"plan_cost": 51,
"objects_used": 121,
"objects_total": 217,
"neural_net_time": 0.03256845474243164,
"num_replanning_steps": 1,
"wall_time": 0.9345319271087646
},
{
"num_node_expansions": 0,
"search_time": 0.0150995,
"total_time": 0.139498,
"plan_length": 55,
"plan_cost": 55,
"objects_used": 184,
"objects_total": 320,
"neural_net_time": 0.04656338691711426,
"num_replanning_steps": 1,
"wall_time": 1.576615810394287
},
{
"num_node_expansions": 0,
"search_time": 0.0195704,
"total_time": 0.0776481,
"plan_length": 76,
"plan_cost": 76,
"objects_used": 157,
"objects_total": 320,
"neural_net_time": 0.044793128967285156,
"num_replanning_steps": 1,
"wall_time": 0.9117276668548584
},
{
"num_node_expansions": 0,
"search_time": 0.0218047,
"total_time": 0.0813003,
"plan_length": 91,
"plan_cost": 91,
"objects_used": 169,
"objects_total": 320,
"neural_net_time": 0.0447840690612793,
"num_replanning_steps": 1,
"wall_time": 1.0234675407409668
},
{
"num_node_expansions": 0,
"search_time": 0.0318204,
"total_time": 0.112719,
"plan_length": 82,
"plan_cost": 82,
"objects_used": 168,
"objects_total": 320,
"neural_net_time": 0.048575401306152344,
"num_replanning_steps": 1,
"wall_time": 1.182650089263916
},
{
"num_node_expansions": 0,
"search_time": 0.0214701,
"total_time": 0.12052,
"plan_length": 68,
"plan_cost": 68,
"objects_used": 193,
"objects_total": 305,
"neural_net_time": 0.046851396560668945,
"num_replanning_steps": 1,
"wall_time": 1.3422448635101318
},
{
"num_node_expansions": 0,
"search_time": 0.0238054,
"total_time": 0.0993613,
"plan_length": 53,
"plan_cost": 53,
"objects_used": 214,
"objects_total": 305,
"neural_net_time": 0.04596352577209473,
"num_replanning_steps": 1,
"wall_time": 1.352567434310913
},
{
"num_node_expansions": 0,
"search_time": 0.0134198,
"total_time": 0.0667924,
"plan_length": 86,
"plan_cost": 86,
"objects_used": 169,
"objects_total": 305,
"neural_net_time": 0.043943166732788086,
"num_replanning_steps": 1,
"wall_time": 0.9647877216339111
},
{
"num_node_expansions": 0,
"search_time": 0.231443,
"total_time": 0.312803,
"plan_length": 84,
"plan_cost": 84,
"objects_used": 194,
"objects_total": 305,
"neural_net_time": 0.04476618766784668,
"num_replanning_steps": 1,
"wall_time": 1.5609796047210693
},
{
"num_node_expansions": 0,
"search_time": 0.0272906,
"total_time": 0.101185,
"plan_length": 63,
"plan_cost": 63,
"objects_used": 211,
"objects_total": 305,
"neural_net_time": 0.04451155662536621,
"num_replanning_steps": 1,
"wall_time": 1.2499635219573975
},
{
"num_node_expansions": 0,
"search_time": 0.0767934,
"total_time": 0.113212,
"plan_length": 156,
"plan_cost": 156,
"objects_used": 114,
"objects_total": 212,
"neural_net_time": 0.03154778480529785,
"num_replanning_steps": 1,
"wall_time": 0.8447625637054443
},
{
"num_node_expansions": 0,
"search_time": 0.665671,
"total_time": 0.694063,
"plan_length": 92,
"plan_cost": 92,
"objects_used": 109,
"objects_total": 212,
"neural_net_time": 0.029831647872924805,
"num_replanning_steps": 0,
"wall_time": 1.1394996643066406
},
{
"num_node_expansions": 0,
"search_time": 0.0104928,
"total_time": 0.0622191,
"plan_length": 68,
"plan_cost": 68,
"objects_used": 159,
"objects_total": 365,
"neural_net_time": 0.05487489700317383,
"num_replanning_steps": 1,
"wall_time": 0.8508009910583496
},
{
"num_node_expansions": 0,
"search_time": 0.0328946,
"total_time": 0.126837,
"plan_length": 89,
"plan_cost": 89,
"objects_used": 203,
"objects_total": 365,
"neural_net_time": 0.053848981857299805,
"num_replanning_steps": 2,
"wall_time": 1.7260208129882812
},
{
"num_node_expansions": 0,
"search_time": 0.0234049,
"total_time": 0.0851975,
"plan_length": 75,
"plan_cost": 75,
"objects_used": 168,
"objects_total": 365,
"neural_net_time": 0.053121328353881836,
"num_replanning_steps": 1,
"wall_time": 1.030031681060791
},
{
"num_node_expansions": 0,
"search_time": 0.013401,
"total_time": 0.0713078,
"plan_length": 59,
"plan_cost": 59,
"objects_used": 169,
"objects_total": 365,
"neural_net_time": 0.05536675453186035,
"num_replanning_steps": 1,
"wall_time": 1.1071906089782715
},
{
"num_node_expansions": 0,
"search_time": 0.104847,
"total_time": 0.195061,
"plan_length": 52,
"plan_cost": 52,
"objects_used": 167,
"objects_total": 302,
"neural_net_time": 0.04499459266662598,
"num_replanning_steps": 1,
"wall_time": 1.4144911766052246
},
{
"num_node_expansions": 0,
"search_time": 0.0765767,
"total_time": 0.131634,
"plan_length": 66,
"plan_cost": 66,
"objects_used": 159,
"objects_total": 302,
"neural_net_time": 0.0444490909576416,
"num_replanning_steps": 1,
"wall_time": 1.1225917339324951
},
{
"num_node_expansions": 0,
"search_time": 0.0633749,
"total_time": 0.159814,
"plan_length": 70,
"plan_cost": 70,
"objects_used": 163,
"objects_total": 302,
"neural_net_time": 0.044997453689575195,
"num_replanning_steps": 1,
"wall_time": 1.3655714988708496
},
{
"num_node_expansions": 0,
"search_time": 0.134185,
"total_time": 0.447814,
"plan_length": 68,
"plan_cost": 68,
"objects_used": 230,
"objects_total": 365,
"neural_net_time": 0.05536222457885742,
"num_replanning_steps": 3,
"wall_time": 4.771425485610962
},
{
"num_node_expansions": 0,
"search_time": 0.0165639,
"total_time": 0.0940178,
"plan_length": 62,
"plan_cost": 62,
"objects_used": 183,
"objects_total": 365,
"neural_net_time": 0.05884861946105957,
"num_replanning_steps": 1,
"wall_time": 1.2651619911193848
},
{
"num_node_expansions": 0,
"search_time": 0.124357,
"total_time": 0.248529,
"plan_length": 81,
"plan_cost": 81,
"objects_used": 214,
"objects_total": 365,
"neural_net_time": 0.05655694007873535,
"num_replanning_steps": 3,
"wall_time": 2.9309194087982178
},
{
"num_node_expansions": 0,
"search_time": 0.0150311,
"total_time": 0.101787,
"plan_length": 63,
"plan_cost": 63,
"objects_used": 192,
"objects_total": 365,
"neural_net_time": 0.0555422306060791,
"num_replanning_steps": 2,
"wall_time": 1.666846752166748
},
{
"num_node_expansions": 0,
"search_time": 0.0150945,
"total_time": 0.0514842,
"plan_length": 90,
"plan_cost": 90,
"objects_used": 175,
"objects_total": 365,
"neural_net_time": 0.05377364158630371,
"num_replanning_steps": 1,
"wall_time": 0.8902196884155273
},
{
"num_node_expansions": 0,
"search_time": 0.0176192,
"total_time": 0.0796522,
"plan_length": 92,
"plan_cost": 92,
"objects_used": 178,
"objects_total": 362,
"neural_net_time": 0.05463862419128418,
"num_replanning_steps": 1,
"wall_time": 1.0109508037567139
},
{
"num_node_expansions": 0,
"search_time": 0.0104213,
"total_time": 0.0470441,
"plan_length": 77,
"plan_cost": 77,
"objects_used": 160,
"objects_total": 362,
"neural_net_time": 0.054520368576049805,
"num_replanning_steps": 1,
"wall_time": 0.7542357444763184
},
{
"num_node_expansions": 0,
"search_time": 0.00448661,
"total_time": 0.0177422,
"plan_length": 84,
"plan_cost": 84,
"objects_used": 136,
"objects_total": 362,
"neural_net_time": 0.05472111701965332,
"num_replanning_steps": 0,
"wall_time": 0.4157280921936035
},
{
"num_node_expansions": 0,
"search_time": 0.045955,
"total_time": 0.190108,
"plan_length": 74,
"plan_cost": 74,
"objects_used": 221,
"objects_total": 322,
"neural_net_time": 0.047133445739746094,
"num_replanning_steps": 1,
"wall_time": 1.6114940643310547
},
{
"num_node_expansions": 0,
"search_time": 0.0459863,
"total_time": 0.178842,
"plan_length": 103,
"plan_cost": 103,
"objects_used": 215,
"objects_total": 441,
"neural_net_time": 0.06811332702636719,
"num_replanning_steps": 1,
"wall_time": 1.7026808261871338
},
{
"num_node_expansions": 0,
"search_time": 0.0375162,
"total_time": 0.17094,
"plan_length": 71,
"plan_cost": 71,
"objects_used": 216,
"objects_total": 441,
"neural_net_time": 0.06928086280822754,
"num_replanning_steps": 1,
"wall_time": 3.0769970417022705
},
{
"num_node_expansions": 0,
"search_time": 0.15904,
"total_time": 0.361705,
"plan_length": 123,
"plan_cost": 123,
"objects_used": 224,
"objects_total": 441,
"neural_net_time": 0.06914591789245605,
"num_replanning_steps": 2,
"wall_time": 2.922773838043213
},
{
"num_node_expansions": 0,
"search_time": 0.127007,
"total_time": 0.591304,
"plan_length": 97,
"plan_cost": 97,
"objects_used": 249,
"objects_total": 441,
"neural_net_time": 0.06865596771240234,
"num_replanning_steps": 2,
"wall_time": 5.019821643829346
},
{
"num_node_expansions": 0,
"search_time": 0.0700383,
"total_time": 0.268587,
"plan_length": 95,
"plan_cost": 95,
"objects_used": 227,
"objects_total": 441,
"neural_net_time": 0.06840014457702637,
"num_replanning_steps": 1,
"wall_time": 2.3747305870056152
},
{
"num_node_expansions": 0,
"search_time": 0.0111234,
"total_time": 0.0605018,
"plan_length": 76,
"plan_cost": 76,
"objects_used": 171,
"objects_total": 417,
"neural_net_time": 0.06322216987609863,
"num_replanning_steps": 1,
"wall_time": 1.0112266540527344
},
{
"num_node_expansions": 0,
"search_time": 0.0183385,
"total_time": 0.106249,
"plan_length": 87,
"plan_cost": 87,
"objects_used": 194,
"objects_total": 417,
"neural_net_time": 0.0725412368774414,
"num_replanning_steps": 1,
"wall_time": 1.364563226699829
},
{
"num_node_expansions": 0,
"search_time": 0.0190809,
"total_time": 0.111638,
"plan_length": 58,
"plan_cost": 58,
"objects_used": 216,
"objects_total": 417,
"neural_net_time": 0.06367969512939453,
"num_replanning_steps": 3,
"wall_time": 2.054568290710449
},
{
"num_node_expansions": 0,
"search_time": 0.210535,
"total_time": 0.334857,
"plan_length": 123,
"plan_cost": 123,
"objects_used": 203,
"objects_total": 417,
"neural_net_time": 0.06560730934143066,
"num_replanning_steps": 2,
"wall_time": 2.3334832191467285
},
{
"num_node_expansions": 0,
"search_time": 0.0219698,
"total_time": 0.130103,
"plan_length": 62,
"plan_cost": 62,
"objects_used": 197,
"objects_total": 417,
"neural_net_time": 0.06369471549987793,
"num_replanning_steps": 1,
"wall_time": 1.6010661125183105
},
{
"num_node_expansions": 0,
"search_time": 0.0101631,
"total_time": 0.0415831,
"plan_length": 76,
"plan_cost": 76,
"objects_used": 112,
"objects_total": 232,
"neural_net_time": 0.03584003448486328,
"num_replanning_steps": 1,
"wall_time": 0.7372550964355469
},
{
"num_node_expansions": 0,
"search_time": 0.0111653,
"total_time": 0.0418656,
"plan_length": 53,
"plan_cost": 53,
"objects_used": 110,
"objects_total": 232,
"neural_net_time": 0.032355308532714844,
"num_replanning_steps": 0,
"wall_time": 0.5313618183135986
},
{
"num_node_expansions": 0,
"search_time": 0.00524832,
"total_time": 0.0220788,
"plan_length": 56,
"plan_cost": 56,
"objects_used": 106,
"objects_total": 232,
"neural_net_time": 0.03553891181945801,
"num_replanning_steps": 1,
"wall_time": 0.7103500366210938
},
{
"num_node_expansions": 0,
"search_time": 0.0136476,
"total_time": 0.0672117,
"plan_length": 78,
"plan_cost": 78,
"objects_used": 130,
"objects_total": 212,
"neural_net_time": 0.02926468849182129,
"num_replanning_steps": 1,
"wall_time": 0.8608791828155518
},
{
"num_node_expansions": 0,
"search_time": 0.016218,
"total_time": 0.0887494,
"plan_length": 75,
"plan_cost": 75,
"objects_used": 133,
"objects_total": 212,
"neural_net_time": 0.029755353927612305,
"num_replanning_steps": 1,
"wall_time": 1.1875898838043213
},
{
"num_node_expansions": 0,
"search_time": 0.0276188,
"total_time": 0.0960435,
"plan_length": 87,
"plan_cost": 87,
"objects_used": 132,
"objects_total": 212,
"neural_net_time": 0.04944968223571777,
"num_replanning_steps": 2,
"wall_time": 1.4252169132232666
},
{
"num_node_expansions": 0,
"search_time": 0.00914205,
"total_time": 0.0572312,
"plan_length": 60,
"plan_cost": 60,
"objects_used": 125,
"objects_total": 212,
"neural_net_time": 0.05208992958068848,
"num_replanning_steps": 1,
"wall_time": 0.8581404685974121
}
]
|
stats = [{'num_node_expansions': 0, 'search_time': 0.0260686, 'total_time': 0.161712, 'plan_length': 64, 'plan_cost': 64, 'objects_used': 261, 'objects_total': 379, 'neural_net_time': 0.10646533966064453, 'num_replanning_steps': 3, 'wall_time': 2.435692071914673}, {'num_node_expansions': 0, 'search_time': 0.0279492, 'total_time': 0.17491, 'plan_length': 52, 'plan_cost': 52, 'objects_used': 276, 'objects_total': 379, 'neural_net_time': 0.058258056640625, 'num_replanning_steps': 4, 'wall_time': 3.361152410507202}, {'num_node_expansions': 0, 'search_time': 0.0313502, 'total_time': 0.245342, 'plan_length': 61, 'plan_cost': 61, 'objects_used': 273, 'objects_total': 379, 'neural_net_time': 0.06083822250366211, 'num_replanning_steps': 4, 'wall_time': 4.374004602432251}, {'num_node_expansions': 0, 'search_time': 0.0462309, 'total_time': 0.237932, 'plan_length': 59, 'plan_cost': 59, 'objects_used': 243, 'objects_total': 379, 'neural_net_time': 0.05759286880493164, 'num_replanning_steps': 3, 'wall_time': 2.5270650386810303}, {'num_node_expansions': 0, 'search_time': 0.0368982, 'total_time': 0.233488, 'plan_length': 54, 'plan_cost': 54, 'objects_used': 272, 'objects_total': 379, 'neural_net_time': 0.05734562873840332, 'num_replanning_steps': 4, 'wall_time': 3.6436092853546143}, {'num_node_expansions': 0, 'search_time': 0.0155738, 'total_time': 0.0682826, 'plan_length': 73, 'plan_cost': 73, 'objects_used': 117, 'objects_total': 217, 'neural_net_time': 0.029698610305786133, 'num_replanning_steps': 1, 'wall_time': 0.906505823135376}, {'num_node_expansions': 0, 'search_time': 0.0171021, 'total_time': 0.0927101, 'plan_length': 63, 'plan_cost': 63, 'objects_used': 122, 'objects_total': 217, 'neural_net_time': 0.05449986457824707, 'num_replanning_steps': 1, 'wall_time': 1.0803697109222412}, {'num_node_expansions': 0, 'search_time': 0.020779, 'total_time': 0.09933, 'plan_length': 55, 'plan_cost': 55, 'objects_used': 124, 'objects_total': 217, 'neural_net_time': 0.03200268745422363, 'num_replanning_steps': 1, 'wall_time': 1.2762155532836914}, {'num_node_expansions': 0, 'search_time': 0.116974, 'total_time': 0.160087, 'plan_length': 118, 'plan_cost': 118, 'objects_used': 113, 'objects_total': 217, 'neural_net_time': 0.032900094985961914, 'num_replanning_steps': 1, 'wall_time': 0.9846065044403076}, {'num_node_expansions': 0, 'search_time': 0.00864599, 'total_time': 0.0618746, 'plan_length': 51, 'plan_cost': 51, 'objects_used': 121, 'objects_total': 217, 'neural_net_time': 0.03256845474243164, 'num_replanning_steps': 1, 'wall_time': 0.9345319271087646}, {'num_node_expansions': 0, 'search_time': 0.0150995, 'total_time': 0.139498, 'plan_length': 55, 'plan_cost': 55, 'objects_used': 184, 'objects_total': 320, 'neural_net_time': 0.04656338691711426, 'num_replanning_steps': 1, 'wall_time': 1.576615810394287}, {'num_node_expansions': 0, 'search_time': 0.0195704, 'total_time': 0.0776481, 'plan_length': 76, 'plan_cost': 76, 'objects_used': 157, 'objects_total': 320, 'neural_net_time': 0.044793128967285156, 'num_replanning_steps': 1, 'wall_time': 0.9117276668548584}, {'num_node_expansions': 0, 'search_time': 0.0218047, 'total_time': 0.0813003, 'plan_length': 91, 'plan_cost': 91, 'objects_used': 169, 'objects_total': 320, 'neural_net_time': 0.0447840690612793, 'num_replanning_steps': 1, 'wall_time': 1.0234675407409668}, {'num_node_expansions': 0, 'search_time': 0.0318204, 'total_time': 0.112719, 'plan_length': 82, 'plan_cost': 82, 'objects_used': 168, 'objects_total': 320, 'neural_net_time': 0.048575401306152344, 'num_replanning_steps': 1, 'wall_time': 1.182650089263916}, {'num_node_expansions': 0, 'search_time': 0.0214701, 'total_time': 0.12052, 'plan_length': 68, 'plan_cost': 68, 'objects_used': 193, 'objects_total': 305, 'neural_net_time': 0.046851396560668945, 'num_replanning_steps': 1, 'wall_time': 1.3422448635101318}, {'num_node_expansions': 0, 'search_time': 0.0238054, 'total_time': 0.0993613, 'plan_length': 53, 'plan_cost': 53, 'objects_used': 214, 'objects_total': 305, 'neural_net_time': 0.04596352577209473, 'num_replanning_steps': 1, 'wall_time': 1.352567434310913}, {'num_node_expansions': 0, 'search_time': 0.0134198, 'total_time': 0.0667924, 'plan_length': 86, 'plan_cost': 86, 'objects_used': 169, 'objects_total': 305, 'neural_net_time': 0.043943166732788086, 'num_replanning_steps': 1, 'wall_time': 0.9647877216339111}, {'num_node_expansions': 0, 'search_time': 0.231443, 'total_time': 0.312803, 'plan_length': 84, 'plan_cost': 84, 'objects_used': 194, 'objects_total': 305, 'neural_net_time': 0.04476618766784668, 'num_replanning_steps': 1, 'wall_time': 1.5609796047210693}, {'num_node_expansions': 0, 'search_time': 0.0272906, 'total_time': 0.101185, 'plan_length': 63, 'plan_cost': 63, 'objects_used': 211, 'objects_total': 305, 'neural_net_time': 0.04451155662536621, 'num_replanning_steps': 1, 'wall_time': 1.2499635219573975}, {'num_node_expansions': 0, 'search_time': 0.0767934, 'total_time': 0.113212, 'plan_length': 156, 'plan_cost': 156, 'objects_used': 114, 'objects_total': 212, 'neural_net_time': 0.03154778480529785, 'num_replanning_steps': 1, 'wall_time': 0.8447625637054443}, {'num_node_expansions': 0, 'search_time': 0.665671, 'total_time': 0.694063, 'plan_length': 92, 'plan_cost': 92, 'objects_used': 109, 'objects_total': 212, 'neural_net_time': 0.029831647872924805, 'num_replanning_steps': 0, 'wall_time': 1.1394996643066406}, {'num_node_expansions': 0, 'search_time': 0.0104928, 'total_time': 0.0622191, 'plan_length': 68, 'plan_cost': 68, 'objects_used': 159, 'objects_total': 365, 'neural_net_time': 0.05487489700317383, 'num_replanning_steps': 1, 'wall_time': 0.8508009910583496}, {'num_node_expansions': 0, 'search_time': 0.0328946, 'total_time': 0.126837, 'plan_length': 89, 'plan_cost': 89, 'objects_used': 203, 'objects_total': 365, 'neural_net_time': 0.053848981857299805, 'num_replanning_steps': 2, 'wall_time': 1.7260208129882812}, {'num_node_expansions': 0, 'search_time': 0.0234049, 'total_time': 0.0851975, 'plan_length': 75, 'plan_cost': 75, 'objects_used': 168, 'objects_total': 365, 'neural_net_time': 0.053121328353881836, 'num_replanning_steps': 1, 'wall_time': 1.030031681060791}, {'num_node_expansions': 0, 'search_time': 0.013401, 'total_time': 0.0713078, 'plan_length': 59, 'plan_cost': 59, 'objects_used': 169, 'objects_total': 365, 'neural_net_time': 0.05536675453186035, 'num_replanning_steps': 1, 'wall_time': 1.1071906089782715}, {'num_node_expansions': 0, 'search_time': 0.104847, 'total_time': 0.195061, 'plan_length': 52, 'plan_cost': 52, 'objects_used': 167, 'objects_total': 302, 'neural_net_time': 0.04499459266662598, 'num_replanning_steps': 1, 'wall_time': 1.4144911766052246}, {'num_node_expansions': 0, 'search_time': 0.0765767, 'total_time': 0.131634, 'plan_length': 66, 'plan_cost': 66, 'objects_used': 159, 'objects_total': 302, 'neural_net_time': 0.0444490909576416, 'num_replanning_steps': 1, 'wall_time': 1.1225917339324951}, {'num_node_expansions': 0, 'search_time': 0.0633749, 'total_time': 0.159814, 'plan_length': 70, 'plan_cost': 70, 'objects_used': 163, 'objects_total': 302, 'neural_net_time': 0.044997453689575195, 'num_replanning_steps': 1, 'wall_time': 1.3655714988708496}, {'num_node_expansions': 0, 'search_time': 0.134185, 'total_time': 0.447814, 'plan_length': 68, 'plan_cost': 68, 'objects_used': 230, 'objects_total': 365, 'neural_net_time': 0.05536222457885742, 'num_replanning_steps': 3, 'wall_time': 4.771425485610962}, {'num_node_expansions': 0, 'search_time': 0.0165639, 'total_time': 0.0940178, 'plan_length': 62, 'plan_cost': 62, 'objects_used': 183, 'objects_total': 365, 'neural_net_time': 0.05884861946105957, 'num_replanning_steps': 1, 'wall_time': 1.2651619911193848}, {'num_node_expansions': 0, 'search_time': 0.124357, 'total_time': 0.248529, 'plan_length': 81, 'plan_cost': 81, 'objects_used': 214, 'objects_total': 365, 'neural_net_time': 0.05655694007873535, 'num_replanning_steps': 3, 'wall_time': 2.9309194087982178}, {'num_node_expansions': 0, 'search_time': 0.0150311, 'total_time': 0.101787, 'plan_length': 63, 'plan_cost': 63, 'objects_used': 192, 'objects_total': 365, 'neural_net_time': 0.0555422306060791, 'num_replanning_steps': 2, 'wall_time': 1.666846752166748}, {'num_node_expansions': 0, 'search_time': 0.0150945, 'total_time': 0.0514842, 'plan_length': 90, 'plan_cost': 90, 'objects_used': 175, 'objects_total': 365, 'neural_net_time': 0.05377364158630371, 'num_replanning_steps': 1, 'wall_time': 0.8902196884155273}, {'num_node_expansions': 0, 'search_time': 0.0176192, 'total_time': 0.0796522, 'plan_length': 92, 'plan_cost': 92, 'objects_used': 178, 'objects_total': 362, 'neural_net_time': 0.05463862419128418, 'num_replanning_steps': 1, 'wall_time': 1.0109508037567139}, {'num_node_expansions': 0, 'search_time': 0.0104213, 'total_time': 0.0470441, 'plan_length': 77, 'plan_cost': 77, 'objects_used': 160, 'objects_total': 362, 'neural_net_time': 0.054520368576049805, 'num_replanning_steps': 1, 'wall_time': 0.7542357444763184}, {'num_node_expansions': 0, 'search_time': 0.00448661, 'total_time': 0.0177422, 'plan_length': 84, 'plan_cost': 84, 'objects_used': 136, 'objects_total': 362, 'neural_net_time': 0.05472111701965332, 'num_replanning_steps': 0, 'wall_time': 0.4157280921936035}, {'num_node_expansions': 0, 'search_time': 0.045955, 'total_time': 0.190108, 'plan_length': 74, 'plan_cost': 74, 'objects_used': 221, 'objects_total': 322, 'neural_net_time': 0.047133445739746094, 'num_replanning_steps': 1, 'wall_time': 1.6114940643310547}, {'num_node_expansions': 0, 'search_time': 0.0459863, 'total_time': 0.178842, 'plan_length': 103, 'plan_cost': 103, 'objects_used': 215, 'objects_total': 441, 'neural_net_time': 0.06811332702636719, 'num_replanning_steps': 1, 'wall_time': 1.7026808261871338}, {'num_node_expansions': 0, 'search_time': 0.0375162, 'total_time': 0.17094, 'plan_length': 71, 'plan_cost': 71, 'objects_used': 216, 'objects_total': 441, 'neural_net_time': 0.06928086280822754, 'num_replanning_steps': 1, 'wall_time': 3.0769970417022705}, {'num_node_expansions': 0, 'search_time': 0.15904, 'total_time': 0.361705, 'plan_length': 123, 'plan_cost': 123, 'objects_used': 224, 'objects_total': 441, 'neural_net_time': 0.06914591789245605, 'num_replanning_steps': 2, 'wall_time': 2.922773838043213}, {'num_node_expansions': 0, 'search_time': 0.127007, 'total_time': 0.591304, 'plan_length': 97, 'plan_cost': 97, 'objects_used': 249, 'objects_total': 441, 'neural_net_time': 0.06865596771240234, 'num_replanning_steps': 2, 'wall_time': 5.019821643829346}, {'num_node_expansions': 0, 'search_time': 0.0700383, 'total_time': 0.268587, 'plan_length': 95, 'plan_cost': 95, 'objects_used': 227, 'objects_total': 441, 'neural_net_time': 0.06840014457702637, 'num_replanning_steps': 1, 'wall_time': 2.3747305870056152}, {'num_node_expansions': 0, 'search_time': 0.0111234, 'total_time': 0.0605018, 'plan_length': 76, 'plan_cost': 76, 'objects_used': 171, 'objects_total': 417, 'neural_net_time': 0.06322216987609863, 'num_replanning_steps': 1, 'wall_time': 1.0112266540527344}, {'num_node_expansions': 0, 'search_time': 0.0183385, 'total_time': 0.106249, 'plan_length': 87, 'plan_cost': 87, 'objects_used': 194, 'objects_total': 417, 'neural_net_time': 0.0725412368774414, 'num_replanning_steps': 1, 'wall_time': 1.364563226699829}, {'num_node_expansions': 0, 'search_time': 0.0190809, 'total_time': 0.111638, 'plan_length': 58, 'plan_cost': 58, 'objects_used': 216, 'objects_total': 417, 'neural_net_time': 0.06367969512939453, 'num_replanning_steps': 3, 'wall_time': 2.054568290710449}, {'num_node_expansions': 0, 'search_time': 0.210535, 'total_time': 0.334857, 'plan_length': 123, 'plan_cost': 123, 'objects_used': 203, 'objects_total': 417, 'neural_net_time': 0.06560730934143066, 'num_replanning_steps': 2, 'wall_time': 2.3334832191467285}, {'num_node_expansions': 0, 'search_time': 0.0219698, 'total_time': 0.130103, 'plan_length': 62, 'plan_cost': 62, 'objects_used': 197, 'objects_total': 417, 'neural_net_time': 0.06369471549987793, 'num_replanning_steps': 1, 'wall_time': 1.6010661125183105}, {'num_node_expansions': 0, 'search_time': 0.0101631, 'total_time': 0.0415831, 'plan_length': 76, 'plan_cost': 76, 'objects_used': 112, 'objects_total': 232, 'neural_net_time': 0.03584003448486328, 'num_replanning_steps': 1, 'wall_time': 0.7372550964355469}, {'num_node_expansions': 0, 'search_time': 0.0111653, 'total_time': 0.0418656, 'plan_length': 53, 'plan_cost': 53, 'objects_used': 110, 'objects_total': 232, 'neural_net_time': 0.032355308532714844, 'num_replanning_steps': 0, 'wall_time': 0.5313618183135986}, {'num_node_expansions': 0, 'search_time': 0.00524832, 'total_time': 0.0220788, 'plan_length': 56, 'plan_cost': 56, 'objects_used': 106, 'objects_total': 232, 'neural_net_time': 0.03553891181945801, 'num_replanning_steps': 1, 'wall_time': 0.7103500366210938}, {'num_node_expansions': 0, 'search_time': 0.0136476, 'total_time': 0.0672117, 'plan_length': 78, 'plan_cost': 78, 'objects_used': 130, 'objects_total': 212, 'neural_net_time': 0.02926468849182129, 'num_replanning_steps': 1, 'wall_time': 0.8608791828155518}, {'num_node_expansions': 0, 'search_time': 0.016218, 'total_time': 0.0887494, 'plan_length': 75, 'plan_cost': 75, 'objects_used': 133, 'objects_total': 212, 'neural_net_time': 0.029755353927612305, 'num_replanning_steps': 1, 'wall_time': 1.1875898838043213}, {'num_node_expansions': 0, 'search_time': 0.0276188, 'total_time': 0.0960435, 'plan_length': 87, 'plan_cost': 87, 'objects_used': 132, 'objects_total': 212, 'neural_net_time': 0.04944968223571777, 'num_replanning_steps': 2, 'wall_time': 1.4252169132232666}, {'num_node_expansions': 0, 'search_time': 0.00914205, 'total_time': 0.0572312, 'plan_length': 60, 'plan_cost': 60, 'objects_used': 125, 'objects_total': 212, 'neural_net_time': 0.05208992958068848, 'num_replanning_steps': 1, 'wall_time': 0.8581404685974121}]
|
# Numbers are not stored in the written representation, so they can't be
# treated like strings.
a = 123
print(a[1])
|
a = 123
print(a[1])
|
def get_reversed_string(word):
return word[::-1]
while True:
string = input()
if string == 'end':
break
rev_str = get_reversed_string(string)
print(f'{string} = {rev_str}')
|
def get_reversed_string(word):
return word[::-1]
while True:
string = input()
if string == 'end':
break
rev_str = get_reversed_string(string)
print(f'{string} = {rev_str}')
|
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def levelOrderBottom(self, root: 'TreeNode') -> 'List[List[int]]':
if not root:
return
stack = [(root,0)]
rst = []
while stack:
n, level = stack.pop(0)
if len(rst) < level + 1:
rst.insert(0,[])
rst[-(level+1)].append(n.val)
if n.left:
stack.append((n.left,level+1))
if n.right:
stack.append((n.right, level+1))
return rst
|
class Solution:
def level_order_bottom(self, root: 'TreeNode') -> 'List[List[int]]':
if not root:
return
stack = [(root, 0)]
rst = []
while stack:
(n, level) = stack.pop(0)
if len(rst) < level + 1:
rst.insert(0, [])
rst[-(level + 1)].append(n.val)
if n.left:
stack.append((n.left, level + 1))
if n.right:
stack.append((n.right, level + 1))
return rst
|
# def function_name_print(a,b,c,d):
#
# print(a,b,c,d)
def funargs(normal,*args, **kwargs):
print(normal)
for item in args:
print(item)
print("\nNow I would like to introduce some of our heroes")
for key,value in kwargs.items():
print(f"{key} is a {value}")
# As a tuple
# function_name_print("Jiggu","g","f","dd")
list = ["Jiggu","g","f","dd"]
normal = "Yhis is normal"
kw = {"Rohan":"Monitor", "Jiggu":"Sports coach","Him":"Programmer"}
funargs(normal,*list,**kw)
|
def funargs(normal, *args, **kwargs):
print(normal)
for item in args:
print(item)
print('\nNow I would like to introduce some of our heroes')
for (key, value) in kwargs.items():
print(f'{key} is a {value}')
list = ['Jiggu', 'g', 'f', 'dd']
normal = 'Yhis is normal'
kw = {'Rohan': 'Monitor', 'Jiggu': 'Sports coach', 'Him': 'Programmer'}
funargs(normal, *list, **kw)
|
"""
This is template on how to configurate your setup for the weedlings model.
You may create a copy of this script and name it "_conf.py" so it will be not be tracked by the ".gitignore"
and is stored only locally.
The "_conf.py" than can be used in other scripts.
"""
PATH = "/home/yourname/projects/weedlings/" # overall path
DATA_PATH = "/home/yourname/projects/weedlings/data/" # write your path to the dataset here
RAW_DATA_PATH = DATA_PATH + "raw_data/" # path where raw data is stored
SPLIT_DATA_PATH = DATA_PATH + "split_data/" # path where the data, that we will use for the model is stored
MODEL_PATH = DATA_PATH + "models/" # path where the saved models will be stored
|
"""
This is template on how to configurate your setup for the weedlings model.
You may create a copy of this script and name it "_conf.py" so it will be not be tracked by the ".gitignore"
and is stored only locally.
The "_conf.py" than can be used in other scripts.
"""
path = '/home/yourname/projects/weedlings/'
data_path = '/home/yourname/projects/weedlings/data/'
raw_data_path = DATA_PATH + 'raw_data/'
split_data_path = DATA_PATH + 'split_data/'
model_path = DATA_PATH + 'models/'
|
class MonoDevelopSvnPackage (Package):
def __init__ (self):
Package.__init__ (self, 'monodevelop', 'trunk')
def svn_co_or_up (self):
self.cd ('..')
if os.path.isdir ('svn'):
self.cd ('svn')
self.sh ('svn up')
else:
self.sh ('svn co http://anonsvn.mono-project.com/source/trunk/monodevelop svn')
self.cd ('svn')
self.cd ('..')
def prep (self):
self.svn_co_or_up ()
self.sh ('cp -r svn _build')
self.cd ('_build/svn')
def build (self):
self.sh (
'echo "main --disable-update-mimedb --disable-update-desktopdb --disable-gnomeplatform --enable-macplatform --disable-tests" > profiles/mac',
'./configure --prefix="%{prefix}" --profile=mac',
'make'
)
def install (self):
self.sh ('%{makeinstall}')
MonoDevelopSvnPackage ()
|
class Monodevelopsvnpackage(Package):
def __init__(self):
Package.__init__(self, 'monodevelop', 'trunk')
def svn_co_or_up(self):
self.cd('..')
if os.path.isdir('svn'):
self.cd('svn')
self.sh('svn up')
else:
self.sh('svn co http://anonsvn.mono-project.com/source/trunk/monodevelop svn')
self.cd('svn')
self.cd('..')
def prep(self):
self.svn_co_or_up()
self.sh('cp -r svn _build')
self.cd('_build/svn')
def build(self):
self.sh('echo "main --disable-update-mimedb --disable-update-desktopdb --disable-gnomeplatform --enable-macplatform --disable-tests" > profiles/mac', './configure --prefix="%{prefix}" --profile=mac', 'make')
def install(self):
self.sh('%{makeinstall}')
mono_develop_svn_package()
|
class MBTA_Exception(Exception):
"""Superclass for all Exceptions raised in mbta package. """
pass
class MBTA_NotFound(MBTA_Exception):
""" Raised when search returns 404 (Not Found). """
def __init__(self, response, query_val):
parameter = response['errors'][0]['source']['parameter']
reason = response['errors'][0]['title']
message = f'{parameter}: {query_val} {reason}'
super().__init__(message)
class MBTA_Forbidden(MBTA_Exception):
""" Raised when request returns a 403 HTTP error code. """
def __init__(self, url):
super().__init__(f'GET {url} returned 403 (Forbidden)')
class MBTA_BadRequest(MBTA_Exception):
""" Raised if MBTA interpreted given request was invalid in syntax or in parameters. """
pass
class MBTA_QuotaExceeded(MBTA_Exception):
""" Raised when user has made too many requests. """
pass
|
class Mbta_Exception(Exception):
"""Superclass for all Exceptions raised in mbta package. """
pass
class Mbta_Notfound(MBTA_Exception):
""" Raised when search returns 404 (Not Found). """
def __init__(self, response, query_val):
parameter = response['errors'][0]['source']['parameter']
reason = response['errors'][0]['title']
message = f'{parameter}: {query_val} {reason}'
super().__init__(message)
class Mbta_Forbidden(MBTA_Exception):
""" Raised when request returns a 403 HTTP error code. """
def __init__(self, url):
super().__init__(f'GET {url} returned 403 (Forbidden)')
class Mbta_Badrequest(MBTA_Exception):
""" Raised if MBTA interpreted given request was invalid in syntax or in parameters. """
pass
class Mbta_Quotaexceeded(MBTA_Exception):
""" Raised when user has made too many requests. """
pass
|
#
# PySNMP MIB module CISCOSB-UDP (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCOSB-UDP
# Produced by pysmi-0.3.4 at Wed May 1 12:24:02 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
Integer, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
SingleValueConstraint, ValueRangeConstraint, ConstraintsIntersection, ValueSizeConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ValueRangeConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ConstraintsUnion")
switch001, = mibBuilder.importSymbols("CISCOSB-MIB", "switch001")
InetAddress, InetAddressType = mibBuilder.importSymbols("INET-ADDRESS-MIB", "InetAddress", "InetAddressType")
ipCidrRouteTos, ipCidrRouteDest, ipCidrRouteMask, ipCidrRouteNextHop, ipCidrRouteEntry = mibBuilder.importSymbols("IP-FORWARD-MIB", "ipCidrRouteTos", "ipCidrRouteDest", "ipCidrRouteMask", "ipCidrRouteNextHop", "ipCidrRouteEntry")
ipAddrEntry, = mibBuilder.importSymbols("IP-MIB", "ipAddrEntry")
rip2IfConfEntry, = mibBuilder.importSymbols("RFC1389-MIB", "rip2IfConfEntry")
ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup")
Counter32, iso, MibScalar, MibTable, MibTableRow, MibTableColumn, ObjectIdentity, NotificationType, Unsigned32, Bits, IpAddress, Counter64, Integer32, Gauge32, MibIdentifier, ModuleIdentity, TimeTicks = mibBuilder.importSymbols("SNMPv2-SMI", "Counter32", "iso", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ObjectIdentity", "NotificationType", "Unsigned32", "Bits", "IpAddress", "Counter64", "Integer32", "Gauge32", "MibIdentifier", "ModuleIdentity", "TimeTicks")
DisplayString, RowStatus, TruthValue, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "RowStatus", "TruthValue", "TextualConvention")
rsUDP = ModuleIdentity((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42))
rsUDP.setRevisions(('2004-06-01 00:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts: rsUDP.setRevisionsDescriptions(('Initial version of this MIB.',))
if mibBuilder.loadTexts: rsUDP.setLastUpdated('200406010000Z')
if mibBuilder.loadTexts: rsUDP.setOrganization('Cisco Small Business')
if mibBuilder.loadTexts: rsUDP.setContactInfo('Postal: 170 West Tasman Drive San Jose , CA 95134-1706 USA Website: Cisco Small Business Home http://www.cisco.com/smb>;, Cisco Small Business Support Community <http://www.cisco.com/go/smallbizsupport>')
if mibBuilder.loadTexts: rsUDP.setDescription('The private MIB module definition for switch001 UDP MIB.')
rsUdpRelayTable = MibTable((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 1), )
if mibBuilder.loadTexts: rsUdpRelayTable.setStatus('current')
if mibBuilder.loadTexts: rsUdpRelayTable.setDescription('This table contains the udp relay configuration per port.')
rsUdpRelayEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 1, 1), ).setIndexNames((0, "CISCOSB-UDP", "rsUdpRelayDstPort"), (0, "CISCOSB-UDP", "rsUdpRelaySrcIpInf"), (0, "CISCOSB-UDP", "rsUdpRelayDstIpAddr"))
if mibBuilder.loadTexts: rsUdpRelayEntry.setStatus('current')
if mibBuilder.loadTexts: rsUdpRelayEntry.setDescription(' The row definition for this table.')
rsUdpRelayDstPort = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 1, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rsUdpRelayDstPort.setStatus('current')
if mibBuilder.loadTexts: rsUdpRelayDstPort.setDescription('The UDP port number in the UDP message header.')
rsUdpRelaySrcIpInf = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 1, 1, 2), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rsUdpRelaySrcIpInf.setStatus('current')
if mibBuilder.loadTexts: rsUdpRelaySrcIpInf.setDescription('The source interface IP that receives UDP message. 255.255.255.255 from all IP interface. 0.0.0.0 - 0.255.255.255 and 127.0.0.0 - 127.255.255.255 not relevant addresses.')
rsUdpRelayDstIpAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 1, 1, 3), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rsUdpRelayDstIpAddr.setStatus('current')
if mibBuilder.loadTexts: rsUdpRelayDstIpAddr.setDescription('The destination IP address the UDP message will be forward. 0.0.0.0 does not forward, 255.255.255.255 broadcasts to all addresses.')
rsUdpRelayStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 1, 1, 4), RowStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rsUdpRelayStatus.setStatus('current')
if mibBuilder.loadTexts: rsUdpRelayStatus.setDescription('The status of a table entry. It is used to delete an entry from this table.')
rsUdpRelayUserInfo = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 1, 1, 5), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rsUdpRelayUserInfo.setStatus('current')
if mibBuilder.loadTexts: rsUdpRelayUserInfo.setDescription('The information used for implementation purposes')
rsUdpRelayMibVersion = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rsUdpRelayMibVersion.setStatus('current')
if mibBuilder.loadTexts: rsUdpRelayMibVersion.setDescription('Mib version. The current version is 1.')
rlUdpSessionTable = MibTable((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 3), )
if mibBuilder.loadTexts: rlUdpSessionTable.setStatus('current')
if mibBuilder.loadTexts: rlUdpSessionTable.setDescription('This table contains the udp sessions information')
rlUdpSessionEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 3, 1), ).setIndexNames((0, "CISCOSB-UDP", "rlUdpSessionLocalAddrType"), (0, "CISCOSB-UDP", "rlUdpSessionLocalAddr"), (0, "CISCOSB-UDP", "rlUdpSessionLocalPort"), (0, "CISCOSB-UDP", "rlUdpSessionAppInst"))
if mibBuilder.loadTexts: rlUdpSessionEntry.setStatus('current')
if mibBuilder.loadTexts: rlUdpSessionEntry.setDescription(' The row definition for this table.')
rlUdpSessionLocalAddrType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 3, 1, 1), InetAddressType())
if mibBuilder.loadTexts: rlUdpSessionLocalAddrType.setStatus('current')
if mibBuilder.loadTexts: rlUdpSessionLocalAddrType.setDescription('The type of the rlUdpSessionLocalAddress address')
rlUdpSessionLocalAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 3, 1, 2), InetAddress())
if mibBuilder.loadTexts: rlUdpSessionLocalAddr.setStatus('current')
if mibBuilder.loadTexts: rlUdpSessionLocalAddr.setDescription('The UDP port session number.')
rlUdpSessionLocalPort = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 3, 1, 3), Integer32())
if mibBuilder.loadTexts: rlUdpSessionLocalPort.setStatus('current')
if mibBuilder.loadTexts: rlUdpSessionLocalPort.setDescription('The UDP port local IP address.')
rlUdpSessionAppInst = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 3, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535)))
if mibBuilder.loadTexts: rlUdpSessionAppInst.setStatus('current')
if mibBuilder.loadTexts: rlUdpSessionAppInst.setDescription('The instance ID for the application on the port (for future use).')
rlUdpSessionAppName = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 3, 1, 5), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 12))).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlUdpSessionAppName.setStatus('current')
if mibBuilder.loadTexts: rlUdpSessionAppName.setDescription('The name of the application that created the session.')
mibBuilder.exportSymbols("CISCOSB-UDP", rsUdpRelayStatus=rsUdpRelayStatus, rlUdpSessionAppInst=rlUdpSessionAppInst, rsUdpRelayTable=rsUdpRelayTable, rlUdpSessionLocalPort=rlUdpSessionLocalPort, rsUdpRelayDstIpAddr=rsUdpRelayDstIpAddr, rlUdpSessionTable=rlUdpSessionTable, rlUdpSessionAppName=rlUdpSessionAppName, rlUdpSessionLocalAddrType=rlUdpSessionLocalAddrType, rsUdpRelayDstPort=rsUdpRelayDstPort, rsUDP=rsUDP, rsUdpRelayMibVersion=rsUdpRelayMibVersion, rsUdpRelaySrcIpInf=rsUdpRelaySrcIpInf, rsUdpRelayEntry=rsUdpRelayEntry, PYSNMP_MODULE_ID=rsUDP, rlUdpSessionLocalAddr=rlUdpSessionLocalAddr, rsUdpRelayUserInfo=rsUdpRelayUserInfo, rlUdpSessionEntry=rlUdpSessionEntry)
|
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_range_constraint, constraints_intersection, value_size_constraint, constraints_union) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'SingleValueConstraint', 'ValueRangeConstraint', 'ConstraintsIntersection', 'ValueSizeConstraint', 'ConstraintsUnion')
(switch001,) = mibBuilder.importSymbols('CISCOSB-MIB', 'switch001')
(inet_address, inet_address_type) = mibBuilder.importSymbols('INET-ADDRESS-MIB', 'InetAddress', 'InetAddressType')
(ip_cidr_route_tos, ip_cidr_route_dest, ip_cidr_route_mask, ip_cidr_route_next_hop, ip_cidr_route_entry) = mibBuilder.importSymbols('IP-FORWARD-MIB', 'ipCidrRouteTos', 'ipCidrRouteDest', 'ipCidrRouteMask', 'ipCidrRouteNextHop', 'ipCidrRouteEntry')
(ip_addr_entry,) = mibBuilder.importSymbols('IP-MIB', 'ipAddrEntry')
(rip2_if_conf_entry,) = mibBuilder.importSymbols('RFC1389-MIB', 'rip2IfConfEntry')
(module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup')
(counter32, iso, mib_scalar, mib_table, mib_table_row, mib_table_column, object_identity, notification_type, unsigned32, bits, ip_address, counter64, integer32, gauge32, mib_identifier, module_identity, time_ticks) = mibBuilder.importSymbols('SNMPv2-SMI', 'Counter32', 'iso', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'ObjectIdentity', 'NotificationType', 'Unsigned32', 'Bits', 'IpAddress', 'Counter64', 'Integer32', 'Gauge32', 'MibIdentifier', 'ModuleIdentity', 'TimeTicks')
(display_string, row_status, truth_value, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'RowStatus', 'TruthValue', 'TextualConvention')
rs_udp = module_identity((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42))
rsUDP.setRevisions(('2004-06-01 00:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts:
rsUDP.setRevisionsDescriptions(('Initial version of this MIB.',))
if mibBuilder.loadTexts:
rsUDP.setLastUpdated('200406010000Z')
if mibBuilder.loadTexts:
rsUDP.setOrganization('Cisco Small Business')
if mibBuilder.loadTexts:
rsUDP.setContactInfo('Postal: 170 West Tasman Drive San Jose , CA 95134-1706 USA Website: Cisco Small Business Home http://www.cisco.com/smb>;, Cisco Small Business Support Community <http://www.cisco.com/go/smallbizsupport>')
if mibBuilder.loadTexts:
rsUDP.setDescription('The private MIB module definition for switch001 UDP MIB.')
rs_udp_relay_table = mib_table((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 1))
if mibBuilder.loadTexts:
rsUdpRelayTable.setStatus('current')
if mibBuilder.loadTexts:
rsUdpRelayTable.setDescription('This table contains the udp relay configuration per port.')
rs_udp_relay_entry = mib_table_row((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 1, 1)).setIndexNames((0, 'CISCOSB-UDP', 'rsUdpRelayDstPort'), (0, 'CISCOSB-UDP', 'rsUdpRelaySrcIpInf'), (0, 'CISCOSB-UDP', 'rsUdpRelayDstIpAddr'))
if mibBuilder.loadTexts:
rsUdpRelayEntry.setStatus('current')
if mibBuilder.loadTexts:
rsUdpRelayEntry.setDescription(' The row definition for this table.')
rs_udp_relay_dst_port = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 1, 1, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rsUdpRelayDstPort.setStatus('current')
if mibBuilder.loadTexts:
rsUdpRelayDstPort.setDescription('The UDP port number in the UDP message header.')
rs_udp_relay_src_ip_inf = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 1, 1, 2), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rsUdpRelaySrcIpInf.setStatus('current')
if mibBuilder.loadTexts:
rsUdpRelaySrcIpInf.setDescription('The source interface IP that receives UDP message. 255.255.255.255 from all IP interface. 0.0.0.0 - 0.255.255.255 and 127.0.0.0 - 127.255.255.255 not relevant addresses.')
rs_udp_relay_dst_ip_addr = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 1, 1, 3), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rsUdpRelayDstIpAddr.setStatus('current')
if mibBuilder.loadTexts:
rsUdpRelayDstIpAddr.setDescription('The destination IP address the UDP message will be forward. 0.0.0.0 does not forward, 255.255.255.255 broadcasts to all addresses.')
rs_udp_relay_status = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 1, 1, 4), row_status()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rsUdpRelayStatus.setStatus('current')
if mibBuilder.loadTexts:
rsUdpRelayStatus.setDescription('The status of a table entry. It is used to delete an entry from this table.')
rs_udp_relay_user_info = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 1, 1, 5), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rsUdpRelayUserInfo.setStatus('current')
if mibBuilder.loadTexts:
rsUdpRelayUserInfo.setDescription('The information used for implementation purposes')
rs_udp_relay_mib_version = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 2), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rsUdpRelayMibVersion.setStatus('current')
if mibBuilder.loadTexts:
rsUdpRelayMibVersion.setDescription('Mib version. The current version is 1.')
rl_udp_session_table = mib_table((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 3))
if mibBuilder.loadTexts:
rlUdpSessionTable.setStatus('current')
if mibBuilder.loadTexts:
rlUdpSessionTable.setDescription('This table contains the udp sessions information')
rl_udp_session_entry = mib_table_row((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 3, 1)).setIndexNames((0, 'CISCOSB-UDP', 'rlUdpSessionLocalAddrType'), (0, 'CISCOSB-UDP', 'rlUdpSessionLocalAddr'), (0, 'CISCOSB-UDP', 'rlUdpSessionLocalPort'), (0, 'CISCOSB-UDP', 'rlUdpSessionAppInst'))
if mibBuilder.loadTexts:
rlUdpSessionEntry.setStatus('current')
if mibBuilder.loadTexts:
rlUdpSessionEntry.setDescription(' The row definition for this table.')
rl_udp_session_local_addr_type = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 3, 1, 1), inet_address_type())
if mibBuilder.loadTexts:
rlUdpSessionLocalAddrType.setStatus('current')
if mibBuilder.loadTexts:
rlUdpSessionLocalAddrType.setDescription('The type of the rlUdpSessionLocalAddress address')
rl_udp_session_local_addr = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 3, 1, 2), inet_address())
if mibBuilder.loadTexts:
rlUdpSessionLocalAddr.setStatus('current')
if mibBuilder.loadTexts:
rlUdpSessionLocalAddr.setDescription('The UDP port session number.')
rl_udp_session_local_port = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 3, 1, 3), integer32())
if mibBuilder.loadTexts:
rlUdpSessionLocalPort.setStatus('current')
if mibBuilder.loadTexts:
rlUdpSessionLocalPort.setDescription('The UDP port local IP address.')
rl_udp_session_app_inst = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 3, 1, 4), integer32().subtype(subtypeSpec=value_range_constraint(0, 65535)))
if mibBuilder.loadTexts:
rlUdpSessionAppInst.setStatus('current')
if mibBuilder.loadTexts:
rlUdpSessionAppInst.setDescription('The instance ID for the application on the port (for future use).')
rl_udp_session_app_name = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 42, 3, 1, 5), display_string().subtype(subtypeSpec=value_size_constraint(0, 12))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rlUdpSessionAppName.setStatus('current')
if mibBuilder.loadTexts:
rlUdpSessionAppName.setDescription('The name of the application that created the session.')
mibBuilder.exportSymbols('CISCOSB-UDP', rsUdpRelayStatus=rsUdpRelayStatus, rlUdpSessionAppInst=rlUdpSessionAppInst, rsUdpRelayTable=rsUdpRelayTable, rlUdpSessionLocalPort=rlUdpSessionLocalPort, rsUdpRelayDstIpAddr=rsUdpRelayDstIpAddr, rlUdpSessionTable=rlUdpSessionTable, rlUdpSessionAppName=rlUdpSessionAppName, rlUdpSessionLocalAddrType=rlUdpSessionLocalAddrType, rsUdpRelayDstPort=rsUdpRelayDstPort, rsUDP=rsUDP, rsUdpRelayMibVersion=rsUdpRelayMibVersion, rsUdpRelaySrcIpInf=rsUdpRelaySrcIpInf, rsUdpRelayEntry=rsUdpRelayEntry, PYSNMP_MODULE_ID=rsUDP, rlUdpSessionLocalAddr=rlUdpSessionLocalAddr, rsUdpRelayUserInfo=rsUdpRelayUserInfo, rlUdpSessionEntry=rlUdpSessionEntry)
|
def entry_id(entry):
for field in ['id', 'link']:
ret = getattr(entry, field, None)
if ret:
return ret
raise Exception('no id field found in entry: {}'.format(entry))
|
def entry_id(entry):
for field in ['id', 'link']:
ret = getattr(entry, field, None)
if ret:
return ret
raise exception('no id field found in entry: {}'.format(entry))
|
print("~" * 60)
print("Tower of Hanoi")
def hanoi(n, src, dst, tmp):
if n > 0:
hanoi(n - 1, src, tmp, dst)
print(f"Move disk {n} from {src} to {dst}")
hanoi(n - 1, tmp, dst, src)
hanoi(4, "A", "B", "C")
print("~" * 60)
print("8 Queens Problem")
queen = [0 for _ in range(8)]
rfree = [True for _ in range(8)]
du = [True for _ in range(15)]
dd = [True for _ in range(15)]
def solve(c):
global solutions
if c == 8:
solutions += 1
print(solutions, end=": ")
for r in range(8):
print(queen[r] + 1, end=" " if r < 7 else "\n")
else:
for r in range(8):
if rfree[r] and dd[c + r] and du[c + 7 - r]:
queen[c] = r
rfree[r] = dd[c + r] = du[c + 7 - r] = False
solve(c + 1)
rfree[r] = dd[c + r] = du[c + 7 - r] = True
solutions = 0
solve(0)
print(f"\nThere are {solutions} solutions")
|
print('~' * 60)
print('Tower of Hanoi')
def hanoi(n, src, dst, tmp):
if n > 0:
hanoi(n - 1, src, tmp, dst)
print(f'Move disk {n} from {src} to {dst}')
hanoi(n - 1, tmp, dst, src)
hanoi(4, 'A', 'B', 'C')
print('~' * 60)
print('8 Queens Problem')
queen = [0 for _ in range(8)]
rfree = [True for _ in range(8)]
du = [True for _ in range(15)]
dd = [True for _ in range(15)]
def solve(c):
global solutions
if c == 8:
solutions += 1
print(solutions, end=': ')
for r in range(8):
print(queen[r] + 1, end=' ' if r < 7 else '\n')
else:
for r in range(8):
if rfree[r] and dd[c + r] and du[c + 7 - r]:
queen[c] = r
rfree[r] = dd[c + r] = du[c + 7 - r] = False
solve(c + 1)
rfree[r] = dd[c + r] = du[c + 7 - r] = True
solutions = 0
solve(0)
print(f'\nThere are {solutions} solutions')
|
class Function:
def __init__(self, name, param_types, return_type, line=0):
self.name = name
self.param_types = param_types
self.return_type = return_type
self.line = line
def __str__(self):
return Function.__qualname__
def getattr(self, name):
raise AttributeError("Invalid attribute or method access")
|
class Function:
def __init__(self, name, param_types, return_type, line=0):
self.name = name
self.param_types = param_types
self.return_type = return_type
self.line = line
def __str__(self):
return Function.__qualname__
def getattr(self, name):
raise attribute_error('Invalid attribute or method access')
|
class Solution:
def minStartValue(self, nums: List[int]) -> int:
total = minSum = 0
for num in nums:
total += num
minSum = min(minSum, total)
return 1 - minSum
|
class Solution:
def min_start_value(self, nums: List[int]) -> int:
total = min_sum = 0
for num in nums:
total += num
min_sum = min(minSum, total)
return 1 - minSum
|
def conduit_login(driver):
driver.find_element_by_xpath('//a[@href="#/login"]').click()
driver.find_element_by_xpath('//input[@placeholder="Email"]').send_keys("testmail61@test.hu")
driver.find_element_by_xpath('//input[@placeholder="Password"]').send_keys("Testpass1")
driver.find_element_by_xpath('//*[@id="app"]//form/button').click()
def conduit_logout(driver):
driver.find_element_by_xpath('//*[@id="app"]/nav/div/ul/li[5]/a').click()
|
def conduit_login(driver):
driver.find_element_by_xpath('//a[@href="#/login"]').click()
driver.find_element_by_xpath('//input[@placeholder="Email"]').send_keys('testmail61@test.hu')
driver.find_element_by_xpath('//input[@placeholder="Password"]').send_keys('Testpass1')
driver.find_element_by_xpath('//*[@id="app"]//form/button').click()
def conduit_logout(driver):
driver.find_element_by_xpath('//*[@id="app"]/nav/div/ul/li[5]/a').click()
|
class Node():
def __init__(self, val):
self.val = val
self.adjacent_nodes = []
self.visited = False
# O(E^d) where d is depth
def word_transform(w1, w2, dictionary):
# make dictionary into linked list
start_node = Node(w1)
end_node = Node(w2)
nodes = [start_node, end_node]
nodes_dict = {start_node.val: start_node, end_node.val: end_node}
while nodes:
node = nodes.pop()
word = node.val
for w in dictionary:
if w == word:
continue
diff = 0
for i in range(len(word)):
if w[i] != word[i]:
diff += 1
diff += abs(len(word) - len(w))
if diff == 1:
if w not in nodes_dict:
nodes_dict[w] = Node(w)
nodes.append(nodes_dict[w])
node.adjacent_nodes.append(nodes_dict[w])
nodes = [start_node]
path = []
while nodes:
node = nodes.pop()
if node == end_node:
path.append(node.val)
return ''.join(path)
path.append(node.val + ' -> ')
node.visited = True
for c in node.adjacent_nodes:
if not c.visited:
nodes.append(c)
return None
|
class Node:
def __init__(self, val):
self.val = val
self.adjacent_nodes = []
self.visited = False
def word_transform(w1, w2, dictionary):
start_node = node(w1)
end_node = node(w2)
nodes = [start_node, end_node]
nodes_dict = {start_node.val: start_node, end_node.val: end_node}
while nodes:
node = nodes.pop()
word = node.val
for w in dictionary:
if w == word:
continue
diff = 0
for i in range(len(word)):
if w[i] != word[i]:
diff += 1
diff += abs(len(word) - len(w))
if diff == 1:
if w not in nodes_dict:
nodes_dict[w] = node(w)
nodes.append(nodes_dict[w])
node.adjacent_nodes.append(nodes_dict[w])
nodes = [start_node]
path = []
while nodes:
node = nodes.pop()
if node == end_node:
path.append(node.val)
return ''.join(path)
path.append(node.val + ' -> ')
node.visited = True
for c in node.adjacent_nodes:
if not c.visited:
nodes.append(c)
return None
|
# leetcode
class Solution:
def mincostTickets(self, days: List[int], costs: List[int]) -> int:
num = 366
one, seven, thirty = costs
dp = [0] * num
idx = 0
for i in range(1, num):
dp[i] = dp[i-1]
if i == days[idx]:
dp[i] = min(
one+dp[i-1 if i-1>0 else 0],
seven+dp[i-7 if i-7>0 else 0],
thirty+dp[i-30 if i-30>0 else 0]
)
if idx != len(days)-1:
idx += 1
else:
break
return dp[days[idx]]
|
class Solution:
def mincost_tickets(self, days: List[int], costs: List[int]) -> int:
num = 366
(one, seven, thirty) = costs
dp = [0] * num
idx = 0
for i in range(1, num):
dp[i] = dp[i - 1]
if i == days[idx]:
dp[i] = min(one + dp[i - 1 if i - 1 > 0 else 0], seven + dp[i - 7 if i - 7 > 0 else 0], thirty + dp[i - 30 if i - 30 > 0 else 0])
if idx != len(days) - 1:
idx += 1
else:
break
return dp[days[idx]]
|
'''
The Python repository "AA" contains the scripts, data,
figures, and text for nudged Arctic Amplification (AA) and
Upper-troposphere Tropical Warming (UTW). The model is SC-WACCM4.
We are interested in the large-scale atmospheric response to
Arctic sea ice loss in AA simulations compared to sea-ice forcing.
See Peings, Cattiaux, and Magnusdottir, GRL (2019) for model set-up.
Author: Zachary Labe (zlabe@uci.edu)
'''
|
"""
The Python repository "AA" contains the scripts, data,
figures, and text for nudged Arctic Amplification (AA) and
Upper-troposphere Tropical Warming (UTW). The model is SC-WACCM4.
We are interested in the large-scale atmospheric response to
Arctic sea ice loss in AA simulations compared to sea-ice forcing.
See Peings, Cattiaux, and Magnusdottir, GRL (2019) for model set-up.
Author: Zachary Labe (zlabe@uci.edu)
"""
|
# employees = {'marge': 3, 'mag': 2}
# employees['phil'] = '5'
# print(employees.values())
# new_list = list(iter(employees))
# for key, value in employees.iteritems():
# print(key,value)
# print(new_list)
# t = ('a', 'b', 'c', 'd')
# print(t.index('c'))
# print(1 > 2)
# myfile = open('test_file.txt')
# read = myfile.read()
# print(read)
# with open('test_file.txt') as myfile:
# read = myfile.read()
# print(read)
f = open('second_file.txt')
lines = f.read()
print(lines)
|
f = open('second_file.txt')
lines = f.read()
print(lines)
|
sample_pos_100_circle = {
(0, 12, 14, 28, 61, 76) : (0.6606687940575429, 0.12955294286970329, 0.1392231402857147),
(0, 14, 26, 28, 61, 76) : (0.6775622847685568, 0.0898623709846611, 0.14956067316950022),
(0, 11, 12, 14, 23, 28, 42, 44, 76, 79, 89) : (0.6065886283561139, 0.20320288122581232, 0.14005207871339437),
(0, 11, 12, 14, 23, 42, 44, 76, 79, 89, 98) : (0.5656826490913177, 0.22945537874500058, 0.14709530367632542),
(0, 12, 14, 23, 42, 44, 89, 90, 98) : (0.49723213477453154, 0.23278842941402605, 0.14874812754801625),
(0, 12, 14, 42, 43, 44, 89, 90, 98) : (0.4531982657491745, 0.21474447325341245, 0.14781957286366254),
(0, 12, 14, 42, 44, 60, 89, 90, 98) : (0.4269561884232388, 0.19727225941604984, 0.1493885409990972),
(1, 8, 15, 22, 27, 28, 51, 53, 62, 74, 76) : (0.846301261746641, 0.18166537169350574, 0.14397835552200322),
(1, 8, 13, 15, 27, 28, 39, 51, 53, 62, 74, 76) : (0.8485490407639608, 0.26577545830529575, 0.14237104291986868),
(1, 8, 13, 15, 27, 39, 51, 53, 55, 62, 74) : (0.8598700336382776, 0.2936319361757566, 0.14316008940627623),
(8, 13, 15, 27, 39, 51, 53, 55, 62, 74, 76) : (0.848475421386148, 0.2979123559117623, 0.1495723404911163),
(8, 15, 22, 27, 28, 51, 53, 61, 74, 76) : (0.8313716731911684, 0.15951059780677493, 0.14984734652985005),
(1, 15, 22, 26, 27, 28, 51, 53, 61, 74) : (0.8707649166253553, 0.12603886971740247, 0.14915740644860379),
(15, 22, 26, 27, 28, 51, 53, 61, 74, 76) : (0.8365094688174124, 0.15377823301715582, 0.1482384443600522),
(1, 8, 15, 27, 39, 51, 53, 55, 57, 62, 74) : (0.8744674026914928, 0.32488477158328966, 0.14993334330995228),
(8, 13, 27, 39, 51, 53, 55, 57, 62, 74, 76) : (0.8394379542077309, 0.3149880381645896, 0.14976819860224347),
(2, 7, 46, 54, 57, 77) : (0.8345091660588192, 0.583756096334454, 0.12229815996364714),
(2, 39, 46, 55, 57, 77) : (0.9084352576938933, 0.5098903011547264, 0.14572090388150585),
(2, 7, 46, 54, 67, 77, 78) : (0.812411509094655, 0.6641080591492242, 0.14888487099965556),
(2, 7, 35, 46, 54, 67, 77, 82, 95) : (0.8518389325402812, 0.6847232482307565, 0.14327587769420472),
(2, 7, 35, 54, 67, 77, 82, 93, 95) : (0.9204975034212663, 0.7431093346713038, 0.14939837995538113),
(3, 29, 30, 34, 45, 65, 86, 94, 97) : (0.1004320333187312, 0.25448500386219897, 0.13457985828835478),
(3, 30, 34, 45, 52, 65, 70, 86, 94, 97) : (0.13232166150446328, 0.1787966932430779, 0.14148065167771823),
(3, 30, 33, 45, 52, 65, 70, 86, 94, 97) : (0.10213454221898952, 0.158512554500736, 0.14562465660768442),
(3, 30, 34, 45, 52, 60, 65, 86, 94, 97) : (0.16328756540749167, 0.2126428426271769, 0.14578456301618062),
(3, 34, 45, 52, 60, 65, 70, 86, 94, 97) : (0.17797832456706061, 0.19683196747732873, 0.14011636481529072),
(3, 30, 34, 45, 50, 60, 65, 86, 94, 97) : (0.1553910862561932, 0.23765246912401705, 0.14827548821813938),
(29, 30, 34, 45, 50, 60, 65, 86, 94, 97) : (0.15000102162768236, 0.30018732583286084, 0.14984415048071437),
(4, 9, 10, 20, 38, 75, 81) : (0.4003130616293591, 0.8285844456813044, 0.1480307501034011),
(4, 9, 10, 38, 48, 75, 81) : (0.38580428031766406, 0.8561990999547606, 0.14870245579695562),
(4, 9, 17, 20, 21, 38, 48, 75, 81, 85) : (0.3287611424267173, 0.7727174414557608, 0.14875929774485536),
(4, 9, 21, 38, 48, 68, 75, 81) : (0.35085609036236404, 0.829788163067764, 0.14875398876294763),
(4, 10, 18, 48, 68, 75, 81) : (0.37649547612262557, 0.8951760847630872, 0.14919996648688127),
(4, 9, 19, 20, 21, 38, 49, 75, 85) : (0.41640100306849537, 0.705093150372995, 0.14015996098823705),
(4, 9, 17, 20, 21, 38, 64, 75, 81, 85) : (0.33085298603236063, 0.7418399215994397, 0.14487972439785962),
(4, 17, 20, 21, 38, 48, 64, 75, 81, 85) : (0.3193974850937622, 0.7680632820869213, 0.1474266580607778),
(4, 9, 17, 20, 21, 38, 49, 64, 75, 85) : (0.34114170574087294, 0.6969174305624999, 0.14405921509093017),
(9, 19, 20, 38, 49, 75, 87) : (0.5006885871277305, 0.7412338818491877, 0.1451388894436533),
(4, 9, 10, 75, 80, 81) : (0.4019264767473983, 0.8734149403352809, 0.14482927195072062),
(4, 10, 18, 48, 75, 80, 81) : (0.3830407940310534, 0.8944881167840582, 0.14681390420878215),
(4, 18, 32, 48, 56, 68, 69, 75, 81) : (0.3229807880040072, 0.8650666484497739, 0.14809708296773283),
(4, 10, 18, 48, 56, 68, 80, 81) : (0.37683713029076393, 0.911312260609274, 0.14832443190916603),
(4, 17, 21, 32, 38, 48, 64, 66, 68, 69, 75, 81, 85) : (0.28091256649751173, 0.7845716212169753, 0.141585496443792),
(4, 18, 21, 32, 38, 48, 64, 66, 68, 69, 75, 81) : (0.28070798853230206, 0.8090664742306333, 0.14931465362464058),
(4, 17, 20, 21, 38, 64, 66, 75, 81, 85) : (0.29785238436809, 0.7234263474491083, 0.1490540650472151),
(4, 18, 21, 32, 48, 56, 66, 68, 69, 81, 96) : (0.26699140597300897, 0.8495296776189856, 0.14875348880939057),
(4, 18, 21, 32, 38, 48, 64, 66, 68, 69, 81, 96) : (0.25527949109936104, 0.8106316384539816, 0.1445317451825426),
(4, 17, 21, 32, 38, 48, 64, 66, 68, 69, 81, 85, 96) : (0.23217561230891856, 0.7805372979198325, 0.14511838625757928),
(4, 9, 10, 19, 20, 38, 71, 75, 87) : (0.4775129839401001, 0.7927769793318314, 0.14462380860637297),
(4, 9, 10, 20, 71, 75, 80, 87) : (0.4747088359878572, 0.8297948931425277, 0.14678768577566298),
(9, 10, 19, 20, 71, 75, 80, 87) : (0.502030117116463, 0.8236087646816392, 0.14943676014695212),
(4, 18, 32, 48, 56, 58, 66, 68, 69, 72, 81, 96) : (0.21696064154531802, 0.874101533075222, 0.13041150648755526),
(4, 18, 21, 32, 48, 58, 64, 66, 68, 69, 72, 81, 96) : (0.20114669372366326, 0.8301128240778305, 0.1493335313715823),
(4, 17, 21, 38, 64, 66, 69, 81, 85, 99) : (0.21769657381971141, 0.7313388234347639, 0.14701057273298804),
(4, 17, 21, 32, 48, 64, 66, 69, 81, 85, 96, 99) : (0.2015477050911515, 0.7529044317010726, 0.1494589238432731),
(20, 25, 31, 49, 59, 84) : (0.4258087319921411, 0.5401043228214542, 0.14745116571790448),
(5, 24, 25, 31, 41, 43, 49, 59, 84, 90) : (0.37662482838264727, 0.4751123959489456, 0.1496946360540124),
(5, 17, 20, 24, 25, 31, 38, 41, 49, 85) : (0.3622865226400378, 0.5612057389900295, 0.14877040889503995),
(5, 17, 21, 24, 25, 31, 38, 41, 49, 85) : (0.3397797027650458, 0.5662701001128034, 0.14899731011520068),
(17, 20, 21, 24, 25, 31, 38, 41, 49, 85) : (0.3529122532222511, 0.5772058553558765, 0.145641194646832),
(5, 24, 25, 31, 41, 43, 50, 84, 90) : (0.36744835703496576, 0.44513805791935623, 0.149017727518376),
(5, 17, 24, 25, 41, 50) : (0.25238459020708376, 0.49714842367609063, 0.14920289957040228),
(5, 24, 25, 31, 43, 50, 59, 83, 84, 90) : (0.3742525826195432, 0.4225237020811445, 0.14492114513872695),
(5, 11, 23, 31, 43, 44, 59, 63, 84, 89, 90) : (0.46586820074056295, 0.38692285503826956, 0.14938930201395317),
(5, 25, 31, 43, 50, 59, 60, 83, 84, 90) : (0.37465236999713214, 0.3967343268979738, 0.14793274615561394),
(5, 24, 25, 31, 43, 50, 60, 83, 84, 90) : (0.3666595366409718, 0.4029451066437212, 0.14935861884170346),
(5, 24, 25, 31, 41, 43, 50, 60, 83, 90) : (0.3374953446014549, 0.40768326591677895, 0.14271109555895584),
(5, 11, 23, 31, 43, 44, 59, 84, 89, 90, 98) : (0.46179357379075087, 0.37130700578519776, 0.14959106548201262),
(5, 31, 43, 44, 50, 59, 60, 83, 84, 89, 90, 98) : (0.3992944529514407, 0.34835251138844014, 0.14481894164813303),
(5, 24, 25, 34, 41, 43, 50, 60, 83, 86, 90) : (0.2643514690001076, 0.38046461029115597, 0.13200682283744283),
(5, 42, 43, 44, 59, 60, 83, 84, 89, 90, 98) : (0.4251496043395029, 0.314317932764338, 0.14818426431967247),
(5, 42, 43, 44, 50, 60, 83, 89, 90, 98) : (0.3896204611486524, 0.2884476340796184, 0.14766772614257698),
(5, 34, 43, 50, 60, 65, 83, 89, 90, 98) : (0.35484204032889544, 0.28298632126058126, 0.14896339447527998),
(5, 24, 34, 41, 43, 50, 60, 65, 83, 86, 90) : (0.24186208866496334, 0.35381703763650374, 0.147248332994493),
(42, 43, 50, 60, 65, 83, 89, 90, 98) : (0.3648226358119667, 0.2529208238960593, 0.14563258715152547),
(5, 17, 21, 24, 25, 41, 64, 85) : (0.26509967721642796, 0.5547482058021883, 0.1467474135798299),
(17, 20, 21, 24, 25, 38, 41, 49, 64, 85) : (0.3204205925258258, 0.6110698164118312, 0.1433963240190826),
(5, 24, 34, 41, 50, 60, 65, 83, 86, 94) : (0.1963459614878132, 0.354221443943041, 0.1499119871156634),
(5, 34, 43, 50, 60, 65, 83, 86, 90, 97, 98) : (0.2786672893971936, 0.2764212575028138, 0.148038361569061),
(6, 8, 13, 36, 39, 46, 57, 79, 91) : (0.7812938642651628, 0.40869196155963294, 0.1483179196387932),
(6, 11, 13, 36, 39, 46, 57, 63, 79, 91) : (0.7400403080009023, 0.4149028417553895, 0.14959527944822024),
(6, 11, 13, 23, 36, 40, 46, 57, 63, 79, 91) : (0.6955733914381548, 0.4466149890794219, 0.14332938261511524),
(6, 11, 23, 36, 40, 46, 59, 63, 91) : (0.661799803852757, 0.47465268914249026, 0.14990023270177139),
(6, 11, 13, 23, 36, 40, 57, 59, 63, 79, 91) : (0.6674444223364877, 0.44592897980175666, 0.1493799596176158),
(6, 8, 11, 13, 23, 36, 39, 57, 63, 76, 79, 91) : (0.7479505156724652, 0.3543364256041871, 0.14504949210030488),
(6, 36, 40, 46, 57, 78) : (0.6989923716784051, 0.5550188424375802, 0.14881436260536204),
(6, 11, 13, 23, 36, 40, 44, 59, 63, 79, 84, 91) : (0.6121508102053388, 0.4160214927121739, 0.13919367839740476),
(6, 11, 23, 31, 36, 40, 44, 59, 63, 79, 84, 91) : (0.5840006753840745, 0.425262952856729, 0.13453194363310325),
(6, 7, 40, 46, 54, 57, 78) : (0.7359758275738826, 0.5714274758487573, 0.1459224915245561),
(6, 19, 40, 46, 54, 78) : (0.6804138212873839, 0.6024152093385852, 0.14958356907798287),
(7, 19, 40, 46, 54, 78) : (0.7001663606329307, 0.6736530749126453, 0.145581886573751),
(6, 11, 12, 23, 31, 36, 44, 59, 63, 79, 84, 89, 91) : (0.5546692350232861, 0.3748947382581936, 0.1404608810549469),
(6, 11, 12, 13, 23, 36, 44, 59, 63, 76, 79, 84, 89, 91) : (0.6158471277538801, 0.33210754135354276, 0.13695160632128495),
(6, 19, 40, 49, 78) : (0.5898959630882554, 0.5849837349401764, 0.1395478206848745),
(6, 19, 31, 40, 49, 59, 84) : (0.5508159716065527, 0.5507115624444804, 0.13320543730746362),
(6, 31, 40, 49, 59, 63, 84) : (0.5334868035040657, 0.4969112537149139, 0.13520536905611247),
(6, 11, 12, 23, 31, 43, 44, 59, 63, 79, 84, 89, 90, 91) : (0.5248341660288149, 0.3695285456138079, 0.14898478769694384),
(16, 19, 40, 54, 78) : (0.648734030229264, 0.69772769100568, 0.14566639395175016),
(7, 16, 19, 54, 78, 92) : (0.7017301747157373, 0.7018096583710086, 0.14788217314648738),
(7, 35, 46, 54, 67, 77, 78, 92, 95) : (0.8016668768331154, 0.7050427315864585, 0.14885954882353508),
(7, 35, 54, 67, 77, 78, 82, 92, 95) : (0.8126860837487624, 0.7390030277575786, 0.14963827070744815),
(7, 35, 54, 67, 77, 82, 92, 93, 95) : (0.8541983606053255, 0.7617510039302191, 0.13551854101469707),
(7, 16, 35, 54, 67, 78, 92, 93, 95) : (0.7835123617757969, 0.7940004134527878, 0.14850931037307125),
(7, 35, 54, 67, 73, 82, 92, 93, 95) : (0.8680257488645291, 0.8105733497073806, 0.14461010599432164),
(16, 35, 54, 67, 73, 92, 93, 95) : (0.8039052049993555, 0.8358136241307832, 0.1460176815171897),
(8, 13, 27, 28, 36, 39, 51, 62, 74, 76, 79) : (0.7864858215585857, 0.29075158032698684, 0.14961460741813482),
(8, 13, 27, 28, 36, 39, 62, 74, 76, 79, 91) : (0.7851472504933936, 0.30671346343945144, 0.14266494791580994),
(8, 13, 27, 36, 39, 57, 62, 74, 76, 79, 91) : (0.7947045059120503, 0.31997763795542744, 0.14446794140299074),
(8, 11, 13, 23, 27, 28, 36, 74, 76, 79, 91) : (0.7372472238258292, 0.2715103777107627, 0.14815884891492234),
(8, 11, 13, 23, 36, 39, 57, 74, 76, 79, 91) : (0.7536701632685218, 0.3264131965382456, 0.1499762709695208),
(8, 11, 13, 23, 28, 36, 39, 63, 74, 76, 79, 91) : (0.7432076014100258, 0.3161679754031407, 0.14735220435952692),
(8, 13, 36, 39, 55, 57, 62, 74) : (0.8270244719636314, 0.3463770009824643, 0.14816894016641344),
(8, 13, 36, 39, 46, 55, 57) : (0.8315524471930096, 0.4208862595245414, 0.14308143530640893),
(9, 19, 20, 49, 75, 78, 87) : (0.526255574364575, 0.7284182151763334, 0.1445142284421115),
(9, 10, 16, 19, 20, 71, 75, 78, 87) : (0.5503029395762983, 0.7725028563327712, 0.1379855198507884),
(9, 19, 20, 40, 49, 75, 78) : (0.5308236138060022, 0.6654717052596012, 0.14166070888466),
(9, 16, 19, 40, 78) : (0.6152792270448181, 0.7022038051249079, 0.14724540705027672),
(9, 19, 20, 31, 38, 49, 75, 85) : (0.4397878732528429, 0.6157549414177731, 0.1379389073709895),
(9, 19, 20, 31, 40, 49, 75) : (0.48958920540021267, 0.6234521812075917, 0.14685558331482343),
(9, 10, 16, 19, 71, 75, 80, 87) : (0.5310332240866265, 0.8284058748099863, 0.14651673216295627),
(9, 10, 16, 19, 71, 78, 87, 92) : (0.6106510896880954, 0.7958501908923952, 0.1430714723104721),
(10, 16, 71, 80, 87, 92) : (0.6264282483677088, 0.9079762183947514, 0.1358534990005984),
(11, 12, 23, 31, 42, 43, 44, 59, 63, 84, 89, 90, 98) : (0.4776061998845129, 0.3308921514293687, 0.14948378198882384),
(11, 12, 14, 23, 42, 43, 44, 59, 63, 79, 84, 89, 90, 98) : (0.5190100909516181, 0.3024309974602939, 0.1461597643756266),
(11, 12, 23, 31, 43, 44, 59, 63, 79, 84, 89, 90, 98) : (0.5167680750767972, 0.3408073723414071, 0.1494775277829455),
(11, 12, 14, 23, 42, 44, 59, 63, 79, 84, 89, 90, 91, 98) : (0.5353432225094631, 0.3092813311287071, 0.14961247846229375),
(11, 12, 23, 42, 43, 44, 59, 63, 79, 84, 89, 90, 91, 98) : (0.5269080789204658, 0.3272778263063749, 0.1492860996243205),
(11, 12, 14, 23, 42, 44, 63, 76, 79, 89, 98) : (0.5651889224135658, 0.24974452994663424, 0.1481860442866704),
(11, 12, 13, 14, 23, 42, 44, 59, 63, 76, 79, 84, 89, 91) : (0.5810248153025497, 0.297301468717096, 0.14553280939641036),
(11, 12, 13, 14, 23, 36, 44, 59, 63, 76, 79, 84, 89, 91) : (0.59020808374762, 0.30242702351356676, 0.14518706205274268),
(11, 12, 13, 14, 23, 28, 42, 44, 63, 76, 79, 89, 91) : (0.6206933635449503, 0.24682154651736443, 0.14397395607960825),
(11, 12, 13, 14, 23, 28, 36, 44, 63, 76, 79, 89, 91) : (0.6443421994012091, 0.27263136238807373, 0.1418464361759105),
(11, 12, 13, 14, 23, 28, 74, 76, 79, 91) : (0.6865690251676432, 0.23557064983017745, 0.1497576533972519),
(11, 12, 13, 23, 28, 36, 63, 74, 76, 79, 91) : (0.7095105226389335, 0.27798372862136267, 0.145811382266761),
(12, 13, 27, 28, 74, 76, 79) : (0.7163112725430478, 0.21385230043077974, 0.14778176906674004),
(12, 14, 28, 61, 74, 76) : (0.692614694039914, 0.15857646831069733, 0.14455379460889162),
(12, 23, 42, 43, 44, 59, 83, 84, 89, 90, 98) : (0.4563543195907547, 0.31480881243674935, 0.14922880337038014),
(12, 23, 31, 43, 44, 59, 83, 84, 89, 90, 98) : (0.45419723615723284, 0.32960642809424645, 0.1499761920887504),
(12, 14, 42, 43, 44, 60, 83, 89, 90, 98) : (0.42955231039420116, 0.2226100668877384, 0.14110959536132095),
(12, 42, 43, 44, 59, 60, 83, 84, 89, 90, 98) : (0.4402325483015652, 0.3046223156987031, 0.14721181227676056),
(14, 22, 28, 61, 74, 76) : (0.7017172984423354, 0.12325899188468137, 0.14999980732453855),
(14, 22, 26, 28, 61, 76) : (0.6912503728261168, 0.10016189310233165, 0.14784082552996525),
(16, 19, 54, 71, 78, 87, 92) : (0.6703761804849702, 0.7581413028998242, 0.13727248723415264),
(16, 54, 71, 78, 87, 92, 95) : (0.7055796088125853, 0.8042768799273943, 0.13751533041746666),
(16, 71, 92, 93, 95) : (0.748680649656, 0.8792981719129548, 0.14810534432725672),
(16, 35, 47, 73, 92, 93, 95) : (0.7973963974798904, 0.8730772012592461, 0.14251677211486202),
(17, 20, 21, 25, 38, 49, 64, 75, 85) : (0.33122073385849954, 0.6424372081216861, 0.140272333871763),
(17, 20, 21, 25, 31, 38, 49, 75, 85) : (0.3899560099849434, 0.6080529827711362, 0.14686618715840474),
(17, 21, 24, 25, 38, 41, 64, 66, 85, 99) : (0.2324845209042679, 0.6381836480533993, 0.14541606090517503),
(17, 21, 24, 25, 41, 64, 66, 85, 88, 99) : (0.17759327332460764, 0.6154216464660676, 0.14680527616816053),
(17, 21, 64, 66, 69, 85, 88, 99) : (0.1700753673132927, 0.7010807602993253, 0.14829695794446568),
(17, 21, 64, 66, 69, 88, 96, 99) : (0.14057040165146145, 0.7404980045079362, 0.14458712542500857),
(21, 32, 64, 66, 69, 88, 96, 99) : (0.13589958287585685, 0.7521082386304109, 0.14938908416349977),
(32, 37, 48, 58, 64, 66, 68, 69, 72, 81, 96) : (0.1587853817899879, 0.8265085757585824, 0.14669323412266905),
(18, 32, 37, 48, 56, 58, 66, 68, 69, 72, 81, 96) : (0.1565898330981594, 0.900576785386657, 0.14039118879912008),
(19, 20, 31, 40, 49, 59, 84) : (0.4955100051053224, 0.5592196556545426, 0.13807852710419102),
(29, 88) : (0.021898984551369127, 0.498905674871803, 0.14491984926943427),
(24, 29, 34, 41, 50, 86, 94) : (0.15186115338348286, 0.38521837733842534, 0.14484075712621175),
(29, 30, 34, 41, 50, 86, 94) : (0.1318289821876929, 0.3907884062675565, 0.14663186091122857),
(30, 34, 45, 50, 60, 65, 83, 86, 94, 97) : (0.17218506307174686, 0.2745348904559653, 0.13778262145170894),
(34, 45, 52, 60, 65, 70, 83, 86, 94, 97) : (0.1946945060242287, 0.20205232918260238, 0.14600384549982623),
(34, 45, 50, 60, 65, 70, 83, 86, 94, 97) : (0.1984942686851189, 0.20938746372536046, 0.14945353002055525),
(32, 37, 48, 64, 66, 69, 81, 96, 99) : (0.13998817052833173, 0.7858689353702485, 0.14814097529549805),
(32, 37, 64, 66, 69, 88, 96, 99) : (0.111022615751386, 0.7676327866502684, 0.1464828433048606),
(34, 60, 65, 70, 83, 86, 97, 98) : (0.27881170846041564, 0.18823061782622416, 0.14535381423478827),
(35, 47, 67, 73, 82, 92, 93, 95) : (0.8668407448339298, 0.8654424303052715, 0.12317143039084451),
}
|
sample_pos_100_circle = {(0, 12, 14, 28, 61, 76): (0.6606687940575429, 0.12955294286970329, 0.1392231402857147), (0, 14, 26, 28, 61, 76): (0.6775622847685568, 0.0898623709846611, 0.14956067316950022), (0, 11, 12, 14, 23, 28, 42, 44, 76, 79, 89): (0.6065886283561139, 0.20320288122581232, 0.14005207871339437), (0, 11, 12, 14, 23, 42, 44, 76, 79, 89, 98): (0.5656826490913177, 0.22945537874500058, 0.14709530367632542), (0, 12, 14, 23, 42, 44, 89, 90, 98): (0.49723213477453154, 0.23278842941402605, 0.14874812754801625), (0, 12, 14, 42, 43, 44, 89, 90, 98): (0.4531982657491745, 0.21474447325341245, 0.14781957286366254), (0, 12, 14, 42, 44, 60, 89, 90, 98): (0.4269561884232388, 0.19727225941604984, 0.1493885409990972), (1, 8, 15, 22, 27, 28, 51, 53, 62, 74, 76): (0.846301261746641, 0.18166537169350574, 0.14397835552200322), (1, 8, 13, 15, 27, 28, 39, 51, 53, 62, 74, 76): (0.8485490407639608, 0.26577545830529575, 0.14237104291986868), (1, 8, 13, 15, 27, 39, 51, 53, 55, 62, 74): (0.8598700336382776, 0.2936319361757566, 0.14316008940627623), (8, 13, 15, 27, 39, 51, 53, 55, 62, 74, 76): (0.848475421386148, 0.2979123559117623, 0.1495723404911163), (8, 15, 22, 27, 28, 51, 53, 61, 74, 76): (0.8313716731911684, 0.15951059780677493, 0.14984734652985005), (1, 15, 22, 26, 27, 28, 51, 53, 61, 74): (0.8707649166253553, 0.12603886971740247, 0.14915740644860379), (15, 22, 26, 27, 28, 51, 53, 61, 74, 76): (0.8365094688174124, 0.15377823301715582, 0.1482384443600522), (1, 8, 15, 27, 39, 51, 53, 55, 57, 62, 74): (0.8744674026914928, 0.32488477158328966, 0.14993334330995228), (8, 13, 27, 39, 51, 53, 55, 57, 62, 74, 76): (0.8394379542077309, 0.3149880381645896, 0.14976819860224347), (2, 7, 46, 54, 57, 77): (0.8345091660588192, 0.583756096334454, 0.12229815996364714), (2, 39, 46, 55, 57, 77): (0.9084352576938933, 0.5098903011547264, 0.14572090388150585), (2, 7, 46, 54, 67, 77, 78): (0.812411509094655, 0.6641080591492242, 0.14888487099965556), (2, 7, 35, 46, 54, 67, 77, 82, 95): (0.8518389325402812, 0.6847232482307565, 0.14327587769420472), (2, 7, 35, 54, 67, 77, 82, 93, 95): (0.9204975034212663, 0.7431093346713038, 0.14939837995538113), (3, 29, 30, 34, 45, 65, 86, 94, 97): (0.1004320333187312, 0.25448500386219897, 0.13457985828835478), (3, 30, 34, 45, 52, 65, 70, 86, 94, 97): (0.13232166150446328, 0.1787966932430779, 0.14148065167771823), (3, 30, 33, 45, 52, 65, 70, 86, 94, 97): (0.10213454221898952, 0.158512554500736, 0.14562465660768442), (3, 30, 34, 45, 52, 60, 65, 86, 94, 97): (0.16328756540749167, 0.2126428426271769, 0.14578456301618062), (3, 34, 45, 52, 60, 65, 70, 86, 94, 97): (0.17797832456706061, 0.19683196747732873, 0.14011636481529072), (3, 30, 34, 45, 50, 60, 65, 86, 94, 97): (0.1553910862561932, 0.23765246912401705, 0.14827548821813938), (29, 30, 34, 45, 50, 60, 65, 86, 94, 97): (0.15000102162768236, 0.30018732583286084, 0.14984415048071437), (4, 9, 10, 20, 38, 75, 81): (0.4003130616293591, 0.8285844456813044, 0.1480307501034011), (4, 9, 10, 38, 48, 75, 81): (0.38580428031766406, 0.8561990999547606, 0.14870245579695562), (4, 9, 17, 20, 21, 38, 48, 75, 81, 85): (0.3287611424267173, 0.7727174414557608, 0.14875929774485536), (4, 9, 21, 38, 48, 68, 75, 81): (0.35085609036236404, 0.829788163067764, 0.14875398876294763), (4, 10, 18, 48, 68, 75, 81): (0.37649547612262557, 0.8951760847630872, 0.14919996648688127), (4, 9, 19, 20, 21, 38, 49, 75, 85): (0.41640100306849537, 0.705093150372995, 0.14015996098823705), (4, 9, 17, 20, 21, 38, 64, 75, 81, 85): (0.33085298603236063, 0.7418399215994397, 0.14487972439785962), (4, 17, 20, 21, 38, 48, 64, 75, 81, 85): (0.3193974850937622, 0.7680632820869213, 0.1474266580607778), (4, 9, 17, 20, 21, 38, 49, 64, 75, 85): (0.34114170574087294, 0.6969174305624999, 0.14405921509093017), (9, 19, 20, 38, 49, 75, 87): (0.5006885871277305, 0.7412338818491877, 0.1451388894436533), (4, 9, 10, 75, 80, 81): (0.4019264767473983, 0.8734149403352809, 0.14482927195072062), (4, 10, 18, 48, 75, 80, 81): (0.3830407940310534, 0.8944881167840582, 0.14681390420878215), (4, 18, 32, 48, 56, 68, 69, 75, 81): (0.3229807880040072, 0.8650666484497739, 0.14809708296773283), (4, 10, 18, 48, 56, 68, 80, 81): (0.37683713029076393, 0.911312260609274, 0.14832443190916603), (4, 17, 21, 32, 38, 48, 64, 66, 68, 69, 75, 81, 85): (0.28091256649751173, 0.7845716212169753, 0.141585496443792), (4, 18, 21, 32, 38, 48, 64, 66, 68, 69, 75, 81): (0.28070798853230206, 0.8090664742306333, 0.14931465362464058), (4, 17, 20, 21, 38, 64, 66, 75, 81, 85): (0.29785238436809, 0.7234263474491083, 0.1490540650472151), (4, 18, 21, 32, 48, 56, 66, 68, 69, 81, 96): (0.26699140597300897, 0.8495296776189856, 0.14875348880939057), (4, 18, 21, 32, 38, 48, 64, 66, 68, 69, 81, 96): (0.25527949109936104, 0.8106316384539816, 0.1445317451825426), (4, 17, 21, 32, 38, 48, 64, 66, 68, 69, 81, 85, 96): (0.23217561230891856, 0.7805372979198325, 0.14511838625757928), (4, 9, 10, 19, 20, 38, 71, 75, 87): (0.4775129839401001, 0.7927769793318314, 0.14462380860637297), (4, 9, 10, 20, 71, 75, 80, 87): (0.4747088359878572, 0.8297948931425277, 0.14678768577566298), (9, 10, 19, 20, 71, 75, 80, 87): (0.502030117116463, 0.8236087646816392, 0.14943676014695212), (4, 18, 32, 48, 56, 58, 66, 68, 69, 72, 81, 96): (0.21696064154531802, 0.874101533075222, 0.13041150648755526), (4, 18, 21, 32, 48, 58, 64, 66, 68, 69, 72, 81, 96): (0.20114669372366326, 0.8301128240778305, 0.1493335313715823), (4, 17, 21, 38, 64, 66, 69, 81, 85, 99): (0.21769657381971141, 0.7313388234347639, 0.14701057273298804), (4, 17, 21, 32, 48, 64, 66, 69, 81, 85, 96, 99): (0.2015477050911515, 0.7529044317010726, 0.1494589238432731), (20, 25, 31, 49, 59, 84): (0.4258087319921411, 0.5401043228214542, 0.14745116571790448), (5, 24, 25, 31, 41, 43, 49, 59, 84, 90): (0.37662482838264727, 0.4751123959489456, 0.1496946360540124), (5, 17, 20, 24, 25, 31, 38, 41, 49, 85): (0.3622865226400378, 0.5612057389900295, 0.14877040889503995), (5, 17, 21, 24, 25, 31, 38, 41, 49, 85): (0.3397797027650458, 0.5662701001128034, 0.14899731011520068), (17, 20, 21, 24, 25, 31, 38, 41, 49, 85): (0.3529122532222511, 0.5772058553558765, 0.145641194646832), (5, 24, 25, 31, 41, 43, 50, 84, 90): (0.36744835703496576, 0.44513805791935623, 0.149017727518376), (5, 17, 24, 25, 41, 50): (0.25238459020708376, 0.49714842367609063, 0.14920289957040228), (5, 24, 25, 31, 43, 50, 59, 83, 84, 90): (0.3742525826195432, 0.4225237020811445, 0.14492114513872695), (5, 11, 23, 31, 43, 44, 59, 63, 84, 89, 90): (0.46586820074056295, 0.38692285503826956, 0.14938930201395317), (5, 25, 31, 43, 50, 59, 60, 83, 84, 90): (0.37465236999713214, 0.3967343268979738, 0.14793274615561394), (5, 24, 25, 31, 43, 50, 60, 83, 84, 90): (0.3666595366409718, 0.4029451066437212, 0.14935861884170346), (5, 24, 25, 31, 41, 43, 50, 60, 83, 90): (0.3374953446014549, 0.40768326591677895, 0.14271109555895584), (5, 11, 23, 31, 43, 44, 59, 84, 89, 90, 98): (0.46179357379075087, 0.37130700578519776, 0.14959106548201262), (5, 31, 43, 44, 50, 59, 60, 83, 84, 89, 90, 98): (0.3992944529514407, 0.34835251138844014, 0.14481894164813303), (5, 24, 25, 34, 41, 43, 50, 60, 83, 86, 90): (0.2643514690001076, 0.38046461029115597, 0.13200682283744283), (5, 42, 43, 44, 59, 60, 83, 84, 89, 90, 98): (0.4251496043395029, 0.314317932764338, 0.14818426431967247), (5, 42, 43, 44, 50, 60, 83, 89, 90, 98): (0.3896204611486524, 0.2884476340796184, 0.14766772614257698), (5, 34, 43, 50, 60, 65, 83, 89, 90, 98): (0.35484204032889544, 0.28298632126058126, 0.14896339447527998), (5, 24, 34, 41, 43, 50, 60, 65, 83, 86, 90): (0.24186208866496334, 0.35381703763650374, 0.147248332994493), (42, 43, 50, 60, 65, 83, 89, 90, 98): (0.3648226358119667, 0.2529208238960593, 0.14563258715152547), (5, 17, 21, 24, 25, 41, 64, 85): (0.26509967721642796, 0.5547482058021883, 0.1467474135798299), (17, 20, 21, 24, 25, 38, 41, 49, 64, 85): (0.3204205925258258, 0.6110698164118312, 0.1433963240190826), (5, 24, 34, 41, 50, 60, 65, 83, 86, 94): (0.1963459614878132, 0.354221443943041, 0.1499119871156634), (5, 34, 43, 50, 60, 65, 83, 86, 90, 97, 98): (0.2786672893971936, 0.2764212575028138, 0.148038361569061), (6, 8, 13, 36, 39, 46, 57, 79, 91): (0.7812938642651628, 0.40869196155963294, 0.1483179196387932), (6, 11, 13, 36, 39, 46, 57, 63, 79, 91): (0.7400403080009023, 0.4149028417553895, 0.14959527944822024), (6, 11, 13, 23, 36, 40, 46, 57, 63, 79, 91): (0.6955733914381548, 0.4466149890794219, 0.14332938261511524), (6, 11, 23, 36, 40, 46, 59, 63, 91): (0.661799803852757, 0.47465268914249026, 0.14990023270177139), (6, 11, 13, 23, 36, 40, 57, 59, 63, 79, 91): (0.6674444223364877, 0.44592897980175666, 0.1493799596176158), (6, 8, 11, 13, 23, 36, 39, 57, 63, 76, 79, 91): (0.7479505156724652, 0.3543364256041871, 0.14504949210030488), (6, 36, 40, 46, 57, 78): (0.6989923716784051, 0.5550188424375802, 0.14881436260536204), (6, 11, 13, 23, 36, 40, 44, 59, 63, 79, 84, 91): (0.6121508102053388, 0.4160214927121739, 0.13919367839740476), (6, 11, 23, 31, 36, 40, 44, 59, 63, 79, 84, 91): (0.5840006753840745, 0.425262952856729, 0.13453194363310325), (6, 7, 40, 46, 54, 57, 78): (0.7359758275738826, 0.5714274758487573, 0.1459224915245561), (6, 19, 40, 46, 54, 78): (0.6804138212873839, 0.6024152093385852, 0.14958356907798287), (7, 19, 40, 46, 54, 78): (0.7001663606329307, 0.6736530749126453, 0.145581886573751), (6, 11, 12, 23, 31, 36, 44, 59, 63, 79, 84, 89, 91): (0.5546692350232861, 0.3748947382581936, 0.1404608810549469), (6, 11, 12, 13, 23, 36, 44, 59, 63, 76, 79, 84, 89, 91): (0.6158471277538801, 0.33210754135354276, 0.13695160632128495), (6, 19, 40, 49, 78): (0.5898959630882554, 0.5849837349401764, 0.1395478206848745), (6, 19, 31, 40, 49, 59, 84): (0.5508159716065527, 0.5507115624444804, 0.13320543730746362), (6, 31, 40, 49, 59, 63, 84): (0.5334868035040657, 0.4969112537149139, 0.13520536905611247), (6, 11, 12, 23, 31, 43, 44, 59, 63, 79, 84, 89, 90, 91): (0.5248341660288149, 0.3695285456138079, 0.14898478769694384), (16, 19, 40, 54, 78): (0.648734030229264, 0.69772769100568, 0.14566639395175016), (7, 16, 19, 54, 78, 92): (0.7017301747157373, 0.7018096583710086, 0.14788217314648738), (7, 35, 46, 54, 67, 77, 78, 92, 95): (0.8016668768331154, 0.7050427315864585, 0.14885954882353508), (7, 35, 54, 67, 77, 78, 82, 92, 95): (0.8126860837487624, 0.7390030277575786, 0.14963827070744815), (7, 35, 54, 67, 77, 82, 92, 93, 95): (0.8541983606053255, 0.7617510039302191, 0.13551854101469707), (7, 16, 35, 54, 67, 78, 92, 93, 95): (0.7835123617757969, 0.7940004134527878, 0.14850931037307125), (7, 35, 54, 67, 73, 82, 92, 93, 95): (0.8680257488645291, 0.8105733497073806, 0.14461010599432164), (16, 35, 54, 67, 73, 92, 93, 95): (0.8039052049993555, 0.8358136241307832, 0.1460176815171897), (8, 13, 27, 28, 36, 39, 51, 62, 74, 76, 79): (0.7864858215585857, 0.29075158032698684, 0.14961460741813482), (8, 13, 27, 28, 36, 39, 62, 74, 76, 79, 91): (0.7851472504933936, 0.30671346343945144, 0.14266494791580994), (8, 13, 27, 36, 39, 57, 62, 74, 76, 79, 91): (0.7947045059120503, 0.31997763795542744, 0.14446794140299074), (8, 11, 13, 23, 27, 28, 36, 74, 76, 79, 91): (0.7372472238258292, 0.2715103777107627, 0.14815884891492234), (8, 11, 13, 23, 36, 39, 57, 74, 76, 79, 91): (0.7536701632685218, 0.3264131965382456, 0.1499762709695208), (8, 11, 13, 23, 28, 36, 39, 63, 74, 76, 79, 91): (0.7432076014100258, 0.3161679754031407, 0.14735220435952692), (8, 13, 36, 39, 55, 57, 62, 74): (0.8270244719636314, 0.3463770009824643, 0.14816894016641344), (8, 13, 36, 39, 46, 55, 57): (0.8315524471930096, 0.4208862595245414, 0.14308143530640893), (9, 19, 20, 49, 75, 78, 87): (0.526255574364575, 0.7284182151763334, 0.1445142284421115), (9, 10, 16, 19, 20, 71, 75, 78, 87): (0.5503029395762983, 0.7725028563327712, 0.1379855198507884), (9, 19, 20, 40, 49, 75, 78): (0.5308236138060022, 0.6654717052596012, 0.14166070888466), (9, 16, 19, 40, 78): (0.6152792270448181, 0.7022038051249079, 0.14724540705027672), (9, 19, 20, 31, 38, 49, 75, 85): (0.4397878732528429, 0.6157549414177731, 0.1379389073709895), (9, 19, 20, 31, 40, 49, 75): (0.48958920540021267, 0.6234521812075917, 0.14685558331482343), (9, 10, 16, 19, 71, 75, 80, 87): (0.5310332240866265, 0.8284058748099863, 0.14651673216295627), (9, 10, 16, 19, 71, 78, 87, 92): (0.6106510896880954, 0.7958501908923952, 0.1430714723104721), (10, 16, 71, 80, 87, 92): (0.6264282483677088, 0.9079762183947514, 0.1358534990005984), (11, 12, 23, 31, 42, 43, 44, 59, 63, 84, 89, 90, 98): (0.4776061998845129, 0.3308921514293687, 0.14948378198882384), (11, 12, 14, 23, 42, 43, 44, 59, 63, 79, 84, 89, 90, 98): (0.5190100909516181, 0.3024309974602939, 0.1461597643756266), (11, 12, 23, 31, 43, 44, 59, 63, 79, 84, 89, 90, 98): (0.5167680750767972, 0.3408073723414071, 0.1494775277829455), (11, 12, 14, 23, 42, 44, 59, 63, 79, 84, 89, 90, 91, 98): (0.5353432225094631, 0.3092813311287071, 0.14961247846229375), (11, 12, 23, 42, 43, 44, 59, 63, 79, 84, 89, 90, 91, 98): (0.5269080789204658, 0.3272778263063749, 0.1492860996243205), (11, 12, 14, 23, 42, 44, 63, 76, 79, 89, 98): (0.5651889224135658, 0.24974452994663424, 0.1481860442866704), (11, 12, 13, 14, 23, 42, 44, 59, 63, 76, 79, 84, 89, 91): (0.5810248153025497, 0.297301468717096, 0.14553280939641036), (11, 12, 13, 14, 23, 36, 44, 59, 63, 76, 79, 84, 89, 91): (0.59020808374762, 0.30242702351356676, 0.14518706205274268), (11, 12, 13, 14, 23, 28, 42, 44, 63, 76, 79, 89, 91): (0.6206933635449503, 0.24682154651736443, 0.14397395607960825), (11, 12, 13, 14, 23, 28, 36, 44, 63, 76, 79, 89, 91): (0.6443421994012091, 0.27263136238807373, 0.1418464361759105), (11, 12, 13, 14, 23, 28, 74, 76, 79, 91): (0.6865690251676432, 0.23557064983017745, 0.1497576533972519), (11, 12, 13, 23, 28, 36, 63, 74, 76, 79, 91): (0.7095105226389335, 0.27798372862136267, 0.145811382266761), (12, 13, 27, 28, 74, 76, 79): (0.7163112725430478, 0.21385230043077974, 0.14778176906674004), (12, 14, 28, 61, 74, 76): (0.692614694039914, 0.15857646831069733, 0.14455379460889162), (12, 23, 42, 43, 44, 59, 83, 84, 89, 90, 98): (0.4563543195907547, 0.31480881243674935, 0.14922880337038014), (12, 23, 31, 43, 44, 59, 83, 84, 89, 90, 98): (0.45419723615723284, 0.32960642809424645, 0.1499761920887504), (12, 14, 42, 43, 44, 60, 83, 89, 90, 98): (0.42955231039420116, 0.2226100668877384, 0.14110959536132095), (12, 42, 43, 44, 59, 60, 83, 84, 89, 90, 98): (0.4402325483015652, 0.3046223156987031, 0.14721181227676056), (14, 22, 28, 61, 74, 76): (0.7017172984423354, 0.12325899188468137, 0.14999980732453855), (14, 22, 26, 28, 61, 76): (0.6912503728261168, 0.10016189310233165, 0.14784082552996525), (16, 19, 54, 71, 78, 87, 92): (0.6703761804849702, 0.7581413028998242, 0.13727248723415264), (16, 54, 71, 78, 87, 92, 95): (0.7055796088125853, 0.8042768799273943, 0.13751533041746666), (16, 71, 92, 93, 95): (0.748680649656, 0.8792981719129548, 0.14810534432725672), (16, 35, 47, 73, 92, 93, 95): (0.7973963974798904, 0.8730772012592461, 0.14251677211486202), (17, 20, 21, 25, 38, 49, 64, 75, 85): (0.33122073385849954, 0.6424372081216861, 0.140272333871763), (17, 20, 21, 25, 31, 38, 49, 75, 85): (0.3899560099849434, 0.6080529827711362, 0.14686618715840474), (17, 21, 24, 25, 38, 41, 64, 66, 85, 99): (0.2324845209042679, 0.6381836480533993, 0.14541606090517503), (17, 21, 24, 25, 41, 64, 66, 85, 88, 99): (0.17759327332460764, 0.6154216464660676, 0.14680527616816053), (17, 21, 64, 66, 69, 85, 88, 99): (0.1700753673132927, 0.7010807602993253, 0.14829695794446568), (17, 21, 64, 66, 69, 88, 96, 99): (0.14057040165146145, 0.7404980045079362, 0.14458712542500857), (21, 32, 64, 66, 69, 88, 96, 99): (0.13589958287585685, 0.7521082386304109, 0.14938908416349977), (32, 37, 48, 58, 64, 66, 68, 69, 72, 81, 96): (0.1587853817899879, 0.8265085757585824, 0.14669323412266905), (18, 32, 37, 48, 56, 58, 66, 68, 69, 72, 81, 96): (0.1565898330981594, 0.900576785386657, 0.14039118879912008), (19, 20, 31, 40, 49, 59, 84): (0.4955100051053224, 0.5592196556545426, 0.13807852710419102), (29, 88): (0.021898984551369127, 0.498905674871803, 0.14491984926943427), (24, 29, 34, 41, 50, 86, 94): (0.15186115338348286, 0.38521837733842534, 0.14484075712621175), (29, 30, 34, 41, 50, 86, 94): (0.1318289821876929, 0.3907884062675565, 0.14663186091122857), (30, 34, 45, 50, 60, 65, 83, 86, 94, 97): (0.17218506307174686, 0.2745348904559653, 0.13778262145170894), (34, 45, 52, 60, 65, 70, 83, 86, 94, 97): (0.1946945060242287, 0.20205232918260238, 0.14600384549982623), (34, 45, 50, 60, 65, 70, 83, 86, 94, 97): (0.1984942686851189, 0.20938746372536046, 0.14945353002055525), (32, 37, 48, 64, 66, 69, 81, 96, 99): (0.13998817052833173, 0.7858689353702485, 0.14814097529549805), (32, 37, 64, 66, 69, 88, 96, 99): (0.111022615751386, 0.7676327866502684, 0.1464828433048606), (34, 60, 65, 70, 83, 86, 97, 98): (0.27881170846041564, 0.18823061782622416, 0.14535381423478827), (35, 47, 67, 73, 82, 92, 93, 95): (0.8668407448339298, 0.8654424303052715, 0.12317143039084451)}
|
# -*- coding: utf-8 -*-
'''Top-level package for lico.'''
__author__ = '''Sjoerd Kerkstra'''
__email__ = 'w.s.kerkstra@example.com'
__version__ = '0.1.1'
|
"""Top-level package for lico."""
__author__ = 'Sjoerd Kerkstra'
__email__ = 'w.s.kerkstra@example.com'
__version__ = '0.1.1'
|
"""Stub implementation containing j2kt_provider helpers."""
def _to_j2kt_jvm_name(name):
"""Convert a label name used in j2cl to be used in j2kt jvm"""
if name.endswith("-j2cl"):
name = name[:-5]
return "%s-j2kt-jvm" % name
def _to_j2kt_native_name(name):
"""Convert a label name used in j2cl to be used in j2kt native"""
if name.endswith("-j2cl"):
name = name[:-5]
return "%s-j2kt-native" % name
def _compile(**kwargs):
pass
def _native_compile(**kwargs):
pass
def _jvm_compile(**kwargs):
pass
j2kt_common = struct(
to_j2kt_jvm_name = _to_j2kt_jvm_name,
to_j2kt_native_name = _to_j2kt_native_name,
compile = _compile,
native_compile = _native_compile,
jvm_compile = _jvm_compile,
)
|
"""Stub implementation containing j2kt_provider helpers."""
def _to_j2kt_jvm_name(name):
"""Convert a label name used in j2cl to be used in j2kt jvm"""
if name.endswith('-j2cl'):
name = name[:-5]
return '%s-j2kt-jvm' % name
def _to_j2kt_native_name(name):
"""Convert a label name used in j2cl to be used in j2kt native"""
if name.endswith('-j2cl'):
name = name[:-5]
return '%s-j2kt-native' % name
def _compile(**kwargs):
pass
def _native_compile(**kwargs):
pass
def _jvm_compile(**kwargs):
pass
j2kt_common = struct(to_j2kt_jvm_name=_to_j2kt_jvm_name, to_j2kt_native_name=_to_j2kt_native_name, compile=_compile, native_compile=_native_compile, jvm_compile=_jvm_compile)
|
# Author: zhao-zh10
# -----------
# User Instructions:
#
# Modify the the search function so that it becomes
# an A* search algorithm as defined in the previous
# lectures.
#
# Your function should return the expanded grid
# which shows, for each element, the count when
# it was expanded or -1 if the element was never expanded.
#
# If there is no path from init to goal,
# the function should return the string 'fail'
# ----------
grid = [[0, 1, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0]]
heuristic = [[9, 8, 7, 6, 5, 4],
[8, 7, 6, 5, 4, 3],
[7, 6, 5, 4, 3, 2],
[6, 5, 4, 3, 2, 1],
[5, 4, 3, 2, 1, 0]]
init = [0, 0]
goal = [len(grid) - 1, len(grid[0]) - 1]
cost = 1
delta = [[-1, 0], # go up
[0, -1], # go left
[1, 0], # go down
[0, 1]] # go right
delta_name = ['^', '<', 'v', '>']
def search(grid, init, goal, cost, heuristic, debug_flag = False):
# ----------------------------------------
# modify the code below
# ----------------------------------------
closed = [[0 for col in range(len(grid[0]))] for row in range(len(grid))]
closed[init[0]][init[1]] = 1
expand = [[-1 for col in range(len(grid[0]))] for row in range(len(grid))]
action = [[-1 for col in range(len(grid[0]))] for row in range(len(grid))]
policy = [[' ' for col in range(len(grid[0]))] for row in range(len(grid))]
x = init[0]
y = init[1]
g = 0
h = heuristic[x][y]
f = g + h
open = [[f, g, h, x, y]]
found = False # flag that is set when search is complete
resign = False # flag set if we can't find expand
count = 0
if debug_flag:
print('initial open list:')
for i in range(len(open)):
print(" ", open[i])
print("----")
while not found and not resign:
if len(open) == 0:
resign = True
if debug_flag:
print('Fail')
print('###### Search terminated without success')
return "Fail"
else:
# remove node from list
open.sort()
open.reverse()
next = open.pop()
if debug_flag:
print('take list item')
print(next)
x = next[3]
y = next[4]
g = next[1]
expand[x][y] = count
count += 1
if x == goal[0] and y == goal[1]:
if debug_flag:
print(next)
print('###### Search successful')
found = True
else:
# expand winning element and add to new open list
for i in range(len(delta)):
x2 = x + delta[i][0]
y2 = y + delta[i][1]
if 0 <= x2 < len(grid) and 0 <= y2 < len(grid[0]):
if closed[x2][y2] == 0 and grid[x2][y2] == 0:
g2 = g + cost
h2 = heuristic[x2][y2]
f2 = g2 + h2
open.append([f2, g2, h2, x2, y2])
if debug_flag:
print('append list item')
print([f2, g2, h2, x2, y2])
closed[x2][y2] = 1
action[x2][y2] = i
if debug_flag:
print('---'*10)
print('new open list:')
for i in range(len(open)):
print(' ', open[i])
print('---'*10)
if found:
x = goal[0]
y = goal[1]
policy[x][y] = '*'
while x != init[0] or y != init[0]:
x2 = x - delta[action[x][y]][0]
y2 = y - delta[action[x][y]][1]
policy[x2][y2] = delta_name[action[x][y]]
x = x2
y = y2
if debug_flag:
print('---'*10)
print('The path policy is:')
for m in range(len(policy)):
print(policy[m])
print('---'*10)
print('The expanded table is :')
for k in range(len(expand)):
print(expand[k])
return expand
search(grid, init, goal, cost, heuristic)
|
grid = [[0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0]]
heuristic = [[9, 8, 7, 6, 5, 4], [8, 7, 6, 5, 4, 3], [7, 6, 5, 4, 3, 2], [6, 5, 4, 3, 2, 1], [5, 4, 3, 2, 1, 0]]
init = [0, 0]
goal = [len(grid) - 1, len(grid[0]) - 1]
cost = 1
delta = [[-1, 0], [0, -1], [1, 0], [0, 1]]
delta_name = ['^', '<', 'v', '>']
def search(grid, init, goal, cost, heuristic, debug_flag=False):
closed = [[0 for col in range(len(grid[0]))] for row in range(len(grid))]
closed[init[0]][init[1]] = 1
expand = [[-1 for col in range(len(grid[0]))] for row in range(len(grid))]
action = [[-1 for col in range(len(grid[0]))] for row in range(len(grid))]
policy = [[' ' for col in range(len(grid[0]))] for row in range(len(grid))]
x = init[0]
y = init[1]
g = 0
h = heuristic[x][y]
f = g + h
open = [[f, g, h, x, y]]
found = False
resign = False
count = 0
if debug_flag:
print('initial open list:')
for i in range(len(open)):
print(' ', open[i])
print('----')
while not found and (not resign):
if len(open) == 0:
resign = True
if debug_flag:
print('Fail')
print('###### Search terminated without success')
return 'Fail'
else:
open.sort()
open.reverse()
next = open.pop()
if debug_flag:
print('take list item')
print(next)
x = next[3]
y = next[4]
g = next[1]
expand[x][y] = count
count += 1
if x == goal[0] and y == goal[1]:
if debug_flag:
print(next)
print('###### Search successful')
found = True
else:
for i in range(len(delta)):
x2 = x + delta[i][0]
y2 = y + delta[i][1]
if 0 <= x2 < len(grid) and 0 <= y2 < len(grid[0]):
if closed[x2][y2] == 0 and grid[x2][y2] == 0:
g2 = g + cost
h2 = heuristic[x2][y2]
f2 = g2 + h2
open.append([f2, g2, h2, x2, y2])
if debug_flag:
print('append list item')
print([f2, g2, h2, x2, y2])
closed[x2][y2] = 1
action[x2][y2] = i
if debug_flag:
print('---' * 10)
print('new open list:')
for i in range(len(open)):
print(' ', open[i])
print('---' * 10)
if found:
x = goal[0]
y = goal[1]
policy[x][y] = '*'
while x != init[0] or y != init[0]:
x2 = x - delta[action[x][y]][0]
y2 = y - delta[action[x][y]][1]
policy[x2][y2] = delta_name[action[x][y]]
x = x2
y = y2
if debug_flag:
print('---' * 10)
print('The path policy is:')
for m in range(len(policy)):
print(policy[m])
print('---' * 10)
print('The expanded table is :')
for k in range(len(expand)):
print(expand[k])
return expand
search(grid, init, goal, cost, heuristic)
|
class Solution:
"""
@param nums: A list of integers
@return: A list of integers includes the index of the first number and the index of the last number
"""
def subarraySum(self, nums):
d = {}
d[0] = -1
L = len(nums)
index = 0
count = 0
while index < L :
count += nums[index]
if count in d :
return [d[count]+1,index]
d[count] = index
index += 1
|
class Solution:
"""
@param nums: A list of integers
@return: A list of integers includes the index of the first number and the index of the last number
"""
def subarray_sum(self, nums):
d = {}
d[0] = -1
l = len(nums)
index = 0
count = 0
while index < L:
count += nums[index]
if count in d:
return [d[count] + 1, index]
d[count] = index
index += 1
|
# python3
class HeapBuilder:
def __init__(self):
self._swaps = []
self._data = []
def ReadData(self):
global n
n = int(input())
self._data = [int(s) for s in input().split()]
assert n == len(self._data)
def WriteResponse(self):
print(len(self._swaps))
for swap in self._swaps:
print(swap[0], swap[1])
def SiftDown(self, i):
minIndex = i
left = 2 * i + 1
if left < n and self._data[left] < self._data[minIndex]:
minIndex = left
right = 2 * i + 2
if right < n and self._data[right] < self._data[minIndex]:
minIndex = right
if i != minIndex:
self._data[i], self._data[minIndex] = self._data[minIndex], self._data[i]
self._swaps.append([i, minIndex])
self.SiftDown(minIndex)
def GenerateSwaps(self):
for i in range(n // 2, -1, -1):
self.SiftDown(i)
def Solve(self):
self.ReadData()
self.GenerateSwaps()
self.WriteResponse()
if __name__ == '__main__':
heap_builder = HeapBuilder()
heap_builder.Solve()
|
class Heapbuilder:
def __init__(self):
self._swaps = []
self._data = []
def read_data(self):
global n
n = int(input())
self._data = [int(s) for s in input().split()]
assert n == len(self._data)
def write_response(self):
print(len(self._swaps))
for swap in self._swaps:
print(swap[0], swap[1])
def sift_down(self, i):
min_index = i
left = 2 * i + 1
if left < n and self._data[left] < self._data[minIndex]:
min_index = left
right = 2 * i + 2
if right < n and self._data[right] < self._data[minIndex]:
min_index = right
if i != minIndex:
(self._data[i], self._data[minIndex]) = (self._data[minIndex], self._data[i])
self._swaps.append([i, minIndex])
self.SiftDown(minIndex)
def generate_swaps(self):
for i in range(n // 2, -1, -1):
self.SiftDown(i)
def solve(self):
self.ReadData()
self.GenerateSwaps()
self.WriteResponse()
if __name__ == '__main__':
heap_builder = heap_builder()
heap_builder.Solve()
|
# python dict of naming overrides
GENE_NAME_OVERRIDE = {
# pmmo Genes
'EQU24_RS19315':'pmoC',
'EQU24_RS19310':'pmoA',
'EQU24_RS19305':'pmoB',
# smmo Genes
'EQU24_RS05930':'mmoR',
'EQU24_RS05925':'mmoG',
'EQU24_RS05910':'mmoC',
'EQU24_RS05900':'mmoZ',
'EQU24_RS05895':'mmoB',
'EQU24_RS05890':'mmoY',
'EQU24_RS05885':'mmoX',
# groEL/groES genes
'EQU24_RS17825':'groS',
'EQU24_RS08650':'groS',
# mxaF genes (mxa and mox)
'EQU24_RS18155':'mxaD',
'EQU24_RS18140':'moxF',
'EQU24_RS18125':'moxI',
'EQU24_RS18120':'moxR',
'EQU24_RS18115':'mxaP', # via blast
'EQU24_RS18110':'mxaS',
'EQU24_RS18105':'mxaA',
'EQU24_RS18100':'mxaC',
'EQU24_RS18095':'mxaK',
'EQU24_RS18090':'mxaL',
'EQU24_RS18145':'mxaB',
# Xox
'EQU24_RS18610':'xoxJ',
'EQU24_RS18605':'xoxF'
}
GENE_PRODUCT_OVERRIDE = {
'EQU24_RS05925':'likely chaperone for smmo',
}
SYS_LOOKUP = {
#pmo
'EQU24_RS19315':'pmo',
'EQU24_RS19310':'pmo',
'EQU24_RS19305':'pmo',
# smo
'EQU24_RS05910':'smo',
'EQU24_RS05905':'smo',
'EQU24_RS05900':'smo',
'EQU24_RS05895':'smo',
'EQU24_RS05890':'smo',
'EQU24_RS05885':'smo',
'EQU24_RS05930':'smo',
'EQU24_RS05925':'smo',
# mxa
'EQU24_RS18145':'mox',
'EQU24_RS18140':'mox',
'EQU24_RS18135':'mox',
'EQU24_RS18130':'mox',
'EQU24_RS18125':'mox',
'EQU24_RS18120':'mox',
'EQU24_RS18115':'mox',
'EQU24_RS18110':'mox',
'EQU24_RS18105':'mox',
'EQU24_RS18100':'mox',
'EQU24_RS18095':'mox',
'EQU24_RS18090':'mox',
# xox
'EQU24_RS18605':'xox',
'EQU24_RS18610':'xox',
#groEL/ES
# 'EQU24_RS17825':'gro',
# 'EQU24_RS17820':'gro',
# 'EQU24_RS08655':'gro',
# 'EQU24_RS08650':'gro',
#pilin
'EQU24_RS04275':'pilin',
'EQU24_RS01095':'pilin',
'EQU24_RS16035':'pilin',
'EQU24_RS03345':'pilin',
'EQU24_RS16020':'pilin',
'EQU24_RS19380':'pilin',
'EQU24_RS00705':'pilin',
'EQU24_RS04470':'pilin',
'EQU24_RS12830':'pilin',
'EQU24_RS04480':'pilin',
'EQU24_RS12835':'pilin',
'EQU24_RS04490':'pilin',
'EQU24_RS04485':'pilin',
'EQU24_RS03355':'pilin',
'EQU24_RS00710':'pilin',
'EQU24_RS05130':'pilin',
'EQU24_RS19585':'pilin',
'EQU24_RS04615':'pilin',
'EQU24_RS05525':'pilin',
'EQU24_RS16025':'pilin',
'EQU24_RS05135':'pilin',
'EQU24_RS12840':'pilin',
'EQU24_RS04585':'pilin',
'EQU24_RS04610':'pilin',
'EQU24_RS04595':'pilin',
'EQU24_RS04600':'pilin',
# secretion
'EQU24_RS19520':'secretion',
'EQU24_RS11235':'secretion',
'EQU24_RS15565':'secretion',
'EQU24_RS06345':'secretion',
'EQU24_RS05115':'secretion',
'EQU24_RS15560':'secretion',
'EQU24_RS11240':'secretion',
'EQU24_RS11280':'secretion',
'EQU24_RS11210':'secretion',
'EQU24_RS11245':'secretion',
'EQU24_RS11180':'secretion',
'EQU24_RS20155':'secretion',
'EQU24_RS15945':'secretion',
'EQU24_RS05120':'secretion',
'EQU24_RS11270':'secretion',
'EQU24_RS11275':'secretion',
'EQU24_RS11250':'secretion',
'EQU24_RS11260':'secretion',
'EQU24_RS20160':'secretion',
'EQU24_RS05110':'secretion',
'EQU24_RS04490':'secretion',
'EQU24_RS03350':'secretion',
'EQU24_RS11255':'secretion',
'EQU24_RS15930':'secretion',
'EQU24_RS16015':'secretion',
'EQU24_RS11215':'secretion',
'EQU24_RS11220':'secretion',
'EQU24_RS11205':'secretion',
'EQU24_RS11190':'secretion',
'EQU24_RS19490':'secretion',
'EQU24_RS05160':'secretion',
'EQU24_RS05105':'secretion',
'EQU24_RS16000':'secretion',
'EQU24_RS19465':'secretion',
'EQU24_RS15995':'secretion',
'EQU24_RS01525':'secretion',
'EQU24_RS05405':'secretion',
'EQU24_RS11175':'secretion',
'EQU24_RS10950':'secretion',
#toxin
'EQU24_RS11700':'toxin',
'EQU24_RS14175':'toxin',
'EQU24_RS18440':'toxin',
'EQU24_RS20880':'toxin',
'EQU24_RS07550':'toxin',
'EQU24_RS11705':'toxin',
'EQU24_RS07535':'toxin',
'EQU24_RS08075':'toxin',
'EQU24_RS02930':'toxin',
'EQU24_RS21185':'toxin',
'EQU24_RS21860':'toxin',
'EQU24_RS17985':'toxin',
'EQU24_RS07545':'toxin',
'EQU24_RS18405':'toxin',
'EQU24_RS00235':'toxin',
'EQU24_RS19535':'toxin',
'EQU24_RS10190':'toxin',
'EQU24_RS08220':'toxin',
'EQU24_RS21865':'toxin',
'EQU24_RS15430':'toxin',
'EQU24_RS20925':'toxin',
'EQU24_RS04285':'toxin',
'EQU24_RS10850':'toxin',
'EQU24_RS20920':'toxin',
'EQU24_RS08175':'toxin',
'EQU24_RS08180':'toxin',
'EQU24_RS08210':'toxin',
'EQU24_RS13090':'toxin',
'EQU24_RS20735':'toxin',
'EQU24_RS04320':'toxin',
'EQU24_RS20730':'toxin',
'EQU24_RS01855':'toxin',
'EQU24_RS10855':'toxin',
'EQU24_RS19540':'toxin',
'EQU24_RS20010':'toxin',
'EQU24_RS20725':'toxin',
'EQU24_RS08130':'toxin',
'EQU24_RS15455':'toxin',
'EQU24_RS13520':'toxin',
'EQU24_RS08065':'toxin',
'EQU24_RS04325':'toxin',
'EQU24_RS01485':'toxin',
'EQU24_RS05330':'toxin',
'EQU24_RS20720':'toxin',
'EQU24_RS13725':'toxin',
'EQU24_RS20935':'toxin',
'EQU24_RS08135':'toxin',
'EQU24_RS01930':'toxin',
'EQU24_RS17920':'toxin',
'EQU24_RS20265':'toxin',
'EQU24_RS16915':'toxin',
'EQU24_RS07460':'toxin',
'EQU24_RS01935':'toxin',
'EQU24_RS22115':'toxin',
'EQU24_RS19020':'toxin',
'EQU24_RS04380':'toxin',
'EQU24_RS04110':'toxin',
'EQU24_RS00215':'toxin',
'EQU24_RS01345':'toxin',
'EQU24_RS07575':'toxin',
'EQU24_RS00220':'toxin',
'EQU24_RS20270':'toxin',
'EQU24_RS05325':'toxin',
'EQU24_RS16470':'toxin',
'EQU24_RS17375':'toxin',
'EQU24_RS12475':'toxin',
'EQU24_RS16330':'toxin',
'EQU24_RS12820':'toxin',
'EQU24_RS12825':'toxin',
'EQU24_RS08850':'toxin',
'EQU24_RS08845':'toxin',
# 5152
'EQU24_RS19480':'5152',
'EQU24_RS19490':'5152',
'EQU24_RS19495':'5152',
'EQU24_RS19515':'5152',
'EQU24_RS19510':'5152',
'EQU24_RS19505':'5152',
'EQU24_RS19470':'5152',
'EQU24_RS19460':'5152',
'EQU24_RS19450':'5152',
# repressible no 5152
'EQU24_RS10650':'RepCurCu-no5152',
'EQU24_RS15800':'RepCurCu-no5152',
'EQU24_RS01900':'RepCurCu-no5152',
'EQU24_RS21005':'RepCurCu-no5152',
'EQU24_RS02325':'RepCurCu-no5152',
'EQU24_RS05885':'RepCurCu-no5152',
'EQU24_RS21000':'RepCurCu-no5152',
'EQU24_RS00670':'RepCurCu-no5152',
'EQU24_RS05870':'RepCurCu-no5152',
'EQU24_RS10665':'RepCurCu-no5152',
'EQU24_RS05880':'RepCurCu-no5152',
'EQU24_RS05905':'RepCurCu-no5152',
'EQU24_RS05915':'RepCurCu-no5152',
'EQU24_RS05920':'RepCurCu-no5152',
'EQU24_RS05925':'RepCurCu-no5152'
}
|
gene_name_override = {'EQU24_RS19315': 'pmoC', 'EQU24_RS19310': 'pmoA', 'EQU24_RS19305': 'pmoB', 'EQU24_RS05930': 'mmoR', 'EQU24_RS05925': 'mmoG', 'EQU24_RS05910': 'mmoC', 'EQU24_RS05900': 'mmoZ', 'EQU24_RS05895': 'mmoB', 'EQU24_RS05890': 'mmoY', 'EQU24_RS05885': 'mmoX', 'EQU24_RS17825': 'groS', 'EQU24_RS08650': 'groS', 'EQU24_RS18155': 'mxaD', 'EQU24_RS18140': 'moxF', 'EQU24_RS18125': 'moxI', 'EQU24_RS18120': 'moxR', 'EQU24_RS18115': 'mxaP', 'EQU24_RS18110': 'mxaS', 'EQU24_RS18105': 'mxaA', 'EQU24_RS18100': 'mxaC', 'EQU24_RS18095': 'mxaK', 'EQU24_RS18090': 'mxaL', 'EQU24_RS18145': 'mxaB', 'EQU24_RS18610': 'xoxJ', 'EQU24_RS18605': 'xoxF'}
gene_product_override = {'EQU24_RS05925': 'likely chaperone for smmo'}
sys_lookup = {'EQU24_RS19315': 'pmo', 'EQU24_RS19310': 'pmo', 'EQU24_RS19305': 'pmo', 'EQU24_RS05910': 'smo', 'EQU24_RS05905': 'smo', 'EQU24_RS05900': 'smo', 'EQU24_RS05895': 'smo', 'EQU24_RS05890': 'smo', 'EQU24_RS05885': 'smo', 'EQU24_RS05930': 'smo', 'EQU24_RS05925': 'smo', 'EQU24_RS18145': 'mox', 'EQU24_RS18140': 'mox', 'EQU24_RS18135': 'mox', 'EQU24_RS18130': 'mox', 'EQU24_RS18125': 'mox', 'EQU24_RS18120': 'mox', 'EQU24_RS18115': 'mox', 'EQU24_RS18110': 'mox', 'EQU24_RS18105': 'mox', 'EQU24_RS18100': 'mox', 'EQU24_RS18095': 'mox', 'EQU24_RS18090': 'mox', 'EQU24_RS18605': 'xox', 'EQU24_RS18610': 'xox', 'EQU24_RS04275': 'pilin', 'EQU24_RS01095': 'pilin', 'EQU24_RS16035': 'pilin', 'EQU24_RS03345': 'pilin', 'EQU24_RS16020': 'pilin', 'EQU24_RS19380': 'pilin', 'EQU24_RS00705': 'pilin', 'EQU24_RS04470': 'pilin', 'EQU24_RS12830': 'pilin', 'EQU24_RS04480': 'pilin', 'EQU24_RS12835': 'pilin', 'EQU24_RS04490': 'pilin', 'EQU24_RS04485': 'pilin', 'EQU24_RS03355': 'pilin', 'EQU24_RS00710': 'pilin', 'EQU24_RS05130': 'pilin', 'EQU24_RS19585': 'pilin', 'EQU24_RS04615': 'pilin', 'EQU24_RS05525': 'pilin', 'EQU24_RS16025': 'pilin', 'EQU24_RS05135': 'pilin', 'EQU24_RS12840': 'pilin', 'EQU24_RS04585': 'pilin', 'EQU24_RS04610': 'pilin', 'EQU24_RS04595': 'pilin', 'EQU24_RS04600': 'pilin', 'EQU24_RS19520': 'secretion', 'EQU24_RS11235': 'secretion', 'EQU24_RS15565': 'secretion', 'EQU24_RS06345': 'secretion', 'EQU24_RS05115': 'secretion', 'EQU24_RS15560': 'secretion', 'EQU24_RS11240': 'secretion', 'EQU24_RS11280': 'secretion', 'EQU24_RS11210': 'secretion', 'EQU24_RS11245': 'secretion', 'EQU24_RS11180': 'secretion', 'EQU24_RS20155': 'secretion', 'EQU24_RS15945': 'secretion', 'EQU24_RS05120': 'secretion', 'EQU24_RS11270': 'secretion', 'EQU24_RS11275': 'secretion', 'EQU24_RS11250': 'secretion', 'EQU24_RS11260': 'secretion', 'EQU24_RS20160': 'secretion', 'EQU24_RS05110': 'secretion', 'EQU24_RS04490': 'secretion', 'EQU24_RS03350': 'secretion', 'EQU24_RS11255': 'secretion', 'EQU24_RS15930': 'secretion', 'EQU24_RS16015': 'secretion', 'EQU24_RS11215': 'secretion', 'EQU24_RS11220': 'secretion', 'EQU24_RS11205': 'secretion', 'EQU24_RS11190': 'secretion', 'EQU24_RS19490': 'secretion', 'EQU24_RS05160': 'secretion', 'EQU24_RS05105': 'secretion', 'EQU24_RS16000': 'secretion', 'EQU24_RS19465': 'secretion', 'EQU24_RS15995': 'secretion', 'EQU24_RS01525': 'secretion', 'EQU24_RS05405': 'secretion', 'EQU24_RS11175': 'secretion', 'EQU24_RS10950': 'secretion', 'EQU24_RS11700': 'toxin', 'EQU24_RS14175': 'toxin', 'EQU24_RS18440': 'toxin', 'EQU24_RS20880': 'toxin', 'EQU24_RS07550': 'toxin', 'EQU24_RS11705': 'toxin', 'EQU24_RS07535': 'toxin', 'EQU24_RS08075': 'toxin', 'EQU24_RS02930': 'toxin', 'EQU24_RS21185': 'toxin', 'EQU24_RS21860': 'toxin', 'EQU24_RS17985': 'toxin', 'EQU24_RS07545': 'toxin', 'EQU24_RS18405': 'toxin', 'EQU24_RS00235': 'toxin', 'EQU24_RS19535': 'toxin', 'EQU24_RS10190': 'toxin', 'EQU24_RS08220': 'toxin', 'EQU24_RS21865': 'toxin', 'EQU24_RS15430': 'toxin', 'EQU24_RS20925': 'toxin', 'EQU24_RS04285': 'toxin', 'EQU24_RS10850': 'toxin', 'EQU24_RS20920': 'toxin', 'EQU24_RS08175': 'toxin', 'EQU24_RS08180': 'toxin', 'EQU24_RS08210': 'toxin', 'EQU24_RS13090': 'toxin', 'EQU24_RS20735': 'toxin', 'EQU24_RS04320': 'toxin', 'EQU24_RS20730': 'toxin', 'EQU24_RS01855': 'toxin', 'EQU24_RS10855': 'toxin', 'EQU24_RS19540': 'toxin', 'EQU24_RS20010': 'toxin', 'EQU24_RS20725': 'toxin', 'EQU24_RS08130': 'toxin', 'EQU24_RS15455': 'toxin', 'EQU24_RS13520': 'toxin', 'EQU24_RS08065': 'toxin', 'EQU24_RS04325': 'toxin', 'EQU24_RS01485': 'toxin', 'EQU24_RS05330': 'toxin', 'EQU24_RS20720': 'toxin', 'EQU24_RS13725': 'toxin', 'EQU24_RS20935': 'toxin', 'EQU24_RS08135': 'toxin', 'EQU24_RS01930': 'toxin', 'EQU24_RS17920': 'toxin', 'EQU24_RS20265': 'toxin', 'EQU24_RS16915': 'toxin', 'EQU24_RS07460': 'toxin', 'EQU24_RS01935': 'toxin', 'EQU24_RS22115': 'toxin', 'EQU24_RS19020': 'toxin', 'EQU24_RS04380': 'toxin', 'EQU24_RS04110': 'toxin', 'EQU24_RS00215': 'toxin', 'EQU24_RS01345': 'toxin', 'EQU24_RS07575': 'toxin', 'EQU24_RS00220': 'toxin', 'EQU24_RS20270': 'toxin', 'EQU24_RS05325': 'toxin', 'EQU24_RS16470': 'toxin', 'EQU24_RS17375': 'toxin', 'EQU24_RS12475': 'toxin', 'EQU24_RS16330': 'toxin', 'EQU24_RS12820': 'toxin', 'EQU24_RS12825': 'toxin', 'EQU24_RS08850': 'toxin', 'EQU24_RS08845': 'toxin', 'EQU24_RS19480': '5152', 'EQU24_RS19490': '5152', 'EQU24_RS19495': '5152', 'EQU24_RS19515': '5152', 'EQU24_RS19510': '5152', 'EQU24_RS19505': '5152', 'EQU24_RS19470': '5152', 'EQU24_RS19460': '5152', 'EQU24_RS19450': '5152', 'EQU24_RS10650': 'RepCurCu-no5152', 'EQU24_RS15800': 'RepCurCu-no5152', 'EQU24_RS01900': 'RepCurCu-no5152', 'EQU24_RS21005': 'RepCurCu-no5152', 'EQU24_RS02325': 'RepCurCu-no5152', 'EQU24_RS05885': 'RepCurCu-no5152', 'EQU24_RS21000': 'RepCurCu-no5152', 'EQU24_RS00670': 'RepCurCu-no5152', 'EQU24_RS05870': 'RepCurCu-no5152', 'EQU24_RS10665': 'RepCurCu-no5152', 'EQU24_RS05880': 'RepCurCu-no5152', 'EQU24_RS05905': 'RepCurCu-no5152', 'EQU24_RS05915': 'RepCurCu-no5152', 'EQU24_RS05920': 'RepCurCu-no5152', 'EQU24_RS05925': 'RepCurCu-no5152'}
|
"""
107. Word Break
https://www.lintcode.com/problem/word-break/description?_from=ladder&&fromId=160
Memoization
"""
class Solution:
"""
@param: s: A string
@param: dict: A dictionary of words dict
@return: A boolean
"""
def wordBreak(self, s, dict):
# write your code here
if dict:
max_dict_word_length = max([len(x) for x in dict])
else:
max_dict_word_length = 0
return self.can_break(s, 0, dict, max_dict_word_length, {})
def can_break(self, s, i, dict, max_dict_word_length, memo):
if i in memo:
return memo[i]
if len(s) == i:
return True
for index in range(i, len(s)):
if index - i > max_dict_word_length:
break
if s[i:index + 1] not in dict:
continue
if self.can_break(s, index + 1, dict, max_dict_word_length, memo):
memo[i] = True
return memo[i]
return False
|
"""
107. Word Break
https://www.lintcode.com/problem/word-break/description?_from=ladder&&fromId=160
Memoization
"""
class Solution:
"""
@param: s: A string
@param: dict: A dictionary of words dict
@return: A boolean
"""
def word_break(self, s, dict):
if dict:
max_dict_word_length = max([len(x) for x in dict])
else:
max_dict_word_length = 0
return self.can_break(s, 0, dict, max_dict_word_length, {})
def can_break(self, s, i, dict, max_dict_word_length, memo):
if i in memo:
return memo[i]
if len(s) == i:
return True
for index in range(i, len(s)):
if index - i > max_dict_word_length:
break
if s[i:index + 1] not in dict:
continue
if self.can_break(s, index + 1, dict, max_dict_word_length, memo):
memo[i] = True
return memo[i]
return False
|
class Coordinate:
coordX = 0
coordY = 0
def __init__(self, coordX=0, coordY=0):
self.coordX = coordX
self.coordY = coordY
pass
def set(self, coordX, coordY):
self.coordX = coordX
self.coordY = coordY
return coordX, coordY
if __name__ == '__main__':
pass
|
class Coordinate:
coord_x = 0
coord_y = 0
def __init__(self, coordX=0, coordY=0):
self.coordX = coordX
self.coordY = coordY
pass
def set(self, coordX, coordY):
self.coordX = coordX
self.coordY = coordY
return (coordX, coordY)
if __name__ == '__main__':
pass
|
apiAttachAvailable = u'API Kullanilabilir'
apiAttachNotAvailable = u'Kullanilamiyor'
apiAttachPendingAuthorization = u'Yetkilendirme Bekliyor'
apiAttachRefused = u'Reddedildi'
apiAttachSuccess = u'Basarili oldu'
apiAttachUnknown = u'Bilinmiyor'
budDeletedFriend = u'Arkadas Listesinden Silindi'
budFriend = u'Arkadas'
budNeverBeenFriend = u'Arkadas Listesinde Hi\xe7 Olmadi'
budPendingAuthorization = u'Yetkilendirme Bekliyor'
budUnknown = u'Bilinmiyor'
cfrBlockedByRecipient = u'\xc7agri alici tarafindan engellendi'
cfrMiscError = u'Diger Hata'
cfrNoCommonCodec = u'Genel codec yok'
cfrNoProxyFound = u'Proxy bulunamadi'
cfrNotAuthorizedByRecipient = u'Ge\xe7erli kullanici alici tarafindan yetkilendirilmemis'
cfrRecipientNotFriend = u'Alici bir arkadas degil'
cfrRemoteDeviceError = u'Uzak ses aygitinda problem var'
cfrSessionTerminated = u'Oturum sonlandirildi'
cfrSoundIOError = u'Ses G/\xc7 hatasi'
cfrSoundRecordingError = u'Ses kayit hatasi'
cfrUnknown = u'Bilinmiyor'
cfrUserDoesNotExist = u'Kullanici/telefon numarasi mevcut degil'
cfrUserIsOffline = u'\xc7evrim Disi'
chsAllCalls = u'Eski Diyalog'
chsDialog = u'Diyalog'
chsIncomingCalls = u'\xc7oklu Sohbet Kabul\xfc Gerekli'
chsLegacyDialog = u'Eski Diyalog'
chsMissedCalls = u'Diyalog'
chsMultiNeedAccept = u'\xc7oklu Sohbet Kabul\xfc Gerekli'
chsMultiSubscribed = u'\xc7oklu Abonelik'
chsOutgoingCalls = u'\xc7oklu Abonelik'
chsUnknown = u'Bilinmiyor'
chsUnsubscribed = u'Aboneligi Silindi'
clsBusy = u'Mesgul'
clsCancelled = u'Iptal Edildi'
clsEarlyMedia = u'Early Media y\xfcr\xfct\xfcl\xfcyor'
clsFailed = u'\xdczg\xfcn\xfcz, arama basarisiz!'
clsFinished = u'Bitirildi'
clsInProgress = u'Arama Yapiliyor'
clsLocalHold = u'Yerel Beklemede'
clsMissed = u'Cevapsiz Arama'
clsOnHold = u'Beklemede'
clsRefused = u'Reddedildi'
clsRemoteHold = u'Uzak Beklemede'
clsRinging = u'ariyor'
clsRouting = u'Y\xf6nlendirme'
clsTransferred = u'Bilinmiyor'
clsTransferring = u'Bilinmiyor'
clsUnknown = u'Bilinmiyor'
clsUnplaced = u'Asla baglanmadi'
clsVoicemailBufferingGreeting = u'Selamlama Ara Bellege Aliniyor'
clsVoicemailCancelled = u'Sesli Posta Iptal Edildi'
clsVoicemailFailed = u'Sesli Mesaj Basarisiz'
clsVoicemailPlayingGreeting = u'Selamlama Y\xfcr\xfct\xfcl\xfcyor'
clsVoicemailRecording = u'Sesli Mesaj Kaydediliyor'
clsVoicemailSent = u'Sesli Posta G\xf6nderildi'
clsVoicemailUploading = u'Sesli Posta Karsiya Y\xfckleniyor'
cltIncomingP2P = u'Gelen Esler Arasi Telefon \xc7agrisi'
cltIncomingPSTN = u'Gelen Telefon \xc7agrisi'
cltOutgoingP2P = u'Giden Esler Arasi Telefon \xc7agrisi'
cltOutgoingPSTN = u'Giden Telefon \xc7agrisi'
cltUnknown = u'Bilinmiyor'
cmeAddedMembers = u'Eklenen \xdcyeler'
cmeCreatedChatWith = u'Sohbet Olusturuldu:'
cmeEmoted = u'Bilinmiyor'
cmeLeft = u'Birakilan'
cmeSaid = u'Ifade'
cmeSawMembers = u'G\xf6r\xfclen \xdcyeler'
cmeSetTopic = u'Konu Belirleme'
cmeUnknown = u'Bilinmiyor'
cmsRead = u'Okundu'
cmsReceived = u'Alindi'
cmsSending = u'G\xf6nderiliyor...'
cmsSent = u'G\xf6nderildi'
cmsUnknown = u'Bilinmiyor'
conConnecting = u'Baglaniyor'
conOffline = u'\xc7evrim Disi'
conOnline = u'\xc7evrim I\xe7i'
conPausing = u'Duraklatiliyor'
conUnknown = u'Bilinmiyor'
cusAway = u'Uzakta'
cusDoNotDisturb = u'Rahatsiz Etmeyin'
cusInvisible = u'G\xf6r\xfcnmez'
cusLoggedOut = u'\xc7evrim Disi'
cusNotAvailable = u'Kullanilamiyor'
cusOffline = u'\xc7evrim Disi'
cusOnline = u'\xc7evrim I\xe7i'
cusSkypeMe = u'Skype Me'
cusUnknown = u'Bilinmiyor'
cvsBothEnabled = u'Video G\xf6nderme ve Alma'
cvsNone = u'Video Yok'
cvsReceiveEnabled = u'Video Alma'
cvsSendEnabled = u'Video G\xf6nderme'
cvsUnknown = u''
grpAllFriends = u'T\xfcm Arkadaslar'
grpAllUsers = u'T\xfcm Kullanicilar'
grpCustomGroup = u'\xd6zel'
grpOnlineFriends = u'\xc7evrimi\xe7i Arkadaslar'
grpPendingAuthorizationFriends = u'Yetkilendirme Bekliyor'
grpProposedSharedGroup = u'Proposed Shared Group'
grpRecentlyContactedUsers = u'Son Zamanlarda Iletisim Kurulmus Kullanicilar'
grpSharedGroup = u'Shared Group'
grpSkypeFriends = u'Skype Arkadaslari'
grpSkypeOutFriends = u'SkypeOut Arkadaslari'
grpUngroupedFriends = u'Gruplanmamis Arkadaslar'
grpUnknown = u'Bilinmiyor'
grpUsersAuthorizedByMe = u'Tarafimdan Yetkilendirilenler'
grpUsersBlockedByMe = u'Engellediklerim'
grpUsersWaitingMyAuthorization = u'Yetkilendirmemi Bekleyenler'
leaAddDeclined = u'Ekleme Reddedildi'
leaAddedNotAuthorized = u'Ekleyen Kisinin Yetkisi Olmali'
leaAdderNotFriend = u'Ekleyen Bir Arkadas Olmali'
leaUnknown = u'Bilinmiyor'
leaUnsubscribe = u'Aboneligi Silindi'
leaUserIncapable = u'Kullanicidan Kaynaklanan Yetersizlik'
leaUserNotFound = u'Kullanici Bulunamadi'
olsAway = u'Uzakta'
olsDoNotDisturb = u'Rahatsiz Etmeyin'
olsNotAvailable = u'Kullanilamiyor'
olsOffline = u'\xc7evrim Disi'
olsOnline = u'\xc7evrim I\xe7i'
olsSkypeMe = u'Skype Me'
olsSkypeOut = u'SkypeOut'
olsUnknown = u'Bilinmiyor'
smsMessageStatusComposing = u'Composing'
smsMessageStatusDelivered = u'Delivered'
smsMessageStatusFailed = u'Failed'
smsMessageStatusRead = u'Read'
smsMessageStatusReceived = u'Received'
smsMessageStatusSendingToServer = u'Sending to Server'
smsMessageStatusSentToServer = u'Sent to Server'
smsMessageStatusSomeTargetsFailed = u'Some Targets Failed'
smsMessageStatusUnknown = u'Unknown'
smsMessageTypeCCRequest = u'Confirmation Code Request'
smsMessageTypeCCSubmit = u'Confirmation Code Submit'
smsMessageTypeIncoming = u'Incoming'
smsMessageTypeOutgoing = u'Outgoing'
smsMessageTypeUnknown = u'Unknown'
smsTargetStatusAcceptable = u'Acceptable'
smsTargetStatusAnalyzing = u'Analyzing'
smsTargetStatusDeliveryFailed = u'Delivery Failed'
smsTargetStatusDeliveryPending = u'Delivery Pending'
smsTargetStatusDeliverySuccessful = u'Delivery Successful'
smsTargetStatusNotRoutable = u'Not Routable'
smsTargetStatusUndefined = u'Undefined'
smsTargetStatusUnknown = u'Unknown'
usexFemale = u'Kadin'
usexMale = u'Erkek'
usexUnknown = u'Bilinmiyor'
vmrConnectError = u'Baglanti Hatasi'
vmrFileReadError = u'Dosya Okuma Hatasi'
vmrFileWriteError = u'Dosya Yazma Hatasi'
vmrMiscError = u'Diger Hata'
vmrNoError = u'Hata Yok'
vmrNoPrivilege = u'Sesli Posta \xd6nceligi Yok'
vmrNoVoicemail = u'B\xf6yle Bir Sesli Posta Yok'
vmrPlaybackError = u'Y\xfcr\xfctme Hatasi'
vmrRecordingError = u'Kayit Hatasi'
vmrUnknown = u'Bilinmiyor'
vmsBlank = u'Bos'
vmsBuffering = u'Ara bellege aliniyor'
vmsDeleting = u'Siliniyor'
vmsDownloading = u'Karsidan Y\xfckleniyor'
vmsFailed = u'Basarisiz Oldu'
vmsNotDownloaded = u'Karsidan Y\xfcklenmedi'
vmsPlayed = u'Y\xfcr\xfct\xfcld\xfc'
vmsPlaying = u'Y\xfcr\xfct\xfcl\xfcyor'
vmsRecorded = u'Kaydedildi'
vmsRecording = u'Sesli Mesaj Kaydediliyor'
vmsUnknown = u'Bilinmiyor'
vmsUnplayed = u'Y\xfcr\xfct\xfclmemis'
vmsUploaded = u'Karsiya Y\xfcklendi'
vmsUploading = u'Karsiya Y\xfckleniyor'
vmtCustomGreeting = u'\xd6zel Selamlama'
vmtDefaultGreeting = u'Varsayilan Selamlama'
vmtIncoming = u'gelen sesli mesaj'
vmtOutgoing = u'Giden'
vmtUnknown = u'Bilinmiyor'
vssAvailable = u'Kullanilabilir'
vssNotAvailable = u'Kullanilamiyor'
vssPaused = u'Duraklatildi'
vssRejected = u'Reddedildi'
vssRunning = u'\xc7alisiyor'
vssStarting = u'Basliyor'
vssStopping = u'Durduruluyor'
vssUnknown = u'Bilinmiyor'
|
api_attach_available = u'API Kullanilabilir'
api_attach_not_available = u'Kullanilamiyor'
api_attach_pending_authorization = u'Yetkilendirme Bekliyor'
api_attach_refused = u'Reddedildi'
api_attach_success = u'Basarili oldu'
api_attach_unknown = u'Bilinmiyor'
bud_deleted_friend = u'Arkadas Listesinden Silindi'
bud_friend = u'Arkadas'
bud_never_been_friend = u'Arkadas Listesinde Hiç Olmadi'
bud_pending_authorization = u'Yetkilendirme Bekliyor'
bud_unknown = u'Bilinmiyor'
cfr_blocked_by_recipient = u'Çagri alici tarafindan engellendi'
cfr_misc_error = u'Diger Hata'
cfr_no_common_codec = u'Genel codec yok'
cfr_no_proxy_found = u'Proxy bulunamadi'
cfr_not_authorized_by_recipient = u'Geçerli kullanici alici tarafindan yetkilendirilmemis'
cfr_recipient_not_friend = u'Alici bir arkadas degil'
cfr_remote_device_error = u'Uzak ses aygitinda problem var'
cfr_session_terminated = u'Oturum sonlandirildi'
cfr_sound_io_error = u'Ses G/Ç hatasi'
cfr_sound_recording_error = u'Ses kayit hatasi'
cfr_unknown = u'Bilinmiyor'
cfr_user_does_not_exist = u'Kullanici/telefon numarasi mevcut degil'
cfr_user_is_offline = u'Çevrim Disi'
chs_all_calls = u'Eski Diyalog'
chs_dialog = u'Diyalog'
chs_incoming_calls = u'Çoklu Sohbet Kabulü Gerekli'
chs_legacy_dialog = u'Eski Diyalog'
chs_missed_calls = u'Diyalog'
chs_multi_need_accept = u'Çoklu Sohbet Kabulü Gerekli'
chs_multi_subscribed = u'Çoklu Abonelik'
chs_outgoing_calls = u'Çoklu Abonelik'
chs_unknown = u'Bilinmiyor'
chs_unsubscribed = u'Aboneligi Silindi'
cls_busy = u'Mesgul'
cls_cancelled = u'Iptal Edildi'
cls_early_media = u'Early Media yürütülüyor'
cls_failed = u'Üzgünüz, arama basarisiz!'
cls_finished = u'Bitirildi'
cls_in_progress = u'Arama Yapiliyor'
cls_local_hold = u'Yerel Beklemede'
cls_missed = u'Cevapsiz Arama'
cls_on_hold = u'Beklemede'
cls_refused = u'Reddedildi'
cls_remote_hold = u'Uzak Beklemede'
cls_ringing = u'ariyor'
cls_routing = u'Yönlendirme'
cls_transferred = u'Bilinmiyor'
cls_transferring = u'Bilinmiyor'
cls_unknown = u'Bilinmiyor'
cls_unplaced = u'Asla baglanmadi'
cls_voicemail_buffering_greeting = u'Selamlama Ara Bellege Aliniyor'
cls_voicemail_cancelled = u'Sesli Posta Iptal Edildi'
cls_voicemail_failed = u'Sesli Mesaj Basarisiz'
cls_voicemail_playing_greeting = u'Selamlama Yürütülüyor'
cls_voicemail_recording = u'Sesli Mesaj Kaydediliyor'
cls_voicemail_sent = u'Sesli Posta Gönderildi'
cls_voicemail_uploading = u'Sesli Posta Karsiya Yükleniyor'
clt_incoming_p2_p = u'Gelen Esler Arasi Telefon Çagrisi'
clt_incoming_pstn = u'Gelen Telefon Çagrisi'
clt_outgoing_p2_p = u'Giden Esler Arasi Telefon Çagrisi'
clt_outgoing_pstn = u'Giden Telefon Çagrisi'
clt_unknown = u'Bilinmiyor'
cme_added_members = u'Eklenen Üyeler'
cme_created_chat_with = u'Sohbet Olusturuldu:'
cme_emoted = u'Bilinmiyor'
cme_left = u'Birakilan'
cme_said = u'Ifade'
cme_saw_members = u'Görülen Üyeler'
cme_set_topic = u'Konu Belirleme'
cme_unknown = u'Bilinmiyor'
cms_read = u'Okundu'
cms_received = u'Alindi'
cms_sending = u'Gönderiliyor...'
cms_sent = u'Gönderildi'
cms_unknown = u'Bilinmiyor'
con_connecting = u'Baglaniyor'
con_offline = u'Çevrim Disi'
con_online = u'Çevrim Içi'
con_pausing = u'Duraklatiliyor'
con_unknown = u'Bilinmiyor'
cus_away = u'Uzakta'
cus_do_not_disturb = u'Rahatsiz Etmeyin'
cus_invisible = u'Görünmez'
cus_logged_out = u'Çevrim Disi'
cus_not_available = u'Kullanilamiyor'
cus_offline = u'Çevrim Disi'
cus_online = u'Çevrim Içi'
cus_skype_me = u'Skype Me'
cus_unknown = u'Bilinmiyor'
cvs_both_enabled = u'Video Gönderme ve Alma'
cvs_none = u'Video Yok'
cvs_receive_enabled = u'Video Alma'
cvs_send_enabled = u'Video Gönderme'
cvs_unknown = u''
grp_all_friends = u'Tüm Arkadaslar'
grp_all_users = u'Tüm Kullanicilar'
grp_custom_group = u'Özel'
grp_online_friends = u'Çevrimiçi Arkadaslar'
grp_pending_authorization_friends = u'Yetkilendirme Bekliyor'
grp_proposed_shared_group = u'Proposed Shared Group'
grp_recently_contacted_users = u'Son Zamanlarda Iletisim Kurulmus Kullanicilar'
grp_shared_group = u'Shared Group'
grp_skype_friends = u'Skype Arkadaslari'
grp_skype_out_friends = u'SkypeOut Arkadaslari'
grp_ungrouped_friends = u'Gruplanmamis Arkadaslar'
grp_unknown = u'Bilinmiyor'
grp_users_authorized_by_me = u'Tarafimdan Yetkilendirilenler'
grp_users_blocked_by_me = u'Engellediklerim'
grp_users_waiting_my_authorization = u'Yetkilendirmemi Bekleyenler'
lea_add_declined = u'Ekleme Reddedildi'
lea_added_not_authorized = u'Ekleyen Kisinin Yetkisi Olmali'
lea_adder_not_friend = u'Ekleyen Bir Arkadas Olmali'
lea_unknown = u'Bilinmiyor'
lea_unsubscribe = u'Aboneligi Silindi'
lea_user_incapable = u'Kullanicidan Kaynaklanan Yetersizlik'
lea_user_not_found = u'Kullanici Bulunamadi'
ols_away = u'Uzakta'
ols_do_not_disturb = u'Rahatsiz Etmeyin'
ols_not_available = u'Kullanilamiyor'
ols_offline = u'Çevrim Disi'
ols_online = u'Çevrim Içi'
ols_skype_me = u'Skype Me'
ols_skype_out = u'SkypeOut'
ols_unknown = u'Bilinmiyor'
sms_message_status_composing = u'Composing'
sms_message_status_delivered = u'Delivered'
sms_message_status_failed = u'Failed'
sms_message_status_read = u'Read'
sms_message_status_received = u'Received'
sms_message_status_sending_to_server = u'Sending to Server'
sms_message_status_sent_to_server = u'Sent to Server'
sms_message_status_some_targets_failed = u'Some Targets Failed'
sms_message_status_unknown = u'Unknown'
sms_message_type_cc_request = u'Confirmation Code Request'
sms_message_type_cc_submit = u'Confirmation Code Submit'
sms_message_type_incoming = u'Incoming'
sms_message_type_outgoing = u'Outgoing'
sms_message_type_unknown = u'Unknown'
sms_target_status_acceptable = u'Acceptable'
sms_target_status_analyzing = u'Analyzing'
sms_target_status_delivery_failed = u'Delivery Failed'
sms_target_status_delivery_pending = u'Delivery Pending'
sms_target_status_delivery_successful = u'Delivery Successful'
sms_target_status_not_routable = u'Not Routable'
sms_target_status_undefined = u'Undefined'
sms_target_status_unknown = u'Unknown'
usex_female = u'Kadin'
usex_male = u'Erkek'
usex_unknown = u'Bilinmiyor'
vmr_connect_error = u'Baglanti Hatasi'
vmr_file_read_error = u'Dosya Okuma Hatasi'
vmr_file_write_error = u'Dosya Yazma Hatasi'
vmr_misc_error = u'Diger Hata'
vmr_no_error = u'Hata Yok'
vmr_no_privilege = u'Sesli Posta Önceligi Yok'
vmr_no_voicemail = u'Böyle Bir Sesli Posta Yok'
vmr_playback_error = u'Yürütme Hatasi'
vmr_recording_error = u'Kayit Hatasi'
vmr_unknown = u'Bilinmiyor'
vms_blank = u'Bos'
vms_buffering = u'Ara bellege aliniyor'
vms_deleting = u'Siliniyor'
vms_downloading = u'Karsidan Yükleniyor'
vms_failed = u'Basarisiz Oldu'
vms_not_downloaded = u'Karsidan Yüklenmedi'
vms_played = u'Yürütüldü'
vms_playing = u'Yürütülüyor'
vms_recorded = u'Kaydedildi'
vms_recording = u'Sesli Mesaj Kaydediliyor'
vms_unknown = u'Bilinmiyor'
vms_unplayed = u'Yürütülmemis'
vms_uploaded = u'Karsiya Yüklendi'
vms_uploading = u'Karsiya Yükleniyor'
vmt_custom_greeting = u'Özel Selamlama'
vmt_default_greeting = u'Varsayilan Selamlama'
vmt_incoming = u'gelen sesli mesaj'
vmt_outgoing = u'Giden'
vmt_unknown = u'Bilinmiyor'
vss_available = u'Kullanilabilir'
vss_not_available = u'Kullanilamiyor'
vss_paused = u'Duraklatildi'
vss_rejected = u'Reddedildi'
vss_running = u'Çalisiyor'
vss_starting = u'Basliyor'
vss_stopping = u'Durduruluyor'
vss_unknown = u'Bilinmiyor'
|
# Copyright (C) 2015-2016 Ammon Smith and Bradley Cai
# Available for use under the terms of the MIT License.
__all__ = [
'print_success',
'print_failure',
]
def print_success(target, usecolor, elapsed):
if usecolor:
start_color = '\033[32;4m'
end_color = '\033[0m'
else:
start_color = ''
end_color = ''
print("%sTarget '%s' ran successfully in %.4f seconds.%s" %
(start_color, target, elapsed, end_color))
def print_failure(target, usecolor, ending):
if usecolor:
start_color = '\033[31;4m'
end_color = '\033[0m'
else:
start_color = ''
end_color = ''
print("%sTarget '%s' was unsuccessful%s%s" %
(start_color, target, ending, end_color))
|
__all__ = ['print_success', 'print_failure']
def print_success(target, usecolor, elapsed):
if usecolor:
start_color = '\x1b[32;4m'
end_color = '\x1b[0m'
else:
start_color = ''
end_color = ''
print("%sTarget '%s' ran successfully in %.4f seconds.%s" % (start_color, target, elapsed, end_color))
def print_failure(target, usecolor, ending):
if usecolor:
start_color = '\x1b[31;4m'
end_color = '\x1b[0m'
else:
start_color = ''
end_color = ''
print("%sTarget '%s' was unsuccessful%s%s" % (start_color, target, ending, end_color))
|
#
# PySNMP MIB module IANA-GMPLS-TC-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/IANA-GMPLS-TC-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:19:44 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ValueSizeConstraint, SingleValueConstraint, ConstraintsUnion, ConstraintsIntersection, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "SingleValueConstraint", "ConstraintsUnion", "ConstraintsIntersection", "ValueRangeConstraint")
ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup")
ObjectIdentity, Counter32, Gauge32, TimeTicks, mib_2, MibScalar, MibTable, MibTableRow, MibTableColumn, MibIdentifier, iso, Integer32, ModuleIdentity, Bits, NotificationType, Unsigned32, IpAddress, Counter64 = mibBuilder.importSymbols("SNMPv2-SMI", "ObjectIdentity", "Counter32", "Gauge32", "TimeTicks", "mib-2", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "MibIdentifier", "iso", "Integer32", "ModuleIdentity", "Bits", "NotificationType", "Unsigned32", "IpAddress", "Counter64")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
ianaGmpls = ModuleIdentity((1, 3, 6, 1, 2, 1, 152))
ianaGmpls.setRevisions(('2015-11-04 00:00', '2015-09-22 00:00', '2014-05-09 00:00', '2014-03-11 00:00', '2013-12-16 00:00', '2013-11-04 00:00', '2013-10-14 00:00', '2013-10-10 00:00', '2013-10-09 00:00', '2010-04-13 00:00', '2010-02-22 00:00', '2010-02-19 00:00', '2007-02-27 00:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts: ianaGmpls.setRevisionsDescriptions(('Updated description for Switching Type 151.', 'Added Switching Type 151.', 'Fixed typographical error that interfered with compilation.', 'Added Administrative Status Information Flags 23-24.', 'Added Switching Type 110.', 'Added missing value 40 to IANAGmplsSwitchingTypeTC.', 'Restored names,added comments for G-PIDs 47, 56; updated IANA contact info.', 'Deprecated 2-4 in IANAGmplsSwitchingTypeTC, added registry reference.', 'Added Generalized PIDs 59-70 and changed names for 47, 56.', 'Added LSP Encoding Type tunnelLine(14), Switching Type evpl(30).', 'Added missing Administrative Status Information Flags 25, 26, and 28.', 'Added dcsc(125).', 'Initial version issued as part of RFC 4802.',))
if mibBuilder.loadTexts: ianaGmpls.setLastUpdated('201511040000Z')
if mibBuilder.loadTexts: ianaGmpls.setOrganization('IANA')
if mibBuilder.loadTexts: ianaGmpls.setContactInfo('Internet Assigned Numbers Authority Postal: 12025 Waterfront Drive, Suite 300 Los Angeles, CA 90094 Tel: +1 310 301-5800 E-Mail: iana&iana.org')
if mibBuilder.loadTexts: ianaGmpls.setDescription('Copyright (C) The IETF Trust (2007). The initial version of this MIB module was published in RFC 4802. For full legal notices see the RFC itself. Supplementary information may be available on: http://www.ietf.org/copyrights/ianamib.html')
class IANAGmplsLSPEncodingTypeTC(TextualConvention, Integer32):
reference = '1. Generalized Multi-Protocol Label Switching (GMPLS) Signaling Functional Description, RFC 3471, section 3.1.1. 2. Generalized MPLS Signalling Extensions for G.709 Optical Transport Networks Control, RFC 4328, section 3.1.1.'
description = 'This type is used to represent and control the LSP encoding type of an LSP signaled by a GMPLS signaling protocol. This textual convention is strongly tied to the LSP Encoding Types sub-registry of the GMPLS Signaling Parameters registry managed by IANA. Values should be assigned by IANA in step with the LSP Encoding Types sub-registry and using the same registry management rules. However, the actual values used in this textual convention are solely within the purview of IANA and do not necessarily match the values in the LSP Encoding Types sub-registry. The definition of this textual convention with the addition of newly assigned values is published periodically by the IANA, in either the Assigned Numbers RFC, or some derivative of it specific to Internet Network Management number assignments. (The latest arrangements can be obtained by contacting the IANA.) Requests for new values should be made to IANA via email (iana&iana.org).'
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 5, 7, 8, 9, 11, 12, 13, 14))
namedValues = NamedValues(("tunnelLspNotGmpls", 0), ("tunnelLspPacket", 1), ("tunnelLspEthernet", 2), ("tunnelLspAnsiEtsiPdh", 3), ("tunnelLspSdhSonet", 5), ("tunnelLspDigitalWrapper", 7), ("tunnelLspLambda", 8), ("tunnelLspFiber", 9), ("tunnelLspFiberChannel", 11), ("tunnelDigitalPath", 12), ("tunnelOpticalChannel", 13), ("tunnelLine", 14))
class IANAGmplsSwitchingTypeTC(TextualConvention, Integer32):
reference = '1. Routing Extensions in Support of Generalized Multi-Protocol Label Switching, RFC 4202, section 2.4. 2. Generalized Multi-Protocol Label Switching (GMPLS) Signaling Functional Description, RFC 3471, section 3.1.1. 3. Revised Definition of The GMPLS Switching Capability and Type Fields, RFC7074, section 5.'
description = 'This type is used to represent and control the LSP switching type of an LSP signaled by a GMPLS signaling protocol. This textual convention is strongly tied to the Switching Types sub-registry of the GMPLS Signaling Parameters registry managed by IANA. Values should be assigned by IANA in step with the Switching Types sub-registry and using the same registry management rules. However, the actual values used in this textual convention are solely within the purview of IANA and do not necessarily match the values in the Switching Types sub-registry. The definition of this textual convention with the addition of newly assigned values is published periodically by the IANA, in either the Assigned Numbers RFC, or some derivative of it specific to Internet Network Management number assignments. (The latest arrangements can be obtained by contacting the IANA.) Requests for new values should be made to IANA via email (iana&iana.org).'
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4, 30, 40, 51, 100, 110, 125, 150, 151, 200))
namedValues = NamedValues(("unknown", 0), ("psc1", 1), ("psc2", 2), ("psc3", 3), ("psc4", 4), ("evpl", 30), ("pbb", 40), ("l2sc", 51), ("tdm", 100), ("otntdm", 110), ("dcsc", 125), ("lsc", 150), ("wsonlsc", 151), ("fsc", 200))
class IANAGmplsGeneralizedPidTC(TextualConvention, Integer32):
reference = '1. Generalized Multi-Protocol Label Switching (GMPLS) Signaling Functional Description, RFC 3471, section 3.1.1. 2. Generalized MPLS Signalling Extensions for G.709 Optical Transport Networks Control, RFC 4328, section 3.1.3. 3. Generalized Multi-Protocol Label Switching (GMPLS) Signaling Extensions for the evolving G.709 Optical Transport Networks Control,[RFC7139], sections 4 and 11.'
description = 'This data type is used to represent and control the LSP Generalized Protocol Identifier (G-PID) of an LSP signaled by a GMPLS signaling protocol. This textual convention is strongly tied to the Generalized PIDs (G-PID) sub-registry of the GMPLS Signaling Parameters registry managed by IANA. Values should be assigned by IANA in step with the Generalized PIDs (G-PID) sub-registry and using the same registry management rules. However, the actual values used in this textual convention are solely within the purview of IANA and do not necessarily match the values in the Generalized PIDs (G-PID) sub-registry. The definition of this textual convention with the addition of newly assigned values is published periodically by the IANA, in either the Assigned Numbers RFC, or some derivative of it specific to Internet Network Management number assignments. (The latest arrangements can be obtained by contacting the IANA.) Requests for new values should be made to IANA via email (iana&iana.org).'
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70))
namedValues = NamedValues(("unknown", 0), ("asynchE4", 5), ("asynchDS3T3", 6), ("asynchE3", 7), ("bitsynchE3", 8), ("bytesynchE3", 9), ("asynchDS2T2", 10), ("bitsynchDS2T2", 11), ("reservedByRFC3471first", 12), ("asynchE1", 13), ("bytesynchE1", 14), ("bytesynch31ByDS0", 15), ("asynchDS1T1", 16), ("bitsynchDS1T1", 17), ("bytesynchDS1T1", 18), ("vc1vc12", 19), ("reservedByRFC3471second", 20), ("reservedByRFC3471third", 21), ("ds1SFAsynch", 22), ("ds1ESFAsynch", 23), ("ds3M23Asynch", 24), ("ds3CBitParityAsynch", 25), ("vtLovc", 26), ("stsSpeHovc", 27), ("posNoScramble16BitCrc", 28), ("posNoScramble32BitCrc", 29), ("posScramble16BitCrc", 30), ("posScramble32BitCrc", 31), ("atm", 32), ("ethernet", 33), ("sdhSonet", 34), ("digitalwrapper", 36), ("lambda", 37), ("ansiEtsiPdh", 38), ("lapsSdh", 40), ("fddi", 41), ("dqdb", 42), ("fiberChannel3", 43), ("hdlc", 44), ("ethernetV2DixOnly", 45), ("ethernet802dot3Only", 46), ("g709ODUj", 47), ("g709OTUk", 48), ("g709CBRorCBRa", 49), ("g709CBRb", 50), ("g709BSOT", 51), ("g709BSNT", 52), ("gfpIPorPPP", 53), ("gfpEthernetMAC", 54), ("gfpEthernetPHY", 55), ("g709ESCON", 56), ("g709FICON", 57), ("g709FiberChannel", 58), ("framedGFP", 59), ("sTM1", 60), ("sTM4", 61), ("infiniBand", 62), ("sDI", 63), ("sDI1point001", 64), ("dVBASI", 65), ("g709ODU125G", 66), ("g709ODUAny", 67), ("nullTest", 68), ("randomTest", 69), ("sixtyfourB66BGFPFEthernet", 70))
class IANAGmplsAdminStatusInformationTC(TextualConvention, Bits):
reference = '1. Generalized Multi-Protocol Label Switching (GMPLS) Signaling Functional Description, RFC 3471, section 8. 2. Generalized MPLS Signaling - RSVP-TE Extensions, RFC 3473, section 7. 3. GMPLS - Communication of Alarm Information, RFC 4783, section 3.2.1.'
description = 'This data type determines the setting of the Admin Status flags in the Admin Status object or TLV, as described in RFC 3471. Setting this object to a non-zero value will result in the inclusion of the Admin Status object or TLV on signaling messages. This textual convention is strongly tied to the Administrative Status Information Flags sub-registry of the GMPLS Signaling Parameters registry managed by IANA. Values should be assigned by IANA in step with the Administrative Status Flags sub-registry and using the same registry management rules. However, the actual values used in this textual convention are solely within the purview of IANA and do not necessarily match the values in the Administrative Status Information Flags sub-registry. The definition of this textual convention with the addition of newly assigned values is published periodically by the IANA, in either the Assigned Numbers RFC, or some derivative of it specific to Internet Network Management number assignments. (The latest arrangements can be obtained by contacting the IANA.) Requests for new values should be made to IANA via email (iana&iana.org).'
status = 'current'
namedValues = NamedValues(("reflect", 0), ("reserved1", 1), ("reserved2", 2), ("reserved3", 3), ("reserved4", 4), ("reserved5", 5), ("reserved6", 6), ("reserved7", 7), ("reserved8", 8), ("reserved9", 9), ("reserved10", 10), ("reserved11", 11), ("reserved12", 12), ("reserved13", 13), ("reserved14", 14), ("reserved15", 15), ("reserved16", 16), ("reserved17", 17), ("reserved18", 18), ("reserved19", 19), ("reserved20", 20), ("reserved21", 21), ("reserved22", 22), ("oamFlowsEnabled", 23), ("oamAlarmsEnabled", 24), ("handover", 25), ("lockout", 26), ("inhibitAlarmCommunication", 27), ("callControl", 28), ("testing", 29), ("administrativelyDown", 30), ("deleteInProgress", 31))
mibBuilder.exportSymbols("IANA-GMPLS-TC-MIB", IANAGmplsSwitchingTypeTC=IANAGmplsSwitchingTypeTC, IANAGmplsLSPEncodingTypeTC=IANAGmplsLSPEncodingTypeTC, IANAGmplsAdminStatusInformationTC=IANAGmplsAdminStatusInformationTC, PYSNMP_MODULE_ID=ianaGmpls, ianaGmpls=ianaGmpls, IANAGmplsGeneralizedPidTC=IANAGmplsGeneralizedPidTC)
|
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, single_value_constraint, constraints_union, constraints_intersection, value_range_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueSizeConstraint', 'SingleValueConstraint', 'ConstraintsUnion', 'ConstraintsIntersection', 'ValueRangeConstraint')
(module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup')
(object_identity, counter32, gauge32, time_ticks, mib_2, mib_scalar, mib_table, mib_table_row, mib_table_column, mib_identifier, iso, integer32, module_identity, bits, notification_type, unsigned32, ip_address, counter64) = mibBuilder.importSymbols('SNMPv2-SMI', 'ObjectIdentity', 'Counter32', 'Gauge32', 'TimeTicks', 'mib-2', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'MibIdentifier', 'iso', 'Integer32', 'ModuleIdentity', 'Bits', 'NotificationType', 'Unsigned32', 'IpAddress', 'Counter64')
(display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention')
iana_gmpls = module_identity((1, 3, 6, 1, 2, 1, 152))
ianaGmpls.setRevisions(('2015-11-04 00:00', '2015-09-22 00:00', '2014-05-09 00:00', '2014-03-11 00:00', '2013-12-16 00:00', '2013-11-04 00:00', '2013-10-14 00:00', '2013-10-10 00:00', '2013-10-09 00:00', '2010-04-13 00:00', '2010-02-22 00:00', '2010-02-19 00:00', '2007-02-27 00:00'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts:
ianaGmpls.setRevisionsDescriptions(('Updated description for Switching Type 151.', 'Added Switching Type 151.', 'Fixed typographical error that interfered with compilation.', 'Added Administrative Status Information Flags 23-24.', 'Added Switching Type 110.', 'Added missing value 40 to IANAGmplsSwitchingTypeTC.', 'Restored names,added comments for G-PIDs 47, 56; updated IANA contact info.', 'Deprecated 2-4 in IANAGmplsSwitchingTypeTC, added registry reference.', 'Added Generalized PIDs 59-70 and changed names for 47, 56.', 'Added LSP Encoding Type tunnelLine(14), Switching Type evpl(30).', 'Added missing Administrative Status Information Flags 25, 26, and 28.', 'Added dcsc(125).', 'Initial version issued as part of RFC 4802.'))
if mibBuilder.loadTexts:
ianaGmpls.setLastUpdated('201511040000Z')
if mibBuilder.loadTexts:
ianaGmpls.setOrganization('IANA')
if mibBuilder.loadTexts:
ianaGmpls.setContactInfo('Internet Assigned Numbers Authority Postal: 12025 Waterfront Drive, Suite 300 Los Angeles, CA 90094 Tel: +1 310 301-5800 E-Mail: iana&iana.org')
if mibBuilder.loadTexts:
ianaGmpls.setDescription('Copyright (C) The IETF Trust (2007). The initial version of this MIB module was published in RFC 4802. For full legal notices see the RFC itself. Supplementary information may be available on: http://www.ietf.org/copyrights/ianamib.html')
class Ianagmplslspencodingtypetc(TextualConvention, Integer32):
reference = '1. Generalized Multi-Protocol Label Switching (GMPLS) Signaling Functional Description, RFC 3471, section 3.1.1. 2. Generalized MPLS Signalling Extensions for G.709 Optical Transport Networks Control, RFC 4328, section 3.1.1.'
description = 'This type is used to represent and control the LSP encoding type of an LSP signaled by a GMPLS signaling protocol. This textual convention is strongly tied to the LSP Encoding Types sub-registry of the GMPLS Signaling Parameters registry managed by IANA. Values should be assigned by IANA in step with the LSP Encoding Types sub-registry and using the same registry management rules. However, the actual values used in this textual convention are solely within the purview of IANA and do not necessarily match the values in the LSP Encoding Types sub-registry. The definition of this textual convention with the addition of newly assigned values is published periodically by the IANA, in either the Assigned Numbers RFC, or some derivative of it specific to Internet Network Management number assignments. (The latest arrangements can be obtained by contacting the IANA.) Requests for new values should be made to IANA via email (iana&iana.org).'
status = 'current'
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(0, 1, 2, 3, 5, 7, 8, 9, 11, 12, 13, 14))
named_values = named_values(('tunnelLspNotGmpls', 0), ('tunnelLspPacket', 1), ('tunnelLspEthernet', 2), ('tunnelLspAnsiEtsiPdh', 3), ('tunnelLspSdhSonet', 5), ('tunnelLspDigitalWrapper', 7), ('tunnelLspLambda', 8), ('tunnelLspFiber', 9), ('tunnelLspFiberChannel', 11), ('tunnelDigitalPath', 12), ('tunnelOpticalChannel', 13), ('tunnelLine', 14))
class Ianagmplsswitchingtypetc(TextualConvention, Integer32):
reference = '1. Routing Extensions in Support of Generalized Multi-Protocol Label Switching, RFC 4202, section 2.4. 2. Generalized Multi-Protocol Label Switching (GMPLS) Signaling Functional Description, RFC 3471, section 3.1.1. 3. Revised Definition of The GMPLS Switching Capability and Type Fields, RFC7074, section 5.'
description = 'This type is used to represent and control the LSP switching type of an LSP signaled by a GMPLS signaling protocol. This textual convention is strongly tied to the Switching Types sub-registry of the GMPLS Signaling Parameters registry managed by IANA. Values should be assigned by IANA in step with the Switching Types sub-registry and using the same registry management rules. However, the actual values used in this textual convention are solely within the purview of IANA and do not necessarily match the values in the Switching Types sub-registry. The definition of this textual convention with the addition of newly assigned values is published periodically by the IANA, in either the Assigned Numbers RFC, or some derivative of it specific to Internet Network Management number assignments. (The latest arrangements can be obtained by contacting the IANA.) Requests for new values should be made to IANA via email (iana&iana.org).'
status = 'current'
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(0, 1, 2, 3, 4, 30, 40, 51, 100, 110, 125, 150, 151, 200))
named_values = named_values(('unknown', 0), ('psc1', 1), ('psc2', 2), ('psc3', 3), ('psc4', 4), ('evpl', 30), ('pbb', 40), ('l2sc', 51), ('tdm', 100), ('otntdm', 110), ('dcsc', 125), ('lsc', 150), ('wsonlsc', 151), ('fsc', 200))
class Ianagmplsgeneralizedpidtc(TextualConvention, Integer32):
reference = '1. Generalized Multi-Protocol Label Switching (GMPLS) Signaling Functional Description, RFC 3471, section 3.1.1. 2. Generalized MPLS Signalling Extensions for G.709 Optical Transport Networks Control, RFC 4328, section 3.1.3. 3. Generalized Multi-Protocol Label Switching (GMPLS) Signaling Extensions for the evolving G.709 Optical Transport Networks Control,[RFC7139], sections 4 and 11.'
description = 'This data type is used to represent and control the LSP Generalized Protocol Identifier (G-PID) of an LSP signaled by a GMPLS signaling protocol. This textual convention is strongly tied to the Generalized PIDs (G-PID) sub-registry of the GMPLS Signaling Parameters registry managed by IANA. Values should be assigned by IANA in step with the Generalized PIDs (G-PID) sub-registry and using the same registry management rules. However, the actual values used in this textual convention are solely within the purview of IANA and do not necessarily match the values in the Generalized PIDs (G-PID) sub-registry. The definition of this textual convention with the addition of newly assigned values is published periodically by the IANA, in either the Assigned Numbers RFC, or some derivative of it specific to Internet Network Management number assignments. (The latest arrangements can be obtained by contacting the IANA.) Requests for new values should be made to IANA via email (iana&iana.org).'
status = 'current'
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70))
named_values = named_values(('unknown', 0), ('asynchE4', 5), ('asynchDS3T3', 6), ('asynchE3', 7), ('bitsynchE3', 8), ('bytesynchE3', 9), ('asynchDS2T2', 10), ('bitsynchDS2T2', 11), ('reservedByRFC3471first', 12), ('asynchE1', 13), ('bytesynchE1', 14), ('bytesynch31ByDS0', 15), ('asynchDS1T1', 16), ('bitsynchDS1T1', 17), ('bytesynchDS1T1', 18), ('vc1vc12', 19), ('reservedByRFC3471second', 20), ('reservedByRFC3471third', 21), ('ds1SFAsynch', 22), ('ds1ESFAsynch', 23), ('ds3M23Asynch', 24), ('ds3CBitParityAsynch', 25), ('vtLovc', 26), ('stsSpeHovc', 27), ('posNoScramble16BitCrc', 28), ('posNoScramble32BitCrc', 29), ('posScramble16BitCrc', 30), ('posScramble32BitCrc', 31), ('atm', 32), ('ethernet', 33), ('sdhSonet', 34), ('digitalwrapper', 36), ('lambda', 37), ('ansiEtsiPdh', 38), ('lapsSdh', 40), ('fddi', 41), ('dqdb', 42), ('fiberChannel3', 43), ('hdlc', 44), ('ethernetV2DixOnly', 45), ('ethernet802dot3Only', 46), ('g709ODUj', 47), ('g709OTUk', 48), ('g709CBRorCBRa', 49), ('g709CBRb', 50), ('g709BSOT', 51), ('g709BSNT', 52), ('gfpIPorPPP', 53), ('gfpEthernetMAC', 54), ('gfpEthernetPHY', 55), ('g709ESCON', 56), ('g709FICON', 57), ('g709FiberChannel', 58), ('framedGFP', 59), ('sTM1', 60), ('sTM4', 61), ('infiniBand', 62), ('sDI', 63), ('sDI1point001', 64), ('dVBASI', 65), ('g709ODU125G', 66), ('g709ODUAny', 67), ('nullTest', 68), ('randomTest', 69), ('sixtyfourB66BGFPFEthernet', 70))
class Ianagmplsadminstatusinformationtc(TextualConvention, Bits):
reference = '1. Generalized Multi-Protocol Label Switching (GMPLS) Signaling Functional Description, RFC 3471, section 8. 2. Generalized MPLS Signaling - RSVP-TE Extensions, RFC 3473, section 7. 3. GMPLS - Communication of Alarm Information, RFC 4783, section 3.2.1.'
description = 'This data type determines the setting of the Admin Status flags in the Admin Status object or TLV, as described in RFC 3471. Setting this object to a non-zero value will result in the inclusion of the Admin Status object or TLV on signaling messages. This textual convention is strongly tied to the Administrative Status Information Flags sub-registry of the GMPLS Signaling Parameters registry managed by IANA. Values should be assigned by IANA in step with the Administrative Status Flags sub-registry and using the same registry management rules. However, the actual values used in this textual convention are solely within the purview of IANA and do not necessarily match the values in the Administrative Status Information Flags sub-registry. The definition of this textual convention with the addition of newly assigned values is published periodically by the IANA, in either the Assigned Numbers RFC, or some derivative of it specific to Internet Network Management number assignments. (The latest arrangements can be obtained by contacting the IANA.) Requests for new values should be made to IANA via email (iana&iana.org).'
status = 'current'
named_values = named_values(('reflect', 0), ('reserved1', 1), ('reserved2', 2), ('reserved3', 3), ('reserved4', 4), ('reserved5', 5), ('reserved6', 6), ('reserved7', 7), ('reserved8', 8), ('reserved9', 9), ('reserved10', 10), ('reserved11', 11), ('reserved12', 12), ('reserved13', 13), ('reserved14', 14), ('reserved15', 15), ('reserved16', 16), ('reserved17', 17), ('reserved18', 18), ('reserved19', 19), ('reserved20', 20), ('reserved21', 21), ('reserved22', 22), ('oamFlowsEnabled', 23), ('oamAlarmsEnabled', 24), ('handover', 25), ('lockout', 26), ('inhibitAlarmCommunication', 27), ('callControl', 28), ('testing', 29), ('administrativelyDown', 30), ('deleteInProgress', 31))
mibBuilder.exportSymbols('IANA-GMPLS-TC-MIB', IANAGmplsSwitchingTypeTC=IANAGmplsSwitchingTypeTC, IANAGmplsLSPEncodingTypeTC=IANAGmplsLSPEncodingTypeTC, IANAGmplsAdminStatusInformationTC=IANAGmplsAdminStatusInformationTC, PYSNMP_MODULE_ID=ianaGmpls, ianaGmpls=ianaGmpls, IANAGmplsGeneralizedPidTC=IANAGmplsGeneralizedPidTC)
|
letters = ["a", "e", "t", "o", "u"]
word = "CreepyNuts"
if (word[1] in letters) and (word[6] in letters):
print(0)
elif (word[1] in letters) or (word[6] in letters):
print(1)
else:
print(2)
|
letters = ['a', 'e', 't', 'o', 'u']
word = 'CreepyNuts'
if word[1] in letters and word[6] in letters:
print(0)
elif word[1] in letters or word[6] in letters:
print(1)
else:
print(2)
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017 - hongzhi.wang <hongzhi.wang@moji.com>
'''
Author: hongzhi.wang
Create Date: 2019-09-04
Modify Date: 2019-09-04
'''
|
"""
Author: hongzhi.wang
Create Date: 2019-09-04
Modify Date: 2019-09-04
"""
|
def parse_input(file):
return [[int(h) for h in l] for l in open(file).read().splitlines()]
input = parse_input('./day 09/Xavier - Python/input.txt')
example = parse_input('./day 09/Xavier - Python/example.txt')
def get_neighbours(map,i,j):
neighbours = []
if i > 0:
neighbours.append((i-1,j))
if i < len(map)-1:
neighbours.append((i+1,j))
if j > 0:
neighbours.append((i,j-1))
if j < len(map[i])-1:
neighbours.append((i,j+1))
return neighbours
def low_points(map):
low_points = []
for i in range(len(map)):
for j in range(len(map[i])):
if map[i][j] < min([map[i][j] for i,j in get_neighbours(map, i , j)]):
low_points.append((i,j))
return low_points
lp_ex = low_points(example)
lp_in = low_points(input)
assert len(lp_ex)+sum([example[i][j] for i,j in lp_ex]) == 15
print(len(lp_in)+sum([input[i][j] for i,j in lp_in]))
def expand(map, point):
points = {point}
neighbours = get_neighbours(map, *point)
for n in neighbours:
if not map[n[0]][n[1]] == 9 and map[n[0]][n[1]] > map[point[0]][point[1]]:
points = points.union(expand(map, n))
return points
def part_two(map, low_points):
sizes = []
for p in low_points:
basin = expand(map, p)
sizes.append(len(basin))
sizes.sort(reverse=True)
return sizes[0]*sizes[1]*sizes[2]
assert part_two(example, lp_ex) == 1134
print(part_two(input, lp_in))
|
def parse_input(file):
return [[int(h) for h in l] for l in open(file).read().splitlines()]
input = parse_input('./day 09/Xavier - Python/input.txt')
example = parse_input('./day 09/Xavier - Python/example.txt')
def get_neighbours(map, i, j):
neighbours = []
if i > 0:
neighbours.append((i - 1, j))
if i < len(map) - 1:
neighbours.append((i + 1, j))
if j > 0:
neighbours.append((i, j - 1))
if j < len(map[i]) - 1:
neighbours.append((i, j + 1))
return neighbours
def low_points(map):
low_points = []
for i in range(len(map)):
for j in range(len(map[i])):
if map[i][j] < min([map[i][j] for (i, j) in get_neighbours(map, i, j)]):
low_points.append((i, j))
return low_points
lp_ex = low_points(example)
lp_in = low_points(input)
assert len(lp_ex) + sum([example[i][j] for (i, j) in lp_ex]) == 15
print(len(lp_in) + sum([input[i][j] for (i, j) in lp_in]))
def expand(map, point):
points = {point}
neighbours = get_neighbours(map, *point)
for n in neighbours:
if not map[n[0]][n[1]] == 9 and map[n[0]][n[1]] > map[point[0]][point[1]]:
points = points.union(expand(map, n))
return points
def part_two(map, low_points):
sizes = []
for p in low_points:
basin = expand(map, p)
sizes.append(len(basin))
sizes.sort(reverse=True)
return sizes[0] * sizes[1] * sizes[2]
assert part_two(example, lp_ex) == 1134
print(part_two(input, lp_in))
|
_base_ = ['./mask_rcnn_r50_8x2_1x.py']
model = dict(roi_head=dict(type='BTRoIHead',
bbox_head=dict(type='Shared2FCCBBoxHeadBT',
loss_cls=dict(type="EQLv2"),
loss_opl=dict(
type='OrthogonalProjectionLoss', loss_weight=0.0),
loss_bt=dict(
type='BarlowTwinLoss', loss_weight=1.0),
)))
data = dict(train=dict(oversample_thr=1e-3))
# test_cfg = dict(rcnn=dict(max_per_img=800))
# train_cfg = dict(rcnn=dict(sampler=dict(pos_fraction=0.5)))
work_dir = 'bt_1x_rfs'
|
_base_ = ['./mask_rcnn_r50_8x2_1x.py']
model = dict(roi_head=dict(type='BTRoIHead', bbox_head=dict(type='Shared2FCCBBoxHeadBT', loss_cls=dict(type='EQLv2'), loss_opl=dict(type='OrthogonalProjectionLoss', loss_weight=0.0), loss_bt=dict(type='BarlowTwinLoss', loss_weight=1.0))))
data = dict(train=dict(oversample_thr=0.001))
work_dir = 'bt_1x_rfs'
|
# -*- coding: utf-8 -*-
# System
SYSTEM_LANGUAGE_KEY = 'System/Language'
SYSTEM_THEME_KEY = 'System/Theme'
SYSTEM_THEME_DEFAULT = 'System'
# File
FILE_SAVE_TO_DIR_KEY = 'File/SaveToDir'
FILE_SAVE_TO_DIR_DEFAULT = ''
FILE_FILENAME_PREFIX_FORMAT_KEY = 'File/FilenamePrefixFormat'
FILE_FILENAME_PREFIX_FORMAT_DEFAULT = '{id}_{year}_{author}_{title}'
FILE_OVERWRITE_EXISTING_FILE_KEY = 'File/OverwriteExistingFile'
FILE_OVERWRITE_EXISTING_FILE_DEFAULT = False
# Network
NETWORK_SCIHUB_URL_KEY = 'Network/SciHubURL'
NETWORK_SCIHUB_URL_DEFAULT = 'https://sci-hub.se'
NETWORK_SCIHUB_URLS_KEY = 'Network/SciHubURLs'
NETWORK_SCIHUB_URLS_DEFAULT = ['https://sci-hub.se', 'https://sci-hub.st']
NETWORK_TIMEOUT_KEY = 'Network/Timeout'
NETWORK_TIMEOUT_DEFAULT = 3000
NETWORK_RETRY_TIMES_KEY = 'Network/RetryTimes'
NETWORK_RETRY_TIMES_DEFAULT = 3
NETWORK_PROXY_ENABLE_KEY = 'Network/ProxyEnable'
NETWORK_PROXY_ENABLE_DEFAULT = False
NETWORK_PROXY_TYPE_KEY = 'Network/ProxyType'
NETWORK_PROXY_TYPE_DEFAULT = 'http'
NETWORK_PROXY_HOST_KEY = 'Network/ProxyHost'
NETWORK_PROXY_HOST_DEFAULT = '127.0.0.1'
NETWORK_PROXY_PORT_KEY = 'Network/ProxyPort'
NETWORK_PROXY_PORT_DEFAULT = '7890'
NETWORK_PROXY_USERNAME_KEY = 'Network/ProxyUsername'
NETWORK_PROXY_USERNAME_DEFAULT = ''
NETWORK_PROXY_PASSWORD_KEY = 'Network/ProxyPassword'
NETWORK_PROXY_PASSWORD_DEFAULT = ''
|
system_language_key = 'System/Language'
system_theme_key = 'System/Theme'
system_theme_default = 'System'
file_save_to_dir_key = 'File/SaveToDir'
file_save_to_dir_default = ''
file_filename_prefix_format_key = 'File/FilenamePrefixFormat'
file_filename_prefix_format_default = '{id}_{year}_{author}_{title}'
file_overwrite_existing_file_key = 'File/OverwriteExistingFile'
file_overwrite_existing_file_default = False
network_scihub_url_key = 'Network/SciHubURL'
network_scihub_url_default = 'https://sci-hub.se'
network_scihub_urls_key = 'Network/SciHubURLs'
network_scihub_urls_default = ['https://sci-hub.se', 'https://sci-hub.st']
network_timeout_key = 'Network/Timeout'
network_timeout_default = 3000
network_retry_times_key = 'Network/RetryTimes'
network_retry_times_default = 3
network_proxy_enable_key = 'Network/ProxyEnable'
network_proxy_enable_default = False
network_proxy_type_key = 'Network/ProxyType'
network_proxy_type_default = 'http'
network_proxy_host_key = 'Network/ProxyHost'
network_proxy_host_default = '127.0.0.1'
network_proxy_port_key = 'Network/ProxyPort'
network_proxy_port_default = '7890'
network_proxy_username_key = 'Network/ProxyUsername'
network_proxy_username_default = ''
network_proxy_password_key = 'Network/ProxyPassword'
network_proxy_password_default = ''
|
#Get roll numbers, name & marks of the students of a class(get from user) and store these details in a file- marks.txt
count = int(input("How many students are there in class? "))
fileObj = open('marks.txt',"w")
for i in range(count):
print("Enter details for student",(i+1),"below:")
rollNo = int(input("Rollno: "))
name = input("Name: ")
marks = float(input("Marks: "))
records = str(rollNo) + "," + name + "," + str(marks) + '\n'
fileObj.write(records)
fileObj.close()
|
count = int(input('How many students are there in class? '))
file_obj = open('marks.txt', 'w')
for i in range(count):
print('Enter details for student', i + 1, 'below:')
roll_no = int(input('Rollno: '))
name = input('Name: ')
marks = float(input('Marks: '))
records = str(rollNo) + ',' + name + ',' + str(marks) + '\n'
fileObj.write(records)
fileObj.close()
|
# -*- coding: utf-8 -*-
"""Untitled1.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1W2P2nxzaV_t_ePeJDnZMmbLkhvRxqZaF
"""
#used for quick sort algo
#pivot is taken as last element
def lomutoPartition(arr,l,h):
pivot=arr[h]
i=l-1
for j in range(l,h):
if arr[j]<pivot:
i=i+1
arr[i],arr[j]=arr[j],arr[i]
arr[i+1],arr[h]=arr[h],arr[i+1]
return i+1
def qsort(arr,l,h):
if l<h:
p=lomutoPartition(arr,l,h)
qsort(arr,l,p-1)
qsort(arr,p+1,h)
#divercode
arr=[10,3,4,29,5,51]
l=0
h=len(arr)-1
qsort(arr,l,h)
|
"""Untitled1.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1W2P2nxzaV_t_ePeJDnZMmbLkhvRxqZaF
"""
def lomuto_partition(arr, l, h):
pivot = arr[h]
i = l - 1
for j in range(l, h):
if arr[j] < pivot:
i = i + 1
(arr[i], arr[j]) = (arr[j], arr[i])
(arr[i + 1], arr[h]) = (arr[h], arr[i + 1])
return i + 1
def qsort(arr, l, h):
if l < h:
p = lomuto_partition(arr, l, h)
qsort(arr, l, p - 1)
qsort(arr, p + 1, h)
arr = [10, 3, 4, 29, 5, 51]
l = 0
h = len(arr) - 1
qsort(arr, l, h)
|
# id: 640;Stairs
# title:"Schody",
# about:"",
# robotCol:3,
# robotRow:10,
# robotDir:3,
# subs:[3,3,0,0,0],
# allowedCommands:0,
# board:" ggggggggGG gggggggGGg ggggggGGgg gggggGGggg ggggGGgggg gggGGggggg ggGGgggggg gGGggggggg GGgggggggg gggggggggg "
class Problem:
def __init__(self, parse_str):
gen = self.__lineGenerator(parse_str)
self.id = next(gen)
self.title = next(gen)
self.about = next(gen)
self.robotCol = (int)(next(gen))
self.robotRow = (int)(next(gen))
self.robotDir = (int)(next(gen))
self.subs = next(gen)
self.allowedCommands = (int)(next(gen))
self.board_str = next(gen)
def getBoardCopy(self):
arr = [self.board_str[i:i+16] for i in range(0, 16*12, 16)]
return arr
def getFlowerCount(self):
return self.board_str.count("R") + self.board_str.count("G") + self.board_str.count("B")
def getFirstId(self):
arr = self.id.split(';')
if len(arr) == 1:
return self.id.zfill(4)
else:
return arr[0].zfill(4)
def __lineGenerator(self, parse_str):
for line in parse_str.splitlines():
if len(line) == 0:
continue
line = line.strip()
if line[-1] == ',':
line = line[:-1]
arr = line.split(':')
yield arr[1].strip().replace('"', "")
|
class Problem:
def __init__(self, parse_str):
gen = self.__lineGenerator(parse_str)
self.id = next(gen)
self.title = next(gen)
self.about = next(gen)
self.robotCol = int(next(gen))
self.robotRow = int(next(gen))
self.robotDir = int(next(gen))
self.subs = next(gen)
self.allowedCommands = int(next(gen))
self.board_str = next(gen)
def get_board_copy(self):
arr = [self.board_str[i:i + 16] for i in range(0, 16 * 12, 16)]
return arr
def get_flower_count(self):
return self.board_str.count('R') + self.board_str.count('G') + self.board_str.count('B')
def get_first_id(self):
arr = self.id.split(';')
if len(arr) == 1:
return self.id.zfill(4)
else:
return arr[0].zfill(4)
def __line_generator(self, parse_str):
for line in parse_str.splitlines():
if len(line) == 0:
continue
line = line.strip()
if line[-1] == ',':
line = line[:-1]
arr = line.split(':')
yield arr[1].strip().replace('"', '')
|
class DSU:
def __init__(self, N):
self.par = list(range(N))
def find(self, U):
if self.par[U] != U:
self.par[U] = self.find(self.par[U])
return self.par[U]
def union(self, U, V):
X, Y = self.find(U), self.find(V)
self.par[X] = Y
class Solution:
def factors(self, n):
for i in range(2, int(math.sqrt(n))+1):
if n % i == 0:
return self.factors(n//i) | set([i])
return set([n])
def largestComponentSize(self, A: List[int]) -> int:
n = len(A)
uf = DSU(n)
factor = defaultdict(list)
for i, num in enumerate(A):
fct = self.factors(num)
for f in fct:
factor[f].append(i)
for k, ind in factor.items():
for i in range(len(ind)-1):
uf.union(ind[i], ind[i+1])
return max(Counter([uf.find(i) for i in range(n)]).values())
|
class Dsu:
def __init__(self, N):
self.par = list(range(N))
def find(self, U):
if self.par[U] != U:
self.par[U] = self.find(self.par[U])
return self.par[U]
def union(self, U, V):
(x, y) = (self.find(U), self.find(V))
self.par[X] = Y
class Solution:
def factors(self, n):
for i in range(2, int(math.sqrt(n)) + 1):
if n % i == 0:
return self.factors(n // i) | set([i])
return set([n])
def largest_component_size(self, A: List[int]) -> int:
n = len(A)
uf = dsu(n)
factor = defaultdict(list)
for (i, num) in enumerate(A):
fct = self.factors(num)
for f in fct:
factor[f].append(i)
for (k, ind) in factor.items():
for i in range(len(ind) - 1):
uf.union(ind[i], ind[i + 1])
return max(counter([uf.find(i) for i in range(n)]).values())
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue May 29 09:58:39 2018
@author: nsde
"""
#%%
#%%
def tf_mahalanobisTransformer(X, scope='mahalanobis_transformer'):
""" Creates a transformer function that for an given input matrix X,
calculates the linear transformation L*X_i """
with tf.variable_scope(scope, reuse=tf.AUTO_REUSE, values=[X]):
X = tf.cast(X, tf.float32)
L = tf.get_variable("L", initializer=np.eye(50, 50, dtype=np.float32))
return tf.matmul(X, L)
#%%
def tf_convTransformer(X, scope='conv_transformer'):
""" Creates a transformer function that for an given input tensor X,
computes the convolution of that tensor with some weights W. """
with tf.variable_scope(scope, reuse=tf.AUTO_REUSE, values=[X]):
X = tf.cast(X, tf.float32)
W = tf.get_variable("W", initializer=np.random.normal(size=(3,3,1,10)).astype('float32'))
return tf.nn.conv2d(X, W, strides=[1,1,1,1], padding="VALID")
#%%
def keras_mahalanobisTransformer(X, scope='mahalanobis_transformer'):
X = tf.cast(X, tf.float32)
with tf.variable_scope(scope, reuse=tf.AUTO_REUSE, values=[X]):
S = Sequential()
S.add(InputLayer(input_shape=(50,)))
S.add(Dense(50, use_bias=False, kernel_initializer='identity'))
return S.call(X)
#%%
if __name__ == '__main__':
# Make sure that variables are shared
X=tf.cast(np.random.normal(size=(100,50)), tf.float32)
tr = KerasTransformer(input_shape=(50,))
tr.add(Dense(50, use_bias=False, kernel_initializer='identity'))
tr.add(Dense(20, use_bias=False, kernel_initializer='identity'))
tr.add(Dense(10, use_bias=False, kernel_initializer='identity'))
trans_func1 = tr.get_function()
res1=trans_func1(X)
res2=trans_func1(X)
# Check that we only have created three variables
for w in tf.trainable_variables():
print(w)
#%%
def tf_pairwiseMahalanobisDistance2(X1, X2, L):
'''
For a given mahalanobis distance parametrized by L, find the pairwise
squared distance between all observations in matrix X1 and matrix X2.
Input
X1: N x d matrix, each row being an observation
X2: M x d matrix, each row being an observation
L: d x d matrix
Output
D: N x M matrix, with squared distances
'''
with tf.name_scope('pairwiseMahalanobisDistance2'):
X1, X2 = tf.cast(X1, tf.float32), tf.cast(X2, tf.float32)
X1L = tf.matmul(X1, L)
X2L = tf.matmul(X2, L)
term1 = tf.pow(tf.norm(X1L, axis=1),2.0)
term2 = tf.pow(tf.norm(X2L, axis=1),2.0)
term3 = 2.0*tf.matmul(X1L, tf.transpose(X2L))
return tf.transpose(tf.maximum(tf.cast(0.0, dtype=X1L.dtype),
term1 + tf.transpose(term2 - term3)))
#%%
def tf_mahalanobisTransformer(X, L):
''' Transformer for the mahalanobis distance '''
with tf.name_scope('mahalanobisTransformer'):
X, L = tf.cast(X, tf.float32), tf.cast(L, tf.float32)
return tf.matmul(X, L)
#%%
def tf_pairwiseConvDistance2(X1, X2, W):
'''
For a given set of convolutional weights W, calculate the convolution
with tensor X1 and X2 and then calculates the pairwise squared distance
(euclidean) between conv features
Input
X: N x h x w x c tensor, each slice being an image
Y: M x h x w x c tensor, each slice being an image
W: f1 x f2 x c x nf tensor, where f1, f2 are the filter sizes and
nf is the number of filters
Output
D: N x M matrix, with squared conv distances
'''
with tf.name_scope('pairwiseConvDistance2'):
X1, X2 = tf.cast(X1, tf.float32), tf.cast(X2, tf.float32)
N, M = tf.shape(X1)[0], tf.shape(X2)[0]
n_filt = tf.shape(W)[3]
convX1 = tf.nn.conv2d(X1, W, strides=[1,1,1,1], padding='SAME') # N x height x width x n_filt
convX2 = tf.nn.conv2d(X2, W, strides=[1,1,1,1], padding='SAME') # M x height x width x n_filt
convX1_perm = tf.transpose(convX1, perm=[3,0,1,2]) # n_filt x N x height x width
convX2_perm = tf.transpose(convX2, perm=[3,0,1,2]) # n_filt x M x height x width
convX1_resh = tf.reshape(convX1_perm, (n_filt, N, -1)) # n_filt x N x (height*width)
convX2_resh = tf.reshape(convX2_perm, (n_filt, M, -1)) # n_filt x M x (height*width)
term1 = tf.expand_dims(tf.pow(tf.norm(convX1_resh, axis=2), 2.0), 2) # n_filt x N x 1
term2 = tf.expand_dims(tf.pow(tf.norm(convX2_resh, axis=2), 2.0), 1) # n_filt x 1 x M
term3 = 2.0*tf.matmul(convX1_resh, tf.transpose(convX2_resh, perm=[0,2,1])) # n_filt x N x M
summ = term1 + term2 - term3 # n_filt x N x M
return tf.maximum(tf.cast(0.0, tf.float32), tf.reduce_sum(summ, axis=0)) # N x M
#%%
def tf_convTransformer(X, W):
''' Transformer for the conv distance '''
with tf.name_scope('convTransformer'):
X, W = tf.cast(X, tf.float32), tf.cast(W, tf.float32)
return tf.nn.conv2d(X, W, strides=[1,1,1,1], padding='SAME')
#%%
def tf_nonlin_pairwiseConvDistance2(X1, X2, W):
'''
For a given set of convolutional weights W, calculate the convolution
with tensor X1 and X2 and then calculates the pairwise squared distance
(euclidean) between conv features
Input
X: N x h x w x c tensor, each slice being an image
Y: M x h x w x c tensor, each slice being an image
W: f1 x f2 x c x nf tensor, where f1, f2 are the filter sizes and
nf is the number of filters
Output
D: N x M matrix, with squared conv distances
'''
with tf.name_scope('pairwiseConvDistance2'):
X1, X2 = tf.cast(X1, tf.float32), tf.cast(X2, tf.float32)
N, M = tf.shape(X1)[0], tf.shape(X2)[0]
n_filt = tf.shape(W)[3]
convX1 = tf.nn.conv2d(X1, W, strides=[1,1,1,1], padding='SAME') # N x height x width x n_filt
convX2 = tf.nn.conv2d(X2, W, strides=[1,1,1,1], padding='SAME') # M x height x width x n_filt
convX1 = tf.nn.relu(convX1)
convX2 = tf.nn.relu(convX2)
convX1_perm = tf.transpose(convX1, perm=[3,0,1,2]) # n_filt x N x height x width
convX2_perm = tf.transpose(convX2, perm=[3,0,1,2]) # n_filt x M x height x width
convX1_resh = tf.reshape(convX1_perm, (n_filt, N, -1)) # n_filt x N x (height*width)
convX2_resh = tf.reshape(convX2_perm, (n_filt, M, -1)) # n_filt x M x (height*width)
term1 = tf.expand_dims(tf.pow(tf.norm(convX1_resh, axis=2), 2.0), 2) # n_filt x N x 1
term2 = tf.expand_dims(tf.pow(tf.norm(convX2_resh, axis=2), 2.0), 1) # n_filt x 1 x M
term3 = 2.0*tf.matmul(convX1_resh, tf.transpose(convX2_resh, perm=[0,2,1])) # n_filt x N x M
summ = term1 + term2 - term3 # n_filt x N x M
return tf.maximum(tf.cast(0.0, tf.float32), tf.reduce_sum(summ, axis=0)) # N x M
#%%
def tf_nonlin_convTransformer(X, W):
''' Transformer for the conv distance '''
with tf.name_scope('convTransformer'):
X, W = tf.cast(X, tf.float32), tf.cast(W, tf.float32)
return tf.nn.relu(tf.nn.conv2d(X, W, strides=[1,1,1,1], padding='SAME'))
#%%
def tf_mode(array):
''' Find the mode of the input array. Expects 1D array '''
with tf.name_scope('mode'):
unique, _, count = tf.unique_with_counts(array)
max_idx = tf.argmax(count, axis=0)
return unique[max_idx]
|
"""
Created on Tue May 29 09:58:39 2018
@author: nsde
"""
def tf_mahalanobis_transformer(X, scope='mahalanobis_transformer'):
""" Creates a transformer function that for an given input matrix X,
calculates the linear transformation L*X_i """
with tf.variable_scope(scope, reuse=tf.AUTO_REUSE, values=[X]):
x = tf.cast(X, tf.float32)
l = tf.get_variable('L', initializer=np.eye(50, 50, dtype=np.float32))
return tf.matmul(X, L)
def tf_conv_transformer(X, scope='conv_transformer'):
""" Creates a transformer function that for an given input tensor X,
computes the convolution of that tensor with some weights W. """
with tf.variable_scope(scope, reuse=tf.AUTO_REUSE, values=[X]):
x = tf.cast(X, tf.float32)
w = tf.get_variable('W', initializer=np.random.normal(size=(3, 3, 1, 10)).astype('float32'))
return tf.nn.conv2d(X, W, strides=[1, 1, 1, 1], padding='VALID')
def keras_mahalanobis_transformer(X, scope='mahalanobis_transformer'):
x = tf.cast(X, tf.float32)
with tf.variable_scope(scope, reuse=tf.AUTO_REUSE, values=[X]):
s = sequential()
S.add(input_layer(input_shape=(50,)))
S.add(dense(50, use_bias=False, kernel_initializer='identity'))
return S.call(X)
if __name__ == '__main__':
x = tf.cast(np.random.normal(size=(100, 50)), tf.float32)
tr = keras_transformer(input_shape=(50,))
tr.add(dense(50, use_bias=False, kernel_initializer='identity'))
tr.add(dense(20, use_bias=False, kernel_initializer='identity'))
tr.add(dense(10, use_bias=False, kernel_initializer='identity'))
trans_func1 = tr.get_function()
res1 = trans_func1(X)
res2 = trans_func1(X)
for w in tf.trainable_variables():
print(w)
def tf_pairwise_mahalanobis_distance2(X1, X2, L):
"""
For a given mahalanobis distance parametrized by L, find the pairwise
squared distance between all observations in matrix X1 and matrix X2.
Input
X1: N x d matrix, each row being an observation
X2: M x d matrix, each row being an observation
L: d x d matrix
Output
D: N x M matrix, with squared distances
"""
with tf.name_scope('pairwiseMahalanobisDistance2'):
(x1, x2) = (tf.cast(X1, tf.float32), tf.cast(X2, tf.float32))
x1_l = tf.matmul(X1, L)
x2_l = tf.matmul(X2, L)
term1 = tf.pow(tf.norm(X1L, axis=1), 2.0)
term2 = tf.pow(tf.norm(X2L, axis=1), 2.0)
term3 = 2.0 * tf.matmul(X1L, tf.transpose(X2L))
return tf.transpose(tf.maximum(tf.cast(0.0, dtype=X1L.dtype), term1 + tf.transpose(term2 - term3)))
def tf_mahalanobis_transformer(X, L):
""" Transformer for the mahalanobis distance """
with tf.name_scope('mahalanobisTransformer'):
(x, l) = (tf.cast(X, tf.float32), tf.cast(L, tf.float32))
return tf.matmul(X, L)
def tf_pairwise_conv_distance2(X1, X2, W):
"""
For a given set of convolutional weights W, calculate the convolution
with tensor X1 and X2 and then calculates the pairwise squared distance
(euclidean) between conv features
Input
X: N x h x w x c tensor, each slice being an image
Y: M x h x w x c tensor, each slice being an image
W: f1 x f2 x c x nf tensor, where f1, f2 are the filter sizes and
nf is the number of filters
Output
D: N x M matrix, with squared conv distances
"""
with tf.name_scope('pairwiseConvDistance2'):
(x1, x2) = (tf.cast(X1, tf.float32), tf.cast(X2, tf.float32))
(n, m) = (tf.shape(X1)[0], tf.shape(X2)[0])
n_filt = tf.shape(W)[3]
conv_x1 = tf.nn.conv2d(X1, W, strides=[1, 1, 1, 1], padding='SAME')
conv_x2 = tf.nn.conv2d(X2, W, strides=[1, 1, 1, 1], padding='SAME')
conv_x1_perm = tf.transpose(convX1, perm=[3, 0, 1, 2])
conv_x2_perm = tf.transpose(convX2, perm=[3, 0, 1, 2])
conv_x1_resh = tf.reshape(convX1_perm, (n_filt, N, -1))
conv_x2_resh = tf.reshape(convX2_perm, (n_filt, M, -1))
term1 = tf.expand_dims(tf.pow(tf.norm(convX1_resh, axis=2), 2.0), 2)
term2 = tf.expand_dims(tf.pow(tf.norm(convX2_resh, axis=2), 2.0), 1)
term3 = 2.0 * tf.matmul(convX1_resh, tf.transpose(convX2_resh, perm=[0, 2, 1]))
summ = term1 + term2 - term3
return tf.maximum(tf.cast(0.0, tf.float32), tf.reduce_sum(summ, axis=0))
def tf_conv_transformer(X, W):
""" Transformer for the conv distance """
with tf.name_scope('convTransformer'):
(x, w) = (tf.cast(X, tf.float32), tf.cast(W, tf.float32))
return tf.nn.conv2d(X, W, strides=[1, 1, 1, 1], padding='SAME')
def tf_nonlin_pairwise_conv_distance2(X1, X2, W):
"""
For a given set of convolutional weights W, calculate the convolution
with tensor X1 and X2 and then calculates the pairwise squared distance
(euclidean) between conv features
Input
X: N x h x w x c tensor, each slice being an image
Y: M x h x w x c tensor, each slice being an image
W: f1 x f2 x c x nf tensor, where f1, f2 are the filter sizes and
nf is the number of filters
Output
D: N x M matrix, with squared conv distances
"""
with tf.name_scope('pairwiseConvDistance2'):
(x1, x2) = (tf.cast(X1, tf.float32), tf.cast(X2, tf.float32))
(n, m) = (tf.shape(X1)[0], tf.shape(X2)[0])
n_filt = tf.shape(W)[3]
conv_x1 = tf.nn.conv2d(X1, W, strides=[1, 1, 1, 1], padding='SAME')
conv_x2 = tf.nn.conv2d(X2, W, strides=[1, 1, 1, 1], padding='SAME')
conv_x1 = tf.nn.relu(convX1)
conv_x2 = tf.nn.relu(convX2)
conv_x1_perm = tf.transpose(convX1, perm=[3, 0, 1, 2])
conv_x2_perm = tf.transpose(convX2, perm=[3, 0, 1, 2])
conv_x1_resh = tf.reshape(convX1_perm, (n_filt, N, -1))
conv_x2_resh = tf.reshape(convX2_perm, (n_filt, M, -1))
term1 = tf.expand_dims(tf.pow(tf.norm(convX1_resh, axis=2), 2.0), 2)
term2 = tf.expand_dims(tf.pow(tf.norm(convX2_resh, axis=2), 2.0), 1)
term3 = 2.0 * tf.matmul(convX1_resh, tf.transpose(convX2_resh, perm=[0, 2, 1]))
summ = term1 + term2 - term3
return tf.maximum(tf.cast(0.0, tf.float32), tf.reduce_sum(summ, axis=0))
def tf_nonlin_conv_transformer(X, W):
""" Transformer for the conv distance """
with tf.name_scope('convTransformer'):
(x, w) = (tf.cast(X, tf.float32), tf.cast(W, tf.float32))
return tf.nn.relu(tf.nn.conv2d(X, W, strides=[1, 1, 1, 1], padding='SAME'))
def tf_mode(array):
""" Find the mode of the input array. Expects 1D array """
with tf.name_scope('mode'):
(unique, _, count) = tf.unique_with_counts(array)
max_idx = tf.argmax(count, axis=0)
return unique[max_idx]
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# simple dictionary
mybasket = {'apple':2.99,'orange':1.99,'milk':5.8}
print(mybasket['apple'])
# dictionary with list inside
mynestedbasket = {'apple':2.99,'orange':1.99,'milk':['chocolate','stawbery']}
print(mynestedbasket['milk'][1].upper())
# append more key
mybasket['pizza'] = 4.5
print(mybasket)
# get only keys
print(mybasket.keys())
# get only values
print(mybasket.values())
# get pair values
print(mybasket.items())
|
mybasket = {'apple': 2.99, 'orange': 1.99, 'milk': 5.8}
print(mybasket['apple'])
mynestedbasket = {'apple': 2.99, 'orange': 1.99, 'milk': ['chocolate', 'stawbery']}
print(mynestedbasket['milk'][1].upper())
mybasket['pizza'] = 4.5
print(mybasket)
print(mybasket.keys())
print(mybasket.values())
print(mybasket.items())
|
class Solution:
def islandPerimeter(self, grid: List[List[int]]) -> int:
if not grid or not grid[0]:
return 0
for i in range(len(grid)):
for j in range(len(grid[0])):
if grid[i][j]:
return self.dfs(grid, i, j)
return 0
def dfs(self, grid, i, j):
if i < 0 or i >= len(grid) or j < 0 or j >= len(grid[0]):
return 1
if grid[i][j] == -1:
return 0
if grid[i][j]:
grid[i][j] = -1
return self.dfs(grid, i + 1, j) + self.dfs(
grid, i, j + 1) + self.dfs(grid, i - 1, j) + self.dfs(
grid, i, j - 1)
else:
return 1
|
class Solution:
def island_perimeter(self, grid: List[List[int]]) -> int:
if not grid or not grid[0]:
return 0
for i in range(len(grid)):
for j in range(len(grid[0])):
if grid[i][j]:
return self.dfs(grid, i, j)
return 0
def dfs(self, grid, i, j):
if i < 0 or i >= len(grid) or j < 0 or (j >= len(grid[0])):
return 1
if grid[i][j] == -1:
return 0
if grid[i][j]:
grid[i][j] = -1
return self.dfs(grid, i + 1, j) + self.dfs(grid, i, j + 1) + self.dfs(grid, i - 1, j) + self.dfs(grid, i, j - 1)
else:
return 1
|
class Solution:
def addBinary(self, a, b):
res, carry = '', 0
i, j = len(a) - 1, len(b) - 1
while i >= 0 or j >= 0 or carry:
curval = (i >= 0 and a[i] == '1') + (j >= 0 and b[j] == '1')
carry, rem = divmod(curval + carry, 2)
res = str(rem) + res
i -= 1
j -= 1
return res
|
class Solution:
def add_binary(self, a, b):
(res, carry) = ('', 0)
(i, j) = (len(a) - 1, len(b) - 1)
while i >= 0 or j >= 0 or carry:
curval = (i >= 0 and a[i] == '1') + (j >= 0 and b[j] == '1')
(carry, rem) = divmod(curval + carry, 2)
res = str(rem) + res
i -= 1
j -= 1
return res
|
#this function would write data in the database
def write_data(name, phone, pincode, city, resources):
#here we will connect to database
#and write to it
f = open('/Users/mukesht/Mukesh/Github/covid_resource/resource_item.text', 'a')
f.write(name + ', ' + phone + ', ' + pincode + ', ' + city + ', [' + resources + ']\n')
f.close()
write_data("Hello World", "657254762", "232101", "Mughalsarai", "[ Oxygen, Vaccine ]")
|
def write_data(name, phone, pincode, city, resources):
f = open('/Users/mukesht/Mukesh/Github/covid_resource/resource_item.text', 'a')
f.write(name + ', ' + phone + ', ' + pincode + ', ' + city + ', [' + resources + ']\n')
f.close()
write_data('Hello World', '657254762', '232101', 'Mughalsarai', '[ Oxygen, Vaccine ]')
|
def validate(n):
string = str(n)
mod = 0 if len(string) % 2 == 0 else 1 # 0 for even, 1 for odd
total = 0
for i, a in enumerate(string):
current = int(a)
if i % 2 == mod:
double = current * 2
if double > 9:
total += double - 9
else:
total += double
else:
total += current
return total % 10 == 0
|
def validate(n):
string = str(n)
mod = 0 if len(string) % 2 == 0 else 1
total = 0
for (i, a) in enumerate(string):
current = int(a)
if i % 2 == mod:
double = current * 2
if double > 9:
total += double - 9
else:
total += double
else:
total += current
return total % 10 == 0
|
expected_output = {
"interfaces": {
"Port-channel1": {
"name": "Port-channel1",
"protocol": "lacp",
"members": {
"GigabitEthernet0/0/1": {
"activity": "Active",
"age": 18,
"aggregatable": True,
"collecting": True,
"defaulted": False,
"distributing": True,
"expired": False,
"flags": "FA",
"interface": "GigabitEthernet0/0/1",
"lacp_port_priority": 100,
"oper_key": 1,
"port_num": 2,
"port_state": 63,
"synchronization": True,
"system_id": "00127,6487.88ff.68ef",
"timeout": "Short",
},
"GigabitEthernet0/0/7": {
"activity": "Active",
"age": 0,
"aggregatable": True,
"collecting": False,
"defaulted": False,
"distributing": False,
"expired": False,
"flags": "FA",
"interface": "GigabitEthernet0/0/7",
"lacp_port_priority": 200,
"oper_key": 1,
"port_num": 1,
"port_state": 15,
"synchronization": True,
"system_id": "00127,6487.88ff.68ef",
"timeout": "Short",
},
},
}
}
}
|
expected_output = {'interfaces': {'Port-channel1': {'name': 'Port-channel1', 'protocol': 'lacp', 'members': {'GigabitEthernet0/0/1': {'activity': 'Active', 'age': 18, 'aggregatable': True, 'collecting': True, 'defaulted': False, 'distributing': True, 'expired': False, 'flags': 'FA', 'interface': 'GigabitEthernet0/0/1', 'lacp_port_priority': 100, 'oper_key': 1, 'port_num': 2, 'port_state': 63, 'synchronization': True, 'system_id': '00127,6487.88ff.68ef', 'timeout': 'Short'}, 'GigabitEthernet0/0/7': {'activity': 'Active', 'age': 0, 'aggregatable': True, 'collecting': False, 'defaulted': False, 'distributing': False, 'expired': False, 'flags': 'FA', 'interface': 'GigabitEthernet0/0/7', 'lacp_port_priority': 200, 'oper_key': 1, 'port_num': 1, 'port_state': 15, 'synchronization': True, 'system_id': '00127,6487.88ff.68ef', 'timeout': 'Short'}}}}}
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
inputs = [
"LLLRLLULLDDLDUDRDDURLDDRDLRDDRUULRULLLDLUURUUUDLUUDLRUDLDUDURRLDRRRUULUURLUDRURULRLRLRRUULRUUUDRRDDRLLLDDLLUDDDLLRLLULULRRURRRLDRLDLLRURDULLDULRUURLRUDRURLRRDLLDDURLDDLUDLRLUURDRDRDDUURDDLDDDRUDULDLRDRDDURDLUDDDRUDLUDLULULRUURLRUUUDDRLDULLLUDLULDUUDLDLRRLLLRLDUDRUULDLDRDLRRDLDLULUUDRRUDDDRDLRLDLRDUDRULDRDURRUULLUDURURUUDRDRLRRDRRDRDDDDLLRURULDURDLUDLUULDDLLLDULUUUULDUDRDURLURDLDDLDDUULRLUUDLDRUDRURURRDDLURURDRLRLUUUURLLRR",
"UUUUURRRURLLRRDRLLDUUUUDDDRLRRDRUULDUURURDRLLRRRDRLLUDURUDLDURURRLUDLLLDRDUDRDRLDRUDUDDUULLUULLDUDUDDRDUUUDLULUDUULLUUULURRUDUULDUDDRDURRLDDURLRDLULDDRUDUDRDULLRLRLLUUDDURLUUDLRUUDDLLRUURDUDLLDRURLDURDLRDUUDLRLLRLRURRUDRRLRDRURRRUULLUDLDURDLDDDUUDRUUUDULLLRDRRDRLURDDRUUUDRRUUDLUDDDRRRRRLRLDLLDDLRDURRURLLLULURULLULRLLDDLDRLDULLDLDDDRLUDDDUDUDRRLRDLLDULULRLRURDLUDDLRUDRLUURRURDURDRRDRULUDURRLULUURDRLDLRUDLUDRURLUDUUULRRLRRRULRRRLRLRLULULDRUUDLRLLRLLLURUUDLUDLRURUDRRLDLLULUDRUDRLLLRLLDLLDUDRRURRLDLUUUURDDDUURLLRRDRUUURRRDRUDLLULDLLDLUDRRDLLDDLDURLLDLLDLLLDR",
"LRDULUUUDLRUUUDURUUULLURDRURDRRDDDLRLRUULDLRRUDDLLUURLDRLLRUULLUDLUDUDRDRDLUUDULLLLRDDUDRRRURLRDDLRLDRLULLLRUUULURDDLLLLRURUUDDDLDUDDDDLLLURLUUUURLRUDRRLLLUUULRDUURDLRDDDUDLLRDULURURUULUDLLRRURDLUULUUDULLUDUUDURLRULRLLDLUULLRRUDDULRULDURRLRRLULLLRRDLLDDLDUDDDUDLRUURUDUUUDDLRRDLRUDRLLRDRDLURRLUDUULDRRUDRRUDLLLLRURRRRRUULULLLRDRDUDRDDURDLDDUURRURLDRRUDLRLLRRURULUUDDDLLLRDRLULLDLDDULDLUUDRURULLDLLLLDRLRRLURLRULRDLLULUDRDR",
"RURRRUDLURRURLURDDRULLDRDRDRRULRRDLDDLDUUURUULLRRDRLDRRDRULLURRRULLLDULDDDDLULRUULRURUDURDUDRLRULLLRDURDDUDDRDLURRURUURDLDDDDDURURRURLLLDDLDRRDUDDLLLDRRLDDUUULDLLDRUURUDDRRLDUULRRDDUDRUULRLDLRLRUURLLDRDLDRLURULDLULDRULURLLRRLLDDDURLRUURUULULRLLLULUDULUUULDRURUDDDUUDDRDUDUDRDLLLRDULRLDLRRDRRLRDLDDULULRLRUUDDUDRRLUDRDUUUDRLLLRRLRUDRRLRUUDDLDURLDRRRUDRRDUDDLRDDLULLDLURLUUDLUDLUDLDRRLRRRULDRLRDUURLUULRDURUDUUDDURDDLRRRLUUUDURULRURLDRURULDDUDDLUDLDLURDDRRDDUDUUURLDLRDDLDULDULDDDLDRDDLUURDULLUDRRRULRLDDLRDRLRURLULLLDULLUUDURLDDULRRDDUULDRLDLULRRDULUDUUURUURDDDRULRLRDLRRURR",
"UDDDRLDRDULDRLRDUDDLDLLDDLUUURDDDLUDRDUDLDURLUURUDUULUUULDUURLULLRLUDLLURUUUULRLRLLLRRLULLDRUULURRLLUDUDURULLLRRRRLRUULLRDRDRRDDLUDRRUULUDRUULRDLRDRRLRRDRRRLULRULUURRRULLRRRURUDUURRLLDDDUDDULUULRURUDUDUDRLDLUULUDDLLLLDRLLRLDULLLRLLDLUUDURDLLRURUUDDDDLLUDDRLUUDUDRDRLLURURLURRDLDDDULUURURURRLUUDUDLDLDDULLURUDLRLDLRLDLDUDULURDUDRLURRRULLDDDRDRURDDLDLULUDRUULDLULRDUUURLULDRRULLUDLDRLRDDUDURRRURRLRDUULURUUDLULDLRUUULUDRDRRUDUDULLDDRLRDLURDLRLUURDRUDRDRUDLULRUDDRDLLLRLURRURRLDDDUDDLRDRRRULLUUDULURDLDRDDDLDURRLRRDLLDDLULULRRDUDUUDUULRDRRDURDDDDUUDDLUDDUULDRDDULLUUUURRRUUURRULDRRDURRLULLDU"]
x=1
y=1
combination = []
#Internal Use
_keypad = [[1,2,3],[4,5,6],[7,8,9]]
for line in inputs:
for input in line:
#Move
if input == "D":
if y < 2: y+=1
elif input == "U":
if y > 0: y-=1
elif input == "L":
if x > 0: x-=1
elif input == "R":
if x < 2: x+=1
combination.append(_keypad[y][x])
print("Combinaison : {}".format(combination))
|
inputs = ['LLLRLLULLDDLDUDRDDURLDDRDLRDDRUULRULLLDLUURUUUDLUUDLRUDLDUDURRLDRRRUULUURLUDRURULRLRLRRUULRUUUDRRDDRLLLDDLLUDDDLLRLLULULRRURRRLDRLDLLRURDULLDULRUURLRUDRURLRRDLLDDURLDDLUDLRLUURDRDRDDUURDDLDDDRUDULDLRDRDDURDLUDDDRUDLUDLULULRUURLRUUUDDRLDULLLUDLULDUUDLDLRRLLLRLDUDRUULDLDRDLRRDLDLULUUDRRUDDDRDLRLDLRDUDRULDRDURRUULLUDURURUUDRDRLRRDRRDRDDDDLLRURULDURDLUDLUULDDLLLDULUUUULDUDRDURLURDLDDLDDUULRLUUDLDRUDRURURRDDLURURDRLRLUUUURLLRR', 'UUUUURRRURLLRRDRLLDUUUUDDDRLRRDRUULDUURURDRLLRRRDRLLUDURUDLDURURRLUDLLLDRDUDRDRLDRUDUDDUULLUULLDUDUDDRDUUUDLULUDUULLUUULURRUDUULDUDDRDURRLDDURLRDLULDDRUDUDRDULLRLRLLUUDDURLUUDLRUUDDLLRUURDUDLLDRURLDURDLRDUUDLRLLRLRURRUDRRLRDRURRRUULLUDLDURDLDDDUUDRUUUDULLLRDRRDRLURDDRUUUDRRUUDLUDDDRRRRRLRLDLLDDLRDURRURLLLULURULLULRLLDDLDRLDULLDLDDDRLUDDDUDUDRRLRDLLDULULRLRURDLUDDLRUDRLUURRURDURDRRDRULUDURRLULUURDRLDLRUDLUDRURLUDUUULRRLRRRULRRRLRLRLULULDRUUDLRLLRLLLURUUDLUDLRURUDRRLDLLULUDRUDRLLLRLLDLLDUDRRURRLDLUUUURDDDUURLLRRDRUUURRRDRUDLLULDLLDLUDRRDLLDDLDURLLDLLDLLLDR', 'LRDULUUUDLRUUUDURUUULLURDRURDRRDDDLRLRUULDLRRUDDLLUURLDRLLRUULLUDLUDUDRDRDLUUDULLLLRDDUDRRRURLRDDLRLDRLULLLRUUULURDDLLLLRURUUDDDLDUDDDDLLLURLUUUURLRUDRRLLLUUULRDUURDLRDDDUDLLRDULURURUULUDLLRRURDLUULUUDULLUDUUDURLRULRLLDLUULLRRUDDULRULDURRLRRLULLLRRDLLDDLDUDDDUDLRUURUDUUUDDLRRDLRUDRLLRDRDLURRLUDUULDRRUDRRUDLLLLRURRRRRUULULLLRDRDUDRDDURDLDDUURRURLDRRUDLRLLRRURULUUDDDLLLRDRLULLDLDDULDLUUDRURULLDLLLLDRLRRLURLRULRDLLULUDRDR', 'RURRRUDLURRURLURDDRULLDRDRDRRULRRDLDDLDUUURUULLRRDRLDRRDRULLURRRULLLDULDDDDLULRUULRURUDURDUDRLRULLLRDURDDUDDRDLURRURUURDLDDDDDURURRURLLLDDLDRRDUDDLLLDRRLDDUUULDLLDRUURUDDRRLDUULRRDDUDRUULRLDLRLRUURLLDRDLDRLURULDLULDRULURLLRRLLDDDURLRUURUULULRLLLULUDULUUULDRURUDDDUUDDRDUDUDRDLLLRDULRLDLRRDRRLRDLDDULULRLRUUDDUDRRLUDRDUUUDRLLLRRLRUDRRLRUUDDLDURLDRRRUDRRDUDDLRDDLULLDLURLUUDLUDLUDLDRRLRRRULDRLRDUURLUULRDURUDUUDDURDDLRRRLUUUDURULRURLDRURULDDUDDLUDLDLURDDRRDDUDUUURLDLRDDLDULDULDDDLDRDDLUURDULLUDRRRULRLDDLRDRLRURLULLLDULLUUDURLDDULRRDDUULDRLDLULRRDULUDUUURUURDDDRULRLRDLRRURR', 'UDDDRLDRDULDRLRDUDDLDLLDDLUUURDDDLUDRDUDLDURLUURUDUULUUULDUURLULLRLUDLLURUUUULRLRLLLRRLULLDRUULURRLLUDUDURULLLRRRRLRUULLRDRDRRDDLUDRRUULUDRUULRDLRDRRLRRDRRRLULRULUURRRULLRRRURUDUURRLLDDDUDDULUULRURUDUDUDRLDLUULUDDLLLLDRLLRLDULLLRLLDLUUDURDLLRURUUDDDDLLUDDRLUUDUDRDRLLURURLURRDLDDDULUURURURRLUUDUDLDLDDULLURUDLRLDLRLDLDUDULURDUDRLURRRULLDDDRDRURDDLDLULUDRUULDLULRDUUURLULDRRULLUDLDRLRDDUDURRRURRLRDUULURUUDLULDLRUUULUDRDRRUDUDULLDDRLRDLURDLRLUURDRUDRDRUDLULRUDDRDLLLRLURRURRLDDDUDDLRDRRRULLUUDULURDLDRDDDLDURRLRRDLLDDLULULRRDUDUUDUULRDRRDURDDDDUUDDLUDDUULDRDDULLUUUURRRUUURRULDRRDURRLULLDU']
x = 1
y = 1
combination = []
_keypad = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
for line in inputs:
for input in line:
if input == 'D':
if y < 2:
y += 1
elif input == 'U':
if y > 0:
y -= 1
elif input == 'L':
if x > 0:
x -= 1
elif input == 'R':
if x < 2:
x += 1
combination.append(_keypad[y][x])
print('Combinaison : {}'.format(combination))
|
#!/usr/bin/env python3
def num_sol(n):
if n==1:
return 1
if n==2:
return 2
solu=num_sol(n-1)+num_sol(n-2)
return solu
# def unrank(n, pos, sorting_criterion="loves_long_tiles"):
# return "(" + unrank(n_in_A, (pos-count) // num_B) + ")" + unrank(n - n_in_A -1, (pos-count) % num_B)
def unrank(n):
if num_sol(n)==1:
return ['[]']
if num_sol(n)==2:
return ['[][]', '[--]']
solu1=[]
solu2=[]
for i in range(num_sol(n-1)):
solu1.append('[]' + unrank(n-1)[i])
for j in range(num_sol(n-2)):
solu2.append('[--]' + unrank(n-2)[j])
return solu1 + solu2
def recognize(tiling, TAc, LANG):
#print(f"tiling={tiling}")
pos = 0
n_tiles = 0
char = None
while pos < len(tiling):
if tiling[pos] != '[':
TAc.print(tiling, "yellow", ["underline"])
TAc.print(LANG.render_feedback("wrong-tile-opening", f'No. The tile in position {n_tiles+1} does not start with "[" (it starts with "{tiling[pos]}" instead). Your tiling is not correctly encoded.'), "red", ["bold"])
return False
n_tiles += 1
if tiling[pos+1] == ']':
pos += 2
else:
if pos+3 < len(tiling) and tiling[pos+3] != ']':
TAc.print(tiling, "yellow", ["underline"])
TAc.print(LANG.render_feedback("wrong-tile-closing", f'No. The tile in position {n_tiles}, starting with {tiling[pos:pos+3]}, does not end wih "]" (it ends with "{tiling[pos+3]}" instead). Your tiling is not correctly encoded.'), "red", ["bold"])
return False
for pos_fill in {pos+1,pos+2}:
if tiling[pos_fill] in {'[',']'}:
TAc.print(tiling, "yellow", ["underline"])
TAc.print(LANG.render_feedback("wrong-tile-filling", f'No. The tile in position {n_tiles}, starting with {tiling[pos:pos+4]}, has a forbidden filling character (namely, "{tiling[pos_fill]}"). Your tiling is not correctly encoded.'), "red", ["bold"])
return False
pos += 4
return True
|
def num_sol(n):
if n == 1:
return 1
if n == 2:
return 2
solu = num_sol(n - 1) + num_sol(n - 2)
return solu
def unrank(n):
if num_sol(n) == 1:
return ['[]']
if num_sol(n) == 2:
return ['[][]', '[--]']
solu1 = []
solu2 = []
for i in range(num_sol(n - 1)):
solu1.append('[]' + unrank(n - 1)[i])
for j in range(num_sol(n - 2)):
solu2.append('[--]' + unrank(n - 2)[j])
return solu1 + solu2
def recognize(tiling, TAc, LANG):
pos = 0
n_tiles = 0
char = None
while pos < len(tiling):
if tiling[pos] != '[':
TAc.print(tiling, 'yellow', ['underline'])
TAc.print(LANG.render_feedback('wrong-tile-opening', f'No. The tile in position {n_tiles + 1} does not start with "[" (it starts with "{tiling[pos]}" instead). Your tiling is not correctly encoded.'), 'red', ['bold'])
return False
n_tiles += 1
if tiling[pos + 1] == ']':
pos += 2
else:
if pos + 3 < len(tiling) and tiling[pos + 3] != ']':
TAc.print(tiling, 'yellow', ['underline'])
TAc.print(LANG.render_feedback('wrong-tile-closing', f'No. The tile in position {n_tiles}, starting with {tiling[pos:pos + 3]}, does not end wih "]" (it ends with "{tiling[pos + 3]}" instead). Your tiling is not correctly encoded.'), 'red', ['bold'])
return False
for pos_fill in {pos + 1, pos + 2}:
if tiling[pos_fill] in {'[', ']'}:
TAc.print(tiling, 'yellow', ['underline'])
TAc.print(LANG.render_feedback('wrong-tile-filling', f'No. The tile in position {n_tiles}, starting with {tiling[pos:pos + 4]}, has a forbidden filling character (namely, "{tiling[pos_fill]}"). Your tiling is not correctly encoded.'), 'red', ['bold'])
return False
pos += 4
return True
|
def check_geneassessment(result, payload, previous_assessment_id=None):
assert result["gene_id"] == payload["gene_id"]
assert result["evaluation"] == payload["evaluation"]
assert result["analysis_id"] == payload.get("analysis_id")
assert result["genepanel_name"] == payload["genepanel_name"]
assert result["genepanel_version"] == payload["genepanel_version"]
assert result["date_superceeded"] is None
assert result["user_id"] == 1
assert result["usergroup_id"] == 1
assert result["previous_assessment_id"] == previous_assessment_id
def test_create_assessment(session, client, test_database):
test_database.refresh()
# Insert new geneassessment with analysis_id
ASSESSMENT1 = {
"gene_id": 1101,
"evaluation": {"comment": "TEST1"},
"analysis_id": 1,
"genepanel_name": "Mendel",
"genepanel_version": "v04",
}
r = client.post("/api/v1/geneassessments/", ASSESSMENT1)
assert r.status_code == 200
ga1 = r.get_json()
check_geneassessment(ga1, ASSESSMENT1)
# Check latest result when loading genepanel (allele_id 1 is in BRCA2)
r = client.get("/api/v1/workflows/analyses/1/genepanels/HBOC/v01/?allele_ids=1")
gp = r.get_json()
assert len(gp["geneassessments"]) == 1
check_geneassessment(gp["geneassessments"][0], ASSESSMENT1)
# Insert new geneassessment, without analysis_id
ASSESSMENT2 = {
"gene_id": 1101,
"evaluation": {"comment": "TEST2"},
"genepanel_name": "Mendel",
"genepanel_version": "v04",
"presented_geneassessment_id": ga1["id"],
}
r = client.post("/api/v1/geneassessments/", ASSESSMENT2)
assert r.status_code == 200
ga2 = r.get_json()
check_geneassessment(ga2, ASSESSMENT2, previous_assessment_id=ga1["id"])
r = client.get("/api/v1/workflows/analyses/1/genepanels/HBOC/v01/?allele_ids=1")
gp = r.get_json()
assert len(gp["geneassessments"]) == 1
check_geneassessment(gp["geneassessments"][0], ASSESSMENT2, previous_assessment_id=ga1["id"])
# Insert new geneassessment, with wrong presented id (should fail)
ASSESSMENT3 = {
"gene_id": 1101,
"evaluation": {"comment": "TEST3"},
"genepanel_name": "Mendel",
"genepanel_version": "v04",
"presented_geneassessment_id": ga1["id"],
}
r = client.post("/api/v1/geneassessments/", ASSESSMENT3)
assert r.status_code == 500
ga2 = (
r.get_json()["message"]
== "'presented_geneassessment_id': 1 does not match latest existing geneassessment id: 2"
)
# Check that latest is same as before
r = client.get("/api/v1/workflows/analyses/1/genepanels/HBOC/v01/?allele_ids=1")
gp = r.get_json()
assert len(gp["geneassessments"]) == 1
check_geneassessment(gp["geneassessments"][0], ASSESSMENT2, previous_assessment_id=ga1["id"])
|
def check_geneassessment(result, payload, previous_assessment_id=None):
assert result['gene_id'] == payload['gene_id']
assert result['evaluation'] == payload['evaluation']
assert result['analysis_id'] == payload.get('analysis_id')
assert result['genepanel_name'] == payload['genepanel_name']
assert result['genepanel_version'] == payload['genepanel_version']
assert result['date_superceeded'] is None
assert result['user_id'] == 1
assert result['usergroup_id'] == 1
assert result['previous_assessment_id'] == previous_assessment_id
def test_create_assessment(session, client, test_database):
test_database.refresh()
assessment1 = {'gene_id': 1101, 'evaluation': {'comment': 'TEST1'}, 'analysis_id': 1, 'genepanel_name': 'Mendel', 'genepanel_version': 'v04'}
r = client.post('/api/v1/geneassessments/', ASSESSMENT1)
assert r.status_code == 200
ga1 = r.get_json()
check_geneassessment(ga1, ASSESSMENT1)
r = client.get('/api/v1/workflows/analyses/1/genepanels/HBOC/v01/?allele_ids=1')
gp = r.get_json()
assert len(gp['geneassessments']) == 1
check_geneassessment(gp['geneassessments'][0], ASSESSMENT1)
assessment2 = {'gene_id': 1101, 'evaluation': {'comment': 'TEST2'}, 'genepanel_name': 'Mendel', 'genepanel_version': 'v04', 'presented_geneassessment_id': ga1['id']}
r = client.post('/api/v1/geneassessments/', ASSESSMENT2)
assert r.status_code == 200
ga2 = r.get_json()
check_geneassessment(ga2, ASSESSMENT2, previous_assessment_id=ga1['id'])
r = client.get('/api/v1/workflows/analyses/1/genepanels/HBOC/v01/?allele_ids=1')
gp = r.get_json()
assert len(gp['geneassessments']) == 1
check_geneassessment(gp['geneassessments'][0], ASSESSMENT2, previous_assessment_id=ga1['id'])
assessment3 = {'gene_id': 1101, 'evaluation': {'comment': 'TEST3'}, 'genepanel_name': 'Mendel', 'genepanel_version': 'v04', 'presented_geneassessment_id': ga1['id']}
r = client.post('/api/v1/geneassessments/', ASSESSMENT3)
assert r.status_code == 500
ga2 = r.get_json()['message'] == "'presented_geneassessment_id': 1 does not match latest existing geneassessment id: 2"
r = client.get('/api/v1/workflows/analyses/1/genepanels/HBOC/v01/?allele_ids=1')
gp = r.get_json()
assert len(gp['geneassessments']) == 1
check_geneassessment(gp['geneassessments'][0], ASSESSMENT2, previous_assessment_id=ga1['id'])
|
def run(m):
sites = m.qualify(["""
SELECT ?equip ?sensor ?setpoint ?sensor_uuid ?setpoint_uuid WHERE {
?setpoint rdf:type/rdfs:subClassOf* brick:Air_Flow_Setpoint .
?sensor rdf:type/rdfs:subClassOf* brick:Air_Flow_Sensor .
?setpoint bf:isPointOf ?equip .
?sensor bf:isPointOf ?equip .
?setpoint bf:uuid ?setpoint_uuid .
?sensor bf:uuid ?sensor_uuid .
};"""])
return sites
|
def run(m):
sites = m.qualify(['\n SELECT ?equip ?sensor ?setpoint ?sensor_uuid ?setpoint_uuid WHERE {\n ?setpoint rdf:type/rdfs:subClassOf* brick:Air_Flow_Setpoint .\n ?sensor rdf:type/rdfs:subClassOf* brick:Air_Flow_Sensor .\n ?setpoint bf:isPointOf ?equip .\n ?sensor bf:isPointOf ?equip .\n ?setpoint bf:uuid ?setpoint_uuid .\n ?sensor bf:uuid ?sensor_uuid .\n };'])
return sites
|
class Edge:
def __init__(self, start, end):
self.start = start
self.end = end
def __str__(self):
return "<" + str(self.start) + " " + str(self.end) + ">"
|
class Edge:
def __init__(self, start, end):
self.start = start
self.end = end
def __str__(self):
return '<' + str(self.start) + ' ' + str(self.end) + '>'
|
class Solution:
def minOperations(self, boxes: str) -> List[int]:
ans = [0]*len(boxes)
lc = 0
lcost = 0
rc = 0
rcost = 0
for i in range(1,len(boxes)):
if boxes[i-1]=="1": lc+=1
lcost += lc
ans[i] = lcost
for i in range(len(boxes)-2,-1,-1):
if boxes[i+1]=="1": rc+=1
rcost += rc
ans[i] += rcost
return ans
|
class Solution:
def min_operations(self, boxes: str) -> List[int]:
ans = [0] * len(boxes)
lc = 0
lcost = 0
rc = 0
rcost = 0
for i in range(1, len(boxes)):
if boxes[i - 1] == '1':
lc += 1
lcost += lc
ans[i] = lcost
for i in range(len(boxes) - 2, -1, -1):
if boxes[i + 1] == '1':
rc += 1
rcost += rc
ans[i] += rcost
return ans
|
class Solution:
def evalRPN(self, tokens: List[str]) -> int:
stack = []
op = {
"+": lambda x, y: x + y,
"-": lambda x, y: x - y,
"*": lambda x, y: x * y,
"/": lambda x, y: x // y if x * y >= 0 else -(-x // y),
}
for token in tokens:
if token in op:
n2 = stack.pop()
n1 = stack.pop()
stack.append(op[token](n1, n2))
else:
stack.append(int(token))
return stack.pop()
|
class Solution:
def eval_rpn(self, tokens: List[str]) -> int:
stack = []
op = {'+': lambda x, y: x + y, '-': lambda x, y: x - y, '*': lambda x, y: x * y, '/': lambda x, y: x // y if x * y >= 0 else -(-x // y)}
for token in tokens:
if token in op:
n2 = stack.pop()
n1 = stack.pop()
stack.append(op[token](n1, n2))
else:
stack.append(int(token))
return stack.pop()
|
# Created by MechAviv
# Map ID :: 402000630
# Desert Cavern : Below the Sinkhole
# Update Quest Record EX | Quest ID: [34931] | Data: dir=1;exp=1
sm.curNodeEventEnd(True)
sm.setTemporarySkillSet(0)
sm.setInGameDirectionMode(True, False, False, False)
sm.setStandAloneMode(True)
sm.removeAdditionalEffect()
sm.zoomCamera(0, 2000, 0, -142, -250)
sm.blind(1, 255, 0, 0, 0, 0, 0)
sm.sendDelay(1200)
sm.blind(0, 0, 0, 0, 0, 1000, 0)
sm.sendDelay(1400)
sm.sendDelay(500)
sm.zoomCamera(3000, 1000, 3000, 100, 0)
sm.sendDelay(3500)
sm.setSpeakerID(3001510)
sm.setSpeakerType(3)
sm.removeEscapeButton()
sm.flipDialogue()
sm.setBoxChat()
sm.boxChatPlayerAsSpeaker()
sm.setBoxOverrideSpeaker()
sm.flipBoxChat()
sm.flipBoxChatPlayerAsSpeaker()
sm.setColor(1)
sm.sendNext("#face2#So this is what's below the sand.")
sm.setSpeakerID(3001510)
sm.setSpeakerType(3)
sm.removeEscapeButton()
sm.flipDialogue()
sm.setBoxChat()
sm.boxChatPlayerAsSpeaker()
sm.setBoxOverrideSpeaker()
sm.flipBoxChat()
sm.flipBoxChatPlayerAsSpeaker()
sm.setColor(1)
sm.sendSay("#face2#And now we've all been separated.")
sm.setSpeakerID(3001500)
sm.setSpeakerType(3)
sm.removeEscapeButton()
sm.flipDialogue()
sm.setBoxChat()
sm.boxChatPlayerAsSpeaker()
sm.setBoxOverrideSpeaker()
sm.flipBoxChat()
sm.flipBoxChatPlayerAsSpeaker()
sm.setColor(1)
sm.sendSay("#face0#Well...")
sm.blind(1, 150, 0, 0, 0, 500, 0)
sm.playSound("Sound/SoundEff.img/PinkBean/expectation", 100)
sm.OnOffLayer_On(500, "d0", 0, -80, -1, "Effect/Direction17.img/effect/ark/illust/7/1", 4, 1, -1, 0)
sm.sendDelay(1000)
sm.blind(0, 0, 0, 0, 0, 500, 0)
sm.OnOffLayer_Off(500, "d0", 0)
sm.sendDelay(500)
sm.setSpeakerID(3001500)
sm.setSpeakerType(3)
sm.removeEscapeButton()
sm.flipDialogue()
sm.setBoxChat()
sm.boxChatPlayerAsSpeaker()
sm.setBoxOverrideSpeaker()
sm.flipBoxChat()
sm.flipBoxChatPlayerAsSpeaker()
sm.setColor(1)
sm.sendNext("#face0#At least we got this.")
sm.setSpeakerID(3001510)
sm.setSpeakerType(3)
sm.removeEscapeButton()
sm.flipDialogue()
sm.setBoxChat()
sm.boxChatPlayerAsSpeaker()
sm.setBoxOverrideSpeaker()
sm.flipBoxChat()
sm.flipBoxChatPlayerAsSpeaker()
sm.setColor(1)
sm.sendSay("#face0#Wow! You managed to catch that while we were falling? Impressive!")
sm.setSpeakerID(3001510)
sm.setSpeakerType(3)
sm.removeEscapeButton()
sm.flipDialogue()
sm.setBoxChat()
sm.boxChatPlayerAsSpeaker()
sm.setBoxOverrideSpeaker()
sm.flipBoxChat()
sm.flipBoxChatPlayerAsSpeaker()
sm.setColor(1)
sm.sendSay("#face2#I'm not happy about being this far underground. What was that demolitions dummy thinking?!")
sm.setSpeakerID(3001510)
sm.setSpeakerType(3)
sm.removeEscapeButton()
sm.flipDialogue()
sm.setBoxChat()
sm.boxChatPlayerAsSpeaker()
sm.setBoxOverrideSpeaker()
sm.flipBoxChat()
sm.flipBoxChatPlayerAsSpeaker()
sm.setColor(1)
sm.sendSay("#face2#Now we're going to waste a bunch of time we don't have tracking everyone down.")
sm.showFadeTransition(0, 1000, 3000)
sm.zoomCamera(0, 1000, 2147483647, 2147483647, 2147483647)
sm.moveCamera(True, 0, 0, 0)
sm.sendDelay(300)
sm.removeOverlapScreen(1000)
sm.moveCamera(True, 0, 0, 0)
sm.setStandAloneMode(False)
sm.setTemporarySkillSet(0)
sm.setInGameDirectionMode(False, True, False, False)
|
sm.curNodeEventEnd(True)
sm.setTemporarySkillSet(0)
sm.setInGameDirectionMode(True, False, False, False)
sm.setStandAloneMode(True)
sm.removeAdditionalEffect()
sm.zoomCamera(0, 2000, 0, -142, -250)
sm.blind(1, 255, 0, 0, 0, 0, 0)
sm.sendDelay(1200)
sm.blind(0, 0, 0, 0, 0, 1000, 0)
sm.sendDelay(1400)
sm.sendDelay(500)
sm.zoomCamera(3000, 1000, 3000, 100, 0)
sm.sendDelay(3500)
sm.setSpeakerID(3001510)
sm.setSpeakerType(3)
sm.removeEscapeButton()
sm.flipDialogue()
sm.setBoxChat()
sm.boxChatPlayerAsSpeaker()
sm.setBoxOverrideSpeaker()
sm.flipBoxChat()
sm.flipBoxChatPlayerAsSpeaker()
sm.setColor(1)
sm.sendNext("#face2#So this is what's below the sand.")
sm.setSpeakerID(3001510)
sm.setSpeakerType(3)
sm.removeEscapeButton()
sm.flipDialogue()
sm.setBoxChat()
sm.boxChatPlayerAsSpeaker()
sm.setBoxOverrideSpeaker()
sm.flipBoxChat()
sm.flipBoxChatPlayerAsSpeaker()
sm.setColor(1)
sm.sendSay("#face2#And now we've all been separated.")
sm.setSpeakerID(3001500)
sm.setSpeakerType(3)
sm.removeEscapeButton()
sm.flipDialogue()
sm.setBoxChat()
sm.boxChatPlayerAsSpeaker()
sm.setBoxOverrideSpeaker()
sm.flipBoxChat()
sm.flipBoxChatPlayerAsSpeaker()
sm.setColor(1)
sm.sendSay('#face0#Well...')
sm.blind(1, 150, 0, 0, 0, 500, 0)
sm.playSound('Sound/SoundEff.img/PinkBean/expectation', 100)
sm.OnOffLayer_On(500, 'd0', 0, -80, -1, 'Effect/Direction17.img/effect/ark/illust/7/1', 4, 1, -1, 0)
sm.sendDelay(1000)
sm.blind(0, 0, 0, 0, 0, 500, 0)
sm.OnOffLayer_Off(500, 'd0', 0)
sm.sendDelay(500)
sm.setSpeakerID(3001500)
sm.setSpeakerType(3)
sm.removeEscapeButton()
sm.flipDialogue()
sm.setBoxChat()
sm.boxChatPlayerAsSpeaker()
sm.setBoxOverrideSpeaker()
sm.flipBoxChat()
sm.flipBoxChatPlayerAsSpeaker()
sm.setColor(1)
sm.sendNext('#face0#At least we got this.')
sm.setSpeakerID(3001510)
sm.setSpeakerType(3)
sm.removeEscapeButton()
sm.flipDialogue()
sm.setBoxChat()
sm.boxChatPlayerAsSpeaker()
sm.setBoxOverrideSpeaker()
sm.flipBoxChat()
sm.flipBoxChatPlayerAsSpeaker()
sm.setColor(1)
sm.sendSay('#face0#Wow! You managed to catch that while we were falling? Impressive!')
sm.setSpeakerID(3001510)
sm.setSpeakerType(3)
sm.removeEscapeButton()
sm.flipDialogue()
sm.setBoxChat()
sm.boxChatPlayerAsSpeaker()
sm.setBoxOverrideSpeaker()
sm.flipBoxChat()
sm.flipBoxChatPlayerAsSpeaker()
sm.setColor(1)
sm.sendSay("#face2#I'm not happy about being this far underground. What was that demolitions dummy thinking?!")
sm.setSpeakerID(3001510)
sm.setSpeakerType(3)
sm.removeEscapeButton()
sm.flipDialogue()
sm.setBoxChat()
sm.boxChatPlayerAsSpeaker()
sm.setBoxOverrideSpeaker()
sm.flipBoxChat()
sm.flipBoxChatPlayerAsSpeaker()
sm.setColor(1)
sm.sendSay("#face2#Now we're going to waste a bunch of time we don't have tracking everyone down.")
sm.showFadeTransition(0, 1000, 3000)
sm.zoomCamera(0, 1000, 2147483647, 2147483647, 2147483647)
sm.moveCamera(True, 0, 0, 0)
sm.sendDelay(300)
sm.removeOverlapScreen(1000)
sm.moveCamera(True, 0, 0, 0)
sm.setStandAloneMode(False)
sm.setTemporarySkillSet(0)
sm.setInGameDirectionMode(False, True, False, False)
|
# "directions" are all the ways you can describe going some way;
# they are code-visible names for directions for adventure authors
direction_names = ["NORTH","SOUTH","EAST","WEST","UP","DOWN","RIGHT","LEFT",
"IN","OUT","FORWARD","BACK",
"NORTHWEST","NORTHEAST","SOUTHWEST","SOUTHEAST"]
direction_list = [ NORTH, SOUTH, EAST, WEST, UP, DOWN, RIGHT, LEFT,
IN, OUT, FORWARD, BACK,
NORTHWEST, NORTHEAST, SOUTHWEST, SOUTHEAST] = \
range(len(direction_names))
NOT_DIRECTION = None
# some old names, for backwards compatibility
(NORTH_WEST, NORTH_EAST, SOUTH_WEST, SOUTH_EAST) = \
(NORTHWEST, NORTHEAST, SOUTHWEST, SOUTHEAST)
directions = dir_by_name = dict(zip(direction_names, direction_list))
def define_direction (number, name):
if name in dir_by_name:
exit("%s is already defined as %d" % (name, dir_by_name[name]))
dir_by_name[name] = number
def lookup_dir (name):
return dir_by_name.get(name, NOT_DIRECTION)
# add lower-case versions of all names in direction_names
for name in direction_names:
define_direction(dir_by_name[name], name.lower())
# add common aliases:
# maybe the alias mechanism should be a more general
# (text-based?) mechanism that works for any command?!!!
common_aliases = [
(NORTH, "n"),
(SOUTH, "s"),
(EAST, "e"),
(WEST, "w"),
(UP, "u"),
(DOWN, "d"),
(FORWARD, "fd"),
(FORWARD, "fwd"),
(FORWARD, "f"),
(BACK, "bk"),
(BACK, "b"),
(NORTHWEST,"nw"),
(NORTHEAST,"ne"),
(SOUTHWEST,"sw"),
(SOUTHEAST, "se")
]
for (k,v) in common_aliases:
define_direction(k,v)
# define the pairs of opposite directions
opposite_by_dir = {}
def define_opposite_dirs (d1, d2):
for dir in (d1, d2):
opposite = opposite_by_dir.get(dir)
if opposite is not None:
exit("opposite for %s is already defined as %s" % (dir, opposite))
opposite_by_dir[d1] = d2
opposite_by_dir[d2] = d1
opposites = [(NORTH, SOUTH),
(EAST, WEST),
(UP, DOWN),
(LEFT, RIGHT),
(IN, OUT),
(FORWARD, BACK),
(NORTHWEST, SOUTHEAST),
(NORTHEAST, SOUTHWEST)]
for (d1,d2) in opposites:
define_opposite_dirs(d1,d2)
def opposite_direction (dir):
return opposite_by_dir[dir]
|
direction_names = ['NORTH', 'SOUTH', 'EAST', 'WEST', 'UP', 'DOWN', 'RIGHT', 'LEFT', 'IN', 'OUT', 'FORWARD', 'BACK', 'NORTHWEST', 'NORTHEAST', 'SOUTHWEST', 'SOUTHEAST']
direction_list = [north, south, east, west, up, down, right, left, in, out, forward, back, northwest, northeast, southwest, southeast] = range(len(direction_names))
not_direction = None
(north_west, north_east, south_west, south_east) = (NORTHWEST, NORTHEAST, SOUTHWEST, SOUTHEAST)
directions = dir_by_name = dict(zip(direction_names, direction_list))
def define_direction(number, name):
if name in dir_by_name:
exit('%s is already defined as %d' % (name, dir_by_name[name]))
dir_by_name[name] = number
def lookup_dir(name):
return dir_by_name.get(name, NOT_DIRECTION)
for name in direction_names:
define_direction(dir_by_name[name], name.lower())
common_aliases = [(NORTH, 'n'), (SOUTH, 's'), (EAST, 'e'), (WEST, 'w'), (UP, 'u'), (DOWN, 'd'), (FORWARD, 'fd'), (FORWARD, 'fwd'), (FORWARD, 'f'), (BACK, 'bk'), (BACK, 'b'), (NORTHWEST, 'nw'), (NORTHEAST, 'ne'), (SOUTHWEST, 'sw'), (SOUTHEAST, 'se')]
for (k, v) in common_aliases:
define_direction(k, v)
opposite_by_dir = {}
def define_opposite_dirs(d1, d2):
for dir in (d1, d2):
opposite = opposite_by_dir.get(dir)
if opposite is not None:
exit('opposite for %s is already defined as %s' % (dir, opposite))
opposite_by_dir[d1] = d2
opposite_by_dir[d2] = d1
opposites = [(NORTH, SOUTH), (EAST, WEST), (UP, DOWN), (LEFT, RIGHT), (IN, OUT), (FORWARD, BACK), (NORTHWEST, SOUTHEAST), (NORTHEAST, SOUTHWEST)]
for (d1, d2) in opposites:
define_opposite_dirs(d1, d2)
def opposite_direction(dir):
return opposite_by_dir[dir]
|
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def upsideDownBinaryTree(self, root):
"""
:type root: TreeNode
:rtype: TreeNode
"""
if not root:
return
left = self.upsideDownBinaryTree(root.left)
right = self.upsideDownBinaryTree(root.right)
if root.left:
root.left.right = root
root.left.left = root.right
root.left = root.right = None
return left if left else root
|
class Solution(object):
def upside_down_binary_tree(self, root):
"""
:type root: TreeNode
:rtype: TreeNode
"""
if not root:
return
left = self.upsideDownBinaryTree(root.left)
right = self.upsideDownBinaryTree(root.right)
if root.left:
root.left.right = root
root.left.left = root.right
root.left = root.right = None
return left if left else root
|
"""Top-level package for clinepunk."""
__author__ = """Taylor Monacelli"""
__email__ = "taylormonacelli@gmail.com"
__version__ = "0.1.14"
|
"""Top-level package for clinepunk."""
__author__ = 'Taylor Monacelli'
__email__ = 'taylormonacelli@gmail.com'
__version__ = '0.1.14'
|
# -*- coding:utf-8 -*-
__author__ = 'zhangzhibo'
__date__ = '202018/5/18 16:56'
|
__author__ = 'zhangzhibo'
__date__ = '202018/5/18 16:56'
|
#Clases del ciclo de lavado
class lavando:
#Etapa 1. Lavado
def lavado(self):
print("Lavando...")
class enjuagando:
#Etapa 2. Enjuagado
def enjuagado(self):
print("Enjuagando...")
class centrifugando:
#Etapa 3. Centrifugado
def centrifugado(self):
print("Centrifugando...")
class finalizado:
#Etapa 4. Finalizado de ciclo
def finalizar(self):
print("Finalizado!")
class LavadoraFacade:
def __init__(self):
self.lavando = lavando()
self.enjuagando = enjuagando()
self.centrifugando = centrifugando()
self.finalizando = finalizado()
#Lista de ciclos
def ciclo_completo(self):
self.lavando.lavado()
self.enjuagando.enjuagado()
self.centrifugando.centrifugado()
self.finalizando.finalizar()
def solo_centrifugado(self):
self.centrifugando.centrifugado()
self.finalizando.finalizar()
def solo_lavado(self):
self.lavando.lavado()
self.finalizando.finalizar()
def solo_enjuagado(self):
self.enjuagando.enjuagado()
self.finalizando.finalizar()
|
class Lavando:
def lavado(self):
print('Lavando...')
class Enjuagando:
def enjuagado(self):
print('Enjuagando...')
class Centrifugando:
def centrifugado(self):
print('Centrifugando...')
class Finalizado:
def finalizar(self):
print('Finalizado!')
class Lavadorafacade:
def __init__(self):
self.lavando = lavando()
self.enjuagando = enjuagando()
self.centrifugando = centrifugando()
self.finalizando = finalizado()
def ciclo_completo(self):
self.lavando.lavado()
self.enjuagando.enjuagado()
self.centrifugando.centrifugado()
self.finalizando.finalizar()
def solo_centrifugado(self):
self.centrifugando.centrifugado()
self.finalizando.finalizar()
def solo_lavado(self):
self.lavando.lavado()
self.finalizando.finalizar()
def solo_enjuagado(self):
self.enjuagando.enjuagado()
self.finalizando.finalizar()
|
'''
Date: 01/08/2019
Problem description:
===================
This problem was asked by Google.
Given an array of integers where every integer occurs three times
except for one integer, which only occurs once, find and return the
non-duplicated integer.
For example, given [6, 1, 3, 3, 3, 6, 6], return 1.
Given [13, 19, 13, 13], return 19.
Do this in O(N) time and O(1) space.
Algorithm:
==========
Input: A list of numbers
Output: An integer represeting the non-duplicate value
Psuedo code:
1. Check for valid input
2. Rerurn value from set(list-comprehension) where element
count equals to one
Note: This is why I love Python!!!
'''
def find_non_dup(A=[]):
if len(A) == 0:
return None
non_dup = list(set([x for x in A if A.count(x) == 1]))
return non_dup[-1]
def test_code():
A = [7,3,3,3,7,8,7]
assert find_non_dup(A) == 8
if __name__ == '__main__':
Array = [9,5,5,5,8,9,8,9,3,4,4,4]
non_dup = find_non_dup(Array)
print("Test1:\nGiven a list [{}]\nThe non-duplicate value is {}".format(', '.join(str(i) for i in Array), non_dup))
'''
Run-time output:
===============
(DailyCodingChallenge-wC3ocw3s) markn@raspberrypi3:~/devel/py-src/DailyCodingChallenge $ python codechallenge_025.py
Test1:
Given a list [9, 5, 5, 5, 8, 9, 8, 9, 3, 4, 4, 4]
The non-duplicate value is 3
(DailyCodingChallenge-wC3ocw3s) markn@raspberrypi3:~/devel/py-src/DailyCodingChallenge $ pytest codechallenge_025.py
================================ test session starts =================================
platform linux2 -- Python 2.7.13, pytest-3.6.3, py-1.5.4, pluggy-0.6.0
rootdir: /home/markn/devel/py-src/DailyCodingChallenge, inifile:
collected 1 item
codechallenge_025.py . [100%]
============================== 1 passed in 0.03 seconds ==============================
'''
|
"""
Date: 01/08/2019
Problem description:
===================
This problem was asked by Google.
Given an array of integers where every integer occurs three times
except for one integer, which only occurs once, find and return the
non-duplicated integer.
For example, given [6, 1, 3, 3, 3, 6, 6], return 1.
Given [13, 19, 13, 13], return 19.
Do this in O(N) time and O(1) space.
Algorithm:
==========
Input: A list of numbers
Output: An integer represeting the non-duplicate value
Psuedo code:
1. Check for valid input
2. Rerurn value from set(list-comprehension) where element
count equals to one
Note: This is why I love Python!!!
"""
def find_non_dup(A=[]):
if len(A) == 0:
return None
non_dup = list(set([x for x in A if A.count(x) == 1]))
return non_dup[-1]
def test_code():
a = [7, 3, 3, 3, 7, 8, 7]
assert find_non_dup(A) == 8
if __name__ == '__main__':
array = [9, 5, 5, 5, 8, 9, 8, 9, 3, 4, 4, 4]
non_dup = find_non_dup(Array)
print('Test1:\nGiven a list [{}]\nThe non-duplicate value is {}'.format(', '.join((str(i) for i in Array)), non_dup))
'\nRun-time output:\n===============\n(DailyCodingChallenge-wC3ocw3s) markn@raspberrypi3:~/devel/py-src/DailyCodingChallenge $ python codechallenge_025.py\nTest1:\nGiven a list [9, 5, 5, 5, 8, 9, 8, 9, 3, 4, 4, 4]\nThe non-duplicate value is 3\n\n(DailyCodingChallenge-wC3ocw3s) markn@raspberrypi3:~/devel/py-src/DailyCodingChallenge $ pytest codechallenge_025.py\n================================ test session starts =================================\nplatform linux2 -- Python 2.7.13, pytest-3.6.3, py-1.5.4, pluggy-0.6.0\nrootdir: /home/markn/devel/py-src/DailyCodingChallenge, inifile:\ncollected 1 item\n\ncodechallenge_025.py . [100%]\n\n============================== 1 passed in 0.03 seconds ==============================\n\n'
|
# -*- coding: utf-8 -*-
# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html
class FormatPipeline(object):
"""
All crawled items are passed through this pipeline
"""
def process_item(self, item, spider):
"""
Process an item produced by the spider
"""
item["link"] = item["link"].strip()
item["category"] = [x.strip() for x in item["category"]]
item["title"] = item["title"].strip()
item["warranty"] = (item["warranty"] or "Not Specified").strip()
item["rating"] = to_float(item["rating"].replace(',', '.'))
item["features"] = [to_ascii(x) for x in item["features"]]
item["features"] = list(set(item["features"]))
item["price"]["value"] = to_float(str(item["price"]["value"]))
if "old_price" in item:
item["old_price"]["value"] = to_float(str(item["old_price"]["value"]))
item["discount_rate"] = to_int((item["discount_rate"] or "0%").strip()[:-1])
# end if
return item
# end def
# end class
def to_ascii(x):
return x.encode('ascii', 'ignore').decode('utf8').strip()
#end def
def parse(func, arg):
"""Tries to parse the value"""
try:
return func(arg)
except ValueError:
return 0
# end def
def to_float(x):
return parse(float, (x or "0"))
# end def
def to_int(x):
return parse(int, (x or "0"))
# end def
|
class Formatpipeline(object):
"""
All crawled items are passed through this pipeline
"""
def process_item(self, item, spider):
"""
Process an item produced by the spider
"""
item['link'] = item['link'].strip()
item['category'] = [x.strip() for x in item['category']]
item['title'] = item['title'].strip()
item['warranty'] = (item['warranty'] or 'Not Specified').strip()
item['rating'] = to_float(item['rating'].replace(',', '.'))
item['features'] = [to_ascii(x) for x in item['features']]
item['features'] = list(set(item['features']))
item['price']['value'] = to_float(str(item['price']['value']))
if 'old_price' in item:
item['old_price']['value'] = to_float(str(item['old_price']['value']))
item['discount_rate'] = to_int((item['discount_rate'] or '0%').strip()[:-1])
return item
def to_ascii(x):
return x.encode('ascii', 'ignore').decode('utf8').strip()
def parse(func, arg):
"""Tries to parse the value"""
try:
return func(arg)
except ValueError:
return 0
def to_float(x):
return parse(float, x or '0')
def to_int(x):
return parse(int, x or '0')
|
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def mergeKLists(self, lists):
"""
:type lists: List[ListNode]
:rtype: ListNode
"""
head = ListNode(0)
curr = head
currs = [h for h in lists if h is not None]
while currs:
min_i = 0
for i, p in enumerate(currs):
if p.val < currs[min_i].val:
min_i = i
curr.next = currs[min_i]
curr = curr.next
if currs[min_i].next:
currs[min_i] = currs[min_i].next
else:
currs.remove(currs[min_i])
return head.next
|
class Listnode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def merge_k_lists(self, lists):
"""
:type lists: List[ListNode]
:rtype: ListNode
"""
head = list_node(0)
curr = head
currs = [h for h in lists if h is not None]
while currs:
min_i = 0
for (i, p) in enumerate(currs):
if p.val < currs[min_i].val:
min_i = i
curr.next = currs[min_i]
curr = curr.next
if currs[min_i].next:
currs[min_i] = currs[min_i].next
else:
currs.remove(currs[min_i])
return head.next
|
START_BRAKING = 17
END_BRAKING = 25
BRAKE_SPEED = 1
""" Straight, please """
def reward_function(params):
# No rewards shaping yet, just add a brake by track position
if params['closest_waypoints'][0] >= START_BRAKING and params['closest_waypoints'][0] >= END_BRAKING and params['speed'] == BRAKE_SPEED:
# BRAKE!
reward = 1
elif params['speed'] > BRAKE_SPEED:
# Don't brake!
reward = 1
else:
# You're doing it wrong!
reward = 1e-3
return reward
|
start_braking = 17
end_braking = 25
brake_speed = 1
' Straight, please '
def reward_function(params):
if params['closest_waypoints'][0] >= START_BRAKING and params['closest_waypoints'][0] >= END_BRAKING and (params['speed'] == BRAKE_SPEED):
reward = 1
elif params['speed'] > BRAKE_SPEED:
reward = 1
else:
reward = 0.001
return reward
|
# See file COPYING distributed with xnatrest for copyright and license.
class XNATRESTError(Exception):
"""base class for xnatrest exceptions"""
class CircularReferenceError(XNATRESTError):
def __init__(self, url):
self.url = url
return
def __str__(self):
return 'circular reference to %s' % self.url
class UnidentifiedServerError(XNATRESTError):
def __str__(self):
return 'could not identify server'
# eof
|
class Xnatresterror(Exception):
"""base class for xnatrest exceptions"""
class Circularreferenceerror(XNATRESTError):
def __init__(self, url):
self.url = url
return
def __str__(self):
return 'circular reference to %s' % self.url
class Unidentifiedservererror(XNATRESTError):
def __str__(self):
return 'could not identify server'
|
# Start and end date
gldas_start_date = '2010-01-01'
gldas_end_date = '2014-01-01'
# Location (Latitude and Longitude)
gldas_geo_point = AutoParam([(38, -117), (38, -118)])
# Create data fetcher
gldasdf = GLDASDF([gldas_geo_point],start_date=gldas_start_date,
end_date=gldas_end_date, resample=False)
|
gldas_start_date = '2010-01-01'
gldas_end_date = '2014-01-01'
gldas_geo_point = auto_param([(38, -117), (38, -118)])
gldasdf = gldasdf([gldas_geo_point], start_date=gldas_start_date, end_date=gldas_end_date, resample=False)
|
class IDGroup:
"""
The IDGroup Type
================
This type supports both iteration and the []
operator to get child ID properties.
You can also add new properties using the [] operator.
For example::
group['a float!'] = 0.0
group['an int!'] = 0
group['a string!'] = "hi!"
group['an array!'] = [0, 0, 1.0, 0]
group['a subgroup!] = {"float": 0.0, "an int": 1.0, "an array": [1, 2],
"another subgroup": {"a": 0.0, "str": "bleh"}}
Note that for arrays, the array type defaults to int unless a float is found
while scanning the template list; if any floats are found, then the whole
array is float. Note that double-precision floating point numbers are used for
python-created float ID properties and arrays (though the internal C api does
support single-precision floats, and the python code will read them).
You can also delete properties with the del operator. For example:
del group['property']
To get the type of a property, use the type() operator, for example::
if type(group['bleh']) == str: pass
To tell if the property is a group or array type, import the Blender.Types module and test
against IDGroupType and IDArrayType, like so::
from Blender.Types import IDGroupType, IDArrayType.
if type(group['bleghr']) == IDGroupType:
(do something)
@ivar name: The name of the property
@type name: string
"""
def pop(item):
"""
Pop an item from the group property.
@type item: string
@param item: The item name.
@rtype: can be dict, list, int, float or string.
@return: The removed property.
"""
def update(updatedict):
"""
Updates items in the dict, similar to normal python
dictionary method .update().
@type updatedict: dict
@param updatedict: A dict of simple types to derive updated/new IDProperties from.
@rtype: None
@return: None
"""
def keys():
"""
Returns a list of the keys in this property group.
@rtype: list of strings.
@return: a list of the keys in this property group.
"""
def values():
"""
Returns a list of the values in this property group.
Note that unless a value is itself a property group or an array, you
cannot change it by changing the values in this list, you must change them
in the parent property group.
For example,
group['some_property'] = new_value
. . .is correct, while,
values = group.values()
values[0] = new_value
. . .is wrong.
@rtype: list of strings.
@return: a list of the values in this property group.
"""
def iteritems():
"""
Implements the python dictionary iteritmes method.
For example::
for k, v in group.iteritems():
print "Property name: " + k
print "Property value: " + str(v)
@rtype: an iterator that spits out items of the form [key, value]
@return: an iterator.
"""
def convert_to_pyobject():
"""
Converts the entire property group to a purely python form.
@rtype: dict
@return: A python dictionary representing the property group
"""
class IDArray:
"""
The IDArray Type
================
@ivar type: returns the type of the array, can be either IDP_Int or IDP_Float
"""
def __getitem__(index):
pass
def __setitem__(index, value):
pass
def __len__():
pass
|
class Idgroup:
"""
The IDGroup Type
================
This type supports both iteration and the []
operator to get child ID properties.
You can also add new properties using the [] operator.
For example::
group['a float!'] = 0.0
group['an int!'] = 0
group['a string!'] = "hi!"
group['an array!'] = [0, 0, 1.0, 0]
group['a subgroup!] = {"float": 0.0, "an int": 1.0, "an array": [1, 2],
"another subgroup": {"a": 0.0, "str": "bleh"}}
Note that for arrays, the array type defaults to int unless a float is found
while scanning the template list; if any floats are found, then the whole
array is float. Note that double-precision floating point numbers are used for
python-created float ID properties and arrays (though the internal C api does
support single-precision floats, and the python code will read them).
You can also delete properties with the del operator. For example:
del group['property']
To get the type of a property, use the type() operator, for example::
if type(group['bleh']) == str: pass
To tell if the property is a group or array type, import the Blender.Types module and test
against IDGroupType and IDArrayType, like so::
from Blender.Types import IDGroupType, IDArrayType.
if type(group['bleghr']) == IDGroupType:
(do something)
@ivar name: The name of the property
@type name: string
"""
def pop(item):
"""
Pop an item from the group property.
@type item: string
@param item: The item name.
@rtype: can be dict, list, int, float or string.
@return: The removed property.
"""
def update(updatedict):
"""
Updates items in the dict, similar to normal python
dictionary method .update().
@type updatedict: dict
@param updatedict: A dict of simple types to derive updated/new IDProperties from.
@rtype: None
@return: None
"""
def keys():
"""
Returns a list of the keys in this property group.
@rtype: list of strings.
@return: a list of the keys in this property group.
"""
def values():
"""
Returns a list of the values in this property group.
Note that unless a value is itself a property group or an array, you
cannot change it by changing the values in this list, you must change them
in the parent property group.
For example,
group['some_property'] = new_value
. . .is correct, while,
values = group.values()
values[0] = new_value
. . .is wrong.
@rtype: list of strings.
@return: a list of the values in this property group.
"""
def iteritems():
"""
Implements the python dictionary iteritmes method.
For example::
for k, v in group.iteritems():
print "Property name: " + k
print "Property value: " + str(v)
@rtype: an iterator that spits out items of the form [key, value]
@return: an iterator.
"""
def convert_to_pyobject():
"""
Converts the entire property group to a purely python form.
@rtype: dict
@return: A python dictionary representing the property group
"""
class Idarray:
"""
The IDArray Type
================
@ivar type: returns the type of the array, can be either IDP_Int or IDP_Float
"""
def __getitem__(index):
pass
def __setitem__(index, value):
pass
def __len__():
pass
|
"""
Let's call an array A a mountain if the following properties hold:
A.length >= 3
There exists some 0 < i < A.length - 1 such that A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.length - 1]
Given an array that is definitely a mountain, return any i such that A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.length - 1].
Example 1:
Input: [0,1,0]
Output: 1
Example 2:
Input: [0,2,1,0]
Output: 1
Note:
1. 3 <= A.length <= 10000
2. 0 <= A[i] <= 10^6
3. A is a mountain, as defined above.
"""
class Solution:
def peakIndexInMountainArray1(self, A):
for i in range(len(A)):
if A[i] > A[i + 1]:
return i
def peakIndexInMountainArray2(self, A):
a, b = 0, len(A) - 1
while a <= b:
c = (a + b) // 2
if A[c] < A[c + 1]:
a = c + 1
else:
b = c - 1
return a
|
"""
Let's call an array A a mountain if the following properties hold:
A.length >= 3
There exists some 0 < i < A.length - 1 such that A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.length - 1]
Given an array that is definitely a mountain, return any i such that A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.length - 1].
Example 1:
Input: [0,1,0]
Output: 1
Example 2:
Input: [0,2,1,0]
Output: 1
Note:
1. 3 <= A.length <= 10000
2. 0 <= A[i] <= 10^6
3. A is a mountain, as defined above.
"""
class Solution:
def peak_index_in_mountain_array1(self, A):
for i in range(len(A)):
if A[i] > A[i + 1]:
return i
def peak_index_in_mountain_array2(self, A):
(a, b) = (0, len(A) - 1)
while a <= b:
c = (a + b) // 2
if A[c] < A[c + 1]:
a = c + 1
else:
b = c - 1
return a
|
def hola():
def bienvenido():
print("hola!")
return bienvenido
# hola()()
def mensaje():
return "Este es un mensaje"
def test(function):
print(mensaje())
test(mensaje)
|
def hola():
def bienvenido():
print('hola!')
return bienvenido
def mensaje():
return 'Este es un mensaje'
def test(function):
print(mensaje())
test(mensaje)
|
def combination(a: int, b: int) -> int:
"""
Choose b from a. a >= b
"""
b = min(b, a - b)
numerator = 1
dominator = 1
for i in range(b):
numerator *= (a - i)
dominator *= (b - i)
return int(numerator / dominator)
if __name__ == '__main__':
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
print(combination(m, n))
|
def combination(a: int, b: int) -> int:
"""
Choose b from a. a >= b
"""
b = min(b, a - b)
numerator = 1
dominator = 1
for i in range(b):
numerator *= a - i
dominator *= b - i
return int(numerator / dominator)
if __name__ == '__main__':
t = int(input())
for _ in range(t):
(n, m) = map(int, input().split())
print(combination(m, n))
|
# Getting all PAL : Prime and pallindrome numbers between two given numbers
def pallindrome(n):
temp=n
rev=0
while(n>0):
dig = n % 10
rev=rev*10 +dig
n = n/10
if temp == rev:
return True
else:
return False
def isprime(n):
if n<=1:
return False
if n<=3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i*i < n:
if n % i == 0 or n % (i+2) == 0:
return False
i=i+6
return True
a=int(input("Enter the number of lower range "))
b=int(input("Enter the number of upper range "))
for i in range(a,b):
if pallindrome(i) and isprime(i):
print(i)
|
def pallindrome(n):
temp = n
rev = 0
while n > 0:
dig = n % 10
rev = rev * 10 + dig
n = n / 10
if temp == rev:
return True
else:
return False
def isprime(n):
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i < n:
if n % i == 0 or n % (i + 2) == 0:
return False
i = i + 6
return True
a = int(input('Enter the number of lower range '))
b = int(input('Enter the number of upper range '))
for i in range(a, b):
if pallindrome(i) and isprime(i):
print(i)
|
async def iter_to_aiter(iter):
"""
:type iter: synchronous iterator
:param iter: a synchronous iterator
This converts a regular iterator to an async iterator.
"""
for _ in iter:
yield _
|
async def iter_to_aiter(iter):
"""
:type iter: synchronous iterator
:param iter: a synchronous iterator
This converts a regular iterator to an async iterator.
"""
for _ in iter:
yield _
|
# buttons
PIN_BUTTON_PROG = 17
PIN_BUTTON_ERASE = 27
# LEDs
PIN_RED = 23
PIN_GREEN = 24
PIN_BLUE = 20
PIN_BLUE2 = 25
# Jumpers
PINS_PROFILES = [5, 6, 13, 19]
# MCU
PIN_RESET_ATMEGA = 16
PIN_MASTER_POWER = 12
PIN_ESP_RESET = 8
PIN_ESP_GPIO_0 = 4
# MISC
PIN_BUZZER = 26
# Interfaces
DEFAULT_SERIAL_SPEED = 9600
DEFAULT_PRGM_COMM_SPEED = 115200
SERIAL_PORT = "/dev/serial0"
|
pin_button_prog = 17
pin_button_erase = 27
pin_red = 23
pin_green = 24
pin_blue = 20
pin_blue2 = 25
pins_profiles = [5, 6, 13, 19]
pin_reset_atmega = 16
pin_master_power = 12
pin_esp_reset = 8
pin_esp_gpio_0 = 4
pin_buzzer = 26
default_serial_speed = 9600
default_prgm_comm_speed = 115200
serial_port = '/dev/serial0'
|
# -*- coding: utf-8 -*-
smtpserver = "smtp.qq.com" # will be read by smtp fixture
def test_showhelo(smtp_connection):
assert 0, smtp_connection.helo()
|
smtpserver = 'smtp.qq.com'
def test_showhelo(smtp_connection):
assert 0, smtp_connection.helo()
|
# -*- coding: utf-8 -*-
project = 'test'
master_doc = 'index'
|
project = 'test'
master_doc = 'index'
|
s, n = map(int, input().split())
arr = [0] * n
for i in range(s):
p = int(input())
for j in range(0, len(arr), p):
arr[j] = 1
for i in arr:
print(i, end=" ")
print()
|
(s, n) = map(int, input().split())
arr = [0] * n
for i in range(s):
p = int(input())
for j in range(0, len(arr), p):
arr[j] = 1
for i in arr:
print(i, end=' ')
print()
|
CHAMP_ID_TO_EMOJI = {'266': '<:champ_266:601909182748164097>', '103': '<:champ_103:601909185243774976>', '84': '<:champ_84:601909188612063233>', '12': '<:champ_12:601909190809878530>', '32': '<:champ_32:601909193456222221>', '34': '<:champ_34:601909195968610356>', '1': '<:champ_1:601909198799896690>', '22': '<:champ_22:601909201564073984>', '136': '<:champ_136:601909204034387986>', '268': '<:champ_268:601909206337191937>', '432': '<:champ_432:601909209348571136>', '53': '<:champ_53:601909212175663129>', '63': '<:champ_63:601909215262408705>', '201': '<:champ_201:601909218072592406>', '51': '<:champ_51:601909220664672275>', '164': '<:champ_164:601909222455640094>', '69': '<:champ_69:601909224213053481>', '31': '<:champ_31:601909227174494208>', '42': '<:champ_42:601909229246218250>', '122': '<:champ_122:601909231268134933>', '131': '<:champ_131:601909232954245122>', '119': '<:champ_119:601909235831406759>', '36': '<:champ_36:601909237928689714>', '245': '<:champ_245:601909241250578462>', '60': '<:champ_60:601909243112718355>', '28': '<:champ_28:601909244823863309>', '81': '<:champ_81:601909247458148353>', '9': '<:champ_9:601909250234646746>', '114': '<:champ_114:601909252642045964>', '105': '<:champ_105:601909255259291648>', '3': '<:champ_3:601909257067298865>', '41': '<:champ_41:601909258963124225>', '86': '<:champ_86:601909261915783188>', '150': '<:champ_150:601909264533028932>', '79': '<:champ_79:601909267032702989>', '104': '<:champ_104:601909269520056352>', '120': '<:champ_120:601909272825298944>', '74': '<:champ_74:601909276398714921>', '420': '<:champ_420:601909278105665588>', '39': '<:champ_39:601909281687732317>', '427': '<:champ_427:601909283675963402>', '40': '<:champ_40:601909286418907137>', '59': '<:champ_59:601909288994340933>', '24': '<:champ_24:601909292534071327>', '126': '<:champ_126:601909294975287325>', '202': '<:champ_202:601909297974083605>', '222': '<:champ_222:601909300687929355>', '145': '<:champ_145:601909302814310437>', '429': '<:champ_429:601909305662504981>', '43': '<:champ_43:601909308183150592>', '30': '<:champ_30:601909340571566080>', '38': '<:champ_38:601909342756929557>', '55': '<:champ_55:601909345663582273>', '10': '<:champ_10:601909347945283584>', '141': '<:champ_141:601909349471748112>', '85': '<:champ_85:601909351523024897>', '121': '<:champ_121:601909353540354061>', '203': '<:champ_203:601909356086296609>', '240': '<:champ_240:601909358258946048>', '96': '<:champ_96:601909360284663808>', '7': '<:champ_7:601909362222432266>', '64': '<:champ_64:601909364881883136>', '89': '<:champ_89:601909366802612236>', '127': '<:champ_127:601909370413907984>', '236': '<:champ_236:601909373194993698>', '117': '<:champ_117:601909375317311488>', '99': '<:champ_99:601909377959460885>', '54': '<:champ_54:601909383433027614>', '90': '<:champ_90:601909385614196767>', '57': '<:champ_57:601909388122390529>', '11': '<:champ_11:601909392623009793>', '21': '<:champ_21:601909395030409235>', '62': '<:champ_62:601909398578659358>', '82': '<:champ_82:601909401506414598>', '25': '<:champ_25:601909403448508437>', '267': '<:champ_267:601909406426333198>', '75': '<:champ_75:601909408628211715>', '111': '<:champ_111:601909410805055488>', '518': '<:champ_518:601909414118686752>', '76': '<:champ_76:601909416110981169>', '56': '<:champ_56:601909419189469185>', '20': '<:champ_20:601909421580484629>', '2': '<:champ_2:601909423983558668>', '61': '<:champ_61:601909426474975263>', '516': '<:champ_516:601909428958003212>', '80': '<:champ_80:601909431747346447>', '78': '<:champ_78:601909434142294086>', '555': '<:champ_555:601909436864397322>', '246': '<:champ_246:601909439876038676>', '133': '<:champ_133:601909442371387395>', '497': '<:champ_497:601909445253005335>', '33': '<:champ_33:601909447320797244>', '421': '<:champ_421:601909449850093579>', '58': '<:champ_58:601909452567871571>', '107': '<:champ_107:601909455478718491>', '92': '<:champ_92:601909458230050816>', '68': '<:champ_68:601909460482654208>', '13': '<:champ_13:601909462776676372>', '113': '<:champ_113:601909465624608777>', '35': '<:champ_35:601909468028207135>', '98': '<:champ_98:601909497539067924>', '102': '<:champ_102:601909500059975685>', '27': '<:champ_27:601909503205834764>', '14': '<:champ_14:601909506074607659>', '15': '<:champ_15:601909508129685504>', '72': '<:champ_72:601909510679953438>', '37': '<:champ_37:601909513066643456>', '16': '<:champ_16:601909515222253582>', '50': '<:champ_50:601909518082899972>', '517': '<:champ_517:601909520939089920>', '134': '<:champ_134:601909523493683213>', '223': '<:champ_223:601909526408724480>', '163': '<:champ_163:601909528652546070>', '91': '<:champ_91:601909531223654439>', '44': '<:champ_44:601909533727653918>', '17': '<:champ_17:601909535929794562>', '412': '<:champ_412:601909538701967370>', '18': '<:champ_18:601909541705089054>', '48': '<:champ_48:601909545056337960>', '23': '<:champ_23:601909548735004723>', '4': '<:champ_4:601909551637200898>', '29': '<:champ_29:601909555810795531>', '77': '<:champ_77:601909558604070961>', '6': '<:champ_6:601909560751423526>', '110': '<:champ_110:601909562953433098>', '67': '<:champ_67:601909566078451735>', '45': '<:champ_45:601909568452165653>', '161': '<:champ_161:601909571069411359>', '254': '<:champ_254:601909573863079936>', '112': '<:champ_112:601909575800717332>', '8': '<:champ_8:601909578438934677>', '106': '<:champ_106:601909581311901719>', '19': '<:champ_19:601909584277405709>', '498': '<:champ_498:601909586701582336>', '101': '<:champ_101:601909589369159691>', '5': '<:champ_5:601909591667769364>', '157': '<:champ_157:601909594758971468>', '83': '<:champ_83:601909596877094940>', '350': '<:champ_350:601909599469305875>', '154': '<:champ_154:601909605194268673>', '238': '<:champ_238:601909607824359462>', '115': '<:champ_115:601909610885939200>', '26': '<:champ_26:601909614031798447>', '142': '<:champ_142:601909616258973696>', '143': '<:champ_143:601909618808979478>'}
RUNE_ID_TO_EMOJI = {'8112': '<:rune_8112:602195444940144650>', '8124': '<:rune_8124:602195452028518410>', '8128': '<:rune_8128:602195459003514920>', '9923': '<:rune_9923:602195465299165308>', '8126': '<:rune_8126:602195466981212190>', '8139': '<:rune_8139:602195469573160970>', '8143': '<:rune_8143:602195471859056641>', '8136': '<:rune_8136:602195473264017462>', '8120': '<:rune_8120:602195475013173288>', '8138': '<:rune_8138:602195477257256963>', '8135': '<:rune_8135:602195479417192449>', '8134': '<:rune_8134:602195482487554058>', '8105': '<:rune_8105:602195484748152843>', '8106': '<:rune_8106:602195487650742283>', '8351': '<:rune_8351:602195494319423529>', '8359': '<:rune_8359:602195503048032291>', '8360': '<:rune_8360:602195510388064256>', '8306': '<:rune_8306:602195512036163585>', '8304': '<:rune_8304:602195513173082113>', '8313': '<:rune_8313:602195513546244128>', '8321': '<:rune_8321:602195517103014084>', '8316': '<:rune_8316:602195519829311562>', '8345': '<:rune_8345:602195522345893911>', '8347': '<:rune_8347:602195524338319370>', '8410': '<:rune_8410:602195527479722000>', '8352': '<:rune_8352:602195529291661489>', '8005': '<:rune_8005:602195538036785152>', '8008': '<:rune_8008:602195543464345601>', '8021': '<:rune_8021:602195550271700992>', '8010': '<:rune_8010:602195555006939137>', '9101': '<:rune_9101:602195557502681088>', '9111': '<:rune_9111:602195559880851536>', '8009': '<:rune_8009:602195562481057792>', '9104': '<:rune_9104:602195563936743455>', '9105': '<:rune_9105:602195565408813056>', '9103': '<:rune_9103:602195567241854979>', '8014': '<:rune_8014:602195568759930900>', '8017': '<:rune_8017:602195571364724774>', '8299': '<:rune_8299:602195573952479242>', '8437': '<:rune_8437:602195580919349261>', '8439': '<:rune_8439:602195586468544533>', '8465': '<:rune_8465:602195592357347358>', '8446': '<:rune_8446:602195594643243018>', '8463': '<:rune_8463:602195596736200757>', '8401': '<:rune_8401:602195601475764234>', '8429': '<:rune_8429:602195603308675078>', '8444': '<:rune_8444:602195605334392832>', '8473': '<:rune_8473:602195607670620161>', '8451': '<:rune_8451:602195610233339914>', '8453': '<:rune_8453:602195612569567250>', '8242': '<:rune_8242:602195615321030840>', '8214': '<:rune_8214:602195620601528330>', '8229': '<:rune_8229:602195626293198859>', '8230': '<:rune_8230:602195631255060541>', '8224': '<:rune_8224:602195633171857418>', '8226': '<:rune_8226:602195635868925970>', '8275': '<:rune_8275:602195639140483072>', '8210': '<:rune_8210:602195640432328792>', '8234': '<:rune_8234:602195643515011092>', '8233': '<:rune_8233:602195645956096010>', '8237': '<:rune_8237:602195647268913162>', '8232': '<:rune_8232:602195649907392525>', '8236': '<:rune_8236:602195652235231235>'}
MASTERIES_TO_EMOJI = {'1': '<:masteries_1:602201182131322886>', '2': '<:masteries_2:602201195792039967>', '3': '<:masteries_3:602201208505106453>', '4': '<:masteries_4:602201225701883924>', '5': '<:masteries_5:602201238528065557>', '6': '<:masteries_6:602201251069034496>', '7': '<:masteries_7:602201263152693325>'}
CHAMP_NONE_EMOJI = "<:champ_0:602225831095435294>"
INVISIBLE_EMOJI = "<:__:602265603893493761>"
CHAMP_NAME_TO_ID = {'Aatrox': '266', 'Ahri': '103', 'Akali': '84', 'Alistar': '12', 'Amumu': '32', 'Anivia': '34', 'Annie': '1', 'Ashe': '22', 'Aurelion Sol': '136', 'Azir': '268', 'Bard': '432', 'Blitzcrank': '53', 'Brand': '63', 'Braum': '201', 'Caitlyn': '51', 'Camille': '164', 'Cassiopeia': '69', "Cho'Gath": '31', 'Corki': '42', 'Darius': '122', 'Diana': '131', 'Draven': '119', 'Dr. Mundo': '36', 'Ekko': '245', 'Elise': '60', 'Evelynn': '28', 'Ezreal': '81', 'Fiddlesticks': '9', 'Fiora': '114', 'Fizz': '105', 'Galio': '3', 'Gangplank': '41', 'Garen': '86', 'Gnar': '150', 'Gragas': '79', 'Graves': '104', 'Hecarim': '120', 'Heimerdinger': '74', 'Illaoi': '420', 'Irelia': '39', 'Ivern': '427', 'Janna': '40', 'Jarvan IV': '59', 'Jax': '24', 'Jayce': '126', 'Jhin': '202', 'Jinx': '222', "Kai'Sa": '145', 'Kalista': '429', 'Karma': '43', 'Karthus': '30', 'Kassadin': '38', 'Katarina': '55', 'Kayle': '10', 'Kayn': '141', 'Kennen': '85', "Kha'Zix": '121', 'Kindred': '203', 'Kled': '240', "Kog'Maw": '96', 'LeBlanc': '7', 'Lee Sin': '64', 'Leona': '89', 'Lissandra': '127', 'Lucian': '236', 'Lulu': '117', 'Lux': '99', 'Malphite': '54', 'Malzahar': '90', 'Maokai': '57', 'Master Yi': '11', 'Miss Fortune': '21', 'Wukong': '62', 'Mordekaiser': '82', 'Morgana': '25', 'Nami': '267', 'Nasus': '75', 'Nautilus': '111', 'Neeko': '518', 'Nidalee': '76', 'Nocturne': '56', 'Nunu & Willump': '20', 'Olaf': '2', 'Orianna': '61', 'Ornn': '516', 'Pantheon': '80', 'Poppy': '78', 'Pyke': '555', 'Qiyana': '246', 'Quinn': '133', 'Rakan': '497', 'Rammus': '33', "Rek'Sai": '421', 'Renekton': '58', 'Rengar': '107', 'Riven': '92', 'Rumble': '68', 'Ryze': '13', 'Sejuani': '113', 'Senna': '235', 'Shaco': '35', 'Shen': '98', 'Shyvana': '102', 'Singed': '27', 'Sion': '14', 'Sivir': '15', 'Skarner': '72', 'Sona': '37', 'Soraka': '16', 'Swain': '50', 'Sylas': '517', 'Syndra': '134', 'Tahm Kench': '223', 'Taliyah': '163', 'Talon': '91', 'Taric': '44', 'Teemo': '17', 'Thresh': '412', 'Tristana': '18', 'Trundle': '48', 'Tryndamere': '23', 'Twisted Fate': '4', 'Twitch': '29', 'Udyr': '77', 'Urgot': '6', 'Varus': '110', 'Vayne': '67', 'Veigar': '45', "Vel'Koz": '161', 'Vi': '254', 'Viktor': '112', 'Vladimir': '8', 'Volibear': '106', 'Warwick': '19', 'Xayah': '498', 'Xerath': '101', 'Xin Zhao': '5', 'Yasuo': '157', 'Yorick': '83', 'Yuumi': '350', 'Zac': '154', 'Zed': '238', 'Ziggs': '115', 'Zilean': '26', 'Zoe': '142', 'Zyra': '143'}
TFT_PRICES = [INVISIBLE_EMOJI, '<:tft_g1:652142396405972992>', '<:tft_g2:652142435606069248>', '<:tft_g3:652142468007067649>', '<:tft_g4:652142511913041960>', '<:tft_g5:652142572541575181>']
|
champ_id_to_emoji = {'266': '<:champ_266:601909182748164097>', '103': '<:champ_103:601909185243774976>', '84': '<:champ_84:601909188612063233>', '12': '<:champ_12:601909190809878530>', '32': '<:champ_32:601909193456222221>', '34': '<:champ_34:601909195968610356>', '1': '<:champ_1:601909198799896690>', '22': '<:champ_22:601909201564073984>', '136': '<:champ_136:601909204034387986>', '268': '<:champ_268:601909206337191937>', '432': '<:champ_432:601909209348571136>', '53': '<:champ_53:601909212175663129>', '63': '<:champ_63:601909215262408705>', '201': '<:champ_201:601909218072592406>', '51': '<:champ_51:601909220664672275>', '164': '<:champ_164:601909222455640094>', '69': '<:champ_69:601909224213053481>', '31': '<:champ_31:601909227174494208>', '42': '<:champ_42:601909229246218250>', '122': '<:champ_122:601909231268134933>', '131': '<:champ_131:601909232954245122>', '119': '<:champ_119:601909235831406759>', '36': '<:champ_36:601909237928689714>', '245': '<:champ_245:601909241250578462>', '60': '<:champ_60:601909243112718355>', '28': '<:champ_28:601909244823863309>', '81': '<:champ_81:601909247458148353>', '9': '<:champ_9:601909250234646746>', '114': '<:champ_114:601909252642045964>', '105': '<:champ_105:601909255259291648>', '3': '<:champ_3:601909257067298865>', '41': '<:champ_41:601909258963124225>', '86': '<:champ_86:601909261915783188>', '150': '<:champ_150:601909264533028932>', '79': '<:champ_79:601909267032702989>', '104': '<:champ_104:601909269520056352>', '120': '<:champ_120:601909272825298944>', '74': '<:champ_74:601909276398714921>', '420': '<:champ_420:601909278105665588>', '39': '<:champ_39:601909281687732317>', '427': '<:champ_427:601909283675963402>', '40': '<:champ_40:601909286418907137>', '59': '<:champ_59:601909288994340933>', '24': '<:champ_24:601909292534071327>', '126': '<:champ_126:601909294975287325>', '202': '<:champ_202:601909297974083605>', '222': '<:champ_222:601909300687929355>', '145': '<:champ_145:601909302814310437>', '429': '<:champ_429:601909305662504981>', '43': '<:champ_43:601909308183150592>', '30': '<:champ_30:601909340571566080>', '38': '<:champ_38:601909342756929557>', '55': '<:champ_55:601909345663582273>', '10': '<:champ_10:601909347945283584>', '141': '<:champ_141:601909349471748112>', '85': '<:champ_85:601909351523024897>', '121': '<:champ_121:601909353540354061>', '203': '<:champ_203:601909356086296609>', '240': '<:champ_240:601909358258946048>', '96': '<:champ_96:601909360284663808>', '7': '<:champ_7:601909362222432266>', '64': '<:champ_64:601909364881883136>', '89': '<:champ_89:601909366802612236>', '127': '<:champ_127:601909370413907984>', '236': '<:champ_236:601909373194993698>', '117': '<:champ_117:601909375317311488>', '99': '<:champ_99:601909377959460885>', '54': '<:champ_54:601909383433027614>', '90': '<:champ_90:601909385614196767>', '57': '<:champ_57:601909388122390529>', '11': '<:champ_11:601909392623009793>', '21': '<:champ_21:601909395030409235>', '62': '<:champ_62:601909398578659358>', '82': '<:champ_82:601909401506414598>', '25': '<:champ_25:601909403448508437>', '267': '<:champ_267:601909406426333198>', '75': '<:champ_75:601909408628211715>', '111': '<:champ_111:601909410805055488>', '518': '<:champ_518:601909414118686752>', '76': '<:champ_76:601909416110981169>', '56': '<:champ_56:601909419189469185>', '20': '<:champ_20:601909421580484629>', '2': '<:champ_2:601909423983558668>', '61': '<:champ_61:601909426474975263>', '516': '<:champ_516:601909428958003212>', '80': '<:champ_80:601909431747346447>', '78': '<:champ_78:601909434142294086>', '555': '<:champ_555:601909436864397322>', '246': '<:champ_246:601909439876038676>', '133': '<:champ_133:601909442371387395>', '497': '<:champ_497:601909445253005335>', '33': '<:champ_33:601909447320797244>', '421': '<:champ_421:601909449850093579>', '58': '<:champ_58:601909452567871571>', '107': '<:champ_107:601909455478718491>', '92': '<:champ_92:601909458230050816>', '68': '<:champ_68:601909460482654208>', '13': '<:champ_13:601909462776676372>', '113': '<:champ_113:601909465624608777>', '35': '<:champ_35:601909468028207135>', '98': '<:champ_98:601909497539067924>', '102': '<:champ_102:601909500059975685>', '27': '<:champ_27:601909503205834764>', '14': '<:champ_14:601909506074607659>', '15': '<:champ_15:601909508129685504>', '72': '<:champ_72:601909510679953438>', '37': '<:champ_37:601909513066643456>', '16': '<:champ_16:601909515222253582>', '50': '<:champ_50:601909518082899972>', '517': '<:champ_517:601909520939089920>', '134': '<:champ_134:601909523493683213>', '223': '<:champ_223:601909526408724480>', '163': '<:champ_163:601909528652546070>', '91': '<:champ_91:601909531223654439>', '44': '<:champ_44:601909533727653918>', '17': '<:champ_17:601909535929794562>', '412': '<:champ_412:601909538701967370>', '18': '<:champ_18:601909541705089054>', '48': '<:champ_48:601909545056337960>', '23': '<:champ_23:601909548735004723>', '4': '<:champ_4:601909551637200898>', '29': '<:champ_29:601909555810795531>', '77': '<:champ_77:601909558604070961>', '6': '<:champ_6:601909560751423526>', '110': '<:champ_110:601909562953433098>', '67': '<:champ_67:601909566078451735>', '45': '<:champ_45:601909568452165653>', '161': '<:champ_161:601909571069411359>', '254': '<:champ_254:601909573863079936>', '112': '<:champ_112:601909575800717332>', '8': '<:champ_8:601909578438934677>', '106': '<:champ_106:601909581311901719>', '19': '<:champ_19:601909584277405709>', '498': '<:champ_498:601909586701582336>', '101': '<:champ_101:601909589369159691>', '5': '<:champ_5:601909591667769364>', '157': '<:champ_157:601909594758971468>', '83': '<:champ_83:601909596877094940>', '350': '<:champ_350:601909599469305875>', '154': '<:champ_154:601909605194268673>', '238': '<:champ_238:601909607824359462>', '115': '<:champ_115:601909610885939200>', '26': '<:champ_26:601909614031798447>', '142': '<:champ_142:601909616258973696>', '143': '<:champ_143:601909618808979478>'}
rune_id_to_emoji = {'8112': '<:rune_8112:602195444940144650>', '8124': '<:rune_8124:602195452028518410>', '8128': '<:rune_8128:602195459003514920>', '9923': '<:rune_9923:602195465299165308>', '8126': '<:rune_8126:602195466981212190>', '8139': '<:rune_8139:602195469573160970>', '8143': '<:rune_8143:602195471859056641>', '8136': '<:rune_8136:602195473264017462>', '8120': '<:rune_8120:602195475013173288>', '8138': '<:rune_8138:602195477257256963>', '8135': '<:rune_8135:602195479417192449>', '8134': '<:rune_8134:602195482487554058>', '8105': '<:rune_8105:602195484748152843>', '8106': '<:rune_8106:602195487650742283>', '8351': '<:rune_8351:602195494319423529>', '8359': '<:rune_8359:602195503048032291>', '8360': '<:rune_8360:602195510388064256>', '8306': '<:rune_8306:602195512036163585>', '8304': '<:rune_8304:602195513173082113>', '8313': '<:rune_8313:602195513546244128>', '8321': '<:rune_8321:602195517103014084>', '8316': '<:rune_8316:602195519829311562>', '8345': '<:rune_8345:602195522345893911>', '8347': '<:rune_8347:602195524338319370>', '8410': '<:rune_8410:602195527479722000>', '8352': '<:rune_8352:602195529291661489>', '8005': '<:rune_8005:602195538036785152>', '8008': '<:rune_8008:602195543464345601>', '8021': '<:rune_8021:602195550271700992>', '8010': '<:rune_8010:602195555006939137>', '9101': '<:rune_9101:602195557502681088>', '9111': '<:rune_9111:602195559880851536>', '8009': '<:rune_8009:602195562481057792>', '9104': '<:rune_9104:602195563936743455>', '9105': '<:rune_9105:602195565408813056>', '9103': '<:rune_9103:602195567241854979>', '8014': '<:rune_8014:602195568759930900>', '8017': '<:rune_8017:602195571364724774>', '8299': '<:rune_8299:602195573952479242>', '8437': '<:rune_8437:602195580919349261>', '8439': '<:rune_8439:602195586468544533>', '8465': '<:rune_8465:602195592357347358>', '8446': '<:rune_8446:602195594643243018>', '8463': '<:rune_8463:602195596736200757>', '8401': '<:rune_8401:602195601475764234>', '8429': '<:rune_8429:602195603308675078>', '8444': '<:rune_8444:602195605334392832>', '8473': '<:rune_8473:602195607670620161>', '8451': '<:rune_8451:602195610233339914>', '8453': '<:rune_8453:602195612569567250>', '8242': '<:rune_8242:602195615321030840>', '8214': '<:rune_8214:602195620601528330>', '8229': '<:rune_8229:602195626293198859>', '8230': '<:rune_8230:602195631255060541>', '8224': '<:rune_8224:602195633171857418>', '8226': '<:rune_8226:602195635868925970>', '8275': '<:rune_8275:602195639140483072>', '8210': '<:rune_8210:602195640432328792>', '8234': '<:rune_8234:602195643515011092>', '8233': '<:rune_8233:602195645956096010>', '8237': '<:rune_8237:602195647268913162>', '8232': '<:rune_8232:602195649907392525>', '8236': '<:rune_8236:602195652235231235>'}
masteries_to_emoji = {'1': '<:masteries_1:602201182131322886>', '2': '<:masteries_2:602201195792039967>', '3': '<:masteries_3:602201208505106453>', '4': '<:masteries_4:602201225701883924>', '5': '<:masteries_5:602201238528065557>', '6': '<:masteries_6:602201251069034496>', '7': '<:masteries_7:602201263152693325>'}
champ_none_emoji = '<:champ_0:602225831095435294>'
invisible_emoji = '<:__:602265603893493761>'
champ_name_to_id = {'Aatrox': '266', 'Ahri': '103', 'Akali': '84', 'Alistar': '12', 'Amumu': '32', 'Anivia': '34', 'Annie': '1', 'Ashe': '22', 'Aurelion Sol': '136', 'Azir': '268', 'Bard': '432', 'Blitzcrank': '53', 'Brand': '63', 'Braum': '201', 'Caitlyn': '51', 'Camille': '164', 'Cassiopeia': '69', "Cho'Gath": '31', 'Corki': '42', 'Darius': '122', 'Diana': '131', 'Draven': '119', 'Dr. Mundo': '36', 'Ekko': '245', 'Elise': '60', 'Evelynn': '28', 'Ezreal': '81', 'Fiddlesticks': '9', 'Fiora': '114', 'Fizz': '105', 'Galio': '3', 'Gangplank': '41', 'Garen': '86', 'Gnar': '150', 'Gragas': '79', 'Graves': '104', 'Hecarim': '120', 'Heimerdinger': '74', 'Illaoi': '420', 'Irelia': '39', 'Ivern': '427', 'Janna': '40', 'Jarvan IV': '59', 'Jax': '24', 'Jayce': '126', 'Jhin': '202', 'Jinx': '222', "Kai'Sa": '145', 'Kalista': '429', 'Karma': '43', 'Karthus': '30', 'Kassadin': '38', 'Katarina': '55', 'Kayle': '10', 'Kayn': '141', 'Kennen': '85', "Kha'Zix": '121', 'Kindred': '203', 'Kled': '240', "Kog'Maw": '96', 'LeBlanc': '7', 'Lee Sin': '64', 'Leona': '89', 'Lissandra': '127', 'Lucian': '236', 'Lulu': '117', 'Lux': '99', 'Malphite': '54', 'Malzahar': '90', 'Maokai': '57', 'Master Yi': '11', 'Miss Fortune': '21', 'Wukong': '62', 'Mordekaiser': '82', 'Morgana': '25', 'Nami': '267', 'Nasus': '75', 'Nautilus': '111', 'Neeko': '518', 'Nidalee': '76', 'Nocturne': '56', 'Nunu & Willump': '20', 'Olaf': '2', 'Orianna': '61', 'Ornn': '516', 'Pantheon': '80', 'Poppy': '78', 'Pyke': '555', 'Qiyana': '246', 'Quinn': '133', 'Rakan': '497', 'Rammus': '33', "Rek'Sai": '421', 'Renekton': '58', 'Rengar': '107', 'Riven': '92', 'Rumble': '68', 'Ryze': '13', 'Sejuani': '113', 'Senna': '235', 'Shaco': '35', 'Shen': '98', 'Shyvana': '102', 'Singed': '27', 'Sion': '14', 'Sivir': '15', 'Skarner': '72', 'Sona': '37', 'Soraka': '16', 'Swain': '50', 'Sylas': '517', 'Syndra': '134', 'Tahm Kench': '223', 'Taliyah': '163', 'Talon': '91', 'Taric': '44', 'Teemo': '17', 'Thresh': '412', 'Tristana': '18', 'Trundle': '48', 'Tryndamere': '23', 'Twisted Fate': '4', 'Twitch': '29', 'Udyr': '77', 'Urgot': '6', 'Varus': '110', 'Vayne': '67', 'Veigar': '45', "Vel'Koz": '161', 'Vi': '254', 'Viktor': '112', 'Vladimir': '8', 'Volibear': '106', 'Warwick': '19', 'Xayah': '498', 'Xerath': '101', 'Xin Zhao': '5', 'Yasuo': '157', 'Yorick': '83', 'Yuumi': '350', 'Zac': '154', 'Zed': '238', 'Ziggs': '115', 'Zilean': '26', 'Zoe': '142', 'Zyra': '143'}
tft_prices = [INVISIBLE_EMOJI, '<:tft_g1:652142396405972992>', '<:tft_g2:652142435606069248>', '<:tft_g3:652142468007067649>', '<:tft_g4:652142511913041960>', '<:tft_g5:652142572541575181>']
|
"""Module that defines constants shared between agents."""
# pattoo-snmp constants
PATTOO_AGENT_SNMPD = 'pattoo_agent_snmpd'
PATTOO_AGENT_SNMP_IFMIBD = 'pattoo_agent_snmp_ifmibd'
|
"""Module that defines constants shared between agents."""
pattoo_agent_snmpd = 'pattoo_agent_snmpd'
pattoo_agent_snmp_ifmibd = 'pattoo_agent_snmp_ifmibd'
|
class Preciousstone:
def __init__(self):
self.preciousStone = []
def storePreciousStone(self,name):
self.preciousStone.append(name)
if( len(self.preciousStone) > 5):
del(self.preciousStone[0])
def displayPreciousStone(self):
if( len(self.preciousStone) > 0):
print(' '.join(self.preciousStone))
preciousstone = Preciousstone()
while(1):
print('1.Store 2.Display 3.Exit')
n = int(input('Enter your choice:'))
if n == 1:
stone = input("Enter the stone name:")
preciousstone.storePreciousStone(stone)
if n == 2:
preciousstone.displayPreciousStone()
if n == 3:
break
|
class Preciousstone:
def __init__(self):
self.preciousStone = []
def store_precious_stone(self, name):
self.preciousStone.append(name)
if len(self.preciousStone) > 5:
del self.preciousStone[0]
def display_precious_stone(self):
if len(self.preciousStone) > 0:
print(' '.join(self.preciousStone))
preciousstone = preciousstone()
while 1:
print('1.Store 2.Display 3.Exit')
n = int(input('Enter your choice:'))
if n == 1:
stone = input('Enter the stone name:')
preciousstone.storePreciousStone(stone)
if n == 2:
preciousstone.displayPreciousStone()
if n == 3:
break
|
class BufferList:
def __init__(self, maxlen):
self.data = []
self.maxlen = maxlen
def append(self, el):
if len(self.data) == self.maxlen:
popped = self.data.pop(0)
else:
popped = None
self.data.append(el)
return popped
def peek(self, i):
return self.data[-i-1]
def __len__(self):
return len(self.data)
|
class Bufferlist:
def __init__(self, maxlen):
self.data = []
self.maxlen = maxlen
def append(self, el):
if len(self.data) == self.maxlen:
popped = self.data.pop(0)
else:
popped = None
self.data.append(el)
return popped
def peek(self, i):
return self.data[-i - 1]
def __len__(self):
return len(self.data)
|
actor_name = input("Enter the actor's name: ")
initial_points = int(input("Enter the points form academy: "))
judges_count = int(input("Enter the number of jury: "))
points_needed = 1250.5
for jury in range(judges_count):
judges_name = input("Enter the name of jury: ")
points_from_judge = float(input("Enter the points from the jury: "))
initial_points += ((len(judges_name) * points_from_judge) / 2)
if initial_points > points_needed:
print(f"Congratulations, {actor_name} got a nominee for leading role with {initial_points:.1f}!")
break
if initial_points <= points_needed:
print(f"Sorry, {actor_name} you need {points_needed - initial_points:.1f} more!")
|
actor_name = input("Enter the actor's name: ")
initial_points = int(input('Enter the points form academy: '))
judges_count = int(input('Enter the number of jury: '))
points_needed = 1250.5
for jury in range(judges_count):
judges_name = input('Enter the name of jury: ')
points_from_judge = float(input('Enter the points from the jury: '))
initial_points += len(judges_name) * points_from_judge / 2
if initial_points > points_needed:
print(f'Congratulations, {actor_name} got a nominee for leading role with {initial_points:.1f}!')
break
if initial_points <= points_needed:
print(f'Sorry, {actor_name} you need {points_needed - initial_points:.1f} more!')
|
print("hello world")
a = 3
b = 4
c = a * b
print(c)
|
print('hello world')
a = 3
b = 4
c = a * b
print(c)
|
#################################################
### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ###
#################################################
def get_resize_target(img_sz, crop_target, do_crop=False):
if crop_target is None: return None
ch,r,c = img_sz
target_r,target_c = crop_target
ratio = (min if do_crop else max)(r/target_r, c/target_c)
return ch,round(r/ratio),round(c/ratio)
|
def get_resize_target(img_sz, crop_target, do_crop=False):
if crop_target is None:
return None
(ch, r, c) = img_sz
(target_r, target_c) = crop_target
ratio = (min if do_crop else max)(r / target_r, c / target_c)
return (ch, round(r / ratio), round(c / ratio))
|
# -*- coding: utf-8 -*-
"""
Created on August 26 20:16:44 2018
@author: ahmad
"""
"""
a program to encrypt and decrypt data in 8-bit XOR encryption using all
built-in functions. No libraries used. This program is for learning puposes
"""
def xor(x,y): #function to cypher text
g = []
for i in range(len(x)):
if x[i] == y[i]:
g.append(0)
elif x[i] != y[i]:
g.append(1)
return g
#x = [1,0,1,0,1,0,0,1] some key
#y = [1,1,1,1,1,0,1,1] values
cipher_string = []
asc_str = []
asc_list = [[]]
refined = ([[]])
cipher = []
cipher_input = input('Enter the string to cipher: ')
key_input = input('Enter 8bit key ex:10101101: ') #'01010101'
for ch in cipher_input:
cipher_string.append(ch)
num_of_char = len(cipher_string)
for i in range(num_of_char):
asc_str.append(('{0:08b}'.format(ord(cipher_string[i]))))
jr = 0
k = 0
for n in range(len(asc_str)):
refined.append([])
for object in asc_str[n]:
if(jr==8):
k += 1
jr = 0
refined[k].append(object)
jr += 1
#if(n == len(asc_str)-1):
# break
l = 0
for l in range(len(refined)):
asc_list.append([])
asc_list[l] = list(map(int, refined[l]))
key = list(map(int, key_input))
f=0
for f in range(len(asc_list)-2):
cipher.append(xor(asc_list[f], key))
cipher_text = []
cipher_str = ["".join((map(str, (cipher[i])))) for i in range(len(cipher))]
for i in range(len(cipher_str)):
cipher_text.append(chr(int(cipher_str[i],2)))
#decipher_1 = list(map(int, decipher))
cipher_text = "".join(cipher_text)
#print(cipher)
#print(cipher_str)
print('\nXOR encryption:',cipher_text)
with open('cypher.txt', 'w') as fout:
fout.write('\nXOR encryption: {0}'.format(cipher_text))
|
"""
Created on August 26 20:16:44 2018
@author: ahmad
"""
'\na program to encrypt and decrypt data in 8-bit XOR encryption using all\nbuilt-in functions. No libraries used. This program is for learning puposes\n'
def xor(x, y):
g = []
for i in range(len(x)):
if x[i] == y[i]:
g.append(0)
elif x[i] != y[i]:
g.append(1)
return g
cipher_string = []
asc_str = []
asc_list = [[]]
refined = [[]]
cipher = []
cipher_input = input('Enter the string to cipher: ')
key_input = input('Enter 8bit key ex:10101101: ')
for ch in cipher_input:
cipher_string.append(ch)
num_of_char = len(cipher_string)
for i in range(num_of_char):
asc_str.append('{0:08b}'.format(ord(cipher_string[i])))
jr = 0
k = 0
for n in range(len(asc_str)):
refined.append([])
for object in asc_str[n]:
if jr == 8:
k += 1
jr = 0
refined[k].append(object)
jr += 1
l = 0
for l in range(len(refined)):
asc_list.append([])
asc_list[l] = list(map(int, refined[l]))
key = list(map(int, key_input))
f = 0
for f in range(len(asc_list) - 2):
cipher.append(xor(asc_list[f], key))
cipher_text = []
cipher_str = [''.join(map(str, cipher[i])) for i in range(len(cipher))]
for i in range(len(cipher_str)):
cipher_text.append(chr(int(cipher_str[i], 2)))
cipher_text = ''.join(cipher_text)
print('\nXOR encryption:', cipher_text)
with open('cypher.txt', 'w') as fout:
fout.write('\nXOR encryption: {0}'.format(cipher_text))
|
def func3(a):
a/0;
def func2(a, b):
func3(a);
def func1(a, b, c):
func2(a, b);
if __name__ == "__main__":
func1(12, 0, 89)
|
def func3(a):
a / 0
def func2(a, b):
func3(a)
def func1(a, b, c):
func2(a, b)
if __name__ == '__main__':
func1(12, 0, 89)
|
def setup():
global pg
pg = createGraphics(1000, 1000)
noLoop()
def draw():
pg.beginDraw()
pg.colorMode(HSB, 360, 100, 100, 100)
pg.background(0, 0, 25)
pg.stroke(60, 7, 86, 100)
pg.noFill()
for i in range(100):
pg.ellipse(random(pg.width), random(pg.height), 100, 100)
pg.endDraw()
pg.save('image.png')
exit()
|
def setup():
global pg
pg = create_graphics(1000, 1000)
no_loop()
def draw():
pg.beginDraw()
pg.colorMode(HSB, 360, 100, 100, 100)
pg.background(0, 0, 25)
pg.stroke(60, 7, 86, 100)
pg.noFill()
for i in range(100):
pg.ellipse(random(pg.width), random(pg.height), 100, 100)
pg.endDraw()
pg.save('image.png')
exit()
|
"""
File: anagram.py
Name: Yujing Wei
----------------------------------
This program recursively finds all the anagram(s)
for the word input by user and terminates when the
input string matches the EXIT constant defined
at line 19
If you correctly implement this program, you should see the
number of anagrams for each word listed below:
* arm -> 3 anagrams
* contains -> 5 anagrams
* stop -> 6 anagrams
* tesla -> 10 anagrams
* spear -> 12 anagrams
"""
# Constants
FILE = 'dictionary.txt' # This is the filename of an English dictionary
EXIT = '-1' # Controls when to stop the loop
# Global variables
words = [] # A list to store words with target length in dictionary.txt.
d = {} # A dictionary to store target word's info -> [character: show-up time(s)].
def main():
global d, words # Call global variables.
print(f'Welcome to stanCode "Anagram Generator" (or {EXIT} to quit)') # Greeting.
while True: # While loop to find anagrams.
s = input('Find anagrams for: ').lower() # Process input word into lowercase, and assign it to 's'.
if s == EXIT: # If input == EXIT constant, break while loop.
break
print('Searching...') # Hint of searching.
read_dictionary(len(s)) # Get words with target length in FILE.
find_anagrams(s) # Function to get anagrams.
d = {} # Remove data in 'd{}' after every find_anagrams function.
words = [] # Remove data in 'words[]' after every find_anagrams function.
def read_dictionary(target_length):
with open(FILE, 'r') as f: # Open FILE and read it.
for word in f: # A line with a word in FILE.
if len(word.strip()) == target_length: # Get words with target length.
words.append(word.strip().lower()) # Append words to 'words' list.
def find_anagrams(s):
"""
:param s: str; Word, which user inputs, to get anagrams with same length and characters.
"""
for ch in s: # Record character and its times of show-up into 'd'({}).
if ch in d: # Count times of characters showing up in 's'.
d[ch] += 1
else:
d[ch] = 1
anagrams = find_anagrams_helper(s, '', []) # Get anagrams with find_anagrams_helper().
if len(anagrams) >= 1:
print(f'{len(anagrams)} anagrams: {anagrams}') # Print the result of anagrams.
else:
print(f'{s} is not in dictionary.')
def find_anagrams_helper(s, current_s, anagrams):
"""
:param s: str; user's input word.
:param current_s: str; '' empty str to place characters.
:param anagrams: list; [] empty list to place results of anagrams.
:return: list; anagrams, list with all of the results.
"""
if len(current_s) == len(s): # Base case: current_s with target length.
if current_s in words: # Check whether current_s in 'd'.
print(f'Found: {current_s}') # Print the result of anagram.
print('Searching...') # Hint of searching.
anagrams.append(current_s) # Append the result to list of 'anagrams'.
else:
for ch in d: # For characters in d, which show up in input 's'.
if d[ch] >= 1: # If the times character >= 1 (<=0 means no left),
# Choose
current_s += ch # Add ch to current_s.
d[ch] -= 1 # Times of character in 'd' -1.
# Explore
if has_prefix(current_s): # If there's prefix with current_s in 'words'.
find_anagrams_helper(s, current_s, anagrams) # Remove ch, which just added to current_s, from 's'.
# Un-choose
current_s = current_s[:len(current_s) - 1] # Remove ch from current_s.
d[ch] += 1 # Times of character in 'd' +1.
return anagrams # Return the list 'anagrams' with results of anagrams.
def has_prefix(sub_s):
"""
:param sub_s: str; test whether words in 'words' has prefix with it.
:return: True; if words in 'words' has prefix with 'sub_s'.
"""
for word in words: # Check words in 'words'.
if word.startswith(sub_s) is True: # If there's word starting with 'sub_s', return True.
return True
if __name__ == '__main__':
main()
|
"""
File: anagram.py
Name: Yujing Wei
----------------------------------
This program recursively finds all the anagram(s)
for the word input by user and terminates when the
input string matches the EXIT constant defined
at line 19
If you correctly implement this program, you should see the
number of anagrams for each word listed below:
* arm -> 3 anagrams
* contains -> 5 anagrams
* stop -> 6 anagrams
* tesla -> 10 anagrams
* spear -> 12 anagrams
"""
file = 'dictionary.txt'
exit = '-1'
words = []
d = {}
def main():
global d, words
print(f'Welcome to stanCode "Anagram Generator" (or {EXIT} to quit)')
while True:
s = input('Find anagrams for: ').lower()
if s == EXIT:
break
print('Searching...')
read_dictionary(len(s))
find_anagrams(s)
d = {}
words = []
def read_dictionary(target_length):
with open(FILE, 'r') as f:
for word in f:
if len(word.strip()) == target_length:
words.append(word.strip().lower())
def find_anagrams(s):
"""
:param s: str; Word, which user inputs, to get anagrams with same length and characters.
"""
for ch in s:
if ch in d:
d[ch] += 1
else:
d[ch] = 1
anagrams = find_anagrams_helper(s, '', [])
if len(anagrams) >= 1:
print(f'{len(anagrams)} anagrams: {anagrams}')
else:
print(f'{s} is not in dictionary.')
def find_anagrams_helper(s, current_s, anagrams):
"""
:param s: str; user's input word.
:param current_s: str; '' empty str to place characters.
:param anagrams: list; [] empty list to place results of anagrams.
:return: list; anagrams, list with all of the results.
"""
if len(current_s) == len(s):
if current_s in words:
print(f'Found: {current_s}')
print('Searching...')
anagrams.append(current_s)
else:
for ch in d:
if d[ch] >= 1:
current_s += ch
d[ch] -= 1
if has_prefix(current_s):
find_anagrams_helper(s, current_s, anagrams)
current_s = current_s[:len(current_s) - 1]
d[ch] += 1
return anagrams
def has_prefix(sub_s):
"""
:param sub_s: str; test whether words in 'words' has prefix with it.
:return: True; if words in 'words' has prefix with 'sub_s'.
"""
for word in words:
if word.startswith(sub_s) is True:
return True
if __name__ == '__main__':
main()
|
n=list(map(int,input("Enter the list").split(",")))
le=max(n)
while max(n)==le:
n.remove(max(n))
print(max(n))
|
n = list(map(int, input('Enter the list').split(',')))
le = max(n)
while max(n) == le:
n.remove(max(n))
print(max(n))
|
class Solution(object):
def arrayPairSum(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
return sum([c for i, c in enumerate(sorted(nums)) if i % 2 == 0])
|
class Solution(object):
def array_pair_sum(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
return sum([c for (i, c) in enumerate(sorted(nums)) if i % 2 == 0])
|
for i in range(int(input())):
text = input().replace('.', '')
countOpen = 0
countDiamonds = 0
for char in text:
if char == '<':
countOpen += 1
elif char == '>' and countOpen > 0:
countDiamonds += 1
countOpen -= 1
print(countDiamonds)
|
for i in range(int(input())):
text = input().replace('.', '')
count_open = 0
count_diamonds = 0
for char in text:
if char == '<':
count_open += 1
elif char == '>' and countOpen > 0:
count_diamonds += 1
count_open -= 1
print(countDiamonds)
|
def read_n_values(n):
print("Please enter", n, "values.")
values = []
for i in range(n):
values.append(input("Value {}: ".format(i + 1)))
return values
def compute_average(values):
# set sum to first value of list
total_sum = values[0]
# iterate over remaining values and add them up
for value in values[1:]:
total_sum += value
return float(total_sum) / len(values)
values = read_n_values(3)
print("Average:", compute_average(values))
|
def read_n_values(n):
print('Please enter', n, 'values.')
values = []
for i in range(n):
values.append(input('Value {}: '.format(i + 1)))
return values
def compute_average(values):
total_sum = values[0]
for value in values[1:]:
total_sum += value
return float(total_sum) / len(values)
values = read_n_values(3)
print('Average:', compute_average(values))
|
load("@rules_python//python:python.bzl", "py_binary", "py_library", "py_test")
def py3_library(*args, **kwargs):
py_library(
srcs_version = "PY3",
*args,
**kwargs
)
def py3_binary(name, main = None, *args, **kwargs):
if main == None:
main = "%s.py" % (name)
py_binary(
name = name,
main = main,
legacy_create_init = False,
python_version = "PY3",
*args,
**kwargs
)
def py3_test(*args, **kwargs):
py_test(
legacy_create_init = False,
python_version = "PY3",
srcs_version = "PY3",
*args,
**kwargs
)
|
load('@rules_python//python:python.bzl', 'py_binary', 'py_library', 'py_test')
def py3_library(*args, **kwargs):
py_library(*args, srcs_version='PY3', **kwargs)
def py3_binary(name, main=None, *args, **kwargs):
if main == None:
main = '%s.py' % name
py_binary(*args, name=name, main=main, legacy_create_init=False, python_version='PY3', **kwargs)
def py3_test(*args, **kwargs):
py_test(*args, legacy_create_init=False, python_version='PY3', srcs_version='PY3', **kwargs)
|
try:
test = int(input().strip())
while test!=0:
k,d0,d1 = map(int,input().strip().split())
d2 = (d1+d0)%10
if k == 2:
if (d1+d0)%3 == 0:
print("YES")
continue
else:
print("NO")
continue
elif k == 3:
if (d1+d2+d0)%3 == 0:
print("YES")
continue
else:
print("NO")
continue
else:
a = (2*(d1+d0))%10
b = (4*(d1+d0))%10
c = (8*(d1+d0))%10
d = (6*(d1+d0))%10
su = d1+d2+d0+((a+b+c+d)*((k-3)//4))
if (k-3)%4 == 1:
su += a
elif (k-3)%4 == 2:
su += a+b
elif (k-3)%4 == 3:
su += a+b+c
if su%3 == 0:
print("YES")
continue
else:
print("NO")
continue
test -=1
except:
pass
|
try:
test = int(input().strip())
while test != 0:
(k, d0, d1) = map(int, input().strip().split())
d2 = (d1 + d0) % 10
if k == 2:
if (d1 + d0) % 3 == 0:
print('YES')
continue
else:
print('NO')
continue
elif k == 3:
if (d1 + d2 + d0) % 3 == 0:
print('YES')
continue
else:
print('NO')
continue
else:
a = 2 * (d1 + d0) % 10
b = 4 * (d1 + d0) % 10
c = 8 * (d1 + d0) % 10
d = 6 * (d1 + d0) % 10
su = d1 + d2 + d0 + (a + b + c + d) * ((k - 3) // 4)
if (k - 3) % 4 == 1:
su += a
elif (k - 3) % 4 == 2:
su += a + b
elif (k - 3) % 4 == 3:
su += a + b + c
if su % 3 == 0:
print('YES')
continue
else:
print('NO')
continue
test -= 1
except:
pass
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.