content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
''' Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit. Note that you cannot sell a stock before you buy one. The points ...
""" Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit. Note that you cannot sell a stock before you buy one. The points ...
class BaseProduct(object): params: dict = {} def __init__(self): pass def get_cashflows(self, *args, **kwargs): return None def pv(self, *args, **kwargs): return 0
class Baseproduct(object): params: dict = {} def __init__(self): pass def get_cashflows(self, *args, **kwargs): return None def pv(self, *args, **kwargs): return 0
def sieve(total): totallist = range(1,total+1) ret = [] if len(totallist) == 1: return ret for num in totallist[1:]: if num in [2,3,5,7,11,13]: ret.append(num) else: insert = True for prime in ret: if num % prime == 0: ...
def sieve(total): totallist = range(1, total + 1) ret = [] if len(totallist) == 1: return ret for num in totallist[1:]: if num in [2, 3, 5, 7, 11, 13]: ret.append(num) else: insert = True for prime in ret: if num % prime == 0: ...
''' Pack consecutive duplicates of list elements into sublists. If a list contains repeated elements they should be placed in separate sublists. Example: * (pack '(a a a a b c c a a d e e e e)) ((A A A A) (B) (C C) (A A) (D) (E E E E)) ''' #taking input of list elements at a single time seperating by space and...
""" Pack consecutive duplicates of list elements into sublists. If a list contains repeated elements they should be placed in separate sublists. Example: * (pack '(a a a a b c c a a d e e e e)) ((A A A A) (B) (C C) (A A) (D) (E E E E)) """ demo_list = input('enter elements seperated by space: ').split(' ') new_...
class SnowyWinter: def snowyHighwayLength(self, startPoints, endPoints): road = [False] * 10001 for s, e in zip(startPoints, endPoints): for i in xrange(s, e): road[i] = True return len([e for e in road if e])
class Snowywinter: def snowy_highway_length(self, startPoints, endPoints): road = [False] * 10001 for (s, e) in zip(startPoints, endPoints): for i in xrange(s, e): road[i] = True return len([e for e in road if e])
############################################################################### # Metadata ''' LC_PATROL_MTD_START { "description" : "Collection of all core LimaCharlie detections.", "author" : "maximelb@google.com", "version" : "1.0" } LC_PATROL_MTD_END ''' #################################################...
""" LC_PATROL_MTD_START { "description" : "Collection of all core LimaCharlie detections.", "author" : "maximelb@google.com", "version" : "1.0" } LC_PATROL_MTD_END """ patrol('WinSuspExecLoc', initialInstances=1, maxInstances=None, relaunchOnFailure=True, onFailureCall=None, scalingFactor=1000, actorArgs=('...
def getNameToDataDict(peopleData): nameToData = {} for ppl in peopleData: nameToData[ppl['name']] = ppl return nameToData def getUniversalAverageMetersPerDay(workoutsData, numberOfPeople, DateManager): chronologicalData = DateManager.getWorkoutsDataChronologically(workoutsData) ergMetersPe...
def get_name_to_data_dict(peopleData): name_to_data = {} for ppl in peopleData: nameToData[ppl['name']] = ppl return nameToData def get_universal_average_meters_per_day(workoutsData, numberOfPeople, DateManager): chronological_data = DateManager.getWorkoutsDataChronologically(workoutsData) ...
# -*- coding: utf-8 -*- """Data types considered in OnTask and its relation with Pandas data types""" class TypeDict(dict): """Class to detect multiple datetime types in Pandas.""" def get(self, key): """Detect if given key is equal to any stored value.""" return next( otype for ...
"""Data types considered in OnTask and its relation with Pandas data types""" class Typedict(dict): """Class to detect multiple datetime types in Pandas.""" def get(self, key): """Detect if given key is equal to any stored value.""" return next((otype for (dtype, otype) in self.items() if key....
# 17th Nov '19 # Time: O(n) # Space: O(1) # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def plusOne(self, head: ListNode) -> ListNode: dummy_head = ListNode(0) dummy_head.next = head n...
class Solution: def plus_one(self, head: ListNode) -> ListNode: dummy_head = list_node(0) dummy_head.next = head non_zero = None temp = dummy_head while temp: if temp.val != 9: non_zero = temp temp = temp.next non_zero.val += 1...
# Created by Egor Kostan. # GitHub: https://github.com/ikostan # LinkedIn: https://www.linkedin.com/in/egor-kostan/ def anagrams(word, words): """ A function that will find all the anagrams of a word from a list. You will be given two inputs a word and an array with words. You should return an arra...
def anagrams(word, words): """ A function that will find all the anagrams of a word from a list. You will be given two inputs a word and an array with words. You should return an array of all the anagrams or an empty array if there are none. """ template = sorted([char for char in word]) ...
# s -> singular # m -> multiple # b -> begin of a compound noun (like "serialized" in "serialized thread") # e -> end of a compound noun (like "thread" in "serialized thread") # a -> alone (never part of a compound noun like "garbage collector") # r -> regular (add s at the end to make it multiple) # i -> irregular (...
noun_list = [['sar', 'git'], ['sar', 'github'], ['sar', 'gitlab'], ['sar', 'gitea'], ['sar', 'bitbucket'], ['smer', 'branch'], ['smer', 'commit'], ['smber', 'log'], ['smar', 'pull request'], ['smar', 'merge request'], ['smber', 'stash'], ['sber', 'status'], ['smber', 'tag'], ['smber', 'origin'], ['smber', 'master'], ['...
class SpineParsingException(Exception): def __init__(self, message, code_error=None, *args, **kwargs): self.message = message self.code_error = code_error super(SpineParsingException, self).__init__(*args, **kwargs) def __str__(self): return str(self.message) class SpineJsonE...
class Spineparsingexception(Exception): def __init__(self, message, code_error=None, *args, **kwargs): self.message = message self.code_error = code_error super(SpineParsingException, self).__init__(*args, **kwargs) def __str__(self): return str(self.message) class Spinejsoned...
## A py module for constants. ## ## Oh, and a license thingy because otherwise it won't look cool and ## professional. ## ## MIT License ## ## Copyright (c) [2016] [Mehrab Hoque] ## ## Permission is hereby granted, free of charge, to any person obtaining a copy ## of this software and associated documentation files (th...
""" A py module for constants. WARN: This module is not meant to be used in any way besides in the internals of the spice API source code. """ 'The URL for verifying credentials.\n' credentials_verify = 'https://myanimelist.net/api/account/verify_credentials.xml' 'The base URLs for querying anime/manga searches based ...
# https://open.kattis.com/problems/flowfree def find_color_positions(board): colors = {} squares_to_visit = 0 for row in range(4): for col in range(4): v = board[row][col] if v == 'W': squares_to_visit += 1 continue if v not in ...
def find_color_positions(board): colors = {} squares_to_visit = 0 for row in range(4): for col in range(4): v = board[row][col] if v == 'W': squares_to_visit += 1 continue if v not in colors: colors[v] = {} ...
# -*- encoding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved # $Id$ # # This program is free software: you can redistribute it and/or modify # ...
{'name': 'Database Auto-Backup', 'version': '1.0', 'author': 'Tiny', 'website': 'http://www.openerp.com', 'category': 'Generic Modules', 'description': "The generic Open ERP Database Auto-Backup system enables the user to make configurations for the automatic backup of the database.\nUser simply requires to specify hos...
# Time: O(m^2 * n^2) # Space: O(m^2 * n^2) # A* Search Algorithm without heap class Solution(object): def minPushBox(self, grid): """ :type grid: List[List[str]] :rtype: int """ directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] def dot(a, b): return a[0]*b...
class Solution(object): def min_push_box(self, grid): """ :type grid: List[List[str]] :rtype: int """ directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] def dot(a, b): return a[0] * b[0] + a[1] * b[1] def can_reach(grid, b, p, t): (clos...
# # PHASE: compile # # DOCUMENT THIS # load( "@io_bazel_rules_scala//scala/private:rule_impls.bzl", "compile_or_empty", "pack_source_jars", ) load("//tools:dump.bzl", "dump") def phase_binary_compile(ctx, p): args = struct( buildijar = False, unused_dependency_checker_ignored_targets =...
load('@io_bazel_rules_scala//scala/private:rule_impls.bzl', 'compile_or_empty', 'pack_source_jars') load('//tools:dump.bzl', 'dump') def phase_binary_compile(ctx, p): args = struct(buildijar=False, unused_dependency_checker_ignored_targets=[target.label for target in p.scalac_provider.default_classpath + ctx.attr....
VERSION = '1.0' ALGORITHM_AUTHOR = 'Chris Schnaufer, Ken Youens-Clark' # ALGORITHM_AUTHOR_EMAIL = 'schnaufer@arizona.edu, kyclark@arizona.edu' ALGORITHM_AUTHOR_EMAIL = ['schnaufer@arizona.edu', 'kyclark@arizona.edu'] WRITE_BETYDB_CSV = True
version = '1.0' algorithm_author = 'Chris Schnaufer, Ken Youens-Clark' algorithm_author_email = ['schnaufer@arizona.edu', 'kyclark@arizona.edu'] write_betydb_csv = True
class InvalidArgument(Exception): def __init__(self, mesaje=""): super().__init__(mesaje) class InvalidRef(Exception): def __init__(self, mesaje="") -> None: super().__init__(mesaje) class InvalidCommand(Exception): def __init__(self, mesaje="") -> None: super().__init__(mesaje)
class Invalidargument(Exception): def __init__(self, mesaje=''): super().__init__(mesaje) class Invalidref(Exception): def __init__(self, mesaje='') -> None: super().__init__(mesaje) class Invalidcommand(Exception): def __init__(self, mesaje='') -> None: super().__init__(mesaje)
#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. class GenerateGraphvizError(Exception): """ Represents a GenerateGraphiz error. `GenerateGraphiz` will be raised when an error is tied to generate_graphviz function """ pass
class Generategraphvizerror(Exception): """ Represents a GenerateGraphiz error. `GenerateGraphiz` will be raised when an error is tied to generate_graphviz function """ pass
# https://binarysearch.com/problems/Count-Nodes-in-Complete-Binary-Tree class Solution: @staticmethod def getList(root, lst): if root == None: return else: lst.append(root.val) Solution.getList(root.left, lst) Solution.getList(root.right, lst) def solve(...
class Solution: @staticmethod def get_list(root, lst): if root == None: return else: lst.append(root.val) Solution.getList(root.left, lst) Solution.getList(root.right, lst) def solve(self, root): lst = [] Solution.getList(root...
"""Defines the common sense rule class.""" class CommonSenseRule: """ A rule brought in from a domain expert. Common sense rules can be used to bring in expert knowledge and avoid that common sense rules are generated. Goal is to facilitate more focus on rules not known before. """ def __init...
"""Defines the common sense rule class.""" class Commonsenserule: """ A rule brought in from a domain expert. Common sense rules can be used to bring in expert knowledge and avoid that common sense rules are generated. Goal is to facilitate more focus on rules not known before. """ def __init...
""" Copyright (c) 2020 Sam Hume 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, subli...
""" Copyright (c) 2020 Sam Hume 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, subli...
def close_catalogue_pop_up(wd): ''' Close catalogue pop up box if it appears. :param WebDriver wd: Selenium webdriver with page loaded. :return: void :rtype: void ''' pop_up_buttons = wd.find_elements_by_css_selector('.Button.variant-plain.size-normal.close-control') for button in pop...
def close_catalogue_pop_up(wd): """ Close catalogue pop up box if it appears. :param WebDriver wd: Selenium webdriver with page loaded. :return: void :rtype: void """ pop_up_buttons = wd.find_elements_by_css_selector('.Button.variant-plain.size-normal.close-control') for button in pop_u...
def flownet_v1_s(input): pass
def flownet_v1_s(input): pass
''' #E1 C=float(raw_input("<<")) F=float((9.0 / 5.0) * C + 32) print(F) ''' ''' #E2 radius,length = eval(raw_input(">>")) area = radius * radius * 3.14 volume = area * length print(area,volume) ''' ''' #E3 feet = eval(raw_input("<<")) meter = feet * 0.305 print(meter) ''' ''' #E4 M = eval(raw_input("Enter the amount of...
""" #E1 C=float(raw_input("<<")) F=float((9.0 / 5.0) * C + 32) print(F) """ '\n#E2\nradius,length = eval(raw_input(">>"))\narea = radius * radius * 3.14\nvolume = area * length\nprint(area,volume)\n' '\n#E3\nfeet = eval(raw_input("<<"))\nmeter = feet * 0.305\nprint(meter)\n' '\n#E4\nM = eval(raw_input("Enter the amount...
''' Author: Shuailin Chen Created Date: 2021-09-14 Last Modified: 2022-01-06 content: fine tuning ''' _base_ = [ './deeplabv3_r50-d8-selfsup_512x512_10k_sn6_sar_pro_rotated_ft.py' ] model = dict( pretrained='/home/csl/code/PolSAR_SelfSup/work_dirs/pbyol_r18_sn6_sar_pro_ul_ep400_lr03/20211009_142911/mmseg_epo...
""" Author: Shuailin Chen Created Date: 2021-09-14 Last Modified: 2022-01-06 content: fine tuning """ _base_ = ['./deeplabv3_r50-d8-selfsup_512x512_10k_sn6_sar_pro_rotated_ft.py'] model = dict(pretrained='/home/csl/code/PolSAR_SelfSup/work_dirs/pbyol_r18_sn6_sar_pro_ul_ep400_lr03/20211009_142911/mmseg_epoch_400.pth', ...
class Solution(object): def numTimesAllBlue(self, light): """ :type light: List[int] :rtype: int """ # N = max(light) # res = [-1]*N # i = 0 # maxp = -1 # count = 0 # for l in light: # if l>maxp: # maxp = l ...
class Solution(object): def num_times_all_blue(self, light): """ :type light: List[int] :rtype: int """ res = 0 bulb_sum = 0 idx_sum = 0 for i in range(len(light)): bulb_sum += light[i] idx_sum += i + 1 if idx_sum =...
class User: """ Class that generates new instances of credentials. """ user_list = [] #empty credential list def __init__(self, account_name, user_name, password, email): # instace variables are viriables that are unique to each new instance of the class self.account_name = ...
class User: """ Class that generates new instances of credentials. """ user_list = [] def __init__(self, account_name, user_name, password, email): self.account_name = account_name self.user_name = user_name self.password = password self.email = email def save_u...
""" Our trie implementation """ _SENTINEL = object() class Trie(dict): "A trie" def __init__(self): super(Trie, self).__init__() def insert(self, key, value): "Inserts a key-value pair into the trie" trie = self for char in key: if char not in trie: ...
""" Our trie implementation """ _sentinel = object() class Trie(dict): """A trie""" def __init__(self): super(Trie, self).__init__() def insert(self, key, value): """Inserts a key-value pair into the trie""" trie = self for char in key: if char not in trie: ...
class Stack: def __init__(self, values = []): self.__stack = values def push(self, value): self.__stack.append(value) def pop(self): return self.__stack.pop() def peek(self): return self.__stack[-1] def __len__(self): return len(self.__stack) if __name__...
class Stack: def __init__(self, values=[]): self.__stack = values def push(self, value): self.__stack.append(value) def pop(self): return self.__stack.pop() def peek(self): return self.__stack[-1] def __len__(self): return len(self.__stack) if __name__ ==...
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution_1: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: head = ListNode() p = head p1, p2 = l1, l2 mem = 0 while p1 and p...
class Listnode: def __init__(self, x): self.val = x self.next = None class Solution_1: def add_two_numbers(self, l1: ListNode, l2: ListNode) -> ListNode: head = list_node() p = head (p1, p2) = (l1, l2) mem = 0 while p1 and p2: sum_val = p1.v...
while True: line = input('> ') if line == 'done': break # Breaks out of loop if done # Otherwise, the loop continues and prints line. print(line) print('Done!')
while True: line = input('> ') if line == 'done': break print(line) print('Done!')
# GOAL: # Convert to human readable information def format_bytes(bytes): units = ['B', 'KB','MB','GB'] for unit in units: out = f'{round(bytes,2)} {unit}' bytes = bytes / 1024 if bytes < 1: break return out def format_time(sec): units = [ ['s', 60], ...
def format_bytes(bytes): units = ['B', 'KB', 'MB', 'GB'] for unit in units: out = f'{round(bytes, 2)} {unit}' bytes = bytes / 1024 if bytes < 1: break return out def format_time(sec): units = [['s', 60], ['m', 60], ['h', 24], ['d', 0]] out = '' qtime = int(se...
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : x = n y = 1 e = 0.000001 while ( x - y > e ) : x = ( x + y ) / 2 y = n / x ...
def f_gold(n): x = n y = 1 e = 1e-06 while x - y > e: x = (x + y) / 2 y = n / x return x if __name__ == '__main__': param = [(1763.655093333857,), (-3544.737136289062,), (7893.209433000695,), (-3008.0331952533734,), (6155.190186637041,), (-5799.751467314729,), (8234.151546380555,...
f = Function(ControlHandle, 'as_Control', (Handle, 'h', InMode)) functions.append(f) as_resource_body = """ return ResObj_New((Handle)_self->ob_itself); """ f = ManualGenerator("as_Resource", as_resource_body) f.docstring = lambda : "Return this Control as a Resource" methods.append(f) DisposeControl_body = """ i...
f = function(ControlHandle, 'as_Control', (Handle, 'h', InMode)) functions.append(f) as_resource_body = '\nreturn ResObj_New((Handle)_self->ob_itself);\n' f = manual_generator('as_Resource', as_resource_body) f.docstring = lambda : 'Return this Control as a Resource' methods.append(f) dispose_control_body = '\n\tif (!P...
# nlantau, 2021-11-04 make_string=lambda x:"".join([i[0] for i in x.split()]) print(make_string("sees eyes xray yoat"))
make_string = lambda x: ''.join([i[0] for i in x.split()]) print(make_string('sees eyes xray yoat'))
"""Rules for writing tests for the IntelliJ aspect.""" load( "//aspect:fast_build_info.bzl", "fast_build_info_aspect", ) def _impl(ctx): """Implementation method for _fast_build_aspect_test_fixture.""" deps = [dep for dep in ctx.attr.deps if "ide-fast-build" in dep[OutputGroupInfo]] inputs = deps...
"""Rules for writing tests for the IntelliJ aspect.""" load('//aspect:fast_build_info.bzl', 'fast_build_info_aspect') def _impl(ctx): """Implementation method for _fast_build_aspect_test_fixture.""" deps = [dep for dep in ctx.attr.deps if 'ide-fast-build' in dep[OutputGroupInfo]] inputs = depset(transitive...
del_items(0x80135544) SetType(0x80135544, "void PreGameOnlyTestRoutine__Fv()") del_items(0x80137608) SetType(0x80137608, "void DRLG_PlaceDoor__Fii(int x, int y)") del_items(0x80137ADC) SetType(0x80137ADC, "void DRLG_L1Shadows__Fv()") del_items(0x80137EF4) SetType(0x80137EF4, "int DRLG_PlaceMiniSet__FPCUciiiiiii(unsigne...
del_items(2148750660) set_type(2148750660, 'void PreGameOnlyTestRoutine__Fv()') del_items(2148759048) set_type(2148759048, 'void DRLG_PlaceDoor__Fii(int x, int y)') del_items(2148760284) set_type(2148760284, 'void DRLG_L1Shadows__Fv()') del_items(2148761332) set_type(2148761332, 'int DRLG_PlaceMiniSet__FPCUciiiiiii(uns...
"""Sensor states.""" OPEN = 0 """The sensor is open.""" CLOSED = 1 """The sensor is closed."""
"""Sensor states.""" open = 0 'The sensor is open.' closed = 1 'The sensor is closed.'
# Do not edit this file directly. # It was auto-generated by: code/programs/reflexivity/reflexive_refresh load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") def ubuntu1404Clang10Sysroot(): http_archive( name = "ubuntu_14_0...
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_file') def ubuntu1404_clang10_sysroot(): http_archive(name='ubuntu_14_04_clang_10_sysroot', build_file='//bazel/deps/ubuntu_14_04_clang_10_sysroot:build.BUILD', sha256='6204f7998b543e7190...
def arrplus(arr): return [arr[i] + i for i in range(len(arr))] if __name__ == '__main__': arr = [8, 4, 1, 7] print(arrplus(arr)) ''' [8, 5, 3, 10] '''
def arrplus(arr): return [arr[i] + i for i in range(len(arr))] if __name__ == '__main__': arr = [8, 4, 1, 7] print(arrplus(arr)) '\n\n[8, 5, 3, 10]\n\n'
class Node: def __init__(self, data): self.data = data self.left = None self.right = None def convert_to_infix(query): myStack = [] query = query[-1::-1] for term in query: if term.data == '_AND': term.left = myStack.pop() term.right = myStack.po...
class Node: def __init__(self, data): self.data = data self.left = None self.right = None def convert_to_infix(query): my_stack = [] query = query[-1::-1] for term in query: if term.data == '_AND': term.left = myStack.pop() term.right = myStack.p...
class ListNode: def __init__(self, x): self.val = x self.next = None def toList(ln): result = [] while ln: result.append(ln.val) ln = ln.next return result def toLinkedList(aList): ln = ListNode(None) curr = ln for val in aList: curr.next = ListNode(...
class Listnode: def __init__(self, x): self.val = x self.next = None def to_list(ln): result = [] while ln: result.append(ln.val) ln = ln.next return result def to_linked_list(aList): ln = list_node(None) curr = ln for val in aList: curr.next = list...
# Copyright 2019 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 = [ 'cloudbuildhelper', 'recipe_engine/json', 'recipe_engine/step', ] def RunSteps(api): api.cloudbuildhelper.report_version() # Coverage f...
deps = ['cloudbuildhelper', 'recipe_engine/json', 'recipe_engine/step'] def run_steps(api): api.cloudbuildhelper.report_version() build(api) upload(api) api.cloudbuildhelper.command = 'custom_cloudbuildhelper' assert api.cloudbuildhelper.update_pins('some/pins.yaml') def build(api): img = api....
loads('''(iemen2.Database User p1 (dp2 S'username' p3 S'root' p4 sS'name' p5 (S'Database' S'' S'Administrator' tp6 sS'creator' p7 I0 sS'privacy' p8 I0 sS'creationtime' p9 S'2008/03/07 10:11:18' p10 sS'disabled' p11 I0 sS'record' p12 NsS'groups' p13 (lp14 I-1 asS'password' p15 S'8843d7f92416211de9ebb963ff4ce28125932878'...
loads("(iemen2.Database\nUser\np1\n(dp2\nS'username'\np3\nS'root'\np4\nsS'name'\np5\n(S'Database'\nS''\nS'Administrator'\ntp6\nsS'creator'\np7\nI0\nsS'privacy'\np8\nI0\nsS'creationtime'\np9\nS'2008/03/07 10:11:18'\np10\nsS'disabled'\np11\nI0\nsS'record'\np12\nNsS'groups'\np13\n(lp14\nI-1\nasS'password'\np15\nS'8843d7f9...
def response_struct() -> str: return """ public struct Response<T: Codable>: Codable { let data: T } """.strip() + '\n'
def response_struct() -> str: return '\npublic struct Response<T: Codable>: Codable {\n let data: T\n}\n '.strip() + '\n'
class FilterBase: def __init__(self) -> None: pass def _check_input(self, array_input, array_output): if not len(array_input.shape) == 2: raise Exception('array_input does not have 2 dimensions') if not len(array_output.shape) == 2: raise Exception('arr...
class Filterbase: def __init__(self) -> None: pass def _check_input(self, array_input, array_output): if not len(array_input.shape) == 2: raise exception('array_input does not have 2 dimensions') if not len(array_output.shape) == 2: raise exception('array_output...
class TagFilterMixin(object): model = None def _get_tag_filter_value(self): return self.request.GET.get('tag', None) def _apply_tag_filter(self, qs): filter_value = self._get_tag_filter_value() if filter_value is not None: qs = qs.filter(tagged_items__tag__slug=filter_v...
class Tagfiltermixin(object): model = None def _get_tag_filter_value(self): return self.request.GET.get('tag', None) def _apply_tag_filter(self, qs): filter_value = self._get_tag_filter_value() if filter_value is not None: qs = qs.filter(tagged_items__tag__slug=filter_v...
#!/usr/bin/env python def dummy(num): pass print("#1 Else in for loop with break") for num in range(100): if num == 2: print("Break") break else: print("else") print() print("#2 Else in for loop without break") for num in range(100): dummy(num) else: print("else") print() print("...
def dummy(num): pass print('#1 Else in for loop with break') for num in range(100): if num == 2: print('Break') break else: print('else') print() print('#2 Else in for loop without break') for num in range(100): dummy(num) else: print('else') print() print('#3 Else in empty for loop ...
"""Template tags to assist in adding structured metadata to views and models.""" __version__ = '0.5.1' default_app_config = "structured_data.apps.StructuredDataConfig"
"""Template tags to assist in adding structured metadata to views and models.""" __version__ = '0.5.1' default_app_config = 'structured_data.apps.StructuredDataConfig'
# # PySNMP MIB module APPIAN-BUFFERS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/APPIAN-BUFFERS-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:23:39 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, ...
(ac_osap, ac_admin_status, ac_node_id) = mibBuilder.importSymbols('APPIAN-SMI-MIB', 'acOsap', 'AcAdminStatus', 'AcNodeId') (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValu...
"""Test Maps of Islands for Hashi Puzzle """ test1 = [ [ [1, 0], [0, 1] ], [ [0, 0, 1], [0, 0, 0], [1, 0, 2] ], [ [0, 1, 0, 2, 0], [0, 0, 0, 0, 0], [0, 1, 0, 2, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0] ], [ ...
"""Test Maps of Islands for Hashi Puzzle """ test1 = [[[1, 0], [0, 1]], [[0, 0, 1], [0, 0, 0], [1, 0, 2]], [[0, 1, 0, 2, 0], [0, 0, 0, 0, 0], [0, 1, 0, 2, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]], [[0, 3, 0, 2, 0, 0, 3], [1, 0, 1, 0, 0, 3, 0], [0, 3, 0, 2, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [4, 0, 2, 0, 0, 0, 2], [0, 0, 0, ...
VALUE = int(input()) recipes = [3, 7] elf_recipe_idx = [0, 1] while VALUE + 10 > len(recipes): new_recipe = sum(map(lambda x: recipes[x], elf_recipe_idx)) recipes.extend((divmod(new_recipe, 10) if new_recipe >= 10 else (new_recipe,))) elf_recipe_idx = [(x + 1 + recipes[x]) % len(recipes) for x i...
value = int(input()) recipes = [3, 7] elf_recipe_idx = [0, 1] while VALUE + 10 > len(recipes): new_recipe = sum(map(lambda x: recipes[x], elf_recipe_idx)) recipes.extend(divmod(new_recipe, 10) if new_recipe >= 10 else (new_recipe,)) elf_recipe_idx = [(x + 1 + recipes[x]) % len(recipes) for x in elf_recipe_i...
class PubSpec: def __init__(self, distribution, prefix="."): if '/' in distribution: pref, sep, dist = distribution.rpartition('/') if len(pref) == 0 or len(dist) == 0: raise ValueError("refspec invalid") self._prefix = pref self._distribution...
class Pubspec: def __init__(self, distribution, prefix='.'): if '/' in distribution: (pref, sep, dist) = distribution.rpartition('/') if len(pref) == 0 or len(dist) == 0: raise value_error('refspec invalid') self._prefix = pref self._distribut...
#!/usr/bin/python # QuickSort items = [8, 3, 1, 7, 0, 10, 2] pivot_index = len(items) -1 pivot_value = items[pivot_index] left_index = 0 while (pivot_index != left_index): item = items[left_index] # item = items[0] # pivot_value = 10 if item <= pivot_value: left_index = left_index + 1 ...
items = [8, 3, 1, 7, 0, 10, 2] pivot_index = len(items) - 1 pivot_value = items[pivot_index] left_index = 0 while pivot_index != left_index: item = items[left_index] if item <= pivot_value: left_index = left_index + 1 continue items[left_index] = items[pivot_index - 1] items[pivot_index ...
class Solution: def isLongPressedName(self, name: str, typed: str) -> bool: cur = tar = 0 pre = name[0] while cur < len(name): if tar >= len(typed): return False if name[cur] == typed[tar]: pre = name[cur] cur +...
class Solution: def is_long_pressed_name(self, name: str, typed: str) -> bool: cur = tar = 0 pre = name[0] while cur < len(name): if tar >= len(typed): return False if name[cur] == typed[tar]: pre = name[cur] cur += 1 ...
def countdown(): i = 5 while i > 0: yield i i -= 1 for i in countdown(): print(i) def numbers(x): for i in range(x): if i % 2 == 0: yield i num = int(input("Digite um numero: ")) print(list(numbers(num)))
def countdown(): i = 5 while i > 0: yield i i -= 1 for i in countdown(): print(i) def numbers(x): for i in range(x): if i % 2 == 0: yield i num = int(input('Digite um numero: ')) print(list(numbers(num)))
targets = [int(s) for s in input().split()] command = input() shot_targets = 0 while command != 'End': target = int(command) if target in range(len(targets)): for i in range(len(targets)): if targets[i] != -1 and i != target and targets[i] > targets[target]: targets[i] -= ta...
targets = [int(s) for s in input().split()] command = input() shot_targets = 0 while command != 'End': target = int(command) if target in range(len(targets)): for i in range(len(targets)): if targets[i] != -1 and i != target and (targets[i] > targets[target]): targets[i] -= t...
class Hamilton(object): pass
class Hamilton(object): pass
class Encapsulation: def set_public(self): print("I am visible to the entire project.") def _set_protected(self): # _ inainte de metoda indica faptul ca e protected print("I am visible by child") def __set_private(self): print("I am not visible outside the class") def get(sel...
class Encapsulation: def set_public(self): print('I am visible to the entire project.') def _set_protected(self): print('I am visible by child') def __set_private(self): print('I am not visible outside the class') def get(self): self.__set_private() class Child(Encap...
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def array_product_except_self(self, nums: [int]) -> [int]: output = [1]*len(nums) cumulative = 1 for i in range(1, len(nums)): cumulative = cumulative * ...
class Listnode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def array_product_except_self(self, nums: [int]) -> [int]: output = [1] * len(nums) cumulative = 1 for i in range(1, len(nums)): cumulative = cumulative * ...
# # PySNMP MIB module ALC-OPT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ALC-OPT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:01:11 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, 0...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, single_value_constraint, value_range_constraint, constraints_union, constraints_intersection) ...
#%% ss ='00 80 e1 13 4f 24 04 0e 3c 90 f5 58 08 00 45 00 00 23 a1 c2 00 00 80 11 15 83 c0 a8 01 17 c0 a8 01 1d 17 71 17 71 00 0f f5 6d 31 36 62 62 62 62 62 00 00 00 00 00 00 00 00 00 00 00 ' ss2='00 80 e1 13 4f 24 04 0e 3c 90 f5 58 08 00 45 00 00 23 a1 c6 00 00 80 11 15 7f c0 a8 01 17 c0 a8 01 1d 17 71 17 71 00 0f 17 ...
ss = '00 80 e1 13 4f 24 04 0e 3c 90 f5 58 08 00 45 00 00 23 a1 c2 00 00 80 11 15 83 c0 a8 01 17 c0 a8 01 1d 17 71 17 71 00 0f f5 6d 31 36 62 62 62 62 62 00 00 00 00 00 00 00 00 00 00 00 ' ss2 = '00 80 e1 13 4f 24 04 0e 3c 90 f5 58 08 00 45 00 00 23 a1 c6 00 00 80 11 15 7f c0 a8 01 17 c0 a8 01 1d 17 71 17 71 00 0f 17 33...
# # Solution to Project Euler problem 9 # Copyright (c) Project Nayuki. All rights reserved. # # https://www.nayuki.io/page/project-euler-solutions # https://github.com/nayuki/Project-Euler-solutions # # Computers are fast, so we can implement a brute-force search to directly solve the problem. def compute(): PER...
def compute(): perimeter = 1000 for a in range(1, PERIMETER + 1): for b in range(a + 1, PERIMETER + 1): c = PERIMETER - a - b if a * a + b * b == c * c: return str(a * b * c) if __name__ == '__main__': print(compute())
class Method: def __init__(self, head, goal, precond, subgoals): self.head = head self.goal = goal self.precond = precond self.subgoals = subgoals
class Method: def __init__(self, head, goal, precond, subgoals): self.head = head self.goal = goal self.precond = precond self.subgoals = subgoals
def decode_line(line): wires, display_numbers = line.split('|') digits = display_numbers.strip().split(' ') wires = wires.strip().split(' ') return wires, digits def count_unique_digits(display_lines): unique = 0 for line in display_lines: _, digits = decode_line(line) for d...
def decode_line(line): (wires, display_numbers) = line.split('|') digits = display_numbers.strip().split(' ') wires = wires.strip().split(' ') return (wires, digits) def count_unique_digits(display_lines): unique = 0 for line in display_lines: (_, digits) = decode_line(line) for...
class MovieRatings: def __init__(self, user_name): """user_name: a string representing the name of the person these movie ratings belong to""" self.name = user_name self.scores = {} def rate(self, movie_name, rating): """movie_name: a string representing...
class Movieratings: def __init__(self, user_name): """user_name: a string representing the name of the person these movie ratings belong to""" self.name = user_name self.scores = {} def rate(self, movie_name, rating): """movie_name: a string representing a movie ...
def inBinary(n): string = bin(n) string = string[2:] return int(string) def isPalindrome(n): string = "" temp = n while n > 0: string += str(n % 10) n = n // 10 return string == str(temp) sumPalindromes = 0 for i in range(1, 1000000): if isPalindrome(i) and isPalindrom...
def in_binary(n): string = bin(n) string = string[2:] return int(string) def is_palindrome(n): string = '' temp = n while n > 0: string += str(n % 10) n = n // 10 return string == str(temp) sum_palindromes = 0 for i in range(1, 1000000): if is_palindrome(i) and is_palind...
for g in range(int(input())): n = int(input()) lim = int(n / 2) + 1 s = 0 for i in range(1, lim): if n % i == 0: s += i if s == n: print(n, 'eh perfeito') else: print(n, 'nao eh perfeito')
for g in range(int(input())): n = int(input()) lim = int(n / 2) + 1 s = 0 for i in range(1, lim): if n % i == 0: s += i if s == n: print(n, 'eh perfeito') else: print(n, 'nao eh perfeito')
class RadixSort: def __init__(self,array): self.array = array def sort(self,exp): count = [0]*(10) sorted_array = [0]*(len(self.array)) for i in range(len(self.array)): index = int(self.array[i]/exp) count[index%10] += 1 for j in range(1,10): ...
class Radixsort: def __init__(self, array): self.array = array def sort(self, exp): count = [0] * 10 sorted_array = [0] * len(self.array) for i in range(len(self.array)): index = int(self.array[i] / exp) count[index % 10] += 1 for j in range(1, 1...
class Plotter: """ +---------+ | Plotter | +---------+---------------------+ | Toolbar | +------------------------+------+ | Title | | | | | | sub1 | | | | |...
class Plotter: """ +---------+ | Plotter | +---------+---------------------+ | Toolbar | +------------------------+------+ | Title | | | | | | sub1 | | | | |...
class InvalidExtensionEnvironment(Exception): pass class Module: ''' Modules differ from extensions in that they not only can read the state, but are allowed to modify the state. The will be loaded on boot, and are not allowed to be unloaded as they are required to continue functioning in a co...
class Invalidextensionenvironment(Exception): pass class Module: """ Modules differ from extensions in that they not only can read the state, but are allowed to modify the state. The will be loaded on boot, and are not allowed to be unloaded as they are required to continue functioning in a con...
def test_generate_report(testdir, cli_options, report_path, report_content): """Check the contents of a generated Markdown report.""" # run pytest with the following CLI options result = testdir.runpytest(*cli_options, "--md", f"{report_path}") # make sure that that we get a '1' exit code # as we h...
def test_generate_report(testdir, cli_options, report_path, report_content): """Check the contents of a generated Markdown report.""" result = testdir.runpytest(*cli_options, '--md', f'{report_path}') assert result.ret == 1 assert report_path.read_text() == report_content
class PropernounError(Exception): """ Unknown Propernoun error """ def __str__(self): doc = self.__doc__.strip() return ': '.join([doc] + [str(a) for a in self.args])
class Propernounerror(Exception): """ Unknown Propernoun error """ def __str__(self): doc = self.__doc__.strip() return ': '.join([doc] + [str(a) for a in self.args])
#!usr/bin/env python #-*- coding:utf-8 -*- """ @author: James Zhang @date: """
""" @author: James Zhang @date: """
print('a') print("hello" + "world") print("hello" + str(4)) print(int("5") + 4) print(float("3.2") + 7) print("the c is ", 5) price = 1000 count = 10 print("price ", price, " count is", count) name = input("Enter you name:") print("hello", name) tt = True if tt and False: print("Impossible")
print('a') print('hello' + 'world') print('hello' + str(4)) print(int('5') + 4) print(float('3.2') + 7) print('the c is ', 5) price = 1000 count = 10 print('price ', price, ' count is', count) name = input('Enter you name:') print('hello', name) tt = True if tt and False: print('Impossible')
def foo(): pass class Model(object): pass
def foo(): pass class Model(object): pass
""" * * Author: Juarez Paulino(coderemite) * Email: juarez.paulino@gmail.com * """ I=lambda:map(int,input().split()) n,k=I() a=*I(), r=min(range(k),key=lambda x:n%a[x]) print(r+1,n//a[r])
""" * * Author: Juarez Paulino(coderemite) * Email: juarez.paulino@gmail.com * """ i = lambda : map(int, input().split()) (n, k) = i() a = (*i(),) r = min(range(k), key=lambda x: n % a[x]) print(r + 1, n // a[r])
str = '''#define GLFW_KEY_UNKNOWN -1 #define GLFW_KEY_SPACE 32 #define GLFW_KEY_APOSTROPHE 39 /* ' */ #define GLFW_KEY_COMMA 44 /* , */ #define GLFW_KEY_MINUS 45 /* - */ #define GLFW_KEY_PERIOD 46 /* . */ #define GLFW_KEY_SLASH 47 /* / */ #define GLFW_KEY_0 48 #define GLFW_KEY_1 49 ...
str = "#define \tGLFW_KEY_UNKNOWN -1\n\n#define \tGLFW_KEY_SPACE 32\n\n#define \tGLFW_KEY_APOSTROPHE 39 /* ' */\n\n#define \tGLFW_KEY_COMMA 44 /* , */\n\n#define \tGLFW_KEY_MINUS 45 /* - */\n\n#define \tGLFW_KEY_PERIOD 46 /* . */\n\n#define \tGLFW_KEY_SLASH 47 /* / */\n\n#define \tGLFW_KEY_0 48\n\n#defi...
#coding=utf-8 def merge(intervals): intervals.sort(key=lambda x: x[0]) merged = [] for interval in intervals: if not merged or merged[-1][1] < interval[0]: merged.append(interval) else: merged[-1][1] = max(merged[-1][1], interval[1]) return merged if __name__ ==...
def merge(intervals): intervals.sort(key=lambda x: x[0]) merged = [] for interval in intervals: if not merged or merged[-1][1] < interval[0]: merged.append(interval) else: merged[-1][1] = max(merged[-1][1], interval[1]) return merged if __name__ == '__main__': ...
# We are deployed on Goerli and Mainnet chains = {1: "mainnet", 5: "goerli"} def get_chain_name(chain_id) -> str: """Return a readable network name for current network""" return chains[chain_id] def get_eth2_chain_name(chain_id) -> str: """Return a readable network name for current network for eth2-depo...
chains = {1: 'mainnet', 5: 'goerli'} def get_chain_name(chain_id) -> str: """Return a readable network name for current network""" return chains[chain_id] def get_eth2_chain_name(chain_id) -> str: """Return a readable network name for current network for eth2-deposit-cli library""" if chain_id == 5: ...
pkgname = "libiptcdata" pkgver = "1.0.4" pkgrel = 0 build_style = "gnu_configure" hostmakedepends = ["pkgconf"] pkgdesc = "Library for manipulating the IPTC metadata" maintainer = "q66 <q66@chimera-linux.org>" license = "LGPL-2.1-or-later" url = "http://libiptcdata.sourceforge.net" source = f"$(SOURCEFORGE_SITE)/{pkgna...
pkgname = 'libiptcdata' pkgver = '1.0.4' pkgrel = 0 build_style = 'gnu_configure' hostmakedepends = ['pkgconf'] pkgdesc = 'Library for manipulating the IPTC metadata' maintainer = 'q66 <q66@chimera-linux.org>' license = 'LGPL-2.1-or-later' url = 'http://libiptcdata.sourceforge.net' source = f'$(SOURCEFORGE_SITE)/{pkgna...
# Created by Jennifer Langford on 3/24/22 for CMIT235 - Week 1 Assignment # This is an ongoing effort weekly for the duration of this course. # The program will be complete at the end of the course. mySubList1 = [[1, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6], [2, 8, 4, 6, 7, 8, 9, 10, 11, 12, 12, 13]] mySubList2 = [[0, -1, 3, ...
my_sub_list1 = [[1, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6], [2, 8, 4, 6, 7, 8, 9, 10, 11, 12, 12, 13]] my_sub_list2 = [[0, -1, 3, 4, 4, 6, -2, 3, 1, 0, -20, -2], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 15]] my_sub_list3 = [[2, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1], [-1, -3, 44, 22, 4, 7, 7, 8, 9, 10, 11, 20]]
def productExceptSelf(nums: [int]) -> [int]: n = len(nums) result = [0] * n result[0] = 1 for i in range(1,n) : result[i] = result[i-1] * nums[i-1] tmp = 1 for i in range(n-2,-1,-1) : tmp *= nums[i+1] result[i] = result[i] * tmp return result if __name__ == "__main__...
def product_except_self(nums: [int]) -> [int]: n = len(nums) result = [0] * n result[0] = 1 for i in range(1, n): result[i] = result[i - 1] * nums[i - 1] tmp = 1 for i in range(n - 2, -1, -1): tmp *= nums[i + 1] result[i] = result[i] * tmp return result if __name__ ==...
class iRODSMeta(object): def __init__(self, name, value, units=None, avu_id=None): self.avu_id = avu_id self.name = name self.value = value self.units = units def __repr__(self): return "<iRODSMeta {avu_id} {name} {value} {units}>".format(**vars(self)) class iRODSMeta...
class Irodsmeta(object): def __init__(self, name, value, units=None, avu_id=None): self.avu_id = avu_id self.name = name self.value = value self.units = units def __repr__(self): return '<iRODSMeta {avu_id} {name} {value} {units}>'.format(**vars(self)) class Irodsmetac...
def simple_poll(): return { "conversation": "conversation-key", "start_state": {"uuid": "choice-1"}, "poll_metadata": { "repeatable": True, 'delivery_class': 'ussd' }, 'channel_types': [], "states": [ { # these are c...
def simple_poll(): return {'conversation': 'conversation-key', 'start_state': {'uuid': 'choice-1'}, 'poll_metadata': {'repeatable': True, 'delivery_class': 'ussd'}, 'channel_types': [], 'states': [{'uuid': 'choice-1', 'name': 'Message 1', 'store_as': 'message-1', 'type': 'choice', 'entry_endpoint': None, 'store_on_...
# coding: utf-8 # # Copyright 2022 :Barry-Thomas-Paul: Moss # # 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 applicab...
class Effectpresetclass(object): """ Const Class This constants defines the class for a preset animation effect. This is stored with the name preset-class inside the com.sun.star.animations.XAnimationNode.UserData sequence. This does not manipulate the timing or synchronization. It can be used...
def lambda_handler(event, context, params=dict()): return { "statusCode": 200, "body": 'Hello im second lambda!' }
def lambda_handler(event, context, params=dict()): return {'statusCode': 200, 'body': 'Hello im second lambda!'}
#!/usr/bin/env python3 """ Process five student marks to find the average. Display average along with the student's name. """ __author__ = "Tony Jenkins" __email__ = "tony.jenkins@elder-studios.co.uk" __date__ = "2018-09-30" __license__ = "Unlicense" name = input ('Enter the student\'s name: ') mark_...
""" Process five student marks to find the average. Display average along with the student's name. """ __author__ = 'Tony Jenkins' __email__ = 'tony.jenkins@elder-studios.co.uk' __date__ = '2018-09-30' __license__ = 'Unlicense' name = input("Enter the student's name: ") mark_1 = int(input('Enter first result: ...
def select_min_idx(arr, start, end): min_idx = start for i in range(start + 1, end): if arr[min_idx] > arr[i]: min_idx = i return min_idx def sort(arr): n = len(arr) for i in range(n): min_idx = select_min_idx(arr, i, n) arr[i], arr[min_idx] = arr[min_idx], arr[...
def select_min_idx(arr, start, end): min_idx = start for i in range(start + 1, end): if arr[min_idx] > arr[i]: min_idx = i return min_idx def sort(arr): n = len(arr) for i in range(n): min_idx = select_min_idx(arr, i, n) (arr[i], arr[min_idx]) = (arr[min_idx], ar...
class Solution: def isMatch(self, s: str, p: str) -> bool: T = [[False] * (len(p) + 1) for _ in range(len(s) + 1)] T[0][0] = True for j in range(len(p)): if p[j] == "*": T[0][j+1] = T[0][j] for i in range(len(s)): for j in range(len(p)): ...
class Solution: def is_match(self, s: str, p: str) -> bool: t = [[False] * (len(p) + 1) for _ in range(len(s) + 1)] T[0][0] = True for j in range(len(p)): if p[j] == '*': T[0][j + 1] = T[0][j] for i in range(len(s)): for j in range(len(p)): ...
# -*- coding: utf-8 -*- # Coded by Sungwook Kim # 2020-12-24 # IDE: Jupyter Notebook x, y, w, h = map(int, input().split()) if y / h > 0.5: t1 = h - y else: t1 = y if x / w > 0.5: t2 = w - x else: t2 = x if t1 > t2: print(t2) else: print(t1)
(x, y, w, h) = map(int, input().split()) if y / h > 0.5: t1 = h - y else: t1 = y if x / w > 0.5: t2 = w - x else: t2 = x if t1 > t2: print(t2) else: print(t1)
class DirTemplateException(Exception): pass class TemplateLineError(DirTemplateException): def __init__(self, filename, error_type, lineno, message, source): super(TemplateLineError, self).__init__(( "{error_type} in {filename} on line {lineno}:\n\n" "{message}\n\n{source}\n" ...
class Dirtemplateexception(Exception): pass class Templatelineerror(DirTemplateException): def __init__(self, filename, error_type, lineno, message, source): super(TemplateLineError, self).__init__('{error_type} in {filename} on line {lineno}:\n\n{message}\n\n{source}\n'.format(filename=filename, erro...
""" This module contains common application exit codes and exceptions that map to them. Author: Sascha Falk <sascha@falk-online.eu> License: MIT License """ EXIT_CODE_SUCCESS = 0 EXIT_CODE_GENERAL_ERROR = 1 EXIT_CODE_COMMAND_LINE_ARGUMENT_ERROR = 2 EXIT_CODE_FILE_NOT_FOUND ...
""" This module contains common application exit codes and exceptions that map to them. Author: Sascha Falk <sascha@falk-online.eu> License: MIT License """ exit_code_success = 0 exit_code_general_error = 1 exit_code_command_line_argument_error = 2 exit_code_file_not_found = 3 exit_code_io_error = 4 exit_code_configura...
''' Given an integer, return its base 7 string representation. Example 1: Input: 100 Output: "202" Example 2: Input: -7 Output: "-10" Note: The input will be in range of [-1e7, 1e7]. ''' class Solution(object): def convertToBase7(self, num): """ :type num: int :rtype: str """ ...
""" Given an integer, return its base 7 string representation. Example 1: Input: 100 Output: "202" Example 2: Input: -7 Output: "-10" Note: The input will be in range of [-1e7, 1e7]. """ class Solution(object): def convert_to_base7(self, num): """ :type num: int :rtype: str """ ...
"""Code related to tokens, as defined in the EAG document. See section 6, page 42, of the NIST document. """
"""Code related to tokens, as defined in the EAG document. See section 6, page 42, of the NIST document. """
""" 477 Leetcode. Total Hamming Distance https://leetcode.com/problems/total-hamming-distance/ """ """ This program converts all the integers in the array to their 32bit binary representation then count the number of zeros in each tuple. For each tuple we multiply the number of zeros with the difference of the l...
""" 477 Leetcode. Total Hamming Distance https://leetcode.com/problems/total-hamming-distance/ """ '\n\nThis program converts all the integers in the array to their 32bit binary representation then count the number of zeros in each tuple.\nFor each tuple we multiply the number of zeros with the difference of the leng...
class Queue: """Queue data structure. Args: elements(list): list of elements (optional) Examples: >>> q1 = Queue() >>> q2 = Queue([1, 2, 3, 4, 5]) >>> print(q1) [] >>> print(q2) [1, 2, 3, 4, 5] """ def __init__(self, elements=None): ...
class Queue: """Queue data structure. Args: elements(list): list of elements (optional) Examples: >>> q1 = Queue() >>> q2 = Queue([1, 2, 3, 4, 5]) >>> print(q1) [] >>> print(q2) [1, 2, 3, 4, 5] """ def __init__(self, elements=None): ...
# -*- coding: utf-8 -*- """ Created on Wed Oct 27 23:16:02 2021 @author: Joshua Fung """ def tsai_wu(s, sigma_lp, sigma_ln, sigma_tp, sigma_tn, tau_lt): s = s.A1 f11 = 1/(sigma_lp*sigma_ln) f22 = 1/(sigma_tp*sigma_tn) f1 = 1/sigma_lp - 1/sigma_ln f2 = 1/sigma_tp - 1/sigma_tn f66 = 1/tau_lt**2 ...
""" Created on Wed Oct 27 23:16:02 2021 @author: Joshua Fung """ def tsai_wu(s, sigma_lp, sigma_ln, sigma_tp, sigma_tn, tau_lt): s = s.A1 f11 = 1 / (sigma_lp * sigma_ln) f22 = 1 / (sigma_tp * sigma_tn) f1 = 1 / sigma_lp - 1 / sigma_ln f2 = 1 / sigma_tp - 1 / sigma_tn f66 = 1 / tau_lt ** 2 ...