r/shittyprogramming • u/CVh655FDBcZ1l • Apr 10 '19
One Line of Code™
https://gist.github.com/WorryingWonton/ce8a3a74b0298f0b734fe4dd0a883a63
101
Upvotes
r/shittyprogramming • u/CVh655FDBcZ1l • Apr 10 '19
View all comments
Show parent comment
1
u/overactor Apr 12 '19 edited Apr 12 '19
My solution was also wrong, it doesn't handle [13, 13, 1] correctly
I wrote this on my phone and didn't try it out, but that should be correct and tail call optimised. (Does python do TCO?)
edit: I just looked it up and found out that python does not do TCO, at which point I transform my recursion into a reduce and end up with the solution OP had.