daily-coding-problem
daily-coding-problem copied to clipboard
Number 7: 10001 is not valid, and decode_cnt does not handle 0 correctly
10001 is not valid because it cannot be broken into valid 1 or 2 character substrings. The criteria point out that leading zeros are not valid.
Eg, attempting to subdivide 10001: 10 pass 0 fail 10 pass 00 fail 1 pass 0 fail 1 pass 00 fail
An example of a valid message containing zeros is 101011
10 pass 10 pass 11 pass 10 pass 10 pass 1 pass 1 pass
With this input, decode_cnt_no_zero returns 13 and decode_cnt returns 4. The correct value is 2, as the above examples are the only valid ways to break apart the message.
Let me know if you want me to share my solution.