#274 · Recursion and backtracking · Intermediate · 60 XP · about 12 min
On an old phone keypad each digit from 2 to 9 stands for a few letters:
A string of digits can therefore spell many letter strings, with one letter for each digit, in the same order. Write keypad_words(digits) that returns every letter string the digits can spell, as a list sorted alphabetically. If digits is empty, return an empty list.
keypad_words("26") # returns ['am', 'an', 'ao', 'bm', 'bn', 'bo', 'cm', 'cn', 'co'] keypad_words("9") # returns ['w', 'x', 'y', 'z'] keypad_words("") # returns []
0 <= len(digits) <= 8digits contains only the characters 2 to 9.First solves only, ranked by stars and then time.