I learned a lot about various languages last time I did one of these, so I figured I'd submit another. Community Wiki of course...
All programming languages are acceptable. The goal is to create the program in a language with the least amount of characters. New lines and indenting should be left in for clarity, but not counted. Try to just have 1 submission per language. Edit the existing one if you can make it shorter.
Write a program which takes 2 command line arguments as defined below:
Arg1: a string to be "encoded"
EncodeMeArg2: a pipe separated list of comma separated characters representing an encoding map to apply to the first argument. Example:
e,f|M,N|c,d|n,m|E,F|o,p|d,eThe program shall apply the character mapping specified in arg 2 to the characters of arg1, and display the output (map e to f, M to N, etc). The program above would output:
FmdpefNf (not FodpefNf as originally posted)
Additional Info:
- If a character in arg 1 is missing from the mapping in arg 2, that particular character should merely be skipped.
- Assume that no invalid input will ever be given (lack of separator, too many separators, etc), so no additional error checking or handling is needed