Micro Challenge #15 – Creating (& breaking) a code

8 May 2020 - 3 minute read

Welcome to the Fifteenth of Altitude Foundation’s #MicroChallenges2020 

Today’s challenge is inspired by VE day!

What’s a Micro Challenge?

These challenges are short activities to help you develop, revise or refresh your coding skills, posted every Monday, Wednesday and Friday.

Micro Challenge #15

In honour of the VE Day Bank Holiday, today’s challenge is about coding codes. 

One of the oldest known codes we have is the Caesar Cipher. This works by shifting the letters in the alphabet by an agreed amount of numbers, so for example, at shift 1:

Hello!

 becomes:

Ifmmp!

At shift 2, the same word becomes:

Jgnnq!

We can show this as:

Shift 2

ABCDEFGHIJKLMNOPQRSTUVWXYZ
YZABCDEFGHIJKLMNOPQRSTUVWX
Alphabet (top)
Cipher (bottom)

However, we wouldn’t want to send the cipher with the code! So instead, we will need a programme to decode it (this will also speed up decoding longer messages).

The Challenge:

Can you design a programme which can be used to decode the Caesar cipher? You will need to include:

  • The dataset (the alphabet) and its original positioning
  • A way of inputting the relevant shift number
  • A way of inputting the code
  • A clear instruction on how to translate the code
  • An output for the revealed message

Hint: you will also need to use a search to find the correct letters at each stage.

(If you want to explore this further, there’s a good guide here)

Review it:

Could you programme it so it works both ways? (You can read about how to do this here if you’re stuck.)

If you send a cipher to a friend, could they use your programme to decode it?

Advanced:

Could you make up your own code and programme for decoding it?

If you want to explore decoding further, check out these Code Breaking Challenges.

Share it

We would love to see what you have created! Please send any pictures, videos, or files of your activities to us – either via Facebook, Twitter or Instagram  using #MicroChallenges2020 or to challenges@altitudefoundation.org. If you are emailing them to us, please let us know if you are happy for us to share your stuff on our social media platforms (with credit, of course). 

Sign-up here to receive a weekly email with Micro Challenges top tips and solutions:



Leave a comment

Leave a Reply