content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
def count_circle_lattice_points(cx: int, cy: int, r: int, k: int) -> int: """ count up integer point (x, y) in the circle or on it. centered at (cx, cy) with radius r. and both x and y are multiple of k. """ assert r >= 0 and k >= 0 cx %= k cy %= k def is_ok(dx: int, dy: int) -> bo...
def count_circle_lattice_points(cx: int, cy: int, r: int, k: int) -> int: """ count up integer point (x, y) in the circle or on it. centered at (cx, cy) with radius r. and both x and y are multiple of k. """ assert r >= 0 and k >= 0 cx %= k cy %= k def is_ok(dx: int, dy: int) -> bo...
# TODO class ICM20948_SETTINGS(object): """ ICM20948 Settings class : param blabla: asfdasg : return: ICM20938 Settings object : rtype: Object """ def __init__(self): pass def parse_config_file(self, filepath): pass # Gyro fu...
class Icm20948_Settings(object): """ ICM20948 Settings class : param blabla: asfdasg : return: ICM20938 Settings object : rtype: Object """ def __init__(self): pass def parse_config_file(self, filepath): pass _gyroscope_sensitivity = {'25...
# Time: O(n) # Space: O(1) # 856 # Given a balanced parentheses string S, # compute the score of the string based on the following rule: # # () has score 1 # AB has score A + B, where A and B are balanced parentheses strings. # (A) has score 2 * A, where A is a balanced parentheses string. # # Example 1: # # Input: "...
try: xrange except NameError: xrange = range '\nCount Cores: USE THIS\nIntuition\nThe final sum will be a sum of powers of 2, as every core (a substring (), with score 1=2**0) will have\nit\'s score multiplied by 2 for each exterior set of parentheses that contains that core. The answer\nis the sum of these mul...
######################### # Custom Error Classes ######################### class LexerClass: def __init__(self,lexicon,ukToken): ''' Steps through rule strings searching for high-level rule string components. Searches for the following high-level tokens in order: ...
class Lexerclass: def __init__(self, lexicon, ukToken): """ Steps through rule strings searching for high-level rule string components. Searches for the following high-level tokens in order: - Reaction Token - Constraint Token - Entity Token...
#!/usr/bin/env python3 # Write a program that prints the reverse-complement of a DNA sequence # You must use a loop and conditional dna = 'ACTGAAAAAAAAAAA' r = dna[::-1] for i in range(len(r)): a = r[i] if a == 'A': print('T', end='') elif a == 'C': print('G', end='') elif a == 'T': print('A', end='') elif a =...
dna = 'ACTGAAAAAAAAAAA' r = dna[::-1] for i in range(len(r)): a = r[i] if a == 'A': print('T', end='') elif a == 'C': print('G', end='') elif a == 'T': print('A', end='') elif a == 'G': print('C', end='') '\npython3 23anti.py\nTTTTTTTTTTTCAGT\n'
def chooseformat(): print("1.) fnamelname") print("2.) fname.lname") print("3.) fname_lname") print("4.) finitlname") print("5.) finit.lname") print("6.) finit_lname") print("7.) fname") input("Choose a format to begin with: ")
def chooseformat(): print('1.) fnamelname') print('2.) fname.lname') print('3.) fname_lname') print('4.) finitlname') print('5.) finit.lname') print('6.) finit_lname') print('7.) fname') input('Choose a format to begin with: ')
info = { "UNIT_NUMBERS": { "nul": 0, "nulste": 0, "een": 1, "eerste": 1, "twee": 2, "tweede": 2, "derde": 3, "drie": 3, "vier": 4, "vijf": 5, "zes": 6, "zeven": 7, "acht": 8, "negen": 9 }, "DIRECT...
info = {'UNIT_NUMBERS': {'nul': 0, 'nulste': 0, 'een': 1, 'eerste': 1, 'twee': 2, 'tweede': 2, 'derde': 3, 'drie': 3, 'vier': 4, 'vijf': 5, 'zes': 6, 'zeven': 7, 'acht': 8, 'negen': 9}, 'DIRECT_NUMBERS': {'tien': 10, 'elf': 11, 'twaalf': 12, 'dertien': 13, 'veertien': 14, 'vijftien': 15, 'zestien': 16, 'zeventien': 17,...
class Director(object): def __init__(self, builder): self._builder = builder def build_computer(self): self._builder.new_computer() self._builder.get_case() self._builder.build_mainboard() self._builder.install_mainboard() self._builder.install_hard_dr...
class Director(object): def __init__(self, builder): self._builder = builder def build_computer(self): self._builder.new_computer() self._builder.get_case() self._builder.build_mainboard() self._builder.install_mainboard() self._builder.install_hard_drive() ...
#openfi #escape char in the olxlo produced file will need substitute at later date #for runtime on the second loop of instantiation self.populate dxpone = { "name":"dxpone", "refapione":"dxponeapione --- Hi and welcome to the text case scenario that will be used to insert \ towards a discord or something simil...
dxpone = {'name': 'dxpone', 'refapione': 'dxponeapione --- Hi and welcome to the text case scenario that will be used to insert \t\ttowards a discord or something similar to justify the text that will be written t it as an extsion \t\tfor demonstaration purposes that will become more prevelant in the future useages of ...
a=2 if a<0: print("the number is negative") if a>0: print("the numner is positive")
a = 2 if a < 0: print('the number is negative') if a > 0: print('the numner is positive')
class Item(): def __init__(self, name, description): # name and description self.name = name self.description = description def __str__(self): # print item's name and description return f"{self.name}: {self.description}"
class Item: def __init__(self, name, description): self.name = name self.description = description def __str__(self): return f'{self.name}: {self.description}'
#####1. Write e Python program to create e set. # e=set() # print(type(e)) #################################################### ####2. Write e Python program to iteration over sets. # e={'e','b','c','t'} # for i in e: # print(i) #################################################### ###3. Write e Python program t...
e = frozenset((358, 434, 53344, 33442, 423, 42)) print(e) e = {358, 434, 53344, 33442889, 423, 42, 42, 42} print(len(e))
# DFS class Solution(object): def isSymmetric(self, root): """ :type root: TreeNode :rtype: bool """ return self.check(root.left, root.right) def check(self, Node1, Node2): if Node1 == None and Node2 == None: return True if Node1 == None or N...
class Solution(object): def is_symmetric(self, root): """ :type root: TreeNode :rtype: bool """ return self.check(root.left, root.right) def check(self, Node1, Node2): if Node1 == None and Node2 == None: return True if Node1 == None or Node2 ...
""" ---> Minimum Insertions to Balance a Parentheses String ---> Medium """ class Solution: def minInsertions(self, s: str) -> int: open_brackets = 0 insertions_needed = 0 i = 0 while i < len(s): if s[i] == '(': open_brackets += 1 else: ...
""" ---> Minimum Insertions to Balance a Parentheses String ---> Medium """ class Solution: def min_insertions(self, s: str) -> int: open_brackets = 0 insertions_needed = 0 i = 0 while i < len(s): if s[i] == '(': open_brackets += 1 else: ...
######## # Copyright (c) 2020 Cloudify Platform Ltd. 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 requi...
dependency_creator = 'dependency_creator' source_deployment = 'source_deployment' target_deployment = 'target_deployment' target_deployment_func = 'target_deployment_func' external_source = 'external_source' external_target = 'external_target' def create_deployment_dependency(dependency_creator, source_deployment=None...
class IRCUser(object): def __init__(self, nick, ident, host, voice=False, op=False): self.nick = nick self.ident = ident self.host = host self.set_hostmask() self.is_voice = voice self.is_op = op def set_hostmask(self): self.hostmask = "%s@%s" % (sel...
class Ircuser(object): def __init__(self, nick, ident, host, voice=False, op=False): self.nick = nick self.ident = ident self.host = host self.set_hostmask() self.is_voice = voice self.is_op = op def set_hostmask(self): self.hostmask = '%s@%s' % (self.id...
## https://beginnersbook.com/2018/01/python-program-check-leap-year-or-not/ def is_leap_year(year): year = int(year); # Leap Year Check if year % 4 == 0 and year % 100 != 0: return True; elif year % 100 == 0: print(year, "is not a Leap Year") return False; elif year % 400 ...
def is_leap_year(year): year = int(year) if year % 4 == 0 and year % 100 != 0: return True elif year % 100 == 0: print(year, 'is not a Leap Year') return False elif year % 400 == 0: return True else: return False
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ########################################### # (c) 2016-2020 Polyvios Pratikakis # polyvios@ics.forth.gr ########################################### #__all__ = ['utils'] ''' empty '''
""" empty """
class Solution: def prisonAfterNDays(self, cells: List[int], N: int) -> List[int]: def nextDay(cells): mask = cells.copy() for i in range(1, len(cells) - 1): if mask[i-1] ^ mask[i+1] == 0: cells[i] = 1 else: ...
class Solution: def prison_after_n_days(self, cells: List[int], N: int) -> List[int]: def next_day(cells): mask = cells.copy() for i in range(1, len(cells) - 1): if mask[i - 1] ^ mask[i + 1] == 0: cells[i] = 1 else: ...
class Subject(object): def regist(self, observer): pass def unregist(self, observer): pass def notify(self): pass class Observer(object): def update(self): pass class MoniterObserver(Observer): def __init__(self, name): self.name = name def updat...
class Subject(object): def regist(self, observer): pass def unregist(self, observer): pass def notify(self): pass class Observer(object): def update(self): pass class Moniterobserver(Observer): def __init__(self, name): self.name = name def update(...
""" Dirty script to help generate go_ast code from an actual Go AST. Paste go code into https://lu4p.github.io/astextract/ and then the AST here. """ AST = r""" &ast.CallExpr { Fun: &ast.FuncLit { Type: &ast.FuncType { Params: &ast.FieldList { List: []*ast.Field { &ast.Field { ...
""" Dirty script to help generate go_ast code from an actual Go AST. Paste go code into https://lu4p.github.io/astextract/ and then the AST here. """ ast = '\n&ast.CallExpr {\n Fun: &ast.FuncLit {\n Type: &ast.FuncType {\n Params: &ast.FieldList {\n List: []*ast.Field {\n &ast.Field {\n ...
""" AERoot module """ __version__ = "0.3.2"
""" AERoot module """ __version__ = '0.3.2'
class CQueue: ''' Custom-made circular queue, which is fixed sized. The motivation here is to have * O(1) complexity for peeking the center part of the data In contrast, deque has O(n) complexity * O(1) complexity to sample from the queue (e.g., sampling replays) ''' def __...
class Cqueue: """ Custom-made circular queue, which is fixed sized. The motivation here is to have * O(1) complexity for peeking the center part of the data In contrast, deque has O(n) complexity * O(1) complexity to sample from the queue (e.g., sampling replays) """ def _...
load("@bazel_skylib//lib:collections.bzl", "collections") load("@bazel_skylib//lib:paths.bzl", "paths") load("@bazel_skylib//lib:shell.bzl", "shell") load("//fs_image/bzl/image_actions:feature.bzl", "image_feature") load("//fs_image/bzl/image_actions:install.bzl", "image_install") load("//fs_image/bzl/image_actions:mkd...
load('@bazel_skylib//lib:collections.bzl', 'collections') load('@bazel_skylib//lib:paths.bzl', 'paths') load('@bazel_skylib//lib:shell.bzl', 'shell') load('//fs_image/bzl/image_actions:feature.bzl', 'image_feature') load('//fs_image/bzl/image_actions:install.bzl', 'image_install') load('//fs_image/bzl/image_actions:mkd...
# This file is created by generate_build_files.py. Do not edit manually. test_support_sources = [ "src/crypto/test/file_test.cc", "src/crypto/test/test_util.cc", ] def create_tests(copts): test_support_sources_complete = test_support_sources + \ native.glob(["src/crypto/test/*.h"]) native.cc_test( ...
test_support_sources = ['src/crypto/test/file_test.cc', 'src/crypto/test/test_util.cc'] def create_tests(copts): test_support_sources_complete = test_support_sources + native.glob(['src/crypto/test/*.h']) native.cc_test(name='aes_test', size='small', srcs=['src/crypto/aes/aes_test.cc'] + test_support_sources_c...
# -*- coding: utf-8 -*- # try something like def index(): sync.go() return dict(message="hello from sync.py")
def index(): sync.go() return dict(message='hello from sync.py')
class Solution(object): def findDisappearedNumbers(self, nums): Out = [] N = set(nums) n = len(nums) for i in range(1, n+1): if i not in N: Out.append(i) return Out nums = [4,3,2,7,8,2,3,1] Object = Solution() print(Object.findDisappearedNumbers(nums))
class Solution(object): def find_disappeared_numbers(self, nums): out = [] n = set(nums) n = len(nums) for i in range(1, n + 1): if i not in N: Out.append(i) return Out nums = [4, 3, 2, 7, 8, 2, 3, 1] object = solution() print(Object.findDisappear...
# Copyright 2019 The Bazel Authors. 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 la...
"""Starlark transition support for Apple rules.""" def _cpu_string(platform_type, settings): """Generates a <platform>_<arch> string for the current target based on the given parameters.""" if platform_type == 'ios': ios_cpus = settings['//command_line_option:ios_multi_cpus'] if ios_cpus: ...
def matmul(a, b): c = [] for i in range(0, len(a)): c.append([]) for k in range(0, len(b[0])): num = 0 for j in range(0, len(a[0])): num += a[i][j]*b[j][k] c[i].append(num) return c def main(): a = [[1,2],[3,4],[5,6]] b = [[3,2,1]...
def matmul(a, b): c = [] for i in range(0, len(a)): c.append([]) for k in range(0, len(b[0])): num = 0 for j in range(0, len(a[0])): num += a[i][j] * b[j][k] c[i].append(num) return c def main(): a = [[1, 2], [3, 4], [5, 6]] b = [[...
class Path: def __init__(self, move_sequence): self.move_sequence = move_sequence def swap_cities(self, city1, city2): tmp = list(self.move_sequence) tmp[city1], tmp[city2] = tmp[city2], tmp[city1] return Path(tuple(tmp)) def __eq__(self, other): return self.move_se...
class Path: def __init__(self, move_sequence): self.move_sequence = move_sequence def swap_cities(self, city1, city2): tmp = list(self.move_sequence) (tmp[city1], tmp[city2]) = (tmp[city2], tmp[city1]) return path(tuple(tmp)) def __eq__(self, other): return self.mo...
split_data = lambda x: [[set(j) for j in i.split("\n")] for i in x] counter = lambda data, set_fn: sum(len(set_fn(*s)) for s in data) if __name__ == "__main__": with open("data.txt", "r") as file: data = split_data(file.read().strip().split("\n\n")) print("Part 1:", counter(data, set.union)) print...
split_data = lambda x: [[set(j) for j in i.split('\n')] for i in x] counter = lambda data, set_fn: sum((len(set_fn(*s)) for s in data)) if __name__ == '__main__': with open('data.txt', 'r') as file: data = split_data(file.read().strip().split('\n\n')) print('Part 1:', counter(data, set.union)) print...
class PathFinder(object): """ Abstract class for a path finder """ def __init__(self, config): # type: (Namespace, Stepper) -> None self.config = config def path(self, from_lat, form_lng, to_lat, to_lng): # pragma: no cover # type: (float, float, float, float) -> List[...
class Pathfinder(object): """ Abstract class for a path finder """ def __init__(self, config): self.config = config def path(self, from_lat, form_lng, to_lat, to_lng): raise NotImplementedError
class StickyNoteType(Enum, IComparable, IFormattable, IConvertible): """ Specifies whether a System.Windows.Controls.StickyNoteControl accepts text or ink. enum StickyNoteType,values: Ink (1),Text (0) """ def __eq__(self, *args): """ x.__eq__(y) <==> x==yx.__eq__(y) <==> x==yx.__eq__(y...
class Stickynotetype(Enum, IComparable, IFormattable, IConvertible): """ Specifies whether a System.Windows.Controls.StickyNoteControl accepts text or ink. enum StickyNoteType,values: Ink (1),Text (0) """ def __eq__(self, *args): """ x.__eq__(y) <==> x==yx.__eq__(y) <==> x==yx.__eq__(y) <==> x==...
class Solution: def moveZeroes(self, nums): """ :type nums: List[int] :rtype: void Do not return anything, modify nums in-place instead. """ length = len(nums) for i in range(0, length - 1): if nums[i] != 0: continue k = i ...
class Solution: def move_zeroes(self, nums): """ :type nums: List[int] :rtype: void Do not return anything, modify nums in-place instead. """ length = len(nums) for i in range(0, length - 1): if nums[i] != 0: continue k = i ...
def pig_latin(word): a={'a','e','i','o','u'} #make vowels case insensitive vowels=a|set(b.upper() for b in a) if word[0].isalpha(): if any(i in vowels for i in word): if word.isalnum(): if word[0] in vowels: pig_version=word+'way' ...
def pig_latin(word): a = {'a', 'e', 'i', 'o', 'u'} vowels = a | set((b.upper() for b in a)) if word[0].isalpha(): if any((i in vowels for i in word)): if word.isalnum(): if word[0] in vowels: pig_version = word + 'way' else: ...
# File: S (Python 2.4) NORMAL = 0 CUSTOM = 1 EMOTE = 2 PIRATES_QUEST = 3 TOONTOWN_QUEST = 4
normal = 0 custom = 1 emote = 2 pirates_quest = 3 toontown_quest = 4
public_key = b"\x30\x81\x9f\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00\x03\x81\x8d\x00\x30\x81\x89\x02\x81\x81\x00\xd9\x7a\xcd" + \ b"\x72\x88\xaa\x98\x10\xee\x43\x50\x98\x95\x42\x98\x2d\x4d\xd7\x2c\xd6\x49\x9d\x4e\x37\x97\x53\x7a\xd3\x94\x8c\x93\x70\x22\xf1\x00" + \ b"\x4b\x4...
public_key = b'0\x81\x9f0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x81\x8d\x000\x81\x89\x02\x81\x81\x00\xd9z\xcd' + b'r\x88\xaa\x98\x10\xeeCP\x98\x95B\x98-M\xd7,\xd6I\x9dN7\x97Sz\xd3\x94\x8c\x93p"\xf1\x00' + b'KJF\xca\xfc\x9c\xa5\x87\xa1\x90h\xb9\x04y\x1dj 1\xa2\xe9,\xb1Q\xb9S\xceX_\x9c\xd2\xfcA' + b'$\x98\xed\x...
#################################################### # Quiz: len, max, min, and Lists #################################################### a = [1, 5, 8] b = [2, 6, 9, 10] c = [100, 200] print(max([len(a), len(b), len(c)])) # 4 print(min([len(a), len(b), len(c)])) # 2 ################################################...
a = [1, 5, 8] b = [2, 6, 9, 10] c = [100, 200] print(max([len(a), len(b), len(c)])) print(min([len(a), len(b), len(c)])) names = ['Carol', 'Albert', 'Ben', 'Donna'] print(' & '.join(sorted(names))) names.append('Eugenia') print(sorted(names))
OPCODE = { "add": 0, "comp": 0, "and": 0, "xor": 0, "shll": 0, "shrl": 0, "shllv": 0, "shrlv": 0, "shra": 0, "shrav": 0, "addi": 8, "compi": 9, "lw": 16, "sw": 24, "b": 40, "br": 32, "bltz": 48, "bz": 49, "bnz": 50, "bl": 43, "bcy": 41, "bncy": 42, } RFORMATS = { "add",...
opcode = {'add': 0, 'comp': 0, 'and': 0, 'xor': 0, 'shll': 0, 'shrl': 0, 'shllv': 0, 'shrlv': 0, 'shra': 0, 'shrav': 0, 'addi': 8, 'compi': 9, 'lw': 16, 'sw': 24, 'b': 40, 'br': 32, 'bltz': 48, 'bz': 49, 'bnz': 50, 'bl': 43, 'bcy': 41, 'bncy': 42} rformats = {'add', 'comp', 'and', 'xor', 'shll', 'shrl', 'shllv', 'shrlv...
moves = open('input/day3-input.txt', 'r').read() visited = set() location = (0,0) visited.add(location) for move in moves: if move == '^': location = (location[0], location[1] + 1) elif move == 'v': location = (location[0], location[1] - 1) elif move == '>': location = (location[0] + 1, location[1])...
moves = open('input/day3-input.txt', 'r').read() visited = set() location = (0, 0) visited.add(location) for move in moves: if move == '^': location = (location[0], location[1] + 1) elif move == 'v': location = (location[0], location[1] - 1) elif move == '>': location = (location[0] ...
def z3(): global bimage_mean, bimage_peak_fine, cell_dir, frame_i, nthread nthread = 1 # load plane filename for frame_i in range(imageframe_nmbr): with h5py.File(output_dir + 'brain_mask' + str(frame_i) + '.hdf5', 'r') as file_handle: image_mean = file_handle['image_mean'][()]....
def z3(): global bimage_mean, bimage_peak_fine, cell_dir, frame_i, nthread nthread = 1 for frame_i in range(imageframe_nmbr): with h5py.File(output_dir + 'brain_mask' + str(frame_i) + '.hdf5', 'r') as file_handle: image_mean = file_handle['image_mean'][()].T brain_mask = file...
__all__ = ['AverageMeter', 'get_error', 'print_numbers_acc'] class AverageMeter(object): """Computes and stores the average and current value Imported from https://github.com/pytorch/examples/blob/master/imagenet/main.py#L247-L262 """ def __init__(self): self.reset() def rese...
__all__ = ['AverageMeter', 'get_error', 'print_numbers_acc'] class Averagemeter(object): """Computes and stores the average and current value Imported from https://github.com/pytorch/examples/blob/master/imagenet/main.py#L247-L262 """ def __init__(self): self.reset() def reset(self): ...
# -*- coding: utf-8 -*- """ Created on Thu Apr 25 17:52:09 2019 @author: Falble """ def has_duplicates(t): """Checks whether any element appears more than once in a sequence. Simple version using a for loop. t: sequence """ d = {} for x in t: if x in d: retur...
""" Created on Thu Apr 25 17:52:09 2019 @author: Falble """ def has_duplicates(t): """Checks whether any element appears more than once in a sequence. Simple version using a for loop. t: sequence """ d = {} for x in t: if x in d: return True d[x] = True return F...
def get_virus_areas(grid): areas = [] dangers = [] walls = [] color = [[0] * n for i in range(m)] for i in range(m): for j in range(n): if grid[i][j] == 1 and color[i][j] == 0: area = [(i, j)] danger = set() wall = 0 ...
def get_virus_areas(grid): areas = [] dangers = [] walls = [] color = [[0] * n for i in range(m)] for i in range(m): for j in range(n): if grid[i][j] == 1 and color[i][j] == 0: area = [(i, j)] danger = set() wall = 0 ...
target = df_data_card.columns[0] class_inputs = list(df_data_card.select_dtypes(include=['object']).columns) # impute data df_data_card = df_data_card.fillna(df_data_card.median()) df_data_card['JOB'] = df_data_card.JOB.fillna('Other') # dummy the categorical variables df_data_card_ABT = pd.concat([df_data_card, pd.g...
target = df_data_card.columns[0] class_inputs = list(df_data_card.select_dtypes(include=['object']).columns) df_data_card = df_data_card.fillna(df_data_card.median()) df_data_card['JOB'] = df_data_card.JOB.fillna('Other') df_data_card_abt = pd.concat([df_data_card, pd.get_dummies(df_data_card[class_inputs])], axis=1).d...
#!/usr/bin/env python3 CENT_PER_INCH = 2.54 height_feet = int(input('Enter the "feet" part of your height: ')) height_inches = int(input('Enter the "inches" part of your height: ')) total_height_inches = height_feet * 12 + height_inches total_cent = total_height_inches * CENT_PER_INCH print(f"Your height of {heigh...
cent_per_inch = 2.54 height_feet = int(input('Enter the "feet" part of your height: ')) height_inches = int(input('Enter the "inches" part of your height: ')) total_height_inches = height_feet * 12 + height_inches total_cent = total_height_inches * CENT_PER_INCH print(f"Your height of {height_feet}'{height_inches} is {...
# Copyright 2013 Google, Inc. All Rights Reserved. # # Google Author(s): Behdad Esfahbod, Roozbeh Pournader class Options(object): class UnknownOptionError(Exception): pass def __init__(self, **kwargs): self.verbose = False self.timing = False self.drop_tables = [] self.set(**kwargs) def set(self, *...
class Options(object): class Unknownoptionerror(Exception): pass def __init__(self, **kwargs): self.verbose = False self.timing = False self.drop_tables = [] self.set(**kwargs) def set(self, **kwargs): for (k, v) in kwargs.items(): if not hasatt...
def remove_void(lst:list): return list(filter(None, lst)) def remove_double_back(string:str): string.replace("\n\n","@@@@@").replace("\n","").replace("@@@@@","") def pretty_print(dct:dict): for val,key in dct.items(): print(val) for el in key: print("\t",el) print("\n")
def remove_void(lst: list): return list(filter(None, lst)) def remove_double_back(string: str): string.replace('\n\n', '@@@@@').replace('\n', '').replace('@@@@@', '') def pretty_print(dct: dict): for (val, key) in dct.items(): print(val) for el in key: print('\t', el) p...
n=int(input()) for i in range(1,n+1): for j in range(1,i+1): print(j,end="") print() for i in range(1,n): for j in range(n-i): print(j+1,end="") print()
n = int(input()) for i in range(1, n + 1): for j in range(1, i + 1): print(j, end='') print() for i in range(1, n): for j in range(n - i): print(j + 1, end='') print()
# # PySNMP MIB module HUAWEI-UNIMNG-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-UNIMNG-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:37:33 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Ma...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, single_value_constraint, value_size_constraint, value_range_constraint, constraints_union) ...
def kill_timer(timer): timer.cancel() def init(): global timeout_add global timeout_end timeout_add = pyjd.gobject.timeout_add timeout_end = kill_timer
def kill_timer(timer): timer.cancel() def init(): global timeout_add global timeout_end timeout_add = pyjd.gobject.timeout_add timeout_end = kill_timer
#!/usr/bin/python3 class _LockCtx(object): __slots__ = ( "__evt", "__bPreventFiringOnUnlock" ) def __init__(self, evt, bPreventFiringOnUnlock:bool = False): self.__evt = evt self.__bPreventFiringOnUnlock = bPreventFiringOnUnlock # def dump(self): print("_LockCtx(") print("\t__evt = " + str(self.__evt...
class _Lockctx(object): __slots__ = ('__evt', '__bPreventFiringOnUnlock') def __init__(self, evt, bPreventFiringOnUnlock: bool=False): self.__evt = evt self.__bPreventFiringOnUnlock = bPreventFiringOnUnlock def dump(self): print('_LockCtx(') print('\t__evt = ' + str(self.__...
class FaultyClient(object): """A faulty scheduler that will always fail""" def __init__(self, cluster_name, hosts, auth, domain, options): pass def setUp(self): pass def tearDown(self): pass def create(self, name, image, command='', template=None, port=5000): rais...
class Faultyclient(object): """A faulty scheduler that will always fail""" def __init__(self, cluster_name, hosts, auth, domain, options): pass def set_up(self): pass def tear_down(self): pass def create(self, name, image, command='', template=None, port=5000): ra...
datasetPath = "/storage/mstrobl/dataset" waveformPath = "/storage/mstrobl/waveforms" featurePath = "/storage/mstrobl/features/" quantumPath = "/storage/mstrobl/quantum/" modelsPath = "/storage/mstrobl/models" testDatasetPath = "/storage/mstrobl/testDataset" testWaveformPath = "/storage/mstrobl/testWaveforms" testFeatu...
dataset_path = '/storage/mstrobl/dataset' waveform_path = '/storage/mstrobl/waveforms' feature_path = '/storage/mstrobl/features/' quantum_path = '/storage/mstrobl/quantum/' models_path = '/storage/mstrobl/models' test_dataset_path = '/storage/mstrobl/testDataset' test_waveform_path = '/storage/mstrobl/testWaveforms' t...
def one_line(): output = [] with open("toChris.txt", "r") as f: line = f.readline() counter = 0 temp = [] while line: if "{" in line: counter += 1 elif "}" in line: counter -= 1 temp.append(line) if...
def one_line(): output = [] with open('toChris.txt', 'r') as f: line = f.readline() counter = 0 temp = [] while line: if '{' in line: counter += 1 elif '}' in line: counter -= 1 temp.append(line) if c...
class Solution(object): def fib(self, N): """ :type N: int :rtype: int """ return self.dynamicProgramming(N) def recursive(self, N): if N <= 1: return N else: return self.recursive(N - 1) + self.recursive(N - 2) def dynami...
class Solution(object): def fib(self, N): """ :type N: int :rtype: int """ return self.dynamicProgramming(N) def recursive(self, N): if N <= 1: return N else: return self.recursive(N - 1) + self.recursive(N - 2) def dynamic_p...
""" # Sample code to perform I/O: name = input() # Reading input from STDIN print('Hi, %s.' % name) # Writing output to STDOUT # Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail """ # Write your code here t = int(input()) for _ in range(t): n =...
""" # Sample code to perform I/O: name = input() # Reading input from STDIN print('Hi, %s.' % name) # Writing output to STDOUT # Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail """ t = int(input()) for _ in range(t): n = int(input()) s = in...
def fib(a, b, end): c = 0 fib_list = [a, b] if end == 0: return fib_list while c < end: nxt = fib_list[c] + fib_list[c + 1] fib_list.append(nxt) c += 1 if nxt >= end: break return fib_list def fib_memo(n): """ uses memoization to reduce c...
def fib(a, b, end): c = 0 fib_list = [a, b] if end == 0: return fib_list while c < end: nxt = fib_list[c] + fib_list[c + 1] fib_list.append(nxt) c += 1 if nxt >= end: break return fib_list def fib_memo(n): """ uses memoization to reduce ca...
"""Wide_Eastasian table. Created by setup.py.""" # Generated: 2016-07-02T04:20:28.048222 # Source: EastAsianWidth-9.0.0.txt # Date: 2016-05-27, 17:00:00 GMT [KW, LI] WIDE_EASTASIAN = ( (0x1100, 0x115f,), # Hangul Choseong Kiyeok ..Hangul Choseong Filler (0x231a, 0x231b,), # Watch ..H...
"""Wide_Eastasian table. Created by setup.py.""" wide_eastasian = ((4352, 4447), (8986, 8987), (9001, 9002), (9193, 9196), (9200, 9200), (9203, 9203), (9725, 9726), (9748, 9749), (9800, 9811), (9855, 9855), (9875, 9875), (9889, 9889), (9898, 9899), (9917, 9918), (9924, 9925), (9934, 9934), (9940, 9940), (9962, 9962), (...
#!/usr/bin/python # -*- coding: utf-8 -*- ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = r''' module: win_dfs_namespace_root short_description: Set up a DFS namespace. description: - This module creates/man...
ansible_metadata = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} documentation = "\nmodule: win_dfs_namespace_root\nshort_description: Set up a DFS namespace.\n\ndescription:\n - This module creates/manages Windows DFS namespaces.\n - Prior to using this module it's required to insta...
# # PySNMP MIB module CISCO-RTTMON-IP-EXT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-RTTMON-IP-EXT-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:11:15 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 ...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, single_value_constraint, constraints_intersection, constraints_union, value_range_constraint) ...
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Copyright 2020, Yutong Xie, UIUC. Using random index to shuffle an array ''' class Solution(object): def search(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ l, r = 0, len(...
""" Copyright 2020, Yutong Xie, UIUC. Using random index to shuffle an array """ class Solution(object): def search(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ (l, r) = (0, len(nums) - 1) while l <= r: ...
#!/usr/bin/env python # -*- coding: utf-8 -*- # This software is under a BSD license. See LICENSE.txt for details. def dt_writer(obj): """Check to ensure conformance to dt_writer protocol. :returns: ``True`` if the object implements the required methods """ return hasattr(obj, "__dt_type__"...
def dt_writer(obj): """Check to ensure conformance to dt_writer protocol. :returns: ``True`` if the object implements the required methods """ return hasattr(obj, '__dt_type__') and hasattr(obj, '__dt_write__') class Dtpywrite(object): """Class documenting methods that must be implemented...
# # PySNMP MIB module Argus-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Argus-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:33:18 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, constraints_union, value_size_constraint, constraints_intersection) ...
""" Transparent class proxy module. A wrapper class can be created using the function `wrap_with` or the decorators `proxy_of` (if the wrapped object type is specified explicitly) or `proxy` (if the wrapped object isn't specified). """ __all__ = ["wrap_with", "proxy_of", "proxy", "instance", "reset_proxy_cache"] IGNO...
""" Transparent class proxy module. A wrapper class can be created using the function `wrap_with` or the decorators `proxy_of` (if the wrapped object type is specified explicitly) or `proxy` (if the wrapped object isn't specified). """ __all__ = ['wrap_with', 'proxy_of', 'proxy', 'instance', 'reset_proxy_cache'] ignor...
def sum(str1: str, str2: str) -> str: """ Find the sum of two numbers represented as strings. Args: str1 - string: number str2 - string: number Returns - string: The result sum """ print("str1=" + str(str1) + ", str2=" + str(str2)) if not str1.isdigit() or not str2.isdigit...
def sum(str1: str, str2: str) -> str: """ Find the sum of two numbers represented as strings. Args: str1 - string: number str2 - string: number Returns - string: The result sum """ print('str1=' + str(str1) + ', str2=' + str(str2)) if not str1.isdigit() or not str2.isdigit()...
""" Auth app testing package. """ __author__ = "William Tucker" __date__ = "2020-03-25" __copyright__ = "Copyright 2020 United Kingdom Research and Innovation" __license__ = "BSD - see LICENSE file in top-level package directory"
""" Auth app testing package. """ __author__ = 'William Tucker' __date__ = '2020-03-25' __copyright__ = 'Copyright 2020 United Kingdom Research and Innovation' __license__ = 'BSD - see LICENSE file in top-level package directory'
parrot = "Norwegian Blue" print(parrot) print(parrot[3]) print(parrot[4]) print(parrot[9]) print(parrot[3]) print(parrot[6]) print(parrot[8])
parrot = 'Norwegian Blue' print(parrot) print(parrot[3]) print(parrot[4]) print(parrot[9]) print(parrot[3]) print(parrot[6]) print(parrot[8])
def bool_prompt(msg: str) -> bool: while True: response = input(f"{msg} [y/n]: ").lower() if response == "y": return True elif response == "n": return False else: print(f"'{response}' is an invalid option.")
def bool_prompt(msg: str) -> bool: while True: response = input(f'{msg} [y/n]: ').lower() if response == 'y': return True elif response == 'n': return False else: print(f"'{response}' is an invalid option.")
class node_values: def __init__(self, iden, value): self.iden = iden self.value = value def get_iden(self): return self.iden def set_iden(self, iden): self.iden = iden def get_value(self): return self.value def set_value(self, value): self.value = ...
class Node_Values: def __init__(self, iden, value): self.iden = iden self.value = value def get_iden(self): return self.iden def set_iden(self, iden): self.iden = iden def get_value(self): return self.value def set_value(self, value): self.value =...
class Person: def __init__(self, first_name, last_name): self.first = first_name self.last = last_name def speak(self): print("My name is "+ self.first+" "+self.last) me = Person("Brandon", "Walsh") you = Person("Ethan", "Reed") me.speak() you.speak()
class Person: def __init__(self, first_name, last_name): self.first = first_name self.last = last_name def speak(self): print('My name is ' + self.first + ' ' + self.last) me = person('Brandon', 'Walsh') you = person('Ethan', 'Reed') me.speak() you.speak()
"""Top-level package for Threaded File Downloader.""" __author__ = """Andy Jackson""" __email__ = 'amjack100@gmail.com' __version__ = '0.1.0'
"""Top-level package for Threaded File Downloader.""" __author__ = 'Andy Jackson' __email__ = 'amjack100@gmail.com' __version__ = '0.1.0'
def minRemove(arr, n): LIS = [0 for i in range(n)] len = 0 for i in range(n): LIS[i] = 1 for i in range(1, n): for j in range(i): if (arr[i] > arr[j] and (i - j) <= (arr[i] - arr[j])): LIS[i] = max(LIS[i], LIS[j] + 1) len = max(len, LIS[i]) return ...
def min_remove(arr, n): lis = [0 for i in range(n)] len = 0 for i in range(n): LIS[i] = 1 for i in range(1, n): for j in range(i): if arr[i] > arr[j] and i - j <= arr[i] - arr[j]: LIS[i] = max(LIS[i], LIS[j] + 1) len = max(len, LIS[i]) return n - l...
# -*- coding:utf-8 -*- ''' For example, the number 7 is a "happy" number: 72 = 49 --> 42 + 92 = 97 --> 92 + 72 = 130 --> 12 + 32 + 02 = 10 --> 12 + 02 = 1 Once the sequence reaches the number 1, it will stay there forever since 12 = 1 On the other hand, the number 6 is not a happy number as the sequence th...
""" For example, the number 7 is a "happy" number: 72 = 49 --> 42 + 92 = 97 --> 92 + 72 = 130 --> 12 + 32 + 02 = 10 --> 12 + 02 = 1 Once the sequence reaches the number 1, it will stay there forever since 12 = 1 On the other hand, the number 6 is not a happy number as the sequence that is generated is the following:...
k, a, b = map(int, input().split()) if a + 1 >= b: print(k + 1) else: if k != 1: t = (k - 2) % a w = (k - 2) // a i = b % a j = b // a """if t == a - 1: print(b * (w + 1)) else: print(b * w + t)""" #p = ((k + 1) // (a + 2)) * (a +...
(k, a, b) = map(int, input().split()) if a + 1 >= b: print(k + 1) elif k != 1: t = (k - 2) % a w = (k - 2) // a i = b % a j = b // a 'if t == a - 1:\n print(b * (w + 1))\n else:\n print(b * w + t)' else: print(2)
""" Validate a Requirements Trace Matrix """ __version__ = "0.1.13"
""" Validate a Requirements Trace Matrix """ __version__ = '0.1.13'
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2019, Carson Anderson <rcanderson23@gmail.com> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # this is a windows documentation stub. actual code lives in the .ps1 # file of the same name ANSIBLE_METADATA = {'me...
ansible_metadata = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} documentation = '\n---\nmodule: win_optional_feature\nversion_added: "2.8"\nshort_description: Manage optional Windows features\ndescription:\n - Install or uninstall optional Windows features on non-Server Windows.\n ...
def arraycopy(ar): ret=[] for item in ar: ret.append(item) return ret def subtAr(a1,a2): ret=[] for i in range(0,len(a1)): ret.append(a1[i]-a2[i]) return ret def sumAr(a1,a2): ret=[] for i in range(0,len(a1)): ret.append(a1[i]+a2[i]) return ret def abs2Ar(a...
def arraycopy(ar): ret = [] for item in ar: ret.append(item) return ret def subt_ar(a1, a2): ret = [] for i in range(0, len(a1)): ret.append(a1[i] - a2[i]) return ret def sum_ar(a1, a2): ret = [] for i in range(0, len(a1)): ret.append(a1[i] + a2[i]) return r...
a = input () b = input () c=a a=b b=c print (a, b)
a = input() b = input() c = a a = b b = c print(a, b)
class Bird: def about(self): print("Species: Bird") def Dance(self): print("Not all but some birds can dance") class Peacock(Bird): def Dance(self): print("Peacock can dance") class Sparrow(Bird): def Dance(self): print("Sparrow can't dance")
class Bird: def about(self): print('Species: Bird') def dance(self): print('Not all but some birds can dance') class Peacock(Bird): def dance(self): print('Peacock can dance') class Sparrow(Bird): def dance(self): print("Sparrow can't dance")
def quickSort(alist, first, last): if (first < last): splitpoint = partition(alist, first, last) quickSort(alist, first, splitpoint - 1) quickSort(alist, splitpoint + 1, last) def partition(alist, first, last): pivotvalue = alist[first] leftmark = first +1 rightmark = ...
def quick_sort(alist, first, last): if first < last: splitpoint = partition(alist, first, last) quick_sort(alist, first, splitpoint - 1) quick_sort(alist, splitpoint + 1, last) def partition(alist, first, last): pivotvalue = alist[first] leftmark = first + 1 rightmark = last ...
def lcsv(str_or_list): ''' List of Comma-Separated Values. Convert a str of comma-separated values to a list over the items, or convert such a list back to a comma-separated string. This function does not understand quotes. See the unit tests for examples of how ``lcsv`` works. ''' if isi...
def lcsv(str_or_list): """ List of Comma-Separated Values. Convert a str of comma-separated values to a list over the items, or convert such a list back to a comma-separated string. This function does not understand quotes. See the unit tests for examples of how ``lcsv`` works. """ if isi...
# # PySNMP MIB module PDN-XDSL-INTERFACE-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/PDN-XDSL-INTERFACE-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:31:00 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (d...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, value_size_constraint, constraints_intersection, constraints_union) ...
def _FindNonRepeat(_InputString, chars): count = 0 _NonRepeat = {} for i in chars: count = _InputString.count(i) if count > 1: print(count,i) if count == 1: _NonRepeat[count] = i #print(_NonRepeat) return(_NonRepeat) def _FindNonRepeat2(...
def __find_non_repeat(_InputString, chars): count = 0 __non_repeat = {} for i in chars: count = _InputString.count(i) if count > 1: print(count, i) if count == 1: _NonRepeat[count] = i return _NonRepeat def __find_non_repeat2(_InputString, chars): ret...
a=[1,2,3,4,5] a=a[::-1] print (a) a=[1,1,2,2,2,2,3,3,3] b=2 print(a.count(b)) a='ana are mere si nu are pere' b=a.split() c=len(b) print(c)
a = [1, 2, 3, 4, 5] a = a[::-1] print(a) a = [1, 1, 2, 2, 2, 2, 3, 3, 3] b = 2 print(a.count(b)) a = 'ana are mere si nu are pere' b = a.split() c = len(b) print(c)
""" LeetCode Problem: 107. Binary Tree Level Order Traversal II Link: https://leetcode.com/problems/binary-tree-level-order-traversal-ii/ Language: Python Written by: Mostofa Adib Shakib Time Complexity: O(N) Space Complexity: O(N) """ class Solution: def levelOrderBottom(self, root: TreeNode) -> List[List[int]]:...
""" LeetCode Problem: 107. Binary Tree Level Order Traversal II Link: https://leetcode.com/problems/binary-tree-level-order-traversal-ii/ Language: Python Written by: Mostofa Adib Shakib Time Complexity: O(N) Space Complexity: O(N) """ class Solution: def level_order_bottom(self, root: TreeNode) -> List[List[int...
class ContactHelper: def __init__(self, app): self.app = app def create(self, contact): wd = self.app.wd wd.find_element_by_link_text("add new").click() wd.find_element_by_name("firstname").click() wd.find_element_by_name("firstname").clear() wd.find_element_by...
class Contacthelper: def __init__(self, app): self.app = app def create(self, contact): wd = self.app.wd wd.find_element_by_link_text('add new').click() wd.find_element_by_name('firstname').click() wd.find_element_by_name('firstname').clear() wd.find_element_by_...
""" 215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 21000? """ number = 2**1000 string = str(number) sum = 0 for c in string: sum = sum + int(c) print("the sum of the digits of the number 2e1000: %s" % sum)
""" 215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 21000? """ number = 2 ** 1000 string = str(number) sum = 0 for c in string: sum = sum + int(c) print('the sum of the digits of the number 2e1000: %s' % sum)
FAST_NULL = 0x000 FAST_NOON = 0x201 FAST_SUNSET = 0x202 FAST_MOONRISE = 0x203 FAST_DUSK = 0x204 FAST_MIDNIGHT = 0x205 FAST_EKADASI = 0x206 FAST_DAY = 0x207
fast_null = 0 fast_noon = 513 fast_sunset = 514 fast_moonrise = 515 fast_dusk = 516 fast_midnight = 517 fast_ekadasi = 518 fast_day = 519
memo = {1: 1, 2: 2, 3: 4} def climb(n): if n == 1: return 1 elif n == 2: return 2 elif n == 3: return 4 else: c = 0 for i in [1, 2, 3]: t = memo.get(n - i) if not t: memo[n - 1] = climb(n - 1) c += memo.get(n...
memo = {1: 1, 2: 2, 3: 4} def climb(n): if n == 1: return 1 elif n == 2: return 2 elif n == 3: return 4 else: c = 0 for i in [1, 2, 3]: t = memo.get(n - i) if not t: memo[n - 1] = climb(n - 1) c += memo.get(n - ...
# pylint: skip-file computing.ubm_training_workers = 8 computing.ivector_dataloader_workers = 22 computing.feature_extraction_workers = 22 computing.use_gpu = True computing.gpu_ids = (0,) paths.output_folder = '/media/ssd2/vvestman/sitw_ivector_outputs' paths.feature_and_list_folder = 'datasets' # No need to update...
computing.ubm_training_workers = 8 computing.ivector_dataloader_workers = 22 computing.feature_extraction_workers = 22 computing.use_gpu = True computing.gpu_ids = (0,) paths.output_folder = '/media/ssd2/vvestman/sitw_ivector_outputs' paths.feature_and_list_folder = 'datasets' paths.kaldi_recipe_folder = '/media/hdd2/v...
numbers = [111, 7, 2, 1] print(len(numbers)) print(numbers) ### numbers.append(4) print(len(numbers)) print(numbers) ### numbers.insert(0, 222) print(len(numbers)) print(numbers) # my_list = [] # Creating an empty list. for i in range(5): my_list.append(i + 1) print(my_list) my_list = [] # Creating an ...
numbers = [111, 7, 2, 1] print(len(numbers)) print(numbers) numbers.append(4) print(len(numbers)) print(numbers) numbers.insert(0, 222) print(len(numbers)) print(numbers) my_list = [] for i in range(5): my_list.append(i + 1) print(my_list) my_list = [] for i in range(5): my_list.insert(0, i + 1) print(my_list) ...
# -*- coding: utf-8 -*- ICX_TO_LOOP = 10 ** 18 LOOP_TO_ISCORE = 1000 def icx(value: int) -> int: return value * ICX_TO_LOOP def loop_to_str(value: int) -> str: if value == 0: return "0" sign: str = "-" if value < 0 else "" integer, exponent = divmod(abs(value), ICX_TO_LOOP) if exponent...
icx_to_loop = 10 ** 18 loop_to_iscore = 1000 def icx(value: int) -> int: return value * ICX_TO_LOOP def loop_to_str(value: int) -> str: if value == 0: return '0' sign: str = '-' if value < 0 else '' (integer, exponent) = divmod(abs(value), ICX_TO_LOOP) if exponent == 0: return f'{s...
# http://codeforces.com/problemset/problem/34/A n = int(input()) heights = [int(x) for x in input().split()] soldiers = [x for x in range(1, n + 1)] heights.append(heights[0]) soldiers.append(soldiers[0]) first_min = 0 second_min = 0 difference_min = 999999999999999999999999 for i in range(len(height...
n = int(input()) heights = [int(x) for x in input().split()] soldiers = [x for x in range(1, n + 1)] heights.append(heights[0]) soldiers.append(soldiers[0]) first_min = 0 second_min = 0 difference_min = 999999999999999999999999 for i in range(len(heights) - 1): difference = abs(heights[i] - heights[i + 1]) if d...
# return n * (n+1) / 2 with open('./input', encoding='utf8') as file: coord_strs = file.readline().strip()[12:].split(', ') x_range = [int(val) for val in coord_strs[0].split('=')[1].split('..')] y_range = [int(val) for val in coord_strs[1].split('=')[1].split('..')] y_speed = abs(y_range[0])-1 print(y_s...
with open('./input', encoding='utf8') as file: coord_strs = file.readline().strip()[12:].split(', ') x_range = [int(val) for val in coord_strs[0].split('=')[1].split('..')] y_range = [int(val) for val in coord_strs[1].split('=')[1].split('..')] y_speed = abs(y_range[0]) - 1 print(y_speed * (y_speed + 1) / 2...
DEFAULT_CELERY_BROKER_LOGIN_METHOD = 'AMQPLAIN' DEFAULT_CELERY_BROKER_URL = None DEFAULT_CELERY_BROKER_USE_SSL = None DEFAULT_CELERY_RESULT_BACKEND = None
default_celery_broker_login_method = 'AMQPLAIN' default_celery_broker_url = None default_celery_broker_use_ssl = None default_celery_result_backend = None
A, B ,C= map(int, input().split()) D=int(input()) C+=D if C>59: B+=C//60 C=C%60 if B>59: A+=B//60 B=B%60 if A>23: A=A%24 print(A,B,C) else: print(A,B,C) else: print(A,B,C) else: print(A,B,C)
(a, b, c) = map(int, input().split()) d = int(input()) c += D if C > 59: b += C // 60 c = C % 60 if B > 59: a += B // 60 b = B % 60 if A > 23: a = A % 24 print(A, B, C) else: print(A, B, C) else: print(A, B, C) else: print(A...
def makeprefixsum(nums): prefixsum = [0] * (len(nums) + 1) for i in range(1, len(nums)+1): prefixsum[i] = prefixsum[i-1] + nums[i-1] return prefixsum def rsq(prefixsum, l, r): # Range Sum Query return prefixsum[r] - prefixsum[l] def countzeroes(nums, l, r): cnt = 0 # complexity O(NM) N ...
def makeprefixsum(nums): prefixsum = [0] * (len(nums) + 1) for i in range(1, len(nums) + 1): prefixsum[i] = prefixsum[i - 1] + nums[i - 1] return prefixsum def rsq(prefixsum, l, r): return prefixsum[r] - prefixsum[l] def countzeroes(nums, l, r): cnt = 0 for i in range(i, r): if...
number_of_nice_strings=0 with open("input.txt") as input: for line in input: line=line.rstrip() #chack vowels num_of_vowels=0 vowels=["a","e","i","o","u"] vowels_dict={} for vowel in vowels: if vowel in line: vowels_dict[vowel] = line.coun...
number_of_nice_strings = 0 with open('input.txt') as input: for line in input: line = line.rstrip() num_of_vowels = 0 vowels = ['a', 'e', 'i', 'o', 'u'] vowels_dict = {} for vowel in vowels: if vowel in line: vowels_dict[vowel] = line.count(vowel) ...
# -*- coding: utf-8 -*- """ Created on Tue Apr 12 13:06:05 2022 @author: Pedro """ #%% ejercicio 2 def a_count(string1: str) -> int: counter = 0 for i in string1: t = i.lower() if t == "a": counter += 1 return counter #%%ejercicio 5 def ip_colmillos(ip: st...
""" Created on Tue Apr 12 13:06:05 2022 @author: Pedro """ def a_count(string1: str) -> int: counter = 0 for i in string1: t = i.lower() if t == 'a': counter += 1 return counter def ip_colmillos(ip: str) -> str: ip = ip.split('.') return '[.]'.join(ip) def finding_joy...