Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Feed Pigeons by Kurush
def checkio(number):
step = 0
current_amount_pigeons = 0
while True:
full_pigeons = current_amount_pigeons
step += 1
current_amount_pigeons += step
number -= current_amount_pigeons
if number < 0:
hungry_pigeons = abs(number)
if hungry_pigeons > step:
return full_pigeons
else:
return full_pigeons + (step - hungry_pigeons)
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert checkio(1) == 1, "1st example"
assert checkio(2) == 1, "2nd example"
assert checkio(5) == 3, "3rd example"
assert checkio(10) == 6, "4th example"
June 11, 2014
Comments: