content
stringlengths
7
1.05M
class Karta: def __init__(self, hodnota, barva, licem_nahoru): self.hodnota = hodnota self.barva = barva self.licem_nahoru = licem_nahoru def __str__(self): if not self.licem_nahoru: return '[???]' barvy = {'Pi': '♠ ', 'Sr': ' ♥', 'Ka': ' ♦', 'Kr':'♣ '} znak_barvy = barvy[self.barva] hodnoty = {1: 'A', 10: 'X', 11: 'J', 12: 'Q', 13: 'K'} znak_hodnoty = hodnoty.get(self.hodnota, str(self.hodnota)) return '[{}{}]'.format(znak_hodnoty, znak_barvy) def otoc_licem_nahoru(self): self.licem_nahoru = True def otoc_licem_dolu(self): self.licem_nahoru = False karta = Karta(3, 'Sr', licem_nahoru=True) print(karta.hodnota) # → 3 print(karta.barva) # → 'Sr' print(karta.licem_nahoru) # → True print(karta) # → [3 ♥] karta.otoc_licem_dolu() print(karta) # → [???] karta.otoc_licem_nahoru() print(karta) # → [3 ♥]
languages = { 54: "af", 28: "sq", 522: "am", 1: "ar", 5121: "ar-AL", 15361: "ar-BA", 3073: "ar-EG", 2049: "ar-IQ", 11265: "ar-JO", 13313: "ar-KU", 12289: "ar-LE", 4097: "ar-LI", 6145: "ar-MO", 8193: "ar-OM", 16385: "ar-QA", 1025: "ar-SA", 10241: "ar-SY", 7169: "ar-TU", 14337: "ar-UA", 9217: "ar-YE", 43: "hy", 77: "as", 44: "az", 2092: "az-CY", 1068: "az-LA", 45: "eu", 35: "be", 69: "bn", 517: "bs", 2: "bg", 523: "my", 36363: "my-BR", 3: "ca", 4: "zh", 3076: "zh-HK", 5124: "zh-MA", 34820: "zh-MN", 2052: "zh-PR", 32772: "zh-SM", 4100: "zh-SI", 1028: "zh-TA", 31748: "zh-HT", 33796: "zh-DO", 518: "hr", 5: "cs", 6: "da", 19: "nl", 2067: "nl-BE", 1043: "nl-NL", 9: "en", 3081: "en-AU", 10249: "en-BE", 4105: "en-CA", 9225: "en-CB", 6153: "en-IR", 8201: "en-JA", 5129: "en-NZ", 13321: "en-PH", 33801: "en-SO", 7177: "en-SA", 32777: "en-TG", 11273: "en-TR", 2057: "en-GB", 1033: "en-US", 12297: "en-ZI", 37: "et", 56: "fo", 41: "fa", 525: "fi-IL", 11: "fi", 12: "fr", 2060: "fr-BE", 3084: "fr-CA", 5132: "fr-LU", 6156: "fr-MO", 1036: "fr-FR", 4108: "fr-SW", 514: "gd", 55: "ka", 7: "de", 3079: "de-AU", 5127: "de-LI", 4103: "de-LU", 1031: "de-DE", 2055: "de-SW", 8: "el", 513: "gl", 71: "gu", 531: "ht", 13: "he", 57: "hi", 14: "hu", 15: "is", 33: "id", 32801: "id-BA", 1057: "id-ID", 16: "it", 1040: "it-IT", 2064: "it-SW", 17: "ja", 75: "kn", 96: "ks", 2144: "ks-IN", 63: "kk", 520: "kh", 33288: "kh-KC", 87: "ki", 18: "ko", 2066: "ko-JO", 1042: "ko-KO", 37906: "ko-RO", 38: "lv", 39: "lt", 2087: "lt-CL", 1063: "lt-LT", 47: "mk", 62: "ms", 2110: "ms-BR", 1086: "ms-MS", 76: "ml", 515: "ml-LT", 88: "ma", 78: "mr", 97: "ne", 2145: "ne-IN", 20: "nb", 1044: "nb-NO", 2068: "nn-NO", 72: "or", 516: "ps", 33284: "ps-AF", 34308: "ps-DW", 21: "pl", 22: "pt", 1046: "pt-BR", 2070: "pt-ST", 70: "pa", 24: "ro", 25: "ru", 79: "sa", 26: "sr", 1050: "sr-YU", 3098: "sr-CY", 2074: "sr-LA", 89: "sd", 519: "si", 27: "sk", 36: "sl", 526: "st", 10: "es", 11274: "es-AR", 16394: "es-NO", 13322: "es-CH", 9226: "es-CO", 5130: "es-CR", 7178: "es-DR", 12298: "es-EQ", 17418: "es-EL", 4106: "es-GU", 18442: "es-HO", 38922: "es-IN", 2058: "es-ME", 3082: "es-MS", 19466: "es-NI", 6154: "es-PA", 15370: "es-PA", 10250: "es-PE", 20490: "es-PR", 36874: "es-IN", 1034: "es-ES", 14346: "es-UR", 8202: "es-VE", 65: "sw", 29: "sv", 2077: "sv-FI", 1053: "sv-SV", 73: "ta", 68: "tt", 74: "te", 30: "th", 39966: "th-LO", 1054: "th-TH", 31: "tr", 34: "uk", 32: "ur", 2080: "ur-IN", 1056: "ur-PA", 67: "uz", 2115: "uz-CY", 1091: "uz-LA", 42: "vi", 512: "cy", 524: "xh", 521: "zu" }
OBSTACLE_SIZE = 45 ROBOT_SIZE = 45 GOAL_SIZE = 45 GOAL_POS_X = 50 GOAL_POS_Y = 50 START_POS_X = 100 START_POS_Y = 700 BOARD_SIZE = 800 STEP = 10 INFINITY = 100000
print("To find the number of vowles in a given string") count = 0 string=input("enter the string:") for i in string: if i in "aeiouAEIOU": count=count+1 print("the vowels in the given string are:",i) print("the total numbr of vowles are:",count)
##Removal of collisions of knolls with large boulders=name ##layerofcliffspolygons=vector ##radiusofknoll=number3.0 ##layerofsmallknollspoints=vector ##radiusoflargeboulders=number4.5 ##knolls=output vector outputs_QGISFIXEDDISTANCEBUFFER_2=processing.runalg('qgis:fixeddistancebuffer', layerofcliffspolygons,radiusoflargeboulders,5.0,False,None) outputs_QGISFIXEDDISTANCEBUFFER_1=processing.runalg('qgis:fixeddistancebuffer', layerofsmallknollspoints,radiusofknoll,5.0,False,None) outputs_QGISEXTRACTBYLOCATION_1=processing.runalg('qgis:extractbylocation', outputs_QGISFIXEDDISTANCEBUFFER_1['OUTPUT'],outputs_QGISFIXEDDISTANCEBUFFER_2['OUTPUT'],['intersects'],0.1,None) outputs_QGISDIFFERENCE_1=processing.runalg('qgis:difference', outputs_QGISFIXEDDISTANCEBUFFER_1['OUTPUT'],outputs_QGISEXTRACTBYLOCATION_1['OUTPUT'],True,None) outputs_QGISPOLYGONCENTROIDS_1=processing.runalg('qgis:polygoncentroids', outputs_QGISDIFFERENCE_1['OUTPUT'],knolls)
# Copyright (c) Sandeep Mistry. All rights reserved. # Licensed under the MIT license. See LICENSE file in the project root for full license information. { 'targets': [ { 'target_name': 'class', 'conditions': [ ['OS=="mac"', { 'sources': [ 'src/class.mm' ], 'xcode_settings': { 'CLANG_CXX_LIBRARY': 'libc++', 'MACOSX_DEPLOYMENT_TARGET': '10.8' } }] ], 'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"], 'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"], 'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ], "link_settings": { "libraries": ["/System/Library/Frameworks/Foundation.framework"] } }, { 'target_name': 'dispatch', 'conditions': [ ['OS=="mac"', { 'sources': [ 'src/dispatch.cpp' ], 'xcode_settings': { 'CLANG_CXX_LIBRARY': 'libc++', 'MACOSX_DEPLOYMENT_TARGET': '10.8' } }] ], 'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"], 'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"], 'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ] }, { 'target_name': 'dl', 'conditions': [ ['OS=="mac"', { 'sources': [ 'src/dl.cpp' ], 'xcode_settings': { 'CLANG_CXX_LIBRARY': 'libc++', 'MACOSX_DEPLOYMENT_TARGET': '10.8' } }] ], 'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"], 'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"], 'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ] }, { 'target_name': 'objc', 'conditions': [ ['OS=="mac"', { 'sources': [ 'src/objc.mm' ], 'xcode_settings': { 'CLANG_CXX_LIBRARY': 'libc++', 'MACOSX_DEPLOYMENT_TARGET': '10.8' } }] ], 'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"], 'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"], 'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ], "link_settings": { "libraries": ["/System/Library/Frameworks/Foundation.framework"] } }, { 'target_name': 'sel', 'conditions': [ ['OS=="mac"', { 'sources': [ 'src/sel.cpp' ], 'xcode_settings': { 'CLANG_CXX_LIBRARY': 'libc++', 'MACOSX_DEPLOYMENT_TARGET': '10.8' } }] ], 'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"], 'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"], 'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ] } ] }
class Solution: def hammingWeight(self, n: int) -> int: wt = 0 is_non_neg = n >= 0 offset = int(not is_non_neg) n = abs(n) for _ in range(32): if is_non_neg and n == 0: break wt += (n + offset) & 1 n >>= 1 return wt class Solution2: def hammingWeight(self, n: int) -> int: return "{0:032b}".format(abs(n)).count("1" if n >= 0 else "0") if __name__ == "__main__": solver = Solution() solver2 = Solution2() for num in range(-5, 5): print(f"HammingWeight({bin(num)}): {solver.hammingWeight(num)}") print(f"HammingWeight({bin(num)}): {solver2.hammingWeight(num)}")
# Time: O(l * n^2) # Space: O(1) class Solution(object): def findLUSlength(self, strs): """ :type strs: List[str] :rtype: int """ def isSubsequence(a, b): i = 0 for j in range(len(b)): if i >= len(a): break if a[i] == b[j]: i += 1 return i == len(a) strs.sort(key=len, reverse=True) for i in range(len(strs)): all_of = True for j in range(len(strs)): if len(strs[j]) < len(strs[i]): break if i != j and isSubsequence(strs[i], strs[j]): all_of = False break if all_of: return len(strs[i]) return -1
"""This problem was asked by Google. Given a set of distinct positive integers, find the largest subset such that every pair of elements in the subset (i, j) satisfies either i % j = 0 or j % i = 0. For example, given the set [3, 5, 10, 20, 21], you should return [5, 10, 20]. Given [1, 3, 6, 24], return [1, 3, 6, 24]. """
f = open("/share/Ecoli/GCA_000005845.2_ASM584v2_genomic.fna") lines = f.readlines() genome = "" for i in range(1, len(lines)): for j in range(len(lines[i]) - 1): genome = genome + lines[i][j] for i in range(0 , 3): extra = len(genome) - i % 11 fragments = "" fragcount = 0 fraglength = 0 for j in range(i, len(genome) - extra, 11): site = genome[j:j+10]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def f(x): return x * x # map()函数接收两个参数,一个是函数,一个是Iterable,map将传入的函数依次作用到序列的每个元素,并把结果作为新的Iterator返回 r = map(f, [1, 2, 3, 4, 5, 6, 7, 8, 9]) print(list(r)) print() # 把这个list所有数字转为字符串 s = map(str, [1, 2, 3, 4, 5, 6, 7, 8, 9]) print(list(s))
#!/usr/local/bin/python3 """Task The height of a binary search tree is the number of edges between the tree's root and its furthest leaf. You are given a pointer, root, pointing to the root of a binary search tree. Complete the getHeight function provided in your editor so that it returns the height of the binary search tree """ class Node: def __init__(self,data): self.right=self.left=None self.data = data class Solution: def insert(self,root,data): if root==None: return Node(data) else: if data<=root.data: cur=self.insert(root.left,data) root.left=cur else: cur=self.insert(root.right,data) root.right=cur return root def getHeight(self,root): if root.left is None and root.right is None: return 0 elif root.right and root.left: total_right = self.getHeight(root.right) + 1 total_left = self.getHeight(root.left) + 1 if total_right > total_left: return total_right else: return total_left elif root.right: return self.getHeight(root.right) + 1 elif root.left: return self.getHeight(root.left) + 1 T=int(input()) myTree=Solution() root=None for i in range(T): data=int(input()) root=myTree.insert(root,data) height=myTree.getHeight(root) print(height)
# Copyright (c) 2016-2020 Renata Hodovan, Akos Kiss. # # Licensed under the BSD 3-Clause License # <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>. # This file may not be copied, modified, or distributed except # according to those terms. class ZellerSplit(object): """ Splits up the input config into n pieces as used by Zeller in the original reference implementation. The approach works iteratively in n steps, first slicing off a chunk sized 1/n-th of the original config, then slicing off 1/(n-1)-th of the remainder, and so on, until the last piece is halved (always using integers division). """ def __init__(self, n=2): """ :param n: The split ratio used to determine how many parts (subsets) the config to split to (both initially and later on whenever config subsets needs to be re-split). """ self._n = n def __call__(self, subsets): """ :param subsets: List of sets that the current configuration is split to. :return: List of newly split sets. """ config = [c for s in subsets for c in s] length = len(config) n = min(length, len(subsets) * self._n) next_subsets = [] start = 0 for i in range(n): stop = start + (length - start) // (n - i) next_subsets.append(config[start:stop]) start = stop return next_subsets def __str__(self): cls = self.__class__ return '%s.%s(n=%s)' % (cls.__module__, cls.__name__, self._n) class BalancedSplit(object): """ Slightly different version of Zeller's split. This version keeps the split balanced by distributing the residuals of the integer division among all chunks. This way, the size of the chunks in the resulting split is not monotonous. """ def __init__(self, n=2): """ :param n: The split ratio used to determine how many parts (subsets) the config to split to (both initially and later on whenever config subsets needs to be re-split). """ self._n = n def __call__(self, subsets): """ :param subsets: List of sets that the current configuration is split to. :return: List of newly split sets. """ config = [c for s in subsets for c in s] length = len(config) n = min(length, len(subsets) * self._n) return [config[length * i // n:length * (i + 1) // n] for i in range(n)] def __str__(self): cls = self.__class__ return '%s.%s(n=%s)' % (cls.__module__, cls.__name__, self._n) # Aliases for split classes to help their identification in CLI. zeller = ZellerSplit balanced = BalancedSplit
# -*- coding: utf-8 -*- """ Created on Thu May 24 21:26:17 2018 @author: Isik """ class Position: """ Represents position in N dimensions Is designed to be able to have a direction added to it. -------------------------------------------------------------------------- properties -------------------------------------------------------------------------- coordinates: List of integers Each integer represents a position in space. The index + 1 is the dime- nsion represented by the value. """ def __init__(self, coordinates = []): self.coordinates = coordinates[:] def __add__(self, direction): """ Addition definition for position NOTE: is only supposed to have a direction type object used here. """ localCoordinates = self.coordinates[:] for i in range( len(localCoordinates), len(direction.directionalCoordinates) ): localCoordinates.append(0) for index, dirCoord in enumerate(direction.directionalCoordinates): localCoordinates[index] += dirCoord return Position(localCoordinates) def __eq__(self, other): for cSelf, cOther in zip(self.coordinates, other.coordinates): if cSelf != cOther: return False return True
"""Take 2 strings s1 and s2 including only letters from ato z. Return a new sorted string, the longest possible, containing distinct letters, each taken only once - coming from s1 or s2. === Examples: === a = "xyaabbbccccdefww" b = "xxxxyyyyabklmopq" longest(a, b) -> "abcdefklmopqwxy" a = "abcdefghijklmnopqrstuvwxyz" longest(a, a) -> "abcdefghijklmnopqrstuvwxyz" """ def longest(s1: str, s2: str) -> str: union_set = set(s1 + s2) return ''.join(sorted(list(union_set)))
def hrs2min(x): return x * 60 def min2sec(x): return x * 60 def SEC_TO_HR(x): return x / 3600.0 # Kelvin to Celcius def check_range(value, min_val, max_val, descrip): """ Check the range of the value Args: value: value to check min_val: minimum value max_val: maximum value descrip: short description of input Returns: True if within range """ if (value < min_val) or (value > max_val): raise ValueError("%s (%f) out of range: %f to %f", descrip, value, min_val, max_val) return True
def test(): a = {'foo': 'bar'} print(a) print(a['foo']) b = {'x':'y'} a.update(b) print(a) keys = a.keys() print(keys) vals = a.values() print(vals) test()
def process(s): n = s.find(";") if n > 0: left = s[:n]+(" " * 64) s = left[:34]+s[n:] return s f = open("revenge.asm") code = f.readlines() f.close() code = [process(c.rstrip()) for c in code] print("\n".join(code))
# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 load("//bazel_tools:java.bzl", "da_java_library") load("//bazel_tools:javadoc_library.bzl", "javadoc_library") load("//bazel_tools:pkg.bzl", "pkg_empty_zip") load("//bazel_tools:pom_file.bzl", "pom_file") load("//bazel_tools:scala.bzl", "scala_source_jar", "scaladoc_jar") load("@io_bazel_rules_scala//scala:scala.bzl", "scala_library") load("@os_info//:os_info.bzl", "is_windows") load("@rules_pkg//:pkg.bzl", "pkg_tar") load("@rules_proto//proto:defs.bzl", "proto_library") load("@scala_version//:index.bzl", "scala_major_version_suffix") # taken from rules_proto: # https://github.com/stackb/rules_proto/blob/f5d6eea6a4528bef3c1d3a44d486b51a214d61c2/compile.bzl#L369-L393 def get_plugin_runfiles(tool, plugin_runfiles): """Gather runfiles for a plugin. """ files = [] if not tool: return files info = tool[DefaultInfo] if not info: return files if info.files: files += info.files.to_list() if info.default_runfiles: runfiles = info.default_runfiles if runfiles.files: files += runfiles.files.to_list() if info.data_runfiles: runfiles = info.data_runfiles if runfiles.files: files += runfiles.files.to_list() if plugin_runfiles: for target in plugin_runfiles: files += target.files.to_list() return files def _proto_gen_impl(ctx): sources_out = ctx.actions.declare_directory(ctx.attr.name + "-sources") descriptor_set_delim = "\\;" if _is_windows(ctx) else ":" descriptors = [depset for src in ctx.attr.srcs for depset in src[ProtoInfo].transitive_descriptor_sets.to_list()] args = [ "--descriptor_set_in=" + descriptor_set_delim.join([depset.path for depset in descriptors]), "--{}_out={}:{}".format(ctx.attr.plugin_name, ",".join(ctx.attr.plugin_options), sources_out.path), ] plugins = [] plugin_runfiles = [] if ctx.attr.plugin_name not in ["java", "python"]: plugins = [ctx.executable.plugin_exec] plugin_runfiles = get_plugin_runfiles(ctx.attr.plugin_exec, ctx.attr.plugin_runfiles) args += [ "--plugin=protoc-gen-{}={}".format(ctx.attr.plugin_name, ctx.executable.plugin_exec.path), ] inputs = [] for src in ctx.attr.srcs: src_root = src[ProtoInfo].proto_source_root for direct_source in src[ProtoInfo].direct_sources: path = "" # in some cases the paths of src_root and direct_source are only partially # overlapping. the following for loop finds the maximum overlap of these two paths for i in range(len(src_root) + 1): if direct_source.path.startswith(src_root[-i:]): path = direct_source.path[i:] else: # this noop is needed to make bazel happy noop = "" path = direct_source.short_path if not path else path path = path[1:] if path.startswith("/") else path inputs += [path] args += inputs posix = ctx.toolchains["@rules_sh//sh/posix:toolchain_type"] ctx.actions.run_shell( mnemonic = "ProtoGen", outputs = [sources_out], inputs = descriptors + [ctx.executable.protoc] + plugin_runfiles, command = posix.commands["mkdir"] + " -p " + sources_out.path + " && " + ctx.executable.protoc.path + " " + " ".join(args), tools = plugins, ) # since we only have the output directory of the protoc compilation, # we need to find all the files below sources_out and add them to the zipper args file zipper_args_file = ctx.actions.declare_file(ctx.label.name + ".zipper_args") ctx.actions.run_shell( mnemonic = "CreateZipperArgsFile", outputs = [zipper_args_file], inputs = [sources_out], command = "{find} -L {src_path} -type f | {sed} -E 's#^{src_path}/(.*)$#\\1={src_path}/\\1#' | {sort} > {args_file}".format( find = posix.commands["find"], sed = posix.commands["sed"], sort = posix.commands["sort"], src_path = sources_out.path, args_file = zipper_args_file.path, ), progress_message = "zipper_args_file %s" % zipper_args_file.path, ) # Call zipper to create srcjar zipper_args = ctx.actions.args() zipper_args.add("c") zipper_args.add(ctx.outputs.out.path) zipper_args.add("@%s" % zipper_args_file.path) ctx.actions.run( executable = ctx.executable._zipper, inputs = [sources_out, zipper_args_file], outputs = [ctx.outputs.out], arguments = [zipper_args], progress_message = "srcjar %s" % ctx.outputs.out.short_path, ) proto_gen = rule( implementation = _proto_gen_impl, attrs = { "srcs": attr.label_list(providers = [ProtoInfo]), "plugin_name": attr.string(), "plugin_exec": attr.label( cfg = "host", executable = True, ), "plugin_options": attr.string_list(), "plugin_runfiles": attr.label_list( default = [], allow_files = True, ), "protoc": attr.label( default = Label("@com_google_protobuf//:protoc"), cfg = "host", allow_files = True, executable = True, ), "_zipper": attr.label( default = Label("@bazel_tools//tools/zip:zipper"), cfg = "host", executable = True, allow_files = True, ), }, outputs = { "out": "%{name}.srcjar", }, output_to_genfiles = True, toolchains = ["@rules_sh//sh/posix:toolchain_type"], ) def _is_windows(ctx): return ctx.configuration.host_path_separator == ";" def _maven_tags(group, artifact_prefix, artifact_suffix): if group and artifact_prefix: artifact = artifact_prefix + "-" + artifact_suffix return ["maven_coordinates=%s:%s:__VERSION__" % (group, artifact)] else: return [] def _proto_scala_srcs(name, grpc): return [":%s" % name] + ([ "@com_github_googleapis_googleapis//google/rpc:code_proto", "@com_github_googleapis_googleapis//google/rpc:status_proto", "@com_github_grpc_grpc//src/proto/grpc/health/v1:health_proto_descriptor", ] if grpc else []) def _proto_scala_deps(grpc, proto_deps): return [ "@maven//:com_google_protobuf_protobuf_java", "@maven//:com_thesamet_scalapb_lenses_{}".format(scala_major_version_suffix), "@maven//:com_thesamet_scalapb_scalapb_runtime_{}".format(scala_major_version_suffix), ] + ([ "@maven//:com_thesamet_scalapb_scalapb_runtime_grpc_{}".format(scala_major_version_suffix), "@maven//:io_grpc_grpc_api", "@maven//:io_grpc_grpc_core", "@maven//:io_grpc_grpc_protobuf", "@maven//:io_grpc_grpc_stub", ] if grpc else []) + [ "%s_scala" % label for label in proto_deps ] def proto_jars( name, srcs, visibility = None, strip_import_prefix = "", grpc = False, deps = [], proto_deps = [], java_deps = [], scala_deps = [], javadoc_root_packages = [], maven_group = None, maven_artifact_prefix = None, maven_artifact_proto_suffix = "proto", maven_artifact_java_suffix = "java-proto", maven_artifact_scala_suffix = "scala-proto"): # Tarball containing the *.proto files. pkg_tar( name = "%s_tar" % name, srcs = srcs, extension = "tar.gz", strip_prefix = strip_import_prefix, visibility = [":__subpackages__", "//release:__subpackages__"], ) # JAR and source JAR containing the *.proto files. da_java_library( name = "%s_jar" % name, srcs = None, deps = None, runtime_deps = ["%s_jar" % label for label in proto_deps], resources = srcs, resource_strip_prefix = "%s/%s/" % (native.package_name(), strip_import_prefix), tags = _maven_tags(maven_group, maven_artifact_prefix, maven_artifact_proto_suffix), visibility = visibility, ) # An empty Javadoc JAR for uploading the source proto JAR to Maven Central. pkg_empty_zip( name = "%s_jar_javadoc" % name, out = "%s_jar_javadoc.jar" % name, ) # Compiled protobufs. proto_library( name = name, srcs = srcs, strip_import_prefix = strip_import_prefix, visibility = visibility, deps = deps + proto_deps, ) # JAR and source JAR containing the generated Java bindings. native.java_proto_library( name = "%s_java" % name, tags = _maven_tags(maven_group, maven_artifact_prefix, maven_artifact_java_suffix), visibility = visibility, deps = [":%s" % name], ) if maven_group and maven_artifact_prefix: pom_file( name = "%s_java_pom" % name, tags = _maven_tags(maven_group, maven_artifact_prefix, maven_artifact_java_suffix), target = ":%s_java" % name, visibility = visibility, ) if javadoc_root_packages: javadoc_library( name = "%s_java_javadoc" % name, srcs = [":%s_java" % name], root_packages = javadoc_root_packages, deps = ["@maven//:com_google_protobuf_protobuf_java"], ) if not is_windows else None else: # An empty Javadoc JAR for uploading the compiled proto JAR to Maven Central. pkg_empty_zip( name = "%s_java_javadoc" % name, out = "%s_java_javadoc.jar" % name, ) # JAR containing the generated Scala bindings. proto_gen( name = "%s_scala_sources" % name, srcs = _proto_scala_srcs(name, grpc), plugin_exec = "//scala-protoc-plugins/scalapb:protoc-gen-scalapb", plugin_name = "scalapb", plugin_options = ["grpc"] if grpc else [], ) all_scala_deps = _proto_scala_deps(grpc, proto_deps) scala_library( name = "%s_scala" % name, srcs = [":%s_scala_sources" % name], tags = _maven_tags(maven_group, maven_artifact_prefix, maven_artifact_scala_suffix), unused_dependency_checker_mode = "error", visibility = visibility, deps = all_scala_deps, exports = all_scala_deps, ) scala_source_jar( name = "%s_scala_src" % name, srcs = [":%s_scala_sources" % name], ) scaladoc_jar( name = "%s_scala_scaladoc" % name, srcs = [":%s_scala_sources" % name], tags = ["scaladoc"], deps = [], ) if is_windows == False else None if maven_group and maven_artifact_prefix: pom_file( name = "%s_scala_pom" % name, target = ":%s_scala" % name, visibility = visibility, )
def reindent(s, numSpaces): leading_space = numSpaces * ' ' lines = [ leading_space + line.strip() for line in s.splitlines() ] return '\n'.join(lines)
__author__ = "ricksy" __email__ = "ricksy@mailbox.org" __copyright__ = "(c) 2020 ricksy" __version__ = "1.0.0" __title__ = "py1" __description__ = "have not idea" __license__ = "MIT"
initials = [ "b", "c", "ch", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "sh", "t", "w", "x", "y", "z", "zh", ] finals = ['S', 'Sj', 'StS', 'StSj', 'Z', 'Zj', 'a', 'b', 'bj', 'd', 'dj', 'e', 'f', 'g', 'hrd', 'i', 'i2', 'j', 'jA', 'jE', 'jO', 'jU', 'k', 'l', 'lj', 'm', 'mj', 'n', 'nj', 'o', 'p', 'pj', 'r', 'rj', 's', 'sj', 't', 'tS', 'tSj', 'tj', 'ts', 'u', 'v', 'vj', 'x', 'z', 'zj'] valid_symbols = initials + finals + ["rr"]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- class Student(object): def __init__(self): self.name = "Michael" def __getattr__(self, attr): if attr == "score": return 99 if attr == "age": return lambda: 25 raise AttributeError("'Student' object has no attribute '%s'" % attr) s = Student() print(s.name) print(s.score) print(s.age()) # AttributeError: 'Student' object has no attribute 'grade' print(s.grade)
r1 = float(input('Primeiro segmento: ')) r2 = float(input('Segundo segmento: ')) r3 = float(input('Terceiro segmento: ')) if (r1 < r2 + r3) and (r2 < r1 + r3) and (r3 < r1 + r2): print('\033[32mOs segmentos acima podem formar um triângulo.\033[m') if r1 == r2 and r1 == r3: print('O triângulo formado será um \033[1;34mEquilátero\033[m, que possui todos os seus segmentos iguais!') elif r1 == r2 or r1 == r3: print('O triângulo formado será um \033[1;35mIsóceles\033[m, que possui dois dos seus segmentos iguais!') else: print('O triângulo formado será um \033[1;36mEscaleno\033[m, que possui todos os seus segmentos diferentes!') else: print('\033[31mOs segmentos acima não podem formar um triângulo.\033[m')
# Conversao de temperatura cel = float(input('Informe a temperatura em °C: ')) far = cel * 1.8 + 32 print(f'{cel}°C equivale a {far}°F')
while True: try: n = int(input()) app_list = input().strip().split() tick_num = int(input()) tick_list = input().strip().split() invalid = 0 tick_dict = {} for app in app_list: tick_dict[app] = 0 for tick in tick_list: if tick in tick_dict: tick_dict[tick] += 1 else: invalid += 1 for app in app_list: print(app+" : "+str(tick_dict[app])) print("Invalid : "+str(invalid)) except: break
""" This file contains the implementation of a 'left-leaning' Red Black Binary Search Tree (LLRBT). The implementation is based on the one described in the book 'Algorithms Fourth Edition' by Robert Sedgewick and Kevin Wayne. A LLRBT is a Tree in which every Node have one of two colors: red or black. The color of a Node represents the color of the link between the Node and its parent. Also, a LLRBT must satisfy the following conditions: - Red links lean left (right red links are not allowed.) - No node has two red links connected to it. - The Tree has perfect black balance: every path from the root to a null link has the same number of black links. http://algs4.cs.princeton.edu/33balanced/ Here another good explanation of the algorithm: http://www.teachsolaisgames.com/articles/balanced_left_leaning.html """ RED = True BLACK = False # Used to print trees in colors TERM_RESET_COLOR = '\033[00m' TERM_RED_COLOR = '\033[01;31m' def is_red(node): """Return if `node` is red. None nodes considered black.""" return False if node is None else node.color == RED def is_black(node): """Return if `node` is black. None nodes considered black.""" return True if node is None else node.color == BLACK def _node_size(node): """Return the `node` size.""" size = 0 if node: size += 1 if node.left: size += node.left.size if node.right: size += node.right.size return size return size class LLRBT(object): class LLRBTNode(object): def __init__(self, value): self.value = value self.size = 1 self.left = None self.right = None self.color = RED def __str__(self): def _print_value(node): """Return `node` value as a string. If the node is red, the value is represented as red.""" if is_red(node): return "{red_color}{value}{reset_color}".format( red_color=TERM_RED_COLOR, value=node.value, reset_color=TERM_RESET_COLOR ) else: return str(node.value) def _print(node, depth=0): """Recursively create a string representation of `node`. The representation flows from left to right. 300 200 150 100 80 50 30 """ ret = "" if node.right: ret += _print(node.right, depth + 1) ret += "\n" + (" " * depth) + _print_value(node) if node.left: ret += _print(node.left, depth + 1) return ret return _print(self, 0) def __init__(self, initialization_list=None): """Initialize the Tree and insert Nodes if an initialization list was given.""" self._root = None self._size = 0 if initialization_list: for v in initialization_list: self.insert(v) def __str__(self): return self._root.__str__() if self._root else "" def insert(self, value): """Return True if `value` was inserted, False otherwise. On repeated values it doesn't do anything. """ def _insert(node): if node is None: return LLRBT.LLRBTNode(value), True if node.value > value: node.left, inserted = _insert(node.left) elif node.value < value: node.right, inserted = _insert(node.right) else: inserted = False node = LLRBT._balance(node) return node, inserted self._root, inserted = _insert(self._root) self._size = self._root.size self._root.color = BLACK return inserted def remove(self, value): """Remove a Node which contains the value `value` and return True if the value was found.""" def _remove(node): # Continue the search on the left tree. if node.value > value: if node.left: # If we have two consecutive black links on the left, # we move one red node from the right to the left. if is_black(node.left) and is_black(node.left.left): node = LLRBT._move_red_left(node) node.left, removed = _remove(node.left) # In this case, the value is not present in the tree. else: removed = False # Two things can happen here: the search must continue on the # right branch or the value is present in the current node. else: # In any case, if the left child is red we should move it # to the right. This will allow us to eventually delete # a node from the right branch. if is_red(node.left): node = LLRBT._rotate_right(node) # Node found. Delete it and return True. if node.value == value and node.right is None: return None, True # At this point, the search continues on the right sub tree. if node.right: # If we have a right node on the left, we move it to # the right. if is_black(node.right) and is_black(node.right.left): node = LLRBT._move_red_right(node) # The value was found, so we need to replace that node # with its successor. if node.value == value: successor, _ = LLRBT._min(node.right) node.value = successor.value node.right = LLRBT._remove_min(node.right) removed = True # The search continues on the right branch else: node.right, removed = _remove(node.right) # The current node doesn't have the value we are looking for # and the right branch is empty. else: removed = False return LLRBT._balance(node), removed if self._root: self._root, removed = _remove(self._root) self._size -= int(removed) return removed def remove_min(self): """Delete the smallest key from the tree and return True if succeeded. Deleting a black node could break the tree invariant, so we need to push down a red node until we get to the leaf node (the one to be deleted).""" if self._root: self._root = LLRBT._remove_min(self._root) if self._root: self._size = self._root.size self._root.color = BLACK return True else: return False @staticmethod def _remove_min(node): """Remove the smallest node of the tree rooted on `node`.""" # This is the smallest key -> delete it if node.left is None: return None # Force left child to be red if is_black(node.left) and is_black(node.left.left): node = LLRBT._move_red_left(node) node.left = LLRBT._remove_min(node.left) # On the way up, fix right leaning trees and 4-nodes return LLRBT._balance(node) def remove_max(self): def _remove_max(node): # Make the left red node the root (move upwards the red) if is_red(node.left): node = LLRBT._rotate_right(node) # This is the greatest key -> delete it if node.right is None: return None if is_black(node.right) and node.right and is_black(node.right.left): node = LLRBT._move_red_right(node) node.right = _remove_max(node.right) return LLRBT._balance(node) if self._root: self._root = _remove_max(self._root) if self._root: self._size = self._root.size self._root.color = BLACK return True else: return False def contains(self, value): """Return True if `value` exists in the Tree.""" def _contains(node): if node.value == value: return True if node.value > value and node.left: return _contains(node.left) if node.value < value and node.right: return _contains(node.right) return False if self._root: return _contains(self._root) return False def max(self): """Return the biggest value of the Tree.""" node = self._root if node is None: return None while node.right: node = node.right return node.value def min(self): """Return the smallest value of the Tree.""" min_node, found = LLRBT._min(self._root) if found: return min_node.value else: return None @staticmethod def _min(node): """Return the smallest node of the tree rooted on `node`. Return True if there is a node, False otherwise.""" if node is None: return None, False while node.left: node = node.left return node, True def floor(self, value): """Return the floor element of `value`.""" def _floor(node): if node is None: return None if node.value == value: return value if node.value > value: return _floor(node.left) if node.value < value: successor = _floor(node.right) return node if successor is None else successor return _floor(self._root) def ceiling(self, value): """Return the ceiling element of `value`.""" def _ceiling(node): if node is None: return None if node.value == value: return value if node.value < value: return _ceiling(node.right) if node.value > value: ancestor = _ceiling(node.left) return node if ancestor is None else ancestor return _ceiling(self._root) def select(self, rank): """Return the key/value of rank k such that precisely k other keys in the BST are smaller than it.""" def _select(node, rank): if node is None: return None if _node_size(node.left) == rank: return node.value if _node_size(node.left) > rank: return _select(node.left, rank) if _node_size(node.left) < rank: return _select(node.right, rank - _node_size(node.left) - 1) return _select(self._root, rank) def rank(self, value): """Return the rank of `value` in the Tree.""" def _rank(node): if node is None: return 0 if node.value == value: return _node_size(node.left) if node.value > value: return _rank(node.left) if node.value < value: return 1 + _node_size(node.left) + _rank(node.right) return _rank(self._root) def pre_order_traversal(self): """Return a generator to traverse the Tree in pre-order.""" def _pre_order_traversal(node): if node is None: return yield node yield from _pre_order_traversal(node.left) yield from _pre_order_traversal(node.right) yield from _pre_order_traversal(self._root) def in_order_traversal(self): """Return a generator to traverse the Tree in in-order.""" def _in_order_traversal(node): if node is None: return yield from _in_order_traversal(node.left) yield node yield from _in_order_traversal(node.right) yield from _in_order_traversal(self._root) def in_order_traversal_iterative(self): def _in_order_traversal_iterative(node): stack = [] while stack or node: if node: stack.append(node) node = node.left else: node = stack.pop() yield node node = node.right yield from _in_order_traversal_iterative(self._root) def post_order_traversal(self): """Return a generator to traverse the Tree in post-order.""" def _post_order_traversal(node): if node is None: return yield from _post_order_traversal(node.left) yield from _post_order_traversal(node.right) yield node yield from _post_order_traversal(self._root) @staticmethod def _rotate_left(node): """Perform a left rotation. Fix a right red link.""" right_node = node.right node.right = right_node.left right_node.left = node right_node.color = node.color node.color = RED right_node.size = node.size node.size = _node_size(node) return right_node @staticmethod def _rotate_right(node): """Perform a left rotation. Fix a double left red link.""" left_node = node.left node.left = left_node.right left_node.right = node left_node.color = node.color node.color = RED left_node.size = node.size node.size = _node_size(node) return left_node @staticmethod def _flip_colors(node): """Flip colors of `node` and its children.""" node.color = not node.color node.left.color = not node.left.color node.right.color = not node.right.color @staticmethod def _move_red_left(node): """Move a red child from the right to the left sub tree.""" # Merge parent and children into a 4-node making their links red LLRBT._flip_colors(node) # Move red child from right branch to the left branch if node.right and is_red(node.right.left): node.right = LLRBT._rotate_right(node.right) node = LLRBT._rotate_left(node) LLRBT._flip_colors(node) return node @staticmethod def _move_red_right(node): # Merge parent and children into a 4-node making their links red LLRBT._flip_colors(node) if node.left and is_red(node.left.left): node = LLRBT._rotate_right(node) LLRBT._flip_colors(node) return node @staticmethod def _balance(node): """Restore LLRBT invariant by applying rotations and flipping colors.""" # Fix a right leaning tree -> rotate left if is_black(node.left) and is_red(node.right): node = LLRBT._rotate_left(node) # 4-node on the left -> rotate right and flip colors if is_red(node.left) and is_red(node.left.left): node = LLRBT._rotate_right(node) # Split 4-node -> flip colors if is_red(node.left) and is_red(node.right): LLRBT._flip_colors(node) node.size = _node_size(node) return node def check_integrity(self): def _check_node_integrity(node): if node is None: return 1 # Check there is no two consecutive left red nodes if is_red(node) and is_red(node.left): raise IntegrityError("RED VIOLATION", "Two consecutive left red nodes.", node) left_height = _check_node_integrity(node.left) right_height = _check_node_integrity(node.right) # Check if it's a valid binary search tree if (node.left and node.left.value >= node.value) or \ (node.right and node.right.value <= node.value): raise IntegrityError( "BINARY SEARCH TREE VIOLATION", "Left child is bigger than root or right child is smaller than root.", node) # Check black height of both children if left_height != 0 and right_height != 0 and left_height != right_height: raise IntegrityError("BLACK HEIGHT VIOLATION", "Left and right subtree doesn't have the same black height.", node) # If node is black, add 1 to the height if left_height != 0: if is_red(node): return left_height else: return left_height + 1 else: return 0 return _check_node_integrity(self._root) @property def size(self): """Return the number of Nodes.""" return self._size class IntegrityError(Exception): """Class to signal integrity errors.""" def __init__(self, invalidation_type, message, node): self.invalidation_type = invalidation_type self.message = message self.node = node if __name__ == "__main__": initialization_list = ["S", "E", "A", "R", "C", "H", "X", "M", "P", "L"] # initialization_list = range(20) tree = LLRBT() for value in initialization_list: tree.insert(value) print(TERM_RED_COLOR + "-> Last key inserted: " + value + TERM_RESET_COLOR) print("------------------------------------") print(tree) print("\n") tree.check_integrity()
# -*- coding: utf-8 -*- GOLDEN_EN_RULES = [ # 1) Simple period to end sentence ("Hello World. My name is Jonas.", ["Hello World.", "My name is Jonas."]), # 2) Question mark to end sentence ("What is your name? My name is Jonas.", ["What is your name?", "My name is Jonas."]), # 3) Exclamation point to end sentence ("There it is! I found it.", ["There it is!", "I found it."]), # 4) One letter upper case abbreviations ("My name is Jonas E. Smith.", ["My name is Jonas E. Smith."]), # 5) One letter lower case abbreviations ("Please turn to p. 55.", ["Please turn to p. 55."]), # 6) Two letter lower case abbreviations in the middle of a sentence ("Were Jane and co. at the party?", ["Were Jane and co. at the party?"]), # 7) Two letter upper case abbreviations in the middle of a sentence ("They closed the deal with Pitt, Briggs & Co. at noon.", ["They closed the deal with Pitt, Briggs & Co. at noon."]), # 8) Two letter lower case abbreviations at the end of a sentence ( "Let's ask Jane and co. They should know.", ["Let's ask Jane and co.", "They should know."]), # 9) Two letter upper case abbreviations at the end of a sentence ( "They closed the deal with Pitt, Briggs & Co. It closed yesterday.", [ "They closed the deal with Pitt, Briggs & Co.", "It closed yesterday." ], ), # 10) Two letter (prepositive) abbreviations ("I can see Mt. Fuji from here.", ["I can see Mt. Fuji from here."]), # 11) Two letter (prepositive & postpositive) abbreviations ( "St. Michael's Church is on 5th st. near the light.", ["St. Michael's Church is on 5th st. near the light."], ), # 12) Possesive two letter abbreviations ("That is JFK Jr.'s book.", ["That is JFK Jr.'s book."]), # 13) Multi-period abbreviations in the middle of a sentence ("I visited the U.S.A. last year.", ["I visited the U.S.A. last year."]), # 14) Multi-period abbreviations at the end of a sentence ( "I live in the E.U. How about you?", ["I live in the E.U.", "How about you?"], ), # 15) U.S. as sentence boundary ( "I live in the U.S. How about you?", ["I live in the U.S.", "How about you?"], ), # 16) U.S. as non sentence boundary with next word capitalized ("I work for the U.S. Government in Virginia.", ["I work for the U.S. Government in Virginia."]), # 17) U.S. as non sentence boundary ("I have lived in the U.S. for 20 years.", ["I have lived in the U.S. for 20 years."]), # Most difficult sentence to crack # 18) A.M. / P.M. as non sentence boundary and sentence boundary ( "At 5 a.m. Mr. Smith went to the bank. He left the bank at 6 P.M. Mr. Smith then went to the store.", [ "At 5 a.m. Mr. Smith went to the bank.", "He left the bank at 6 P.M.", "Mr. Smith then went to the store." ] ), # 19) Number as non sentence boundary ("She has $100.00 in her bag.", ["She has $100.00 in her bag."]), # 20) Number as sentence boundary ("She has $100.00. It is in her bag.", ["She has $100.00.", "It is in her bag."]), # 21) Parenthetical inside sentence ("He teaches science (He previously worked for 5 years as an engineer.) at the local University.", ["He teaches science (He previously worked for 5 years as an engineer.) at the local University."]), # 22) Email addresses ("Her email is Jane.Doe@example.com. I sent her an email.", ["Her email is Jane.Doe@example.com.", "I sent her an email."]), # 23) Web addresses ("The site is: https://www.example.50.com/new-site/awesome_content.html. Please check it out.", ["The site is: https://www.example.50.com/new-site/awesome_content.html.", "Please check it out."]), # 24) Single quotations inside sentence ( "She turned to him, 'This is great.' she said.", ["She turned to him, 'This is great.' she said."], ), # 25) Double quotations inside sentence ( 'She turned to him, "This is great." she said.', ['She turned to him, "This is great." she said.'], ), # 26) Double quotations at the end of a sentence ( 'She turned to him, "This is great." She held the book out to show him.', [ 'She turned to him, "This is great."', "She held the book out to show him." ], ), # 27) Double punctuation (exclamation point) ("Hello!! Long time no see.", ["Hello!!", "Long time no see."]), # 28) Double punctuation (question mark) ("Hello?? Who is there?", ["Hello??", "Who is there?"]), # 29) Double punctuation (exclamation point / question mark) ("Hello!? Is that you?", ["Hello!?", "Is that you?"]), # 30) Double punctuation (question mark / exclamation point) ("Hello?! Is that you?", ["Hello?!", "Is that you?"]), # 31) List (period followed by parens and no period to end item) ( "1.) The first item 2.) The second item", ["1.) The first item", "2.) The second item"], ), # 32) List (period followed by parens and period to end item) ( "1.) The first item. 2.) The second item.", ["1.) The first item.", "2.) The second item."], ), # 33) List (parens and no period to end item) ( "1) The first item 2) The second item", ["1) The first item", "2) The second item"], ), # 34) List (parens and period to end item) ("1) The first item. 2) The second item.", ["1) The first item.", "2) The second item."]), # 35) List (period to mark list and no period to end item) ( "1. The first item 2. The second item", ["1. The first item", "2. The second item"], ), # 36) List (period to mark list and period to end item) ( "1. The first item. 2. The second item.", ["1. The first item.", "2. The second item."], ), # 37) List with bullet ( "• 9. The first item • 10. The second item", ["• 9. The first item", "• 10. The second item"], ), # 38) List with hypthen ( "⁃9. The first item ⁃10. The second item", ["⁃9. The first item", "⁃10. The second item"], ), # 39) Alphabetical list ( "a. The first item b. The second item c. The third list item", ["a. The first item", "b. The second item", "c. The third list item"], ), # 40) Geo Coordinates ( "You can find it at N°. 1026.253.553. That is where the treasure is.", [ "You can find it at N°. 1026.253.553.", "That is where the treasure is." ], ), # 41) Named entities with an exclamation point ( "She works at Yahoo! in the accounting department.", ["She works at Yahoo! in the accounting department."], ), # 42) I as a sentence boundary and I as an abbreviation ( "We make a good team, you and I. Did you see Albert I. Jones yesterday?", [ "We make a good team, you and I.", "Did you see Albert I. Jones yesterday?" ], ), # 43) Ellipsis at end of quotation ( "Thoreau argues that by simplifying one’s life, “the laws of the universe will appear less complex. . . .”", [ "Thoreau argues that by simplifying one’s life, “the laws of the universe will appear less complex. . . .”" ], ), # 44) Ellipsis with square brackets ( """"Bohr [...] used the analogy of parallel stairways [...]" (Smith 55).""", [ '"Bohr [...] used the analogy of parallel stairways [...]" (Smith 55).' ], ), # 45) Ellipsis as sentence boundary (standard ellipsis rules) ("If words are left off at the end of a sentence, and that is all that is omitted, indicate the omission with ellipsis marks (preceded and followed by a space) and then indicate the end of the sentence with a period . . . . Next sentence.", [ "If words are left off at the end of a sentence, and that is all that is omitted, indicate the omission with ellipsis marks (preceded and followed by a space) and then indicate the end of the sentence with a period . . . .", "Next sentence." ]), # 46) Ellipsis as sentence boundary (non-standard ellipsis rules) ( "I never meant that.... She left the store.", ["I never meant that....", "She left the store."], ), # 47) Ellipsis as non sentence boundary ( "I wasn’t really ... well, what I mean...see . . . what I'm saying, the thing is . . . I didn’t mean it.", [ "I wasn’t really ... well, what I mean...see . . . what I'm saying, the thing is . . . I didn’t mean it." ], ), # 48) 4-dot ellipsis ( "One further habit which was somewhat weakened . . . was that of combining words into self-interpreting compounds. . . . The practice was not abandoned. . . .", [ "One further habit which was somewhat weakened . . . was that of combining words into self-interpreting compounds.", ". . . The practice was not abandoned. . . ." ], ) ]
""" Faster R-CNN with GIOU Assigner Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=1500 ] = 0.110 Average Precision (AP) @[ IoU=0.25 | area= all | maxDets=1500 ] = -1.000 Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=1500 ] = 0.265 Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=1500 ] = 0.075 Average Precision (AP) @[ IoU=0.50:0.95 | area=verytiny | maxDets=1500 ] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 | area= tiny | maxDets=1500 ] = 0.077 Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=1500 ] = 0.227 Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=1500 ] = 0.331 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.169 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=300 ] = 0.174 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=1500 ] = 0.174 Average Recall (AR) @[ IoU=0.50:0.95 | area=verytiny | maxDets=1500 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= tiny | maxDets=1500 ] = 0.110 Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=1500 ] = 0.372 Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=1500 ] = 0.458 Optimal LRP @[ IoU=0.50 | area= all | maxDets=1500 ] = 0.897 Optimal LRP Loc @[ IoU=0.50 | area= all | maxDets=1500 ] = 0.290 Optimal LRP FP @[ IoU=0.50 | area= all | maxDets=1500 ] = 0.438 Optimal LRP FN @[ IoU=0.50 | area= all | maxDets=1500 ] = 0.717 # Class-specific LRP-Optimal Thresholds # [0.76 0.446 0.603 0.588 0.713 0.445 0.511 nan] +----------+-------+---------------+-------+--------------+-------+ | category | AP | category | AP | category | AP | +----------+-------+---------------+-------+--------------+-------+ | airplane | 0.208 | bridge | 0.029 | storage-tank | 0.205 | | ship | 0.195 | swimming-pool | 0.073 | vehicle | 0.127 | | person | 0.044 | wind-mill | 0.000 | None | None | +----------+-------+---------------+-------+--------------+-------+ +----------+-------+---------------+-------+--------------+-------+ | category | oLRP | category | oLRP | category | oLRP | +----------+-------+---------------+-------+--------------+-------+ | airplane | 0.817 | bridge | 0.968 | storage-tank | 0.812 | | ship | 0.827 | swimming-pool | 0.919 | vehicle | 0.879 | | person | 0.954 | wind-mill | 1.000 | None | None | +----------+-------+---------------+-------+--------------+-------+ """ _base_ = [ '../_base_/models/faster_rcnn_r50_fpn_aitod.py', '../_base_/datasets/aitod_detection.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py' ] model = dict( train_cfg=dict( rpn=dict( assigner=dict( iou_calculator=dict(type='BboxOverlaps2D'), assign_metric='iou')), rcnn=dict( assigner=dict( iou_calculator=dict(type='BboxOverlaps2D'), assign_metric='iou')))) # optimizer optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) # learning policy checkpoint_config = dict(interval=4)
SESSION_NAME = "researcher_username" EXPIRY_NAME = "expiry" SESSION_UUID = "session_uuid" STUDY_ADMIN_RESTRICTION = "study_admin_restriction"
class Solution: def addDigits(self, num: int) -> int: while num > 9: num = sum([int(x) for x in str(num)]) return num
class Node: def __init__(self, data): self.data = data self.left = self.right = None class Solution: def tiltOfBinaryTreeUtil(self, root): if root is None: return 0 left_tilt = self.tiltOfBinaryTreeUtil(root.left) right_tilt = self.tiltOfBinaryTreeUtil(root.right) currentNode_tilt = abs(left_tilt - right_tilt) self.total_tilt += currentNode_tilt return root.data + left_tilt + right_tilt def tiltOfBinaryTree(self, root): self.total_tilt = 0 self.tiltOfBinaryTreeUtil(root) return self.total_tilt if __name__ == '__main__': root = Node(50) root.left = Node(10) root.right = Node(40) root.left.left = Node(30) root.left.right = Node(20) print(Solution().tiltOfBinaryTree(root)) # 4 # / \ # 2 9 # / \ \ # 3 5 7 # Explanation: # Tilt of node 3 : 0 # Tilt of node 5 : 0 # Tilt of node 7 : 0 # Tilt of node 2 : |3-5| = 2 # Tilt of node 9 : |0-7| = 7 # Tilt of node 4 : |(3+5+2)-(9+7)| = 6 # Tilt of binary tree : 0 + 0 + 0 + 2 + 7 + 6 = 15 root = Node(4) root.left = Node(2) root.right = Node(9) root.right.right = Node(7) root.left.left = Node(3) root.left.right = Node(5) print(Solution().tiltOfBinaryTree(root))
def getLongestPalindrome(start: int, end: int, s: str) -> str: while start > -1 and end < len(s) and s[start] == s[end]: start -= 1 end += 1 return s[start + 1:end] def longestPalindrome(s: str) -> str: if not s or len(s) == 0: return "" if len(s) == 1: return s result = "" for index in range(len(s)): odd = getLongestPalindrome(index, index, s) even = getLongestPalindrome(index, index + 1, s) if len(odd) > len(result): result = odd if len(even) > len(result): result = even return result if __name__ == "__main__": print(longestPalindrome("babad")) print(longestPalindrome("cbbd")) print(longestPalindrome("a")) print(longestPalindrome("ac")) print(longestPalindrome("bb"))
class WeatherItem: def __init__(self, name, prefix="", suffix="", condition_type_list=[]): self.__name = name self.__prefix = prefix self.__suffix = suffix self.__condition_list = condition_type_list def __eq__(self, other): if isinstance(other, self.__class__): return self.__name == other.name return False def __ne__(self, other): return not self.__eq__(other) def __str__(self): return "{%s, %s, %s, %s}" % (self.__name, self.__prefix, self.__suffix, self.__condition_list) __repr__ = __str__ @property def name(self): return self.__name @property def conditions(self): return self.__condition_list def is_for_condition_type(self, condition_type): return condition_type in self.__condition_list def format_for_output(self): output = self.__name if self.__prefix != "": output = self.__prefix + " " + output if self.__suffix != "": output = output + " " + self.__suffix return output
secondary_todo_list
window = None scene = 'title' state = '' class Cursor(): class Title(): menu = 0 class Save_Select(): save = 0 class Roguelike_Menu(): level = 0 character = 0 class Roguelike_Start(): select = 0 class Save(): data = { 0 : '', 1 : '', 2 : '', } class Select(): class Roguelike_Menu(): level = 0 character = 0 class Pool(): card = { 'all' : [], 'fire' : [], 'water' : [], 'nature' : [], 'earth' : [], 'light' : [], 'normal' : [] } item = { 'common' : [], } class Field(): wall = [] thing = [] portal = [] class Player(): level = 0 exp = 0 exp_max = 0 life = 20 card = [] equip = [] item = [] class Player_Rogue(): level = 0 exp = 0 exp_max = 0 life = 20 deck = [] equip = [] item = []
class Car: """ Add class description here """ def __init__(self, name, length, location, orientation): """ A constructor for a Car object :param name: A string representing the car's name :param length: A positive int representing the car's length. :param location: A tuple representing the car's head (row, col) location :param orientation: One of either 0 (VERTICAL) or 1 (HORIZONTAL) """ # Note that this function is required in your Car implementation. # However, is not part of the API for general car types. self.__length = length self.__orientation = orientation self.__location = location self.__name = name def car_coordinates(self): """ :return: A list of coordinates the car is in """ result = [] for i in range(self.__length): if self.__orientation == 0: result.append((self.__location[0] + i, self.__location[1])) elif self.__orientation == 1: result.append((self.__location[0], self.__location[1] + i)) return result def possible_moves(self): """ :return: A dictionary of strings describing possible movements permitted by this car. """ # For this car type, keys are from 'udrl' # The keys for vertical cars are 'u' and 'd'. # The keys for horizontal cars are 'l' and 'r'. # You may choose appropriate strings. # implement your code and erase the "pass" # The dictionary returned should look something like this: # result = {'f': "cause the car to fly and reach the Moon", # 'd': "cause the car to dig and reach the core of Earth", # 'a': "another unknown action"} # A car returning this dictionary supports the commands 'f','d','a'. result = {} if self.__orientation == 0: result['u'] = 'cause the car can get up to the reach of the mountains' result['d'] = 'cause the car get go down to the center of Earth' elif self.__orientation == 1: result['l'] = 'cause the car get go west in to the sea' result['r'] = 'cause the car get go east to the desert' return result def movement_requirements(self, movekey): """ :param movekey: A string representing the key of the required move. :return: A list of cell locations which must be empty in order for this move to be legal. """ # For example, a car in locations [(1,2),(2,2)] requires [(3,2)] to # be empty in order to move down (with a key 'd'). if movekey == 'u': return (self.__location[0] - 1, self.__location[1]) elif movekey == 'r': return (self.__location[0], self.__location[1] + self.__length) elif movekey == 'l': return (self.__location[0], self.__location[1] - 1) elif movekey == 'd': return (self.__location[0] + self.__length, self.__location[1]) return None def move(self, movekey): """ :param movekey: A string representing the key of the required move. :return: True upon success, False otherwise """ if movekey == 'u': self.__location = (self.__location[0] - 1, self.__location[1]) elif movekey == 'r': self.__location = (self.__location[0], self.__location[1] + 1) elif movekey == 'd': self.__location = (self.__location[0] + 1, self.__location[1]) elif movekey == 'l': self.__location = (self.__location[0], self.__location[1] - 1) return None def get_name(self): """ :return: The name of this car. """ # implement your code and erase the "pass" return self.__name
in_file = open('occurrences.txt', 'r') out_file = open('present.txt', 'w') counter = 7740 for line in in_file: row = line.split('\t') country = row[5] id = row[0] ref = row[8] if country == '': country = row[6] if country == '': pass else: out_file.write('M' + str(counter) + '\t' + id + '\t\ttrue\t' + 'http://eol.org/schema/terms/Present' + '\t' + country + '\t\t\t\tCompiler: Anne E Thessen\t' + ref + '\n') counter = counter + 1
#023 - Separando dígitos de um número num = int(input('informe um numero: ')) u = num // 1 % 10 d = num // 10 % 10 c = num // 100 % 10 m = num // 1000 % 10 print(f'analisando o numero {num}') print(f'unidade {u}') print(f'dezena: {d}') print(f'centena: {c}') print(f'milhar: {m}')
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # This line will be programatically read/write by setup.py. # Leave them at the bottom of this file and don't touch them. __version__ = "0.1.1"
""" @author: David Lei @since: 19/09/2017 Bottom up solution to find the nth fibonacci number. """ def fib(n): TABLE = [0, 1] calculated = 1 while calculated < n: next_number = TABLE[calculated] + TABLE[calculated - 1] print("Adding computed value to table {0} + {1} = {2}".format( TABLE[calculated ], TABLE[calculated - 1], next_number)) TABLE.append(next_number) calculated += 1 return TABLE[n] print(fib(14))
# Create a dictionary of lists with new data avocados_dict = { "date": ["2019-11-17", "2019-12-01"], "small_sold": [10859987, 9291631], "large_sold": [7674135, 6238096] } # Convert dictionary into DataFrame avocados_2019 = pd.DataFrame(avocados_dict) # Print the new DataFrame print(avocados_2019)
Li = [ 22, 35 , 26 , 98 , 55 , 10 , 67 ] Li.sort() Li.reverse() print(Li)
class HsrpOutput(object): # 'show hsrp detail' output showHsrpDetailOutput = \ { 'GigabitEthernet0/0/0/0': { 'address_family': { 'ipv4': { 'version': { 1: { 'groups': { 0: { 'active_ip_address': 'unknown', 'active_router': 'unknown', 'bfd': { 'address': '10.1.1.1', 'interface_name': 'GigabitEthernet0/0/0/1', 'state': 'inactive' }, 'group_number': 0, 'hsrp_router_state': 'init', 'preempt': True, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'stored', 'statistics': { 'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': 'never', 'num_state_changes': 0 }, 'timers': { 'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True }, 'virtual_mac_address': '0000.0c07.ac00' }, 10: { 'active_ip_address': 'local', 'active_priority': 63, 'active_router': 'local', 'authentication': 'cisco123', 'group_number': 10, 'hsrp_router_state': 'active', 'num_of_slaves': 1, 'preempt': True, 'primary_ipv4_address': { 'address': '10.1.1.254' }, 'priority': 63, 'session_name': 'group10', 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': { 'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:36:53', 'num_state_changes': 4 }, 'timers': { 'cfgd_hello_msec': 10000, 'cfgd_hold_msec': 30000, 'hello_msec': 10000, 'hello_msec_flag': True, 'hold_msec': 30000, 'hold_msec_flag': True }, 'tracked_interfaces': { 'GigabitEthernet0/0/0/1': { 'interface_name': 'GigabitEthernet0/0/0/1', 'priority_decrement': 123 } }, 'tracked_objects': { '1': { 'object_name': '1', 'priority_decrement': 25 }, 'num_tracked_objects': 2, 'num_tracked_objects_up': 1 }, 'virtual_mac_address': '0000.0c07.ac0a' }, 20: { 'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 20, 'hsrp_router_state': 'active', 'primary_ipv4_address': { 'address': '10.1.1.128' }, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': { 'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:52', 'num_state_changes': 4 }, 'timers': { 'cfgd_hello_msec': 111, 'cfgd_hold_msec': 333, 'hello_msec': 111, 'hello_msec_flag': True, 'hold_msec': 333, 'hold_msec_flag': True }, 'tracked_interfaces': { 'GigabitEthernet0/0/0/1': { 'interface_name': 'GigabitEthernet0/0/0/1', 'priority_decrement': 251 } }, 'tracked_objects': { 'num_tracked_objects': 1, 'num_tracked_objects_up': 1 }, 'virtual_mac_address': '0000.0c07.ac14' } }, 'slave_groups': { 30: { 'follow': 'group10', 'group_number': 30, 'hsrp_router_state': 'init', 'primary_ipv4_address': { 'address': 'unknown' }, 'priority': 100, 'standby_state': 'stored', 'virtual_mac_address': '0000.0c07.ac1e' } } } } }, 'ipv6': { 'version': { 2: { 'groups': { 10: { 'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 10, 'hsrp_router_state': 'active', 'link_local_ipv6_address': { 'address': 'fe80::205:73ff:fea0:a' }, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': { 'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:18', 'num_state_changes': 4 }, 'timers': { 'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True }, 'virtual_mac_address': '0005.73a0.000a' }, 20: { 'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 20, 'hsrp_router_state': 'active', 'link_local_ipv6_address': { 'address': 'fe80::205:73ff:fea0:14' }, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': { 'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:18', 'num_state_changes': 4 }, 'timers': { 'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True }, 'virtual_mac_address': '0005.73a0.0014' }, 30: { 'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 30, 'hsrp_router_state': 'active', 'link_local_ipv6_address': { 'address': 'fe80::205:73ff:fea0:1e' }, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': { 'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:18', 'num_state_changes': 4 }, 'timers': { 'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True }, 'virtual_mac_address': '0005.73a0.001e' } } } } } }, 'bfd': { 'detection_multiplier': 3, 'enabled': True, 'interval': 15 }, 'delay': { 'minimum_delay': 100, 'reload_delay': 1000 }, 'interface': 'GigabitEthernet0/0/0/0', 'redirects_disable': True, 'use_bia': False } } showHsrpDetailOutputIncomplete = \ { 'GigabitEthernet0/0/0/0': { 'address_family': { 'ipv4': { 'version': { 1: { 'groups': { 0: { 'active_ip_address': 'unknown', 'active_router': 'unknown', 'bfd': { 'address': '10.1.1.1', 'interface_name': 'GigabitEthernet0/0/0/1', 'state': 'inactive' }, 'group_number': 0, 'hsrp_router_state': 'init', 'preempt': True, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'stored', 'statistics': { 'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': 'never', 'num_state_changes': 0 }, 'virtual_mac_address': '0000.0c07.ac00' }, 10: { 'active_ip_address': 'local', 'active_priority': 63, 'active_router': 'local', 'authentication': 'cisco123', 'group_number': 10, 'hsrp_router_state': 'active', 'num_of_slaves': 1, 'preempt': True, 'primary_ipv4_address': { 'address': '10.1.1.254' }, 'priority': 63, 'session_name': 'group10', 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': { 'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:36:53', 'num_state_changes': 4 }, 'timers': { 'cfgd_hello_msec': 10000, 'cfgd_hold_msec': 30000, 'hello_msec': 10000, 'hello_msec_flag': True, 'hold_msec': 30000, 'hold_msec_flag': True }, 'tracked_interfaces': { 'GigabitEthernet0/0/0/1': { 'interface_name': 'GigabitEthernet0/0/0/1', 'priority_decrement': 123 } }, 'tracked_objects': { '1': { 'object_name': '1', 'priority_decrement': 25 }, 'num_tracked_objects': 2, 'num_tracked_objects_up': 1 }, 'virtual_mac_address': '0000.0c07.ac0a' }, 20: { 'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 20, 'hsrp_router_state': 'active', 'primary_ipv4_address': { 'address': '10.1.1.128' }, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': { 'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:52', 'num_state_changes': 4 }, 'timers': { 'cfgd_hello_msec': 111, 'cfgd_hold_msec': 333, 'hello_msec': 111, 'hello_msec_flag': True, 'hold_msec': 333, 'hold_msec_flag': True }, 'tracked_interfaces': { 'GigabitEthernet0/0/0/1': { 'interface_name': 'GigabitEthernet0/0/0/1', 'priority_decrement': 251 } }, 'tracked_objects': { 'num_tracked_objects': 1, 'num_tracked_objects_up': 1 }, 'virtual_mac_address': '0000.0c07.ac14' } }, 'slave_groups': { 30: { 'follow': 'group10', 'group_number': 30, 'hsrp_router_state': 'init', 'primary_ipv4_address': { 'address': 'unknown' }, 'priority': 100, 'standby_state': 'stored', 'virtual_mac_address': '0000.0c07.ac1e' } } } } }, 'ipv6': { 'version': { 2: { 'groups': { 10: { 'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 10, 'hsrp_router_state': 'active', 'link_local_ipv6_address': { 'address': 'fe80::205:73ff:fea0:a' }, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': { 'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:18', 'num_state_changes': 4 }, 'timers': { 'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True }, 'virtual_mac_address': '0005.73a0.000a' }, 20: { 'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 20, 'hsrp_router_state': 'active', 'link_local_ipv6_address': { 'address': 'fe80::205:73ff:fea0:14' }, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': { 'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:18', 'num_state_changes': 4 }, 'timers': { 'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True }, 'virtual_mac_address': '0005.73a0.0014' }, 30: { 'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 30, 'hsrp_router_state': 'active', 'link_local_ipv6_address': { 'address': 'fe80::205:73ff:fea0:1e' }, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': { 'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:18', 'num_state_changes': 4 }, 'timers': { 'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True }, 'virtual_mac_address': '0005.73a0.001e' } } } } } }, 'bfd': { 'detection_multiplier': 3, 'enabled': True, 'interval': 15 }, 'delay': { 'minimum_delay': 100, 'reload_delay': 1000 }, 'interface': 'GigabitEthernet0/0/0/0', 'redirects_disable': True, 'use_bia': False } } # 'show hsrp summary' output showHsrpSummaryOutput = \ { 'address_family': { 'ipv4': { 'intf_down': 0, 'intf_total': 1, 'intf_up': 1, 'state': { 'ACTIVE': { 'sessions': 2, 'slaves': 0, 'total': 2 }, 'ALL': { 'sessions': 3, 'slaves': 1, 'total': 4 }, 'INIT': { 'sessions': 1, 'slaves': 1, 'total': 2 }, 'LEARN': { 'sessions': 0, 'slaves': 0, 'total': 0 }, 'LISTEN': { 'sessions': 0, 'slaves': 0, 'total': 0 }, 'SPEAK': { 'sessions': 0, 'slaves': 0, 'total': 0 }, 'STANDBY': { 'sessions': 0, 'slaves': 0, 'total': 0 } }, 'virtual_addresses_active': 3, 'virtual_addresses_inactive': 0, 'vritual_addresses_total': 3 }, 'ipv6': { 'intf_down': 0, 'intf_total': 1, 'intf_up': 1, 'state': { 'ACTIVE': { 'sessions': 3, 'slaves': 0, 'total': 3 }, 'ALL': { 'sessions': 3, 'slaves': 0, 'total': 3 }, 'INIT': { 'sessions': 0, 'slaves': 0, 'total': 0 }, 'LEARN': { 'sessions': 0, 'slaves': 0, 'total': 0 }, 'LISTEN': { 'sessions': 0, 'slaves': 0, 'total': 0 }, 'SPEAK': { 'sessions': 0, 'slaves': 0, 'total': 0 }, 'STANDBY': { 'sessions': 0, 'slaves': 0, 'total': 0 } }, 'virtual_addresses_active': 5, 'virtual_addresses_inactive': 0, 'vritual_addresses_total': 5 } }, 'bfd_sessions_down': 0, 'bfd_sessions_inactive': 1, 'bfd_sessions_up': 0, 'num_bfd_sessions': 1, 'num_tracked_objects': 2, 'tracked_objects_down': 1, 'tracked_objects_up': 1 } # Hsrp Ops Object final output hsrpOpsOutput = \ { 'GigabitEthernet0/0/0/0': { 'address_family': { 'ipv4': { 'version': { 1: { 'groups': { 0: { 'active_ip_address': 'unknown', 'active_router': 'unknown', 'bfd': { 'address': '10.1.1.1', 'interface_name': 'GigabitEthernet0/0/0/1' }, 'group_number': 0, 'hsrp_router_state': 'init', 'preempt': True, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'timers': { 'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True }, 'virtual_mac_address': '0000.0c07.ac00' }, 10: { 'active_ip_address': 'local', 'active_router': 'local', 'authentication': 'cisco123', 'group_number': 10, 'hsrp_router_state': 'active', 'preempt': True, 'primary_ipv4_address': { 'address': '10.1.1.254' }, 'priority': 63, 'session_name': 'group10', 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'timers': { 'hello_msec': 10000, 'hello_msec_flag': True, 'hold_msec': 30000, 'hold_msec_flag': True }, 'tracked_interfaces': { 'GigabitEthernet0/0/0/1': { 'interface_name': 'GigabitEthernet0/0/0/1', 'priority_decrement': 123 } }, 'tracked_objects': { '1': { 'object_name': '1', 'priority_decrement': 25 } }, 'virtual_mac_address': '0000.0c07.ac0a' }, 20: { 'active_ip_address': 'local', 'active_router': 'local', 'group_number': 20, 'hsrp_router_state': 'active', 'primary_ipv4_address': { 'address': '10.1.1.128' }, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'timers': { 'hello_msec': 111, 'hello_msec_flag': True, 'hold_msec': 333, 'hold_msec_flag': True }, 'tracked_interfaces': { 'GigabitEthernet0/0/0/1': { 'interface_name': 'GigabitEthernet0/0/0/1', 'priority_decrement': 251 } }, 'virtual_mac_address': '0000.0c07.ac14' } }, 'slave_groups': { 30: { 'follow': 'group10', 'primary_ipv4_address': { 'address': 'unknown' }, 'virtual_mac_address': '0000.0c07.ac1e' } } } } }, 'ipv6': { 'version': { 2: { 'groups': { 10: { 'active_ip_address': 'local', 'active_router': 'local', 'group_number': 10, 'hsrp_router_state': 'active', 'link_local_ipv6_address': { 'address': 'fe80::205:73ff:fea0:a' }, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'timers': { 'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True }, 'virtual_mac_address': '0005.73a0.000a' }, 20: { 'active_ip_address': 'local', 'active_router': 'local', 'group_number': 20, 'hsrp_router_state': 'active', 'link_local_ipv6_address': { 'address': 'fe80::205:73ff:fea0:14' }, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'timers': { 'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True }, 'virtual_mac_address': '0005.73a0.0014' }, 30: { 'active_ip_address': 'local', 'active_router': 'local', 'group_number': 30, 'hsrp_router_state': 'active', 'link_local_ipv6_address': { 'address': 'fe80::205:73ff:fea0:1e' }, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'timers': { 'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True }, 'virtual_mac_address': '0005.73a0.001e' } } } } } }, 'bfd': { 'detection_multiplier': 3, 'enabled': True, 'interval': 15 }, 'delay': { 'minimum_delay': 100, 'reload_delay': 1000 }, 'interface': 'GigabitEthernet0/0/0/0', 'redirects_disable': True, 'use_bia': False } } # vim: ft=python et sw=4
SPECS = { "org.freedesktop.DBus.ObjectManager": """ <interface name="org.freedesktop.DBus.ObjectManager"> <method name="GetManagedObjects"> <arg name="objpath_interfaces_and_properties" type="a{oa{sa{sv}}}" direction="out" /> </method> </interface> """, "org.storage.stratis2.FetchProperties.r4": """ <interface name="org.storage.stratis2.FetchProperties.r4"> <method name="GetAllProperties"> <arg name="results" type="a{s(bv)}" direction="out" /> </method> <method name="GetProperties"> <arg name="properties" type="as" direction="in" /> <arg name="results" type="a{s(bv)}" direction="out" /> </method> </interface> """, "org.storage.stratis2.Manager.r4": """ <interface name="org.storage.stratis2.Manager.r4"> <method name="ConfigureSimulator"> <arg name="denominator" type="u" direction="in" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> <method name="CreatePool"> <arg name="name" type="s" direction="in" /> <arg name="redundancy" type="(bq)" direction="in" /> <arg name="devices" type="as" direction="in" /> <arg name="key_desc" type="(bs)" direction="in" /> <arg name="clevis_info" type="(b(ss))" direction="in" /> <arg name="result" type="(b(oao))" direction="out" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> <method name="DestroyPool"> <arg name="pool" type="o" direction="in" /> <arg name="result" type="(bs)" direction="out" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> <method name="EngineStateReport"> <arg name="result" type="s" direction="out" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> <method name="SetKey"> <arg name="key_desc" type="s" direction="in" /> <arg name="key_fd" type="h" direction="in" /> <arg name="interactive" type="b" direction="in" /> <arg name="result" type="(bb)" direction="out" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> <method name="UnlockPool"> <arg name="pool_uuid" type="s" direction="in" /> <arg name="unlock_method" type="s" direction="in" /> <arg name="result" type="(bas)" direction="out" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> <method name="UnsetKey"> <arg name="key_desc" type="s" direction="in" /> <arg name="result" type="b" direction="out" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> <property name="Version" type="s" access="read"> <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" /> </property> </interface> """, "org.storage.stratis2.Report.r4": """ <interface name="org.storage.stratis2.Report.r4"> <method name="GetReport"> <arg name="name" type="s" direction="in" /> <arg name="result" type="s" direction="out" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> </interface> """, "org.storage.stratis2.blockdev.r4": """ <interface name="org.storage.stratis2.blockdev.r4"> <method name="SetUserInfo"> <arg name="id" type="(bs)" direction="in" /> <arg name="changed" type="(bs)" direction="out" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> <property name="Devnode" type="s" access="read"> <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" /> </property> <property name="HardwareInfo" type="(bs)" access="read"> <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" /> </property> <property name="InitializationTime" type="t" access="read"> <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" /> </property> <property name="PhysicalPath" type="s" access="read"> <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" /> </property> <property name="Pool" type="o" access="read"> <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" /> </property> <property name="Tier" type="q" access="read"> <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false" /> </property> <property name="UserInfo" type="(bs)" access="read"> <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false" /> </property> <property name="Uuid" type="s" access="read"> <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" /> </property> </interface> """, "org.storage.stratis2.filesystem.r4": """ <interface name="org.storage.stratis2.filesystem.r4"> <method name="SetName"> <arg name="name" type="s" direction="in" /> <arg name="result" type="(bs)" direction="out" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> <property name="Created" type="s" access="read"> <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" /> </property> <property name="Devnode" type="s" access="read"> <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="invalidates" /> </property> <property name="Name" type="s" access="read" /> <property name="Pool" type="o" access="read"> <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" /> </property> <property name="Uuid" type="s" access="read"> <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" /> </property> </interface> """, "org.storage.stratis2.pool.r4": """ <interface name="org.storage.stratis2.pool.r4"> <method name="AddCacheDevs"> <arg name="devices" type="as" direction="in" /> <arg name="results" type="(bao)" direction="out" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> <method name="AddDataDevs"> <arg name="devices" type="as" direction="in" /> <arg name="results" type="(bao)" direction="out" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> <method name="Bind"> <arg name="pin" type="s" direction="in" /> <arg name="json" type="s" direction="in" /> <arg name="results" type="b" direction="out" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> <method name="BindKeyring"> <arg name="key_desc" type="s" direction="in" /> <arg name="results" type="b" direction="out" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> <method name="CreateFilesystems"> <arg name="specs" type="as" direction="in" /> <arg name="results" type="(ba(os))" direction="out" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> <method name="DestroyFilesystems"> <arg name="filesystems" type="ao" direction="in" /> <arg name="results" type="(bas)" direction="out" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> <method name="InitCache"> <arg name="devices" type="as" direction="in" /> <arg name="results" type="(bao)" direction="out" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> <method name="SetName"> <arg name="name" type="s" direction="in" /> <arg name="result" type="(bs)" direction="out" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> <method name="SnapshotFilesystem"> <arg name="origin" type="o" direction="in" /> <arg name="snapshot_name" type="s" direction="in" /> <arg name="result" type="(bo)" direction="out" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> <method name="Unbind"> <arg name="results" type="b" direction="out" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> <method name="UnbindKeyring"> <arg name="results" type="b" direction="out" /> <arg name="return_code" type="q" direction="out" /> <arg name="return_string" type="s" direction="out" /> </method> <property name="Encrypted" type="b" access="read"> <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" /> </property> <property name="Name" type="s" access="read" /> <property name="Uuid" type="s" access="read"> <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" /> </property> </interface> """, }
""" Code generated from go.sum by //:gazelle-update-repos """ load("@bazel_gazelle//:deps.bzl", "go_repository") def go_dependencies(): """ Managed by gazelle. Add "# keep" comment to modified lines. """ go_repository( name = "co_honnef_go_tools", importpath = "honnef.co/go/tools", sum = "h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8=", version = "v0.0.1-2020.1.4", ) go_repository( name = "com_github_abbot_go_http_auth", importpath = "github.com/abbot/go-http-auth", sum = "h1:9ZqcMQ0fB+ywKACVjGfZM4C7Uq9D5rq0iSmwIjX187k=", version = "v0.4.1-0.20181019201920-860ed7f246ff", ) go_repository( name = "com_github_alecthomas_template", importpath = "github.com/alecthomas/template", sum = "h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=", version = "v0.0.0-20190718012654-fb15b899a751", ) go_repository( name = "com_github_alecthomas_units", importpath = "github.com/alecthomas/units", sum = "h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=", version = "v0.0.0-20190924025748-f65c72e2690d", ) go_repository( name = "com_github_andybalholm_brotli", importpath = "github.com/andybalholm/brotli", sum = "h1:JKnhI/XQ75uFBTiuzXpzFrUriDPiZjlOSzh6wXogP0E=", version = "v1.0.2", ) go_repository( name = "com_github_antihax_optional", importpath = "github.com/antihax/optional", sum = "h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwcg=", version = "v1.0.0", ) go_repository( name = "com_github_beorn7_perks", importpath = "github.com/beorn7/perks", sum = "h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=", version = "v1.0.1", ) go_repository( name = "com_github_burntsushi_toml", importpath = "github.com/BurntSushi/toml", sum = "h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=", version = "v0.3.1", ) go_repository( name = "com_github_burntsushi_xgb", importpath = "github.com/BurntSushi/xgb", sum = "h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc=", version = "v0.0.0-20160522181843-27f122750802", ) go_repository( name = "com_github_census_instrumentation_opencensus_proto", importpath = "github.com/census-instrumentation/opencensus-proto", sum = "h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk=", version = "v0.2.1", ) go_repository( name = "com_github_cespare_xxhash", importpath = "github.com/cespare/xxhash", sum = "h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=", version = "v1.1.0", ) go_repository( name = "com_github_cespare_xxhash_v2", importpath = "github.com/cespare/xxhash/v2", sum = "h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=", version = "v2.1.2", ) go_repository( name = "com_github_chzyer_logex", importpath = "github.com/chzyer/logex", sum = "h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=", version = "v1.1.10", ) go_repository( name = "com_github_chzyer_readline", importpath = "github.com/chzyer/readline", sum = "h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=", version = "v0.0.0-20180603132655-2972be24d48e", ) go_repository( name = "com_github_chzyer_test", importpath = "github.com/chzyer/test", sum = "h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=", version = "v0.0.0-20180213035817-a1ea475d72b1", ) go_repository( name = "com_github_client9_misspell", importpath = "github.com/client9/misspell", sum = "h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=", version = "v0.3.4", ) go_repository( name = "com_github_cncf_udpa_go", importpath = "github.com/cncf/udpa/go", sum = "h1:hzAQntlaYRkVSFEfj9OTWlVV1H155FMD8BTKktLv0QI=", version = "v0.0.0-20210930031921-04548b0d99d4", ) go_repository( name = "com_github_cncf_xds_go", importpath = "github.com/cncf/xds/go", sum = "h1:zH8ljVhhq7yC0MIeUL/IviMtY8hx2mK8cN9wEYb8ggw=", version = "v0.0.0-20211011173535-cb28da3451f1", ) go_repository( name = "com_github_cpuguy83_go_md2man_v2", importpath = "github.com/cpuguy83/go-md2man/v2", sum = "h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU=", version = "v2.0.1", ) go_repository( name = "com_github_creack_pty", importpath = "github.com/creack/pty", sum = "h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w=", version = "v1.1.9", ) go_repository( name = "com_github_davecgh_go_spew", importpath = "github.com/davecgh/go-spew", sum = "h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=", version = "v1.1.1", ) go_repository( name = "com_github_djherbis_atime", importpath = "github.com/djherbis/atime", sum = "h1:rgwVbP/5by8BvvjBNrbh64Qz33idKT3pSnMSJsxhi0g=", version = "v1.1.0", ) go_repository( name = "com_github_dustin_go_humanize", importpath = "github.com/dustin/go-humanize", sum = "h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=", version = "v1.0.0", ) go_repository( name = "com_github_emicklei_go_restful_v3", importpath = "github.com/emicklei/go-restful/v3", sum = "h1:R5iagkkTsfFpe1nce6Yniw3wmSx0Qw5YP469YzRFNEs=", version = "v3.7.1", ) go_repository( name = "com_github_envoyproxy_go_control_plane", importpath = "github.com/envoyproxy/go-control-plane", sum = "h1:fP+fF0up6oPY49OrjPrhIJ8yQfdIM85NXMLkMg1EXVs=", version = "v0.9.10-0.20210907150352-cf90f659a021", ) go_repository( name = "com_github_envoyproxy_protoc_gen_validate", importpath = "github.com/envoyproxy/protoc-gen-validate", sum = "h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=", version = "v0.1.0", ) go_repository( name = "com_github_fasthttp_router", importpath = "github.com/fasthttp/router", sum = "h1:Z025tHFTjDp6T6QMBjloyGL6KV5wtakW365K/7KiE1c=", version = "v1.4.4", ) go_repository( name = "com_github_frankban_quicktest", importpath = "github.com/frankban/quicktest", sum = "h1:+cqqvzZV87b4adx/5ayVOaYZ2CrvM4ejQvUdBzPPUss=", version = "v1.14.0", ) go_repository( name = "com_github_fsnotify_fsnotify", importpath = "github.com/fsnotify/fsnotify", sum = "h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=", version = "v1.4.7", ) go_repository( name = "com_github_ghodss_yaml", importpath = "github.com/ghodss/yaml", sum = "h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=", version = "v1.0.0", ) go_repository( name = "com_github_gin_contrib_sse", importpath = "github.com/gin-contrib/sse", sum = "h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=", version = "v0.1.0", ) go_repository( name = "com_github_gin_gonic_gin", importpath = "github.com/gin-gonic/gin", sum = "h1:QmUZXrvJ9qZ3GfWvQ+2wnW/1ePrTEJqPKMYEU3lD/DM=", version = "v1.7.4", ) go_repository( name = "com_github_go_chi_chi", importpath = "github.com/go-chi/chi", sum = "h1:fGFk2Gmi/YKXk0OmGfBh0WgmN3XB8lVnEyNz34tQRec=", version = "v4.1.2+incompatible", ) go_repository( name = "com_github_go_gl_glfw", importpath = "github.com/go-gl/glfw", sum = "h1:QbL/5oDUmRBzO9/Z7Seo6zf912W/a6Sr4Eu0G/3Jho0=", version = "v0.0.0-20190409004039-e6da0acd62b1", ) go_repository( name = "com_github_go_gl_glfw_v3_3_glfw", importpath = "github.com/go-gl/glfw/v3.3/glfw", sum = "h1:WtGNWLvXpe6ZudgnXrq0barxBImvnnJoMEhXAzcbM0I=", version = "v0.0.0-20200222043503-6f7a984d4dc4", ) go_repository( name = "com_github_go_kit_kit", importpath = "github.com/go-kit/kit", sum = "h1:wDJmvq38kDhkVxi50ni9ykkdUr1PKgqKOoi01fa0Mdk=", version = "v0.9.0", ) go_repository( name = "com_github_go_kit_log", importpath = "github.com/go-kit/log", sum = "h1:DGJh0Sm43HbOeYDNnVZFl8BvcYVvjD5bqYJvp0REbwQ=", version = "v0.1.0", ) go_repository( name = "com_github_go_logfmt_logfmt", importpath = "github.com/go-logfmt/logfmt", sum = "h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4=", version = "v0.5.0", ) go_repository( name = "com_github_go_playground_locales", importpath = "github.com/go-playground/locales", sum = "h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=", version = "v0.13.0", ) go_repository( name = "com_github_go_playground_universal_translator", importpath = "github.com/go-playground/universal-translator", sum = "h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=", version = "v0.17.0", ) go_repository( name = "com_github_go_playground_validator_v10", importpath = "github.com/go-playground/validator/v10", sum = "h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE=", version = "v10.4.1", ) go_repository( name = "com_github_go_stack_stack", importpath = "github.com/go-stack/stack", sum = "h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=", version = "v1.8.0", ) go_repository( name = "com_github_gogo_protobuf", importpath = "github.com/gogo/protobuf", sum = "h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo=", version = "v1.1.1", ) go_repository( name = "com_github_golang_glog", importpath = "github.com/golang/glog", sum = "h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=", version = "v0.0.0-20160126235308-23def4e6c14b", ) go_repository( name = "com_github_golang_groupcache", importpath = "github.com/golang/groupcache", sum = "h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=", version = "v0.0.0-20210331224755-41bb18bfe9da", ) go_repository( name = "com_github_golang_mock", importpath = "github.com/golang/mock", sum = "h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=", version = "v1.6.0", ) go_repository( name = "com_github_golang_protobuf", importpath = "github.com/golang/protobuf", sum = "h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=", version = "v1.5.2", ) go_repository( name = "com_github_golang_snappy", importpath = "github.com/golang/snappy", sum = "h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=", version = "v0.0.4", ) go_repository( name = "com_github_google_btree", importpath = "github.com/google/btree", sum = "h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=", version = "v1.0.0", ) go_repository( name = "com_github_google_go_cmp", importpath = "github.com/google/go-cmp", sum = "h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=", version = "v0.5.6", ) go_repository( name = "com_github_google_gofuzz", importpath = "github.com/google/gofuzz", sum = "h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=", version = "v1.0.0", ) go_repository( name = "com_github_google_martian", importpath = "github.com/google/martian", sum = "h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=", version = "v2.1.0+incompatible", ) go_repository( name = "com_github_google_martian_v3", importpath = "github.com/google/martian/v3", sum = "h1:d8MncMlErDFTwQGBK1xhv026j9kqhvw1Qv9IbWT1VLQ=", version = "v3.2.1", ) go_repository( name = "com_github_google_pprof", importpath = "github.com/google/pprof", sum = "h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec=", version = "v0.0.0-20210720184732-4bb14d4b1be1", ) go_repository( name = "com_github_google_renameio", importpath = "github.com/google/renameio", sum = "h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA=", version = "v0.1.0", ) go_repository( name = "com_github_google_uuid", importpath = "github.com/google/uuid", sum = "h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=", version = "v1.3.0", ) go_repository( name = "com_github_googleapis_gax_go_v2", importpath = "github.com/googleapis/gax-go/v2", sum = "h1:dp3bWCh+PPO1zjRRiCSczJav13sBvG4UhNyVTa1KqdU=", version = "v2.1.1", ) go_repository( name = "com_github_gorilla_mux", importpath = "github.com/gorilla/mux", sum = "h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=", version = "v1.8.0", ) go_repository( name = "com_github_grpc_ecosystem_go_grpc_prometheus", importpath = "github.com/grpc-ecosystem/go-grpc-prometheus", sum = "h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=", version = "v1.2.0", ) go_repository( name = "com_github_grpc_ecosystem_grpc_gateway", importpath = "github.com/grpc-ecosystem/grpc-gateway", sum = "h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=", version = "v1.16.0", ) go_repository( name = "com_github_hashicorp_golang_lru", importpath = "github.com/hashicorp/golang-lru", sum = "h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU=", version = "v0.5.1", ) go_repository( name = "com_github_hpcloud_tail", importpath = "github.com/hpcloud/tail", sum = "h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=", version = "v1.0.0", ) go_repository( name = "com_github_ianlancetaylor_demangle", importpath = "github.com/ianlancetaylor/demangle", sum = "h1:mV02weKRL81bEnm8A0HT1/CAelMQDBuQIfLw8n+d6xI=", version = "v0.0.0-20200824232613-28f6c0f3b639", ) go_repository( name = "com_github_jpillora_backoff", importpath = "github.com/jpillora/backoff", sum = "h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA=", version = "v1.0.0", ) go_repository( name = "com_github_json_iterator_go", importpath = "github.com/json-iterator/go", sum = "h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=", version = "v1.1.12", ) go_repository( name = "com_github_jstemmer_go_junit_report", importpath = "github.com/jstemmer/go-junit-report", sum = "h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o=", version = "v0.9.1", ) go_repository( name = "com_github_julienschmidt_httprouter", importpath = "github.com/julienschmidt/httprouter", sum = "h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=", version = "v1.3.0", ) go_repository( name = "com_github_justinas_alice", importpath = "github.com/justinas/alice", sum = "h1:+MHSA/vccVCF4Uq37S42jwlkvI2Xzl7zTPCN5BnZNVo=", version = "v1.2.0", ) go_repository( name = "com_github_kisielk_gotool", importpath = "github.com/kisielk/gotool", sum = "h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=", version = "v1.0.0", ) go_repository( name = "com_github_klauspost_compress", importpath = "github.com/klauspost/compress", sum = "h1:hLQYb23E8/fO+1u53d02A97a8UnsddcvYzq4ERRU4ds=", version = "v1.14.1", ) go_repository( name = "com_github_klauspost_cpuid", importpath = "github.com/klauspost/cpuid", sum = "h1:5JNjFYYQrZeKRJ0734q51WCEEn2huer72Dc7K+R/b6s=", version = "v1.3.1", ) go_repository( name = "com_github_klauspost_cpuid_v2", importpath = "github.com/klauspost/cpuid/v2", sum = "h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=", version = "v2.0.9", ) go_repository( name = "com_github_konsorten_go_windows_terminal_sequences", importpath = "github.com/konsorten/go-windows-terminal-sequences", sum = "h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=", version = "v1.0.3", ) go_repository( name = "com_github_kr_logfmt", importpath = "github.com/kr/logfmt", sum = "h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY=", version = "v0.0.0-20140226030751-b84e30acd515", ) go_repository( name = "com_github_kr_pretty", importpath = "github.com/kr/pretty", sum = "h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=", version = "v0.3.0", ) go_repository( name = "com_github_kr_pty", importpath = "github.com/kr/pty", sum = "h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=", version = "v1.1.1", ) go_repository( name = "com_github_kr_text", importpath = "github.com/kr/text", sum = "h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=", version = "v0.2.0", ) go_repository( name = "com_github_labstack_echo_v4", importpath = "github.com/labstack/echo/v4", sum = "h1:OMVsrnNFzYlGSdaiYGHbgWQnr+JM7NG+B9suCPie14M=", version = "v4.6.1", ) go_repository( name = "com_github_labstack_gommon", importpath = "github.com/labstack/gommon", sum = "h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0=", version = "v0.3.0", ) go_repository( name = "com_github_leodido_go_urn", importpath = "github.com/leodido/go-urn", sum = "h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=", version = "v1.2.0", ) go_repository( name = "com_github_mattn_go_colorable", importpath = "github.com/mattn/go-colorable", sum = "h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=", version = "v0.1.8", ) go_repository( name = "com_github_mattn_go_isatty", importpath = "github.com/mattn/go-isatty", sum = "h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=", version = "v0.0.14", ) go_repository( name = "com_github_matttproud_golang_protobuf_extensions", importpath = "github.com/matttproud/golang_protobuf_extensions", sum = "h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=", version = "v1.0.1", ) go_repository( name = "com_github_minio_md5_simd", importpath = "github.com/minio/md5-simd", sum = "h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=", version = "v1.1.2", ) go_repository( name = "com_github_minio_minio_go_v7", importpath = "github.com/minio/minio-go/v7", sum = "h1:0+Xt1SkCKDgcx5cmo3UxXcJ37u5Gy+/2i/+eQYqmYJw=", version = "v7.0.20", ) go_repository( name = "com_github_minio_sha256_simd", importpath = "github.com/minio/sha256-simd", sum = "h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g=", version = "v1.0.0", ) go_repository( name = "com_github_mitchellh_colorstring", importpath = "github.com/mitchellh/colorstring", sum = "h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ=", version = "v0.0.0-20190213212951-d06e56a500db", ) go_repository( name = "com_github_mitchellh_go_homedir", importpath = "github.com/mitchellh/go-homedir", sum = "h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=", version = "v1.1.0", ) go_repository( name = "com_github_modern_go_concurrent", importpath = "github.com/modern-go/concurrent", sum = "h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=", version = "v0.0.0-20180306012644-bacd9c7ef1dd", ) go_repository( name = "com_github_modern_go_reflect2", importpath = "github.com/modern-go/reflect2", sum = "h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=", version = "v1.0.2", ) go_repository( name = "com_github_mostynb_go_grpc_compression", importpath = "github.com/mostynb/go-grpc-compression", sum = "h1:D9tGUINmcII049pxOj9dl32Fzhp26TrDVQXECoKJqQg=", version = "v1.1.16", ) go_repository( name = "com_github_mostynb_zstdpool_syncpool", importpath = "github.com/mostynb/zstdpool-syncpool", sum = "h1:vE8zD0+YdQD9Rca0TAGNexUCOCt1IQbdqRUHJoxxERA=", version = "v0.0.12", ) go_repository( name = "com_github_mwitkow_go_conntrack", importpath = "github.com/mwitkow/go-conntrack", sum = "h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=", version = "v0.0.0-20190716064945-2f068394615f", ) go_repository( name = "com_github_oneofone_xxhash", importpath = "github.com/OneOfOne/xxhash", sum = "h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=", version = "v1.2.2", ) go_repository( name = "com_github_onsi_ginkgo", importpath = "github.com/onsi/ginkgo", sum = "h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w=", version = "v1.8.0", ) go_repository( name = "com_github_onsi_gomega", importpath = "github.com/onsi/gomega", sum = "h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo=", version = "v1.5.0", ) go_repository( name = "com_github_pierrec_cmdflag", importpath = "github.com/pierrec/cmdflag", sum = "h1:ybjGJnPr/aURn2IKWjO49znx9N0DL6YfGsIxN0PYuVY=", version = "v0.0.2", ) go_repository( name = "com_github_pierrec_lz4_v3", importpath = "github.com/pierrec/lz4/v3", sum = "h1:fqXL+KOc232xP6JgmKMp22fd+gn8/RFZjTreqbbqExc=", version = "v3.3.4", ) go_repository( name = "com_github_pkg_errors", importpath = "github.com/pkg/errors", sum = "h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=", version = "v0.9.1", ) go_repository( name = "com_github_pmezard_go_difflib", importpath = "github.com/pmezard/go-difflib", sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=", version = "v1.0.0", ) go_repository( name = "com_github_prometheus_client_golang", importpath = "github.com/prometheus/client_golang", sum = "h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf3/SASFAGtQ=", version = "v1.11.0", ) go_repository( name = "com_github_prometheus_client_model", importpath = "github.com/prometheus/client_model", sum = "h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=", version = "v0.2.0", ) go_repository( name = "com_github_prometheus_common", importpath = "github.com/prometheus/common", sum = "h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4=", version = "v0.32.1", ) go_repository( name = "com_github_prometheus_procfs", importpath = "github.com/prometheus/procfs", sum = "h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU=", version = "v0.7.3", ) go_repository( name = "com_github_prometheus_statsd_exporter", importpath = "github.com/prometheus/statsd_exporter", sum = "h1:hA05Q5RFeIjgwKIYEdFd59xu5Wwaznf33yKI+pyX6T8=", version = "v0.21.0", ) go_repository( name = "com_github_rogpeppe_fastuuid", importpath = "github.com/rogpeppe/fastuuid", sum = "h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi2s=", version = "v1.2.0", ) go_repository( name = "com_github_rogpeppe_go_internal", importpath = "github.com/rogpeppe/go-internal", sum = "h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=", version = "v1.6.1", ) go_repository( name = "com_github_rs_xid", importpath = "github.com/rs/xid", sum = "h1:6NjYksEUlhurdVehpc7S7dk6DAmcKv8V9gG0FsVN2U4=", version = "v1.3.0", ) go_repository( name = "com_github_russross_blackfriday_v2", importpath = "github.com/russross/blackfriday/v2", sum = "h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=", version = "v2.1.0", ) go_repository( name = "com_github_savsgio_gotils", importpath = "github.com/savsgio/gotils", sum = "h1:ocK/D6lCgLji37Z2so4xhMl46se1ntReQQCUIU4BWI8=", version = "v0.0.0-20210921075833-21a6215cb0e4", ) go_repository( name = "com_github_schollz_progressbar_v2", importpath = "github.com/schollz/progressbar/v2", sum = "h1:3L9bP5KQOGEnFP8P5V8dz+U0yo5I29iY5Oa9s9EAwn0=", version = "v2.13.2", ) go_repository( name = "com_github_shurcool_sanitized_anchor_name", importpath = "github.com/shurcooL/sanitized_anchor_name", sum = "h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=", version = "v1.0.0", ) go_repository( name = "com_github_sirupsen_logrus", importpath = "github.com/sirupsen/logrus", sum = "h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=", version = "v1.8.1", ) go_repository( name = "com_github_slok_go_http_metrics", importpath = "github.com/slok/go-http-metrics", sum = "h1:rh0LaYEKza5eaYRGDXujKrOln57nHBi4TtVhmNEpbgM=", version = "v0.10.0", ) go_repository( name = "com_github_smartystreets_goconvey", importpath = "github.com/smartystreets/goconvey", sum = "h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=", version = "v1.6.4", ) go_repository( name = "com_github_spaolacci_murmur3", importpath = "github.com/spaolacci/murmur3", sum = "h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ=", version = "v0.0.0-20180118202830-f09979ecbc72", ) go_repository( name = "com_github_stretchr_objx", importpath = "github.com/stretchr/objx", sum = "h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=", version = "v0.1.1", ) go_repository( name = "com_github_stretchr_testify", importpath = "github.com/stretchr/testify", sum = "h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=", version = "v1.7.0", ) go_repository( name = "com_github_ugorji_go_codec", importpath = "github.com/ugorji/go/codec", sum = "h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=", version = "v1.1.7", ) go_repository( name = "com_github_urfave_cli_v2", importpath = "github.com/urfave/cli/v2", sum = "h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=", version = "v2.3.0", ) go_repository( name = "com_github_urfave_negroni", importpath = "github.com/urfave/negroni", sum = "h1:kIimOitoypq34K7TG7DUaJ9kq/N4Ofuwi1sjz0KipXc=", version = "v1.0.0", ) go_repository( name = "com_github_valyala_bytebufferpool", importpath = "github.com/valyala/bytebufferpool", sum = "h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=", version = "v1.0.0", ) go_repository( name = "com_github_valyala_fasthttp", importpath = "github.com/valyala/fasthttp", sum = "h1:lrauRLII19afgCs2fnWRJ4M5IkV0lo2FqA61uGkNBfE=", version = "v1.31.0", ) go_repository( name = "com_github_valyala_fasttemplate", importpath = "github.com/valyala/fasttemplate", sum = "h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4=", version = "v1.2.1", ) go_repository( name = "com_github_yuin_goldmark", importpath = "github.com/yuin/goldmark", sum = "h1:dPmz1Snjq0kmkz159iL7S6WzdahUTHnHB5M56WFVifs=", version = "v1.3.5", ) go_repository( name = "com_google_cloud_go", importpath = "cloud.google.com/go", sum = "h1:y/cM2iqGgGi5D5DQZl6D9STN/3dR/Vx5Mp8s752oJTY=", version = "v0.99.0", ) go_repository( name = "com_google_cloud_go_bigquery", importpath = "cloud.google.com/go/bigquery", sum = "h1:PQcPefKFdaIzjQFbiyOgAqyx8q5djaE7x9Sqe712DPA=", version = "v1.8.0", ) go_repository( name = "com_google_cloud_go_datastore", importpath = "cloud.google.com/go/datastore", sum = "h1:/May9ojXjRkPBNVrq+oWLqmWCkr4OU5uRY29bu0mRyQ=", version = "v1.1.0", ) go_repository( name = "com_google_cloud_go_pubsub", importpath = "cloud.google.com/go/pubsub", sum = "h1:ukjixP1wl0LpnZ6LWtZJ0mX5tBmjp1f8Sqer8Z2OMUU=", version = "v1.3.1", ) go_repository( name = "com_google_cloud_go_storage", importpath = "cloud.google.com/go/storage", sum = "h1:STgFzyU5/8miMl0//zKh2aQeTyeaUH3WN9bSUiJ09bA=", version = "v1.10.0", ) go_repository( name = "com_shuralyov_dmitri_gpu_mtl", importpath = "dmitri.shuralyov.com/gpu/mtl", sum = "h1:VpgP7xuJadIUuKccphEpTJnWhS2jkQyMt6Y7pJCD7fY=", version = "v0.0.0-20190408044501-666a987793e9", ) go_repository( name = "in_gopkg_alecthomas_kingpin_v2", importpath = "gopkg.in/alecthomas/kingpin.v2", sum = "h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=", version = "v2.2.6", ) go_repository( name = "in_gopkg_check_v1", importpath = "gopkg.in/check.v1", sum = "h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=", version = "v1.0.0-20190902080502-41f04d3bba15", ) go_repository( name = "in_gopkg_errgo_v2", importpath = "gopkg.in/errgo.v2", sum = "h1:0vLT13EuvQ0hNvakwLuFZ/jYrLp5F3kcWHXdRggjCE8=", version = "v2.1.0", ) go_repository( name = "in_gopkg_fsnotify_v1", importpath = "gopkg.in/fsnotify.v1", sum = "h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=", version = "v1.4.7", ) go_repository( name = "in_gopkg_ini_v1", importpath = "gopkg.in/ini.v1", sum = "h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI=", version = "v1.66.2", ) go_repository( name = "in_gopkg_tomb_v1", importpath = "gopkg.in/tomb.v1", sum = "h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=", version = "v1.0.0-20141024135613-dd632973f1e7", ) go_repository( name = "in_gopkg_yaml_v2", importpath = "gopkg.in/yaml.v2", sum = "h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=", version = "v2.4.0", ) go_repository( name = "in_gopkg_yaml_v3", importpath = "gopkg.in/yaml.v3", sum = "h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=", version = "v3.0.0-20200313102051-9f266ea9e77c", ) go_repository( name = "io_goji", importpath = "goji.io", sum = "h1:uIssv/elbKRLznFUy3Xj4+2Mz/qKhek/9aZQDUMae7c=", version = "v2.0.2+incompatible", ) go_repository( name = "io_opencensus_go", importpath = "go.opencensus.io", sum = "h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M=", version = "v0.23.0", ) go_repository( name = "io_opencensus_go_contrib_exporter_prometheus", importpath = "contrib.go.opencensus.io/exporter/prometheus", sum = "h1:0QfIkj9z/iVZgK31D9H9ohjjIDApI2GOPScCKwxedbs=", version = "v0.4.0", ) go_repository( name = "io_opentelemetry_go_proto_otlp", importpath = "go.opentelemetry.io/proto/otlp", sum = "h1:rwOQPCuKAKmwGKq2aVNnYIibI6wnV7EvzgfTCzcdGg8=", version = "v0.7.0", ) go_repository( name = "io_rsc_binaryregexp", importpath = "rsc.io/binaryregexp", sum = "h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE=", version = "v0.2.0", ) go_repository( name = "io_rsc_quote_v3", importpath = "rsc.io/quote/v3", sum = "h1:9JKUTTIUgS6kzR9mK1YuGKv6Nl+DijDNIc0ghT58FaY=", version = "v3.1.0", ) go_repository( name = "io_rsc_sampler", importpath = "rsc.io/sampler", sum = "h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=", version = "v1.3.0", ) go_repository( name = "org_cloudfoundry_code_bytefmt", importpath = "code.cloudfoundry.org/bytefmt", sum = "h1:tW+ztA4A9UT9xnco5wUjW1oNi35k22eUEn9tNpPYVwE=", version = "v0.0.0-20190710193110-1eb035ffe2b6", ) go_repository( name = "org_golang_google_api", importpath = "google.golang.org/api", sum = "h1:TXXKS1slM3b2bZNJwD5DV/Tp6/M2cLzLOLh9PjDhrw8=", version = "v0.61.0", ) go_repository( name = "org_golang_google_appengine", importpath = "google.golang.org/appengine", sum = "h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=", version = "v1.6.7", ) go_repository( name = "org_golang_google_genproto", importpath = "google.golang.org/genproto", sum = "h1:ZrsicilzPCS/Xr8qtBZZLpy4P9TYXAfl49ctG1/5tgw=", version = "v0.0.0-20211223182754-3ac035c7e7cb", ) go_repository( name = "org_golang_google_grpc", importpath = "google.golang.org/grpc", sum = "h1:Eeu7bZtDZ2DpRCsLhUlcrLnvYaMK1Gz86a+hMVvELmM=", version = "v1.43.0", ) go_repository( name = "org_golang_google_grpc_cmd_protoc_gen_go_grpc", importpath = "google.golang.org/grpc/cmd/protoc-gen-go-grpc", sum = "h1:M1YKkFIboKNieVO5DLUEVzQfGwJD30Nv2jfUgzb5UcE=", version = "v1.1.0", ) go_repository( name = "org_golang_google_protobuf", importpath = "google.golang.org/protobuf", sum = "h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=", version = "v1.27.1", ) go_repository( name = "org_golang_x_crypto", importpath = "golang.org/x/crypto", sum = "h1:0es+/5331RGQPcXlMfP+WrnIIS6dNnNRe0WB02W0F4M=", version = "v0.0.0-20211215153901-e495a2d5b3d3", ) go_repository( name = "org_golang_x_exp", importpath = "golang.org/x/exp", sum = "h1:QE6XYQK6naiK1EPAe1g/ILLxN5RBoH5xkJk3CqlMI/Y=", version = "v0.0.0-20200224162631-6cc2880d07d6", ) go_repository( name = "org_golang_x_image", importpath = "golang.org/x/image", sum = "h1:+qEpEAPhDZ1o0x3tHzZTQDArnOixOzGD9HUJfcg0mb4=", version = "v0.0.0-20190802002840-cff245a6509b", ) go_repository( name = "org_golang_x_lint", importpath = "golang.org/x/lint", sum = "h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=", version = "v0.0.0-20210508222113-6edffad5e616", ) go_repository( name = "org_golang_x_mobile", importpath = "golang.org/x/mobile", sum = "h1:4+4C/Iv2U4fMZBiMCc98MG1In4gJY5YRhtpDNeDeHWs=", version = "v0.0.0-20190719004257-d2bd2a29d028", ) go_repository( name = "org_golang_x_mod", importpath = "golang.org/x/mod", sum = "h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=", version = "v0.4.2", ) go_repository( name = "org_golang_x_net", importpath = "golang.org/x/net", sum = "h1:hEYJvxw1lSnWIl8X9ofsYMklzaDs90JI2az5YMd4fPM=", version = "v0.0.0-20211216030914-fe4d6282115f", ) go_repository( name = "org_golang_x_oauth2", importpath = "golang.org/x/oauth2", sum = "h1:RerP+noqYHUQ8CMRcPlC2nvTa4dcBIjegkuWdcUDuqg=", version = "v0.0.0-20211104180415-d3ed0bb246c8", ) go_repository( name = "org_golang_x_sync", importpath = "golang.org/x/sync", sum = "h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=", version = "v0.0.0-20210220032951-036812b2e83c", ) go_repository( name = "org_golang_x_sys", importpath = "golang.org/x/sys", sum = "h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=", version = "v0.0.0-20211216021012-1d35b9e2eb4e", ) go_repository( name = "org_golang_x_term", importpath = "golang.org/x/term", sum = "h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=", version = "v0.0.0-20201126162022-7de9c90e9dd1", ) go_repository( name = "org_golang_x_text", importpath = "golang.org/x/text", sum = "h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=", version = "v0.3.7", ) go_repository( name = "org_golang_x_time", importpath = "golang.org/x/time", sum = "h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=", version = "v0.0.0-20191024005414-555d28b269f0", ) go_repository( name = "org_golang_x_tools", importpath = "golang.org/x/tools", sum = "h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=", version = "v0.1.5", ) go_repository( name = "org_golang_x_xerrors", importpath = "golang.org/x/xerrors", sum = "h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=", version = "v0.0.0-20200804184101-5ec99f83aff1", )
k=[] for i in range(3): #while True: try: a=input() except: break k.append(a) check = [True for i in range(len(k))] check_three = False three_s=(-1,-1) three_e=(-1,-1) remove_list = [] for num,i in enumerate(k): for j in range(len(i)): if j+2 <len(i): if not check_three and (i[j],i[j+1],i[j+2]) == ('`','`','`'): three_s=(num,j) check_three=True elif check_three and (i[j],i[j+1],i[j+2]) == ('`','`','`'): three_e=(num,j+2) remove_list.append((three_s,three_e)) three_s=(-1,-1) three_e=(-1,-1) check_three=False print(remove_list)
# 多处理异常 print('start') # 存在异常的代码 try: # 捕获异常 a=int(input('请输入一个数值:')) print('你输入的数值:', a) print(100 / a) except ValueError: # 处理异常 print('ValueError') except ZeroDivisionError: print('ZeroDivisionError') except: print('final exept') print('end...')
# # Device Database and registry # # Need to be adapted to your local devices. # And these are just default values, not my ones... :) mqtt_ip = "192.168.178.10" mqtt_port = 1883 influxdb_ip = "192.168.178.12" influxdb_user = "myuser" influxdb_pw = "mypw" influxdb_db = "mydb" fritz_ip = "192.168.17.1" fritz_user = "fritzuser" fritz_pw = "fritzpasswd" fritz_evswitch = "11234 0134134" gen24_ip = "192.168.178.13" ipump_ip = "192.168.178.14"
def react_chat_red(eventType, GPIO): RED_LED = 'P8_8' if len(eventType) != 0: if eventType[0] == "on": GPIO.output(RED_LED, GPIO.HIGH) elif eventType[0] == "off": GPIO.output(RED_LED, GPIO.LOW) elif eventType[0] == "toggle": state = GPIO.input(RED_LED) if state == 1: GPIO.output(RED_LED, GPIO.LOW) elif state == 0: GPIO.output(RED_LED, GPIO.HIGH)
#%% def numDistinctIslands(grid): cnt_row, cnt_col = len(grid), len(grid[0]) def dfs(index_row, index_col, dir): if ( index_row < 0 or index_row >= cnt_row or index_col < 0 or index_col >= cnt_col or not grid[index_row][index_col] ): return "" grid[index_row][index_col] = 0 return ( dir + dfs(index_row + 1, index_col, "1") + dfs(index_row - 1, index_col, "2") + dfs(index_row, index_col + 1, "3") + dfs(index_row, index_col - 1, "4") + "-" + dir ) island_set = set() for index_row in range(cnt_row): for index_col in range(cnt_col): if grid[index_row][index_col]: island_set.add(dfs(index_row, index_col, "*")) print(island_set) return len(island_set) grid = [[1, 1, 0, 1, 1], [1, 0, 0, 0, 0], [0, 0, 0, 0, 1], [1, 1, 0, 1, 1]] print(numDistinctIslands(grid)) # %%
""" Experiment on the work of Faten. Manully define preference relationship between several alternatives and run the . """ # Author: Yiru Zhang <yiru.zhang@irisa.fr> # License: Unlicense
with open('input') as f: data = f.read().strip().split('\n') initial = {(j, i, 0, 0) for i, s in enumerate(data) for j, c in enumerate(s) if c=='#'} def fence(s): min_x = min(s, key=lambda x: x[0])[0] min_y = min(s, key=lambda x: x[1])[1] min_z = min(s, key=lambda x: x[2])[2] min_w = min(s, key=lambda x: x[3])[3] max_x = max(s, key=lambda x: x[0])[0] max_y = max(s, key=lambda x: x[1])[1] max_z = max(s, key=lambda x: x[2])[2] max_w = max(s, key=lambda x: x[3])[3] return (min_x-1, max_x+2), (min_y-1, max_y+2), (min_z-1, max_z+2), (min_w-1, max_w+2) def neighbours(s, x, y, z, w): n=0 for _x in range(x-1, x+2): for _y in range(y-1, y+2): for _z in range(z-1, z+2): for _w in range(w-1, w+2): if not (_x==x and _y==y and _z==z and _w==w): if (_x, _y, _z, _w) in s: n+=1 return n for _ in range(6): new = set() r_x, r_y, r_z, r_w = fence(initial) for x in range(*r_x): for y in range(*r_y): for z in range(*r_z): for w in range(*r_w): n = neighbours(initial, x, y, z, w) if (x,y,z, w) in initial: if n==2 or n==3: new.add((x,y,z,w)) else: if n==3: new.add((x,y,z,w)) initial = new print(len(initial)) print('done')
# import time # #Indroduction to the game # print("Hello there \nWelcome to TIC-TAC-TOE") # time.sleep(1) # #list of numbers # num_list = [1,2,3,4,5,6,7,8,9] # print(num_list) # #Request for tutorial # def tutorial(): # tutorial_list = ["=>This game is restricted to 2 players only", # "=>There are two characters used to play this game 'X' and 'O'", # "=>Whoever chooses 'X' would go first", # "=>A board would be printed out every time a player makes a move", # "=>Numbers 1-9 would be used to determine postions on the board", # "=>The first player to get '3' of their characters to either horizontally, vertically or diagonally WINS!", # "=>Goodluck and REMEMBER TO HAVE FUN"] # for item in tutorial_list: # print(item) # time.sleep(5) # #countdown to begin game # def countdown(): # t = 3 # while t > 0: # print(t) # time.sleep(1) # t -=1 # return "Lets Go!!!" # def begin_game(): # start = 'no' # if start == 'y': # print(countdown()) # elif start == 'n': # print('Closing Game') # while start != 'y' or start !='n': # start = input("Begin Game?(y/n)") # start = start.lower() boardlist = [" " for i in range(10)] boardlist[0] = "nil" def board(boardlist): print(f"\n {boardlist[1]} | {boardlist[2]} | {boardlist[3]} ") print("-----|-----|-----") print(f" {boardlist[4]} | {boardlist[5]} | {boardlist[6]} ") print("-----|-----|-----") print(f" {boardlist[7]} | {boardlist[8]} | {boardlist[9]} ") def insertLetter(pos, letter): board[pos] = letter def freeSpace(pos): return boardlist[pos] == " " def isBoardFull(): return " " not in boardlist def playerMove(): a = True while a: position = input("Enter the position to place an 'X' (1-9): ") try: position = int(position) if position in range(1,10): if freeSpace(position): insertLetter(position, 'X') a = False else: print("Sorry, this spot is occupied!") else: print("Enter a number between 1-9!") except: print("Enter a number!") def computerMove(): possiblePositions = [] for i, letter in enumerate(boardlist): if letter == " ": possiblePositions.append(i) moves = ['X', 'O'] for _ in moves: for i in possiblePositions: sampleBoard = boardlist[:] sampleBoard[i] = _ if checkWin(sampleBoard, _): move = i return move # function to check who won the game def checkWin(bod, let): return (bod[1] == let and bod[2] == let and bod[3] == let) or (bod[4] == let and bod[5] == let and bod[6] == let) or (bod[7] == let and bod[8] == let and bod[9] == let) or (bod[1] == let and bod[4] == let and bod[7] == let) or (bod[2] == let and bod[5] == let and bod[8] == let) or (bod[3] == let and bod[6] == let and bod[9] == let) or (bod[1] == let and bod[5] == let and bod[9] == let) or (bod[3] == let and bod[5] == let and bod[7] == let) def m(): game = 3 charCount = 1 while game > 0: if charCount % 2 == 0: char = 'O' else: char = 'X' print(char) charCount += 1 game -= 1 def preset(): new = 'none' new = new.lower() while new != 'y': new = input('Do you wish to go through the tutorial?(y/n): ') return tutorial() print(begin_game()) def main(): board() while not isBoardFull(): if checkWin(boardlist, 'X'): print("X won!") break else: computerMove() board() if checkWin(boardlist, 'O'): print("O won!") break else: playerMove() board() else: print("Tie game") #function to print the score board def scoreboard(score_board): print("------------------------------") print(" SCOREBOARD ") print("------------------------------") players = [score_board.keys()] for i in range(2): print(f" {players[i]}, {score_board[players[i]]}") print("------------------------------")
# # PySNMP MIB module HH3C-MIRRORGROUP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HH3C-MIRRORGROUP-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:15:33 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, SingleValueConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint", "SingleValueConstraint", "ConstraintsUnion") hh3cCommon, = mibBuilder.importSymbols("HH3C-OID-MIB", "hh3cCommon") ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup") MibIdentifier, ObjectIdentity, ModuleIdentity, NotificationType, TimeTicks, iso, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter32, Bits, Unsigned32, IpAddress, Integer32, Gauge32, Counter64 = mibBuilder.importSymbols("SNMPv2-SMI", "MibIdentifier", "ObjectIdentity", "ModuleIdentity", "NotificationType", "TimeTicks", "iso", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter32", "Bits", "Unsigned32", "IpAddress", "Integer32", "Gauge32", "Counter64") RowStatus, TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "RowStatus", "TextualConvention", "DisplayString") hh3cMirrGroup = ModuleIdentity((1, 3, 6, 1, 4, 1, 25506, 2, 68)) hh3cMirrGroup.setRevisions(('2006-01-10 19:03',)) if mibBuilder.loadTexts: hh3cMirrGroup.setLastUpdated('200601131403Z') if mibBuilder.loadTexts: hh3cMirrGroup.setOrganization('Hangzhou H3C Tech. Co., Ltd.') hh3cMGInfoObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1)) hh3cMGObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1)) hh3cMGTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1), ) if mibBuilder.loadTexts: hh3cMGTable.setStatus('current') hh3cMGEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1), ).setIndexNames((0, "HH3C-MIRRORGROUP-MIB", "hh3cMGID")) if mibBuilder.loadTexts: hh3cMGEntry.setStatus('current') hh3cMGID = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1, 1), Integer32()) if mibBuilder.loadTexts: hh3cMGID.setStatus('current') hh3cMGType = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("local", 1), ("remoteSource", 2), ("remoteDestination", 3)))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cMGType.setStatus('current') hh3cMGStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("active", 1), ("inactive", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: hh3cMGStatus.setStatus('current') hh3cMGRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1, 4), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cMGRowStatus.setStatus('current') hh3cMGMirrorIfObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2)) hh3cMGMirrorIfTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1), ) if mibBuilder.loadTexts: hh3cMGMirrorIfTable.setStatus('current') hh3cMGMirrorIfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1, 1), ).setIndexNames((0, "HH3C-MIRRORGROUP-MIB", "hh3cMGID"), (0, "HH3C-MIRRORGROUP-MIB", "hh3cMGMirrorIfIndex"), (0, "HH3C-MIRRORGROUP-MIB", "hh3cMGMirrorDirection")) if mibBuilder.loadTexts: hh3cMGMirrorIfEntry.setStatus('current') hh3cMGMirrorIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1, 1, 1), Integer32()) if mibBuilder.loadTexts: hh3cMGMirrorIfIndex.setStatus('current') hh3cMGMirrorDirection = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("inbound", 1), ("outbound", 2), ("both", 3)))) if mibBuilder.loadTexts: hh3cMGMirrorDirection.setStatus('current') hh3cMGMirrorRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1, 1, 3), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cMGMirrorRowStatus.setStatus('current') hh3cMGMonitorIfObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3)) hh3cMGMonitorIfTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3, 1), ) if mibBuilder.loadTexts: hh3cMGMonitorIfTable.setStatus('current') hh3cMGMonitorIfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3, 1, 1), ).setIndexNames((0, "HH3C-MIRRORGROUP-MIB", "hh3cMGID"), (0, "HH3C-MIRRORGROUP-MIB", "hh3cMGMonitorIfIndex")) if mibBuilder.loadTexts: hh3cMGMonitorIfEntry.setStatus('current') hh3cMGMonitorIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3, 1, 1, 1), Integer32()) if mibBuilder.loadTexts: hh3cMGMonitorIfIndex.setStatus('current') hh3cMGMonitorRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3, 1, 1, 2), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cMGMonitorRowStatus.setStatus('current') hh3cMGReflectorIfObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4)) hh3cMGReflectorIfTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4, 1), ) if mibBuilder.loadTexts: hh3cMGReflectorIfTable.setStatus('current') hh3cMGReflectorIfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4, 1, 1), ).setIndexNames((0, "HH3C-MIRRORGROUP-MIB", "hh3cMGID"), (0, "HH3C-MIRRORGROUP-MIB", "hh3cMGReflectorIfIndex")) if mibBuilder.loadTexts: hh3cMGReflectorIfEntry.setStatus('current') hh3cMGReflectorIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4, 1, 1, 1), Integer32()) if mibBuilder.loadTexts: hh3cMGReflectorIfIndex.setStatus('current') hh3cMGReflectorRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4, 1, 1, 2), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cMGReflectorRowStatus.setStatus('current') hh3cMGRprobeVlanObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5)) hh3cMGRprobeVlanTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5, 1), ) if mibBuilder.loadTexts: hh3cMGRprobeVlanTable.setStatus('current') hh3cMGRprobeVlanEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5, 1, 1), ).setIndexNames((0, "HH3C-MIRRORGROUP-MIB", "hh3cMGID"), (0, "HH3C-MIRRORGROUP-MIB", "hh3cMGRprobeVlanID")) if mibBuilder.loadTexts: hh3cMGRprobeVlanEntry.setStatus('current') hh3cMGRprobeVlanID = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 4094))) if mibBuilder.loadTexts: hh3cMGRprobeVlanID.setStatus('current') hh3cMGRprobeVlanRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5, 1, 1, 2), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cMGRprobeVlanRowStatus.setStatus('current') mibBuilder.exportSymbols("HH3C-MIRRORGROUP-MIB", hh3cMGMonitorRowStatus=hh3cMGMonitorRowStatus, hh3cMGRprobeVlanObjects=hh3cMGRprobeVlanObjects, hh3cMGMirrorRowStatus=hh3cMGMirrorRowStatus, hh3cMGRowStatus=hh3cMGRowStatus, hh3cMGObjects=hh3cMGObjects, hh3cMGMonitorIfIndex=hh3cMGMonitorIfIndex, hh3cMGRprobeVlanEntry=hh3cMGRprobeVlanEntry, hh3cMGMonitorIfObjects=hh3cMGMonitorIfObjects, hh3cMGReflectorIfTable=hh3cMGReflectorIfTable, hh3cMGReflectorIfObjects=hh3cMGReflectorIfObjects, hh3cMGMirrorIfTable=hh3cMGMirrorIfTable, hh3cMGReflectorIfIndex=hh3cMGReflectorIfIndex, hh3cMGRprobeVlanTable=hh3cMGRprobeVlanTable, hh3cMGRprobeVlanRowStatus=hh3cMGRprobeVlanRowStatus, hh3cMGMonitorIfEntry=hh3cMGMonitorIfEntry, hh3cMirrGroup=hh3cMirrGroup, hh3cMGMirrorIfIndex=hh3cMGMirrorIfIndex, hh3cMGMirrorIfEntry=hh3cMGMirrorIfEntry, PYSNMP_MODULE_ID=hh3cMirrGroup, hh3cMGID=hh3cMGID, hh3cMGInfoObjects=hh3cMGInfoObjects, hh3cMGTable=hh3cMGTable, hh3cMGMirrorIfObjects=hh3cMGMirrorIfObjects, hh3cMGReflectorIfEntry=hh3cMGReflectorIfEntry, hh3cMGReflectorRowStatus=hh3cMGReflectorRowStatus, hh3cMGType=hh3cMGType, hh3cMGStatus=hh3cMGStatus, hh3cMGEntry=hh3cMGEntry, hh3cMGMonitorIfTable=hh3cMGMonitorIfTable, hh3cMGMirrorDirection=hh3cMGMirrorDirection, hh3cMGRprobeVlanID=hh3cMGRprobeVlanID)
'''THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.''' # Bitcoin Cash (BCH) qpz32c4lg7x7lnk9jg6qg7s4uavdce89myax5v5nuk # Ether (ETH) - 0x843d3DEC2A4705BD4f45F674F641cE2D0022c9FB # Litecoin (LTC) - Lfk5y4F7KZa9oRxpazETwjQnHszEPvqPvu # Bitcoin (BTC) - 34L8qWiQyKr8k4TnHDacfjbaSqQASbBtTd # contact :- github@jamessawyer.co.uk """ You have m types of coins available in infinite quantities where the value of each coins is given in the array S=[S0,... Sm-1] Can you determine number of ways of making change for n units using the given types of coins? https://www.hackerrank.com/challenges/coin-change/problem """ def dp_count(S, m, n): # table[i] represents the number of ways to get to amount i table = [0] * (n + 1) # There is exactly 1 way to get to zero(You pick no coins). table[0] = 1 # Pick all coins one by one and update table[] values # after the index greater than or equal to the value of the # picked coin for coin_val in S: for j in range(coin_val, n + 1): table[j] += table[j - coin_val] return table[n] if __name__ == "__main__": print(dp_count([1, 2, 3], 3, 4)) # answer 4 print(dp_count([2, 5, 3, 6], 4, 10)) # answer 5
# 2020.07.26 # May not have time to do it on 27th, so... # Problem Statement # https://leetcode.com/problems/merge-k-sorted-lists/ # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next # one by one compare class Solution: def mergeKLists(self, lists: List[ListNode]) -> ListNode: # get rid of empty linked lists lists = [i for i in lists if i] # check empty case if len(lists) == 0: return None # initialize pointers list_ptr = [] for list_head in lists: list_ptr.append(list_head) answer_ptr = ListNode() answer_head = ListNode() first_time = True # loop until finish going through all the nodes while len(list_ptr) != 0: # pick the smallest value and add smallest = inf smallest_idx = 0 for i in range(0, len(list_ptr)): if list_ptr[i] is not None and list_ptr[i].val < smallest: smallest = list_ptr[i].val smallest_idx = i answer_ptr.val = smallest if first_time: answer_head = answer_ptr first_time = False # move the ptr which points to the smallest value to the next if list_ptr[smallest_idx].next is not None: list_ptr[smallest_idx] = list_ptr[smallest_idx].next # if has been traversed, remove from the list else: list_ptr.remove(list_ptr[smallest_idx]) # if all have been traversed if len(list_ptr) == 0: return answer_head else: # should add other nodes answer_ptr.next = ListNode() answer_ptr = answer_ptr.next # only one list left, can do early return if len(list_ptr) == 1: answer_ptr.val = list_ptr[0].val answer_ptr.next = list_ptr[0].next return answer_head return answer_head
def test_valid(cldf_dataset, cldf_logger): assert cldf_dataset.validate(log=cldf_logger) def test_languages(cldf_dataset, cldf_logger): assert len(list(cldf_dataset['LanguageTable'])) == 14 def test_sources(cldf_dataset, cldf_logger): assert len(cldf_dataset.sources) == 1 def test_parameters(cldf_dataset, cldf_logger): assert len(list(cldf_dataset['ParameterTable'])) == 140 def test_forms(cldf_dataset, cldf_logger): assert len(list(cldf_dataset['FormTable'])) == 1960 # 90829 komba sun mirâsiŋ sun assert len([ f for f in cldf_dataset['FormTable'] if f['Form'] == 'mirâsiŋ' ]) == 1 def test_cognates(cldf_dataset, cldf_logger): cogsets = {c['Cognateset_ID'] for c in cldf_dataset['CognateTable']} assert len(cogsets) == 949
print('-=' * 20, 'CADASTRO DE USUÁRIOS', '-=' * 20) r = '' mais18 = homens = mulheresMenos20 = 0 while True: idade = int(input('Idade: ')) sexo = str(input('Sexo [M/F]:')).strip().upper()[0] while sexo not in 'M/F': sexo = str(input('Sexo [M/F]:')).strip().upper()[0] if idade > 18: mais18 += 1 if sexo == 'M': homens += 1 if sexo == 'F' and idade < 20: mulheresMenos20 += 1 r = str(input('Quer continuar? [S/N]: ')).strip().upper()[0] while r not in 'S/N': r = str(input('Quer continuar? [S/N]: ')).strip().upper()[0] if r == 'N': break print(f'''Ao todo, temos {homens} homens, {mais18} pessoas acima de 18 anos e {mulheresMenos20} mulheres abaixo de 20 anos''')
meny = """ Hvilken størrelse skal du finne? 1) Strekning s 2) Fart v 3) Tid t """ enhetsmeny = """ Hvilken enhet skal du bruke? 1) lengde: kilometer, tid: timer, fart: km/t 2) lengde: meter, tid: sekunder, fart: m/s 3) lengde: meter, tid: minutter, fart: m/min """ # les inn hvilket problem brukeren ønsker å løse ukjent_storrelse = input(meny) enhet = int(input(enhetsmeny)) - 1 # les av enhetene brukeren ønsker å benytte enheter = [('km', 'timer', 'km/t'), ('m', 'min', 'm/min'), ('m', 's', 'm/s')] strekningsenhet, tidsenhet, fartsenhet = enheter[enhet] if ukjent_storrelse == '1': v = float(input(f'Skriv inn farta v [{fartsenhet}]: ')) t = float(input(f'Skriv inn tiden t [{tidsenhet}]: ')) s = v*t print("strekningen s: ", s, strekningsenhet) elif ukjent_storrelse == '2': s = float(input(f'Skriv inn strekningen s [{strekningsenhet}]: ')) t = float(input(f'Skriv inn tiden t [{tidsenhet}]: ')) v = s/t print("farte v: ", v, fartsenhet) elif ukjent_storrelse == '3': s = float(input(f'Skriv inn strekningen s [{strekningsenhet}]: ')) v = float(input(f'Skriv inn farta v [{fartsenhet}]: ')) t = s/v print('Tiden t: ', t, tidsenhet)
# Python Week 3 Day-16 # الصفوف )الأزواج المرتبة( في لغة البايثون # Python Tuples mytuple = ("Python", "Java", "C++", "C#") print(mytuple) print("--------------------------------\n") # في المثال التالي قمنا بتعريف tuple فارغ ، لا يحتوي على أي عنصر. # An empty tuple in Python. EmptyTuple = () print(EmptyTuple) print("--------------------------------\n") # في المثال التالي قمنا بتعريف tuple يحتوي على عنصر واحد فقط. # tupleitem = ("Python",) print(tupleitem) print("--------------------------------\n") # في المثال التالي قمنا بتعريف tuple يحتوي على أعداد صحيحة وعشرية # هنا لا حاجة لوضع فاصلة , إضافية بعد آخر قيمة كما في المثال السابق num_tuple = (2, 3, 1.5, 3.7) print(num_tuple) print("--------------------------------\n") # The data inside a tuple can be of one or more data types. """ في المثال التالي قمنا بتعريف tuple يحتوي على عدة أنواع من أنواع البيانات: أعداد صحيحة، أعداد عشرية، ونصوص. """ data_types_tuple = ("Samsung", 2, "Apple", 2.3) print(data_types_tuple) print("--------------------------------\n") # للوصول لأي عنصر في tuplee عليك استخدام رقم ال index الخاص بالعنصر، باستخدام الأقواس المربعة [] # You can access tuple items by referring to the index number, inside square brackets []. """ print(tuple_items[1]) print(tuple_items[2]) print(tuple_items[3]) """ tuple_items = ("Python", "Java", "C++", "C#") print( " 0- Python", " 1- Java", " 2- C++", " 3- C#") # Example print("index 0 = ",tuple_items[0]) print("index 1 = ",tuple_items[1]) print("index 2 = ",tuple_items[2]) print("index 3 = ",tuple_items[3]) print("--------------------------------\n") # Once a tuple is created, you cannot change its values. Tuples are unchangeable. # في ال tuple لا يمكنك تغيير القيم التي تسندها إليها أثناء إنشائها، فهي غير قابلة للتغير أو التعديل عليها. # في ال tuple القيم غير قابلة للتغيير أو التعديل عليها. print("--------------------------------\n") """ هنا قمنا بتعريف tuple تحتوي على نصوص ثم قمنا بطباعة جميع القيم باستخدام الحلقة You can loop through the tuple items by using a for loop. """ thistuple = ("apple", "banana", "cherry", "orange", "kiwi", "melon", "mango") for basket in thistuple: print(basket) print("--------------------------------\n") """ تقسيم ال tuple إلى أجزاء / تجزئة ال tuple إذا أردنا عرض أو طباعة جزء من عناصر ال tuple نقوم بعرض العناصر كما في القوائم عن طريق رقم ال index Divide the tuple into parts / fragment the tuple If we want to display or print part of the items tuple we display the items as in the menus via Index """ thistuple = ("apple", "banana", "cherry", "orange", "kiwi", "melon", "mango") print(" 0- apple", " 1- banana", " 2- cherry", " 3- orange", " 4- kiwi", " 5- melon", " 6- mango") # Example print(thistuple[0:2]) print(thistuple[2:4]) print(thistuple[4:6]) print(thistuple[3:]) print(thistuple[1:5]) print("\n--------------------------------\n") print("--------------------------------\n") print("--------------------------------\n")
class BalanceResponse(object): def __init__(self, data): self.exchangeId = data['exchangeId'] self.currencyId = data['currencyId'] self.availableBalance = data['availableBalance'] self.realizedBalance = data['realizedBalance'] self.currencySymbol = data['currencySymbol'] self.exchangeName = data['exchangeName']
#!/usr/bin/python3 """ Copyright 2018 Nicolas Simonin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. MIT License """ ''' A 433MHz Wireless Switch protocol decoder This class expects to be initialized with a protocol dictionary and some tollerance parameters. the protocol dictionary shall contain "pulse_len", "start","zero" and "one" like this example: { "pulse_len": 0.000350, "start": [ 1, 31 ], "zero": [ 1, 3 ], "one": [ 3, 1 ] } the pulse_len_tollerance is applied at pulse_len and then moltiplied. Format for protocol definitions: pulselength: pulse length in seconds, e.g. 0.000350 "start": [1, 31] means 1 high pulse and 31 low pulses: _ | |_______________________________ "zero" bit: waveform for a data bit of value "0", [1, 3] means 1 high pulse and 3 low pulses, total length (1+3)*pulselength: _ | |___ "one" bit: waveform for a data bit of value "1", e.g. [3,1]: ___ | |_ ''' class Decoder: def __init__(self, protocol, pulse_len_tollerance, extra_tollerance, tollerance_delay, min_duration = 0.000200, expected_bit_count = 24): self.state = "reset" self.protocol = protocol self.expected_bit_count = expected_bit_count self.current_result = None self.start_time = None self.results_list = [] self.discarded_list = [] self.values = [] self.pulse_len_tollerance = pulse_len_tollerance self.extra_tollerance = extra_tollerance self.tollerance_delay = tollerance_delay self.min_duration = min_duration def parse(self,values): self.values.append(values) #print(repr(self.values)) while(len(self.values) >= 3): if (self.filterGlitchesOut()): continue if (self.state == "reset"): #looking for a start if(self.is_a("start")): self.state = "started" self.current_result = "" self.start_time = self.values[0]["time"] #print("started" + str(self.values[0]["time"])) del self.values[0] #remove one extra entry if the start sequence is identified elif (self.state == "started"): if(self.is_a("zero")): self.current_result += "0" #print("0", end='', flush=True) del self.values[0] #remove one extra entry if the sequence is identified elif(self.is_a("one")): self.current_result += "1" #print("1", end='', flush=True) del self.values[0] #remove one extra entry if the sequence is identified elif (self.is_a("start")): self.save_result() self.state = "started" self.current_result = "" self.start_time = self.values[0]["time"] #print("started"+ str(self.values[0]["time"])) del self.values[0] #remove one extra entry if the start sequence is identified else: if (self.is_a("zero", long_last_bit_check = True)): self.current_result += "0" #print("0", end='', flush=True) elif(self.is_a("one", long_last_bit_check = True)): self.current_result += "1" #print("1", end='', flush=True) self.save_result() self.state = "reset" self.current_result = None self.start_time = None #print ("abort") del self.values[0] #remove one edge anyhow def save_result(self): if(len(self.current_result) == self.expected_bit_count): self.results_list.append({"time": self.start_time, "data" : self.current_result}) else: self.discarded_list.append({"time": self.start_time, "data" : self.current_result, "discard_time": self.values[0]["time"]}) #print (str(len(self.current_result)) + " bits received from " + str(self.start_time) + # " but discarded at " + str(self.values[0]["time"]) + ".") #todo make it part of the result if(len(self.current_result) >self.expected_bit_count): print("Warning: received " +str(self.current_result) + " bits.") def filterGlitchesOut(self): hi_time = self.values[1]["time"] - self.values[0]["time"] if (hi_time < self.min_duration): del self.values[1] del self.values[0] return True low_time = self.values[2]["time"] - self.values[1]["time"] if (low_time < self.min_duration): del self.values[2] del self.values[1] return True return False def is_a(self,protocol_element, long_last_bit_check = False): #print (repr(self.values)) if(self.values[0]["value"] == 0): return False hi_time = self.values[1]["time"] - self.values[0]["time"] low_time = self.values[2]["time"] - self.values[1]["time"] p_hi_time_min = self.protocol[protocol_element][0] * (self.protocol["pulse_len"]-self.pulse_len_tollerance) - self.extra_tollerance + self.tollerance_delay p_hi_time_max = self.protocol[protocol_element][0] * (self.protocol["pulse_len"]+self.pulse_len_tollerance) + self.extra_tollerance + self.tollerance_delay p_low_time_min = self.protocol[protocol_element][1] * (self.protocol["pulse_len"]-self.pulse_len_tollerance) - self.extra_tollerance + self.tollerance_delay p_low_time_max = self.protocol[protocol_element][1] * (self.protocol["pulse_len"]+self.pulse_len_tollerance) + self.extra_tollerance + self.tollerance_delay if (hi_time < p_hi_time_min): #if(protocol_element is not "start"): # print ("hi: "+ str(hi_time) + ", min: " + str(p_hi_time_min)) return False if (hi_time > p_hi_time_max): #if(protocol_element is not "start"): # print ("hi: "+ str(hi_time) + ", max: " + str(p_hi_time_max)) return False if (low_time < p_low_time_min): #if(protocol_element is not "start"): # print ("low " + str(low_time) + ", min:" + str(p_low_time_min)) return False if (low_time > p_low_time_max): if long_last_bit_check is True: #print("last bit set on " + protocol_element + " at " + str(self.values[0]["time"]) ) return True else: return False #if we reach this point we have a match return True
''' Given a sorted, increasing-order array with unique integer elements, write an algorithm to create a binary search tree with minimal height. ''' class myBST(): def __init__(self,key = None, parent = None): # quick BST structure self.key = key self.parent = parent self.right = None self.left = None def insert(self,key): # insertion to a tree if self.key == None: # edge case: key of node is None self.key = key else: node = self if key > node.key: if node.right: # if there is a right child, recurse right, else create new node node.right.insert(key) else: self.right = self.__class__(key,node) self.right.key = key else: if node.left: node.left.insert(key) else: self.left = self.__class__(key,node) self.left.key = key def __str__(self): "Returns ASCII drawing of the tree" s = str(self.key) if (self.left is not None) or (self.right is not None): ws = len(s) sl, wl, cl = [''], 0, 0 if self.left is not None: sl = str(self.left).splitlines() wl = len(sl[0]) cl = len(sl[0].lstrip(' _')) sr, wr, cr = [''], 0, 0 if self.right is not None: sr = str(self.right).splitlines() wr = len(sr[0]) cr = len(sr[0].rstrip(' _')) while len(sl) < len(sr): sl.append(' ' * wl) while len(sr) < len(sl): sr.append(' ' * wr) s = s.rjust(ws + cl, '_').ljust(ws + cl + cr, '_') s = [s.rjust(ws + wl + cr).ljust(ws + wl + wr)] s = '\n'.join(s + [l + (' ' * ws) + r for (l,r) in zip(sl, sr)]) return s def create_minimal_tree(self,arr): # takes sorted increasing array of unique elements and creates a minimal height tree. mid = len(arr)//2 self.insert(arr[mid]) # insert middle element left = [i for i in arr[:mid]] right = [i for i in arr[mid+1:]] #print(left,right) if left: # recurse on the left half of array self.create_minimal_tree(left) if right: # recurse on the right half of the array self.create_minimal_tree(right) bst = myBST() a = range(31) bst.create_minimal_tree(a) print(bst)
while True: print('Para interromper o programa digite [-1]') print('\033[34m=-\033[m'*19) n = int(input('Digite um número para ver sua taboada: ')) for t in range(1, 11): print(f'{n} + {t:2} = {n+t}') print('\033[35m=-\033[m'*6) for t in range(1, 11): print(f'{n} X {t:2} = {n*t}') print('\033[36m=-\033[m'*6) if n == -1: break print('\033[31mFIM DO PROGRAMA!!!\033[m')
""" Prefer Interpolated F-Strings Over C-style Format Strings and str.format """ # Defining binary and hexadecimal variables binary = 0b10111011 hexadecimal = 0xc5f key = "my_var" value = 1.234 pantry = [ ("avocados", 125), ("bananas", 2.5), ("cherries", 15) ] template = "%s loves food, See %s cook." name = "everlookneversee" if __name__ == '__main__': # Converting binary and hexadecimal values to integer strings print("Binary is %d, hexadecimal is %d" % (binary, hexadecimal)) print("\n" + "*-*" * 50 + "\n") # First problem in c-style string formatting formatted = "%-10s = %.2f" % (key, value) print(formatted) try: formatted = "%-10s = %.2f" % (value, key) print(formatted) except TypeError: print("Must be real number, not str") try: formatted = "%.2f = %-10s" % (key, value) print(formatted) except TypeError: print("Must be real number, not str") print("\n" + "*-*" * 50 + "\n") # Second problem in c-style string formatting for i, (item , count) in enumerate(pantry): print('#%d: %-10s = %.2f' % (i, item, count)) print("\n") for i, (item, count) in enumerate(pantry): print('#%d: %-10s = %d' % ( i + 1, item.title(), round(count) )) print("\n" + "*-*" * 50 + "\n") # Third problem in c-style string formatting formatted = template % (name, name) print(formatted) formatted = template % (name.title(), name.title()) print(formatted)
#! /usr/bin/env python3 # Load maze file into nested array: with open('../inputs/input25.txt') as fp: grid = [list(line.strip()) for line in fp.readlines()] ydim = len(grid) xdim = len(grid[0]) SYMBOLS = { 'east': '>', 'south': 'v', 'empty': '.'} # Look up which coords a mover wants to move to def target_cell(coords, type): (x, y) = coords if type == SYMBOLS['east']: return ((x + 1) % xdim, y) elif type == SYMBOLS['south']: return (x, (y + 1) % ydim) # Prepare the new grid after moving all of one type of symbol def move_all_facers(grid, type): # Count how many moved: moves = 0 # Pre-fill with empties grid1 = [[SYMBOLS['empty'] for _x in range(xdim)] for _y in range(ydim)] # Map movers into grid1 for y in range(ydim): for x in range(xdim): if grid[y][x] == type: (tx, ty) = target_cell((x,y), type) if grid[ty][tx] == SYMBOLS['empty']: # Make move grid1[ty][tx] = type grid1[y][x] = SYMBOLS['empty'] moves += 1 else: # Stay put grid1[y][x] = type # Current movers all changed in grid from symbol to dot, in grid1 from dot to symbol # Now backfill all non-movers: for y in range(ydim): for x in range(xdim): if grid[y][x] != type and grid1[y][x] != type: grid1[y][x] = grid[y][x] return (grid1, moves) def pgrid(grid): for row in grid: print("".join(row)) print("---") # Do one step, moving all the symbols that have a space to move into def step(grid): # East moves first, then South (grid, east_moves) = move_all_facers(grid, SYMBOLS['east']) # pgrid(grid) (grid, south_moves) = move_all_facers(grid, SYMBOLS['south']) # pgrid(grid) return (grid, east_moves + south_moves) # How many steps before grid reaches a settled state? steps = 0 while 1: steps += 1 # print("Step {}".format(steps)) (grid, moves) = step(grid) if moves == 0: break print("Part 1:", steps)
def solve(arr): n = len(arr) lis = [1 for _ in range(n)] for i in range(1, n): for j in range(0, i): if arr[j] < arr[i] and lis[i] < 1 + lis[j]: lis[i] = 1 + lis[j] return max(lis) arr = [3, 10, 2, 1, 20] assert 3 == solve(arr) arr = [3, 2] assert 1 == solve(arr) arr = [50, 3, 10, 7, 40, 80] assert 4 == solve(arr)
#pragma error #pragma repy restrictions.badcallname pass
class TestAnomalyDetector(object): # Lets make some dummy tests to test our Travis-CI configuration def test_pass(self): assert 1 == 1 def nothing(self): print('This does nothing');
# Copyright 2022 The Bazel Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """The implementation of the `java_proto_library` rule and its aspect.""" load(":common/java/java_semantics.bzl", "semantics") load(":common/proto/proto_common.bzl", "ProtoLangToolchainInfo", proto_common = "proto_common_do_not_use") java_common = _builtins.toplevel.java_common JavaInfo = _builtins.toplevel.JavaInfo ProtoInfo = _builtins.toplevel.ProtoInfo # The provider is used to collect source and runtime jars in the `proto_library` dependency graph. JavaProtoAspectInfo = provider("JavaProtoAspectInfo", fields = ["jars"]) def _filter_provider(provider, *attrs): return [dep[provider] for attr in attrs for dep in attr if provider in dep] def _bazel_java_proto_aspect_impl(target, ctx): """Generates and compiles Java code for a proto_library. The function runs protobuf compiler on the `proto_library` target using `proto_lang_toolchain` specified by `--proto_toolchain_for_java` flag. This generates a source jar. After that the source jar is compiled, respecting `deps` and `exports` of the `proto_library`. Args: target: (Target) The `proto_library` target (any target providing `ProtoInfo`. ctx: (RuleContext) The rule context. Returns: ([JavaInfo, JavaProtoAspectInfo]) A JavaInfo describing compiled Java version of`proto_library` and `JavaProtoAspectInfo` with all source and runtime jars. """ proto_toolchain_info = ctx.attr._aspect_java_proto_toolchain[ProtoLangToolchainInfo] source_jar = None if proto_common.experimental_should_generate_code(target, proto_toolchain_info, "java_proto_library"): # Generate source jar using proto compiler. source_jar = ctx.actions.declare_file(ctx.label.name + "-speed-src.jar") proto_common.compile( ctx.actions, proto_toolchain_info, [source_jar], source_jar, proto_info = target[ProtoInfo], ) # Compile Java sources (or just merge if there aren't any) deps = _filter_provider(JavaInfo, ctx.rule.attr.deps) exports = _filter_provider(JavaInfo, ctx.rule.attr.exports) if source_jar and proto_toolchain_info.runtime: deps.append(proto_toolchain_info.runtime[JavaInfo]) java_info, jars = java_compile_for_protos( ctx, "-speed.jar", source_jar, deps, exports, ) transitive_jars = [dep[JavaProtoAspectInfo].jars for dep in ctx.rule.attr.deps if JavaProtoAspectInfo in dep] return [ java_info, JavaProtoAspectInfo(jars = depset(jars, transitive = transitive_jars)), ] def java_compile_for_protos(ctx, output_jar_suffix, source_jar = None, deps = [], exports = [], injecting_rule_kind = "java_proto_library"): """Compiles Java source jar returned by proto compiler. Use this call for java_xxx_proto_library. It uses java_common.compile with some checks disabled (via javacopts) and jspecify disabled, so that the generated code passes. It also takes care that input source jar is not repackaged with a different name. When `source_jar` is `None`, the function only merges `deps` and `exports`. Args: ctx: (RuleContext) Used to call `java_common.compile` output_jar_suffix: (str) How to name the output jar. For example: `-speed.jar`. source_jar: (File) Input source jar (may be `None`). deps: (list[JavaInfo]) `deps` of the `proto_library`. exports: (list[JavaInfo]) `exports` of the `proto_library`. injecting_rule_kind: (str) Rule kind requesting the compilation. It's embedded into META-INF of the produced runtime jar, for debugging. Returns: ((JavaInfo, list[File])) JavaInfo of this target and list containing source and runtime jar, when they are created. """ if source_jar != None: path, sep, filename = ctx.label.name.rpartition("/") output_jar = ctx.actions.declare_file(path + sep + "lib" + filename + output_jar_suffix) java_toolchain = ctx.attr._java_toolchain[java_common.JavaToolchainInfo] java_info = java_common.compile( ctx, source_jars = [source_jar], deps = deps, exports = exports, output = output_jar, output_source_jar = source_jar, injecting_rule_kind = injecting_rule_kind, javac_opts = java_toolchain.compatible_javacopts("proto"), enable_jspecify = False, java_toolchain = java_toolchain, include_compilation_info = False, ) jars = [source_jar, output_jar] else: # If there are no proto sources just pass along the compilation dependencies. java_info = java_common.merge(deps + exports, merge_java_outputs = False, merge_source_jars = False) jars = [] return java_info, jars bazel_java_proto_aspect = aspect( implementation = _bazel_java_proto_aspect_impl, attrs = { "_aspect_java_proto_toolchain": attr.label( default = configuration_field(fragment = "proto", name = "proto_toolchain_for_java"), ), "_java_toolchain": attr.label( default = Label(semantics.JAVA_TOOLCHAIN_LABEL), ), }, attr_aspects = ["deps", "exports"], required_providers = [ProtoInfo], provides = [JavaInfo, JavaProtoAspectInfo], fragments = ["java"], ) def bazel_java_proto_library_rule(ctx): """Merges results of `java_proto_aspect` in `deps`. Args: ctx: (RuleContext) The rule context. Returns: ([JavaInfo, DefaultInfo, OutputGroupInfo]) """ java_info = java_common.merge([dep[JavaInfo] for dep in ctx.attr.deps], merge_java_outputs = False) transitive_src_and_runtime_jars = depset(transitive = [dep[JavaProtoAspectInfo].jars for dep in ctx.attr.deps]) transitive_runtime_jars = depset(transitive = [java_info.transitive_runtime_jars]) return [ java_info, DefaultInfo( files = transitive_src_and_runtime_jars, runfiles = ctx.runfiles(transitive_files = transitive_runtime_jars), ), OutputGroupInfo(default = depset()), ] java_proto_library = rule( implementation = bazel_java_proto_library_rule, attrs = { "deps": attr.label_list(providers = [ProtoInfo], aspects = [bazel_java_proto_aspect]), "licenses": attr.license() if hasattr(attr, "license") else attr.string_list(), "distribs": attr.string_list(), }, provides = [JavaInfo], )
""" Define contstants """ LOOP_DEV = "/dev/loop0" IMG_FILE = "/tmp/hl_lvm.img" IMG_SIZE = 128 * 1024 ** 2 TEST_VG = "holland" TEST_LV = "test_lv"
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") load("@bazel_skylib//lib:paths.bzl", "paths") load("//ocaml:providers.bzl", "CompilationModeSettingProvider", "OcamlProvider", "OcamlNsResolverProvider", "OcamlLibraryMarker", "OcamlModuleMarker", "OcamlNsMarker") load("//ppx:providers.bzl", "PpxCodepsProvider", ) load(":impl_common.bzl", "dsorder", "module_sep", "resolver_suffix") load(":impl_ccdeps.bzl", "dump_CcInfo") # load("//ocaml/_functions:utils.bzl", "get_sdkpath") ## Plain Library targets do not produce anything, they just pass on ## their deps. ## NS Lib targets also do not directly produce anything, they just ## pass on their deps. The real work is done in the transition ## functions, which set the ConfigState that controls build actions of ## deps. ################# def impl_library(ctx, mode, tool, tool_args): debug = False # print("**** NS_LIB {} ****************".format(ctx.label)) # env = {"PATH": get_sdkpath(ctx)} # tc = ctx.toolchains["@rules_ocaml//ocaml:toolchain"] # mode = ctx.attr._mode[CompilationModeSettingProvider].value ns_resolver_depset = None ns_resolver_module = None ns_resolver = [] ns_resolver_files = [] the_ns_resolvers = [] # WARNING: due to transition processing, ns_resolver providers # must be indexed by [0] if ctx.attr._rule.startswith("ocaml_ns"): # print("tgt: %s" % ctx.label) # print("rule: %s" % ctx.attr._rule) if ctx.attr.resolver: # print("user-provided resolver") ns_resolver = ctx.attr.resolver ns_resolver_module = ctx.file.resolver ns_name = ctx.attr.ns else: # print("generated resolver") # print("NS RESOLVER FILECT: %s" % len(ctx.files._ns_resolver)) ns_resolver = ctx.attr._ns_resolver[0] # index by int ns_resolver_module = ctx.files._ns_resolver[0] # print("ns_resolver: %s" % ns_resolver) # print("ns_resolver_module: %s" % ns_resolver_module) if OcamlNsResolverProvider in ns_resolver: # print("LBL: %s" % ctx.label) # print("ns_resolver: %s" % ns_resolver[OcamlNsResolverProvider]) if hasattr(ns_resolver[OcamlNsResolverProvider], "ns_name"): ns_name = ns_resolver[OcamlNsResolverProvider].ns_name else: # FIXME: when does this happen? ns_name = "" ## if ns_resolver ends in __0Resolver, then we know that one ## of the submodules is a user-provided resolver; the ## __0Resolver was just used to compile the submodules. So we ## need to find the user-provided resolver (its name matches ## the ns name), and make all the other submodules depend on ## it. ## pathological case: ns contains a single user-provided ## resolver. in that case we have no aliases so no resolver. ## there would be no point in such an ns but its possible. if ns_resolver_module: # print("LBL: %s" % ctx.label) (ns_resolver_mname, ext) = paths.split_extension(ns_resolver_module.basename) # print("ns_resolver_mname: %s" % ns_resolver_mname) if ns_resolver_mname == ns_name + resolver_suffix: print("Resolver is user-provided") user_provided_resolver = True else: user_provided_resolver = False else: user_provided_resolver = False if user_provided_resolver: ##FIXME: efficiency for submodule in ctx.files.submodules: (bname, ext) = paths.split_extension(submodule.basename) if bname == ns_name: print("Found user-provided resolver submodule") the_ns_resolvers.append(submodule) # else: if OcamlProvider in ns_resolver: ##ctx.attr._ns_resolver[0]: # print("ns_resolver provider: %s" % ns_resolver[OcamlProvider]) ns_resolver_files = ns_resolver[OcamlProvider].inputs ns_resolver_depset = ns_resolver[OcamlProvider].inputs # the_ns_resolvers.append(ns_resolver_module[0]) # print("ns_resolver_depset: %s" % ns_resolver_depset) # print("ns_name: %s" % ns_name) ################ ## FIXME: does lib need to handle adjunct deps? they're carried by ## modules indirect_adjunct_depsets = [] indirect_adjunct_path_depsets = [] ################ paths_direct = [] # resolver_depsets_list = [] ####################### direct_deps_attr = None if ctx.attr._rule == "ocaml_ns_archive": direct_dep_files = ctx.files.submodules direct_deps_attr = ctx.attr.submodules elif ctx.attr._rule == "ocaml_ns_library": direct_dep_files = ctx.files.submodules direct_deps_attr = ctx.attr.submodules elif ctx.attr._rule == "ocaml_archive": direct_dep_files = ctx.files.manifest direct_deps_attr = ctx.attr.manifest elif ctx.attr._rule == "ocaml_library": direct_dep_files = ctx.files.manifest direct_deps_attr = ctx.attr.manifest else: fail("impl_library called by non-aggregator: %s" % ctx.attr._rule) ## FIXME: direct_dep_files (and direct_deps_attr) are in the order ## set by the submodule/modules attribute; they must be put in ## dependency-order. for f in direct_dep_files: paths_direct.append(f.dirname) # if ctx.label.name == "tezos-shell": # print("LBL: %s" % ctx.label) # for dep in direct_deps_attr: # print("DEP: %s" % dep[OcamlProvider].fileset) #### INDIRECT DEPS first #### # these are "indirect" from the perspective of the consumer indirect_fileset_depsets = [] indirect_inputs_depsets = [] indirect_linkargs_depsets = [] indirect_paths_depsets = [] ccInfo_list = [] direct_module_deps_files = ctx.files.submodules if ctx.attr._rule.startswith("ocaml_ns") else ctx.files.manifest direct_module_deps = ctx.attr.submodules if ctx.attr._rule.startswith("ocaml_ns") else ctx.attr.manifest for dep in direct_module_deps: # if ctx.label.name == 'tezos-base': # print("DEPPP: %s" % dep) # ignore DefaultInfo, its just for printing, not propagation if OcamlProvider in dep: # should always be True # if ctx.label.name == 'tezos-base': # print("directdep: %s" % dep[OcamlProvider]) indirect_fileset_depsets.append(dep[OcamlProvider].fileset) # linkargs: what goes on cmd line to build archive or # executable FIXME: __excluding__ sibling modules! Why? # because even if we put only indirect deps in linkargs, # the head (direct) dep could still appear anywhere in the # dep closure; in particular, we may have sibling deps, in # which case omitting the head dep for linkargs would do # us no good. So we need to filter to remove ALL # (sub)modules from linkargs. # if linkarg not in direct_module_deps_files: indirect_linkargs_depsets.append(dep[OcamlProvider].linkargs) # if ctx.label.name == "tezos-base": # print("LIBDEP LINKARGS: %s" % dep[OcamlProvider].linkargs) # indirect_linkargs_depsets.append(dep[OcamlProvider].files) ## inputs == all deps indirect_inputs_depsets.append(dep[OcamlProvider].inputs) indirect_paths_depsets.append(dep[OcamlProvider].paths) indirect_linkargs_depsets.append(dep[DefaultInfo].files) if CcInfo in dep: ## we do not need to do anything with ccdeps here, ## just pass them on in a provider # if ctx.label.name == "tezos-legacy-store": # dump_CcInfo(ctx, dep) ccInfo_list.append(dep[CcInfo]) if PpxCodepsProvider in dep: indirect_adjunct_path_depsets.append(dep[PpxCodepsProvider].paths) indirect_adjunct_depsets.append(dep[PpxCodepsProvider].ppx_codeps) # print("indirect_inputs_depsets: %s" % indirect_inputs_depsets) # normalized_direct_dep_files = [] # for dep in direct_dep_files: # print("direct dep: %s" % dep) # print("the_ns_resolvers: %s" % the_ns_resolvers) # # (bname, ext) = paths.split_extension(dep.basename) # if dep.basename not in the_ns_resolvers: ## [0].basename: # normalized_direct_dep_files.append(dep) # else: # print("removing %s" % dep) inputs_depset = depset( order = dsorder, direct = direct_dep_files, transitive = ([ns_resolver_depset] if ns_resolver_depset else []) + indirect_inputs_depsets # + [depset(direct_dep_files)] ) ## To put direct deps in dep-order, we need to merge the linkargs ## deps and iterate over them: new_linkargs = [] ## start with ns_resolver: if ctx.attr._rule.startswith("ocaml_ns"): if ns_resolver: for f in ns_resolver[DefaultInfo].files.to_list(): # for f in ns_resolver[0].files.to_list(): paths_direct.append(f.dirname) new_linkargs.append(f) linkargs_depset = depset( order = dsorder, ## direct = ns_resolver_files, transitive = indirect_linkargs_depsets # transitive = ([ns_resolver_depset] if ns_resolver_depset else []) + indirect_linkargs_depsets ) for dep in inputs_depset.to_list(): if dep in direct_dep_files: new_linkargs.append(dep) ####################### ## Do we need to do this? Why? ctx.actions.do_nothing( mnemonic = "NS_LIB", inputs = inputs_depset ) ####################### # print("INPUTS_DEPSET: %s" % inputs_depset) # print("the_ns_resolvers: %s" % the_ns_resolvers) #### PROVIDERS #### defaultDepset = depset( order = dsorder, # direct = normalized_direct_dep_files, # ns_resolver_module, # transitive = [depset(direct = the_ns_resolvers)] direct = the_ns_resolvers + [ns_resolver_module] if ns_resolver_module else [], transitive = [depset(direct_dep_files)] # transitive = [depset(normalized_direct_dep_files)] ) defaultInfo = DefaultInfo( files = defaultDepset ) ################ ppx codeps ################ ppx_codeps_depset = depset( order = dsorder, transitive = indirect_adjunct_depsets ) ppxAdjunctsProvider = PpxCodepsProvider( ppx_codeps = ppx_codeps_depset, paths = depset( order = dsorder, transitive = indirect_adjunct_path_depsets ) ) new_inputs_depset = depset( order = dsorder, ## direct = ns_resolver_files, transitive = ([ns_resolver_depset] if ns_resolver_depset else []) + [inputs_depset] # + indirect_inputs_depsets ) paths_depset = depset( order = dsorder, direct = paths_direct, transitive = indirect_paths_depsets ) # print("new_linkargs: %s" % new_linkargs) ocamlProvider = OcamlProvider( files = depset(direct=new_linkargs), fileset = depset( transitive=([ns_resolver_depset] if ns_resolver_depset else []) + indirect_fileset_depsets ), inputs = new_inputs_depset, linkargs = linkargs_depset, paths = paths_depset, ns_resolver = ns_resolver, ) # print("ocamlProvider: %s" % ocamlProvider) outputGroupInfo = OutputGroupInfo( resolver = ns_resolver_files, ppx_codeps = ppx_codeps_depset, # cc = ... extract from CcInfo? all = depset( order = dsorder, transitive=[ new_inputs_depset, ] ) ) providers = [ defaultInfo, ocamlProvider, ppxAdjunctsProvider, outputGroupInfo, ] providers.append( OcamlLibraryMarker(marker = "OcamlLibraryMarker") ) if ctx.attr._rule.startswith("ocaml_ns"): providers.append( OcamlNsMarker( marker = "OcamlNsMarker", ns_name = ns_name if ns_resolver else "" ), ) # if ctx.label.name == "tezos-legacy-store": # print("ccInfo_list ct: %s" % len(ccInfo_list)) ccInfo_merged = cc_common.merge_cc_infos(cc_infos = ccInfo_list) # if ctx.label.name == "tezos-legacy-store": # print("ccInfo_merged: %s" % ccInfo_merged) if ccInfo_list: providers.append(ccInfo_merged) return providers
def celsius_to_fahrenheit(Celsius): F = (Celsius/5)*9 + 32 print(F) def celsius_to_kelvin(Celsius): K = Celsius + 273 print(K) def kelvin_to_celsius(Kelvin): C = Kelvin - 273 print(C) def kelvin_to_fahrenheit(Kelvin): F = (((Kelvin - 273) / 5) * 9) + 32 print(F) def fahrenheit_to_kelvin(Fahrenheit): K = (((Fahrenheit - 32) / 9) * 5) + 273 print(K) def fahrenheit_to_celsius(Fahrenheit): C = ((Fahrenheit - 32) / 9) * 5 print(C)
"""Module for compilation configuration.""" class CompilationConfiguration: """Class that allows the compilation process to be customized.""" dump_artifacts_on_unexpected_failures: bool enable_topological_optimizations: bool check_every_input_in_inputset: bool treat_warnings_as_errors: bool enable_unsafe_features: bool random_inputset_samples: int use_insecure_key_cache: bool def __init__( self, dump_artifacts_on_unexpected_failures: bool = True, enable_topological_optimizations: bool = True, check_every_input_in_inputset: bool = False, treat_warnings_as_errors: bool = False, enable_unsafe_features: bool = False, random_inputset_samples: int = 30, use_insecure_key_cache: bool = False, ): self.dump_artifacts_on_unexpected_failures = dump_artifacts_on_unexpected_failures self.enable_topological_optimizations = enable_topological_optimizations self.check_every_input_in_inputset = check_every_input_in_inputset self.treat_warnings_as_errors = treat_warnings_as_errors self.enable_unsafe_features = enable_unsafe_features self.random_inputset_samples = random_inputset_samples self.use_insecure_key_cache = use_insecure_key_cache def __eq__(self, other) -> bool: return isinstance(other, CompilationConfiguration) and self.__dict__ == other.__dict__
def add(x, y): return x + y a = 1 b = 2 result = add(a, b) print("This is the sum: {}, {}, {}".format(a,b,result))
def regex(ref, char): passed = True for i in ref: if char == i: passed = False return passed
''' Created on Aug 30, 2018 @author: Manikandan.R ''' print ('Running Fibonacci') a, b = 0, 1 while a < 10: print(a, end=',') a, b = b, a + b print ('Handling Strings') alphas = "abcdefghijklmnopqrstuvwxyz" index = len(alphas) // 2 alpha1 = alphas[: index] alpha2 = alphas[index :] print ('alphas: ' + alphas) print ('alpha1: ' + alpha1) print ('alpha2: ' + alpha2) print ('Handling Lists') lists = [1, 2, 3, 4, 5, 6, 7, 8, 9] print ('My List: ', lists) print ('4th element from start: ', lists[4]) print ('1st element from end: ', lists[-1])
""" is_anti_list(["1", "0", "0", "1"], ["0", "1", "1", "0"]) ➞ True is_anti_list(["apples", "bananas", "bananas"], ["bananas", "apples", "apples"]) ➞ True is_anti_list([3.14, True, 3.14], [3.14, False, 3.14]) ➞ False """ def is_anti_list(list1, list2) -> bool: if len(list1) != len(list2): return False if (set(list1) != set(list2)) or len(set(list1)) != 2: return False for element1, element2 in zip(list1, list2): if element1 == element2: return False return True print(is_anti_list(["1", "0", "0", "1"], ["0", "1", "1", "0"])) print(is_anti_list(["apples", "bananas", "bananas"], ["bananas", "apples", "apples"])) print(is_anti_list([3.14, True, 3.14], [3.14, False, 3.14])) print(is_anti_list(["1", "1", "0", "1"], ["0", "1", "1", "0"]))
class DebuggableAttribute(Attribute,_Attribute): """ Modifies code generation for runtime just-in-time (JIT) debugging. This class cannot be inherited. DebuggableAttribute(isJITTrackingEnabled: bool,isJITOptimizerDisabled: bool) DebuggableAttribute(modes: DebuggingModes) """ def __init__(self,*args): """ x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """ pass @staticmethod def __new__(self,*__args): """ __new__(cls: type,isJITTrackingEnabled: bool,isJITOptimizerDisabled: bool) __new__(cls: type,modes: DebuggingModes) """ pass DebuggingFlags=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets the debugging modes for the attribute. Get: DebuggingFlags(self: DebuggableAttribute) -> DebuggingModes """ IsJITOptimizerDisabled=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets a value that indicates whether the runtime optimizer is disabled. Get: IsJITOptimizerDisabled(self: DebuggableAttribute) -> bool """ IsJITTrackingEnabled=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets a value that indicates whether the runtime will track information during code generation for the debugger. Get: IsJITTrackingEnabled(self: DebuggableAttribute) -> bool """ DebuggingModes=None
class Appointment(): def __init__(self): self.patient_ID = 0 self.doctor_ID = 0 self.profession = "" self.day = "" self.confirm = 0 self.success = 0
class Solution: def singleNumber(self, nums: List[int]) -> int: result = 0 for n in nums: result ^= n return result
x_range_callback = """ var start = cb_obj.start; var end = cb_obj.end; var width = end - start; var threshold = %f * width; // threshold factor is set from python-side configuration var intron_alpha = %f; // alpha value is set from python-side configuration // iterate over each intron var data = source.data; for (i=0; i<data["x"].length; i++) { // if the screen-space width is large enough, make the intron visible if(data["width"][i] >= threshold) data["alpha"][i] = intron_alpha; else // otherwise, make the intron fully transparent data["alpha"][i] = 0; } source.change.emit(); """
X_full = brca.data X_train, X_test, y_train, y_test = train_test_split(X_full, y, test_size=0.2, random_state=0) scaler.fit(X_train) X_train = scaler.transform(X_train) X_test = scaler.transform(X_test) clf = neighbors.KNeighborsClassifier(n_neighbors=5) clf.fit(X_train, y_train) test_score = clf.score(X_test, y_test) train_score = clf.score(X_train, y_train) print(f"test score: {test_score} \ntrain score: {train_score}")
# -*- coding: utf-8 -*- def main(): s = input() if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]: print('Bad') else: print('Good') if __name__ == '__main__': main()
#UNION my_set1 = {3, 4, 5} my_set2 = {5, 6, 7} my_set3 = my_set1 | my_set2 print(my_set3) # {3, 4, 5, 6, 7} #INTERSECCION my_set1 = {3, 4, 5} my_set2 = {5, 6, 7} my_set3 = my_set1 & my_set2 print(my_set3) # {5} #DIFERENCIA my_set1 = {3, 4, 5} my_set2 = {5, 6, 7} my_set3 = my_set1 - my_set2 print(my_set3) my_set4 = my_set2 - my_set1 print(my_set4) # {3, 4} # {6, 7} # DIFERENCIA SIMETRICA my_set1 = {3, 4, 5} my_set2 = {5, 6, 7} my_set3 = my_set1 ^ my_set2 print(my_set3) # {3, 4, 6, 7}
#!/usr/bin/env python # # description: Edit Distance # difficulty: Hard # leetcode_num: 72 # leetcode_url: https://leetcode.com/problems/edit-distance/ # # Given two words word1 and word2, find the minimum number of operations # required to convert word1 to word2. # # You have the following 3 operations permitted on a word: # # Insert a character # Delete a character # Replace a character # Example 1: # # Input: word1 = "horse", word2 = "ros" # Output: 3 # Explanation: # horse -> rorse (replace 'h' with 'r') # rorse -> rose (remove 'r') # rose -> ros (remove 'e') # Example 2: # # Input: word1 = "intention", word2 = "execution" # Output: 5 # Explanation: # intention -> inention (remove 't') # inention -> enention (replace 'i' with 'e') # enention -> exention (replace 'n' with 'x') # exention -> exection (replace 'n' with 'c') # exection -> execution (insert 'u') def getMinEditDistance(source, dest, m, n): if m == 0: return n if n == 0: return m if source[m-1] == dest[n-1]: return getMinEditDistance(source, dest, m-1, n-1) # No edits return 1 + min( getMinEditDistance(source, dest, m, n-1), # Character addition getMinEditDistance(source, dest, m-1, n), # Charater removal getMinEditDistance(source, dest, m-1, n-1), # Charater replacement ) # Recursive Solution def MinEditDistanceRecursive(source, dest): return getMinEditDistance(source, dest, len(source), len(dest)) # Solution using dynamic programming def MinEditDistance(source, dest): m = len(source) n = len(dest) dist = [[0 for _ in range(n+1)] for _ in range(m+1)] for i in range(m+1): for j in range(n+1): if i == 0: dist[i][j] = j elif j == 0: dist[i][j] = i elif source[i-1] == dest[j-1]: dist[i][j] = dist[i-1][j-1] # No edits else: dist[i][j] = 1 + min( dist[i][j-1], # Character addition dist[i-1][j], # Charater removal dist[i-1][j-1] # Charater replacement ) return dist[m][n] if __name__ == '__main__': test_cases = [ (('horse', 'ros'), 3), (('intention', 'execution'), 5) ] for args, res in test_cases: assert MinEditDistanceRecursive(args[0], args[1]) == res, 'Test Failed' assert MinEditDistance(args[0], args[1]) == res, 'Test Failed'
''' Contains all the modules that should be available when this folder is imported. ''' __all__ = [ 'google_search', 'bumble_help', 'clock_in', 'clock_out', 'chatbot', 'grepapp_search', 'send_email', 'open_notepad', 'wiki_search', 'wolfram_search', 'start_research_server', 'stop_research_server', 'store_research_data', 'silent_mode_on', 'voice_mode_on', 'youtube_search', 'add_zoom_link', 'open_zoom_link', 'sleep', 'stop_listening', 'add_contact', 'add_employer', 'set_default_speech_mode', 'load_routines', 'run_routine', 'internet_speed_test', 'run_online_tasks' ] '''Essential Features that should be included in every custon list.''' __essential__ = [ 'sleep', 'stop_listening', 'silent_mode_on', 'voice_mode_on', 'set_default_speech_mode' ] '''Contains cybersecurity specific features.''' __cybersecurity__ = __essential__ + [] '''Contains geo specific features.''' __geo__ = __essential__ + [] def create_feature_lists(): feature_lists = {} feature_lists['all'] = __all__ feature_lists['cybersecurity'] = __cybersecurity__ feature_lists['geo'] = __geo__ return feature_lists feature_lists = create_feature_lists()
class Test(): def __init__(self, test_attr): self.test_attr = test_attr self.test_fn() print(self.test_attr) def test_fn(self): self.test_attr = "goodbye world"
class Library: def __init__(self,libraryname,booklist): self.lend_book={} self.library_name=libraryname self.booklist=booklist for book in self.booklist: self.lend_book[book] = None def add_books(self,book_name): self.booklist.append(book_name) self.lend_book[book_name]=None def lendz_books(self,book,author): if book in self.booklist: if self.lend_book[book] is None: self.lend_book[book]=author else: print("the book is already taken") else: print("wrong book name entered:") def return_books(self,book,author): if book in self.booklist: if self.book[book] is not None: self.booklist.append(book) self.lend_book[book] = None def delete_books(self,book_name): if book_name in self.booklist: self.booklist.remove(book_name) self.lend_book.pop(book_name) else: print("the book is not the list") def print_details(self): return f"the book's list is {self.booklist} and library name is {self.library_name}" if __name__ == "__main__": list_books = ['Cookbook', 'Motu Patlu', 'Chacha_chaudhary', 'Rich Dad and Poor Dad'] Library_name = 'Harry' secret_key = 123456 harry = Library( Library_name,list_books) print("welcome to the library system\n There are various function in this library") print("to add books 'a'\n to lend book 'l'\nto return the book 'r'\nto delete the book 'd'\to print the book list 'p' :") Exit=False while(Exit is not True): input_1 = input("options:") if input_1 == 'a': input_2 = input("enter the book name you want to enter:") harry.add_books(input_2) elif input_1 == 'l': input_2 = input("enter the book name you want to lend:") input_3 = input("enter your name :") harry.lendz_books(input_2, input_3) elif input_1 == "r": input_2 = input("enter the book name you want to return") input_3 = input("enter your name :") harry.return_books(input_2, input_3) elif input_1 == 'd': input_2 = input("enter the book you want to delete:") secret = input("enter the secret key to get access:") if secret == secret_key: harry.delete_books(input_2) else: print("key is wrong") elif input_1 == 'p': print(harry.print_details())
class Solution: # O(n) time | O(1) space where n is the length of the input array def missingNumber(self, nums: List[int]) -> int: missingNumber = 0 for i in range(len(nums)): missingNumber ^= nums[i] for i in range(len(nums) + 1): missingNumber ^= i return missingNumber
"""Consts for Cast integration.""" DOMAIN = "cast" DEFAULT_PORT = 8009 # Stores a threading.Lock that is held by the internal pychromecast discovery. INTERNAL_DISCOVERY_RUNNING_KEY = "cast_discovery_running" # Stores UUIDs of cast devices that were added as entities. Doesn't store # None UUIDs. ADDED_CAST_DEVICES_KEY = "cast_added_cast_devices" # Stores an audio group manager. CAST_MULTIZONE_MANAGER_KEY = "cast_multizone_manager" # Store a CastBrowser CAST_BROWSER_KEY = "cast_browser" # Dispatcher signal fired with a ChromecastInfo every time we discover a new # Chromecast or receive it through configuration SIGNAL_CAST_DISCOVERED = "cast_discovered" # Dispatcher signal fired with a ChromecastInfo every time a Chromecast is # removed SIGNAL_CAST_REMOVED = "cast_removed" # Dispatcher signal fired when a Chromecast should show a Safegate Pro Cast view. SIGNAL_HASS_CAST_SHOW_VIEW = "cast_show_view" CONF_IGNORE_CEC = "ignore_cec" CONF_KNOWN_HOSTS = "known_hosts" CONF_UUID = "uuid"
# Write a program that prints the next 20 leap years (enter year or if not, get current year as default) print('Type your year that you want to check:') value = int(input()) count = 1 i = 0 def leap_years(year): if year % 100 == 0: if year % 400 == 0: return True else: return False elif year % 4 == 0: return True else: return False while count <= 20: if not leap_years(value): if leap_years(value + i): print(value + i) count += 1 i += 1 else: if leap_years(value + i): print(value + i) count += 1 i += 4 # print(leap_years(value))
# Top fields BANDIT_TYPE = 'bandit_type' BANDIT_ID = 'bandit_id' PRIORS = 'priors' ARM_IDS = 'arm_ids' PARAMETERS = 'parameters' # Values N = 'n' REWARD_SUM = 'reward_sum' SQUARED_REWARD_SUM = 'squared_reward_sum' N_REWARDS = 'n_rewards' # Parametres EPSILON = 'epsilon'
class PyCrudException(Exception): pass class DBException(PyCrudException): pass class PermissionException(PyCrudException): pass class UnknownDatabaseException(PyCrudException): pass class InvalidQueryConditionColumn(PyCrudException): pass class InvalidQueryConditionOperator(PyCrudException): pass class InvalidQueryConditionValue(PyCrudException): pass class UnknownQueryOperator(PyCrudException): pass class InvalidQueryValue(PyCrudException): pass class InvalidOrderSyntax(PyCrudException): pass class UnsupportedQueryOperator(PyCrudException): pass
# -*- coding: UTF-8 -*- def formatMultiline(text, line_length): return "\n".join(text[i - line_length: i] for i in range(line_length, len(text) + line_length, line_length) ) def breakByWords(text, max_len): result = "" words = text.split() while len(words): wordsInLine = len(words) while sum(len(word) for word in words[0:wordsInLine]) > max_len: wordsInLine = wordsInLine - 1 if wordsInLine == 0: wordsInLine = 1 result += " ".join(words[0:wordsInLine]) + "\n" del words[0:wordsInLine] return result
if __name__ == '__main__': string = "2018-11-13" print(string.replace("-", "")) string = "201812" print(string.count("2")) string = "12345678901234567890" for i in range(len(string)): print(string[i], end="") if (i + 1) % 4 == 0: print("\n") string = "12345678901234567890" column_num = 1 last_i = 0 for i in range(len(string)): print(string[i], end="") if (i - last_i) % column_num == 0: last_i = i column_num += 1 print("\n") string = "123abcABCDE" print("\n") subline_num = 0 digit_num = 0 alpha_num = 0 for ch in string: if ch.isdigit(): digit_num += 1 elif ch.isalpha(): alpha_num += 1 else: subline_num += 1 print(subline_num) print(digit_num) print(alpha_num)
UNK = 0 BOS = 1 EOS = 2 WORD = { UNK: '<unk>', BOS: '<s>', EOS: '</s>' }
''' Created on Feb 14, 2019 @author: jcorley ''' PROTOCOL = "tcp" IP_ADDRESS = "127.0.0.1" PORT="5555" KEY_REQUEST_TYPE = "request_type" KEY_FAILURE_MESSAGE = "failure_message" KEY_RECIPES = "recipes" KEY_STATUS = "status" SUCCESS_STATUS = 1 BAD_MESSAGE_STATUS = -1 UNSUPPORTED_OPERATION_STATUS = -1 LOAD_RECIPES_REQUEST_TYPE = "load_recipes"
CLI_OPTS = { 'data_path': { 'env': 'ELLIOTT_DATA_PATH', 'help': 'Git URL or File Path to build data' }, 'group': { 'env': 'ELLIOTT_GROUP', 'help': 'Sub-group directory or branch to pull build data' }, 'working_dir': { 'env': 'ELLIOTT_WORKING_DIR', 'help': 'Persistent working directory to use' }, } CLI_ENV_VARS = {k: v['env'] for (k, v) in CLI_OPTS.iteritems()} CLI_CONFIG_TEMPLATE = '\n'.join(['#{}\n{}:\n'.format(v['help'], k) for (k, v) in CLI_OPTS.iteritems()])