Programming contests

50 Programming Exercise for Beginners

January 2, 2019, 12:00 AM – December 31, 2019, 12:00 AM

SMS

Write a program that reads English forenames from the standard input until end-of-file (EOF), made up of arbitrary number of English uppercase letters, one forename per line.
The program should write to the standard output which numeric keys are to be pressed in a traditional mobile phone with a numeric keypad, and in what order, if we want to send the strings scanned by the program as SMS messages with as few keypresses as possible. (For example, the name ANDREW can be entered as 2663777339.)

Sample Input

  1. ANDREW
  2. JOHN
  3. ADAM
  4. SARAH
download as text file

Output for Sample Input

  1. 2663777339
  2. 56664466
  3. 2326
  4. 77772777244
download as text file
Acknowledgement This work was supported by the construction EFOP-3.4.3-16-2016-00021. The project was supported by the European Union, co-financed by the European Social Fund.
University of Debrecen; Faculty of Informatics; v. 09/30/2024