Canadian Computing Competition: 2007 Stage 1, Junior #2
Text messaging using a cell phone is popular among teenagers. The messages can appear peculiar because short forms and symbols are used to abbreviate messages and hence reduce typing.
For example, LOL
means "laughing out loud" and :-)
is called an emoticon which looks like a happy face (on its side) and it indicates chuckling. This is all quite a mystery to some adults.
Write a program that will continually input a short form and output the translation for an adult using the following translation table:
Short Form | Translation |
---|---|
CU |
see you |
:-) |
I'm happy |
:-( |
I'm unhappy |
;-) |
wink |
:-P |
stick out my tongue |
(~.~) |
sleepy |
TA |
totally awesome |
CCC |
Canadian Computing Competition |
CUZ |
because |
TY |
thank-you |
YW |
you're welcome |
TTYL |
talk to you later |
Input Specification
The user will enter text to be translated one line at a time. When the short form TTYL
is entered, the program ends. Users may enter text that is found in the translation table, or they may enter other words. All entered text will be symbols or uppercase letters. There will be no spaces and no quotation marks.
Output Specification
The program will output text immediately after each line of input. If the input is one of the phrases in the translation table, the output will be the translation; if the input does not appear in the table, the output will be the original word. The translation of the last short form entered TTYL
should be output.
Sample Input
CCC
:-)
SQL
TTYL
Sample Output
Canadian Computing Competition
I'm happy
SQL
talk to you later
CCC problem statements in large part from the PEG OJ
Comments
Since the original data were weak (and malformed), the data were updated, and all submissions were rejudged.
Please, help!
I checked for typos, I inputted all possible keys within the dictionary, and strings not within the dictionary, and all seems fine. But when I submit, I get a WA error. Seems like my "CCC" is rendering "Canadian Computing Competitio", with no "n" in the end, if that is the error.
Anyone has any idea?
TY!
You made a typo on line 7, it should be "awesome" instead of "awsome".
Join the DMOJ Discord to receive help.
This comment is hidden due to too much negative feedback. Show it anyway.
Reread the input specification.
Here are the translations for each TXTMSG, in Python dictionary:
(Triple-click to select all)
txt_diction = {'CU': 'see you', ':-)': "I'm happy", ':-(': "I'm unhappy", ';-)': 'wink', ':-p': 'stick out my tongue', '(~.~)': 'sleepy', 'TA': 'totally awesome', 'CCC': 'Canadian Computing Competition', 'CUZ': 'because', 'TY': 'thank-you', "YW": "you're welcome", 'TTYL': 'talk to you later'}
How would I make the code now that the user has typed "TTYL"?
Your program has to keep getting the user's input until they enter "TTYL" at which point you need to stop getting input. Keep in mind, TTYL is a part of what you need to be translating, so make sure to include it when you're translating the words. Hope that helps.
How many inputs are we supposed to get?
Your program should keep receiving input until the input is
TTYL
, which after your program should terminate.I always get a No such element Error, and I don't know why!
My code works on Netbeans but consistently gets errors here! I don't understand what's going on. :'(
This comment is hidden due to too much negative feedback. Show it anyway.
Why does mine give the same error?
Calling
scanner
inside your while loop.thanks