Created
September 18, 2015 06:56
-
-
Save baweaver/c9f3f7191a514b14a645 to your computer and use it in GitHub Desktop.
The pad mapper problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Given an input string of 0 or more digits '2' - '9', list out all the possible strings | |
# from a typical phonepad digit-to-letter conversion (below), one per line | |
# | |
# 2: ABC 3: DEF 4: GHI 5: JKL 6: MNO 7: PQRS 8: TUV 9: WXYZ | |
LETTERS = [%w(A B C), %w(D E F), %w(G H I), %w(J K L), %w(M N O), %w(P Q R S), %w(T U V), %w(W X Y Z)] | |
def pad_mapper(*numbers) | |
# Fill me out! | |
end | |
describe '#pad_mapper' do | |
context 'When given two digits with three letter keys' do | |
it 'returns nine results as letter pairs' do | |
expect(pad_mapper(2,3)).to eq(%w( | |
AD AE AF | |
BD BE BF | |
CD CE CF | |
)) | |
end | |
end | |
context 'When given two digits with one three letter and one four letter key' do | |
it 'returns twelve results' do | |
expect(pad_mapper(3,7)).to eq(%w( | |
DP EP FP | |
DQ EQ FQ | |
DR ER FR | |
DS ES FS | |
)) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment