Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Infinit cycle with itertools.count solution in Clear category for Feed Pigeons by kudinov.feodor
from itertools import count
def checkio(number):
fed_pigeons = 0
for new_pigeons in count(start=1):
if number > fed_pigeons + new_pigeons:
fed_pigeons += new_pigeons
number -= fed_pigeons
else:
return fed_pigeons if fed_pigeons > number else number
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"
Oct. 11, 2019