content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
img_size = (992, 736) img_norm_cfg = dict(mean=[0, 0, 0], std=[255, 255, 255], to_rgb=True) train_pipeline = [ dict(type='LoadImageFromFile'), dict(type='LoadAnnotations', with_bbox=True), dict( type='MinIoURandomCrop', min_ious=(0.1, 0.3, 0.5, 0.7, 0.9), min_crop_size=0.3), dic...
img_size = (992, 736) img_norm_cfg = dict(mean=[0, 0, 0], std=[255, 255, 255], to_rgb=True) train_pipeline = [dict(type='LoadImageFromFile'), dict(type='LoadAnnotations', with_bbox=True), dict(type='MinIoURandomCrop', min_ious=(0.1, 0.3, 0.5, 0.7, 0.9), min_crop_size=0.3), dict(type='Resize', img_scale=[(992, 736), (89...
global edge_id edge_id = 0 class Edge: def __init__(self, source, target, weight=1): global edge_id self.id = edge_id edge_id += 1 self.source = source self.target = target self.weight = weight
global edge_id edge_id = 0 class Edge: def __init__(self, source, target, weight=1): global edge_id self.id = edge_id edge_id += 1 self.source = source self.target = target self.weight = weight
def main(): # input N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) # compute DA = [0]*N DBC =[0]*N for i in range(N): DA[A[i]-1] += 1 for i in range(N): DBC[B[C[i]-1]-1...
def main(): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) da = [0] * N dbc = [0] * N for i in range(N): DA[A[i] - 1] += 1 for i in range(N): DBC[B[C[i] - 1] - 1] += 1 s = 0 for i in ran...
#This is given a list of mutations, and get the read names that contain the mutation #Note: We use the CS tag in the alignments, thus each alignment should contain this tag. class ReadsTracer(): def __init__(self): pass # def trace_reads_from_mutation(self): pass #only catch mismatch h...
class Readstracer: def __init__(self): pass def trace_reads_from_mutation(self): pass def parse_snp_from_cs_tag(self, i_start_pos, s_CS_tag): pass
code ={ "CONTINUE":100, "SWITCHING_PROTOCOLS":101, "PROCESSING":101, "OK":200, "CREATED":201, "ACCEPTED":202, "NON_AUTHORITATIVE_INFORMATION":203, "NO_CONTENT":204, "RESET_CONTENT":205, "PARTIAL_CONTENT":206, "MULTI_STATUS":207, "ALREADY_REPORTED":208, ...
code = {'CONTINUE': 100, 'SWITCHING_PROTOCOLS': 101, 'PROCESSING': 101, 'OK': 200, 'CREATED': 201, 'ACCEPTED': 202, 'NON_AUTHORITATIVE_INFORMATION': 203, 'NO_CONTENT': 204, 'RESET_CONTENT': 205, 'PARTIAL_CONTENT': 206, 'MULTI_STATUS': 207, 'ALREADY_REPORTED': 208, 'IM_USED': 226, 'MULTIPLE_CHOICES': 300, 'MOVED_PERMANE...
# Space: O(n) # Time: O(n) class Solution: def maxArea(self, h, w, horizontalCuts, verticalCuts): horizontalCuts = [0] + horizontalCuts + [h] verticalCuts = [0] + verticalCuts + [w] horizontalCuts = sorted(horizontalCuts) verticalCuts = sorted(verticalCuts) h_max = max(ho...
class Solution: def max_area(self, h, w, horizontalCuts, verticalCuts): horizontal_cuts = [0] + horizontalCuts + [h] vertical_cuts = [0] + verticalCuts + [w] horizontal_cuts = sorted(horizontalCuts) vertical_cuts = sorted(verticalCuts) h_max = max((horizontalCuts[i] - horizo...
class chipManager(): def __init__(self,chipsize,chipNums): self.player1chips = chipNums self.player2chips = chipNums self.chipsize = chipsize def getP1Chips(): return self.player1chips def getP2Chips(): return self.player2chips def transferToDealer(txToDealer): if txToDealer: self.player1chips = s...
class Chipmanager: def __init__(self, chipsize, chipNums): self.player1chips = chipNums self.player2chips = chipNums self.chipsize = chipsize def get_p1_chips(): return self.player1chips def get_p2_chips(): return self.player2chips def transfer_to_dealer(txToD...
''' Catalan number `cat(n)`. Recursive formula: cat(5) = cat(0)*cat(4) + cat(1)*cat(3) + .. cat(4)*cat(0) Direct formula: cat(n) = (2n)! / (n+1)!(n)! Answer for: - Number of BST given the number of unique keys. - Number of binary trees with the same preorder traversal. - Number of balanced parantheses sequence -...
""" Catalan number `cat(n)`. Recursive formula: cat(5) = cat(0)*cat(4) + cat(1)*cat(3) + .. cat(4)*cat(0) Direct formula: cat(n) = (2n)! / (n+1)!(n)! Answer for: - Number of BST given the number of unique keys. - Number of binary trees with the same preorder traversal. - Number of balanced parantheses sequence -...
# Input : arr[] = {15, 18, 2, 3, 6, 12} # Output: 2 # Explanation : Initial array must be {2, 3, # 6, 12, 15, 18}. We get the given array after # rotating the initial array twice. # Input : arr[] = {7, 9, 11, 12, 5} # Output: 4 # Input: arr[] = {7, 9, 11, 12, 15}; # Output: 0 def single_rotation(arr, l): temp =...
def single_rotation(arr, l): temp = arr[0] for i in range(l - 1): arr[i] = arr[i + 1] arr[l - 1] = temp def find_min(arr, l): min = arr[0] for i in range(l): if min < arr[i]: min = arr[i] minimum = min for i in range(l): if min == arr[i]: inde...
__version__ = (1, 0, 0, "final", 0) ADMIN_PIPELINE_CSS = { 'admin_bs3': { 'source_filenames': ( 'admintools_bootstrap/chosen/chosen.css', 'admintools_bootstrap/lib/bootstrap-datetimepicker.css', 'admintools_bootstrap/lib/bootstrap-fileupload.scss', 'adminto...
__version__ = (1, 0, 0, 'final', 0) admin_pipeline_css = {'admin_bs3': {'source_filenames': ('admintools_bootstrap/chosen/chosen.css', 'admintools_bootstrap/lib/bootstrap-datetimepicker.css', 'admintools_bootstrap/lib/bootstrap-fileupload.scss', 'admintools_bootstrap/sass/admin.scss', 'admintools_bootstrap/css/mmenu.cs...
t = int(input()) for _ in range(t): s = [s_temp for s_temp in input().strip()] #s_len = len(s) #s_first_half = s[:s_len//2] #s_second_half = s[s_len//2+s_len%2:][::-1] op = 0 for i in range(len(s)//2): #op += ord(max(s_first_half[i], s_second_half[i])) - ord(min(s_first_half[i],...
t = int(input()) for _ in range(t): s = [s_temp for s_temp in input().strip()] op = 0 for i in range(len(s) // 2): op += abs(ord(s[i]) - ord(s[len(s) - i - 1])) print(op)
def n_lower_cases(string): return sum([int(c.islower()) for c in string]) def n_upper_cases(string): return sum([int(c.isupper()) for c in string]) def n_whitespace(string): cnt = 0.0 for c in string: if c == '_': cnt += 1 return cnt string = input() symb_amt = n_whitespace(str...
def n_lower_cases(string): return sum([int(c.islower()) for c in string]) def n_upper_cases(string): return sum([int(c.isupper()) for c in string]) def n_whitespace(string): cnt = 0.0 for c in string: if c == '_': cnt += 1 return cnt string = input() symb_amt = n_whitespace(str...
#!/usr/bin/env python3 inp = "01111010110010011" def solve(target_len): # translate input into numbers state = [int(c) for c in inp] # generate data while len(state) < target_len: state += [0] + [1-i for i in state[::-1]] # compute checksujm state = state[:target_len] while len(s...
inp = '01111010110010011' def solve(target_len): state = [int(c) for c in inp] while len(state) < target_len: state += [0] + [1 - i for i in state[::-1]] state = state[:target_len] while len(state) % 2 == 0: for i in range(int(len(state) / 2)): state[i] = 1 if state[2 * i] =...
# Data Center URL DATA_FILES_BASE_URL = "https://www.meps.ahrq.gov/mepsweb/data_files/pufs/" DATA_STATS_BASE_URL = "https://www.meps.ahrq.gov/data_stats/download_data/pufs/" # Base Year List DATA_FILES_YEARS = [ 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 200...
data_files_base_url = 'https://www.meps.ahrq.gov/mepsweb/data_files/pufs/' data_stats_base_url = 'https://www.meps.ahrq.gov/data_stats/download_data/pufs/' data_files_years = [2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008, 2007, 2006, 2005] base_models = ['DentalVisits', 'EmergencyRoomVisits', 'HomeH...
class CompositorNodeFlip: axis = None def update(self): pass
class Compositornodeflip: axis = None def update(self): pass
def add_native_methods(clazz): def flattenAlternative__com_sun_org_apache_xalan_internal_xsltc_compiler_Pattern__com_sun_org_apache_xalan_internal_xsltc_compiler_Template__java_util_Map_java_lang_String__com_sun_org_apache_xalan_internal_xsltc_compiler_Key___(a0, a1, a2, a3, a4): raise NotImplementedError()...
def add_native_methods(clazz): def flatten_alternative__com_sun_org_apache_xalan_internal_xsltc_compiler__pattern__com_sun_org_apache_xalan_internal_xsltc_compiler__template__java_util__map_java_lang__string__com_sun_org_apache_xalan_internal_xsltc_compiler__key___(a0, a1, a2, a3, a4): raise not_implemente...
entrada = str(input()).split(' ') p = int(entrada[0]) j1 = int(entrada[1]) j2 = int(entrada[2]) r = int(entrada[3]) a = int(entrada[4]) if r == 0 and a == 0: if (j1 + j2) % 2 == 0 and p == 1: print('Jogador 1 ganha!') elif (j1 + j2) % 2 != 0 and p == 0: print('Jogador 1 ganha!') else: print('Jogador 2 ganha...
entrada = str(input()).split(' ') p = int(entrada[0]) j1 = int(entrada[1]) j2 = int(entrada[2]) r = int(entrada[3]) a = int(entrada[4]) if r == 0 and a == 0: if (j1 + j2) % 2 == 0 and p == 1: print('Jogador 1 ganha!') elif (j1 + j2) % 2 != 0 and p == 0: print('Jogador 1 ganha!') else: ...
# -*- coding: utf-8 -*- class VariableTypeAlreadyRegistered(Exception): pass class InvalidType(Exception): pass
class Variabletypealreadyregistered(Exception): pass class Invalidtype(Exception): pass
# Find Pivot Index ''' Given an array of integers nums, write a method that returns the "pivot" index of this array. We define the pivot index as the index where the sum of all the numbers to the left of the index is equal to the sum of all the numbers to the right of the index. If no such index exists, we should re...
""" Given an array of integers nums, write a method that returns the "pivot" index of this array. We define the pivot index as the index where the sum of all the numbers to the left of the index is equal to the sum of all the numbers to the right of the index. If no such index exists, we should return -1. If there ar...
#!/usr/local/bin/python3.5 -u answer = 42 print(answer)
answer = 42 print(answer)
#!/bin/python3 h = list(map(int, input().strip().split(' '))) word = input().strip() max_height = 0 for w in word: i = ord(w)-97 max_height = max(max_height, h[i]) print (len(word)*max_height)
h = list(map(int, input().strip().split(' '))) word = input().strip() max_height = 0 for w in word: i = ord(w) - 97 max_height = max(max_height, h[i]) print(len(word) * max_height)
def hangman(word, letters): result = 0 a = 0 for item in letters: if 6 <= a: return False b = word.count(item) if 0 == b: a += 1 else: result += b return len(word) == result
def hangman(word, letters): result = 0 a = 0 for item in letters: if 6 <= a: return False b = word.count(item) if 0 == b: a += 1 else: result += b return len(word) == result
class AreaKnowledge: def __init__(self, text=None): self.text = text self._peoples_names = set() self.peoples_info = list() def set_text(self, text): self.text = text def update_people_photos(self, persons): for person in persons: self.update_people_phot...
class Areaknowledge: def __init__(self, text=None): self.text = text self._peoples_names = set() self.peoples_info = list() def set_text(self, text): self.text = text def update_people_photos(self, persons): for person in persons: self.update_people_pho...
class PTestException(Exception): pass class ScreenshotError(PTestException): pass
class Ptestexception(Exception): pass class Screenshoterror(PTestException): pass
# # PySNMP MIB module BFD-STD-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/BFD-STD-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:37:46 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 0...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, value_size_constraint, constraints_intersection, value_range_constraint, single_value_constraint) ...
class Solution: def judgeCircle(self, moves: str) -> bool: x_axis = y_axis = 0 for move in moves: if move == "U": y_axis += 1 elif move == "D": y_axis -= 1 elif move == "R": x_axis += 1 elif move == "L": ...
class Solution: def judge_circle(self, moves: str) -> bool: x_axis = y_axis = 0 for move in moves: if move == 'U': y_axis += 1 elif move == 'D': y_axis -= 1 elif move == 'R': x_axis += 1 elif move == 'L'...
with open("EX10.txt","r") as fp: words = 0 for data in fp: lines=data.split() for line in lines: words += 1 print("Total No.of Words:",words)
with open('EX10.txt', 'r') as fp: words = 0 for data in fp: lines = data.split() for line in lines: words += 1 print('Total No.of Words:', words)
__author__ = 'zoulida' class people(object): def __new__(cls, *args, **kargs): return super(people, cls).__new__(cls) def __init__(self, name): self.name = name def talk(self): print("hello,I am %s" % self.name) class student(people): def __new__(cls, *args, **kargs): ...
__author__ = 'zoulida' class People(object): def __new__(cls, *args, **kargs): return super(people, cls).__new__(cls) def __init__(self, name): self.name = name def talk(self): print('hello,I am %s' % self.name) class Student(people): def __new__(cls, *args, **kargs): ...
nombres=[] sueldo=[] totalsueldos=[] for x in range(3): nombres.append(input("Cual es tu nombre? ")) mes1=int(input("Cual fue tu sueldo de Junio? ")) mes2=int(input("Cual fue tu sueldo de Julio? ")) mes3=int(input("Cual fue tu sueldo de Agosto? ")) sueldo.append([mes1,mes2,mes3]) totalsueldos.a...
nombres = [] sueldo = [] totalsueldos = [] for x in range(3): nombres.append(input('Cual es tu nombre? ')) mes1 = int(input('Cual fue tu sueldo de Junio? ')) mes2 = int(input('Cual fue tu sueldo de Julio? ')) mes3 = int(input('Cual fue tu sueldo de Agosto? ')) sueldo.append([mes1, mes2, mes3]) t...
# contains hyperparameters for our seq2seq model. you can add some more config = { 'batch_size': 200, 'max_vocab_size': 20000, 'max_seq_len': 26, # decided based on the sentence length distribution of amazon corpus 'embedding_dim': 100, # we had trained a 100-dim w2v vecs in tut 1 }
config = {'batch_size': 200, 'max_vocab_size': 20000, 'max_seq_len': 26, 'embedding_dim': 100}
class Solution: def isValid(self, s: str) -> bool: stack = [] other_half = {")": "(", "]": "[", "}": "{"} for char in s: if char in "{[(": stack.append(char) elif char in ")]}" and stack and stack[-1] == other_half[char]: stack.pop() ...
class Solution: def is_valid(self, s: str) -> bool: stack = [] other_half = {')': '(', ']': '[', '}': '{'} for char in s: if char in '{[(': stack.append(char) elif char in ')]}' and stack and (stack[-1] == other_half[char]): stack.pop(...
skills = [ { "id": "0001", "name": "Liver of Steel", "type": "Passive", "isPermable": False, "effects": {"maximumInebriety": "+5"}, }, {"id": "0002", "name": "Chronic Indigestion", "type": "Combat", "mpCost": 5}, { "id": "0003", "name": "The Smile ...
skills = [{'id': '0001', 'name': 'Liver of Steel', 'type': 'Passive', 'isPermable': False, 'effects': {'maximumInebriety': '+5'}}, {'id': '0002', 'name': 'Chronic Indigestion', 'type': 'Combat', 'mpCost': 5}, {'id': '0003', 'name': 'The Smile of Mr. A.', 'type': 'Buff', 'mpCost': 5, 'isPermable': False}, {'id': '0004',...
load("@bazel_gazelle//:deps.bzl", "go_repository") def go_repositories(): go_repository( name = "co_honnef_go_tools", build_extra_args = ["-exclude=**/testdata", "-exclude=go/packages/packagestest"], importpath = "honnef.co/go/tools", sum = "h1:MNh1AVMyVX23VUHE2O27jm6lNj3vjO5DexS4A1...
load('@bazel_gazelle//:deps.bzl', 'go_repository') def go_repositories(): go_repository(name='co_honnef_go_tools', build_extra_args=['-exclude=**/testdata', '-exclude=go/packages/packagestest'], importpath='honnef.co/go/tools', sum='h1:MNh1AVMyVX23VUHE2O27jm6lNj3vjO5DexS4A1xvnzk=', version='v0.2.2') go_reposit...
def main(shot_name): # load air shot behind Microbone to Getter NP-10H info('extracting {}'.format(shot_name)) #for testing just sleep a few seconds #sleep(5) # this action blocks until completed extract_pipette(shot_name) #isolate microbone close(description='Microbone to Turbo') ...
def main(shot_name): info('extracting {}'.format(shot_name)) extract_pipette(shot_name) close(description='Microbone to Turbo') close('C') sleep(2) sleep(3)
# Enquete: Utilize o codigo em favorite_language.py # Crie uma lista de pessoas que devam participar da enquete sobre linguagem favorita. Inclua alguns nomes que ja' estejam no dicionario e outros que nao estao. # Percorra a lista de pessoas que devem participar da enquete. Se elas ja tiverem respondido `a enquete, mos...
favorite_languages = {'jen': 'python', 'sarah': 'c', 'edward': 'ruby', 'phil': 'python', 'chefe': 'javascript', 'edgar': 'php'} list_name = ['edgar', 'marcia', 'jen', 'augusto', 'retirante', 'sarah', 'chefe', 'madalena', 'joao', 'goza-montinho'] for key in list_name: if key in favorite_languages: print(f'Mu...
def reverse_filter( s ): return s[ ::-1 ] def string_trim_upper( value ): return value.strip().upper() def string_trim_lower( value ): return value.strip().lower() def datetimeformat( value, format='%H:%M / %d-%m-%Y' ): return value.strftime( format )
def reverse_filter(s): return s[::-1] def string_trim_upper(value): return value.strip().upper() def string_trim_lower(value): return value.strip().lower() def datetimeformat(value, format='%H:%M / %d-%m-%Y'): return value.strftime(format)
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def bazel_sonarqube_repositories( sonar_scanner_cli_version = "4.5.0.2216", sonar_scanner_cli_sha256 = "a271a933d14da6e8705d58996d30afd0b4afc93c0bfe957eb377bed808c4fa89"): http_archive( name = "org_sonarsource_scanner_cli...
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') def bazel_sonarqube_repositories(sonar_scanner_cli_version='4.5.0.2216', sonar_scanner_cli_sha256='a271a933d14da6e8705d58996d30afd0b4afc93c0bfe957eb377bed808c4fa89'): http_archive(name='org_sonarsource_scanner_cli_sonar_scanner_cli', build_file='...
rawInstructions = [line.rstrip() for line in open("day12_input.txt")] instructions=[] for line in rawInstructions: instructions.append([line[0], int(line[1:])]) orientations = [[0,1], [1,0], [0,-1], [-1,0]] position = [0, 0, 1] def makeMove1(position, instruction): x = position[0] y = position[1...
raw_instructions = [line.rstrip() for line in open('day12_input.txt')] instructions = [] for line in rawInstructions: instructions.append([line[0], int(line[1:])]) orientations = [[0, 1], [1, 0], [0, -1], [-1, 0]] position = [0, 0, 1] def make_move1(position, instruction): x = position[0] y = position[1] ...
class DebugHeaders(object): # List of headers we want to display header_filter = ( 'CONTENT_TYPE', 'HTTP_ACCEPT', 'HTTP_ACCEPT_CHARSET', 'HTTP_ACCEPT_ENCODING', 'HTTP_ACCEPT_LANGUAGE', 'HTTP_CACHE_CONTROL', 'HTTP_CONNECTION', 'HTTP_HOST', ...
class Debugheaders(object): header_filter = ('CONTENT_TYPE', 'HTTP_ACCEPT', 'HTTP_ACCEPT_CHARSET', 'HTTP_ACCEPT_ENCODING', 'HTTP_ACCEPT_LANGUAGE', 'HTTP_CACHE_CONTROL', 'HTTP_CONNECTION', 'HTTP_HOST', 'HTTP_KEEP_ALIVE', 'HTTP_REFERER', 'HTTP_USER_AGENT', 'QUERY_STRING', 'REMOTE_ADDR', 'REMOTE_HOST', 'REQUEST_METHOD...
class Solution: def plusOne(self, digits: 'List[int]') -> 'List[int]': fl = 1 for i in range(len(digits)-1,-1,-1): if digits[i] == 9 and fl == 1: fl = 1 digits[i] = 0 else: digits[i] += 1 fl = 0 b...
class Solution: def plus_one(self, digits: 'List[int]') -> 'List[int]': fl = 1 for i in range(len(digits) - 1, -1, -1): if digits[i] == 9 and fl == 1: fl = 1 digits[i] = 0 else: digits[i] += 1 fl = 0 ...
dictionary = { "CSS": "101", "Python": ["101", "201", "301"] } print(dictionary.get("CSS", None)) print(dictionary.get("HTML", None))
dictionary = {'CSS': '101', 'Python': ['101', '201', '301']} print(dictionary.get('CSS', None)) print(dictionary.get('HTML', None))
# edit the following parameters which control the benchmark mincpus = 16 maxcpus = 128 nsteps_cpus = 6 multigpu = (1,2,3,) multithread = (1,2,4,8) multithread = (8,) multithread_gpu = (42,) if (maxcpus < max(multigpu)): raise ValueError('increase the number of processors') systems = ['interface','lj'] runconfig ...
mincpus = 16 maxcpus = 128 nsteps_cpus = 6 multigpu = (1, 2, 3) multithread = (1, 2, 4, 8) multithread = (8,) multithread_gpu = (42,) if maxcpus < max(multigpu): raise value_error('increase the number of processors') systems = ['interface', 'lj'] runconfig = ['cpu-opt', 'cpu-omp', 'cpu-kokkos', 'cpu-kokkos-omp', 'c...
values = { frozenset(("hardQuotaSize=1", "id=1", "hardQuotaUnit=TB")): { "status_code": "200", "text": { "responseData": {}, "responseHeader": { "now": 1492551097041, "requestId": "WPaFuAoQgF4AADVcf4kAAAAz", "status": "ok", ...
values = {frozenset(('hardQuotaSize=1', 'id=1', 'hardQuotaUnit=TB')): {'status_code': '200', 'text': {'responseData': {}, 'responseHeader': {'now': 1492551097041, 'requestId': 'WPaFuAoQgF4AADVcf4kAAAAz', 'status': 'ok'}, 'responseStatus': 'ok'}}, frozenset(('hardQuotaSize=1', 'id=2', 'hardQuotaUnit=TB')): {'status_code...
input_file = __file__.split("/") input_file[-1] = "input.txt" with open("/".join(input_file)) as f: actions = [entry.strip().split() for entry in f] curr_aim = curr_depth = curr_horiz = 0 for direction, num in actions: if direction in {"up", "down"}: aim_change = int(num) if direction == "down" else...
input_file = __file__.split('/') input_file[-1] = 'input.txt' with open('/'.join(input_file)) as f: actions = [entry.strip().split() for entry in f] curr_aim = curr_depth = curr_horiz = 0 for (direction, num) in actions: if direction in {'up', 'down'}: aim_change = int(num) if direction == 'down' else i...
# # PySNMP MIB module Juniper-PPPOE-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Juniper-PPPOE-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:53:05 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Ma...
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, single_value_constraint, constraints_intersection, value_range_constraint, value_size_constraint) ...
n=int(input()) s=[str(input()) for a in range(n)] for i in range(n): c=0 for j in range(len(s[i])): if s[i][j] == "W": for k in range(max(0,j-2),min(len(s[i]),j+2)): if s[i][k]=="B": c+=1 break print(c)
n = int(input()) s = [str(input()) for a in range(n)] for i in range(n): c = 0 for j in range(len(s[i])): if s[i][j] == 'W': for k in range(max(0, j - 2), min(len(s[i]), j + 2)): if s[i][k] == 'B': c += 1 break print(c)
t = int(input()) for _ in range(t): n = int(input()) l1 = set(list(map(int,input().split()))) l2 = set(list(map(int,input().split()))) if l1==l2: print(1) else: print(0)
t = int(input()) for _ in range(t): n = int(input()) l1 = set(list(map(int, input().split()))) l2 = set(list(map(int, input().split()))) if l1 == l2: print(1) else: print(0)
#/* *** ODSATag: Sequential *** */ # Return the position of an element in a list. # If the element is not found, return -1. def sequentialSearch(elements, e): for i in range(len(elements)): # For each element if elements[i] == e: # if we found it return i # return this po...
def sequential_search(elements, e): for i in range(len(elements)): if elements[i] == e: return i return -1 if __name__ == '__main__': arr = [2, 3, 4, 5, 7, 10] print(arr) for key in [4, 6, 10]: pos = sequential_search(arr, key) print(f'Search for {key} --> positio...
############################################################################## # 01: Is Unique? ############################################################################## def caseAndSpaceTreat(inputString, caseSensitive=True, spaces=True): ''' Returns a lowercase string if case insensitive, and removes sp...
def case_and_space_treat(inputString, caseSensitive=True, spaces=True): """ Returns a lowercase string if case insensitive, and removes spaces if necessary """ if caseSensitive == False: input_string = inputString.lower() if spaces == False: input_string = inputString.replace...
d = 3255 f = d // 15-17 z = d // (f*5) d = d % (z+1) print("d = ", d)
d = 3255 f = d // 15 - 17 z = d // (f * 5) d = d % (z + 1) print('d = ', d)
message = "o" def scope(): global message message = "p" scope() print(message)
message = 'o' def scope(): global message message = 'p' scope() print(message)
# This file is part of the faebryk project # SPDX-License-Identifier: MIT class lazy: def __init__(self, expr): self.expr = expr def __str__(self): return str(self.expr()) def __repr__(self): return repr(self.expr()) def kw2dict(**kw): return dict(kw) class hashable_dict: ...
class Lazy: def __init__(self, expr): self.expr = expr def __str__(self): return str(self.expr()) def __repr__(self): return repr(self.expr()) def kw2dict(**kw): return dict(kw) class Hashable_Dict: def __init__(self, obj: dict): self.obj = obj def __hash__...
def Sum_Divisors(x): s = 0 for i in range(1,(x // 2) + 1): if x % i == 0: s += i return s def Amicable(x,y): if x!=y: if Sum_Divisors(x) == y and Sum_Divisors(y) == x : return True return False def Sum_Amicable(): l=[] for i in range(284,10000): ...
def sum__divisors(x): s = 0 for i in range(1, x // 2 + 1): if x % i == 0: s += i return s def amicable(x, y): if x != y: if sum__divisors(x) == y and sum__divisors(y) == x: return True return False def sum__amicable(): l = [] for i in range(284, 1000...
def is_odd(n): '''Return True if the number is odd and False otherwise.''' if n % 2 != 0: odd = True else: odd = False return odd def main(): '''Define main function.''' # Prompt the user for a number number = float(input('Please enter a number: ')) ...
def is_odd(n): """Return True if the number is odd and False otherwise.""" if n % 2 != 0: odd = True else: odd = False return odd def main(): """Define main function.""" number = float(input('Please enter a number: ')) print(is_odd(number)) main()
def ans(x): if len(x) == 2 or len(x) == 10: return False return True
def ans(x): if len(x) == 2 or len(x) == 10: return False return True
# Autogenerated config.py # Documentation: # qute://help/configuring.html # qute://help/settings.html # Uncomment this to still load settings configured via autoconfig.yml config.load_autoconfig() config.source('colors_qutebrowser.py')
config.load_autoconfig() config.source('colors_qutebrowser.py')
L, R = map(int, input().split()) L -= 1 R -= 1 S = input() print(S[:L] + ''.join(reversed(S[L:R+1])) + S[R+1:len(S)])
(l, r) = map(int, input().split()) l -= 1 r -= 1 s = input() print(S[:L] + ''.join(reversed(S[L:R + 1])) + S[R + 1:len(S)])
# https://codeforces.com/problemset/problem/339/A s = [x for x in input().split("+")] if len(s) == 1: print(s[0]) else: s.sort() print("+".join(s))
s = [x for x in input().split('+')] if len(s) == 1: print(s[0]) else: s.sort() print('+'.join(s))
GIT_BRANCH_MASTER = "master" GIT_BRANCH_MAIN = "main" GITHUB_PUBLIC_DOMAIN_NAME = "github.com" KNOWN_DEFAULT_BRANCHES = (GIT_BRANCH_MASTER, GIT_BRANCH_MAIN)
git_branch_master = 'master' git_branch_main = 'main' github_public_domain_name = 'github.com' known_default_branches = (GIT_BRANCH_MASTER, GIT_BRANCH_MAIN)
# # PySNMP MIB module AC-V5-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AC-V5-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 16:54:49 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...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_union, single_value_constraint, value_size_constraint, constraints_intersection) ...
# Name:COLLIN FRANCE # Date:JULY 11 17 # proj02: sum # Write a program that prompts the user to enter numbers, one per line, # ending with a line containing 0, and keep a running sum of the numbers. # Only print out the sum after all the numbers are entered # (at least in your final version). Each time you read in a ...
loop_control = True collin = 0 while loop_control == True: number = raw_input('any number to a start equation. Enter a zero to show you are finished') if Number == '0': loop_control = False collin = int(Number) + collin (print(collin), 'is the sum')
#cons(a,b) constructs a pair, and car(pair) returns the first and cdr(pair) returns the last element of the pair. #For example , car(cons(3,4)) returns 3, and cdr(cons(3,4)) returns 4. #Given this implementation of cons: '''def cons(a,b): def pair(f): return f(a,b) return pair() ''' #Implement...
"""def cons(a,b): def pair(f): return f(a,b) return pair() """
def rotateImage(a): w = len(a) h = w img = [0] * h for col in range(h): img_row = [0] * w for row in range(w): img_row[h - row - 1] = a[row][col] img[col] = img_row return img
def rotate_image(a): w = len(a) h = w img = [0] * h for col in range(h): img_row = [0] * w for row in range(w): img_row[h - row - 1] = a[row][col] img[col] = img_row return img
def ajuda(msg): help(msg) n=str(input('Digite um comando para ver a ajuda: ')) ajuda(n)
def ajuda(msg): help(msg) n = str(input('Digite um comando para ver a ajuda: ')) ajuda(n)
def tower_of_hanoi(num_of_disks, mv_from, mv_to, tmp_bar): if num_of_disks == 1: print(f'Move disk 1 from {mv_from} to {mv_to}') return tower_of_hanoi(num_of_disks - 1, mv_from, tmp_bar, mv_to) print(f'Move disk {num_of_disks} from {mv_from} to {mv_to}') tower_of_hanoi(num_of_disks - 1,...
def tower_of_hanoi(num_of_disks, mv_from, mv_to, tmp_bar): if num_of_disks == 1: print(f'Move disk 1 from {mv_from} to {mv_to}') return tower_of_hanoi(num_of_disks - 1, mv_from, tmp_bar, mv_to) print(f'Move disk {num_of_disks} from {mv_from} to {mv_to}') tower_of_hanoi(num_of_disks - 1, ...
# https://www.codewars.com/kata/5a2d70a6f28b821ab4000004/ ''' Instructions : This kata is part of the collection Mary's Puzzle Books. Zero Terminated Sum Mary has another puzzle book, and it's up to you to help her out! This book is filled with zero-terminated substrings, and you have to find the substring with the...
""" Instructions : This kata is part of the collection Mary's Puzzle Books. Zero Terminated Sum Mary has another puzzle book, and it's up to you to help her out! This book is filled with zero-terminated substrings, and you have to find the substring with the largest sum of its digits. For example, one puzzle looks l...
class PPO: def get_specs(env=None): specs = { "type": "ppo_agent", "states_preprocessing": { "type":"flatten" }, "subsampling_fraction": 0.1, "optimization_steps": 50, "entropy_regularization": 0.01, "gae_...
class Ppo: def get_specs(env=None): specs = {'type': 'ppo_agent', 'states_preprocessing': {'type': 'flatten'}, 'subsampling_fraction': 0.1, 'optimization_steps': 50, 'entropy_regularization': 0.01, 'gae_lambda': None, 'likelihood_ratio_clipping': 0.2, 'actions_exploration': {'type': 'epsilon_decay', 'initi...
class Solution: # This will technically work, but it's slow as all get-out. # Worst case would be O(n^2) as you have to traverse your # entire list of n numbers k times, which if k is 1 less # than the length of nums, is effectively n. def rotate(self, nums, k): start = end = len(nums) ...
class Solution: def rotate(self, nums, k): start = end = len(nums) if k >= start: k = k % start if k == 0: return x = 1 while k > 0: k -= 1 for i in range(1, end): temp = nums[-i] nums[-i] = nums...
ACCESS_DENIED = "access_denied" INVALID_CLIENT = "invalid_client" INVALID_GRANT = "invalid_grant" INVALID_REQUEST = "invalid_request" INVALID_SCOPE = "invalid_scope" INVALID_STATE = "invalid_state" INVALID_RESPONSE = "invalid_response" SERVER_ERROR = "server_error" TEMPORARILY_UNAVAILABLE = "temporarily_unavailable" UN...
access_denied = 'access_denied' invalid_client = 'invalid_client' invalid_grant = 'invalid_grant' invalid_request = 'invalid_request' invalid_scope = 'invalid_scope' invalid_state = 'invalid_state' invalid_response = 'invalid_response' server_error = 'server_error' temporarily_unavailable = 'temporarily_unavailable' un...
def sum(n): return n * (n + 1) // 2 print(sum(46341))
def sum(n): return n * (n + 1) // 2 print(sum(46341))
pessoas = {'nome':'Gilson', 'Idade':55, 'Sexo': 'M'} print(pessoas) print(pessoas['nome']) print(pessoas['Idade']) print(f'{pessoas["nome"]}') print(pessoas.keys()) print(pessoas.values()) print(pessoas.items()) for k in pessoas.values(): print(k) for k ,v in pessoas.items(): print(f'{k} = {v}') brasil = [] es...
pessoas = {'nome': 'Gilson', 'Idade': 55, 'Sexo': 'M'} print(pessoas) print(pessoas['nome']) print(pessoas['Idade']) print(f"{pessoas['nome']}") print(pessoas.keys()) print(pessoas.values()) print(pessoas.items()) for k in pessoas.values(): print(k) for (k, v) in pessoas.items(): print(f'{k} = {v}') brasil = []...
# simple inheritance # base class class student: def __init__(self, name, age): self.name = name self.age = age def getdata(self): self.name = input('enter name') self.age = input('enter age') def putdata(self): print(self.name, self.age) # Derived class or sub...
class Student: def __init__(self, name, age): self.name = name self.age = age def getdata(self): self.name = input('enter name') self.age = input('enter age') def putdata(self): print(self.name, self.age) class Sciencestudent(student): def science(self): ...
#!/user/bin/env python '''rWork.py: This filter returns True if the r_work value for this structure is within the specified range ''' __author__ = "Mars (Shih-Cheng) Huang" __maintainer__ = "Mars (Shih-Cheng) Huang" __email__ = "marshuang80@gmail.com" __version__ = "0.2.0" __status__ = "Done" class RWork(object): ...
"""rWork.py: This filter returns True if the r_work value for this structure is within the specified range """ __author__ = 'Mars (Shih-Cheng) Huang' __maintainer__ = 'Mars (Shih-Cheng) Huang' __email__ = 'marshuang80@gmail.com' __version__ = '0.2.0' __status__ = 'Done' class Rwork(object): """This filter return...
#%% # nums = [-1,2,1,-4] # target = 1 # nums = [0, 1, 2] # target = 0 nums = [1, 1, 1, 0] target = 100 nums = [0, 2, 1, -3, -5] target = 1 def threeSumClosest(nums: list, target: int)->int: nums.sort() ptrLow = 0 ptrHigh = len(nums) - 1 bestEstimate = 10e10 #remember that we are dealing with thre...
nums = [1, 1, 1, 0] target = 100 nums = [0, 2, 1, -3, -5] target = 1 def three_sum_closest(nums: list, target: int) -> int: nums.sort() ptr_low = 0 ptr_high = len(nums) - 1 best_estimate = 100000000000.0 while ptrHigh - ptrLow - 1 >= 0: for ind in range(ptrLow + 1, ptrHigh): cur...
# md5 : 696999570c6da88ed87e96e1014f4fd0 # sha1 : bbf782f04e4b5dafbfe1afef6b08ab08a1777852 # sha256 : 8d6c894aeb73da24ba8c8af002f7299211c23a616cccf18443c6f38b43c33b3e ord_names = { 102: b'ChooseColorA', 103: b'ChooseColorW', 104: b'ChooseFontA', 105: b'ChooseFontW', 106: b'CommDlgExtendedError', ...
ord_names = {102: b'ChooseColorA', 103: b'ChooseColorW', 104: b'ChooseFontA', 105: b'ChooseFontW', 106: b'CommDlgExtendedError', 107: b'DllCanUnloadNow', 108: b'DllGetClassObject', 109: b'FindTextA', 110: b'FindTextW', 111: b'GetFileTitleA', 112: b'GetFileTitleW', 113: b'GetOpenFileNameA', 114: b'GetOpenFileNameW', 115...
first = int(input()) i = 0 list = [] outputval = 0 if(first>0 and first<11): while(i<first): i+=1 f, s = map(int, input().split()) list.append(int(s/f)) if (min(list)<0): print(0) else: print(min(list))
first = int(input()) i = 0 list = [] outputval = 0 if first > 0 and first < 11: while i < first: i += 1 (f, s) = map(int, input().split()) list.append(int(s / f)) if min(list) < 0: print(0) else: print(min(list))
# 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 Tableproperties(object): commit_num_retries = 'commit.retry.num-retries' commit_num_retries_default = 4 commit_min_retry_wait_ms = 'commit.retry.min-wait-ms' commit_min_retry_wait_ms_default = 100 commit_max_retry_wait_ms = 'commit.retry.max-wait-ms' commit_max_retry_wait_ms_default = 6000...
#!/usr/bin/env python # encoding: utf-8 ''' #-------------------------------------------------------------------# # CONFIDENTIAL --- CUSTOM STUDIOS # #-------------------------------------------------------------------# # ...
""" #-------------------------------------------------------------------# # CONFIDENTIAL --- CUSTOM STUDIOS # #-------------------------------------------------------------------# # # # @Project Na...
class Solution: # O(n^2) time | O(1) space - where n is the length of the input array def maxDistance(self, colors: List[int]) -> int: maxDist = 0 for i in range(len(colors)): for j in range(i, len(colors)): if colors[i] != colors[j]: maxDist = max...
class Solution: def max_distance(self, colors: List[int]) -> int: max_dist = 0 for i in range(len(colors)): for j in range(i, len(colors)): if colors[i] != colors[j]: max_dist = max(maxDist, j - i) return maxDist
''' @File : init.py @Author : Zehong Ma @Version : 1.0 @Contact : zehongma@qq.com @Desc : None '''
""" @File : init.py @Author : Zehong Ma @Version : 1.0 @Contact : zehongma@qq.com @Desc : None """
# https://www.codechef.com/LTIME98C/problems/REDALERT for T in range(int(input())): n,d,h=map(int,input().split()) l,check=list(map(int,input().split())),0 for i in l: if(i==0): if(check<d): check=0 else: check-=d continue check+=i if(check>h): ...
for t in range(int(input())): (n, d, h) = map(int, input().split()) (l, check) = (list(map(int, input().split())), 0) for i in l: if i == 0: if check < d: check = 0 else: check -= d continue check += i if check > h: ...
# print("Hello") # print("Hello") i = 0 while i < 5: print("Hello No.", i) i += 1 print("Always happens once loop is finished") print("i is now", i) i = 10 while i > 0: print("Going down the floor:", i) # i could do more stuff i -= 2 print("Whew we are done with this i:", i) i = 20 while True: ...
i = 0 while i < 5: print('Hello No.', i) i += 1 print('Always happens once loop is finished') print('i is now', i) i = 10 while i > 0: print('Going down the floor:', i) i -= 2 print('Whew we are done with this i:', i) i = 20 while True: print('i is', i) if i > 28: break i += 2 while ...
# -*- coding: utf-8 -*- class RpcSetPassword: def __init__(self, hashed_password): self.hashed_password = hashed_password def out_rpc_set_password(self, pack): pack.add_value("HashedPassword", self.hashed_password)
class Rpcsetpassword: def __init__(self, hashed_password): self.hashed_password = hashed_password def out_rpc_set_password(self, pack): pack.add_value('HashedPassword', self.hashed_password)
class LinkedList: class _Node: def __init__(self, e=None, node_next=None): self.e = e self.next = node_next def __str__(self): return str(self.e) def __repr__(self): return self.__str__() def __init__(self): self._dummy_head = se...
class Linkedlist: class _Node: def __init__(self, e=None, node_next=None): self.e = e self.next = node_next def __str__(self): return str(self.e) def __repr__(self): return self.__str__() def __init__(self): self._dummy_head = ...
#================================================================ # Runge-Kutta 4th Order Function for Spring Damping # # Author: Bayu R. J. (remove this lol) # Version: 1.0 *initial release # Level: Beginner # Python : IDLE 3.6.3 (use 'new file' to make a whole script) #=========================================...
def dy(u): dy = u return dy def du(x, u): k = 2 c = 460 m = 450 du = (-c * u - k * x) / m return du y = 0.01 u = 0 r = 0 n = 10 a = y b = 1 h = (b - a) / N xpoints = [y] for i in range(99999): r += h if r < b: xpoints.append(r) i += 1 ypoints = [] upoints = [] for x in x...
n = 9 while n>=1: if(n>1): print(str(n) + " bottles of beer on the wall, " + str(n) + " bottles of beer.") n-=1 print("take one down and pass it around, " + str(n) + " bottles of beer on the wall.\n\n") else: print(str(n) + " bottles of beer on the wall, " + str(n) + " bottle of ...
n = 9 while n >= 1: if n > 1: print(str(n) + ' bottles of beer on the wall, ' + str(n) + ' bottles of beer.') n -= 1 print('take one down and pass it around, ' + str(n) + ' bottles of beer on the wall.\n\n') else: print(str(n) + ' bottles of beer on the wall, ' + str(n) + ' bottl...
dy_import_module_symbols("testdatalimit_helper") # Send 10MB of data through with a high limit of 3MB. Which means as soon as it sends # 3MB, the shim should block until the time limit (in this case 20 seconds) is up. UPLOAD_LIMIT = 1024 * 1024 * 3 # 3MB DOWNLOAD_LIMIT = 1024 * 1024 * 3 # 3MB TIME_LIMIT = 10 DATA_TO_...
dy_import_module_symbols('testdatalimit_helper') upload_limit = 1024 * 1024 * 3 download_limit = 1024 * 1024 * 3 time_limit = 10 data_to_send = 'HelloWorld' * 1024 * 1024 launch_test()
class Hand: def __init__(self, stay=False): self.stay = stay self.cards = [] def drawCard(self, deck): self.cards.append(deck.dealCard()) def displayHand(self): return f"{[f'{card.num}{card.face},' for card in self.cards]}" # Corner case to be resol...
class Hand: def __init__(self, stay=False): self.stay = stay self.cards = [] def draw_card(self, deck): self.cards.append(deck.dealCard()) def display_hand(self): return f"{[f'{card.num}{card.face},' for card in self.cards]}" def calculate_score(self): values ...
class Fee(object): def __init__(self, currency, fastest, slowest): self.currency = currency self.fastest = fastest self.slowest = slowest def __str__(self): return "Fees for %s [Fastest %s] [Slowest %s]" % (self.currency, self.fastest, self.slowest) def __repr__(self): ...
class Fee(object): def __init__(self, currency, fastest, slowest): self.currency = currency self.fastest = fastest self.slowest = slowest def __str__(self): return 'Fees for %s [Fastest %s] [Slowest %s]' % (self.currency, self.fastest, self.slowest) def __repr__(self): ...
f = open("input.txt",'r') L = [] for item in f: L.append(item.strip()) # Construct arrays of possible keys: creden = ["ecl","eyr","hcl","byr","iyr","pid","hgt"] creden_plus = ["ecl","eyr","hcl","byr","iyr","pid","hgt","cid"] creden.sort() creden_plus.sort() # stores all passports passports = [] # stores key-va...
f = open('input.txt', 'r') l = [] for item in f: L.append(item.strip()) creden = ['ecl', 'eyr', 'hcl', 'byr', 'iyr', 'pid', 'hgt'] creden_plus = ['ecl', 'eyr', 'hcl', 'byr', 'iyr', 'pid', 'hgt', 'cid'] creden.sort() creden_plus.sort() passports = [] passport = [] for item in L: if item == '': passports....
# Auxiliary def goodness(x,y): xx = x-np.average(x) yy = y-np.average(y) A = np.sqrt(np.inner(xx,xx)) B = np.sqrt(np.inner(yy,yy)) return np.inner(xx/A,yy/B) def argminrnd(items, target): # Returns the argmin item. if there are many, returns one at random. # items and target must be the s...
def goodness(x, y): xx = x - np.average(x) yy = y - np.average(y) a = np.sqrt(np.inner(xx, xx)) b = np.sqrt(np.inner(yy, yy)) return np.inner(xx / A, yy / B) def argminrnd(items, target): candidates = np.where(target == target.min())[0] return items[random.choice(candidates)] def argmaxrnd...
zahlen = [] with open('AdventOfCode_01_1_Input.txt') as f: for zeile in f: zahlen.append(int(zeile)) print(sum(zahlen))
zahlen = [] with open('AdventOfCode_01_1_Input.txt') as f: for zeile in f: zahlen.append(int(zeile)) print(sum(zahlen))
if __name__ == '__main__': a = 2,4 b = 1, c = b d = c # a, b = c, d print(c) print(d) a, b = b, a print(a, b) # Sets contains non duplicate items
if __name__ == '__main__': a = (2, 4) b = (1,) c = b d = c print(c) print(d) (a, b) = (b, a) print(a, b)
class BitDecoder: def encode(self, morse_msg, morse_format, timing): if isinstance(morse_msg, int): morse_msg = bin(morse_msg)[2:] symbol_gap = '0' * timing.intra_char char_gap = '0' * timing.inter_char word_gap = '0' * timing.inter_word words = morse_msg.split...
class Bitdecoder: def encode(self, morse_msg, morse_format, timing): if isinstance(morse_msg, int): morse_msg = bin(morse_msg)[2:] symbol_gap = '0' * timing.intra_char char_gap = '0' * timing.inter_char word_gap = '0' * timing.inter_word words = morse_msg.split(m...
class Dog: def __init__(self, name, age): self.name = name self.age = age # print(name) # below method will return us the attribute value of the object # getter def get_name(self): return self.name def get_age(self): return self.age # setter # set ...
class Dog: def __init__(self, name, age): self.name = name self.age = age def get_name(self): return self.name def get_age(self): return self.age def set_age(self, age): self.age = age d = dog('tyson', 12) d.set_age(25) print(d.get_age())
#!/usr/bin/env python3 ############################################################################################ # # # Program purpose: Computes the sum and average of n integer numbers (input from the # # ...
def do_suming(input_mess: str) -> dict: (user_data, cont, main_sum) = ('', True, 0) count = 0 while cont: try: user_data = int(input(input_mess)) if user_data == 0: cont = False else: main_sum += user_data count += 1...
library_list = [ 'esoctiostan', 'esohststan', 'esookestan', 'esowdstan', 'esoxshooter', 'ing_oke', 'ing_sto', 'ing_og', 'ing_mas', 'ing_fg', 'irafblackbody', 'irafbstdscal', 'irafctiocal', 'irafctionewcal', 'irafiidscal', 'irafirscal', 'irafoke1990', 'irafredcal', 'irafspec16cal', 'irafspec50cal', '...
library_list = ['esoctiostan', 'esohststan', 'esookestan', 'esowdstan', 'esoxshooter', 'ing_oke', 'ing_sto', 'ing_og', 'ing_mas', 'ing_fg', 'irafblackbody', 'irafbstdscal', 'irafctiocal', 'irafctionewcal', 'irafiidscal', 'irafirscal', 'irafoke1990', 'irafredcal', 'irafspec16cal', 'irafspec50cal', 'irafspechayescal'] es...
class CharacterComponent: def __init__(self, name): self.name=name def equip(self): pass class CharacterConcreteComponent(CharacterComponent): def equip(self): return f'{self.name} equipment:' class Decorator(CharacterComponent): _character: CharacterComponent def __init__(...
class Charactercomponent: def __init__(self, name): self.name = name def equip(self): pass class Characterconcretecomponent(CharacterComponent): def equip(self): return f'{self.name} equipment:' class Decorator(CharacterComponent): _character: CharacterComponent def __i...
# Code on Python 3.7.4 # Working @ Dec, 2020 # david-boo.github.io # Define sequences. Then put two strings together to produce the list of pairs that we wish to compare, and a filter returns just those pairs for which seq1 != seq2 # Taking the length of the filtered list gives us the Hamming distance seq1=...
seq1 = 'AAAGAAAACGCCAACCCCCCCCCGTGCTGCAGTCTTGATTGCTGTATGAGAGATCCGGCCCTGTACGCGGTCCCCGTAGGACACTCACAGACGTCCACAGTTCTAGAAGAAGCGCTTATTCGTATTCGTCGACCTGTCCCCTGCTCCGTCCAGCGGTTAGAGTCCTACATGTACGTTGGAAGAGCACTCCCGACCGGTGCGGTTAGTACATCTTTTGTGATTTCCGAGTTCCGTGAAGGGGAGACCGATATGTACGCTCAGCATATGTCGATGCTGCAACGTGCATAAGGACGTAGACGGATACGCACAGTG...
class Solution: def canFormArray(self, arr: List[int], pieces: List[List[int]]) -> bool: x={} f=[] z=[] for i in pieces: x[i[0]]=i l=0 while l<len(arr): if arr[l] in x: f.append(x[arr[l]]) print(f) el...
class Solution: def can_form_array(self, arr: List[int], pieces: List[List[int]]) -> bool: x = {} f = [] z = [] for i in pieces: x[i[0]] = i l = 0 while l < len(arr): if arr[l] in x: f.append(x[arr[l]]) print(f)...