content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
class LevelUpCooldownError(Exception): pass class MaxLevelError(Exception): pass
class Levelupcooldownerror(Exception): pass class Maxlevelerror(Exception): pass
# # Copyright 2013 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing...
result_ok = 0 result_error = 1 plugin_errors = 'plugin_errors' errors = 'errors' class Result(object): def __init__(self): self._result = {} self._result['result_code'] = RESULT_OK self._result['result'] = [] def add(self, obj_list): self._result['result'].extend(obj_list) ...
mys1 = {1,2,3,4} mys2 = {3,4,5,6} mys1.difference_update(mys2) print(mys1) # DU1 mys3 = {'a','b','c','d'} mys4 = {'d','w','f','g'} mys5 = {'v','w','x','z'} mys3.difference_update(mys4) print(mys3) # DU2 mys4.difference_update(mys5) print(mys4) # DU3
mys1 = {1, 2, 3, 4} mys2 = {3, 4, 5, 6} mys1.difference_update(mys2) print(mys1) mys3 = {'a', 'b', 'c', 'd'} mys4 = {'d', 'w', 'f', 'g'} mys5 = {'v', 'w', 'x', 'z'} mys3.difference_update(mys4) print(mys3) mys4.difference_update(mys5) print(mys4)
NUMERICAL_TYPE = "num" NUMERICAL_PREFIX = "n_" CATEGORY_TYPE = "cat" CATEGORY_PREFIX = "c_" TIME_TYPE = "time" TIME_PREFIX = "t_" MULTI_CAT_TYPE = "multi-cat" MULTI_CAT_PREFIX = "m_" MULTI_CAT_DELIMITER = "," MAIN_TABLE_NAME = "main" MAIN_TABLE_TEST_NAME = "main_test" TABLE_PREFIX = "table_" LABEL = "label" HAS...
numerical_type = 'num' numerical_prefix = 'n_' category_type = 'cat' category_prefix = 'c_' time_type = 'time' time_prefix = 't_' multi_cat_type = 'multi-cat' multi_cat_prefix = 'm_' multi_cat_delimiter = ',' main_table_name = 'main' main_table_test_name = 'main_test' table_prefix = 'table_' label = 'label' hash_max = ...
# Operations allowed : Insertion, Addition, Deletion def func(str1, str2, m, n): dp = [[0 for x in range(n+1)] for x in range(m+1)] for i in range(m+1): for j in range(n+1): if i == 0: dp[i][j] = j elif j == 0: dp[i][j] = i elif str1[i...
def func(str1, str2, m, n): dp = [[0 for x in range(n + 1)] for x in range(m + 1)] for i in range(m + 1): for j in range(n + 1): if i == 0: dp[i][j] = j elif j == 0: dp[i][j] = i elif str1[i - 1] == str2[j - 1]: dp[i][j]...
# Tai Sakuma <tai.sakuma@gmail.com> ##__________________________________________________________________|| def create_file_start_length_list(file_nevents_list, max_events_per_run = -1, max_events_total = -1, max_files_per_run = 1): file_nevents_list = _apply_max_events_total(file_nevents_list, max_events_total) ...
def create_file_start_length_list(file_nevents_list, max_events_per_run=-1, max_events_total=-1, max_files_per_run=1): file_nevents_list = _apply_max_events_total(file_nevents_list, max_events_total) return _file_start_length_list(file_nevents_list, max_events_per_run, max_files_per_run) def _apply_max_events_...
def buildFireTraps(start, end, step, x, y): for i in range(start, end+1, step): if x: hero.buildXY("fire-trap", x, i) else: hero.buildXY("fire-trap", i, y) buildFireTraps(40, 112, 24, False, 114) buildFireTraps(110, 38, -18, 140, False) buildFireTraps(132, 32, -20, False, 2...
def build_fire_traps(start, end, step, x, y): for i in range(start, end + 1, step): if x: hero.buildXY('fire-trap', x, i) else: hero.buildXY('fire-trap', i, y) build_fire_traps(40, 112, 24, False, 114) build_fire_traps(110, 38, -18, 140, False) build_fire_traps(132, 32, -20, ...
"""exercism protein translation module.""" def proteins(strand): """ Translate RNA sequences into proteins. :param strand string - The RNA to translate. :return list - The protein the RNA translated into. """ # Some unit tests seem to be funky because of the order ... # proteins = set() ...
"""exercism protein translation module.""" def proteins(strand): """ Translate RNA sequences into proteins. :param strand string - The RNA to translate. :return list - The protein the RNA translated into. """ proteins = [] stop_codons = ['UAA', 'UAG', 'UGA'] protein_map = {'AUG': 'Meth...
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' ***************************************** Author: zhlinh Email: zhlinhng@gmail.com Version: 0.0.1 Created Time: 2016-01-10 Last_modify: 2016-01-10 ****************************************** ''' ''' Implement atoi to convert a string to an i...
""" ***************************************** Author: zhlinh Email: zhlinhng@gmail.com Version: 0.0.1 Created Time: 2016-01-10 Last_modify: 2016-01-10 ****************************************** """ '\nImplement atoi to convert a string to an integer.\n\nHint: Carefully consider all possible...
# TLV format: # TAG | LENGTH | VALUE # Header contains nested TLV triplets TRACE_TAG_HEADER = 1 TRACE_TAG_EVENTS = 2 TRACE_TAG_FILES = 3 TRACE_TAG_METADATA = 4 HEADER_TAG_VERSION = 1 HEADER_TAG_FILES = 2 HEADER_TAG_METADATA = 3
trace_tag_header = 1 trace_tag_events = 2 trace_tag_files = 3 trace_tag_metadata = 4 header_tag_version = 1 header_tag_files = 2 header_tag_metadata = 3
""" capo_optimizer library, allows quick determination of optimal guitar capo positioning. """ version = (0, 0, 1) __version__ = '.'.join(map(str, version))
""" capo_optimizer library, allows quick determination of optimal guitar capo positioning. """ version = (0, 0, 1) __version__ = '.'.join(map(str, version))
menu = """ What would your weight would be in other celestian bodies Choose a celestial body 1-Sun 2-Mercury 3-Venus 4-Mars 5-Jupiter 6-Saturn 7-Uranus 8-Neptune 9-The Moon 10- Ganymede """ option = int(input(menu)) class celestial_body: def gravity_calculation(name,acceleration): mass = float(input...
menu = '\nWhat would your weight would be in other celestian bodies\nChoose a celestial body\n\n1-Sun\n2-Mercury\n3-Venus\n4-Mars\n5-Jupiter\n6-Saturn\n7-Uranus\n8-Neptune\n9-The Moon\n10- Ganymede\n' option = int(input(menu)) class Celestial_Body: def gravity_calculation(name, acceleration): mass = float...
''' Classes to work with WebSphere Application Servers Author: Christoph Stoettner Mail: christoph.stoettner@stoeps.de Documentation: http://scripting101.stoeps.de Version: 5.0.1 Date: 09/19/2015 License: Apache 2.0 ''' class WasServers: def __init__(self): # Get a...
""" Classes to work with WebSphere Application Servers Author: Christoph Stoettner Mail: christoph.stoettner@stoeps.de Documentation: http://scripting101.stoeps.de Version: 5.0.1 Date: 09/19/2015 License: Apache 2.0 """ class Wasservers: def __init__(self): self.Al...
class Solution: def findReplaceString(self, S: str, indexes: List[int], sources: List[str], targets: List[str]) -> str: ans = [""] * len(S) for i in range(len(S)): ans[i] = S[i] for i in range(len(indexes)): start = indexes[i] src = sources[i] ...
class Solution: def find_replace_string(self, S: str, indexes: List[int], sources: List[str], targets: List[str]) -> str: ans = [''] * len(S) for i in range(len(S)): ans[i] = S[i] for i in range(len(indexes)): start = indexes[i] src = sources[i] ...
############################################################################### # Singlecell plot arrays # ############################################################################### tag = "singlecell"
tag = 'singlecell'
class PipelineNotDeployed(Exception): def __init__(self, pipeline_id=None, message="Pipeline not deployed") -> None: self.pipeline_id = pipeline_id self.message = message super().__init__(self.message) def __str__(self): return f"{self.pipeline_id} -> {self.message}"
class Pipelinenotdeployed(Exception): def __init__(self, pipeline_id=None, message='Pipeline not deployed') -> None: self.pipeline_id = pipeline_id self.message = message super().__init__(self.message) def __str__(self): return f'{self.pipeline_id} -> {self.message}'
class TGConfigError(Exception):pass def coerce_config(configuration, prefix, converters): """Convert configuration values to expected types.""" options = dict((key[len(prefix):], configuration[key]) for key in configuration if key.startswith(prefix)) for option, converter in converte...
class Tgconfigerror(Exception): pass def coerce_config(configuration, prefix, converters): """Convert configuration values to expected types.""" options = dict(((key[len(prefix):], configuration[key]) for key in configuration if key.startswith(prefix))) for (option, converter) in converters.items(): ...
class Solution: def search(self, nums, target): if not nums: return -1 x, y = 0, len(nums) - 1 while x <= y: m = x + (y - x) // 2 if nums[m] > nums[0]: x = m + 1 elif nums[m] < nums[0]: y = m else: ...
class Solution: def search(self, nums, target): if not nums: return -1 (x, y) = (0, len(nums) - 1) while x <= y: m = x + (y - x) // 2 if nums[m] > nums[0]: x = m + 1 elif nums[m] < nums[0]: y = m els...
class Chapter: id: float title: str text: str
class Chapter: id: float title: str text: str
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def getKthFromEnd(self, head: ListNode, k: int) -> ListNode: p1 = head for _ in range(k): if p1: p1 = p1.next else: return None ...
class Solution: def get_kth_from_end(self, head: ListNode, k: int) -> ListNode: p1 = head for _ in range(k): if p1: p1 = p1.next else: return None p2 = head while p1: p1 = p1.next p2 = p2.next re...
with open('input.txt') as f: lines = f.readlines() ans = 0 for line in lines: input, output = line.split(" | ") for word in output.split(): length = len(word) if length == 2 or length == 4 or length == 3 or length == 7: ans += 1 print(ans)
with open('input.txt') as f: lines = f.readlines() ans = 0 for line in lines: (input, output) = line.split(' | ') for word in output.split(): length = len(word) if length == 2 or length == 4 or length == 3 or (length == 7): ans += 1 print(ans)
def fibonacci_iterative(num): a = 0 b = 1 total = 0 for _ in range(2, num + 1): total = a + b a = b b = total return total def fibonacci_recursive(num): if num < 2: return num return fibonacci_recursive(num-1) + fibonacci_recursive(num-2) print(fibonacci_i...
def fibonacci_iterative(num): a = 0 b = 1 total = 0 for _ in range(2, num + 1): total = a + b a = b b = total return total def fibonacci_recursive(num): if num < 2: return num return fibonacci_recursive(num - 1) + fibonacci_recursive(num - 2) print(fibonacci_...
data = { 'red' : 1, 'green' : 2, 'blue' : 3 } def makedict(**kwargs): return kwargs data = makedict(red=1, green=2, blue=3) print(data) def dodict(*args, **kwds): d = {} for k, v in args: d[k] = v d.update(kwds) return d tada = dodict(yellow=2, green=4, *data.items()) print(tada)
data = {'red': 1, 'green': 2, 'blue': 3} def makedict(**kwargs): return kwargs data = makedict(red=1, green=2, blue=3) print(data) def dodict(*args, **kwds): d = {} for (k, v) in args: d[k] = v d.update(kwds) return d tada = dodict(*data.items(), yellow=2, green=4) print(tada)
"""69. Sqrt(x)""" class Solution(object): def mySqrt(self, x): """ :type x: int :rtype: int """ #####Practice ############### l = 0 r = x while l <= r: mid = l + (r - l)//2 if mid*mid <= x < (mid+1)*(mid+1): ...
"""69. Sqrt(x)""" class Solution(object): def my_sqrt(self, x): """ :type x: int :rtype: int """ l = 0 r = x while l <= r: mid = l + (r - l) // 2 if mid * mid <= x < (mid + 1) * (mid + 1): return mid elif m...
# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. # Copyright (C) 2014 Tech Receptives (<http://techreceptives.com>) { 'name': 'Singapore - Accounting', 'author': 'Tech Receptives', 'website': 'http://www.techreceptives.com', 'category': 'Localization',...
{'name': 'Singapore - Accounting', 'author': 'Tech Receptives', 'website': 'http://www.techreceptives.com', 'category': 'Localization', 'description': '\nSingapore accounting chart and localization.\n=======================================================\n\nAfter installing this module, the Configuration wizard for ac...
# A Narcissistic Number is a number which is the sum of its own digits, each raised to the power of the number # of digits in a given base. In this Kata, we will restrict ourselves to decimal (base 10). # For example, take 153 (3 digits): # 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153 # and 1634 (4 digits): # 1^4 + 6...
def is_narcissistic(num): if 0: return False n = num exponente = len(str(num)) sum = 0 while n > 0: sum += pow(int(n % 10), exponente) n = int(n / 10) return sum == num print(is_narcissistic(12)) print(is_narcissistic(153)) print(is_narcissistic(1634))
#!/usr/bin/python # -*- coding: UTF-8 -*- class Hello(object): def hello(self, name='world'): print('Hello, %s.' % name)
class Hello(object): def hello(self, name='world'): print('Hello, %s.' % name)
class Solution: """ @param n: an integer @param k: an integer @return: how many problem can you accept """ def canAccept(self, n, k): n = int(n / k) start = 0 end = n while start + 1 < end: mid = start + int((end - start) / 2) fact = ((1 + ...
class Solution: """ @param n: an integer @param k: an integer @return: how many problem can you accept """ def can_accept(self, n, k): n = int(n / k) start = 0 end = n while start + 1 < end: mid = start + int((end - start) / 2) fact = (1 +...
# Note that we can only test things here all implementations must support valid_data = [ ("acceptInsecureCerts", [ False, None, ]), ("browserName", [ None, ]), ("browserVersion", [ None, ]), ("platformName", [ None, ]), ("pageLoadStrategy", [ N...
valid_data = [('acceptInsecureCerts', [False, None]), ('browserName', [None]), ('browserVersion', [None]), ('platformName', [None]), ('pageLoadStrategy', [None, 'none', 'eager', 'normal']), ('proxy', [None]), ('timeouts', [None, {}, {'script': 0, 'pageLoad': 2.0, 'implicit': 2 ** 53 - 1}, {'script': 50, 'pageLoad': 25}...
class CodesDict(object): def __init__(self, codes): self.__dict__.update(codes) _codes = { 'waiting': 1, 'analysis': 2, 'paid': 3, 'available': 4, 'dispute': 5, 'returned': 6, 'canceled': 7, } codes = CodesDict(_codes)
class Codesdict(object): def __init__(self, codes): self.__dict__.update(codes) _codes = {'waiting': 1, 'analysis': 2, 'paid': 3, 'available': 4, 'dispute': 5, 'returned': 6, 'canceled': 7} codes = codes_dict(_codes)
class Monitor: def __init__(self, controller, redis_address): self.controller = controller self.redis_address = redis_address def _schedule(self, gid, nid, domain, name, args={}, cron='@every 1m'): """ Schedule the given jumpscript (domain/name) to run on the specified node ac...
class Monitor: def __init__(self, controller, redis_address): self.controller = controller self.redis_address = redis_address def _schedule(self, gid, nid, domain, name, args={}, cron='@every 1m'): """ Schedule the given jumpscript (domain/name) to run on the specified node acc...
senseiraw = { "name": "SteelSeries Sensei RAW (Experimental)", "vendor_id": 0x1038, "product_id": 0x1369, "interface_number": 0, "commands": { "set_logo_light_effect": { "description": "Set the logo light effect", "cli": ["-e", "--logo-light-effect"], "...
senseiraw = {'name': 'SteelSeries Sensei RAW (Experimental)', 'vendor_id': 4152, 'product_id': 4969, 'interface_number': 0, 'commands': {'set_logo_light_effect': {'description': 'Set the logo light effect', 'cli': ['-e', '--logo-light-effect'], 'command': [7, 1], 'value_type': 'choice', 'choices': {'steady': 1, 'breath...
def ordering_fries(): print("Can I have some fried potatoes please?") def countries_papagias_preferes(): print("Albania-Bulgaria-Romania...!")
def ordering_fries(): print('Can I have some fried potatoes please?') def countries_papagias_preferes(): print('Albania-Bulgaria-Romania...!')
""" Description: find the area of triangle, given breadth and height """ # function definition of areatriangle def areatriangle(breadth,height): return (breadth*height)/2; # input breadth and height b = int(input("Enter the breadth of triangle: ")) h = int(input("Enter teh height of triangle: ")) print("The area o...
""" Description: find the area of triangle, given breadth and height """ def areatriangle(breadth, height): return breadth * height / 2 b = int(input('Enter the breadth of triangle: ')) h = int(input('Enter teh height of triangle: ')) print('The area of the triangle is: ' + str(areatriangle(b, h)))
''' Linked List has 2 parts : A node that stores the data and a pointer to the next Node. So it is handled in 2 classes: 1. Node class with operations: 1. init function to get the data and next node value 2. get_data function to get the data of the node 3. set_data function to set the data of the node ...
""" Linked List has 2 parts : A node that stores the data and a pointer to the next Node. So it is handled in 2 classes: 1. Node class with operations: 1. init function to get the data and next node value 2. get_data function to get the data of the node 3. set_data function to set the data of the node ...
""" create by hanxiao on """ __author__ = "hanxiao" PRE_PAGE = 15 BEANS_UPLOAD_ONE_BOOK = 0.5
""" create by hanxiao on """ __author__ = 'hanxiao' pre_page = 15 beans_upload_one_book = 0.5
# This file was generated by wxPython's wscript. VERSION_STRING = '4.0.7.post2' MAJOR_VERSION = 4 MINOR_VERSION = 0 RELEASE_NUMBER = 7 BUILD_TYPE = 'release' VERSION = (MAJOR_VERSION, MINOR_VERSION, RELEASE_NUMBER, '.post2')
version_string = '4.0.7.post2' major_version = 4 minor_version = 0 release_number = 7 build_type = 'release' version = (MAJOR_VERSION, MINOR_VERSION, RELEASE_NUMBER, '.post2')
## TASK 1 - here are the expected letter frequencies in the english language - convert them to a byte frequency table expected_letter_frequencies = {'a': 8.167, 'b': 1.492, 'c': 2.782, 'd': 4.253, 'e': 12.702, 'f': 2.228, 'g': 2.015, 'h': 6.094, 'i': 6.966, 'j': 0.153, 'k': 0.772, 'l': 4.025, 'm': 2.406, 'n': 6.749, '...
expected_letter_frequencies = {'a': 8.167, 'b': 1.492, 'c': 2.782, 'd': 4.253, 'e': 12.702, 'f': 2.228, 'g': 2.015, 'h': 6.094, 'i': 6.966, 'j': 0.153, 'k': 0.772, 'l': 4.025, 'm': 2.406, 'n': 6.749, 'o': 7.507, 'p': 1.929, 'q': 0.095, 'r': 5.987, 's': 6.327, 't': 9.056, 'u': 2.758, 'v': 0.978, 'w': 2.361, 'x': 0.15, '...
def bracket_check(brackets): '''function for checking a string of brackets''' o = [ '{', '[', '(' ] c = [ '}', ']', ')' ] l = [] check = 0 for i in brackets: if i in o: check += 1 if i in c: check -= 1 if check == 0: print('yep') else...
def bracket_check(brackets): """function for checking a string of brackets""" o = ['{', '[', '('] c = ['}', ']', ')'] l = [] check = 0 for i in brackets: if i in o: check += 1 if i in c: check -= 1 if check == 0: print('yep') else: ...
class Utils: @staticmethod def fastModuloPow(num: int, pow: int, modulo: int) -> int: result = 1 while pow: if pow % 2 == 0: num = (num ** 2) % modulo pow = pow // 2 else: result = (num * result) % modulo pow...
class Utils: @staticmethod def fast_modulo_pow(num: int, pow: int, modulo: int) -> int: result = 1 while pow: if pow % 2 == 0: num = num ** 2 % modulo pow = pow // 2 else: result = num * result % modulo pow ...
# https://leetcode.com/problems/satisfiability-of-equality-equations class UnionFind: def __init__(self): self.node2par = {chr(i + 97): chr(i + 97) for i in range(26)} def find_par(self, x): if self.node2par[x] == x: return x par = self.find_par(self.node2par[x]) r...
class Unionfind: def __init__(self): self.node2par = {chr(i + 97): chr(i + 97) for i in range(26)} def find_par(self, x): if self.node2par[x] == x: return x par = self.find_par(self.node2par[x]) return par def unite(self, x, y): (x, y) = (self.find_par(...
# # PySNMP MIB module A3COM-HUAWEI-DHCPSNOOP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/A3COM-HUAWEI-DHCPSNOOP-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:04:11 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version ...
(hwdot1q_vlan_index,) = mibBuilder.importSymbols('A3COM-HUAWEI-LswVLAN-MIB', 'hwdot1qVlanIndex') (h3c_common,) = mibBuilder.importSymbols('A3COM-HUAWEI-OID-MIB', 'h3cCommon') (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mib...
#Copyright (c) 2020 Jan Kiefer #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES...
class Chatusr: def __init__(self, utfmsg): self.wob_id = utfmsg.get_int_arg(1) self.message = utfmsg.get_string_arg(2) self.type = utfmsg.get_int_list_arg(0)[2] self.mode = 0 if utfmsg.get_arg_count() <= 3 else utfmsg.get_int_arg(3) self.overheard = False if utfmsg.get_arg_c...
ast = int(input("Ingrese numero de asteroides")) nom =input("Ingrese nombre de asteroides") print("Los",ast,"asteroides",nom,"caen del cielo")
ast = int(input('Ingrese numero de asteroides')) nom = input('Ingrese nombre de asteroides') print('Los', ast, 'asteroides', nom, 'caen del cielo')
#!/usr/bin/env python compsys={ 'Artisan':{ 'db':'file-store', 'objects':['Artisan','Product','Order','Customer'], }, 'Central Office user':{ 'db':'file-store', 'objects':['Artisan','Product','Order','Customer'], }, }
compsys = {'Artisan': {'db': 'file-store', 'objects': ['Artisan', 'Product', 'Order', 'Customer']}, 'Central Office user': {'db': 'file-store', 'objects': ['Artisan', 'Product', 'Order', 'Customer']}}
def main(): my_integ_loop.getIntegrator( trick.Runge_Kutta_2, 4) trick.stop(300.0) if __name__ == "__main__": main()
def main(): my_integ_loop.getIntegrator(trick.Runge_Kutta_2, 4) trick.stop(300.0) if __name__ == '__main__': main()
S_ASK_DOWNLOAD = 0 C_ANSWER_YES = 1 C_ANSWER_NO = 2 S_ASK_UPLOAD = 3 S_ASK_WAIT = 4 S_BEGIN = 5
s_ask_download = 0 c_answer_yes = 1 c_answer_no = 2 s_ask_upload = 3 s_ask_wait = 4 s_begin = 5
#!/usr/bin/env python3 n = 4 A = [[0.1, 0.5, 3, 0.25], [1.2, 0.2, 0.25, 0.2], [-1, 0.25, 0.3, 2], [2, 0.00001, 1, 0.4]] b = [0, 1, 2, 3] # Gauss elim for i in range(n): pivot = A[i][i] b[i] /= pivot for j in range(n): A[i][j] /= pivot for j in range(i + 1, n): times = A[j][i] ...
n = 4 a = [[0.1, 0.5, 3, 0.25], [1.2, 0.2, 0.25, 0.2], [-1, 0.25, 0.3, 2], [2, 1e-05, 1, 0.4]] b = [0, 1, 2, 3] for i in range(n): pivot = A[i][i] b[i] /= pivot for j in range(n): A[i][j] /= pivot for j in range(i + 1, n): times = A[j][i] b[j] -= times * b[i] for k in ran...
depends = ["unittest"] description = """ Plug and play integration with the Jenkins Coninuous Integration server. For more information, visit: http://www.jenkins-ci.org/ """
depends = ['unittest'] description = '\nPlug and play integration with the Jenkins Coninuous Integration server.\n\nFor more information, visit:\nhttp://www.jenkins-ci.org/\n'
def keyExtract(array, key): """Returns values of specific key from list of dicts. Args: array (list): List to be processed. key (str): Key to extract. Returns: list: List of extracted values. Example: >>> keyExtract([ {'a': 0, ...}, {'a': 1, ...}, {'a': 2, ...}...
def key_extract(array, key): """Returns values of specific key from list of dicts. Args: array (list): List to be processed. key (str): Key to extract. Returns: list: List of extracted values. Example: >>> keyExtract([ {'a': 0, ...}, {'a': 1, ...}, {'a': 2, ......
#Pat McDonald - 8/2/2018 #Exercise 3: Collatz conjecture #Week 3 of Programming and Scripting #Inspired by Reddit!: https://www.reddit.com/r/Python/comments/57r6bf/collatz_conjecture_program/?st=jdhil1j5&sh=ba8fd995 n = int(input("Type an integer: ")) print(n) while n != 1: if (n % 2 == 0): #(n / 2) outputs a floa...
n = int(input('Type an integer: ')) print(n) while n != 1: if n % 2 == 0: n = n // 2 print(n) else: n = 3 * n + 1 print(n)
n = int(input()) lista = [int(x) for x in input().split()] qtde = lista.count(0) indice = [] for i in range(0,qtde): indice.append(lista.index(0)) lista[indice[i]] = 2 for i in range(0,n): menor = 100000 for j in range(0,len(indice)): temp = abs(i - indice[j]) if(temp < menor): ...
n = int(input()) lista = [int(x) for x in input().split()] qtde = lista.count(0) indice = [] for i in range(0, qtde): indice.append(lista.index(0)) lista[indice[i]] = 2 for i in range(0, n): menor = 100000 for j in range(0, len(indice)): temp = abs(i - indice[j]) if temp < menor: ...
"""Codewars: Happy Numbers 6 kyu URL:https://www.codewars.com/kata/59d53c3039c23b404200007e/train/python Math geeks and computer nerds love to anthropomorphize numbers and assign emotions and personalities to them. Thus there is defined the concept of a "happy" number. A happy number is defined as an integer in wh...
"""Codewars: Happy Numbers 6 kyu URL:https://www.codewars.com/kata/59d53c3039c23b404200007e/train/python Math geeks and computer nerds love to anthropomorphize numbers and assign emotions and personalities to them. Thus there is defined the concept of a "happy" number. A happy number is defined as an integer in wh...
N = int(input()) S = str(input()) flag = False half = (N+1) // 2 if S[:half] == S[half:N]: flag = True if flag: print("Yes") else: print("No")
n = int(input()) s = str(input()) flag = False half = (N + 1) // 2 if S[:half] == S[half:N]: flag = True if flag: print('Yes') else: print('No')
#!/usr/bin/env python weight = input("your weight is? ") height = input("your height is? ") bmi = float(weight) / ( float(height) ** 2 ) print(f"your bmi: {bmi:.2f}") if bmi <= 18.5: print("you are so thin!") elif bmi <= 25 and bmi > 18.5: print("well, you are fit.") elif bmi <= 28 and bmi > 25: print("it l...
weight = input('your weight is? ') height = input('your height is? ') bmi = float(weight) / float(height) ** 2 print(f'your bmi: {bmi:.2f}') if bmi <= 18.5: print('you are so thin!') elif bmi <= 25 and bmi > 18.5: print('well, you are fit.') elif bmi <= 28 and bmi > 25: print('it looks you are a little heav...
#!/usr/bin/env conda-execute # conda execute # env: # - python ==3.5 # - conda-build # - pygithub >=1.29 # - pyyaml # - requests # - setuptools # - tqdm # channels: # - conda-forge # run_with: python # TODO take package or list of packages # TODO take github url or github urls # TODO If user doesn't have a fo...
def main(): return if __init__ == '__main__': main()
class SvResponseBase: def __init__(self, cl_request): self.cl_request = cl_request def payload(): """ OVERRIDE THIS TO IMPLEMENT """ raise
class Svresponsebase: def __init__(self, cl_request): self.cl_request = cl_request def payload(): """ OVERRIDE THIS TO IMPLEMENT """ raise
#! env\bin\python # Ryan Simmons # Coffee Machine Project class CoffeeMachine: # the values in supplies refers to 1-1 with this supply_str = ['water', 'milk', 'coffee beans', 'disposable cups', 'money'] def __init__(self, supplies): self.supplies = supplies def supply_checker(self, drink)...
class Coffeemachine: supply_str = ['water', 'milk', 'coffee beans', 'disposable cups', 'money'] def __init__(self, supplies): self.supplies = supplies def supply_checker(self, drink): for i in range(len(drink)): if drink[i] > self.supplies[i]: print(f'Sorry not ...
""" Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings. You need to help them find out their common interest with the least list index sum. If there is a choice tie between answers, output all of them with no order requirement. You ...
""" Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings. You need to help them find out their common interest with the least list index sum. If there is a choice tie between answers, output all of them with no order requirement. You ...
# Write a program to print the pattern def pattern(a): print("Output :") for i in range(1, a+1): c = 1 for k in range(a, i, -1): print(" ", end="") for j in range(1, 2*i): if j < i: print(c, end="") c += 1 els...
def pattern(a): print('Output :') for i in range(1, a + 1): c = 1 for k in range(a, i, -1): print(' ', end='') for j in range(1, 2 * i): if j < i: print(c, end='') c += 1 else: print(c, end='') ...
# O(n ^ 4) # class Solution: # def countQuadruplets(self, nums: List[int]) -> int: # n = len(nums) # ans = 0 # for a in range(n - 3): # for b in range(a + 1, n - 2): # for c in range(b + 1, n -1): # for d in range(c + 1, n): # ...
class Solution: def count_quadruplets(self, nums: List[int]) -> int: n = len(nums) cnt = defaultdict(int) ans = 0 for b in range(n - 3, 0, -1): for d in range(b + 2, n): cnt[nums[d] - nums[b + 1]] += 1 for a in range(b): ans +=...
# Constants # # Device Variables VAR_BILLINGPERIODDURATION = 'zigbee:BillingPeriodDuration' VAR_BILLINGPERIODSTART = 'zigbee:BillingPeriodStart' VAR_BLOCK1PRICE = 'zigbee:Block1Price' VAR_BLOCK1THRESHOLD = 'zigbee:Block1Threshold' VAR_BLOCK2PRICE = 'zigbee:Block2Price' VAR_BLOCK2THRESHOLD = 'zigbee:Block2Threshold' V...
var_billingperiodduration = 'zigbee:BillingPeriodDuration' var_billingperiodstart = 'zigbee:BillingPeriodStart' var_block1_price = 'zigbee:Block1Price' var_block1_threshold = 'zigbee:Block1Threshold' var_block2_price = 'zigbee:Block2Price' var_block2_threshold = 'zigbee:Block2Threshold' var_block3_price = 'zigbee:Block...
# Bit manipulation class Solution: def subsets(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ result = [] for i in range(1 << len(nums)): tmp = [] for j in range(len(nums)): if i >> j & 1: ...
class Solution: def subsets(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ result = [] for i in range(1 << len(nums)): tmp = [] for j in range(len(nums)): if i >> j & 1: tmp.append(nums[j...
"""Utility queries for create, drop tables and insert data.""" # DROP TABLES songplay_table_drop = "drop table if exists songplays" user_table_drop = "drop table if exists users" song_table_drop = "drop table if exists songs" artist_table_drop = "drop table if exists artists" time_table_drop = "drop table if exists t...
"""Utility queries for create, drop tables and insert data.""" songplay_table_drop = 'drop table if exists songplays' user_table_drop = 'drop table if exists users' song_table_drop = 'drop table if exists songs' artist_table_drop = 'drop table if exists artists' time_table_drop = 'drop table if exists time' songplay_ta...
def load_file_list(f_list): lines=[] for fp in f_list: with open(fp,'r',encoding='utf-8') as f: for line in f: strs=line.strip().split('\t') lines.append([float(strs[0]),len(lines),strs[1]]) return lines def build_id_dict(list): dic={} for l in l...
def load_file_list(f_list): lines = [] for fp in f_list: with open(fp, 'r', encoding='utf-8') as f: for line in f: strs = line.strip().split('\t') lines.append([float(strs[0]), len(lines), strs[1]]) return lines def build_id_dict(list): dic = {} f...
# ------------- # netrecon info # -------------- __name__ = 'netrecon' __version__ = 0.19 __author__ = 'Avery Rozar: avery.rozar@trolleyesecurity.com'
__name__ = 'netrecon' __version__ = 0.19 __author__ = 'Avery Rozar: avery.rozar@trolleyesecurity.com'
def read_puzzle(path): with open(path, 'r+') as file: return file.read().split('\n') class Submarine: horizontal = 0 depth = 0 aim = 0 def forward(self, x): self.horizontal = self.horizontal + x self.depth = self.depth + self.aim * x def down(self, y): self.ai...
def read_puzzle(path): with open(path, 'r+') as file: return file.read().split('\n') class Submarine: horizontal = 0 depth = 0 aim = 0 def forward(self, x): self.horizontal = self.horizontal + x self.depth = self.depth + self.aim * x def down(self, y): self.aim...
class FieldDimension: def __init__(self, dimension, indexes): self.dimension = dimension self.indexes = indexes @classmethod def to_index(cls, t): """ :param t: t look like "1" or "4-7" :return: tuple either size of 1 or 2 (1) or (4, 7) """ ...
class Fielddimension: def __init__(self, dimension, indexes): self.dimension = dimension self.indexes = indexes @classmethod def to_index(cls, t): """ :param t: t look like "1" or "4-7" :return: tuple either size of 1 or 2 (1) or (4, 7) """ a = t.spl...
for t in range(int(input())): N = int(input()) A = list(map(int, input().split())) counter = 0 flag = False result = True for i in A: if i == 1 and not flag: counter = 1 flag = True elif i == 1 and counter < 6 : result = False br...
for t in range(int(input())): n = int(input()) a = list(map(int, input().split())) counter = 0 flag = False result = True for i in A: if i == 1 and (not flag): counter = 1 flag = True elif i == 1 and counter < 6: result = False brea...
""" Topic modeling is a type of statistical modeling for discovering the abstract 'topics' that occur in a collection of documents, Latent Dirichlet Allocation is an example of topic model and is used to classify text in a document to a particular topic. It builds a topic per document model and words per topic model, m...
""" Topic modeling is a type of statistical modeling for discovering the abstract 'topics' that occur in a collection of documents, Latent Dirichlet Allocation is an example of topic model and is used to classify text in a document to a particular topic. It builds a topic per document model and words per topic model, m...
class Solution(object): def hammingWeight(self, n): """ :type n: int :rtype: int """ s = 0 while n > 0: if n % 2 == 1: s += 1 n = n // 2 return s def test_0(): assert Solution().hammingWeight(11) == 3 assert So...
class Solution(object): def hamming_weight(self, n): """ :type n: int :rtype: int """ s = 0 while n > 0: if n % 2 == 1: s += 1 n = n // 2 return s def test_0(): assert solution().hammingWeight(11) == 3 assert s...
""" NAME : DIBANSA, RAHMANI P. NAME : BELGA, EMJAY COURSE : BSCPE 2-2 ACADEMIC YEAR : 2019-2020 PROGRAM'S SUMMARY: THIS PROGRAM WOULD MIMIC A STACK OF NOTEBOOKS THAT WOULD BE CHECKED. THIS PROGRAM RECORDS THE NAME OF THE NOTEBOOK'S OWNER AND ADDS THE NOTEBOOK ON THE TOP OF THE STACK. AS ...
""" NAME : DIBANSA, RAHMANI P. NAME : BELGA, EMJAY COURSE : BSCPE 2-2 ACADEMIC YEAR : 2019-2020 PROGRAM'S SUMMARY: THIS PROGRAM WOULD MIMIC A STACK OF NOTEBOOKS THAT WOULD BE CHECKED. THIS PROGRAM RECORDS THE NAME OF THE NOTEBOOK'S OWNER AND ADDS THE NOTEBOOK ON THE TOP OF THE STACK. AS THE USE...
# https://leetcode.com/problems/longest-substring-of-all-vowels-in-order/ class Solution: def longestBeautifulSubstring(self, word: str) -> int: dp = [0] * len(word) dic = {'a': 0, 'e': 1, 'i': 2, 'o': 3, 'u': 4} dp[0] = 1 if word[0] == 'a' else 0 for i in range(1, len(word)): ...
class Solution: def longest_beautiful_substring(self, word: str) -> int: dp = [0] * len(word) dic = {'a': 0, 'e': 1, 'i': 2, 'o': 3, 'u': 4} dp[0] = 1 if word[0] == 'a' else 0 for i in range(1, len(word)): if 0 <= dic[word[i]] - dic[word[i - 1]] <= 1 and dp[i - 1] > 0: ...
# flake8: noqa def foo(): def inner(): x = __test_source() __test_sink(x) def inner_with_model(): return __test_source()
def foo(): def inner(): x = __test_source() __test_sink(x) def inner_with_model(): return __test_source()
"""A collection of command-related exceptions.""" __all__ = ('CommandError', 'ArgumentError', 'MissingArgumentError', 'UnusedArgumentsError', 'AuthorizationError', 'ComplexityError') class CommandError(Exception): """Raised on any command processing error.""" class ArgumentError(CommandError): "...
"""A collection of command-related exceptions.""" __all__ = ('CommandError', 'ArgumentError', 'MissingArgumentError', 'UnusedArgumentsError', 'AuthorizationError', 'ComplexityError') class Commanderror(Exception): """Raised on any command processing error.""" class Argumenterror(CommandError): """Raised when ...
with open("3.txt") as f: nums = [x for x in f.read().split("\n")] totals = [0] * len(nums[0]) for n in nums: for i, c in enumerate(n): totals[i] += 1 if c == "1" else -1 gamma = int("".join(map(lambda x: "1" if x > 0 else "0", totals)), 2) epsilon = int("".join(map(lambda x: "1" ...
with open('3.txt') as f: nums = [x for x in f.read().split('\n')] totals = [0] * len(nums[0]) for n in nums: for (i, c) in enumerate(n): totals[i] += 1 if c == '1' else -1 gamma = int(''.join(map(lambda x: '1' if x > 0 else '0', totals)), 2) epsilon = int(''.join(map(lambda x: '1...
""" This problem was asked by Lyft. Given a list of integers and a number K, return which contiguous elements of the list sum to K. For example, if the list is [1, 2, 3, 4, 5] and K is 9, then it should return [2, 3, 4], since 2 + 3 + 4 = 9. """ # solved through caterpillar method def get_contigous_sum(k, arr): ...
""" This problem was asked by Lyft. Given a list of integers and a number K, return which contiguous elements of the list sum to K. For example, if the list is [1, 2, 3, 4, 5] and K is 9, then it should return [2, 3, 4], since 2 + 3 + 4 = 9. """ def get_contigous_sum(k, arr): front = 0 total = 0 for back...
# define inception block layer def InceptBlock(filters, strides): """InceptNet convolutional striding block. filters: tuple: (f1,f2,f3) filters1: for conv1x1 filters2: for conv1x1,conv3x3 filters3L for conv1x1,conv5x5""" filters1, filters2, filters3 = filters conv1x1 = stax.serial(...
def incept_block(filters, strides): """InceptNet convolutional striding block. filters: tuple: (f1,f2,f3) filters1: for conv1x1 filters2: for conv1x1,conv3x3 filters3L for conv1x1,conv5x5""" (filters1, filters2, filters3) = filters conv1x1 = stax.serial(stax.Conv(filters1, (1, 1), strides, p...
class PackageInstaller(object): """ Installs packages """ def __init__(self, connector, packages)-> None: self.__packages_installed = 0 self.__packages = packages self.__bash_connector = connector for package in self.__packages: self.__run_package_installer...
class Packageinstaller(object): """ Installs packages """ def __init__(self, connector, packages) -> None: self.__packages_installed = 0 self.__packages = packages self.__bash_connector = connector for package in self.__packages: self.__run_package_installer(...
count = 0 count2 = 0 while True: questions = set() # 2nd part everyone = set() fst = True try: person = input() while person != "": for x in person: questions.add(x) if fst: for x in person: everyone.add(...
count = 0 count2 = 0 while True: questions = set() everyone = set() fst = True try: person = input() while person != '': for x in person: questions.add(x) if fst: for x in person: everyone.add(x) else...
class SerializerError(Exception): def __init__(self, message): self._message = message class ValidationError(SerializerError): pass class InvalidSerializer(SerializerError): pass
class Serializererror(Exception): def __init__(self, message): self._message = message class Validationerror(SerializerError): pass class Invalidserializer(SerializerError): pass
n = int(input()) a = [['' for j in range(n)] for i in range(n)] for i in range(n): f = 0 for j in range(i, n): a[i][j] = str(f) f += 1 f = i for j in range(i): a[i][j] = str(f) f -= 1 for row in a: print(' '.join(row)) # For the record, I feel dumb because it coul...
n = int(input()) a = [['' for j in range(n)] for i in range(n)] for i in range(n): f = 0 for j in range(i, n): a[i][j] = str(f) f += 1 f = i for j in range(i): a[i][j] = str(f) f -= 1 for row in a: print(' '.join(row))
#!/usr/bin/env python3 # https://abc102.contest.atcoder.jp/tasks/abc102_b n = int(input()) a = [int(x) for x in input().split()] a.sort() print(a[-1] - a[0])
n = int(input()) a = [int(x) for x in input().split()] a.sort() print(a[-1] - a[0])
# Spiegelmann (9071005) | In Monster Park Maps response = sm.sendAskYesNo("Do you want to leave?") if response: sm.warpInstanceOut(951000000)
response = sm.sendAskYesNo('Do you want to leave?') if response: sm.warpInstanceOut(951000000)
#!/usr/local/bin/python3 def main(): # Test suite tests = [ [None, None], # Should throw a TypeError [-1, None], # Should throw a ValueError [0, 0], [9, 9], [138, 3], [65536, 7] ] print('Testing add_digits') for item in tests: try: ...
def main(): tests = [[None, None], [-1, None], [0, 0], [9, 9], [138, 3], [65536, 7]] print('Testing add_digits') for item in tests: try: temp_result = add_digits(item[0]) if temp_result == item[1]: print('PASSED: add_digits({}) returned {}'.format(item[0], tem...
""" Rules for representing package from package managers. """ _PACKAGE_JSON_TEMPLATE = "\"package\": \"{package}\", \"version\": \"{version}\", \"sum\": \"{sum}\"" def _package_json_impl(ctx): ctx.actions.write( output = ctx.outputs.manifest, content = "{" + _PACKAGE_JSON_TEMPLATE.format( ...
""" Rules for representing package from package managers. """ _package_json_template = '"package": "{package}", "version": "{version}", "sum": "{sum}"' def _package_json_impl(ctx): ctx.actions.write(output=ctx.outputs.manifest, content='{' + _PACKAGE_JSON_TEMPLATE.format(package=ctx.attr.package, version=ctx.attr....
#Kunal Gautam #Codewars : @Kunalpod #Problem name: Most digits #Problem level: 7 kyu def find_longest(arr): return arr[[len(str(x)) for x in arr].index(max([len(str(x)) for x in arr]))]
def find_longest(arr): return arr[[len(str(x)) for x in arr].index(max([len(str(x)) for x in arr]))]
#!/usr/bin/env python3 def main(): # initialize round counter to 0 and answer to blank round = 0 answer = " " # set up loop while round < 3 and (answer.lower() != "brian" and answer.lower() != "shrubbery"): # increment round round += 1 answer = input("Finish the movie ti...
def main(): round = 0 answer = ' ' while round < 3 and (answer.lower() != 'brian' and answer.lower() != 'shrubbery'): round += 1 answer = input('Finish the movie title, "Monty Python\'s The Life of ______: ') if answer.lower() == 'brian': print('Correct') elif ans...
def sentence_maker(phrase): interrogatives = ("why","how","what") capitalized = phrase.capitalize() #startswith function checks whether the string starts with the given values if phrase.startswith(interrogatives): return f"{capitalized}?" else: return f"{capitalized}." conversation...
def sentence_maker(phrase): interrogatives = ('why', 'how', 'what') capitalized = phrase.capitalize() if phrase.startswith(interrogatives): return f'{capitalized}?' else: return f'{capitalized}.' conversation = [] while True: user_input = input('Say something: ') if userInput == ...
# https://www.algoexpert.io/questions/Search%20In%20Sorted%20Matrix # O(n + m) time | O(1) space # where 'n' is the length of row and 'm' is the length on column def search_in_sorted_matrix(matrix, target): row = 0 col = len(matrix[0]) - 1 while row < len(matrix) and col >= 0: if matrix[row][col]...
def search_in_sorted_matrix(matrix, target): row = 0 col = len(matrix[0]) - 1 while row < len(matrix) and col >= 0: if matrix[row][col] > target: col -= 1 elif matrix[row][col] < row: row += 1 else: return [row, col] return [-1, -1]
def get_variables(): return { 'SPECIAL_FUNC': {'hoge': 'fuga'} }
def get_variables(): return {'SPECIAL_FUNC': {'hoge': 'fuga'}}
n=int(input()) numSwaps=0 a=list(map(int, input().strip().split())) for i in range(n-1): for j in range(n-i-1): if (a[j]>a[j+1]): a[j],a[j+1]=a[j+1],a[j] numSwaps+=1 print(f"Array is Sorted in {numSwaps} swaps") print(f"First Element: {a[j]}") print(f"Last Element: {a[j...
n = int(input()) num_swaps = 0 a = list(map(int, input().strip().split())) for i in range(n - 1): for j in range(n - i - 1): if a[j] > a[j + 1]: (a[j], a[j + 1]) = (a[j + 1], a[j]) num_swaps += 1 print(f'Array is Sorted in {numSwaps} swaps') print(f'First Element: {a[j]}') print(f'La...
""" https://leetcode.com/problems/roman-to-integer/ """ def roman_to_integer(s): """ This implementation passed all tests on submission January 18, 2022. There's not too much any other way of implementing this, am I right? You really just have encode each of the rules that are stated. """ o ...
""" https://leetcode.com/problems/roman-to-integer/ """ def roman_to_integer(s): """ This implementation passed all tests on submission January 18, 2022. There's not too much any other way of implementing this, am I right? You really just have encode each of the rules that are stated. """ o =...
# Has the same id a = [1, 2, 3] c = a print(id(a), id(c)) # Has a different id b = 42 print(id(b)) b = '42' print(id(b))
a = [1, 2, 3] c = a print(id(a), id(c)) b = 42 print(id(b)) b = '42' print(id(b))
class Score: def __init__(self, name, loader): self.name = name self.metrics = ['F', 'M'] self.highers = [1, 0] self.scores = [0. if higher else 1. for higher in self.highers] self.best = self.scores self.best_epoch = [0] * len(self.scores) self.present = self...
class Score: def __init__(self, name, loader): self.name = name self.metrics = ['F', 'M'] self.highers = [1, 0] self.scores = [0.0 if higher else 1.0 for higher in self.highers] self.best = self.scores self.best_epoch = [0] * len(self.scores) self.present = s...
mysql = { 'user': 'scott', 'password': 'password', 'host': '127.0.0.1', 'database': 'employees', 'raise_on_warnings': True, }
mysql = {'user': 'scott', 'password': 'password', 'host': '127.0.0.1', 'database': 'employees', 'raise_on_warnings': True}
# Author: allannozomu # Runtime: 544 ms # Memory: 19.8 MB class Solution: def isMonotonic(self, A: List[int]) -> bool: if (A[0] < A[-1]): ordered = sorted(A) else: ordered = sorted(A, reverse = True) return ordered == A
class Solution: def is_monotonic(self, A: List[int]) -> bool: if A[0] < A[-1]: ordered = sorted(A) else: ordered = sorted(A, reverse=True) return ordered == A
def szyfr(slowa): wynik = [] for slowo in slowa: wynik.append(slimak(slowo)) return wynik def slimak(slowo): ukl = [[" " for _ in range(len(slowo))] for _ in range(len(slowo))] kon = [1,2,2,2] + [j for j in range(3, 20)] + [j for j in range(3, 20)] kon.sort() pivot = int(len(slowo) ...
def szyfr(slowa): wynik = [] for slowo in slowa: wynik.append(slimak(slowo)) return wynik def slimak(slowo): ukl = [[' ' for _ in range(len(slowo))] for _ in range(len(slowo))] kon = [1, 2, 2, 2] + [j for j in range(3, 20)] + [j for j in range(3, 20)] kon.sort() pivot = int(len(slow...
class Vessel: def __init__(self, name: str): """ Initializing class instance with vessel name :param name: """ self.name = name self.fuel = 0.0 # list of dicts with passenger attributes self.passengers = [] def __getattr__(self, item): ""...
class Vessel: def __init__(self, name: str): """ Initializing class instance with vessel name :param name: """ self.name = name self.fuel = 0.0 self.passengers = [] def __getattr__(self, item): """ Called when unknown attribute is about t...
class Error(Exception): pass class InvalidTypeError(Error): pass class InvalidArgumentError(Error): pass
class Error(Exception): pass class Invalidtypeerror(Error): pass class Invalidargumenterror(Error): pass