I think there is actually a test case where it has whitespace in the end and it works without .trim()
It's too complicated for the beginners you know but pretty smart
That's a clever one, I didn't think of slicing the string.
Fixed, can you try again?
Yeah i missed a conversion, sorry for that.
It's up to you to write code that stays within the limits of the language you choose.
Some languages eliminate the current call frame when you do tail recursion (no further actions after the call returns), making it a jump to the top just like a loop. You can do this yourself in other languages as well through trampolining. Sometimes you can also write it so that you get log(n) call depth and log2(1000000) is about 20 so plenty of room if you do that. Probably not worth it though, easier to use a loop. A tail recursive function directly translates to a loop (set the new state then jump to the top)
I wrote the function recursively, and it passed all the tests apart from 1. This is the error the feedback gave:
RecursionError: maximum recursion depth exceeded in comparison
Is recursion in general discouraged if we are using large inputs? Would a for cycle be a better alternative in this case?
ok, thx now i see :). Maybe add some more info...
Reverse numbers go as 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 101, 111, 121,..., 717,727, 737,..., 909
100th is 909
i dont get, how from n = 100 you get 909?
(expected 212212 to equal '224212.12')
I failed only 1 random test and get this info.
My result is 212212.
Why does it expect to return a decimal?
You're asked to implement a greedy algorithm. Whether it's optimal or not is irrelevant here.