Introduction
One day, you were just relaxing in your office in the CIA, when suddenly you see an alert on your computer. Your programs have just intercepted hundreds of coded messages! A quick examination reveals the rule for encoding, but you need a program in order to decode fast.
Challenge
You will be given a list of strings, separated by commas. Each string will contain either:
- Part of the coded message
- It is part of the coded message if it is not in the form
a=b
. Note that it is part of the message if it isab=c
. Add this string to the coded message.
- It is part of the coded message if it is not in the form
- Part of the encoding scheme
- This will be in the form of
a=b
. That means that all a's in the message must be replaced by b's. Note that it could bea==
, meaning that all a`s must be replaced with ='s.
- This will be in the form of
Your program must then output the message, decoded using the scheme found.
Other info:
Your input will only contain commas for separating the strings. It could contain other characters, like !1#, etc. It will not contain uppercase letters. Bits of decoding info do not decode each other. Only the message is affected by the decoding information. Only one replacement will be given for each character, e.g. no "io,"i=u","i=g"
Examples
Input:"ta","y=s","y","a=e","b=t","b"," ","j","j=1"
Output:test 1
Input:"z=p","zota","g=e","yugkb","y=t","u=o","k=s","li","fg","b=="
Output:potatoes=life
Input:"p","=","==n","ot","p=a","hiz","i=e","z=r"
Output:another
This is code-golf, so shortest answer in bytes wins!
"massega","e=a","a=e"
and the like? \$\endgroup\$ – Jonathan Allan Apr 5 '17 at 21:28"io,"i=u","i=g"
\$\endgroup\$ – Luke Borowy Apr 5 '17 at 21:32