content
stringlengths
7
1.05M
DEFAULT_BRANCH = "unstable" GITREPOS = {} GITREPOS["builders_extra"] = [ "https://github.com/threefoldtech/jumpscaleX_builders", "%s" % DEFAULT_BRANCH, "JumpscaleBuildersExtra", "{DIR_BASE}/lib/jumpscale/JumpscaleBuildersExtra", ] GITREPOS["installer"] = [ "https://github.com/threefoldtech/jumpsca...
#!/usr/bin/env python script_version = "0.21" processed_comp_list = [] spdx_lics = [] # The name of a custom attribute which should override the default package supplier SBOM_CUSTOM_SUPPLIER_NAME = "PackageSupplier" usage_dict = { "SOURCE_CODE": "CONTAINS", "STATICALLY_LINKED": "STATIC_LINK", "DYNAMICALL...
gos_file = open('GOS.csv') gos_lines = gos_file.readlines() gos_file.close() gos_map = {} for l in gos_lines[1:]: sl = l.split(',') gos_map[int(sl[0])] = int(sl[1]) observe_file = open('rf_observ - Copy.csv') obs_lines = observe_file.readlines() observe_file.close() obs_tot_map = {} obs_rea_map = {} obs_pre_map ...
class Solution: def maxNumberOfBalloons(self, text: str) -> int: b = text.count('b') a = text.count('a') l = int(text.count('l') / 2) o = int(text.count('o') / 2) n = text.count('n') f = [b, a, l, o, n] return min(f) class Solution: def maxNumberOfB...
#!/usr/bin/env python files = [ "oiio-logo-no-alpha.png", "oiio-logo-with-alpha.png" ] for f in files: command += rw_command (OIIO_TESTSUITE_IMAGEDIR, f)
# Enter your code here. Read input from STDIN. Print output to STDOUT # Take 2 input sets A and B input() A = set(map(int, input().split())) input() B = set(map(int, input().split())) # Print union by set.union print(len(A.union(B)))
#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @Author: 思文伟 @Date: 2022/03/23 16:09:22 ''' class DictToObject(object): def __init__(self, py_dict): """ """ if not isinstance(py_dict, dict): raise ValueError("Data Type Must Be dict") for field in py_dict: ...
# -*- coding: utf-8 -*- def main(): n, w = map(int, input().split()) ws = [0 for _ in range(n)] vs = [0 for _ in range(n)] inf = 10 ** 12 dp = [[inf for _ in range(((n + 1) * 10 ** 3) + 1)] for _ in range(n + 1)] for i in range(n): wi, vi = map(int, input().split()) ...
OCTICON_DIFF_REMOVED = """ <svg class="octicon octicon-diff-removed" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M2.75 2.5h10.5a.25.25 0 01.25.25v10.5a.25.25 0 01-.25.25H2.75a.25.25 0 01-.25-.25V2.75a.25.25 0 01.25-.25zM13.25 1H2.75A1.75 1.75 0 001 2.75v10...
# int : 정수 자료형 num01 = 10 # 양수 : 변수 num01에 10 저장 num02 = -10 # 음수 : 변수 num02에 -10 저장 print(num01) # num01 변수 값 표시 10 print(num02) # num02 변수 값 표시 -10 # float : 실수 자료형 float01 = 10.25 # 양수 : float01에 10.25 저장 float02 = -10.25 # 음수 : float01에 -10.25 저장 float03 = 2e1 # 양수 float03에 2 의 10의...
# The isBadVersion API is already defined for you. # @param version, an integer # @return a bool # def isBadVersion(version): class Solution: def firstBadVersion(self, n): """ :type n: int :rtype: int """ left, right = 1, n while left <= right: mid = left...
class DayOfAGossipingBusDriver(object): def __init__(self, drivers, gossip_universe): self.drivers = drivers self.gossip_universe = gossip_universe def one_minute_passed(self): self.share_gossips_between_all_drivers() self.all_drivers_drive() def share_gossips_between_all_d...
class ModelError(Exception): """ Errors about Models """ pass
# Example which shows using ANSI color codes to print color to the terminal # window. def color(this_color, string): return "\033[" + this_color + "m" + string + "\033[0m" for i in range(30, 38): c = str(i) print('This is %s' % color(c, 'color ' + c)) c = '1;' + str(i) print('This is %s' % color(...
class Solution: def convert(self, s: str, numRows: int) -> str: if (numRows == 1): return s result = "" s_len = s.__len__()#给定字符串的长度 num = numRows * 2 - 2#一个循环的长度 for row in range(numRows):#以行数建立循环,行数为给定的 col=0 while row + col < s_len: ...
# @Author : guopeiming # @Contact : guopeiming2016@{qq, gmail, 163}.com oovKey = '<unk>' oovId = 0 padKey = '<pad>' padId = 1 BOS = '<BOS>' EOS = '<EOS>' APP = 0 SEG = 1 actionPadId = 2 bertAttr = 'bert' embeddings_layer_keyword = 'embeddings' EPSILON = 1e-10 MAX_OOV_NUM = 1500
class BaseTestCSVUpload(object): def test_generate_username_from_email(self): reader = [['', 'cleartext$password', 'rohith@openwisp.com', 'Rohith', 'ASRK']] batch = self.radius_batch_model.objects.create() batch.add(reader) self.assertEqual(self.radius_batch_model.objects.all().count...
a3, a2, a1 = int(input()), int(input()), int(input()) b3, b2, b1 = int(input()), int(input()), int(input()) a_total = a3 * 3 + a2 * 2 + a1 b_total = b3 * 3 + b2 * 2 + b1 if a_total > b_total: print("A") elif a_total == b_total: print("T") else: print("B")
""" 1598. Crawler Log Folder Easy The Leetcode file system keeps a log each time some user performs a change folder operation. The operations are described below: "../" : Move to the parent folder of the current folder. (If you are already in the main folder, remain in the same folder). "./" : Remain in the same fol...
def indval(x): return '@' + str(x) def immval(x): return '#' + str(x)
class FeatureExtractor(object): def __init__(self, files): self.files = files def retrieve_coords(self): return self._retrieve_coords() def retrieve_dihedrals(self): return self._retrieve_dihedrals()
class Imaging(object): """ Provides managed to unmanaged interoperation support for creating image objects. """ @staticmethod def CreateBitmapSourceFromHBitmap(bitmap,palette,sourceRect,sizeOptions): """ CreateBitmapSourceFromHBitmap(bitmap: IntPtr,palette: IntPtr,sourceRect: Int32Rect,sizeOptions: BitmapSi...
# quicksort algorithms for linked list class ListNode: def __init__(self, val, next=None): self.val = val self.next = next def __repr__(self): rv = str(self.val) if self.next: rv = rv + ' -> ' + repr(self.next) return rv def qsort(start, end=None): if...
class Solution: def romanToInt(self, s: str) -> int: d = {'I':1, 'V':5, 'X':10,'L':50,'C':100, 'D':500,'M':1000, 'IV':4, 'IX':9, 'XL':40, 'XC':90,'CD':400, 'CM':900} i, res = 0, 0 while i < len(s): twoDig = s[i:i+2] oneDig = s[i...
""" 面试题8:二叉树的下一个节点 题目:给定一棵二叉树和其中的一个节点,如何找出中序遍历序列的下一个节点?树中的节点除了 有两个分别指向左、右节点的指针,还有一个指向父节点的指针。 例: a |b c| |d e| |f g| |h i| 中序遍历为{d, b, h, e, i, a, f, c, g} 输入b输出h,输入i输出a """ class TreeNode(object): def __init__(self, x): self.val = x ...
description = 'Installs the Triple Axis Calculations into ZEBRA ' requires = ['monochromator', 'sample'] excludes = ['zebraeuler', 'zebranb'] sysconfig = dict(instrument = 'ZEBRA',) devices = dict( ZEBRA = device('nicos_sinq.sxtal.instrument.TASSXTal', description = 'instrument object', instrume...
class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ res = 0 if x >= 0: flag = True else: flag = False x = -x while x is not 0: res = (res * 10) + x % 10 x = x/10 ...
cont=0 soma=0 numero=int(input("Digite um numero: ")) while cont <=10: soma = soma + cont*2 cont = cont +1 print (soma)
# ------------------------------ print('задание множеств:') A = {1, 2, 3} A = set('qwerty') print(A) # выводится не по порядку print('равные множества:') A = {1, 2, 3} B = {3, 2, 3, 1} print(A == B) # ------------------------------ print('перебор элементов множества:') primes = {2, 3, 5, 7, 11} for num in primes: ...
a = input('please input a number: ') b = input('please input a second number: ') ax = a bx = b a = bx b = ax print(a) print(b)
a = [2, 3, 4, 7] b = a b = a[:] # => comando para receber uma cópia da a em b b[2] = 8 # trocando o número 2 por 8 print(a) print(b) print(f'Lista A: {a}') print(f'Lista B: {b}')
def ex7(): running = True while running: try: user_input = int(input("Enter an integer: ")) if user_input < 2 or str(user_input) == 0: print("Invalid input") if user_input == 1: print(f"Btw the integer {user_input} is no...
# -*- coding: utf-8 -*- """ __init__.py Created on 2017-11-19 by hbldh <henrik.blidh@nedomkull.com> """
class Column: def __init__(self, key, label, auto=False): self.key = key self.label = label self.auto = auto def get_json(self): return {"key": self.key, "label": self.label} def render(self, val): return val if val else "" class AggrColumn(Column): def __init...
class Solution(object): def XXX(self, root): """ :type root: TreeNode :rtype: int """ if not root: return 0 max_depth=0 ret=[] def dfs(root,max_depth): if root: max_depth+=1 if not root.left and n...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- d = { 'Michael': 95, 'Bob': 75, 'Tracy': 85, '95':95, 90:90, 'stanford':100 } print('d[\'Michael\'] =', d['Michael']) print('d[\'Bob\'] =', d['Bob']) print('d[\'Tracy\'] =', d['Tracy']) print('d[\'95\'] =',d['95']) print('d[90] =',d[90]) print('d[s...
""" Ex 07 -Develop a program that reads two grade of a student, calculate and shows it the mean """ print('Student average') print('-' * 30) n1 = float(input("Student's first grade: ")) n2 = float(input("Student's second grade: ")) m = (n1 + n2) / 2 print(f"The student's average is: {m}") input('Enter to exit')
def check_range_and_int(val, name, low=0, high=127): """Checks a parameter to match Loihi Calls two methods to check if the parameter value is integer and in a range between low and high. Parameters ---------- val : int The value of the parameter name : str The name of the ...
#!/usr/bin/env python """ __init__ Tests for creating daemons. """
"""Given the head of a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the nodes in each of the two partitions. Example 1: Input: head = [1,4,3,2,5,2], x = 3 Output: [1,2,2,4,3,5] Example 2: Input:...
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """TODO: Add v_r for pinch velocity""" def calc_vr_pinch(): vr_pinch = 0 # TODO: Add the equation for vr_pinch return vr_pinch
class Solution: def get_balls(self, arr): def dfs(i, j, r, c): if(i == r): return j curr = arr[i][j] if(curr == 1 and (j+1 == c or arr[i][j+1] == -1)): return -1 elif(curr == -1) and (j-1<0 or arr[i][j-1] == 1): ...
pkgname = "libxrandr" pkgver = "1.5.2" pkgrel = 0 build_style = "gnu_configure" configure_args = ["--enable-malloc0returnsnull"] hostmakedepends = ["pkgconf"] makedepends = ["xorgproto", "libxext-devel", "libxrender-devel"] pkgdesc = "X RandR Library from X.org" maintainer = "q66 <q66@chimera-linux.org>" license = "MIT...
class AbstractStemmer: pass class PorterStemmer(AbstractStemmer): """ A Stemmer class tutorial from: https://medium.com/analytics-vidhya/building-a-stemmer-492e9a128e84 """ consonants = "bcdfghjklmnpqrstwxz" special_case = "y" vowels = "aeiou" def _divide_into_groups(self, word): ...
def consumer(): # 有yield的函数就是生成器,没的跑 r = 'what the fuck?' print(r) # 😄发送None时,函数从头开始执行的,到 yield r 停止,此后的send(xxx)都是从 n = yield 开始。记住,n = yield 是启动点, yield r 暂停点,并返回yield r结果给produce函数 while True: # 注意,yield r 是代码终止点,n = yield是启动点, # 一个正常的循环♻过程是从 n = yield开始执行,到下面,执行到r ='200k'后,...
def funcao(*num, sit=False): """ ->Programa que recebe N notas em lista e faz um tratamento das N notas! O elif poderia ser >5, mas quero treinar esse metodo :param num: Recebe N notas (aceita +) :param sit: Recebe um valor BOOL (infelizmente só sei fzer receber com ou sem str) :return: retorna ...
class Solution: def numSimilarGroups(self, A): def explore(s): visited.add(s) for v in edges[s]: if v not in visited: explore(v) res, edges, visited = 0, {}, set() if len(A) >= 2 * len(A[0]): strs = set(A) for s in A: ...
class Restaurant(): def __init__(self,name,type): self.restaurant_name = name self.cuisine_type = type def describe_restaurant(self): print("Nombre: ", self.restaurant_name) print("Tipo de cocina: ", self.cuisine_type) def open_restaurant(self): print("That ...
N, Q = map(int,input().split()) A = [0] + list(map(int,input().split())) # print(N, Q) # print(A) # print("----") for i in range(Q): t, x, y = map(int,input().split()) if t == 1: A[x] = A[x] ^ y if t == 2: xor_list = A[x:-1] + [y] for j in range(len(xor_list)-1): res = ...
""" RENDER """ render_camera = 'cam1' render_lights = '' """ MATERIAL """ mat = 'constant1' mat_color = '' """ INSTANCES """ inst_state = 0
#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @Time : 2021/02/07 13:00:31 @Author : Ren Qiang @Contact : renqiang06@126.com ''' # Start # 求1+3+...+99 print('1+3+...+99 = ', sum(range(1,100,2))) print('1+3+...+99 = ' + str(sum(range(1,100,2)))) def DNA_strand_1(dna): for i in dna: i.replace...
def validate_x(w: int, x: int, r: int) -> bool: if r <= x <= w - r: return True return False def validate_y(h: int, y: int, r: int) -> bool: if r <= y <= h - r: return True return False def resolve(): w, h, x, y, r = map(int, input().split()) if validate_x(w, x, r) and valid...
def swap_bits(num, i, j): if (num>>i & 1) != (num>>j & 1): num ^= ((1<<i) | (1<<j)) return num num = 129 for x in range(num, num+10): print(bin(x), bin(swap_bits(x, 1, 2)))
# -*- coding: utf-8 -*- INPUT_PATH = "../data/data_reduced.json" OUTPUT_PATH = "../data/recommendations.json" NUM_RECS = 5
#!/bin/python3 """ Task: Write a program that asks the user for their name and greets them with their name. """ nameBuffer=input("State your name: ") print(f"Greetings {nameBuffer}")
# Done by Carlos Amaral (2020/09/19) taxi_ride_info = ["da7a62fce04", 180, 1.1, True] print("The data type for the taxi_ride_info variable is: ", type(taxi_ride_info)) print("The data type for the first element of taxi_ride_info is: ", type(taxi_ride_info[0])) print("The data type for the second element of taxi_rid...
class Solution: def sumNumbers(self, root ): self.result = 0 self.preOrder(root,0) return self.result def preOrder(self,root,tmp): if not root: return if not root.left and not root.right: # sum here self.result += tmp*10 + root.val ...
problemDescription = ''' *problemDescription* \n This problem was asked by Square. You are given a histogram consisting of rectangles of different heights. These heights are represented in an input list, such that [1, 3, 2, 5] corresponds to the following diagram: x x x x x x x x x x x Determine ...
# -*- coding: utf-8 -*- # Copyright 2019 Carsten Blank # # 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 la...
class Solution: def tribonacci(self, n: int) -> int: if n == 0 or n == 1: return n t0, t1, t2 = 0, 1, 1 for i in range(n - 2): t2, t1, t0 = t2 + t1 + t0, t2, t1 return t2
# -*- coding: utf-8 -*- """ Supply Generic Supply functionality such as catalogs and items that are used across multiple applications """ module = request.controller resourcename = request.function if not (deployment_settings.has_module("inv") or deployment_settings.has_module("asset")): raise HTTP(404,...
# -*- coding: utf-8 -*- ''' This module is obsolete. ''' PLUGS = [ ("caps", "http://nsap.intra.cea.fr/caps-doc/"), ("qmri", "https://bioproj.extra.cea.fr/redmine/projects/qmri/publishing/"), ("funtk", "https://bioproj.extra.cea.fr/redmine/projects/funtk/publishing/"), ("pclinfmri", "") ]
''' Finding all maximal cliques of size "n" Now that you've explored triangles (and open triangles), let's move on to the concept of maximal cliques. Maximal cliques are cliques that cannot be extended by adding an adjacent edge, and are a useful property of the graph when finding communities. NetworkX provides a func...
#!/usr/bin/env python3 def enb(): print("enb command line comming soon")
''' @jacksontenorio8 Faça um programa que leia nome e peso de várias pessoas, guardando tudo em uma lista. No final, mostre: A)Quantas pessoas foram cadastradas. B)Uma listagem com as pessoas mais pesadas C)Uma listagem com as pessoas mais leves. ''' lista1 = [] lista2 = [] maior = menor = 0 while True: lista1.appe...
#Given a string in which the letter h occurs at least two times, # reverse the sequence of characters enclosed between the first and last appearances. s = input() i1 = s.find('h') print(s.find('h')) i2 = s.rfind('h') print(s.rfind('h')) sh = s[i1:(i2+1)] new_s = s[:i1] + sh[::-1] + s[(i2+1):] print(new_s)
#!/usr/bin/env python # BST class Node: def __init__(self, data): self.left = None self.right = None self.data = data def insert(self, data): if self.data: if data < self.data: if self.left is None: self.left = Node(data) ...
URL = "url" IOTA = "iota" DOC = "document" URL_TYPES = [URL, IOTA, DOC]
# unexpected indent #a = 1 # + 2 # + 3 # invalid syntax #a = 1 + # 2 + # 3 a = 1 + \ 2 + \ 3 print(a)
botname = "имя бота" bot_codename = "v2" botsite = "https://catware.space/" bugreport_url = "https://vk.com/catweird" systemname = "ABMSv2" systemname_acronym = "Advanced Bot Manipulation System v2" developer = "Catware" source_link = "https://github.com/Catware-Foundation" distribution_like = "abmsv2"
class DeltaCalculator: def __init__(self): self._values = {} def delta(self, key, value): last = self._values.get(key) self._values[key] = value if last is None: return None return value - last
""" Creating the first queue. Not working right now, need to fix... """ SIZE = 5 REAR = -1 FRONT = -1 VALUES = [] def enQueue(value): global FRONT global REAR if REAR == SIZE - 1: print('Our Queue is full. \n') else: if FRONT: FRONT = 0 REAR += 1 value = VAL...
# __init__.py """ Hi there! """
def save_user(backend, user, response, *args, **kwargs) -> None: if user and not user.is_staff: user.is_staff = True user.save()
# -*- coding: utf-8 -*- # __author__ = xiaobao # __date__ = 2019/11/26 23:06:13 # desc: desc # 一些恶魔抓住了公主(P)并将她关在了地下城的右下角。地下城是由 M x N 个房间组成的二维网格。我们英勇的骑士(K)最初被安置在左上角的房间里,他必须穿过地下城并通过对抗恶魔来拯救公主。 # 骑士的初始健康点数为一个正整数。如果他的健康点数在某一时刻降至 0 或以下,他会立即死亡。 # 有些房间由恶魔守卫,因此骑士在进入这些房间时会失去健康点数(若房间里的值为负整数,则表示骑士将损失健康点数);其他房间要么是空的(房间里的值为 0),...
def snake_case_key(key: str) -> str: assert isinstance(key, str) new_key = key[0] for char in key[1:]: if char.isupper(): new_key += "_{char}".format(char=char.lower()) elif char == "-": new_key += "__" else: new_key += char return new_key
#!/usr/bin/env python3 if __name__ == '__main__': width = 1001 cur = 1 cur_w = 3 ans = 1 while cur_w <= width: ans += 4 * cur + 10 * (cur_w - 1) cur += 4 * (cur_w - 1) cur_w += 2 print(ans)
""" LINK: https://leetcode.com/problems/3sum-closest/ Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. Example 1: Input: nums = [-1,2,1,-4]...
BROKER_URL = 'redis://localhost:6379/0' CELERY_RESULT_BACKEND = 'redis://localhost:6379/0' CELERY_IMPORTS = ("octavious.parallelizer.celery", ) CELERY_TASK_RESULT_EXPIRES = 300
def quick_sort(lst): aux_quick_sort(lst, 0, len(lst) - 1) return lst def aux_quick_sort(lst, start, end): if start >= end: return pivot_pos = partition(lst, start, end) aux_quick_sort(lst, start, pivot_pos - 1) aux_quick_sort(lst, pivot_pos + 1, end) def partition(lst, start, end): ...
settings = { "WIDTH": 200, "HEIGHT": 66, "CHANNELS": 3, "BALANCE_MODE": 'RESAMPLE', "DEFAULT_TRAIN_FILE_DIRECTORY": 'D:/train_data/raw/', "DEFAULT_TRAIN_FILE": 'D:/train_data/raw/training_data_{}.npy', "DEFAULT_TRAIN_FILE_PROCESSED_DIRECTORY": 'D:/train_data/processed/', "DEFAULT_TRAIN_F...
# Agent Template. # # Copy this agent.py in your model dir (e.g. models/mymodel/agent.py) # and implement predict(state) method to start class Agent(): def __init__(self, **kwargs): # initialize anything you need. # e.g. load pre-trained model pass def predict(self, state): # ...
# -*- coding: utf-8 -*- # @Author: Zengjq # @Date: 2019-02-20 17:07:27 # @Last Modified by: Zengjq # @Last Modified time: 2019-03-06 00:14:23 # leetcode 有更好的解法但是太难想了 class Solution: # 28% mem 5% def countBits(self, num: int): res = [] for x in range(num + 1): counter = 0 ...
# The famous Hello, world! problem written in python. # Author: Adrian Sypos # Date: 21/09/2017 print("Hello, world!")
regions = [ "0 - Global", "1 - KR", "2 - BR", "3 - EUNE", "4 - EUW", "5 - JP", "6 - NA", "7 - OCE", "8 - LAN", "9 - LAS", "10 - TR", "11 - RU", ] lanes = [ "0 - Main", "1 - Top", "2 - Jungle", "3 - Middle", "4 - Bottom", "5 - Support", ] tiers = ...
def myPow(self,x,n): if n<0: x=1/x n=-n pow=1 while n: if n&1: pow*=x x*=x n>>=1 return pow def myPow2(self,x,n): if not n: return 1 if n<0: return 1/self.myPow2(x,-n) if n%2: return x*self.myPow2(...
def is_palindrome(string): # base case: the string is less than 1 character if len(string) <= 1: return True if string[0] == string[-1]: return is_palindrome(string[1:-1]) return False """ print(f"kayak : {is_palindrome("kayak")}") print(f"empty string : {is_palindrome(""...
# # PySNMP MIB module COLUBRIS-VIRTUAL-AP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/COLUBRIS-VIRTUAL-AP-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:25:40 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 ...
def can_build(env, platform): return env["tools"] def configure(env): pass def get_doc_path(): return "doc_classes" def get_doc_classes(): return [ "VGColor", "VGGradient", "VGLinearGradient", "VGMeshRenderer", "VGPaint", "VGPath", "VGRadialG...
def can_partition(num): s = sum(num) if s % 2 != 0: # if 's' is a an odd number, we can't have two subsets with same total return False s = int(s / 2) # we are trying to find a subset of given numbers that has a total sum of 's/2'. n = len(num) dp = [[False for x in range(s + 1)] for y in...
text = input("Enter text: ") count = 0 for char in text: if char == "a": count +=1 if char == "e": count += 2 if char == "i": count += 3 if char == "o": count += 4 if char == "u": count += 5 print(count)
''' Author : MiKueen Level : Easy Problem Statement : Happy Number Write an algorithm to determine if a number n is "happy". A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the num...
""" Dummy tests """ def test_pass(): """Test nothing at all (well, "pass" anyway).""" pass def test_true(): """Test True.""" assert True
# Maximum Subarray: https://leetcode.com/problems/maximum-subarray/ # Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. # A subarray is a contiguous part of an array. # This problem is actually kind of like a dynamic programming pr...
# Se quiser uma contagem de 6: 0 a 6 ou 1 a 7 ou 2 a 8, pois conta do 0 ao 5 e no 6 para for c in range(1, 7): print(c) print('FIM') print('-=-'*10) # -1 serve para contar ao contrário for c in range(6, 0, -1): print(c) print('FIM') print('-=-'*10) # O terceiro valor resulta é o salto ou manipulação do laço f...
x = float(input()) if x <= 400.00: s = x * 1.15 r = s - x p = 15 if 400.01 <= x <= 800.00: s = x * 1.12 r = s - x p = 12 if 800.01 <= x <= 1200.00: s = x * 1.10 r = s - x p = 10 if 1200.01 <= x <= 2000.00: s = x * 1.07 r = s - x p = 7 if x > 2000.00: s = x * 1.04 ...
for k in range(int(input())): D1 = input() D2, D3, D4, D5 = tuple(input().split()) D6 = input() probs = 0 if D1 == '*' and D6 == '*': probs += 1 if D2 == '*' and D4 == '*': probs += 1 if D3 == '*' and D5 == '*': probs += 1 print(48 if probs == 3 else 8 if probs == 2 else 2 if probs ==...
patches = [ # Remove attribute property EventIntegrationAssociation and Metadata { "op": "remove", "path": "/PropertyTypes/AWS::AppIntegrations::EventIntegration.EventIntegrationAssociation", }, { "op": "remove", "path": "/PropertyTypes/AWS::AppIntegrations::EventIntegrat...
""" Tema: Resolviendo reto. Curso: Python intermedio. Plataforma: Platzi. Profesor: Facundo García Martoni. Alumno: @edinsonrequena. """ def divisor(num): divisor_list = [] for i in range(1, num + 1): if num % i == 0: divisor_list.append(i) return divisor_list def main(): ...
class TwoPointers(object): def removeElement(self, nums, val): """ :type nums: List[int] :type val: int :rtype: int """ #initialize count count = 0 #loop in range of length of list nums for i in range(len(nums)): #if element at inde...