Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Simple decision solution in Clear category for Feed Pigeons by Zyzlik
def checkio(portions):
pigeons = 0
new_pigeons = 0
while portions:
new_pigeons += 1
pigeons += new_pigeons
if portions > pigeons: # feed all the pigeons
portions -= pigeons
elif portions < pigeons and portions <= (pigeons - new_pigeons):
# if not enough portions to new pigeons
return (pigeons - new_pigeons)
elif portions < pigeons and portions > (pigeons - new_pigeons):
# if not enough to all pigeons, but enough to couple new
return portions
Aug. 16, 2015