content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
def test_info(client): url = "/" resp = client.get(url) assert resp.status_code == 200 resp = resp.get_json() def test_list_repositories(client): url = '/list_repositories' resp = client.get(url) assert resp.status_code == 200 resp = resp.get_json() assert isinstance(resp, li...
def test_info(client): url = '/' resp = client.get(url) assert resp.status_code == 200 resp = resp.get_json() def test_list_repositories(client): url = '/list_repositories' resp = client.get(url) assert resp.status_code == 200 resp = resp.get_json() assert isinstance(resp, list) ...
""" You are given an array of integers. On each move you are allowed to increase exactly one of its element by one. Find the minimal number of moves required to obtain a strictly increasing sequence from the input. Example For inputArray = [1, 1, 1], the output should be arrayChange(inputArray) = 3. """ def arrayChan...
""" You are given an array of integers. On each move you are allowed to increase exactly one of its element by one. Find the minimal number of moves required to obtain a strictly increasing sequence from the input. Example For inputArray = [1, 1, 1], the output should be arrayChange(inputArray) = 3. """ def array_ch...
n, L, t = map(int, input().split()) a = list(map(int, input().split())) pos = [True] * n def next_step(): for i in range(n): if pos[i]: a[i] += 1 else: a[i] -= 1 for i in range(n): if a[i] == 0 and pos[i] is False: pos[i] = True elif a[i] == ...
(n, l, t) = map(int, input().split()) a = list(map(int, input().split())) pos = [True] * n def next_step(): for i in range(n): if pos[i]: a[i] += 1 else: a[i] -= 1 for i in range(n): if a[i] == 0 and pos[i] is False: pos[i] = True elif a[i] ==...
n = "12345" digit_sum = sum(map(int, list(n))) print(digit_sum)
n = '12345' digit_sum = sum(map(int, list(n))) print(digit_sum)
# MIT License # (C) Copyright 2021 Hewlett Packard Enterprise Development LP. # # group : Manage appliance groups def get_gms_groups(self) -> dict: """Get all appliance groups in Orchestrator .. list-table:: :header-rows: 1 * - Swagger Section - Method - Endpoint ...
def get_gms_groups(self) -> dict: """Get all appliance groups in Orchestrator .. list-table:: :header-rows: 1 * - Swagger Section - Method - Endpoint * - group - GET - /gms/group :return: Returns dictionary of all appliance groups in Orchest...
def new_string(word: str, repeat: int): return word * repeat word = input() repeat = int(input()) print(new_string(word, repeat))
def new_string(word: str, repeat: int): return word * repeat word = input() repeat = int(input()) print(new_string(word, repeat))
with open("test_cases.txt", "w") as file: file.write("discount_factor, safety_distance, ghostbuster_mode\n") discount_factors = [1.0, 0.9, 0.8, 0.7, 0.6] safety_distances = [4, 3, 2, 1] ghostbuster_modes = ["inactive", "defensive", "offensive"] file.write("-----------------\n") for discount_fact...
with open('test_cases.txt', 'w') as file: file.write('discount_factor, safety_distance, ghostbuster_mode\n') discount_factors = [1.0, 0.9, 0.8, 0.7, 0.6] safety_distances = [4, 3, 2, 1] ghostbuster_modes = ['inactive', 'defensive', 'offensive'] file.write('-----------------\n') for discount_fact...
class Employee: def __init__(self,myname): self.myname = myname self.dt = self.Details() def mydisplay(self): print("The employee name is: ", self.myname) print('*'*25) self.dt.mydisplay1() class Details: def __init__(self): self.staffno ...
class Employee: def __init__(self, myname): self.myname = myname self.dt = self.Details() def mydisplay(self): print('The employee name is: ', self.myname) print('*' * 25) self.dt.mydisplay1() class Details: def __init__(self): self.staffno = 6...
""" What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? """ def prime_factors(num): i = 2 factors = [] while i * i <= num: if num % i: i += 1 else: num //= i factors.append(i) if num > 1: factors....
""" What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? """ def prime_factors(num): i = 2 factors = [] while i * i <= num: if num % i: i += 1 else: num //= i factors.append(i) if num > 1: factors.a...
# Write a program that asks the user for a Login Name and password. Then when they type "lock", they need to type in their name and password to unlock the program. user = str(input("Please provide a loginname: ")) unlock_user = str() password = str(input("Please provide your password: ")) unlock_pw = str() lock = str()...
user = str(input('Please provide a loginname: ')) unlock_user = str() password = str(input('Please provide your password: ')) unlock_pw = str() lock = str() print("To lock your computer type 'lock'.") while lock != 'lock': lock = input('What is your command? ') while unlock_user != user: unlock_user = input('En...
# # @lc app=leetcode id=791 lang=python3 # # [791] Custom Sort String # # @lc code=start class Solution: def customSortString(self, S: str, T: str) -> str: cnt = Counter(T) res = '' for c in S: res += cnt[c] * c del(cnt[c]) for c, t in cnt.items(): ...
class Solution: def custom_sort_string(self, S: str, T: str) -> str: cnt = counter(T) res = '' for c in S: res += cnt[c] * c del cnt[c] for (c, t) in cnt.items(): res += t * c return res
# # PySNMP MIB module Nortel-MsCarrier-MscPassport-DisdnNI2MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Nortel-MsCarrier-MscPassport-DisdnNI2MIB # Produced by pysmi-0.3.4 at Wed May 1 14:29:44 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davw...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, constraints_intersection, constraints_union, value_range_constraint, value_size_constraint) ...
expected_output = { "tag": { "1": { "topo_type": "unicast", "topo_name": "base", "tid": 0, "topo_id": "0x0", "flex_algo": { 128: { "prefix": { "2.2.2.2": { "pre...
expected_output = {'tag': {'1': {'topo_type': 'unicast', 'topo_name': 'base', 'tid': 0, 'topo_id': '0x0', 'flex_algo': {128: {'prefix': {'2.2.2.2': {'prefix_attr': {'x_flag': False, 'r_flag': False, 'n_flag': True}, 'subnet': '32', 'source_router_id': '2.2.2.2', 'algo': {0: {'sid_index': 23, 'bound': True}, 1: {}}, 'vi...
# Link: https://leetcode.com/problems/rotate-array/ # Time: O(N) # Space: O(1) # Given an array of numbers: [1, 2, 3, 4, 5] and k = 3 # 1. reverse the entire array # - [5, 4, 3, 2, 1] # # 2. reverse from 0 to k - 1 # - [3, 4, 5, 2, 1] # # 3. reverse from k to len(arr) - 1 # - [3, 4, 5, 1, 2] def reverse(nums...
def reverse(nums, start, end): while start < end: (nums[start], nums[end]) = (nums[end], nums[start]) start += 1 end -= 1 def rotate(nums, k): k = k % len(nums) reverse(nums, 0, len(nums) - 1) reverse(nums, 0, k - 1) reverse(nums, k, len(nums) - 1) def main(): nums = [1...
book = [] used_words = set() while(True): try: book += [input().split(" ")] except: break for line in book: output_line = "" for word in line: if word.lower() not in used_words: output_line += word if len(output_line) == 0 else " " + word used_words.a...
book = [] used_words = set() while True: try: book += [input().split(' ')] except: break for line in book: output_line = '' for word in line: if word.lower() not in used_words: output_line += word if len(output_line) == 0 else ' ' + word used_words.add(wor...
#!/usr/bin/env python2 ''' Copyright 2016 Aaron Stephens <aaron@icebrg.io>, ICEBRG 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 b...
""" Copyright 2016 Aaron Stephens <aaron@icebrg.io>, ICEBRG Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agre...
# Copyright 2020 Syntio Inc. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, s...
""" Contains all of the custom exceptions raised by the Persistor. """ class Persistorconfigurationexception(Exception): """ Raised when an App Configuration setting is not present or has an invalid value. """ class Generalbindingconfigurationexception(PersistorConfigurationException): """ Raised ...
# Exploration # env: the environment where the policy(ai) will be # normalizer: normalize the states/inputs # policy: ai # direction: # delta: perturbation class Explorator(): def __init__(self, hyperParameters, normalizer, policy, enviroment): self.hyperParameters = hyperParameters self.enviromen...
class Explorator: def __init__(self, hyperParameters, normalizer, policy, enviroment): self.hyperParameters = hyperParameters self.enviroment = enviroment self.normalizer = normalizer self.policy = policy def explore(self, direction=None, delta=None): state = self.envir...
print(__file__) #these aliases are used to connect pizza boxes and amplifiers i0 = pba1.adc3 i0_amp.par = i0 i0.amp = i0_amp it = pba1.adc4 it_amp.par = it it.amp = it_amp ir = pba1.adc5 ir_amp.par = ir ir.amp = ir_amp ''' iff = pba1.adc6 iff_amp.par = iff iff.amp = iff_amp ir = pba2.adc6 ir_amp.par = ir ir.amp ...
print(__file__) i0 = pba1.adc3 i0_amp.par = i0 i0.amp = i0_amp it = pba1.adc4 it_amp.par = it it.amp = it_amp ir = pba1.adc5 ir_amp.par = ir ir.amp = ir_amp '\niff = pba1.adc6\niff_amp.par = iff\niff.amp = iff_amp\n\nir = pba2.adc6\nir_amp.par = ir\nir.amp = ir_amp\n'
""" Problem : https://en.wikipedia.org/wiki/Longest_common_subsequence_problem """ def longest_common_subsequence(s1, s2): # lengths of strings s1 and s2 m, n = len(s1), len(s2) # to cache the results cache = [[0 for j in range(n + 1)] for i in range(m + 1)] for i, character_s1 in enumerate(s1): ...
""" Problem : https://en.wikipedia.org/wiki/Longest_common_subsequence_problem """ def longest_common_subsequence(s1, s2): (m, n) = (len(s1), len(s2)) cache = [[0 for j in range(n + 1)] for i in range(m + 1)] for (i, character_s1) in enumerate(s1): for (j, character_s2) in enumerate(s2): ...
# GYP file to build unit tests. { 'includes': [ 'apptype_console.gypi', 'common.gypi', ], 'targets': [ { 'target_name': 'addTest', 'type': 'executable', 'include_dirs' : [ '../src/core', ], 'sources': [ '../experimental/Intersection/AddTestOutput/main.cpp'...
{'includes': ['apptype_console.gypi', 'common.gypi'], 'targets': [{'target_name': 'addTest', 'type': 'executable', 'include_dirs': ['../src/core'], 'sources': ['../experimental/Intersection/AddTestOutput/main.cpp'], 'dependencies': ['skia_lib.gyp:skia_lib', 'experimental.gyp:experimental', 'pdf.gyp:pdf'], 'conditions':...
#!/usr/bin/env python3 out_segments = [] with open("8/input.txt", "r") as fd: for line in fd: out_segments.extend(line.rstrip().split(" | ")[1].split(" ")) unique_count = 0 for seg in out_segments: unique_count += 1 if len(seg) in [2, 4, 3, 7] else 0 print(unique_count)
out_segments = [] with open('8/input.txt', 'r') as fd: for line in fd: out_segments.extend(line.rstrip().split(' | ')[1].split(' ')) unique_count = 0 for seg in out_segments: unique_count += 1 if len(seg) in [2, 4, 3, 7] else 0 print(unique_count)
def debug_banks(banks): steps = 0 debugged = [] while debugged.count(banks) < 2: steps += 1 blocks = max(banks) cand_index = banks.index(blocks) banks[cand_index] = 0 while blocks != 0: cand_index += 1 blocks -= 1 banks[cand_index...
def debug_banks(banks): steps = 0 debugged = [] while debugged.count(banks) < 2: steps += 1 blocks = max(banks) cand_index = banks.index(blocks) banks[cand_index] = 0 while blocks != 0: cand_index += 1 blocks -= 1 banks[cand_index %...
""" file: predict author: fupeng date: 2017/5/17 """
""" file: predict author: fupeng date: 2017/5/17 """
s = input() def conv2num(c): n = ord(c) if 97 <= n <= 122: return n - 96 elif 65 <= n <= 90: return n - 38 elif 48 <= n <= 57: return n + 5 else: return 0 num_str = '' for i in range(len(s)): num_str += (bin(conv2num(s[i])))[2:].zfill(6) for i in range(0, len...
s = input() def conv2num(c): n = ord(c) if 97 <= n <= 122: return n - 96 elif 65 <= n <= 90: return n - 38 elif 48 <= n <= 57: return n + 5 else: return 0 num_str = '' for i in range(len(s)): num_str += bin(conv2num(s[i]))[2:].zfill(6) for i in range(0, len(num_s...
"""Package for drf-jsonmask""" __project__ = "drf_jsonmask" __version__ = "0.1.1" VERSION = __project__ + '-' + __version__
"""Package for drf-jsonmask""" __project__ = 'drf_jsonmask' __version__ = '0.1.1' version = __project__ + '-' + __version__
#!/usr/bin/python3 def multiply_by_2(a_dictionary): a = {} for x, y in a_dictionary.items(): a.update({x: y*2}) return a
def multiply_by_2(a_dictionary): a = {} for (x, y) in a_dictionary.items(): a.update({x: y * 2}) return a
class ActionResponse: def __init__(self, serverError, isSuccessful, statusCode, message, fullName, messageCode): self.serverError = serverError self.isSuccessful = isSuccessful self.statusCode = statusCode self.message = message self.fullName = fullName self.messageCo...
class Actionresponse: def __init__(self, serverError, isSuccessful, statusCode, message, fullName, messageCode): self.serverError = serverError self.isSuccessful = isSuccessful self.statusCode = statusCode self.message = message self.fullName = fullName self.messageC...
""" @author: acfromspace """ def count_substring(string, sub_string): count = 0 for index in range(len(string)): if string[index:].startswith(sub_string): count += 1 return count print("count_substring():", count_substring("ABCDEFEFE", "EFE"))
""" @author: acfromspace """ def count_substring(string, sub_string): count = 0 for index in range(len(string)): if string[index:].startswith(sub_string): count += 1 return count print('count_substring():', count_substring('ABCDEFEFE', 'EFE'))
print ('Program untuk menentukan bilangan terbesar') def pengulangan(): print ('Masukkan 3 bilangan yang diinginkan!') a=int(input('bilangan1 = ')) b=int(input('bilangan2 = ')) c=int(input('bilangan3 = ')) if a>b and a>c: if b>c: print (a, 'adalah bilangan terbesar dari', b, 'dan', c,) else: print (a, ...
print('Program untuk menentukan bilangan terbesar') def pengulangan(): print('Masukkan 3 bilangan yang diinginkan!') a = int(input('bilangan1 = ')) b = int(input('bilangan2 = ')) c = int(input('bilangan3 = ')) if a > b and a > c: if b > c: print(a, 'adalah bilangan terbesar dari...
with open('arquivo.txt', 'w') as arq: arq.write('Felipe\n') arq.write('Tamara\n') arq.write('Malvo\n') with open('arquivo.txt', 'r') as arq: for l in arq.readlines(): print(f'{l}')
with open('arquivo.txt', 'w') as arq: arq.write('Felipe\n') arq.write('Tamara\n') arq.write('Malvo\n') with open('arquivo.txt', 'r') as arq: for l in arq.readlines(): print(f'{l}')
class Solution: def countComponents(self, n: int, edges: List[List[int]]) -> int: # key: num, val: self.graph = {} for i in range(n): self.graph[i] = i for u, v in edges: self.union(u, v) parents = set() for i in range(n): parent ...
class Solution: def count_components(self, n: int, edges: List[List[int]]) -> int: self.graph = {} for i in range(n): self.graph[i] = i for (u, v) in edges: self.union(u, v) parents = set() for i in range(n): parent = self.find(i) ...
nome = input('nome do arquivo: ') arquivo = open(nome, 'r', encoding='UTF-8') arquivo_saida = open('arquivo_saida', 'w', encoding='UTF-8') branco = 0 for linha in arquivo: linha = linha.rstrip() linha = linha.replace(' ', '') if linha == '': branco += 1 else: branco = 0 if branco < 2...
nome = input('nome do arquivo: ') arquivo = open(nome, 'r', encoding='UTF-8') arquivo_saida = open('arquivo_saida', 'w', encoding='UTF-8') branco = 0 for linha in arquivo: linha = linha.rstrip() linha = linha.replace(' ', '') if linha == '': branco += 1 else: branco = 0 if branco < 2...
INIT_MSG = (''' __ ___ __ ______ _ __ / |/ /__ / /_____ _/ ____/___ __________ ___ ___ ____| |/ / / /|_/ / _ \/ __/ __ `/ /_ / __ `/ ___/ __ `__ \/ _ \/ ___/ / / / / / __/ /_/ /_/ / __/ / /_/ / / / / / / / / __/ / / | /_/ /_/\___/\__/\__,_/_/ \__,...
init_msg = ' __ ___ __ ______ _ __\n / |/ /__ / /_____ _/ ____/___ __________ ___ ___ ____| |/ /\n / /|_/ / _ \\/ __/ __ `/ /_ / __ `/ ___/ __ `__ \\/ _ \\/ ___/ / \n / / / / __/ /_/ /_/ / __/ / /_/ / / / / / / / / __/ / / | \n/_/ /_/\\___/\\__/\\__,_/_/ ...
class MessageTrigger: async def execute_message(self, client, msg): raise NotImplementedError( "'execute_message' is not implemented for this message trigger" ) async def get_trigger_score(self, client, msg): raise NotImplementedError( "'get_trigger_score' is not...
class Messagetrigger: async def execute_message(self, client, msg): raise not_implemented_error("'execute_message' is not implemented for this message trigger") async def get_trigger_score(self, client, msg): raise not_implemented_error("'get_trigger_score' is not implemented for this message ...
# https://docs.python.org/3/reference/compound_stmts.html#the-for-statement def country_to_caps(): countries = ['USA','France','Germany'] capitols = ['Washington, D.C.', 'Paris', 'Berlin'] countries_to_capitols = dict(zip(countries, capitols)) return countries_to_capitols def simple_for(): count...
def country_to_caps(): countries = ['USA', 'France', 'Germany'] capitols = ['Washington, D.C.', 'Paris', 'Berlin'] countries_to_capitols = dict(zip(countries, capitols)) return countries_to_capitols def simple_for(): countries_to_capitols = country_to_caps() capitols_to_countries = {} for (...
def print_formatted(number): xl = len(str(number)) yl = len(str(oct(number)).replace("0o", "")) zl = len(str(hex(number)).replace("0x", "")) bl = len(str(bin(number)).replace("0b", "")) #print(number, str(bin(number)).replace("0b", ""), bl) for n in range(1, number+1): x = str(n).rjust(...
def print_formatted(number): xl = len(str(number)) yl = len(str(oct(number)).replace('0o', '')) zl = len(str(hex(number)).replace('0x', '')) bl = len(str(bin(number)).replace('0b', '')) for n in range(1, number + 1): x = str(n).rjust(bl) y = str(oct(n)).replace('0o', '').rjust(bl) ...
""" Initial S-boxes Sb1 definition """ def Sb1(bitStringArray): x = int("".join((map(str, bitStringArray))), 2) if x == 0: result = 1 elif x == 1: result = 0 elif x == 2: result = 5 elif x == 3: result = 3 elif x == 4: result = int("e", 16) elif x ==...
""" Initial S-boxes Sb1 definition """ def sb1(bitStringArray): x = int(''.join(map(str, bitStringArray)), 2) if x == 0: result = 1 elif x == 1: result = 0 elif x == 2: result = 5 elif x == 3: result = 3 elif x == 4: result = int('e', 16) elif x == 5:...
def ducci_sequence(*ns): while True: yield ns ns = tuple(abs(ns[i - 1] - ns[i]) for i in range(len(ns))) def ducci(*ns): known = set() for ns in ducci_sequence(*ns): print(ns) if ns in known or set(ns) == {0}: break known.add(ns) return len(known) + 1...
def ducci_sequence(*ns): while True: yield ns ns = tuple((abs(ns[i - 1] - ns[i]) for i in range(len(ns)))) def ducci(*ns): known = set() for ns in ducci_sequence(*ns): print(ns) if ns in known or set(ns) == {0}: break known.add(ns) return len(known) +...
class FileCheckerError(Exception): """The exception raised when detecting an error during style checking. The argument can be a string (the description of the error), or a list of strings, if the description of the error spans over multiple lines. """ pass
class Filecheckererror(Exception): """The exception raised when detecting an error during style checking. The argument can be a string (the description of the error), or a list of strings, if the description of the error spans over multiple lines. """ pass
coco_categories = { 0: 'unlabeled', 1: 'person', 2: 'bicycle', 3: 'car', 4: 'motorcycle', 5: 'airplane', 6: 'bus', 7: 'train', 8: 'truck', 9: 'boat', 10: 'traffic light', 11: 'fire hydrant', 12: 'stop sign', 13: 'parking meter', 14: 'bench', 15: 'bird', 16: 'cat', 17: 'dog', 18: 'horse', 19: 'sheep'...
coco_categories = {0: 'unlabeled', 1: 'person', 2: 'bicycle', 3: 'car', 4: 'motorcycle', 5: 'airplane', 6: 'bus', 7: 'train', 8: 'truck', 9: 'boat', 10: 'traffic light', 11: 'fire hydrant', 12: 'stop sign', 13: 'parking meter', 14: 'bench', 15: 'bird', 16: 'cat', 17: 'dog', 18: 'horse', 19: 'sheep', 20: 'cow', 21: 'ele...
# Python program to check whether an alphabet is vowel or consonant. # Step 1: Get a character from the user # Step 2: Check whether the input is vowel or consonant by using the python built-in functions like(lower(), upper()). # Step 3: If the character is vowel print Vowel otherwise print Consonant # Step 4: E...
x = input('') if x == 'A' or x == 'a' or x == 'E' or (x == 'e') or (x == 'I') or (x == 'i') or (x == 'O') or (x == 'o') or (x == 'U') or (x == 'u'): print('Vowel') else: print('Consonant')
StringPieces = ["AY8PMPAR", "NGAT", "ME", "OME.", "ETINGAT2", "7MA", "Y8PMPA", "RKHO", "ME", "MEE", "TIN", "GAT27M", "KHOME.", "MEETI", "27MAY8", "PMP", "ARKH"] def compareStrings(i, j): count = 0 for k in range(len(StringPieces[i])): if StringPieces[j][count] == StringPieces[i][k]: ...
string_pieces = ['AY8PMPAR', 'NGAT', 'ME', 'OME.', 'ETINGAT2', '7MA', 'Y8PMPA', 'RKHO', 'ME', 'MEE', 'TIN', 'GAT27M', 'KHOME.', 'MEETI', '27MAY8', 'PMP', 'ARKH'] def compare_strings(i, j): count = 0 for k in range(len(StringPieces[i])): if StringPieces[j][count] == StringPieces[i][k]: if k ...
def convert_num(num_str: str): """ >>> convert_num("12345") 12345 >>> convert_num("-12345") -12345 >>> convert_num("12345-") -12345 >>> convert_num("-12345-") 12345 """ num, sign = num_str[:-1], num_str[-1] if sign == "-": return -int(num) return int(num_st...
def convert_num(num_str: str): """ >>> convert_num("12345") 12345 >>> convert_num("-12345") -12345 >>> convert_num("12345-") -12345 >>> convert_num("-12345-") 12345 """ (num, sign) = (num_str[:-1], num_str[-1]) if sign == '-': return -int(num) return int(nu...
# pylint: skip-file # flake8: noqa def main(): ''' ansible oc module for processing templates ''' module = AnsibleModule( argument_spec=dict( kubeconfig=dict(default='/etc/origin/master/admin.kubeconfig', type='str'), state=dict(default='present', type='str', choices=[...
def main(): """ ansible oc module for processing templates """ module = ansible_module(argument_spec=dict(kubeconfig=dict(default='/etc/origin/master/admin.kubeconfig', type='str'), state=dict(default='present', type='str', choices=['present', 'list']), debug=dict(default=False, type='bool'), namespace=...
s=input() t=input() k=int(input()) l=min(len(s),len(t)) m=0 i=0 if (len(s)+len(t)<k): print("Yes") exit() while(i<l): if s[i]!=t[i]: break else: i+=1 p=len(s)-i q=len(t)-i if (p+q<=k and (k-p-q)%2==0): print("Yes") else: print("No")
s = input() t = input() k = int(input()) l = min(len(s), len(t)) m = 0 i = 0 if len(s) + len(t) < k: print('Yes') exit() while i < l: if s[i] != t[i]: break else: i += 1 p = len(s) - i q = len(t) - i if p + q <= k and (k - p - q) % 2 == 0: print('Yes') else: print('No')
class Heap: def __init__(self): self.items = [0] self.size = 0 def empty(self): return len(self.items) == 1 def insert(self, *k): self.size += 1 self.items.append(k[0]) self.sift_up() def extract_minimum(self): root = self.items[1] self....
class Heap: def __init__(self): self.items = [0] self.size = 0 def empty(self): return len(self.items) == 1 def insert(self, *k): self.size += 1 self.items.append(k[0]) self.sift_up() def extract_minimum(self): root = self.items[1] self...
max = 0 try: while True: a=int(input("Masukkan Bilangan: ")) if max < a: max = a if a == 0: break print("\nBilangan Terbesar Adalah :", max) except: print ("Masukkan Tipe Data Integer!")
max = 0 try: while True: a = int(input('Masukkan Bilangan: ')) if max < a: max = a if a == 0: break print('\nBilangan Terbesar Adalah :', max) except: print('Masukkan Tipe Data Integer!')
def quit(reason): print("exited exit reason: ", reason) exit(reason) def help(): print("you can find all the commands on our wiki(https://github.com/lucasammer/handydandy/wiki)") class colors: HEADER = '\033[95m' OKBLUE = '\033[94m' OKCYAN = '\033[96m' OKGREEN = '\033[92m' WARNING = '\033[93m' FAIL = ...
def quit(reason): print('exited exit reason: ', reason) exit(reason) def help(): print('you can find all the commands on our wiki(https://github.com/lucasammer/handydandy/wiki)') class Colors: header = '\x1b[95m' okblue = '\x1b[94m' okcyan = '\x1b[96m' okgreen = '\x1b[92m' warning = '\...
hiddenimports = [ 'pysam.Pileup' , 'pysam.bcftools' , 'pysam.calignedsegment' , 'pysam.calignmentfile' , 'pysam.cbcf' , 'pysam.cfaidx' , 'pysam.config' , 'pysam.csamfile' , 'pysam.ctabix' ...
hiddenimports = ['pysam.Pileup', 'pysam.bcftools', 'pysam.calignedsegment', 'pysam.calignmentfile', 'pysam.cbcf', 'pysam.cfaidx', 'pysam.config', 'pysam.csamfile', 'pysam.ctabix', 'pysam.ctabixproxies', 'pysam.cutils', 'pysam.cvcf', 'pysam.include', 'pysam.libchtslib', 'pysam.namedtuple', 'pysam.samtools', 'pysam.utils...
# -*- coding: utf-8 -*- largura = int(input("digite a largura: ")) altura = int(input("digite a altura: ")) while altura > 0: x = 0 while x < largura: print("#" , end = '') x+=1 altura = altura - 1 print()
largura = int(input('digite a largura: ')) altura = int(input('digite a altura: ')) while altura > 0: x = 0 while x < largura: print('#', end='') x += 1 altura = altura - 1 print()
""" Make a program that reads the wage of an employee, and calculate its increase. For wages up to US$1,250.00, calculate a increase of 15%. For bigger wages the increase is of 10%. NOTE: Wage calculates for month. """ wage = float(input('Enter the wage: ')) if wage <= 1250: new_wage = wage * 1.15 else: ne...
""" Make a program that reads the wage of an employee, and calculate its increase. For wages up to US$1,250.00, calculate a increase of 15%. For bigger wages the increase is of 10%. NOTE: Wage calculates for month. """ wage = float(input('Enter the wage: ')) if wage <= 1250: new_wage = wage * 1.15 else: new_...
class TrainingException(Exception): pass class PublishingException(Exception): pass class ResourceConfigDownloadFailed(Exception): pass
class Trainingexception(Exception): pass class Publishingexception(Exception): pass class Resourceconfigdownloadfailed(Exception): pass
__all__ = [ 'date_utils', 'file_utils', 'filter_utils', 'logging_utils' ]
__all__ = ['date_utils', 'file_utils', 'filter_utils', 'logging_utils']
expected_output = { "session_type": { "AnyConnect": { "username": { "XXX": { "index": { 62535: { "assigned_ip": "10.25.112.2", "audt_sess_id": "42626e2b0f4470005e7b60ea", ...
expected_output = {'session_type': {'AnyConnect': {'username': {'XXX': {'index': {62535: {'assigned_ip': '10.25.112.2', 'audt_sess_id': '42626e2b0f4470005e7b60ea', 'bytes': {'rx': 187465614, 'tx': 355483199}, 'dtls_tunnel': '(1)SHA1', 'duration': '1d 1h:36m:09s', 'encryption': '(1)none', 'group_policy': 'GroupPolicy_RS...
""" Module: 'struct' on pySBC 1.13.0 with FW1.5.12-264 """ # MCU: (sysname='pySBC', nodename='pySBC', release='1.13.0 with FW1.5.12', version='v1.13-264-gb0c6ec5bb-dirty on 2020-11-25', machine='simpleRTK-SBC with STM32F745') # Stubber: 1.3.4 def calcsize(): pass def pack(): pass def pack_into(): pass de...
""" Module: 'struct' on pySBC 1.13.0 with FW1.5.12-264 """ def calcsize(): pass def pack(): pass def pack_into(): pass def unpack(): pass def unpack_from(): pass
s = ' -43' def myAtoi(s): """ :type str: str :rtype: int """ s = s.lstrip() if not s: return 0 sample = '' if s[0] == '-' or s[0] == '+': sample = s[0] s = s[1:] end = len(s) for i, char in enumerate(s): if char not in ['0', '1', '2', '3', '4',...
s = ' -43' def my_atoi(s): """ :type str: str :rtype: int """ s = s.lstrip() if not s: return 0 sample = '' if s[0] == '-' or s[0] == '+': sample = s[0] s = s[1:] end = len(s) for (i, char) in enumerate(s): if char not in ['0', '1', '2', '3', '4'...
# see LICENSE class Pdu(object): def __init__(self, pdu, len_smsc, cnt=1, seq=1): self.pdu = pdu.upper() self.length = len(pdu) / 2 - len_smsc self.cnt = cnt self.seq = seq
class Pdu(object): def __init__(self, pdu, len_smsc, cnt=1, seq=1): self.pdu = pdu.upper() self.length = len(pdu) / 2 - len_smsc self.cnt = cnt self.seq = seq
# # PySNMP MIB module EATON-EPDU-MA-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/EATON-EPDU-MA-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:59:03 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Ma...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, constraints_union, single_value_constraint, value_size_constraint, value_range_constraint) ...
card_pub_key = 15335876 door_pub_key = 15086442 def find_loop_size(subject_num, pub_key): value = 1 loops = 0 while value != pub_key: value *= subject_num value %= 20201227 loops += 1 return loops def find_enc_key(pub_key, loop_size): value = 1 for i in range(loop_...
card_pub_key = 15335876 door_pub_key = 15086442 def find_loop_size(subject_num, pub_key): value = 1 loops = 0 while value != pub_key: value *= subject_num value %= 20201227 loops += 1 return loops def find_enc_key(pub_key, loop_size): value = 1 for i in range(loop_size)...
class ImpalaQueryDirector: def __init__(self, query_builder): self.query_builder = query_builder def build_query( self, regions=None, genes=None, effect_types=None, family_ids=None, person_ids=None, inheritance=None, ...
class Impalaquerydirector: def __init__(self, query_builder): self.query_builder = query_builder def build_query(self, regions=None, genes=None, effect_types=None, family_ids=None, person_ids=None, inheritance=None, roles=None, sexes=None, variant_type=None, real_attr_filter=None, ultra_rare=None, fre...
set_name(0x8013015C, "PresOnlyTestRoutine__Fv", SN_NOWARN) set_name(0x80130184, "FeInitBuffer__Fv", SN_NOWARN) set_name(0x801301AC, "FeAddEntry__Fii8TXT_JUSTiP7FeTableP5CFont", SN_NOWARN) set_name(0x8013021C, "FeAddTable__FP11FeMenuTablei", SN_NOWARN) set_name(0x8013029C, "FeDrawBuffer__Fv", SN_NOWARN) set_name(0x80130...
set_name(2148729180, 'PresOnlyTestRoutine__Fv', SN_NOWARN) set_name(2148729220, 'FeInitBuffer__Fv', SN_NOWARN) set_name(2148729260, 'FeAddEntry__Fii8TXT_JUSTiP7FeTableP5CFont', SN_NOWARN) set_name(2148729372, 'FeAddTable__FP11FeMenuTablei', SN_NOWARN) set_name(2148729500, 'FeDrawBuffer__Fv', SN_NOWARN) set_name(2148730...
"""Reverse a linked list in place iteratively and recursively. Example: LL = 1 -> 2 -> 3 -> 4 Reversed LL = 1 <- 2 <- 3 <- 4 """ class ListNode(object): def __init__(self, x): self.val = x self.next = None def reverse_recursively(ll): head = None def traverse(ll): ...
"""Reverse a linked list in place iteratively and recursively. Example: LL = 1 -> 2 -> 3 -> 4 Reversed LL = 1 <- 2 <- 3 <- 4 """ class Listnode(object): def __init__(self, x): self.val = x self.next = None def reverse_recursively(ll): head = None def traverse(ll): ...
# https://leetcode.com/problems/divide-two-integers/description/ # # algorithms # Medium (15.74%) # Total Accepted: 149.6k # Total Submissions: 950.6k # beats 38.54% of python submissions class Solution(object): def divide(self, dividend, divisor): """ :type dividend: int :type divisor:...
class Solution(object): def divide(self, dividend, divisor): """ :type dividend: int :type divisor: int :rtype: int """ symbol = -1 if dividend > 0 and divisor > 0 or (dividend < 0 and divisor < 0): symbol = 1 dividend = int(math.fabs(divi...
# # PySNMP MIB module ZHNSYSTEM (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ZHNSYSTEM # Produced by pysmi-0.3.4 at Wed May 1 15:46:47 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...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, value_size_constraint, constraints_union, constraints_intersection, single_value_constraint) ...
__author__ = "Loran425" def majority(data): count = {} for char in data: if char not in count.keys(): count[char] = 1 else: count[char] += 1 if count[char] >= len(data) // 2: return char # Break as soon as we find a majority return None...
__author__ = 'Loran425' def majority(data): count = {} for char in data: if char not in count.keys(): count[char] = 1 else: count[char] += 1 if count[char] >= len(data) // 2: return char return None if __name__ == '__main__': array = [...
def makefield(n, m, mines): dx = (-1, -1, -1, 0, 0, 1, 1, 1) dy = (-1, 0, 1, -1, 1, -1, 0, 1) field = [] for k in range(n+2): field.append([0] * (m + 2)) for minei, miniej in mines: for k in range(len(dx)): field[minei + dx[k]][miniej + dy[k]] += 1 for minei, minej in...
def makefield(n, m, mines): dx = (-1, -1, -1, 0, 0, 1, 1, 1) dy = (-1, 0, 1, -1, 1, -1, 0, 1) field = [] for k in range(n + 2): field.append([0] * (m + 2)) for (minei, miniej) in mines: for k in range(len(dx)): field[minei + dx[k]][miniej + dy[k]] += 1 for (minei, min...
ga = { "population": 30, "n_gen": 45, "seed": 873, "mut_rate": 0.4, "cross_rate": 1 } model = { "map_size": 50, "min_len": 5, # minimal possible distance in meters "max_len": 15, # maximal possible disance to go straight in meters "len_step": 1, "pos_step": 1 } files = { ...
ga = {'population': 30, 'n_gen': 45, 'seed': 873, 'mut_rate': 0.4, 'cross_rate': 1} model = {'map_size': 50, 'min_len': 5, 'max_len': 15, 'len_step': 1, 'pos_step': 1} files = {'ga_archive': '.\\GA_archive\\', 'ga_conv': '.\\', 'tc_img': '.\\TC_img\\', 'tc_file': '.\\TC_file\\'}
#Python program to illustrate the working of slicing function #Using List (Without steps value) my_List = [0,1,2,3,4,5,6,7,8,9] #index 0,1,2,3,4,5,6,7,8,9 #index -10,-9,-8,-7,-6,-5,-4,-3,-2,-1 slicedValueObject = slice(0,5,2) print(my_List[slicedValueObject])
my__list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] sliced_value_object = slice(0, 5, 2) print(my_List[slicedValueObject])
#!/usr/bin/env python __author__ = "Pallab Maji" __copyright__ = "Copyright 2019-2020, codesteller" __license__ = "MIT" """ Created by : codesteller Date : 06/12/19 Description : config.py Add Description Here """ # Paths DBDIR = "/home/codesteller/dataset/idd/IDD...
__author__ = 'Pallab Maji' __copyright__ = 'Copyright 2019-2020, codesteller' __license__ = 'MIT' '\nCreated by : codesteller \nDate : 06/12/19\nDescription : config.py\n\nAdd Description Here\n\n' dbdir = '/home/codesteller/dataset/idd/IDD_Detection'
""" Datos de entrada edad_uno-->e_uno-->int edad_dos-->e_dos-->int edad_tres-->e_tres-->int Datos de salida promedio-->p-->float """ #Entradas e_uno=int(input("Digite edad uno: ")) e_dos=int(input("Digite edad dos: ")) e_tres=int(input("Digite edad tres: ")) #Caja negra p=(e_uno+e_dos+e_tres)/3#float #Saidas print(f"El...
""" Datos de entrada edad_uno-->e_uno-->int edad_dos-->e_dos-->int edad_tres-->e_tres-->int Datos de salida promedio-->p-->float """ e_uno = int(input('Digite edad uno: ')) e_dos = int(input('Digite edad dos: ')) e_tres = int(input('Digite edad tres: ')) p = (e_uno + e_dos + e_tres) / 3 print(f'El promedio es: {p}')
def pytest_addoption(parser): group = parser.getgroup('general') group.addoption('--force_run', action='store_true', dest='force_run', default=False, help='force run ahAPICore case.')
def pytest_addoption(parser): group = parser.getgroup('general') group.addoption('--force_run', action='store_true', dest='force_run', default=False, help='force run ahAPICore case.')
vowels = ["a", "A", "e", "E", "i", "I", "o", "O", "u", "U"] def has_vowels(l): for x in l: for v in vowels: if x == v: return True return False assert has_vowels("banana") == True assert has_vowels("ubuntu") == True assert has_vowels("QQQQ") == False assert has_vowels("wyrd"...
vowels = ['a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U'] def has_vowels(l): for x in l: for v in vowels: if x == v: return True return False assert has_vowels('banana') == True assert has_vowels('ubuntu') == True assert has_vowels('QQQQ') == False assert has_vowels('wyrd'...
# # PySNMP MIB module FOUNDRY-SN-TRAP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/FOUNDRY-SN-TRAP-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:02:05 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_size_constraint, constraints_union, value_range_constraint, single_value_constraint) ...
class Solution: def remove_nonalph(self, s): letters = 'abcdefghijklmnopqrstuvwxyz0123456789' s = s.lower() res = [] for l in s: if l in letters: res.append(l) return "".join(res) def isPalindrome(self, s: str) -> bool: res = True ...
class Solution: def remove_nonalph(self, s): letters = 'abcdefghijklmnopqrstuvwxyz0123456789' s = s.lower() res = [] for l in s: if l in letters: res.append(l) return ''.join(res) def is_palindrome(self, s: str) -> bool: res = True ...
class Points: def __init__(self): self.points = 0 def lines(self, i): if i == 1: self.points = self.points + 40 if i == 2: self.points = self.points + 100 if i == 3: self.points = self.points + 300 if i == 4: self.points = ...
class Points: def __init__(self): self.points = 0 def lines(self, i): if i == 1: self.points = self.points + 40 if i == 2: self.points = self.points + 100 if i == 3: self.points = self.points + 300 if i == 4: self.points =...
"""Basic tests for the fixtures.""" def test_extensions_option(pg_engine): """Verifies the --pg-extensions option works. This test entirely relies on the test suite being executed with:: --pg-extensions=btree_gin,,btree_gist """ are_installed = pg_engine.execute(""" SELECT ...
"""Basic tests for the fixtures.""" def test_extensions_option(pg_engine): """Verifies the --pg-extensions option works. This test entirely relies on the test suite being executed with:: --pg-extensions=btree_gin,,btree_gist """ are_installed = pg_engine.execute("\n SELECT\n E...
# Author : Paul Nadal # Last update : 16 October 2020 # EPFL Rocket Team, 1015 Lausanne, Switzerland def motorReader(motorFilePath): # MOTORREADER extracts the raw motor data from RASP formated text file # named 'motorFilePath'. # ------------------------------------------------------------------------- ...
def motor_reader(motorFilePath): with open(motorFilePath, 'r') as file: line = file.readline() info = line.split() t = [] t = [] while line: line = file.readline() tmp = line.split() if tmp: t.append(float(tmp[0])) ...
### As you know, I recieved TLE ...... :( def main(): # input N, W = map(int, input().split()) STP = [list(map(int, input().split())) for _ in range(N)] # compute stop = 0 for i in range(N): if stop < STP[i][1]: stop = STP[i][1] total = [0 for _ in range(stop)] for i in range(N): for j i...
def main(): (n, w) = map(int, input().split()) stp = [list(map(int, input().split())) for _ in range(N)] stop = 0 for i in range(N): if stop < STP[i][1]: stop = STP[i][1] total = [0 for _ in range(stop)] for i in range(N): for j in range(stop): if STP[i][0...
# # PySNMP MIB module FASTPATH-INVENTORY-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/FASTPATH-INVENTORY-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:12:05 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (d...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, constraints_union, constraints_intersection, value_range_constraint, single_value_constraint) ...
def p(var): print(var) return a=1 b=1.5 c=1234567890123456 d="444" e='c' p('Hello, world!') p(c) for i in range(1,10): p(i) j=1 while j<10: p(j) j+=1 if 1==2: p(666) else: p(777)
def p(var): print(var) return a = 1 b = 1.5 c = 1234567890123456 d = '444' e = 'c' p('Hello, world!') p(c) for i in range(1, 10): p(i) j = 1 while j < 10: p(j) j += 1 if 1 == 2: p(666) else: p(777)
#XGBoost ZSN no scale_pos_weight XGBclassifier= xgboost.XGBClassifier(random_state=22) XGBclassifier.fit(X_train, Y_ZSN_train.values.ravel()) importances=XGBclassifier.feature_importances_; importances np.where(importances>0.02) X_train_rid = X_train.iloc[:, [ 0, 9, 24, 27, 33, 41, 43, 44, 46, 53, 78, 85, ...
xg_bclassifier = xgboost.XGBClassifier(random_state=22) XGBclassifier.fit(X_train, Y_ZSN_train.values.ravel()) importances = XGBclassifier.feature_importances_ importances np.where(importances > 0.02) x_train_rid = X_train.iloc[:, [0, 9, 24, 27, 33, 41, 43, 44, 46, 53, 78, 85, 87, 91, 92, 93, 97, 98, 101]] x_test_rid =...
def selection_sort(value): n = len(value) for i in range(n-1): loc = i for j in range(i+1, n): if value[j] < value[loc]: loc = j if loc != i: value[i], value[loc] = value[loc], value[i] print(value) return value values = [6, 5, 3, 1, 8, 7, 2, 4] print (values) values = selection_sort(values)
def selection_sort(value): n = len(value) for i in range(n - 1): loc = i for j in range(i + 1, n): if value[j] < value[loc]: loc = j if loc != i: (value[i], value[loc]) = (value[loc], value[i]) print(value) return value values = [6, 5, ...
class NoEmitMixin: ''' Mixin that raises a :class:`NotImplementedError` for `Construct._emit*` functions ''' def _emitparse(*args, **kwargs): raise NotImplementedError def _emitbuild(*args, **kwargs): raise NotImplementedError def _emitseq(*args, **kwargs): raise NotIm...
class Noemitmixin: """ Mixin that raises a :class:`NotImplementedError` for `Construct._emit*` functions """ def _emitparse(*args, **kwargs): raise NotImplementedError def _emitbuild(*args, **kwargs): raise NotImplementedError def _emitseq(*args, **kwargs): raise NotIm...
# # Python classes review graded # # ### Problem 1: # Create a Movie class with the following properties/attributes: ```movieName```, ```rating```, and ```yearReleased```. # * Override the default ```str``` (to-String) method and implement the code that will print the value of all the properties/attributes of the Movie...
class Movie: def __init__(self, movieName, rating, yearReleased): self.movieName = movieName self.rating = rating self.yearReleased = yearReleased def __str__(self): return f'{self.movieName}, {self.rating}, {self.yearReleased}' class Product: def __init__(self, price, qu...
val = int(input("Enter value:")) if val > 0: print("Positive number") elif val < 0: print("Negative number") else: print("0 value.")
val = int(input('Enter value:')) if val > 0: print('Positive number') elif val < 0: print('Negative number') else: print('0 value.')
#declaring and formatting multiples variables as integer. num01= int(input('Type the first number: ')) num02= int(input('Type the second number: ')) #showing to user the sum of numbers print('The sum of the first and the second number is:', num01 + num02)
num01 = int(input('Type the first number: ')) num02 = int(input('Type the second number: ')) print('The sum of the first and the second number is:', num01 + num02)
for t in range(int(input())): board = [] for i in range(9): board.append(list(input())) for i in range(9): for j in range(9): if board[i][j] == "2": board[i][j] = "1" for i in range(9): for j in range(9): print(board[i][j], end = "") print()
for t in range(int(input())): board = [] for i in range(9): board.append(list(input())) for i in range(9): for j in range(9): if board[i][j] == '2': board[i][j] = '1' for i in range(9): for j in range(9): print(board[i][j], end='') ...
def alphabet_position(text): offset = ord('a') - 1 positions = (ord(char) - offset for char in text.lower() if char.isalpha()) return ' '.join(map(str, positions))
def alphabet_position(text): offset = ord('a') - 1 positions = (ord(char) - offset for char in text.lower() if char.isalpha()) return ' '.join(map(str, positions))
#Declare s as str (immutable/value) and print the value def on_str(): """Declare s as str (immutable) and print the value""" s = 'Doesn\'t say hello world' sbis = s print("La valeur de s est ", s) print("La taille de s est ", len(s)) print("La valeur de sbis est ", sbis)
def on_str(): """Declare s as str (immutable) and print the value""" s = "Doesn't say hello world" sbis = s print('La valeur de s est ', s) print('La taille de s est ', len(s)) print('La valeur de sbis est ', sbis)
nome = input('Qual o seu Nome?:') peso = float(input('Qual o seu Peso?:')) if peso <= 65: categoria = 'Pena' elif peso > 65 and peso < 72: categoria = 'Leve' elif peso > 72 and peso < 79: categoria = 'Ligeiro' elif peso > 79 and peso < 86: categoria = 'Meio medio' elif peso > 86 and peso < 93: cat...
nome = input('Qual o seu Nome?:') peso = float(input('Qual o seu Peso?:')) if peso <= 65: categoria = 'Pena' elif peso > 65 and peso < 72: categoria = 'Leve' elif peso > 72 and peso < 79: categoria = 'Ligeiro' elif peso > 79 and peso < 86: categoria = 'Meio medio' elif peso > 86 and peso < 93: categ...
# Coffee machine options : latte (200 mL water + 2 g coffee + 15 ml milk), espresso (50 ml water + 18 g coffee), cappuccino (250 ml water + 24 g coffee + 100 ml milk) # Different prices (espresso = 1.50, latte = 2.50, cappuccino = 3.00) # hardware : Water inlet, coin slot, ADD contactless, coin acceptor, LCD display, d...
coffee_cup = '\n\n\n .\n `:.\n `:.\n .:\' ,::\n .:\' ;:\'\n :: ;:\'\n : .:\'\n `. :.\n _________________________\n : _ _ _ _ _ _ _ ...
''' The MIT License (MIT) Copyright (c) 2016 WavyCloud Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, p...
""" The MIT License (MIT) Copyright (c) 2016 WavyCloud Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, p...
''' Finds longest common subsequence of two arrays. ''' ######################################################################### def lcs(a, b): ''' Finds longest common subsequence of arrays a, b. ''' lengths = [[0 for j in range(len(b) + 1)] for i in range(len(a) + 1)] for i, x in enumerate(a): ...
""" Finds longest common subsequence of two arrays. """ def lcs(a, b): """ Finds longest common subsequence of arrays a, b. """ lengths = [[0 for j in range(len(b) + 1)] for i in range(len(a) + 1)] for (i, x) in enumerate(a): for (j, y) in enumerate(b): if x == y: leng...
#!/usr/bin/env python # coding: utf-8 # # Counting Point Mutations # ## Problem # # Given two strings **s** and **t** of equal length, the Hamming distance between **s** and **t**, denoted dH(s,t), is the number of corresponding symbols that differ in **s** and **t**. # # > **Given:** Two DNA strings **s** and **t**...
def hamming_distance(seq1, seq2): """Calculate the Hamming difference between 'seq1' and 'seq2'.""" return sum((0 if a == b else 1 for (a, b) in zip(seq1, seq2))) with open('rosalind_hamm.txt', 'r') as fasta: sequence = str() for line in fasta: sequence = sequence + line list = sequence.spli...
# 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 use...
class Manageraccessrequired(Exception): """Manager access level is required for the operation attempted""" class Owneraccessrequired(Exception): """Owner access level is required for the operation attempted""" class Unknownmarkettype(Exception): """Marketplace must be registered""" class Contractexceptio...
# # PySNMP MIB module AT-DS3-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AT-DS3-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:29:45 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:...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, single_value_constraint, constraints_intersection, value_size_constraint, constraints_union) ...
def bucket_brigade_update(cl, prev_cl, reward: int, bid_ratio: float = 0.01): # Exit when it's the first step if prev_cl is None: return # Distribute reward discounted = (1 - bid_ratio) * prev_cl.r if reward !...
def bucket_brigade_update(cl, prev_cl, reward: int, bid_ratio: float=0.01): if prev_cl is None: return discounted = (1 - bid_ratio) * prev_cl.r if reward != 0: prev_cl.r = discounted + bid_ratio * reward else: prev_cl.r = discounted + bid_ratio * cl.r def bucket_brigade_update_f...
class Solution: def encode(self, num: int) -> str: if num == 0: return "" k = 1 while num > 2 ** k: num -= 2 ** k k += 1 v = [] num -= 1 while num != 0: v.append(str(num % 2)) num //= 2 v += ['0'] * (...
class Solution: def encode(self, num: int) -> str: if num == 0: return '' k = 1 while num > 2 ** k: num -= 2 ** k k += 1 v = [] num -= 1 while num != 0: v.append(str(num % 2)) num //= 2 v += ['0'] * ...
#!/usr/bin/env python3.8 key = "0ba883a22afb84506c8d8fd9e42a5ce4e8eb1cc87c315a28dd" flag_enc = open("flag.txt.enc", "r").read() flag = "" i = 2 for c in flag_enc: flag += chr(ord(c) ^ ord(key[(i) % len(key)])) i += 1 print(flag)
key = '0ba883a22afb84506c8d8fd9e42a5ce4e8eb1cc87c315a28dd' flag_enc = open('flag.txt.enc', 'r').read() flag = '' i = 2 for c in flag_enc: flag += chr(ord(c) ^ ord(key[i % len(key)])) i += 1 print(flag)