OCR Coding Challenges - Solutions

As a background task, I've started work on possible solutions to the OCR Coding Challenges. Remember that my solution is just one of a number of possible solutions, and I don't claim that it's necessarily the best one.  If you want a Python reference or would like to recap any programming techniques, I have also added a Python course to the Computing and ICT in a Nutshell YouTube channel.

Note that, although I have been programming for almost 40 years, I don't claim to be an expert in Python, or even believe that Python is the best language for the job.  For that reason, I have avoided using any techniques, such as list comprehension, that are particularly Pythonic.

Apart from the Arithmetic Test example (which requires a bit more work as it loads other modules), solutions open in Basthon, which is a French IDE that doesn't require you to register. Click the Exécuter button to run them - and make sure that you don't translate the page!

No. Link
1Factorial Finder (iterative solution)
Factorial Finder (recursive solution)
2Speed Tracker
3Thief!
4Classification
5Fruit Machine
7Credit Card Validator
8Arithmetic Test*
9Happy Numbers
10Number Names
13Caesar Cipher
15Pangrams - ASCII version
Pangrams - Dictionary version
16Kaprekar
17Number Table
18Years in Range
19Logic Gate
20Palindrome (string slicing)
Palindrome (recursive)
23Fibbing
33Mor-se Coding
34What's the day?
36Triangulate
37Fizz Buzz
38Sing Along
41Prime Factorisation
67What have the Romans ever done for us?
70Of Mice and Men
71Goldbach

* Some of the tasks are more open-ended and I have included similar examples from other sources, such as previous coursework tasks.

You'll notice that I tend to use lists or tuples in my code to avoid the need for multiple IFs, and also demonstrate how it can be used to improve a common Magic 8 Ball program here.  You can also make use of True and False to avoid the need for a lot of IFs in your code.  Finally, there is a video on recursion, in which I explain how the factorial, palindrome and prime factorisation programs work.

If you prefer to use a local IDE, you can download these programs.  You can also download further programming examples in BASIC, JavaScript and Python.