This question is inspired by retrograde music. Retrograde music is a piece of music that can both be played normally (from the beginning to the end) as reversed (from the end the beginning). A similar thing exists in literature, this is called a semi-palindrome, e.g. "roma" and "amor". Your task is to write a retrograde program. If executed normally it has to encode a string with the morse code, decode it when executed reversed.
You're to write a program or function that accepts a string and outputs it's morse code encoding (STDIN and STDOUT are used in case of a program, a function receives it's input as a function argument and returns a string). However, when you run the reverse of the program, it works the same except it decodes the input. Note that you don't have to use the same programming language. The reversing of the program is done manually.
- Comments are not allowed in your program, as they would make this task very easy.
- You have to use the international morse code. This includes letters, numbers and some punctuation. See the link for a complete list. No prosigns or special characters have to be supported. There's one exception mentioned in the edit.
- You have to represent dots and dashes with
- Letters are separated with
(spaces), words are separated with
- You can choose to use either use lower or uppercase. However, you have to be consistent (if your program only uses uppercase, the reversed program must do so too).
- You can assume the program will only receive valid input.
Input of the normal program or output of the reversed program:
Output of the normal program or input of the reversed program:
-- --- .-. ... . / -.-. --- -.. . ..--..
Because I want to reward both clever (short) algorithms and creativity, Your score will be based upon your votes and the program length. Concretely, it will be
100 * amount of votes / program length (in bytes)
EDIT: The morse code site I mentioned uses the same code for opening and closing parentheses, however it's not my intention to let you implement a feature for recognizing this. So you have to use these more modern morse codes for the parentheses:
( = -.--. ) = -.--.-