## WC '95 P1 - Coded Message

View as PDF

Points: 7
Time limit: 1.0s
Memory limit: 16M

Problem type
##### Woburn Challenge 1995

You have just found the secret instructions on how to encode a message:

"Calculate the message length and round up to the nearest multiple of 5. Write out the message in rows of 5 characters each until the message is complete. Send the message a column at a time from left to right."

For example, suppose the message is THIS IS A CODED MESSAGE.
It is 23 characters long so two spaces are added at the end to make it 25 characters long. The rows of 5 characters are:

1 2 3 4 5

T H I S
I S   A
C O D E D
M E S S
A G E

The characters are sent one column at a time from left to right (a period indicates a space):

TIC.AHSOMGI.DEESAES...DS

#### Input Specification

The input will consist of 5 commands to encode/decode a message.
The first line of each command is a character to indicate what your program should do: D means decode, E means encode.
The second line of each command will contain the text to encode/decode.

#### Output Specification

The decoded/encoded message for each test case.

#### Sample Input

(note that spaces, not periods will appear in the input/output)

D
TIC.AHSOMGI.DEESAES...DS
E
MEET.ME.IN.THE.PARK.TONIGHT.AT.SEVEN

(and 3 more commands)

#### Sample Output

THIS.IS.A.CODED.MESSAGE..
MM.PTH.NEETAOTS.E.HRN.E.TIEKIAV..N..GTE.