content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
''' This is a sample input, you can change it of course but you have to follow rules of the questions ''' compressed_string = "2[1[b]10[c]]a" def decompress(str=compressed_string): string = "" number_stack = [] replace_index_stack = [] bracket_index_stack = [] i = 0 while i < len(str): ...
""" This is a sample input, you can change it of course but you have to follow rules of the questions """ compressed_string = '2[1[b]10[c]]a' def decompress(str=compressed_string): string = '' number_stack = [] replace_index_stack = [] bracket_index_stack = [] i = 0 while i < len(str): ...
# Problem 6 MIT Midterm # # The function isMyNumber is used to hide a secret number (integer). # It takes an integer guess as a parameter and compares it to the secret number. # It returns: # -1 if the parameter x is less than the secret number # 0 if the parameter x is correct # 1 if the parameter x is greater than th...
def is_my_number(guess): """ Procedure that hides a secret number. :param guess: integer number :return: -1 if guess is less than the secret number 0 if guess is equal to the secret number 1 if guess is greater than the secret number """ secretnum = 5 if guess == secretnum: ...
def add(a,b): return a+b def sub(a,b): return a-b def multiply(a,b): return a*b def div(a,b): return a/b
def add(a, b): return a + b def sub(a, b): return a - b def multiply(a, b): return a * b def div(a, b): return a / b
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def add(self, data): if self.head is None: self.head = Node(data) else: temp = self.head self.head = N...
class Node: def __init__(self, data): self.data = data self.next = None class Linkedlist: def __init__(self): self.head = None def add(self, data): if self.head is None: self.head = node(data) else: temp = self.head self.head = ...
#!/usr/bin/python x = int(raw_input("Ingrese el input1: ")) print(not x)
x = int(raw_input('Ingrese el input1: ')) print(not x)
''' Visit the link : https://reeborg.ca/reeborg.html?lang=en&mode=python&menu=worlds%2Fmenus%2Freeborg_intro_en.json&name=Hurdle%202&url=worlds%2Ftutorial_en%2Fhurdle2.json ''' def turn_right(): turn_left() turn_left() turn_left() def complete(): move() turn_left() move() turn_right() ...
""" Visit the link : https://reeborg.ca/reeborg.html?lang=en&mode=python&menu=worlds%2Fmenus%2Freeborg_intro_en.json&name=Hurdle%202&url=worlds%2Ftutorial_en%2Fhurdle2.json """ def turn_right(): turn_left() turn_left() turn_left() def complete(): move() turn_left() move() turn_right() ...
# Copyright 2017 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. DEPS = [ 'bisect_tester_staging', 'chromium', 'chromium_tests', 'recipe_engine/path', 'recipe_engine/properties', 'recipe_engine/step...
deps = ['bisect_tester_staging', 'chromium', 'chromium_tests', 'recipe_engine/path', 'recipe_engine/properties', 'recipe_engine/step'] def run_steps(api): api.path.c.dynamic_paths['bisect_results'] = api.path['start_dir'].join('bisect_results') api.chromium.set_config('chromium') test = api.chromium_tests....
""" Problem Statement: Print Indentation Correctly Given a string "(hello word (bye bye))" Need to print: ( hello word ( bye bye ) ) Language: Python Written by: Mostofa Adib Shakib References: => https://leetcode.com/discuss/interview-question/409902/Snap-or-phone-or-print-indentation-correctly...
""" Problem Statement: Print Indentation Correctly Given a string "(hello word (bye bye))" Need to print: ( hello word ( bye bye ) ) Language: Python Written by: Mostofa Adib Shakib References: => https://leetcode.com/discuss/interview-question/409902/Snap-or-phone-or-print-indentation-correctly...
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. (http://www.facebook.com) # $builtin-init-module$ # These values are injected by our boot process. flake8 has no knowledge about # their definitions and will complain without these circular assignments. _Unbound = _Unbound # noqa: F821 def _...
__unbound = _Unbound def __context_var_guard(obj): _builtin() def __token_guard(obj): _builtin() def _builtin(): """This function acts as a marker to `freeze_modules.py` it should never actually be called.""" _unimplemented() def _address(c): _builtin() def _anyset_check(obj): _builtin(...
def longestCommonSubsequence(str1, str2): if not str1 or not str2: return [] dp = [[0 for _ in range(len(str2))] for __ in range(len(str1))] commons = [] inc = 0 for i in range(len(str1)): if str1[i] == str2[0]: inc = 1 dp[i][0] = inc inc = 0 for j in ra...
def longest_common_subsequence(str1, str2): if not str1 or not str2: return [] dp = [[0 for _ in range(len(str2))] for __ in range(len(str1))] commons = [] inc = 0 for i in range(len(str1)): if str1[i] == str2[0]: inc = 1 dp[i][0] = inc inc = 0 for j in ra...
# -*- coding: utf-8 -*- class Node: def __init__(self, node_type): self.type = node_type self.node_problems = [] @property def name(self): return "" @property def problems(self): return self.node_problems class ValueNode(Node): def __init__(self, node_type, va...
class Node: def __init__(self, node_type): self.type = node_type self.node_problems = [] @property def name(self): return '' @property def problems(self): return self.node_problems class Valuenode(Node): def __init__(self, node_type, value): super()._...
''' https://leetcode.com/problems/maximum-subarray/ ''' class Solution(object): def maxSubArray(self, nums): if len(nums) == 1: return nums[0] m = nums[0] h = {0:nums[0]} for i in range(1, len(nums)): # we loop through the array and store the longest suba...
""" https://leetcode.com/problems/maximum-subarray/ """ class Solution(object): def max_sub_array(self, nums): if len(nums) == 1: return nums[0] m = nums[0] h = {0: nums[0]} for i in range(1, len(nums)): h[i] = max(nums[i], nums[i] + h[i - 1]) ...
input = open('input.txt', 'r').read().split("\n") # Part 1 x = 0 depth = 0 for line in input: line_elements = line.split(' ') cmd = line_elements[0] distance = int(line_elements[1]) if cmd == 'forward': x += distance elif cmd == 'down': depth += distance else: depth += -distance print('X: ' + str(x)) p...
input = open('input.txt', 'r').read().split('\n') x = 0 depth = 0 for line in input: line_elements = line.split(' ') cmd = line_elements[0] distance = int(line_elements[1]) if cmd == 'forward': x += distance elif cmd == 'down': depth += distance else: depth += -distance p...
_base_ = [ '../../_base_/models/swav/r50.py', '../../_base_/datasets/imagenet/swav_mcrop-2-6_sz224_96_bs32.py', '../../_base_/default_runtime.py', ] # model settings model = dict( type='SwAV', backbone=dict( type='ResNet', depth=50, num_stages=4, out_indices=(3,), #...
_base_ = ['../../_base_/models/swav/r50.py', '../../_base_/datasets/imagenet/swav_mcrop-2-6_sz224_96_bs32.py', '../../_base_/default_runtime.py'] model = dict(type='SwAV', backbone=dict(type='ResNet', depth=50, num_stages=4, out_indices=(3,), norm_cfg=dict(type='SyncBN'), style='pytorch'), neck=dict(type='SwAVNeck', in...
# File: vmray_consts.py # # Licensed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt) VMRAY_JSON_SERVER = "vmray_server" VMRAY_JSON_API_KEY = "vmray_api_key" VMRAY_JSON_DISABLE_CERT = "disable_cert_verification" VMRAY_ERR_SERVER_CONNECTION = "Could not connect to server. {}" VMRAY_ERR_CONNECTIVITY_TES...
vmray_json_server = 'vmray_server' vmray_json_api_key = 'vmray_api_key' vmray_json_disable_cert = 'disable_cert_verification' vmray_err_server_connection = 'Could not connect to server. {}' vmray_err_connectivity_test = 'Connectivity test failed' vmray_succ_connectivity_test = 'Connectivity test passed' vmray_err_unsup...
IDENTIFIER = 'everything' NEWSPAPER_DIR = 'newspapers_everything' RESULTS_DIR = 'results_everything' MIN_FREQUENCY = 50 EPOCHS = 40 MODEL_OPTIONS = { 'vector_size': 100, 'alpha': 0.1, 'window': 8, 'sample': 0.00001, 'workers': 8 } VOCABULARY = f'{IDENTIFIER}.dict'
identifier = 'everything' newspaper_dir = 'newspapers_everything' results_dir = 'results_everything' min_frequency = 50 epochs = 40 model_options = {'vector_size': 100, 'alpha': 0.1, 'window': 8, 'sample': 1e-05, 'workers': 8} vocabulary = f'{IDENTIFIER}.dict'
a, b, c = map(int, input().split()) x = max(a, b, c) total = a + b + c if x % 2 != total % 2: x += 1 print((3 * x - total) // 2)
(a, b, c) = map(int, input().split()) x = max(a, b, c) total = a + b + c if x % 2 != total % 2: x += 1 print((3 * x - total) // 2)
class BentPlateTestingTool(object): """ BentPlateTestingTool() """ def CreateByFaces(self, part1, face1, part2, face2): """ CreateByFaces(self: BentPlateTestingTool,part1: Part,face1: IList[Point],part2: Part,face2: IList[Point]) -> BentPlate """ pass
class Bentplatetestingtool(object): """ BentPlateTestingTool() """ def create_by_faces(self, part1, face1, part2, face2): """ CreateByFaces(self: BentPlateTestingTool,part1: Part,face1: IList[Point],part2: Part,face2: IList[Point]) -> BentPlate """ pass
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def __init__(self): self.rst = list() def inorderTraversal(self, root): """ :type root: TreeNode :rt...
class Solution: def __init__(self): self.rst = list() def inorder_traversal(self, root): """ :type root: TreeNode :rtype: List[int] """ self.inorder_traverse(root) return self.rst def inorder_traverse(self, root): if root: self.i...
count = 0 sum = 0 while True: X = float(input('')) if X >= 0 and X <= 10: count += 1 sum += X if count == 2: average = sum / count print('media = %0.2f' %average) break else: print('nota invalida')
count = 0 sum = 0 while True: x = float(input('')) if X >= 0 and X <= 10: count += 1 sum += X if count == 2: average = sum / count print('media = %0.2f' % average) break else: print('nota invalida')
commands = [] while True: try: line = input() except: break if not line: break commands.append(line.split()) for starting_a in range(155, 160): d = {'a': starting_a, 'b': 0, 'c': 0, 'd': 0} i = 0 out = [] while len(out) < 100: if commands[i][0] == 'inc' and commands[i+1][0] == ...
commands = [] while True: try: line = input() except: break if not line: break commands.append(line.split()) for starting_a in range(155, 160): d = {'a': starting_a, 'b': 0, 'c': 0, 'd': 0} i = 0 out = [] while len(out) < 100: if commands[i][0] == 'inc' an...
tiles = [ (17, 20946, 50678), # https://www.openstreetmap.org/way/215472849 (17, 20959, 50673), # https://www.openstreetmap.org/node/1713279804 (17, 20961, 50675), # https://www.openstreetmap.org/node/3188857553 (17, 20969, 50656), # https://www.openstreetmap.org/node/3396659022 (17, 21013, 50637), ...
tiles = [(17, 20946, 50678), (17, 20959, 50673), (17, 20961, 50675), (17, 20969, 50656), (17, 21013, 50637), (17, 21019, 50617), (17, 21028, 50645), (17, 38597, 49266), (17, 38598, 49259), (17, 38600, 49261), (17, 38601, 49258)] for (z, x, y) in tiles: assert_has_feature(z, x, y, 'pois', {'kind': 'toys'})
def method1(n: int) -> int: c = 0 while n: c += n & 1 n >>= 1 return c def method2(n: int) -> int: if n == 0: return 0 else: return (n & 1) + method2(n >> 1) if __name__ == "__main__": """ from timeit import timeit print(timeit(lambda: method1(9), numb...
def method1(n: int) -> int: c = 0 while n: c += n & 1 n >>= 1 return c def method2(n: int) -> int: if n == 0: return 0 else: return (n & 1) + method2(n >> 1) if __name__ == '__main__': '\n from timeit import timeit\n print(timeit(lambda: method1(9), number=...
''' Given two integer arrays nums1 and nums2, return the maximum length of a subarray that appears in both arrays. Input: nums1 = [1,2,3,2,1], nums2 = [3,2,1,4,7] Output: 3 Explanation: The repeated subarray with maximum length is [3,2,1]. Input: num1 = [3], nums2 = [3] Output: 1 Input: [1,2], [4,6] Output: 0 Input...
""" Given two integer arrays nums1 and nums2, return the maximum length of a subarray that appears in both arrays. Input: nums1 = [1,2,3,2,1], nums2 = [3,2,1,4,7] Output: 3 Explanation: The repeated subarray with maximum length is [3,2,1]. Input: num1 = [3], nums2 = [3] Output: 1 Input: [1,2], [4,6] Output: 0 Input...
def data_generator_enabled(request): return {'DATA_GENERATOR_ENABLED': True}
def data_generator_enabled(request): return {'DATA_GENERATOR_ENABLED': True}
class Encoders: def __init__(self, aStar): self.aStar = aStar self.countLeft = 0 self.countRight = 0 self.lastCountLeft = 0 self.lastCountRight = 0 self.countSignLeft = 1 self.countSignRight = -1 self.aStar.reset_encoders() def readCounts(self): ...
class Encoders: def __init__(self, aStar): self.aStar = aStar self.countLeft = 0 self.countRight = 0 self.lastCountLeft = 0 self.lastCountRight = 0 self.countSignLeft = 1 self.countSignRight = -1 self.aStar.reset_encoders() def read_counts(self):...
def DectoHex(n): if isinstance(n,int) == True: hexnum = hex(n)[2:] return hexnum.upper() else: intnum = int(n) hexnum = hex(intnum)[2:] return hexnum.upper()
def decto_hex(n): if isinstance(n, int) == True: hexnum = hex(n)[2:] return hexnum.upper() else: intnum = int(n) hexnum = hex(intnum)[2:] return hexnum.upper()
params = [ { 'dronename': 'drone', 'stateofhealth': 100.0, 'startstateofcharge': 100.0, 'altitude': 100.0, 'temperaturesealevel': 15.0, 'rain': False, 'dropsize': 0.0, 'liquidwatercontent': 1.0, 'temperature': 15.0, 'wind': False, 'windspeed': 0.0, 'winddirection': 0.0, 'relativehumidity': 85.0, 'icing': False, 'timest...
params = [{'dronename': 'drone', 'stateofhealth': 100.0, 'startstateofcharge': 100.0, 'altitude': 100.0, 'temperaturesealevel': 15.0, 'rain': False, 'dropsize': 0.0, 'liquidwatercontent': 1.0, 'temperature': 15.0, 'wind': False, 'windspeed': 0.0, 'winddirection': 0.0, 'relativehumidity': 85.0, 'icing': False, 'timestep...
__ = "-=> FILL ME IN! <=-" def assert_equal(expected, actual): assert expected == actual, '%r == %r' % (expected, actual) # double quoted strings are strings string = "Hello, world." assert_equal(__, isinstance(string, str)) # single quoted strings are also strings string = 'Goodbye, world.' assert_equal(__, i...
__ = '-=> FILL ME IN! <=-' def assert_equal(expected, actual): assert expected == actual, '%r == %r' % (expected, actual) string = 'Hello, world.' assert_equal(__, isinstance(string, str)) string = 'Goodbye, world.' assert_equal(__, isinstance(string, str)) string = 'Howdy, world!' assert_equal(__, isinstance(stri...
""" >>> nCr(4, 2) 6 """ def nCr(n, k): # C = [[0] * (k+1) for i in range(n+1)] # for i in range(n+1): # C[i][0] = 1 # for i in range(1, k+1): # C[0][i] = 0 # for i in range(1, n+1): # for j in range(1, k+1): # C[i][j] = C[i-1][j-1] + C[i-1][j] # return C C =...
""" >>> nCr(4, 2) 6 """ def n_cr(n, k): c = [0] * (k + 1) C[0] = 1 for i in range(n): print(i) c_backup = C[:] for j in range(1, k + 1): C[j] += C_backup[j - 1] return C[k] print(n_cr(4, 2)) print(n_cr(5, 4)) print(n_cr(6, 3))
skip_files = ["Fleece+CoreFoundation.h"] excluded = ["FLStr","operatorslice","operatorFLSlice","FLMutableArray_Retain","FLMutableArray_Release","FLMutableDict_Retain","FLMutableDict_Release","FLEncoder_NewWritingToFile","FLSliceResult_Free"] default_param_name = {"FLValue":"value","FLSliceResult":"slice","FLSlice":"sli...
skip_files = ['Fleece+CoreFoundation.h'] excluded = ['FLStr', 'operatorslice', 'operatorFLSlice', 'FLMutableArray_Retain', 'FLMutableArray_Release', 'FLMutableDict_Retain', 'FLMutableDict_Release', 'FLEncoder_NewWritingToFile', 'FLSliceResult_Free'] default_param_name = {'FLValue': 'value', 'FLSliceResult': 'slice', 'F...
"""This application overrides to django-machina's forum_conversation app.""" # pylint: disable=invalid-name default_app_config = ( "ashley.machina_extensions.forum_conversation.apps.ForumConversationAppConfig" )
"""This application overrides to django-machina's forum_conversation app.""" default_app_config = 'ashley.machina_extensions.forum_conversation.apps.ForumConversationAppConfig'
# [351] Android Unlock Patterns # Description # Given an Android 3x3 key lock screen and two integers m and n, where 1 <= m <= n <= 9, # count the total number of unlock patterns of the Android lock screen, which consist # of minimum of m keys and maximum n keys. # Rules for a valid pattern: # 1) Each pattern must ...
class Solution: """ @param m: an integer @param n: an integer @return: the total number of unlock patterns of the Android lock screen """ def __init__(self): self.count = 0 self.res = [] self.corners = [[0, 0], [0, 2], [2, 0], [2, 2]] def number_of_patterns(self, m,...
# SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. class GroupTransform: """ GroupTransform """ def __init__(self): pass def getTransform(self, index): pass def getNumTransforms(self): pass def appendTransform(self, transform...
class Grouptransform: """ GroupTransform """ def __init__(self): pass def get_transform(self, index): pass def get_num_transforms(self): pass def append_transform(self, transform): pass
''' Created on 27 Aug 2010 @author: dev solr configurations ''' solr_base_url = "http://solr:8983/solr/" solr_urls = { 'all' : solr_base_url + 'all', 'locations' : solr_base_url + 'locations', 'comments' : solr_base_url + 'comments', 'images' : solr_base_url + 'images', 'works' : solr_base_url +...
""" Created on 27 Aug 2010 @author: dev solr configurations """ solr_base_url = 'http://solr:8983/solr/' solr_urls = {'all': solr_base_url + 'all', 'locations': solr_base_url + 'locations', 'comments': solr_base_url + 'comments', 'images': solr_base_url + 'images', 'works': solr_base_url + 'works', 'people': solr_bas...
def clean_version( version: str, *, build: bool = False, patch: bool = False, commit: bool = False, drop_v: bool = False, flat: bool = False, ): "Clean up and transform the many flavours of versions" # 'v1.13.0-103-gb137d064e' --> 'v1.13-103' if version in ["", "-"]: re...
def clean_version(version: str, *, build: bool=False, patch: bool=False, commit: bool=False, drop_v: bool=False, flat: bool=False): """Clean up and transform the many flavours of versions""" if version in ['', '-']: return version nibbles = version.split('-') if not patch: if nibbles[0] ...
print("Insert an in integer") n = input() nn = n + n nnn = nn + n result = int(n) + int(nn) + int(nnn) print(result)
print('Insert an in integer') n = input() nn = n + n nnn = nn + n result = int(n) + int(nn) + int(nnn) print(result)
""" Metaclass of Response and Request """ class ResponseMeta(type): """ Meta class of Response """ response_class_by_response_type = {} @classmethod def register(mcs, clazz, typez): """ register son class to response_class_by_response_type :param clazz: son class ...
""" Metaclass of Response and Request """ class Responsemeta(type): """ Meta class of Response """ response_class_by_response_type = {} @classmethod def register(mcs, clazz, typez): """ register son class to response_class_by_response_type :param clazz: son class ...
# ______________________________________________________________________________ # The Wumpus World class Gold(Thing): def __eq__(self, rhs): '''All Gold are equal''' return rhs.__class__ == Gold pass class Bump(Thing): pass class Glitter(Thing): pass class Pit(Thing): pass cl...
class Gold(Thing): def __eq__(self, rhs): """All Gold are equal""" return rhs.__class__ == Gold pass class Bump(Thing): pass class Glitter(Thing): pass class Pit(Thing): pass class Breeze(Thing): pass class Arrow(Thing): pass class Scream(Thing): pass class Wumpus...
"""2019 Advent of Code, Day 1""" with open("input", "r+") as file: puzzle_input = file.readlines() def mass(item): """Calculate the fuel required for an item, and the fuel required for that fuel, and so on""" fuel = item // 3 - 2 if fuel < 0: return 0 return fuel + mass(fuel) SUM = 0 SUM...
"""2019 Advent of Code, Day 1""" with open('input', 'r+') as file: puzzle_input = file.readlines() def mass(item): """Calculate the fuel required for an item, and the fuel required for that fuel, and so on""" fuel = item // 3 - 2 if fuel < 0: return 0 return fuel + mass(fuel) sum = 0 sum_2 ...
class Command(object): """ By using the NAMES command, a user can list all nicknames that are visible to him. For more details on what is visible and what is not, see "Internet Relay Chat: Channel Management" [IRC-CHAN]. The <channel> parameter specifies which channel(s) to return information ...
class Command(object): """ By using the NAMES command, a user can list all nicknames that are visible to him. For more details on what is visible and what is not, see "Internet Relay Chat: Channel Management" [IRC-CHAN]. The <channel> parameter specifies which channel(s) to return information a...
print(divmod(100, 7)) print(7 > 2 and 1 > 6) print(7 > 2 or 1 > 6) number_list = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] print(number_list[2:8]) print(number_list[0:9:3]) print(number_list[0:10:3])
print(divmod(100, 7)) print(7 > 2 and 1 > 6) print(7 > 2 or 1 > 6) number_list = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] print(number_list[2:8]) print(number_list[0:9:3]) print(number_list[0:10:3])
# https://docs.python.org/3/library/functions.html#built-in-functions my_results = [True, True, 2*2==4, True] print(all(my_results)) # all statements in the sequence should be truthy to get True else we get False my_results.append(False) print(my_results) print(all(my_results)) #In logic this is called universal quanto...
my_results = [True, True, 2 * 2 == 4, True] print(all(my_results)) my_results.append(False) print(my_results) print(all(my_results)) print(any(my_results)) print(len(my_results)) my_results.append(9000) print('max', max(my_results)) my_results.append(-30) print(my_results) print('min', min(my_results)) print('summa', s...
#!/usr/bin/env pyrate build_output = ['makefile'] ex_d = executable('exampleM2_debug.bin', 'test.cpp foo.cpp', compiler_opts = '-O0') ex_r = executable('exampleM2_release.bin', 'test.cpp foo.cpp', compiler_opts = '-O3') default_targets = ex_r
build_output = ['makefile'] ex_d = executable('exampleM2_debug.bin', 'test.cpp foo.cpp', compiler_opts='-O0') ex_r = executable('exampleM2_release.bin', 'test.cpp foo.cpp', compiler_opts='-O3') default_targets = ex_r
class DescriptionError(Exception): pass class ParseError(DescriptionError): pass class GettingError(DescriptionError): pass
class Descriptionerror(Exception): pass class Parseerror(DescriptionError): pass class Gettingerror(DescriptionError): pass
MyAttr = 'eval:1' My_Attr = 'eval:foo=1;bar=2;foo+bar' attr_1 = 'tango:a/b/c/d' attr_2 = 'a/b/c/d' attr1 = 'eval:"Hello_World!!"' foo = 'eval:/@Foo/True' # 1foo = 'eval:2' Foo = 'eval:False' res_attr = 'res:attr1' dev1 = 'tango:a/b/c' # invalid for attribute dev2 = 'eval:@foo' # invalid for attribute
my_attr = 'eval:1' my__attr = 'eval:foo=1;bar=2;foo+bar' attr_1 = 'tango:a/b/c/d' attr_2 = 'a/b/c/d' attr1 = 'eval:"Hello_World!!"' foo = 'eval:/@Foo/True' foo = 'eval:False' res_attr = 'res:attr1' dev1 = 'tango:a/b/c' dev2 = 'eval:@foo'
# Program to input a number and find it's sum of digits n = int(input("Enter the number: ")) tot = 0 while(n>0): d = n%10 tot = tot+d n=n//10 print("Sum of Digits is:",tot)
n = int(input('Enter the number: ')) tot = 0 while n > 0: d = n % 10 tot = tot + d n = n // 10 print('Sum of Digits is:', tot)
def func(): print("func() in one.py") print("TOP LEVEL ONE.PY") if __name__ == "__main__": print("one.py is being run directly") else: print("one.py has been imported")
def func(): print('func() in one.py') print('TOP LEVEL ONE.PY') if __name__ == '__main__': print('one.py is being run directly') else: print('one.py has been imported')
class NessusObject(object): def __init__(self, server): self._id = None self._server = server def save(self): if self._id is None: return getattr(self._server, "create_%s" % self.__class__.__name__.lower())(self) else: return getattr(self._server, "updat...
class Nessusobject(object): def __init__(self, server): self._id = None self._server = server def save(self): if self._id is None: return getattr(self._server, 'create_%s' % self.__class__.__name__.lower())(self) else: return getattr(self._server, 'updat...
#Find structs by field type. #@author Rena #@category Struct #@keybinding #@menupath #@toolbar StringColumnDisplay = ghidra.app.tablechooser.StringColumnDisplay AddressableRowObject = ghidra.app.tablechooser.AddressableRowObject TableChooserExecutor = ghidra.app.tablechooser.TableChooserExecutor DTM = state.tool.getS...
string_column_display = ghidra.app.tablechooser.StringColumnDisplay addressable_row_object = ghidra.app.tablechooser.AddressableRowObject table_chooser_executor = ghidra.app.tablechooser.TableChooserExecutor dtm = state.tool.getService(ghidra.app.services.DataTypeManagerService) af = currentProgram.getAddressFactory() ...
expected_output = { "interface": { "GigabitEthernet1/0/1": { "out": { "mcast_pkts": 188396, "bcast_pkts": 0, "ucast_pkts": 124435064, "name": "GigabitEthernet1/0/1", "octets": 24884341205, }, ...
expected_output = {'interface': {'GigabitEthernet1/0/1': {'out': {'mcast_pkts': 188396, 'bcast_pkts': 0, 'ucast_pkts': 124435064, 'name': 'GigabitEthernet1/0/1', 'octets': 24884341205}, 'in': {'mcast_pkts': 214513, 'bcast_pkts': 0, 'ucast_pkts': 15716712, 'name': 'GigabitEthernet1/0/1', 'octets': 3161931167}}}}
DOMAIN = "echonet_lite" MANUFACTURER = { 0x0B: "Panasonic", 0x69: "Toshiba", 0x2f: "AIPHONE", } CONF_STATE_CLASS = "state_class"
domain = 'echonet_lite' manufacturer = {11: 'Panasonic', 105: 'Toshiba', 47: 'AIPHONE'} conf_state_class = 'state_class'
""" Container for Configuration related errors. """ class ConfigError(Exception): """ Generic exception raised by configuration errors. """ def __init__(self, expr, msg): self.expression = expr self.message = msg def __str__(self): return self.message
""" Container for Configuration related errors. """ class Configerror(Exception): """ Generic exception raised by configuration errors. """ def __init__(self, expr, msg): self.expression = expr self.message = msg def __str__(self): return self.message
files = ['avalon_mm_bfm_pkg.vhd', 'avalon_st_bfm_pkg.vhd', 'axilite_bfm_pkg.vhd', 'axistream_bfm_pkg.vhd', 'gmii_bfm_pkg.vhd', 'gpio_bfm_pkg.vhd', 'i2c_bfm_pkg.vhd', 'rgmii_bfm_pkg.vhd', 'sbi_bfm_pkg.vhd', 'spi_bfm_pkg.vhd', 'uart...
files = ['avalon_mm_bfm_pkg.vhd', 'avalon_st_bfm_pkg.vhd', 'axilite_bfm_pkg.vhd', 'axistream_bfm_pkg.vhd', 'gmii_bfm_pkg.vhd', 'gpio_bfm_pkg.vhd', 'i2c_bfm_pkg.vhd', 'rgmii_bfm_pkg.vhd', 'sbi_bfm_pkg.vhd', 'spi_bfm_pkg.vhd', 'uart_bfm_pkg.vhd']
#pragma repy restrictions.loose # create a junk.py file myfo = open("junk.py","w") print >> myfo, "print 'Hello world'" myfo.close() removefile("junk.py") # should be removed...
myfo = open('junk.py', 'w') (print >> myfo, "print 'Hello world'") myfo.close() removefile('junk.py')
""" How to find GCD (Greater Common Divisor) of two numbers using recursion? Based on Euclidean Algorithm """ def GCD(n1, n2): assert n1 != 0 and n2 != 0 and int(n1) == n1 and int(n2) == n2, "error" if n1 < 0: n1 *= -1 if n2 < 0: n2 *= -1 if n1 % n2 == 0: return n2 return G...
""" How to find GCD (Greater Common Divisor) of two numbers using recursion? Based on Euclidean Algorithm """ def gcd(n1, n2): assert n1 != 0 and n2 != 0 and (int(n1) == n1) and (int(n2) == n2), 'error' if n1 < 0: n1 *= -1 if n2 < 0: n2 *= -1 if n1 % n2 == 0: return n2 retur...
a = ['a','b','c'] b = ['1','2','3','4','5','6'] c = list(zip(*b)) print(a) print(c) for d,e in zip(c,a): print(d) print(e)
a = ['a', 'b', 'c'] b = ['1', '2', '3', '4', '5', '6'] c = list(zip(*b)) print(a) print(c) for (d, e) in zip(c, a): print(d) print(e)
#!/usr/bin/env python # coding: utf-8 # # Mendel's First Law # ## Problem # # Probability is the mathematical study of randomly occurring phenomena. We will model such a phenomenon with a random variable, which is simply a variable that can take a number of different distinct outcomes depending on the result of an un...
def mendel(x, y, z): total = x + y + z two_recess = z / total * ((z - 1) / (total - 1)) two_hetero = y / total * ((y - 1) / (total - 1)) hetero_recess = z / total * (y / (total - 1)) + y / total * (z / (total - 1)) recess_prob = twoRecess + twoHetero * 1 / 4 + heteroRecess * 1 / 2 print(1 - rece...
# examples on set and dict comprehensions # EXAMPLES OF SET COMPREHENSION # making a set comprehension is actually really easy # instead of a list, we'll just use a set notation as follows: my_list = [char for char in 'hello'] my_set = {char for char in 'hello'} print(my_list) print(my_set) my_list1 = [num for num i...
my_list = [char for char in 'hello'] my_set = {char for char in 'hello'} print(my_list) print(my_set) my_list1 = [num for num in range(10)] my_set1 = {num for num in range(10)} print(my_list1) print(my_set1) my_list2 = [num ** 2 for num in range(50) if num % 2 == 0] my_set2 = {num ** 2 for num in range(50) if num % 2 =...
class binding_(object): """Register key bindings with the object binding.""" def __init__(self): self.bindings = {} def __call__(self, key): def register(func): def decorator(model, nav, io, *args, **kwargs): res = func(model, nav, io, *args, **kwargs) ...
class Binding_(object): """Register key bindings with the object binding.""" def __init__(self): self.bindings = {} def __call__(self, key): def register(func): def decorator(model, nav, io, *args, **kwargs): res = func(model, nav, io, *args, **kwargs) ...
class HtmlReportException(Exception): pass class HtmlReport: def __init__(self): self.path = None self.file = None self.header = None self.start_time = None self.is_initialized = False def __del__(self): if self.is_initialized and self.file: sel...
class Htmlreportexception(Exception): pass class Htmlreport: def __init__(self): self.path = None self.file = None self.header = None self.start_time = None self.is_initialized = False def __del__(self): if self.is_initialized and self.file: sel...
SIZE = 9 INPUT_LEVEL_DIR = "File.txt" INPUT_CONSTRAINTS_DIR = "Constraints.txt" OUTPUT_SOLUTION_DIR = "Solution.txt" ASSIGNED_VALUE_NUM = 0
size = 9 input_level_dir = 'File.txt' input_constraints_dir = 'Constraints.txt' output_solution_dir = 'Solution.txt' assigned_value_num = 0
class Mother: @staticmethod def take_screenshot(): print('I can make a screenshot') @staticmethod def receive_email(): print('I can receive email') class Father: @staticmethod def drive_car(): print('I can drive a car ') @staticmethod def play_music(): ...
class Mother: @staticmethod def take_screenshot(): print('I can make a screenshot') @staticmethod def receive_email(): print('I can receive email') class Father: @staticmethod def drive_car(): print('I can drive a car ') @staticmethod def play_music(): ...
class NewsModule: def __init__(self): pass def update(self): pass
class Newsmodule: def __init__(self): pass def update(self): pass
# AUTOGENERATED! DO NOT EDIT! File to edit: 01_Virtual_data_setup.ipynb (unless otherwise specified). __all__ = ['Get_sub_watersheds'] # Cell def Get_sub_watersheds(watershed, order_max, order_min = 4): '''Obtains the sub-watersheds a different orders starting from the order_max and ending on the order_min, t...
__all__ = ['Get_sub_watersheds'] def get_sub_watersheds(watershed, order_max, order_min=4): """Obtains the sub-watersheds a different orders starting from the order_max and ending on the order_min, there is no return, it only updates the watershed.Table""" orders = np.arange(order_max, order_min, -1).tolis...
class Slot: def __init__(self, name="", description = ""): self.type = type # categorical, verbatim self.name = name self.description = description self.values = ["not-present"] self.values_descriptions = ["Ignore me, I'm used for programming."] def len (self): ...
class Slot: def __init__(self, name='', description=''): self.type = type self.name = name self.description = description self.values = ['not-present'] self.values_descriptions = ["Ignore me, I'm used for programming."] def len(self): return len(self.values) ...
# Check if removing an edge of a binary tree can divide # the tree in two equal halves # Count the number of nodes, say n. Then traverse the tree # in bottom up manner and check if n - s = s class Node: def __init__(self, val): self.val = val self.left = None self.right = None def coun...
class Node: def __init__(self, val): self.val = val self.left = None self.right = None def count(root): if not root: return 0 return count(root.left) + count(root.right) + 1 def check_util(root, n): if root == None: return False if count(root) == n - count(...
class Cipher: def __init__(self, codestring): # Hints: # Does the capitalization of the words or letter matter here? # Is hello the same as Hello or even hElLo in terms of definition? Yes # Maybe we should convert everything to uppercase # Add your code here self.a...
class Cipher: def __init__(self, codestring): self.alphabet = None self.codestring = '' for letter in 'ZYXWVUTSRQPONMLKJIHGFEDCBA': if None not in codestring: self.codestring += None self.codestring = codestring + self.codestring self.code = {} ...
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2006 Zuza Software Foundation # # This file is part of translate. # # translate is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of t...
"""A wrapper for sys.stdout etc that provides tell() for current position""" class Stdiowrapper: def __init__(self, stream): self.stream = stream self.pos = 0 self.closed = 0 def __getattr__(self, attrname, default=None): return getattr(self.stream, attrname, default) def...
description = 'FRM II FAK40 information (cooling water system)' group = 'lowlevel' tango_base = 'tango://ictrlfs.ictrl.frm2:10000/frm2/' devices = dict( FAK40_Cap = device('nicos.devices.entangle.AnalogInput', tangodevice = tango_base +'fak40/CF001', description = 'The capacity of the cooling wat...
description = 'FRM II FAK40 information (cooling water system)' group = 'lowlevel' tango_base = 'tango://ictrlfs.ictrl.frm2:10000/frm2/' devices = dict(FAK40_Cap=device('nicos.devices.entangle.AnalogInput', tangodevice=tango_base + 'fak40/CF001', description='The capacity of the cooling water system', pollinterval=60, ...
# # PySNMP MIB module DHCP-SERVER-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///home/tin/Dev/mibs.snmplabs.com/asn1/DHCP-SERVER-MIB # Produced by pysmi-0.3.4 at Fri Jan 31 21:33:35 2020 # On host bier platform Linux version 5.4.0-3-amd64 by user tin # Using Python version 3.7.6 (default, Jan 19 2020, 22:34:52)...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, constraints_union, value_size_constraint, constraints_intersection) ...
def residual(s:dict, y, x): """ Return residuals :param s: state - supply empty dict on first call :param y: incoming observation :param x: term structure of predictions out k steps ahead, made after y received :returns k-vector of residuals """ k = len(x) if not s: ...
def residual(s: dict, y, x): """ Return residuals :param s: state - supply empty dict on first call :param y: incoming observation :param x: term structure of predictions out k steps ahead, made after y received :returns k-vector of residuals """ k = len(x) if not s: ...
html_head = r"""<?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" ...
html_head = '<?xml version="1.0" encoding="utf-8" ?>\n<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n<head>\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8"...
"""Dot notation for dictionary.""" class Map(dict): """dot.notation access to dictionary attributes. Args: dict (dict): dictionary to map. """ __getattr__ = dict.get __setattr__ = dict.__setitem__ __delattr__ = dict.__delitem__
"""Dot notation for dictionary.""" class Map(dict): """dot.notation access to dictionary attributes. Args: dict (dict): dictionary to map. """ __getattr__ = dict.get __setattr__ = dict.__setitem__ __delattr__ = dict.__delitem__
#!/usr/bin/python3 # https://practice.geeksforgeeks.org/problems/max-level-sum-in-binary-tree/1 def maxLevelSum(root): # Code here h = {} level = 0 getLevelSum(root, level, h) return max(h.values()) def getLevelSum(root, level, h): if root == None: return if level not in h...
def max_level_sum(root): h = {} level = 0 get_level_sum(root, level, h) return max(h.values()) def get_level_sum(root, level, h): if root == None: return if level not in h: h[level] = 0 h[level] += root.data get_level_sum(root.left, level + 1, h) get_level_sum(root.r...
# Copyright 2017 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. class BigQueryObject(object): """A BigQueryObject holds data that will be read from/written to BigQuery.""" def __eq__(self, other): return self.__...
class Bigqueryobject(object): """A BigQueryObject holds data that will be read from/written to BigQuery.""" def __eq__(self, other): return self.__dict__ == other.__dict__ @staticmethod def get_bigquery_attributes(): """Returns a list of attributes that exist in the BigQuery schema. ...
A = [10,13,7] B = [1,2,3,4,5,6] def sum_all(A, B): ASum = sum(A) #print(ASum) BSum = sum(B) #print(BSum) TSum = ASum+BSum #print(TSum) return ASum, BSum, TSum ASum, BSum, TSum = sum_all(A,B) print('The sum of list 1 is '+str(ASum)) print('The sum of list 2 is '+str(BSum)) print('The sum of both lists is '+str...
a = [10, 13, 7] b = [1, 2, 3, 4, 5, 6] def sum_all(A, B): a_sum = sum(A) b_sum = sum(B) t_sum = ASum + BSum return (ASum, BSum, TSum) (a_sum, b_sum, t_sum) = sum_all(A, B) print('The sum of list 1 is ' + str(ASum)) print('The sum of list 2 is ' + str(BSum)) print('The sum of both lists is ' + str(TSum)...
class ScriptBase(type): def __init__(cls, name, bases, attrs): if cls is None: return if not hasattr(cls, "plugins"): cls.plugins = [] else: cls.plugins.append(cls) class ServerBase: __metaclass__ = ScriptBase def __init__(self): su...
class Scriptbase(type): def __init__(cls, name, bases, attrs): if cls is None: return if not hasattr(cls, 'plugins'): cls.plugins = [] else: cls.plugins.append(cls) class Serverbase: __metaclass__ = ScriptBase def __init__(self): super(S...
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None # Find the max and then break the array in two parts. # Then recursively class Solution(object): def constructMaximumBinaryTree(self, nums): ...
class Solution(object): def construct_maximum_binary_tree(self, nums): """ :type nums: List[int] :rtype: TreeNode """ def max_tree(nums, start, end): if start >= end: return None else: opt = (nums[start], start) ...
class BuildProducts(object): '''A class to help keep track of build products in the build. Really this is just a wrapper around a dict stored at the key 'BUILD_TOOL' in an environment. This class doesn't worry about what stored in that dict, though it's generally things like SharedLib configurators...
class Buildproducts(object): """A class to help keep track of build products in the build. Really this is just a wrapper around a dict stored at the key 'BUILD_TOOL' in an environment. This class doesn't worry about what stored in that dict, though it's generally things like SharedLib configurators...
"""Meta Content presentation""" amendment_header = [ "Amendment of Directive 85/611/EEC", "Amendment of Directive 93/6/EEC", "Amendment of Directive 2000/12/EC" ] test_presentations = [ "Article 8 is replaced by the following:", "In Article 7, paragraphs 1 and 2 are " "replaced by the followin...
"""Meta Content presentation""" amendment_header = ['Amendment of Directive 85/611/EEC', 'Amendment of Directive 93/6/EEC', 'Amendment of Directive 2000/12/EC'] test_presentations = ['Article 8 is replaced by the following:', 'In Article 7, paragraphs 1 and 2 are replaced by the following:', 'Article 6 is amended as fo...
class ResourceObject: def __init__(self, resource_type, resource_name, mem_limit_threshold, mem_request_threshold, cpu_limit_threshold, cpu_request_threshold, max_hit): self.resource_type ...
class Resourceobject: def __init__(self, resource_type, resource_name, mem_limit_threshold, mem_request_threshold, cpu_limit_threshold, cpu_request_threshold, max_hit): self.resource_type = resource_type self.resource_name = resource_name self.cpu_limit = 0 self.mem_limit = 0 ...
M = [] size1 = int(input()) for i in range(size1): row = [] for j in range(size1): row.append(int(input())) M.append(row) M2 = [] for i in range(size1): row = [] for j in range(size1): row.append(int(input())) M2.append(row) result = [ [ 0 for i in range(size1) ] for j in r...
m = [] size1 = int(input()) for i in range(size1): row = [] for j in range(size1): row.append(int(input())) M.append(row) m2 = [] for i in range(size1): row = [] for j in range(size1): row.append(int(input())) M2.append(row) result = [[0 for i in range(size1)] for j in range(size...
def currencyCodes(): """ This function returns a list of currency codes. It looks simple, but it can be improved without affecting other components. """ currency_codes = ['USD', 'EUR', 'AUD'] return currency_codes
def currency_codes(): """ This function returns a list of currency codes. It looks simple, but it can be improved without affecting other components. """ currency_codes = ['USD', 'EUR', 'AUD'] return currency_codes
MYSQL_HOST = 'localhost' MYSQL_DBNAME = 'spider' MYSQL_USER = 'root' MYSQL_PASSWD = '123456' MYSQL_PORT = 3306 MYSQL_CHARSET = 'utf8' MYSQL_UNICODE = True
mysql_host = 'localhost' mysql_dbname = 'spider' mysql_user = 'root' mysql_passwd = '123456' mysql_port = 3306 mysql_charset = 'utf8' mysql_unicode = True
class Concrete: x: int @require(lambda x: x > 0) def __init__(self, x: int) -> None: self.x = x @require(lambda self: self.x > 2) @require(lambda number: number > 0) def some_func(self, number: int) -> int: """Do something.""" class Reference: pass __book_url__ = "dummy...
class Concrete: x: int @require(lambda x: x > 0) def __init__(self, x: int) -> None: self.x = x @require(lambda self: self.x > 2) @require(lambda number: number > 0) def some_func(self, number: int) -> int: """Do something.""" class Reference: pass __book_url__ = 'dummy' _...
squares = [1, 4, 9, 16, 25] i = 0 while i < len(squares): print(i, squares[i]) i = i + 1 words = ['cat', 'window', 'defenestrate'] for w in words: print(w, len(w)) for i in range(len(words)): print(i, words[i], len(words[i]))
squares = [1, 4, 9, 16, 25] i = 0 while i < len(squares): print(i, squares[i]) i = i + 1 words = ['cat', 'window', 'defenestrate'] for w in words: print(w, len(w)) for i in range(len(words)): print(i, words[i], len(words[i]))
def ov_range(a_1,a_2,b_1,b_2): big_a=a_1 small_a=a_2 big_b=b_1 small_b=b_1 if a_1<a_2: big_a=a_2 small_a=a_1 elif a_1>a_2: big_a=a_1 small_a=a_2 if b_1>b_2: big_b=b_1 small_b=b_2 elif b_1<b_2: big_b=b_2 small_b=b_1 #print(big_a, '\n', small_a, '\n', big_b, '\n', small_b) interval_1=b...
def ov_range(a_1, a_2, b_1, b_2): big_a = a_1 small_a = a_2 big_b = b_1 small_b = b_1 if a_1 < a_2: big_a = a_2 small_a = a_1 elif a_1 > a_2: big_a = a_1 small_a = a_2 if b_1 > b_2: big_b = b_1 small_b = b_2 elif b_1 < b_2: big_b = ...
#!/usr/bin/env python """ _Agent_t_ Agent test methods """ __all__ = []
""" _Agent_t_ Agent test methods """ __all__ = []
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file") all_content = """filegroup(name = "all", srcs = glob(["**"]), visibility = ["//visibility:public"])""" def include_third_party_repositories(): http_archive( name = "com_github_libevent", build_file_content = all_cont...
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive', 'http_file') all_content = 'filegroup(name = "all", srcs = glob(["**"]), visibility = ["//visibility:public"])' def include_third_party_repositories(): http_archive(name='com_github_libevent', build_file_content=all_content, strip_prefix='libeven...
class ContactInformation(object): def __init__(self, name, weight=100, *args, **kwargs): self.name = name self.weight = weight def __str__(self): return "Unusable Contact: {:s} ({:d})".format(self.name, self.weight) class EmailAddress(ContactInformation): def __init__(self, name, ...
class Contactinformation(object): def __init__(self, name, weight=100, *args, **kwargs): self.name = name self.weight = weight def __str__(self): return 'Unusable Contact: {:s} ({:d})'.format(self.name, self.weight) class Emailaddress(ContactInformation): def __init__(self, name,...
# # Copyright 2019 FMR LLC <opensource@fmr.com> # # SPDX-License-Identifier: MIT # """CLI and library to concurrently execute user-defined commands across AWS accounts. ## Overview `awsrun` is both a CLI and library to execute commands over one or more AWS accounts concurrently. Commands are user-defined Python modul...
"""CLI and library to concurrently execute user-defined commands across AWS accounts. ## Overview `awsrun` is both a CLI and library to execute commands over one or more AWS accounts concurrently. Commands are user-defined Python modules that implement a simple interface to abstract away the complications of obtainin...
py_ignore = """ # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # PyInstaller # Usually these files are...
py_ignore = '\n# Byte-compiled / optimized / DLL files\n__pycache__/\n*.py[cod]\n*$py.class\n\n# C extensions\n*.so\n\n# Distribution / packaging\n.Python\nbuild/\ndevelop-eggs/\ndist/\ndownloads/\neggs/\n.eggs/\nlib/\nlib64/\nparts/\nsdist/\nvar/\nwheels/\n*.egg-info/\n.installed.cfg\n*.egg\nMANIFEST\n\n# PyInstaller\...
class train_test_setup(): def __init__(self, device, net_type, save_dir, voc, prerocess, training_epoch=100, latent_k=32, batch_size=40, hidden_size=300, clip=50, num_of_reviews = 5, intra_method='dualFC', inter_method='dualFC', learning_rate=0.00001, dropout=0, setence_max_len=50...
class Train_Test_Setup: def __init__(self, device, net_type, save_dir, voc, prerocess, training_epoch=100, latent_k=32, batch_size=40, hidden_size=300, clip=50, num_of_reviews=5, intra_method='dualFC', inter_method='dualFC', learning_rate=1e-05, dropout=0, setence_max_len=50): self.device = device ...
"""Provides HTML tags wrappers for pretty printing.""" def bold(s): return '<b>'+s+'</b>' def italic(s): return '<i>'+s+'</i>' def b(s): return bold(s) def i(s): return italic(s) def red(s): return '<font color="red">'+s+'</font>' def green(s): return '<font color="green">'+s+'</font...
"""Provides HTML tags wrappers for pretty printing.""" def bold(s): return '<b>' + s + '</b>' def italic(s): return '<i>' + s + '</i>' def b(s): return bold(s) def i(s): return italic(s) def red(s): return '<font color="red">' + s + '</font>' def green(s): return '<font color="green">' + s...
class Solution(object): def threeSumClosest(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ nums.sort() triplate = [] prevSum = float("-inf") prevDiff = target - prevSum for i in range(len(nums) - 2): ...
class Solution(object): def three_sum_closest(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ nums.sort() triplate = [] prev_sum = float('-inf') prev_diff = target - prevSum for i in range(len(nums) - 2...
MODELS = { "pwc": ( 'configs/pwcnet/pwcnet_ft_4x1_300k_sintel_final_384x768.py', 'checkpoints/pwcnet_ft_4x1_300k_sintel_final_384x768.pth' ), "flownetc": ( 'configs/flownet/flownetc_8x1_sfine_sintel_384x448.py', 'checkpoints/flownetc_8x1_sfine_sintel_384x448.pth' ), ...
models = {'pwc': ('configs/pwcnet/pwcnet_ft_4x1_300k_sintel_final_384x768.py', 'checkpoints/pwcnet_ft_4x1_300k_sintel_final_384x768.pth'), 'flownetc': ('configs/flownet/flownetc_8x1_sfine_sintel_384x448.py', 'checkpoints/flownetc_8x1_sfine_sintel_384x448.pth'), 'raft': ('configs/raft/raft_8x2_100k_mixed_368x768.py', 'c...
''' Implementation of exponential search Time Complexity: O(logn) Space Complexity: Depends on implementation of binary_search {O(logn): recursive, O(1):iterative} Used for unbounded search, when the length of array is infinite or not known ''' #iterative implementation of binary search def binary_search(arr, s, e, x...
""" Implementation of exponential search Time Complexity: O(logn) Space Complexity: Depends on implementation of binary_search {O(logn): recursive, O(1):iterative} Used for unbounded search, when the length of array is infinite or not known """ def binary_search(arr, s, e, x): """ #arr: the array in which we ...
# Copyright (c) 2016, The Regents of the University of California, # through Lawrence Berkeley National Laboratory (subject to receipt # of any required approvals from the U.S. Dept. of Energy). # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the ...
""" Custom exception and warning classes. """ class Eventexception(Exception): """Custom Event exception""" def __init__(self, value): self.value = value def __str__(self): return repr(self.value) class Eventwarning(Warning): """Custom Event warning""" pass class Timerangeexcept...
""" Searching lists. """ toys = ["blocks", "slinky", "fidget spinner", "cards", "doll house", "legos", "blocks", "teddy bear"] # Finding items in a list print(toys.index("legos")) print(toys.index("blocks")) #print(toys.index("video game")) print("") # Checking if items are in a list print("legos" in toys) print("b...
""" Searching lists. """ toys = ['blocks', 'slinky', 'fidget spinner', 'cards', 'doll house', 'legos', 'blocks', 'teddy bear'] print(toys.index('legos')) print(toys.index('blocks')) print('') print('legos' in toys) print('blocks' in toys) print('video game' in toys) print('teddy bear' not in toys) print('dice' not in t...