Difference between revisions of "Top Secret"

From CompSciWiki
Jump to: navigation, search
m (Fixed photo)
(Fixed some formatting and a typo in problem statement)
Line 1: Line 1:
 
{{1010PrAD|ProblemName=Top Secret
 
{{1010PrAD|ProblemName=Top Secret
  
|Problem= You are a software developer for CSIS (Canadian Security Inteligence Service) and you've been sent a secret message, but all of the software at your station has been deleted! However, this message is very important and must be decoded right away. That's where you come in. You will write a program that decodes the message, verifies the authenticity, then prints out the mission directive.
+
|Problem= You are a software developer for CSIS (Canadian Security Inteligence Service) and you've been sent a secret message, but all of the software at your station has been deleted! However, this message is very important and must be decoded right away. That's where you come in. You will write a program that decodes the message, verifies the authenticity, then prints out the mission directive.
  
First, the message is in a secret code. Every character is represented by a different character. The following arrays show the relationshipThe first one is our alphabet, the second is the secret one.
+
First, the message is in a secret code. Every character is represented by a different character. The following arrays show the relationship. The first one is our alphabet, the second is the secret one.
  
char [] array1 = {'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','.','!',' '};<br />
+
char [] array1 = {'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','.','!',' '};<br>
 
char [] array2 = {'l','x','g','r','j','w','!','i','q','a','t','z','.','s','y','k','e','o',' ','p','d','c','h','n','v','u','f','b','m'};
 
char [] array2 = {'l','x','g','r','j','w','!','i','q','a','t','z','.','s','y','k','e','o',' ','p','d','c','h','n','v','u','f','b','m'};
  
<br \><br \>
+
<br><br>
  
 
Once you've decoded the message, you'll have to verify it.  Every other character, starting with the first character, if put together, will form a palindrome.  You must write two methods: one that will form the palindrome out of the message, the other method to make sure that it is indeed a palindrome.
 
Once you've decoded the message, you'll have to verify it.  Every other character, starting with the first character, if put together, will form a palindrome.  You must write two methods: one that will form the palindrome out of the message, the other method to make sure that it is indeed a palindrome.
  
 
Once you've verified that, there is one last check.  The message must start with the phrase "top secret".  If not, it's a fake!  After you've determined that the message is the real deal, you have to print out just the mission instruction.  (Use substring to print out the message after the "top secret" part)
 
Once you've verified that, there is one last check.  The message must start with the phrase "top secret".  If not, it's a fake!  After you've determined that the message is the real deal, you have to print out just the mission instruction.  (Use substring to print out the message after the "top secret" part)
<br \><br \>
+
<br><br>
 
+
  
  

Revision as of 14:33, 9 April 2010

Back to the Program-A-Day homepage

Problem

You are a software developer for CSIS (Canadian Security Inteligence Service) and you've been sent a secret message, but all of the software at your station has been deleted! However, this message is very important and must be decoded right away. That's where you come in. You will write a program that decodes the message, verifies the authenticity, then prints out the mission directive.

First, the message is in a secret code. Every character is represented by a different character. The following arrays show the relationship. The first one is our alphabet, the second is the secret one.

char [] array1 = {'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','.','!',' '};
char [] array2 = {'l','x','g','r','j','w','!','i','q','a','t','z','.','s','y','k','e','o',' ','p','d','c','h','n','v','u','f','b','m'};



Once you've decoded the message, you'll have to verify it. Every other character, starting with the first character, if put together, will form a palindrome. You must write two methods: one that will form the palindrome out of the message, the other method to make sure that it is indeed a palindrome.

Once you've verified that, there is one last check. The message must start with the phrase "top secret". If not, it's a fake! After you've determined that the message is the real deal, you have to print out just the mission instruction. (Use substring to print out the message after the "top secret" part)

 

Problem Solving and Programming Examples

Wiki bench01.jpg

Solution



Code

Solution Code

Back to the Program-A-Day homepage