Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
While Portions Remain solution in Clear category for Feed Pigeons by John.Hammell
def checkio(portions_remaining):
pigeons_eating = 0
new_pigeons_eating = 0
# Each loop is a minute of pigeons eating.
while portions_remaining:
portions_remaining -= pigeons_eating # Pigeons already eating eat first.
if portions_remaining < 1:
return pigeons_eating
new_pigeons_eating += 1
if portions_remaining <= new_pigeons_eating:
pigeons_eating += portions_remaining
return pigeons_eating
else:
portions_remaining -= new_pigeons_eating
pigeons_eating += new_pigeons_eating
Oct. 4, 2015
Comments: