content
stringlengths
7
1.05M
# # PySNMP MIB module SAVEPOWER-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SAVEPOWER-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:52:41 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 201...
x = 0 x = x + 10 x = x - 10 x = x * 10 x = x @ 10 x = x / 10 x = x // 10 x = x % 10 x = x ** 10 x = x >> 10 x = x << 10 x = x & 10 x = x ^ 10 x = x | 10 x = x + (10 + 20 * 3) x = x - (10 + 20 * 3) x = x * (10 + 20 * 3) x = x @ (10 + 20 * 3) x = x / (10 + 20 * 3) x = x // (10 + 20 * 3) x = x % (10 + 20 * 3) x = x ** (1...
# OOP和委托: "包装"对象 """ 委托通常就是指控制器对象内嵌其他对象,而把运算请求传给那些对象 控制器负责管理工作,例如记录存取等。在Python中,委托通常是以 __getattr__钩子方法实现的,因为这个方法会拦截对不存在属性的读取, 因为这个方法会拦截对不存在属性的读取,包装类(有时成为代理类),可以使用 __getattr__把任意读取转发给被包装的对象。包装类包又被包装对象的接口, 而且自己也可以增假其他运算。 """ class wrapper: def __init__(self): self.wrapperd = object def __getattr__(self...
class Reduction(): def __init__(self, m, b,c): self.m = m self.b = b self.c = c def reduction(self, d): T1 = [0]*(self.b-2) D_red = [0]*self.m for i in xrange(0,self.b-1): T1[i] = (d[i + 2*self.b + 1] + d[i + 3*self.b + (2*self.c)])%2; fo...
# DESAFIO 113 # Reescreva a função leiaint() que fizemos no DESAFIO 104, incluindo agora a possibilidade de digitação # de um número de tipo inválido. Aproveite e crie também uma função leiafloat() com a mesma funcionalidade. vermelho = "\033[0;31;40m" rc = "\033[m" def leiaint(x): while True: try: ...
""" Codemonk link: https://www.hackerearth.com/practice/data-structures/hash-tables/basics-of-hash-tables/practice-problems/algorithm/little-jhool-and-the-magical-jewels/ Little Jhool is still out of his mind - exploring all his happy childhood memories. And one of his favorite memory is when he found a magical ghost,...
a = 0 s = 0 c = 0 while a != 999: a = int(input('Digite um número: [ou 999 para parar] ')) if a == 999: break c = c + 1 s = a + s print(f'A soma dos {c} termos que você digitou é {a}.')
# # PySNMP MIB module LJM9050mfp-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/LJM9050mfp-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:57:38 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...
arr = [] userinput = 10 # for c in range[0,5]: # arr.append(input("enter number ")+ str(c+1) +": ")) newarr = [] # Function to ask for users input def user_prompt(userinput): try: print("input here : ") userinput = int(input()) arr.append(userinput) except: # Catches for an error s...
def leiaint(msg): while True: try: a = int(input(msg)) except (ValueError, TypeError): print("\033[31mErro! Por favor, digite um número inteiro.\033[m") continue except KeyboardInterrupt: print('\n\033[31mUsuário preferiu não digitar esse númer...
class Solution: @staticmethod def naive(s): stack = [] d = {"(":")","{":"}","[":"]"} for tmps in s: if tmps in d: stack.append(d[tmps]) if tmps in d.values(): if len(stack)==0: return False tmp = stack.pop() ...
__package__ = 'pywebio' __description__ = 'Write interactive web app in script way.' __url__ = 'https://pywebio.readthedocs.io' __version__ = "1.6.1" __version_info__ = (1, 6, 1, 0) __author__ = 'WangWeimin' __author_email__ = 'wang0.618@qq.com' __license__ = 'MIT'
""" Question: Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. Note: A leaf is a node with no children. Example 1: Input: root = [3,9,20,null,null,15,7] Output: 2 """ # Definition for a binary tree nod...
#!/usr/local/bin/python # Code Fights Pressure Gauges Problem def pressureGauges(morning, evening): return [list(map(min, zip(morning, evening))), list(map(max, zip(morning, evening)))] def main(): tests = [ [ [3, 5, 2, 6], [1, 6, 6, 6], [ ...
class Event(object): def __init__(self): self._handlers = [] def __iadd__(self, handler): self._handlers.append(handler) return self def __isub__(self, handler): self._handlers.remove(handler) return self def fire(self, *args, **kwargs): # Make a copy ...
# Declare and initialise the variables that we will use later on in our program. # Remember that this is not necessary, since in Python variables can be created dynamically. # For example if you delete lines 4, 5, 6 the program will still work. number1 = 0 number2 = 0 mult = 0 # Ask the user for two numbers using the ...
""" Definition of ListNode class ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next """ class Solution: """ @param head: The first node of the linked list. @return: You should return the head of the sorted linked list, using constant ...
# -*- coding: utf-8 -*- def main(capacidade, valores, pesos): pesos_valores = [] for i in range(len(valores)): pesos_valores.append((pesos[i], valores[i])) pesos_valores_ordenanos = sorted( pesos_valores, key = lambda item: item[1]/item[0], reverse=True ) x = [0]*...
class IncrementalAverage: """ This class enables us to store the running average of some datapoints on an incremental way, without the need of saving all the values. """ def __init__(self): self.counter = 1 self.sum = 0 def __str__(self): return str(self.sum) d...
#!/usr/bin/python3 # https://practice.geeksforgeeks.org/problems/element-that-appears-once-where-every-element-occurs-twice/0 # XOR of any number with 0 results in the same number # XOR of number with same number results in 'Zero' # So if we take the XOR of all elements the one doubles will zero out and # only the si...
class Solution: """ @param: nums: A list of integers @return: An integer denotes the sum of max two non-overlapping subarrays """ def maxTwoSubArrays(self, nums): # right2left[i] 表示从i到数组末尾最大的连续子序列 right2left = [0 for _ in range(len(nums))] right2left[-1] = nums[-1] in...
class Solution: """ @param n: An integer as description @return: A list of strings. For example, if n = 7, your code should return ["1", "2", "fizz", "4", "buzz", "fizz", "7"] """ def fizzBuzz(self, n): results = [] for i in range(1, n + 1): if i % 15 == 0: ...
# ex6.py 字符串和文本 # 字符串可以包含任意数量多变量 # f"{var}" # "some strings and {}".format(var) # 声明数字变量 types_of_people types_of_people = 10 # 声明字符串变量 x,并用格式字符串,插入 types_of_people x = f"There are {types_of_people} types of people." # 声明字符串变量 binary 和 do_not binary = "binary" do_not = "don't" # 声明字符串变量 y,并把 binary 和 do_not 插入格式字符串...
COURSES = [ (0, '-----'), (1, 'Svenska 1'), (2, 'Svenska 2'), (3, 'Svenska 3'), (4, 'Matematik 1'), (5, 'Matematik 2'), (6, 'Matematik 3'), (7, 'Matematik 4'), (8, 'Matematik 5'), (9, 'Engelska 1'), (10, 'Engelska 2'), (11, 'Engelska 3'), (9, 'Engelska 1'), ...
class BankAccount: bank_name = 'My Bank' def print_bank_name(self): print('My name is', self.bank_name)
# Este programa muestra como imprimir el valor de una variable. numero = 7 print("El valor de la variable es: ") print(numero) # Este programa fue escrito por Emilio Carcaño Bringas.
"""Set module version. <Major>.<Minor>.<maintenance>[alpha/beta/..] Alphas will be numbered like this -> 0.4.0a0 """ VERSION = '0.7.2'
""" A tic-tac-toe solver using minimax (without alpha-beta pruning). Example usage: >>> game = GameTree() >>> game.run_minimax_game() """ class GameTree: # A list to switch between players players = ["X", "O"] def __init__(self, value=" ", player_number=0): self.value = value sel...
a=10 b=5 print(a+b) print(success)
# Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. { 'variables': { 'werror': '', }, 'includes': [ '../../native_client/build/untrusted.gypi', ], 'targets': [ { 'target_name': 'opu...
#Kunal Gautam #Codewars : @Kunalpod #Problem name: Who likes it? #Problem level: 6 kyu def likes(names): if not names: return "no one likes this" elif len(names)==1: return names[0] + " likes this" elif len(names)==2: return names[0] + " and " + names[1] + " like this" elif len(names...
def configure(conf): conf.env.ARCHITECTURE = 'x86' conf.env.VALID_ARCHITECTURES = ['x86', 'i386'] conf.env.ARCH_FAMILY = 'x86' conf.env.ARCH_LP64 = False conf.env.append_unique('DEFINES', '_X86')
#【P1255】数楼梯 - 洛谷 - 90 n = int(input()) if n == 0: print(0) else: l = [1, 1, 2] for i in range(n): l[2] = l[0] + l[1] l[0] = l[1] l[1] = l[2] print(l[0])
# Make a list of the multiples of 3 from 3 to 30. Use a for loop to print the numbers in your list. multiples_of_three = [3,6,9,12,15,18,21,24,27,30] for multiple in multiples_of_three: print (multiple * multiple * multiple) print (multiples_of_three)
def foo(): x = 1 y = 1 res = x + y return res x = 2 y = 2 x1 = 1 y1 = 1 res = x1 + y1 def bar(arg=res): return arg
class Solution(object): def findContentChildren(self, g, s): """ :type g: List[int] :type s: List[int] :rtype: int """ res = 0 g = sorted(g) s = sorted(s) i = 0 j = 0 while i <= len(g)-1 and j <= len(s)-1: ...
word = input("please type in any word of your choice: \n") while word != "Jesus": if word == "Jesus": break else: word = input("please type in any word of your choice: \n") else: print("The Name above all Name \n")
#python的运算符实例 #'+'加号 # 俩个对象相加(可以是俩个数字,也可以是俩个字符串(将俩个字符串连接)) a=7+8 print(a) b="GOOD"+"Job" print(b) #'-'减号 #取一个数字的相反数或者实现俩个数字相减 c=-7 print(c) print(19-1) #'*'乘号 #如果是数字则进行乘法运算,字符串则复制若干次 d=4*7 print(d) e="hello"*7 print(e) #'/'除号 #表示俩个数字相除(Python 3.0中会直接输出正确的值) f=7/2 print(f) #'**'求幂运算 g=2**3 print(g) #'<'小于号 返回一个布尔值 ...
# # PySNMP MIB module TY3250I-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TY3250I-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:20:48 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...
# # PySNMP MIB module SCA-MPLINK2-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SCA-MPLINK2-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:52:59 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27...
lar = float(input('Digite a largura: ')) alt = float(input('Digite a altra: ')) dim = lar * alt area = dim / 2 print(''' Sua parede tem uma dimensão de {} x {} com uma área equivalente a {:.2f}m². Para pintá-la serão necessários {:.2f} litros de tinta. '''.format(lar, alt, dim, area)) #cálculo para descobrir a área é ...
""" This file auto-generated with generate-enums.js """ class EnumNamespace: """A collection of enum values. This collection can be used as specification to traitlets.Enum as it supports the `in` operator, and also supports tab completion as the values are attributes. """ def __init__(self, **...
삼성전자 = 50000 총평가금액 = 삼성전자 * 100 print(총평가금액) 시가총액 = 29800000000 현재가 = 50000 PER = 15.79 print(시가총액, type(시가총액)) print(현재가, type(현재가)) print(PER, type(PER)) s = "hello" t = "python" print(s+"!", t) a = 128 print(type(a)) a = "132" print(type(a)) num_str = "720" #형 변환 print(int(num_str) + 1) num = 100 result = str...
""" Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. Example: Input: 38 Output: 2 Explanation: The process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return it. Follow up: Could you do it without any loop/recursion...
matriz = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] for linha in range(0, 3): for coluna in range(0, 3): matriz[linha][coluna] = int(input('Digite um valor para [{}, {}]: '.format(linha + 1, coluna + 1))) for l in range(0, 3): for c in range(0, 3): print('[{:^5}] '.format(matriz[l][...
"""Constants for launch_library.""" DOMAIN = "launch_library" ATTR_LAUNCH_FACILITY = "facility" ATTR_LAUNCH_PAD = "pad" ATTR_LAUNCH_PAD_COUNTRY_CODE = "provider_country_code" ATTR_LAUNCH_PROVIDER = "provider" ATTR_REASON = "reason" ATTR_STREAM_LIVE = "stream_live" ATTR_WINDOW_END = "window_end" ATTR_WINDOW_START = "w...
MINIMAL_WEEDCOCO = { "images": [], "annotations": [], "categories": [], "agcontexts": [], "info": { "description": "Something", "metadata": { "name": "Something", "description": "Images of weeds", "creator": [{"@type": "Person", "name": "Someone"}]...
""" @Pedro Santana Abreu (https://linktr.ee/pedrosantanaabreu) @Icev (https://somosicev.com) PT-BR: Sabe-se que o quilowatt de energia custa um quinto do salário mínimo. Faça um programa que receba o valor do salário mínimo e a quantidade de quilowatts consumida por uma residência. Calcule e mostre: a) o valor de cad...
def BMICalculator(param): def BMICategory(BMI): if BMI <= 18.4: return ("18.4 and below", "Malnutrition risk") elif BMI >= 18.5 and BMI <= 24.9: return("18.5 - 24.9", "Low risk") elif BMI >= 25.0 and BMI <= 29.9: return("25 - 29.9", "Enhanced risk") ...
class ComposableQuery: def __init__(self, path, executor=None): self.path = path if type(path) is list else [path] self.executor = executor @property def full_path(self): return '/'.join(self.path) async def get(self): async with self.executor.construct_session() as ses...
# This sample validates that an unbound variable error is reported # even if that variable has a type declaration. def fn1(): aaa: int # This should generate an error because aaa is unbound. return aaa fn1()
class FormTypes: Q = "10-Q" K = "10-K" def __init__(self): raise NotImplementedError
""" Trolls are attacking your comment section! A common way to deal with this situation is to remove all of the vowels from the trolls' comments, neutralizing the threat. Your task is to write a function that takes a string and return a new string with all vowels removed. For example, the string "This website is for...
#This program finds the favtorial of the specified numbers def factorial(number): '''This function finds the factorial of the number passed as argument''' if number < 0: print('Invalid entry! Cannot find factorial of a negative number') if number == 0 or number == 1: return 1 else: ...
cid = input('Digite o nome da sua cidade:') pn = cid.split() if('Santo' in pn[0]): print('Começa com Santo') else: print('Não começa com Santo')
JOYO_JUKUJI = {'伯父': 'おじ', '河岸': 'かし', '今朝': 'けさ', '砂利': 'じゃり', '師走': 'しわす、しはす', '築山': 'つきやま', '祝詞': 'のりと', '寄席': 'よせ', '素人': 'しろうと', '部屋': 'へや', '白髪': 'しらが', 'お巡りさん': 'おまわりさん', '下手': 'へた', '猛者': 'もさ', '差し支える': 'さしつかえる', '一言居士': 'いちげんこじ', '浮気': 'うわき', '数寄屋': 'すきや', '真っ赤': 'まっか', '波止場': 'はとば', '神楽': 'かぐら', '心地': 'ここち', ...
#encoding:utf-8 subreddit = 'cursedimages+cursedcomments+cursedmemes+cursed_images+cursedguns+hmmm+cursedamongus' t_channel = '@r_cursed' def send_post(submission, r2t): return r2t.send_simple(submission)
#!/usr/bin/env python3 #-*- coding: utf8 -*- i = 0 while True: print("i = %d" % i) i += 1
bit_pattern_31 = \ [ 8,-3, 9,5, #/*mean (0), correlation (0)*/, 4,2, 7,-12, #/*mean (1.12461e-05), correlation (0.0437584)*/, -11,9, -8,2, #/*mean (3.37382e-05), correlation (0.0617409)*/, 7,-12, 12,-13, #/*mean (5.62303e-05), correlation (0.0636977)*/, 2,-13, 2,12, #/*mean (0.000134953), correlat...
LOGIN_URL = 'https://pocketapi.48.cn/user/api/v1/login/app/mobile' IM_ROOM_MESSAGE_URL = 'https://pocketapi.48.cn/im/api/v1/chatroom/msg/list/homeowner' IM_ROOM_MESSAGE_ALL_URL = 'https://pocketapi.48.cn/im/api/v1/chatroom/msg/list/all' IM_ROOM_INFO_URL = 'https://pocketapi.48.cn/im/api/v1/im/room/info/type/source' IM_...
"""VHDL generation of the Binary Modulo operator""" __author__ = "Jon Dawson" __copyright__ = "Copyright 2010, Jonathan P Dawson" __license__ = "MIT:" __version__ = "0.1.3" __maintainer__ = "Jon Dawson" __email__ = "chips@jondawson.org.uk" __status__ = "Prototype" def write(stream): identifier = stream.get_identi...
''' Descripttion: version: Author: HuSharp Date: 2021-02-14 18:15:33 LastEditors: HuSharp LastEditTime: 2021-02-14 20:11:25 @Email: 8211180515@csu.edu.cn ''' def tree(label, branches=[]): for branch in branches: assert is_tree(branch), 'branches must tree! ' return [label] + list(branches) def label...
""" Recebendo dados do usuário input() -> Todo dado recebido via input é do tipo String Em Python, string é tudo que estiver entre: - Aspas simples; - Aspas duplas; - Aspas simples triplas; - Aspas duplas triplas; Exemplos: - Aspas Simples -> 'Angelina Jolie' - Aspas duplas -> "Angelina Jolie" - Aspas simples tripla...
def sortedSquaredArray(array): return sorted(map(lambda x: x * x, array)) def test_sample(): assert sortedSquaredArray([1, 2, 3, 5, 6, 8, 9]) == [ 1, 4, 9, 25, 36, 64, 81]
"""@package This package enables the project study field usage for the database. """ class StudyField: """ This class defines a Study Field. e.g.: Computer Science, Mathematics, ... """ def __init__(self, field_name, is_active): """ Study field initializer. :param field_na...
# target wechat user to response wechat_user = 'target user to respond' # chrome driver path driver_path = './chromedriver' # API Keys weather_api = "open weather api" lta_api = "lta datamall api" news_api = "news api" url_api = 'url shorten api' url_workspace = 'url shorten workspace id' # news news_latest = 7 news...
def insertionSort(arr): for i in range(1, len(arr)): # iterate from 1..n element = arr[i] # current element j = i # current index while j > 0 and arr[j - 1] > element: ''' compare with the sorted list on the right and shift those elements one place right ...
"""Normalizes paths to targets which may vary based on the workspace.""" labels = struct( package = Label("@pub__bazel_codegen//:_bazel_codegen"), template = Label("//dart/build_rules/codegen:codegen_template"), )
# -*- coding: utf-8 -*- __all__ = ['test_order_book'] def test_order_book(exchange, orderbook, method, symbol): # todo add real order book tests here print( exchange.id, symbol, method, orderbook['nonce'] if orderbook['nonce'] else orderbook['datetime'], len(orderbook[...
class Container(object): """ Holds hashable objects. Objects may occur 0 or more times """ def __init__(self): """ Creates a new container with no objects in it. I.e., any object occurs 0 times in self. """ self.vals = {} def insert(self, e): """ assumes e is hashable ...
def getSeqTerm(n): if n % 3 == 0: return n // 3 * 2 elif n == 1: return 2 else: return 1 def sumDigits(n): sum = 0 while n > 0: sum += n % 10 n //= 10 return sum def euler65(lastN): num, den = getSeqTerm(lastN), 1 for x in range(lastN - 1, 0, -1): num, den = den + getSeqTerm(x) * num, num retur...
class Note: def __init__(self, **kwargs): self.id = kwargs.get("id") self.title = kwargs.get("title") self.content = kwargs.get("content") def __str__(self): return self.title def __repr__(self): return f"<Note id={self.id} title={self.title}>"
def is_increasing_sequence(sequence): for i in range(len(sequence) - 1): if sequence[i] >= sequence[i + 1]: return i return -1 def almostIncreasingSequence(sequence): j = is_increasing_sequence(sequence) if j == -1: return True if is_increasing_sequence(sequence[j - 1 :...
# For manual installation, fill in the fields below. If you are using # install.sh, the config.py should have been generated for you. APPLICATION_ROOT = None CSRF_ENABLED = True DATABASE_URI = 'mysql+pymysql://root:@localhost:3306/test?charset=utf8' GITHUB_BOT = '' GITHUB_TOKEN = '' GITHUB_OWNER = 'CCExtractor' GITHUB_...
def gcd(a, b): if b == 0: return a else: return gcd(b, a%b) def main(): n = int(input()) a = list(map(int,input().split())) L = [a[0] for _ in range(n)] R = [a[n-1] for _ in range(n)] for i in range(1,n): L[i] = gcd(L[i-1], a[i]) for i in range(1,n): R[i...
with open("dane.txt", "r") as f: liczby = [int(line) for line in f.readlines()] def remove(remove_every_num: int, nums_list: list[int]): i = remove_every_num - 1 # Indeksacja od 0. while i < len(nums_list): del nums_list[i] i = i + (remove_every_num - 1) def gen_lucky_numbers(high: int...
"""Input file for input template test""" def template_function(foo): """Runs some checks on the given function parameter. This rule runs checks on a given function parameter in chosen template. Use `bazel build` to run the check. Args: foo: A unique name for this function. """ pass e...
#n1 = int(input("Insira o valor em metro para converter em centimetros e milimetros: ")) #cen = n1/100 #mil = n1/1000 #print('O valor inserido em centrimetros é: {} e em Milímetros é {},'.format(cen, mil)) medida = float(input('Insira a medida em metros: ')) km = medida/1000 hm = medida/100 dc = medida/10 dm = medida*...
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved. # class FileCompressionType(): def __init__(self): pass Types = { 'GZIP': { 'name': 'GZIP', 'file_extension': '.gz', 'mime_type': 'applica...
''' This is not meant to be edited by the user ''' rest_test_url = "https://tudata-test.ulb.tu-darmstadt.de/rest" rest_url = "https://tudatalib.ulb.tu-darmstadt.de/rest"
# Python program to demonstrate # logical or operator a = 10 b = 10 c = -10 if any([a == b , 4 > 5]): # (a==b or 4 > 5) print("True") else: print("False")
def f(x, y): '''Returns the first argument. :type x: (int, :py:class:`b.C`, b.C) :param b.C y: ignored :rtype: :class:`b.C` ''' _, c = x return c
""" Bruno Franco Salamin 2022-02-14 listas y sus metodos como imprimir una flecha encifrado del cesar refactorización comprensiva buenos nombres """ cabeza = [ " * ", " *** ", "*****"] cuerpo = [" *** "] * 7 def flecha(): for i in cabeza: print(i) for i in cuerpo: p...
# # @lc app=leetcode id=58 lang=python3 # # [58] Length of Last Word # class Solution: def lengthOfLastWord(self, s: str) -> int: ls = len(s) # slow and fast pointers slow = -1 # iterate over trailing spaces while slow >= -ls and s[slow] == ' ': slow -= 1 ...
""" This code has been commented away. It's a bit unclear to what extend we want to continue supporting this feature, hence it was ignored during the 2.x -> 3.x port. """ # import json # import re # from collections import defaultdict # from pathlib import Path # from typing import Any, Dict, List, Optional, Set, Text...
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def reverseKGroup(self, head, k): """ :type head: ListNode :type k: int :rtype: ListNode """ hd = ListNode(0) hd.ne...
''' 2. Write a program to search for the "saddle points" in a 5 by 5 array of integers. A saddle point is a cell whose value is greater than or equal to in its row, and less than or equal to any in its column. There may be more than one saddle point in the array. Print out the coordinates of any saddle points your ...
load( "@bazel_tools//tools/build_defs/repo:utils.bzl", "patch", "read_netrc", "update_attrs", "use_netrc", "workspace_and_buildfile", ) load("@bazel_skylib//lib:versions.bzl", "versions") NETRC_FORMAT = """ machine {hostname} password {token} """ NETRC_ERROR = """ {path} file not found, pl...
""" Recipes available to data with tags ['GHOST', 'CAL', 'ARC']. Default is "makeProcessedArc". """ recipe_tags = set(['GHOST', 'CAL', 'ARC']) def makeProcessedArc(p): """ This recipe performs the standardization and corrections needed to convert the raw input arc images into a single stacked arc image. Th...
# begin the table print("<table>") infile = open("test 3 column.csv","r") for line in infile: row = line.split(",") print("<tr>") for i in row.count: print("<td>%s</td>" % row[i]) print("</tr>") # end the table print("</table>")
N=int(input()) #집의 수 matrix = [] #N개의 집에 대한 R, G, B 비용 map배열 for i in range(N): #각 색별 페인트 비용 map matrix.append(list(map(int, input().split()))) for i in range(1, N): #i번째 집을 빨강으로 칠했을 때의 최소값 matrix[i][0] = matrix[i][0] + min(matrix[i-1][1], matrix[i-1][2]) #i번째 집을 초록으로 칠했을 때의 최소값 ...
SCREEN_WIDTH = 650 SCREEN_HEIGHT = 650 SCALE = 20 CURR_DIRECTION = "right" HIGHSCORE_FILE_PATH = "highscore.txt" DIRECTIONS = { "up": (0, -SCALE), "down": (0, SCALE), "right": (SCALE, 0), "left": (-SCALE, 0), }
mobile = "https://mobile.twitter.com" base = "https://twitter.com/i" async def Favorites(username, init): url = "{}/{}/favorites?lang=en".format(mobile, username) if init != -1: url += "&max_id={}".format(init) return url async def Followers(username, init): url = "{}/{}/followers?lang=en".f...
# coding: utf-8 classificacao = raw_input() tipo = raw_input() especie = raw_input() if (classificacao == "vertebrado"): if(tipo == "ave"): if (especie == "carnivoro"): print("aguia") elif(especie == "onivoro"): print("pomba") elif (tipo == "mamifero"): if (especie == "onivoro"): print("homem") el...
# -*-coding: utf-8 -*- """ @Project: utils @File : __init__.py.py @Author : panjq @E-mail : pan_jinquan@163.com @Date : 2019-05-10 17:08:02 """
class Matrix: def __init__(self, matrix_string: str): # another solution (functional) # [list(map(int, elements.split())) for elements in matrix_string.splitlines()] self.matrix = [ [int(element) for element in elements.split()] for elements in matrix_string.splitline...
class TreeCount: def countWays(self, n): if n <= 1: return n def C(m, n): # 求C(m, n) f = lambda x, y: x * y return reduce(f, range(m, m - n, -1)) / reduce(f, range(1, n + 1)) return C(n * 2, n) / (n + 1)
nome = "C:\\Users\\emerson eduardo\\Desktop\\Engenharia Civil\\hino.txt" with open(nome, "w", encoding='utf-8') as arq: arq.write(" Vamos todos cantar de coração \n") arq.write(" A cruz de malta é o teu pendão! \n") arq.write(" Tens o nome do heroico português \n") arq.write(" Vas...
_base_ = "./wheat_detection_mstrain.py" data_root = "/data/" data = dict( samples_per_gpu=1, train=dict( ann_file=[ data_root + "coco_train.json", data_root + "coco_pseudo_test.json", data_root + "coco_pseudo_test.json", data_root + "coco_pseudo_test.json...
# string = [char for char in input() if char not in ['a', 'o', 'u', 'e', 'i', 'A', 'O', 'U', 'E', 'I']] # print(''.join(string)) print(''.join([char for char in input() if char not in ['a', 'o', 'u', 'e', 'i', 'A', 'O', 'U', 'E', 'I']]))