Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Solve it in your sleep() solution in Creative category for Funny Addition by macfreek
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
DELAY = 0.10 # 0.20 fails for CheckIO. Apparently the process is paused after some time.
def put_coin_in_basket():
time.sleep(DELAY)
def checkio(data):
"""Given two pouches of coins, return the total number of coins.
Solution: every second we put a coin in a basket. See how long it takes."""
start = time.perf_counter()
pouch = data[0]
while pouch:
pouch -= 1 # take a coin out of the pouch.
put_coin_in_basket()
pouch = data[1]
while pouch:
pouch -= 1 # take a coin out of the pouch.
put_coin_in_basket()
end = time.perf_counter()
print(start,end,(end-start)/DELAY)
return int((end-start)/DELAY)
April 26, 2014
Comments: