Alphabetic Phone Number Generator [Problem of the Week]
Mmm, not quite problem of the “week” since it has been a while since I last posted a problem – I had a busy few weeks, my apologies!
Anyway, let’s move to the problem – another Microsoft interview problem. Sure you’ve all seen how phone pads hold three letters of the alphabet for every number you can press (except for 1 and 0). Check the photo below to know what I mean …

The problem is simple. The input is a distinct, seven-digit number. The required output is all seven-character strings that could be generated from this number. For the sake of the problem, assume we have a different phone-pad layout as follows:
0: a, b, c
1: d, e, f
2: g, h, i
3: j, k, l
4: m, n, o
5: p, q, r
6: s, t, u
7: v, w, x
8: y, z, A
9: B, C, D
So, for a three-digit number [012], these are all possible combinations of strings generated from such number according to the above dictionary:
[ 012 ] adg adh adi aeg aeh aei afg afh afi bdg bdh bdi beg beh bei bfg bfh bfi cdg cdh cdi ceg ceh cei cfg cfh cfi
Results will be treated the ACM way this time – results comparison. No code submissions. I want the results for the number:
0267451
I want the full output: All generated strings …
Don’t post that HERE in the comments!
Post only the number of strings generated, then paste the strings anywhere and send me the link or email them .. Only if the number of strings is correct, I will check the results!

RSS - Posts
There’s a trick .. I’m warning .. so read properly this time!!!
AlaaShaker
October 3, 2008 at 4:51 am
Using the multiplication rule (Probability Theory):
3 * 3 * 3 * 3 * 3 * 3 * 3 = ( 3 ^ 7 ) = 2187 combinations.
A tree would make a hell of a good job to illustrate the idea, now if you are interested in the output just lemme know :p
Metal_
October 3, 2008 at 6:32 am
To Metal_:
loooool
You’re so right about the count. I guess it’s obvious I do want the output – sure a tree will do, and I won’t feel any sorry for you mate
AlaaShaker
October 3, 2008 at 12:42 pm
2187
http://www.4shared.com/file/65491300/e9d65d0e/words.html
TeCNoYoTTa
October 3, 2008 at 1:26 pm
FIRST WINNER: TeCNoYoTTa .. Congrats!
AlaaShaker
October 3, 2008 at 1:39 pm
loool.. I was asked the same question too
.. seems they don’t change their questions in the interviews !!!
Roaa
October 3, 2008 at 2:58 pm
http://rafb.net/p/hTWRFd42.html
I was kidding about the output for sure :] It’s was only 6 AM, woke up to get something to drink, check up on things and get back to bed…
About the tree, it’s for illustrating the idea with a simple input, like 3-digit number, not for solving your 7-digit number input.
Metal_
October 3, 2008 at 5:22 pm
SECOND WINNER: Metal_ .. 3 more to go ..
AlaaShaker
October 3, 2008 at 10:58 pm
awalan : alf alf alf mabrook , ana 3erft enk 5atbt
3obal ely a3rfhom
balash ana , rabena yewfa2ak isa we dayman fe progress keda ,, ya rafe3 rasna
:D
sry for the upper output mss , tecno told me that i have to upload the output file
here it is :
http://www.2shared.com/file/4054546/13e1a1c9/mohamed_hesham.html
Mohamed Hesham
October 7, 2008 at 9:20 pm
THIRD WINNER: Mohamed Hesham ..
Thanks, man. Allah yebarek feeek .. w 3o2balak enta kaman
To Roaa: yeah, tell me about that! lol
AlaaShaker
October 9, 2008 at 1:58 am
number of strings: 2187
see them here:
http://rafb.net/p/GofUnt52.html
Tasniem Seliem
October 9, 2008 at 2:16 pm
FOURTH WINNER: Tasniem Seliem .. Good Job (Y)
AlaaShaker
October 9, 2008 at 2:19 pm
URL: http://rafb.net/p/kSc4ol46.html
2187 strings
Amal Hussein
October 10, 2008 at 9:16 pm
number of strings generated is 2187
5olio
October 11, 2008 at 12:46 am
[...] the past problem was of medium difficulty, but there’s a trick that could make your life much easier. Do you [...]
Alphabetic Phone Number Generator SOLVED [Problem of the Week] « AlaaShaker’s Weblog
October 18, 2008 at 6:09 am