content
stringlengths
7
1.05M
def main(j, args, params, tags, tasklet): page = args.page action = args.requestContext.params.get('action', 'install') aysid = args.requestContext.params.get('aysid') instance = args.requestContext.params.get('instance', 'main') parent = args.requestContext.params.get('parent', '') installedag...
class SpaceAge(object): earth_year = 31557600 corr = { 'earth': 1, 'mercury': 0.2408467, 'venus': 0.61519726, 'mars': 1.8808158, 'jupiter': 11.862615, 'saturn': 29.447498, 'uranus': 84.016846, 'neptune': 164.79132 } def __init__(self, seco...
ACME_DEPLOYMENT = """ apiVersion: extensions/v1beta1 kind: Deployment metadata: name: %(deployment_name)s labels: app: openshift-acme spec: progressDeadlineSeconds: 600 replicas: 1 revisionHistoryLimit: 10 selector: matchLabels: app: openshift-acme strategy: type: Recreate template: ...
#!/usr/bin/env python NAME = 'Cisco ACE XML Gateway' def is_waf(self): if self.matchheader(('server', 'ACE XML Gateway')): return True return False
# WARNING!!! # DO NOT MODIFY THIS FILE DIRECTLY. # TO GENERATE THIS RUN: ./updateWorkspaceSnapshots.sh BASE_ARCHITECTURES = ["amd64"] # Exceptions: # - s390x doesn't have libunwind8. # https://github.com/GoogleContainerTools/distroless/pull/612#issue-500157699 # - ppc64le doesn't have stretch security-channel. # ...
"""Top-level package for `functions` project.""" __package_name__ = "functions-cli" __version__ = "0.1.0"
if __name__ == '__main__': n = int(input()) if((n%2!=0)or((n>=6)and(n<=20))): print("Weird") else: print("Not Weird")
''' Created on Apr 4, 2021 @author: x2012x ''' class ConductorException(Exception): pass class UnsupportedAction(ConductorException): pass class UnsupportedIntent(ConductorException): pass class RegistrationExists(ConductorException): pass class SpeakableException(ConductorException): def __ini...
#!/usr/bin/env python3 ################################################################################## # # # Program purpose: Finds a replace the string "Python" with "Java" and the # # string "Java" with "P...
class ObjectMaterialSource(Enum,IComparable,IFormattable,IConvertible): """ Defines enumerated values for the source of material of single objects. enum ObjectMaterialSource,values: MaterialFromLayer (0),MaterialFromObject (1),MaterialFromParent (3) """ def __eq__(self,*args): """ x.__eq__(y) <==> x...
#!/usr/bin/env python3.8 # ######################################## # # Python Tips, by Wolfgang Azevedo # https://github.com/wolfgang-azevedo/python-tips # # Numbers # 2020-03-03 # ######################################## # # # Boolean type returns True or False as a result # Tipo boleano retorna True, se o valor co...
# question : https://quera.ir/problemset/university/296/ n = int(input()) for i in range(1, n + 1): line = '' for j in range(1, n + 1): if i in [1, n]: line += '#' elif j in [1, n]: line += '#' elif i == j: line += '#' elif j == n - i + 1: ...
categories = { 'coco': [ {"color": [220, 20, 60], "isthing": 1, "id": 1, "name": "person"}, {"color": [119, 11, 32], "isthing": 1, "id": 2, "name": "bicycle"}, {"color": [0, 0, 142], "isthing": 1, "id": 3, "name": "car"}, {"color": [0, 0, 230], "isthing": 1, "id": 4, "name": "mo...
load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "net_gac4", "nuget_package") def packages(): nuget_package( name = "npgsql", package = "npgsql", version = "4.0.3", # sha256 = "4e1f91eb9f0c3dfb8e029edbc325175cd202455df3641bc16155ef422b6bfd6f", core_lib = { "netsta...
aihub_dialog_datasets = { "train": { "clean": ["data/Training"] } } librispeech_datasets = { "train": { "clean": ["LibriSpeech/train-clean-100", "LibriSpeech/train-clean-360"], "other": ["LibriSpeech/train-other-500"] }, "test": { "clean": ["LibriSpeech/test-clean"],...
def matrix_script(): first_multiple_input = input().split() n = int(first_multiple_input[0]) m = int(first_multiple_input[1]) matrix = [] for _ in range(n): matrix_item = input() matrix.append(matrix_item) ref = [] for i in range(m): for ...
''' from sklearn.cluster import KMeans from sklearn.preprocessing import StandardScaler from sklearn.preprocessing import MinMaxScaler import numpy as np import logging def calculate_wcss(data): wcss = [] scaler = MinMaxScaler() data = scaler.fit_transform(data) for n in range(2, 21): kmeans = ...
# -*- coding: UTF-8-*- def enumerate_fn(): '''enumerate是python内置函数:获取每个元素的索引和值 :return:打印每个元素的索引和值 ''' list = [10,29,30,41,50] for index, value in enumerate(list,0): print (index,value) enumerate_fn()
class Solution: def maximalSquare(self, matrix: List[List[str]]) -> int: row = len(matrix) col = len(matrix[0]) res = 0 dp = [[0 for i in range(col+1)] for j in range(row+1)] for i in range(1,row+1): for j in range(1,col+1): if matrix[i-1]...
class Solution: # @param A, a list of integer # @return an integer def singleNumber(self, A): return reduce(lambda x, y: x ^ y, A)
"""Implements the modified UTF-7 specification used for encoding and decoding mailbox names in IMAP. See Also: `RFC 3501 5.1.3 <https://tools.ietf.org/html/rfc3501#section-5.1.3>`_ """ __all__ = ['modutf7_encode', 'modutf7_decode'] def _modified_b64encode(src: str) -> bytes: # Inspired by Twisted Python's ...
#!/usr/bin/env python def read_input(filename): with open(filename) as fd: return [line.strip() for line in fd.readlines()] def reduce_chunks(line): """Meh >>> lines = read_input('example') >>> reduce_chunks(lines[2]) '{([(<[}>{{[(' """ while True: prev = line for...
# KeyPairs.py # Pairs key name to corresponding numerical identifier keyPairs = [("C",1),("Db/C#",2),("D",3),("Eb/D#",4),("E",5),("F",6), ("Gb/F#",7),("G",8),("Ab/G#",9),("A",10),("Bb/A#",11),("B",12)]
file = open('/Users/hansr/Desktop/Homo_sapiens.GRCh37.75.gtf', 'rU') hgncfile = open('/Users/hansr/Desktop/hgnc_complete_set.txt', 'rU') outfile = open('/Users/hansr/Desktop/EnsembleId2GeneName.csv', 'w') id2symbol = {} id2name = {} for line in hgncfile: if line.startswith('hgnc_id'): continue splits...
""" №290. К.Ю. Поляков. Укажите наименьшее целое значение А, при котором выражение (2y + 4x < A) ∨ (x + 2y > 80) истинно для любых целых неотрицательных значений x и y. """ a = 1 while True: for x in range(1000): for y in range(1000): if not ((2 * y + 4 * x < a) or (x + 2 * y > 80)):...
""" link: https://leetcode.com/problems/partition-list problem: 修改链表,使得比x小的值都在x之前 solution: 双指针扫 """ class Solution: def partition(self, head: ListNode, x: int) -> ListNode: if head is None: return head _head = ListNode(0) _head.next = head i = _head while i.next and i.n...
{ "targets": [ { "target_name": "action_before_build", "type": "none", "hard_dependency": 1, "actions": [ { "action_name": "build rust-native-storage library", "inputs": [ "scripts/build_storage_lib.sh" ], "outputs": [ "" ], "action": ["scrip...
def fib(n): a,b = 1,2 for _ in range(n-1): a,b = b, a + b return a def count_basic(n): return fib(n) def count_multi(n,ways): if n < 0: return 0 elif n == 0: return 1 elif n in ways: return 1 + sum([count_multi(n - x, ways) for x in ways if x < n]) else: ...
VAR = 42 def func(): global VAR VAR += 1
#### formas de pagamento price = float(input('Qual o preço das comprar: R$ ')) print("""FORMAS DE PAGAMENTO [1] À vista (dinheiro ou cheque) [2] À vista cartão (1x) [3] 2x no cartão [4] 3x ou mais no cartão """) met = int(input('Qual a forma de pagamento: \n')) if met==1: price = price*0.9 print('O valor total...
class BackendBaseException(Exception): """ Base exception for all custom exceptions of this service. """ def __init__(self, message: str) -> None: self.message = message class AuthenticationException(BackendBaseException): pass class ViewException(BackendBaseException): def __init__...
''' Pseudocode 1. Start 2. Take dividend from the user 3. Take divisor from user 4. Calculate the quotient 5. Calculate the remainder 6. Disdlays quotient and remainder 7. End ''' # Take the value of dividend dividend = int(input('Enter the value of dividend: ')) # Take the value of the divisor divisor = int(inp...
""" 练习1: 定义函数,在终端中打印一维列表. list01 = [5, 546, 6, 56, 76, ] for item in list01: print(item) list02 = [7,6,879,9,909,] for item in list02: print(item) """ # 做(一种行为) def print_single_list(list_target): """ 在终端中打印列表元素 :param list_target: list类型的需要打印的数据 """ for item i...
def any(x) -> bool: pass def all(x) -> bool: pass def bool(x) -> bool: pass def bytes(x) -> Bytes: pass def dict() -> Dict: pass def dir(x) -> List[String]: pass def enumerate(x) -> List[Tuple[int, any]]: pass def float(x) -> float: pass def hasattr(x, name) -> bool: pass def hash(x) -> int: ...
""" All the functions to manipulate the resource fields, state changes, etc. Grouped by the type of the fields and the purpose of the manipulation. Used in the handling routines to check if there were significant changes at all (i.e. not our own internal and system changes, like the uids, links, etc), and to get the ...
def parse_policy(policy): a, b, c = policy.split() lo, hi = a.split("-") return (int(lo), int(hi), b[:-1], c) def part1(pws): return sum(1 for lo, hi, c, pw in pws if lo <= pw.count(c) <= hi) def part2(pws): return sum(1 for lo, hi, c, pw in pws if (pw[lo - 1] == c) != (pw[hi - 1] == c)) if __...
# Copyright (C) 2018 The Dagger Authors. # # 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 w...
__author__ = "Liyuan Liu and Frank Xu" __credits__ = ["Liyuan Liu", "Frank Xu", "Jingbo Shang"] __license__ = "Apache License 2.0" __maintainer__ = "Liyuan Liu" __email__ = "llychinalz@gmail.com"
def convert_month_to_days(number_of_months: int) -> int: return number_of_months * 30 def convert_week_to_days(number_of_weeks: int) -> int: return number_of_weeks * 7 class CovidEstimator: def __init__(self, **kwargs): self.currently_infected: int = 0 self.currently_infected_worst_cas...
class _BaseOptimizer: def __init__(self, model, learning_rate=1e-4, reg=1e-3): self.learning_rate = learning_rate self.reg = reg self.grad_tracker = {} for idx, m in enumerate(model.modules): self.grad_tracker[idx] = dict(dw=0, db=0) def update(self, model): ...
def getOrderFromDict(d): return RobinhoodOrder(d['symbol'],d['action'],d['shares'],d['price'],d['date']) class RobinhoodOrder(object): def __init__(self, symbol, action, shares, price, date): self.symbol = symbol self.action = action self.shares = shares self.price = price ...
''' In this little assignment you are given a string of space separated numbers, and have to return the highest and lowest number. Example: high_and_low("1 2 3 4 5") # return "5 1" high_and_low("1 2 -3 4 5") # return "5 -3" high_and_low("1 9 3 4 -5") # return "9 -5" Notes: All numbers are valid Int32, no need to va...
class TrustDomain(object): """ Represents the name of a SPIFFE trust domain (e.g. 'domain.test'). :param trust_domain: The name of the Trust Domain """ name: str def __init__(self, trust_domain: str): self.name = trust_domain
n1 = 10 n2 = 20 print(n1,n2) n1 , n2 = n2 ,n1 print(n1,n2)
pizzas = ['Pizza_A', 'Pizza_B', 'Pizza_C'] for pizza in pizzas: print(f'Gosto da {pizza}') print('Eu realmente gosto de pizza.') for i in range(1, 1): print(i) pizzas_amigos = pizzas[:] pizzas.append('Pizza_D') pizzas_amigos.append('Pizza_E') for pizza in pizzas: print(pizza) print() ...
# -*- coding: utf-8 -*- """058 - Validação de Dados Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1ZTluph36T-5jWIn1AJP2JN1XKyqGAYep """ sexo = '' while sexo != 'M' and sexo != 'F': sexo = str(input('DIgite o sexo [M/F]: ')).upper() if sexo !=...
liste = [1,6,9,4,5,7] plusFort = 0 for nb in liste: if nb>plusFort: plusFort = nb print("Le plus fort de la liste est {}".format(plusFort))
{ 'targets': [{ 'target_name': 'addon', 'include_dirs': [ "<!(node -e \"require('nan')\")", 'lib/kcp', 'src', ], 'sources': [ 'lib/kcp/ikcp.c', 'src/utils.c', 'src/Loop.cc', 'src/SessUDP.cc', 'src/Cryptor.cc', 'src/KcpuvSess.cc', 'src/Mux.cc'...
# Given an integer array nums of unique elements, return all possible subsets # (the power set). # The solution set must not contain duplicate subsets. # Return the solution in any order. # # Example 1: # Input: nums = [1,2,3] # Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]] # # Example 2: # Input: nums = [0] # Out...
n = int(input()) a = list(map(int,input().split())) dist = [-1] * n dist[0] = 0 pos = [0] for u in pos: for v in [u - 1, u + 1, a[u] - 1]: if v >= 0 and v < n and dist[v] == -1: dist[v] = dist[u] + 1 pos.append(v) print(*dist)
def letter_count(word): count = {} for i in word: count[i] = word.count(i) return count new = (letter_count("mehedi hasan shifat").items()) for i,j in new: print("'{}' -> {} times".format(i,j)) print(len(new))
class AbstractProducerAdapter: def __init__(self, config: dict): self.config = config def get_current_energy_production(self) -> float: """ Returns the current energy production """ pass
# TASK: # You are given two non-empty arrays A and B consisting of N integers. Arrays A and B represent N voracious fish in a river, ordered downstream along the flow of the river. # The fish are numbered from 0 to N − 1. If P and Q are two fish and P < Q, then fish P is initially upstream of fish Q. Initially, each f...
def random_choice(): return bool(GLOBAL_UNKOWN_VAR) def is_safe(arg): return UNKNOWN_FUNC(arg) def true_func(): return True def test_basic(): s = TAINTED_STRING if is_safe(s): ensure_not_tainted(s) else: ensure_tainted(s) if not is_safe(s): ensure_tainted(s) ...
m = 4 b = 5 c = 6 d = 7 n = 0 d = d*d print(d) c = d*2 - c*2 print(c) p = b*d+m*c print(p) dn = c-d print(dn) cn = c-m print(cn) d = d-dn print(d) c = c-n print(c) a = d + c f = m + b e = a + f print(d,dn) print(c,d,f) print(m,b,p) print(cn,dn) print(a,e)
# Copyright (C) 2017 Udacity Inc. # All Rights Reserved. # Author: Brandon Kinman ################################################################################## # UPDATED USING CLASS FROM LESSON 23 PID CONTROL ################################################################################## class PIDControll...
"""SNMP constants.""" CONF_ACCEPT_ERRORS = 'accept_errors' CONF_AUTH_KEY = 'auth_key' CONF_AUTH_PROTOCOL = 'auth_protocol' CONF_BASEOID = 'baseoid' CONF_COMMUNITY = 'community' CONF_DEFAULT_VALUE = 'default_value' CONF_PRIV_KEY = 'priv_key' CONF_PRIV_PROTOCOL = 'priv_protocol' CONF_VERSION = 'version' DEFAULT_AUTH_PRO...
try: while 1: n=int(input()) k=(n-10)//9 m=n-10-9*k print(81*(k+1)+m*(m+2)+1) except:pass
def run(df, docs): for doc in docs: doc.start("t10 - Columns to lowercase", df) columns = list(df.columns) # for each column for i in columns: try: # all charts to lowercase and no leading or trailing spaces df[i] = df[i].str.lower().str.strip() except: ...
n = int(input()) for i in range(n): s = int(input()) p = 0 for j in range(0, s): p = (p * 2) + 1 print(p)
#!/usr/bin/env python # # chemweight.py # # # import re mass = { "H": 1.00794, "He": 4.002602, "Li": 6.941, "Be": 9.012182, "B": 10.811, "C": 12.011, "N": 14.00674, "O": 15.9994, "F": 18.9984032, "Ne": 20.1797, "Na": 22.989768, "Mg": 24.3050, "Al": 26.981539, "Si": 28.0855, "P": 30....
COMPANY_NAME = "Enter the legal name of your business (not the trading name) then use 'Search Companies House'\ and select your company from the list. It will then prefill your company number and postcode." COMPANY_WEBSITE = "Website address, where we can see your products online." COMPANY_NUMBER = "The...
#!/usr/bin/env python #pylint: skip-file # This source code is licensed under the Apache license found in the # LICENSE file in the root directory of this project. class ZtdPlatformImage(object): def __init__(self): """ Attributes: swaggerTypes (dict): The key is attribute name and the...
{ "targets": [ { "target_name": "naudiodon", "sources": [ "src/naudiodon.cc", "src/GetDevices.cc", "src/GetHostAPIs.cc", "src/AudioIO.cc", "src/PaContext.cc" ], "include_dirs": [ "<!@(node -p \"require('node-addon-api').include\")", "po...
#!/usr/bin/env python # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # California Institute of Technology # (C) 2007 All Rights Reserved # # {LicenseText} # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
#------------------------------------------------------------------------------- # 6857 #------------------------------------------------------------------------------- N = 600851475143 d = 3 while d * d <= N and N != 1: while N % d == 0: N //= d last = d d += 2 if N != 1: last = N print(last)
def doIt (func, x, y): z = func (x, y) return z def add (arg1, arg2): return arg1 + arg2 def sub (arg1, arg2): return arg1 - arg2 print ('Addition:') print ( doIt (add, 2, 3) ) # Passing the name of the function # and its arguments print ('Subtraction:') print ( do...
list=["rayne","coder","python","c","c++","java"] #REMOVE list.remove("java") print(list) #remove BY index list.pop(1) # 1- coder print(list)
n=int(input()) namibia=0 kenya=0 tanzania=0 ethiopia=0 zim=0 zam=0 zimzam=0 zimzamMode=False namaVisit=False last='' lgo="" for i in range(n): go=input() lgo=go if last==go: continue if go=='kenya': kenya=1 if go=='tanzania': tanzania=1 if go=='ethiopia': ethiopia=1 if go=='zambia': if last=='zimbabwe': z...
# # PySNMP MIB module NETREALITY-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NETREALITY-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:10:11 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2...
''' Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes. You should try to do it in place. The program should run in O(1) space complexity and O(nodes) time complexity. Example 1: Input: 1->2->3->4-...
def num_of_factors(num): n = 0 factor = 1 while factor * factor < num: if num % factor == 0: n += 1 factor += 1 if factor * factor > num: return n * 2 else: # perfect square return n * 2 + 1 triangle = 0 i = 1 while True: triangle += i if ...
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = Nonea class Solution(object): def postorderTraversal(self, root): """ :type root: TreeNode :rtype: List[int] """ ...
"""文字列基礎 引数の番号を指定して値を埋め込む方法 [説明ページ] https://tech.nkhn37.net/python-str-format-f-string/#i-2 """ # 引数の番号を指定して値を埋め込む print('{0}は{2}歳の{1}です。'.format('太郎', '男性', 20)) # 変数に値を入れて使用する場合も同様 name = '太郎' sex = '男性' age = 20 print('{0}は{2}歳の{1}です。'.format(name, sex, age))
# bulk_data = [] # for row in csv_file_object: # data_dict = {} # for i in range(len(row)): # data_dict[header[i]] = row[i] # op_dict = { # "index": { # "_index": INDEX_NAME, # "_type": TYPE_NAME, # "_id": data_dict[ID_FIELD] # } # } # b...
class t_list(): def __init__(self, lst = []): lst.sort() self.lst = [[el, el] for el in lst] def __len__ (self): return len(self.lst) def create(self, lst): lst.sort() self.lst = [[el, el] for el in lst] def add(self, val, t): left = 0 right = ...
OperandSet = { 'Ib' : { '16' : ( "0x10", ), '32' : ( "0x10", ), '64' : ( "0x20", ) }, 'Eb_Gb' : { '16' : ( "[bx+si], al", ), '32' : ( "[eax+ebx], ch", "[ebx+ecx*4], bl", "[bx+0x10], dh"), '64' : ( "[rax], r8b", ) ...
''' In mathematics, the Fibonacci numbers, commonly denoted Fn, form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is, F0=0 , F1=1 and Fn= F(n-1) + F(n-2) The Fibonacci numbers are the numbers in the following integer sequence....
"""Python serial number generator.""" class SerialGenerator: """Machine to create unique incrementing serial numbers. >>> serial = SerialGenerator(start=100) >>> serial.generate() 100 >>> serial.generate() 101 >>> serial.generate() 102 >>> serial.reset() >>> serial.generate() ...
def calculation(operator,n_1,n_2): if operator == "multiply": return n_1 * n_2 elif operator == "divide": return n_1 // n_2 elif operator == "add": return n_1 + n_2 elif operator == "subtract": return n_1 - n_2 operator = input() n_1 = int(input()) n_2 = int(input()) pr...
# -*- coding: utf-8 -*- """ flaskbb.utils.permissions ~~~~~~~~~~~~~~~~~~~~~~~~~ A place for all permission checks :copyright: (c) 2014 by the FlaskBB Team. :license: BSD, see LICENSE for more details. """ def check_perm(user, perm, forum, post_user_id=None): """Checks if the `user` has a spe...
class Solution: def nextGreatestLetter(self, letters: List[str], target: str) -> str: if target >= letters[-1]: return letters[0] left, right = 0, len(letters) while left < right: mid = left + (right - left) // 2 if letters[mid] <= target: left = mid ...
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( keypad , n ) : if ( not keypad or n <= 0 ) : return 0 if ( n == 1 ) : return 10 odd = [...
def log(rv): """ Returns the natural logarithm of a random variable """ return rv.log() def exp(rv): """ Returns the exponentiation of a random variable """ return rv.exp() def sqrt(rv): """ Returns the square root of a random variable """ return rv**0.5 def pow(rv, k)...
#첫째 줄에 A, B, C가 순서대로 주어진다. (2 ≤ A, B, C ≤ 10000) #첫째 줄에 (A+B)%C, 둘째 줄에 ((A%C) + (B%C))%C, 셋째 줄에 (A×B)%C, 넷째 줄에 ((A%C) × (B%C))%C를 출력한다. a,b,c = input().split() a = int(a) b = int(b) c = int(c) print((a+b)%c, ((a%c)+(b%c))%c, (a*b)%c, ((a%c)*(b%c)%c), sep="\n")
""" python实现顺序栈 1。目标:实现栈(后进先出) 2。设计 """ class ListStack: def __init__(self): """初始化一个空栈""" self.elems = [] def push(self, item): """入栈操作""" self.elems.append(item) def destack(self): """出栈操作""" if not self.elems: raise Exception('destac...
#!/usr/bin/env python # -*- coding: utf-8 -*- DENIED_ACTIONS = { "access-analyzer:DeleteAnalyzer", "cloudtrail:CreateTrail", "cloudtrail:DeleteTrail", "cloudtrail:UpdateTrail", "cloudtrail:StopLogging", "config:DeleteConfigRule", "config:DeleteConfigurationRecorder", "config:DeleteDeliv...
X = int(input()) Y = int(input()) Z = int(input()) N = int(input()) result = [ [x, y, z] for x in range(X+1) for y in range(Y+1) for z in range(Z+1) if x + y + z != N ] print(result)
class Solution: def lexicographically_minimal_string(self, a, b): """ :type strs: a, b :rtype: str """ a = [ord(x) for x in list(a[::-1])] b = [ord(x) for x in list(b[::-1])] lms = [] while len(a) != 0 and len(b) != 0: if a[-1] < b[-1]: ...
class Solution: def minimumDeleteSum(self, s1, s2): """ :type s1: str :type s2: str :rtype: int """ # use dynamic programming and rolling window dp = [[0] * (len(s2) + 1) for _ in range(2)] for i in range(len(s2)): dp[0][i+1] = dp[0][i] + o...
with open('test.txt', 'w') as file: content = input('Write into file: ') file.write(content) with open('test.txt', 'a') as file: s = '' while s!= '@': file.write(s) s = input('Append into file: ') with open('test.txt') as file: print(file.read())
def sumofs1(): s1=0 n=int(input("enter a number:")) for i in range(1,n+1): s1=s1+i print("sumofs1=",s1) def sumofs2(): s2=0 m=int(input("enter a number:")) for j in range(1,m+1): s2=s2+(j*j) print("sumofs2=",s2) def sumofs3(): s3=0 p=int(input("enter...
# Add your list of tweets here in this list. Make sure the messages are inside double quotes and end with a comma. # For example: "Hello Check, my profile", # The program will then randomly select one of the messages and post it to Twitter. # Also if your message contains a double quote, you need to escape it with a b...
types = [] sums = [] try: with open('hoteldata.txt', 'r', encoding='utf8') as inFile: line = inFile.readline() while line != "": currentDayData = line.split(';') if len(currentDayData) != 4: raise Exception("Invalid Format") if curren...
#!/usr/bin/env python3 types = { "BASIC_CONSTRAINTS": { "ca": "ca_bool_int", "pathlen": "ASN1_INTEGER", }, } getter_conv_tmpl = { "ca_bool_int": "ctx.{k} == 0xFF", "ASN1_INTEGER": "tonumber(C.ASN1_INTEGER_get(ctx.{k}))", } setter_conv_tmpl = { "ca_bool_int": ''' toset.{k} = cfg_...
# # PySNMP MIB module DLINK-3100-MIR-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DLINK-3100-MIR-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:48:41 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, ...
""" Given two int values, return their sum. Unless the two values are the same, then return double their sum. sum_double(1, 2) → 3 sum_double(3, 2) → 5 sum_double(2, 2) → 8 """ def sum_double(a, b): # if a not b return sum if (a != b): return a + b # else return double sum else: r...
input[int] = [3, 5, 6, 1, 2, 4] def find_max_num(array): # 이 부분을 채워보세요! # ans = max(input) for num in array: for compare_num in array: if num < compare_num: break else: return num # 숫자 비교를 하는데, break를 한 번도 거치지 않았다면 # 비교 대상 중 가장 큰 값이라고 판단하고 ...
# classificationMethod.py # ----------------------- # Licensing Information: You are free to use or extend these projects for # educational purposes provided that (1) you do not distribute or publish # solutions, (2) you retain this notice, and (3) you provide clear # attribution to UC Berkeley, including a link to ht...
''' mbinary ######################################################################### # File : allOoneDS.py # Author: mbinary # Mail: zhuheqin1@gmail.com # Blog: https://mbinary.xyz # Github: https://github.com/mbinary # Created Time: 2018-05-19 23:07 # Description: ####################################################...