0% found this document useful (0 votes)
409 views

Algorithm Challenge Booklet

This document contains 40 algorithm challenges of varying difficulties that are intended to help learners become familiar with creating flowcharts and pseudocode. The challenges include tasks like asking for user input, performing calculations, and using conditional logic. Reference materials for pseudocode and relevant techniques are provided.

Uploaded by

bagus sujatmiko
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
409 views

Algorithm Challenge Booklet

This document contains 40 algorithm challenges of varying difficulties that are intended to help learners become familiar with creating flowcharts and pseudocode. The challenges include tasks like asking for user input, performing calculations, and using conditional logic. Reference materials for pseudocode and relevant techniques are provided.

Uploaded by

bagus sujatmiko
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

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.

Version 1 1 © OCR 2017


Contents
Difficulty 1 Challenges 4
Challenge 1 4
Challenge 2 4
Challenge 3 4
Challenge 4 4
Difficulty 2 Challenges 5
Challenge 5: 5
Challenge 6 5
Challenge 7: 5
Difficulty 3 Challenges 6
Challenge 8 6
Difficulty 4 Challenges 6
Challenge 9 6
Challenge 10 6
Challenge 11 7
Challenge 12 7
Challenge 13: 7
Difficulty 5 Challenges 8
Challenge 14 8
Challenge 15 8
Challenge 16 8
Challenge 17 9
Challenge 18 9
Challenge 19 9
Pseudocode only challenges 10
Challenge 20 10
Challenge 21: 10
Challenge 22 10
Challenge 23 11
No help given, pseudocode only! 12
Challenge 24 12
Challenge 25 12
Challenge 26 12
Challenge 27 13

Version 1 2 © OCR 2017


Version 1 3 © OCR 2017
Difficulty 6 Challenges 14
Challenge 28 14
Challenge 29 14
Challenge 30: 14
Challenge 31 15
Challenge 32: 15
Difficulty 7 Challenges 16
Challenge 33 16
Challenge 34 16
Challenge 35 16
Difficulty 8 challenges 17
Challenge 36 17
Challenge 37: 17
Difficulty 9 Challenges 18
Challenge 38 18
Challenge 39: 18
Challenge Rating 10: 18
Challenge 40 18

Version 1 4 © OCR 2017


Difficulty 1 Challenges

Challenge 1
Design a program which asks the user to input their name, age and favourite colour.

You may need the following…


Arithmetic Operations Decisions Iteration
- BEGIN / END - -
INPUT

Challenge 2
The program asks the user to input their first name. The program then outputs the users first
name.

Suggested Pseudocode Statements


Arithmetic Operations Decisions Repetition
- BEGIN / END - -
INPUT
OUTPUT

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.

Suggested Pseudocode Statements


Arithmetic Operations Decisions Repetition
- BEGIN / END - -
INPUT
OUTPUT

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.

Suggested Pseudocode Statements


Arithmetic Operations Decisions Repetition
- BEGIN / END - -
INPUT
OUTPUT

Version 1 5 © OCR 2017


Difficulty 2 Challenges

Challenge 5
The program asks the user to input two numbers. The program adds them together and then
outputs the total.

Suggested Pseudocode Statements


Arithmetic Operations Decisions Repetition
+ BEGIN / END - -
= INPUT
OUTPUT

Challenge 6
The program asks the user to input two numbers. The program will then output:

● The two numbers added together followed by…


● The two numbers multiplied together.
Suggested Pseudocode Statements
Arithmetic Operations Decisions Repetition
+ BEGIN / END - -
* INPUT
= OUTPUT

Challenge 7 Tip: Speed = Distance / Time


Write an algorithm that:

● Asks the user for the distance (in metres).


● Asks the user for the time in seconds that a journey was completed in.
● Calculates and outputs the average speed using a function.
Suggested Pseudocode Statements
Arithmetic Operations Decisions Repetition
/ BEGIN / END - -
= INPUT
OUTPUT

Version 1 6 © OCR 2017


Difficulty 3 Challenges

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:

● Stores a random first name as a variable.


