content
stringlengths
7
1.05M
class Solution: def peakIndexInMountainArray(self, arr: List[int]) -> int: l = -1 r = len(arr) while l < r - 1: m = (l + r) >> 1 if arr[m - 1] < arr[m] and arr[m] > arr[m + 1]: return m elif arr[m - 1] < arr[m]: l = m ...
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. IGNORED_FILE_PREFIXES = ["."] IGNORED_FILE_SUFFIXES = ["~", ".swp"] IGNORED_DIRS = [".git", ".svn", ".hg"] def filter_...
# CHANGEME w = str(input("Pattern: ")) S = str(input("Search string (s): ")) B = {} or_mask = [0]*len(w) or_mask[len(w)-1] = 1 D = [0]*len(w) done = [] for i in list(set(w)): tmp = [0]*len(w) for pos in [pos for pos, char in enumerate(w) if char == i]: tmp[len(w)-pos-1] = 1 B[i] = tmp for c in w...
""" A set of common vocabularies used in MIDAS queries. """ UK_COUNTIES = """ABERDEENSHIRE,ALDERNEY,ANGUS,ANTRIM,ARGYLL (IN HIGHLAND REGION), ARGYLL (IN STRATHCLYDE REGION),ARGYLLSHIRE,ARMAGH,ASCENSION IS, AUSTRALIA (ADDITIONAL ISLANDS),AVON,AYRSHIRE,BANFFSHIRE,BEDFORDSHIRE, BERKSHIRE,BERWICKSHIRE,BORDERS,BOU...
# -*- coding: utf-8 -*- """ smash.models.encryption_model_response This file was automatically generated for SMASH by SMASH v2.0 ( https://smashlabs.io ) """ class EncryptionModelResponse(object): """Implementation of the 'Encryption Model Response' model. TODO: type model description here. A...
N, M = list(map(int, input().split())) grid = [['@' for x in range(M)] for y in range(N)] for i in range(N): line = input() for j in range(M): grid[i][j] = line[j] alreadySeen = False jr = jc = -1 for i in range(N): if alreadySeen: break for j in range(M): if (alreadySeen): ...
''' Author : MiKueen Level : Hard Problem Statement : Median of Two Sorted Arrays There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). You may assume nums1 and nums2 cannot be both empty. Example 1: ...
# -*- coding: utf-8 -*- class JoinMixin(object): """Provide join related functionality to statement classes. Note: This class is not to be instantiated directly. """ def __init__(self, **kwargs): """Constructor Keyword Arguments: **kwargs: Base class arguments. ...
def main(): # Ask for the user's weight in pounds. weight = int(input('Please enter your weight in pounds: ')) # Ask for the user's height in inches. height = int(input('Please enter your height in inches: ')) # Calculate the BMI (BMI = weight*703/height^2) BMI = (weight * 703.0) / (height*hei...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- assert type(b'asdf') == bytes assert len(b'asdf') == 4 assert str(b'asdf') == "b'asdf'" assert type(b'asdf'[0]) == int assert b'asdf'[0] == 97 assert len('中文') == 2 assert len(bytes('中文', encoding = 'utf-8')) == 6 try: bytes('', 'fe') except LookupError as e: ass...
class Employee: def __init__(self, name, ID, department, job_title): self.__name = name self.__id = ID self.__department = department self.__job_title = job_title def set_name(self, name): self.__name = name def set_id(self, ID): self.__id = ID def ...
def selecao_em_vetor(): vetor = list() for i in range(100): vetor.append(float(input())) for j in range(100): if vetor[j] <= 10.0: print(f'A[{j}] = {vetor[j]:.1f}') selecao_em_vetor()
def pythoagorialTripletSum(sum1): if sum == 0: return 0 for i in range(1, int(sum1/3)+1): for j in range(i +1, int(sum1/2) + 1): k = sum1 - i - j if (i * i + j *j == k * k): print(i, j, k, end = " ") return print("No Triplet...
class Scene: def __init__(self, name = ""): #print("new Scene Object created") self.srcs = [] #all sources with visible state of this scene, including srcs from nested scenes self.scenes = [] #list of all nested scenes self.name = name
with open("dane/liczby.txt") as f: lines = [l.strip() for l in f.readlines()] wynik42 = open("wynik42.txt", "w") div_2 = 0 div_8 = 0 for line in lines: if line[-1] == "0": div_2 += 1 if line[-1] == "0" and line[-2] == "0" and line[-3] == "0": div_8 += 1 wynik42.write(f"zadanie 4.2: {div...
st = ['id', 'pwd', 'name', 'age'] data = ['id01', 'pwd01', 'james', 30] cust = zip(st,data) print(cust) for s,d in cust: print('%s : %s' % (s,d)) dic_cust = dict(zip(st,data)) print(dic_cust)
### Quicksort 1 - Partition - Solution def quickSort(arr): pivotNum = arr[0] for i in range(1, len(arr)): if pivotNum > arr[i]: for j in range(i, 0, -1): temp = arr[j] arr[j] = arr[j-1] arr[j-1] = temp print(*arr) n = int(input()) arr = l...
atuple = 'dev', "tst", '''acc''', """prd """ print(atuple,type(atuple),id(atuple), len(atuple))
# 2021-01-30 # Emma Benjaminson # Quick Sort Implementation # Source: https://www.educative.io/edpresso/how-to-implement-quicksort-in-python def QuickSort(arr): elements = len(arr) # base case if elements < 2: return arr current_position = 0 # position of the partitioning element # part...
# # PySNMP MIB module HPR-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPR-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:30:23 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:15)...
def get_binary_rep(data, spacing=0, separator=" "): format(i,'b').zfill(8) def bin_rep_string_arr(data): map() return [] def bin_rep_int_arr(data): return [] def bin_rep_unicode_arr(data): return [] def bin_rep_bytes_arr(data): return [] def hex_rep_string_arr(data): return [] d...
# Accessing tuple elements using slicing my_tuple = ('p','r','o','g','r','a','m','i','n','g') # elements 2nd to 4th print(my_tuple[1:4]) # elements beginning to 4nd print(my_tuple[:-7]) # elements 8th to end print(my_tuple[7:]) # elements beginning to end print(my_tuple[:])
image_width = 400 image_height = 400 prediction_size = 8 batch_size = 10 noise_ratio = 0.1
# # PySNMP MIB module ALTEON-CHEETAH-NETWORK-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ALTEON-CHEETAH-NETWORK-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:05:12 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version ...
D=float(input("Qual a distância a ser percorrida: ")) Vm=int(input("Qual a velocidade média de viagem: ")) T_v= D/Vm minutos= T_v*60 print("tempo de viagem: %d minutos " % minutos)
class Script(object): START_MSG = """<b>👋Hy {}, ഈ ബോട്ട് Moviesbizzv2.0 ഗ്രൂപ്പിലേക്ക് ഉള്ളത് എന്ന് ഇനി വീണ്ടും വീണ്ടും പറയണോ?? അപ്പോ പിന്നെ എന്തിനാ വീണ്ടും വീണ്ടും സ്റ്റാർട്ട് കുത്തി കളിക്കാൻ വരുന്നേ... ആ സൈഡിലോട്ട് എങ്ങാനും മാറി ഇരിക്ക്‌ ഇനി🤭🤭 """ HELP_MSG = """ <i>നീ ഏതാ..... ഒന്ന് പോടെയ് അവൻ help ചോയ...
""" 面向对象 创建桌子类 数据:品牌,材质,尺寸(长,宽,高) 创建电脑类 数据:型号,CPU型号,内存大小,硬盘大小 行为:开机,关机 """ class Desk: def __init__(self,brand="",material="",size=()): self.brand=brand self.material=material self.size=size lege=Desk("乐哥","复合材质",(50,20,10))
# # PySNMP MIB module PDN-IFDEV-IWF-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/PDN-IFDEV-IWF-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:30:02 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Ma...
n = int(input())/10e2 if 0.1 > n: print("00") elif 5 >= n: if len(str(int(n*10))) == 1: print("0{}".format(int(n*10))) else: print(int(n*10)) elif 30 >= n: print(int(n)+50) elif 70 >= n: print((int(n) - 30)//5 + 80) else: print(89)
#TUPLAS SÃO VARIAVEIS COMPOSTAS #AS TUPLAS SÃO IMUTÁVEIS!! #TUPLAS UTILAZAM PARENTESES () OU SEM NADA lanche = ("Hambúrguer" , 'Suco', 'Pizza', 'Pudim') print(lanche[1]) #USANDO O ESQUEMA DE FATIAMENTO DA AULA 09 print(lanche[-1]) #PEGA O ULTIMO ,QUE NO CASO O PUDIM print(lanche[1:3])...
# Gareth Duffy 2-3-2018 # example of for loop using range function as iterator # for loops are definite iterators compared to e.g. while loops (indefinite) for i in range(1, 99, 2): # change range to experiment (third value is the 'step') print(i, end=' ') # end prints all on one line instead of separate lines
fairumei = "alphabet.java" henkou = fairumei.split(".") print(henkou[-1])
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"boto3_available": "00_utils.ipynb", "setStockDataRoot": "00_utils.ipynb", "stockDataRoot": "00_utils.ipynb", "requestUrl": "00_utils.ipynb", "setSecUserAgent": "00_utils.i...
# ============================================ # Global Constants # ============================================ # Shared variables PUZZLE_ROWS = 9 # Number of rows on the board. PUZZLE_COLUMNS = 9 # Number of columns on the board. # Game variables LEVEL_1_TOTAL_MEDALS = 3 LEVEL_2_TOTAL_MEDALS = 4 LEVEL_3_TOTAL_MED...
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def diameterOfBinaryTree(self, root: TreeNode) -> int: if root is None: return 0 ...
""" Error classes for USGS Paremeter Codes""" class Error(Exception): """Base class for other exceptions""" def __init__(self, *args, **kwargs): Exception.__init__(self, *args, **kwargs) class AlreadyExistsError(Error): """Raises an error when data already exists""" def __init__(self, *arg...
class Dataset(): def __init__(self, train_images, test_images, train_labels, test_labels, emotion_index_map, time_delay=None): self._train_images = train_images self._test_images = test_images self._train_labels = train_labels self._test_labels = test_labels self._emotion_i...
""" port part of hwpy: an OO hardware interface library home: https://www.github.com/wovo/hwpy """ class port: """A port is a set of pins. port.n is the number of pins. port.pins are the pins themselves. """ def __init__( self, pins ): """Create a port from a list of pins. """ ...
__author__ = 'alvertisjo' recommenderSE='http://snf-561492.vm.okeanos.grnet.gr:8080/recommender-se/rest/recommender/' recommnederProductCategories=['Home Appliances', 'Electrical Supplies', 'Kitchen Merchandise', 'Pet Care - Food', 'Clothing', 'Sports Equipment', 'Healthcare', 'Communications', 'Lubricants', 'Audio Vi...
"""Probabilistic linear solvers. Iterative probabilistic numerical methods solving linear systems :math:`Ax = b`. """ class ProbabilisticLinearSolver: r"""Compose a custom probabilistic linear solver. Class implementing probabilistic linear solvers. Such (iterative) solvers infer solutions to problems o...
# Python program showing no need to # use global keyword for accessing # a global value # global variable a = 15 b = 10 # function to perform addition def add(): c = a + b print(c) # calling a function add()
def test(): for i in xrange(1): t = '' for j in xrange(int(1e5)): t += 'x' #print(len(t)) test()
""" Copyright (c) 2009 Charles E. R. Wegrzyn All Right Reserved. chuck.wegrzyn at gmail.com This application is free software and subject to the Version 1.0 of the Common Public Attribution License. """
def miniPeaks(nums): result = [] left = 0 right = 0 for i in range(1, len(nums) - 1): left = nums[i - 1] right = nums[i + 1] if nums[i] > left and nums[i] > right: result.append(nums[i]) return result # Time Complexity : O(n) # Space Co...
#!/usr/bin/env python __author__ = "Aditya Pahuja" __copyright__ = "Copyright (c) 2020" __maintainer__ = "Aditya Pahuja" __email__ = "aditya.s.pahuja@gmail.com" __status__ = "Production" class Window: def __init__(self, start_date, stop_date): self.start_date = start_date self.stop_date = stop_d...
#!/usr/bin/python def modular_helper(base, exponent, modulus, prefactor=1): c = 1 for k in range(exponent): c = (c * base) % modulus return ((prefactor % modulus) * c) % modulus def fibN(n): phi = (1 + 5 ** 0.5) / 2 return int(phi ** n / 5 ** 0.5 + 0.5) # Alternate problem solutions start...
""" python实现二叉树 """ class Node: """节点类""" def __init__(self, value): self.value = value self.left = None self.right = None class BinaryTree: def __init__(self): """ 初始化一棵空树,树根为None的树为空树 """ self.root = None def add(self, item): """二叉树中添加1个节点,使用队列思想""...
# List of lists, where each inner list corresponds to a bubble class ListSet: def __init__(self, N): self.N = N self._bubbles = [] for i in range(N): self._bubbles.append({i}) def get_set_label(self, i): """ Return a number that is the same for every elem...
# -*- coding:utf-8 -*- class calc: ''' 計算を行うクラスです ''' def sum_(a, b): ''' 足し算を行う Parameters ---------- a: float b: float Returns ------- sum_: float ''' sum_ = a + b return sum_ def sub_(a, b): ...
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def lowestCommonAncestor(self, root, p, q): """ :type root: TreeNode :type p: TreeNode ...
def is_connected(node1,node2,G): """returns True if node1 and node2 are connected in G. Otherwise returns False Prec:G is a dictionary. node1 and node2 are keys in G""" to_visit=G[node1] visit=[node1] while(to_visit!=[]): cur_node=to_visit[0] visit.append(cur_node) to...
class Vector2D: def __init__(self, vec: List[List[int]]): self.v = vec self.row=0 self.col=0 def next(self) -> int: if self.hasNext(): val=self.v[self.row][self.col] self.col+=1 return val else: return ...
# Create a dictionary with the roll number, name and marks # of n students in a class and display the names of students # who have marks above 75. n = int(input("Enter number of students: ")) result = {} for i in range(n): print("Enter Details of student No.", i+1) rno = int(input("Roll No: ")) name = inp...
def abs(x: str) -> float: return x if x > 0 else -x # print(abs(10)) # print(abs(-10)) x = set() # print(type(x)) x.add(10) x.add(10) x.add(10) # print(x) # print(len(x)) # print([ord(character) for character in input()]) # print(x.__repr__()) # var = map(int, input().split()) # print(var) n = int(input()) ...
first_number = 500 / 100 + 50 + 45 second_number = 250 - 50 print(first_number) print(second_number) total = first_number + second_number print(total)
CORE_URL = "https://www.gov.br/receitafederal/pt-br/assuntos/orientacao-tributaria/cadastros/consultas/dados-publicos-cnpj" CORE_URL_FILES = "http://200.152.38.155/CNPJ" CNAE_JSON_NAME = 'cnaes.json' NATJU_JSON_NAME = 'natju.json' QUAL_SOCIO_JSON_NAME = 'qual_socio.json' MOTIVOS_JSON_NAME = 'motivos.json' PAIS_JS...
CLIENT_LOCK_QUEUE_REQUEST_TIME_OUT = 30000 CLIENT_UNLOCK_QUEUE_REQUEST_TIME_OUT = 30000 CLIENT_DEFAULT_DECLARE_QUEUES_REQUEST_TIME_OUT = 30000 CLIENT_DEFAULT_DECLARE_QUEUE_REQUEST_TIME_OUT = 30000 CLIENT_DEFAULT_DECLARE_EXCHANGES_REQUEST_TIME_OUT = 30000 CLIENT_DEFAULT_DECLARE_EXCHANGE_REQUEST_TIME_OUT = 30000 CLIENT_D...
# Sometimes methods take arguments. # Try changing the argument passed to lpad. # Then try some whole different methods... catcher = 'Joyce' print(third_batter.lpad(10)) print(third_batter.startswith('M')) print(third_batter.endswith(''))
count_shiny_gold_bag = 0 rules = {} with open("input.txt", "r") as f: lines = [line.rstrip() for line in f.readlines()] answered_yes_group = [] for line in lines: line = line.split(" bags contain ") line[1] = line[1].split(",") bags = [] for bag in line[1]: bag ...
class ParserInterface(): def open(self): pass def get_data(self): pass def close(self): pass
# Number of bromine atoms in each species cfc11 = 0 cfc12 = 0 cfc113 = 0 cfc114 = 0 cfc115 = 0 carb_tet = 0 mcf = 0 hcfc22 = 0 hcfc141b = 0 hcfc142b = 0 halon1211 = 1 halon1202 = 2 halon1301 = 1 halon2402 = 2 ch3br = 1 ch3cl = 0 aslist = [cfc11, cfc12, cfc113, cfc114, cfc115, ca...
class S: ASSETS_PATH = "assets/" WINDOW_SIZE = (432, 768) @staticmethod def save_sprite(name, image): name = name.upper() if not hasattr(S, name): setattr(S, name, image) setattr(S, name + "_RECT", image.get_rect())
#!/usr/bin/env python count = 3 list1 = [] while count > 0: num = int(input(">>> ")) list1.append(num) count -= 1 list1.sort() print(list1)
def Fun(): pass class A: def __init__(self): pass def Fun(self): pass try: print(Fun.__name__) print(A.__init__.__name__) print(A.Fun.__name__) print(A().Fun.__name__) except AttributeError: print('SKIP')
a = input() d = {'A':0,'B':0} for i in range(0,len(a),2): d[a[i]] += int(a[i+1]) if d['A'] > d['B']: print("A") else: print("B")
# -*- coding: utf-8 -*- # this file is released under public domain and you can use without limitations ######################################################################### ## This is a sample controller ## - index is the default action of any application ## - user is required for authentication and authorization...
# Leetcode 94. Binary Tree Inorder Traversal # # Link: https://leetcode.com/problems/binary-tree-inorder-traversal/ # Difficulty: Easy # Complexity: # O(N) time | where N represent the number of nodes in the tree # O(N) space | where N represent the number of nodes in the tree # Definition for a binary tree node. ...
""" Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of connected components in an undirected graph. Example 1: 0 3 | | 1 --- 2 4 Given n = 5 and edges = [[0, 1], [1, 2], [3, 4]], retur...
def median(L): L.sort() return L[len(L) // 2] if __name__ == "__main__": L = [10, 17, 25, 1, 4, 15, 6] print(median(L))
""" 9095 : 1, 2, 3 더하기 URL : https://www.acmicpc.net/problem/9095 Input : 3 4 7 10 Output : 7 44 274 """ def make(i, n): if i == n: return 1 count = 0 if (i + 1) <= n: count += make(i + 1, n) if (i + 2) <= n: ...
def greet(bot_name, birth_year): print('Hello! My name is ' + bot_name + '.') print('I was created in ' + birth_year + '.') def remind_name(): print('Please, remind me your name.') name = input() print('What a great name you have, ' + name + '!') def guess_age(): # Remainders are the remains...
''' Все сразу 2 🌶️ Дополните приведенный код, чтобы он: Заменил второй элемент списка на 17; Добавил числа 4, 5 и 6 в конец списка; Удалил первый элемент списка; Удвоил список; Вставил число 25 по индексу 3; Вывел список, с помощью функции print(). --- numbers = [8, 9, 10, 11] ''' numbers = [8, 9, 10, 11] numbers.in...
class Solution: """ @问题: 在 nums = [2,2,1,1,1,2,2] 中找出 majority elements 即出现次数大于一半的数字,这里答案是 2 @思路: 1)如果用字典计数,那么时空间复杂度都是o(n) : 2)用摩尔投票法 Moore Voting,用一个cnt计算某一个元素相比所有其他元素的势能,选那个势能最大的 """ def majorityElement(self, nums: List[int]) -> int: res, cnt = nums[0], 0 for num in nu...
self.description = "Install packages with huge descriptions" p1 = pmpkg("pkg1") p1.desc = 'A' * 500 * 1024 self.addpkg(p1) p2 = pmpkg("pkg2") p2.desc = 'A' * 600 * 1024 self.addpkg(p2) self.args = "-U %s %s" % (p1.filename(), p2.filename()) # We error out when fed a package with an invalid description; the second o...
# 99 Days of Code - Sung to the tune of "99 bottles of beer" x = 99 z = 1 while x > 1: y = x - 1 print(x , "days of code to complete,", x, "days of code.") print("Commit to win,then start again", y, "days of code to complete...") print() x = x - 1 if x == 1: print("1 day of code to complete,",...
def dist(X, m): S = 0 for x in X: S += abs(x - m) return S T = int(input()) for ti in range(T): N, M, F = map(int, input().split()) X = [] Y = [] for fi in range(F): x, y = map(int, input().split()) X.append(x) Y.append(y) X = sorted(X) Y = sorted(Y) F = 2 if F & 1: xx = str(...
# When squirrels get together for a party, they like to have acorns. A squirrel party is successful when the number of acorns is between 40 and 60, inclusively. During the weekends, there is no need for acorns. The party is always fun. # input num_acorns = int(input('Enter the number of acorns: ')) is_weekend = input...
"""Supported Versions class.""" class SupportedVersions: """Container for all supported versions by the ONYX.CENTER.""" def __init__(self, versions: list): """Initialize the versions.""" self.versions = versions def supports(self, version: str) -> bool: """Check if the provided v...
class Report(object): """ Parent class for all reports """ __slots__ = ( 'stats', 'start', 'end', ) def __init__(self, start, end): self.start = start self.end = end def render(self, output): """ Render the report to the specified output file """ ...
# MIN-MAX HACKER EARTH n = int(input()) arr = str(input()) arr = arr.split() arr1 = [] for i in range(0,n,1): x = int(arr[i]) arr1 += [x] min_arr = min(arr1) max_arr = max(arr1) count = 0 for i in range(min_arr+1,max_arr,1): num = i for j in range(0,n,1): if num == arr1[j]: ...
# # Collective Knowledge (MLPerf inference benchmark submitter) # # See CK LICENSE.txt for licensing details # See CK COPYRIGHT.txt for copyright details # # Developer: Grigori Fursin, http://fursin.net # cfg = {} # Will be updated by CK (meta description of this module) work = {} # Will be updated by CK (temporal d...
# -*- coding: utf-8 -*- # (c)2010-2012 Chris Pressey, Cat's Eye Technologies. # All rights reserved. Released under a BSD-style license (see LICENSE). """ Abstract Syntax Trees for the Unlikely programming language. $Id: ast.py 318 2010-01-07 01:49:38Z cpressey $ """ class ArtefactExistsError(Exception): """An...
del_items(0x800A0FE4) SetType(0x800A0FE4, "void VID_OpenModule__Fv()") del_items(0x800A10A4) SetType(0x800A10A4, "void InitScreens__Fv()") del_items(0x800A1194) SetType(0x800A1194, "void MEM_SetupMem__Fv()") del_items(0x800A11C0) SetType(0x800A11C0, "void SetupWorkRam__Fv()") del_items(0x800A1250) SetType(0x800A1250, "...
def arithmetic_arranger(problems, count_start=False): line_1 = "" line_2 = "" line_3 = "" line_4 = "" for i, problem in enumerate(problems): a, b, c = problem.split() d = max(len(a), len(c)) if len(problems) > 5: return "Error: Too many problems." if le...
# Copyright (c) 2019 The Bazel Utils Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. def runtime_library(): return [ "_WINDOWS", "WIN32", ] def winver(): return [ "_WIN32_WINNT=0x0A00", "WIN...
def arithmetic_arranger(problems, solution=False): # Limit of 4 problems per call if len(problems) > 5: return "Error: Too many problems." # Declaring list to organise problems summa1 = [] summa2 = [] operator = [] # Organising problems in right list for problem in problems: ...
""" Azure concepts """ def Graphic_shape(): return "egg" def Graphic_colorfill(): return "#CCCC33" def Graphic_colorbg(): return "#CCCC33" def Graphic_border(): return 0 def Graphic_is_rounded(): return True
# -*- coding: utf-8 -*- """ Created on Wed Feb 2 07:13:58 2022 @author: LENOVO """ #lista en blanco lista = [] #lista con elementos lista2 = [1,2,3,4,5] #Acceder a elementos de una lista listAlumnos = ["juan", "luis", "pablo"] alumnospos_1 = listAlumnos[1] #Hay 3 elementos y solo se puede elegir pero en este meto...
class Solution(object): def isAnagram(self, s, t): """ :type s: str :type t: str :rtype: bool """ letters = [0 for i in range(256)] for i in range(len(s)): letters[ord(s[i])] += 1 for i in range(len(t)): letters[ord(t[i])] -= 1 ...
''' PURPOSE The function capital_indexes takes a single parameter, which is a string. It returns a list of all the indexes in the string that have capital letters. EXAMPLE Calling capital_indexes("HeLlO") should return the list [0, 2, 4]. ''' def capital_indexes(input_str): try: input_str_len ...
n,m = map(int, input().split()) arr = list(map(int, input().split())) a = set(map(int, input().split())) b = set(map(int,input().split())) print(n,m) print(arr) print(a) print(b) c = 0 for i in arr: if i in a: c = c +1 if i in b: c = c-1 print(c)
# Road to the Mine 1 (931060030) | Xenon 3rd Job lackey = 2159397 gelimer = 2154009 goon = 9300643 sm.lockInGameUI(True) sm.spawnNpc(lackey, 648, 28) # TO DO: Figure out why the lackey doesn't move and just spazes in place (initial start x: 1188) # sm.moveCamera(100, 738, ground) # sm.sendDelay(1000) # sm.moveCamer...
PWR_MGMT_1 = 0x6b ACCEL_CONFIG = 0x1C ACCEL_XOUT_H = 0x3B ACCEL_XOUT_L = 0x3C ACCEL_YOUT_H = 0x3D ACCEL_YOUT_L = 0x3E ACCEL_ZOUT_H = 0x3F ACCEL_ZOUT_L = 0x40 GYRO_CONFIG = 0x1B GYRO_XOUT_H = 0x43 GYRO_XOUT_L = 0x44 GYRO_YOUT_H = 0x45 GYRO_YOUT_L = 0x46 GYRO_ZOUT_H = 0x47 GYRO_ZOUT_L = 0x48 TEMP_H = 0x41 TEMP_L = 0x4...
""" __init__.py Created by lmarvaud on 31/01/2019 """
### ### Week 2: Before Class ### ## Make a list of the words one two three o'clock four o'clock rock words = ["one", "two", "three", "o'clock", "four", "o'clock", 'rock'] ## Pick out the first word as a string words[0] ## Pick out the first word as a list words[0:1] ## Pick out the last word as a string word...
word1 = input("Enter a word: ") word2 = input("Enter another word: ") word1 = word1.lower() word2 = word2.lower() dic1 = {} dic2 = {} for elm in word1: if elm in dic1.keys(): count = dic1[elm] count += 1 dic1[elm] = count else: dic1[elm] = 1 for elm in word2: if elm in di...
S = input() if S[-2:] == 'ai': print(S[:-2] + 'AI') else: print(S + '-AI')
def words(digit): for i in digit: num = int(i) if num == 1: print("One") if num == 2: print("Two") if num == 3: print("Three") if num == 4: print("Four") if num == 5: print("Five") if num =...
class Solution: def twoSum(self, numbers, target): """ :type numbers: List[int] :type target: int :rtype: List[int] """ n = len(numbers) left, right = 0, n-1 while left < right: if numbers[left]+numbers[right]==target: return [left+1, right...
# Importação de bibliotecas # Título do programa print('\033[1;34;40mANÁLISE DE DADOS DO GRUPO\033[m') # Objetos maiores = 0 homens = 0 mulheres = 0 # Lógica while True: print('\033[34m-\033[m' * 50) print(f'\033[1;33m{"CADASTRE UMA PESSOA":^50}\033[m') print('\033[34m-\033[m' * 50) idade = int(inp...