#toyprogrammingchallenge
Another Freebie...
This problem was asked by Facebook.
Given the mapping a = 1, b = 2, ... z = 26, and an encoded message, count the number of ways it can be decoded.
For example, the message '111' would give 3, since it could be decoded as 'aaa', 'ka', and 'ak'.
You can assume that the messages are decodable. For example, '001' is not allowed.
lol not efficient if **all** you need is the count, but it does work of course.
@billstclair @Absinthe Time-complexity has nothing to do with raw-speed. If you do the brute force solution and actually list all solutions with a copy approach (the absolute simplest least efficient way) then your dealing with exponential space complexity. Good luck computing large datasets on even the beefiest of machines where a linear solution would attack it with ease.
@billstclair @freemo how does that solve it? Am I missing something?
@billstclair
I don't know about that word "instantly" there but cool solution ;)
@Absinthe
@billstclair @Absinthe @freemo
This solution gives wrong answers in certain cases. E.g. "10" should return one solution, the letter "j', but instead it gives zero. I'm suspicious of the inequalities on line 95 (strictly greater than zero AND strictly less than twenty-six permits the integers 1-25, which looks like a fencepost error given a 26-character alphabet).
Good catch, elm isnt one of the languages i mess with so i didnt run it myself and only got a vague idea of what is going on.
(length (list-solutions)) 😈