content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
def solution(x, y): x = int(x) y = int(y) numCycles = 0 while (x > 1 or y > 1): if (x == y or x < 1 or y < 1): return "impossible" elif (x > y): factor = int(x/y) numCycles+=factor if (y == 1): numCycles-=1 x = x-y*(factor-1) else: x = x-y*factor elif (x < y): factor = int(y/x) numCycles+=factor if (x == 1): numCycles-=1 y = y-x*(factor-1) else: y = y-x*factor return str(numCycles)
def solution(x, y): x = int(x) y = int(y) num_cycles = 0 while x > 1 or y > 1: if x == y or x < 1 or y < 1: return 'impossible' elif x > y: factor = int(x / y) num_cycles += factor if y == 1: num_cycles -= 1 x = x - y * (factor - 1) else: x = x - y * factor elif x < y: factor = int(y / x) num_cycles += factor if x == 1: num_cycles -= 1 y = y - x * (factor - 1) else: y = y - x * factor return str(numCycles)
valores = [1, 2, 3, 4, 5, 6, 7, 8, 9] pares = list(filter(lambda x : x % 2 == 0, valores)) impares = list(filter(lambda x : x % 2 != 0, valores)) print(pares) print(impares)
valores = [1, 2, 3, 4, 5, 6, 7, 8, 9] pares = list(filter(lambda x: x % 2 == 0, valores)) impares = list(filter(lambda x: x % 2 != 0, valores)) print(pares) print(impares)
cpf = '04045683941' novo_cpf = cpf[:-2]#selecionando os 9 primeiros e deixando os dois ultimos #040456839 reverso = 10 total = 0 for index in range(19): if index > 8: index -= 9 total += int(novo_cpf[index]) * reverso print(cpf [index], index), reverso reverso -= 1 if reverso < 2: reverso = 11
cpf = '04045683941' novo_cpf = cpf[:-2] reverso = 10 total = 0 for index in range(19): if index > 8: index -= 9 total += int(novo_cpf[index]) * reverso (print(cpf[index], index), reverso) reverso -= 1 if reverso < 2: reverso = 11
class StubSoundPlayer: def __init__(self): pass def play_once(self, filename): pass def set_music_volume(self, new_volume): pass def change_music(self): pass def play_sound_event(self, sound_event): pass def process_events(self, sound_event_list): pass
class Stubsoundplayer: def __init__(self): pass def play_once(self, filename): pass def set_music_volume(self, new_volume): pass def change_music(self): pass def play_sound_event(self, sound_event): pass def process_events(self, sound_event_list): pass
t = int(input()) for i in range(t): n, m = input().split() n = int(n) m = int(m) print((n-1)*(m-1))
t = int(input()) for i in range(t): (n, m) = input().split() n = int(n) m = int(m) print((n - 1) * (m - 1))
class Solution: def maximalSquare(self, matrix: List[List[str]]) -> int: if len(matrix)<1: return 0 dp=[[0 for i in range(len(matrix[0])+1)] for j in range(len(matrix)+1)] max1=0 for i in range(len(matrix)): for j in range(len(matrix[0])): if matrix[i][j]=='1': dp[i+1][j+1]=min(dp[i][j],dp[i][j+1],dp[i+1][j])+1 max1=max(max1,dp[i+1][j+1]) return max1**2
class Solution: def maximal_square(self, matrix: List[List[str]]) -> int: if len(matrix) < 1: return 0 dp = [[0 for i in range(len(matrix[0]) + 1)] for j in range(len(matrix) + 1)] max1 = 0 for i in range(len(matrix)): for j in range(len(matrix[0])): if matrix[i][j] == '1': dp[i + 1][j + 1] = min(dp[i][j], dp[i][j + 1], dp[i + 1][j]) + 1 max1 = max(max1, dp[i + 1][j + 1]) return max1 ** 2
# # Common constants # APP_NAME = 'autonom' DEFAULT_CONFIG_FILE = 'autonom.ini' DEFAULT_SESSMGR = 'ticket' # We do this to convert run-time errors into compile time errors CF_DEFAULT = 'DEFAULT' CF_LISTEN = 'listen' CF_PORT = 'port' CF_PROVIDERS = 'providers' CF_FIXED_IP_LIST = 'fixed_ip_list' CF_LOG = 'log' CF_LOG_EX = 'log_data' CF_PROVIDER = 'provider' CF_ID = 'id' CF_HREF = 'href' CF_DESC = 'desc' CF_ROUTE = 'route' CF_VIEW = 'view' CF_PWCK = 'pwck' CF_COOKIE_NAME = 'cookie_name' CF_SESSION_SIG = 'session_sig' CF_TICKET_MAXAGE = 'ticket_maxage' CF_COOKIE_MAXAGE = 'cookie_maxage' CF_COOKIE_RENEW = 'cookie_renew' CF_ATIME_MIN = 'ticket_min_atime' CF_PROXY_LIST = 'proxy_list' CF_PROXY_PSK = 'proxy_secret' CF_IPLOGIN_MAXAGE = 'iplogin_maxage' CF_MODULE = 'module' CF_TEMPLATE_PATH = 'template_path' CF_DOCROOT = 'docroot' CF_TICKET_DB = 'ticket_db_path' CF_AUTH_REALM = 'http_auth_realm' RT_SESSION_MGR = 'session_mgr' CF_BACKENDS = 'backends' CF_BACKEND = 'backend' LOG_SYSLOG = 1 LOG_STDIO = 2 LOG_FILE = 3 CF_PWTYPE = 'style' CF_PASSWD = 'passwd' CF_GROUPS = 'groups' CF_DIGEST = 'digest' FF_APACHE2 = 'apache' FF_UNIX = 'unix' FF_DEFAULT = FF_APACHE2 CF_TLREALMS_DATA = 'tlrealms_data'
app_name = 'autonom' default_config_file = 'autonom.ini' default_sessmgr = 'ticket' cf_default = 'DEFAULT' cf_listen = 'listen' cf_port = 'port' cf_providers = 'providers' cf_fixed_ip_list = 'fixed_ip_list' cf_log = 'log' cf_log_ex = 'log_data' cf_provider = 'provider' cf_id = 'id' cf_href = 'href' cf_desc = 'desc' cf_route = 'route' cf_view = 'view' cf_pwck = 'pwck' cf_cookie_name = 'cookie_name' cf_session_sig = 'session_sig' cf_ticket_maxage = 'ticket_maxage' cf_cookie_maxage = 'cookie_maxage' cf_cookie_renew = 'cookie_renew' cf_atime_min = 'ticket_min_atime' cf_proxy_list = 'proxy_list' cf_proxy_psk = 'proxy_secret' cf_iplogin_maxage = 'iplogin_maxage' cf_module = 'module' cf_template_path = 'template_path' cf_docroot = 'docroot' cf_ticket_db = 'ticket_db_path' cf_auth_realm = 'http_auth_realm' rt_session_mgr = 'session_mgr' cf_backends = 'backends' cf_backend = 'backend' log_syslog = 1 log_stdio = 2 log_file = 3 cf_pwtype = 'style' cf_passwd = 'passwd' cf_groups = 'groups' cf_digest = 'digest' ff_apache2 = 'apache' ff_unix = 'unix' ff_default = FF_APACHE2 cf_tlrealms_data = 'tlrealms_data'
class BudgetNotFound(Exception): pass class WrongPushException(Exception): def __init__(self, expected_delta, delta): self.expected_delta = expected_delta self.delta = delta string = 'tried to push a changed_entities with %d entities while we expected %d entities' @property def msg(self): return self.string % (self.delta, self.expected_delta) def __repr__(self): return self.msg class NoBudgetNameException(ValueError): def __init__(self): super(NoBudgetNameException,self).__init__('you should pass a budget_name ') class NoCredentialsException(BaseException): def __init__(self): super(NoCredentialsException,self).__init__('you should pass email and password if you don\'t pass a Connection')
class Budgetnotfound(Exception): pass class Wrongpushexception(Exception): def __init__(self, expected_delta, delta): self.expected_delta = expected_delta self.delta = delta string = 'tried to push a changed_entities with %d entities while we expected %d entities' @property def msg(self): return self.string % (self.delta, self.expected_delta) def __repr__(self): return self.msg class Nobudgetnameexception(ValueError): def __init__(self): super(NoBudgetNameException, self).__init__('you should pass a budget_name ') class Nocredentialsexception(BaseException): def __init__(self): super(NoCredentialsException, self).__init__("you should pass email and password if you don't pass a Connection")
#Source : https://leetcode.com/problems/insertion-sort-list/ #Author : Yuan Wang #Date : 2021-02-01 ''' ********************************************************************************** *Sort a linked list using insertion sort. * *Example1 : *Input: 4->2->1->3 *Output: 1->2->3->4 **********************************************************************************/ ''' #time complexity : O(n) space complexity : O(1) def insertionSortList(self, head: ListNode) -> ListNode: p = ListNode(0) dummy = p dummy.next = head current = head while current and current.next: val = current.next.val if current.val < val: current = current.next continue if p.next.val > val: p = dummy while p.next.val < val: p = p.next temp = current.next current.next = temp.next temp.next = p.next p.next = temp return dummy.next
""" ********************************************************************************** *Sort a linked list using insertion sort. * *Example1 : *Input: 4->2->1->3 *Output: 1->2->3->4 **********************************************************************************/ """ def insertion_sort_list(self, head: ListNode) -> ListNode: p = list_node(0) dummy = p dummy.next = head current = head while current and current.next: val = current.next.val if current.val < val: current = current.next continue if p.next.val > val: p = dummy while p.next.val < val: p = p.next temp = current.next current.next = temp.next temp.next = p.next p.next = temp return dummy.next
class ScoreCache: def __init__(self): self.parent_cache = dict() self.child_cache = dict() self.joint_cache = dict() def print(self): print("____CACHE_____") print("parents->(parent_states,parent_states_counts)") print(self.parent_cache) print("child->child_states_counts") print(self.child_cache) print("(child,hashed(parents)->k2") print(self.joint_cache)
class Scorecache: def __init__(self): self.parent_cache = dict() self.child_cache = dict() self.joint_cache = dict() def print(self): print('____CACHE_____') print('parents->(parent_states,parent_states_counts)') print(self.parent_cache) print('child->child_states_counts') print(self.child_cache) print('(child,hashed(parents)->k2') print(self.joint_cache)
Config = { 'game': { 'height': 640, 'width': 800, 'tile_width': 32 }, 'resources': { 'sprites': { 'player': "src/res/char.png" } } }
config = {'game': {'height': 640, 'width': 800, 'tile_width': 32}, 'resources': {'sprites': {'player': 'src/res/char.png'}}}
def find_binary_partitioned_seat(seat_range, input_text): for letter in input_text: difference = abs(seat_range[0] - seat_range[1]) // 2 if (letter == "F") or (letter == "L"): seat_range = [seat_range[0], seat_range[0] + difference] else: seat_range = [seat_range[1] - difference, seat_range[1]] assert seat_range[0] == seat_range[1] return(seat_range[0]) with open("input.txt", "r") as puzzle_input: seat_ids = [] for line in puzzle_input: line = line.strip() vertical_seat_input = line[:-3] horizontal_seat_input = line[-3:] vertical_seat = find_binary_partitioned_seat([0, 127], vertical_seat_input) horizontal_seat = find_binary_partitioned_seat([0, 7], horizontal_seat_input) seat_ids.append(vertical_seat * 8 + horizontal_seat) seat_ids.sort() for seat_id_index in range(len(seat_ids) - 1): if seat_ids[seat_id_index + 1] == seat_ids[seat_id_index] + 2: print(seat_ids[seat_id_index] + 1, "is open")
def find_binary_partitioned_seat(seat_range, input_text): for letter in input_text: difference = abs(seat_range[0] - seat_range[1]) // 2 if letter == 'F' or letter == 'L': seat_range = [seat_range[0], seat_range[0] + difference] else: seat_range = [seat_range[1] - difference, seat_range[1]] assert seat_range[0] == seat_range[1] return seat_range[0] with open('input.txt', 'r') as puzzle_input: seat_ids = [] for line in puzzle_input: line = line.strip() vertical_seat_input = line[:-3] horizontal_seat_input = line[-3:] vertical_seat = find_binary_partitioned_seat([0, 127], vertical_seat_input) horizontal_seat = find_binary_partitioned_seat([0, 7], horizontal_seat_input) seat_ids.append(vertical_seat * 8 + horizontal_seat) seat_ids.sort() for seat_id_index in range(len(seat_ids) - 1): if seat_ids[seat_id_index + 1] == seat_ids[seat_id_index] + 2: print(seat_ids[seat_id_index] + 1, 'is open')
f = open('input.txt', 'r') row = f.read() data = row.split() result = 0 children = {0: 1} metadata = {} deep = 1 slot = 2 for i in data: i = int(i) if slot == 2 and children[deep - 1] > 0 and (deep not in metadata or metadata[deep] == 0): children[deep] = i children[deep - 1] -= 1 slot = 1 continue if slot == 2 and deep in children and children[deep] == 0 and deep in metadata and metadata[deep] > 0: result += i metadata[deep] -= 1 if metadata[deep] == 0 and children[deep - 1] == 0: while deep in metadata and metadata[deep] == 0: deep -= 1 continue elif slot == 1: metadata[deep] = i slot = 2 if children[deep] > 0: deep += 1 continue print('Result:', result)
f = open('input.txt', 'r') row = f.read() data = row.split() result = 0 children = {0: 1} metadata = {} deep = 1 slot = 2 for i in data: i = int(i) if slot == 2 and children[deep - 1] > 0 and (deep not in metadata or metadata[deep] == 0): children[deep] = i children[deep - 1] -= 1 slot = 1 continue if slot == 2 and deep in children and (children[deep] == 0) and (deep in metadata) and (metadata[deep] > 0): result += i metadata[deep] -= 1 if metadata[deep] == 0 and children[deep - 1] == 0: while deep in metadata and metadata[deep] == 0: deep -= 1 continue elif slot == 1: metadata[deep] = i slot = 2 if children[deep] > 0: deep += 1 continue print('Result:', result)
class Event: def __init__(self, time): self.time = time def __lt__(self, other): return self.time < other.time def __le__(self, other): return self < other or self.time == other.time class InjectEvent(Event): def __init__(self, time, packet): super(InjectEvent, self).__init__(time) self.packet = packet def fromLine(line): time, packet = line.split() return InjectEvent(float(time), float(packet)) def __str__(self): return "{} inject {}".format(self.time, self.packet) class SentEvent(Event): def __init__(self, time, algorithm): super(SentEvent, self).__init__(time) self.algorithm = algorithm def __lt__(self, other): if isinstance(other, SentEvent): return self.time < other.time or self.time == other.time and self.algorithm < other.algorithm return super(SentEvent, self).__lt__(other) def __str__(self): return "{} sent {}".format(self.time, self.algorithm.algorithmType) class ErrorEvent(Event): def __init__(self, time): super(ErrorEvent, self).__init__(time) def __str__(self): return "{} error".format(self.time) class ScheduleEvent(SentEvent): def __init__(self, time, algorithm, packet): super(ScheduleEvent, self).__init__(time, algorithm) self.packet = packet def __str__(self): return "{} schedule {} {}".format(self.time, self.algorithm.algorithmType, self.packet) class WaitEvent: pass
class Event: def __init__(self, time): self.time = time def __lt__(self, other): return self.time < other.time def __le__(self, other): return self < other or self.time == other.time class Injectevent(Event): def __init__(self, time, packet): super(InjectEvent, self).__init__(time) self.packet = packet def from_line(line): (time, packet) = line.split() return inject_event(float(time), float(packet)) def __str__(self): return '{} inject {}'.format(self.time, self.packet) class Sentevent(Event): def __init__(self, time, algorithm): super(SentEvent, self).__init__(time) self.algorithm = algorithm def __lt__(self, other): if isinstance(other, SentEvent): return self.time < other.time or (self.time == other.time and self.algorithm < other.algorithm) return super(SentEvent, self).__lt__(other) def __str__(self): return '{} sent {}'.format(self.time, self.algorithm.algorithmType) class Errorevent(Event): def __init__(self, time): super(ErrorEvent, self).__init__(time) def __str__(self): return '{} error'.format(self.time) class Scheduleevent(SentEvent): def __init__(self, time, algorithm, packet): super(ScheduleEvent, self).__init__(time, algorithm) self.packet = packet def __str__(self): return '{} schedule {} {}'.format(self.time, self.algorithm.algorithmType, self.packet) class Waitevent: pass
problems = input().split(";") count = 0 for problem in problems: if "-" in problem: upper = problem.split("-")[1] lower = problem.split("-")[0] count += int(upper) - int(lower) + 1 else: count += 1 print(count)
problems = input().split(';') count = 0 for problem in problems: if '-' in problem: upper = problem.split('-')[1] lower = problem.split('-')[0] count += int(upper) - int(lower) + 1 else: count += 1 print(count)
# game states IN_PROGRESS = 0 PLAYER1 = 1 PLAYER2 = 2 DRAW = 3 GAME_STATES = {"IN_PROGRESS": IN_PROGRESS, "PLAYER1": PLAYER1, "PLAYER2": PLAYER2, "DRAW": DRAW}
in_progress = 0 player1 = 1 player2 = 2 draw = 3 game_states = {'IN_PROGRESS': IN_PROGRESS, 'PLAYER1': PLAYER1, 'PLAYER2': PLAYER2, 'DRAW': DRAW}
# Do not edit. bazel-deps autogenerates this file from maven_deps.yaml. def declare_maven(hash): native.maven_jar( name = hash["name"], artifact = hash["artifact"], sha1 = hash["sha1"], repository = hash["repository"] ) native.bind( name = hash["bind"], actual = hash["actual"] ) def maven_dependencies(callback = declare_maven): callback({"artifact": "args4j:args4j:2.33", "lang": "java", "sha1": "bd87a75374a6d6523de82fef51fc3cfe9baf9fc9", "repository": "https://repo.maven.apache.org/maven2/", "name": "args4j_args4j", "actual": "@args4j_args4j//jar", "bind": "jar/args4j/args4j"}) callback({"artifact": "com.google.api.grpc:proto-google-common-protos:1.0.0", "lang": "java", "sha1": "86f070507e28b930e50d218ee5b6788ef0dd05e6", "repository": "https://repo.maven.apache.org/maven2/", "name": "com_google_api_grpc_proto_google_common_protos", "actual": "@com_google_api_grpc_proto_google_common_protos//jar", "bind": "jar/com/google/api/grpc/proto_google_common_protos"}) # duplicates in com.google.code.findbugs:jsr305 fixed to 3.0.2 # - com.google.guava:guava:23.0 wanted version 1.3.9 # - io.grpc:grpc-core:1.10.0 wanted version 3.0.0 # - com.google.instrumentation:instrumentation-api:0.4.3 wanted version 3.0.0 callback({"artifact": "com.google.code.findbugs:jsr305:3.0.2", "lang": "java", "sha1": "25ea2e8b0c338a877313bd4672d3fe056ea78f0d", "repository": "https://repo.maven.apache.org/maven2/", "name": "com_google_code_findbugs_jsr305", "actual": "@com_google_code_findbugs_jsr305//jar", "bind": "jar/com/google/code/findbugs/jsr305"}) callback({"artifact": "com.google.code.gson:gson:2.8.2", "lang": "java", "sha1": "3edcfe49d2c6053a70a2a47e4e1c2f94998a49cf", "repository": "https://repo.maven.apache.org/maven2/", "name": "com_google_code_gson_gson", "actual": "@com_google_code_gson_gson//jar", "bind": "jar/com/google/code/gson/gson"}) # duplicates in com.google.errorprone:error_prone_annotations promoted to 2.1.2 # - com.google.guava:guava:23.0 wanted version 2.0.18 # - io.grpc:grpc-core:1.10.0 wanted version 2.1.2 # - com.google.truth:truth:0.35 wanted version 2.0.19 callback({"artifact": "com.google.errorprone:error_prone_annotations:2.1.2", "lang": "java", "sha1": "6dcc08f90f678ac33e5ef78c3c752b6f59e63e0c", "repository": "https://repo.maven.apache.org/maven2/", "name": "com_google_errorprone_error_prone_annotations", "actual": "@com_google_errorprone_error_prone_annotations//jar", "bind": "jar/com/google/errorprone/error_prone_annotations"}) # duplicates in com.google.guava:guava fixed to 23.0 # - io.grpc:grpc-core:1.10.0 wanted version 19.0 # - io.grpc:grpc-protobuf:1.10.0 wanted version 19.0 # - com.google.truth:truth:0.35 wanted version 22.0-android callback({"artifact": "com.google.guava:guava:23.0", "lang": "java", "sha1": "c947004bb13d18182be60077ade044099e4f26f1", "repository": "https://repo.maven.apache.org/maven2/", "name": "com_google_guava_guava", "actual": "@com_google_guava_guava//jar", "bind": "jar/com/google/guava/guava"}) callback({"artifact": "com.google.instrumentation:instrumentation-api:0.4.3", "lang": "java", "sha1": "41614af3429573dc02645d541638929d877945a2", "repository": "https://repo.maven.apache.org/maven2/", "name": "com_google_instrumentation_instrumentation_api", "actual": "@com_google_instrumentation_instrumentation_api//jar", "bind": "jar/com/google/instrumentation/instrumentation_api"}) callback({"artifact": "com.google.j2objc:j2objc-annotations:1.1", "lang": "java", "sha1": "ed28ded51a8b1c6b112568def5f4b455e6809019", "repository": "https://repo.maven.apache.org/maven2/", "name": "com_google_j2objc_j2objc_annotations", "actual": "@com_google_j2objc_j2objc_annotations//jar", "bind": "jar/com/google/j2objc/j2objc_annotations"}) callback({"artifact": "com.google.protobuf:protobuf-java-util:3.5.1", "lang": "java", "sha1": "6e40a6a3f52455bd633aa2a0dba1a416e62b4575", "repository": "https://repo.maven.apache.org/maven2/", "name": "com_google_protobuf_protobuf_java_util", "actual": "@com_google_protobuf_protobuf_java_util//jar", "bind": "jar/com/google/protobuf/protobuf_java_util"}) callback({"artifact": "com.google.protobuf:protobuf-java:3.5.1", "lang": "java", "sha1": "8c3492f7662fa1cbf8ca76a0f5eb1146f7725acd", "repository": "https://repo.maven.apache.org/maven2/", "name": "com_google_protobuf_protobuf_java", "actual": "@com_google_protobuf_protobuf_java//jar", "bind": "jar/com/google/protobuf/protobuf_java"}) callback({"artifact": "com.google.truth:truth:0.35", "lang": "java", "sha1": "c08a7fde45e058323bcfa3f510d4fe1e2b028f37", "repository": "https://repo.maven.apache.org/maven2/", "name": "com_google_truth_truth", "actual": "@com_google_truth_truth//jar", "bind": "jar/com/google/truth/truth"}) callback({"artifact": "io.grpc:grpc-context:1.10.0", "lang": "java", "sha1": "da0a701be6ba04aff0bd54ca3db8248d8f2eaafc", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_grpc_grpc_context", "actual": "@io_grpc_grpc_context//jar", "bind": "jar/io/grpc/grpc_context"}) callback({"artifact": "io.grpc:grpc-core:1.10.0", "lang": "java", "sha1": "8976afebf2a6530574a71bc1260920ce910c2292", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_grpc_grpc_core", "actual": "@io_grpc_grpc_core//jar", "bind": "jar/io/grpc/grpc_core"}) callback({"artifact": "io.grpc:grpc-netty:1.10.0", "lang": "java", "sha1": "a1056d69003c9b46d1c4aa4a9167c6e8a714d152", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_grpc_grpc_netty", "actual": "@io_grpc_grpc_netty//jar", "bind": "jar/io/grpc/grpc_netty"}) callback({"artifact": "io.grpc:grpc-protobuf-lite:1.10.0", "lang": "java", "sha1": "b8e40dd308dc370e64bd2c337bb2761a03299a7f", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_grpc_grpc_protobuf_lite", "actual": "@io_grpc_grpc_protobuf_lite//jar", "bind": "jar/io/grpc/grpc_protobuf_lite"}) callback({"artifact": "io.grpc:grpc-protobuf:1.10.0", "lang": "java", "sha1": "64098f046f227b47238bc747e3cee6c7fc087bb8", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_grpc_grpc_protobuf", "actual": "@io_grpc_grpc_protobuf//jar", "bind": "jar/io/grpc/grpc_protobuf"}) callback({"artifact": "io.grpc:grpc-services:1.10.0", "lang": "java", "sha1": "ae898f12418429c9d1396aaf5ac2377bf8ecb25b", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_grpc_grpc_services", "actual": "@io_grpc_grpc_services//jar", "bind": "jar/io/grpc/grpc_services"}) callback({"artifact": "io.grpc:grpc-stub:1.10.0", "lang": "java", "sha1": "d022706796b0820d388f83571da160fb8d280ded", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_grpc_grpc_stub", "actual": "@io_grpc_grpc_stub//jar", "bind": "jar/io/grpc/grpc_stub"}) callback({"artifact": "io.netty:netty-all:4.1.22.Final", "lang": "java", "sha1": "c1cea5d30025e4d584d2b287d177c31aea4ae629", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_netty_netty_all", "actual": "@io_netty_netty_all//jar", "bind": "jar/io/netty/netty_all"}) callback({"artifact": "io.netty:netty-buffer:4.1.17.Final", "lang": "java", "sha1": "fdd68fb3defd7059a7392b9395ee941ef9bacc25", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_netty_netty_buffer", "actual": "@io_netty_netty_buffer//jar", "bind": "jar/io/netty/netty_buffer"}) callback({"artifact": "io.netty:netty-codec-http2:4.1.17.Final", "lang": "java", "sha1": "f9844005869c6d9049f4b677228a89fee4c6eab3", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_netty_netty_codec_http2", "actual": "@io_netty_netty_codec_http2//jar", "bind": "jar/io/netty/netty_codec_http2"}) callback({"artifact": "io.netty:netty-codec-http:4.1.17.Final", "lang": "java", "sha1": "251d7edcb897122b9b23f24ff793cd0739056b9e", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_netty_netty_codec_http", "actual": "@io_netty_netty_codec_http//jar", "bind": "jar/io/netty/netty_codec_http"}) callback({"artifact": "io.netty:netty-codec-socks:4.1.17.Final", "lang": "java", "sha1": "a159bf1f3d5019e0d561c92fbbec8400967471fa", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_netty_netty_codec_socks", "actual": "@io_netty_netty_codec_socks//jar", "bind": "jar/io/netty/netty_codec_socks"}) callback({"artifact": "io.netty:netty-codec:4.1.17.Final", "lang": "java", "sha1": "1d00f56dc9e55203a4bde5aae3d0828fdeb818e7", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_netty_netty_codec", "actual": "@io_netty_netty_codec//jar", "bind": "jar/io/netty/netty_codec"}) callback({"artifact": "io.netty:netty-common:4.1.17.Final", "lang": "java", "sha1": "581c8ee239e4dc0976c2405d155f475538325098", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_netty_netty_common", "actual": "@io_netty_netty_common//jar", "bind": "jar/io/netty/netty_common"}) callback({"artifact": "io.netty:netty-handler-proxy:4.1.17.Final", "lang": "java", "sha1": "9330ee60c4e48ca60aac89b7bc5ec2567e84f28e", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_netty_netty_handler_proxy", "actual": "@io_netty_netty_handler_proxy//jar", "bind": "jar/io/netty/netty_handler_proxy"}) callback({"artifact": "io.netty:netty-handler:4.1.17.Final", "lang": "java", "sha1": "18c40ffb61a1d1979eca024087070762fdc4664a", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_netty_netty_handler", "actual": "@io_netty_netty_handler//jar", "bind": "jar/io/netty/netty_handler"}) callback({"artifact": "io.netty:netty-resolver:4.1.17.Final", "lang": "java", "sha1": "8f386c80821e200f542da282ae1d3cde5cad8368", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_netty_netty_resolver", "actual": "@io_netty_netty_resolver//jar", "bind": "jar/io/netty/netty_resolver"}) callback({"artifact": "io.netty:netty-transport:4.1.17.Final", "lang": "java", "sha1": "9585776b0a8153182412b5d5366061ff486914c1", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_netty_netty_transport", "actual": "@io_netty_netty_transport//jar", "bind": "jar/io/netty/netty_transport"}) callback({"artifact": "io.opencensus:opencensus-api:0.11.0", "lang": "java", "sha1": "c1ff1f0d737a689d900a3e2113ddc29847188c64", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_opencensus_opencensus_api", "actual": "@io_opencensus_opencensus_api//jar", "bind": "jar/io/opencensus/opencensus_api"}) callback({"artifact": "io.opencensus:opencensus-contrib-grpc-metrics:0.11.0", "lang": "java", "sha1": "d57b877f1a28a613452d45e35c7faae5af585258", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_opencensus_opencensus_contrib_grpc_metrics", "actual": "@io_opencensus_opencensus_contrib_grpc_metrics//jar", "bind": "jar/io/opencensus/opencensus_contrib_grpc_metrics"}) callback({"artifact": "junit:junit:4.12", "lang": "java", "sha1": "2973d150c0dc1fefe998f834810d68f278ea58ec", "repository": "https://repo.maven.apache.org/maven2/", "name": "junit_junit", "actual": "@junit_junit//jar", "bind": "jar/junit/junit"}) callback({"artifact": "org.codehaus.mojo:animal-sniffer-annotations:1.14", "lang": "java", "sha1": "775b7e22fb10026eed3f86e8dc556dfafe35f2d5", "repository": "https://repo.maven.apache.org/maven2/", "name": "org_codehaus_mojo_animal_sniffer_annotations", "actual": "@org_codehaus_mojo_animal_sniffer_annotations//jar", "bind": "jar/org/codehaus/mojo/animal_sniffer_annotations"}) callback({"artifact": "org.hamcrest:hamcrest-core:1.3", "lang": "java", "sha1": "42a25dc3219429f0e5d060061f71acb49bf010a0", "repository": "https://repo.maven.apache.org/maven2/", "name": "org_hamcrest_hamcrest_core", "actual": "@org_hamcrest_hamcrest_core//jar", "bind": "jar/org/hamcrest/hamcrest_core"}) callback({"artifact": "org.textmapper:lapg:0.9.18", "lang": "java", "sha1": "9d480589d5770d75c4401f38c3cfd22a7139a397", "repository": "https://repo.maven.apache.org/maven2/", "name": "org_textmapper_lapg", "actual": "@org_textmapper_lapg//jar", "bind": "jar/org/textmapper/lapg"}) callback({"artifact": "org.textmapper:templates:0.9.18", "lang": "java", "sha1": "1979db4fe5d0581639d3ace891a7abeaf95f8220", "repository": "https://repo.maven.apache.org/maven2/", "name": "org_textmapper_templates", "actual": "@org_textmapper_templates//jar", "bind": "jar/org/textmapper/templates"}) callback({"artifact": "org.textmapper:textmapper:0.9.18", "lang": "java", "sha1": "80ffa6ce9f7f3250fcc62419c0898ffeedbd5902", "repository": "https://repo.maven.apache.org/maven2/", "name": "org_textmapper_textmapper", "actual": "@org_textmapper_textmapper//jar", "bind": "jar/org/textmapper/textmapper"})
def declare_maven(hash): native.maven_jar(name=hash['name'], artifact=hash['artifact'], sha1=hash['sha1'], repository=hash['repository']) native.bind(name=hash['bind'], actual=hash['actual']) def maven_dependencies(callback=declare_maven): callback({'artifact': 'args4j:args4j:2.33', 'lang': 'java', 'sha1': 'bd87a75374a6d6523de82fef51fc3cfe9baf9fc9', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'args4j_args4j', 'actual': '@args4j_args4j//jar', 'bind': 'jar/args4j/args4j'}) callback({'artifact': 'com.google.api.grpc:proto-google-common-protos:1.0.0', 'lang': 'java', 'sha1': '86f070507e28b930e50d218ee5b6788ef0dd05e6', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'com_google_api_grpc_proto_google_common_protos', 'actual': '@com_google_api_grpc_proto_google_common_protos//jar', 'bind': 'jar/com/google/api/grpc/proto_google_common_protos'}) callback({'artifact': 'com.google.code.findbugs:jsr305:3.0.2', 'lang': 'java', 'sha1': '25ea2e8b0c338a877313bd4672d3fe056ea78f0d', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'com_google_code_findbugs_jsr305', 'actual': '@com_google_code_findbugs_jsr305//jar', 'bind': 'jar/com/google/code/findbugs/jsr305'}) callback({'artifact': 'com.google.code.gson:gson:2.8.2', 'lang': 'java', 'sha1': '3edcfe49d2c6053a70a2a47e4e1c2f94998a49cf', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'com_google_code_gson_gson', 'actual': '@com_google_code_gson_gson//jar', 'bind': 'jar/com/google/code/gson/gson'}) callback({'artifact': 'com.google.errorprone:error_prone_annotations:2.1.2', 'lang': 'java', 'sha1': '6dcc08f90f678ac33e5ef78c3c752b6f59e63e0c', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'com_google_errorprone_error_prone_annotations', 'actual': '@com_google_errorprone_error_prone_annotations//jar', 'bind': 'jar/com/google/errorprone/error_prone_annotations'}) callback({'artifact': 'com.google.guava:guava:23.0', 'lang': 'java', 'sha1': 'c947004bb13d18182be60077ade044099e4f26f1', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'com_google_guava_guava', 'actual': '@com_google_guava_guava//jar', 'bind': 'jar/com/google/guava/guava'}) callback({'artifact': 'com.google.instrumentation:instrumentation-api:0.4.3', 'lang': 'java', 'sha1': '41614af3429573dc02645d541638929d877945a2', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'com_google_instrumentation_instrumentation_api', 'actual': '@com_google_instrumentation_instrumentation_api//jar', 'bind': 'jar/com/google/instrumentation/instrumentation_api'}) callback({'artifact': 'com.google.j2objc:j2objc-annotations:1.1', 'lang': 'java', 'sha1': 'ed28ded51a8b1c6b112568def5f4b455e6809019', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'com_google_j2objc_j2objc_annotations', 'actual': '@com_google_j2objc_j2objc_annotations//jar', 'bind': 'jar/com/google/j2objc/j2objc_annotations'}) callback({'artifact': 'com.google.protobuf:protobuf-java-util:3.5.1', 'lang': 'java', 'sha1': '6e40a6a3f52455bd633aa2a0dba1a416e62b4575', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'com_google_protobuf_protobuf_java_util', 'actual': '@com_google_protobuf_protobuf_java_util//jar', 'bind': 'jar/com/google/protobuf/protobuf_java_util'}) callback({'artifact': 'com.google.protobuf:protobuf-java:3.5.1', 'lang': 'java', 'sha1': '8c3492f7662fa1cbf8ca76a0f5eb1146f7725acd', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'com_google_protobuf_protobuf_java', 'actual': '@com_google_protobuf_protobuf_java//jar', 'bind': 'jar/com/google/protobuf/protobuf_java'}) callback({'artifact': 'com.google.truth:truth:0.35', 'lang': 'java', 'sha1': 'c08a7fde45e058323bcfa3f510d4fe1e2b028f37', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'com_google_truth_truth', 'actual': '@com_google_truth_truth//jar', 'bind': 'jar/com/google/truth/truth'}) callback({'artifact': 'io.grpc:grpc-context:1.10.0', 'lang': 'java', 'sha1': 'da0a701be6ba04aff0bd54ca3db8248d8f2eaafc', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'io_grpc_grpc_context', 'actual': '@io_grpc_grpc_context//jar', 'bind': 'jar/io/grpc/grpc_context'}) callback({'artifact': 'io.grpc:grpc-core:1.10.0', 'lang': 'java', 'sha1': '8976afebf2a6530574a71bc1260920ce910c2292', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'io_grpc_grpc_core', 'actual': '@io_grpc_grpc_core//jar', 'bind': 'jar/io/grpc/grpc_core'}) callback({'artifact': 'io.grpc:grpc-netty:1.10.0', 'lang': 'java', 'sha1': 'a1056d69003c9b46d1c4aa4a9167c6e8a714d152', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'io_grpc_grpc_netty', 'actual': '@io_grpc_grpc_netty//jar', 'bind': 'jar/io/grpc/grpc_netty'}) callback({'artifact': 'io.grpc:grpc-protobuf-lite:1.10.0', 'lang': 'java', 'sha1': 'b8e40dd308dc370e64bd2c337bb2761a03299a7f', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'io_grpc_grpc_protobuf_lite', 'actual': '@io_grpc_grpc_protobuf_lite//jar', 'bind': 'jar/io/grpc/grpc_protobuf_lite'}) callback({'artifact': 'io.grpc:grpc-protobuf:1.10.0', 'lang': 'java', 'sha1': '64098f046f227b47238bc747e3cee6c7fc087bb8', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'io_grpc_grpc_protobuf', 'actual': '@io_grpc_grpc_protobuf//jar', 'bind': 'jar/io/grpc/grpc_protobuf'}) callback({'artifact': 'io.grpc:grpc-services:1.10.0', 'lang': 'java', 'sha1': 'ae898f12418429c9d1396aaf5ac2377bf8ecb25b', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'io_grpc_grpc_services', 'actual': '@io_grpc_grpc_services//jar', 'bind': 'jar/io/grpc/grpc_services'}) callback({'artifact': 'io.grpc:grpc-stub:1.10.0', 'lang': 'java', 'sha1': 'd022706796b0820d388f83571da160fb8d280ded', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'io_grpc_grpc_stub', 'actual': '@io_grpc_grpc_stub//jar', 'bind': 'jar/io/grpc/grpc_stub'}) callback({'artifact': 'io.netty:netty-all:4.1.22.Final', 'lang': 'java', 'sha1': 'c1cea5d30025e4d584d2b287d177c31aea4ae629', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'io_netty_netty_all', 'actual': '@io_netty_netty_all//jar', 'bind': 'jar/io/netty/netty_all'}) callback({'artifact': 'io.netty:netty-buffer:4.1.17.Final', 'lang': 'java', 'sha1': 'fdd68fb3defd7059a7392b9395ee941ef9bacc25', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'io_netty_netty_buffer', 'actual': '@io_netty_netty_buffer//jar', 'bind': 'jar/io/netty/netty_buffer'}) callback({'artifact': 'io.netty:netty-codec-http2:4.1.17.Final', 'lang': 'java', 'sha1': 'f9844005869c6d9049f4b677228a89fee4c6eab3', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'io_netty_netty_codec_http2', 'actual': '@io_netty_netty_codec_http2//jar', 'bind': 'jar/io/netty/netty_codec_http2'}) callback({'artifact': 'io.netty:netty-codec-http:4.1.17.Final', 'lang': 'java', 'sha1': '251d7edcb897122b9b23f24ff793cd0739056b9e', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'io_netty_netty_codec_http', 'actual': '@io_netty_netty_codec_http//jar', 'bind': 'jar/io/netty/netty_codec_http'}) callback({'artifact': 'io.netty:netty-codec-socks:4.1.17.Final', 'lang': 'java', 'sha1': 'a159bf1f3d5019e0d561c92fbbec8400967471fa', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'io_netty_netty_codec_socks', 'actual': '@io_netty_netty_codec_socks//jar', 'bind': 'jar/io/netty/netty_codec_socks'}) callback({'artifact': 'io.netty:netty-codec:4.1.17.Final', 'lang': 'java', 'sha1': '1d00f56dc9e55203a4bde5aae3d0828fdeb818e7', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'io_netty_netty_codec', 'actual': '@io_netty_netty_codec//jar', 'bind': 'jar/io/netty/netty_codec'}) callback({'artifact': 'io.netty:netty-common:4.1.17.Final', 'lang': 'java', 'sha1': '581c8ee239e4dc0976c2405d155f475538325098', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'io_netty_netty_common', 'actual': '@io_netty_netty_common//jar', 'bind': 'jar/io/netty/netty_common'}) callback({'artifact': 'io.netty:netty-handler-proxy:4.1.17.Final', 'lang': 'java', 'sha1': '9330ee60c4e48ca60aac89b7bc5ec2567e84f28e', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'io_netty_netty_handler_proxy', 'actual': '@io_netty_netty_handler_proxy//jar', 'bind': 'jar/io/netty/netty_handler_proxy'}) callback({'artifact': 'io.netty:netty-handler:4.1.17.Final', 'lang': 'java', 'sha1': '18c40ffb61a1d1979eca024087070762fdc4664a', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'io_netty_netty_handler', 'actual': '@io_netty_netty_handler//jar', 'bind': 'jar/io/netty/netty_handler'}) callback({'artifact': 'io.netty:netty-resolver:4.1.17.Final', 'lang': 'java', 'sha1': '8f386c80821e200f542da282ae1d3cde5cad8368', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'io_netty_netty_resolver', 'actual': '@io_netty_netty_resolver//jar', 'bind': 'jar/io/netty/netty_resolver'}) callback({'artifact': 'io.netty:netty-transport:4.1.17.Final', 'lang': 'java', 'sha1': '9585776b0a8153182412b5d5366061ff486914c1', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'io_netty_netty_transport', 'actual': '@io_netty_netty_transport//jar', 'bind': 'jar/io/netty/netty_transport'}) callback({'artifact': 'io.opencensus:opencensus-api:0.11.0', 'lang': 'java', 'sha1': 'c1ff1f0d737a689d900a3e2113ddc29847188c64', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'io_opencensus_opencensus_api', 'actual': '@io_opencensus_opencensus_api//jar', 'bind': 'jar/io/opencensus/opencensus_api'}) callback({'artifact': 'io.opencensus:opencensus-contrib-grpc-metrics:0.11.0', 'lang': 'java', 'sha1': 'd57b877f1a28a613452d45e35c7faae5af585258', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'io_opencensus_opencensus_contrib_grpc_metrics', 'actual': '@io_opencensus_opencensus_contrib_grpc_metrics//jar', 'bind': 'jar/io/opencensus/opencensus_contrib_grpc_metrics'}) callback({'artifact': 'junit:junit:4.12', 'lang': 'java', 'sha1': '2973d150c0dc1fefe998f834810d68f278ea58ec', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'junit_junit', 'actual': '@junit_junit//jar', 'bind': 'jar/junit/junit'}) callback({'artifact': 'org.codehaus.mojo:animal-sniffer-annotations:1.14', 'lang': 'java', 'sha1': '775b7e22fb10026eed3f86e8dc556dfafe35f2d5', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'org_codehaus_mojo_animal_sniffer_annotations', 'actual': '@org_codehaus_mojo_animal_sniffer_annotations//jar', 'bind': 'jar/org/codehaus/mojo/animal_sniffer_annotations'}) callback({'artifact': 'org.hamcrest:hamcrest-core:1.3', 'lang': 'java', 'sha1': '42a25dc3219429f0e5d060061f71acb49bf010a0', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'org_hamcrest_hamcrest_core', 'actual': '@org_hamcrest_hamcrest_core//jar', 'bind': 'jar/org/hamcrest/hamcrest_core'}) callback({'artifact': 'org.textmapper:lapg:0.9.18', 'lang': 'java', 'sha1': '9d480589d5770d75c4401f38c3cfd22a7139a397', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'org_textmapper_lapg', 'actual': '@org_textmapper_lapg//jar', 'bind': 'jar/org/textmapper/lapg'}) callback({'artifact': 'org.textmapper:templates:0.9.18', 'lang': 'java', 'sha1': '1979db4fe5d0581639d3ace891a7abeaf95f8220', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'org_textmapper_templates', 'actual': '@org_textmapper_templates//jar', 'bind': 'jar/org/textmapper/templates'}) callback({'artifact': 'org.textmapper:textmapper:0.9.18', 'lang': 'java', 'sha1': '80ffa6ce9f7f3250fcc62419c0898ffeedbd5902', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'org_textmapper_textmapper', 'actual': '@org_textmapper_textmapper//jar', 'bind': 'jar/org/textmapper/textmapper'})
def zebra_2(x,y): pattern=["/","/","/","-","-","-"] z=0 while z<y: for i in range(0,x): print(pattern[i % len(pattern)], end='') z+=1 print("\n") x=int(input("give me a number of charcters in the row:" )) y=int(input("give me a number of rows:" )) zebra_2(x,y)
def zebra_2(x, y): pattern = ['/', '/', '/', '-', '-', '-'] z = 0 while z < y: for i in range(0, x): print(pattern[i % len(pattern)], end='') z += 1 print('\n') x = int(input('give me a number of charcters in the row:')) y = int(input('give me a number of rows:')) zebra_2(x, y)
weather_appid = "12345678" weather_appsecret = "abcdefg" baidu_map_ak = "dfjkal;fjalskf;as"
weather_appid = '12345678' weather_appsecret = 'abcdefg' baidu_map_ak = 'dfjkal;fjalskf;as'
first, second, year = map(int, input().split()) if first == second: print(1) elif first < 13 and second < 13: print(0) else: print(1)
(first, second, year) = map(int, input().split()) if first == second: print(1) elif first < 13 and second < 13: print(0) else: print(1)
# Converts the rows of data, with the specified # headers, into an easily human readable csv string. def readable_csv(rows, headers, digits=None): if digits is not None: for i, row in enumerate(rows): for j, col in enumerate(row): if isinstance(col, float): rows[i][j] = round(col, digits) # First, stringify everything. rows = [[str(c) for c in row] for row in rows] # Get the width needed for each column and add two. widths = [max([len(r[col]) for r in rows]) for col in range(len(rows[0]))] widths = [max(w, len(headers[i])) + 2 for i, w in enumerate(widths)] def space(row): return [c.ljust(widths[i]) for i, c in enumerate(row)] result = '%s\n'%(','.join(space(headers))) for row in rows: result += '%s\n'%(','.join(space(row))) return result[:-1]
def readable_csv(rows, headers, digits=None): if digits is not None: for (i, row) in enumerate(rows): for (j, col) in enumerate(row): if isinstance(col, float): rows[i][j] = round(col, digits) rows = [[str(c) for c in row] for row in rows] widths = [max([len(r[col]) for r in rows]) for col in range(len(rows[0]))] widths = [max(w, len(headers[i])) + 2 for (i, w) in enumerate(widths)] def space(row): return [c.ljust(widths[i]) for (i, c) in enumerate(row)] result = '%s\n' % ','.join(space(headers)) for row in rows: result += '%s\n' % ','.join(space(row)) return result[:-1]
class PLSR_SSS_Helper(object): def __init__(self,train_data,X,mse,msemin,component,y,y_c,y_cv,attribute,importance, prediction,dir_path,reportpath,prediction_map,modelsavepath,img_path,tran_path): self.train_data = train_data self.X = X self.mse = mse self.msemin = msemin self.component = component self.y = y self.y_c = y_c self.y_cv = y_cv self.attribute = attribute self.importance = importance self.prediction = prediction self.dir_path = dir_path self.reportpath = reportpath self.prediction_map = prediction_map self.modelsavepath = modelsavepath self.img_path = img_path self.tran_path = tran_path # # # # def __str__(self): # return self.dir_path
class Plsr_Sss_Helper(object): def __init__(self, train_data, X, mse, msemin, component, y, y_c, y_cv, attribute, importance, prediction, dir_path, reportpath, prediction_map, modelsavepath, img_path, tran_path): self.train_data = train_data self.X = X self.mse = mse self.msemin = msemin self.component = component self.y = y self.y_c = y_c self.y_cv = y_cv self.attribute = attribute self.importance = importance self.prediction = prediction self.dir_path = dir_path self.reportpath = reportpath self.prediction_map = prediction_map self.modelsavepath = modelsavepath self.img_path = img_path self.tran_path = tran_path
# Symmetric Difference # Problem Link: https://www.hackerrank.com/challenges/symmetric-difference/problem m = int(input()) marr = set(map(int, input().split())) n = int(input()) narr = set(map(int, input().split())) for x in sorted(marr ^ narr): print(x)
m = int(input()) marr = set(map(int, input().split())) n = int(input()) narr = set(map(int, input().split())) for x in sorted(marr ^ narr): print(x)
class Scene: def __init__(self, camera, shapes, materials, lights): self.camera = camera self.shapes = shapes self.materials = materials self.lights = lights
class Scene: def __init__(self, camera, shapes, materials, lights): self.camera = camera self.shapes = shapes self.materials = materials self.lights = lights
# https://leetcode.com/problems/climbing-stairs/ class Solution: # def climbStairs(self, n: int) -> int: # array = [1, 2] # for i in range(2, n+1): # array.append(array[i-1] + array[i-2]) # return array[n-1] def climbStairs(self, n: int) -> int: if n <= 2: return n f1, f2, f3 = 1, 2, 3 for i in range(3, n+1): f3 = f1 + f2 f1 = f2 f2 = f3 return f3 print(Solution().climbStairs(1)) print(Solution().climbStairs(2)) print(Solution().climbStairs(3)) print(Solution().climbStairs(4)) print(Solution().climbStairs(5))
class Solution: def climb_stairs(self, n: int) -> int: if n <= 2: return n (f1, f2, f3) = (1, 2, 3) for i in range(3, n + 1): f3 = f1 + f2 f1 = f2 f2 = f3 return f3 print(solution().climbStairs(1)) print(solution().climbStairs(2)) print(solution().climbStairs(3)) print(solution().climbStairs(4)) print(solution().climbStairs(5))
# HAUL Resources def get(i): return None def use(filename): # Do nothing, it is overridden when testing; in order to load resources at runtime return -1
def get(i): return None def use(filename): return -1
def failure_message(message=None, user=None, user_group=None): resp = '''Message failed to send, please try again later or contact administrator from: Broadcast Admin - Only you can see this message ''' return resp
def failure_message(message=None, user=None, user_group=None): resp = 'Message failed to send, please try again later or contact administrator\n from: Broadcast Admin\n - Only you can see this message\n ' return resp
n_str = input() n = int(n_str) if (n == 1): print(1.000000000000) else: sum = 0.000000000000 for i in range(1, n+1): sum += round((1.000000000000)/i, 12) print(sum)
n_str = input() n = int(n_str) if n == 1: print(1.0) else: sum = 0.0 for i in range(1, n + 1): sum += round(1.0 / i, 12) print(sum)
class Redirect: def __init__(self, url: str = ""): self.redirect_url = url def to_dict(self): tmp_dict = { "redirect_url": self.redirect_url, } return tmp_dict
class Redirect: def __init__(self, url: str=''): self.redirect_url = url def to_dict(self): tmp_dict = {'redirect_url': self.redirect_url} return tmp_dict
#!/usr/bin/python array = [0] * 43 Top = 1 Bottom = 2 Far = 4 Near = 8 Left = 16 Right = 32 scopeName = 'FDataConstants::' #Edge map array[Top + Far] = 'TopFar' array[Top + Near] = 'TopNear' array[Top + Left] = 'FTopLeft' array[Top + Right] = 'TopRight' array[Bottom + Far] = 'BottomFar' array[Bottom + Near] = 'BottomNear' array[Bottom + Left] = 'BottomLeft' array[Bottom + Right] = 'BottomRight' array[Far + Left] = 'FarLeft' array[Far + Right] = 'FarRight' array[Near + Left] = 'NearLeft' array[Near+ Right] = 'NearRight' #Vertex map array[Top + Far + Left] = 'TopFarLeft' array[Top + Far + Right] = 'TopFarRight' array[Top + Near + Left] = 'TopNearLeft' array[Top + Near + Right] = 'TopNearRight' array[Bottom + Far + Left] = 'BottomFarLeft' array[Bottom + Far + Right] = 'BottomFarRight' array[Bottom + Near + Left] = 'BottomNearLeft' array[Bottom + Near + Right] = 'BottomNearRight' for e in array: if e == 0: print(str(e), end=', '), else: print('\n' + scopeName + str(e), end=', '),
array = [0] * 43 top = 1 bottom = 2 far = 4 near = 8 left = 16 right = 32 scope_name = 'FDataConstants::' array[Top + Far] = 'TopFar' array[Top + Near] = 'TopNear' array[Top + Left] = 'FTopLeft' array[Top + Right] = 'TopRight' array[Bottom + Far] = 'BottomFar' array[Bottom + Near] = 'BottomNear' array[Bottom + Left] = 'BottomLeft' array[Bottom + Right] = 'BottomRight' array[Far + Left] = 'FarLeft' array[Far + Right] = 'FarRight' array[Near + Left] = 'NearLeft' array[Near + Right] = 'NearRight' array[Top + Far + Left] = 'TopFarLeft' array[Top + Far + Right] = 'TopFarRight' array[Top + Near + Left] = 'TopNearLeft' array[Top + Near + Right] = 'TopNearRight' array[Bottom + Far + Left] = 'BottomFarLeft' array[Bottom + Far + Right] = 'BottomFarRight' array[Bottom + Near + Left] = 'BottomNearLeft' array[Bottom + Near + Right] = 'BottomNearRight' for e in array: if e == 0: (print(str(e), end=', '),) else: (print('\n' + scopeName + str(e), end=', '),)
class Website(object): def __init__(self, site): self.URL = site class Internet(object): def __init__(self): self.url_list = dict() def add_url(self, website): if website.URL in self.url_list: self.url_list[website.URL] += 1 else: self.url_list[website.URL] = 1 def solution(self): return sorted(self.url_list.items(), key=lambda i: (-i[1], i[0])) def solve(S, N): net = Internet() for s in S: net.add_url(s) return net.solution() # write your code here N = int(input()) S = [] for _ in range(N): S.append(Website(input())) out_ = solve(S, N) print(len(out_)) for i_out_ in out_: print(i_out_[0])
class Website(object): def __init__(self, site): self.URL = site class Internet(object): def __init__(self): self.url_list = dict() def add_url(self, website): if website.URL in self.url_list: self.url_list[website.URL] += 1 else: self.url_list[website.URL] = 1 def solution(self): return sorted(self.url_list.items(), key=lambda i: (-i[1], i[0])) def solve(S, N): net = internet() for s in S: net.add_url(s) return net.solution() n = int(input()) s = [] for _ in range(N): S.append(website(input())) out_ = solve(S, N) print(len(out_)) for i_out_ in out_: print(i_out_[0])
max= 0 a = 2 b = 3 if a < b: max= b if b < a: max= a assert (max == a or max == b) and max >= a and max >= b
max = 0 a = 2 b = 3 if a < b: max = b if b < a: max = a assert (max == a or max == b) and max >= a and (max >= b)
def rotateLeft(array_list , num_rotate ): alist = list(array_list) rotated_list = alist[num_rotate :]+alist[:num_rotate ] return rotated_list array_list = [] n = int(input("Enter number of elements in array list : ")) for i in range(0, n): elem = int(input()) array_list.append(elem) num_rotate=int(input('Enter Number of rotations to be made: ')) print("The List after rotations is: ") print(rotateLeft(array_list, num_rotate))
def rotate_left(array_list, num_rotate): alist = list(array_list) rotated_list = alist[num_rotate:] + alist[:num_rotate] return rotated_list array_list = [] n = int(input('Enter number of elements in array list : ')) for i in range(0, n): elem = int(input()) array_list.append(elem) num_rotate = int(input('Enter Number of rotations to be made: ')) print('The List after rotations is: ') print(rotate_left(array_list, num_rotate))
#createMinMaxFunction.py def minimum_value(lst): #check if any ints or floats are in the list type_list = check_list_types(lst) #if not, return error if float not in type_list and int not in type_list: return "error" # if not create check every value in list against the value assigned to minimum # default value for minimum is inf minimum = float('inf') for val in lst: try: if val < minimum: minimum = val except: return_operator_error(val) return minimum def maximum_value(lst): #check if any ints or floats are in the list type_list = check_list_types(lst) #if not, return error if float not in type_list and int not in type_list: return "error" # if not create check every value in list against the value assigned to minimum # default value for minimum is inf maximum = float('-inf') for val in lst: try: if val > maximum: maximum = val except: return_operator_error(val) return maximum def return_operator_error(val): print("object is type:", type(val), "Cannot apply operator") def check_list_types(lst): # create a list called type_list that records type every element in lst type_list = [type(val) for val in lst] #reduce this list with set() to record each type only once #convert set() to list() types = list(set(type_list)) return types list1 = [12,24,33,485] string_list = ["These", "are", "strings", "not", "values"] mixed_list = [1,2,35,"fdsajfsa",3128473217980] min_list1 = minimum_value(list1) max_list1 = maximum_value(list1) min_string = minimum_value(string_list) max_string = maximum_value(string_list) min_mixed = minimum_value(mixed_list) max_mixed = maximum_value(mixed_list) print("Minimum value from list1:", min_list1) print("Maximum value from list1:", max_list1) print("Minimum value from string_list:", min_string) print("Maximum value from string_list:", max_string) print("Minimum value from mixed_list:", min_mixed) print("Maximum value from mixed_list:", max_mixed)
def minimum_value(lst): type_list = check_list_types(lst) if float not in type_list and int not in type_list: return 'error' minimum = float('inf') for val in lst: try: if val < minimum: minimum = val except: return_operator_error(val) return minimum def maximum_value(lst): type_list = check_list_types(lst) if float not in type_list and int not in type_list: return 'error' maximum = float('-inf') for val in lst: try: if val > maximum: maximum = val except: return_operator_error(val) return maximum def return_operator_error(val): print('object is type:', type(val), 'Cannot apply operator') def check_list_types(lst): type_list = [type(val) for val in lst] types = list(set(type_list)) return types list1 = [12, 24, 33, 485] string_list = ['These', 'are', 'strings', 'not', 'values'] mixed_list = [1, 2, 35, 'fdsajfsa', 3128473217980] min_list1 = minimum_value(list1) max_list1 = maximum_value(list1) min_string = minimum_value(string_list) max_string = maximum_value(string_list) min_mixed = minimum_value(mixed_list) max_mixed = maximum_value(mixed_list) print('Minimum value from list1:', min_list1) print('Maximum value from list1:', max_list1) print('Minimum value from string_list:', min_string) print('Maximum value from string_list:', max_string) print('Minimum value from mixed_list:', min_mixed) print('Maximum value from mixed_list:', max_mixed)
def main(): n = int(input()) p = [] for _ in range(n): p.append(input()) k = p.copy() k.sort() # print(k, p) if k == p: print("INCREASING") return # print(reversed(k), p, reversed(k) == p) if list(reversed(k)) == p: print("DECREASING") else: print("NEITHER") return if __name__ == "__main__": main()
def main(): n = int(input()) p = [] for _ in range(n): p.append(input()) k = p.copy() k.sort() if k == p: print('INCREASING') return if list(reversed(k)) == p: print('DECREASING') else: print('NEITHER') return if __name__ == '__main__': main()
nome = input('Qual o seu nome? ') sobrenome = input('Qual o seu sobrenome? ') print('Seja bem-vindo(a), {} {}!'.format(nome, sobrenome)) print('Ordem natural: {0} {1}'.format(nome, sobrenome)) print('Ordem inversa: {1} {0}'.format(nome, sobrenome)) print('Outra forma: {0} {1} {other}'.format(nome, sobrenome, other = 'Santos'))
nome = input('Qual o seu nome? ') sobrenome = input('Qual o seu sobrenome? ') print('Seja bem-vindo(a), {} {}!'.format(nome, sobrenome)) print('Ordem natural: {0} {1}'.format(nome, sobrenome)) print('Ordem inversa: {1} {0}'.format(nome, sobrenome)) print('Outra forma: {0} {1} {other}'.format(nome, sobrenome, other='Santos'))
# import time # import os # import stat # import random # import string # # import pytest # # import cattle # # from kubernetes import client as k8sclient, config as k8sconfig # BASE_URL = "http://%ip%:9333/v1" token = "" fqdn = "" create_param = { 'fqdn': '', 'hosts': ["1.1.1.1", "2.2.2.2"] } update_param = { 'fqdn': '', 'hosts': ["3.3.3.3"] } def set_token_fqdn(result): global token, fqdn token = result['token'] fqdn = result['data']['fqdn'] def get_token_fqdn(): return token, fqdn # SIZE = str(16 * 1024 * 1024) # VOLUME_NAME = "longhorn-testvol" # DEV_PATH = "/dev/longhorn/" # VOLUME_RWTEST_SIZE = 512 # VOLUME_INVALID_POS = -1 # PORT = ":9500" # # RETRY_COUNTS = 300 # RETRY_ITERVAL = 0.5 # # LONGHORN_NAMESPACE = "longhorn-system" # # COMPATIBILTY_TEST_IMAGE_PREFIX = "rancher/longhorn-test:version-test" # UPGRADE_TEST_IMAGE_PREFIX = "rancher/longhorn-test:upgrade-test" # # ISCSI_DEV_PATH = "/dev/disk/by-path" # # # @pytest.fixture # def clients(request): # k8sconfig.load_incluster_config() # ips = get_mgr_ips() # client = get_client(ips[0] + PORT) # hosts = client.list_host() # assert len(hosts) == len(ips) # clis = get_clients(hosts) # request.addfinalizer(lambda: cleanup_clients(clis)) # cleanup_clients(clis) # return clis # # # def cleanup_clients(clis): # client = clis.itervalues().next() # volumes = client.list_volume() # for v in volumes: # # ignore the error when clean up # try: # client.delete(v) # except Exception: # pass # images = client.list_engine_image() # for img in images: # if not img["default"]: # # ignore the error when clean up # try: # client.delete(img) # except Exception: # pass # # # def get_client(address): # url = 'http://' + address + '/v1/schemas' # c = cattle.from_env(url=url) # return c # # # def get_mgr_ips(): # ret = k8sclient.CoreV1Api().list_pod_for_all_namespaces( # label_selector="app=longhorn-manager", # watch=False) # mgr_ips = [] # for i in ret.items: # mgr_ips.append(i.status.pod_ip) # return mgr_ips # # # def get_self_host_id(): # envs = os.environ # return envs["NODE_NAME"] # # # def get_backupstore_url(): # backupstore = os.environ['LONGHORN_BACKUPSTORES'] # backupstore = backupstore.replace(" ", "") # backupstores = backupstore.split(",") # # assert len(backupstores) != 0 # return backupstores # # # def get_clients(hosts): # clients = {} # for host in hosts: # assert host["uuid"] is not None # assert host["address"] is not None # clients[host["uuid"]] = get_client(host["address"] + PORT) # return clients # # # def wait_for_device_login(dest_path, name): # dev = "" # for i in range(RETRY_COUNTS): # files = os.listdir(dest_path) # if name in files: # dev = name # break # time.sleep(RETRY_ITERVAL) # assert dev == name # return dev # # # def wait_for_volume_state(client, name, state): # for i in range(RETRY_COUNTS): # volume = client.by_id_volume(name) # if volume["state"] == state: # break # time.sleep(RETRY_ITERVAL) # assert volume["state"] == state # return volume # # # def wait_for_volume_delete(client, name): # for i in range(RETRY_COUNTS): # volumes = client.list_volume() # found = False # for volume in volumes: # if volume["name"] == name: # found = True # if not found: # break # time.sleep(RETRY_ITERVAL) # assert not found # # # def wait_for_volume_engine_image(client, name, image): # for i in range(RETRY_COUNTS): # volume = client.by_id_volume(name) # if volume["engineImage"] == image: # break # time.sleep(RETRY_ITERVAL) # assert volume["engineImage"] == image # return volume # # # def wait_for_volume_replica_count(client, name, count): # for i in range(RETRY_COUNTS): # volume = client.by_id_volume(name) # if len(volume["replicas"]) == count: # break # time.sleep(RETRY_ITERVAL) # assert len(volume["replicas"]) == count # return volume # # # def wait_for_snapshot_purge(volume, *snaps): # for i in range(RETRY_COUNTS): # snapshots = volume.snapshotList(volume=volume["name"]) # snapMap = {} # for snap in snapshots: # snapMap[snap["name"]] = snap # found = False # for snap in snaps: # if snap in snapMap: # found = True # break # if not found: # break # time.sleep(RETRY_ITERVAL) # assert not found # # # def wait_for_engine_image_state(client, image_name, state): # for i in range(RETRY_COUNTS): # image = client.by_id_engine_image(image_name) # if image["state"] == state: # break # time.sleep(RETRY_ITERVAL) # assert image["state"] == state # return image # # # def wait_for_engine_image_ref_count(client, image_name, count): # for i in range(RETRY_COUNTS): # image = client.by_id_engine_image(image_name) # if image["refCount"] == count: # break # time.sleep(RETRY_ITERVAL) # assert image["refCount"] == count # if count == 0: # assert image["noRefSince"] != "" # return image # # # def k8s_delete_replica_pods_for_volume(volname): # k8sclient.CoreV1Api().delete_collection_namespaced_pod( # label_selector="longhorn-volume-replica=" + volname, # namespace=LONGHORN_NAMESPACE, # watch=False) # # # @pytest.fixture # def volume_name(request): # return generate_volume_name() # # # @pytest.fixture # def csi_pvc_name(request): # return generate_volume_name() # # # def generate_volume_name(): # return VOLUME_NAME + "-" + \ # ''.join(random.choice(string.ascii_lowercase + string.digits) # for _ in range(6)) # # # def get_default_engine_image(client): # images = client.list_engine_image() # for img in images: # if img["default"]: # return img # assert False # # # def get_compatibility_test_image(cli_v, cli_minv, # ctl_v, ctl_minv, # data_v, data_minv): # return "%s.%d-%d.%d-%d.%d-%d" % (COMPATIBILTY_TEST_IMAGE_PREFIX, # cli_v, cli_minv, # ctl_v, ctl_minv, # data_v, data_minv) # # # def generate_random_data(count): # return ''.join(random.choice(string.ascii_lowercase + string.digits) # for _ in range(count)) # # # def volume_read(dev, start, count): # r_data = "" # fdev = open(dev, 'rb') # if fdev is not None: # fdev.seek(start) # r_data = fdev.read(count) # fdev.close() # return r_data # # # def volume_write(dev, start, data): # w_length = 0 # fdev = open(dev, 'rb+') # if fdev is not None: # fdev.seek(start) # fdev.write(data) # fdev.close() # w_length = len(data) # return w_length # # # def volume_valid(dev): # return stat.S_ISBLK(os.stat(dev).st_mode) # # # def parse_iscsi_endpoint(iscsi): # iscsi_endpoint = iscsi[8:] # return iscsi_endpoint.split('/') # # # def get_iscsi_ip(iscsi): # iscsi_endpoint = parse_iscsi_endpoint(iscsi) # ip = iscsi_endpoint[0].split(':') # return ip[0] # # # def get_iscsi_port(iscsi): # iscsi_endpoint = parse_iscsi_endpoint(iscsi) # ip = iscsi_endpoint[0].split(':') # return ip[1] # # # def get_iscsi_target(iscsi): # iscsi_endpoint = parse_iscsi_endpoint(iscsi) # return iscsi_endpoint[1] # # # def get_iscsi_lun(iscsi): # iscsi_endpoint = parse_iscsi_endpoint(iscsi) # return iscsi_endpoint[2] # # # def exec_nsenter(cmd): # exec_cmd = "nsenter --mount=/host/proc/1/ns/mnt \ # --net=/host/proc/1/ns/net bash -c \"" + cmd + "\"" # fp = os.popen(exec_cmd) # ret = fp.read() # fp.close() # return ret # # # def iscsi_login(iscsi_ep): # ip = get_iscsi_ip(iscsi_ep) # port = get_iscsi_port(iscsi_ep) # target = get_iscsi_target(iscsi_ep) # lun = get_iscsi_lun(iscsi_ep) # # discovery # cmd_discovery = "iscsiadm -m discovery -t st -p " + ip # exec_nsenter(cmd_discovery) # # login # cmd_login = "iscsiadm -m node -T " + target + " -p " + ip + " --login" # exec_nsenter(cmd_login) # blk_name = "ip-%s:%s-iscsi-%s-lun-%s" % (ip, port, target, lun) # wait_for_device_login(ISCSI_DEV_PATH, blk_name) # dev = os.path.realpath(ISCSI_DEV_PATH + "/" + blk_name) # return dev # # # def iscsi_logout(iscsi_ep): # ip = get_iscsi_ip(iscsi_ep) # target = get_iscsi_target(iscsi_ep) # cmd_logout = "iscsiadm -m node -T " + target + " -p " + ip + " --logout" # exec_nsenter(cmd_logout) # cmd_rm_discovery = "iscsiadm -m discovery -p " + ip + " -o delete" # exec_nsenter(cmd_rm_discovery) # # # def generate_random_pos(size, used={}): # for i in range(RETRY_COUNTS): # pos = 0 # if int(SIZE) != size: # pos = random.randrange(0, int(SIZE) - size, 1) # collided = False # # it's [start, end) vs [pos, pos + size) # for start, end in used.items(): # if pos + size <= start or pos >= end: # continue # collided = True # break # if not collided: # break # assert not collided # used[pos] = pos + size # return pos # # # def get_upgrade_test_image(cli_v, cli_minv, # ctl_v, ctl_minv, # data_v, data_minv): # return "%s.%d-%d.%d-%d.%d-%d" % (UPGRADE_TEST_IMAGE_PREFIX, # cli_v, cli_minv, # ctl_v, ctl_minv, # data_v, data_minv)
base_url = 'http://%ip%:9333/v1' token = '' fqdn = '' create_param = {'fqdn': '', 'hosts': ['1.1.1.1', '2.2.2.2']} update_param = {'fqdn': '', 'hosts': ['3.3.3.3']} def set_token_fqdn(result): global token, fqdn token = result['token'] fqdn = result['data']['fqdn'] def get_token_fqdn(): return (token, fqdn)
a, b, i = 0, 1, 2 fibo = [a, b] while i < 100: i = i + 1 a, b = b, a+b fibo.append(b)
(a, b, i) = (0, 1, 2) fibo = [a, b] while i < 100: i = i + 1 (a, b) = (b, a + b) fibo.append(b)
# Recursive solution for permutation class Solution: def permute(self, nums: List[int]) -> List[List[int]]: result = [] self.permu_helper(nums, [], result) return result def permu_helper(self, new_list, temp, result): if len(new_list) == 0: result.append(temp) return for i in range(len(new_list)): self.permu_helper(new_list[:i]+new_list[i+1:],temp+[new_list[i]], result )
class Solution: def permute(self, nums: List[int]) -> List[List[int]]: result = [] self.permu_helper(nums, [], result) return result def permu_helper(self, new_list, temp, result): if len(new_list) == 0: result.append(temp) return for i in range(len(new_list)): self.permu_helper(new_list[:i] + new_list[i + 1:], temp + [new_list[i]], result)
rankDict = { '1': 'A', '11': 'J', '12': 'Q', '13': 'K' } class Rank: def __init__(self, number): if not (1 <= number <= 13): raise Exception("number is out of range") self.number = number def __str__(self): return rankDict.get(str(self.number), str(self.number))
rank_dict = {'1': 'A', '11': 'J', '12': 'Q', '13': 'K'} class Rank: def __init__(self, number): if not 1 <= number <= 13: raise exception('number is out of range') self.number = number def __str__(self): return rankDict.get(str(self.number), str(self.number))
def server(host, port, symmetricKey): sockVanilla = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sockVanilla.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sockVanilla.bind((host, port)) sockVanilla.listen(5) while True: sockClientVanilla, source = sockVanilla.accept() sock = EasySafeSocket(sockClientVanilla, symmetricKey) threading.Thread(target=OnConnection, args=(sock, source[0], source[1])).start()
def server(host, port, symmetricKey): sock_vanilla = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sockVanilla.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sockVanilla.bind((host, port)) sockVanilla.listen(5) while True: (sock_client_vanilla, source) = sockVanilla.accept() sock = easy_safe_socket(sockClientVanilla, symmetricKey) threading.Thread(target=OnConnection, args=(sock, source[0], source[1])).start()
name_list= ['Sharon','Mic','Josh','Hannah','Hansel'] height_list = [172,166,187,200,166] weight_list = [59.5,65.6,49.8,64.2,47.5] size_list = ['M','L','S','M','S'] bmi_list = [] for i in range(len(name_list)): bmi = weight_list[i]/((height_list[i]/100)**2) bmi_list.append('{:.2f}'.format(bmi)) print("{:<10} {:<8} {:<8} {:<8} {:<5}".format('Name','Weight','Height','BMI','Size')) for i in range(len(name_list)): print("{:<10} {:<8} {:<8} {:<8} {:<5}".format(name_list[i], weight_list[i],height_list[i],bmi_list[i],size_list[i]))
name_list = ['Sharon', 'Mic', 'Josh', 'Hannah', 'Hansel'] height_list = [172, 166, 187, 200, 166] weight_list = [59.5, 65.6, 49.8, 64.2, 47.5] size_list = ['M', 'L', 'S', 'M', 'S'] bmi_list = [] for i in range(len(name_list)): bmi = weight_list[i] / (height_list[i] / 100) ** 2 bmi_list.append('{:.2f}'.format(bmi)) print('{:<10} {:<8} {:<8} {:<8} {:<5}'.format('Name', 'Weight', 'Height', 'BMI', 'Size')) for i in range(len(name_list)): print('{:<10} {:<8} {:<8} {:<8} {:<5}'.format(name_list[i], weight_list[i], height_list[i], bmi_list[i], size_list[i]))
def get_fuel(fuel): fuel = ((fuel // 3) - 2) if fuel <= 0: return 0 return fuel + get_fuel(fuel) total = 0 with open("d1.txt", "r") as f: for line in f: total += get_fuel(int(line)) print(total)
def get_fuel(fuel): fuel = fuel // 3 - 2 if fuel <= 0: return 0 return fuel + get_fuel(fuel) total = 0 with open('d1.txt', 'r') as f: for line in f: total += get_fuel(int(line)) print(total)
def impares_no_intervalo(intervalo: tuple, lista: list): inicial, final = intervalo return [numero for numero in lista if numero % 2 != 0 and inicial <= numero <= final] limite = (0,10) l = [-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] # --- OUTPUT --- # [1, 3, 5, 7, 9] print(impares_no_intervalo(limite, l))
def impares_no_intervalo(intervalo: tuple, lista: list): (inicial, final) = intervalo return [numero for numero in lista if numero % 2 != 0 and inicial <= numero <= final] limite = (0, 10) l = [-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] print(impares_no_intervalo(limite, l))
# -- coding:utf-8-- class DL(object): def __init__(self): self.dlcs = 0 def q(self): self.dlcs = self.dlcs + 1 print(str(self.dlcs)) def a(self): self.dlcs = 0 print(str(self.dlcs)) hi = DL() hi.q() hi.q() hi.q() hi.q() hi.q() hi.a()
class Dl(object): def __init__(self): self.dlcs = 0 def q(self): self.dlcs = self.dlcs + 1 print(str(self.dlcs)) def a(self): self.dlcs = 0 print(str(self.dlcs)) hi = dl() hi.q() hi.q() hi.q() hi.q() hi.q() hi.a()
# # This file contains the Python code from Program 8.20 of # "Data Structures and Algorithms # with Object-Oriented Design Patterns in Python" # by Bruno R. Preiss. # # Copyright (c) 2003 by Bruno R. Preiss, P.Eng. All rights reserved. # # http://www.brpreiss.com/books/opus7/programs/pgm08_20.txt # class OpenScatterTableV2(OpenScatterTable): def withdraw(self, obj): if self._count == 0: raise ContainerEmpty i = self.findInstance(obj) if i < 0: raise KeyError while True: j = (i + 1) % len(self) while self._array[j]._state == self.OCCUPIED: h = self.h(self._array[j]._obj) if ((h <= i and i < j) or (i < j and j < h) or \ (j < h and h <= i)): break j = (j + 1) % len(self) if self._array[j]._state == self.EMPTY: break self._array[i] = self._array[j] i = j self._array[i] = self.Entry(self.EMPTY, None) self._count -= 1 # ...
class Openscattertablev2(OpenScatterTable): def withdraw(self, obj): if self._count == 0: raise ContainerEmpty i = self.findInstance(obj) if i < 0: raise KeyError while True: j = (i + 1) % len(self) while self._array[j]._state == self.OCCUPIED: h = self.h(self._array[j]._obj) if h <= i and i < j or (i < j and j < h) or (j < h and h <= i): break j = (j + 1) % len(self) if self._array[j]._state == self.EMPTY: break self._array[i] = self._array[j] i = j self._array[i] = self.Entry(self.EMPTY, None) self._count -= 1
# CodeWars Count_Of_Positives_/_Sum_Of_Negatives def count_positives_sum_negatives(arr): null_list = [] sum_of_positives = 0 sum_of_negatives = 0 if arr == [0, 0] or arr == []: return null_list for i in arr: if i > 0: sum_of_positives += 1 elif i < 0: sum_of_negatives += i else: continue return [sum_of_positives, sum_of_negatives]
def count_positives_sum_negatives(arr): null_list = [] sum_of_positives = 0 sum_of_negatives = 0 if arr == [0, 0] or arr == []: return null_list for i in arr: if i > 0: sum_of_positives += 1 elif i < 0: sum_of_negatives += i else: continue return [sum_of_positives, sum_of_negatives]
class Student: email = 'default@redi-school.org' def __init__(self, name, birthday, courses): # class public attributes self.full_name = name self.first_name = name.split(' ')[0] self.birthday = birthday self.courses = courses self.attendance = [] # Objects john = Student('John Schneider', '2010-04-05', ['German', 'Arts', 'History']) mary = Student('Mary von Neumann', '2010-05-06', ['German', 'Math', 'Geography', 'Science']) lucy = Student('Lucy Schwarz', '2010-07-08', ['English', 'Math', 'Dance']) # The class attribute can be changed for a single object lucy.email = 'lucy@redi-school.org' print(f'{lucy.first_name} can be contacted at {lucy.email}') # Lucy can be contacted at lucy@redi-school.org # But it didn't change the others print(f'{john.first_name} can be contacted at {john.email}') # John can be contacted at default@redi-school.org # Or for all objects that didn't have changed it. for student in [john, mary, lucy]: print(f'{student.first_name}:{student.email}') # John:default@redi.org # Mary:default@redi.org # Lucy:lucy@redi-school.org # Changing the class attribute will be visible if the object does not have an # attribute with the same name Student.email = 'default@redi.org' for student in [john, mary, lucy]: # Note that there is no warning at email now. print(f'{student.first_name}:{student.email}') # John:default@redi.org # Maria:default@redi.org # Lucy:lucy@redi-school.org # Changing the attribute for an object doesn't affect the class attribute. john.email = 'john@redi.org' for student in [john, mary, lucy]: print(f'{student.first_name}:{student.email}') # John:john@redi.org # Maria:default@redi.org # Lucy:lucy@redi-school.org
class Student: email = 'default@redi-school.org' def __init__(self, name, birthday, courses): self.full_name = name self.first_name = name.split(' ')[0] self.birthday = birthday self.courses = courses self.attendance = [] john = student('John Schneider', '2010-04-05', ['German', 'Arts', 'History']) mary = student('Mary von Neumann', '2010-05-06', ['German', 'Math', 'Geography', 'Science']) lucy = student('Lucy Schwarz', '2010-07-08', ['English', 'Math', 'Dance']) lucy.email = 'lucy@redi-school.org' print(f'{lucy.first_name} can be contacted at {lucy.email}') print(f'{john.first_name} can be contacted at {john.email}') for student in [john, mary, lucy]: print(f'{student.first_name}:{student.email}') Student.email = 'default@redi.org' for student in [john, mary, lucy]: print(f'{student.first_name}:{student.email}') john.email = 'john@redi.org' for student in [john, mary, lucy]: print(f'{student.first_name}:{student.email}')
# Task # Given sets of integers, M and N, print their symmetric difference in ascending order. # The term symmetric difference indicates those values that exist in either M or N but do not # exist in both. # # Input Format # The first line of input contains an integer, M. # The second line contains M space-separated integers. # The third line contains an integer, N. # The fourth line contains N space-separated integers. # # Output Format # Output the symmetric difference integers in ascending order, one per line. # # Sample Input # 4 # 2 4 5 9 # 4 # 2 4 11 12 # Sample Output # 5 # 9 # 11 # 12 m, m_set = int(input()), set(input().split()) n, n_set = int(input()), set(input().split()) values_in_m = m_set.difference(n_set) values_in_n = n_set.difference(m_set) m_union_n = values_in_m.union(values_in_n) for number in sorted(int(i) for i in m_union_n): print(number)
(m, m_set) = (int(input()), set(input().split())) (n, n_set) = (int(input()), set(input().split())) values_in_m = m_set.difference(n_set) values_in_n = n_set.difference(m_set) m_union_n = values_in_m.union(values_in_n) for number in sorted((int(i) for i in m_union_n)): print(number)
SOC_IRAM_LOW = 0x4037c000 SOC_IRAM_HIGH = 0x403e0000 SOC_DRAM_LOW = 0x3fc80000 SOC_DRAM_HIGH = 0x3fce0000 SOC_RTC_DRAM_LOW = 0x50000000 SOC_RTC_DRAM_HIGH = 0x50002000 SOC_RTC_DATA_LOW = 0x50000000 SOC_RTC_DATA_HIGH = 0x50002000
soc_iram_low = 1077395456 soc_iram_high = 1077805056 soc_dram_low = 1070071808 soc_dram_high = 1070465024 soc_rtc_dram_low = 1342177280 soc_rtc_dram_high = 1342185472 soc_rtc_data_low = 1342177280 soc_rtc_data_high = 1342185472
class Node: def __init__(self, data, next=None): self.data = data self.next = next class LinkedList: def __init__(self): self.head = None def insert_first(self, data): node = Node(data, self.head) self.head = node def __repr__(self): return str(self.head) l = LinkedList() l.insert_first(123) print(l)
class Node: def __init__(self, data, next=None): self.data = data self.next = next class Linkedlist: def __init__(self): self.head = None def insert_first(self, data): node = node(data, self.head) self.head = node def __repr__(self): return str(self.head) l = linked_list() l.insert_first(123) print(l)
# [Grand Athenaeum] sm.removeEscapeButton() sm.flipDialoguePlayerAsSpeaker() sm.sendNext("Supposedly the White Mage was last seen in Ellin Forest. If that's true, there must be evidence.") sm.sendSay("Ephenia the Fairy Queen's dwelling is nearby. I'll see if she knows anything.") sm.startQuest(parentID)
sm.removeEscapeButton() sm.flipDialoguePlayerAsSpeaker() sm.sendNext("Supposedly the White Mage was last seen in Ellin Forest. If that's true, there must be evidence.") sm.sendSay("Ephenia the Fairy Queen's dwelling is nearby. I'll see if she knows anything.") sm.startQuest(parentID)
# reference.py # This script is for image references cookieurl = ["https://media1.tenor.com/images/45fe45f75ec523c2abf4e75ca2ac2fe2/tenor.gif?itemid=11797931", "https://media1.tenor.com/images/de6a49b999216fbda779cd27a24919c3/tenor.gif?itemid=19073253"] cookiesurl = ["https://media1.tenor.com/images/30c8ce96272fe73f58841164a179f6d1/tenor.gif?itemid=17729544", "https://media1.tenor.com/images/54abaf4ed18aa4d5e2c71d6e03f82fea/tenor.gif?itemid=16659532"] bonkurl = ["https://media1.tenor.com/images/dd3c08dbdb41ba9cb5d59c527e6d881a/tenor.gif?itemid=20472628", "https://media1.tenor.com/images/0f145914d9e66a19829d7145daf9abcc/tenor.gif?itemid=19401897", "https://media1.tenor.com/images/4dee992174206c66cb208bee31174b8d/tenor.gif?itemid=18805247"] hugurl = ["https://media1.tenor.com/images/29a4aef07fde6e590aeaa3381324bbd1/tenor.gif?itemid=18630098", "https://media1.tenor.com/images/f77657e4f9d454de399b7c8acb1b8735/tenor.gif?itemid=7939501", "https://media1.tenor.com/images/24ac13447f9409d41c1aecb923aedf81/tenor.gif?itemid=3972670"] kissurl = ["https://media1.tenor.com/images/4700f51c48d41104e541459743db42ae/tenor.gif?itemid=17947049"] fistbumpurl = ["https://media2.giphy.com/media/l0HlL6XHioKD5Gsgg/giphy.gif?cid=ecf05e473oo7yozme81o170s0i9tjwxdb7pq69ba46acewt0&rid=giphy.gif"] frickurl = ["https://media1.tenor.com/images/fa98b23ca1dba1925da62f834f27153f/tenor.gif?itemid=19355212"] donuturl = ["https://media1.tenor.com/images/29a1be900e68a176097ff05eb51514b5/tenor.gif?itemid=8158743"]
cookieurl = ['https://media1.tenor.com/images/45fe45f75ec523c2abf4e75ca2ac2fe2/tenor.gif?itemid=11797931', 'https://media1.tenor.com/images/de6a49b999216fbda779cd27a24919c3/tenor.gif?itemid=19073253'] cookiesurl = ['https://media1.tenor.com/images/30c8ce96272fe73f58841164a179f6d1/tenor.gif?itemid=17729544', 'https://media1.tenor.com/images/54abaf4ed18aa4d5e2c71d6e03f82fea/tenor.gif?itemid=16659532'] bonkurl = ['https://media1.tenor.com/images/dd3c08dbdb41ba9cb5d59c527e6d881a/tenor.gif?itemid=20472628', 'https://media1.tenor.com/images/0f145914d9e66a19829d7145daf9abcc/tenor.gif?itemid=19401897', 'https://media1.tenor.com/images/4dee992174206c66cb208bee31174b8d/tenor.gif?itemid=18805247'] hugurl = ['https://media1.tenor.com/images/29a4aef07fde6e590aeaa3381324bbd1/tenor.gif?itemid=18630098', 'https://media1.tenor.com/images/f77657e4f9d454de399b7c8acb1b8735/tenor.gif?itemid=7939501', 'https://media1.tenor.com/images/24ac13447f9409d41c1aecb923aedf81/tenor.gif?itemid=3972670'] kissurl = ['https://media1.tenor.com/images/4700f51c48d41104e541459743db42ae/tenor.gif?itemid=17947049'] fistbumpurl = ['https://media2.giphy.com/media/l0HlL6XHioKD5Gsgg/giphy.gif?cid=ecf05e473oo7yozme81o170s0i9tjwxdb7pq69ba46acewt0&rid=giphy.gif'] frickurl = ['https://media1.tenor.com/images/fa98b23ca1dba1925da62f834f27153f/tenor.gif?itemid=19355212'] donuturl = ['https://media1.tenor.com/images/29a1be900e68a176097ff05eb51514b5/tenor.gif?itemid=8158743']
def D(): n = int(input()) neighbours = [None] #Asi puedo manejar numero de personas como index for i in range(n): neighbours.append([int(x) for x in input().split()]) visited = set() ans = [None,1] visited.add(1) a , b = neighbours[1][0] , neighbours[1][1] if(b in neighbours[a]): ans+=[a,b] else: ans+=[b,a] visited.add(a) visited.add(b) for i in range(1,n): person = ans[i] if(neighbours[person][0] not in visited): ans.append(neighbours[person][0]) visited.add(neighbours[person][0]) if(neighbours[person][1] not in visited): ans.append(neighbours[person][1]) visited.add(neighbours[person][1]) ans = ans[1:] ans = [str(x) for x in ans] print(" ".join(ans)) D()
def d(): n = int(input()) neighbours = [None] for i in range(n): neighbours.append([int(x) for x in input().split()]) visited = set() ans = [None, 1] visited.add(1) (a, b) = (neighbours[1][0], neighbours[1][1]) if b in neighbours[a]: ans += [a, b] else: ans += [b, a] visited.add(a) visited.add(b) for i in range(1, n): person = ans[i] if neighbours[person][0] not in visited: ans.append(neighbours[person][0]) visited.add(neighbours[person][0]) if neighbours[person][1] not in visited: ans.append(neighbours[person][1]) visited.add(neighbours[person][1]) ans = ans[1:] ans = [str(x) for x in ans] print(' '.join(ans)) d()
# Count total cars per company # My Solution df.groupby('company').count() # Given Solution df['company'].value_counts()
df.groupby('company').count() df['company'].value_counts()
''' Python Program to Remove the Duplicate Items from a List ''' lst = [3,5,2,7,5,4,3,7,8,2,5,4,7,2,1] print(lst) def method(): new_lst = [] for item in lst: if item not in new_lst: new_lst.append(item) print(new_lst) method()
""" Python Program to Remove the Duplicate Items from a List """ lst = [3, 5, 2, 7, 5, 4, 3, 7, 8, 2, 5, 4, 7, 2, 1] print(lst) def method(): new_lst = [] for item in lst: if item not in new_lst: new_lst.append(item) print(new_lst) method()
# this module is the template of all environment in this project # some basic and common features are listed in this class class ENVError(Exception): def __init__(self, value_): self.__value = value_ def __str__(self): print('Environment error occur: ' + self.__value) class ENV: def __init__(self): pass def reset(self): raise ENVError('You have not defined the reset function of environment') def step(self, action): raise ENVError('You have not defined the step function of environment')
class Enverror(Exception): def __init__(self, value_): self.__value = value_ def __str__(self): print('Environment error occur: ' + self.__value) class Env: def __init__(self): pass def reset(self): raise env_error('You have not defined the reset function of environment') def step(self, action): raise env_error('You have not defined the step function of environment')
C_ENDINGS = ('.c', '.i', ) CXX_ENDINGS = ('.cpp', '.cxx', '.cc', '.c++', '.CPP', '.CXX', '.C', '.CC', '.C++', '.ii', ) OBJC_ENDINGS = ('.m', '.mi', ) OBJCXX_ENDINGS = ('.mm', '.mii', ) FORTRAN_ENDINGS = ('.f', '.for', '.ftn', '.f77', '.f90', '.f95', '.f03', '.f08', '.F', '.FOR', '.FTN', '.F77', '.F90', '.F95', '.F03', '.F08', ) SOURCE_ENDINGS = C_ENDINGS + CXX_ENDINGS + OBJC_ENDINGS + OBJCXX_ENDINGS + FORTRAN_ENDINGS OBJ_ENDINGS = ('.o', ) BITCODE_ENDINGS = ('.bc', ) AR_ENDINGS = ('.a', ) SHARED_ENDINGS = ('.so', ) INPUT_ENDINGS = SOURCE_ENDINGS + OBJ_ENDINGS + BITCODE_ENDINGS + AR_ENDINGS + SHARED_ENDINGS FORTRAN_COMPILE_FLAGS = ('-fall-intrinsics', '-fallow-argument-mismatch', '-fallow-invalid-boz', '-fbackslash', '-fcray-pointer', '-fd-lines-as-code', '-fd-lines-as-comments', '-fdec', '-fdec-char-conversions', '-fdec-structure', '-fdec-intrinsic-ints', '-fdec-static', '-fdec-math', '-fdec-include', '-fdec-format-defaults', '-fdec-blank-format-item', '-fdefault-double-8', '-fdefault-integer-8', '-fdefault-real-8', '-fdefault-real-10', '-fdefault-real-16', '-fdollar-ok', '-ffixed-line-length-n', '-ffixed-line-length-none', '-fpad-source', '-ffree-form', '-ffree-line-length-n', '-ffree-line-length-none', '-fimplicit-none', '-finteger-4-integer-8', '-fmax-identifier-length', '-fmodule-private', '-ffixed-form', '-fno-range-check', '-fopenacc', '-freal-4-real-10', '-freal-4-real-16', '-freal-4-real-8', '-freal-8-real-10', '-freal-8-real-16', '-freal-8-real-4', '-std=', '-ftest-forall-temp', '-flarge-sizes', '-flogical-abbreviations', '-fxor-operator','-fno-leading-underscore', '-funderscoring', '-fno-underscoring', '-fsecond-underscore') COMPILE_FLAGS = FORTRAN_COMPILE_FLAGS LINK_FLAGS = ('-static', '-static-flang-libs', '-fno-fortran-main', '-noFlangLibs') IGNORE_FLAGS = ('-Kieee') ALIAS = {'-openmp':'-fopenmp', '-static-libgfortran':'-static-flang-libs', '-Mbackslash': '-fbackslash', '-Mfixed':'-ffixed-form', '-Mfreeform':'-ffree-form', '-Mrecursive':'-frecursive'} class ParseArg: def __init__(self, args): self.args = [] for x in args[1:]: if x in ALIAS: self.args.append(ALIAS[x]) else: self.args.append(x) def hasFlag(self, flag, remove=False): if flag in self.args: if remove: self.args.remove(flag) return True return False def getOpt(self, flag, remove=False): for i in range(0, len(self.args)): if self.args[i].startswith(flag): value = self.args[i+1] if remove: self.args.remove(value) del self.args[i] return value return None def getDef(self, flag, remove=False): for i in range(0, len(self.args)): if self.args[i].startswith(flag+"="): value = self.args[i] if remove: self.args.remove(value) return value[len(flag)+1:] return None def getInputFiles(self, endings, remove=False): inputFiles = [] skip = False for x in self.args: if skip: skip = False continue if not x.startswith('-'): if x.endswith(endings): inputFiles.append(x) elif '=' in x: skip = True if remove: for x in inputFiles: self.args.remove(x) return inputFiles def get(self): return self.args def getCompile(self, warn=False): argv = [] for x in self.args: if x.startswith('-l') or x.startswith('-fuse-ld='): if warn: print(sys.argv[0]+": warning: argument unused during compilation: \""+x+"\"", file=sys.stderr) elif x in LINK_FLAGS: if warn: print(sys.argv[0]+": warning: argument unused during compilation: \""+x+"\"", file=sys.stderr) elif not x in IGNORE_FLAGS: argv.append(x) return argv def getLink(self, warn=False): argv = [] for x in self.args: if x in COMPILE_FLAGS: if warn: print(sys.argv[0]+": warning: argument unused during linking: \""+x+"\"", file=sys.stderr) elif not x in IGNORE_FLAGS: argv.append(x) return argv
c_endings = ('.c', '.i') cxx_endings = ('.cpp', '.cxx', '.cc', '.c++', '.CPP', '.CXX', '.C', '.CC', '.C++', '.ii') objc_endings = ('.m', '.mi') objcxx_endings = ('.mm', '.mii') fortran_endings = ('.f', '.for', '.ftn', '.f77', '.f90', '.f95', '.f03', '.f08', '.F', '.FOR', '.FTN', '.F77', '.F90', '.F95', '.F03', '.F08') source_endings = C_ENDINGS + CXX_ENDINGS + OBJC_ENDINGS + OBJCXX_ENDINGS + FORTRAN_ENDINGS obj_endings = ('.o',) bitcode_endings = ('.bc',) ar_endings = ('.a',) shared_endings = ('.so',) input_endings = SOURCE_ENDINGS + OBJ_ENDINGS + BITCODE_ENDINGS + AR_ENDINGS + SHARED_ENDINGS fortran_compile_flags = ('-fall-intrinsics', '-fallow-argument-mismatch', '-fallow-invalid-boz', '-fbackslash', '-fcray-pointer', '-fd-lines-as-code', '-fd-lines-as-comments', '-fdec', '-fdec-char-conversions', '-fdec-structure', '-fdec-intrinsic-ints', '-fdec-static', '-fdec-math', '-fdec-include', '-fdec-format-defaults', '-fdec-blank-format-item', '-fdefault-double-8', '-fdefault-integer-8', '-fdefault-real-8', '-fdefault-real-10', '-fdefault-real-16', '-fdollar-ok', '-ffixed-line-length-n', '-ffixed-line-length-none', '-fpad-source', '-ffree-form', '-ffree-line-length-n', '-ffree-line-length-none', '-fimplicit-none', '-finteger-4-integer-8', '-fmax-identifier-length', '-fmodule-private', '-ffixed-form', '-fno-range-check', '-fopenacc', '-freal-4-real-10', '-freal-4-real-16', '-freal-4-real-8', '-freal-8-real-10', '-freal-8-real-16', '-freal-8-real-4', '-std=', '-ftest-forall-temp', '-flarge-sizes', '-flogical-abbreviations', '-fxor-operator', '-fno-leading-underscore', '-funderscoring', '-fno-underscoring', '-fsecond-underscore') compile_flags = FORTRAN_COMPILE_FLAGS link_flags = ('-static', '-static-flang-libs', '-fno-fortran-main', '-noFlangLibs') ignore_flags = '-Kieee' alias = {'-openmp': '-fopenmp', '-static-libgfortran': '-static-flang-libs', '-Mbackslash': '-fbackslash', '-Mfixed': '-ffixed-form', '-Mfreeform': '-ffree-form', '-Mrecursive': '-frecursive'} class Parsearg: def __init__(self, args): self.args = [] for x in args[1:]: if x in ALIAS: self.args.append(ALIAS[x]) else: self.args.append(x) def has_flag(self, flag, remove=False): if flag in self.args: if remove: self.args.remove(flag) return True return False def get_opt(self, flag, remove=False): for i in range(0, len(self.args)): if self.args[i].startswith(flag): value = self.args[i + 1] if remove: self.args.remove(value) del self.args[i] return value return None def get_def(self, flag, remove=False): for i in range(0, len(self.args)): if self.args[i].startswith(flag + '='): value = self.args[i] if remove: self.args.remove(value) return value[len(flag) + 1:] return None def get_input_files(self, endings, remove=False): input_files = [] skip = False for x in self.args: if skip: skip = False continue if not x.startswith('-'): if x.endswith(endings): inputFiles.append(x) elif '=' in x: skip = True if remove: for x in inputFiles: self.args.remove(x) return inputFiles def get(self): return self.args def get_compile(self, warn=False): argv = [] for x in self.args: if x.startswith('-l') or x.startswith('-fuse-ld='): if warn: print(sys.argv[0] + ': warning: argument unused during compilation: "' + x + '"', file=sys.stderr) elif x in LINK_FLAGS: if warn: print(sys.argv[0] + ': warning: argument unused during compilation: "' + x + '"', file=sys.stderr) elif not x in IGNORE_FLAGS: argv.append(x) return argv def get_link(self, warn=False): argv = [] for x in self.args: if x in COMPILE_FLAGS: if warn: print(sys.argv[0] + ': warning: argument unused during linking: "' + x + '"', file=sys.stderr) elif not x in IGNORE_FLAGS: argv.append(x) return argv
#Python solution for AoC qn 2 f = open("2.txt","r") strings = f.readlines() #Part 1 freq_total = { "2":0, "3":0 } for s in strings: s = s.strip().lower() freq_indv = {} #Count how many of each letter is inside for ch in s: if ch in freq_indv: freq_indv[ch]+=1 else: freq_indv[ch]=1 #Check how many found found = { "2":False, "3":False } for ch in freq_indv: if (not found["2"]) and freq_indv[ch]==2: found["2"] = True freq_total["2"]+=1 elif (not found["3"]) and freq_indv[ch]==3: found["3"] = True freq_total["3"]+=1 if found["2"] and found["3"]: break continue print("Checksum: "+str(freq_total["2"]*freq_total["3"])) #Part 2 found = False for i in range(len(strings)-1): s1 = strings[i] for j in range(i+1,len(strings)): s2 = strings[j] different = 0 found = True common = "" #Compare s1 and s2 for k in range(min(len(s1),len(s2))): if s1[k] != s2[k]: different+=1 else: common+=s1[k] if different>1: found = False break if found: print("Common Letters: "+common) break if found: break
f = open('2.txt', 'r') strings = f.readlines() freq_total = {'2': 0, '3': 0} for s in strings: s = s.strip().lower() freq_indv = {} for ch in s: if ch in freq_indv: freq_indv[ch] += 1 else: freq_indv[ch] = 1 found = {'2': False, '3': False} for ch in freq_indv: if not found['2'] and freq_indv[ch] == 2: found['2'] = True freq_total['2'] += 1 elif not found['3'] and freq_indv[ch] == 3: found['3'] = True freq_total['3'] += 1 if found['2'] and found['3']: break continue print('Checksum: ' + str(freq_total['2'] * freq_total['3'])) found = False for i in range(len(strings) - 1): s1 = strings[i] for j in range(i + 1, len(strings)): s2 = strings[j] different = 0 found = True common = '' for k in range(min(len(s1), len(s2))): if s1[k] != s2[k]: different += 1 else: common += s1[k] if different > 1: found = False break if found: print('Common Letters: ' + common) break if found: break
class Solution: @staticmethod def naive(prices): maxReturn = 0 minVal = prices[0] for i in range(1,len(prices)): if prices[i]-minVal > maxReturn: maxReturn = prices[i]-minVal if prices[i]<minVal: minVal = prices[i] return maxReturn
class Solution: @staticmethod def naive(prices): max_return = 0 min_val = prices[0] for i in range(1, len(prices)): if prices[i] - minVal > maxReturn: max_return = prices[i] - minVal if prices[i] < minVal: min_val = prices[i] return maxReturn
''' subsets and subarrays subarrays: a = [10,20,30] => [ [10], [20], [30] [10,20], [10,20,30], [20,30], ] subsets: a = [10,20,30] => [ [], [10,20,30] [10], [20], [30], [10, 20], [10, 30], [20, 30] ] ''' def print_subsets(a): limit = 2 ** len(a) for i in range(limit): for j in range(len(a)): if(i & (1 << j) > 0): print(a[j], end=" ") print() def print_subarray(a): for i in range(len(a)): for j in range(i, len(a)): for k in range(i, j+1): print(a[k], end=" ") print() print_subsets([10,20,30]) print_subarray([10,20,30])
""" subsets and subarrays subarrays: a = [10,20,30] => [ [10], [20], [30] [10,20], [10,20,30], [20,30], ] subsets: a = [10,20,30] => [ [], [10,20,30] [10], [20], [30], [10, 20], [10, 30], [20, 30] ] """ def print_subsets(a): limit = 2 ** len(a) for i in range(limit): for j in range(len(a)): if i & 1 << j > 0: print(a[j], end=' ') print() def print_subarray(a): for i in range(len(a)): for j in range(i, len(a)): for k in range(i, j + 1): print(a[k], end=' ') print() print_subsets([10, 20, 30]) print_subarray([10, 20, 30])
# -*- coding: utf-8 -*- # blue to red diverging set blue_to_red_diverging = ['#d7191c', '#fdae61', '#ffffbf', '#abd9e9', '#2c7bb6'] # red oragne sequential single hue: orange_sequential = ['#fff5eb', '#fee6ce', '#fdd0a2', '#fdae6b', '#fd8d3c', '#f16913', '#d94801', '#a63603', '#7f2704'] # blue sequential single hue: blue_sequential = ['#f7fbff', '#deebf7', '#c6dbef', '#9ecae1', '#6baed6', '#4292c6', '#2171b5', '#08519c', '#08306b'] mpl_default = ['b', 'r', 'g', 'c', 'm', 'y', 'k'] # Cynthia Brewer Set 1 categorical_1 = [ '#e41a1c', '#377eb8', '#4daf4a', '#ff7f00', '#a65628', '#f781bf', '#999999', '#984ea3', '#ffff33'] # Cynthia Brewer Set 2 categorical_2 = ['#66c2a5', '#fc8d62', '#8da0cb', '#e78ac3', '#a6d854', '#ffd92f', '#e5c494', '#b3b3b3' ] # Dark Brewer Set 2 categorical_3 = ['#1b9e77', '#d95f02', '#7570b3', '#e7298a', '#66a61e', '#e6ab02', '#a6761d', '#666666']
blue_to_red_diverging = ['#d7191c', '#fdae61', '#ffffbf', '#abd9e9', '#2c7bb6'] orange_sequential = ['#fff5eb', '#fee6ce', '#fdd0a2', '#fdae6b', '#fd8d3c', '#f16913', '#d94801', '#a63603', '#7f2704'] blue_sequential = ['#f7fbff', '#deebf7', '#c6dbef', '#9ecae1', '#6baed6', '#4292c6', '#2171b5', '#08519c', '#08306b'] mpl_default = ['b', 'r', 'g', 'c', 'm', 'y', 'k'] categorical_1 = ['#e41a1c', '#377eb8', '#4daf4a', '#ff7f00', '#a65628', '#f781bf', '#999999', '#984ea3', '#ffff33'] categorical_2 = ['#66c2a5', '#fc8d62', '#8da0cb', '#e78ac3', '#a6d854', '#ffd92f', '#e5c494', '#b3b3b3'] categorical_3 = ['#1b9e77', '#d95f02', '#7570b3', '#e7298a', '#66a61e', '#e6ab02', '#a6761d', '#666666']
''' Author : Hemant Rana Date : 30th Aug 2020 link : https://leetcode.com/problems/container-with-most-water ''' class Solution: def maxArea(self, height: List[int]) -> int: h_len=len(height) max_area=0 b,e=0,h_len-1 while(b<e): area=min(height[b],height[e])*(e-b) max_area=max(area,max_area) if(height[b]>height[e]): e-=1 else: b+=1 return max_area
""" Author : Hemant Rana Date : 30th Aug 2020 link : https://leetcode.com/problems/container-with-most-water """ class Solution: def max_area(self, height: List[int]) -> int: h_len = len(height) max_area = 0 (b, e) = (0, h_len - 1) while b < e: area = min(height[b], height[e]) * (e - b) max_area = max(area, max_area) if height[b] > height[e]: e -= 1 else: b += 1 return max_area
class Struct(object): def __init__(self, data=None, **kwds): if not data: data = {} for name, value in data.items(): if name: setattr(self, name, self._wrap(value)) for name, value in kwds.items(): if name: setattr(self, name, self._wrap(value)) def _wrap(self, value): if isinstance(value, (tuple, list, set, frozenset)): return type(value)([self._wrap(v) for v in value]) else: return Struct(value) if isinstance(value, dict) else value def clone(self, **kwds): return Struct(self.__to_dict__(), **kwds) def __repr__(self): return "Struct: " + repr(self.__dict__) def __len__(self): return len(self.__dict__) def __to_dict__(self): res = {} res.update(self.__dict__) for k in res.keys(): if isinstance(res[k], Struct): res[k] = res[k].__to_dict__() elif isinstance(res[k], (tuple, list, set, frozenset)): res[k] = [i.__to_dict__() if isinstance(i, Struct) else i for i in res[k]] return res class StructDefault(Struct): def __getattr__(self, item): return self._default_
class Struct(object): def __init__(self, data=None, **kwds): if not data: data = {} for (name, value) in data.items(): if name: setattr(self, name, self._wrap(value)) for (name, value) in kwds.items(): if name: setattr(self, name, self._wrap(value)) def _wrap(self, value): if isinstance(value, (tuple, list, set, frozenset)): return type(value)([self._wrap(v) for v in value]) else: return struct(value) if isinstance(value, dict) else value def clone(self, **kwds): return struct(self.__to_dict__(), **kwds) def __repr__(self): return 'Struct: ' + repr(self.__dict__) def __len__(self): return len(self.__dict__) def __to_dict__(self): res = {} res.update(self.__dict__) for k in res.keys(): if isinstance(res[k], Struct): res[k] = res[k].__to_dict__() elif isinstance(res[k], (tuple, list, set, frozenset)): res[k] = [i.__to_dict__() if isinstance(i, Struct) else i for i in res[k]] return res class Structdefault(Struct): def __getattr__(self, item): return self._default_
##To find the kth maximum number in an array. lst=[] len=int(input("Enter the length of the array.\n")) for i in range(0,len): e=input("Enter the element.\n") lst.append(e) k=int(input("Enter the value of k\n")) lst.sort(reverse=True) f=k-1 print(lst[f])
lst = [] len = int(input('Enter the length of the array.\n')) for i in range(0, len): e = input('Enter the element.\n') lst.append(e) k = int(input('Enter the value of k\n')) lst.sort(reverse=True) f = k - 1 print(lst[f])
# create a list of movies list_of_movies = None list_of_movies = [ 'Toy Story', 'Lion King', 'Coco' ] # cycle through each movie title in the list of movies # starting from the first item and ending at the last item for movie_title in list_of_movies: print('***{}***'.format(movie_title)) # create an empty variable called word word = '' # cycle through each letter in the movie title for letter in movie_title: print(' {}'.format(letter)) word += letter print("The letters create the word variable >>{}".format(word)) print("The movie title is the same as the word variable: {}".format(movie_title == word)) print('\n\n') word = ''
list_of_movies = None list_of_movies = ['Toy Story', 'Lion King', 'Coco'] for movie_title in list_of_movies: print('***{}***'.format(movie_title)) word = '' for letter in movie_title: print(' {}'.format(letter)) word += letter print('The letters create the word variable >>{}'.format(word)) print('The movie title is the same as the word variable: {}'.format(movie_title == word)) print('\n\n') word = ''
''' Run through and ensure that all the required programs are installed on the system and functioning '''
""" Run through and ensure that all the required programs are installed on the system and functioning """
def solution(n, computers): def dfs(n, s, metrix, visited): stack = [s] visited.add(s) while stack: this = stack[-1] remove = True for i in range(n): if this == i: continue if i in visited: continue if metrix[this][i]: visited.add(i) stack.append(i) remove = False break if remove: stack.pop() answer = 0 visited = set() for i in range(n): if i not in visited: dfs(n, i, computers, visited) answer += 1 return answer if __name__ == "__main__": n = 3 c = [[1, 1, 0], [1, 1, 0], [0, 0, 1]] print(solution(n, c))
def solution(n, computers): def dfs(n, s, metrix, visited): stack = [s] visited.add(s) while stack: this = stack[-1] remove = True for i in range(n): if this == i: continue if i in visited: continue if metrix[this][i]: visited.add(i) stack.append(i) remove = False break if remove: stack.pop() answer = 0 visited = set() for i in range(n): if i not in visited: dfs(n, i, computers, visited) answer += 1 return answer if __name__ == '__main__': n = 3 c = [[1, 1, 0], [1, 1, 0], [0, 0, 1]] print(solution(n, c))
def is_paired(input_string: str) -> bool: input_string = clean_input_string(input_string) if len(input_string) % 2 != 0: return False while input_string: if not remove_bracket(input_string[0], input_string): return False return True def remove_bracket(bracket: str, input_string: list) -> bool: pairs = { '{': '}', '[': ']', '(': ')', } if bracket not in pairs: return False if input_string[1] == pairs[bracket]: del input_string[1] del input_string[0] return True elif input_string[-1] == pairs[bracket]: del input_string[-1] del input_string[0] return True def clean_input_string(input_string: str) -> list: template = '[]{}()' return [char for char in input_string if char in template]
def is_paired(input_string: str) -> bool: input_string = clean_input_string(input_string) if len(input_string) % 2 != 0: return False while input_string: if not remove_bracket(input_string[0], input_string): return False return True def remove_bracket(bracket: str, input_string: list) -> bool: pairs = {'{': '}', '[': ']', '(': ')'} if bracket not in pairs: return False if input_string[1] == pairs[bracket]: del input_string[1] del input_string[0] return True elif input_string[-1] == pairs[bracket]: del input_string[-1] del input_string[0] return True def clean_input_string(input_string: str) -> list: template = '[]{}()' return [char for char in input_string if char in template]
def test_oops(client): url = f'/fake-path' response = client.get(url) assert response.status_code == 404
def test_oops(client): url = f'/fake-path' response = client.get(url) assert response.status_code == 404
#-*- coding: utf-8 -*- class ValueDefinition: str_val_dict = {} val_str_dict = {} @classmethod def get(cls, data): if not cls.val_str_dict: cls.val_str_dict = dict(zip(cls.str_val_dict.values(), cls.str_val_dict.keys())) if type(data) == str: return cls.str_val_dict.get(data) else: return cls.val_str_dict.get(data) class SectionType(ValueDefinition): str_val_dict = { "name_section" : 0, "type_section" : 1, "import_section" : 2, "function_section" : 3, "table_section" : 4, "memory_section" : 5, "global_section" : 6, "export_section" : 7, "start_section" : 8, "elem_section" : 9, "code_section" : 10, "data_section" : 11, "invalid_section" : 12 } class TypeOpcode(ValueDefinition): str_val_dict = { "i32": 0x7f, 'i64': 0x7e, 'f32': 0x7d, 'f64': 0x7c, 'anyfunc': 0x70, 'func': 0x60, 'empty_block_type': 0x40 } class ExternalKind(ValueDefinition): str_val_dict = { "Function": 0, 'Table': 1, 'Memory': 2, 'Global': 3 } class InitExprOp(ValueDefinition): str_val_dict = { "i32.const": 0x41, "i64.const": 0x42, "f32.const": 0x43, "f64.const": 0x44, "v128.const": 0xfd, "get_global": 0x23, "end": 0x0b } class NameType(ValueDefinition): str_val_dict = { 'module': 0, 'function': 1, 'local': 2 }
class Valuedefinition: str_val_dict = {} val_str_dict = {} @classmethod def get(cls, data): if not cls.val_str_dict: cls.val_str_dict = dict(zip(cls.str_val_dict.values(), cls.str_val_dict.keys())) if type(data) == str: return cls.str_val_dict.get(data) else: return cls.val_str_dict.get(data) class Sectiontype(ValueDefinition): str_val_dict = {'name_section': 0, 'type_section': 1, 'import_section': 2, 'function_section': 3, 'table_section': 4, 'memory_section': 5, 'global_section': 6, 'export_section': 7, 'start_section': 8, 'elem_section': 9, 'code_section': 10, 'data_section': 11, 'invalid_section': 12} class Typeopcode(ValueDefinition): str_val_dict = {'i32': 127, 'i64': 126, 'f32': 125, 'f64': 124, 'anyfunc': 112, 'func': 96, 'empty_block_type': 64} class Externalkind(ValueDefinition): str_val_dict = {'Function': 0, 'Table': 1, 'Memory': 2, 'Global': 3} class Initexprop(ValueDefinition): str_val_dict = {'i32.const': 65, 'i64.const': 66, 'f32.const': 67, 'f64.const': 68, 'v128.const': 253, 'get_global': 35, 'end': 11} class Nametype(ValueDefinition): str_val_dict = {'module': 0, 'function': 1, 'local': 2}
strip_words = [ 'Kind', 'MAE', 'Pandemisch' ] skip_names = [ 'Water' ] ignore_names = [ 'alfalfa', 'ali', 'belladonna', 'cold', 'drank', 'gas', 'hot', 'linn', 'sepia', 'skin', 'slow', 'stol', 'ultra', 'vicks', 'vitamine', 'yasmin' ] # require_implicit_certainty = [ # 'acid', # 'agnus', # 'allium', # 'angelica', # 'anti', # 'apis', # 'ben', # 'bleu', # 'buxus', # 'cactus', # 'cad', # 'cat', # 'china', # 'citroenmelisse', # 'code', # 'diane', # 'duivelsklauw', # 'dry', # 'eucalyptus', # 'formule', # 'flor', # 'femke', # 'getinte', # 'glucose', # 'glucosamine', # 'hedera', # 'hoest', # 'humaan', # 'indium', # 'iris', # 'lobelia', # 'luis', # 'muse', # 'nol', # 'red', # 'robinia', # 'sabina', # 'saxen', # 'senna', # 'stadium', # 'talia', # 'thuja', # 'timo', # 'tobi', # 'rectale' # 'veronica', # 'will' # ] # require_more_certainty = [ # 'adrenaline', # 'allegra', # 'ammonium', # 'arum', # 'belfor', # 'calcium', # 'digitalis', # 'discus', # 'formica', # 'ginkgo', # 'kalium', # 'lac', # 'lucht', # 'maagzuur', # 'melissa', # 'mercurius', # 'mono', # 'myosotis', # 'nicotine', # 'nol', # 'oblong', # 'omega', # 'plasma', # 'platina', # 'prick', # 'rectale', # 'ribes', # 'selenium', # 'terra', # 'viola', # 'zeel', # 'zure', # 'zuurstof' # ]
strip_words = ['Kind', 'MAE', 'Pandemisch'] skip_names = ['Water'] ignore_names = ['alfalfa', 'ali', 'belladonna', 'cold', 'drank', 'gas', 'hot', 'linn', 'sepia', 'skin', 'slow', 'stol', 'ultra', 'vicks', 'vitamine', 'yasmin']
#!/usr/bin/env python esInputs = "/home/matthieu/.emulationstation/es_input.cfg" esSettings = '/home/matthieu/.emulationstation/es_settings.cfg' recalboxConf = "/home/matthieu/recalbox/recalbox.conf" retroarchRoot = "/home/matthieu/recalbox/configs/retroarch" retroarchCustom = retroarchRoot + '/retroarchcustom.cfg' retroarchCustomOrigin = retroarchRoot + "/retroarchcustom.cfg.origin" retroarchCoreCustom = retroarchRoot + "/cores/retroarch-core-options.cfg" retroarchBin = "retroarch" retroarchCores = "/usr/lib/libretro/" shadersRoot = "/home/matthieu/recalbox/share_init/shaders/presets/" shadersExt = '.gplsp' libretroExt = '_libretro.so' fbaRoot = '/home/matthieu/recalbox/configs/fba/' fbaCustom = fbaRoot + 'fba2x.cfg' fbaCustomOrigin = fbaRoot + 'fba2x.cfg.origin' fba2xBin = '/usr/bin/fba2x' mupenCustom = "/home/matthieu/recalbox/configs/mupen64/mupen64plus.cfg" shaderPresetRoot = "/home/matthieu/recalbox/share/system/shadersets/" kodiJoystick = '/home/matthieu/.kodi/userdata/keymaps/recalbox.xml' kodiMappingUser = '/home/matthieu/recalbox/configs/kodi/input.xml' kodiBin = '/usr/lib/kodi/kodi.bin' logdir = '/home/matthieu/recalbox/logs/'
es_inputs = '/home/matthieu/.emulationstation/es_input.cfg' es_settings = '/home/matthieu/.emulationstation/es_settings.cfg' recalbox_conf = '/home/matthieu/recalbox/recalbox.conf' retroarch_root = '/home/matthieu/recalbox/configs/retroarch' retroarch_custom = retroarchRoot + '/retroarchcustom.cfg' retroarch_custom_origin = retroarchRoot + '/retroarchcustom.cfg.origin' retroarch_core_custom = retroarchRoot + '/cores/retroarch-core-options.cfg' retroarch_bin = 'retroarch' retroarch_cores = '/usr/lib/libretro/' shaders_root = '/home/matthieu/recalbox/share_init/shaders/presets/' shaders_ext = '.gplsp' libretro_ext = '_libretro.so' fba_root = '/home/matthieu/recalbox/configs/fba/' fba_custom = fbaRoot + 'fba2x.cfg' fba_custom_origin = fbaRoot + 'fba2x.cfg.origin' fba2x_bin = '/usr/bin/fba2x' mupen_custom = '/home/matthieu/recalbox/configs/mupen64/mupen64plus.cfg' shader_preset_root = '/home/matthieu/recalbox/share/system/shadersets/' kodi_joystick = '/home/matthieu/.kodi/userdata/keymaps/recalbox.xml' kodi_mapping_user = '/home/matthieu/recalbox/configs/kodi/input.xml' kodi_bin = '/usr/lib/kodi/kodi.bin' logdir = '/home/matthieu/recalbox/logs/'
def set_timer(): # WIP pass
def set_timer(): pass
class Stack: def __init__(self): self.data = [] def push(self, value): self.data.append(value) def pop(self): return self.data.pop() def peek(self): if len(self.data) > 0: return self.data[-1:][0] else: return None def size(self): return len(self.data)
class Stack: def __init__(self): self.data = [] def push(self, value): self.data.append(value) def pop(self): return self.data.pop() def peek(self): if len(self.data) > 0: return self.data[-1:][0] else: return None def size(self): return len(self.data)
class Ingredient(): def __init__(self, amount, unit, name): self.amount = self.convert_to_decimal(amount) self.unit = unit self.name = name def convert_to_decimal(self, amount): try: return float(amount) except ValueError: num, denom = amount.split('/') return float(num) / float(denom) def convert_to_grams(self): pass
class Ingredient: def __init__(self, amount, unit, name): self.amount = self.convert_to_decimal(amount) self.unit = unit self.name = name def convert_to_decimal(self, amount): try: return float(amount) except ValueError: (num, denom) = amount.split('/') return float(num) / float(denom) def convert_to_grams(self): pass
# Return the Nth Even Number # nthEven(1) //=> 0, the first even number is 0 # nthEven(3) //=> 4, the 3rd even number is 4 (0, 2, 4) # nthEven(100) //=> 198 # nthEven(1298734) //=> 2597466 # The input will not be 0. def nth_even(n): return 2 * (n - 1) def test_nth_even(): assert nth_even(1) == 0 assert nth_even(2) == 2 assert nth_even(3) == 4 assert nth_even(100) == 198 assert nth_even(1298734) == 2597466
def nth_even(n): return 2 * (n - 1) def test_nth_even(): assert nth_even(1) == 0 assert nth_even(2) == 2 assert nth_even(3) == 4 assert nth_even(100) == 198 assert nth_even(1298734) == 2597466
# https://www.codechef.com/problems/GOODBAD for T in range(int(input())): l,k=map(int,input().split()) s,c,b=input(),0,0 for i in s: if(i>='A' and i<='Z'): c+=1 if(i>='a' and i<='z'): b+=1 if(c<=k and b<=k): print("both") elif(c<=k): print("chef") elif(b<=k): print("brother") else: print("none")
for t in range(int(input())): (l, k) = map(int, input().split()) (s, c, b) = (input(), 0, 0) for i in s: if i >= 'A' and i <= 'Z': c += 1 if i >= 'a' and i <= 'z': b += 1 if c <= k and b <= k: print('both') elif c <= k: print('chef') elif b <= k: print('brother') else: print('none')
# class Tree: # def __init__(self, val, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: treeSum = 0 def solve(self, root): def preOrder(root): if root: self.treeSum += root.val preOrder(root.right) preOrder(root.left) return root preOrder(root) return self.treeSum
class Solution: tree_sum = 0 def solve(self, root): def pre_order(root): if root: self.treeSum += root.val pre_order(root.right) pre_order(root.left) return root pre_order(root) return self.treeSum
class Service: def __init__(self, name, connector_func, state_processor_method=None, batch_size=1, tags=None, names_previous_services=None, names_required_previous_services=None, workflow_formatter=None, dialog_formatter=None, response_formatter=None, label=None): self.name = name self.batch_size = batch_size self.state_processor_method = state_processor_method self.names_previous_services = names_previous_services or set() self.names_required_previous_services = names_required_previous_services or set() self.tags = set(tags or []) self.workflow_formatter = workflow_formatter self.dialog_formatter = dialog_formatter self.response_formatter = response_formatter self.connector_func = connector_func self.previous_services = set() self.required_previous_services = set() self.dependent_services = set() self.next_services = set() self.label = label or self.name def is_sselector(self): return 'selector' in self.tags def is_responder(self): return 'responder' in self.tags def is_input(self): return 'input' in self.tags def is_last_chance(self): return 'last_chance' in self.tags def is_timeout(self): return 'timeout' in self.tags def apply_workflow_formatter(self, payload): if not self.workflow_formatter: return payload return self.workflow_formatter(payload) def apply_dialog_formatter(self, payload): if not self.dialog_formatter: return [self.apply_workflow_formatter(payload)] return self.dialog_formatter(self.apply_workflow_formatter(payload)) def apply_response_formatter(self, payload): if not self.response_formatter: return payload return self.response_formatter(payload) def simple_workflow_formatter(workflow_record): return workflow_record['dialog'].to_dict()
class Service: def __init__(self, name, connector_func, state_processor_method=None, batch_size=1, tags=None, names_previous_services=None, names_required_previous_services=None, workflow_formatter=None, dialog_formatter=None, response_formatter=None, label=None): self.name = name self.batch_size = batch_size self.state_processor_method = state_processor_method self.names_previous_services = names_previous_services or set() self.names_required_previous_services = names_required_previous_services or set() self.tags = set(tags or []) self.workflow_formatter = workflow_formatter self.dialog_formatter = dialog_formatter self.response_formatter = response_formatter self.connector_func = connector_func self.previous_services = set() self.required_previous_services = set() self.dependent_services = set() self.next_services = set() self.label = label or self.name def is_sselector(self): return 'selector' in self.tags def is_responder(self): return 'responder' in self.tags def is_input(self): return 'input' in self.tags def is_last_chance(self): return 'last_chance' in self.tags def is_timeout(self): return 'timeout' in self.tags def apply_workflow_formatter(self, payload): if not self.workflow_formatter: return payload return self.workflow_formatter(payload) def apply_dialog_formatter(self, payload): if not self.dialog_formatter: return [self.apply_workflow_formatter(payload)] return self.dialog_formatter(self.apply_workflow_formatter(payload)) def apply_response_formatter(self, payload): if not self.response_formatter: return payload return self.response_formatter(payload) def simple_workflow_formatter(workflow_record): return workflow_record['dialog'].to_dict()
text = input() command = input() while command != 'Decode': current_command = command.split('|') action = current_command[0] if action == 'Move': num_of_letters = int(current_command[1]) substring = text[:num_of_letters] text = text[num_of_letters:] + substring elif action == 'Insert': index = int(current_command[1]) new_value = current_command[2] text = text[:index] + new_value + text[index:] elif action == 'ChangeAll': substring = current_command[1] replacement = current_command[2] text = text.replace(substring, replacement) command = input() print(f"The decrypted message is: {text}")
text = input() command = input() while command != 'Decode': current_command = command.split('|') action = current_command[0] if action == 'Move': num_of_letters = int(current_command[1]) substring = text[:num_of_letters] text = text[num_of_letters:] + substring elif action == 'Insert': index = int(current_command[1]) new_value = current_command[2] text = text[:index] + new_value + text[index:] elif action == 'ChangeAll': substring = current_command[1] replacement = current_command[2] text = text.replace(substring, replacement) command = input() print(f'The decrypted message is: {text}')
# To implement a stack using a list # Made by Nouman stack=[] def push(x): stack.append(x) print("Stack: ", stack) print(x," pushed into stack") def pop(): x=stack.pop() print("\nPopped: ",x) print("Stack :",stack) size=int(input("Enter size of stack: ")) print("\nEnter elements into stack: ") for i in range(size): x=int(input("\nInput: ")) push(x) for i in range(size): pop()
stack = [] def push(x): stack.append(x) print('Stack: ', stack) print(x, ' pushed into stack') def pop(): x = stack.pop() print('\nPopped: ', x) print('Stack :', stack) size = int(input('Enter size of stack: ')) print('\nEnter elements into stack: ') for i in range(size): x = int(input('\nInput: ')) push(x) for i in range(size): pop()
class Solution: def wordPattern(self, pattern: str, s: str) -> bool: words = s.split(' ') if len(pattern) != len(words): return False w_to_p = {} p_to_w = {} for i, w in enumerate(words): if pattern[i] not in p_to_w: p_to_w[pattern[i]] = w if w not in w_to_p: w_to_p[w] = pattern[i] if p_to_w[pattern[i]] != w or w_to_p[w] != pattern[i]: return False return True
class Solution: def word_pattern(self, pattern: str, s: str) -> bool: words = s.split(' ') if len(pattern) != len(words): return False w_to_p = {} p_to_w = {} for (i, w) in enumerate(words): if pattern[i] not in p_to_w: p_to_w[pattern[i]] = w if w not in w_to_p: w_to_p[w] = pattern[i] if p_to_w[pattern[i]] != w or w_to_p[w] != pattern[i]: return False return True
class Solution: @staticmethod def naive(nums,target): left,right = 0,len(nums)-1 while right>left+1: mid = (left+right)//2 if nums[mid]>target: right = mid elif nums[mid]<target: left = mid else: return mid if target<=nums[right] and target<=nums[left]: return left if nums[left]<target<=nums[right]: return right if target>=nums[right] and target>nums[left]: if target==nums[right]: return right else: return right+1
class Solution: @staticmethod def naive(nums, target): (left, right) = (0, len(nums) - 1) while right > left + 1: mid = (left + right) // 2 if nums[mid] > target: right = mid elif nums[mid] < target: left = mid else: return mid if target <= nums[right] and target <= nums[left]: return left if nums[left] < target <= nums[right]: return right if target >= nums[right] and target > nums[left]: if target == nums[right]: return right else: return right + 1
# # PySNMP MIB module CISCO-WAN-MG-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-WAN-MG-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 18:02: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, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsIntersection, ValueSizeConstraint, SingleValueConstraint, ValueRangeConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueSizeConstraint", "SingleValueConstraint", "ValueRangeConstraint", "ConstraintsUnion") ciscoWan, = mibBuilder.importSymbols("CISCOWAN-SMI", "ciscoWan") SnmpAdminString, = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString") ModuleCompliance, NotificationGroup, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup", "ObjectGroup") IpAddress, Counter32, TimeTicks, Gauge32, Unsigned32, MibIdentifier, Bits, iso, ObjectIdentity, Counter64, ModuleIdentity, NotificationType, MibScalar, MibTable, MibTableRow, MibTableColumn, Integer32 = mibBuilder.importSymbols("SNMPv2-SMI", "IpAddress", "Counter32", "TimeTicks", "Gauge32", "Unsigned32", "MibIdentifier", "Bits", "iso", "ObjectIdentity", "Counter64", "ModuleIdentity", "NotificationType", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Integer32") TruthValue, RowStatus, DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "TruthValue", "RowStatus", "DisplayString", "TextualConvention") ciscoWanMgMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 351, 150, 10)) ciscoWanMgMIB.setRevisions(('2005-05-27 00:00', '2004-01-20 00:00', '2002-06-14 00:00', '2001-05-25 00:00', '2000-07-19 15:00', '2000-03-27 00:00', '1999-11-27 00:00',)) if mibBuilder.loadTexts: ciscoWanMgMIB.setLastUpdated('200505270000Z') if mibBuilder.loadTexts: ciscoWanMgMIB.setOrganization('Cisco Systems, Inc.') ciscoWanMgMIBObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 351, 150, 10, 1)) mediaGateway = MibIdentifier((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 1)) mediaGatewayController = MibIdentifier((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2)) mediaGatewayEndpoint = MibIdentifier((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3)) mediaGatewayLine = MibIdentifier((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 4)) mediaGatewayControllerResolution = MibIdentifier((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 5)) mediaGatewayDomainName = MibIdentifier((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 6)) mgName = MibScalar((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 64))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mgName.setStatus('current') mgAdministrativeState = MibScalar((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("inService", 1), ("commandedOutOfService", 2), ("pendingOutOfService", 3))).clone('commandedOutOfService')).setMaxAccess("readonly") if mibBuilder.loadTexts: mgAdministrativeState.setStatus('current') mgAdministrativeStateControl = MibScalar((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("inService", 1), ("forcefulOutOfService", 2), ("gracefulOutOfService", 3))).clone('forcefulOutOfService')).setMaxAccess("readwrite") if mibBuilder.loadTexts: mgAdministrativeStateControl.setStatus('current') mgShutdownGraceTime = MibScalar((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 65535))).setUnits('seconds').setMaxAccess("readwrite") if mibBuilder.loadTexts: mgShutdownGraceTime.setStatus('current') mgSupportedProtocolTable = MibTable((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 1, 7), ) if mibBuilder.loadTexts: mgSupportedProtocolTable.setStatus('current') mgSupportedProtocolEntry = MibTableRow((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 1, 7, 1), ).setIndexNames((0, "CISCO-WAN-MG-MIB", "mgProtocolNumber")) if mibBuilder.loadTexts: mgSupportedProtocolEntry.setStatus('current') mgProtocolNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 1, 7, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))) if mibBuilder.loadTexts: mgProtocolNumber.setStatus('current') mgProtocolName = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 1, 7, 1, 2), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 64))).setMaxAccess("readonly") if mibBuilder.loadTexts: mgProtocolName.setStatus('current') maxConcurrentMgcs = MibScalar((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 3), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setUnits('controllers').setMaxAccess("readonly") if mibBuilder.loadTexts: maxConcurrentMgcs.setStatus('current') mgcTable = MibTable((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 1), ) if mibBuilder.loadTexts: mgcTable.setStatus('current') mgcEntry = MibTableRow((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 1, 1), ).setIndexNames((0, "CISCO-WAN-MG-MIB", "mgcNumber")) if mibBuilder.loadTexts: mgcEntry.setStatus('current') mgcNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))) if mibBuilder.loadTexts: mgcNumber.setStatus('current') mgcName = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 1, 1, 2), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 64))).setMaxAccess("readcreate") if mibBuilder.loadTexts: mgcName.setStatus('current') mgcDnsResolution = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 1, 1, 3), TruthValue().clone('false')).setMaxAccess("readonly") if mibBuilder.loadTexts: mgcDnsResolution.setStatus('deprecated') mgcAssociationState = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 1, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("mgcUnassociated", 1), ("mgcAssociated", 2), ("mgcAssociatedCommLoss", 3)))).setMaxAccess("readonly") if mibBuilder.loadTexts: mgcAssociationState.setStatus('deprecated') mgcAssociationStateControl = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 1, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("mgcUnassociate", 1), ("mgcAssociate", 2), ("mgcClear", 3))).clone('mgcUnassociate')).setMaxAccess("readcreate") if mibBuilder.loadTexts: mgcAssociationStateControl.setStatus('deprecated') mgcUnassociationPolicy = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 1, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("mgcNoAction", 1), ("mgcRelease", 2))).clone('mgcNoAction')).setMaxAccess("readcreate") if mibBuilder.loadTexts: mgcUnassociationPolicy.setStatus('deprecated') mgcCommLossUnassociationTimeout = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 1, 1, 7), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 65535)).clone(-1)).setUnits('seconds').setMaxAccess("readcreate") if mibBuilder.loadTexts: mgcCommLossUnassociationTimeout.setStatus('deprecated') mgcRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 1, 1, 8), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: mgcRowStatus.setStatus('current') mgcProtocolTable = MibTable((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 2), ) if mibBuilder.loadTexts: mgcProtocolTable.setStatus('deprecated') mgcProtocolEntry = MibTableRow((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 2, 1), ).setIndexNames((0, "CISCO-WAN-MG-MIB", "mgcNumber"), (0, "CISCO-WAN-MG-MIB", "mgProtocolNumber")) if mibBuilder.loadTexts: mgcProtocolEntry.setStatus('deprecated') mgcProtocolRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 2, 1, 1), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: mgcProtocolRowStatus.setStatus('deprecated') mgEndpointCreationPolicy = MibScalar((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("dynamic", 1), ("strictDynamic", 2), ("static", 3))).clone('static')).setMaxAccess("readwrite") if mibBuilder.loadTexts: mgEndpointCreationPolicy.setStatus('current') mgEndpointTable = MibTable((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 1), ) if mibBuilder.loadTexts: mgEndpointTable.setStatus('current') mgEndpointEntry = MibTableRow((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 1, 1), ).setIndexNames((0, "CISCO-WAN-MG-MIB", "mgEndpointNumber")) if mibBuilder.loadTexts: mgEndpointEntry.setStatus('current') mgEndpointNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))) if mibBuilder.loadTexts: mgEndpointNumber.setStatus('current') mgEndpointLineNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 1, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readcreate") if mibBuilder.loadTexts: mgEndpointLineNumber.setStatus('current') mgEndpointName = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 1, 1, 3), SnmpAdminString()).setMaxAccess("readcreate") if mibBuilder.loadTexts: mgEndpointName.setStatus('current') mgEndpointSpeed = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 1, 1, 4), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setUnits('Kbps').setMaxAccess("readonly") if mibBuilder.loadTexts: mgEndpointSpeed.setStatus('current') mgEndpointState = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 1, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("mgEndpointActive", 1), ("mgEndpointFailed", 2), ("mgEndpointDegraded", 3)))).setMaxAccess("readonly") if mibBuilder.loadTexts: mgEndpointState.setStatus('current') mgEndpointChannelMap = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 1, 1, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setMaxAccess("readcreate") if mibBuilder.loadTexts: mgEndpointChannelMap.setStatus('current') mgEndpointRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 1, 1, 7), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: mgEndpointRowStatus.setStatus('current') lineAssignmentTable = MibTable((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 4, 1), ) if mibBuilder.loadTexts: lineAssignmentTable.setStatus('current') lineAssignmentEntry = MibTableRow((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 4, 1, 1), ).setIndexNames((0, "CISCO-WAN-MG-MIB", "lineNumber")) if mibBuilder.loadTexts: lineAssignmentEntry.setStatus('current') lineNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 4, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))) if mibBuilder.loadTexts: lineNumber.setStatus('current') channelAssignment = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 4, 1, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setMaxAccess("readonly") if mibBuilder.loadTexts: channelAssignment.setStatus('current') lineName = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 4, 1, 1, 3), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 64))).setMaxAccess("readwrite") if mibBuilder.loadTexts: lineName.setStatus('current') mgcResolutionTable = MibTable((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 5, 1), ) if mibBuilder.loadTexts: mgcResolutionTable.setStatus('current') mgcResolutionEntry = MibTableRow((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 5, 1, 1), ).setIndexNames((0, "CISCO-WAN-MG-MIB", "mgcResolutionIndex")) if mibBuilder.loadTexts: mgcResolutionEntry.setStatus('current') mgcResolutionIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 5, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))) if mibBuilder.loadTexts: mgcResolutionIndex.setStatus('current') mgcResolutionName = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 5, 1, 1, 2), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 64))).setMaxAccess("readcreate") if mibBuilder.loadTexts: mgcResolutionName.setStatus('current') mgcResolutionIpAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 5, 1, 1, 3), IpAddress()).setMaxAccess("readcreate") if mibBuilder.loadTexts: mgcResolutionIpAddress.setStatus('current') mgcResolutionCommState = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 5, 1, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("csActive", 1), ("csInactive", 2))).clone('csInactive')).setMaxAccess("readonly") if mibBuilder.loadTexts: mgcResolutionCommState.setStatus('current') mgcResolutionPreference = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 5, 1, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readcreate") if mibBuilder.loadTexts: mgcResolutionPreference.setStatus('current') mgcResolutionRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 5, 1, 1, 6), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: mgcResolutionRowStatus.setStatus('current') mgcDnsResolutionFlag = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 5, 1, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("internal", 1), ("external", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: mgcDnsResolutionFlag.setStatus('current') mgDomainNameTable = MibTable((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 6, 1), ) if mibBuilder.loadTexts: mgDomainNameTable.setStatus('current') mgDomainNameEntry = MibTableRow((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 6, 1, 1), ).setIndexNames((0, "CISCO-WAN-MG-MIB", "mgDomainNameIndex")) if mibBuilder.loadTexts: mgDomainNameEntry.setStatus('current') mgDomainNameIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 6, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))) if mibBuilder.loadTexts: mgDomainNameIndex.setStatus('current') mgDomainName = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 6, 1, 1, 2), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 64))).setMaxAccess("readcreate") if mibBuilder.loadTexts: mgDomainName.setStatus('current') mgDnsResolutionType = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 6, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("internalOnly", 1), ("externalOnly", 2), ("internalFirst", 3), ("externalFirst", 4))).clone('internalOnly')).setMaxAccess("readcreate") if mibBuilder.loadTexts: mgDnsResolutionType.setStatus('current') mgDomainNameRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 6, 1, 1, 4), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: mgDomainNameRowStatus.setStatus('current') mgEndpointExtTable = MibTable((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 3), ) if mibBuilder.loadTexts: mgEndpointExtTable.setStatus('current') mgEndpointExtEntry = MibTableRow((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 3, 1), ) mgEndpointEntry.registerAugmentions(("CISCO-WAN-MG-MIB", "mgEndpointExtEntry")) mgEndpointExtEntry.setIndexNames(*mgEndpointEntry.getIndexNames()) if mibBuilder.loadTexts: mgEndpointExtEntry.setStatus('current') mgEndpointRepetition = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 3, 1, 1), Unsigned32().clone(1)).setMaxAccess("readcreate") if mibBuilder.loadTexts: mgEndpointRepetition.setStatus('current') mgMIBConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 351, 150, 10, 3)) mgMIBCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 1)) mgMIBGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2)) mgMIBCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 1, 1)).setObjects(("CISCO-WAN-MG-MIB", "mediaGatewayGroup"), ("CISCO-WAN-MG-MIB", "mediaGatewayControllerGroup"), ("CISCO-WAN-MG-MIB", "mediaGatewayEndpointGroup"), ("CISCO-WAN-MG-MIB", "mediaGatewayLineGroup"), ("CISCO-WAN-MG-MIB", "mediaGatewayControllerResolutionGroup")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): mgMIBCompliance = mgMIBCompliance.setStatus('deprecated') mgMIBCompliance1 = ModuleCompliance((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 1, 2)).setObjects(("CISCO-WAN-MG-MIB", "mediaGatewayGroup"), ("CISCO-WAN-MG-MIB", "mediaGatewayControllerGroup1"), ("CISCO-WAN-MG-MIB", "mediaGatewayEndpointGroup"), ("CISCO-WAN-MG-MIB", "mediaGatewayLineGroup"), ("CISCO-WAN-MG-MIB", "mediaGatewayDomainNameGroup"), ("CISCO-WAN-MG-MIB", "mediaGatewayControllerResolutionGroup1")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): mgMIBCompliance1 = mgMIBCompliance1.setStatus('deprecated') mgMIBCompliance2 = ModuleCompliance((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 1, 3)).setObjects(("CISCO-WAN-MG-MIB", "mediaGatewayGroup"), ("CISCO-WAN-MG-MIB", "mediaGatewayControllerGroup2"), ("CISCO-WAN-MG-MIB", "mediaGatewayEndpointGroup"), ("CISCO-WAN-MG-MIB", "mediaGatewayLineGroup"), ("CISCO-WAN-MG-MIB", "mediaGatewayDomainNameGroup"), ("CISCO-WAN-MG-MIB", "mediaGatewayControllerResolutionGroup1")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): mgMIBCompliance2 = mgMIBCompliance2.setStatus('deprecated') mgMIBCompliance3 = ModuleCompliance((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 1, 4)).setObjects(("CISCO-WAN-MG-MIB", "mediaGatewayGroup"), ("CISCO-WAN-MG-MIB", "mediaGatewayControllerGroup2"), ("CISCO-WAN-MG-MIB", "mediaGatewayEndpointGroup"), ("CISCO-WAN-MG-MIB", "mediaGatewayLineGroup"), ("CISCO-WAN-MG-MIB", "mediaGatewayDomainNameGroup"), ("CISCO-WAN-MG-MIB", "mediaGatewayControllerResolutionGroup1"), ("CISCO-WAN-MG-MIB", "mediaGatewayEndptRepetitionGroup")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): mgMIBCompliance3 = mgMIBCompliance3.setStatus('current') mediaGatewayGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2, 1)).setObjects(("CISCO-WAN-MG-MIB", "mgName"), ("CISCO-WAN-MG-MIB", "mgAdministrativeState"), ("CISCO-WAN-MG-MIB", "mgAdministrativeStateControl"), ("CISCO-WAN-MG-MIB", "mgShutdownGraceTime"), ("CISCO-WAN-MG-MIB", "mgProtocolName")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): mediaGatewayGroup = mediaGatewayGroup.setStatus('current') mediaGatewayControllerGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2, 2)).setObjects(("CISCO-WAN-MG-MIB", "maxConcurrentMgcs"), ("CISCO-WAN-MG-MIB", "mgcName"), ("CISCO-WAN-MG-MIB", "mgcDnsResolution"), ("CISCO-WAN-MG-MIB", "mgcAssociationState"), ("CISCO-WAN-MG-MIB", "mgcAssociationStateControl"), ("CISCO-WAN-MG-MIB", "mgcUnassociationPolicy"), ("CISCO-WAN-MG-MIB", "mgcCommLossUnassociationTimeout"), ("CISCO-WAN-MG-MIB", "mgcRowStatus"), ("CISCO-WAN-MG-MIB", "mgcProtocolRowStatus")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): mediaGatewayControllerGroup = mediaGatewayControllerGroup.setStatus('deprecated') mediaGatewayEndpointGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2, 3)).setObjects(("CISCO-WAN-MG-MIB", "mgEndpointCreationPolicy"), ("CISCO-WAN-MG-MIB", "mgEndpointName"), ("CISCO-WAN-MG-MIB", "mgEndpointLineNumber"), ("CISCO-WAN-MG-MIB", "mgEndpointSpeed"), ("CISCO-WAN-MG-MIB", "mgEndpointState"), ("CISCO-WAN-MG-MIB", "mgEndpointChannelMap"), ("CISCO-WAN-MG-MIB", "mgEndpointRowStatus")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): mediaGatewayEndpointGroup = mediaGatewayEndpointGroup.setStatus('current') mediaGatewayLineGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2, 4)).setObjects(("CISCO-WAN-MG-MIB", "channelAssignment"), ("CISCO-WAN-MG-MIB", "lineName")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): mediaGatewayLineGroup = mediaGatewayLineGroup.setStatus('current') mediaGatewayControllerResolutionGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2, 5)).setObjects(("CISCO-WAN-MG-MIB", "mgcResolutionName"), ("CISCO-WAN-MG-MIB", "mgcResolutionIpAddress"), ("CISCO-WAN-MG-MIB", "mgcResolutionCommState"), ("CISCO-WAN-MG-MIB", "mgcResolutionPreference"), ("CISCO-WAN-MG-MIB", "mgcResolutionRowStatus")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): mediaGatewayControllerResolutionGroup = mediaGatewayControllerResolutionGroup.setStatus('deprecated') mediaGatewayControllerGroup1 = ObjectGroup((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2, 6)).setObjects(("CISCO-WAN-MG-MIB", "maxConcurrentMgcs"), ("CISCO-WAN-MG-MIB", "mgcName"), ("CISCO-WAN-MG-MIB", "mgcAssociationState"), ("CISCO-WAN-MG-MIB", "mgcAssociationStateControl"), ("CISCO-WAN-MG-MIB", "mgcUnassociationPolicy"), ("CISCO-WAN-MG-MIB", "mgcCommLossUnassociationTimeout"), ("CISCO-WAN-MG-MIB", "mgcRowStatus"), ("CISCO-WAN-MG-MIB", "mgcProtocolRowStatus")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): mediaGatewayControllerGroup1 = mediaGatewayControllerGroup1.setStatus('deprecated') mediaGatewayControllerResolutionGroup1 = ObjectGroup((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2, 7)).setObjects(("CISCO-WAN-MG-MIB", "mgcResolutionName"), ("CISCO-WAN-MG-MIB", "mgcResolutionIpAddress"), ("CISCO-WAN-MG-MIB", "mgcResolutionCommState"), ("CISCO-WAN-MG-MIB", "mgcResolutionPreference"), ("CISCO-WAN-MG-MIB", "mgcResolutionRowStatus"), ("CISCO-WAN-MG-MIB", "mgcDnsResolutionFlag")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): mediaGatewayControllerResolutionGroup1 = mediaGatewayControllerResolutionGroup1.setStatus('current') mediaGatewayDomainNameGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2, 8)).setObjects(("CISCO-WAN-MG-MIB", "mgDomainName"), ("CISCO-WAN-MG-MIB", "mgDnsResolutionType"), ("CISCO-WAN-MG-MIB", "mgDomainNameRowStatus")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): mediaGatewayDomainNameGroup = mediaGatewayDomainNameGroup.setStatus('current') mediaGatewayControllerGroup2 = ObjectGroup((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2, 9)).setObjects(("CISCO-WAN-MG-MIB", "maxConcurrentMgcs"), ("CISCO-WAN-MG-MIB", "mgcName"), ("CISCO-WAN-MG-MIB", "mgcRowStatus")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): mediaGatewayControllerGroup2 = mediaGatewayControllerGroup2.setStatus('current') mediaGatewayEndptRepetitionGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2, 10)).setObjects(("CISCO-WAN-MG-MIB", "mgEndpointRepetition")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): mediaGatewayEndptRepetitionGroup = mediaGatewayEndptRepetitionGroup.setStatus('current') mibBuilder.exportSymbols("CISCO-WAN-MG-MIB", mgEndpointCreationPolicy=mgEndpointCreationPolicy, mgProtocolNumber=mgProtocolNumber, mgcNumber=mgcNumber, mediaGatewayGroup=mediaGatewayGroup, mgcResolutionIpAddress=mgcResolutionIpAddress, mgEndpointSpeed=mgEndpointSpeed, mgcDnsResolution=mgcDnsResolution, mgAdministrativeStateControl=mgAdministrativeStateControl, mgMIBConformance=mgMIBConformance, mgName=mgName, mgDomainNameTable=mgDomainNameTable, mgMIBCompliance3=mgMIBCompliance3, mgMIBCompliance=mgMIBCompliance, lineAssignmentEntry=lineAssignmentEntry, mgcTable=mgcTable, mediaGatewayControllerResolutionGroup=mediaGatewayControllerResolutionGroup, mgEndpointExtTable=mgEndpointExtTable, mgEndpointExtEntry=mgEndpointExtEntry, mgcProtocolRowStatus=mgcProtocolRowStatus, mgcAssociationState=mgcAssociationState, mgcDnsResolutionFlag=mgcDnsResolutionFlag, mediaGateway=mediaGateway, mediaGatewayEndpoint=mediaGatewayEndpoint, mgSupportedProtocolTable=mgSupportedProtocolTable, mgDomainName=mgDomainName, ciscoWanMgMIBObjects=ciscoWanMgMIBObjects, mgEndpointLineNumber=mgEndpointLineNumber, mgMIBCompliance2=mgMIBCompliance2, channelAssignment=channelAssignment, mgMIBCompliance1=mgMIBCompliance1, mediaGatewayDomainNameGroup=mediaGatewayDomainNameGroup, mgcResolutionPreference=mgcResolutionPreference, mgcProtocolEntry=mgcProtocolEntry, mediaGatewayLine=mediaGatewayLine, mgcResolutionName=mgcResolutionName, mediaGatewayLineGroup=mediaGatewayLineGroup, mediaGatewayControllerGroup=mediaGatewayControllerGroup, mgEndpointRowStatus=mgEndpointRowStatus, mgDomainNameEntry=mgDomainNameEntry, mediaGatewayDomainName=mediaGatewayDomainName, mgEndpointRepetition=mgEndpointRepetition, mgDomainNameIndex=mgDomainNameIndex, mgShutdownGraceTime=mgShutdownGraceTime, mgcEntry=mgcEntry, mgcAssociationStateControl=mgcAssociationStateControl, mgAdministrativeState=mgAdministrativeState, mgcRowStatus=mgcRowStatus, mgEndpointChannelMap=mgEndpointChannelMap, mgDomainNameRowStatus=mgDomainNameRowStatus, mgcUnassociationPolicy=mgcUnassociationPolicy, mediaGatewayControllerGroup1=mediaGatewayControllerGroup1, ciscoWanMgMIB=ciscoWanMgMIB, mediaGatewayEndpointGroup=mediaGatewayEndpointGroup, mediaGatewayController=mediaGatewayController, mediaGatewayControllerResolution=mediaGatewayControllerResolution, mgcResolutionCommState=mgcResolutionCommState, mgcResolutionRowStatus=mgcResolutionRowStatus, mediaGatewayControllerGroup2=mediaGatewayControllerGroup2, mgProtocolName=mgProtocolName, mgSupportedProtocolEntry=mgSupportedProtocolEntry, mgEndpointEntry=mgEndpointEntry, mgDnsResolutionType=mgDnsResolutionType, mgEndpointName=mgEndpointName, mgcResolutionTable=mgcResolutionTable, mgEndpointState=mgEndpointState, mediaGatewayControllerResolutionGroup1=mediaGatewayControllerResolutionGroup1, mgcProtocolTable=mgcProtocolTable, lineAssignmentTable=lineAssignmentTable, PYSNMP_MODULE_ID=ciscoWanMgMIB, mgcResolutionIndex=mgcResolutionIndex, mgcCommLossUnassociationTimeout=mgcCommLossUnassociationTimeout, mgcResolutionEntry=mgcResolutionEntry, mgMIBGroups=mgMIBGroups, mgEndpointNumber=mgEndpointNumber, mgcName=mgcName, mgMIBCompliances=mgMIBCompliances, mediaGatewayEndptRepetitionGroup=mediaGatewayEndptRepetitionGroup, mgEndpointTable=mgEndpointTable, maxConcurrentMgcs=maxConcurrentMgcs, lineName=lineName, lineNumber=lineNumber)
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_size_constraint, single_value_constraint, value_range_constraint, constraints_union) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsIntersection', 'ValueSizeConstraint', 'SingleValueConstraint', 'ValueRangeConstraint', 'ConstraintsUnion') (cisco_wan,) = mibBuilder.importSymbols('CISCOWAN-SMI', 'ciscoWan') (snmp_admin_string,) = mibBuilder.importSymbols('SNMP-FRAMEWORK-MIB', 'SnmpAdminString') (module_compliance, notification_group, object_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup', 'ObjectGroup') (ip_address, counter32, time_ticks, gauge32, unsigned32, mib_identifier, bits, iso, object_identity, counter64, module_identity, notification_type, mib_scalar, mib_table, mib_table_row, mib_table_column, integer32) = mibBuilder.importSymbols('SNMPv2-SMI', 'IpAddress', 'Counter32', 'TimeTicks', 'Gauge32', 'Unsigned32', 'MibIdentifier', 'Bits', 'iso', 'ObjectIdentity', 'Counter64', 'ModuleIdentity', 'NotificationType', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Integer32') (truth_value, row_status, display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'TruthValue', 'RowStatus', 'DisplayString', 'TextualConvention') cisco_wan_mg_mib = module_identity((1, 3, 6, 1, 4, 1, 351, 150, 10)) ciscoWanMgMIB.setRevisions(('2005-05-27 00:00', '2004-01-20 00:00', '2002-06-14 00:00', '2001-05-25 00:00', '2000-07-19 15:00', '2000-03-27 00:00', '1999-11-27 00:00')) if mibBuilder.loadTexts: ciscoWanMgMIB.setLastUpdated('200505270000Z') if mibBuilder.loadTexts: ciscoWanMgMIB.setOrganization('Cisco Systems, Inc.') cisco_wan_mg_mib_objects = mib_identifier((1, 3, 6, 1, 4, 1, 351, 150, 10, 1)) media_gateway = mib_identifier((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 1)) media_gateway_controller = mib_identifier((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2)) media_gateway_endpoint = mib_identifier((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3)) media_gateway_line = mib_identifier((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 4)) media_gateway_controller_resolution = mib_identifier((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 5)) media_gateway_domain_name = mib_identifier((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 6)) mg_name = mib_scalar((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 1, 1), snmp_admin_string().subtype(subtypeSpec=value_size_constraint(1, 64))).setMaxAccess('readwrite') if mibBuilder.loadTexts: mgName.setStatus('current') mg_administrative_state = mib_scalar((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('inService', 1), ('commandedOutOfService', 2), ('pendingOutOfService', 3))).clone('commandedOutOfService')).setMaxAccess('readonly') if mibBuilder.loadTexts: mgAdministrativeState.setStatus('current') mg_administrative_state_control = mib_scalar((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('inService', 1), ('forcefulOutOfService', 2), ('gracefulOutOfService', 3))).clone('forcefulOutOfService')).setMaxAccess('readwrite') if mibBuilder.loadTexts: mgAdministrativeStateControl.setStatus('current') mg_shutdown_grace_time = mib_scalar((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 1, 4), integer32().subtype(subtypeSpec=value_range_constraint(-1, 65535))).setUnits('seconds').setMaxAccess('readwrite') if mibBuilder.loadTexts: mgShutdownGraceTime.setStatus('current') mg_supported_protocol_table = mib_table((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 1, 7)) if mibBuilder.loadTexts: mgSupportedProtocolTable.setStatus('current') mg_supported_protocol_entry = mib_table_row((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 1, 7, 1)).setIndexNames((0, 'CISCO-WAN-MG-MIB', 'mgProtocolNumber')) if mibBuilder.loadTexts: mgSupportedProtocolEntry.setStatus('current') mg_protocol_number = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 1, 7, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))) if mibBuilder.loadTexts: mgProtocolNumber.setStatus('current') mg_protocol_name = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 1, 7, 1, 2), snmp_admin_string().subtype(subtypeSpec=value_size_constraint(1, 64))).setMaxAccess('readonly') if mibBuilder.loadTexts: mgProtocolName.setStatus('current') max_concurrent_mgcs = mib_scalar((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 3), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 65535))).setUnits('controllers').setMaxAccess('readonly') if mibBuilder.loadTexts: maxConcurrentMgcs.setStatus('current') mgc_table = mib_table((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 1)) if mibBuilder.loadTexts: mgcTable.setStatus('current') mgc_entry = mib_table_row((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 1, 1)).setIndexNames((0, 'CISCO-WAN-MG-MIB', 'mgcNumber')) if mibBuilder.loadTexts: mgcEntry.setStatus('current') mgc_number = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 1, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))) if mibBuilder.loadTexts: mgcNumber.setStatus('current') mgc_name = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 1, 1, 2), snmp_admin_string().subtype(subtypeSpec=value_size_constraint(1, 64))).setMaxAccess('readcreate') if mibBuilder.loadTexts: mgcName.setStatus('current') mgc_dns_resolution = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 1, 1, 3), truth_value().clone('false')).setMaxAccess('readonly') if mibBuilder.loadTexts: mgcDnsResolution.setStatus('deprecated') mgc_association_state = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 1, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('mgcUnassociated', 1), ('mgcAssociated', 2), ('mgcAssociatedCommLoss', 3)))).setMaxAccess('readonly') if mibBuilder.loadTexts: mgcAssociationState.setStatus('deprecated') mgc_association_state_control = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 1, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('mgcUnassociate', 1), ('mgcAssociate', 2), ('mgcClear', 3))).clone('mgcUnassociate')).setMaxAccess('readcreate') if mibBuilder.loadTexts: mgcAssociationStateControl.setStatus('deprecated') mgc_unassociation_policy = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 1, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('mgcNoAction', 1), ('mgcRelease', 2))).clone('mgcNoAction')).setMaxAccess('readcreate') if mibBuilder.loadTexts: mgcUnassociationPolicy.setStatus('deprecated') mgc_comm_loss_unassociation_timeout = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 1, 1, 7), integer32().subtype(subtypeSpec=value_range_constraint(-1, 65535)).clone(-1)).setUnits('seconds').setMaxAccess('readcreate') if mibBuilder.loadTexts: mgcCommLossUnassociationTimeout.setStatus('deprecated') mgc_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 1, 1, 8), row_status()).setMaxAccess('readcreate') if mibBuilder.loadTexts: mgcRowStatus.setStatus('current') mgc_protocol_table = mib_table((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 2)) if mibBuilder.loadTexts: mgcProtocolTable.setStatus('deprecated') mgc_protocol_entry = mib_table_row((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 2, 1)).setIndexNames((0, 'CISCO-WAN-MG-MIB', 'mgcNumber'), (0, 'CISCO-WAN-MG-MIB', 'mgProtocolNumber')) if mibBuilder.loadTexts: mgcProtocolEntry.setStatus('deprecated') mgc_protocol_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 2, 2, 1, 1), row_status()).setMaxAccess('readcreate') if mibBuilder.loadTexts: mgcProtocolRowStatus.setStatus('deprecated') mg_endpoint_creation_policy = mib_scalar((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('dynamic', 1), ('strictDynamic', 2), ('static', 3))).clone('static')).setMaxAccess('readwrite') if mibBuilder.loadTexts: mgEndpointCreationPolicy.setStatus('current') mg_endpoint_table = mib_table((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 1)) if mibBuilder.loadTexts: mgEndpointTable.setStatus('current') mg_endpoint_entry = mib_table_row((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 1, 1)).setIndexNames((0, 'CISCO-WAN-MG-MIB', 'mgEndpointNumber')) if mibBuilder.loadTexts: mgEndpointEntry.setStatus('current') mg_endpoint_number = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 1, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))) if mibBuilder.loadTexts: mgEndpointNumber.setStatus('current') mg_endpoint_line_number = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 1, 1, 2), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))).setMaxAccess('readcreate') if mibBuilder.loadTexts: mgEndpointLineNumber.setStatus('current') mg_endpoint_name = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 1, 1, 3), snmp_admin_string()).setMaxAccess('readcreate') if mibBuilder.loadTexts: mgEndpointName.setStatus('current') mg_endpoint_speed = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 1, 1, 4), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 65535))).setUnits('Kbps').setMaxAccess('readonly') if mibBuilder.loadTexts: mgEndpointSpeed.setStatus('current') mg_endpoint_state = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 1, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('mgEndpointActive', 1), ('mgEndpointFailed', 2), ('mgEndpointDegraded', 3)))).setMaxAccess('readonly') if mibBuilder.loadTexts: mgEndpointState.setStatus('current') mg_endpoint_channel_map = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 1, 1, 6), integer32().subtype(subtypeSpec=value_range_constraint(0, 2147483647))).setMaxAccess('readcreate') if mibBuilder.loadTexts: mgEndpointChannelMap.setStatus('current') mg_endpoint_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 1, 1, 7), row_status()).setMaxAccess('readcreate') if mibBuilder.loadTexts: mgEndpointRowStatus.setStatus('current') line_assignment_table = mib_table((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 4, 1)) if mibBuilder.loadTexts: lineAssignmentTable.setStatus('current') line_assignment_entry = mib_table_row((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 4, 1, 1)).setIndexNames((0, 'CISCO-WAN-MG-MIB', 'lineNumber')) if mibBuilder.loadTexts: lineAssignmentEntry.setStatus('current') line_number = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 4, 1, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))) if mibBuilder.loadTexts: lineNumber.setStatus('current') channel_assignment = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 4, 1, 1, 2), integer32().subtype(subtypeSpec=value_range_constraint(0, 2147483647))).setMaxAccess('readonly') if mibBuilder.loadTexts: channelAssignment.setStatus('current') line_name = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 4, 1, 1, 3), snmp_admin_string().subtype(subtypeSpec=value_size_constraint(1, 64))).setMaxAccess('readwrite') if mibBuilder.loadTexts: lineName.setStatus('current') mgc_resolution_table = mib_table((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 5, 1)) if mibBuilder.loadTexts: mgcResolutionTable.setStatus('current') mgc_resolution_entry = mib_table_row((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 5, 1, 1)).setIndexNames((0, 'CISCO-WAN-MG-MIB', 'mgcResolutionIndex')) if mibBuilder.loadTexts: mgcResolutionEntry.setStatus('current') mgc_resolution_index = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 5, 1, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))) if mibBuilder.loadTexts: mgcResolutionIndex.setStatus('current') mgc_resolution_name = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 5, 1, 1, 2), snmp_admin_string().subtype(subtypeSpec=value_size_constraint(1, 64))).setMaxAccess('readcreate') if mibBuilder.loadTexts: mgcResolutionName.setStatus('current') mgc_resolution_ip_address = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 5, 1, 1, 3), ip_address()).setMaxAccess('readcreate') if mibBuilder.loadTexts: mgcResolutionIpAddress.setStatus('current') mgc_resolution_comm_state = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 5, 1, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('csActive', 1), ('csInactive', 2))).clone('csInactive')).setMaxAccess('readonly') if mibBuilder.loadTexts: mgcResolutionCommState.setStatus('current') mgc_resolution_preference = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 5, 1, 1, 5), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))).setMaxAccess('readcreate') if mibBuilder.loadTexts: mgcResolutionPreference.setStatus('current') mgc_resolution_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 5, 1, 1, 6), row_status()).setMaxAccess('readcreate') if mibBuilder.loadTexts: mgcResolutionRowStatus.setStatus('current') mgc_dns_resolution_flag = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 5, 1, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('internal', 1), ('external', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: mgcDnsResolutionFlag.setStatus('current') mg_domain_name_table = mib_table((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 6, 1)) if mibBuilder.loadTexts: mgDomainNameTable.setStatus('current') mg_domain_name_entry = mib_table_row((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 6, 1, 1)).setIndexNames((0, 'CISCO-WAN-MG-MIB', 'mgDomainNameIndex')) if mibBuilder.loadTexts: mgDomainNameEntry.setStatus('current') mg_domain_name_index = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 6, 1, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))) if mibBuilder.loadTexts: mgDomainNameIndex.setStatus('current') mg_domain_name = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 6, 1, 1, 2), snmp_admin_string().subtype(subtypeSpec=value_size_constraint(1, 64))).setMaxAccess('readcreate') if mibBuilder.loadTexts: mgDomainName.setStatus('current') mg_dns_resolution_type = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 6, 1, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('internalOnly', 1), ('externalOnly', 2), ('internalFirst', 3), ('externalFirst', 4))).clone('internalOnly')).setMaxAccess('readcreate') if mibBuilder.loadTexts: mgDnsResolutionType.setStatus('current') mg_domain_name_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 6, 1, 1, 4), row_status()).setMaxAccess('readcreate') if mibBuilder.loadTexts: mgDomainNameRowStatus.setStatus('current') mg_endpoint_ext_table = mib_table((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 3)) if mibBuilder.loadTexts: mgEndpointExtTable.setStatus('current') mg_endpoint_ext_entry = mib_table_row((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 3, 1)) mgEndpointEntry.registerAugmentions(('CISCO-WAN-MG-MIB', 'mgEndpointExtEntry')) mgEndpointExtEntry.setIndexNames(*mgEndpointEntry.getIndexNames()) if mibBuilder.loadTexts: mgEndpointExtEntry.setStatus('current') mg_endpoint_repetition = mib_table_column((1, 3, 6, 1, 4, 1, 351, 150, 10, 1, 3, 3, 1, 1), unsigned32().clone(1)).setMaxAccess('readcreate') if mibBuilder.loadTexts: mgEndpointRepetition.setStatus('current') mg_mib_conformance = mib_identifier((1, 3, 6, 1, 4, 1, 351, 150, 10, 3)) mg_mib_compliances = mib_identifier((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 1)) mg_mib_groups = mib_identifier((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2)) mg_mib_compliance = module_compliance((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 1, 1)).setObjects(('CISCO-WAN-MG-MIB', 'mediaGatewayGroup'), ('CISCO-WAN-MG-MIB', 'mediaGatewayControllerGroup'), ('CISCO-WAN-MG-MIB', 'mediaGatewayEndpointGroup'), ('CISCO-WAN-MG-MIB', 'mediaGatewayLineGroup'), ('CISCO-WAN-MG-MIB', 'mediaGatewayControllerResolutionGroup')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): mg_mib_compliance = mgMIBCompliance.setStatus('deprecated') mg_mib_compliance1 = module_compliance((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 1, 2)).setObjects(('CISCO-WAN-MG-MIB', 'mediaGatewayGroup'), ('CISCO-WAN-MG-MIB', 'mediaGatewayControllerGroup1'), ('CISCO-WAN-MG-MIB', 'mediaGatewayEndpointGroup'), ('CISCO-WAN-MG-MIB', 'mediaGatewayLineGroup'), ('CISCO-WAN-MG-MIB', 'mediaGatewayDomainNameGroup'), ('CISCO-WAN-MG-MIB', 'mediaGatewayControllerResolutionGroup1')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): mg_mib_compliance1 = mgMIBCompliance1.setStatus('deprecated') mg_mib_compliance2 = module_compliance((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 1, 3)).setObjects(('CISCO-WAN-MG-MIB', 'mediaGatewayGroup'), ('CISCO-WAN-MG-MIB', 'mediaGatewayControllerGroup2'), ('CISCO-WAN-MG-MIB', 'mediaGatewayEndpointGroup'), ('CISCO-WAN-MG-MIB', 'mediaGatewayLineGroup'), ('CISCO-WAN-MG-MIB', 'mediaGatewayDomainNameGroup'), ('CISCO-WAN-MG-MIB', 'mediaGatewayControllerResolutionGroup1')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): mg_mib_compliance2 = mgMIBCompliance2.setStatus('deprecated') mg_mib_compliance3 = module_compliance((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 1, 4)).setObjects(('CISCO-WAN-MG-MIB', 'mediaGatewayGroup'), ('CISCO-WAN-MG-MIB', 'mediaGatewayControllerGroup2'), ('CISCO-WAN-MG-MIB', 'mediaGatewayEndpointGroup'), ('CISCO-WAN-MG-MIB', 'mediaGatewayLineGroup'), ('CISCO-WAN-MG-MIB', 'mediaGatewayDomainNameGroup'), ('CISCO-WAN-MG-MIB', 'mediaGatewayControllerResolutionGroup1'), ('CISCO-WAN-MG-MIB', 'mediaGatewayEndptRepetitionGroup')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): mg_mib_compliance3 = mgMIBCompliance3.setStatus('current') media_gateway_group = object_group((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2, 1)).setObjects(('CISCO-WAN-MG-MIB', 'mgName'), ('CISCO-WAN-MG-MIB', 'mgAdministrativeState'), ('CISCO-WAN-MG-MIB', 'mgAdministrativeStateControl'), ('CISCO-WAN-MG-MIB', 'mgShutdownGraceTime'), ('CISCO-WAN-MG-MIB', 'mgProtocolName')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): media_gateway_group = mediaGatewayGroup.setStatus('current') media_gateway_controller_group = object_group((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2, 2)).setObjects(('CISCO-WAN-MG-MIB', 'maxConcurrentMgcs'), ('CISCO-WAN-MG-MIB', 'mgcName'), ('CISCO-WAN-MG-MIB', 'mgcDnsResolution'), ('CISCO-WAN-MG-MIB', 'mgcAssociationState'), ('CISCO-WAN-MG-MIB', 'mgcAssociationStateControl'), ('CISCO-WAN-MG-MIB', 'mgcUnassociationPolicy'), ('CISCO-WAN-MG-MIB', 'mgcCommLossUnassociationTimeout'), ('CISCO-WAN-MG-MIB', 'mgcRowStatus'), ('CISCO-WAN-MG-MIB', 'mgcProtocolRowStatus')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): media_gateway_controller_group = mediaGatewayControllerGroup.setStatus('deprecated') media_gateway_endpoint_group = object_group((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2, 3)).setObjects(('CISCO-WAN-MG-MIB', 'mgEndpointCreationPolicy'), ('CISCO-WAN-MG-MIB', 'mgEndpointName'), ('CISCO-WAN-MG-MIB', 'mgEndpointLineNumber'), ('CISCO-WAN-MG-MIB', 'mgEndpointSpeed'), ('CISCO-WAN-MG-MIB', 'mgEndpointState'), ('CISCO-WAN-MG-MIB', 'mgEndpointChannelMap'), ('CISCO-WAN-MG-MIB', 'mgEndpointRowStatus')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): media_gateway_endpoint_group = mediaGatewayEndpointGroup.setStatus('current') media_gateway_line_group = object_group((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2, 4)).setObjects(('CISCO-WAN-MG-MIB', 'channelAssignment'), ('CISCO-WAN-MG-MIB', 'lineName')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): media_gateway_line_group = mediaGatewayLineGroup.setStatus('current') media_gateway_controller_resolution_group = object_group((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2, 5)).setObjects(('CISCO-WAN-MG-MIB', 'mgcResolutionName'), ('CISCO-WAN-MG-MIB', 'mgcResolutionIpAddress'), ('CISCO-WAN-MG-MIB', 'mgcResolutionCommState'), ('CISCO-WAN-MG-MIB', 'mgcResolutionPreference'), ('CISCO-WAN-MG-MIB', 'mgcResolutionRowStatus')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): media_gateway_controller_resolution_group = mediaGatewayControllerResolutionGroup.setStatus('deprecated') media_gateway_controller_group1 = object_group((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2, 6)).setObjects(('CISCO-WAN-MG-MIB', 'maxConcurrentMgcs'), ('CISCO-WAN-MG-MIB', 'mgcName'), ('CISCO-WAN-MG-MIB', 'mgcAssociationState'), ('CISCO-WAN-MG-MIB', 'mgcAssociationStateControl'), ('CISCO-WAN-MG-MIB', 'mgcUnassociationPolicy'), ('CISCO-WAN-MG-MIB', 'mgcCommLossUnassociationTimeout'), ('CISCO-WAN-MG-MIB', 'mgcRowStatus'), ('CISCO-WAN-MG-MIB', 'mgcProtocolRowStatus')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): media_gateway_controller_group1 = mediaGatewayControllerGroup1.setStatus('deprecated') media_gateway_controller_resolution_group1 = object_group((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2, 7)).setObjects(('CISCO-WAN-MG-MIB', 'mgcResolutionName'), ('CISCO-WAN-MG-MIB', 'mgcResolutionIpAddress'), ('CISCO-WAN-MG-MIB', 'mgcResolutionCommState'), ('CISCO-WAN-MG-MIB', 'mgcResolutionPreference'), ('CISCO-WAN-MG-MIB', 'mgcResolutionRowStatus'), ('CISCO-WAN-MG-MIB', 'mgcDnsResolutionFlag')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): media_gateway_controller_resolution_group1 = mediaGatewayControllerResolutionGroup1.setStatus('current') media_gateway_domain_name_group = object_group((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2, 8)).setObjects(('CISCO-WAN-MG-MIB', 'mgDomainName'), ('CISCO-WAN-MG-MIB', 'mgDnsResolutionType'), ('CISCO-WAN-MG-MIB', 'mgDomainNameRowStatus')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): media_gateway_domain_name_group = mediaGatewayDomainNameGroup.setStatus('current') media_gateway_controller_group2 = object_group((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2, 9)).setObjects(('CISCO-WAN-MG-MIB', 'maxConcurrentMgcs'), ('CISCO-WAN-MG-MIB', 'mgcName'), ('CISCO-WAN-MG-MIB', 'mgcRowStatus')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): media_gateway_controller_group2 = mediaGatewayControllerGroup2.setStatus('current') media_gateway_endpt_repetition_group = object_group((1, 3, 6, 1, 4, 1, 351, 150, 10, 3, 2, 10)).setObjects(('CISCO-WAN-MG-MIB', 'mgEndpointRepetition')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): media_gateway_endpt_repetition_group = mediaGatewayEndptRepetitionGroup.setStatus('current') mibBuilder.exportSymbols('CISCO-WAN-MG-MIB', mgEndpointCreationPolicy=mgEndpointCreationPolicy, mgProtocolNumber=mgProtocolNumber, mgcNumber=mgcNumber, mediaGatewayGroup=mediaGatewayGroup, mgcResolutionIpAddress=mgcResolutionIpAddress, mgEndpointSpeed=mgEndpointSpeed, mgcDnsResolution=mgcDnsResolution, mgAdministrativeStateControl=mgAdministrativeStateControl, mgMIBConformance=mgMIBConformance, mgName=mgName, mgDomainNameTable=mgDomainNameTable, mgMIBCompliance3=mgMIBCompliance3, mgMIBCompliance=mgMIBCompliance, lineAssignmentEntry=lineAssignmentEntry, mgcTable=mgcTable, mediaGatewayControllerResolutionGroup=mediaGatewayControllerResolutionGroup, mgEndpointExtTable=mgEndpointExtTable, mgEndpointExtEntry=mgEndpointExtEntry, mgcProtocolRowStatus=mgcProtocolRowStatus, mgcAssociationState=mgcAssociationState, mgcDnsResolutionFlag=mgcDnsResolutionFlag, mediaGateway=mediaGateway, mediaGatewayEndpoint=mediaGatewayEndpoint, mgSupportedProtocolTable=mgSupportedProtocolTable, mgDomainName=mgDomainName, ciscoWanMgMIBObjects=ciscoWanMgMIBObjects, mgEndpointLineNumber=mgEndpointLineNumber, mgMIBCompliance2=mgMIBCompliance2, channelAssignment=channelAssignment, mgMIBCompliance1=mgMIBCompliance1, mediaGatewayDomainNameGroup=mediaGatewayDomainNameGroup, mgcResolutionPreference=mgcResolutionPreference, mgcProtocolEntry=mgcProtocolEntry, mediaGatewayLine=mediaGatewayLine, mgcResolutionName=mgcResolutionName, mediaGatewayLineGroup=mediaGatewayLineGroup, mediaGatewayControllerGroup=mediaGatewayControllerGroup, mgEndpointRowStatus=mgEndpointRowStatus, mgDomainNameEntry=mgDomainNameEntry, mediaGatewayDomainName=mediaGatewayDomainName, mgEndpointRepetition=mgEndpointRepetition, mgDomainNameIndex=mgDomainNameIndex, mgShutdownGraceTime=mgShutdownGraceTime, mgcEntry=mgcEntry, mgcAssociationStateControl=mgcAssociationStateControl, mgAdministrativeState=mgAdministrativeState, mgcRowStatus=mgcRowStatus, mgEndpointChannelMap=mgEndpointChannelMap, mgDomainNameRowStatus=mgDomainNameRowStatus, mgcUnassociationPolicy=mgcUnassociationPolicy, mediaGatewayControllerGroup1=mediaGatewayControllerGroup1, ciscoWanMgMIB=ciscoWanMgMIB, mediaGatewayEndpointGroup=mediaGatewayEndpointGroup, mediaGatewayController=mediaGatewayController, mediaGatewayControllerResolution=mediaGatewayControllerResolution, mgcResolutionCommState=mgcResolutionCommState, mgcResolutionRowStatus=mgcResolutionRowStatus, mediaGatewayControllerGroup2=mediaGatewayControllerGroup2, mgProtocolName=mgProtocolName, mgSupportedProtocolEntry=mgSupportedProtocolEntry, mgEndpointEntry=mgEndpointEntry, mgDnsResolutionType=mgDnsResolutionType, mgEndpointName=mgEndpointName, mgcResolutionTable=mgcResolutionTable, mgEndpointState=mgEndpointState, mediaGatewayControllerResolutionGroup1=mediaGatewayControllerResolutionGroup1, mgcProtocolTable=mgcProtocolTable, lineAssignmentTable=lineAssignmentTable, PYSNMP_MODULE_ID=ciscoWanMgMIB, mgcResolutionIndex=mgcResolutionIndex, mgcCommLossUnassociationTimeout=mgcCommLossUnassociationTimeout, mgcResolutionEntry=mgcResolutionEntry, mgMIBGroups=mgMIBGroups, mgEndpointNumber=mgEndpointNumber, mgcName=mgcName, mgMIBCompliances=mgMIBCompliances, mediaGatewayEndptRepetitionGroup=mediaGatewayEndptRepetitionGroup, mgEndpointTable=mgEndpointTable, maxConcurrentMgcs=maxConcurrentMgcs, lineName=lineName, lineNumber=lineNumber)
#!/usr/local/bin/python3.3 def echo(message): print(message) return echo('Direct Call') x = echo x('Indirect Call') def indirect(func, arg): func(arg) indirect(echo, "Argument Call") schedule = [(echo, 'Spam'), (echo, 'Ham')] for (func, arg) in schedule: func(arg) def make(label): def echo(message): print(label + ': ' + message) return echo F = make('Spam') F('Eggs') F('Ham') def func(a): b = 'spam' return b * a print(func(8)) print(dir(func)) func.handles = 'Bottom-Press' func.count = 0 print(dir(func)) def func(a: 'spam', b: (1, 10), c: float) -> int: return a+b+c print(func.__annotations__)
def echo(message): print(message) return echo('Direct Call') x = echo x('Indirect Call') def indirect(func, arg): func(arg) indirect(echo, 'Argument Call') schedule = [(echo, 'Spam'), (echo, 'Ham')] for (func, arg) in schedule: func(arg) def make(label): def echo(message): print(label + ': ' + message) return echo f = make('Spam') f('Eggs') f('Ham') def func(a): b = 'spam' return b * a print(func(8)) print(dir(func)) func.handles = 'Bottom-Press' func.count = 0 print(dir(func)) def func(a: 'spam', b: (1, 10), c: float) -> int: return a + b + c print(func.__annotations__)
command = input() numbers = [int(x) for x in input().split()] parity = 0 if command == 'Even' else 1 result = sum(filter(lambda x: x % 2 == parity, numbers)) print(result * len(numbers))
command = input() numbers = [int(x) for x in input().split()] parity = 0 if command == 'Even' else 1 result = sum(filter(lambda x: x % 2 == parity, numbers)) print(result * len(numbers))
class ListNode: def __init__(self, data, link=None): self.data = data self.link = link
class Listnode: def __init__(self, data, link=None): self.data = data self.link = link
temperature =int(input("Enter Temperature: ")) if temperature > 30: print("It's a hot day") elif temperature < 10: print("It's a cold day") else: print("it's neither hot nor cold")
temperature = int(input('Enter Temperature: ')) if temperature > 30: print("It's a hot day") elif temperature < 10: print("It's a cold day") else: print("it's neither hot nor cold")
TRACKS = 'tracks' STUDIES = 'studies' EXPERIMENTS = 'experiments' SAMPLES = 'samples' SCHEMA_URL_PART1 = 'https://raw.githubusercontent.com/fairtracks/fairtracks_standard/' SCHEMA_URL_PART2 = '/current/json/schema/fairtracks.schema.json' TOP_SCHEMA_FN = 'fairtracks.schema.json' TERM_ID = 'term_id' ONTOLOGY = 'ontology' TERM_LABEL = 'term_label' DOC_ONTOLOGY_VERSIONS_NAMES = {'doc_info': 'doc_ontology_versions', 'document': 'ontology_versions'} HAS_AUGMENTED_METADATA = {'doc_info': 'has_augmented_metadata', 'document': 'has_augmented_metadata'} FILE_NAME = 'file_name' FILE_URL = 'file_url' ITEMS = 'items' PROPERTIES = 'properties' VERSION_IRI = '<owl:versionIRI rdf:resource="' DOAP_VERSION = '<doap:Version>' EDAM_ONTOLOGY = 'http://edamontology.org/' IDENTIFIERS_API_URL = 'http://resolver.api.identifiers.org/' NCBI_TAXONOMY_RESOLVER_URL = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=taxonomy&retmode=json' SAMPLE_TYPE_MAPPING = {'http://purl.obolibrary.org/obo/NCIT_C12508':['sample_type', 'cell_type'], 'http://purl.obolibrary.org/obo/NCIT_C12913':['sample_type', 'abnormal_cell_type'], 'http://purl.obolibrary.org/obo/NCIT_C16403':['sample_type', 'cell_line'], 'http://purl.obolibrary.org/obo/NCIT_C103199':['sample_type', 'organism_part']} SAMPLE_ORGANISM_PART_PATH = ['sample_type', 'organism_part', 'term_label'] SAMPLE_DETAILS_PATH = ['sample_type', 'details'] BIOSPECIMEN_CLASS_PATH = ['biospecimen_class', 'term_id'] SAMPLE_TYPE_SUMMARY_PATH = ['sample_type', 'summary'] EXPERIMENT_TARGET_PATHS = [['target', 'sequence_feature', 'term_label'], ['target', 'gene_id'], ['target', 'gene_product_type', 'term_label'], ['target', 'macromolecular_structure', 'term_label'], ['target', 'phenotype', 'term_label']] TARGET_DETAILS_PATH = ['target', 'details'] TARGET_SUMMARY_PATH = ['target', 'summary'] TRACK_FILE_URL_PATH = ['file_url'] SPECIES_ID_PATH = ['species_id'] SPECIES_NAME_PATH = ['species_name'] ONTOLOGY_FOLDER_PATH = 'ontologies' RESOLVED_RESOURCES = 'resolvedResources'
tracks = 'tracks' studies = 'studies' experiments = 'experiments' samples = 'samples' schema_url_part1 = 'https://raw.githubusercontent.com/fairtracks/fairtracks_standard/' schema_url_part2 = '/current/json/schema/fairtracks.schema.json' top_schema_fn = 'fairtracks.schema.json' term_id = 'term_id' ontology = 'ontology' term_label = 'term_label' doc_ontology_versions_names = {'doc_info': 'doc_ontology_versions', 'document': 'ontology_versions'} has_augmented_metadata = {'doc_info': 'has_augmented_metadata', 'document': 'has_augmented_metadata'} file_name = 'file_name' file_url = 'file_url' items = 'items' properties = 'properties' version_iri = '<owl:versionIRI rdf:resource="' doap_version = '<doap:Version>' edam_ontology = 'http://edamontology.org/' identifiers_api_url = 'http://resolver.api.identifiers.org/' ncbi_taxonomy_resolver_url = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=taxonomy&retmode=json' sample_type_mapping = {'http://purl.obolibrary.org/obo/NCIT_C12508': ['sample_type', 'cell_type'], 'http://purl.obolibrary.org/obo/NCIT_C12913': ['sample_type', 'abnormal_cell_type'], 'http://purl.obolibrary.org/obo/NCIT_C16403': ['sample_type', 'cell_line'], 'http://purl.obolibrary.org/obo/NCIT_C103199': ['sample_type', 'organism_part']} sample_organism_part_path = ['sample_type', 'organism_part', 'term_label'] sample_details_path = ['sample_type', 'details'] biospecimen_class_path = ['biospecimen_class', 'term_id'] sample_type_summary_path = ['sample_type', 'summary'] experiment_target_paths = [['target', 'sequence_feature', 'term_label'], ['target', 'gene_id'], ['target', 'gene_product_type', 'term_label'], ['target', 'macromolecular_structure', 'term_label'], ['target', 'phenotype', 'term_label']] target_details_path = ['target', 'details'] target_summary_path = ['target', 'summary'] track_file_url_path = ['file_url'] species_id_path = ['species_id'] species_name_path = ['species_name'] ontology_folder_path = 'ontologies' resolved_resources = 'resolvedResources'
class Constant(): def __init__(self, value): self._value = value def __call__(self): return self._value y = Constant(5) print((y()))
class Constant: def __init__(self, value): self._value = value def __call__(self): return self._value y = constant(5) print(y())
print(2, type(2)) print(3.5, type(3.5)) print([], type([])) print(True, type(True)) print(None, type(None)) # code to put in a for-each loop for the Pattern Loop Exercise
print(2, type(2)) print(3.5, type(3.5)) print([], type([])) print(True, type(True)) print(None, type(None))
def create_dimension_competitors(cursor): cursor.execute('''CREATE TABLE dimension_competitors ( company_name text, company_permalink text, competitor_name text, competitor_permalink text, extracted_at text )''')
def create_dimension_competitors(cursor): cursor.execute('CREATE TABLE dimension_competitors\n ( company_name text,\n company_permalink text,\n competitor_name text,\n competitor_permalink text,\n extracted_at text\n )')
name_1 = input() name_2 = input() delimiter = input() print(f"{name_1}{delimiter}{name_2}")
name_1 = input() name_2 = input() delimiter = input() print(f'{name_1}{delimiter}{name_2}')
def f(x): for i in reversed([20, 19, 18, 17, 16, 15, 14, 13, 12, 11]): if x % i != 0: return False return True i = 20 while f(i) == False: i += 20 print(i)
def f(x): for i in reversed([20, 19, 18, 17, 16, 15, 14, 13, 12, 11]): if x % i != 0: return False return True i = 20 while f(i) == False: i += 20 print(i)
a=int(input("Enter any number ")) for x in range(1,a+1): print(x)
a = int(input('Enter any number ')) for x in range(1, a + 1): print(x)
def pre_order(root): ret = [] stack, node = [], root while stack or node: if node: ret.append(node.val) stack.append(node) node = node.left else: node = stack.pop() node = node.right return ret def in_order(root): ret = [] stack, node = [], root while stack or node: if node: stack.append(node) node = node.left else: node = stack.pop() ret.append(node.val) node = node.right return ret def post_order(root): ret = [] stack, node = [], root while stack or node: if node: ret.append(node.val) stack.append(node) # move to right first, then reverse its result node = node.right else: node = stack.pop() node = node.left return ret[::-1]
def pre_order(root): ret = [] (stack, node) = ([], root) while stack or node: if node: ret.append(node.val) stack.append(node) node = node.left else: node = stack.pop() node = node.right return ret def in_order(root): ret = [] (stack, node) = ([], root) while stack or node: if node: stack.append(node) node = node.left else: node = stack.pop() ret.append(node.val) node = node.right return ret def post_order(root): ret = [] (stack, node) = ([], root) while stack or node: if node: ret.append(node.val) stack.append(node) node = node.right else: node = stack.pop() node = node.left return ret[::-1]
# Keep a dictionary that has items ordered in a deque structure class DequeDict: # Entry that holds the key, value class DequeEntry: def __init__(self, key, value): self.key = key self.value = value self.prev = None self.next = None # Helpful for debugging, print key and value def __repr__(self): return "(k={}, v={})".format(self.key, self.value) def __init__(self): self.htbl = {} self.head = None self.tail = None # Helpful for debugging, print out entire Deque def __repr__(self): entries = [] entry = self.head while entry: entries.append(entry) entry = entry.next return "<DequeDict({})>".format(entries) # Iterator def __iter__(self): self.current = self.head return self # Next for iterator def __next__(self): if self.current == None: raise StopIteration value = self.current.value self.current = self.current.next return value # For Python2 next = __next__ def __contains__(self, key): return key in self.htbl def __len__(self): return len(self.htbl) # value = dequeDict[key] def __getitem__(self, key): return self.htbl[key].value # dequeDict[key] = value # NOTE: pushes a new item, updates an old item in the Deque def __setitem__(self, key, value): if key in self.htbl: self.__update(key, value) else: self.__push(key, value) # del dequeDict[key] # Just removes the item completely as expected def __delitem__(self, key): self.__remove(key) # Get first item # NOTE: LRU since queue is FIFO def first(self): return self.head.value # Push (key, value) as first in deque def pushFirst(self, key, value): assert (key not in self.htbl) entry = self.DequeEntry(key, value) self.htbl[key] = entry headEntry = self.head if headEntry: headEntry.prev = entry entry.next = headEntry else: self.tail = entry self.head = entry # Remove and return first item # NOTE: LRU since queue is FIFO def popFirst(self): first = self.head self.__remove(first.key) return first.value # Get last item # NOTE: MRU since queue is FIFO def last(self): return self.tail.value # Remove and return last item # NOTE: MRU since queue is FIFO def popLast(self): last = self.tail self.__remove(last.key) return last.value # Remove the entry with the given key completely from DequeDict def __remove(self, key): assert (key in self.htbl) entry = self.htbl[key] prevEntry = entry.prev nextEntry = entry.next if prevEntry: prevEntry.next = nextEntry else: self.head = nextEntry if nextEntry: nextEntry.prev = prevEntry else: self.tail = prevEntry del self.htbl[key] # Insert a new item into the DequeDict def __push(self, key, value): assert (key not in self.htbl) entry = self.DequeEntry(key, value) self.htbl[key] = entry tailEntry = self.tail if tailEntry: tailEntry.next = entry entry.prev = tailEntry else: self.head = entry self.tail = entry # Update an item that currently exists in the DequeDict def __update(self, key, value): # Just remove and push since it should be very fast anyways self.__remove(key) self.__push(key, value) # Some quick test code to make sure this works if __name__ == '__main__': dd = DequeDict() l = [1, 2, 3, 4, 5, 6] for e in l: dd[len(l) - e] = e for e, f in zip(l, dd): assert (e == f) for e in l: f = dd.popFirst() assert (e == f) for e in l: dd[len(l) - e] = e for e in l[::-1]: f = dd.popLast() assert (e == f) for e in l: dd[len(l) - e] = e dd[3] = -1 dd[5] = 7 del dd[1] assert (dd.popFirst() == 2) assert (dd.popFirst() == 4) assert (dd.popFirst() == 6) assert (dd.popFirst() == -1) assert (dd.popFirst() == 7)
class Dequedict: class Dequeentry: def __init__(self, key, value): self.key = key self.value = value self.prev = None self.next = None def __repr__(self): return '(k={}, v={})'.format(self.key, self.value) def __init__(self): self.htbl = {} self.head = None self.tail = None def __repr__(self): entries = [] entry = self.head while entry: entries.append(entry) entry = entry.next return '<DequeDict({})>'.format(entries) def __iter__(self): self.current = self.head return self def __next__(self): if self.current == None: raise StopIteration value = self.current.value self.current = self.current.next return value next = __next__ def __contains__(self, key): return key in self.htbl def __len__(self): return len(self.htbl) def __getitem__(self, key): return self.htbl[key].value def __setitem__(self, key, value): if key in self.htbl: self.__update(key, value) else: self.__push(key, value) def __delitem__(self, key): self.__remove(key) def first(self): return self.head.value def push_first(self, key, value): assert key not in self.htbl entry = self.DequeEntry(key, value) self.htbl[key] = entry head_entry = self.head if headEntry: headEntry.prev = entry entry.next = headEntry else: self.tail = entry self.head = entry def pop_first(self): first = self.head self.__remove(first.key) return first.value def last(self): return self.tail.value def pop_last(self): last = self.tail self.__remove(last.key) return last.value def __remove(self, key): assert key in self.htbl entry = self.htbl[key] prev_entry = entry.prev next_entry = entry.next if prevEntry: prevEntry.next = nextEntry else: self.head = nextEntry if nextEntry: nextEntry.prev = prevEntry else: self.tail = prevEntry del self.htbl[key] def __push(self, key, value): assert key not in self.htbl entry = self.DequeEntry(key, value) self.htbl[key] = entry tail_entry = self.tail if tailEntry: tailEntry.next = entry entry.prev = tailEntry else: self.head = entry self.tail = entry def __update(self, key, value): self.__remove(key) self.__push(key, value) if __name__ == '__main__': dd = deque_dict() l = [1, 2, 3, 4, 5, 6] for e in l: dd[len(l) - e] = e for (e, f) in zip(l, dd): assert e == f for e in l: f = dd.popFirst() assert e == f for e in l: dd[len(l) - e] = e for e in l[::-1]: f = dd.popLast() assert e == f for e in l: dd[len(l) - e] = e dd[3] = -1 dd[5] = 7 del dd[1] assert dd.popFirst() == 2 assert dd.popFirst() == 4 assert dd.popFirst() == 6 assert dd.popFirst() == -1 assert dd.popFirst() == 7
# # Copyright (C) 2000-2005 by Yasushi Saito (yasushi.saito@gmail.com) # # Jockey is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2, or (at your option) any # later version. # # Jockey is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # def generate_doc(name, suffix="", append = 0): if append: fp = open(name + "_doc.py", "a+") else: fp = open(name + "_doc.py", "w") fp.write("# automatically generated by generate_docs.py.\n") fp.write("doc" + suffix + "=\" \"\n") fp.close() generate_doc( "area") generate_doc( "arrow") generate_doc( "axis", "_x") generate_doc( "axis", "_y", 1) generate_doc( "bar_plot") generate_doc( "color") generate_doc( "error_bar","_1") generate_doc( "error_bar", "_2", 1) generate_doc( "error_bar", "_3", 1) generate_doc( "error_bar", "_4", 1) generate_doc( "error_bar", "_5", 1) generate_doc( "error_bar", "_6", 1) generate_doc( "fill_style") generate_doc("line_plot") generate_doc("pie_plot") generate_doc("text_box") generate_doc("range_plot") generate_doc("legend") generate_doc("legend", "_entry", 1) generate_doc("line_style") generate_doc("tick_mark")
def generate_doc(name, suffix='', append=0): if append: fp = open(name + '_doc.py', 'a+') else: fp = open(name + '_doc.py', 'w') fp.write('# automatically generated by generate_docs.py.\n') fp.write('doc' + suffix + '=" "\n') fp.close() generate_doc('area') generate_doc('arrow') generate_doc('axis', '_x') generate_doc('axis', '_y', 1) generate_doc('bar_plot') generate_doc('color') generate_doc('error_bar', '_1') generate_doc('error_bar', '_2', 1) generate_doc('error_bar', '_3', 1) generate_doc('error_bar', '_4', 1) generate_doc('error_bar', '_5', 1) generate_doc('error_bar', '_6', 1) generate_doc('fill_style') generate_doc('line_plot') generate_doc('pie_plot') generate_doc('text_box') generate_doc('range_plot') generate_doc('legend') generate_doc('legend', '_entry', 1) generate_doc('line_style') generate_doc('tick_mark')
class Solution: def minTimeToVisitAllPoints(self, points: List[List[int]]) -> int: if not points or len(points) == 1: return 0 time = 0 for index,cur_point in enumerate(points): if index == len(points) - 1: return time next_point = points[index+1] cross_path = min(abs(cur_point[0] - next_point[0]),abs(cur_point[1] - next_point[1])) straight_path = max(abs(cur_point[0] - next_point[0]),abs(cur_point[1] - next_point[1])) - cross_path time += cross_path +straight_path
class Solution: def min_time_to_visit_all_points(self, points: List[List[int]]) -> int: if not points or len(points) == 1: return 0 time = 0 for (index, cur_point) in enumerate(points): if index == len(points) - 1: return time next_point = points[index + 1] cross_path = min(abs(cur_point[0] - next_point[0]), abs(cur_point[1] - next_point[1])) straight_path = max(abs(cur_point[0] - next_point[0]), abs(cur_point[1] - next_point[1])) - cross_path time += cross_path + straight_path