Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Uncategorized category for Feed Pigeons by marcin85
# migrated from python 2.7
def checkio(food):
it = 0
a=0
pigeons = {}
while food>0:
it+=1
a=a+it
for i in range(a):
if not i+1 in pigeons:
pigeons[i+1] = 0
print(i)
for pigeon in pigeons:
if food > 0:
food -= 1
pigeons[pigeon]+=1
return sum(1 for x in list(pigeons.values()) if x != 0)
#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"
March 28, 2014
Comments: