content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
q = int(input()) for _ in range(q): n,m,c_lib,c_road = map(int,input().strip().split(' ')) roads = [] for _ in m: roads.append([int(x) for x in input().strip().split(' ')])
q = int(input()) for _ in range(q): (n, m, c_lib, c_road) = map(int, input().strip().split(' ')) roads = [] for _ in m: roads.append([int(x) for x in input().strip().split(' ')])
class Yaku(object): yaku_id = None name = '' han = {'open': None, 'closed': None} is_yakuman = False def __init__(self, yaku_id, name, open_value, closed_value, is_yakuman=False): self.id = yaku_id self.name = name self.han = {'open': open_value, 'closed': closed_value} ...
class Yaku(object): yaku_id = None name = '' han = {'open': None, 'closed': None} is_yakuman = False def __init__(self, yaku_id, name, open_value, closed_value, is_yakuman=False): self.id = yaku_id self.name = name self.han = {'open': open_value, 'closed': closed_value} ...
""" Problem 1: Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5, between 2000 and 3200 (both included). The numbers obtained should be printed in a comma-separated sequence on a single line. Hints: Consider using range(#begin, #end) method. """ # Solution: numbers =...
""" Problem 1: Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5, between 2000 and 3200 (both included). The numbers obtained should be printed in a comma-separated sequence on a single line. Hints: Consider using range(#begin, #end) method. """ numbers = [] for i in ...
# Solution to exercise Brackets # http://www.codility.com/train/ def solution(S): # Create a stack to track what braces are open stack = [] opposite_braces = {'(': ')', '{': '}', '[': ']'} for i in S: # Each time a brace is opened, add it to the stack if i == '(' or i == '{' or i == '[':...
def solution(S): stack = [] opposite_braces = {'(': ')', '{': '}', '[': ']'} for i in S: if i == '(' or i == '{' or i == '[': stack.append(i) else: if len(stack) == 0: return 0 j = stack.pop() if not i == opposite_braces[j]: ...
with open('input.txt') as f: input = f.read().splitlines() heights = [] for line in input: x = [] for digit in line: x.append(int(digit)) heights.append(x) # X and Y are swapped in two dimensional array # Use dedicated function to avoid confusion def get_value_coordinate(map, coordinate): ...
with open('input.txt') as f: input = f.read().splitlines() heights = [] for line in input: x = [] for digit in line: x.append(int(digit)) heights.append(x) def get_value_coordinate(map, coordinate): x = coordinate[0] y = coordinate[1] if x < 0 or y < 0: return 100 else: ...
# The parser accepts properties and methods in implementation-specific entities # although the code generator will disregard them. # # This is useful, for example, for linting or for visualizing the meta-model # even though no code is generated based on these properties and methods. @implementation_specific class Som...
@implementation_specific class Something: x: int def do_something(self) -> None: pass __book_url__ = 'dummy' __book_version__ = 'dummy'
class Solution: def minPathSum(self, grid): """ :type grid: List[List[int]] :rtype: int """ for i in range(len(grid)): for j in range(len(grid[0])): grid[i][j] += min(grid[i][j - 1] if j > 0 else float("inf"), grid[i - 1][j] if i > 0 else float("in...
class Solution: def min_path_sum(self, grid): """ :type grid: List[List[int]] :rtype: int """ for i in range(len(grid)): for j in range(len(grid[0])): grid[i][j] += min(grid[i][j - 1] if j > 0 else float('inf'), grid[i - 1][j] if i > 0 else float(...
class NullNode: def __init__(self, parent): self.parent = parent def add(self, key, value): self.parent.grow(key, value) def search(self, key): return None def get_list(self): return list() class LeftNullNode(NullNode): def add(self, key, value): self.pare...
class Nullnode: def __init__(self, parent): self.parent = parent def add(self, key, value): self.parent.grow(key, value) def search(self, key): return None def get_list(self): return list() class Leftnullnode(NullNode): def add(self, key, value): self.pa...
""" Sponge Knowledge Base Remote service configuration """ def onInit(): sponge.addCategories( CategoryMeta("service").withLabel("My Service").withPredicate(lambda processor: processor.kb.name.startswith("service")) )
""" Sponge Knowledge Base Remote service configuration """ def on_init(): sponge.addCategories(category_meta('service').withLabel('My Service').withPredicate(lambda processor: processor.kb.name.startswith('service')))
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode: # head pointer will be used for return value node = head ...
class Solution: def remove_nth_from_end(self, head: ListNode, n: int) -> ListNode: node = head length = 0 while node: length += 1 node = node.next if length == 1: head = head.next return head node = head index = length ...
# 406. Queue Reconstruction by Height # Suppose you have a random list of people standing in a queue. # Each person is described by a pair of integers (h, k), # where h is the height of the person # and k is the number of people in front of this person who have a height greater than or equal to h. # Write an algori...
class Solution(object): def reconstruct_queue(self, people): """ :type people: List[List[int]] :rtype: List[List[int]] """ res = [] if not people: return res peopledict = {} for i in range(len(people)): p = people[i] ...
"""This problem was asked by Google. Let A be an N by M matrix in which every row and every column is sorted. Given i1, j1, i2, and j2, compute the number of elements of M smaller than M[i1, j1] and larger than M[i2, j2]. For example, given the following matrix: [[1, 3, 7, 10, 15, 20], [2, 6, 9, 14, 22, 25], [3,...
"""This problem was asked by Google. Let A be an N by M matrix in which every row and every column is sorted. Given i1, j1, i2, and j2, compute the number of elements of M smaller than M[i1, j1] and larger than M[i2, j2]. For example, given the following matrix: [[1, 3, 7, 10, 15, 20], [2, 6, 9, 14, 22, 25], [3,...
class Service(object): """ Base class for service implementations in 'services' directory. """ def __init__(self, response, api_key, destination_config): """ Initialize service. :param response: data to be transformed :param api_key: api key for 3r...
class Service(object): """ Base class for service implementations in 'services' directory. """ def __init__(self, response, api_key, destination_config): """ Initialize service. :param response: data to be transformed :param api_key: api key for 3...
def _gen_build_info(name, maven_coords, multi_release_jar): if not (maven_coords): return [] rev = native.read_config("selenium", "rev", "unknown") time = native.read_config("selenium", "timestamp", "unknown") multi_release = "false" if multi_release_jar: multi_release = "true" ...
def _gen_build_info(name, maven_coords, multi_release_jar): if not maven_coords: return [] rev = native.read_config('selenium', 'rev', 'unknown') time = native.read_config('selenium', 'timestamp', 'unknown') multi_release = 'false' if multi_release_jar: multi_release = 'true' nat...
class Graphs: def axlab(self, axis="", lab="", **kwargs): """Labels the X and Y axes on graph displays. APDL Command: /AXLAB Parameters ---------- axis Axis specifier: X - Apply label to X axis. Y - Apply label to Y axis. lab ...
class Graphs: def axlab(self, axis='', lab='', **kwargs): """Labels the X and Y axes on graph displays. APDL Command: /AXLAB Parameters ---------- axis Axis specifier: X - Apply label to X axis. Y - Apply label to Y axis. lab ...
headers = { 1: """<!--- title: "Tutorial 1" metaTitle: "Build Your First QA System" metaDescription: "" slug: "/docs/tutorial1" date: "2020-09-03" id: "tutorial1md" --->""", 2: """<!--- title: "Tutorial 2" metaTitle: "Fine-tuning a model on your own data" metaDescription: "" slug: "/docs/tutorial2" date: "2020-...
headers = {1: '<!---\ntitle: "Tutorial 1"\nmetaTitle: "Build Your First QA System"\nmetaDescription: ""\nslug: "/docs/tutorial1"\ndate: "2020-09-03"\nid: "tutorial1md"\n--->', 2: '<!---\ntitle: "Tutorial 2"\nmetaTitle: "Fine-tuning a model on your own data"\nmetaDescription: ""\nslug: "/docs/tutorial2"\ndate: "2020-09-...
res = 0 for i in range(1000): if i%3==0: res+=i continue if i%5==0: res+=i print(res)
res = 0 for i in range(1000): if i % 3 == 0: res += i continue if i % 5 == 0: res += i print(res)
class JADocuments(object): def __init__(self, document): self.document = document def appendObjectInDocument(self, objectToAppend, attribute): attr = self.document.get(attribute, {}) if not attr: self.document[attribute] = objectToAppend else: if isinstanc...
class Jadocuments(object): def __init__(self, document): self.document = document def append_object_in_document(self, objectToAppend, attribute): attr = self.document.get(attribute, {}) if not attr: self.document[attribute] = objectToAppend elif isinstance(self.docu...
#!/usr/bin/env python # -*- coding:utf-8 -*- """ The format of the text, such as font color. """ class bcolor(object): PURPLE = '\033[95m' CYAN = '\033[96m' DARKCYAN = '\033[36m' BLUE = '\033[94m' GREEN = '\033[92m' YELLOW = '\033[91m' RED = '\033[91m' BOLD = '\033[1m' UNDERLINE = ...
""" The format of the text, such as font color. """ class Bcolor(object): purple = '\x1b[95m' cyan = '\x1b[96m' darkcyan = '\x1b[36m' blue = '\x1b[94m' green = '\x1b[92m' yellow = '\x1b[91m' red = '\x1b[91m' bold = '\x1b[1m' underline = '\x1b[4m' end = '\x1b[0m' fontcolors = dic...
class smtp: host, port = ('127.0.0.1', 2025) class database: dbname = "database.sqlite" class site: host, port = ('127.0.0.1', 5000) debug = False SECRET_KEY = "<aslkfhaskldfhasklfhaskldfhaskldfhakslfhlaskdf>"
class Smtp: (host, port) = ('127.0.0.1', 2025) class Database: dbname = 'database.sqlite' class Site: (host, port) = ('127.0.0.1', 5000) debug = False secret_key = '<aslkfhaskldfhasklfhaskldfhaskldfhakslfhlaskdf>'
neighbours = {'1': ['2', '3'], '2': ['1', '3'], '3': ['2', '4'], '4': ['1', '3'], 'T': [] } colors = dict() for region in neighbours.keys(): colors[region] = 'black' def is_valid(colors): for region, region_neighbours in neighbo...
neighbours = {'1': ['2', '3'], '2': ['1', '3'], '3': ['2', '4'], '4': ['1', '3'], 'T': []} colors = dict() for region in neighbours.keys(): colors[region] = 'black' def is_valid(colors): for (region, region_neighbours) in neighbours.items(): for neighbour in region_neighbours: if colors[nei...
# Copyright (c) 2015 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. { 'variables': { 'chromium_code': 1, }, 'targets': [ { # GN version: //gpu:skia_runner 'target_name': 'skia_runner', 'typ...
{'variables': {'chromium_code': 1}, 'targets': [{'target_name': 'skia_runner', 'type': 'executable', 'dependencies': ['../../base/base.gyp:base', '../../gpu/command_buffer/command_buffer.gyp:gles2_utils', '../../gpu/gpu.gyp:command_buffer_service', '../../gpu/gpu.gyp:gles2_implementation', '../../gpu/gpu.gyp:gl_in_proc...
#!/usr/bin/env python # Copyright Contributors to the Open Shading Language project. # SPDX-License-Identifier: BSD-3-Clause # https://github.com/AcademySoftwareFoundation/OpenShadingLanguage command += testshade("-g 2 2 -debug printbackfacing") # debug output is very verbose, use regexp to filter down to # only the...
command += testshade('-g 2 2 -debug printbackfacing') filter_re = 'Need.*globals.*'
with open("delete.txt", "w") as f: f.write("Hello World") f.write("\n") f.write("Anthony Lister") f.write("\n") f.write("more stringy text here!") f.write("\n")
with open('delete.txt', 'w') as f: f.write('Hello World') f.write('\n') f.write('Anthony Lister') f.write('\n') f.write('more stringy text here!') f.write('\n')
initial_card_deck = ( "Ace of Clubs", "2 of Clubs", "3 of Clubs", "4 of Clubs", "5 of Clubs", "6 of Clubs", "7 of Clubs", "8 of Clubs", "9 of Clubs", "10 of Clubs", "Jack of Clubs", "Queen of Clubs", "King of Clubs", "Ace of Diamonds", "2 of Diamonds", "3 ...
initial_card_deck = ('Ace of Clubs', '2 of Clubs', '3 of Clubs', '4 of Clubs', '5 of Clubs', '6 of Clubs', '7 of Clubs', '8 of Clubs', '9 of Clubs', '10 of Clubs', 'Jack of Clubs', 'Queen of Clubs', 'King of Clubs', 'Ace of Diamonds', '2 of Diamonds', '3 of Diamonds', '4 of Diamonds', '5 of Diamonds', '6 of Diamonds', ...
n = int(input()) tasks = [0] * (n if n >= 3 else 3) tasks[0] = 0 tasks[1] = 1 for i in range(2, n): tasks[i] = tasks[i - 1] * 3 + (i - 1) * 2 print(3 ** n - tasks[n - 1])
n = int(input()) tasks = [0] * (n if n >= 3 else 3) tasks[0] = 0 tasks[1] = 1 for i in range(2, n): tasks[i] = tasks[i - 1] * 3 + (i - 1) * 2 print(3 ** n - tasks[n - 1])
class Cipher(object): def __init__(self, map1, map2): self.trans=str.maketrans(map1,map2) self.trans2=str.maketrans(map2,map1) def encode(self, s): return s.translate(self.trans) def decode(self, s): return s.translate(self.trans2)
class Cipher(object): def __init__(self, map1, map2): self.trans = str.maketrans(map1, map2) self.trans2 = str.maketrans(map2, map1) def encode(self, s): return s.translate(self.trans) def decode(self, s): return s.translate(self.trans2)
class Base: def __init__(self): print("Base initializer") def f(self): print("Base.f()") class Sub(Base): def __init__(self): super().__init__() print("Sub initializer") def f(self): print("Sub.f()") def main(): b = Base() b.f() s = Sub() s...
class Base: def __init__(self): print('Base initializer') def f(self): print('Base.f()') class Sub(Base): def __init__(self): super().__init__() print('Sub initializer') def f(self): print('Sub.f()') def main(): b = base() b.f() s = sub() s.f...
#!/usr/bin/env python3 class rec: pass rec.name = 'Bob' rec.age = 40 print(rec.name) x = rec() y = rec() print(x.name, y.name) x.name = 'Sue' print(x.name, y.name, rec.name) print(list(rec.__dict__.keys())) l = [name for name in rec.__dict__ if not name.startswith('__')] print(l) print(list(x.__dict__.keys...
class Rec: pass rec.name = 'Bob' rec.age = 40 print(rec.name) x = rec() y = rec() print(x.name, y.name) x.name = 'Sue' print(x.name, y.name, rec.name) print(list(rec.__dict__.keys())) l = [name for name in rec.__dict__ if not name.startswith('__')] print(l) print(list(x.__dict__.keys())) print(list(y.__dict__.keys(...
# Copyright 2016 Google Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
"""Creates a VM with user specified disks attached to it.""" compute_url_base = 'https://www.googleapis.com/compute/v1/' def disk_name(context, diskobj): return context.env['deployment'] + '-disk-' + diskobj['name'] def generate_config(context): """Creates configuration.""" resources = [] project = co...
BLACK = "black" RED = "red" NO_COLOR = "no color" class NILNode(object): def __init__(self, parent=None, left=None, right=None, color=BLACK): self._left = None self._right = right or None self._parent = parent or None self._color = color @property def left(self): i...
black = 'black' red = 'red' no_color = 'no color' class Nilnode(object): def __init__(self, parent=None, left=None, right=None, color=BLACK): self._left = None self._right = right or None self._parent = parent or None self._color = color @property def left(self): i...
def uppercase(string): list = [] for i in string: list.append(i.capitalize()) list = " ".join(list) return list string = input().split(" ") print(uppercase(string))
def uppercase(string): list = [] for i in string: list.append(i.capitalize()) list = ' '.join(list) return list string = input().split(' ') print(uppercase(string))
""" Profile ../profile-datasets-py/standard54lev_o3_trunc/002.py file automaticaly created by prof_gen.py script """ self["ID"] = "../profile-datasets-py/standard54lev_o3_trunc/002.py" self["Q"] = numpy.array([ 3.88740500e+00, 3.57059500e+00, 3.36870300e+00, 3.21868100e+00, 3.15067400e+00,...
""" Profile ../profile-datasets-py/standard54lev_o3_trunc/002.py file automaticaly created by prof_gen.py script """ self['ID'] = '../profile-datasets-py/standard54lev_o3_trunc/002.py' self['Q'] = numpy.array([3.887405, 3.570595, 3.368703, 3.218681, 3.150674, 3.214371, 3.322073, 3.758418, 5.479223, 9.643877...
class Cursor(object): """DB-API Cursor to SQLFlow.""" def __init__(self): self.description = None self.rowcount = None raise NotImplementedError def close(self): """Close the curosr now.""" raise NotImplementedError def execute(self, operation): """Prep...
class Cursor(object): """DB-API Cursor to SQLFlow.""" def __init__(self): self.description = None self.rowcount = None raise NotImplementedError def close(self): """Close the curosr now.""" raise NotImplementedError def execute(self, operation): """Prep...
class ORCEngine: """The API necessary to provide a new ORC reader/writer""" @classmethod def read_metadata( cls, fs, paths, columns, index, split_stripes, aggregate_files, **kwargs ): raise NotImplementedError() @classmethod def read_partition(cls, fs, part, columns, **kwargs):...
class Orcengine: """The API necessary to provide a new ORC reader/writer""" @classmethod def read_metadata(cls, fs, paths, columns, index, split_stripes, aggregate_files, **kwargs): raise not_implemented_error() @classmethod def read_partition(cls, fs, part, columns, **kwargs): rai...
""" ## Setup interactive python environment (iPython or Jupyter Notebook) # ############################################################################## ## Setup using pip: # # import gen3 # from gen3.auth import Gen3Auth # from gen3.submission import Gen3Submission # # Download gen3sdk scripts from GitHub # !wget ht...
""" ## Setup interactive python environment (iPython or Jupyter Notebook) # ############################################################################## ## Setup using pip: # # import gen3 # from gen3.auth import Gen3Auth # from gen3.submission import Gen3Submission # # Download gen3sdk scripts from GitHub # !wget ht...
#!/usr/bin/env python3 #Author: Stefan Toman if __name__ == '__main__': n = int(input()) t = tuple(map(int, input().split())) print(hash(t))
if __name__ == '__main__': n = int(input()) t = tuple(map(int, input().split())) print(hash(t))
#Reverse string by splitting a string by 1 letter def rev(s): b = [] print(type(s)) #Split a string for every nth letter # a = ([s[i:i+n] for i in range(0, len(s), n)]) a = ([s[i:i+1] for i in range(0, len(s), 1)]) print(a) print(len(a)) for i in range(len(a)): b.append(a[i-1]) ...
def rev(s): b = [] print(type(s)) a = [s[i:i + 1] for i in range(0, len(s), 1)] print(a) print(len(a)) for i in range(len(a)): b.append(a[i - 1]) print(b) rev('aksfgakfgajkfgajkfgaf')
def rand7(): pass class Solution: def rand10(self): c = rand7() * 7 + rand7() - 8 if c < 40: return (c % 10) + 1 # Here c ~ [40..48] # Thus (c % 10) ~ [0..8] # Thus e ~ [0..62] e = (c % 10)*7 + rand7() - 1 if e < 60: return...
def rand7(): pass class Solution: def rand10(self): c = rand7() * 7 + rand7() - 8 if c < 40: return c % 10 + 1 e = c % 10 * 7 + rand7() - 1 if e < 60: return e % 10 + 1 return self.rand10()
# -*- coding: utf-8 -*- """ Created on Tue Apr 7 17:04:37 2020 @author: sznik """ #Find Cost of Tile to Cover W x H Floor - Calculate the total cost #of tile it would take to cover a floor plan of width and height, #using a cost entered by the user. cost_of_tile = int(input("please enter the cost of th...
""" Created on Tue Apr 7 17:04:37 2020 @author: sznik """ cost_of_tile = int(input('please enter the cost of the tile: ')) h_tile = int(input('please nter the height of the tile: ')) w_tile = int(input('please enter the width of the tile: ')) w_room = int(input('widht of the room: ')) h_room = int(input('height of ro...
class Solution: def validateStackSequences(self, pushed: List[int], popped: List[int]) -> bool: pushed = collections.deque(pushed) stack = [] for x in popped: if len(stack) > 0 and x == stack[-1]: stack.pop() continue while len(pushed...
class Solution: def validate_stack_sequences(self, pushed: List[int], popped: List[int]) -> bool: pushed = collections.deque(pushed) stack = [] for x in popped: if len(stack) > 0 and x == stack[-1]: stack.pop() continue while len(pushe...
class Item: """ Describes the specific item instance. """ # The Quality of an item is never negative # The Quality of an item is never more than 50 # "Sulfuras" is a legendary item and as such its Quality is 80 and it never alters. MIN_QUALITY = 0 MAX_QUALITY = 50 LEG_MAX_QUALITY = 80 ...
class Item: """ Describes the specific item instance. """ min_quality = 0 max_quality = 50 leg_max_quality = 80 min_sell_in = 0 def __init__(self, _name, _sell_in, _quality): """ name : name of the item sell_in: number of days remaining to sell of the ite...
""" Common utilities on linked list """ class ListNode(object): def __init__(self, x): self.val = x self.next = None def to_list(self): vals = [] p = self while p: vals.append(p.val) p = p.next return vals def __str__(self): ...
""" Common utilities on linked list """ class Listnode(object): def __init__(self, x): self.val = x self.next = None def to_list(self): vals = [] p = self while p: vals.append(p.val) p = p.next return vals def __str__(self): ...
#Oppretter en funksjon som beregner antall celsius fra fahrenheit som argument. def celsius(fahrenheit): celsius = round((fahrenheit-32)*(5/9),1) #Beregner celsius og runder av til ett desimal. print(fahrenheit, "fahrenheit er lik ", celsius, "celsius.") #Kaller funksjonen med brukerens input som argument. cel...
def celsius(fahrenheit): celsius = round((fahrenheit - 32) * (5 / 9), 1) print(fahrenheit, 'fahrenheit er lik ', celsius, 'celsius.') celsius(int(input('Skriv inn antall fahrenheit: ')))
#!/usr/bin/env python # -*- coding: utf-8 -*- # This file was part of Flask-Bootstrap and was modified under the terms of # its BSD License. Copyright (c) 2013, Marc Brinkmann. All rights reserved. # # This file was part of Bootstrap-Flask and was modified under the terms of # its MIT License. Copyright (c) 2018 Grey ...
def test_sample_request(app, client): @app.get('/sample') def sample(): return 'OK' r = client.get('/sample') assert r.status_code == 200 assert r.data == b'OK'
f = open('input.txt') numbers = [] l = 1492208709 numbers = [] for line in f: numbers.append(int(line[:-1])) flag = False for i in range(len(numbers)): if flag: break su = numbers[i] mi = numbers[i] ma = numbers[i] for j in range(i+1, len(numbers)): su += numbers[j] if number...
f = open('input.txt') numbers = [] l = 1492208709 numbers = [] for line in f: numbers.append(int(line[:-1])) flag = False for i in range(len(numbers)): if flag: break su = numbers[i] mi = numbers[i] ma = numbers[i] for j in range(i + 1, len(numbers)): su += numbers[j] if ...
#!/usr/bin/env python # data should have the value of the directory where all of the data is stored. # Example of data value for dataset: 'data': '/work/csesd/pnnguyen/schnablelab/HCCtools/compressDatasetWorkflow/test_data/*' file_paths = {'data': '/work/csesd/pnnguyen/schnablelab/HCCtools/compressDatasetWorkflow/tes...
file_paths = {'data': '/work/csesd/pnnguyen/schnablelab/HCCtools/compressDatasetWorkflow/test_data/*'} use_anonymous = True
inp = input("Type your mathematical sentence here:\n") def tokenize(inp): chars = list(inp) clean_chars = [] number = "" for i in chars: if i.isdigit(): number += i elif i == "+" or i == "-": if number != "": clean_chars.append(number) clean_chars.append(i) number = "" else: ...
inp = input('Type your mathematical sentence here:\n') def tokenize(inp): chars = list(inp) clean_chars = [] number = '' for i in chars: if i.isdigit(): number += i elif i == '+' or i == '-': if number != '': clean_chars.append(number) ...
def print_rangoli(size): row = (2*size)-1 col = (row * 2) - 1 charater = size + 96 #ascending for i in range(1, (row//2)+1): in_row = [] for x in range(i): in_row.append(chr(charater-x)) for x in reversed(range(i-1)): in_row.append(chr(charater-x...
def print_rangoli(size): row = 2 * size - 1 col = row * 2 - 1 charater = size + 96 for i in range(1, row // 2 + 1): in_row = [] for x in range(i): in_row.append(chr(charater - x)) for x in reversed(range(i - 1)): in_row.append(chr(charater - x)) pr...
rid = 'explorer' endpoint = 'http://node.karbowanec.com:32348' host = '0.0.0.0' port = 3001 debug = True
rid = 'explorer' endpoint = 'http://node.karbowanec.com:32348' host = '0.0.0.0' port = 3001 debug = True
""" 71 Hungry Sequence - https://codeforces.com/problemset/problem/327/B """ n = int(input()) for i in range(n): print(3*n + i, end = " ")
""" 71 Hungry Sequence - https://codeforces.com/problemset/problem/327/B """ n = int(input()) for i in range(n): print(3 * n + i, end=' ')
# -*- coding: utf-8 -*- { "name" : "Website LinkedIn Login/Sign-Up", "summary" : "When the user clicks on Login/Sign-Up, the requested form appears in a very nice Ajax popup, integrated with Facebook, Odoo, Google+, LinkedIn.", "category" : "Website", "version" ...
{'name': 'Website LinkedIn Login/Sign-Up', 'summary': 'When the user clicks on Login/Sign-Up, the requested form appears in a very nice Ajax popup, integrated with Facebook, Odoo, Google+, LinkedIn.', 'category': 'Website', 'version': '1.0', 'author': 'Krishnaram.S', 'license': 'AGPL-3', 'website': 'https://www.techver...
print('====== DESAFIO 08 ======') n = float(input('Digite o valor em metros: ')) km = n / 1000 hm = n / 100 dam = n / 10 dm = n * 10 cm = n * 100 mm = n * 1000 print('''O medida de {}m corresponde a {}km {}hm {}dam {}dm {}cm {}mm'''.format(n, km, hm, dam, dm, cm, mm))
print('====== DESAFIO 08 ======') n = float(input('Digite o valor em metros: ')) km = n / 1000 hm = n / 100 dam = n / 10 dm = n * 10 cm = n * 100 mm = n * 1000 print('O medida de {}m corresponde a\n{}km\n{}hm\n{}dam\n{}dm\n{}cm\n{}mm'.format(n, km, hm, dam, dm, cm, mm))
# table definition table = { 'table_name' : 'db_tables', 'module_id' : 'db', 'short_descr' : 'Db tables', 'long_descr' : 'Database tables', 'sub_types' : None, 'sub_trans' : None, 'sequence' : ['seq', ['module_row_id'], None], 'tree_params' : [ 'module_...
table = {'table_name': 'db_tables', 'module_id': 'db', 'short_descr': 'Db tables', 'long_descr': 'Database tables', 'sub_types': None, 'sub_trans': None, 'sequence': ['seq', ['module_row_id'], None], 'tree_params': ['module_row_id', ['table_name', 'short_descr', None, 'seq'], None], 'roll_params': None, 'indexes': None...
IMPLICITS = { "memory_dict": "DictAccess*", "msize": None, "pedersen_ptr": "HashBuiltin*", "range_check_ptr": None, "syscall_ptr": "felt*", "bitwise_ptr": "BitwiseBuiltin*", "exec_env": "ExecutionEnvironment*", } IMPLICITS_SET = set(IMPLICITS.keys()) def print_implicit(name): type_ = ...
implicits = {'memory_dict': 'DictAccess*', 'msize': None, 'pedersen_ptr': 'HashBuiltin*', 'range_check_ptr': None, 'syscall_ptr': 'felt*', 'bitwise_ptr': 'BitwiseBuiltin*', 'exec_env': 'ExecutionEnvironment*'} implicits_set = set(IMPLICITS.keys()) def print_implicit(name): type_ = IMPLICITS.get(name, None) if ...
def miniMaxSum(arr): arr.sort() tot = 0 for num in arr: tot += num print(tot-arr[4], tot-arr[0])
def mini_max_sum(arr): arr.sort() tot = 0 for num in arr: tot += num print(tot - arr[4], tot - arr[0])
#flags to distinguish objects FLAGS = { "F_ROCKET" : 1, "F_ALIEN" : 2, "F_KIT" : 3, "F_LASER" : 4, "F_BALL" : 5}
flags = {'F_ROCKET': 1, 'F_ALIEN': 2, 'F_KIT': 3, 'F_LASER': 4, 'F_BALL': 5}
""" Linear search using subroutines with return values and parameters """ def inputNames(): names = [] for i in range(10): name = input("Enter a name: ") names.append(name) return names def namesSearch(aList, item): for i in aList: if i == item: print("Name found!") return True return False nameLi...
""" Linear search using subroutines with return values and parameters """ def input_names(): names = [] for i in range(10): name = input('Enter a name: ') names.append(name) return names def names_search(aList, item): for i in aList: if i == item: print('Name found...
def zip_longest(*input_iters, default=None) -> tuple: r"""iterz.zip_longest(*input_iters[, default]) Similar to zip_cycle but yields values until the longest of the input iterators is exhausted. Shorter iterators yields None when exhausted. Usage: >>> alist = [1, 2] >>> blist = [4, 5, 6, 7, 8]...
def zip_longest(*input_iters, default=None) -> tuple: """iterz.zip_longest(*input_iters[, default]) Similar to zip_cycle but yields values until the longest of the input iterators is exhausted. Shorter iterators yields None when exhausted. Usage: >>> alist = [1, 2] >>> blist = [4, 5, 6, 7, 8] ...
""" 1. Problem Summary / Clarifications / TDD: 1. Output(1->2->4, 1->3->4): 1->1->2->3->4->4 2. Output(1->2->3, 4->5->6): 1->2->3->4->5->6 3. Output(4->5->6, 1->2->3): 1->2->3->4->5->6 4. Output(1->3->5, 2->4->6->8->10): 1->2->3->4->5->6->8->10 6. Output(1->3->5, 2->4->6...
""" 1. Problem Summary / Clarifications / TDD: 1. Output(1->2->4, 1->3->4): 1->1->2->3->4->4 2. Output(1->2->3, 4->5->6): 1->2->3->4->5->6 3. Output(4->5->6, 1->2->3): 1->2->3->4->5->6 4. Output(1->3->5, 2->4->6->8->10): 1->2->3->4->5->6->8->10 6. Output(1->3->5, 2->4->6...
# read the input.txt def read_dossier(): # store information articles = {'Authors': [], 'Date': [], 'SOURCE': [], 'TEXT': []} # open file dossier = open('Steele_dossier.txt', 'r', encoding='ascii', errors='ignore').read() # split the individual texts texts = dossier.split("---...
def read_dossier(): articles = {'Authors': [], 'Date': [], 'SOURCE': [], 'TEXT': []} dossier = open('Steele_dossier.txt', 'r', encoding='ascii', errors='ignore').read() texts = dossier.split('-----------------------------------------------------------------------------------') for t in range(len(texts))...
#################################### # Author: "BALAVIGNESH" # # Maintainer: "BALAVIGNESH" # # License: "CC0 1.0 Universal" # # Date: "10/05/2021" # #################################### class Calculator: def add(*args): return sum(args) def multiply(*args): ...
class Calculator: def add(*args): return sum(args) def multiply(*args): result = 1 for x in args: result *= x return result class Calculatorpool: _instance_pool = [] def __call__(cls, size): for x in range(size): cls._instance_pool.appe...
class Tile: def __init__(self, x, y): '''A black tile''' self.x = x self.y = y def display(self, color): '''Draws the tile''' if color == "B": fill(0) elif color == "W": fill(255) ellipse(self.x, self.y, 90, 90)
class Tile: def __init__(self, x, y): """A black tile""" self.x = x self.y = y def display(self, color): """Draws the tile""" if color == 'B': fill(0) elif color == 'W': fill(255) ellipse(self.x, self.y, 90, 90)
msg= '68 65 32 30 32 32 7b 74 68 31 73 5f 30 6e 33 5f 31 73 5f 72 33 33 33 33 6c 79 5f 73 31 6d 70 6c 33 7d' res = '' for n in msg.split(' '): res += chr(int(n,16)) print(res)
msg = '68 65 32 30 32 32 7b 74 68 31 73 5f 30 6e 33 5f 31 73 5f 72 33 33 33 33 6c 79 5f 73 31 6d 70 6c 33 7d' res = '' for n in msg.split(' '): res += chr(int(n, 16)) print(res)
# # Copyright (c) 2020 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 wri...
""" Helpeer functions and constnats for working with various units. """ ki_b = 1024 mi_b = 1024 * KiB gi_b = 1024 * MiB ti_b = 1024 * GiB pi_b = 1024 * TiB _suffixes = {'k': KiB, 'm': MiB, 'g': GiB, 't': TiB} def humansize(s): """ Convert human size (e.g. 2m) to bytes. Supports units in _SUFFIXES, case in...
class Solution: def subdomainVisits(self, cpdomains: List[str]) -> List[str]: mp = {} for i in cpdomains: lst = i.split() cnt = int(lst[0]) domains = lst[1].split('.') domain = '' for j, val in enumerate(reversed(domains)): ...
class Solution: def subdomain_visits(self, cpdomains: List[str]) -> List[str]: mp = {} for i in cpdomains: lst = i.split() cnt = int(lst[0]) domains = lst[1].split('.') domain = '' for (j, val) in enumerate(reversed(domains)): ...
file1 = open('passwordPhilosophy_input.txt', 'r') lines_read = file1.readlines() old_valid_count = 0 new_valid_count = 0 def is_valid_old(letter_rule, test_password): my_tuple = letter_rule.split(" ") total_range = my_tuple[0] letter = my_tuple[1] min_max = total_range.split("-") minimum = int(min...
file1 = open('passwordPhilosophy_input.txt', 'r') lines_read = file1.readlines() old_valid_count = 0 new_valid_count = 0 def is_valid_old(letter_rule, test_password): my_tuple = letter_rule.split(' ') total_range = my_tuple[0] letter = my_tuple[1] min_max = total_range.split('-') minimum = int(min_...
# Definition for a binary tree node # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class BSTIterator: # @param root, a binary search tree's root node def __init__(self, root): self.curt = root self.stack = [] # ...
class Bstiterator: def __init__(self, root): self.curt = root self.stack = [] def has_next(self): return self.curt or len(self.stack) != 0 def next(self): curt = self.curt stack = self.stack while curt: stack.append(curt) curt = curt...
"""Collatz sequence. @author: Pablo Trinidad <github.com/pablotrinidad> """ def collatz(n): """Sequence generation.""" l = [] while n > 1: l.append(n) if n % 2 == 0: n = n / 2 else: n = (3 * n) + 1 l.append(n) return l n = int(input("Enter an integ...
"""Collatz sequence. @author: Pablo Trinidad <github.com/pablotrinidad> """ def collatz(n): """Sequence generation.""" l = [] while n > 1: l.append(n) if n % 2 == 0: n = n / 2 else: n = 3 * n + 1 l.append(n) return l n = int(input('Enter an integer n...
def power(x): return x * x def power2(x, n): s = 1 while n > 0: n = n -1 s = s * x return s def main(): x = input() x = int(x) print(power(x)) print('\n power2: \n',power2(x, 3)) if __name__ == "__main__": main()
def power(x): return x * x def power2(x, n): s = 1 while n > 0: n = n - 1 s = s * x return s def main(): x = input() x = int(x) print(power(x)) print('\n power2: \n', power2(x, 3)) if __name__ == '__main__': main()
# String # We are given two arrays A and B of words. Each word is a string of lowercase letters. # # Now, say that word b is a subset of word a if every letter in b occurs in a, including multiplicity. For example, "wrr" is a subset of "warrior", but is not a subset of "world". # # Now say a word a from A is univers...
class Solution: def word_subsets(self, A, B): """ :type A: List[str] :type B: List[str] :rtype: List[str] """ def freq_count(word): output = [0] * 26 for char in word: output[ord(char) - ord('a')] += 1 return outpu...
""" HackerRank Problem : https://www.hackerrank.com/challenges/the-minion-game/problem Submission : https://www.hackerrank.com/challenges/the-minion-game/submissions/code/163371713 """ def minion_game(string): kevin = 0 stuart = 0 # your code goes here vw = 'aeiou'.upper() strl = len(string...
""" HackerRank Problem : https://www.hackerrank.com/challenges/the-minion-game/problem Submission : https://www.hackerrank.com/challenges/the-minion-game/submissions/code/163371713 """ def minion_game(string): kevin = 0 stuart = 0 vw = 'aeiou'.upper() strl = len(string) for i in range(strl): ...
class o: "For classes that are mostly data stores, with few (or no) methods." def __init__(i, **d): i.__dict__.update(d) def __repr__(i): return i.__class__.__name__ + str( {k: v for k, v in sorted(i.__dict__.items()) if k[0] != "_"}) def _so(name, d, f): d, f = d.__dict__, f.__dict__ k = globals()[nam...
class O: """For classes that are mostly data stores, with few (or no) methods.""" def __init__(i, **d): i.__dict__.update(d) def __repr__(i): return i.__class__.__name__ + str({k: v for (k, v) in sorted(i.__dict__.items()) if k[0] != '_'}) def _so(name, d, f): (d, f) = (d.__dict__, f....
# Write a function that takes in a string of one or more words, # and returns the same string, but with all five or more letter words reversed # (Just like the name of this Kata). Strings passed in will consist of only letters and spaces. # Spaces will be included only when more than one word is present. # Exa...
def spin_words(sentence): revrese = [] words = sentence.split(' ') for word in words: if len(word) >= 5: revrese.append(word[::-1]) else: revrese.append(word) return ' '.join((str(i) for i in revrese))
def can_build(env, platform): # should probably change this to only be true on iOS and Android return False def configure(env): pass def get_doc_classes(): return [ "MobileVRInterface", ] def get_doc_path(): return "doc_classes"
def can_build(env, platform): return False def configure(env): pass def get_doc_classes(): return ['MobileVRInterface'] def get_doc_path(): return 'doc_classes'
def get_data(): return [[\ [0,0,3,0,2,0,6,0,0],\ [9,0,0,3,0,5,0,0,1],\ [0,0,1,8,0,6,4,0,0],\ [0,0,8,1,0,2,9,0,0],\ [7,0,0,0,0,0,0,0,8],\ [0,0,6,7,0,8,2,0,0],\ [0,0,2,6,0,9,5,0,0],\ [8,0,0,2,0,3,0,0,9],\ [0,0,5,0,1,0,3,0,0]\ ],[\ [2,0,0,0,8,0,3,0,0],\ [0,6,0,0,7,0,0,8,4],\ [0,3,0,5,0,0,2,0,9],\ [0,0,0,1,0...
def get_data(): return [[[0, 0, 3, 0, 2, 0, 6, 0, 0], [9, 0, 0, 3, 0, 5, 0, 0, 1], [0, 0, 1, 8, 0, 6, 4, 0, 0], [0, 0, 8, 1, 0, 2, 9, 0, 0], [7, 0, 0, 0, 0, 0, 0, 0, 8], [0, 0, 6, 7, 0, 8, 2, 0, 0], [0, 0, 2, 6, 0, 9, 5, 0, 0], [8, 0, 0, 2, 0, 3, 0, 0, 9], [0, 0, 5, 0, 1, 0, 3, 0, 0]], [[2, 0, 0, 0, 8, 0, 3, 0, 0],...
# Finding Bell Number using Summation of Sterling's Numbers def Sterling(N, k): if n == 0 or k == 0 or k > n: return 0 if k == 1 or n == k: return 1 else : return k*Sterling(N-1, k) + Sterling(N-1, k-1) def BellNumbers(N): PARTITIONS = 1 for i in range(N): ...
def sterling(N, k): if n == 0 or k == 0 or k > n: return 0 if k == 1 or n == k: return 1 else: return k * sterling(N - 1, k) + sterling(N - 1, k - 1) def bell_numbers(N): partitions = 1 for i in range(N): partitions += sterling(N, i) return PARTITIONS main_set = ...
URL_RAW = 'http://www.rda.gov.lk/source/rda_roads.htm' RAW_HTML_FILE = 'data/raw.html' ROADS_FILE = 'data/roads.tsv' GRAPH_PLACES_FILE = 'data/graph.places.json' GRAPH_ROADS_FILE = 'data/graph.roads.json' MAP_FILE = 'data/map.svg' STYLE_PLACE_CIRCLE = dict( r=6, fill='white', stroke='gray', stroke_wid...
url_raw = 'http://www.rda.gov.lk/source/rda_roads.htm' raw_html_file = 'data/raw.html' roads_file = 'data/roads.tsv' graph_places_file = 'data/graph.places.json' graph_roads_file = 'data/graph.roads.json' map_file = 'data/map.svg' style_place_circle = dict(r=6, fill='white', stroke='gray', stroke_width=3) style_place_t...
""" Question 30 : Define a function that can accepts two string as input and print the string with maximum length in console. If two strings have the same length, then the function should print all the string line by line. Hints : Use len() function to get the length of a string. """ # Solution : ...
""" Question 30 : Define a function that can accepts two string as input and print the string with maximum length in console. If two strings have the same length, then the function should print all the string line by line. Hints : Use len() function to get the length of a string. """ def print_val...
''' Greatest common divisor input : no = list integers output : GCD of those integers ''' no = input().split() a = int(no[0]) b = int(no[1]) assert (a >= 0 and b >= 0), "a,b should be >= 0" def gcd(a, b): if (a > b): while (b != 0): a, b = b, a % b return a print ...
""" Greatest common divisor input : no = list integers output : GCD of those integers """ no = input().split() a = int(no[0]) b = int(no[1]) assert a >= 0 and b >= 0, 'a,b should be >= 0' def gcd(a, b): if a > b: while b != 0: (a, b) = (b, a % b) return a print(gcd(a,...
# 1 # 2 1 # 3 2 1 # 4 3 2 1 # 5 4 3 2 1 noOfRows=5 for row in range(0,noOfRows): for col in range(row+1,0,-1): print(col, end=' ') print()
no_of_rows = 5 for row in range(0, noOfRows): for col in range(row + 1, 0, -1): print(col, end=' ') print()
# TODO: Finish the class Movie. class Movie: """A movie contains a title, a release year, an actor, budget and revenue. """ def __init__(self): pass # TODO: Adjust bubble_sort to become movie_sort. def bubble_sort(numbers): """Sorts a list of numbers using bubble sort. Args: numb...
class Movie: """A movie contains a title, a release year, an actor, budget and revenue. """ def __init__(self): pass def bubble_sort(numbers): """Sorts a list of numbers using bubble sort. Args: numbers: a list of numbers. Returns: A sorted list of numbers. """ ...
class Solution(object): def threeSum(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ length = len(nums) solution = [] dic_num = dict() nums.sort() for i in range(length): dic_num[nums[i]] = i i = 0 ...
class Solution(object): def three_sum(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ length = len(nums) solution = [] dic_num = dict() nums.sort() for i in range(length): dic_num[nums[i]] = i i = 0 ...
_base_ = ['./slowfast_r50_4x16x1_256e_kinetics400_rgb.py'] model = dict( backbone=dict( resample_rate=4, # tau speed_ratio=4, # alpha channel_ratio=8, # beta_inv slow_pathway=dict(fusion_kernel=7))) work_dir = './work_dirs/slowfast_r50_3d_8x8x1_256e_kinetics400_rgb'
_base_ = ['./slowfast_r50_4x16x1_256e_kinetics400_rgb.py'] model = dict(backbone=dict(resample_rate=4, speed_ratio=4, channel_ratio=8, slow_pathway=dict(fusion_kernel=7))) work_dir = './work_dirs/slowfast_r50_3d_8x8x1_256e_kinetics400_rgb'
""" Take a look at the code in the problem description where we test if a number is prime. Refactor the code and put it into the function below to turn the prime_generator() function into a generator. Implement your generator so that others can get a prime number generator like this: g = prime_generator(100) # g c...
""" Take a look at the code in the problem description where we test if a number is prime. Refactor the code and put it into the function below to turn the prime_generator() function into a generator. Implement your generator so that others can get a prime number generator like this: g = prime_generator(100) # g c...
# -*- coding: utf-8 -*- __all__ = ('safestr', 'strictstr') def safestr(data, encoding='utf8'): if isinstance(data, str): return data try: try: if isinstance(data, bytes): data = str(data, encoding, 'replace') else: data = str(data) except UnicodeError: data = repr(data) except Exception as...
__all__ = ('safestr', 'strictstr') def safestr(data, encoding='utf8'): if isinstance(data, str): return data try: try: if isinstance(data, bytes): data = str(data, encoding, 'replace') else: data = str(data) except UnicodeError: ...
f = open('input.txt', 'r') valid = 0 for line in f.readlines(): parts = line.strip().split() ranges = parts[0].split('-') minN = int(ranges[0]) maxN = int(ranges[1]) letter = parts[1].split(':')[0] password = parts[2] count = password.count(letter) print(minN, maxN, letter, password, co...
f = open('input.txt', 'r') valid = 0 for line in f.readlines(): parts = line.strip().split() ranges = parts[0].split('-') min_n = int(ranges[0]) max_n = int(ranges[1]) letter = parts[1].split(':')[0] password = parts[2] count = password.count(letter) print(minN, maxN, letter, password, c...
class TicTacToe: def __init__(self, n: int): """ Initialize your data structure here. """ self.n = n # self.board = [[0] * n for i in range(n)] # use an array of length 2n + 2 to represent the status of each player # 1st row for player 1, 2nd row for player 2...
class Tictactoe: def __init__(self, n: int): """ Initialize your data structure here. """ self.n = n self.status = [[0] * (2 * n + 2) for i in range(2)] def move(self, row: int, col: int, player: int) -> int: """ Player {player} makes a move at ({row}, {...
class LevelCodes: __parsedLevelCodes = None def __init__(self, path): file_io = open(path) raw_level_codes = file_io.readlines() self.__parsedLevelCodes = dict() for line in raw_level_codes: parsed = line.strip().split(" ") self.__parsedLevelCodes[int(par...
class Levelcodes: __parsed_level_codes = None def __init__(self, path): file_io = open(path) raw_level_codes = file_io.readlines() self.__parsedLevelCodes = dict() for line in raw_level_codes: parsed = line.strip().split(' ') self.__parsedLevelCodes[int(p...
class Item: def __init__(self, name="", id="", gender="", age="", birth="", constellation="", height="", weight="", size="", degree="", marriage="", occupational="", lives="", origin="", area="", payment="", serve_time="", language="", serve_type="", hobbits="", c...
class Item: def __init__(self, name='', id='', gender='', age='', birth='', constellation='', height='', weight='', size='', degree='', marriage='', occupational='', lives='', origin='', area='', payment='', serve_time='', language='', serve_type='', hobbits='', characteristic='', message=''): self.name = ...
''' Implementing Linked list data structure with respect to Sentinel element method. In this program Sentinel element will be a node which is called nil. For safe programming reasons, nil.val will be None which will return some exceptions if in any part of the program we want to compare it with another node...
""" Implementing Linked list data structure with respect to Sentinel element method. In this program Sentinel element will be a node which is called nil. For safe programming reasons, nil.val will be None which will return some exceptions if in any part of the program we want to compare it with another node...
# NEW # class Track: subjects = {}
class Track: subjects = {}
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
class Abstractextensionhandler: def on_instance_started_event(self): raise NotImplementedError def on_instance_activated_event(self): raise NotImplementedError def on_artifact_updated_event(self, artifacts_updated_event): raise NotImplementedError def on_artifact_update_sched...
# Code generated by font-to-py.py. # Font: digi_italic.ttf Char set: .0123456789: version = '0.26' def height(): return 30 def max_width(): return 23 def hmap(): return True def reverse(): return False def monospaced(): return False def min_ch(): return 32 def max_c...
version = '0.26' def height(): return 30 def max_width(): return 23 def hmap(): return True def reverse(): return False def monospaced(): return False def min_ch(): return 32 def max_ch(): return 63 _font = b'\x12\x00\x0f\xf8\x00\x1f\xfc\x00?\xfc\x00\x1f\xfb\x00\x00\x07\x00\x00\x07\x0...
class HttpMethod: GET = 'GET' POST = 'POST' PUT = 'PUT' DELETE = 'DELETE' class HttpStatusCode: HTTP_100_CONTINUE = 100 HTTP_101_SWITCHING_PROTOCOLS = 101 HTTP_200_OK = 200 HTTP_201_CREATED = 201 HTTP_202_ACCEPTED = 202 HTTP_203_NON_AUTHORITATIVE_INFORMATION = 203 HTTP_20...
class Httpmethod: get = 'GET' post = 'POST' put = 'PUT' delete = 'DELETE' class Httpstatuscode: http_100_continue = 100 http_101_switching_protocols = 101 http_200_ok = 200 http_201_created = 201 http_202_accepted = 202 http_203_non_authoritative_information = 203 http_204_n...
class Ball: def __init__(self): print("Ball is ready") def get_class_name(self): print("Ball") def play(self): print("Lets play ball") class BasketballBall(Ball): def __init__(self): # call super() function super().__init__() print("Basketball ball is ...
class Ball: def __init__(self): print('Ball is ready') def get_class_name(self): print('Ball') def play(self): print('Lets play ball') class Basketballball(Ball): def __init__(self): super().__init__() print('Basketball ball is ready') def get_class_name...
# Nested List a=[i for i in range(11)] b=[i for i in range(11,21)] c=[b,a] print(c) c.sort() print(c) # Sorting is done lexographically, i.e. the contents # of the nested list are not changed
a = [i for i in range(11)] b = [i for i in range(11, 21)] c = [b, a] print(c) c.sort() print(c)
# Optimized Solution # Time Complexity: O(n) | Space Complexity: O(n) def arrayOfProducts(array): resulting_lst = [1] * len(array) print("resulting_lst = ", resulting_lst) left_products_lst = [1] * len(array) print("left_products_lst = ", left_products_lst) right_products_lst = [1] * len(a...
def array_of_products(array): resulting_lst = [1] * len(array) print('resulting_lst = ', resulting_lst) left_products_lst = [1] * len(array) print('left_products_lst = ', left_products_lst) right_products_lst = [1] * len(array) print('right_products_lst = ', right_products_lst) left_running_...
def removeElement(nums, val): index = 0 for i in nums: if i == val: continue else: nums[index] = i index += 1 return index
def remove_element(nums, val): index = 0 for i in nums: if i == val: continue else: nums[index] = i index += 1 return index
### Sequence Equation - Solution def permutationEquation(p): arr = [0] * len(p) for i in range(1, len(p)+1): for j in range(1, len(p)+1): if p[p[j-1]-1] == i: arr[i-1] = j print(*arr, sep='\n') n = int(input()) p = tuple(map(int, input().split()[:n])) permutationEquatio...
def permutation_equation(p): arr = [0] * len(p) for i in range(1, len(p) + 1): for j in range(1, len(p) + 1): if p[p[j - 1] - 1] == i: arr[i - 1] = j print(*arr, sep='\n') n = int(input()) p = tuple(map(int, input().split()[:n])) permutation_equation(p)