content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
bandera = ["N","B","B","N","A","B","B","N","B","N","N","A","N","N","B","A","A"] print(bandera) negro = [] blanco = [] azul = [] def ordenada(bandera): if len(bandera) > 0: color = bandera.pop(0) if color =="N": negro.append(color) ordenada(bandera) elif color == "B": ...
bandera = ['N', 'B', 'B', 'N', 'A', 'B', 'B', 'N', 'B', 'N', 'N', 'A', 'N', 'N', 'B', 'A', 'A'] print(bandera) negro = [] blanco = [] azul = [] def ordenada(bandera): if len(bandera) > 0: color = bandera.pop(0) if color == 'N': negro.append(color) ordenada(bandera) e...
class Solution: def missingNumber(self, nums: List[int]) -> int: result = len(nums) for i in range(len(nums)): result ^= i ^ nums[i] return result
class Solution: def missing_number(self, nums: List[int]) -> int: result = len(nums) for i in range(len(nums)): result ^= i ^ nums[i] return result
""" Default termsets for various languages """ LANGUAGES = dict() # Dutch termset dictionary nl = dict() nl_clinical = dict() nl_pseudo = [ "probleemloos", "zonder probleem", "zonder moeilijkheid", "geen verandering", "geen duidelijke verandering", "geen evidente verandering", "geen signi...
""" Default termsets for various languages """ languages = dict() nl = dict() nl_clinical = dict() nl_pseudo = ['probleemloos', 'zonder probleem', 'zonder moeilijkheid', 'geen verandering', 'geen duidelijke verandering', 'geen evidente verandering', 'geen significante verandering', 'geen significante stijging', 'geen s...
class Solution: def __init__(self): self.inorder_p = {} self.postorder_idx = None def buildTree(self, inorder: List[int], postorder: List[int]) -> TreeNode: self.postorder_idx = len(postorder) - 1 for i, v in enumerate(inorder): self.inorder_p[v] = i ...
class Solution: def __init__(self): self.inorder_p = {} self.postorder_idx = None def build_tree(self, inorder: List[int], postorder: List[int]) -> TreeNode: self.postorder_idx = len(postorder) - 1 for (i, v) in enumerate(inorder): self.inorder_p[v] = i retu...
class StopType: """ Message type that will cause an actor to exit when sent an instance of this class, even with a non-empty inbox. """ __INSTANCE = None def __new__(cls): if StopType.__INSTANCE is None: StopType.__INSTANCE = super().__new__(cls) return StopType.__...
class Stoptype: """ Message type that will cause an actor to exit when sent an instance of this class, even with a non-empty inbox. """ __instance = None def __new__(cls): if StopType.__INSTANCE is None: StopType.__INSTANCE = super().__new__(cls) return StopType.__IN...
def intAdd(x): return lambda y: x + y def intMul(x): return lambda y: x * y def numAdd(x): return lambda y: x + y def numMul(x): return lambda y: x * y
def int_add(x): return lambda y: x + y def int_mul(x): return lambda y: x * y def num_add(x): return lambda y: x + y def num_mul(x): return lambda y: x * y
"""Deprecated suppression style.""" __revision__ = None a = 1 # pylint: disable=invalid-name b = 1 # pylint: disable-msg=invalid-name # pylint: disable=invalid-name c = 1 # pylint: enable=invalid-name # pylint: disable-msg=invalid-name d = 1 # pylint: enable-msg=invalid-name # pylint: disable-msg=C0103 e = 1 # p...
"""Deprecated suppression style.""" __revision__ = None a = 1 b = 1 c = 1 d = 1 e = 1 f = 1
class Node: def __init__(self, data) -> None: self.data = data self.left = None self.right = None def levelOrderTraversal(root): if root is None: return queue = [] queue.append(root) while len(queue) > 0: print(queue[0].data) node = q...
class Node: def __init__(self, data) -> None: self.data = data self.left = None self.right = None def level_order_traversal(root): if root is None: return queue = [] queue.append(root) while len(queue) > 0: print(queue[0].data) node = queue.pop(0) ...
def toTwoComp(n): s = bin(n & int("1"*16, 2))[2:] return ("{0:0>%s}" % (16)).format(s) def fromTwoComp(n): temp = n[:1] num = "" if int(temp): for x in n[1:]: if x == "1": num = num + "0" else: num = num + "1" ...
def to_two_comp(n): s = bin(n & int('1' * 16, 2))[2:] return ('{0:0>%s}' % 16).format(s) def from_two_comp(n): temp = n[:1] num = '' if int(temp): for x in n[1:]: if x == '1': num = num + '0' else: num = num + '1' return -int(n...
_.subdomain_matching _.static_folder Meta csrf csrf_class csrf_secret csrf_time_limit confirm get_user _.user catch_all bad_gateway page_not_found
_.subdomain_matching _.static_folder Meta csrf csrf_class csrf_secret csrf_time_limit confirm get_user _.user catch_all bad_gateway page_not_found
l1 = ["Bhindi","Aloo","Chopsticks","Chowmein"] i = 1 # for item in l1: # if i%2 != 0: # print(f"Please buy {item}") # i+=1 for index,item in enumerate(l1): if index%2==0: # even 0 se start print(f"Please buy {item}")
l1 = ['Bhindi', 'Aloo', 'Chopsticks', 'Chowmein'] i = 1 for (index, item) in enumerate(l1): if index % 2 == 0: print(f'Please buy {item}')
{ "targets": [ { "target_name": "trusted", "dependencies": [ "deps/wrapper/wrapper.gyp:wrapper", ], "sources": [ "src/node/main.cpp", "src/node/helper.cpp", "src/node/stdafx.cpp", ...
{'targets': [{'target_name': 'trusted', 'dependencies': ['deps/wrapper/wrapper.gyp:wrapper'], 'sources': ['src/node/main.cpp', 'src/node/helper.cpp', 'src/node/stdafx.cpp', 'src/node/common/wopenssl.cpp', 'src/node/utils/wlog.cpp', 'src/node/utils/wrap.cpp', 'src/node/utils/wjwt.cpp', 'src/node/utils/wcsp.cpp', 'src/no...
""" Common constants for Pipeline. """ AD_FIELD_NAME = 'asof_date' ANNOUNCEMENT_FIELD_NAME = 'announcement_date' CASH_FIELD_NAME = 'cash' BUYBACK_ANNOUNCEMENT_FIELD_NAME = 'buyback_date' DAYS_SINCE_PREV = 'days_since_prev' DAYS_TO_NEXT = 'days_to_next' NEXT_ANNOUNCEMENT = 'next_announcement' PREVIOUS_ANNOUNCEMENT = 'pr...
""" Common constants for Pipeline. """ ad_field_name = 'asof_date' announcement_field_name = 'announcement_date' cash_field_name = 'cash' buyback_announcement_field_name = 'buyback_date' days_since_prev = 'days_since_prev' days_to_next = 'days_to_next' next_announcement = 'next_announcement' previous_announcement = 'pr...
''' urlycue's private modules ''' type(1 or 0 @ 0) # Python >= 3.5 is required
""" urlycue's private modules """ type(1 or 0 @ 0)
with open ("testcopy.txt", "r") as test_copy: chunk_size = 10 read_data = test_copy.read(chunk_size) while len(read_data) > 0: print(read_data) read_data = test_copy.read (chunk_size)
with open('testcopy.txt', 'r') as test_copy: chunk_size = 10 read_data = test_copy.read(chunk_size) while len(read_data) > 0: print(read_data) read_data = test_copy.read(chunk_size)
#!/usr/bin/env python # -*- coding: utf-8 -*- # Author: Dusan Klinec, ph4r05, 2018 def collect(*args, **kwargs): pass def mem_free(*args, **kwargs): return 1000 def mem_alloc(*args, **kwargs): return 100
def collect(*args, **kwargs): pass def mem_free(*args, **kwargs): return 1000 def mem_alloc(*args, **kwargs): return 100
def part01(input, slope_right, slope_down): total = 0 pos = 0 for i in range(0, len(input), slope_down): if input[i][pos] == "#": total += 1 pos = (pos + slope_right) % len(input[i]) return total def part02(input): return part01(input, 1, 1) * part01(input, 3, 1) * part0...
def part01(input, slope_right, slope_down): total = 0 pos = 0 for i in range(0, len(input), slope_down): if input[i][pos] == '#': total += 1 pos = (pos + slope_right) % len(input[i]) return total def part02(input): return part01(input, 1, 1) * part01(input, 3, 1) * part0...
def meme1(): return str( bytes( list( map( lambda i: i + 48, [ int("49"), int("3c", 16), int("60"), int(str(-16)), int("...
def meme1(): return str(bytes(list(map(lambda i: i + 48, [int('49'), int('3c', 16), int('60'), int(str(-16)), int('38', 16), int('41', 12), int('1l', 36), int('2020', 3), int('-100', 4), int('30', 21), int('1o', 26), int('3h', 18), int('2j', 25), int('29', 31), int(str(63), int('1011', 2))]))), ''.join(map(lambda c...
""" aoe2record-to-json utility functions. """ def is_record(path: str) -> bool: """ Is filename a record file? :param (str) path: User-supplied filename. :return: True if filename is valid record file; otherwise False. :rtype: bool """ return path.find("..") == -1 def record(path: str) ...
""" aoe2record-to-json utility functions. """ def is_record(path: str) -> bool: """ Is filename a record file? :param (str) path: User-supplied filename. :return: True if filename is valid record file; otherwise False. :rtype: bool """ return path.find('..') == -1 def record(path: str) ->...
# /app/models.py class Family: def __init__(self): pass def get_tree(self): """ Return tree of all family members """ pass def jsonify(self): pass class Person: def __init__(self): pass def get_profile(self): """ ...
class Family: def __init__(self): pass def get_tree(self): """ Return tree of all family members """ pass def jsonify(self): pass class Person: def __init__(self): pass def get_profile(self): """ Returns profile of...
# https://leetcode.com/problems/all-possible-full-binary-trees/description/ # # algorithms # Medium (64.1%) # Total Accepted: 3k # Total Submissions: 4.7k # beats 87.00% of python submissions # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # ...
class Solution(object): def all_possible_fbt(self, N): """ :type N: int :rtype: List[TreeNode] """ if N & 1 == 0: return [] if N == 1: return [tree_node(0)] res = [] for i in xrange(1, N / 2 + 1, 2): left_arr = self...
def is_valid(input_line: str) -> bool: min_max, pass_char, password = input_line.split(' ') min_count, max_count = [int(i) for i in min_max.split('-')] pass_char = pass_char.rstrip(':') min_valid = (password[min_count-1] == pass_char) max_valid = (password[max_count-1] == pass_char) ret_val =...
def is_valid(input_line: str) -> bool: (min_max, pass_char, password) = input_line.split(' ') (min_count, max_count) = [int(i) for i in min_max.split('-')] pass_char = pass_char.rstrip(':') min_valid = password[min_count - 1] == pass_char max_valid = password[max_count - 1] == pass_char ret_val ...
X = 'spam' Y = 'eggs' # will swap X, Y = Y, X print((X, Y))
x = 'spam' y = 'eggs' (x, y) = (Y, X) print((X, Y))
fout=open('oops.txt','wt') print('oops, i created a file',file=fout) fout.close() fin=open('oops.txt','rt') po=fin.read() fin.close() print(po)
fout = open('oops.txt', 'wt') print('oops, i created a file', file=fout) fout.close() fin = open('oops.txt', 'rt') po = fin.read() fin.close() print(po)
# Curbrock Summon 3 CURBROCK3 = 9400931 # MOD ID CURBROCKS_ESCAPE_ROUTE_VER3 = 600050050 # MAP ID sm.spawnMob(CURBROCK3, 320, -208, False) sm.createClock(1800) sm.addEvent(sm.invokeAfterDelay(1800000, "warp", CURBROCKS_ESCAPE_ROUTE_VER3, 0)) sm.waitForMobDeath(CURBROCK3) sm.warp(CURBROCKS_ESCAPE_ROUTE_VER3) sm.stopEv...
curbrock3 = 9400931 curbrocks_escape_route_ver3 = 600050050 sm.spawnMob(CURBROCK3, 320, -208, False) sm.createClock(1800) sm.addEvent(sm.invokeAfterDelay(1800000, 'warp', CURBROCKS_ESCAPE_ROUTE_VER3, 0)) sm.waitForMobDeath(CURBROCK3) sm.warp(CURBROCKS_ESCAPE_ROUTE_VER3) sm.stopEvents()
#! /usr/bin/python class Calculator(object): def add(self, operanda, operandb): return operanda + operandb
class Calculator(object): def add(self, operanda, operandb): return operanda + operandb
#!/usr/bin/python3 def print_matrix_integer(matrix=[[]]): for X in matrix: for Y in X: print('{:d}'.format(Y), end="") if Y != X[-1]: print(' ', end="") print()
def print_matrix_integer(matrix=[[]]): for x in matrix: for y in X: print('{:d}'.format(Y), end='') if Y != X[-1]: print(' ', end='') print()
class Position: """ Coordanates system that uses an 'y' and 'x' notation to represent unequivocally a specific location that goes universally for every object. """ __slots__ = ('y', 'x') @staticmethod def create_collection(first_position: tuple, last_position: tuple): "...
class Position: """ Coordanates system that uses an 'y' and 'x' notation to represent unequivocally a specific location that goes universally for every object. """ __slots__ = ('y', 'x') @staticmethod def create_collection(first_position: tuple, last_position: tuple): """ ...
#!/usr/bin/env python3 bday_dict = {} while True: name = input("\nEnter name: ") if len(name) != 0 and type(name) == str: # Check the existence of the name in bday_dict if bday_dict.get(name): print("\n{} found in db".format(name)) print("Name: {}".format(name)) ...
bday_dict = {} while True: name = input('\nEnter name: ') if len(name) != 0 and type(name) == str: if bday_dict.get(name): print('\n{} found in db'.format(name)) print('Name: {}'.format(name)) print('Date : {}\n'.format(bday_dict[name])) else: pri...
N=int(input()) A=list(map(int,input().split())) diff=0 ans=N for i in range(N-1): if A[i]<A[i+1]: diff+=1 ans+=diff else: diff=0 print(ans)
n = int(input()) a = list(map(int, input().split())) diff = 0 ans = N for i in range(N - 1): if A[i] < A[i + 1]: diff += 1 ans += diff else: diff = 0 print(ans)
inFile = open('input.txt') primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] for line in inFile: n = int(line) if n == 0: break lenPrime = len(primes) counter = [0] * lenPrime for i in range(1, n + 1): number = i ...
in_file = open('input.txt') primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] for line in inFile: n = int(line) if n == 0: break len_prime = len(primes) counter = [0] * lenPrime for i in range(1, n + 1): number = i for (...
structure = { 'Public_encryption': 'public Alice key for encoding', 'Public_signing': 'public Alice key for signing', 'Message': {'message_id_hash': #message_id_5383710b780583f1f462b6e719071523147cde25a5a47c380126c3395f84b9b3 {'Address': address, #e6jB08WPeBjoPS4Lb4CFRVW/TAWSrGq7MD5OG8NVA794z4GwhlXz7vov1i2w6GLWY...
structure = {'Public_encryption': 'public Alice key for encoding', 'Public_signing': 'public Alice key for signing', 'Message': {'message_id_hash': {'Address': address, 'Files': ['Qm...', 'Qm...', 'Qm...']}}, 'Points': []}
# We are dealing with the "Young's Double Slit Experiment" simulation here: # https://github.com/NSLS-II/sirepo-bluesky/blob/master/sirepo_bluesky/tests/SIREPO_SRDB_ROOT/user/SdP3aU5G/srw/00000000/sirepo-data.json RE( optimization_plan( fly_plan=run_fly_sim, bounds=param_bounds, db=db, ...
re(optimization_plan(fly_plan=run_fly_sim, bounds=param_bounds, db=db, run_parallel=True, num_interm_vals=1, num_scans_at_once=4, sim_id='00000000', server_name='http://localhost:8000', root_dir=root_dir, watch_name='W60', flyer_name='sirepo_flyer', intensity_name='mean', opt_type='sirepo', max_iter=5))
""" This module includes wrapper classes for Tool connection parameters """ #pylint: disable=too-few-public-methods class ToolConnection(object): """ Base class for ToolConnection classes used to wrap configuration parameters for tool connections """ #pylint: disable=too-few-public-methods class ToolUsbHi...
""" This module includes wrapper classes for Tool connection parameters """ class Toolconnection(object): """ Base class for ToolConnection classes used to wrap configuration parameters for tool connections """ class Toolusbhidconnection(ToolConnection): """ Helper class wrapping configuration par...
'''class Pessoa(object): def __init__(self, nome, idade, peso): self.nome = nome self.idade = idade self.peso = peso def andar(self): print('anda') pessoa1 = Pessoa("Juliana", 23, 75) pessoa2 = Pessoa("Carlos", 39, 72) print(pessoa1.nome) pessoa1.andar() def fatorial(n): i...
"""class Pessoa(object): def __init__(self, nome, idade, peso): self.nome = nome self.idade = idade self.peso = peso def andar(self): print('anda') pessoa1 = Pessoa("Juliana", 23, 75) pessoa2 = Pessoa("Carlos", 39, 72) print(pessoa1.nome) pessoa1.andar() def fatorial(n): i...
""" Implements a set of ORMs for getting, setting against a database """ class RawJobDescriptionClient(object): raise NotImplementedError
""" Implements a set of ORMs for getting, setting against a database """ class Rawjobdescriptionclient(object): raise NotImplementedError
{ "targets": [ { "target_name": "addon", "sources": ["./src/cpp/nodeBridge.cpp", "./src/cpp/os/windows.cpp"], "include_dirs": [ "<!@(node -p \"require('node-addon-api').include\")" ], 'defines': [ 'NAPI_CPP_EXCEPTIONS' ] } ...
{'targets': [{'target_name': 'addon', 'sources': ['./src/cpp/nodeBridge.cpp', './src/cpp/os/windows.cpp'], 'include_dirs': ['<!@(node -p "require(\'node-addon-api\').include")'], 'defines': ['NAPI_CPP_EXCEPTIONS']}]}
expected_output = {'interface': {'Eth5/48.106': {'interface_status': 'protocol-down/link-down/admin-up', 'ip_address': '10.81.6.1'}, 'Lo3': {'interface_status': ...
expected_output = {'interface': {'Eth5/48.106': {'interface_status': 'protocol-down/link-down/admin-up', 'ip_address': '10.81.6.1'}, 'Lo3': {'interface_status': 'protocol-up/link-up/admin-up', 'ip_address': '192.168.205.1'}, 'Po1.102': {'interface_status': 'protocol-up/link-up/admin-up', 'ip_address': '192.168.70.2'}, ...
#!/usr/bin/env python3 grid = {} def sum_neighboors(x, y): sum = 0 for i in range(-1, 2): for k in range(-1, 2): sum = sum + grid.get((x + i, y + k), 0) return sum def print_grid(grid): print("---") for i in range(-10, 10): for k in range(-10, 10): print(...
grid = {} def sum_neighboors(x, y): sum = 0 for i in range(-1, 2): for k in range(-1, 2): sum = sum + grid.get((x + i, y + k), 0) return sum def print_grid(grid): print('---') for i in range(-10, 10): for k in range(-10, 10): print(grid.get((i, k), 0), end='...
#!/usr/bin/env python3 ipchk = "192.168.0.1" # a string tests as True if ipchk: print("Looks like the IP address was set: " + ipchk)
ipchk = '192.168.0.1' if ipchk: print('Looks like the IP address was set: ' + ipchk)
class BloxplorerException(Exception): def __init__(self, message, resource_url, request_method): self.message = message self.resource_url = resource_url self.request_method = request_method def __str__(self): return f'{self.message} (URL: {self.resource_url}, Method: {self.requ...
class Bloxplorerexception(Exception): def __init__(self, message, resource_url, request_method): self.message = message self.resource_url = resource_url self.request_method = request_method def __str__(self): return f'{self.message} (URL: {self.resource_url}, Method: {self.requ...
__author__ = 'Managed by Q, Inc.', __author_email__ = 'open-source@managedbyq.com' __description__ = 'MBQ Atomiq' __license__ = 'Apache 2.0' __title__ = 'mbq.atomiq' __url__ = 'https://github.com/managedbyq/mbq.atomiq' __version__ = '1.1.0'
__author__ = ('Managed by Q, Inc.',) __author_email__ = 'open-source@managedbyq.com' __description__ = 'MBQ Atomiq' __license__ = 'Apache 2.0' __title__ = 'mbq.atomiq' __url__ = 'https://github.com/managedbyq/mbq.atomiq' __version__ = '1.1.0'
# -*- coding: utf-8 -*- __author__ = "Thomas Bianchi" __copyright__ = "Thomas Bianchi" __license__ = "mit"
__author__ = 'Thomas Bianchi' __copyright__ = 'Thomas Bianchi' __license__ = 'mit'
num1=int(input("enter a num")) num2=int(input("enter a num")) if num1<0 and num2<0: print("enter a positive number") else: sum=0 while(num1>0 and num2>0): sum = num1+num2 print("the sum is",sum) break
num1 = int(input('enter a num')) num2 = int(input('enter a num')) if num1 < 0 and num2 < 0: print('enter a positive number') else: sum = 0 while num1 > 0 and num2 > 0: sum = num1 + num2 print('the sum is', sum) break
def counting_sort(A, B, k): C = [0 for i in range(0, k+1)] for j in A: C[j] += 1 for i in range(1, k+1): C[i] += C[i-1] for n in reversed(A): B[C[n]-1] = n C[n] = C[n] - 1 return B if __name__ == "__main__": myList = [4,0,3,6,1,5,7,0,4] otherList = [0 for i in range(0, len(myList))] pri...
def counting_sort(A, B, k): c = [0 for i in range(0, k + 1)] for j in A: C[j] += 1 for i in range(1, k + 1): C[i] += C[i - 1] for n in reversed(A): B[C[n] - 1] = n C[n] = C[n] - 1 return B if __name__ == '__main__': my_list = [4, 0, 3, 6, 1, 5, 7, 0, 4] other_...
class APP: APPLICATION = "denon-commander" AUTHOR = "Aleksander Psuj" VERSION = "V1.0" class CONNECTION: # I recommend to set static IP address on device IP = "192.168.1.150" class DEFAULT: # Default volume from -80 to 18 VOLUME = "-40" # Default input INPUT = "GAME" ...
class App: application = 'denon-commander' author = 'Aleksander Psuj' version = 'V1.0' class Connection: ip = '192.168.1.150' class Default: volume = '-40' input = 'GAME' sound_mode = 'MCH STEREO'
def longestSubsequence(A, N): L = [1]*N hm = {} for i in range(1,N): if abs(A[i]-A[i-1]) == 1: L[i] = 1 + L[i-1] elif hm.get(A[i]+1,0) or hm.get(A[i]-1,0): L[i] = 1+max(hm.get(A[i]+1,0), hm.get(A[i]-1,0)) hm[A[i]] = L[i] return max(L) A = [1, 2, 3, 4, 5, 3, 2] N = len(A) print(longestSubsequence(A, N))
def longest_subsequence(A, N): l = [1] * N hm = {} for i in range(1, N): if abs(A[i] - A[i - 1]) == 1: L[i] = 1 + L[i - 1] elif hm.get(A[i] + 1, 0) or hm.get(A[i] - 1, 0): L[i] = 1 + max(hm.get(A[i] + 1, 0), hm.get(A[i] - 1, 0)) hm[A[i]] = L[i] return max(...
#reversing a string using loop s = ('Python is the best programming language') reversed_string = '' for i in range(len(s)-1, -1, -1): reversed_string += s[i] print("reversed string: ", reversed_string) exit() #The range() function has two sets of parameters, as follows: #range(stop) #stop: Number of integer...
s = 'Python is the best programming language' reversed_string = '' for i in range(len(s) - 1, -1, -1): reversed_string += s[i] print('reversed string: ', reversed_string) exit()
# math3d_side.py class Side: NEITHER = 'NEITHER' BACK = 'BACK' FRONT = 'FRONT'
class Side: neither = 'NEITHER' back = 'BACK' front = 'FRONT'
"""Defines the StartResponseMock class. Copyright 2013 by Rackspace Hosting, 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 ...
"""Defines the StartResponseMock class. Copyright 2013 by Rackspace Hosting, 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 ...
first_space = int(input()) end_space = int(input()) magic_num = int(input()) combinations = 0 is_found = False for a in range(first_space, end_space + 1): for b in range(first_space, end_space + 1): combinations +=1 if a + b == magic_num: print(f'Combination N:{combinations} ({a} + {b} =...
first_space = int(input()) end_space = int(input()) magic_num = int(input()) combinations = 0 is_found = False for a in range(first_space, end_space + 1): for b in range(first_space, end_space + 1): combinations += 1 if a + b == magic_num: print(f'Combination N:{combinations} ({a} + {b} ...
#!/bin/python PrimerTypes = ["ForwardPrimer", "ReversePrimer"] FastaRegionPrefix = "REGION_" ClustalCommand = "clustalo"
primer_types = ['ForwardPrimer', 'ReversePrimer'] fasta_region_prefix = 'REGION_' clustal_command = 'clustalo'
# Read two integer numbers and, after that, exchange their values. Print the variable values before and after the exchange, as shown below: a = int(input()) b = int(input()) print(f'Before:\na = {a}\nb = {b}') a, b = b, a print(f'After:\na = {a}\nb = {b}')
a = int(input()) b = int(input()) print(f'Before:\na = {a}\nb = {b}') (a, b) = (b, a) print(f'After:\na = {a}\nb = {b}')
IDENTITY = lambda a: a IF = IDENTITY # boolean values TRUE = lambda a: lambda b: a FALSE = lambda a: lambda b: b # base boolean operations OR = lambda a: lambda b: a(TRUE)(b) AND = lambda a: lambda b: a(b)(FALSE) NOT = lambda a: a(FALSE)(TRUE) # additional boolean operations XOR = lambda a: lambda b: a(b(FALSE)(T...
identity = lambda a: a if = IDENTITY true = lambda a: lambda b: a false = lambda a: lambda b: b or = lambda a: lambda b: a(TRUE)(b) and = lambda a: lambda b: a(b)(FALSE) not = lambda a: a(FALSE)(TRUE) xor = lambda a: lambda b: a(b(FALSE)(TRUE))(b(TRUE)(FALSE)) xnor = lambda a: lambda b: not(xor(a)(b))
def merge(d, *dicts): """ Recursively merges dictionaries """ for d_update in dicts: if not isinstance(d, dict): raise TypeError("{0} is not a dict".format(d)) dict_merge_pair(d, d_update) return d def dict_merge_pair(d1, d2): """ Recursively merges values f...
def merge(d, *dicts): """ Recursively merges dictionaries """ for d_update in dicts: if not isinstance(d, dict): raise type_error('{0} is not a dict'.format(d)) dict_merge_pair(d, d_update) return d def dict_merge_pair(d1, d2): """ Recursively merges values from ...
# example to understand variables a = [2, 4, 6] b = a a.append(8) print(b) # example to understand variables scope a = 15; b = 25 def my_function(): global a a = 11; b = 21 my_function() print(a) #11 print(b) #25
a = [2, 4, 6] b = a a.append(8) print(b) a = 15 b = 25 def my_function(): global a a = 11 b = 21 my_function() print(a) print(b)
def multiply(a,b): return a*b def divide(a,b): return a/b
def multiply(a, b): return a * b def divide(a, b): return a / b
expected_output = { "version": { "build_time": "08:13:43 Apr 7, 2021", "firmware_ver": "18r.1.00h", "install_time": "07:14:32 Jun 1, 2021", "slot": { "L1/0": { "name": "L1/0", "primary_ver": "18r.1.00h", "secondary_ver": "...
expected_output = {'version': {'build_time': '08:13:43 Apr 7, 2021', 'firmware_ver': '18r.1.00h', 'install_time': '07:14:32 Jun 1, 2021', 'slot': {'L1/0': {'name': 'L1/0', 'primary_ver': '18r.1.00h', 'secondary_ver': '18r.1.00h', 'status': 'ACTIVE'}, 'L2/0': {'name': 'L2/0', 'primary_ver': '18r.1.00h', 'secondary_ver...
# testNamespace.someFunction testNamespace.some_function("", 0, False) # testNamespace.someFunctionWithDefl testNamespace.some_function_with_defl(5, True)
testNamespace.some_function('', 0, False) testNamespace.some_function_with_defl(5, True)
def solve(): n = int(input()) f = [1, 2] + [0] * (n - 2) for i in range(2, n): f[i] = (f[i - 2] + f[i - 1]) % 15746 print(f[n - 1]) solve()
def solve(): n = int(input()) f = [1, 2] + [0] * (n - 2) for i in range(2, n): f[i] = (f[i - 2] + f[i - 1]) % 15746 print(f[n - 1]) solve()
# -*- coding: UTF-8 -*- """Set Operations.""" hero1 = {"smart", "rich", "armored", "martial_artist", "strong"} hero2 = {"smart", "fast", "strong", "invulnerable", "antigravity"} type(hero1) type(hero2) # Attributes for both heros (union) hero1 | hero2 hero1.union(hero2) # Attributes common to both heros (intersecti...
"""Set Operations.""" hero1 = {'smart', 'rich', 'armored', 'martial_artist', 'strong'} hero2 = {'smart', 'fast', 'strong', 'invulnerable', 'antigravity'} type(hero1) type(hero2) hero1 | hero2 hero1.union(hero2) hero1 & hero2 hero1.intersection(hero2) hero1 - hero2 hero1.difference(hero2) hero2 - hero1 hero2.difference(...
m, n = map(int, input().split()) dicionario = {} for i in range(m): cargo, valor = input().split() dicionario[cargo] = int(valor) for i in range(n): a = input().split() total = 0 while a != ["."]: for word in a: if word in dicionario: total += dicionario[word] a = input().split() print(total)
(m, n) = map(int, input().split()) dicionario = {} for i in range(m): (cargo, valor) = input().split() dicionario[cargo] = int(valor) for i in range(n): a = input().split() total = 0 while a != ['.']: for word in a: if word in dicionario: total += dicionario[word]...
f = lambda seg,c: sum([v[0]/(v[1]+c) for v in seg]) n,t = [int(i) for i in input().split()] seg = [] l,r = -2011,10**9 for i in range(n): seg.append([int(j) for j in input().split()]) l = max(l,-seg[i][1]) c = (l+r)/2 curr = f(seg,c) it = 1000 while abs(curr-t) > 10**(-7) and it > 0: if curr >= t: ...
f = lambda seg, c: sum([v[0] / (v[1] + c) for v in seg]) (n, t) = [int(i) for i in input().split()] seg = [] (l, r) = (-2011, 10 ** 9) for i in range(n): seg.append([int(j) for j in input().split()]) l = max(l, -seg[i][1]) c = (l + r) / 2 curr = f(seg, c) it = 1000 while abs(curr - t) > 10 ** (-7) and it > 0: ...
# Copyright (c) 2020 Graphcore Ltd. All rights reserved # signatures for manually added operators signatures = { 'beginIpuBlock': [['clong'], ['clong'], ['clong']], 'cast': ['Args', ['scalar_type']], 'internalCast': ['Args', ['cstr']], 'constantPad': ['Args', ['clong_list'], ['cfloat']], 'edgePad':...
signatures = {'beginIpuBlock': [['clong'], ['clong'], ['clong']], 'cast': ['Args', ['scalar_type']], 'internalCast': ['Args', ['cstr']], 'constantPad': ['Args', ['clong_list'], ['cfloat']], 'edgePad': ['Args', ['clong_list']], 'optimizerGroup': [['clong'], ['tensor_list']], 'printIpuTensor': ['Args', ['cstr']], 'callCp...
def post(settings): data = {"dynaconf_merge": True} if settings.get("ADD_BEATLES") is True: data["BANDS"] = ["Beatles"] return data
def post(settings): data = {'dynaconf_merge': True} if settings.get('ADD_BEATLES') is True: data['BANDS'] = ['Beatles'] return data
# Bluerred Image Detection # # Author: Jasonsey # Email: 2627866800@qq.com # # ============================================================================= """global config file""" # ------------------------------net config------------------------ NUM_CLASS = 2 # number of classes CUDA_VISIBLE_DEVI...
"""global config file""" num_class = 2 cuda_visible_devices = '2' batch_size = 32 predict_gpu_memory = 0.08 thrift_host = '172.18.31.211' thrift_port = 9099 thrift_num_works = 12 def init_config(): """config the remaining configuration""" global GPUS gpus = len(CUDA_VISIBLE_DEVICES.split(',')) init_config(...
class Text(): RED = "\033[1;31;1m" GREEN = '\033[1;32;1m' YELLOW = '\033[1;33;1m' UNDERLINE = '\033[4m' def apply(str, format): return(format + str + '\033[0m')
class Text: red = '\x1b[1;31;1m' green = '\x1b[1;32;1m' yellow = '\x1b[1;33;1m' underline = '\x1b[4m' def apply(str, format): return format + str + '\x1b[0m'
# ................................................................................................................. level_dict["bronze"] = { "scheme": "bronze_scheme", "size": (9,6,9), "intro": "bronze", "hel...
level_dict['bronze'] = {'scheme': 'bronze_scheme', 'size': (9, 6, 9), 'intro': 'bronze', 'help': ('$scale(1.5)mission:\nactivate the exit!\n\n' + 'to activate the exit\nfeed it with electricity:\n\n' + 'connect the generator\nwith the motor\n' + 'and close the circuit\nwith the wire stones',), 'player': {'position': (0...
# parsetab.py # This file is automatically generated. Do not edit. _tabversion = '3.10' _lr_method = 'LALR' _lr_signature = 'leftIDleftNUMBERINFINITYleftBEGIN_CASEEND_CASEBEGIN_BMATRIXEND_BMATRIXBEGIN_PMATRIXEND_PMATRIXBACKSLASHESleftINTEGRALDIFFERENTIALDIEPARTIALLIMITTOrightCOMMArightPIPErightLPARENRPARENrightLBRAC...
_tabversion = '3.10' _lr_method = 'LALR' _lr_signature = 'leftIDleftNUMBERINFINITYleftBEGIN_CASEEND_CASEBEGIN_BMATRIXEND_BMATRIXBEGIN_PMATRIXEND_PMATRIXBACKSLASHESleftINTEGRALDIFFERENTIALDIEPARTIALLIMITTOrightCOMMArightPIPErightLPARENRPARENrightLBRACERBRACELBRACKETRBRACKETFRACleftPIPRIMErightLEGELTGTEQNEQleftINrightDOT...
class EndPointParam: NO_VALUE = (None, ) # Simple tuple for testing with `is` def __init__(self, vtype=str, default=NO_VALUE, help_text=None, required=False): self.name = 'param' self.data_type = vtype self.default = default self.help_text = help_text self.required = ...
class Endpointparam: no_value = (None,) def __init__(self, vtype=str, default=NO_VALUE, help_text=None, required=False): self.name = 'param' self.data_type = vtype self.default = default self.help_text = help_text self.required = required def clean(self, value): ...
async def test_index(test_cli): resp = await test_cli.get('/') assert resp.status == 200 data = await resp.text() assert '<title>squash</title>' in data
async def test_index(test_cli): resp = await test_cli.get('/') assert resp.status == 200 data = await resp.text() assert '<title>squash</title>' in data
if name: env = 1 else: env = 2
if name: env = 1 else: env = 2
n,k = map(int,input().split()) s = input() if n//2 >= k: for i in range(k-1): print("LEFT") for i in range(n-1): print("PRINT",s[i]) print("RIGHT") print("PRINT",s[n-1]) else: for i in range(n-k): print("RIGHT") for i in range(1,n): print("PRINT",s[-i]) ...
(n, k) = map(int, input().split()) s = input() if n // 2 >= k: for i in range(k - 1): print('LEFT') for i in range(n - 1): print('PRINT', s[i]) print('RIGHT') print('PRINT', s[n - 1]) else: for i in range(n - k): print('RIGHT') for i in range(1, n): print('PRI...
def stringsRearrangement(inputArray): ''' Given an array of equal-length strings, check if it is possible to rearrange the strings in such a way that after the rearrangement the strings at consecutive positions would differ by exactly one character. ''' totalLen = len(inputArray) for i in ...
def strings_rearrangement(inputArray): """ Given an array of equal-length strings, check if it is possible to rearrange the strings in such a way that after the rearrangement the strings at consecutive positions would differ by exactly one character. """ total_len = len(inputArray) for i i...
# https://projecteuler.net/problem=20 def reverse_str(s): return s[::-1] def sum_str(a, b): if len(b) > len(a): return sum_str(b, a) reverseA = reverse_str(a) reverseB = reverse_str(b) i = 0 add = 0 result = [] while i < len(a): o1 = int(reverseA[i]) o2 = 0 ...
def reverse_str(s): return s[::-1] def sum_str(a, b): if len(b) > len(a): return sum_str(b, a) reverse_a = reverse_str(a) reverse_b = reverse_str(b) i = 0 add = 0 result = [] while i < len(a): o1 = int(reverseA[i]) o2 = 0 if i < len(b): o2 = i...
''' lec 3 ''' my_list = [1,2,3,4,5] print(my_list) my_nested_list = [1,2,3,my_list] print(my_nested_list) my_list [0] = 6 print(my_list) print(my_list[0]) print(my_list[1]) print(my_list[-1]) print(my_list) print(my_list[1:3]) print(my_list[:]) x,y = ['a', 'b'] print(x,y) print(my_list) my_list.append(7) print...
""" lec 3 """ my_list = [1, 2, 3, 4, 5] print(my_list) my_nested_list = [1, 2, 3, my_list] print(my_nested_list) my_list[0] = 6 print(my_list) print(my_list[0]) print(my_list[1]) print(my_list[-1]) print(my_list) print(my_list[1:3]) print(my_list[:]) (x, y) = ['a', 'b'] print(x, y) print(my_list) my_list.append(7) prin...
class dummy_storage: def retrieve(self): return {} def persist(self, credentials): return None
class Dummy_Storage: def retrieve(self): return {} def persist(self, credentials): return None
# https://app.codesignal.com/interview-practice/task/5vcioHMkhGqkaQQYt/solutions # Singly-linked lists are already defined with this interface: # class ListNode(object): # def __init__(self, x): # self.value = x # self.next = None # def rearrangeLastN(head, n): if n < 1: return head l = 0...
def rearrange_last_n(head, n): if n < 1: return head l = 0 iterator = head while iterator: iterator = iterator.next l += 1 if l <= 1 or n >= l: return head reversing_elements = l - n i = 0 start = head while head: i += 1 if i == reversi...
x = int(input()) ans = 0 ans = (x//500)*1000 x = x % 500 ans += (x//5)*5 print(ans)
x = int(input()) ans = 0 ans = x // 500 * 1000 x = x % 500 ans += x // 5 * 5 print(ans)
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def dfs(self, root): stack = [] stack.append((root, 1)) ans = sys.maxsize while stack: ...
class Solution: def dfs(self, root): stack = [] stack.append((root, 1)) ans = sys.maxsize while stack: (curr, depth) = stack.pop() if curr.right != None: stack.append((curr.right, depth + 1)) if curr.left != None: s...
class SubScript(): """Creates an instance of SubScript""" def __init__(self): self.NUM_0 = u'\u2080' self.NUM_1 = u'\u2081' self.NUM_2 = u'\u2082' self.NUM_3 = u'\u2083' self.NUM_4 = u'\u2084' self.NUM_5 = u'\u2085' self.NUM_6 = u'\u2086' ...
class Subscript: """Creates an instance of SubScript""" def __init__(self): self.NUM_0 = u'β‚€' self.NUM_1 = u'₁' self.NUM_2 = u'β‚‚' self.NUM_3 = u'₃' self.NUM_4 = u'β‚„' self.NUM_5 = u'β‚…' self.NUM_6 = u'₆' self.NUM_7 = u'₇' self.NUM_8 = u'β‚ˆ' ...
student = { "name": "Mark", "student_id": 15163, "feedback": None } all_students = [ {"name": "Mark", "student_id": 15163}, {"name": "Katarina", "student_id": 63112}, {"name": "Jessica", "student_id": 30021} ] student["name"] == "Mark" student["last_name"] == KeyError student.get("last_name", ...
student = {'name': 'Mark', 'student_id': 15163, 'feedback': None} all_students = [{'name': 'Mark', 'student_id': 15163}, {'name': 'Katarina', 'student_id': 63112}, {'name': 'Jessica', 'student_id': 30021}] student['name'] == 'Mark' student['last_name'] == KeyError student.get('last_name', 'Unknown') == 'Unknown' studen...
og=list(input("Enter number ")) new=set(og) print("".join(og),"is a Unique Number") if len(new)==len(og) else print("".join(og),"is not a Unique Number")
og = list(input('Enter number ')) new = set(og) print(''.join(og), 'is a Unique Number') if len(new) == len(og) else print(''.join(og), 'is not a Unique Number')
n = int(input()) cont = 0 while cont < n: num = int(input()) if cont == 0: maior = num elif num > maior: maior = num cont += 1 print(maior)
n = int(input()) cont = 0 while cont < n: num = int(input()) if cont == 0: maior = num elif num > maior: maior = num cont += 1 print(maior)
class Solution: def climbStairs(self, n: int) -> int: if n==1: return 1 if n==2: return 2 l=[1,2] for i in range(2,n): l.append(l[i-1]+l[i-2]) return l.pop()
class Solution: def climb_stairs(self, n: int) -> int: if n == 1: return 1 if n == 2: return 2 l = [1, 2] for i in range(2, n): l.append(l[i - 1] + l[i - 2]) return l.pop()
class PipelineException(Exception): def __init__(self, msg=''): self.msg = msg super(PipelineException, self).__init__(msg)
class Pipelineexception(Exception): def __init__(self, msg=''): self.msg = msg super(PipelineException, self).__init__(msg)
b=[9,6,3,2,5,8,7,4,1,0] def selection_sort(b): for i in range((len(b))-1): min = b[i] for j in range(i + 1, len(b)): if b[j] < min: min = b[j] pos=j b[pos] = b[i] b[i]=min print(b) selection_sort(b) pri...
b = [9, 6, 3, 2, 5, 8, 7, 4, 1, 0] def selection_sort(b): for i in range(len(b) - 1): min = b[i] for j in range(i + 1, len(b)): if b[j] < min: min = b[j] pos = j b[pos] = b[i] b[i] = min print(b) selection_sort(b) p...
def cipher(s): return ''.join((map(lambda c: chr(219-ord(c)) if 97 <= ord(c) <= 122 else c, s))) print(cipher('Anyone who has never made a mistake has never tried anything new.'))
def cipher(s): return ''.join(map(lambda c: chr(219 - ord(c)) if 97 <= ord(c) <= 122 else c, s)) print(cipher('Anyone who has never made a mistake has never tried anything new.'))
"""Task queue - deque example""" class TaskQueue: """Task queue using list""" def __init__(self): self._tasks = [] def push(self, task): self._tasks.insert(0, task) def pop(self): return self._tasks.pop() def __len__(self): return len(self._tasks) def test_queue...
"""Task queue - deque example""" class Taskqueue: """Task queue using list""" def __init__(self): self._tasks = [] def push(self, task): self._tasks.insert(0, task) def pop(self): return self._tasks.pop() def __len__(self): return len(self._tasks) def test_queue...
# BOJ 9465 n = 5 stickers = [[50, 10, 100, 20, 40], [30, 50, 70, 10, 60]] memo = [[0 for _ in range(n)] for _ in range(2)] memo[0][0] = stickers[0][0] memo[0][1] = stickers[0][1] def solve(n): for i in range(1, n): if i < 2: memo[0][i] = memo[1][i - 1] + stickers[0][i] memo[1][i] ...
n = 5 stickers = [[50, 10, 100, 20, 40], [30, 50, 70, 10, 60]] memo = [[0 for _ in range(n)] for _ in range(2)] memo[0][0] = stickers[0][0] memo[0][1] = stickers[0][1] def solve(n): for i in range(1, n): if i < 2: memo[0][i] = memo[1][i - 1] + stickers[0][i] memo[1][i] = memo[0][i -...
class GenericMachine(): alphabet = set() trans_func = dict() start_state = str() final_states = set() def __init__(self, _alphabet, _trans_func, _start_state, _final_states): self.alphabet = _alphabet self.trans_func = _trans_func self.start_state = _start_state self...
class Genericmachine: alphabet = set() trans_func = dict() start_state = str() final_states = set() def __init__(self, _alphabet, _trans_func, _start_state, _final_states): self.alphabet = _alphabet self.trans_func = _trans_func self.start_state = _start_state self.f...
''' Python has built-in string validation methods for basic data. It can check if a string is composed of alphabetical characters, alphanumeric characters, digits, etc. str.isalnum() This method checks if all the characters of a string are alphanumeric (a-z, A-Z and 0-9). >>> print 'ab123'.isalnum() True >>> print 'a...
""" Python has built-in string validation methods for basic data. It can check if a string is composed of alphabetical characters, alphanumeric characters, digits, etc. str.isalnum() This method checks if all the characters of a string are alphanumeric (a-z, A-Z and 0-9). >>> print 'ab123'.isalnum() True >>> print 'a...
# -*- encoding: utf-8 -*- class WebError(Exception): def __init__(self, code, message=''): Exception.__init__(self) self.code = code self.message = message def __str__(self): return self.message
class Weberror(Exception): def __init__(self, code, message=''): Exception.__init__(self) self.code = code self.message = message def __str__(self): return self.message
HELP_MESSAGE = """Hi there, I am a bot that shows the current free games on all the major game platforms out there. You will get automatically notified when new games become free to collect. If you would like to see the current free game please use the following command: /freegame """ BOT_TOKEN = '123'
help_message = 'Hi there, I am a bot that shows the current free games on all the major game platforms out there.\nYou will get automatically notified when new games become free to collect.\nIf you would like to see the current free game please use the following command: /freegame\n' bot_token = '123'
# EG7-09 get_value investigation 2 def get_value(prompt, value_min, value_max): return ride_number=get_value(prompt='Please enter the ride number you want:',value_min=1,value_max=5) print('You have selected ride:',ride_number)
def get_value(prompt, value_min, value_max): return ride_number = get_value(prompt='Please enter the ride number you want:', value_min=1, value_max=5) print('You have selected ride:', ride_number)
# https://www.codewars.com/kata/5266876b8f4bf2da9b000362/train/python def likes(names): counter=0 for name in names: counter+=1 if counter==0: return("no one likes this") elif counter==1: return(f"{names[0]} likes this") elif counter==2: return(f"{names[0]} and {n...
def likes(names): counter = 0 for name in names: counter += 1 if counter == 0: return 'no one likes this' elif counter == 1: return f'{names[0]} likes this' elif counter == 2: return f'{names[0]} and {names[1]} like this' elif counter == 3: return f'{names...
# Created by MechAviv # Quest ID :: 20865 # The Path of a Thunder Breaker sm.setSpeakerID(1101007) if sm.sendAskYesNo("Yer sure about this? Remember, ye can't change yer mind, so ye'll want to pick carefully. Ye really want to join me as a Thunder Breaker?"): sm.setSpeakerID(1101007) sm.sendNext("Just like tha...
sm.setSpeakerID(1101007) if sm.sendAskYesNo("Yer sure about this? Remember, ye can't change yer mind, so ye'll want to pick carefully. Ye really want to join me as a Thunder Breaker?"): sm.setSpeakerID(1101007) sm.sendNext('Just like that, yer a Thunder Breaker! Now let me give ye some abilities.') sm.giveI...
""" 1. get the user,pwd and current sold from the console 2. validate the user and password 3. Enable the login through an enter 4. Display the sold after the login 5. Retrieve an amount of cash 6. Display the password encrypted e.g. instead of 'abcd' show '****'. 7. Be aware that the nr of '*' should be equal with the...
""" 1. get the user,pwd and current sold from the console 2. validate the user and password 3. Enable the login through an enter 4. Display the sold after the login 5. Retrieve an amount of cash 6. Display the password encrypted e.g. instead of 'abcd' show '****'. 7. Be aware that the nr of '*' should be equal with the...
""" Author: Trevor Stalnaker, Justin Pusztay File: fsm.py A class that models a finite state machine """ class FSM(): """ Models a generalized finite state machine """ def __init__(self, startState, states, transitions): self._state = startState self._startState = startState s...
""" Author: Trevor Stalnaker, Justin Pusztay File: fsm.py A class that models a finite state machine """ class Fsm: """ Models a generalized finite state machine """ def __init__(self, startState, states, transitions): self._state = startState self._startState = startState sel...
#!/usr/bin/env python # -*- coding: utf-8 -*- arr = [6,5,4,2,1,8,3] def qsort(l, r): global arr if l >= r: return first, last, key = l, r, arr[l] while first < last: while first < last and arr[last] >= key: last -= 1 arr[first] = arr[last] while first < last and arr[first] <= key...
arr = [6, 5, 4, 2, 1, 8, 3] def qsort(l, r): global arr if l >= r: return (first, last, key) = (l, r, arr[l]) while first < last: while first < last and arr[last] >= key: last -= 1 arr[first] = arr[last] while first < last and arr[first] <= key: f...