● Asks the user to input their first name.
● If it is the same as the stored name, outputs 'You’re cool.'
● Otherwise outputs 'Nice to meet you.'
Suggested Pseudocode Statements
Arithmetic Operations Decisions Repetition
= BEGIN / END IF -
INPUT ELSE
OUTPUT ==

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.

Suggested Pseudocode Statements


Arithmetic Operations Decisions Repetition
- BEGIN / END IF -
INPUT ELSE
OUTPUT ==

Version 1 7 © OCR 2017


Difficulty 4 Challenges

Challenge 11
The program asks the user to
input two numbers. It will then output the larger of these two numbers.

Suggested Pseudocode Statements


Arithmetic Operations Decisions Repetition
> BEGIN / END IF -
= INPUT ELSE
OUTPUT

Challenge 12
Write an algorithm that:

● Generates a random number between 1 and 10.


● It must then ask the user to guess this number.
● If they guess it correctly it should display ‘Correct’
● Otherwise, display ‘Not what I was thinking’
Suggested Pseudocode Statements
Arithmetic Operations Decisions Repetition
= BEGIN / END IF -
RANDOM INPUT ELSE
OUTPUT ==

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 ==

Version 1 8 © OCR 2017


Difficulty 5 Challenges

Challenge 14
Write an algorithm that:

● Asks the user to input the traffic light colour.


● If the traffic light colour is green, outputs ‘Go.’
● If the traffic light colour is amber, outputs ‘Get Ready.’
● Otherwise outputs ‘Stop.’
Suggested Pseudocode Statements
Arithmetic Operations Decisions Repetition
- BEGIN / END IF -
INPUT ELIF
OUTPUT ELSE
==

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.

Suggested Pseudocode Statements


Arithmetic Operations Decisions Repetition
< BEGIN / END - WHILE or FOR
+ OUPUT
=

Challenge 18
Write an algorithm that:

● Outputs all odd numbers between 1 and 20 only.


Suggested Pseudocode Statements
Arithmetic Operations Decisions Repetition
< BEGIN / END - WHILE or FOR
+ OUTPUT
=

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

Version 1 10 © OCR 2017


Pseudocode only challenges

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.

They have a log of customer’s orders stored in a file, as shown:

Customer Name Large Medium Small Card?


Smith, J 5 6 1 No
Williams, P 10 12 3 Yes
etc

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.

Suggested Pseudocode Statements


Arithmetic Operations Decisions Repetition
>= BEGIN / END IF -
= ELSE
==

Challenge 21
A local swimming centre offers the following discounts:

1. Members who are aged between 13 and 15 receive a 30% discount.


2. Members who are aged between 16 and 17 receive a 20% discount.
3. Members who are aged 50 and over receive a 40% discount.
4. All other members receive no discount.
Create an algorithm using Pseudocode for the above actions.

Suggested Pseudocode Statements


Arithmetic Operations Decisions Repetition
>= BEGIN / END IF -
<= INPUT ELIF
AND , OR OUTPUT ELSE
=

Version 1 11 © OCR 2017


Challenge 22
Write an algorithm that:

● 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

Suggested Pseudocode Statements


Arithmetic Operations Decisions Repetition
>= BEGIN / END IF -
< INPUT ELIF
AND OUTPUT ELSE
= ==

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
==

Version 1 12 © OCR 2017


No help given, pseudocode only!

Challenge 24
Create an algorithm that that:

● Randomly generates the computer status ‘rock’ ‘paper’ or ‘scissors.’


● Asks the user to input their status ‘rock’ ‘paper’ or ‘scissors.’
● If the computer and user have the same status then output ‘Game Tied.’
● If the computer generates ‘Rock’ and user generates ‘Scissors’ then output ‘Computer
Wins’
● If the computer generates ‘Paper’ and user generates ‘Rock’ then output ‘Computer Wins’
● If the computer generates ‘Scissors’ and user generates ‘Paper’ then output ‘Computer
Wins’
Otherwise output ‘You Win!’

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:

RunnerNumber Name AgeCatagory Club?


44325 Wilburforce, Emily U18 SpeedyClub
543 Chan, Zhu Snr
2425 Patel, Aisha Vet
5552 Ewards, Craig Snr LighteningFast Runners

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.

The program uses the following method:

● The user inputs age of the dog in years


