We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Recursive Digit Sum
- Discussions
Recursive Digit Sum
Recursive Digit Sum
Sort by
recency
|
595 Discussions
|
Please Login in order to post a comment
Python solution:
Python 3 solution
Initially I tried expanding the string n by k multiple:
This lead to runtime error in 4 hidden cases.
Instead, summing all digits in n then multiplying by k solves the runtime issue.
Modern solution using java 8 streams:
Agree with others that the description isn't very clear in regards to what k is used for. Had to work it out from the failed test cases.
go is unfortunately pretty badly supported here.
My code produces a Runtime Error just for test cases 7,8,9, while the exact same code produces correct output on my machine (for case 7:the expected 7).
It's also suspicious that a Runtime Error happens only for a certain case...usually it's a real problem or not. :(( hackerrank these are things wanting to move me away to other platforms.