+ 21
🌟🌟CHALLENGE: SUM OF SUB-NUMBERS🏆🌟🌟
(level : easy) Find the number whose sum of its sub-numbers gives the initial (input) number. The sub-numbers of result number are obtained as follows: 1. first sub-number is equal to the first digit of result number, 2. second sub-number = on previous sub-number we add the following digit. 3. and so on to the end of all digits. For example: Input: 5684 Output: 5117 Proof: 5 + 51 + 511 + 5117 = 5684 Note: if it is impossible to find the result, output is like: Impossible! Any language is welcome!
11 Answers
+ 3
Here is mine
https://code.sololearn.com/cFh0z1Z3f8ZV/?ref=app
+ 20
This is my solution for example :
https://code.sololearn.com/WdqXuUUX81Xq/?ref=app
+ 8
This is my answer in Java:
To see an impossible case, enter 232.
Another impossible case is 999995!
To see an interesting case enter 1234567.
My code also works for 0 or 1-digit numbers!
https://code.sololearn.com/cH9Ftw1hHRYo
+ 5
heres mine...
py one-liner..
https://code.sololearn.com/cIZAFF4P6x2c/?ref=app
+ 4
I'm having fun. :D
https://code.sololearn.com/cXaMOTpZbUXr/?ref=app
+ 3
not yet ready, but there are some rules:
output<input
but not more than 999 + 99 +9
+ 3
This seems to be right.
https://code.sololearn.com/cldY1Wzl75XQ/#java
+ 3
My solution works like this: a 'TestNumber' method sums the sub-numbers separately from zero until that sum is greater than the initial number in which case it returns false, otherwise it means that a solution was found and returns true. See it pls. ☺😊😀😁
https://code.sololearn.com/cROBDWzK3Agw/?ref=app
+ 1
Functional one liner https://code.sololearn.com/cmLjvTOqjtve/?ref=app