0% found this document useful (0 votes)
8 views2 pages

Programming Olympiad 2016 Round 1 Tasks

IT

Uploaded by

nombusomkorwana
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Programming Olympiad 2016 Round 1 Tasks

IT

Uploaded by

nombusomkorwana
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Programming Olympiad 2016 : Round 1

Not to be used before 1 August 2016


1. This paper is for ALL candidates.
2. All answers must be TYPED or PASTED on your Answer Sheet. Handwritten Answer Sheets will
be disqualified.
3. Each correct answer for questions 1, and 2 earns 8 marks; each correct answer for question 3 earns
9 marks.
4. You have 60 minutes to attempt as many questions as possible.
5. Programs should be readable, concise, and use appropriate variable names.
6. Indicate the question, your name, surname and the language and version used at the start of every
program e.g. “Q3 Sam King, Python 2.7”
7. Save your program as Qn Name Surname e.g. Q3 Sam King
8. You may assume that the user input will satisfy the problem specification and so you do not need to
validate the input.
9. Do not write code to produce only specific answers, as the external judges may use other test
cases.
10. After the contest you may be given time to print out your Answer Sheet. Do not make any changes.
11. Make sure you save the programs you have created and the Answer Sheet in a place where your
teacher can find them.
12. DO NOT MODIFY ANY FILES AFTER THE END OF THE CONTEST AS THIS WILL LEAD TO
DISQUALIFICATION.

1. Speeding
Examples:
Gauteng has introduced a system of Input: Time? 30 Distance? 1000
measuring the speed of cars over distance.
Output: 120
Write a program that will ask for a time in
seconds and a distance in metres as input Input: Time? 4 Distance? 75
and will give the speed in km/h as output. Output: 67
Your program must discard fractions of a km
(if any). For example, if the speed is 75.9 Test your program with the following and
km/h your program must give 75 as the type or paste each answer in the correct
answer. block on your Answer Sheet (or in the
correct block on your screen if you are
The speed for test case (d) was clocked by a taking part online).
special vehicle at Hakskeen Pan.
a) 20 seconds, 800 metres
b) 90 seconds, 1800 metres
c) 5100 seconds, 168000 metres
d) 22 seconds, 7900 metres
2. Maths 3. Encryption
Write a program that asks for a positive The ACME Code Company has released
integer value N, then calculates all the factors their new encryption algorithm: UrghTM. To
of N (other than N itself) and adds them encrypt a message using the UrghTM
together to give the answer. A factor is a algorithm is simple.
positive, whole number that divides N exactly.
For example, the factors of 8 are 1, 2, and 4. Each letter ends up N letters to the right of its
The sum: 1 + 2 + 4 = 7 original position, and the last N letters wrap
around to the beginning. In addition the
Examples: letters are replaced by letters N places further
Input: N? 8 in the alphabet.
Output: 7
For example:
Input: N? 12 If you shift the word APPLE by N=2 then it
Output: 16 becomes LEAPP
If you then replace the letters by letters 2
Test your program with the following and places further in the alphabet, LEAPP
type or paste each answer in the correct becomes NGCRR
block on your Answer Sheet (or in the
correct block on your screen if you are If you shift the word ENCRYPTION by N=4
taking part online). you get TIONENCRYP. If you then replace
the letters by letters 4 places further in the
a) N= 6 alphabet, you get XMSRIRGVCT
b) N = 100
Write a program that, given a word and the
c) N = 30030
integer number N, will output the encrypted
d) N = 119451 word.

Examples:
Input: Word? APPLE N? 2
Output: NGCRR

Input: Word? ENCRYPTION N? 4


Output: XMSRIRGVCT

Test your program with the following and


type or paste each answer in the correct
block on your Answer Sheet (or in the
correct block on your screen if you are
taking part online).

a) CAT N = 1
b) ACT N = 2
c) NEOAOQNL N = 4
d) EMDVENZKCFUTJXUGKYSARH N = 10

You might also like