Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Portions, minutes and birds solution in Creative category for Feed Pigeons by Fermax
def checkio(portions):
minute = 0
last_fed = 0
birds = 0
while True:
minute += 1
birds += minute
if portions >= birds:
portions -= birds
last_fed = birds
else:
return max(last_fed, portions)
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio(1) == 1, "1st example"
assert checkio(2) == 1, "2nd example"
assert checkio(5) == 3, "3rd example"
assert checkio(10) == 6, "4th example"
Jan. 11, 2014
Comments: