content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# -*- python -*-
load(
"//tools/workspace/lcm:lcm.bzl",
"lcm_cc_library",
"lcm_java_library",
"lcm_py_library",
)
load(
"@drake//tools/skylark:drake_cc.bzl",
"drake_installed_headers",
"installed_headers_for_drake_deps",
)
def drake_lcm_cc_library(
name,
deps = [],
tags = [],
strip_include_prefix = None,
**kwargs):
"""A wrapper to insert Drake-specific customizations."""
# Drake's *.lcm files all live in our //drake/lcmtypes package. Per LCM
# upstream convention, the include directory for generated code should
# always look like "my_lcm_package/my_lcm_struct.h", but by default Bazel
# would provide "drake/lcmtypes/my_lcm_package/my_lcm_struct.h" as an
# allowed spelling. Here, we override that to enforce that Drake's include
# statements use the standard formulation. (We allow callers to override
# our enforcement though, such as for special-case testing.)
if strip_include_prefix == None:
strip_include_prefix = "/" + native.package_name()
detail = lcm_cc_library(
name = name,
deps = deps,
tags = tags + ["nolint"],
strip_include_prefix = strip_include_prefix,
**kwargs
)
drake_installed_headers(
name = name + ".installed_headers",
hdrs = detail.hdrs,
deps = installed_headers_for_drake_deps(deps),
tags = ["nolint"],
)
def drake_lcm_java_library(
name,
tags = [],
**kwargs):
"""A wrapper to insert Drake-specific customizations."""
lcm_java_library(
name = name,
tags = tags + ["nolint"],
**kwargs
)
def drake_lcm_py_library(
name,
tags = [],
**kwargs):
"""A wrapper to insert Drake-specific customizations."""
lcm_py_library(
name = name,
tags = tags + ["nolint"],
**kwargs
)
| load('//tools/workspace/lcm:lcm.bzl', 'lcm_cc_library', 'lcm_java_library', 'lcm_py_library')
load('@drake//tools/skylark:drake_cc.bzl', 'drake_installed_headers', 'installed_headers_for_drake_deps')
def drake_lcm_cc_library(name, deps=[], tags=[], strip_include_prefix=None, **kwargs):
"""A wrapper to insert Drake-specific customizations."""
if strip_include_prefix == None:
strip_include_prefix = '/' + native.package_name()
detail = lcm_cc_library(name=name, deps=deps, tags=tags + ['nolint'], strip_include_prefix=strip_include_prefix, **kwargs)
drake_installed_headers(name=name + '.installed_headers', hdrs=detail.hdrs, deps=installed_headers_for_drake_deps(deps), tags=['nolint'])
def drake_lcm_java_library(name, tags=[], **kwargs):
"""A wrapper to insert Drake-specific customizations."""
lcm_java_library(name=name, tags=tags + ['nolint'], **kwargs)
def drake_lcm_py_library(name, tags=[], **kwargs):
"""A wrapper to insert Drake-specific customizations."""
lcm_py_library(name=name, tags=tags + ['nolint'], **kwargs) |
# copybara:strip_for_google3_begin
def pyproto_test_wrapper(name):
src = name + "_wrapper.py"
native.py_test(
name = name,
srcs = [src],
legacy_create_init = False,
main = src,
data = ["@com_google_protobuf//:testdata"],
deps = [
"//python:message_ext",
"@com_google_protobuf//:python_common_test_protos",
"@com_google_protobuf//:python_specific_test_protos",
"@com_google_protobuf//:python_srcs",
],
)
# copybara:replace_for_google3_begin
#
# def pyproto_test_wrapper(name):
# src = name + "_wrapper.py"
# native.py_test(
# name = name,
# srcs = [src],
# main = src,
# deps = [
# "//net/proto2/python/internal:" + name + "_for_deps",
# "//net/proto2/python/public:use_upb_protos",
# ],
# )
#
# copybara:replace_for_google3_end
| def pyproto_test_wrapper(name):
src = name + '_wrapper.py'
native.py_test(name=name, srcs=[src], legacy_create_init=False, main=src, data=['@com_google_protobuf//:testdata'], deps=['//python:message_ext', '@com_google_protobuf//:python_common_test_protos', '@com_google_protobuf//:python_specific_test_protos', '@com_google_protobuf//:python_srcs']) |
class History:
def __init__(self):
self.HistoryVector = []
def Add(self, action, observation=-1, state=None):
self.HistoryVector.append(ENTRY(action, observation, state))
def GetVisitedStates(self):
states = []
if self.HistoryVector:
for history in self.HistoryVector:
if history.State:
states.append(history.State)
return states
def Pop(self):
self.HistoryVector = self.HistoryVector[:-1]
def Truncate(self, t):
self.HistoryVector = self.HistoryVector[:t]
def Clear(self):
self.HistoryVector[:] = []
def Forget(self, t):
self.HistoryVector = self.HistoryVector[t:]
def Size(self):
return len(self.HistoryVector)
def Back(self):
assert(self.Size() > 0)
return self.HistoryVector[-1]
def __eq__(self, other):
if(other.Size() != self.Size()):
return False
for i,history in enumerate(other):
if (history.Action != self.HistoryVector[i].Action) or \
(history.Observation != self.HistoryVector[i].Observation):
return False
return True
def __getitem__(self, t):
assert(t>=0 and t<self.Size())
return self.HistoryVector[t]
class ENTRY:
def __init__(self, action, observation, state):
self.Action = action
self.Observation = observation
self.State = state
def __str__(self):
return "(" + str(self.Action) + " , " + str(self.Observation) + ")"
if __name__ == "__main__":
entry = ENTRY(1, 1, None)
history = History()
history.Add(1, 1)
assert(history.Size() == 1)
history.Add(2, 2)
print(history)
assert(History().Add(1, 1) == History().Add(1, 1)) | class History:
def __init__(self):
self.HistoryVector = []
def add(self, action, observation=-1, state=None):
self.HistoryVector.append(entry(action, observation, state))
def get_visited_states(self):
states = []
if self.HistoryVector:
for history in self.HistoryVector:
if history.State:
states.append(history.State)
return states
def pop(self):
self.HistoryVector = self.HistoryVector[:-1]
def truncate(self, t):
self.HistoryVector = self.HistoryVector[:t]
def clear(self):
self.HistoryVector[:] = []
def forget(self, t):
self.HistoryVector = self.HistoryVector[t:]
def size(self):
return len(self.HistoryVector)
def back(self):
assert self.Size() > 0
return self.HistoryVector[-1]
def __eq__(self, other):
if other.Size() != self.Size():
return False
for (i, history) in enumerate(other):
if history.Action != self.HistoryVector[i].Action or history.Observation != self.HistoryVector[i].Observation:
return False
return True
def __getitem__(self, t):
assert t >= 0 and t < self.Size()
return self.HistoryVector[t]
class Entry:
def __init__(self, action, observation, state):
self.Action = action
self.Observation = observation
self.State = state
def __str__(self):
return '(' + str(self.Action) + ' , ' + str(self.Observation) + ')'
if __name__ == '__main__':
entry = entry(1, 1, None)
history = history()
history.Add(1, 1)
assert history.Size() == 1
history.Add(2, 2)
print(history)
assert history().Add(1, 1) == history().Add(1, 1) |
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# Given a 32-bit signed integer, reverse digits of an integer.
class Solution:
max32BitsNum = 1 << 31
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
if x > Solution.max32BitsNum - 1 or x < -Solution.max32BitsNum:
return 0
if x > -10 and x < 10:
return x
isNeg = False
if x < 0:
x = -x
isNeg = True
val = x % 10
x = x // 10
while x != 0:
val = val * 10 + x % 10
x = x // 10
val = val if val >= -Solution.max32BitsNum and val <= Solution.max32BitsNum - 1 else 0
return -val if isNeg else val
| class Solution:
max32_bits_num = 1 << 31
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
if x > Solution.max32BitsNum - 1 or x < -Solution.max32BitsNum:
return 0
if x > -10 and x < 10:
return x
is_neg = False
if x < 0:
x = -x
is_neg = True
val = x % 10
x = x // 10
while x != 0:
val = val * 10 + x % 10
x = x // 10
val = val if val >= -Solution.max32BitsNum and val <= Solution.max32BitsNum - 1 else 0
return -val if isNeg else val |
#
# Copyright 2018 Asylo authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Provides a function to look up a toolchain installation path."""
def _fail_if_directory_does_not_exist(repository_ctx, path, what):
result = repository_ctx.execute(["test", "-d", path])
if result.return_code == 0:
return path
fail("Install path to " + what + " does not exist: " + path)
def _try_get_file_line1(repository_ctx, path):
result = repository_ctx.execute(["cat", path])
if result.return_code == 0:
# First line of output with no \n:
return result.stdout.split("\n", 1)[0]
return None
def installation_path(repository_ctx, file, user_defined, default, what):
"""Looks up an installation location.
Args:
repository_ctx: A repository_rule context object.
file: The file that should contain the installation location.
user_defined: A path that user may provide to override lookup (may be None).
default: When both |file| and |user_defined| are unavailable, fall back on
this value (may be None).
what: A string for the failure message to indicate which component could not
retrieve its installation location.
Returns:
string: A path to a directory.
"""
result = ""
if user_defined:
result = user_defined
if not result:
result = _try_get_file_line1(
repository_ctx,
repository_ctx.os.environ["HOME"] +
"/.asylo/" + file,
)
if not result:
result = _try_get_file_line1(
repository_ctx,
"/usr/local/share/asylo/" + file,
)
if not result:
result = default
what = what + " [default]"
test_result = repository_ctx.execute(["test", "-d", result])
if test_result.return_code != 0:
result = "/opt/asylo/toolchains/sgx_x86_64"
what = what + " [INTERNAL TRANSITION]"
if not result:
fail("Unknown install location for " + what)
return _fail_if_directory_does_not_exist(repository_ctx, result, what)
| """Provides a function to look up a toolchain installation path."""
def _fail_if_directory_does_not_exist(repository_ctx, path, what):
result = repository_ctx.execute(['test', '-d', path])
if result.return_code == 0:
return path
fail('Install path to ' + what + ' does not exist: ' + path)
def _try_get_file_line1(repository_ctx, path):
result = repository_ctx.execute(['cat', path])
if result.return_code == 0:
return result.stdout.split('\n', 1)[0]
return None
def installation_path(repository_ctx, file, user_defined, default, what):
"""Looks up an installation location.
Args:
repository_ctx: A repository_rule context object.
file: The file that should contain the installation location.
user_defined: A path that user may provide to override lookup (may be None).
default: When both |file| and |user_defined| are unavailable, fall back on
this value (may be None).
what: A string for the failure message to indicate which component could not
retrieve its installation location.
Returns:
string: A path to a directory.
"""
result = ''
if user_defined:
result = user_defined
if not result:
result = _try_get_file_line1(repository_ctx, repository_ctx.os.environ['HOME'] + '/.asylo/' + file)
if not result:
result = _try_get_file_line1(repository_ctx, '/usr/local/share/asylo/' + file)
if not result:
result = default
what = what + ' [default]'
test_result = repository_ctx.execute(['test', '-d', result])
if test_result.return_code != 0:
result = '/opt/asylo/toolchains/sgx_x86_64'
what = what + ' [INTERNAL TRANSITION]'
if not result:
fail('Unknown install location for ' + what)
return _fail_if_directory_does_not_exist(repository_ctx, result, what) |
_FONT = {
32: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575],
33: [10, 1048575, 1048575, 1048575, 1048575, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1048575, 1048575, 1032447, 1032447, 1032447, 1048575, 1048575, 1048575, 1048575],
34: [10, 1048575, 1048575, 1048575, 1045455, 1045455, 1045455, 1045455, 1045455, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575],
35: [10, 1048575, 1048575, 1048575, 1048575, 986895, 986895, 986895, 786435, 786435, 986895, 986895, 986895, 786435, 786435, 986895, 986895, 1048575, 1048575, 1048575, 1048575],
36: [10, 1048575, 1048575, 1048575, 1044735, 1044735, 983103, 983043, 1048515, 1048515, 1044483, 983055, 787455, 802815, 802803, 786435, 1032207, 1044735, 1044735, 1048575, 1048575],
37: [10, 1048575, 1048575, 1048575, 1048575, 851907, 999228, 1036092, 1036092, 1045308, 1047747, 986367, 848703, 848847, 848847, 848883, 987132, 1048575, 1048575, 1048575, 1048575],
38: [10, 1048575, 1048575, 1048575, 1048575, 1032255, 983055, 986895, 986895, 1032255, 798735, 786639, 787395, 987075, 790275, 835587, 61455, 1048575, 1048575, 1048575, 1048575],
39: [10, 1048575, 1048575, 1048575, 1044735, 1044735, 1044735, 1044735, 1044735, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575],
40: [10, 1048575, 1048575, 1048575, 1048575, 987135, 1033215, 1044735, 1047615, 1047615, 1048335, 1048335, 1048335, 1048335, 1048335, 1047615, 1047615, 1044735, 984063, 987135, 1048575],
41: [10, 1048575, 1048575, 1048575, 1048575, 1048335, 1047567, 1044735, 1033215, 1033215, 987135, 987135, 987135, 987135, 987135, 1033215, 1033215, 1044735, 1047615, 1048335, 1048575],
42: [10, 1048575, 1048575, 1048575, 1048575, 1044735, 1044735, 798915, 786435, 1044735, 1032255, 986895, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575],
43: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1047807, 1047807, 1047807, 1047807, 983043, 1047807, 1047807, 1047807, 1047807, 1048575, 1048575, 1048575, 1048575],
44: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1032447, 1032447, 1032447, 1033215, 1044735, 1047615, 1048575],
45: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1032255, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575],
46: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1044543, 1044543, 1044543, 1048575, 1048575, 1048575, 1048575],
47: [10, 1048575, 1048575, 1048575, 999423, 1036287, 1036287, 1036287, 1045503, 1045503, 1045503, 1047807, 1047807, 1048383, 1048383, 1048383, 1048527, 1048527, 1048527, 1048563, 1048575],
48: [10, 1048575, 1048575, 1048575, 1048575, 1032255, 983055, 986895, 802755, 802755, 798915, 798915, 802755, 802755, 986895, 983055, 1032255, 1048575, 1048575, 1048575, 1048575],
49: [10, 1048575, 1048575, 1048575, 1048575, 1033215, 1032447, 1032207, 1033155, 1033215, 1033215, 1033215, 1033215, 1033215, 1033215, 786447, 786447, 1048575, 1048575, 1048575, 1048575],
50: [10, 1048575, 1048575, 1048575, 1048575, 1032207, 983043, 987123, 987135, 987135, 1033215, 1044735, 1047615, 1048335, 1048527, 983043, 983043, 1048575, 1048575, 1048575, 1048575],
51: [10, 1048575, 1048575, 1048575, 1048575, 1032207, 786435, 802767, 802815, 790527, 983103, 983103, 790527, 802815, 790515, 983043, 1032207, 1048575, 1048575, 1048575, 1048575],
52: [10, 1048575, 1048575, 1048575, 1048575, 987135, 984063, 983295, 986175, 986943, 986895, 987075, 786435, 786435, 987135, 987135, 987135, 1048575, 1048575, 1048575, 1048575],
53: [10, 1048575, 1048575, 1048575, 1048575, 786447, 786447, 1048335, 1048335, 1032207, 983055, 790527, 802815, 802815, 790515, 983043, 1032207, 1048575, 1048575, 1048575, 1048575],
54: [10, 1048575, 1048575, 1048575, 1048575, 984063, 983103, 1047567, 1048335, 1032195, 983043, 802755, 802755, 802755, 790275, 983055, 1032255, 1048575, 1048575, 1048575, 1048575],
55: [10, 1048575, 1048575, 1048575, 1048575, 786435, 786435, 802815, 987135, 1033215, 1033215, 1044735, 1044735, 1044735, 1047615, 1047615, 1047615, 1048575, 1048575, 1048575, 1048575],
56: [10, 1048575, 1048575, 1048575, 1048575, 1032255, 786447, 802755, 802755, 986883, 1032207, 983055, 790467, 802755, 802755, 983043, 1032255, 1048575, 1048575, 1048575, 1048575],
57: [10, 1048575, 1048575, 1048575, 1048575, 1032255, 983055, 790275, 802755, 802755, 802755, 786447, 786495, 987135, 984063, 1032207, 1047567, 1048575, 1048575, 1048575, 1048575],
58: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1044543, 1044543, 1044543, 1048575, 1048575, 1048575, 1044543, 1044543, 1044543, 1048575, 1048575, 1048575, 1048575],
59: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1044543, 1044543, 1044543, 1048575, 1048575, 1048575, 1032447, 1032447, 1032447, 1033215, 1044735, 1047615, 1048575],
60: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 802815, 984063, 1047567, 1048515, 1047567, 984063, 802815, 1048575, 1048575, 1048575, 1048575, 1048575],
61: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 786435, 1048575, 1048575, 786435, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575],
62: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048515, 1047567, 984063, 802815, 984063, 1047567, 1048515, 1048575, 1048575, 1048575, 1048575, 1048575],
63: [10, 1048575, 1048575, 1048575, 1048575, 1032207, 983043, 987123, 987135, 1033215, 1044735, 1047615, 1048575, 1048575, 1044543, 1044543, 1044543, 1048575, 1048575, 1048575, 1048575],
64: [10, 1048575, 1048575, 1048575, 1048575, 1032447, 983103, 790287, 802575, 802755, 787395, 786627, 798915, 798915, 786627, 787395, 1048335, 1047567, 983103, 983295, 1048575],
65: [10, 1048575, 1048575, 1048575, 1048575, 1044543, 1032975, 1032975, 1032975, 1032975, 986883, 987075, 987075, 983043, 983040, 802800, 802800, 1048575, 1048575, 1048575, 1048575],
66: [10, 1048575, 1048575, 1048575, 1048575, 1044483, 983043, 987075, 987075, 987075, 1044483, 983043, 802755, 802755, 790467, 983043, 1032195, 1048575, 1048575, 1048575, 1048575],
67: [10, 1048575, 1048575, 1048575, 1048575, 983295, 786495, 850959, 1048323, 1048515, 1048515, 1048515, 1048515, 1048323, 851727, 786447, 983295, 1048575, 1048575, 1048575, 1048575],
68: [10, 1048575, 1048575, 1048575, 1048575, 1044483, 983043, 987075, 802755, 802755, 802755, 802755, 802755, 802755, 987075, 983043, 1044483, 1048575, 1048575, 1048575, 1048575],
69: [10, 1048575, 1048575, 1048575, 1048575, 786447, 786447, 1048335, 1048335, 1048335, 983055, 983055, 1048335, 1048335, 1048335, 786447, 786447, 1048575, 1048575, 1048575, 1048575],
70: [10, 1048575, 1048575, 1048575, 1048575, 786447, 786447, 1048335, 1048335, 1048335, 983055, 983055, 1048335, 1048335, 1048335, 1048335, 1048335, 1048575, 1048575, 1048575, 1048575],
71: [10, 1048575, 1048575, 1048575, 1048575, 983295, 786495, 850959, 1048323, 1048515, 1048515, 802755, 802755, 802563, 802575, 786447, 786687, 1048575, 1048575, 1048575, 1048575],
72: [10, 1048575, 1048575, 1048575, 1048575, 802755, 802755, 802755, 802755, 802755, 786435, 786435, 802755, 802755, 802755, 802755, 802755, 1048575, 1048575, 1048575, 1048575],
73: [10, 1048575, 1048575, 1048575, 1048575, 983055, 983055, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 983055, 983055, 1048575, 1048575, 1048575, 1048575],
74: [10, 1048575, 1048575, 1048575, 1048575, 983055, 983055, 987135, 987135, 987135, 987135, 987135, 987135, 987135, 984051, 1032195, 1044495, 1048575, 1048575, 1048575, 1048575],
75: [10, 1048575, 1048575, 1048575, 1048575, 802755, 987075, 1033155, 1032387, 1044675, 1047555, 1044483, 1044675, 1033155, 987075, 987075, 802755, 1048575, 1048575, 1048575, 1048575],
76: [10, 1048575, 1048575, 1048575, 1048575, 1048335, 1048335, 1048335, 1048335, 1048335, 1048335, 1048335, 1048335, 1048335, 1048335, 786447, 786447, 1048575, 1048575, 1048575, 1048575],
77: [10, 1048575, 1048575, 1048575, 1048575, 986895, 986895, 986895, 789519, 798915, 798915, 798915, 798915, 802755, 802755, 802755, 802755, 1048575, 1048575, 1048575, 1048575],
78: [10, 1048575, 1048575, 1048575, 1048575, 802755, 802563, 802563, 801987, 801987, 799683, 799683, 799683, 790467, 790467, 802755, 802755, 1048575, 1048575, 1048575, 1048575],
79: [10, 1048575, 1048575, 1048575, 1048575, 1032255, 983055, 986895, 802755, 802755, 802755, 802755, 802755, 802755, 986895, 983055, 1032255, 1048575, 1048575, 1048575, 1048575],
80: [10, 1048575, 1048575, 1048575, 1048575, 1032195, 983043, 790467, 802755, 802755, 790467, 983043, 1032195, 1048515, 1048515, 1048515, 1048515, 1048575, 1048575, 1048575, 1048575],
81: [10, 1048575, 1048575, 1048575, 1048575, 1032255, 983055, 986895, 802755, 802755, 802755, 802755, 802755, 802755, 790275, 983055, 1032255, 1032447, 787455, 802815, 1048575],
82: [10, 1048575, 1048575, 1048575, 1048575, 1032195, 983043, 790467, 802755, 802755, 790467, 983043, 1032195, 987075, 987075, 802755, 65475, 1048575, 1048575, 1048575, 1048575],
83: [10, 1048575, 1048575, 1048575, 1048575, 983103, 786447, 851907, 1048515, 1048323, 1032207, 983103, 790527, 802815, 802803, 786435, 1032207, 1048575, 1048575, 1048575, 1048575],
84: [10, 1048575, 1048575, 1048575, 1048575, 786435, 786435, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1048575, 1048575, 1048575, 1048575],
85: [10, 1048575, 1048575, 1048575, 1048575, 802755, 802755, 802755, 802755, 802755, 802755, 802755, 802755, 802755, 790275, 983055, 1032255, 1048575, 1048575, 1048575, 1048575],
86: [10, 1048575, 1048575, 1048575, 1048575, 802800, 802800, 987075, 987075, 987075, 986883, 1032975, 1032975, 1032207, 1044543, 1044543, 1044543, 1048575, 1048575, 1048575, 1048575],
87: [10, 1048575, 1048575, 1048575, 1048575, 65520, 65520, 65520, 65520, 61680, 61680, 61680, 53040, 53040, 53040, 16320, 16320, 1048575, 1048575, 1048575, 1048575],
88: [10, 1048575, 1048575, 1048575, 1048575, 802800, 987075, 987075, 1032975, 1044543, 1044543, 1044543, 1032207, 1032975, 987075, 987075, 802800, 1048575, 1048575, 1048575, 1048575],
89: [10, 1048575, 1048575, 1048575, 1048575, 65520, 802755, 802755, 986895, 986895, 1032255, 1032255, 1044735, 1044735, 1044735, 1044735, 1044735, 1048575, 1048575, 1048575, 1048575],
90: [10, 1048575, 1048575, 1048575, 1048575, 786435, 786435, 790527, 987135, 1033215, 1044735, 1044543, 1047615, 1048335, 1048323, 786435, 786435, 1048575, 1048575, 1048575, 1048575],
91: [10, 1048575, 1048575, 1048575, 1048575, 1032255, 1048383, 1048383, 1048383, 1048383, 1048383, 1048383, 1048383, 1048383, 1048383, 1048383, 1048383, 1048383, 1048383, 1032255, 1048575],
92: [10, 1048575, 1048575, 1048575, 1048563, 1048527, 1048527, 1048527, 1048383, 1048383, 1048383, 1047807, 1047807, 1045503, 1045503, 1045503, 1036287, 1036287, 1036287, 999423, 1048575],
93: [10, 1048575, 1048575, 1048575, 1048575, 1032255, 1036287, 1036287, 1036287, 1036287, 1036287, 1036287, 1036287, 1036287, 1036287, 1036287, 1036287, 1036287, 1036287, 1032255, 1048575],
94: [10, 1048575, 1048575, 1048575, 1048575, 1047807, 1044543, 1045311, 1036239, 987075, 999411, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575],
95: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 786432, 1048575],
96: [10, 1048575, 1048575, 1048575, 1048383, 1047807, 1045503, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575],
97: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 983055, 786447, 802815, 786495, 802755, 802755, 802755, 786435, 786495, 1048575, 1048575, 1048575, 1048575],
98: [10, 1048575, 1048575, 1048575, 1048515, 1048515, 1048515, 1048515, 1032195, 983043, 790467, 802755, 802755, 802755, 790467, 983043, 1032195, 1048575, 1048575, 1048575, 1048575],
99: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 786687, 786447, 1048323, 1048515, 1048515, 1048515, 1048323, 786447, 786495, 1048575, 1048575, 1048575, 1048575],
100: [10, 1048575, 1048575, 1048575, 802815, 802815, 802815, 802815, 786495, 786447, 802563, 802755, 802755, 802755, 802563, 786447, 786495, 1048575, 1048575, 1048575, 1048575],
101: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1032255, 786447, 802755, 786435, 1048515, 1048515, 1048323, 983055, 983103, 1048575, 1048575, 1048575, 1048575],
102: [10, 1048575, 1048575, 1048575, 255, 63, 1047615, 1047615, 786435, 786435, 1047615, 1047615, 1047615, 1047615, 1047615, 1047615, 1047615, 1048575, 1048575, 1048575, 1048575],
103: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 786495, 786447, 802563, 802755, 802755, 802755, 802563, 786447, 786495, 802815, 983043, 1032195, 1048575],
104: [10, 1048575, 1048575, 1048575, 1048515, 1048515, 1048515, 1048515, 1032195, 983043, 790467, 802755, 802755, 802755, 802755, 802755, 802755, 1048575, 1048575, 1048575, 1048575],
105: [10, 1048575, 1048575, 1048575, 1048575, 1044735, 1044735, 1048575, 1044483, 1044483, 1044735, 1044735, 1044735, 1044735, 1044735, 786687, 787455, 1048575, 1048575, 1048575, 1048575],
106: [10, 1048575, 1048575, 1048575, 1048575, 1033215, 1033215, 1048575, 983055, 983055, 987135, 987135, 987135, 987135, 987135, 987135, 987135, 987135, 983043, 1032207, 1048575],
107: [10, 1048575, 1048575, 1048575, 1048515, 1048515, 1048515, 1048515, 790467, 984003, 1032387, 1044483, 1047555, 1044675, 1033155, 987075, 802755, 1048575, 1048575, 1048575, 1048575],
108: [10, 1048575, 1048575, 1048575, 1044483, 1044483, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 786687, 787455, 1048575, 1048575, 1048575, 1048575],
109: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 983043, 786435, 798915, 798915, 798915, 798915, 802755, 802755, 802755, 1048575, 1048575, 1048575, 1048575],
110: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1032195, 983043, 790467, 802755, 802755, 802755, 802755, 802755, 802755, 1048575, 1048575, 1048575, 1048575],
111: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1032255, 983055, 790275, 802755, 802755, 802755, 790275, 983055, 1032255, 1048575, 1048575, 1048575, 1048575],
112: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1032195, 983043, 790467, 802755, 802755, 802755, 790467, 983043, 1032195, 1048515, 1048515, 1048515, 1048575],
113: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 786495, 786447, 802563, 802755, 802755, 802755, 802563, 786447, 786495, 802815, 802815, 802815, 1048575],
114: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 786495, 786447, 1048335, 1048335, 1048335, 1048335, 1048335, 1048335, 1048335, 1048575, 1048575, 1048575, 1048575],
115: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 786495, 786435, 1048515, 1047555, 983055, 787455, 802803, 786435, 983055, 1048575, 1048575, 1048575, 1048575],
116: [10, 1048575, 1048575, 1048575, 1048575, 1047615, 1047615, 1047615, 786435, 786435, 1047615, 1047615, 1047615, 1047615, 1047615, 786495, 786687, 1048575, 1048575, 1048575, 1048575],
117: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 802755, 802755, 802755, 802755, 802755, 802755, 802563, 786447, 786495, 1048575, 1048575, 1048575, 1048575],
118: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 802755, 802755, 986895, 986895, 986895, 986895, 1032255, 1032255, 1032255, 1048575, 1048575, 1048575, 1048575],
119: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 802800, 802800, 802032, 802032, 998451, 983811, 983811, 983811, 987075, 1048575, 1048575, 1048575, 1048575],
120: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 802755, 986895, 1032255, 1032255, 1044735, 1032255, 1035327, 986895, 802755, 1048575, 1048575, 1048575, 1048575],
121: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 802755, 802755, 802575, 986895, 986895, 986175, 986175, 983103, 1032447, 1032447, 1044483, 1047555, 1048575],
122: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 983043, 983043, 1033215, 1044735, 1047615, 1048335, 1048335, 983043, 983043, 1048575, 1048575, 1048575, 1048575],
123: [10, 1048575, 1048575, 1048575, 787455, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1048335, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 787455, 1048575],
124: [10, 1048575, 1048575, 1048575, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1048575],
125: [10, 1048575, 1048575, 1048575, 1047555, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 987135, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1047555, 1048575],
126: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 850959, 786435, 984051, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575],
}
| _font = {32: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575], 33: [10, 1048575, 1048575, 1048575, 1048575, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1048575, 1048575, 1032447, 1032447, 1032447, 1048575, 1048575, 1048575, 1048575], 34: [10, 1048575, 1048575, 1048575, 1045455, 1045455, 1045455, 1045455, 1045455, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575], 35: [10, 1048575, 1048575, 1048575, 1048575, 986895, 986895, 986895, 786435, 786435, 986895, 986895, 986895, 786435, 786435, 986895, 986895, 1048575, 1048575, 1048575, 1048575], 36: [10, 1048575, 1048575, 1048575, 1044735, 1044735, 983103, 983043, 1048515, 1048515, 1044483, 983055, 787455, 802815, 802803, 786435, 1032207, 1044735, 1044735, 1048575, 1048575], 37: [10, 1048575, 1048575, 1048575, 1048575, 851907, 999228, 1036092, 1036092, 1045308, 1047747, 986367, 848703, 848847, 848847, 848883, 987132, 1048575, 1048575, 1048575, 1048575], 38: [10, 1048575, 1048575, 1048575, 1048575, 1032255, 983055, 986895, 986895, 1032255, 798735, 786639, 787395, 987075, 790275, 835587, 61455, 1048575, 1048575, 1048575, 1048575], 39: [10, 1048575, 1048575, 1048575, 1044735, 1044735, 1044735, 1044735, 1044735, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575], 40: [10, 1048575, 1048575, 1048575, 1048575, 987135, 1033215, 1044735, 1047615, 1047615, 1048335, 1048335, 1048335, 1048335, 1048335, 1047615, 1047615, 1044735, 984063, 987135, 1048575], 41: [10, 1048575, 1048575, 1048575, 1048575, 1048335, 1047567, 1044735, 1033215, 1033215, 987135, 987135, 987135, 987135, 987135, 1033215, 1033215, 1044735, 1047615, 1048335, 1048575], 42: [10, 1048575, 1048575, 1048575, 1048575, 1044735, 1044735, 798915, 786435, 1044735, 1032255, 986895, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575], 43: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1047807, 1047807, 1047807, 1047807, 983043, 1047807, 1047807, 1047807, 1047807, 1048575, 1048575, 1048575, 1048575], 44: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1032447, 1032447, 1032447, 1033215, 1044735, 1047615, 1048575], 45: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1032255, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575], 46: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1044543, 1044543, 1044543, 1048575, 1048575, 1048575, 1048575], 47: [10, 1048575, 1048575, 1048575, 999423, 1036287, 1036287, 1036287, 1045503, 1045503, 1045503, 1047807, 1047807, 1048383, 1048383, 1048383, 1048527, 1048527, 1048527, 1048563, 1048575], 48: [10, 1048575, 1048575, 1048575, 1048575, 1032255, 983055, 986895, 802755, 802755, 798915, 798915, 802755, 802755, 986895, 983055, 1032255, 1048575, 1048575, 1048575, 1048575], 49: [10, 1048575, 1048575, 1048575, 1048575, 1033215, 1032447, 1032207, 1033155, 1033215, 1033215, 1033215, 1033215, 1033215, 1033215, 786447, 786447, 1048575, 1048575, 1048575, 1048575], 50: [10, 1048575, 1048575, 1048575, 1048575, 1032207, 983043, 987123, 987135, 987135, 1033215, 1044735, 1047615, 1048335, 1048527, 983043, 983043, 1048575, 1048575, 1048575, 1048575], 51: [10, 1048575, 1048575, 1048575, 1048575, 1032207, 786435, 802767, 802815, 790527, 983103, 983103, 790527, 802815, 790515, 983043, 1032207, 1048575, 1048575, 1048575, 1048575], 52: [10, 1048575, 1048575, 1048575, 1048575, 987135, 984063, 983295, 986175, 986943, 986895, 987075, 786435, 786435, 987135, 987135, 987135, 1048575, 1048575, 1048575, 1048575], 53: [10, 1048575, 1048575, 1048575, 1048575, 786447, 786447, 1048335, 1048335, 1032207, 983055, 790527, 802815, 802815, 790515, 983043, 1032207, 1048575, 1048575, 1048575, 1048575], 54: [10, 1048575, 1048575, 1048575, 1048575, 984063, 983103, 1047567, 1048335, 1032195, 983043, 802755, 802755, 802755, 790275, 983055, 1032255, 1048575, 1048575, 1048575, 1048575], 55: [10, 1048575, 1048575, 1048575, 1048575, 786435, 786435, 802815, 987135, 1033215, 1033215, 1044735, 1044735, 1044735, 1047615, 1047615, 1047615, 1048575, 1048575, 1048575, 1048575], 56: [10, 1048575, 1048575, 1048575, 1048575, 1032255, 786447, 802755, 802755, 986883, 1032207, 983055, 790467, 802755, 802755, 983043, 1032255, 1048575, 1048575, 1048575, 1048575], 57: [10, 1048575, 1048575, 1048575, 1048575, 1032255, 983055, 790275, 802755, 802755, 802755, 786447, 786495, 987135, 984063, 1032207, 1047567, 1048575, 1048575, 1048575, 1048575], 58: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1044543, 1044543, 1044543, 1048575, 1048575, 1048575, 1044543, 1044543, 1044543, 1048575, 1048575, 1048575, 1048575], 59: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1044543, 1044543, 1044543, 1048575, 1048575, 1048575, 1032447, 1032447, 1032447, 1033215, 1044735, 1047615, 1048575], 60: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 802815, 984063, 1047567, 1048515, 1047567, 984063, 802815, 1048575, 1048575, 1048575, 1048575, 1048575], 61: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 786435, 1048575, 1048575, 786435, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575], 62: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048515, 1047567, 984063, 802815, 984063, 1047567, 1048515, 1048575, 1048575, 1048575, 1048575, 1048575], 63: [10, 1048575, 1048575, 1048575, 1048575, 1032207, 983043, 987123, 987135, 1033215, 1044735, 1047615, 1048575, 1048575, 1044543, 1044543, 1044543, 1048575, 1048575, 1048575, 1048575], 64: [10, 1048575, 1048575, 1048575, 1048575, 1032447, 983103, 790287, 802575, 802755, 787395, 786627, 798915, 798915, 786627, 787395, 1048335, 1047567, 983103, 983295, 1048575], 65: [10, 1048575, 1048575, 1048575, 1048575, 1044543, 1032975, 1032975, 1032975, 1032975, 986883, 987075, 987075, 983043, 983040, 802800, 802800, 1048575, 1048575, 1048575, 1048575], 66: [10, 1048575, 1048575, 1048575, 1048575, 1044483, 983043, 987075, 987075, 987075, 1044483, 983043, 802755, 802755, 790467, 983043, 1032195, 1048575, 1048575, 1048575, 1048575], 67: [10, 1048575, 1048575, 1048575, 1048575, 983295, 786495, 850959, 1048323, 1048515, 1048515, 1048515, 1048515, 1048323, 851727, 786447, 983295, 1048575, 1048575, 1048575, 1048575], 68: [10, 1048575, 1048575, 1048575, 1048575, 1044483, 983043, 987075, 802755, 802755, 802755, 802755, 802755, 802755, 987075, 983043, 1044483, 1048575, 1048575, 1048575, 1048575], 69: [10, 1048575, 1048575, 1048575, 1048575, 786447, 786447, 1048335, 1048335, 1048335, 983055, 983055, 1048335, 1048335, 1048335, 786447, 786447, 1048575, 1048575, 1048575, 1048575], 70: [10, 1048575, 1048575, 1048575, 1048575, 786447, 786447, 1048335, 1048335, 1048335, 983055, 983055, 1048335, 1048335, 1048335, 1048335, 1048335, 1048575, 1048575, 1048575, 1048575], 71: [10, 1048575, 1048575, 1048575, 1048575, 983295, 786495, 850959, 1048323, 1048515, 1048515, 802755, 802755, 802563, 802575, 786447, 786687, 1048575, 1048575, 1048575, 1048575], 72: [10, 1048575, 1048575, 1048575, 1048575, 802755, 802755, 802755, 802755, 802755, 786435, 786435, 802755, 802755, 802755, 802755, 802755, 1048575, 1048575, 1048575, 1048575], 73: [10, 1048575, 1048575, 1048575, 1048575, 983055, 983055, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 983055, 983055, 1048575, 1048575, 1048575, 1048575], 74: [10, 1048575, 1048575, 1048575, 1048575, 983055, 983055, 987135, 987135, 987135, 987135, 987135, 987135, 987135, 984051, 1032195, 1044495, 1048575, 1048575, 1048575, 1048575], 75: [10, 1048575, 1048575, 1048575, 1048575, 802755, 987075, 1033155, 1032387, 1044675, 1047555, 1044483, 1044675, 1033155, 987075, 987075, 802755, 1048575, 1048575, 1048575, 1048575], 76: [10, 1048575, 1048575, 1048575, 1048575, 1048335, 1048335, 1048335, 1048335, 1048335, 1048335, 1048335, 1048335, 1048335, 1048335, 786447, 786447, 1048575, 1048575, 1048575, 1048575], 77: [10, 1048575, 1048575, 1048575, 1048575, 986895, 986895, 986895, 789519, 798915, 798915, 798915, 798915, 802755, 802755, 802755, 802755, 1048575, 1048575, 1048575, 1048575], 78: [10, 1048575, 1048575, 1048575, 1048575, 802755, 802563, 802563, 801987, 801987, 799683, 799683, 799683, 790467, 790467, 802755, 802755, 1048575, 1048575, 1048575, 1048575], 79: [10, 1048575, 1048575, 1048575, 1048575, 1032255, 983055, 986895, 802755, 802755, 802755, 802755, 802755, 802755, 986895, 983055, 1032255, 1048575, 1048575, 1048575, 1048575], 80: [10, 1048575, 1048575, 1048575, 1048575, 1032195, 983043, 790467, 802755, 802755, 790467, 983043, 1032195, 1048515, 1048515, 1048515, 1048515, 1048575, 1048575, 1048575, 1048575], 81: [10, 1048575, 1048575, 1048575, 1048575, 1032255, 983055, 986895, 802755, 802755, 802755, 802755, 802755, 802755, 790275, 983055, 1032255, 1032447, 787455, 802815, 1048575], 82: [10, 1048575, 1048575, 1048575, 1048575, 1032195, 983043, 790467, 802755, 802755, 790467, 983043, 1032195, 987075, 987075, 802755, 65475, 1048575, 1048575, 1048575, 1048575], 83: [10, 1048575, 1048575, 1048575, 1048575, 983103, 786447, 851907, 1048515, 1048323, 1032207, 983103, 790527, 802815, 802803, 786435, 1032207, 1048575, 1048575, 1048575, 1048575], 84: [10, 1048575, 1048575, 1048575, 1048575, 786435, 786435, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1048575, 1048575, 1048575, 1048575], 85: [10, 1048575, 1048575, 1048575, 1048575, 802755, 802755, 802755, 802755, 802755, 802755, 802755, 802755, 802755, 790275, 983055, 1032255, 1048575, 1048575, 1048575, 1048575], 86: [10, 1048575, 1048575, 1048575, 1048575, 802800, 802800, 987075, 987075, 987075, 986883, 1032975, 1032975, 1032207, 1044543, 1044543, 1044543, 1048575, 1048575, 1048575, 1048575], 87: [10, 1048575, 1048575, 1048575, 1048575, 65520, 65520, 65520, 65520, 61680, 61680, 61680, 53040, 53040, 53040, 16320, 16320, 1048575, 1048575, 1048575, 1048575], 88: [10, 1048575, 1048575, 1048575, 1048575, 802800, 987075, 987075, 1032975, 1044543, 1044543, 1044543, 1032207, 1032975, 987075, 987075, 802800, 1048575, 1048575, 1048575, 1048575], 89: [10, 1048575, 1048575, 1048575, 1048575, 65520, 802755, 802755, 986895, 986895, 1032255, 1032255, 1044735, 1044735, 1044735, 1044735, 1044735, 1048575, 1048575, 1048575, 1048575], 90: [10, 1048575, 1048575, 1048575, 1048575, 786435, 786435, 790527, 987135, 1033215, 1044735, 1044543, 1047615, 1048335, 1048323, 786435, 786435, 1048575, 1048575, 1048575, 1048575], 91: [10, 1048575, 1048575, 1048575, 1048575, 1032255, 1048383, 1048383, 1048383, 1048383, 1048383, 1048383, 1048383, 1048383, 1048383, 1048383, 1048383, 1048383, 1048383, 1032255, 1048575], 92: [10, 1048575, 1048575, 1048575, 1048563, 1048527, 1048527, 1048527, 1048383, 1048383, 1048383, 1047807, 1047807, 1045503, 1045503, 1045503, 1036287, 1036287, 1036287, 999423, 1048575], 93: [10, 1048575, 1048575, 1048575, 1048575, 1032255, 1036287, 1036287, 1036287, 1036287, 1036287, 1036287, 1036287, 1036287, 1036287, 1036287, 1036287, 1036287, 1036287, 1032255, 1048575], 94: [10, 1048575, 1048575, 1048575, 1048575, 1047807, 1044543, 1045311, 1036239, 987075, 999411, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575], 95: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 786432, 1048575], 96: [10, 1048575, 1048575, 1048575, 1048383, 1047807, 1045503, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575], 97: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 983055, 786447, 802815, 786495, 802755, 802755, 802755, 786435, 786495, 1048575, 1048575, 1048575, 1048575], 98: [10, 1048575, 1048575, 1048575, 1048515, 1048515, 1048515, 1048515, 1032195, 983043, 790467, 802755, 802755, 802755, 790467, 983043, 1032195, 1048575, 1048575, 1048575, 1048575], 99: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 786687, 786447, 1048323, 1048515, 1048515, 1048515, 1048323, 786447, 786495, 1048575, 1048575, 1048575, 1048575], 100: [10, 1048575, 1048575, 1048575, 802815, 802815, 802815, 802815, 786495, 786447, 802563, 802755, 802755, 802755, 802563, 786447, 786495, 1048575, 1048575, 1048575, 1048575], 101: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1032255, 786447, 802755, 786435, 1048515, 1048515, 1048323, 983055, 983103, 1048575, 1048575, 1048575, 1048575], 102: [10, 1048575, 1048575, 1048575, 255, 63, 1047615, 1047615, 786435, 786435, 1047615, 1047615, 1047615, 1047615, 1047615, 1047615, 1047615, 1048575, 1048575, 1048575, 1048575], 103: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 786495, 786447, 802563, 802755, 802755, 802755, 802563, 786447, 786495, 802815, 983043, 1032195, 1048575], 104: [10, 1048575, 1048575, 1048575, 1048515, 1048515, 1048515, 1048515, 1032195, 983043, 790467, 802755, 802755, 802755, 802755, 802755, 802755, 1048575, 1048575, 1048575, 1048575], 105: [10, 1048575, 1048575, 1048575, 1048575, 1044735, 1044735, 1048575, 1044483, 1044483, 1044735, 1044735, 1044735, 1044735, 1044735, 786687, 787455, 1048575, 1048575, 1048575, 1048575], 106: [10, 1048575, 1048575, 1048575, 1048575, 1033215, 1033215, 1048575, 983055, 983055, 987135, 987135, 987135, 987135, 987135, 987135, 987135, 987135, 983043, 1032207, 1048575], 107: [10, 1048575, 1048575, 1048575, 1048515, 1048515, 1048515, 1048515, 790467, 984003, 1032387, 1044483, 1047555, 1044675, 1033155, 987075, 802755, 1048575, 1048575, 1048575, 1048575], 108: [10, 1048575, 1048575, 1048575, 1044483, 1044483, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 786687, 787455, 1048575, 1048575, 1048575, 1048575], 109: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 983043, 786435, 798915, 798915, 798915, 798915, 802755, 802755, 802755, 1048575, 1048575, 1048575, 1048575], 110: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1032195, 983043, 790467, 802755, 802755, 802755, 802755, 802755, 802755, 1048575, 1048575, 1048575, 1048575], 111: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1032255, 983055, 790275, 802755, 802755, 802755, 790275, 983055, 1032255, 1048575, 1048575, 1048575, 1048575], 112: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1032195, 983043, 790467, 802755, 802755, 802755, 790467, 983043, 1032195, 1048515, 1048515, 1048515, 1048575], 113: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 786495, 786447, 802563, 802755, 802755, 802755, 802563, 786447, 786495, 802815, 802815, 802815, 1048575], 114: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 786495, 786447, 1048335, 1048335, 1048335, 1048335, 1048335, 1048335, 1048335, 1048575, 1048575, 1048575, 1048575], 115: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 786495, 786435, 1048515, 1047555, 983055, 787455, 802803, 786435, 983055, 1048575, 1048575, 1048575, 1048575], 116: [10, 1048575, 1048575, 1048575, 1048575, 1047615, 1047615, 1047615, 786435, 786435, 1047615, 1047615, 1047615, 1047615, 1047615, 786495, 786687, 1048575, 1048575, 1048575, 1048575], 117: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 802755, 802755, 802755, 802755, 802755, 802755, 802563, 786447, 786495, 1048575, 1048575, 1048575, 1048575], 118: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 802755, 802755, 986895, 986895, 986895, 986895, 1032255, 1032255, 1032255, 1048575, 1048575, 1048575, 1048575], 119: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 802800, 802800, 802032, 802032, 998451, 983811, 983811, 983811, 987075, 1048575, 1048575, 1048575, 1048575], 120: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 802755, 986895, 1032255, 1032255, 1044735, 1032255, 1035327, 986895, 802755, 1048575, 1048575, 1048575, 1048575], 121: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 802755, 802755, 802575, 986895, 986895, 986175, 986175, 983103, 1032447, 1032447, 1044483, 1047555, 1048575], 122: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 983043, 983043, 1033215, 1044735, 1047615, 1048335, 1048335, 983043, 983043, 1048575, 1048575, 1048575, 1048575], 123: [10, 1048575, 1048575, 1048575, 787455, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1048335, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 787455, 1048575], 124: [10, 1048575, 1048575, 1048575, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1048575], 125: [10, 1048575, 1048575, 1048575, 1047555, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 987135, 1044735, 1044735, 1044735, 1044735, 1044735, 1044735, 1047555, 1048575], 126: [10, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 850959, 786435, 984051, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575]} |
"""
335 / 335 test cases passed.
Status: Accepted
Runtime: 40 ms
"""
class Solution:
def checkPossibility(self, nums: List[int]) -> bool:
cnt = 0
for i in range(1, len(nums)):
if nums[i - 1] > nums[i]:
cnt += 1
if cnt > 1:
return False
if i - 2 >= 0 and nums[i - 2] > nums[i]:
nums[i] = nums[i - 1]
else:
nums[i - 1] = nums[i]
return True
| """
335 / 335 test cases passed.
Status: Accepted
Runtime: 40 ms
"""
class Solution:
def check_possibility(self, nums: List[int]) -> bool:
cnt = 0
for i in range(1, len(nums)):
if nums[i - 1] > nums[i]:
cnt += 1
if cnt > 1:
return False
if i - 2 >= 0 and nums[i - 2] > nums[i]:
nums[i] = nums[i - 1]
else:
nums[i - 1] = nums[i]
return True |
# Problem: Implement a 3 stack
# Algorithm for n-stacks using dynamic arrays (list)
# Stack: LIFO (Last In First Out)
# pop from top and push to top
# data = our dynamic array
# Maintain tops array for n-number of stacks and initialize to -1
# Maintain lengths for each stack.
# Push(stack, value)
# Check if stack is empty if yes append to data and tops=len(data)-1
# Increment lengths by 1
# Insert at top
# Increment tops for all stacks which are next in sequence
# Pop(stack)
# Check if stack is empty if yes return -999
# Decrement length by 1
# Delete at top
# Increment tops for all stacks which are next in sequence
class NStack:
def __init__(self, n=3):
self.data = []
self.tops = []
self.lengths = []
# Initialize tops and lengths
for i in range(n):
self.tops.append(-1)
self.lengths.append(0)
def push(self, stack, value):
# Case for stack is empty
if self.tops[stack] == -1:
self.data.append(value)
self.tops[stack] = len(self.data)-1
else:
self.data.insert(self.tops[stack], value)
# Increment tops for all stacks which are next in sequence
for i in range(len(self.tops)):
if i != stack and self.tops[i] != -1 and self.tops[i] > self.tops[stack]:
self.tops[i] += 1
self.lengths[stack] += 1
def pop(self, stack):
# Check if stack is empty
if self.tops[stack] == -1:
return -9999
else:
# save the value to return
value = self.data[self.tops[stack]]
# Delete element at tops of given stack
del self.data[self.tops[stack]]
self.lengths[stack] += -1
# Rearrange my indeces in top
# Stack had only one item
if self.lengths[stack] == 0:
self.tops[stack] = -1
# Decrement tops of all stacks which are next in sequence
for i in range(len(self.tops)):
if i != stack and self.tops[i] > self.tops[stack]:
self.tops[i] -= 1
return value
def print_nstack(self):
print("Data", self.data, "Lengths", self.lengths, "Top Indices", self.tops)
for i in range(len(self.tops)):
print("Stack:", i, "-->", self.data[self.tops[i]:self.tops[i]+self.lengths[i]])
def main():
nstack = NStack(3)
nstack.print_nstack()
nstack.push(0, 10)
nstack.print_nstack()
nstack.push(1, 10)
nstack.print_nstack()
nstack.push(1, 20)
nstack.print_nstack()
nstack.push(2, 30)
nstack.push(2, 40)
nstack.push(2, 30)
nstack.push(2, 40)
nstack.print_nstack()
print(nstack.pop(0))
nstack.print_nstack()
print(nstack.pop(2))
nstack.print_nstack()
print(nstack.pop(2))
nstack.print_nstack()
print(nstack.pop(0))
nstack.print_nstack()
print(nstack.pop(1))
nstack.print_nstack()
print(nstack.pop(1))
nstack.print_nstack()
print(nstack.pop(1))
nstack.print_nstack()
print(nstack.push(1,90))
nstack.print_nstack()
if __name__=='__main__':
main()
| class Nstack:
def __init__(self, n=3):
self.data = []
self.tops = []
self.lengths = []
for i in range(n):
self.tops.append(-1)
self.lengths.append(0)
def push(self, stack, value):
if self.tops[stack] == -1:
self.data.append(value)
self.tops[stack] = len(self.data) - 1
else:
self.data.insert(self.tops[stack], value)
for i in range(len(self.tops)):
if i != stack and self.tops[i] != -1 and (self.tops[i] > self.tops[stack]):
self.tops[i] += 1
self.lengths[stack] += 1
def pop(self, stack):
if self.tops[stack] == -1:
return -9999
else:
value = self.data[self.tops[stack]]
del self.data[self.tops[stack]]
self.lengths[stack] += -1
if self.lengths[stack] == 0:
self.tops[stack] = -1
for i in range(len(self.tops)):
if i != stack and self.tops[i] > self.tops[stack]:
self.tops[i] -= 1
return value
def print_nstack(self):
print('Data', self.data, 'Lengths', self.lengths, 'Top Indices', self.tops)
for i in range(len(self.tops)):
print('Stack:', i, '-->', self.data[self.tops[i]:self.tops[i] + self.lengths[i]])
def main():
nstack = n_stack(3)
nstack.print_nstack()
nstack.push(0, 10)
nstack.print_nstack()
nstack.push(1, 10)
nstack.print_nstack()
nstack.push(1, 20)
nstack.print_nstack()
nstack.push(2, 30)
nstack.push(2, 40)
nstack.push(2, 30)
nstack.push(2, 40)
nstack.print_nstack()
print(nstack.pop(0))
nstack.print_nstack()
print(nstack.pop(2))
nstack.print_nstack()
print(nstack.pop(2))
nstack.print_nstack()
print(nstack.pop(0))
nstack.print_nstack()
print(nstack.pop(1))
nstack.print_nstack()
print(nstack.pop(1))
nstack.print_nstack()
print(nstack.pop(1))
nstack.print_nstack()
print(nstack.push(1, 90))
nstack.print_nstack()
if __name__ == '__main__':
main() |
#User gives input and loop continues until user keeps entering even numbers
Evennumber=0;
while(Evennumber%2==0):
print("Let me check if the entered number is even or not");
Evennumber=int(input());
if(Evennumber%2==0):
print("Number enter is even");
if(Evennumber%2!=0):
print("You have not entered the Even number");
#If the entered number is not Even the loop doesn't continue and breaks
continue;
| evennumber = 0
while Evennumber % 2 == 0:
print('Let me check if the entered number is even or not')
evennumber = int(input())
if Evennumber % 2 == 0:
print('Number enter is even')
if Evennumber % 2 != 0:
print('You have not entered the Even number')
continue |
arquivo = open('exemplo.txt', 'r', encoding='utf8')
for linha in arquivo:
print(linha.strip())
arquivo.close()
| arquivo = open('exemplo.txt', 'r', encoding='utf8')
for linha in arquivo:
print(linha.strip())
arquivo.close() |
def bonAppetit(bill, k, b):
rest = b - int((sum(bill) - bill[k]) / 2)
if rest != 0:
print(rest)
else:
print('Bon Appetit')
return | def bon_appetit(bill, k, b):
rest = b - int((sum(bill) - bill[k]) / 2)
if rest != 0:
print(rest)
else:
print('Bon Appetit')
return |
"""Setup constants, ymmv."""
PIN_MEMORY = True
NON_BLOCKING = True
BENCHMARK = True
MAX_THREADING = 40
SHARING_STRATEGY = 'file_descriptor' # file_system or file_descriptor
DEBUG_TRAINING = False
DISTRIBUTED_BACKEND = 'gloo' # nccl would be faster, but require gpu-transfers for indexing and stuff
cifar10_mean = [0.4914672374725342, 0.4822617471218109, 0.4467701315879822]
cifar10_std = [0.24703224003314972, 0.24348513782024384, 0.26158785820007324]
cifar100_mean = [0.5071598291397095, 0.4866936206817627, 0.44120192527770996]
cifar100_std = [0.2673342823982239, 0.2564384639263153, 0.2761504650115967]
mnist_mean = (0.13066373765468597,)
mnist_std = (0.30810782313346863,)
imagenet_mean = [0.485, 0.456, 0.406]
imagenet_std = [0.229, 0.224, 0.225]
tiny_imagenet_mean = [0.4789886474609375, 0.4457630515098572, 0.3944724500179291]
tiny_imagenet_std = [0.27698642015457153, 0.2690644860267639, 0.2820819020271301]
| """Setup constants, ymmv."""
pin_memory = True
non_blocking = True
benchmark = True
max_threading = 40
sharing_strategy = 'file_descriptor'
debug_training = False
distributed_backend = 'gloo'
cifar10_mean = [0.4914672374725342, 0.4822617471218109, 0.4467701315879822]
cifar10_std = [0.24703224003314972, 0.24348513782024384, 0.26158785820007324]
cifar100_mean = [0.5071598291397095, 0.4866936206817627, 0.44120192527770996]
cifar100_std = [0.2673342823982239, 0.2564384639263153, 0.2761504650115967]
mnist_mean = (0.13066373765468597,)
mnist_std = (0.30810782313346863,)
imagenet_mean = [0.485, 0.456, 0.406]
imagenet_std = [0.229, 0.224, 0.225]
tiny_imagenet_mean = [0.4789886474609375, 0.4457630515098572, 0.3944724500179291]
tiny_imagenet_std = [0.27698642015457153, 0.2690644860267639, 0.2820819020271301] |
"""Provide exceptions to be raised by the `dynamic_models` app.
All exceptions inherit from a `DynamicModelError` base class.
"""
class DynamicModelError(Exception):
"""Base exception for use in dynamic models."""
class OutdatedModelError(DynamicModelError):
"""Raised when a model's schema is outdated on save."""
class NullFieldChangedError(DynamicModelError):
"""Raised when a field is attempted to be change from NULL to NOT NULL."""
class InvalidFieldNameError(DynamicModelError):
"""Raised when a field name is invalid."""
class UnsavedSchemaError(DynamicModelError):
"""
Raised when a model schema has not been saved to the db and a dynamic model
is attempted to be created.
"""
| """Provide exceptions to be raised by the `dynamic_models` app.
All exceptions inherit from a `DynamicModelError` base class.
"""
class Dynamicmodelerror(Exception):
"""Base exception for use in dynamic models."""
class Outdatedmodelerror(DynamicModelError):
"""Raised when a model's schema is outdated on save."""
class Nullfieldchangederror(DynamicModelError):
"""Raised when a field is attempted to be change from NULL to NOT NULL."""
class Invalidfieldnameerror(DynamicModelError):
"""Raised when a field name is invalid."""
class Unsavedschemaerror(DynamicModelError):
"""
Raised when a model schema has not been saved to the db and a dynamic model
is attempted to be created.
""" |
prices = {}
quantities = {}
while True:
tokens = input()
if tokens == 'buy':
break
else:
tokens = tokens.split(" ")
product = tokens[0]
price = float(tokens[1])
quantity = int(tokens[2])
prices[product] = price
if product not in quantities:
quantities[product] = quantity
else:
quantities[product] += quantity
for keys in quantities.keys():
result = quantities[keys] * prices[keys]
print(f'{keys} -> {result:.2f}')
| prices = {}
quantities = {}
while True:
tokens = input()
if tokens == 'buy':
break
else:
tokens = tokens.split(' ')
product = tokens[0]
price = float(tokens[1])
quantity = int(tokens[2])
prices[product] = price
if product not in quantities:
quantities[product] = quantity
else:
quantities[product] += quantity
for keys in quantities.keys():
result = quantities[keys] * prices[keys]
print(f'{keys} -> {result:.2f}') |
def addFriendship(d, u1, u2):
if u1 not in d:
d[u1] = [u2]
else:
x = d[u1]
x.append(u2)
d[u1] = x
inFile = open("friendship.txt", "r")
d = {}
for line in inFile:
infos = line.split("\t")
user1 = int(infos[0])
user2 = int(infos[1].replace("\n", ""))
addFriendship(d, user1, user2)
addFriendship(d, user2, user1)
user = int(input("Enter a user id to suggest some friends: "))
if user not in d:
print("There is no such user")
else:
friendDict = {}
friends = d[user]
for friend in friends:
friendsOfFriend = d[friend]
for f in friendsOfFriend:
if f != user and f not in friends:
if f not in friendDict:
friendDict[f] = 1
else:
friendDict[f] = friendDict[f] + 1
#print(friendDict)
if len(friendDict) > 0:
maxVal = max(friendDict.values())
result = []
for k,v in friendDict.items():
if v == maxVal:
result.append(k)
#print(result)
printingResult = ""
while(len(result) > 0):
minElement = min(result)
printingResult = printingResult + str(minElement) + ", "
result.remove(minElement)
print(printingResult[:-2])
else:
print("There is no friend to suggest")
inFile.close()
| def add_friendship(d, u1, u2):
if u1 not in d:
d[u1] = [u2]
else:
x = d[u1]
x.append(u2)
d[u1] = x
in_file = open('friendship.txt', 'r')
d = {}
for line in inFile:
infos = line.split('\t')
user1 = int(infos[0])
user2 = int(infos[1].replace('\n', ''))
add_friendship(d, user1, user2)
add_friendship(d, user2, user1)
user = int(input('Enter a user id to suggest some friends: '))
if user not in d:
print('There is no such user')
else:
friend_dict = {}
friends = d[user]
for friend in friends:
friends_of_friend = d[friend]
for f in friendsOfFriend:
if f != user and f not in friends:
if f not in friendDict:
friendDict[f] = 1
else:
friendDict[f] = friendDict[f] + 1
if len(friendDict) > 0:
max_val = max(friendDict.values())
result = []
for (k, v) in friendDict.items():
if v == maxVal:
result.append(k)
printing_result = ''
while len(result) > 0:
min_element = min(result)
printing_result = printingResult + str(minElement) + ', '
result.remove(minElement)
print(printingResult[:-2])
else:
print('There is no friend to suggest')
inFile.close() |
#Make a menu driven program to accept, delete and display the following data stored in a dictionary.
#Book_Id.........string
#Book_Name.... string
#Price......float
#Discount...int
#The program should continue as long as the user wishes to. At one point of time, I should be able to view minimum 3 records.
class Product:
def GetProduct(self):
self.book_id = input("Enter book ID: ")
self.name_of_book = input("Enter Name : ")
global price_of_books
price_of_books = int(input("Enter book Price of books : "))
disc=0
if price_of_books >=500:
disc=100
else:
disc=0
def PutProduct(self):
print('ID:',self.book_id,'NAME:', self.name_of_book,'COST:', price_of_books,)
def SearchById(self, id):
if self.book_id == id:
return True
else:
return False
def SearchByName(self, name):
if self.name_of_book == name:
return True
else:
return False
def Purchase(self):
print("Purchase....")
q = int(input("enter quantity of particular book you want to purchase:"))
n = int(input("Enter Total products?"))
L = []
for i in range(n):
P = Product()
P.GetProduct()
L.append(P)
while True:
print("Main Menu\n1]Show All book\n2]Search By Id\n3]Search By Name\n4") | class Product:
def get_product(self):
self.book_id = input('Enter book ID: ')
self.name_of_book = input('Enter Name : ')
global price_of_books
price_of_books = int(input('Enter book Price of books : '))
disc = 0
if price_of_books >= 500:
disc = 100
else:
disc = 0
def put_product(self):
print('ID:', self.book_id, 'NAME:', self.name_of_book, 'COST:', price_of_books)
def search_by_id(self, id):
if self.book_id == id:
return True
else:
return False
def search_by_name(self, name):
if self.name_of_book == name:
return True
else:
return False
def purchase(self):
print('Purchase....')
q = int(input('enter quantity of particular book you want to purchase:'))
n = int(input('Enter Total products?'))
l = []
for i in range(n):
p = product()
P.GetProduct()
L.append(P)
while True:
print('Main Menu\n1]Show All book\n2]Search By Id\n3]Search By Name\n4') |
"""
Module: 'usocket' on esp8266 v1.11
"""
# MCU: (sysname='esp8266', nodename='esp8266', release='2.2.0-dev(9422289)', version='v1.11-8-g48dcbbe60 on 2019-05-29', machine='ESP module with ESP8266')
# Stubber: 1.1.0
AF_INET = 2
AF_INET6 = 10
IPPROTO_IP = 0
IP_ADD_MEMBERSHIP = 1024
SOCK_DGRAM = 2
SOCK_RAW = 3
SOCK_STREAM = 1
SOL_SOCKET = 1
SO_REUSEADDR = 4
def callback():
pass
def getaddrinfo():
pass
def print_pcbs():
pass
def reset():
pass
class socket:
''
def accept():
pass
def bind():
pass
def close():
pass
def connect():
pass
| """
Module: 'usocket' on esp8266 v1.11
"""
af_inet = 2
af_inet6 = 10
ipproto_ip = 0
ip_add_membership = 1024
sock_dgram = 2
sock_raw = 3
sock_stream = 1
sol_socket = 1
so_reuseaddr = 4
def callback():
pass
def getaddrinfo():
pass
def print_pcbs():
pass
def reset():
pass
class Socket:
""""""
def accept():
pass
def bind():
pass
def close():
pass
def connect():
pass |
# N digit numbers with digit sum S
# https://www.interviewbit.com/problems/n-digit-numbers-with-digit-sum-s-/
#
# Find out the number of N digit numbers, whose digits on being added equals to a given number S.
# Note that a valid number starts from digits 1-9 except the number 0 itself. i.e. leading
# zeroes are not allowed.
#
# Since the answer can be large, output answer modulo 1000000007
#
# **
# N = 2, S = 4
# Valid numbers are {22, 31, 13, 40}
# Hence output 4.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
class Solution:
# @param A : integer
# @param B : integer
# @return an integer
def solve(self, N, S):
arr = [[0] * (S + 1) for _ in range(N + 1)]
arr[0][0] = 1
for n in range(N):
for s in range(S):
for digit in range(10):
if s + digit <= S:
arr[n + 1][s + digit] += arr[n][s]
else:
break
return arr[N][S] % 1000000007
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | class Solution:
def solve(self, N, S):
arr = [[0] * (S + 1) for _ in range(N + 1)]
arr[0][0] = 1
for n in range(N):
for s in range(S):
for digit in range(10):
if s + digit <= S:
arr[n + 1][s + digit] += arr[n][s]
else:
break
return arr[N][S] % 1000000007 |
# -*- coding: utf-8 -*-
def print_logo():
"""
___ __ __ _ __
/ _ \___ ___/ / / / (_)__ / /_
/ , _/ -_) _ / / /__/ (_-</ __/
/_/|_|\__/\_,_/ /____/_/___/\__/
by Team Avengers
MIT LICENSE
"""
print(" ___ __ __ _ __ \n / _ \___ ___/ / / / (_)__ / /_\n / , _/ -_) _ / / /__/ (_-</ __/\n/_/|_|\__/\_,_/ /____/_/___/\__/ \n")
print("by Team Avengers\nMIT LICENSE\n\n")
| def print_logo():
"""
___ __ __ _ __
/ _ \\___ ___/ / / / (_)__ / /_
/ , _/ -_) _ / / /__/ (_-</ __/
/_/|_|\\__/\\_,_/ /____/_/___/\\__/
by Team Avengers
MIT LICENSE
"""
print(' ___ __ __ _ __ \n / _ \\___ ___/ / / / (_)__ / /_\n / , _/ -_) _ / / /__/ (_-</ __/\n/_/|_|\\__/\\_,_/ /____/_/___/\\__/ \n')
print('by Team Avengers\nMIT LICENSE\n\n') |
class FizzBuzz(object):
def say(self, number):
if number % 3 == 0 and number % 5 == 0:
return 'FizzBuzz'
elif number % 3 == 0:
return 'Fizz'
elif number % 5 == 0:
return 'Buzz'
else:
return number
| class Fizzbuzz(object):
def say(self, number):
if number % 3 == 0 and number % 5 == 0:
return 'FizzBuzz'
elif number % 3 == 0:
return 'Fizz'
elif number % 5 == 0:
return 'Buzz'
else:
return number |
# -*- coding: utf-8 -*-
__title__ = 'amicleaner'
__version__ = '0.2.0'
__short_version__ = '.'.join(__version__.split('.')[:2])
__author__ = 'Guy Rodrigue Koffi'
__author_email__ = 'koffirodrigue@gmail.com'
__license__ = 'MIT'
| __title__ = 'amicleaner'
__version__ = '0.2.0'
__short_version__ = '.'.join(__version__.split('.')[:2])
__author__ = 'Guy Rodrigue Koffi'
__author_email__ = 'koffirodrigue@gmail.com'
__license__ = 'MIT' |
#-*- coding: utf-8 -*-
spam = 65 # an integer declaration.
print(spam)
print(type(spam)) # this is a function call
eggs = 2
print(eggs)
print(type(eggs))
# Let's see the numeric operations
print(spam + eggs) # sum
print(spam - eggs) # difference
print(spam * eggs) # product
print(spam / eggs) # quotient
print(spam % eggs) # remainder or module
print(spam ** eggs) # power
fooo = -2 # negative value
print(fooo)
print(type(fooo))
print(-fooo) # negated
print(abs(fooo)) # absolute value
print(int(fooo)) # convert to integer
print(float(fooo)) # convert to float
fooo += 1 # auto incremental
print(fooo)
# More on the quotient
print(spam / eggs) # quotient
print(spam / float(eggs)) # quotient
# More on the operations result type
print(type(spam + eggs))
print(type(float(spam) + eggs))
#===============================================================================
# - Python automatically infers the type of the result depending on operands type
#===============================================================================
# Let's try again the power
print(eggs ** spam)
print(type(eggs ** spam))
#===============================================================================
# - Use parentheses to alter operations order
#===============================================================================
#===============================================================================
# Python numeric types:
# - int:
# - Traditional integer
# - Implemented using long in C, at least 32 bits precision
# - Its values are [-sys.maxint - 1, sys.maxint]
# - long:
# - Long integer with unlimited precision
# - Created automatically or when an L suffix is provided
# - float:
# - Floating point number
# - Specified with a dot . as decimals separator
# - Implemented using double in C
# - Check sys.float_info for its internal representation
#
#===============================================================================
#===============================================================================
# SOURCES:
# - http://docs.python.org/2/library/stdtypes.html#numeric-types-int-float-long-complex
#===============================================================================
| spam = 65
print(spam)
print(type(spam))
eggs = 2
print(eggs)
print(type(eggs))
print(spam + eggs)
print(spam - eggs)
print(spam * eggs)
print(spam / eggs)
print(spam % eggs)
print(spam ** eggs)
fooo = -2
print(fooo)
print(type(fooo))
print(-fooo)
print(abs(fooo))
print(int(fooo))
print(float(fooo))
fooo += 1
print(fooo)
print(spam / eggs)
print(spam / float(eggs))
print(type(spam + eggs))
print(type(float(spam) + eggs))
print(eggs ** spam)
print(type(eggs ** spam)) |
#!/usr/bin/env python
# created by Bruce Yuan on 17-11-27
class ConstError(Exception):
def __init__(self, message):
self._message = str(message)
def __str__(self):
return self._message
__repr__ = __str__
| class Consterror(Exception):
def __init__(self, message):
self._message = str(message)
def __str__(self):
return self._message
__repr__ = __str__ |
banyakPerulangan = 10
i = 0
while (i < banyakPerulangan):
print('Hello World')
i += 1 | banyak_perulangan = 10
i = 0
while i < banyakPerulangan:
print('Hello World')
i += 1 |
class Solution:
def sortSentence(self, s: str) -> str:
s=s.split()
s.sort(key = lambda x: x[-1])
sent=""
for i in s:
sent += (i[:-1]+" ")
s=sent.strip()
return s | class Solution:
def sort_sentence(self, s: str) -> str:
s = s.split()
s.sort(key=lambda x: x[-1])
sent = ''
for i in s:
sent += i[:-1] + ' '
s = sent.strip()
return s |
a=10
b=20
print(b-a)
print("SUBTRACTED b-a")
| a = 10
b = 20
print(b - a)
print('SUBTRACTED b-a') |
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'targets': [
{
'target_name': 'camera',
'dependencies': [
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'change_picture',
'dependencies': [
'<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-selector/compiled_resources2.gyp:iron-selector-extracted',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
'../compiled_resources2.gyp:route',
'camera',
'change_picture_browser_proxy',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'change_picture_browser_proxy',
'dependencies': [
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'easy_unlock_browser_proxy',
'dependencies': [
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'easy_unlock_turn_off_dialog',
'dependencies': [
'<(DEPTH)/ui/webui/resources/cr_elements/cr_dialog/compiled_resources2.gyp:cr_dialog',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
'easy_unlock_browser_proxy',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'import_data_browser_proxy',
'dependencies': [
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'manage_profile',
'dependencies': [
'../compiled_resources2.gyp:route',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
'manage_profile_browser_proxy',
'sync_browser_proxy',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'manage_profile_browser_proxy',
'dependencies': [
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'password_prompt_dialog',
'dependencies': [
'../compiled_resources2.gyp:route',
'<(EXTERNS_GYP):quick_unlock_private',
'lock_screen_constants',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'people_page',
'dependencies': [
'../compiled_resources2.gyp:route',
'../settings_page/compiled_resources2.gyp:settings_animated_pages',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:icon',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
'easy_unlock_browser_proxy',
'easy_unlock_turn_off_dialog',
'lock_screen_constants',
'lock_state_behavior',
'profile_info_browser_proxy',
'sync_browser_proxy',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'profile_info_browser_proxy',
'dependencies': [
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'lock_state_behavior',
'dependencies': [
'../compiled_resources2.gyp:route',
'<(EXTERNS_GYP):quick_unlock_private',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'lock_screen_constants',
'dependencies': [
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'lock_screen',
'dependencies': [
'../compiled_resources2.gyp:route',
'lock_screen_constants',
'lock_state_behavior',
'password_prompt_dialog',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'setup_pin_dialog',
'dependencies': [
'../compiled_resources2.gyp:route',
'lock_screen_constants',
'password_prompt_dialog',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'sync_page',
'dependencies': [
'../compiled_resources2.gyp:route',
'../settings_page/compiled_resources2.gyp:settings_animated_pages',
'sync_browser_proxy',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'sync_browser_proxy',
'dependencies': [
'<(DEPTH)/third_party/closure_compiler/externs/compiled_resources2.gyp:metrics_private',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'user_list',
'dependencies': [
'../compiled_resources2.gyp:route',
'<(EXTERNS_GYP):settings_private',
'<(EXTERNS_GYP):users_private',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'users_add_user_dialog',
'dependencies': [
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
'<(EXTERNS_GYP):users_private',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'users_page',
'dependencies': [
'user_list',
'users_add_user_dialog',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
{
'target_name': 'import_data_dialog',
'dependencies': [
'../prefs/compiled_resources2.gyp:prefs_behavior',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
'import_data_browser_proxy',
],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
],
}
| {'targets': [{'target_name': 'camera', 'dependencies': ['<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'change_picture', 'dependencies': ['<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-selector/compiled_resources2.gyp:iron-selector-extracted', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior', '../compiled_resources2.gyp:route', 'camera', 'change_picture_browser_proxy'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'change_picture_browser_proxy', 'dependencies': ['<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'easy_unlock_browser_proxy', 'dependencies': ['<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'easy_unlock_turn_off_dialog', 'dependencies': ['<(DEPTH)/ui/webui/resources/cr_elements/cr_dialog/compiled_resources2.gyp:cr_dialog', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior', 'easy_unlock_browser_proxy'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'import_data_browser_proxy', 'dependencies': ['<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'manage_profile', 'dependencies': ['../compiled_resources2.gyp:route', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior', 'manage_profile_browser_proxy', 'sync_browser_proxy'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'manage_profile_browser_proxy', 'dependencies': ['<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'password_prompt_dialog', 'dependencies': ['../compiled_resources2.gyp:route', '<(EXTERNS_GYP):quick_unlock_private', 'lock_screen_constants'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'people_page', 'dependencies': ['../compiled_resources2.gyp:route', '../settings_page/compiled_resources2.gyp:settings_animated_pages', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:icon', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior', 'easy_unlock_browser_proxy', 'easy_unlock_turn_off_dialog', 'lock_screen_constants', 'lock_state_behavior', 'profile_info_browser_proxy', 'sync_browser_proxy'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'profile_info_browser_proxy', 'dependencies': ['<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'lock_state_behavior', 'dependencies': ['../compiled_resources2.gyp:route', '<(EXTERNS_GYP):quick_unlock_private'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'lock_screen_constants', 'dependencies': ['<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'lock_screen', 'dependencies': ['../compiled_resources2.gyp:route', 'lock_screen_constants', 'lock_state_behavior', 'password_prompt_dialog', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'setup_pin_dialog', 'dependencies': ['../compiled_resources2.gyp:route', 'lock_screen_constants', 'password_prompt_dialog', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'sync_page', 'dependencies': ['../compiled_resources2.gyp:route', '../settings_page/compiled_resources2.gyp:settings_animated_pages', 'sync_browser_proxy', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'sync_browser_proxy', 'dependencies': ['<(DEPTH)/third_party/closure_compiler/externs/compiled_resources2.gyp:metrics_private', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'user_list', 'dependencies': ['../compiled_resources2.gyp:route', '<(EXTERNS_GYP):settings_private', '<(EXTERNS_GYP):users_private'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'users_add_user_dialog', 'dependencies': ['<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert', '<(EXTERNS_GYP):users_private'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'users_page', 'dependencies': ['user_list', 'users_add_user_dialog'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'import_data_dialog', 'dependencies': ['../prefs/compiled_resources2.gyp:prefs_behavior', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior', 'import_data_browser_proxy'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi']}]} |
"""
PERIODS
"""
numPeriods = 180
"""
STOPS
"""
numStations = 13
station_names = (
"Hamburg Hbf", # 0
"Landwehr", # 1
"Hasselbrook", # 2
"Wansbeker Chaussee*", # 3
"Friedrichsberg*", # 4
"Barmbek*", # 5
"Alte Woehr (Stadtpark)", # 6
"Ruebenkamp (City Nord)", # 7
"Ohlsdorf*", # 8
"Kornweg", # 9
"Hoheneichen", # 10
"Wellingsbuettel", # 11
"Poppenbuettel*", # 12
)
numStops = 26
stops_position = (
(0, 0), # Stop 0
(2, 0), # Stop 1
(3, 0), # Stop 2
(4, 0), # Stop 3
(5, 0), # Stop 4
(6, 0), # Stop 5
(7, 0), # Stop 6
(8, 0), # Stop 7
(9, 0), # Stop 8
(11, 0), # Stop 9
(13, 0), # Stop 10
(14, 0), # Stop 11
(15, 0), # Stop 12
(15, 1), # Stop 13
(15, 1), # Stop 14
(13, 1), # Stop 15
(12, 1), # Stop 16
(11, 1), # Stop 17
(10, 1), # Stop 18
(9, 1), # Stop 19
(8, 1), # Stop 20
(7, 1), # Stop 21
(6, 1), # Stop 22
(4, 1), # Stop 23
(2, 1), # Stop 24
(1, 1), # Stop 25
)
stops_distance = (
(0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # Stop 0
(0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # Stop 1
(0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # Stop 2
(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # Stop 3
(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # Stop 4
(0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # Stop 5
(0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # Stop 6
(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # Stop 7
(0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # Stop 8
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # Stop 9
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # Stop 10
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # Stop 11
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # Stop 12
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # Stop 13
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # Stop 14
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0), # Stop 15
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0), # Stop 16
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0), # Stop 17
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0), # Stop 18
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0), # Stop 19
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0), # Stop 20
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0), # Stop 21
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0), # Stop 22
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0), # Stop 23
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2), # Stop 24
(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # Stop 25
)
station_start = 0
"""
TRAMS
"""
numTrams = 18
tram_capacity = 514
tram_capacity_cargo = 304
tram_capacity_min_passenger = 208
tram_capacity_min_cargo = 0
tram_speed = 1
tram_headway = 1
tram_min_service = 1
tram_max_service = 10
min_time_next_tram = 0.333
tram_travel_deviation = 0.167
"""
PASSENGERS
"""
passenger_set = "pas-20210422-1717-int4e-1"
passenger_service_time_board = 0.0145
passenger_service_time_alight = 0.0145
"""
CARGO
"""
numCargo = 50
cargo_size = 4
cargo_station_destination = (
8, # 0
4, # 1
5, # 2
4, # 3
3, # 4
5, # 5
4, # 6
5, # 7
8, # 8
8, # 9
5, # 10
12, # 11
8, # 12
4, # 13
8, # 14
5, # 15
12, # 16
4, # 17
3, # 18
12, # 19
12, # 20
12, # 21
4, # 22
3, # 23
4, # 24
12, # 25
5, # 26
3, # 27
12, # 28
5, # 29
4, # 30
3, # 31
12, # 32
5, # 33
3, # 34
8, # 35
8, # 36
12, # 37
8, # 38
4, # 39
3, # 40
3, # 41
8, # 42
3, # 43
4, # 44
12, # 45
12, # 46
5, # 47
3, # 48
4, # 49
)
cargo_release = (
2, # 0
3, # 1
5, # 2
7, # 3
8, # 4
8, # 5
14, # 6
16, # 7
17, # 8
22, # 9
24, # 10
25, # 11
26, # 12
27, # 13
28, # 14
30, # 15
32, # 16
33, # 17
33, # 18
34, # 19
35, # 20
37, # 21
37, # 22
37, # 23
37, # 24
38, # 25
39, # 26
41, # 27
41, # 28
44, # 29
45, # 30
46, # 31
47, # 32
48, # 33
49, # 34
49, # 35
56, # 36
57, # 37
61, # 38
61, # 39
62, # 40
65, # 41
65, # 42
66, # 43
67, # 44
70, # 45
70, # 46
71, # 47
71, # 48
72, # 49
)
cargo_station_deadline = (
33, # 0
119, # 1
176, # 2
72, # 3
18, # 4
171, # 5
105, # 6
155, # 7
156, # 8
123, # 9
126, # 10
91, # 11
36, # 12
87, # 13
144, # 14
134, # 15
141, # 16
101, # 17
163, # 18
108, # 19
144, # 20
175, # 21
76, # 22
162, # 23
47, # 24
97, # 25
87, # 26
114, # 27
164, # 28
142, # 29
55, # 30
56, # 31
57, # 32
118, # 33
59, # 34
160, # 35
170, # 36
139, # 37
71, # 38
71, # 39
82, # 40
161, # 41
109, # 42
151, # 43
77, # 44
80, # 45
169, # 46
97, # 47
129, # 48
99, # 49
)
cargo_max_delay = 3
cargo_service_time_load = 0.3333333333333333
cargo_service_time_unload = 0.25
"""
parameters for reproducibiliy. More information: https://numpy.org/doc/stable/reference/random/parallel.html
"""
#initial entropy
entropy = 8991598675325360468762009371570610170
#index for seed sequence child
child_seed_index = (
0, # 0
)
"""
Results from timetabling
"""
scheme = "SV"
method = "timetabling_closed"
passengerData = "0-rep"
downstream_cargo = False
delivery_optional = True
assignment_method = "timetabling_closed"
operating = (
False, # 0
False, # 1
False, # 2
False, # 3
False, # 4
True, # 5
True, # 6
True, # 7
True, # 8
True, # 9
True, # 10
True, # 11
True, # 12
True, # 13
True, # 14
True, # 15
True, # 16
True, # 17
)
tram_tour = (
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), # 0
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), # 1
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), # 2
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), # 3
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), # 4
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), # 5
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), # 6
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), # 7
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), # 8
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), # 9
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), # 10
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), # 11
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), # 12
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), # 13
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), # 14
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), # 15
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), # 16
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), # 17
)
tram_time_arrival = (
(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), # 0
(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), # 1
(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), # 2
(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), # 3
(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), # 4
(10.0, 14.0, 16.0, 18.0, 22.0, 24.0, 27.0, 29.0, 31.0, 34.0, 37.0, 39.0, 41.0, 46.0, 57.0, 61.0, 69.0, 75.0, 77.0, 79.0, 82.0, 84.0, 89.0, 100.0, 111.0, 116.0), # 5
(29.0, 41.0, 43.0, 45.0, 47.0, 49.0, 51.0, 53.0, 55.0, 61.0, 64.0, 66.0, 73.0, 76.0, 82.0, 86.0, 94.0, 97.0, 101.0, 104.0, 106.0, 108.0, 112.0, 116.0, 126.0, 133.0), # 6
(54.0, 66.0, 68.0, 70.0, 72.0, 74.0, 76.0, 78.0, 80.0, 83.0, 86.0, 88.0, 90.0, 94.0, 96.0, 98.0, 103.0, 110.0, 113.0, 115.0, 117.0, 120.0, 131.0, 140.0, 146.0, 155.0), # 7
(65.0, 73.0, 75.0, 77.0, 79.0, 81.0, 83.0, 85.0, 88.0, 91.0, 94.0, 96.0, 98.0, 100.0, 108.0, 111.0, 115.0, 118.0, 126.0, 137.0, 139.0, 143.0, 145.0, 147.0, 157.0, 160.0), # 8
(72.0, 75.0, 82.0, 87.0, 89.0, 91.0, 100.0, 105.0, 112.0, 122.0, 129.0, 131.0, 133.0, 135.0, 137.0, 139.0, 142.0, 145.0, 147.0, 149.0, 151.0, 153.0, 155.0, 157.0, 159.0, 162.0), # 9
(84.0, 88.0, 94.0, 99.0, 110.0, 112.0, 114.0, 116.0, 122.0, 128.0, 131.0, 133.0, 135.0, 137.0, 139.0, 141.0, 144.0, 147.0, 149.0, 151.0, 153.0, 155.0, 157.0, 159.0, 161.0, 164.0), # 10
(102.0, 113.0, 115.0, 117.0, 119.0, 121.0, 123.0, 125.0, 127.0, 130.0, 133.0, 135.0, 137.0, 139.0, 141.0, 143.0, 146.0, 149.0, 151.0, 153.0, 155.0, 157.0, 159.0, 161.0, 163.0, 166.0), # 11
(112.0, 115.0, 117.0, 119.0, 121.0, 123.0, 125.0, 127.0, 129.0, 132.0, 135.0, 137.0, 139.0, 141.0, 143.0, 145.0, 148.0, 151.0, 153.0, 155.0, 157.0, 159.0, 161.0, 163.0, 165.0, 168.0), # 12
(114.0, 117.0, 119.0, 121.0, 123.0, 125.0, 127.0, 129.0, 131.0, 134.0, 137.0, 139.0, 141.0, 143.0, 145.0, 147.0, 150.0, 153.0, 155.0, 157.0, 159.0, 161.0, 163.0, 165.0, 167.0, 170.0), # 13
(116.0, 119.0, 121.0, 123.0, 125.0, 127.0, 129.0, 131.0, 133.0, 136.0, 139.0, 141.0, 143.0, 145.0, 147.0, 149.0, 152.0, 155.0, 157.0, 159.0, 161.0, 163.0, 165.0, 167.0, 169.0, 172.0), # 14
(118.0, 121.0, 123.0, 125.0, 127.0, 129.0, 131.0, 133.0, 135.0, 138.0, 141.0, 143.0, 145.0, 147.0, 149.0, 151.0, 154.0, 157.0, 159.0, 161.0, 163.0, 165.0, 167.0, 169.0, 171.0, 174.0), # 15
(120.0, 123.0, 125.0, 127.0, 129.0, 131.0, 133.0, 135.0, 137.0, 140.0, 143.0, 145.0, 147.0, 149.0, 151.0, 153.0, 156.0, 159.0, 161.0, 163.0, 165.0, 167.0, 169.0, 171.0, 173.0, 176.0), # 16
(122.0, 125.0, 127.0, 129.0, 131.0, 133.0, 135.0, 137.0, 139.0, 142.0, 145.0, 147.0, 149.0, 151.0, 153.0, 155.0, 158.0, 161.0, 163.0, 165.0, 167.0, 169.0, 171.0, 173.0, 175.0, 178.0), # 17
)
tram_time_departure = (
(-0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.0, -0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.0, -0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.0, -0.0), # 0
(-0.0, -0.0, -0.0, -0.0, -0.0, 0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0), # 1
(-0.0, -0.0, -0.0, -0.0, -0.0, 0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, 0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0), # 2
(-0.0, -0.0, -0.0, -0.0, 0.0, 0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, 0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0), # 3
(-0.0, -0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.0, -0.0, -0.0, -0.0, 0.0, 0.0, -0.0, 0.0, -0.0, -0.0, -0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.0, -0.0, -0.0), # 4
(12.0, 15.0, 17.0, 21.0, 23.0, 26.0, 28.0, 30.0, 32.0, 35.0, 38.0, 40.0, 45.0, 56.0, 60.0, 67.0, 73.0, 76.0, 78.0, 81.0, 83.0, 88.0, 99.0, 110.0, 114.0, 125.0), # 5
(39.0, 42.0, 44.0, 46.0, 48.0, 50.0, 52.0, 54.0, 59.0, 62.0, 65.0, 72.0, 75.0, 81.0, 85.0, 92.0, 95.0, 100.0, 103.0, 105.0, 107.0, 111.0, 115.0, 125.0, 131.0, 140.0), # 6
(64.0, 67.0, 69.0, 71.0, 73.0, 75.0, 77.0, 79.0, 81.0, 84.0, 87.0, 89.0, 93.0, 95.0, 97.0, 101.0, 108.0, 112.0, 114.0, 116.0, 119.0, 130.0, 139.0, 145.0, 153.0, 157.0), # 7
(71.0, 74.0, 76.0, 78.0, 80.0, 82.0, 84.0, 87.0, 89.0, 92.0, 95.0, 97.0, 99.0, 107.0, 110.0, 113.0, 116.0, 125.0, 136.0, 138.0, 142.0, 144.0, 146.0, 156.0, 158.0, 161.0), # 8
(73.0, 81.0, 86.0, 88.0, 90.0, 99.0, 104.0, 111.0, 120.0, 127.0, 130.0, 132.0, 134.0, 136.0, 138.0, 140.0, 143.0, 146.0, 148.0, 150.0, 152.0, 154.0, 156.0, 158.0, 160.0, 163.0), # 9
(86.0, 93.0, 98.0, 109.0, 111.0, 113.0, 115.0, 121.0, 126.0, 129.0, 132.0, 134.0, 136.0, 138.0, 140.0, 142.0, 145.0, 148.0, 150.0, 152.0, 154.0, 156.0, 158.0, 160.0, 162.0, 165.0), # 10
(111.0, 114.0, 116.0, 118.0, 120.0, 122.0, 124.0, 126.0, 128.0, 131.0, 134.0, 136.0, 138.0, 140.0, 142.0, 144.0, 147.0, 150.0, 152.0, 154.0, 156.0, 158.0, 160.0, 162.0, 164.0, 167.0), # 11
(113.0, 116.0, 118.0, 120.0, 122.0, 124.0, 126.0, 128.0, 130.0, 133.0, 136.0, 138.0, 140.0, 142.0, 144.0, 146.0, 149.0, 152.0, 154.0, 156.0, 158.0, 160.0, 162.0, 164.0, 166.0, 169.0), # 12
(115.0, 118.0, 120.0, 122.0, 124.0, 126.0, 128.0, 130.0, 132.0, 135.0, 138.0, 140.0, 142.0, 144.0, 146.0, 148.0, 151.0, 154.0, 156.0, 158.0, 160.0, 162.0, 164.0, 166.0, 168.0, 171.0), # 13
(117.0, 120.0, 122.0, 124.0, 126.0, 128.0, 130.0, 132.0, 134.0, 137.0, 140.0, 142.0, 144.0, 146.0, 148.0, 150.0, 153.0, 156.0, 158.0, 160.0, 162.0, 164.0, 166.0, 168.0, 170.0, 173.0), # 14
(119.0, 122.0, 124.0, 126.0, 128.0, 130.0, 132.0, 134.0, 136.0, 139.0, 142.0, 144.0, 146.0, 148.0, 150.0, 152.0, 155.0, 158.0, 160.0, 162.0, 164.0, 166.0, 168.0, 170.0, 172.0, 175.0), # 15
(121.0, 124.0, 126.0, 128.0, 130.0, 132.0, 134.0, 136.0, 138.0, 141.0, 144.0, 146.0, 148.0, 150.0, 152.0, 154.0, 157.0, 160.0, 162.0, 164.0, 166.0, 168.0, 170.0, 172.0, 174.0, 177.0), # 16
(123.0, 126.0, 128.0, 130.0, 132.0, 134.0, 136.0, 138.0, 140.0, 143.0, 146.0, 148.0, 150.0, 152.0, 154.0, 156.0, 159.0, 162.0, 164.0, 166.0, 168.0, 170.0, 172.0, 174.0, 176.0, 179.0), # 17
)
cargo_tram_assignment = (
5, # 0
5, # 1
5, # 2
5, # 3
5, # 4
13, # 5
6, # 6
6, # 7
14, # 8
7, # 9
7, # 10
6, # 11
6, # 12
7, # 13
6, # 14
17, # 15
11, # 16
6, # 17
6, # 18
7, # 19
11, # 20
17, # 21
7, # 22
6, # 23
6, # 24
6, # 25
7, # 26
7, # 27
10, # 28
7, # 29
7, # 30
7, # 31
7, # 32
7, # 33
7, # 34
7, # 35
11, # 36
11, # 37
7, # 38
7, # 39
7, # 40
14, # 41
8, # 42
9, # 43
8, # 44
8, # 45
17, # 46
9, # 47
15, # 48
9, # 49
)
| """
PERIODS
"""
num_periods = 180
'\nSTOPS\n'
num_stations = 13
station_names = ('Hamburg Hbf', 'Landwehr', 'Hasselbrook', 'Wansbeker Chaussee*', 'Friedrichsberg*', 'Barmbek*', 'Alte Woehr (Stadtpark)', 'Ruebenkamp (City Nord)', 'Ohlsdorf*', 'Kornweg', 'Hoheneichen', 'Wellingsbuettel', 'Poppenbuettel*')
num_stops = 26
stops_position = ((0, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (11, 0), (13, 0), (14, 0), (15, 0), (15, 1), (15, 1), (13, 1), (12, 1), (11, 1), (10, 1), (9, 1), (8, 1), (7, 1), (6, 1), (4, 1), (2, 1), (1, 1))
stops_distance = ((0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2), (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
station_start = 0
'\nTRAMS\n'
num_trams = 18
tram_capacity = 514
tram_capacity_cargo = 304
tram_capacity_min_passenger = 208
tram_capacity_min_cargo = 0
tram_speed = 1
tram_headway = 1
tram_min_service = 1
tram_max_service = 10
min_time_next_tram = 0.333
tram_travel_deviation = 0.167
'\nPASSENGERS\n'
passenger_set = 'pas-20210422-1717-int4e-1'
passenger_service_time_board = 0.0145
passenger_service_time_alight = 0.0145
'\nCARGO\n'
num_cargo = 50
cargo_size = 4
cargo_station_destination = (8, 4, 5, 4, 3, 5, 4, 5, 8, 8, 5, 12, 8, 4, 8, 5, 12, 4, 3, 12, 12, 12, 4, 3, 4, 12, 5, 3, 12, 5, 4, 3, 12, 5, 3, 8, 8, 12, 8, 4, 3, 3, 8, 3, 4, 12, 12, 5, 3, 4)
cargo_release = (2, 3, 5, 7, 8, 8, 14, 16, 17, 22, 24, 25, 26, 27, 28, 30, 32, 33, 33, 34, 35, 37, 37, 37, 37, 38, 39, 41, 41, 44, 45, 46, 47, 48, 49, 49, 56, 57, 61, 61, 62, 65, 65, 66, 67, 70, 70, 71, 71, 72)
cargo_station_deadline = (33, 119, 176, 72, 18, 171, 105, 155, 156, 123, 126, 91, 36, 87, 144, 134, 141, 101, 163, 108, 144, 175, 76, 162, 47, 97, 87, 114, 164, 142, 55, 56, 57, 118, 59, 160, 170, 139, 71, 71, 82, 161, 109, 151, 77, 80, 169, 97, 129, 99)
cargo_max_delay = 3
cargo_service_time_load = 0.3333333333333333
cargo_service_time_unload = 0.25
'\nparameters for reproducibiliy. More information: https://numpy.org/doc/stable/reference/random/parallel.html\n'
entropy = 8991598675325360468762009371570610170
child_seed_index = (0,)
'\nResults from timetabling\n'
scheme = 'SV'
method = 'timetabling_closed'
passenger_data = '0-rep'
downstream_cargo = False
delivery_optional = True
assignment_method = 'timetabling_closed'
operating = (False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True)
tram_tour = ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25))
tram_time_arrival = ((0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), (10.0, 14.0, 16.0, 18.0, 22.0, 24.0, 27.0, 29.0, 31.0, 34.0, 37.0, 39.0, 41.0, 46.0, 57.0, 61.0, 69.0, 75.0, 77.0, 79.0, 82.0, 84.0, 89.0, 100.0, 111.0, 116.0), (29.0, 41.0, 43.0, 45.0, 47.0, 49.0, 51.0, 53.0, 55.0, 61.0, 64.0, 66.0, 73.0, 76.0, 82.0, 86.0, 94.0, 97.0, 101.0, 104.0, 106.0, 108.0, 112.0, 116.0, 126.0, 133.0), (54.0, 66.0, 68.0, 70.0, 72.0, 74.0, 76.0, 78.0, 80.0, 83.0, 86.0, 88.0, 90.0, 94.0, 96.0, 98.0, 103.0, 110.0, 113.0, 115.0, 117.0, 120.0, 131.0, 140.0, 146.0, 155.0), (65.0, 73.0, 75.0, 77.0, 79.0, 81.0, 83.0, 85.0, 88.0, 91.0, 94.0, 96.0, 98.0, 100.0, 108.0, 111.0, 115.0, 118.0, 126.0, 137.0, 139.0, 143.0, 145.0, 147.0, 157.0, 160.0), (72.0, 75.0, 82.0, 87.0, 89.0, 91.0, 100.0, 105.0, 112.0, 122.0, 129.0, 131.0, 133.0, 135.0, 137.0, 139.0, 142.0, 145.0, 147.0, 149.0, 151.0, 153.0, 155.0, 157.0, 159.0, 162.0), (84.0, 88.0, 94.0, 99.0, 110.0, 112.0, 114.0, 116.0, 122.0, 128.0, 131.0, 133.0, 135.0, 137.0, 139.0, 141.0, 144.0, 147.0, 149.0, 151.0, 153.0, 155.0, 157.0, 159.0, 161.0, 164.0), (102.0, 113.0, 115.0, 117.0, 119.0, 121.0, 123.0, 125.0, 127.0, 130.0, 133.0, 135.0, 137.0, 139.0, 141.0, 143.0, 146.0, 149.0, 151.0, 153.0, 155.0, 157.0, 159.0, 161.0, 163.0, 166.0), (112.0, 115.0, 117.0, 119.0, 121.0, 123.0, 125.0, 127.0, 129.0, 132.0, 135.0, 137.0, 139.0, 141.0, 143.0, 145.0, 148.0, 151.0, 153.0, 155.0, 157.0, 159.0, 161.0, 163.0, 165.0, 168.0), (114.0, 117.0, 119.0, 121.0, 123.0, 125.0, 127.0, 129.0, 131.0, 134.0, 137.0, 139.0, 141.0, 143.0, 145.0, 147.0, 150.0, 153.0, 155.0, 157.0, 159.0, 161.0, 163.0, 165.0, 167.0, 170.0), (116.0, 119.0, 121.0, 123.0, 125.0, 127.0, 129.0, 131.0, 133.0, 136.0, 139.0, 141.0, 143.0, 145.0, 147.0, 149.0, 152.0, 155.0, 157.0, 159.0, 161.0, 163.0, 165.0, 167.0, 169.0, 172.0), (118.0, 121.0, 123.0, 125.0, 127.0, 129.0, 131.0, 133.0, 135.0, 138.0, 141.0, 143.0, 145.0, 147.0, 149.0, 151.0, 154.0, 157.0, 159.0, 161.0, 163.0, 165.0, 167.0, 169.0, 171.0, 174.0), (120.0, 123.0, 125.0, 127.0, 129.0, 131.0, 133.0, 135.0, 137.0, 140.0, 143.0, 145.0, 147.0, 149.0, 151.0, 153.0, 156.0, 159.0, 161.0, 163.0, 165.0, 167.0, 169.0, 171.0, 173.0, 176.0), (122.0, 125.0, 127.0, 129.0, 131.0, 133.0, 135.0, 137.0, 139.0, 142.0, 145.0, 147.0, 149.0, 151.0, 153.0, 155.0, 158.0, 161.0, 163.0, 165.0, 167.0, 169.0, 171.0, 173.0, 175.0, 178.0))
tram_time_departure = ((-0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.0, -0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.0, -0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.0, -0.0), (-0.0, -0.0, -0.0, -0.0, -0.0, 0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0), (-0.0, -0.0, -0.0, -0.0, -0.0, 0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, 0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0), (-0.0, -0.0, -0.0, -0.0, 0.0, 0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, 0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0, -0.0), (-0.0, -0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.0, -0.0, -0.0, -0.0, 0.0, 0.0, -0.0, 0.0, -0.0, -0.0, -0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.0, -0.0, -0.0), (12.0, 15.0, 17.0, 21.0, 23.0, 26.0, 28.0, 30.0, 32.0, 35.0, 38.0, 40.0, 45.0, 56.0, 60.0, 67.0, 73.0, 76.0, 78.0, 81.0, 83.0, 88.0, 99.0, 110.0, 114.0, 125.0), (39.0, 42.0, 44.0, 46.0, 48.0, 50.0, 52.0, 54.0, 59.0, 62.0, 65.0, 72.0, 75.0, 81.0, 85.0, 92.0, 95.0, 100.0, 103.0, 105.0, 107.0, 111.0, 115.0, 125.0, 131.0, 140.0), (64.0, 67.0, 69.0, 71.0, 73.0, 75.0, 77.0, 79.0, 81.0, 84.0, 87.0, 89.0, 93.0, 95.0, 97.0, 101.0, 108.0, 112.0, 114.0, 116.0, 119.0, 130.0, 139.0, 145.0, 153.0, 157.0), (71.0, 74.0, 76.0, 78.0, 80.0, 82.0, 84.0, 87.0, 89.0, 92.0, 95.0, 97.0, 99.0, 107.0, 110.0, 113.0, 116.0, 125.0, 136.0, 138.0, 142.0, 144.0, 146.0, 156.0, 158.0, 161.0), (73.0, 81.0, 86.0, 88.0, 90.0, 99.0, 104.0, 111.0, 120.0, 127.0, 130.0, 132.0, 134.0, 136.0, 138.0, 140.0, 143.0, 146.0, 148.0, 150.0, 152.0, 154.0, 156.0, 158.0, 160.0, 163.0), (86.0, 93.0, 98.0, 109.0, 111.0, 113.0, 115.0, 121.0, 126.0, 129.0, 132.0, 134.0, 136.0, 138.0, 140.0, 142.0, 145.0, 148.0, 150.0, 152.0, 154.0, 156.0, 158.0, 160.0, 162.0, 165.0), (111.0, 114.0, 116.0, 118.0, 120.0, 122.0, 124.0, 126.0, 128.0, 131.0, 134.0, 136.0, 138.0, 140.0, 142.0, 144.0, 147.0, 150.0, 152.0, 154.0, 156.0, 158.0, 160.0, 162.0, 164.0, 167.0), (113.0, 116.0, 118.0, 120.0, 122.0, 124.0, 126.0, 128.0, 130.0, 133.0, 136.0, 138.0, 140.0, 142.0, 144.0, 146.0, 149.0, 152.0, 154.0, 156.0, 158.0, 160.0, 162.0, 164.0, 166.0, 169.0), (115.0, 118.0, 120.0, 122.0, 124.0, 126.0, 128.0, 130.0, 132.0, 135.0, 138.0, 140.0, 142.0, 144.0, 146.0, 148.0, 151.0, 154.0, 156.0, 158.0, 160.0, 162.0, 164.0, 166.0, 168.0, 171.0), (117.0, 120.0, 122.0, 124.0, 126.0, 128.0, 130.0, 132.0, 134.0, 137.0, 140.0, 142.0, 144.0, 146.0, 148.0, 150.0, 153.0, 156.0, 158.0, 160.0, 162.0, 164.0, 166.0, 168.0, 170.0, 173.0), (119.0, 122.0, 124.0, 126.0, 128.0, 130.0, 132.0, 134.0, 136.0, 139.0, 142.0, 144.0, 146.0, 148.0, 150.0, 152.0, 155.0, 158.0, 160.0, 162.0, 164.0, 166.0, 168.0, 170.0, 172.0, 175.0), (121.0, 124.0, 126.0, 128.0, 130.0, 132.0, 134.0, 136.0, 138.0, 141.0, 144.0, 146.0, 148.0, 150.0, 152.0, 154.0, 157.0, 160.0, 162.0, 164.0, 166.0, 168.0, 170.0, 172.0, 174.0, 177.0), (123.0, 126.0, 128.0, 130.0, 132.0, 134.0, 136.0, 138.0, 140.0, 143.0, 146.0, 148.0, 150.0, 152.0, 154.0, 156.0, 159.0, 162.0, 164.0, 166.0, 168.0, 170.0, 172.0, 174.0, 176.0, 179.0))
cargo_tram_assignment = (5, 5, 5, 5, 5, 13, 6, 6, 14, 7, 7, 6, 6, 7, 6, 17, 11, 6, 6, 7, 11, 17, 7, 6, 6, 6, 7, 7, 10, 7, 7, 7, 7, 7, 7, 7, 11, 11, 7, 7, 7, 14, 8, 9, 8, 8, 17, 9, 15, 9) |
print("Rock..Paper..Scissors..")
print("Type rock or paper or scissors")
player1 = input("player 1, Your move: ")
player2 = input("player 2, Your move: ")
if player1 == player2:
print("It's a draw!")
elif player1 == "rock":
if player2 == "scissors":
print("player1 wins!")
elif player2 == "paper":
print("player2 wins!")
elif player1 == "paper":
if player2 == "rock":
print("player1 wins!")
elif player2 == "scissors":
print("player2 wins!")
elif player1 == "scissors":
if player2 == "paper":
print("player1 wins!")
elif player2 == "rock":
print("player2 wins!")
else:
print("Check spelling") | print('Rock..Paper..Scissors..')
print('Type rock or paper or scissors')
player1 = input('player 1, Your move: ')
player2 = input('player 2, Your move: ')
if player1 == player2:
print("It's a draw!")
elif player1 == 'rock':
if player2 == 'scissors':
print('player1 wins!')
elif player2 == 'paper':
print('player2 wins!')
elif player1 == 'paper':
if player2 == 'rock':
print('player1 wins!')
elif player2 == 'scissors':
print('player2 wins!')
elif player1 == 'scissors':
if player2 == 'paper':
print('player1 wins!')
elif player2 == 'rock':
print('player2 wins!')
else:
print('Check spelling') |
ATTR_CODE = "auth_code"
CONF_MQTT_IN = "mqtt_in"
CONF_MQTT_OUT = "mqtt_out"
DATA_KEY = "media_player.hisense_tv"
DEFAULT_CLIENT_ID = "HomeAssistant"
DEFAULT_MQTT_PREFIX = "hisense"
DEFAULT_NAME = "Hisense TV"
DOMAIN = "hisense_tv"
| attr_code = 'auth_code'
conf_mqtt_in = 'mqtt_in'
conf_mqtt_out = 'mqtt_out'
data_key = 'media_player.hisense_tv'
default_client_id = 'HomeAssistant'
default_mqtt_prefix = 'hisense'
default_name = 'Hisense TV'
domain = 'hisense_tv' |
class Solution:
def mergeAlternately(self, word1: str, word2: str) -> str:
first, second = len(word1), len(word2)
result = ""
for one, two in zip(word1, word2):
result += one + two
diff = first - second
if not diff:
return result
elif diff > 0:
result += word1[-diff:]
else:
result += word2[diff:]
return result
| class Solution:
def merge_alternately(self, word1: str, word2: str) -> str:
(first, second) = (len(word1), len(word2))
result = ''
for (one, two) in zip(word1, word2):
result += one + two
diff = first - second
if not diff:
return result
elif diff > 0:
result += word1[-diff:]
else:
result += word2[diff:]
return result |
matches = 0
for line in open('2/input.txt'):
acceptable_range, letter, password = line.split(" ")
low, high = acceptable_range.split("-")
count = password.count(letter[0])
if count in range(int(low), int(high)+1):
matches += 1
print(matches) | matches = 0
for line in open('2/input.txt'):
(acceptable_range, letter, password) = line.split(' ')
(low, high) = acceptable_range.split('-')
count = password.count(letter[0])
if count in range(int(low), int(high) + 1):
matches += 1
print(matches) |
class Solution:
def countNegatives(self, grid: List[List[int]]) -> int:
count = 0
for row in grid:
for c in row:
if c < 0: count += 1
return count | class Solution:
def count_negatives(self, grid: List[List[int]]) -> int:
count = 0
for row in grid:
for c in row:
if c < 0:
count += 1
return count |
class MyHashSet:
def __init__(self):
self.set = [False] * 1000001
def add(self, key: int) -> None:
self.set[key] = True
def remove(self, key: int) -> None:
self.set[key] = False
def contains(self, key: int) -> bool:
return self.set[key]
| class Myhashset:
def __init__(self):
self.set = [False] * 1000001
def add(self, key: int) -> None:
self.set[key] = True
def remove(self, key: int) -> None:
self.set[key] = False
def contains(self, key: int) -> bool:
return self.set[key] |
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=line-too-long
# pylint: disable=too-many-statements
# pylint: disable=too-many-lines
# pylint: disable=too-many-locals
# pylint: disable=unused-argument
def create_healthcareapis(cmd, client,
resource_group,
name,
kind,
location,
access_policies_object_id,
tags=None,
etag=None,
cosmos_db_offer_throughput=None,
authentication_authority=None,
authentication_audience=None,
authentication_smart_proxy_enabled=None,
cors_origins=None,
cors_headers=None,
cors_methods=None,
cors_max_age=None,
cors_allow_credentials=None):
service_description = {}
service_description['location'] = location
service_description['kind'] = kind
service_description['properties'] = {}
service_description['properties']['access_policies'] = []
for policy in access_policies_object_id.split(','):
service_description['properties']['access_policies'].append({'object_id': policy})
service_description['properties']['cors_configuration'] = {}
service_description['properties']['cors_configuration']['origins'] = None if cors_origins is None else cors_origins.split(',')
service_description['properties']['cors_configuration']['headers'] = None if cors_headers is None else cors_headers.split(',')
service_description['properties']['cors_configuration']['methods'] = None if cors_methods is None else cors_methods.split(',')
service_description['properties']['cors_configuration']['max_age'] = cors_max_age
service_description['properties']['cors_configuration']['allow_credentials'] = cors_allow_credentials
service_description['properties']['cosmos_db_configuration'] = {}
service_description['properties']['cosmos_db_configuration']['offer_throughput'] = cosmos_db_offer_throughput
service_description['authentication_configuration'] = {}
service_description['authentication_configuration']['authority'] = authentication_authority
service_description['authentication_configuration']['audience'] = authentication_audience
service_description['authentication_configuration']['smart_proxy_enabled'] = authentication_smart_proxy_enabled
return client.create_or_update(resource_group_name=resource_group, resource_name=name, service_description=service_description)
def update_healthcareapis(cmd, client,
resource_group,
name,
kind=None,
location=None,
access_policies_object_id=None,
tags=None,
etag=None,
cosmos_db_offer_throughput=None,
authentication_authority=None,
authentication_audience=None,
authentication_smart_proxy_enabled=None,
cors_origins=None,
cors_headers=None,
cors_methods=None,
cors_max_age=None,
cors_allow_credentials=None):
service_description = client.get(resource_group_name=resource_group, resource_name=name).as_dict()
if location is not None:
service_description['location'] = location
if kind is not None:
service_description['kind'] = kind
if access_policies_object_id is not None:
service_description['properties']['access_policies'] = []
for policy in access_policies_object_id.split(','):
service_description['properties']['access_policies'].append({'object_id': policy})
if service_description['properties'].get('cors_configuration') is None:
service_description['properties']['cors_configuration'] = {}
if cors_origins is not None:
service_description['properties']['cors_configuration']['origins'] = None if cors_origins is None else cors_origins.split(',')
if cors_headers is not None:
service_description['properties']['cors_configuration']['headers'] = None if cors_headers is None else cors_headers.split(',')
if cors_methods is not None:
service_description['properties']['cors_configuration']['methods'] = None if cors_methods is None else cors_methods.split(',')
if cors_max_age is not None:
service_description['properties']['cors_configuration']['max_age'] = cors_max_age
if cors_allow_credentials is not None:
service_description['properties']['cors_configuration']['allow_credentials'] = cors_allow_credentials
if service_description['properties'].get('cosmos_db_configuration') is None:
service_description['properties']['cosmos_db_configuration'] = {}
if cosmos_db_offer_throughput is not None:
service_description['properties']['cosmos_db_configuration']['offer_throughput'] = cosmos_db_offer_throughput
if service_description['properties'].get('authentication_configuration') is None:
service_description['authentication_configuration'] = {}
if authentication_authority is not None:
service_description['authentication_configuration']['authority'] = authentication_authority
if authentication_audience is not None:
service_description['authentication_configuration']['audience'] = authentication_audience
if authentication_smart_proxy_enabled is not None:
service_description['authentication_configuration']['smart_proxy_enabled'] = authentication_smart_proxy_enabled
return client.create_or_update(resource_group_name=resource_group, resource_name=name, service_description=service_description)
def list_healthcareapis(cmd, client,
resource_group=None):
if resource_group is not None:
return client.list_by_resource_group(resource_group_name=resource_group)
return client.list()
def show_healthcareapis(cmd, client,
resource_group,
name):
return client.get(resource_group_name=resource_group, resource_name=name)
def delete_healthcareapis(cmd, client,
resource_group,
name):
return client.delete(resource_group_name=resource_group, resource_name=name)
| def create_healthcareapis(cmd, client, resource_group, name, kind, location, access_policies_object_id, tags=None, etag=None, cosmos_db_offer_throughput=None, authentication_authority=None, authentication_audience=None, authentication_smart_proxy_enabled=None, cors_origins=None, cors_headers=None, cors_methods=None, cors_max_age=None, cors_allow_credentials=None):
service_description = {}
service_description['location'] = location
service_description['kind'] = kind
service_description['properties'] = {}
service_description['properties']['access_policies'] = []
for policy in access_policies_object_id.split(','):
service_description['properties']['access_policies'].append({'object_id': policy})
service_description['properties']['cors_configuration'] = {}
service_description['properties']['cors_configuration']['origins'] = None if cors_origins is None else cors_origins.split(',')
service_description['properties']['cors_configuration']['headers'] = None if cors_headers is None else cors_headers.split(',')
service_description['properties']['cors_configuration']['methods'] = None if cors_methods is None else cors_methods.split(',')
service_description['properties']['cors_configuration']['max_age'] = cors_max_age
service_description['properties']['cors_configuration']['allow_credentials'] = cors_allow_credentials
service_description['properties']['cosmos_db_configuration'] = {}
service_description['properties']['cosmos_db_configuration']['offer_throughput'] = cosmos_db_offer_throughput
service_description['authentication_configuration'] = {}
service_description['authentication_configuration']['authority'] = authentication_authority
service_description['authentication_configuration']['audience'] = authentication_audience
service_description['authentication_configuration']['smart_proxy_enabled'] = authentication_smart_proxy_enabled
return client.create_or_update(resource_group_name=resource_group, resource_name=name, service_description=service_description)
def update_healthcareapis(cmd, client, resource_group, name, kind=None, location=None, access_policies_object_id=None, tags=None, etag=None, cosmos_db_offer_throughput=None, authentication_authority=None, authentication_audience=None, authentication_smart_proxy_enabled=None, cors_origins=None, cors_headers=None, cors_methods=None, cors_max_age=None, cors_allow_credentials=None):
service_description = client.get(resource_group_name=resource_group, resource_name=name).as_dict()
if location is not None:
service_description['location'] = location
if kind is not None:
service_description['kind'] = kind
if access_policies_object_id is not None:
service_description['properties']['access_policies'] = []
for policy in access_policies_object_id.split(','):
service_description['properties']['access_policies'].append({'object_id': policy})
if service_description['properties'].get('cors_configuration') is None:
service_description['properties']['cors_configuration'] = {}
if cors_origins is not None:
service_description['properties']['cors_configuration']['origins'] = None if cors_origins is None else cors_origins.split(',')
if cors_headers is not None:
service_description['properties']['cors_configuration']['headers'] = None if cors_headers is None else cors_headers.split(',')
if cors_methods is not None:
service_description['properties']['cors_configuration']['methods'] = None if cors_methods is None else cors_methods.split(',')
if cors_max_age is not None:
service_description['properties']['cors_configuration']['max_age'] = cors_max_age
if cors_allow_credentials is not None:
service_description['properties']['cors_configuration']['allow_credentials'] = cors_allow_credentials
if service_description['properties'].get('cosmos_db_configuration') is None:
service_description['properties']['cosmos_db_configuration'] = {}
if cosmos_db_offer_throughput is not None:
service_description['properties']['cosmos_db_configuration']['offer_throughput'] = cosmos_db_offer_throughput
if service_description['properties'].get('authentication_configuration') is None:
service_description['authentication_configuration'] = {}
if authentication_authority is not None:
service_description['authentication_configuration']['authority'] = authentication_authority
if authentication_audience is not None:
service_description['authentication_configuration']['audience'] = authentication_audience
if authentication_smart_proxy_enabled is not None:
service_description['authentication_configuration']['smart_proxy_enabled'] = authentication_smart_proxy_enabled
return client.create_or_update(resource_group_name=resource_group, resource_name=name, service_description=service_description)
def list_healthcareapis(cmd, client, resource_group=None):
if resource_group is not None:
return client.list_by_resource_group(resource_group_name=resource_group)
return client.list()
def show_healthcareapis(cmd, client, resource_group, name):
return client.get(resource_group_name=resource_group, resource_name=name)
def delete_healthcareapis(cmd, client, resource_group, name):
return client.delete(resource_group_name=resource_group, resource_name=name) |
'''
import cachetools
from . import lang
enabled = True
maxsize = 1000
scriptures = {}
for each in lang.available:
scriptures[each] = cachetools.LRUCache(maxsize=maxsize)
''' | """
import cachetools
from . import lang
enabled = True
maxsize = 1000
scriptures = {}
for each in lang.available:
scriptures[each] = cachetools.LRUCache(maxsize=maxsize)
""" |
class Solution:
def mySqrt(self, x: int) -> int:
low=0
high=x
middle= (low+high)//2
while(high>middle and middle>low):
square=middle*middle
if (square==x):
return int(middle)
if (square>x):
high=middle
else:
low=middle
middle=(low+high)//2
if x<high*high: #check this condition for x=8 or x=1
return int(low)
else:
return int(high)
| class Solution:
def my_sqrt(self, x: int) -> int:
low = 0
high = x
middle = (low + high) // 2
while high > middle and middle > low:
square = middle * middle
if square == x:
return int(middle)
if square > x:
high = middle
else:
low = middle
middle = (low + high) // 2
if x < high * high:
return int(low)
else:
return int(high) |
# -*- coding:utf-8 -*-
'''
File: templates.py
File Created: Tuesday, 12th February 2019
Author: Hongzoeng Ng (kenecho@hku.hk)
-----
Last Modified: Tuesday, 12th February 2019
Modified By: Hongzoeng Ng (kenecho@hku.hk>)
-----
Copyright @ 2018 KenEcho
'''
moving_average_code = """# Moving average strategy
start = '%s'
end = '%s'
universe = %s
benchmark = "HS300"
freq = "d"
refresh_rate = 1
max_history_window = %s
accounts = {
"security_account": AccountConfig(
account_type="security",
capital_base=10000000,
commission=Commission(buycost=0.00, sellcost=0.00, unit="perValue"),
slippage=Slippage(value=0.00, unit="perValue")
)
}
def initialize(context):
context.asset_allocation = %s
def handle_data(context):
security_account = context.get_account("security_account")
current_universe = context.get_universe("stock", exclude_halt=False)
hist = context.get_attribute_history(
attribute="closePrice", time_range=max_history_window, style="sat"
)
for stk in current_universe:
short_ma = hist[stk][-%s:].mean()
long_ma = hist[stk][:].mean()
if (short_ma > long_ma) and (stk not in security_account.get_positions()):
security_account.order_pct_to(stk, context.asset_allocation[stk])
elif short_ma <= long_ma and (stk in security_account.get_positions()):
security_account.order_to(stk, 0)
"""
macd_code = """# MACD Strategy
import pandas as pd
import numpy as np
import talib
start = '%s'
end = '%s'
universe = %s
benchmark = 'HS300'
freq = 'd'
refresh_rate = 1
max_history_window = %s
accounts = {
'security_account': AccountConfig(
account_type='security',
capital_base=10000000,
commission = Commission(buycost=0.00, sellcost=0.00, unit='perValue'),
slippage = Slippage(value=0.00, unit='perValue')
)
}
def initialize(context):
context.asset_allocation = %s
context.short_win = %s # default to be 12
context.long_win = %s # default to be 26
context.macd_win = %s # default to be 9
def handle_data(context):
security_account = context.get_account('security_account')
current_universe = context.get_universe('stock', exclude_halt=False)
hist = context.get_attribute_history(
attribute='closePrice', time_range=max_history_window, style='sat'
)
for stk in current_universe:
prices = hist[stk].values
macd, signal, macdhist = talib.MACD(
prices,
fastperiod=context.short_win,
slowperiod=context.long_win,
signalperiod=context.macd_win
)
if (macd[-1] - signal[-1] > 0) and (stk not in security_account.get_positions()):
security_account.order_pct_to(stk, context.asset_allocation[stk])
elif (macd[-1] - signal[-1] < 0) and (stk in security_account.get_positions()):
security_account.order_to(stk, 0)
"""
stochastic_oscillator_code = """# Stochastic oscillator
import pandas as pd
import numpy as np
import talib as ta
start = '%s'
end = '%s'
universe = %s
benchmark = 'HS300'
freq = 'd'
refresh_rate = 1
max_history_window = %s
accounts = {
'security_account': AccountConfig(
account_type='security',
capital_base=10000000,
commission = Commission(buycost=0.00, sellcost=0.00, unit='perValue'),
slippage = Slippage(value=0.00, unit='perValue')
)
}
def initialize(context):
context.asset_allocation = %s
context.fastk = %s # default to be 14
context.slowk = %s # default to be 3
context.slowd = %s # default to be 3
def handle_data(context):
security_account = context.get_account('security_account')
current_universe = context.get_universe('stock', exclude_halt=False)
hist_close = context.get_attribute_history(
attribute='closePrice', time_range=max_history_window, style='sat'
)
hist_high = context.get_attribute_history(
attribute='highPrice', time_range=max_history_window, style='sat'
)
hist_low = context.get_attribute_history(
attribute='lowPrice', time_range=max_history_window, style='sat'
)
for stk in current_universe:
close = hist_close[stk].values
high = hist_high[stk].values
low = hist_low[stk].values
slowk, slowd = ta.STOCH(
high, low, close,
fastk_period=context.fastk,
slowk_period=context.slowk,
slowk_matype=0,
slowd_period=context.slowd,
slowd_matype=0
)
if (slowk[-1] > slowd[-1]) and (stk not in security_account.get_positions()):
security_account.order_pct_to(stk, context.asset_allocation[stk])
elif (slowk[-1] < slowd[-1]) and (stk in security_account.get_positions()):
security_account.order_to(stk, 0)
"""
buy_hold_code = """# Buy & Hold strategy
start = '%s'
end = '%s'
universe = %s
benchmark = "HS300"
freq = "d"
refresh_rate = 1
accounts = {
"security_account": AccountConfig(
account_type="security",
capital_base=10000000,
commission=Commission(buycost=0.00, sellcost=0.00, unit="perValue"),
slippage=Slippage(value=0.00, unit="perValue")
)
}
def initialize(context):
context.asset_allocation = %s
def handle_data(context):
security_account = context.get_account("security_account")
current_universe = context.get_universe("stock", exclude_halt=False)
for stk in current_universe:
if stk not in security_account.get_positions():
security_account.order_pct_to(stk, context.asset_allocation[stk])
""" | """
File: templates.py
File Created: Tuesday, 12th February 2019
Author: Hongzoeng Ng (kenecho@hku.hk)
-----
Last Modified: Tuesday, 12th February 2019
Modified By: Hongzoeng Ng (kenecho@hku.hk>)
-----
Copyright @ 2018 KenEcho
"""
moving_average_code = '# Moving average strategy\nstart = \'%s\'\nend = \'%s\'\nuniverse = %s\nbenchmark = "HS300"\nfreq = "d"\nrefresh_rate = 1\nmax_history_window = %s\n\naccounts = {\n "security_account": AccountConfig(\n account_type="security",\n capital_base=10000000,\n commission=Commission(buycost=0.00, sellcost=0.00, unit="perValue"),\n slippage=Slippage(value=0.00, unit="perValue")\n )\n}\n\n\ndef initialize(context):\n context.asset_allocation = %s\n\n\ndef handle_data(context):\n security_account = context.get_account("security_account")\n current_universe = context.get_universe("stock", exclude_halt=False)\n hist = context.get_attribute_history(\n attribute="closePrice", time_range=max_history_window, style="sat"\n )\n\n for stk in current_universe:\n short_ma = hist[stk][-%s:].mean()\n long_ma = hist[stk][:].mean()\n\n if (short_ma > long_ma) and (stk not in security_account.get_positions()):\n security_account.order_pct_to(stk, context.asset_allocation[stk])\n elif short_ma <= long_ma and (stk in security_account.get_positions()):\n security_account.order_to(stk, 0)\n\n'
macd_code = "# MACD Strategy\nimport pandas as pd\nimport numpy as np\nimport talib\n\nstart = '%s'\nend = '%s'\nuniverse = %s\nbenchmark = 'HS300'\nfreq = 'd'\nrefresh_rate = 1\nmax_history_window = %s\n\n\naccounts = {\n 'security_account': AccountConfig(\n account_type='security',\n capital_base=10000000,\n commission = Commission(buycost=0.00, sellcost=0.00, unit='perValue'),\n slippage = Slippage(value=0.00, unit='perValue')\n )\n}\n\ndef initialize(context):\n context.asset_allocation = %s\n context.short_win = %s # default to be 12\n context.long_win = %s # default to be 26\n context.macd_win = %s # default to be 9\n\ndef handle_data(context):\n security_account = context.get_account('security_account')\n current_universe = context.get_universe('stock', exclude_halt=False)\n hist = context.get_attribute_history(\n attribute='closePrice', time_range=max_history_window, style='sat'\n )\n\n for stk in current_universe:\n prices = hist[stk].values\n macd, signal, macdhist = talib.MACD(\n prices,\n fastperiod=context.short_win,\n slowperiod=context.long_win,\n signalperiod=context.macd_win\n )\n if (macd[-1] - signal[-1] > 0) and (stk not in security_account.get_positions()):\n security_account.order_pct_to(stk, context.asset_allocation[stk])\n elif (macd[-1] - signal[-1] < 0) and (stk in security_account.get_positions()):\n security_account.order_to(stk, 0)\n\n"
stochastic_oscillator_code = "# Stochastic oscillator\nimport pandas as pd\nimport numpy as np\nimport talib as ta\n\nstart = '%s' \nend = '%s' \nuniverse = %s\nbenchmark = 'HS300' \nfreq = 'd' \nrefresh_rate = 1\nmax_history_window = %s\n \n\naccounts = {\n 'security_account': AccountConfig(\n account_type='security',\n capital_base=10000000,\n commission = Commission(buycost=0.00, sellcost=0.00, unit='perValue'),\n slippage = Slippage(value=0.00, unit='perValue')\n )\n}\n \ndef initialize(context):\n context.asset_allocation = %s\n context.fastk = %s # default to be 14\n context.slowk = %s # default to be 3\n context.slowd = %s # default to be 3\n \ndef handle_data(context):\n security_account = context.get_account('security_account')\n current_universe = context.get_universe('stock', exclude_halt=False)\n hist_close = context.get_attribute_history(\n attribute='closePrice', time_range=max_history_window, style='sat'\n )\n hist_high = context.get_attribute_history(\n attribute='highPrice', time_range=max_history_window, style='sat'\n )\n hist_low = context.get_attribute_history(\n attribute='lowPrice', time_range=max_history_window, style='sat'\n )\n \n for stk in current_universe:\n close = hist_close[stk].values\n high = hist_high[stk].values\n low = hist_low[stk].values\n slowk, slowd = ta.STOCH(\n high, low, close,\n fastk_period=context.fastk,\n slowk_period=context.slowk,\n slowk_matype=0,\n slowd_period=context.slowd,\n slowd_matype=0\n )\n if (slowk[-1] > slowd[-1]) and (stk not in security_account.get_positions()):\n security_account.order_pct_to(stk, context.asset_allocation[stk])\n elif (slowk[-1] < slowd[-1]) and (stk in security_account.get_positions()):\n security_account.order_to(stk, 0)\n\n"
buy_hold_code = '# Buy & Hold strategy\nstart = \'%s\'\nend = \'%s\'\nuniverse = %s\nbenchmark = "HS300"\nfreq = "d"\nrefresh_rate = 1\n\naccounts = {\n "security_account": AccountConfig(\n account_type="security",\n capital_base=10000000,\n commission=Commission(buycost=0.00, sellcost=0.00, unit="perValue"),\n slippage=Slippage(value=0.00, unit="perValue")\n )\n}\n\n\ndef initialize(context):\n context.asset_allocation = %s\n\n\ndef handle_data(context):\n security_account = context.get_account("security_account")\n current_universe = context.get_universe("stock", exclude_halt=False)\n\n for stk in current_universe:\n if stk not in security_account.get_positions():\n security_account.order_pct_to(stk, context.asset_allocation[stk])\n\n' |
print("Podaj a:")
a = int(input())
print("Podaj b:")
b = int(input())
print("A") if a > b else print("=") if a == b else print("B")
| print('Podaj a:')
a = int(input())
print('Podaj b:')
b = int(input())
print('A') if a > b else print('=') if a == b else print('B') |
def get_user_access_token():
"""Get the secret access token of the currently-logged-in Microsoft user, for use with the Microsoft REST API.
Requires this app to have its own Microsoft client ID and secret. """
pass
def get_user_email():
"""Get the email address of the currently-logged-in Microsoft user.To log in with Microsoft,
call anvil_microsoft.auth.login() from form code. """
pass
def get_user_refresh_token():
"""Get the secret refresh token of the currently-logged-in Microsoft user, for use with the Microsoft REST API.
Requires this app to have its own Microsoft client ID and secret. """
pass
def login():
"""Prompt the user to log in with their Microsoft account"""
pass
def refresh_access_token(refresh_token):
"""Get a new access token from a refresh token you have saved, for use with the Microsoft REST API. Requires this
app to have its own Microsoft client ID and secret. """
pass
| def get_user_access_token():
"""Get the secret access token of the currently-logged-in Microsoft user, for use with the Microsoft REST API.
Requires this app to have its own Microsoft client ID and secret. """
pass
def get_user_email():
"""Get the email address of the currently-logged-in Microsoft user.To log in with Microsoft,
call anvil_microsoft.auth.login() from form code. """
pass
def get_user_refresh_token():
"""Get the secret refresh token of the currently-logged-in Microsoft user, for use with the Microsoft REST API.
Requires this app to have its own Microsoft client ID and secret. """
pass
def login():
"""Prompt the user to log in with their Microsoft account"""
pass
def refresh_access_token(refresh_token):
"""Get a new access token from a refresh token you have saved, for use with the Microsoft REST API. Requires this
app to have its own Microsoft client ID and secret. """
pass |
class DB:
'''
Convience class for decibel scale. Other non-linear scales such as the richter scale could be handled similarly.
Usage:
dB = DB()
.
. (later)
.
gain = 15 * dB
'''
def __rmul__(self, val):
'''
Only allow multiplication from the right to avoid confusing situation
like: 15 * dB * 10
'''
return 10 ** (val / 10.)
def __test__():
dB = DB()
gain = 10 * dB
assert abs(gain - 10) < 1e-8
try:
gain2 = dB * 10
raise Exception('Should raise a type error!')
except TypeError:
pass
__test__()
| class Db:
"""
Convience class for decibel scale. Other non-linear scales such as the richter scale could be handled similarly.
Usage:
dB = DB()
.
. (later)
.
gain = 15 * dB
"""
def __rmul__(self, val):
"""
Only allow multiplication from the right to avoid confusing situation
like: 15 * dB * 10
"""
return 10 ** (val / 10.0)
def __test__():
d_b = db()
gain = 10 * dB
assert abs(gain - 10) < 1e-08
try:
gain2 = dB * 10
raise exception('Should raise a type error!')
except TypeError:
pass
__test__() |
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=line-too-long
Dogfood_RMEndpoint = 'https://api-dogfood.resources.windows-int.net/'
Helm_Environment_File_Fault_Type = 'helm-environment-file-error'
Invalid_Location_Fault_Type = 'location-validation-error'
Load_Kubeconfig_Fault_Type = 'kubeconfig-load-error'
Read_ConfigMap_Fault_Type = 'configmap-read-error'
Get_ResourceProvider_Fault_Type = 'resource-provider-fetch-error'
Get_ConnectedCluster_Fault_Type = 'connected-cluster-fetch-error'
Create_ConnectedCluster_Fault_Type = 'connected-cluster-create-error'
Delete_ConnectedCluster_Fault_Type = 'connected-cluster-delete-error'
Bad_DeleteRequest_Fault_Type = 'bad-delete-request-error'
Cluster_Already_Onboarded_Fault_Type = 'cluster-already-onboarded-error'
Resource_Already_Exists_Fault_Type = 'resource-already-exists-error'
Resource_Does_Not_Exist_Fault_Type = 'resource-does-not-exist-error'
Create_ResourceGroup_Fault_Type = 'resource-group-creation-error'
Add_HelmRepo_Fault_Type = 'helm-repo-add-error'
List_HelmRelease_Fault_Type = 'helm-list-release-error'
KeyPair_Generate_Fault_Type = 'keypair-generation-error'
PublicKey_Export_Fault_Type = 'publickey-export-error'
PrivateKey_Export_Fault_Type = 'privatekey-export-error'
Install_HelmRelease_Fault_Type = 'helm-release-install-error'
Delete_HelmRelease_Fault_Type = 'helm-release-delete-error'
Check_PodStatus_Fault_Type = 'check-pod-status-error'
Kubernetes_Connectivity_FaultType = 'kubernetes-cluster-connection-error'
Helm_Version_Fault_Type = 'helm-not-updated-error'
Check_HelmVersion_Fault_Type = 'helm-version-check-error'
Helm_Installation_Fault_Type = 'helm-not-installed-error'
Check_HelmInstallation_Fault_Type = 'check-helm-installed-error'
Get_HelmRegistery_Path_Fault_Type = 'helm-registry-path-fetch-error'
Pull_HelmChart_Fault_Type = 'helm-chart-pull-error'
Export_HelmChart_Fault_Type = 'helm-chart-export-error'
Get_Kubernetes_Version_Fault_Type = 'kubernetes-get-version-error'
Get_Kubernetes_Distro_Fault_Type = 'kubernetes-get-distribution-error'
Get_Kubernetes_Namespace_Fault_Type = 'kubernetes-get-namespace-error'
Update_Agent_Success = 'Agents for Connected Cluster {} have been updated successfully'
Update_Agent_Failure = 'Error while updating agents. Please run \"kubectl get pods -n azure-arc\" to check the pods in case of timeout error. Error: {}'
Cluster_Info_Not_Found_Type = 'Error while finding current cluster server details'
Kubeconfig_Failed_To_Load_Fault_Type = "failed-to-load-kubeconfig-file"
Proxy_Cert_Path_Does_Not_Exist_Fault_Type = 'proxy-cert-path-does-not-exist-error'
Proxy_Cert_Path_Does_Not_Exist_Error = 'Proxy cert path {} does not exist. Please check the path provided'
| dogfood_rm_endpoint = 'https://api-dogfood.resources.windows-int.net/'
helm__environment__file__fault__type = 'helm-environment-file-error'
invalid__location__fault__type = 'location-validation-error'
load__kubeconfig__fault__type = 'kubeconfig-load-error'
read__config_map__fault__type = 'configmap-read-error'
get__resource_provider__fault__type = 'resource-provider-fetch-error'
get__connected_cluster__fault__type = 'connected-cluster-fetch-error'
create__connected_cluster__fault__type = 'connected-cluster-create-error'
delete__connected_cluster__fault__type = 'connected-cluster-delete-error'
bad__delete_request__fault__type = 'bad-delete-request-error'
cluster__already__onboarded__fault__type = 'cluster-already-onboarded-error'
resource__already__exists__fault__type = 'resource-already-exists-error'
resource__does__not__exist__fault__type = 'resource-does-not-exist-error'
create__resource_group__fault__type = 'resource-group-creation-error'
add__helm_repo__fault__type = 'helm-repo-add-error'
list__helm_release__fault__type = 'helm-list-release-error'
key_pair__generate__fault__type = 'keypair-generation-error'
public_key__export__fault__type = 'publickey-export-error'
private_key__export__fault__type = 'privatekey-export-error'
install__helm_release__fault__type = 'helm-release-install-error'
delete__helm_release__fault__type = 'helm-release-delete-error'
check__pod_status__fault__type = 'check-pod-status-error'
kubernetes__connectivity__fault_type = 'kubernetes-cluster-connection-error'
helm__version__fault__type = 'helm-not-updated-error'
check__helm_version__fault__type = 'helm-version-check-error'
helm__installation__fault__type = 'helm-not-installed-error'
check__helm_installation__fault__type = 'check-helm-installed-error'
get__helm_registery__path__fault__type = 'helm-registry-path-fetch-error'
pull__helm_chart__fault__type = 'helm-chart-pull-error'
export__helm_chart__fault__type = 'helm-chart-export-error'
get__kubernetes__version__fault__type = 'kubernetes-get-version-error'
get__kubernetes__distro__fault__type = 'kubernetes-get-distribution-error'
get__kubernetes__namespace__fault__type = 'kubernetes-get-namespace-error'
update__agent__success = 'Agents for Connected Cluster {} have been updated successfully'
update__agent__failure = 'Error while updating agents. Please run "kubectl get pods -n azure-arc" to check the pods in case of timeout error. Error: {}'
cluster__info__not__found__type = 'Error while finding current cluster server details'
kubeconfig__failed__to__load__fault__type = 'failed-to-load-kubeconfig-file'
proxy__cert__path__does__not__exist__fault__type = 'proxy-cert-path-does-not-exist-error'
proxy__cert__path__does__not__exist__error = 'Proxy cert path {} does not exist. Please check the path provided' |
""" GOST R 34.10-20** digital signature implementation
This module implements Weierstrass elliptic curves (class elliptic_curve),
and GOST R 34.10-20** digital signature: generation, verification, test
and various supplemental stuff
""" | """ GOST R 34.10-20** digital signature implementation
This module implements Weierstrass elliptic curves (class elliptic_curve),
and GOST R 34.10-20** digital signature: generation, verification, test
and various supplemental stuff
""" |
class Solution:
def maxProfit(self, k: int, prices: List[int]) -> int:
n, res = len(prices), 0
if n < 2:
return 0
if k > n // 2:
for i in range(1, n):
if prices[i] > prices[i - 1]:
res += prices[i] - prices[i - 1]
return res
hold, sold = [float('-inf')] * (k + 1), [0] * (k + 1)
for price in prices:
for j in range(1, k + 1):
hold[j] = max(hold[j], sold[j - 1] - price)
sold[j] = max(sold[j], hold[j] + price)
return sold[k]
| class Solution:
def max_profit(self, k: int, prices: List[int]) -> int:
(n, res) = (len(prices), 0)
if n < 2:
return 0
if k > n // 2:
for i in range(1, n):
if prices[i] > prices[i - 1]:
res += prices[i] - prices[i - 1]
return res
(hold, sold) = ([float('-inf')] * (k + 1), [0] * (k + 1))
for price in prices:
for j in range(1, k + 1):
hold[j] = max(hold[j], sold[j - 1] - price)
sold[j] = max(sold[j], hold[j] + price)
return sold[k] |
def proper_divisors_sum(n):
return sum(a for a in xrange(1, n) if not n % a)
def amicable_numbers(a, b):
return proper_divisors_sum(a) == b and proper_divisors_sum(b) == a
# def amicable_numbers(a, b):
# # this works after multiple submissions to get lucky on random inputs
# return sum(c for c in xrange(1, a) if not a % c) == b
| def proper_divisors_sum(n):
return sum((a for a in xrange(1, n) if not n % a))
def amicable_numbers(a, b):
return proper_divisors_sum(a) == b and proper_divisors_sum(b) == a |
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 4 11:19:30 2021
@author: Easin
"""
in1 = input().split()
list1 = []
for elem in range(len(in1)):
list1.append(int(in1[elem]))
#print(list1)
maxm = max(list1)
list2=[]
for val in range(len(list1)):
if list1[val] != maxm:
out = maxm - list1[val]
list2.append(out)
print(out) | """
Created on Sat Sep 4 11:19:30 2021
@author: Easin
"""
in1 = input().split()
list1 = []
for elem in range(len(in1)):
list1.append(int(in1[elem]))
maxm = max(list1)
list2 = []
for val in range(len(list1)):
if list1[val] != maxm:
out = maxm - list1[val]
list2.append(out)
print(out) |
def save_to_file(data: list, filename: str):
"""Save to file."""
with open(f"{filename}", "w") as f:
for item_ in data:
f.write("%s\n" % item_)
| def save_to_file(data: list, filename: str):
"""Save to file."""
with open(f'{filename}', 'w') as f:
for item_ in data:
f.write('%s\n' % item_) |
MESSAGE_TIMESPAN = 2000
SIMULATED_DATA = False
I2C_ADDRESS = 0x77
GPIO_PIN_ADDRESS = 24
BLINK_TIMESPAN = 1000
| message_timespan = 2000
simulated_data = False
i2_c_address = 119
gpio_pin_address = 24
blink_timespan = 1000 |
"""Meta variables for SkLite"""
__title__ = "sklite"
__version__ = "0.0.2"
__description__ = "Use Scikit Learn models in Flutter"
__url__ = "https://github.com/axegon/sklite"
__author__ = "Alexander Ejbekov"
__author_email__ = "alexander@kialo.ai"
__license__ = "MIT"
__compat__ = "0.0.1"
| """Meta variables for SkLite"""
__title__ = 'sklite'
__version__ = '0.0.2'
__description__ = 'Use Scikit Learn models in Flutter'
__url__ = 'https://github.com/axegon/sklite'
__author__ = 'Alexander Ejbekov'
__author_email__ = 'alexander@kialo.ai'
__license__ = 'MIT'
__compat__ = '0.0.1' |
pkgname = "evolution-data-server"
pkgver = "3.44.0"
pkgrel = 0
build_style = "cmake"
# TODO: libgdata
configure_args = [
"-DENABLE_GOOGLE=OFF", "-DWITH_LIBDB=OFF",
"-DSYSCONF_INSTALL_DIR=/etc", "-DENABLE_INTROSPECTION=ON",
"-DENABLE_VALA_BINDINGS=ON",
]
hostmakedepends = [
"cmake", "ninja", "pkgconf", "flex", "glib-devel", "gperf",
"gobject-introspection", "gettext-tiny", "vala", "perl",
]
makedepends = [
"libglib-devel", "libcanberra-devel", "libical-devel", "heimdal-devel",
"webkitgtk-devel", "libsecret-devel", "gnome-online-accounts-devel",
"gcr-devel", "sqlite-devel", "libgweather-devel", "libsoup-devel",
"json-glib-devel", "nss-devel", "nspr-devel", "vala-devel",
"openldap-devel",
]
checkdepends = ["dbus"]
pkgdesc = "Centralized access to appointments and contacts"
maintainer = "q66 <q66@chimera-linux.org>"
license = "LGPL-2.0-or-later"
url = "https://gitlab.gnome.org/GNOME/evolution-data-server"
source = f"$(GNOME_SITE)/{pkgname}/{pkgver[:-2]}/{pkgname}-{pkgver}.tar.xz"
sha256 = "0d8881b5c51e1b91761b1945db264a46aabf54a73eea1ca8f448b207815d582e"
# internally passes some stuff that only goes to linker
tool_flags = {"CFLAGS": ["-Wno-unused-command-line-argument"]}
options = ["!cross"]
def post_install(self):
self.rm(self.destdir / "usr/lib/systemd", recursive = True)
@subpackage("evolution-data-server-devel")
def _devel(self):
return self.default_devel()
| pkgname = 'evolution-data-server'
pkgver = '3.44.0'
pkgrel = 0
build_style = 'cmake'
configure_args = ['-DENABLE_GOOGLE=OFF', '-DWITH_LIBDB=OFF', '-DSYSCONF_INSTALL_DIR=/etc', '-DENABLE_INTROSPECTION=ON', '-DENABLE_VALA_BINDINGS=ON']
hostmakedepends = ['cmake', 'ninja', 'pkgconf', 'flex', 'glib-devel', 'gperf', 'gobject-introspection', 'gettext-tiny', 'vala', 'perl']
makedepends = ['libglib-devel', 'libcanberra-devel', 'libical-devel', 'heimdal-devel', 'webkitgtk-devel', 'libsecret-devel', 'gnome-online-accounts-devel', 'gcr-devel', 'sqlite-devel', 'libgweather-devel', 'libsoup-devel', 'json-glib-devel', 'nss-devel', 'nspr-devel', 'vala-devel', 'openldap-devel']
checkdepends = ['dbus']
pkgdesc = 'Centralized access to appointments and contacts'
maintainer = 'q66 <q66@chimera-linux.org>'
license = 'LGPL-2.0-or-later'
url = 'https://gitlab.gnome.org/GNOME/evolution-data-server'
source = f'$(GNOME_SITE)/{pkgname}/{pkgver[:-2]}/{pkgname}-{pkgver}.tar.xz'
sha256 = '0d8881b5c51e1b91761b1945db264a46aabf54a73eea1ca8f448b207815d582e'
tool_flags = {'CFLAGS': ['-Wno-unused-command-line-argument']}
options = ['!cross']
def post_install(self):
self.rm(self.destdir / 'usr/lib/systemd', recursive=True)
@subpackage('evolution-data-server-devel')
def _devel(self):
return self.default_devel() |
budget = float(input())
name = "Hello, there!"
count = 0
diff_count = 0
fee = 0
while True:
name = input()
if name == "Stop":
print(f"You bought {count} products for {fee:.2f} leva.")
break
price = float(input())
diff_count += 1
if diff_count%3 == 0:
price = price / 2
if price > budget:
print(f"You don't have enough money!")
print (f"You need {price-budget:.2f} leva!")
break
budget -= price
fee += price
count += 1
| budget = float(input())
name = 'Hello, there!'
count = 0
diff_count = 0
fee = 0
while True:
name = input()
if name == 'Stop':
print(f'You bought {count} products for {fee:.2f} leva.')
break
price = float(input())
diff_count += 1
if diff_count % 3 == 0:
price = price / 2
if price > budget:
print(f"You don't have enough money!")
print(f'You need {price - budget:.2f} leva!')
break
budget -= price
fee += price
count += 1 |
'''Taking the input of CIPHERTEXT from the user and removing UNWANTED CHARACTERS and/or WHITESPACES'''
Input = input("Enter ciphertext:")
Input = Input.upper()
NotRecog = '''`~1234567890!@#$%^&*()-_=+[{]}\|'";:.>/?,< '''
for i in Input:
if i in NotRecog:
Input = Input.replace(i,'')
'''Taking the input of KEY from the user and removing UNWANTED CHARACTERS and/or WHITESPACES'''
Key = input("Enter key:")
Key = Key.upper()
NotRecog = '''`~1234567890!@#$%^&*()-_=+[{]}\|'";:.>/?,< '''
for i in Key:
if i in NotRecog:
Key = Key.replace(i,'')
'''Making the KEYWORD which will be used to decipher the ciphertext
Keyword is made on the basis of two things:
1) LENGTH of the Ciphertext = Keyword
2) The KEY is REPEATED again and again till the length is statisfied
Ex: Ciphertext: Aeeealuyel
Key: Hippo
Keyword:HippoHippo'''
Keyword = ''
for i in range(0,len(Input)):
if len(Keyword)<=len(Input):
if len(Input)==len(Key):
n = len(Input)
Keyword += Key[0:n]
elif len(Input)-len(Key)<=len(Input)-len(Keyword):
n = len(Input)-len(Key)
Keyword += Key[0:n]
else:
n = len(Input)-len(Keyword)
Keyword += Key[0:n]
if len(Keyword)==len(Input):
break
'''Deciphering the Ciphertext using the Keyword and TempLists
The AlphaList and TempLists are reversed,i.e.,A will be Z, B will be Y and so on, This is the main difference between
Vigenere and Beaufort Cipher'''
AlphaList = ['Z','Y','X','W','V','U','T','S','R','Q','P','O','N','M','L','K','J','I','H','G','F','E','D','C','B','A']
Result = ''
'''Creation of TempLists:
TempLists(Required row of letters from vigenere grid) is made on the basis of Caesar shift.
A Beaufort Square has 26 Rows & Columns each labeled as a LETTER of the ALPHABET in ORDER.
Each row is shifted(Caesar Shift) according to the formula: Index/Number of Label Letter-1
Ex: Let the row be Z
Number of Label Letter: 26
Shift: 26-1=25
After Shifting the List is reversed on the basis explained above.
Deciphering:
Deciphering is done in 3 steps:
1) A letter of the Keyword is taken
2) Corresponding(Same index/number) Letter of Ciphertext is searched in the row of TempLists
3) After finding the Ciphertext Letter the Column Letter/Index(Check the letter at same index in original AlphaList) is
the Deciphered Letter
Ex: Ciphertext: Aeeealuyel
Key: Hippo
Keyword: Hippohippo
Let letter be H
Corresponding Letter in Ciphertext: A
TempList: ['H', 'G', 'F', 'E', 'D', 'C', 'B', 'A', 'Z', 'Y', 'X', 'W', 'V', 'U', 'T', 'S', 'R', 'Q', 'P', 'O', 'N', 'M', 'L', 'K', 'J', 'I']
Location of A in TempList: Index 7
In AlphaList at Index 7 is H
ColumnName/Index: H
Deciphered Letter: H'''
for i in range(0,len(Keyword)):
TempLi = ['Z','Y','X','W','V','U','T','S','R','Q','P','O','N','M','L','K','J','I','H','G','F','E','D','C','B','A']
if Keyword[i]=='A':
Result += Input[i]
else:
for j in range(0,AlphaList.index(Keyword[i])):
TempLi+=[TempLi.pop(0)]
L = Input[i]
n = TempLi.index(L)
Result += AlphaList[25-n]
print("Deciphered text:",Result) | """Taking the input of CIPHERTEXT from the user and removing UNWANTED CHARACTERS and/or WHITESPACES"""
input = input('Enter ciphertext:')
input = Input.upper()
not_recog = '`~1234567890!@#$%^&*()-_=+[{]}\\|\'";:.>/?,< '
for i in Input:
if i in NotRecog:
input = Input.replace(i, '')
'Taking the input of KEY from the user and removing UNWANTED CHARACTERS and/or WHITESPACES'
key = input('Enter key:')
key = Key.upper()
not_recog = '`~1234567890!@#$%^&*()-_=+[{]}\\|\'";:.>/?,< '
for i in Key:
if i in NotRecog:
key = Key.replace(i, '')
'Making the KEYWORD which will be used to decipher the ciphertext\nKeyword is made on the basis of two things:\n1) LENGTH of the Ciphertext = Keyword\n2) The KEY is REPEATED again and again till the length is statisfied\nEx: Ciphertext: Aeeealuyel\n Key: Hippo\n Keyword:HippoHippo'
keyword = ''
for i in range(0, len(Input)):
if len(Keyword) <= len(Input):
if len(Input) == len(Key):
n = len(Input)
keyword += Key[0:n]
elif len(Input) - len(Key) <= len(Input) - len(Keyword):
n = len(Input) - len(Key)
keyword += Key[0:n]
else:
n = len(Input) - len(Keyword)
keyword += Key[0:n]
if len(Keyword) == len(Input):
break
'Deciphering the Ciphertext using the Keyword and TempLists\nThe AlphaList and TempLists are reversed,i.e.,A will be Z, B will be Y and so on, This is the main difference between \nVigenere and Beaufort Cipher'
alpha_list = ['Z', 'Y', 'X', 'W', 'V', 'U', 'T', 'S', 'R', 'Q', 'P', 'O', 'N', 'M', 'L', 'K', 'J', 'I', 'H', 'G', 'F', 'E', 'D', 'C', 'B', 'A']
result = ''
"Creation of TempLists:\nTempLists(Required row of letters from vigenere grid) is made on the basis of Caesar shift.\nA Beaufort Square has 26 Rows & Columns each labeled as a LETTER of the ALPHABET in ORDER.\nEach row is shifted(Caesar Shift) according to the formula: Index/Number of Label Letter-1\nEx: Let the row be Z\n Number of Label Letter: 26\n Shift: 26-1=25\nAfter Shifting the List is reversed on the basis explained above.\n\nDeciphering:\nDeciphering is done in 3 steps:\n1) A letter of the Keyword is taken\n2) Corresponding(Same index/number) Letter of Ciphertext is searched in the row of TempLists\n3) After finding the Ciphertext Letter the Column Letter/Index(Check the letter at same index in original AlphaList) is\nthe Deciphered Letter\nEx: Ciphertext: Aeeealuyel\n Key: Hippo\n Keyword: Hippohippo\n Let letter be H\n Corresponding Letter in Ciphertext: A\n TempList: ['H', 'G', 'F', 'E', 'D', 'C', 'B', 'A', 'Z', 'Y', 'X', 'W', 'V', 'U', 'T', 'S', 'R', 'Q', 'P', 'O', 'N', 'M', 'L', 'K', 'J', 'I']\n Location of A in TempList: Index 7\n In AlphaList at Index 7 is H\n ColumnName/Index: H\n Deciphered Letter: H"
for i in range(0, len(Keyword)):
temp_li = ['Z', 'Y', 'X', 'W', 'V', 'U', 'T', 'S', 'R', 'Q', 'P', 'O', 'N', 'M', 'L', 'K', 'J', 'I', 'H', 'G', 'F', 'E', 'D', 'C', 'B', 'A']
if Keyword[i] == 'A':
result += Input[i]
else:
for j in range(0, AlphaList.index(Keyword[i])):
temp_li += [TempLi.pop(0)]
l = Input[i]
n = TempLi.index(L)
result += AlphaList[25 - n]
print('Deciphered text:', Result) |
class Geometric:
def Area(self, x, y):
return x * y
| class Geometric:
def area(self, x, y):
return x * y |
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
#
"""
Legal content, should offer a lot of fun to write, this is not used so far
"""
__version__ = '4.0'
content = {
'classified_headline':(
'Commercial Rentals', 'Business Opportunities', 'Bed & Breakfast', 'Year Round Rentals',
'Winter Rentals', 'Apartments/Rooms', 'Vacation/Summer Rentals', 'Off-Island Rentals', 'Rentals Wanted',
'Articles For Sale', 'Yard Sales', 'Wanted', 'Music & Arts', 'Pets & Livestock', 'Help Wanted',
'Child Care Wanted', 'CareGiving Offered', 'Instruction', 'Services', 'Home Services',
'Landscaping & Gardening', 'Heating Supplies & Service', 'Announcements', 'Public Notices',
'Lost & Found', 'Legal Notices <#city#>', 'Bargain Box'),
}
| """
Legal content, should offer a lot of fun to write, this is not used so far
"""
__version__ = '4.0'
content = {'classified_headline': ('Commercial Rentals', 'Business Opportunities', 'Bed & Breakfast', 'Year Round Rentals', 'Winter Rentals', 'Apartments/Rooms', 'Vacation/Summer Rentals', 'Off-Island Rentals', 'Rentals Wanted', 'Articles For Sale', 'Yard Sales', 'Wanted', 'Music & Arts', 'Pets & Livestock', 'Help Wanted', 'Child Care Wanted', 'CareGiving Offered', 'Instruction', 'Services', 'Home Services', 'Landscaping & Gardening', 'Heating Supplies & Service', 'Announcements', 'Public Notices', 'Lost & Found', 'Legal Notices <#city#>', 'Bargain Box')} |
# Solution to day 10 of AOC 2015, Elves Look, Elves Say
# https://adventofcode.com/2015/day/10
new_sequence = '1113222113'
for i in range(50):
print('i, len(new_sequence)', i, len(new_sequence))
sequence = new_sequence
run_digit = None
run_length = 0
new_sequence = ''
for head in sequence:
if run_digit is not None and run_digit != head: # Time to add to new_sequence.
new_sequence = new_sequence + str(run_length) + run_digit
# Start new run.
run_length = 1
else:
run_length += 1
run_digit = head
new_sequence = new_sequence + str(run_length) + run_digit # Time to add to new_sequence.
# print('sequence, new_sequence:', new_sequence)
print('Solution:', len(new_sequence))
| new_sequence = '1113222113'
for i in range(50):
print('i, len(new_sequence)', i, len(new_sequence))
sequence = new_sequence
run_digit = None
run_length = 0
new_sequence = ''
for head in sequence:
if run_digit is not None and run_digit != head:
new_sequence = new_sequence + str(run_length) + run_digit
run_length = 1
else:
run_length += 1
run_digit = head
new_sequence = new_sequence + str(run_length) + run_digit
print('Solution:', len(new_sequence)) |
# Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.
#
# Symbol Value
# I 1
# V 5
# X 10
# L 50
# C 100
# D 500
# M 1000
# For example, two is written as II in Roman numeral, just two one's added together. Twelve is written as, XII, which is simply X + II. The number twenty seven is written as XXVII, which is XX + V + II.
#
# Roman numerals are usually written largest to smallest from left to right. However, the numeral for four is not IIII. Instead, the number four is written as IV. Because the one is before the five we subtract it making four. The same principle applies to the number nine, which is written as IX. There are six instances where subtraction is used:
#
# I can be placed before V (5) and X (10) to make 4 and 9.
# X can be placed before L (50) and C (100) to make 40 and 90.
# C can be placed before D (500) and M (1000) to make 400 and 900.
# Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999.
#
# Example 1:
#
# Input: 3
# Output: "III"
# Example 2:
#
# Input: 4
# Output: "IV"
# Example 3:
#
# Input: 9
# Output: "IX"
# Example 4:
#
# Input: 58
# Output: "LVIII"
# Explanation: C = 100, L = 50, XXX = 30 and III = 3.
# Example 5:
#
# Input: 1994
# Output: "MCMXCIV"
# Explanation: M = 1000, CM = 900, XC = 90 and IV = 4.
class Solution(object):
def intToRoman(self, num):
"""
:type num: int
:rtype: str
"""
total = ''
while num >= 1000:
total += "M"
num -= 1000
if 899 < num <= 999:
total += "CM"
num -= 900
if 500 <= num < 900:
total += "D"
num -= 500
if 399 < num <= 499:
total += "CD"
num -= 400
while num > 99:
total += "C"
num -= 100
if 89 < num <= 99:
total += "XC"
num -= 90
if 50 <= num < 90:
total += "L"
num -= 50
if 39 < num <= 49:
total += "XL"
num -= 40
while num > 9:
total += "X"
num -= 10
if num == 9:
total += "IX"
num = 0
if 5 <= num < 9:
total += "V"
num -= 5
if num == 4:
total += "IV"
num = 0
while num > 0:
total += "I"
num -= 1
return total
| class Solution(object):
def int_to_roman(self, num):
"""
:type num: int
:rtype: str
"""
total = ''
while num >= 1000:
total += 'M'
num -= 1000
if 899 < num <= 999:
total += 'CM'
num -= 900
if 500 <= num < 900:
total += 'D'
num -= 500
if 399 < num <= 499:
total += 'CD'
num -= 400
while num > 99:
total += 'C'
num -= 100
if 89 < num <= 99:
total += 'XC'
num -= 90
if 50 <= num < 90:
total += 'L'
num -= 50
if 39 < num <= 49:
total += 'XL'
num -= 40
while num > 9:
total += 'X'
num -= 10
if num == 9:
total += 'IX'
num = 0
if 5 <= num < 9:
total += 'V'
num -= 5
if num == 4:
total += 'IV'
num = 0
while num > 0:
total += 'I'
num -= 1
return total |
class Solution:
def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode:
head = list1
for i in range(a - 1):
list1 = list1.next
a_1 = list1
for i in range(b - a + 1):
list1 = list1.next
b_1 = list1.next
list1.next = None
a_1.next = list2
while list2.next:
list2 = list2.next
list2.next = b_1
return head
| class Solution:
def merge_in_between(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode:
head = list1
for i in range(a - 1):
list1 = list1.next
a_1 = list1
for i in range(b - a + 1):
list1 = list1.next
b_1 = list1.next
list1.next = None
a_1.next = list2
while list2.next:
list2 = list2.next
list2.next = b_1
return head |
# problem3.py
# The prime factors of 13195 are 5, 7, 13 and 29.
# What is the largest prime factor of the number 600851475143 ?
number = 600851475143
divider = 2
while number != 1:
if number % divider == 0:
number = number / divider
print(divider)
else:
divider += 1
| number = 600851475143
divider = 2
while number != 1:
if number % divider == 0:
number = number / divider
print(divider)
else:
divider += 1 |
class Solution:
# Accumulator List (Accepted), O(n) time and space
def waysToMakeFair(self, nums: List[int]) -> int:
acc = []
is_even = True
n = len(nums)
for i in range(n):
even, odd = acc[i-1] if i > 0 else (0, 0)
if is_even:
even += nums[i]
else:
odd += nums[i]
is_even = not is_even
acc.append((even, odd))
res = 0
for i in range(n):
even = odd = 0
if i > 0:
even += acc[i-1][0]
odd += acc[i-1][1]
if i < n-1:
even += acc[n-1][1] - acc[i][1]
odd += acc[n-1][0] - acc[i][0]
if even == odd:
res += 1
return res
# Two Sum Pairs for even and odd (Top Voted), O(n) time, O(1) space
def waysToMakeFair(self, A: List[int]) -> int:
s1, s2 = [0, 0], [sum(A[0::2]), sum(A[1::2])]
res = 0
for i, a in enumerate(A):
s2[i % 2] -= a
res += s1[0] + s2[1] == s1[1] + s2[0]
s1[i % 2] += a
return res
| class Solution:
def ways_to_make_fair(self, nums: List[int]) -> int:
acc = []
is_even = True
n = len(nums)
for i in range(n):
(even, odd) = acc[i - 1] if i > 0 else (0, 0)
if is_even:
even += nums[i]
else:
odd += nums[i]
is_even = not is_even
acc.append((even, odd))
res = 0
for i in range(n):
even = odd = 0
if i > 0:
even += acc[i - 1][0]
odd += acc[i - 1][1]
if i < n - 1:
even += acc[n - 1][1] - acc[i][1]
odd += acc[n - 1][0] - acc[i][0]
if even == odd:
res += 1
return res
def ways_to_make_fair(self, A: List[int]) -> int:
(s1, s2) = ([0, 0], [sum(A[0::2]), sum(A[1::2])])
res = 0
for (i, a) in enumerate(A):
s2[i % 2] -= a
res += s1[0] + s2[1] == s1[1] + s2[0]
s1[i % 2] += a
return res |
#!/usr/bin/python3
def list_division(my_list_1, my_list_2, list_length):
idx = 0
results = []
error = None
while list_division and idx < list_length:
try:
results.append(my_list_1[idx] / my_list_2[idx])
except ZeroDivisionError:
error = "division by 0"
results.append(0)
except(TypeError, ValueError):
error = "wrong type"
results.append(0)
except IndexError:
error = "out of range"
results.append(0)
finally:
if error is not None:
print(error)
error = None
idx += 1
return results
| def list_division(my_list_1, my_list_2, list_length):
idx = 0
results = []
error = None
while list_division and idx < list_length:
try:
results.append(my_list_1[idx] / my_list_2[idx])
except ZeroDivisionError:
error = 'division by 0'
results.append(0)
except (TypeError, ValueError):
error = 'wrong type'
results.append(0)
except IndexError:
error = 'out of range'
results.append(0)
finally:
if error is not None:
print(error)
error = None
idx += 1
return results |
class Solution(object):
def maxProfit(self, prices):
"""
:type prices: List[int]
:rtype: int
"""
length = len(prices)
if length == 0:
return 0
max_profit, low = 0, prices[0]
for i in range(1, length):
if low > prices[i]:
low = prices[i]
else:
temp = prices[i] - low
if temp > max_profit:
max_profit = temp
return max_profit | class Solution(object):
def max_profit(self, prices):
"""
:type prices: List[int]
:rtype: int
"""
length = len(prices)
if length == 0:
return 0
(max_profit, low) = (0, prices[0])
for i in range(1, length):
if low > prices[i]:
low = prices[i]
else:
temp = prices[i] - low
if temp > max_profit:
max_profit = temp
return max_profit |
# Section 6.2.5 snippets
country_capitals1 = {'Belgium': 'Brussels',
'Haiti': 'Port-au-Prince'}
country_capitals2 = {'Nepal': 'Kathmandu',
'Uruguay': 'Montevideo'}
country_capitals3 = {'Haiti': 'Port-au-Prince',
'Belgium': 'Brussels'}
country_capitals1 == country_capitals2
country_capitals1 == country_capitals3
country_capitals1 != country_capitals2
##########################################################################
# (C) Copyright 2019 by Deitel & Associates, Inc. and #
# Pearson Education, Inc. All Rights Reserved. #
# #
# DISCLAIMER: The authors and publisher of this book have used their #
# best efforts in preparing the book. These efforts include the #
# development, research, and testing of the theories and programs #
# to determine their effectiveness. The authors and publisher make #
# no warranty of any kind, expressed or implied, with regard to these #
# programs or to the documentation contained in these books. The authors #
# and publisher shall not be liable in any event for incidental or #
# consequential damages in connection with, or arising out of, the #
# furnishing, performance, or use of these programs. #
##########################################################################
| country_capitals1 = {'Belgium': 'Brussels', 'Haiti': 'Port-au-Prince'}
country_capitals2 = {'Nepal': 'Kathmandu', 'Uruguay': 'Montevideo'}
country_capitals3 = {'Haiti': 'Port-au-Prince', 'Belgium': 'Brussels'}
country_capitals1 == country_capitals2
country_capitals1 == country_capitals3
country_capitals1 != country_capitals2 |
class BitmexDataIterator():
def __init__(self,data):
self._data = data
self._index = 0
def __next__(self):
pass
class BitmexDataStructure():
"""
Data Object for Bitmex data manipulation
"""
def __init__(self,symbol,use_compression=False):
self._symbol = symbol
self._header = None
self._data = None
self._size = None
self._use_compression = use_compression
def add_data(self,data):
if self._data:
self._ensure_correct_data_format(data)
pass
else:
pass
def save_data(self):
if self._use_compression:
pass
else:
pass
def _ensure_correct_data_format(self,data_to_compare):
pass
def __iter__(self):
return BitmexDataIterator(self) | class Bitmexdataiterator:
def __init__(self, data):
self._data = data
self._index = 0
def __next__(self):
pass
class Bitmexdatastructure:
"""
Data Object for Bitmex data manipulation
"""
def __init__(self, symbol, use_compression=False):
self._symbol = symbol
self._header = None
self._data = None
self._size = None
self._use_compression = use_compression
def add_data(self, data):
if self._data:
self._ensure_correct_data_format(data)
pass
else:
pass
def save_data(self):
if self._use_compression:
pass
else:
pass
def _ensure_correct_data_format(self, data_to_compare):
pass
def __iter__(self):
return bitmex_data_iterator(self) |
N = int(input())
Y = 0
for _ in range(N):
t = input().split()
x = float(t[0])
u = t[1]
if u == 'JPY':
Y += x
elif u == 'BTC':
Y += x * 380000.0
print(Y)
| n = int(input())
y = 0
for _ in range(N):
t = input().split()
x = float(t[0])
u = t[1]
if u == 'JPY':
y += x
elif u == 'BTC':
y += x * 380000.0
print(Y) |
def reverse(x: int) -> int:
neg = x < 0
if neg:
x *= -1
result = 0
while x:
result = result * 10 + x % 10
x //= 10
return result if not neg else -1 * result
assert reverse(123) == 321
assert reverse(-123) == -321
| def reverse(x: int) -> int:
neg = x < 0
if neg:
x *= -1
result = 0
while x:
result = result * 10 + x % 10
x //= 10
return result if not neg else -1 * result
assert reverse(123) == 321
assert reverse(-123) == -321 |
class ParenthesizePropertyNameAttribute(Attribute,_Attribute):
"""
Indicates whether the name of the associated property is displayed with parentheses in the Properties window. This class cannot be inherited.
ParenthesizePropertyNameAttribute()
ParenthesizePropertyNameAttribute(needParenthesis: bool)
"""
def Equals(self,o):
"""
Equals(self: ParenthesizePropertyNameAttribute,o: object) -> bool
Compares the specified object to this object and tests for equality.
o: The object to be compared.
Returns: true if equal; otherwise,false.
"""
pass
def GetHashCode(self):
"""
GetHashCode(self: ParenthesizePropertyNameAttribute) -> int
Gets the hash code for this object.
Returns: The hash code for the object the attribute belongs to.
"""
pass
def IsDefaultAttribute(self):
"""
IsDefaultAttribute(self: ParenthesizePropertyNameAttribute) -> bool
Gets a value indicating whether the current value of the attribute is the
default value for the attribute.
Returns: true if the current value of the attribute is the default value of the
attribute; otherwise,false.
"""
pass
def __eq__(self,*args):
""" x.__eq__(y) <==> x==y """
pass
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
@staticmethod
def __new__(self,needParenthesis=None):
"""
__new__(cls: type)
__new__(cls: type,needParenthesis: bool)
"""
pass
def __ne__(self,*args):
pass
NeedParenthesis=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets a value indicating whether the Properties window displays the name of the property in parentheses in the Properties window.
Get: NeedParenthesis(self: ParenthesizePropertyNameAttribute) -> bool
"""
Default=None
| class Parenthesizepropertynameattribute(Attribute, _Attribute):
"""
Indicates whether the name of the associated property is displayed with parentheses in the Properties window. This class cannot be inherited.
ParenthesizePropertyNameAttribute()
ParenthesizePropertyNameAttribute(needParenthesis: bool)
"""
def equals(self, o):
"""
Equals(self: ParenthesizePropertyNameAttribute,o: object) -> bool
Compares the specified object to this object and tests for equality.
o: The object to be compared.
Returns: true if equal; otherwise,false.
"""
pass
def get_hash_code(self):
"""
GetHashCode(self: ParenthesizePropertyNameAttribute) -> int
Gets the hash code for this object.
Returns: The hash code for the object the attribute belongs to.
"""
pass
def is_default_attribute(self):
"""
IsDefaultAttribute(self: ParenthesizePropertyNameAttribute) -> bool
Gets a value indicating whether the current value of the attribute is the
default value for the attribute.
Returns: true if the current value of the attribute is the default value of the
attribute; otherwise,false.
"""
pass
def __eq__(self, *args):
""" x.__eq__(y) <==> x==y """
pass
def __init__(self, *args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
@staticmethod
def __new__(self, needParenthesis=None):
"""
__new__(cls: type)
__new__(cls: type,needParenthesis: bool)
"""
pass
def __ne__(self, *args):
pass
need_parenthesis = property(lambda self: object(), lambda self, v: None, lambda self: None)
'Gets a value indicating whether the Properties window displays the name of the property in parentheses in the Properties window.\n\n\n\nGet: NeedParenthesis(self: ParenthesizePropertyNameAttribute) -> bool\n\n\n\n'
default = None |
matriz = [[], [], []]
for i in range(0, 3):
matriz[0].append(int(input(f'Digite um valor para [{0}, {i}]: ')))
for i in range(0, 3):
matriz[1].append(int(input(f'Digite um valor para [{1}, {i}]: ')))
for i in range(0, 3):
matriz[2].append(int(input(f'Digite um valor para [{2}, {i}]: ')))
print(f'{matriz[0]}\n{matriz[1]}\n{matriz[2]}')
matriz = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for l in range(0, 3):
for c in range(0, 3):
matriz[[l][c]] = int(input(f'Digite um valor para [{l}, {c}]: '))
print('-=' * 30)
for l in range(0, 3):
for c in range(0, 3):
print(f'[{matriz[l] [c]}]', end='')
print()
| matriz = [[], [], []]
for i in range(0, 3):
matriz[0].append(int(input(f'Digite um valor para [{0}, {i}]: ')))
for i in range(0, 3):
matriz[1].append(int(input(f'Digite um valor para [{1}, {i}]: ')))
for i in range(0, 3):
matriz[2].append(int(input(f'Digite um valor para [{2}, {i}]: ')))
print(f'{matriz[0]}\n{matriz[1]}\n{matriz[2]}')
matriz = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for l in range(0, 3):
for c in range(0, 3):
matriz[[l][c]] = int(input(f'Digite um valor para [{l}, {c}]: '))
print('-=' * 30)
for l in range(0, 3):
for c in range(0, 3):
print(f'[{matriz[l][c]}]', end='')
print() |
r"""Psuedo-spectral implementations of some useful equations
In PsDNS, equations are represented as class objects that implement a
:meth:`rhs` method. The :meth:`rhs` method takes one argument,
*uhat*, which is the solution vector, normally in spectral space
expressed as a :class:`~psdns.bases.SpectralArray`, and it returns the
right-hand side vector. That is, for the PDE
.. math::
\frac{\partial}{\partial t} \boldsymbol{U}(t)
= \boldsymbol{F}[\boldsymbol{U}]
the :meth:`rhs` method takes :math:`\boldsymbol{U}` and returns
:math:`\boldsymbol{F}[\boldsymbol{U}]`.
Since normally only a single equation is needed in a given script,
no equations are imported by default when importing :mod:`psdns`.
Users can also implement their own equations. There is no need to
subclass from any specific base class, any class that implements a
:meth:`rhs` method can be used as an equation.
The :mod:`~psdns.equations` sub-module also includes some functions
that return initial conditions for certain canonical problems, either
in the form of stand-alone functions, or class methods.
"""
| """Psuedo-spectral implementations of some useful equations
In PsDNS, equations are represented as class objects that implement a
:meth:`rhs` method. The :meth:`rhs` method takes one argument,
*uhat*, which is the solution vector, normally in spectral space
expressed as a :class:`~psdns.bases.SpectralArray`, and it returns the
right-hand side vector. That is, for the PDE
.. math::
\\frac{\\partial}{\\partial t} \\boldsymbol{U}(t)
= \\boldsymbol{F}[\\boldsymbol{U}]
the :meth:`rhs` method takes :math:`\\boldsymbol{U}` and returns
:math:`\\boldsymbol{F}[\\boldsymbol{U}]`.
Since normally only a single equation is needed in a given script,
no equations are imported by default when importing :mod:`psdns`.
Users can also implement their own equations. There is no need to
subclass from any specific base class, any class that implements a
:meth:`rhs` method can be used as an equation.
The :mod:`~psdns.equations` sub-module also includes some functions
that return initial conditions for certain canonical problems, either
in the form of stand-alone functions, or class methods.
""" |
class Solution:
def __init__(self):
self.map = {}
def cloneGraph(self, node):
if node is None:
return None
next = UndirectedGraphNode(node.label)
self.map[str(node.label)] = next
for tmp in node.neighbors:
if str(tmp.label) in self.map:
next.neighbors.append(self.map.get(str(tmp.label)))
else:
next.neighbors.append(self.cloneGraph(tmp))
return self.map.get(str(node.label))
| class Solution:
def __init__(self):
self.map = {}
def clone_graph(self, node):
if node is None:
return None
next = undirected_graph_node(node.label)
self.map[str(node.label)] = next
for tmp in node.neighbors:
if str(tmp.label) in self.map:
next.neighbors.append(self.map.get(str(tmp.label)))
else:
next.neighbors.append(self.cloneGraph(tmp))
return self.map.get(str(node.label)) |
"""
Package used by tests.
"""
C = 3
| """
Package used by tests.
"""
c = 3 |
#!/usr/bin/env python3
"""
Copyright (c) 2017-present, Facebook, Inc.
All rights reserved.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree.
"""
PREFIX = "__osc_"
OUTFILE_TABLE = "__osc_tbl_"
OUTFILE_EXCLUDE_ID = "__osc_ex_"
OUTFILE_INCLUDE_ID = "__osc_in_"
NEW_TABLE_PREFIX = "__osc_new_"
DELTA_TABLE_PREFIX = "__osc_chg_"
RENAMED_TABLE_PREFIX = "__osc_old_"
INSERT_TRIGGER_PREFIX = "__osc_ins_"
UPDATE_TRIGGER_PREFIX = "__osc_upd_"
DELETE_TRIGGER_PREFIX = "__osc_del_"
# tables with 64 character length names need a generic place-holder name
GENERIC_TABLE_NAME = "online_schema_change_temp_tbl"
# Special prefixes for tables that have longer table names
SHORT_NEW_TABLE_PREFIX = "n!"
SHORT_DELTA_TABLE_PREFIX = "c!"
SHORT_RENAMED_TABLE_PREFIX = "o!"
SHORT_INSERT_TRIGGER_PREFIX = "i!"
SHORT_UPDATE_TRIGGER_PREFIX = "u!"
SHORT_DELETE_TRIGGER_PREFIX = "d!"
OSC_LOCK_NAME = "OnlineSchemaChange"
CHUNK_BYTES = 2 * 1024 * 1024
REPLAY_DEFAULT_TIMEOUT = 5 # replay until we can finish in 5 seconds
DEFAULT_BATCH_SIZE = 500
DEFAULT_REPLAY_ATTEMPT = 10
DEFAULT_RESERVED_SPACE_PERCENT = 1
LONG_TRX_TIME = 30
MAX_RUNNING_BEFORE_DDL = 200
DDL_GUARD_ATTEMPTS = 600
LOCK_MAX_ATTEMPTS = 3
LOCK_MAX_WAIT_BEFORE_KILL_SECONDS = 0.5
SESSION_TIMEOUT = 600
DEFAULT_REPLAY_GROUP_SIZE = 200
PK_COVERAGE_SIZE_THRESHOLD = 500 * 1024 * 1024
MAX_WAIT_FOR_SLOW_QUERY = 100
MAX_TABLE_LENGTH = 64
MAX_REPLAY_BATCH_SIZE = 500000
MAX_REPLAY_CHANGES = 2146483647
| """
Copyright (c) 2017-present, Facebook, Inc.
All rights reserved.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree.
"""
prefix = '__osc_'
outfile_table = '__osc_tbl_'
outfile_exclude_id = '__osc_ex_'
outfile_include_id = '__osc_in_'
new_table_prefix = '__osc_new_'
delta_table_prefix = '__osc_chg_'
renamed_table_prefix = '__osc_old_'
insert_trigger_prefix = '__osc_ins_'
update_trigger_prefix = '__osc_upd_'
delete_trigger_prefix = '__osc_del_'
generic_table_name = 'online_schema_change_temp_tbl'
short_new_table_prefix = 'n!'
short_delta_table_prefix = 'c!'
short_renamed_table_prefix = 'o!'
short_insert_trigger_prefix = 'i!'
short_update_trigger_prefix = 'u!'
short_delete_trigger_prefix = 'd!'
osc_lock_name = 'OnlineSchemaChange'
chunk_bytes = 2 * 1024 * 1024
replay_default_timeout = 5
default_batch_size = 500
default_replay_attempt = 10
default_reserved_space_percent = 1
long_trx_time = 30
max_running_before_ddl = 200
ddl_guard_attempts = 600
lock_max_attempts = 3
lock_max_wait_before_kill_seconds = 0.5
session_timeout = 600
default_replay_group_size = 200
pk_coverage_size_threshold = 500 * 1024 * 1024
max_wait_for_slow_query = 100
max_table_length = 64
max_replay_batch_size = 500000
max_replay_changes = 2146483647 |
with open('input.txt') as f:
octopus = list(map(lambda line: list(map(int, line.strip())), f.readlines()))
def print_grid(grid):
for line in grid:
print(''.join(map(str, line)))
def update(grid):
flash_count = 0
# increase all
flashed = set()
to_updates = []
for row in range(len(grid)):
for col in range(len(grid[0])):
grid[row][col] += 1
if grid[row][col] >= 10:
flashed.add((row, col))
to_updates.extend(
list(filter(
lambda x: x[0] >= 0 and x[0] < len(grid) and x[1] >= 0 and x[1] < len(grid[0]),
[(row + delta_row, col + delta_col) for delta_row in range(-1, 2) for delta_col in range(-1, 2)]
))
)
# loop update
while len(to_updates) > 0:
row, col = to_updates.pop()
if (row, col) in flashed: continue
grid[row][col] += 1
if grid[row][col] >= 10:
flashed.add((row, col))
to_updates.extend(
list(filter(
lambda x: x[0] >= 0 and x[0] < len(grid) and x[1] >= 0 and x[1] < len(grid[0]),
[(row + delta_row, col + delta_col) for delta_row in range(-1, 2) for delta_col in range(-1, 2)]
))
)
# clear
for row in range(len(grid)):
for col in range(len(grid[0])):
if grid[row][col] >= 10:
grid[row][col] = 0
flash_count += 1
def check_all_flash(grid):
return all(map(lambda line: sum(line) == 0, grid))
res = 0
while True:
update(octopus)
res += 1
if check_all_flash(octopus):
break
print(res)
| with open('input.txt') as f:
octopus = list(map(lambda line: list(map(int, line.strip())), f.readlines()))
def print_grid(grid):
for line in grid:
print(''.join(map(str, line)))
def update(grid):
flash_count = 0
flashed = set()
to_updates = []
for row in range(len(grid)):
for col in range(len(grid[0])):
grid[row][col] += 1
if grid[row][col] >= 10:
flashed.add((row, col))
to_updates.extend(list(filter(lambda x: x[0] >= 0 and x[0] < len(grid) and (x[1] >= 0) and (x[1] < len(grid[0])), [(row + delta_row, col + delta_col) for delta_row in range(-1, 2) for delta_col in range(-1, 2)])))
while len(to_updates) > 0:
(row, col) = to_updates.pop()
if (row, col) in flashed:
continue
grid[row][col] += 1
if grid[row][col] >= 10:
flashed.add((row, col))
to_updates.extend(list(filter(lambda x: x[0] >= 0 and x[0] < len(grid) and (x[1] >= 0) and (x[1] < len(grid[0])), [(row + delta_row, col + delta_col) for delta_row in range(-1, 2) for delta_col in range(-1, 2)])))
for row in range(len(grid)):
for col in range(len(grid[0])):
if grid[row][col] >= 10:
grid[row][col] = 0
flash_count += 1
def check_all_flash(grid):
return all(map(lambda line: sum(line) == 0, grid))
res = 0
while True:
update(octopus)
res += 1
if check_all_flash(octopus):
break
print(res) |
#
# PySNMP MIB module CISCO-FIPS-STATS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-FIPS-STATS-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:41:23 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")
ConstraintsUnion, ValueRangeConstraint, ValueSizeConstraint, ConstraintsIntersection, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsIntersection", "SingleValueConstraint")
ciscoMgmt, = mibBuilder.importSymbols("CISCO-SMI", "ciscoMgmt")
ObjectGroup, NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "ObjectGroup", "NotificationGroup", "ModuleCompliance")
NotificationType, Bits, Counter64, MibScalar, MibTable, MibTableRow, MibTableColumn, TimeTicks, Integer32, IpAddress, iso, Gauge32, MibIdentifier, ModuleIdentity, Unsigned32, ObjectIdentity, Counter32 = mibBuilder.importSymbols("SNMPv2-SMI", "NotificationType", "Bits", "Counter64", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "TimeTicks", "Integer32", "IpAddress", "iso", "Gauge32", "MibIdentifier", "ModuleIdentity", "Unsigned32", "ObjectIdentity", "Counter32")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
ciscoFipsStatsMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 9, 9, 999999))
ciscoFipsStatsMIB.setRevisions(('2003-03-10 00:00',))
if mibBuilder.loadTexts: ciscoFipsStatsMIB.setLastUpdated('200303100000Z')
if mibBuilder.loadTexts: ciscoFipsStatsMIB.setOrganization('Cisco Systems, Inc.')
ciscoFipsStatsMIBNotifs = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 999999, 0))
ciscoFipsStatsMIBObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 999999, 1))
ciscoFipsStatsMIBConform = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 999999, 2))
cfipsStats = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 999999, 1, 1))
cfipsStatsGlobal = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 999999, 1, 1, 1))
cfipsPostStatus = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 999999, 1, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("running", 1), ("passed", 2), ("failed", 3), ("notAvailable", 4))).clone('notAvailable')).setMaxAccess("readonly")
if mibBuilder.loadTexts: cfipsPostStatus.setStatus('current')
ciscoFipsStatsMIBCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 999999, 2, 1))
ciscoFipsStatsMIBGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 999999, 2, 2))
ciscoFipsStatsMIBCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 9, 9, 999999, 2, 1, 1)).setObjects(("CISCO-FIPS-STATS-MIB", "ciscoFipsStatsMIBGroup"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoFipsStatsMIBCompliance = ciscoFipsStatsMIBCompliance.setStatus('current')
ciscoFipsStatsMIBGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 9, 999999, 2, 2, 1)).setObjects(("CISCO-FIPS-STATS-MIB", "cfipsPostStatus"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoFipsStatsMIBGroup = ciscoFipsStatsMIBGroup.setStatus('current')
mibBuilder.exportSymbols("CISCO-FIPS-STATS-MIB", PYSNMP_MODULE_ID=ciscoFipsStatsMIB, ciscoFipsStatsMIBObjects=ciscoFipsStatsMIBObjects, ciscoFipsStatsMIB=ciscoFipsStatsMIB, ciscoFipsStatsMIBNotifs=ciscoFipsStatsMIBNotifs, ciscoFipsStatsMIBGroup=ciscoFipsStatsMIBGroup, cfipsPostStatus=cfipsPostStatus, ciscoFipsStatsMIBCompliance=ciscoFipsStatsMIBCompliance, ciscoFipsStatsMIBGroups=ciscoFipsStatsMIBGroups, ciscoFipsStatsMIBConform=ciscoFipsStatsMIBConform, ciscoFipsStatsMIBCompliances=ciscoFipsStatsMIBCompliances, cfipsStats=cfipsStats, cfipsStatsGlobal=cfipsStatsGlobal)
| (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_range_constraint, value_size_constraint, constraints_intersection, single_value_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsUnion', 'ValueRangeConstraint', 'ValueSizeConstraint', 'ConstraintsIntersection', 'SingleValueConstraint')
(cisco_mgmt,) = mibBuilder.importSymbols('CISCO-SMI', 'ciscoMgmt')
(object_group, notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'ObjectGroup', 'NotificationGroup', 'ModuleCompliance')
(notification_type, bits, counter64, mib_scalar, mib_table, mib_table_row, mib_table_column, time_ticks, integer32, ip_address, iso, gauge32, mib_identifier, module_identity, unsigned32, object_identity, counter32) = mibBuilder.importSymbols('SNMPv2-SMI', 'NotificationType', 'Bits', 'Counter64', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'TimeTicks', 'Integer32', 'IpAddress', 'iso', 'Gauge32', 'MibIdentifier', 'ModuleIdentity', 'Unsigned32', 'ObjectIdentity', 'Counter32')
(display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention')
cisco_fips_stats_mib = module_identity((1, 3, 6, 1, 4, 1, 9, 9, 999999))
ciscoFipsStatsMIB.setRevisions(('2003-03-10 00:00',))
if mibBuilder.loadTexts:
ciscoFipsStatsMIB.setLastUpdated('200303100000Z')
if mibBuilder.loadTexts:
ciscoFipsStatsMIB.setOrganization('Cisco Systems, Inc.')
cisco_fips_stats_mib_notifs = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 999999, 0))
cisco_fips_stats_mib_objects = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 999999, 1))
cisco_fips_stats_mib_conform = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 999999, 2))
cfips_stats = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 999999, 1, 1))
cfips_stats_global = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 999999, 1, 1, 1))
cfips_post_status = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 999999, 1, 1, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('running', 1), ('passed', 2), ('failed', 3), ('notAvailable', 4))).clone('notAvailable')).setMaxAccess('readonly')
if mibBuilder.loadTexts:
cfipsPostStatus.setStatus('current')
cisco_fips_stats_mib_compliances = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 999999, 2, 1))
cisco_fips_stats_mib_groups = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 999999, 2, 2))
cisco_fips_stats_mib_compliance = module_compliance((1, 3, 6, 1, 4, 1, 9, 9, 999999, 2, 1, 1)).setObjects(('CISCO-FIPS-STATS-MIB', 'ciscoFipsStatsMIBGroup'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
cisco_fips_stats_mib_compliance = ciscoFipsStatsMIBCompliance.setStatus('current')
cisco_fips_stats_mib_group = object_group((1, 3, 6, 1, 4, 1, 9, 9, 999999, 2, 2, 1)).setObjects(('CISCO-FIPS-STATS-MIB', 'cfipsPostStatus'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
cisco_fips_stats_mib_group = ciscoFipsStatsMIBGroup.setStatus('current')
mibBuilder.exportSymbols('CISCO-FIPS-STATS-MIB', PYSNMP_MODULE_ID=ciscoFipsStatsMIB, ciscoFipsStatsMIBObjects=ciscoFipsStatsMIBObjects, ciscoFipsStatsMIB=ciscoFipsStatsMIB, ciscoFipsStatsMIBNotifs=ciscoFipsStatsMIBNotifs, ciscoFipsStatsMIBGroup=ciscoFipsStatsMIBGroup, cfipsPostStatus=cfipsPostStatus, ciscoFipsStatsMIBCompliance=ciscoFipsStatsMIBCompliance, ciscoFipsStatsMIBGroups=ciscoFipsStatsMIBGroups, ciscoFipsStatsMIBConform=ciscoFipsStatsMIBConform, ciscoFipsStatsMIBCompliances=ciscoFipsStatsMIBCompliances, cfipsStats=cfipsStats, cfipsStatsGlobal=cfipsStatsGlobal) |
N = int(input())
a = list(map(int, input().split()))
s = float("inf")
for i in range(min(a), max(a) + 1):
t = 0
for j in a:
t += (j - i) ** 2
s = min(s, t)
print(s)
| n = int(input())
a = list(map(int, input().split()))
s = float('inf')
for i in range(min(a), max(a) + 1):
t = 0
for j in a:
t += (j - i) ** 2
s = min(s, t)
print(s) |
class LoginBase():
freeTimeExpires = -1
def __init__(self, cr):
self.cr = cr
def sendLoginMsg(self, loginName, password, createFlag):
pass
def getErrorCode(self):
return 0
def needToSetParentPassword(self):
return 0 | class Loginbase:
free_time_expires = -1
def __init__(self, cr):
self.cr = cr
def send_login_msg(self, loginName, password, createFlag):
pass
def get_error_code(self):
return 0
def need_to_set_parent_password(self):
return 0 |
class RequiredClass:
pass
def main():
required = RequiredClass()
print(required)
if __name__ == '__main__':
main()
| class Requiredclass:
pass
def main():
required = required_class()
print(required)
if __name__ == '__main__':
main() |
def join_topic(part1: str, part2: str):
p1 = part1.rstrip('/')
p2 = part2.rstrip('/')
return p1 + '/' + p2
| def join_topic(part1: str, part2: str):
p1 = part1.rstrip('/')
p2 = part2.rstrip('/')
return p1 + '/' + p2 |
# encoding: utf-8
class DropShadowFilter(object):
def __init__(self, distance=4.0, angle=45.0, color=0, alpha=1.0,
blurX=4.0, blurY=4.0, strength=1.0, quality=1,
inner=False, knockout=False, hideObject=False):
self._type = 'DropShadowFilter'
self.distance = distance
self.angle = angle
self.color = color
self.alpha = alpha
self.blurX = blurX
self.blurY = blurY
self.strength = strength
self.quality = quality
self.inner = inner
self.knockout = knockout
self.hideObject = hideObject
def clone(self):
return DropShadowFilter(self.distance, self.angle, self.color,
self.alpha, self.blurX, self.blurY,
self.strength, self.quality,
self.inner, self.knockout,
self.hideObject) | class Dropshadowfilter(object):
def __init__(self, distance=4.0, angle=45.0, color=0, alpha=1.0, blurX=4.0, blurY=4.0, strength=1.0, quality=1, inner=False, knockout=False, hideObject=False):
self._type = 'DropShadowFilter'
self.distance = distance
self.angle = angle
self.color = color
self.alpha = alpha
self.blurX = blurX
self.blurY = blurY
self.strength = strength
self.quality = quality
self.inner = inner
self.knockout = knockout
self.hideObject = hideObject
def clone(self):
return drop_shadow_filter(self.distance, self.angle, self.color, self.alpha, self.blurX, self.blurY, self.strength, self.quality, self.inner, self.knockout, self.hideObject) |
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 12 13:38:30 2022
@author: mlols
"""
def hk_modes(hier_num):
"""
Generate modes in the HK hierarchy.
Parameters
----------
hier_num : int
Number in the HK hierarchy (hier_num = n means the nth model).
Returns
-------
p_modes : list
List of psi modes, represented as tuples.
Each tuple contains the horizontal and vertical wavenumbers.
t_modes : list
List of theta modes, represented as tuples.
Examples
--------
>>> p_modes, t_modes = hk_modes(1)
>>> print(p_modes)
[(0, 1), (1, 1)]
>>> print(t_modes)
[(0, 2), (1,1)]
>>> p_modes, t_modes = hk_modes(2)
>>> print(p_modes)
[(0, 1), (0, 3), (1, 1), (1, 2)]
>>> print(t_modes)
[(0, 2), (0, 4), (1,1), (1, 2)]
"""
p_modes = [(0,1), (1,1)] #Base model
t_modes = [(0,2), (1,1)]
current_pair = (1,1) #
#Add pairs of modes. Fills shells of constant L1 norm by increasing norm.
#Within shell, fills modes in descending lexicographical order.
#When starting new shell, add modes of zero horiz wavenumber.
for i in range(1, hier_num):
if current_pair[1] == 1:
level = current_pair[0]+1
current_pair = (1, level)
p_modes.append((0, level*2-1))
t_modes.append((0, level*2))
else:
current_pair = (current_pair[0]+1, current_pair[1]-1)
p_modes.append(current_pair)
t_modes.append(current_pair)
p_modes.sort()
t_modes.sort()
return p_modes, t_modes | """
Created on Sat Feb 12 13:38:30 2022
@author: mlols
"""
def hk_modes(hier_num):
"""
Generate modes in the HK hierarchy.
Parameters
----------
hier_num : int
Number in the HK hierarchy (hier_num = n means the nth model).
Returns
-------
p_modes : list
List of psi modes, represented as tuples.
Each tuple contains the horizontal and vertical wavenumbers.
t_modes : list
List of theta modes, represented as tuples.
Examples
--------
>>> p_modes, t_modes = hk_modes(1)
>>> print(p_modes)
[(0, 1), (1, 1)]
>>> print(t_modes)
[(0, 2), (1,1)]
>>> p_modes, t_modes = hk_modes(2)
>>> print(p_modes)
[(0, 1), (0, 3), (1, 1), (1, 2)]
>>> print(t_modes)
[(0, 2), (0, 4), (1,1), (1, 2)]
"""
p_modes = [(0, 1), (1, 1)]
t_modes = [(0, 2), (1, 1)]
current_pair = (1, 1)
for i in range(1, hier_num):
if current_pair[1] == 1:
level = current_pair[0] + 1
current_pair = (1, level)
p_modes.append((0, level * 2 - 1))
t_modes.append((0, level * 2))
else:
current_pair = (current_pair[0] + 1, current_pair[1] - 1)
p_modes.append(current_pair)
t_modes.append(current_pair)
p_modes.sort()
t_modes.sort()
return (p_modes, t_modes) |
#!/usr/bin/env python3
class Solution:
def setZeroes(self, matrix):
nrow, ncol = len(matrix), len(matrix[0])
for i in range(nrow):
for j in range(ncol):
if matrix[i][j] == 0:
matrix[i][j] = 'X'
for k in range(ncol):
if matrix[i][k] != 0:
matrix[i][k] = 'X'
for k in range(nrow):
if matrix[k][j] != 0:
matrix[k][j] = 'X'
for i in range(nrow):
for j in range(ncol):
if matrix[i][j] == 'X':
matrix[i][j] = 0
for i in range(nrow):
print(matrix[i])
matrix = [[0,1,2,0],[3,4,5,2],[1,3,1,5]]
matrix = [[1,1,1],[1,0,1],[1,1,1]]
sol = Solution()
sol.setZeroes(matrix)
| class Solution:
def set_zeroes(self, matrix):
(nrow, ncol) = (len(matrix), len(matrix[0]))
for i in range(nrow):
for j in range(ncol):
if matrix[i][j] == 0:
matrix[i][j] = 'X'
for k in range(ncol):
if matrix[i][k] != 0:
matrix[i][k] = 'X'
for k in range(nrow):
if matrix[k][j] != 0:
matrix[k][j] = 'X'
for i in range(nrow):
for j in range(ncol):
if matrix[i][j] == 'X':
matrix[i][j] = 0
for i in range(nrow):
print(matrix[i])
matrix = [[0, 1, 2, 0], [3, 4, 5, 2], [1, 3, 1, 5]]
matrix = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]
sol = solution()
sol.setZeroes(matrix) |
""" Class description goes here. """
"""Exceptions classes used in dataclay."""
__author__ = 'Alex Barcelo <alex.barcelo@bsc.es>'
__copyright__ = '2015 Barcelona Supercomputing Center (BSC-CNS)'
| """ Class description goes here. """
'Exceptions classes used in dataclay.'
__author__ = 'Alex Barcelo <alex.barcelo@bsc.es>'
__copyright__ = '2015 Barcelona Supercomputing Center (BSC-CNS)' |
# Parameters
BEHAVIORS = 'behaviors'
STIMULUS_ELEMENTS = 'stimulus_elements'
MECHANISM_NAME = 'mechanism'
START_V = 'start_v'
START_VSS = 'start_vss'
START_W = 'start_w'
ALPHA_V = 'alpha_v'
ALPHA_VSS = 'alpha_vss'
ALPHA_W = 'alpha_w'
BETA = 'beta'
MU = 'mu'
DISCOUNT = 'discount'
TRACE = 'trace'
BEHAVIOR_COST = 'behavior_cost'
U = 'u'
LAMBDA = 'lambda'
RESPONSE_REQUIREMENTS = 'response_requirements'
BIND_TRIALS = 'bind_trials'
N_SUBJECTS = 'n_subjects'
TITLE = 'title'
SUBPLOTTITLE = 'subplottitle'
RUNLABEL = 'runlabel'
SUBJECT = 'subject'
XSCALE = 'xscale'
XSCALE_MATCH = 'xscale_match'
PHASES = 'phases'
CUMULATIVE = 'cumulative'
MATCH = 'match'
FILENAME = 'filename'
# Commands
RUN = '@run'
VARIABLES = '@variables'
PHASE = '@phase'
FIGURE = '@figure'
SUBPLOT = '@subplot'
LEGEND = '@legend'
VPLOT = '@vplot'
VSSPLOT = '@vssplot'
WPLOT = '@wplot'
PPLOT = '@pplot'
NPLOT = '@nplot'
VEXPORT = '@vexport'
WEXPORT = '@wexport'
PEXPORT = '@pexport'
NEXPORT = '@nexport'
HEXPORT = '@hexport'
VSSEXPORT = '@vssexport'
# Other
DEFAULT = 'default'
RAND = 'rand'
CHOICE = 'choice'
COUNT = 'count'
COUNT_LINE = 'count_line'
KEYWORDS = (BEHAVIORS,
STIMULUS_ELEMENTS,
MECHANISM_NAME,
START_V,
START_VSS,
START_W,
ALPHA_V,
ALPHA_VSS,
ALPHA_W,
BETA,
MU,
DISCOUNT,
TRACE,
BEHAVIOR_COST,
U,
LAMBDA,
RESPONSE_REQUIREMENTS,
BIND_TRIALS,
N_SUBJECTS,
TITLE,
SUBPLOTTITLE,
RUNLABEL,
SUBJECT,
XSCALE,
XSCALE_MATCH,
PHASES,
CUMULATIVE,
MATCH,
FILENAME,
VARIABLES,
PHASE,
RUN,
FIGURE,
SUBPLOT,
LEGEND,
VPLOT,
VSSPLOT,
WPLOT,
PPLOT,
NPLOT,
VEXPORT,
WEXPORT,
PEXPORT,
NEXPORT,
DEFAULT,
RAND,
COUNT,
COUNT_LINE)
PHASEDIV = '|'
# Properties for evaluation
EVAL_SUBJECT = "subject"
EVAL_RUNLABEL = "runlabel"
# EVAL_EXACTSTEPS = "exact_steps"
EVAL_EXACT = "exact"
# EVAL_EXACTN = "exact_n"
EVAL_CUMULATIVE = "cumulative"
EVAL_PHASES = "phases"
EVAL_FILENAME = "filename"
# Property values for evaluation
EVAL_AVERAGE = "average"
EVAL_ON = "on"
EVAL_OFF = "off"
EVAL_ALL = "all"
| behaviors = 'behaviors'
stimulus_elements = 'stimulus_elements'
mechanism_name = 'mechanism'
start_v = 'start_v'
start_vss = 'start_vss'
start_w = 'start_w'
alpha_v = 'alpha_v'
alpha_vss = 'alpha_vss'
alpha_w = 'alpha_w'
beta = 'beta'
mu = 'mu'
discount = 'discount'
trace = 'trace'
behavior_cost = 'behavior_cost'
u = 'u'
lambda = 'lambda'
response_requirements = 'response_requirements'
bind_trials = 'bind_trials'
n_subjects = 'n_subjects'
title = 'title'
subplottitle = 'subplottitle'
runlabel = 'runlabel'
subject = 'subject'
xscale = 'xscale'
xscale_match = 'xscale_match'
phases = 'phases'
cumulative = 'cumulative'
match = 'match'
filename = 'filename'
run = '@run'
variables = '@variables'
phase = '@phase'
figure = '@figure'
subplot = '@subplot'
legend = '@legend'
vplot = '@vplot'
vssplot = '@vssplot'
wplot = '@wplot'
pplot = '@pplot'
nplot = '@nplot'
vexport = '@vexport'
wexport = '@wexport'
pexport = '@pexport'
nexport = '@nexport'
hexport = '@hexport'
vssexport = '@vssexport'
default = 'default'
rand = 'rand'
choice = 'choice'
count = 'count'
count_line = 'count_line'
keywords = (BEHAVIORS, STIMULUS_ELEMENTS, MECHANISM_NAME, START_V, START_VSS, START_W, ALPHA_V, ALPHA_VSS, ALPHA_W, BETA, MU, DISCOUNT, TRACE, BEHAVIOR_COST, U, LAMBDA, RESPONSE_REQUIREMENTS, BIND_TRIALS, N_SUBJECTS, TITLE, SUBPLOTTITLE, RUNLABEL, SUBJECT, XSCALE, XSCALE_MATCH, PHASES, CUMULATIVE, MATCH, FILENAME, VARIABLES, PHASE, RUN, FIGURE, SUBPLOT, LEGEND, VPLOT, VSSPLOT, WPLOT, PPLOT, NPLOT, VEXPORT, WEXPORT, PEXPORT, NEXPORT, DEFAULT, RAND, COUNT, COUNT_LINE)
phasediv = '|'
eval_subject = 'subject'
eval_runlabel = 'runlabel'
eval_exact = 'exact'
eval_cumulative = 'cumulative'
eval_phases = 'phases'
eval_filename = 'filename'
eval_average = 'average'
eval_on = 'on'
eval_off = 'off'
eval_all = 'all' |
nums_str = []
with open("dane/dane.txt") as f:
lines = []
for line in f:
sline = line.strip()
num = int(sline, 8)
num_str = str(num)
nums_str.append(num_str)
count = 0
for num_str in nums_str:
if num_str[0] == num_str[-1]:
count += 1
print(f"{count=}")
| nums_str = []
with open('dane/dane.txt') as f:
lines = []
for line in f:
sline = line.strip()
num = int(sline, 8)
num_str = str(num)
nums_str.append(num_str)
count = 0
for num_str in nums_str:
if num_str[0] == num_str[-1]:
count += 1
print(f'count={count!r}') |
'''
Provides utility functions for encoding and decoding linestrings using the
Google encoded polyline algorithm.
'''
def encode_coords(coords):
'''
Encodes a polyline using Google's polyline algorithm
See http://code.google.com/apis/maps/documentation/polylinealgorithm.html
for more information.
:param coords: list of Point objects
:type coords: list
:returns: Google-encoded polyline string.
:rtype: string
'''
result = []
prev_lat = 0
prev_lng = 0
for item in coords:
lat, lng = int(item.lat * 1e5), int(item.lng * 1e5)
d_lat = _encode_value(lat - prev_lat)
d_lng = _encode_value(lng - prev_lng)
prev_lat, prev_lng = lat, lng
result.append(d_lat)
result.append(d_lng)
return ''.join(c for r in result for c in r)
def _split_into_chunks(value):
while value >= 32: #2^5, while there are at least 5 bits
# first & with 2^5-1, zeros out all the bits other than the first five
# then OR with 0x20 if another bit chunk follows
yield (value & 31) | 0x20
value >>= 5
yield value
def _encode_value(value):
# Step 2 & 4
value = ~(value << 1) if value < 0 else (value << 1)
# Step 5 - 8
chunks = _split_into_chunks(value)
# Step 9-10
return (chr(chunk + 63) for chunk in chunks)
def decode(point_str):
'''Decodes a polyline that has been encoded using Google's algorithm
http://code.google.com/apis/maps/documentation/polylinealgorithm.html
This is a generic method that returns a list of (latitude, longitude)
tuples.
:param point_str: Encoded polyline string.
:type point_str: string
:returns: List of 2-tuples where each tuple is (latitude, longitude)
:rtype: list
'''
# sone coordinate offset is represented by 4 to 5 binary chunks
coord_chunks = [[]]
for char in point_str:
# convert each character to decimal from ascii
value = ord(char) - 63
# values that have a chunk following have an extra 1 on the left
split_after = not (value & 0x20)
value &= 0x1F
coord_chunks[-1].append(value)
if split_after:
coord_chunks.append([])
del coord_chunks[-1]
coords = []
for coord_chunk in coord_chunks:
coord = 0
for i, chunk in enumerate(coord_chunk):
coord |= chunk << (i * 5)
#there is a 1 on the right if the coord is negative
if coord & 0x1:
coord = ~coord #invert
coord >>= 1
coord /= 100000.0
coords.append(coord)
# convert the 1 dimensional list to a 2 dimensional list and offsets to
# actual values
points = []
prev_x = 0
prev_y = 0
for i in xrange(0, len(coords) - 1, 2):
if coords[i] == 0 and coords[i + 1] == 0:
continue
prev_x += coords[i + 1]
prev_y += coords[i]
# a round to 6 digits ensures that the floats are the same as when
# they were encoded
points.append((round(prev_x, 6), round(prev_y, 6)))
return points | """
Provides utility functions for encoding and decoding linestrings using the
Google encoded polyline algorithm.
"""
def encode_coords(coords):
"""
Encodes a polyline using Google's polyline algorithm
See http://code.google.com/apis/maps/documentation/polylinealgorithm.html
for more information.
:param coords: list of Point objects
:type coords: list
:returns: Google-encoded polyline string.
:rtype: string
"""
result = []
prev_lat = 0
prev_lng = 0
for item in coords:
(lat, lng) = (int(item.lat * 100000.0), int(item.lng * 100000.0))
d_lat = _encode_value(lat - prev_lat)
d_lng = _encode_value(lng - prev_lng)
(prev_lat, prev_lng) = (lat, lng)
result.append(d_lat)
result.append(d_lng)
return ''.join((c for r in result for c in r))
def _split_into_chunks(value):
while value >= 32:
yield (value & 31 | 32)
value >>= 5
yield value
def _encode_value(value):
value = ~(value << 1) if value < 0 else value << 1
chunks = _split_into_chunks(value)
return (chr(chunk + 63) for chunk in chunks)
def decode(point_str):
"""Decodes a polyline that has been encoded using Google's algorithm
http://code.google.com/apis/maps/documentation/polylinealgorithm.html
This is a generic method that returns a list of (latitude, longitude)
tuples.
:param point_str: Encoded polyline string.
:type point_str: string
:returns: List of 2-tuples where each tuple is (latitude, longitude)
:rtype: list
"""
coord_chunks = [[]]
for char in point_str:
value = ord(char) - 63
split_after = not value & 32
value &= 31
coord_chunks[-1].append(value)
if split_after:
coord_chunks.append([])
del coord_chunks[-1]
coords = []
for coord_chunk in coord_chunks:
coord = 0
for (i, chunk) in enumerate(coord_chunk):
coord |= chunk << i * 5
if coord & 1:
coord = ~coord
coord >>= 1
coord /= 100000.0
coords.append(coord)
points = []
prev_x = 0
prev_y = 0
for i in xrange(0, len(coords) - 1, 2):
if coords[i] == 0 and coords[i + 1] == 0:
continue
prev_x += coords[i + 1]
prev_y += coords[i]
points.append((round(prev_x, 6), round(prev_y, 6)))
return points |
router = {"host":"192.168.56.1",
"port":"830",
"username":"cisco",
"password":"cisco123!",
"hostkey_verify":"False"
} | router = {'host': '192.168.56.1', 'port': '830', 'username': 'cisco', 'password': 'cisco123!', 'hostkey_verify': 'False'} |
"""
======================================
Classifier (:mod:`classifier` package)
======================================
This package provides supervised machine learning classifiers.
The decision forest module (:mod:`classifier.decision_forest`)
--------------------------------------------------------------
.. automodule:: classifier.decision_forest
:members:
""" | """
======================================
Classifier (:mod:`classifier` package)
======================================
This package provides supervised machine learning classifiers.
The decision forest module (:mod:`classifier.decision_forest`)
--------------------------------------------------------------
.. automodule:: classifier.decision_forest
:members:
""" |
class InstascrapeError(Exception):
"""Base exception class for all of the exceptions raised by Instascrape."""
class ExtractionError(InstascrapeError):
"""Raised when Instascrape fails to extract specified data from HTTP response."""
def __init__(self, message: str):
super().__init__("Failed to extract data from response. (message: '{0}')".format(message))
class PrivateAccessError(InstascrapeError):
"""Raised when user does not have permission to access specified data, i.e. private profile which the user is not following."""
def __init__(self):
super().__init__("The user profile is private and not being followed by you.")
class RateLimitedError(InstascrapeError):
"""Raised when Instascrape receives a 429 TooManyRequests from Instagram."""
def __init__(self):
super().__init__("(429) Too many requests. Failed to query data. Rate limited by Instagram.")
class NotFoundError(InstascrapeError):
"""Raised when Instascrape receives a 404 Not Found from Instagram."""
def __init__(self, message: str = None):
super().__init__(message or "(404) Nothing found.")
class ConnectionError(InstascrapeError):
"""Raised when Instascrape fails to connect to Instagram server."""
def __init__(self, url: str):
super().__init__("Failed to connect to '{0}'.".format(url))
class LoginError(InstascrapeError):
"""Raised when Instascrape fails to perform authentication, e.g. wrong credentials."""
def __init__(self, message: str):
super().__init__("Failed to log into Instagram. (message: '{0}')".format(message))
class TwoFactorAuthRequired(LoginError):
"""Raised when Instascrape fails to perform authentication due to two-factor authenticattion."""
def __init__(self):
super().__init__("two-factor authentication is required")
class CheckpointChallengeRequired(LoginError):
"""Raised when Instascrape fails to perform authentication due to checkpoint challenge."""
def __init__(self):
super().__init__("checkpoint challenge solving is required")
class AuthenticationRequired(InstascrapeError):
"""Raised when anonymous/unauthenticated (guest) user tries to perform actions that require authentication."""
def __init__(self):
super().__init__("Login is required in order to perform this action.")
class DownloadError(InstascrapeError):
"""Raised when Instascrape fails to download data from Instagram server."""
def __init__(self, message: str, url: str):
super().__init__("Download Failed -> {0} (url: '{1}')".format(message, url))
| class Instascrapeerror(Exception):
"""Base exception class for all of the exceptions raised by Instascrape."""
class Extractionerror(InstascrapeError):
"""Raised when Instascrape fails to extract specified data from HTTP response."""
def __init__(self, message: str):
super().__init__("Failed to extract data from response. (message: '{0}')".format(message))
class Privateaccesserror(InstascrapeError):
"""Raised when user does not have permission to access specified data, i.e. private profile which the user is not following."""
def __init__(self):
super().__init__('The user profile is private and not being followed by you.')
class Ratelimitederror(InstascrapeError):
"""Raised when Instascrape receives a 429 TooManyRequests from Instagram."""
def __init__(self):
super().__init__('(429) Too many requests. Failed to query data. Rate limited by Instagram.')
class Notfounderror(InstascrapeError):
"""Raised when Instascrape receives a 404 Not Found from Instagram."""
def __init__(self, message: str=None):
super().__init__(message or '(404) Nothing found.')
class Connectionerror(InstascrapeError):
"""Raised when Instascrape fails to connect to Instagram server."""
def __init__(self, url: str):
super().__init__("Failed to connect to '{0}'.".format(url))
class Loginerror(InstascrapeError):
"""Raised when Instascrape fails to perform authentication, e.g. wrong credentials."""
def __init__(self, message: str):
super().__init__("Failed to log into Instagram. (message: '{0}')".format(message))
class Twofactorauthrequired(LoginError):
"""Raised when Instascrape fails to perform authentication due to two-factor authenticattion."""
def __init__(self):
super().__init__('two-factor authentication is required')
class Checkpointchallengerequired(LoginError):
"""Raised when Instascrape fails to perform authentication due to checkpoint challenge."""
def __init__(self):
super().__init__('checkpoint challenge solving is required')
class Authenticationrequired(InstascrapeError):
"""Raised when anonymous/unauthenticated (guest) user tries to perform actions that require authentication."""
def __init__(self):
super().__init__('Login is required in order to perform this action.')
class Downloaderror(InstascrapeError):
"""Raised when Instascrape fails to download data from Instagram server."""
def __init__(self, message: str, url: str):
super().__init__("Download Failed -> {0} (url: '{1}')".format(message, url)) |
class Proxy:
def __init__(self, host, port):
self.host=host
self.port=port
self.succeed=0
self.fail=0
def markSucceed(self):
self.succeed +=1
def markFail(self):
self.fail +=1
def __str__(self):
return f'http://{self.host}:{self.port}'
| class Proxy:
def __init__(self, host, port):
self.host = host
self.port = port
self.succeed = 0
self.fail = 0
def mark_succeed(self):
self.succeed += 1
def mark_fail(self):
self.fail += 1
def __str__(self):
return f'http://{self.host}:{self.port}' |
lineitem_scheme = ["l_orderkey","l_partkey","l_suppkey","l_linenumber","l_quantity","l_extendedprice",
"l_discount","l_tax","l_returnflag","l_linestatus","l_shipdate","l_commitdate","l_receiptdate","l_shipinstruct",
"l_shipmode","l_comment", "null"]
order_scheme = ["o_orderkey", "o_custkey","o_orderstatus","o_totalprice","o_orderdate","o_orderpriority","o_clerk",
"o_shippriority","o_comment", "null"]
customer_scheme = ["c_custkey","c_name","c_address","c_nationkey","c_phone","c_acctbal","c_mktsegment","c_comment", "null"]
part_scheme = ["p_partkey","p_name","p_mfgr","p_brand","p_type","p_size","p_container","p_retailprice","p_comment","null"]
supplier_scheme = ["s_suppkey","s_name","s_address","s_nationkey","s_phone","s_acctbal","s_comment","null"]
partsupp_scheme = ["ps_partkey","ps_suppkey","ps_availqty","ps_supplycost","ps_comment","null"]
nation_scheme = ["n_nationkey","n_name","n_regionkey","n_comment","null"]
region_scheme = ["r_regionkey" ,"r_name","r_comment","null"]
schema_quotes = ["time","symbol","seq","bid","ask","bsize","asize","is_nbbo"]
schema_trades = ["time","symbol","size","price"] | lineitem_scheme = ['l_orderkey', 'l_partkey', 'l_suppkey', 'l_linenumber', 'l_quantity', 'l_extendedprice', 'l_discount', 'l_tax', 'l_returnflag', 'l_linestatus', 'l_shipdate', 'l_commitdate', 'l_receiptdate', 'l_shipinstruct', 'l_shipmode', 'l_comment', 'null']
order_scheme = ['o_orderkey', 'o_custkey', 'o_orderstatus', 'o_totalprice', 'o_orderdate', 'o_orderpriority', 'o_clerk', 'o_shippriority', 'o_comment', 'null']
customer_scheme = ['c_custkey', 'c_name', 'c_address', 'c_nationkey', 'c_phone', 'c_acctbal', 'c_mktsegment', 'c_comment', 'null']
part_scheme = ['p_partkey', 'p_name', 'p_mfgr', 'p_brand', 'p_type', 'p_size', 'p_container', 'p_retailprice', 'p_comment', 'null']
supplier_scheme = ['s_suppkey', 's_name', 's_address', 's_nationkey', 's_phone', 's_acctbal', 's_comment', 'null']
partsupp_scheme = ['ps_partkey', 'ps_suppkey', 'ps_availqty', 'ps_supplycost', 'ps_comment', 'null']
nation_scheme = ['n_nationkey', 'n_name', 'n_regionkey', 'n_comment', 'null']
region_scheme = ['r_regionkey', 'r_name', 'r_comment', 'null']
schema_quotes = ['time', 'symbol', 'seq', 'bid', 'ask', 'bsize', 'asize', 'is_nbbo']
schema_trades = ['time', 'symbol', 'size', 'price'] |
#!/usr/bin/env python3
# Daniel Nicolas Gisolfi
class UserCommand:
""" The users input that will be translated into a shell command """
def __init__(self, cmd:str, args:list):
self.command = cmd
self.args = args
| class Usercommand:
""" The users input that will be translated into a shell command """
def __init__(self, cmd: str, args: list):
self.command = cmd
self.args = args |
# https://github.com/adamsaparudin/python-datascience
# if (kondisi)
# if ("adam" == "adam") # True / False
# Task 1
# FIZZBUZZ
# print FIZZ jika bisa dibagi 3,
# print BUZZ jika bisa dibagi 5,
# print FIZZBUZZ jika bisa dibagi 15,
# print angka nya sendiri jika tidak bisa dibagi 3 atau 5
# input 6
# FIZZ
# input 10
# BUZZ
# input 30
# FIZZBUZZ
def print_fizzbuzz(numb):
if (numb % 15) == 0:
return "FIZZBUZZ"
elif (numb % 3) == 0:
print("FIZZ")
elif (numb % 5) == 0:
print("BUZZ")
else:
print( numb)
def tambahan(a, b):
return a + b
def main():
while True:
numb = int(input("Input bilangan bulat: "))
fizz = print_fizzbuzz(numb)
print(fizz)
main() | def print_fizzbuzz(numb):
if numb % 15 == 0:
return 'FIZZBUZZ'
elif numb % 3 == 0:
print('FIZZ')
elif numb % 5 == 0:
print('BUZZ')
else:
print(numb)
def tambahan(a, b):
return a + b
def main():
while True:
numb = int(input('Input bilangan bulat: '))
fizz = print_fizzbuzz(numb)
print(fizz)
main() |
def parse_list_ranges(s,sep='-'):
r = []
x = s.split(',')
for y in x:
z = y.split(sep)
if len(z)==1:
r += [int(z[0])]
else:
r += range(int(z[0]),int(z[1])+1)
return list(r)
def parse_list_floats(s):
x = s.split(',')
return list(map(float, x))
| def parse_list_ranges(s, sep='-'):
r = []
x = s.split(',')
for y in x:
z = y.split(sep)
if len(z) == 1:
r += [int(z[0])]
else:
r += range(int(z[0]), int(z[1]) + 1)
return list(r)
def parse_list_floats(s):
x = s.split(',')
return list(map(float, x)) |
class LayoutRuleFixedNumber(LayoutRule, IDisposable):
"""
This class indicate the layout rule of a Beam System is Fixed-Number.
LayoutRuleFixedNumber(numberOfLines: int)
"""
def Dispose(self):
""" Dispose(self: LayoutRuleFixedNumber,A_0: bool) """
pass
def ReleaseManagedResources(self, *args):
""" ReleaseManagedResources(self: APIObject) """
pass
def ReleaseUnmanagedResources(self, *args):
""" ReleaseUnmanagedResources(self: APIObject) """
pass
def __enter__(self, *args):
""" __enter__(self: IDisposable) -> object """
pass
def __exit__(self, *args):
""" __exit__(self: IDisposable,exc_type: object,exc_value: object,exc_back: object) """
pass
def __init__(self, *args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
@staticmethod
def __new__(self, numberOfLines):
""" __new__(cls: type,numberOfLines: int) """
pass
NumberOfLines = property(
lambda self: object(), lambda self, v: None, lambda self: None
)
"""Get or set the number of the beams in a beam system.
Get: NumberOfLines(self: LayoutRuleFixedNumber) -> int
Set: NumberOfLines(self: LayoutRuleFixedNumber)=value
"""
| class Layoutrulefixednumber(LayoutRule, IDisposable):
"""
This class indicate the layout rule of a Beam System is Fixed-Number.
LayoutRuleFixedNumber(numberOfLines: int)
"""
def dispose(self):
""" Dispose(self: LayoutRuleFixedNumber,A_0: bool) """
pass
def release_managed_resources(self, *args):
""" ReleaseManagedResources(self: APIObject) """
pass
def release_unmanaged_resources(self, *args):
""" ReleaseUnmanagedResources(self: APIObject) """
pass
def __enter__(self, *args):
""" __enter__(self: IDisposable) -> object """
pass
def __exit__(self, *args):
""" __exit__(self: IDisposable,exc_type: object,exc_value: object,exc_back: object) """
pass
def __init__(self, *args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
@staticmethod
def __new__(self, numberOfLines):
""" __new__(cls: type,numberOfLines: int) """
pass
number_of_lines = property(lambda self: object(), lambda self, v: None, lambda self: None)
'Get or set the number of the beams in a beam system.\n\n\n\nGet: NumberOfLines(self: LayoutRuleFixedNumber) -> int\n\n\n\nSet: NumberOfLines(self: LayoutRuleFixedNumber)=value\n\n' |
def print_tree(mcts_obj, root_node):
fifo = []
for child_node in root_node.children:
q = 0
if mcts_obj.visits[child_node] > 0:
q = mcts_obj.Q[child_node] / mcts_obj.visits[child_node]
print(
child_node,
mcts_obj.Q[child_node],
mcts_obj.visits[child_node],
q
)
fifo.append(child_node)
print("-")
while fifo:
root_node = fifo.pop()
print("(", root_node, ")")
for child_node in root_node.children:
q = 0
if mcts_obj.visits[child_node] > 0:
q = mcts_obj.Q[child_node] / mcts_obj.visits[child_node]
print(
child_node,
mcts_obj.Q[child_node],
mcts_obj.visits[child_node],
q
)
fifo.append(child_node)
if root_node.children:
print(" ")
def gen_tree_graph(root_node, G):
fifo = []
root_id = str(root_node)
G.add_node(root_id)
for child_node in root_node.children:
child_id = str(child_node)
G.add_node(child_id)
G.add_edge(root_id, child_id)
fifo.append(child_node)
while fifo:
root_node = fifo.pop()
root_id = str(root_node)
for child_node in root_node.children:
child_id = str(child_node)
G.add_node(child_id)
G.add_edge(root_id, child_id)
fifo.append(child_node)
| def print_tree(mcts_obj, root_node):
fifo = []
for child_node in root_node.children:
q = 0
if mcts_obj.visits[child_node] > 0:
q = mcts_obj.Q[child_node] / mcts_obj.visits[child_node]
print(child_node, mcts_obj.Q[child_node], mcts_obj.visits[child_node], q)
fifo.append(child_node)
print('-')
while fifo:
root_node = fifo.pop()
print('(', root_node, ')')
for child_node in root_node.children:
q = 0
if mcts_obj.visits[child_node] > 0:
q = mcts_obj.Q[child_node] / mcts_obj.visits[child_node]
print(child_node, mcts_obj.Q[child_node], mcts_obj.visits[child_node], q)
fifo.append(child_node)
if root_node.children:
print(' ')
def gen_tree_graph(root_node, G):
fifo = []
root_id = str(root_node)
G.add_node(root_id)
for child_node in root_node.children:
child_id = str(child_node)
G.add_node(child_id)
G.add_edge(root_id, child_id)
fifo.append(child_node)
while fifo:
root_node = fifo.pop()
root_id = str(root_node)
for child_node in root_node.children:
child_id = str(child_node)
G.add_node(child_id)
G.add_edge(root_id, child_id)
fifo.append(child_node) |
class DataStructure(object):
def __init__(self):
self.name2id = {}
self.id2item = {}
def add_item(self, item_name, item_id, item):
self.name2id[item_name] = item_id
self.id2item[item_id] = item
def search_by_name(self, target_name):
target_id = self.name2id[target_name]
target_item = self.id2item[target_id]
return target_item
def search_by_id(self, target_id):
target_item = self.id2item[target_id]
return target_item
| class Datastructure(object):
def __init__(self):
self.name2id = {}
self.id2item = {}
def add_item(self, item_name, item_id, item):
self.name2id[item_name] = item_id
self.id2item[item_id] = item
def search_by_name(self, target_name):
target_id = self.name2id[target_name]
target_item = self.id2item[target_id]
return target_item
def search_by_id(self, target_id):
target_item = self.id2item[target_id]
return target_item |
class Calendar:
def __init__(self, day, month, year):
print("Clase Base - Calendar")
self.day = day
self.month = month
self.year = year
def __str__(self):
return "{}-{}-{}".format(self.day,
self.month,
self.year) | class Calendar:
def __init__(self, day, month, year):
print('Clase Base - Calendar')
self.day = day
self.month = month
self.year = year
def __str__(self):
return '{}-{}-{}'.format(self.day, self.month, self.year) |
#My favorite song described
#Genre, Artists and Album
Genre = "Bollywood Romance"
Composer = "Amit Trivedi"
Lyricist = "Amitabh Bhattacharya"
Singer_male = "Arijit Singh"
Singer_female = "Nikhita Gandhi"
Album = "Kedarnath"
#YearReleased
YearReleased = 2018
#Duration
DurationInSeconds = 351
print("My favorite song is from the Album " + Album + " and in the genre " + Genre)
print("The artists of this song are :")
print("Composer: " + Composer)
print("Lyricist: " + Lyricist)
print("Singer(Male): " + Singer_male)
print("Singer(Female): " + Singer_female)
print("It was released in the year" , YearReleased , "and has a duration of", DurationInSeconds , "seconds")
| genre = 'Bollywood Romance'
composer = 'Amit Trivedi'
lyricist = 'Amitabh Bhattacharya'
singer_male = 'Arijit Singh'
singer_female = 'Nikhita Gandhi'
album = 'Kedarnath'
year_released = 2018
duration_in_seconds = 351
print('My favorite song is from the Album ' + Album + ' and in the genre ' + Genre)
print('The artists of this song are :')
print('Composer: ' + Composer)
print('Lyricist: ' + Lyricist)
print('Singer(Male): ' + Singer_male)
print('Singer(Female): ' + Singer_female)
print('It was released in the year', YearReleased, 'and has a duration of', DurationInSeconds, 'seconds') |
#!/bin/python
#If player is X, I'm the first player.
#If player is O, I'm the second player.
player = raw_input()
#Read the board now. The board is a 3x3 array filled with X, O or _.
board = []
for i in xrange(0, 3):
board.append(raw_input())
#Proceed with processing and print 2 integers separated by a single space.
#Example: print random.randint(0, 2), random.randint(0, 2)
| player = raw_input()
board = []
for i in xrange(0, 3):
board.append(raw_input()) |
DEFAULT_ENV_NAME = "CartPole-v1"
DEFAULT_ALGORITHM = "random"
DEFAULT_MAX_EPISODES = 1000
DEFAULT_LEARNING_RATE = 0.001
DEFAULT_GAMMA = 0.95
DEFAULT_UPDATE_FREQUENCY = 20
| default_env_name = 'CartPole-v1'
default_algorithm = 'random'
default_max_episodes = 1000
default_learning_rate = 0.001
default_gamma = 0.95
default_update_frequency = 20 |
def initials(name):
parts = name.split(' ')
letters = ''
for part in parts:
letters += part[0]
return letters | def initials(name):
parts = name.split(' ')
letters = ''
for part in parts:
letters += part[0]
return letters |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.