Preparing for the final CD
Writing code to crack the "code"

Introduction

Many of you have done really well this semester. I wanted to have some fun this last week as we thought about the final competency demo. Thus, this completely optional programming activity is a way for you to apply some different things you have learned and see if you can crack a secret code to view the "Super Duper Top Secret Study Guide" for the final competency demo.

 

The Plot

Person A: Psst!

Person B:  You talking to me?

Person A:  Yeah!  Did you hear?

Person B:  Hear what?

Person A:  The good news!  I went into the lab yesterday and found out that Dr. Schafer forgot to log out of the computer in the front of the room.  I found the following file stored on it:

Person B :  SWEET!  Let's open it.

secretcode

Person A : What the heck is that?

Person B : Oh, man, Schafer outsmarted us AGAIN.  It looks like he has encoded it with some secret code.  Was there anything else on the computer?

Person A : Actually, yeah, there were these two files...

Person B : Well, let's see what hints says:

After letters - skip their pennymath value
After numbers - skip their number
After anything else - skip 8
Person A : That's not very helpful.

Person B : Well, maybe it is.  Let's check out hello world

Person B : Wait, a minute, I think I have an idea!

Person A : You do?

Person B : Sure.  Notice that the first character of helloworld.txt just HAPPENS to be an H?

Person A : Yeah...

Person B : I wonder if the file actually translates to SAY "Hello World"

Person A : It might, but there is a lot more text there than just "Hello World"

Person B : Yeah, but notice that the hints file said that "After letters - skip their pennymath value"  What was the pennymath value of H again?

Person A : E.. F.. G... H.  That's the 8th letter of the alphabet.

Person B : Alright, let's skip 8 letters:

Person A : Wait a minute.  After you skipped 8 letters the NEXT letter is an e.  The next letter in Hello World.

Person B : And e is the 5th letter of the alphabet so let's skip the five letters after that...

Person A : SWEET.  The L is the next letter after that.  Can this really be that easy?

Person B : It just might be.  I bet I can write some code to figure it out.

Person A : Oh, I gotta try this too.

 

The Challenge

Write a method called

decode(inputfile,outputfile). 

decode() should take two parameters - both of which are strings.  The first should be the name of an encoded file (either helloworld.txt or superDuperTopSecretStudyGuide.txt).  The second should be the name of a file that you will use as an output file.  For example:

    decode("superDuperTopSecretStudyGuide.txt" , "translatedguide.txt")

 

Your method should read in the contents of the inputfile and, using the scheme described above, decode the hidden message, writing to the outputfile as it goes (or all at once when it is done depending on what you decide to use).

 

Don't Worry

This problem is more than I would ask you to do on the final CD. It is just a chance for you to stretch your brain a little bit. If you can't get it (or simply don't want to take the time to try) you can download the decoded study guide and/or my solution below so that EVERYONE has access to the complete study guide.