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
|
576 Discussions
|
Please Login in order to post a comment
Python solution. Another terrible formulated problem, look at the line:
n = str(sum(int(digit) for digit in n))k
This is not what the problem asks, but works, because when working with big numbers you cannot simply multiply the string, here throws a Memory Error, you need to reduce first, something you wouldn't do if was a normal work, you NEED the exception that was throw to investigate, that is how a developer work, ffs!
Also who knows the math that multiply the sum of digits is the same of sum the multiply of the original number?
Where are those genius?
Finally solved this one in Java.
What was tripping me up was some of the tests use really long strings and my first (few) solution timed out.
My working hack was to test if the input string was longer than an integer. If not run normally, and if so, break the string into integer sized bites...
it passes now but could be rewritten to be shorter likely.
My code is in C# and is performative. It fails 2 hidden test cases with wrong answer which is really frustrating because I cannot see the input. Any idea how to get to see the Inputs?
I can't do it because of optimization problems and I don't know how to further improve the 3-line code. so i give up