java.lang.Object MultiTapTextEntry
public class MultiTapTextEntry
From Google code jam 2010 qualification round, South Africa. The release tests for this example are the small and large practice inputs from the code jam.
Even before phones with keyboards and touch screens, you could send text on mobile phones. One of the methods used was multi-tap text entry.
The 2 key is labeled with abc; the 3 key with def; each key 2-9 is labeled with 3 letters, except 7 which is labeled pqrs and 9 which is labeled wxyz.
To insert the character E for instance, the program would press 33 (the digit 3 since e appears on the 3 key; twice since it is the second letter listed for 3). In order to insert two characters in sequence from the same key, the user must pause before pressing the key a second time. The space character ' ' should be printed to indicate a pause. For example, 2 2 indicates AA whereas 22 indicates B.
Each message will consist of only lowercase characters a-z and space characters ' '. Pressing zero emits a space.
Note that the Google code jam problem incorrectly describes this as T9 text entry.
Method Summary | |
---|---|
static java.lang.String |
getMultitapSpelling(java.lang.String txt)
Return the multi-tap encoding of a message. |
static void |
main(java.lang.String[] args)
Read input and write output using the format described in the Google code jam problem. |
Method Detail |
---|
public static java.lang.String getMultitapSpelling(java.lang.String txt)
public static void main(java.lang.String[] args) throws java.lang.Exception
Case #n: outputwhere n is the test case number (starting at 1) and the output is the result of encoding that test case. If a file is provided on the command line, read that, otherwise read from standard input. Output is written to standard output.
java.lang.Exception