Coding Conundrums Evolved 1: Alien Encounter
(Banner generated with
LC_ALL=C tr -c "[:lower:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"
, adapted from here)
This post is part of a new biweekly series of programming problems, targeted at those learning to program using C# at University. The problems will vary in difficulty - some will be rather easy, and some will be quite challenging! Don't worry if you can't solve a problem just yet - come back to it in a few months and it'll seem a lot easier than it did before.
The year is 2258. Humans have established themselves as spacefarers and have made contact with several alien species. You are a member of the esteemed Captain Obanji's crew aboard the spaceship iveinya, on a mission to explore the galaxy! While out exploring, you and your crew discover a new species of intelligent life! You decide to call them the Outer Clockwise Eyamporreans (simply because it sounds cool).
Chief of Communications Officer Bramaar has been analysing the Eyamporreans' language. He has discovered that it is based on the english alphabet (abcdefghijklmnopqrstuvwxyz
) managed to work out that he can use a simple substitution cipher to translate the Eyamporreans' language into English. He has also worked out what each letter in their language corresponds to in english:
a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
i | u | c | r | a | v | j | w | m | d | q | o | n | b | f | p | l | y | e | t | s | k | z | g | x | h |
(abcdefghijklmnopqrstuvwxyz
/ iucravjwmdqonbfplyetskzgxh
)
Unfortunately, he has been having a spot of bother whilst writing an automatic translator for the language. This is where you come in. Given a single line of Eyamporrean through the standard input, translate it into English and output the result. See if you can translate the following alien communications back into english:
jyaatmbje, etyibja cyaitsyae!
za zfsor omqa tf zaocfna xfs tf fsy poibat.
rf xfs wika ibx yfcqat vsao? fsy epicacyvt me ysbbmbj fst.
Helpful Hints
- The input will only contain the lowercase letters of the alphabet, spaces, and possibly punctuation such as
!
and?
. - You should pass any characters such as whitespace and punctuation that your program doesn't understand straight through your translator.
- It never hurts to do a quick
.ToLower()
call on all the input your program receives, just in case.
Challenge
Officer Bramaar and Captain Obanji are impressed with your work. Using your translator, they have been able to understand the Eyamporreans' messages and ascertain their intentions. Now, they would like to send a message back.
Alter your program so that you can not only translate Eyamporrean messages into english, but also translate English into Eyamporrean.
See if you can translate these messages into Eyamporrean:
hello eyamporreans! we come in peace.
we represent the planet earth.
do you require assistance?
The solution to this puzzle can be found here. The password to the archive will be released along with next week's challenge.
Update: The next post has been released! Find it here: Binary Biomass