Cipher Counts
mediumAn old field cipher maps letters to numbers: A=1, B=2, … Z=26. Messages were sent as bare digit strings with no separators — so "12" could be AB (1, 2) or L (12).
Given the digit string msg, return how many distinct letter sequences it could decode to. A chunk with a leading zero (like "06") is never valid.
Example 1
in msg = "12"
out 2
AB or L.
Example 2
in msg = "226"
out 3
BZ (2,26), VF (22,6), BBF (2,2,6).
Example 3
in msg = "06"
out 0
No letter maps to 0, and 06 has a leading zero.
Constraints
- · 1 <= len(msg) <= 100
- · msg contains only digits
solution.py● loading python…
test results
Hit ▶ Run to test your code against the visible cases.