● If the age is 2 or less, the human equivalent is 12 times the age
● If the age is more hen 2, the human equivalent id 24 for the first 2 years, plus 6 for every
additional year.
Write an algorithm to calculate and output the human equivalent of the age of the dog using the
method described.

Version 1 13 © OCR 2017


Challenge 27
The cost of a day-time journey is £3 for the first kilometre and £2 for every kilometre after that. If
there are five of more passengers in the taxi, and extra 50% is added to the charge.

Write an algorithm to calculate the cost of a day-time journey.

Your algorithm should:

● 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.

Version 1 14 © OCR 2017


Difficulty 6 Challenges

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.

Produce an algorithm that:

● 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.

Write an algorithm that:

● 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”

Version 1 15 © OCR 2017


Challenge 31
The student is writing an algorithm to solve a problem.

● 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

Write an algorithm for the process described above.

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:

● Enter the amount of money she wants to save.


● Input the number of bank accounts she wants to compare.
● Enter the interest rate for each account.
● The interest is calculated by dividing the money to be saved by 100 and then multiplying
this by the interest rate.
● The total is calculated by adding the money to be saved to the interest and then outputted.
● The program should repeat this for all bank accounts.
Create an algorithm using Pseudocode for the above actions.

Version 1 16 © OCR 2017


Difficulty 7 Challenges

Challenge 33
Write an algorithm that:

● Ask the user to input how many GCSE’s they have.


● They should then be allowed to enter a result for each GCSE grade.
● The computer should work out how many points they have got (9=9, 8=8, 7=7 etc).
● If their score is 40 or over it should output ‘You can go to the sixth form’
● If they their score between 35 and 39 it should output ‘A discussion is needed’
● Otherwise it should say ‘Sorry not enough points.’

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.

Version 1 17 © OCR 2017


Difficulty 8 challenges

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.

The machine has a small keypad with keys 0 to 9, OK and


CANCEL. It also has a small LCD screen, which can
display a short message.

To get a drink, users select an item number between 1


and 20 with the keypad and confirm their choice by
pressing OK. If they make a mistake they can press the
CANCEL button and start again. If the selection is valid
and the drink is available it dispenses the drink. The
display screen is used to show suitable short messages
throughout the process.

Write an Algorithm of the process described above.

Version 1 18 © OCR 2017


Difficulty 9 Challenges

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.

Year Start Paid in Interest Final


1 0.00 100.00 10.00 110.00
2 110.00 100.00 21.00 231.00
3 231.00 100.00 33.10 364.10
4 364.10 100.00 46.41 510.51
5 510.51 100.00 61.05 671.56

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.

Write an algorithm for the process described above.

Challenge Rating 10

Challenge 40
Write an algorithm that:

● Gives the user 3 lives at the start of the game.


● Allows the user to play the game until their have no lives left.
● They should move onto the next level for every 5 points they earn.
● The game is complete when they receive 20 points.
● At the end of the game it should tell the user which level they got up to.

Version 1 19 © OCR 2017


We’d like to know your view on the resources we produce. By clicking on ‘Like’ or ‘Dislike’ you can help us to ensure that our resources
work for you. When the email template pops up please add additional comments if you wish and then just click ‘Send’. Thank you.
If you do not currently offer this OCR qualification but would like to do so, please complete the Expression of Interest Form which can
be found here: www.ocr.org.uk/expression-of-interest
Looking for a resource? There is now a quick and easy search tool to help find free resources for your qualification:
www.ocr.org.uk/i-want-to/find-resources/

OCR Resources: the small print


OCR’s resources are provided to support the teaching of OCR specifications, but in no way constitute an endorsed teaching method that is required by the Board, and the decision to
use them lies with the individual teacher. Whilst every effort is made to ensure the accuracy of the content, OCR cannot be held responsible for any errors or omissions within these
resources.
© OCR 2017 - This resource may be freely copied and distributed, as long as the OCR logo and this message remain intact and OCR is acknowledged as the originator of this work.
OCR acknowledges the use of the following content: n/a
Please get in touch if you want to discuss the accessibility of resources we offer to support delivery of our qualifications: [email protected]

Version 1 20 © OCR 2017

You might also like