Suppose that we are trying to crack a substitution cipher (https://en.wikipedia.org/wiki/Substitution cipher), and that we have some partial information that should help us be able to decode the encoded text. Write a C++ program that operates as described below.

Your program should accept three command line arguments. Argument 1 and 2 are filenames and argument 3 is a string containing a word.

The first file will contain exactly two lines that represent a way to encode text. The first line will be a subset of the letters A-Z, and the corresponding characters on the second line will represent the encoding. For example, in the file shown below, the code letter for an A would be a P and the code for an E would be an X. This means that in an encoded piece of text, the letter X would represent an E in the original text. Note that because we only have partial information not all of the letters A...Z will necessarily appear on the first line.

ABCDEF...
PLMAXY...

The second file will be an encoded text. Only the letters a...z and A...Z will be encoded. All other whitespace or punctuation will be unchanged.

Since not all of the letters appear in file 1, there may be a letter in the encoded text that you do not know how to decode. This is where the third argument is used. The third argument will be a word that is known to appear in the source text.

Your job is to try assigning corresponding letters to the parts of the cipher that are unknown until the word in the third argument appears in the decoded text.

Sample input:

file1:

ABCFGHIJKLMNPORSTUVWXYZ
PDFZATMEBYOCSWINVXLJRUQ

file2:

VTK GHA EXOSKG HLKI VTK ZKCFK

commandline:

./pl file1 file2 DOG

output:

THE DOG JUMPED OVER THE FENCE
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.