elements=["1-kiwi","2-pear","3-kiwi","4-banana","5-melon","6-banana","7-melon","8-pineapple","9-apple","10-pineapple","...","100-pineapple"]defsubstractSum(n):if10<=n<=10000:sum_n=0fordigitinstr(n):sum_n+=int(digit)result=n-sum_nwhileresult>100:fordigitinstr(n):sum_n+=int(digit)result=n-sum_nprint(n,result,elements[result-1])else:print("{}: Use value between 10 and 10000".format(n))substractSum(9)substractSum(10)substractSum(31)substractSum(110)substractSum(111)substractSum(325)substractSum(1204)substractSum(1316)substractSum(2888)substractSum(10000)substractSum(10001)
Output of the above:
❯ python 260.py
9: Use value between 10 and 10000
10 9 9-apple
31 27 27-apple
110 100 100-pineapple
111 99 99-apple
325 95 95-melon
1204 98 98-pineapple
1316 95 95-melon
2888 80 80-cucumber
10000 100 100-pineapple
10001: Use value between 10 and 10000
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Some python-that-can-be-improved:
Output of the above: