You are hereProgramming Problems / 2011 Programming Problems

# 2011 Programming Problems

By - Posted on 17 April 2012

## Remainder

You have two words and must remove all letters from the first word that are contained in the second. For example, if you are given the words "computer program", remove letters from the first word, "computer" if they occur in the second, "program", leaving the letters "cute".

Example:

```Enter two words : computer program
Remainder : cute```

## Encryption

A secret code reorders the letters in a message using an array. E.g. the following message "Attack at noon or we are done for" is placed in a 6*6 array :

```Attack
*at*no
on*or*
we*are
*done*
for...```

Blank letters are replaced by asterisks, and full stops are added to the message so that it fills out the array. The coded message can then be read down the columns, i.e.

`A*ow*ftanedott**ora*oan.cnrre.ko*e*.`

Write a program that will encrypt a message as above. Use an array with 6 columns, and adjust the number of rows depending on the message length.

Example:

```Enter a message : Attack at noon or we are done for
The encrypted message is : A*ow*ftanedott**ora*oan.cnrre.ko*e*.```

See if you can also decode the message that has been encrypted using the above rules.

## Maze of numbers

Given the following number rectangle:

```10 14  9 15  4
6  13 20  1 10
21 10 30 11  3
13 12 10  9  7
16  9 13 41 12```

A path is formed by starting somewhere on the first column of numbers, e.g. the 6 and moving on column to the right for each step, and going either up, down or staying at the same level. The path finishes when it reaches the rightmost column. An example path is shown by the red numbers below. You should right a program to find the path whose constituent numbers when added together form the smallest number.

```10 14  9 15  4
6  13 20  1 10
21 10 30 11  3
13 12 10  9  7
16  9 13 41 12```

This is a tricky problem, so you can see the solution to a related problem here: problem and solution