"US Telephone Keypads"
Given the following information about a US telephone touchtone keypad:
1: N/A 2: A,B,C 3: D,E,F
4: G,H,I 5: J,K,L 6: M,N,O
7: P,R,S 8: T,U,V 9: W,X,Y
calculate the product of each characters value.
As an example, say the user enters: "Practice", the product would be:
7 * 7 * 2 * 2 * 8 * 4 * 2 * 3 = 37,632
What is the value of this string: "Programming Challenges are fun"?
A tip for this challenge, is make sure you have the letter to numbers correct, double check every letter!
Awnser:
P - 7 - 7
R - 7 - 49
O - 6 - 294
G - 4 - 1,176
R - 7 - 8,232
A - 2 - 16,464
M - 6 - 98,784
M - 6 - 592,704
I - 4 - 2,370,816
N - 6 - 14,224,896
G - 4 - 56,899,584
C - 2 - 113,799,168
H - 4 - 455,196,672
A - 2 - 910,393,344
L - 5 - 4,551,966,720
L - 5 - 22,759,833,600
E - 3 - 68,279,500,800
N - 6 - 409,677,004,800
G - 4 - 1,638,708,019,200
E - 3 - 4,916,124,057,600
S - 7 - 34,412,868,403,200
A - 2 - 68,825,736,806,400
R - 7 - 481,780,157,644,800
E - 3 - 1,445,340,472,934,400
F - 3 - 4,336,021,418,803,200
U - 8 - 34,688,171,350,425,600
N - 6 - 208,129,028,102,553,600
= 208129028102553600
R - 7 - 49
O - 6 - 294
G - 4 - 1,176
R - 7 - 8,232
A - 2 - 16,464
M - 6 - 98,784
M - 6 - 592,704
I - 4 - 2,370,816
N - 6 - 14,224,896
G - 4 - 56,899,584
C - 2 - 113,799,168
H - 4 - 455,196,672
A - 2 - 910,393,344
L - 5 - 4,551,966,720
L - 5 - 22,759,833,600
E - 3 - 68,279,500,800
N - 6 - 409,677,004,800
G - 4 - 1,638,708,019,200
E - 3 - 4,916,124,057,600
S - 7 - 34,412,868,403,200
A - 2 - 68,825,736,806,400
R - 7 - 481,780,157,644,800
E - 3 - 1,445,340,472,934,400
F - 3 - 4,336,021,418,803,200
U - 8 - 34,688,171,350,425,600
N - 6 - 208,129,028,102,553,600
= 208129028102553600
Source:
function solution(){
$result = 1;
$word = "Programming Challenges are fun";
$letter2 = array(
"A"=>2,"B"=>2,"C"=>2,
"D"=>3,"E"=>3,"F"=>3,
"G"=>4,"H"=>4,"I"=>4,
"J"=>5,"K"=>5,"L"=>5,
"M"=>6,"N"=>6,"O"=>6,
"P"=>7,"R"=>7,"S"=>7,
"T"=>8,"U"=>8,"V"=>8,
"W"=>9,"X"=>9,"Y"=>9
);
$array = str_split(strtoupper(str_replace(" ", "", $word)));
foreach( $array as $char){
$result *= $letter2[$char];
echo $char." - ".$letter2[$char]." - ".number_format($result)."<br />";
}
echo "<br /><strong> = ".number_format($result, 0, '.', '')."</strong>";
}