Some little programming puzzle I found. Apparently Facebook asked this sometime. A message containing letters from A-Z is being encoded to numbers using the following mapping: a -> 1, b -> 2, ... etc. How many decodings of some given number. Takes an input of numeral characters.
✓ Published0🌍 Public
BBBischof
Last edited Dec 6, 2013
Created on Dec 6, 2013
This example demonstrates a recursive solution to the classic Facebook interview puzzle of counting possible letter-to-number decodings for a given numeral string. It shows how the algorithm branches by treating each string as either a single digit or a two-digit pair, with base cases for lengths zero, one, and two. The code relies on Python’s `sys.argv` to read input from the command line and uses custom helper functions `howMany` and `isValid` to handle recursion and validate two-digit codes against the 1–26 mapping. The rendering approach is purely console-based, printing the final count directly.
AI-generated description