content
stringlengths
7
1.05M
def BuscarCaja(p,q): global L mitad=(p+q)//2 if q==p+1 or q==p: if L[p]==1: return p else: return q elif 1 in L[mitad:q+1]: return BuscarCaja(mitad,q) else: return BuscarCaja(p,mitad-1) L=[0,0,0,0,1,0] print("Indice: "+str(BuscarCaja(0,len(L)-1))) L=[0,1,0,0,0,0,0,0...
# 32. Longest Valid Parentheses # ttungl@gmail.com # Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. # For "(()", the longest valid parentheses substring is "()", which has length = 2. # Another example is ")()())", where the longes...
class TimeoutError(Exception): """Error raised when .result() on a future doesn't return within time.""" class EventLoopNotInitialized(Exception): """Event loop not initialized.""" class RequestBodyNotBytes(Exception): """Request body must be bytes."""
#!/usr/bin/env python3 class Solution(object): def searchInsert(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ if(len(nums) == 1): if(target > nums[0]): return 1 elif(target < nums[0]): return 0 else: return 0 # Split the array in half halfLengt...
#! /usr/bin/env python3 # -*- coding: utf-8 -*- # # binary_heap_implement.py # python # # 🎂"Here's to the crazy ones. The misfits. The rebels. # The troublemakers. The round pegs in the square holes. # The ones who see things differently. They're not found # of rules. And they have no respect for the status quo. # You...
SUCCEED='SUCCEED' FAILED='FAILED' FORCE_RESIZE_IMAGE=True DEFAULT_AVAILABLE_PRODUCT_FOR_SHOP=60 DEFAULT_SHIPPING_FEE=2000 CURRENCY=' تومان' # Image Size for models PRODUCT_IMAGE_WIDTH=600 PRODUCT_IMAGE_HEIGHT=600 PRODUCT_THUMBNAIL_WIDTH=250 PRODUCT_THUMBNAIL_HEIGHT=250 CATEGORY_IMAGE_WIDTH=250 CATEGORY_IMAGE_HEIG...
""" Copyright 2021 Google LLC 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 https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, softw...
def main(request, response): cookie = request.cookies.first(b"COOKIE_NAME", None) response_headers = [(b"Content-Type", b"text/javascript"), (b"Access-Control-Allow-Credentials", b"true")] origin = request.headers.get(b"Origin", None) if origin: response_headers.append(...
#!/usr/bin/env python # Copyright Contributors to the Open Shading Language project. # SPDX-License-Identifier: BSD-3-Clause # https://github.com/AcademySoftwareFoundation/OpenShadingLanguage command += testshade("-t 1 -g 64 64 -od uint8 -o Fout spline_c_float_v_floatarray.tif test_spline_c_float_v_floatarray") comm...
# coding: utf-8 n, r, avg = [int(i) for i in input().split()] li = [] for i in range(n): tmp = [int(i) for i in input().split()] li.append([tmp[1],tmp[0]]) li.sort(reverse=True) dis = avg*n-sum([i[1] for i in li]) ans = 0 while dis > 0: exam = li.pop() if dis <= r-exam[1]: ans += exam[0]*dis ...
#elif basic a = 10 if(a < 1): print('benar') elif(a > 1): print('salah') elif(a == 1): print('input salah') else: print('input salah')
class Solution: def createTargetArray(self, nums, index): target = [] for n, i in zip(nums, index): target.insert(i, n) return target
""" 2. Add Two Numbers Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) Output: 7 -> 0 -> 8 Explanation: 342 + 465 = 807. """ # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def addTwoNumbers(self, l1, l2): ...
cmd = [] with open('input.txt', 'r') as f: cmd = list(map(lambda l: l.strip().split(' '), f.readlines())) horizon_pos = 0 deep = 0 aim = 0 for c in cmd: if c[0] == 'forward': val = int(c[1]) horizon_pos += val deep += aim * val elif c[0] == 'down': aim += int(c[1]) elif c[0] == 'up': aim -= int(c[1]) pri...
class ChildObject: def __init__(self, sumo_client, meta_data): self.sumo = sumo_client self.__blob = None self.__png = None source = meta_data["_source"] fields = meta_data["fields"] self.tag_name = fields["tag_name"][0] self.sumo_id = meta_data["_id"] ...
confusables = { u'\u2460': '1', u'\u2780': '1', u'\U0001D7D0': '2', u'\U0001D7DA': '2', u'\U0001D7E4': '2', u'\U0001D7EE': '2', u'\U0001D7F8': '2', u'\uA75A': '2', u'\u01A7': '2', u'\u03E8': '2', u'\uA644': '2', u'\u14BF': '2', u'\uA6EF': '2', u'\u2461': '2', ...
''' All tests for the Osscie Package ''' def test_1(): ''' Sample Test ''' assert True
# built_ins.py # # https://www.educative.io/module/lesson/advanced-concepts-in-python/qZ4ZVVDN6kp # map """ The map built-in also takes a function and an iterable and return an iterator that applies the function to each item in the iterable """ def doubler(x): return x * 2 my_list = [1, 2, 3, 4, 5] for item i...
config = dict( # Project settings project_name='MoA_feature_selection', batch_size=1024, num_workers=4, # Validation n_folds=5, # Preprocessing outlier_removal=True, # TODO # General training # Ensemble of models ensemble=[ dict( # Model ...
class Par(object): def __init__(self,tokens): self.tokens=tokens def parse(self): self.count = 0 while self.count < len(self.tokens): tokens_type = self.tokens[self.count][0] tokens_value = self.tokens[self.count][1] #print(tokens_type , tokens_value) if tokens_type == 'VARIABLE' and tokens...
class ProgressBarStyle(Enum, IComparable, IFormattable, IConvertible): """ Specifies the style that a System.Windows.Forms.ProgressBar uses to indicate the progress of an operation. enum ProgressBarStyle,values: Blocks (0),Continuous (1),Marquee (2) """ def __eq__(self, *args): """ x._...
""" UPPER VS LOWER: Write a Python function that accepts a string and calculates the number of upper case letters and lower case letters. Sample String : 'Hello Mr. Rogers, how are you this fine Tuesday?' Expected Output : No. of Upper case characters : 4 No. of Lower case Characters : 33 HINT: Two string methods th...
""" @name: PyHouse/src/Modules/Families/__init__.py @author: D. Brian Kimmel @contact: D.BrianKimmel@gmail.com @copyright: (c) 2013-2015 by D. Brian Kimmel @note: Created on May 17, 2013 @license: MIT License @summary: Various families of lighting systems. insteon upb x-10 zigbee z-wave lutron and o...
input_str = """ cut -135 deal with increment 38 deal into new stack deal with increment 29 cut 120 deal with increment 30 deal into new stack cut -7198 deal into new stack deal with increment 59 cut -8217 deal with increment 75 cut 4868 deal with increment 29 cut 4871 deal with increment 2 deal into new stack deal with...
'''Implemente a função fatorial(x), que recebe como parâmetro um número inteiroe devolve um número inteiro correspondente ao fatorial de x. Sua solução deve ser implementada utilizando recursão.''' def fatorial(x): if x <= 1: return 1 else: return x * fatorial(x - 1)
print("Hello! Please answer a few questions:") user_name = input("What is your name? ") user_age = input("How old are you? ") user_city = input("Where do you live? ") print(f"""\nHello, {user_name.title()}! Your age is {user_age}, You live in {user_city.title()}.""") input()
"""Baseball statistics calculation functions.""" def batting_average(at_bats, hits): """Calculates the batting average to 3 decimal places using number of at bats and hits.""" try: return round(hits / at_bats, 3) except ZeroDivisionError: return round(0, 3)
# Problem: https://docs.google.com/document/d/1tS-7_Z0VNpwO-8lgj6B3NWzIN9bHtQW7Pxqhy8U4HvQ/edit?usp=sharing message = input() rev = message[::-1] for a, b in zip(message, rev): print(a, b)
class ConfigFromJSON(object): def __init__(self, filename): self.json_file = filename @property def json_file(self): print('set') return self.__json_file @json_file.setter def json_file(self, value): print('check') if value is not 0: raise Value...
# @Time : 2019/8/11 10:45 # @Author : shakespere # @FileName: Word Break.py class Solution(object): def wordBreak(self, s, wordDict): dp = [False * (len(s)+1)] dp[0] = True#空字符串 for i in range(1,len(s)+1): for j in range(i): if dp[j] and s[j:i] in wor...
# -*- coding: utf-8 -*- # @Time : 2019-12-20 16:17 # @Author : songzhenxi # @Email : songzx_2326@163.com # @File : LeetCode_242_1034.py # @Software: PyCharm # 给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的字母异位词。 # # 示例 1: # # 输入: s = "anagram", t = "nagaram" # 输出: true # # # 示例 2: # # 输入: s = "rat", t = "car" # 输出: false...
class _GetAttrAccumulator: @staticmethod def apply(gaa, target): if not isinstance(gaa, _GetAttrAccumulator): if isinstance(gaa, dict): return { _GetAttrAccumulator.apply(k, target): _GetAttrAccumulator.apply(v, target) for k, v in gaa....
# Smallest Difference Problem : Two arrays are given and you have to find the # pair (i , j) such abs(i-j) is the smallest where i belongs to the first array and j belong to the second array respectively def smallestDifference(arr1 : list, arr2 : list) : arr1.sort();arr2.sort() i = 0;j = 0 smalles...
class CasHelper: def __init__(self, app): self.app = app def wrong_password(self, credentials): wd = self.app.wd #self.app.open_home_page() wd.find_element_by_css_selector("input.form-control").click() wd.find_element_by_css_selector("input.form-control").clear() ...
"""Nullutil: nullutil for Python.""" # Null Coalesce # This means: # lhs ?? rhs def qq(lhs, rhs): return lhs if lhs is not None else rhs # Safty Access # This means: # instance?.member # instance?.member(*params) def q_(instance, member, params=None): if instance is None: return None ...
# -*- coding: utf-8 -*- # Authors: Y. Jia <ytjia.zju@gmail.com> """ Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). https://leetcode.com/problems/minimum-window-substring/description/ """ class Solution(object): def minWindow(self, s,...
class Articles: """ Article class defines Article objects """ def __init__(self,author,title,description,article_url,image_url,days,hours,minutes): self.author = author self.title = title self.description = description self.article_url = article_url self.image_ur...
class AnyArg(object): """AnyArg for wildcard mock assertions""" def __eq__(self, b: any): return True
""" This file was generated when mcuprog was built """ VERSION = '3.9.1.120' COMMIT_ID = '84ffb61b46baa4fb20896deb0179d09fe3097b5c' BUILD_DATE = '2021-08-23 18:16:12 +0700'
''' Created on 2017. 8. 16. @author: jongyeob ''' _tlm0x8D2_image_size = 2048 tlm0x08D2_struct = [('I','frame_number'), ('I','frame_position'), ('{}B'.format(_tlm0x8D2_image_size),'data')]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- assert True; assert not False assert True assert not False
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Written by Lucas Sinclair and Paul Rougieux. JRC biomass Project. Unit D1 Bioeconomy. """ # Built-in modules # # Third party modules # ############################################################################### class Graphs(object): def __getitem__(self, k...
# # PySNMP MIB module SNMP-USM-DH-OBJECTS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SNMP-USM-DH-OBJECTS-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:00:30 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 ...
pessoas = list() dados = list() pesados = list() leve = list() menor = maior = 0 while True: nome = str(input('Insira o nome: ')) peso = float(input('Insira o peso (kg): ')) if len(pessoas) == 0: menor = peso maior = peso elif peso < menor: menor = peso elif peso > maior: maior = peso dad...
# coding=utf-8 # Author: Jianghan LI # Question: 072.Edit_Distance # Complexity: O(N) # Date: 2017-09-06 8:01 - 8:11, 0 wrong try class Solution(object): def minDistance(self, w1, w2): """ :type word1: str :type word2: str :rtype: int """ m, n = len(w1) + 1, len(w2...
# -*- coding: utf-8 -*- __version__ = '0.1.0b1' __description__ = """Simple AWS Route 53 DNS Updater. Dynamically update a Route 53 DNS record to the current public IP of the computer/network it is executed on. Records will only be modified if the current value and public IP differ. """
def get_message_native_type(type): dictionary = { 'uint8': 'uint8_t', 'uint16': 'uint16_t', 'uint32': 'uint32_t', 'uint64': 'uint64_t', 'int8': 'int8_t', 'int16': 'int16_t', 'int32': 'int32_t', 'int64': 'int64_t', 'buffer': 'iota::vector<uint8_t>', 'list': 'iota::vector<uint64_t>', 'string': 'iot...
''' @author: l4zyc0d3r People who are happy makes other happy. I am gonna finish it slowly but definitely.cdt ''' class Solution: def triangleNumber(self, N: List[int]) -> int: cou = 0 N.sort(reverse=True) for k, x in enumerate(N): j = k+1 i = len(N)-1 w...
# print("小明") # import random # for i in range(5): # print(i) # for j in 'string': # print(j) # # for m in range(0,5): # print(m*(random.random())) # # def insert_sort(ilist): # for i in range(len(ilist)): # print(i) # for j in range(i): # print(j) # # if ilist[i]...
""" Manually selected famous paintings that can be optionally put in a test-set. The MIT License (MIT) Originally created at 6/23/20, for Python 3.x Copyright (c) 2021 Panos Achlioptas (ai.stanford.edu/~optas) & Stanford Geometric Computing Lab """ masterpieces_for_test = [ 'leonardo-da-vinci_mona-lisa', 'vin...
m = [("chethan", 20, 30), ("john", 40, 50)] print(m[1]) file = open("writingintocsvfile.csv", "w") file.write("Name, Age, Weight") for n in range(len(m)): file.write('\n') for k in range(len(m[1])): file.write(str(m[n][k])) file.write(',') file.close()
# 014_Conversor_de_temperatura.py # Converte temperatura de ºC para ºF print() C = float(input("Temperatura em ºC: ")) F = (9/5)*C + 32 print(f"{C}ºC equivale a {F:.1f}ºF") print()
def add_numbers(num1 , num2): return num1 + num2 def subtract_numbers(num1 , num2): return num1 - num2 def multiply_numbers(num1 , num2): return num1 * num2 def divide_numbers(num1 , num2): return num1 / num2
def multiples_of_3_or_5(limit: int) -> int: """Computes the sum of all the multiples of 3 or 5 below the given limit, using tail recursion. :param limit: Limit of the values to sum (exclusive). :return: Sum of all the multiples of 3 or 5 below the given limit. """ def loop(acc, num): if...
""" Python Lists Lists are the most versatile of Python's compound data types. A list contains items separated by commas and enclosed within square brackets ([]). To some extent, lists are similar to arrays in C. One of the differences between them is that all the items belonging to a list can be of different da...
""" This file assembles a toolchain for a Mac M1 host using the Clang Compiler and glibc. It downloads the necessary headers, executables, and pre-compiled static/shared libraries to the external subfolder of the Bazel cache (the same place third party deps are downloaded with http_archive or similar functions in WORK...
class DynamicOptions: def alphad(self, value="", **kwargs): """Defines the mass matrix multiplier for damping. APDL Command: ALPHAD Parameters ---------- value Mass matrix multiplier for damping. Notes ----- This command defines the mass...
class DefinitionGroups(object, IEnumerable[DefinitionGroup], IEnumerable, IDisposable): """ A specialized set of definition groups that allows creation of new groups. """ def Contains(self, definitionGroup): """ Contains(self: DefinitionGroups,definitionGroup: DefinitionGroup) -> bool ...
def solution(): data = open(r'inputs\day11.in').readlines() print('Part 1 result: ' + str(part1(data))) print('Part 2 result: ' + str(part2(data))) def part1(data): # 2d array of ints that represents the octopus' current value octomap = [] for line in data: octomap.append([int(x) for x ...
{ "variables": { "boost_lib": "<!(node -p \"process.env.BOOST_LIB || '../../deps/boost/stage/lib'\")", "boost_dir": "<!(node -p \"process.env.BOOST_DIR || 'boost'\")", "conditions": [ ["target_arch=='x64'", { "arch": "x64", }], ["target_arch=='ia32'", { "arch": "x32", }], ], }, "target_...
# # @lc app=leetcode.cn id=94 lang=python3 # # [94] 二叉树的中序遍历 # # https://leetcode-cn.com/problems/binary-tree-inorder-traversal/description/ # # algorithms # Medium (71.81%) # Likes: 544 # Dislikes: 0 # Total Accepted: 180.4K # Total Submissions: 251.1K # Testcase Example: '[1,null,2,3]' # # 给定一个二叉树,返回它的中序 遍历。 #...
# 10. 矩形覆盖 # 我们可以用2*1的小矩形横着或者竖着去覆盖更大的矩形。请问用n个2*1的小矩形无重叠地覆盖一个2*n的大矩形,总共有多少种方法? # 直接递归 复杂度过高 内存溢出 # -*- coding:utf-8 -*- class Solution: def rectCover(self, number): # write code here if(number<=2): return number return self.rectCover(number-1) + self.rectCover(number-2) # 尾递归 # ...
''' - DESAFIO 043 - Desenvolva uma lógica que leia o peso e a altura de uma pessoa, calcule seu IMC e mostre o seu status de acordo com a tabela abaixo: - Abaixo de 18.5: Abaixo do peso - Entre 18.5 e 25: Peso ideal - 25 até 30: Sobrepeso - 30 até 40: Obesidade - Acima de 40: Obesidade mórbida ''' p...
class Solution: def solve(self, nums): setNums = set(nums) count = 0 for i in setNums: if i + 1 in setNums: count += nums.count(i) return count
# -*- coding: utf-8 -*- """ Created on 14 Apr 2020 15:08:45 @author: jiahuei """
class Movie: def __init__(self, name): self.__name = name @property def name(self): return self.__name def __str__(self) -> str: return self.__name class Ticket: def __init__(self, movie=None, location=None): if movie is None: movie = Movie('Avengers'...
"""Experiments Module ======================== This module merge all the modules under the concept of experiment. """
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Oct 16 09:42:38 2019 @author: Giles """ # x = 5 # y = 12 # # z = x + y # # print(z) # 1x = 3 # new_variable = 9 # z = x - y # a = 2.5 # b = 3.14159 # c = b * a**2 # # # radius = 2.5 # pi = 3.14159 # area_of_circle = pi * radius**2 # phrase_1 = 'Th...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def _closest(lst, number): """Find the closest number in a list. Arguments: lst: List to look into. number: Desired number. """ return lst[min(range(len(lst)), key=lambda i: abs(lst[i] - number))]
# -*- coding:utf-8 -*- #https://leetcode.com/problems/substring-with-concatenation-of-all-words/description/ class Solution(object): def findSubstring(self, s, words): """ :type s: str :type words: List[str] :rtype: List[int] """ ret = [] if not word...
channel = "test-channel" feedtitle = "Discord Channel RSS" feedlink = "github.com/gmemstr/webbot" feeddescription = "Discord Channel RSS" flaskdebug = True flaskport = 5000
class Solution: def triangleNumber(self, nums): """ :type nums: List[int] :rtype: int """ # valid triangle sum of two smaller nums > largest num nums.sort(reverse=True) cnt, n = 0, len(nums) for i in range(n - 2): # if i > 0 and nums[i] == ...
""" Problem #1: Add Two Numbers Leetcode URL: https://leetcode.com/problems/add-two-numbers/ Description on LeetCode: " You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return ...
#: A dict contains permission's number as string and its corresponding meanings. PERM_MAP = { "1": "download and preview", "2": "upload", "3": "upload, download, preview, remove and move", "4": "upload, download, preview, remove, move and change acls of others", "5": "preview" } #: A set contains a...
#!/usr/bin/env python # -*- encoding: utf-8 -*- # vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8: # Author: https://github.com/LFreedomDev # Created on 2018-08-31 # pretask schema { 'pretask': { 'taskid':str, 'project': str, 'url': str, } } class PreTaskDB(object): """ databa...
def _reduced_string(s): if not s: return "Empty String" letters = list() counts = list() last = "" counts_index = -1 for ch in s: if last != ch: letters.append(ch) counts.append(1) counts_index += 1 last = ch else: ...
# Config file for user settings # Change anything as desired ''' Navigation Settings ''' PAN_DIST = 15 PAN_DIST_LARGE = 60 ZOOM_FACTOR = 1.35 '''Canvas Settings''' SUB_COLOR = (1, 0, 0, 1) PATH_COLOR = (0, 0, 0, 0.7) GRID_COLOR = (0.4, 0, 0, 0.3) TAG_COLOR = (0, 0, 1, 0.8) ELEMENT_COLOR = (0, .5, 0, 1.0) MAGNIFY = 4...
class Solution(object): def combinationSum2(self, candidates, target): """ :type candidates: List[int] :type target: int :rtype: List[List[int]] """ path = [] res = [] candidates.sort() def dfs(i,n,t): if t == 0: res...
''' Python函数测试代码 ''' def testFunc(width, height): return width * height # 区分是执行文件还是被其他模块调用 if __name__ == "__main__": print("执行main方法") else: print(__name__) # 这行代码没有被区分是执行文件还是被调用,所以如果被其他模块引入的时候会执行 # print("5 * 5 =",testFunc(5, 5))
# 使用海象运算符 # 海象运算符的本质是先求出左边的表达式的值,然后将值赋值给右边的变量 # 然后根据这个变量的值进行判断,这样子可以减少一个临时的别的变量进行判断 foo = {'a': 10, 'b': 0} # 常规方式 a_num = foo.get('a', 0) if a_num: print('a > 0') # 海象运算符 if a := foo.get('a', 0): print('a > 0')
def find_peak(arr, begin=0, end=None, l=None): '''find_peak is a recursive function that uses divide and conquer methodolology (similar to binary search) to find the index of a peak element in O(log n) time complexity''' # initialize values on first iteration if end is None or l is None: l =...
ECG_CHAN_1 = 0 ECG_CHAN_2 = 1 ECG_CHAN_3 = 2 LEAD_05_CHAN_1_DATA_SIZE = 9 LEAD_12_CHAN_1_DATA_SIZE = 6 LEAD_12_CHAN_2_DATA_SIZE = 9 LEAD_12_CHAN_3_DATA_SIZE = 9 TI_ADS1293_CONFIG_REG = 0x00 #/* Main Configurat...
# field_subject on islandora 8 is configured to map to the following vocabs: Corporate, Family, Geographic Location, # Person, Subject class MemberOf: def __init__(self): self.drupal_fieldnames = {'memberof': 'field_member_of'} self.memberof = 'Repository Item' def get_memberof(self): ...
# -*- coding: UTF-8 -*- def read(file): """ Read the content of the file as a list Args: file: the name of the file with the path """ with open(file, 'r') as f: return f.read().split("\n") def write(file, text): """ Save the file into a specific directory Args: file: ...
# Copyright 2016-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. An additional grant # of patent rights can be found in the PATENTS file in the same directory. """ Map of paths to build mo...
a = [1, 2, 3, 4, 5] b = [4, 5, 6, 7, 8] diff = [] for item in a: if item not in b: diff.append(item) for item in b: if item not in a: diff.append(item) print(diff)
# # PySNMP MIB module ZYXEL-CPU-PROTECTION-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ZYXEL-CPU-PROTECTION-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:49:18 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7....
# Функция принимает параметры # A - множество, например, A = [1,2,3,4,5,6,7,8,9,10] # arr - матрица отношения, состоящая из нулей и единиц # Печатает пары отношения # Например, множество A = [3, 5, 7] # arr = [ # [1,0,1] # [0,1,0] # [0,1,1] # ] # Функция напечатает отношение # { (3, 3), (3, 7), (5, 5), (7...
# GENERATED VERSION FILE # TIME: Tue Oct 6 17:46:50 2020 __version__ = "0.3.0+0e6315d" short_version = "0.3.0"
class RequestLog: def __init__(self): self.url = None self.request_headers = None self.request_body = None self.request_method = None self.request_timestamp = None self.status_code = None self.response_headers = None self.response_body = None s...
#is_hot = True #is_cold = False #if is_hot: #print("it's a hot day wear a vest") #elif is_cold: #print("its cold") #else: #print("die"1111111111111) #good_credit = True #price = 1000000 #if good_credit: #print("you need to put down 10%") #print("payment is " + "$" + str(0.1*price)) #else: ...
def media_digitos(n): num = list(map(int,str(n))) return sum(num) / len(num) n = int(input("digite o valor: ")) print(f"a media dos valores e: {media_digitos(n)}")
__title__ = "asent" __version__ = "0.3.0" # the ONLY source of version ID __download_url__ = "https://github.com/kennethenevoldsen/asent" __documentation__ = "https://kennethenevoldsen.github.io/asent"
N = int(input()) T = [int(input()) for _ in range(N)] total = sum(T) ans = 1e10 for i in range(2 ** N): tmp = 0 for j in range(N): if i & (1 << j): tmp += T[j] ans = min(ans, max(tmp, total - tmp)) print(ans)
x=int(input()) y=int(input()) i=int(1) fact=int(1) while i<=x : fact=((fact%y)*(i%y))%y i=i+1 print(fact)
class DLinkedNode(): def __init__(self, key: int = None, value: int = None, prev: 'DLinkedList' = None, next: 'DLinkedList' = None): self.key = key self.value = value self.prev = prev self.next = next class DLinkedList(): def __init__(self): self.head = DLinkedNode() ...
class TokenStream: def __init__(self, tokens): self.tokens = tokens def lookahead(self, index): return self.tokens[index] def peek(self): return self.tokens[0] def advance(self): return self.tokens.pop(0) def defer(self, token): self.tokens.insert(0, toke...
# Definitions for Machine.Status MACHINE_STATUS_BROKEN = 0 MACHINE_STATUS_ALIVE = 1 # The "prebaked" downage categories PREBAKED_DOWNAGE_CATEGORY_TEXTS = [ 'Software Problem', 'Hardware Problem', 'Machine Problem' ] # TODO: remove this and actually query locations after basic demo # x should be within [0-...
#CODE ARENA PLAYER #Problem Link : https://www.hackerearth.com/practice/algorithms/searching/ternary-search/practice-problems/algorithm/small-factorials/ f = [1] * 105 for i in range(2,105): f[i] = f[i-1] * i t = int(input()) while t: t-=1 n = int(input()) print(f[n])
""" Programacion orientad a objetos! - conceptos que lo soportan! 1 - astraccion de datos: proceso mediante el cual somos capaces de escoger la implementacion de un objeto que contenga o modele las propiedades en el problema. 2 - encapsulamiento: ocultar la representacion y el estado de las propiedades de un objeto! s...