import sys
def optimal_summands(n):
summands = []
sum = n
i = 0
while (sum > 0):
if 2*(i+1) < sum:
i+=1
summands.append(i)
sum-=i
else:
summands.append(sum)
sum=0
return summands
if __name__ == '__main__':
input = sys.stdin.read()
n = int(input)
summands = optimal_summands(n)
print(len(summands))
for x in summands:
print(x, end=' ')
I am having an issue running this with my own input. I go to my terminal and type
(ykp) y9@Y9Acer:~/practice$ python optimal_summands.py 15
and nothing happens.
How am I supposed to run my own code on custom inputs? This seems like something that should be simple but I have not seen an example of how to do this anywhere in the documentation.