SCC - Seminole Community CollegeGo to your search results
AdmissionsDegrees and ProgramsCampus LifeContact UsFrequently Asked QuestionsMySCCQuick LinksFuture Students Navigational Options Ciphers Programming Problem

Ciphers Computer Programming Problem


Problem Description

In this problem, each letter of the alphabet corresponds to a number using the scheme: a=1, b=2, c=3, ... y=25, z=26. To encode a message, an encryption key word is "added" to the message. The key word is the first word in the message that is five or more characters long. For example, if the message were:

give me liberty or give me death

the key word would be liberty. The encrypted message would be:

s r x j e y k u k g w l s n d p k a w g d p n c y z

The first letter, s, results from adding 7 for the letter g to 12 for the letter l. This results in 19 which is the letter s. The other letters are calculated in a like manner. The algorithm you develop should wrap around to the beginning of the alphabet if the sum of two letters exceeds 26. For example, when the letter l (12) is added to y (25) the sum is 37. There is no 37th letter in the alphabet. Therefore you should use 37 - 26 or 11 which is the letter k.

The key word is repeated indefinitely to the end of the message. For example:

give me liberty or give me death

libe rt ylibert yl iber ty liber

--------------------------------

srxj ey kukgwls nd pkaw gd pncyz (Spaces are left between the words in this example for clarity. Do not include spaces in your results. )

Every message will have at least one five letter word.

Spaces are not encrypted and not included in the output. Only messages in lowercase letters will be entered. No punctuation or special characters will be entered.

Input/Ouput

When encrypting, the input will consist of a sentence or phrase entered via the standard input device. The output must be the key and the encrypted message. Only lower case letters will be entered soit is not necessary to edit the input.

A text file will be provided with the sentences and phrases displayed below. You can copy and paste these for testing purposes to save time. These do not constitute the complete set of testing data the judges will use.

Your application can be created to process a single set of data. That is, after processing a set of data, your application can end. You can then start the application again and enter a second set of data. If you use a graphical interface (Visual Basic, C#, ...) you can enter the data in text boxes and display the results in text boxes or labels. However, a graphical interface is not required for this application.

Sample Input/Output

Input Phrase Keyword Encrypted Output
a stitch in time saves ninestitcht m c c w k a c w n l u x m j p h a g c w y
it is a rainy day rainya u r g z j b r b x v b h
it only hurts when i laugh hurtsq o g h e g c m l m a r z y g q g s o z p
jack and jill went to the hills hillsr j o w t v m v u e t f q z m b x f t x p r x x l
Want more information?

Melinda White
Program Manager
Phone: 407.708.2447
Fax: 407.708.2322
Office: V102-I
whitemc@scc-fl.edu

Get Admissions Info
or call 407.708.2050

Did you know?

SCC offers a Computer Programming Technical certificate, allowing students to increase their skills and knowledge in just one year.