Beruflich Dokumente
Kultur Dokumente
Bob was given the task of ordering from McDonalds for the overnight party. Bob asked Alice for the
delivery number, and Alice politely said 8MCDO. Bob thought Alice was so stupid for giving him letters
instead of numbers. Can you help Bob translate the letters for him?
--------------------| 1
| 2 | 3
|
|
| ABC | DEF |
--------------------| 4
| 5 | 6
|
| GHI | JKL | MNO |
--------------------| 7
| 8 | 9
|
| PQRS | TUV | WXYZ |
---------------------
Write a program that accepts a string of alphabetic letters, possibly with some
digits from 0 to 9. You are ensured that the input contains no whitespace and
that all letters are in uppercase. Output the same string but with the all the
letters replaced by the corresponding digits according to the keypad above. See
sample test cases. Hint: Use s = input('Enter string: ','s');
Input
Output
8MCDO
86236
000000O 0000006
SHAKEYS 7425397
UP000
87000
X
100
400
400
100
Y
Z
P
Output
200 210 2200
52
500 1000 500
3
500 1000 1000
6
200 300
50
0
R
3
5
4
Y T
M
2 1 25
3 1 41
3 10 360
The Diner is located at (0, 0) in the local map. Because there are three
destinations, located at (A, B), (C, D), and (E, F), Finn has the freedom to
choose the order of his visits. In one whole trip, he starts from the Diner,
and then visits the three destinations one by one in any order, and finally
returns to the Diner. Given A, B, C, D, E, and F, in km, can you help Finn
determine the minimum travel distance of one whole trip?
Make a program that accepts 6 integers, A, B, C, D, E and F, whose absolute values are less than 100.
Output the minimum travel distance (in km) of one whole trip, accurate to 4 decimal places. You are
ensured that no 2 destinations are the same, and no destination is at (0, 0). To illustrate the answer for
the first sample test case, the figure above can help you. See other sample test cases.