Showing posts with label UVA Python solutions. Show all posts
Showing posts with label UVA Python solutions. Show all posts

30 January 2018

UVA 10170 - The Hotel with Infinite Rooms Python Solution

from sys import stdin
scan = lambda : stdin.readline()

while True:
    n,k = map(int, scan().split())
    k = k
    sum = 0
    while True:
        sum += n
        if(sum >= k):
            print(n)
            break
        n += 1
   
   

20 December 2017

Example of decorator in pyhon

from time import time

def timer(any_function):
    def count_time():
        start = time()
        any_function()
        stop = time()
        print("%.15f"%(stop-start),'seconds')
        return    return count_time

@timerdef hello():
    print("Hello World")
    return
@timerdef another_function():
    for item in [1,2,3,4,5,6,7,8,9]:
        print("%d "%item,end='')
    print()
    return
hello()
another_function()

UVA 10679 - I Love Strings!!