Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Feed Pigeons by Gabbek
def n_pigeons_food(total):
food = 0
pigeons = 0
arriving_pigeons = 1
while True:
pigeons += arriving_pigeons
food += pigeons
arriving_pigeons += 1
if food + pigeons > total:
return pigeons, food
def checkio(food_available):
pigeons, food_used = n_pigeons_food(food_available)
if food_used > food_available:
return pigeons - (food_used - food_available)
return pigeons
Oct. 3, 2015