Recursion Revisited

This time, the problem was a little different. Phone keys have certain letters written on them as shown below:

Telephone Keypad

We were to write a function that takes up to four digits of a phone number and return a list of all possible combinations that can be written.

Example:

Armed with the following “help”:

I tackled the problem with recursion and came up with the following:

This is just a simple iteration on my initial post of Counting Leaves and shows how easy recursion can be once you get the hang of it!

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">