content
stringlengths
7
1.05M
# 函数input让程序暂时停止等待用户输入一些文本 name = input('输入自己的名字: ') print(name + ',你好!') # 使用int()来获取数值输入 age = input(name + ',输入你的年龄:') age = int(age) if age < 18: print('未成年🔞') elif 18 < age < 40: print('中年人') else: print('老年人') # 求模运算符 用来求a/b剩下的余数 a = 5 b = 3 i = 6 c = a % b print('') print(c) if c % 2 == 0: ...
class Solution: def longestCommonPrefix(self, strs: List[str]) -> str: if not len(strs): return '' shortest_length = min(len(s) for s in strs) res = [] for i in range(shortest_length): _set = set(s[i] for s in strs) if len(_set) > 1: ...
#Date: 022622 #Difficulty: Easy class Solution(object): def reverseString(self, s): """ :type s: List[str] :rtype: None Do not return anything, modify s in-place instead. """ left = 0 right=len(s)-1 while left<right: s[left],s[right]=s[right],s[lef...
filename = "Tp_Files/examples/files/numbers.txt" # Relative Path with open(filename, 'r') as fh: lines_str = fh.read() # reads all the lines into a string print(len(lines_str)) # number of characters in file print(lines_str) # the content of the file
KtlintConfigInfo = provider( fields = { "editorconfig": "Editor config file to use", }, ) def _ktlint_config_impl(ctx): return [ KtlintConfigInfo( editorconfig = ctx.file.editorconfig, ), ] ktlint_config = rule( _ktlint_config_impl, attrs = { "editor...
number = int(input()) for i in range(number): valores = [float(k) for k in input().split()] x = valores[0] * 0.2 + valores[1] * 0.3 + valores[2] * 0.5 print("{0:.1f}".format(x))
def no_spacing_string(max_length=None, min_length=None): def validate(value): if ' ' in value: raise ValueError('There must be no spaces in this field') if max_length and len(value) > max_length: raise ValueError( f'This field must be shorter than {max_length}...
#!/usr/bin/env python AMAZON_ACCESS_KEY = 'YOUR_AMAZON_ACCESS_KEY' AMAZON_SECRET_KEY = 'YOUR_AMAZON_SECRET_KEY' AMAZON_ASSOC_TAG = 'YOUR_AMAZON_ASSOC_TAG'
def read_log(filename): with open(filename, "r") as f: lines = f.readlines() return [l.strip() for l in lines] def only_success(log_lines): return [l for l in log_lines if "processed user" in l] def only_errors(log_lines): return [l for l in log_lines if "processing error" in l] def get_stats(line): unparse...
def unified_to_char(code_point: str) -> str: """Renders a character from its hexadecimal codepoint :param code_point: Character code point ex: `'261D'` >>> emoji_data_python.unified_to_char('1F603') '😃' """ return ''.join([chr(int(code, 16)) for code in code_point.split('-')])
''' Configuration File. ''' ## # Learning Loss for Active Learning NUM_TRAIN = 50000 # N NUM_VAL = 50000 - NUM_TRAIN BATCH = 128 # B SUBSET = 10000 # M ADDENDUM = 1000 # K MARGIN = 1.0 # xi WEIGHT = 1.0 # lambda TRIALS = 3 CYCLES = 10 EPOCH = 200 LR = 0.1 MILESTONES = [160] EPOCHL = 120 # After 120 epochs...
# read test.txt with open("test.txt") as file: for line in file: print(line[0])
# Pirple: Python is Easy # Homework Assignment 07 - Dictionaries and Sets # Written by Franz A. Tapia Chaca # on 01 Feburary 2021 # Practice using dictionaries # Program: # 1) Details of a song are stored in a dictionary, and a single loop # prints out the song's details # 2) The user is prompted to guess the dictiona...
def login(_id): members = ['dongmin', 'ldm8191', 'leezche'] for member in members: if member == _id: return True return False
""" Copyright 2013 Rackspace 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, software dist...
#Martin Quinn month = [31,28,31,30,31,30,31,31,30,31,30,31] day = 1 year = 1901 sunday = 1 count = 0 i = 0 daycount = 0 monthcount = 0; yearcount = 0; #this is a for loop to count the years for year in range(1900,2000): yearcount = yearcount + 1 #this checks to see wether it is a leap year or not if((year%4)...
for _ in range(int(input())): s = input().split() o = [] for x in s: if len(x) == 4: o.append("****") else: o.append(x) print(*o)
#!/usr/bin/python # class_attribute.py class Cat: species = 'mammal' def __init__(self, name, age): self.name = name self.age = age missy = Cat('Missy', 3) lucky = Cat('Lucky', 5) print(missy.name, missy.age) print(lucky.name, lucky.age) print(Cat.species) print(missy.__class__.species)...
""" Write a program which accepts a sequence of comma-separated numbers from console and generate a list and a tuple which contains every number. Suppose the following input is supplied to the program: 34,67,55,33,12,98 Then, the output should be: ['34', '67', '55', '33', '12', '98'] ('34', '67', '55', '33', '12', ...
"""Helper methods for the Stats class""" def get_numeric_series(): """Creates a list of numbers (float) Returns: [nums]: a list of numbers """ nums = [] inp = get_number() while (inp): nums.append(inp) inp = get_number() return nums def get_number(): """Reads a...
'''Square root approximation to demstrate the use of While loop''' value = int(input('Enter value to approximate its root: ')) #Guess a root root = 1.0 diff = root * root - value while diff > 0.0000001 or diff < -0.0000001: root = (root + value / root) / 2 diff = root * root - value print(root)
#!/usr/bin/env python # coding: utf-8 # ### Reminder Regarding dividing stuff in Python: # IF you divide two integers: python considers this as an integer division ! # dividing one float by an integer: the result is always a float -> so we should convert one of them to float ! # In[8]: L = 2 #k = 0.78 # float k = 1...
class Solution: def maxSlidingWindow(self, nums: List[int], k: int) -> List[int]: que = collections.deque() res = [] for i, num in enumerate(nums): if que and i - que[0][0] >= k: que.popleft() while que and que[-1][1] <= num: que.pop() que.append([i, num])...
""" Some top-level exceptions that are generally useful. """ class UploadedImageIsUnreadableError(Exception): """ Raise this when the image generation backend can't read the image being uploaded. This doesn't necessarily mean that the image is definitely mal-formed or corrupt, but the imaging library ...
# Read to ints and return a multiplication var1 = int(input("Digite um número inteiro: ")) var2 = int(input("Digite um outro número inteiro: ")) def multi(x,y): return x * y print(f'O produto de {var1} com {var2} é igual a {multi(var1, var2)}')
#%% 1-misol list1=[1,2,3] list2=[11, 22, 33] list3=[] if(len(list1)==len(list2)): list3 = [i for j in zip(list1, list2) for i in j] print(list3) elif(len(list1)>len(list2)): list3 = [i for j in zip(list1, list2) for i in j] list3.append(list1[len(list2):len(list1)]) print(list3) elif(len(list1)<l...
# -*- coding:utf-8 -*- class SyntaxException(Exception): pass
FRANCHISES = """ select t1.aliases, overall, firsts, seconds, third, y1,y2, unique_a, unique_1, unique_12 from (select Count(A."PlayerID") as overall,T."Aliases" as aliases, MAX(A."year") as y1, MIN(A."year") as y2, Count (distinct A."PlayerID") as unique_a from public."all-nba-teams_list" A, public.teams T where A...
# # Copyright 2020 The FATE Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
# # PySNMP MIB module SENAO-ENTERPRISE-INDOOR-AP-CB-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SENAO-ENTERPRISE-INDOOR-AP-CB-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:53:40 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using P...
class ModelNotFoundException(Exception): pass class UnknownFunctionException(Exception): pass
# -*- coding: utf-8 -*- """ 二叉树:填充每个节点的下一个右侧节点指针2 https://leetcode-cn.com/problems/populating-next-right-pointers-in-each-node-ii/ """ class Node: def __init__(self, val: int = 0, left: 'Node' = None, right: 'Node' = None, next: 'Node' = None): self.val = val self.left = left self.right = ...
def DivisiblePairCount(arr) : count = 0 k = len(arr) for i in range(0, k): for j in range(i+1, k): if (arr[i] % arr[j] == 0 or arr[j] % arr[i] == 0): count += 1 return count if __name__ == "__main__": #give input in form of a list -- [1,2,3] arr = [int...
# # Copyright (c) 2019 Intel Corporation # # 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...
computers = int ( input () ) total_computers = computers total_rating = 0 total_sales = 0 while not computers == 0: command = int ( input () ) possible_sales = 0 last_digit = command % 10 first_two_digits = command // 10 rating = last_digit if rating == 3: possible_sales = first_two_digi...
def estrai_classico(lista, lettera): output = [] for l in lista: if l[0] == lettera: output.append(l) return output def quadrati(val_massimo): output = [] for v in range(val_massimo): output.append(v ** 2) return output def quadrato(numero): return numero ** 2 def costruisci_pari(i): return "{} è p...
class Teammy: def __init__(self): self.name = 'T3ammy' self.lastname = 'Sit_Uncle_Engineer' self.nickname = 'teammy' def WhoIAM(self): ''' นี่คือฟังชั่่นที่ใช้ในการแสดงชื่อของคราสนี้ ''' print('My name is: {}'.format(self.name)) prin...
""" 백준 11948번 : 과목선택 """ score = [] for _ in range(6): score.append(int(input())) print(sum(score) - min(score[:4]) - min(score[4:]))
#-*- coding:utf-8 -*- ############################################################################## # # Copyright (C) 2012 Michael Telahun Makonnen <mmakonnen@gmail.com>. # All Rights Reserved. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero G...
# name, image, value, uses, [effect] software_list = [ ["Smokescreen", "PLACEHOLDER.JPG", 50, 1], ["Fork", "PLACEHOLDER.JPG", 150, 2], ["Fortify", "PLACEHOLDER.JPG", 75, 2], ["Disrupt", "PLACEHOLDER.JPG", 100, 1], ["Sleep", "PLACEHOLDER.JPG", 200, 4], ["Glamour", "PLACEHOLDER.JPG", 100, 1], ...
# Leo colorizer control file for embperl mode. # This file is in the public domain. # Properties for embperl mode. properties = { "commentEnd": "-->", "commentStart": "<!--", } # Attributes dict for embperl_main ruleset. embperl_main_attributes_dict = { "default": "null", "digit_re": "", ...
# # PySNMP MIB module RH-ATT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RH-ATT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:48: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, 09:...
""" Write a Python program to sum all the items in a list. """ list1 = [1, 2, -8] sum_numbers = 0 for x in list1: sum_numbers += x print(sum_numbers)
################################################################################ # # # ____ _ # # | _ \ ___ __| |_ __ _ _ _ __ ___ ...
class FragmentChain: """Class to represent a set of DNA fragments that can assemble into a linear or circular construct. Parameters ---------- fragments A list of fragments that can be assembled into a linear/cicular construct. is_standardized Indicates whether the fragment is in ...
"""Here we have "scanners" for the different Python versions. "scanner" is a compiler-centric term, but it is really a bit different from a traditional compiler scanner/lexer. Here we start out with text disasembly and change that to be more ameanable to parsing in which we look only at the opcode name, and not and i...
while True: try: num = int(input("Enter the number to find factorial: ")) except: print("Entered value is not valid. Please try again.") continue factorial = 1 if num < 0: print("We can not find the factorial of a negative number.") elif num == 0: ...
# Coffee Break Python a = 'hello' b = 'world' print(a, b, sep=' Python ', end='!')
d = int(input('dias: ')) k = float(input('Km rodados :')) p = 60*d + 0,15*k print(f'R$ {p: .2f}' )
class K8sRepository: def __init__(self): pass @staticmethod def create_k8s_pods_view_model(result): success = [] try: for each_host in result['success']: for each_resource in result['success'][each_host.encode('raw_unicode_escape')]['resources']: ...
""" # Purpose of the bisection method is to find an interval where there exists a root # Programmed by Aladdin Persson # 2019-10-07 Initial programming """ def function(x): # return (x**2 - 2) return x ** 2 + 2 * x - 1 def bisection(a0, b0, eps, delta, maxit): # Initialize search bracket s.t a <= b ...
# Copyright (c) 2012 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': { 'conditions': [ ['OS == "linux" and chromeos==0', { 'use_system_libexif%': 1, }, { # OS != "linux" and chrome...
'''Node class. :copyright: 2021, Jeroen van der Heijden <jeroen@cesbit.com> ''' class Node: __slots__ = ('element', '_string', 'start', 'end', 'children') def __init__(self, element, string, start, end=None): self.element = element self.start = start self.end = end self._str...
#PROCESSAMENTO def concatenar(frase): escopo_frase = frase.strip().upper().split() concatenada = '' for a in range(len(escopo_frase)): concatenada += escopo_frase[a] return concatenada def fraseFormatada(frase): frase_escopo = [] for i in range(len(frase), 0, -1): frase_escopo...
# Paula Daly Solution to Problem 5 March 2019 # Prime Numbers # taking input from user number = int(input("Enter any number: ")) # prime number is always greater than 1 if number > 1: for i in range(2, number): if (number % i) == 0: print(number, "is not a prime number") break e...
n, m = map(int, input().split()) wa = [0 for _ in range(n)] ac = [0 for _ in range(n)] for _ in range(m): p, s = input().split() if s == 'WA' and ac[int(p)-1] == 0: wa[int(p)-1] += 1 else: if ac[int(p)-1] == 0: ac[int(p)-1] = 1 wa_ans = 0 ac_ans = sum(ac) for i in range(n): ...
v = int(input()) # pool`s litters p1 = int(input()) # litters per hour p2 = int(input()) n = float(input()) # hours litters_p1 = p1 * n litters_p2 = p2 * n all_litters_from_p1_p2 = litters_p1 + litters_p2 percent_pool = all_litters_from_p1_p2 / v * 100 percent_p1 = litters_p1 / all_litters_from_p1_p2 * 100 perc...
class Solution(object): def uniquePathsWithObstacles(self, obstacleGrid): row = len(obstacleGrid) col = len(obstacleGrid[0]) grid = [[0 for c in range(col)] for r in range(row)] for c in range(col): if (obstacleGrid[0][c] == 0): grid[0][c...
class FizzBuzz: start = 1 stop = 100 factor_1 = 3 factor_2 = 5 word_1 = "Fizz" word_2 = "Buzz" def __init__(self, *args, **kwargs): self.start = kwargs.get("start", self.start) self.stop = kwargs.get("stop", self.stop) + 1 # non inclusive self.factor_1 = kwargs.get(...
class Config: SCALE=600 MAX_SCALE=1200 TEXT_PROPOSALS_WIDTH=16 MIN_NUM_PROPOSALS = 2 MIN_RATIO=0.5 #0.5 LINE_MIN_SCORE=0.8 #0.9 MAX_HORIZONTAL_GAP=50 #50 TEXT_PROPOSALS_MIN_SCORE=0.7 #0.7 TEXT_PROPOSALS_NMS_THRESH=0.2 #0.2 MIN_V_OVERLAPS=0.7 #0.7 MIN_SIZE_SIM=0.7 ...
""" Given two strings text and pattern, return the list of start indexes in text that matches with the pattern using knuth_morris_pratt algorithm. If idx is in the list, text[idx : idx + M] matches with pattern. Time complexity : O(N+M) N and M is the length of text and pattern, respectively. """ def knuth_morris_pr...
class Sample: def __init__(slf,name) -> None: slf.name = name s = Sample("Deepak") print(s.name)
__all__ = [ "ability","entity","logic","event" #"simple" ]
""" Network related code. """ __author__ = "Brian Allen Vanderburg II" __copyright__ = "Copyright (C) 2017 Brian Allen Vanderburg II" __license__ = "Apache License 2.0"
""" Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one. Example 1: Input: [1,3,4,2,2] Output: 2 Example 2: Input: [3,1,3,4,2] Output: 3 """ ...
class SQLQuery: class solves: createTable = """ CREATE TABLE IF NOT EXISTS ctf_solves ( user INTEGER NOT NULL, question INTEGER NOT NULL, FOREIGN KEY (user) REFERENCES users (id), FOREIGN KEY (question) REFERENCES ctf_q...
class User: def __init__(self, id, name, passwd): self.id = id self.name = name self.passwd = passwd class Game: def __init__(self, name, category, game_console, id=None): self.id = id self.name = name self.category = category self.game_console = game_co...
class no_grad: def __enter__(self): return None def __exit__(self, *args): return True def __call__(self, func): return self class enable_grad: def __enter__(self): return None def __exit__(self, *args): return True def __call__(self, func): ...
# 赛道长度,不建议更改 # TRACK_LENGTH = 48 TRACK_LENGTH = 48 # 最大步伐长度 MAX_STEP = 10 MIN_STEP = 2 # 栅栏数量 FENCE_NUM = '🚧' * 11 # 跑道护栏 GUARD_BAR = "+" * 25 DICT = { "horse_one": ["1号🦄", "🦄"], "horse_two": ["2号🐭", "🐭"], "horse_three": ["3号🐗", "🐗"], "horse_four": ["4号🦌", "🦌"], "horse_five": ["5号🐴", "...
class Point(object): """ Creates Class Point. """ def __init__(self, x=0, y=0): """ Defines x and y Variables. """ self.__coords = [x, y] # get functions series def get_x(self): return self.__coords[0] def get_y(self): return self.__coords[1] def get_c(self, po...
result = DATA result[:, 0] = result[:, 0].clip(50, 80)
#!/usr/bin/env python __all__ = [ "test_blast", "test_blast_xml", "test_cigar", "test_clustal", "test_dialign", "test_ebi", "test_fasta", "test_genbank", "test_locuslink", "test_ncbi_taxonomy", "test_nexus", "test_phylip", "test_record", "test_record_finder", ...
"""Faça um Programa que leia um número e exiba o dia correspondente da semana. (1-Domingo, 2- Segunda, etc.), se digitar outro valor deve aparecer valor inválido""" print('Digite um numero para o dia da semana, sendo') print('1 Domingo') print('2 Segunda feira') print('3 Terça feira') print('4 Quarta feira') print('5 ...
# # PySNMP MIB module QB-QOS-MGMT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/QB-QOS-MGMT-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:43:34 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27...
class BaseLines(object): def __init__(self, tc_freq, t_freq): # get probability of context given target <likelihood> self.row_sums = tc_freq.astype(float).sum(axis=1) self.p_c_given_t = (tc_freq.astype(float)+1) / (self.row_sums[:, np.newaxis] + 1 + corpus_size) # get probability of target <prior> self.p_t ...
# For the complete list of possible settings and their documentation, see # https://docs.djangoproject.com/en/1.11/ref/settings/ and # https://github.com/taigaio/taiga-back/tree/stable/settings. Documentation for # custom Taiga settings can be found at https://taigaio.github.io/taiga-doc/dist/. # Make sure to read http...
class Customer: def __init__(self, first_name, last_name, phone_number, email, national_id, driving_license, customer_id=None, creation_date=None): self.customer_id = customer_id self.first_name = first_name self.last_name = last_name self.phone_number = phone_numb...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) minimum = min(a) min_count = a.count(minimum) if min_count < 2 or not (n * minimum == sum([(num & minimum) for num in a])): print(0) else: total = 2 total *= min_count * (min_count - ...
""" Shoots balls using cardboard and paper plates, tastefully decorated with EDM artists. """ class Shooter(object): def __init__(self, shooterM, hopperM, shooterS, hopperS): self.shooterM = shooterM self.hopperM = hopperM self.shooterS = shooterS self.hopperS = hopperS s...
# Escreva um programa que leia um valor em metros e o exiba convertido em centímetros e milímetros. print('-' * 100) print('{: ^100}'.format('EXERCÍCIO 008 - CONVERSOR DE MEDIDAS')) print('-' * 100) n = float(input('Uma distância em metros: ')) mm = n * 1000 cm = n * 100 dm = n * 10 dam = n / 10 hm = n / 100 km = n ...
''' Alocação de Sala de Cinema O objetivo dessa atividade é implementar o sistema de alocação de uma única sala de cinema. Se existem cadeiras livres, os clientes podem reservá-las. Também podem desistir da reserva. O sistema deve mostrar quem está sentado em cada cadeira. ''' class Cliente: def __init__(self, no...
# ch4/ch01_ex01.py n_files = 254 files = [] # method 1 for i in range(n_files): files.append(open('output1/sample%i.txt' % i, 'w')) # method 2 '''for i in range(n_files): f = open('output1/sample%i.txt' % i, 'w') files.append(f) f.close()''' # method 3 '''for i in range(n_files): with open('outp...
""" Linked List: - Linked List is a collection of node that connected through their references. - It is a linear data structure. - It provides faster insertion and deletion over array. Doubly Linked List: Doubly Linked List is type of linked list in which every node bi-directionally connected...
# input.py get users input email = 'username@gmail.com' password = 'password' title = 'software engineer' zipCode = '91101' name = 'John Do' phone = '(xxx) xxx-xxxx'
# Alexa is given n piles of equal or unequal heights. # In one step, Alexa can remove any number of boxes from # the pile which has the maximum height and try to make # it equal to the one which is just lower than the maximum # height of the stack. # Determine the minimum number of steps required to make all of # the p...
''' Created on 1.12.2016 @author: Darren '''''' Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its next right node. If there is no next right node, the next pointer...
class Solution: def solve(self, board: List[List[str]]) -> None: """ Do not return anything, modify board in-place instead. """ def valid(i, j, m, n): return i >= 0 and i < m and j >= 0 and j < n def dfs(board, i, j, m, n): di = [-1, ...
class Vector2(object): def __init__( self, args ): x, y = args self.x, self.y = float( x ), float( y ) def __str__( self ): s = "(" s += ", ".join( [ str( i ) for i in [ self.x, self.y ] ] ) s += ")" return s class Vector3(object): def __init__( self, args ): x, y, z = args self.x...
class Solution(object): def combine(self, N, K): def helper(first, combination): if len(combination)==K: answer.append(combination) else: for num in xrange(first, N+1): helper(num+1, combination+[num]) answer = [] he...
class Solution: def minimumSum(self, num: int) -> int: arr = [] while num: arr.append(num%10) num = num // 10 arr.sort() return (arr[0]*10 + arr[3]) + (arr[1]*10 + arr[2])
'''Faça um programa que leia nome e média de um aluno, guardando também a situação em um dicionário. No final, mostre o conteúdo da estrutura na tela.''' alunos = [] aluno1 = dict() aluno1['Nome'] = input('Nome: ') aluno1['Media'] = float(input('Média: ')) alunos.append(aluno1) for i in alunos: if i['Media'] >= 7...
def _impl(ctx): ctx.actions.write( output = ctx.outputs.executable, content = ctx.file._shellcheck.short_path, ) return [ DefaultInfo( executable = ctx.outputs.executable, runfiles = ctx.runfiles(files = [ctx.file._shellcheck]), ), ] def _impl_tes...
# coding=utf-8 """ 二叉树最长连续序列 给一棵二叉树,找到最长连续路径的长度。 这条路径是指 任何的节点序列中的起始节点到树中的任一节点都必须遵循 父-子 联系。最长的连续路径必须是从父亲节点到孩子节点(不能逆序)。 思路: 这题扯兮兮的 """ """ Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ class Solution: """ @param roo...
initial_hash_values = [ '6a09e667', 'bb67ae85', '3c6ef372', 'a54ff53a', '510e527f', '9b05688c', '1f83d9ab', '5be0cd19' ] sha_256_constants = [ '428a2f98', '71374491', 'b5c0fbcf', 'e9b5dba5', '3956c25b', '59...
# required argument, the arguments passed to the function in correct positional order.  def func(a, **b): print(b) print(b['d']) func(a=1, b=2, c=3, d=4) # Variable-length arguments: This used when you need to process unspecified additional arguments. # An asterisk (*) is placed before the variable name ...
print('=' * 20) print('10 termos de uma PA') print('=' * 20) n1 = int(input('Primeiro termo: ')) n2 = int(input('Digite a razão: ')) dec = n1 + (10 - 1) * n2 for c in range(n1, dec + n2, n2): print(c, end=' -> ') print('Acabou')
#!/usr/bin/python -OO # -*- coding: UTF-8 -*- """ Хук проверяет, что логин - валидный почтовый адрес пользователя Кристы или ССКсофт Подключение централизованное, через Kallithea pretxnchangegroup.release_branch_merge_control = python:path/to/script/check-login.py:pretxnchangegroup_badmerges """ domains = ['foo.b...
# Author: Ashish Jangra from Teenage Coder num = 5 for i in range(5): print(num * "* ")
# Question # 37. Write a program to perform sorting on the given list of strings, on the basis of length of strings # Code a = input("List of strings, sep with commas:\n") strings = [i.strip() for i in a.split(",")] strings.sort(key=lambda x: len(x)) print("Sorted strings") print(strings) # Input # List of string...
# Medium # https://leetcode.com/problems/unique-paths-ii/ # TC: O(M * N) # SC: O(N) class Solution: def uniquePathsWithObstacles(self, obstacleGrid: List[List[int]]) -> int: n, m = len(obstacleGrid[0]), len(obstacleGrid) prev_row = [0 for _ in range(n)] for i in range(m): for j...