Algorithm Challenge Booklet
Algorithm Challenge Booklet
40 Algorithm Challenges
This booklet has been created to help learners become familiar with creating flowcharts and
pseudocode.
Reference may be made to the pseudocode guide at the back of the GCSE (9-1) Computer
Science specification when creating pseudocode answers or learners may wish to develop their
own style of pseudocode for use within the challenges.
It should be noted that there may be different ways to solve each challenge. Credit should be
given for a solution where it meets the requirements and is technically correct. There is no
requirement to write the pseudocode in any particular style. You may wish to limit credit where you
feel a learner does not create a fully efficient solution.
Whilst the challenges are graded from 1 to 10 in difficulty, these are approximate, and are
suggested only. The grading in difficulty does not necessarily reflect the GCSE 9-1 grading
systems.
A list of relevant techniques that learners may need to understand to solve these challenges may
be found in the current GCSE (9-1) Computer Science specification. This is available to download
from the J276 Computer Science webpage.
Challenge 1
Design a program which asks the user to input their name, age and favourite colour.
Challenge 2
The program asks the user to input their first name. The program then outputs the users first
name.
Challenge 3
The program asks the user to input their surname and then their first name. The program then
outputs the user’s first name and then their surname separately.
Challenge 4
The program asks the user to input their first name and then their surname. The program then
outputs the user’s first name and then their surname on the same line.
Challenge 5
The program asks the user to input two numbers. The program adds them together and then
outputs the total.
Challenge 6
The program asks the user to input two numbers. The program will then output:
Challenge 8
The program asks the user to input how many minutes and texts they have used in the last month
and then outputs the total cost of the bill. This is calculated by working out:
● The total cost of the minutes (at £0.10 per minute) and….
● Adding this to the total cost of the texts (at £0.05 per text) and….
● Adding on an additional monthly charge of £10.00.
Suggested Pseudocode Statements
Arithmetic Operations Decisions Repetition
+ BEGIN / END - -
* INPUT
= OUTPUT
Challenge 9
Write an algorithm that:
Challenge 10
The program asks the user to input the number of letters in the alphabet. The program must then
output whether they got it correct or incorrect.
Challenge 11
The program asks the user to
input two numbers. It will then output the larger of these two numbers.
Challenge 12
Write an algorithm that:
Challenge 13
A company calculates holiday allowance for employees.
The company gives each employees 28 days holiday each year. Holidays are awarded based on
the following rules:
1. Full time employees who work 5 days a week get 28 days holiday a year
2. Part time employees get a proportion of holiday allowance based on how many days they
work, e.g. An employee who works 1 day a week would only get 1/5th of the holidays
allowed.
Suggested Pseudocode Statements
Arithmetic Operations Decisions Repetition
/ BEGIN / END IF -
* INPUT ELSE
= OUTPUT ==
Challenge 14
Write an algorithm that:
Challenge 15
Write a program that:
● Asks the user to name one of the Olympic Values (Respect, Excellence and Friendship)
● If they correctly name one, output 'That’s correct‘
● Otherwise outputs ‘Incorrect’
Suggested Pseudocode Statements
Arithmetic Operations Decisions Repetition
- BEGIN / END IF -
INPUT ELIF
OUTPUT ELSE
==
Challenge 16
Write an algorithm that:
● Asks the user how long on average they spend watching TV each day.
● If it is less than 2 hours, outputs ‘That should be ok’
● If it is between 2 and 4 hours, outputs ‘That will rot your brain’
● Otherwise outputs “That is too much TV”
Suggested Pseudocode Statements
Arithmetic Operations Decisions Repetition
< BEGIN / END IF -
>= INPUT ELIF
< OUTPUT ELSE
AND
Challenge 17
Write an algorithm that:
Version 1 9 © OCR 2017
• Outputs all numbers between 1 and 10 only.
Challenge 18
Write an algorithm that:
Challenge 19
Write an algorithm that:
● Asks the user to input a number and repeat this until they guess the number 7.
● Congratulate the user with a ‘Well Done’ message when they guess correctly.
Suggested Pseudocode Statements
Arithmetic Operations Decisions Repetition
= BEGIN / END IF -
INPUT ELSE
OUPUT ==
ELSE
Challenge 20
MyHotPizza company have developed a new loyalty reward system for customers. Customers are
automatically sent a reward card if they order more than 20 pizzas in a year.
Write an algorithm that goes through the customer orders, and where needed, sends customers a
loyalty card if they do not already have one. If they have not ordered enough pizzas, then it
removes them from the card list.
Challenge 21
A local swimming centre offers the following discounts:
● Asks the user to input how many marks they got on a test.
● It should then convert this to a grade between 1 to 9 using the table below and then output
the grade to the user. If they have not scored enough to be given a grade than a ‘U’ grade
must be output.
Mark Grade
Greater than or equal to 10 1
Greater than or equal to 20 2
Greater than or equal to 30 3
etc
Challenge 23
Create an algorithm that will:
● Allow the user to input how much money they want to change to coins.
● Select which coin they want to convert the money into £1, 50p, 20p, 10p, 5p, 2p ,p
● Calculate how many of each coin will be given in.
Suggested Pseudocode Statements
Arithmetic Operations Decisions Repetition
/ BEGIN / END IF -
= ELIF
ELSE
==
Challenge 24
Create an algorithm that that:
Challenge 25
SpeedyClub Runners is a local sports club, who organise a 5k race every year.
The results of the race are stored in a record structure (called RaceFile) as follows:
Produce an algorithm that counts the number of runners in each Age category for the race.
Challenge 26
A dog that is 5 years old is equivalent to a 42 year old human. Ashok is writing a program which
converts the age of the dog to the equivalent age for a human.
● Allow the number of passengers and he distance of the journey to be input as whole
numbers,
● Calculate the cost of the journey,
● Output the cost that has been calculated.
Challenge 28
A gardener needs to buy some turf for a project they are working on. The garden is rectangular
with a circular flower bed in the middle.
● Asks the user for the dimensions of the lawn and the radius of the circle (in metres)
● Calculates and output the amount of turf needed
2
Tip: Circle area = Pi x Radius
Challenge 29
The wages earned by a worker is either £2 for every teddy bear the have made or £5 for every
hour they have worked, whichever is larger.
● allows the user to input the number of teddy bears made and the number of hours worked
● calculates the wages for the number of teddy bears made
● calculates the wages for the number of hours worked
● outputs the larger of the two results.
Challenge 30
An isosceles triangle is a triangle that has at least two equal sides. The diagram below shows
examples of isosceles triangles. In each diagram the marked sides are equal.
Write an algorithm for a computer program that determines whether a triangle in an isosceles
triangle.
● The user inputs the lengths of the three sides as Length 1, Length 2 and Length 3
● If any two side have the same length the program outputs “Isosceles”
● Otherwise the program outputs “Not Isosceles”
● The user will provide a series of numbers, representing the weights in grams of individual
fruits.
● The weights are always whole positive numbers.
● The number of weights to be entered will also be provided by the user.
● The solution should calculate and report the mean weight of the fruits to two decimal
places.
Two examples of the executing solution are shown below:
How many weights do you want to How many weights do you want to
enter? enter?
3 4
Enter a weight: Enter a weight:
138 279
Enter a weight: Enter a weight:
135 135
Enter a weight: Enter a weight:
285 145
Average weight is: 186.00 Enter a weight:
138
Average weight is: 174.25
Challenge 32:
Norma would like to invest her savings in a bank account that generates the most money. She
would like a program that will allow her to:
Challenge 33
Write an algorithm that:
Challenge 34
Roger has switched to a new electric supplier. He will receive free electric one day a week. He will
not pay for the day that he uses the least amount of electric. Write an algorithm that will:
● Allow the user to input the day of the week and then unit of units of electric used.
● Compare them until all comparisons are completed.
Output the day that will be free of charge.
Challenge 35
Write an algorithm that:
● Asks the user to input many cars are available for a trip.
● Asks the user to input how many people are going on the trip.
● If there are enough seats it should output ‘We have enough seats’
● If there are not enough seats it calculate how many extra cars are needed and then output
‘Another x cars are needed’ with x being the number of cars.
NOTE: Assume you can fit FIVE people in each car.
Challenge 36
● Petrol costs £1.40 per litre. Diesel costs £1.55 per litre. LPG costs £0.95 per litre.
● Ask the user for which type of fuel their car uses and how much they have put into it.
● Calculate the correct price of the fuel they have taken.
● Ask how much money they have handed over and calculate the amount of change they are
due.
● Finally, ask them if they have a loyalty card and if they do calculate how many points they
should have added to it using the following – 1 point for every litre of fuel they’ve taken plus
1 point for every full pound they’ve paid.
● If the number of points they get is more than 100 they get a bonus 10% extra points.
● The number of points should then be outputted
Challenge 37
A free drinks machine in an office provides 20 different
drinks.
Challenge 38
The company also offers a saving plan. Customers pay a fixed amount each year into the savings
plan. At the end of each year, the company adds the value of the savings plan at the start of the
year to the amount paid, and then adds interest of 10% to obtain the final value for the year.
For example, if a customer saves £100 each year, the value of the savings plan for 5 years is
shown in the table below.
Write an algorithm which allows the user to input the amount saved each year and the number of
years, and the outputs the growth of the savings plan in the format shown above.
Challenge 39
A primary school teacher wants a computer program to test the basic arithmetic skills of her
students. The program should generate a quiz consisting of a series of random questions, using in
each case any two numbers and addition, subtraction and multiplication. The system should ask
student’s name, then ask 10 questions, output if the answer to each question is correct or not and
produce a final score out of 10.
Scores from the quiz should be stored and added to when a student takes a new quiz.
Challenge Rating 10
Challenge 40
Write an algorithm that: