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

2024 PO R1 Question Paper ENG

The document outlines the rules and tasks for the Programming Olympiad 2024, including instructions for participants on how to submit answers and the scoring system for each question. It presents three programming tasks: calculating the number of black squares on a checkered board, determining a tree's growth speed based on its name, and encoding a player's sequence of attacks in a fighting game. Participants are reminded to follow specific guidelines to avoid disqualification.

Uploaded by

Abdur Rahman
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)
24 views2 pages

2024 PO R1 Question Paper ENG

The document outlines the rules and tasks for the Programming Olympiad 2024, including instructions for participants on how to submit answers and the scoring system for each question. It presents three programming tasks: calculating the number of black squares on a checkered board, determining a tree's growth speed based on its name, and encoding a player's sequence of attacks in a fighting game. Participants are reminded to follow specific guidelines to avoid disqualification.

Uploaded by

Abdur Rahman
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
You are on page 1/ 2

IITPSA NPC

Level 1 West, Gallagher House,


Gallagher Convention Centre,
Leading ICT Professionalism 19 Richards Drive, Midrand, South Africa
and Ethical Digital P O Box 1714, Halfway House
1685, South Africa
Transformation
Tel: +27 87 655 1679 or
+27 11 315 1319
www.iitpsa.org.za

Programming Olympiad 2024 : Round 1


Not to be used before 29 July 2024

1. This paper is for ALL participants.


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

Question 1: Checkered Board Task


Chess, Checkers and many other games are played on an 8 Write a program that reads in the checkered board's side
by 8 checkered board. Many other games can be played on length S as input. Your program must output the number of
boards of different sizes. black squares on a S by S checkered board. Assume the top
right square of the board is always black.
Examples
Input: 5
Output 13
Input: 8
Output: 32

Figure 1. 5 by 5 checkered board

Directors: Ms. S.B. Goba (President), Ms. P. Pasi (VP), K.W. Matthee (Treasurer),
.Gwanzura, T. Mashegoane, R. Kisten, , J. Singh, K.F. Chipidza,
Prof. L.A. Futcher, Ms. J.M. Overdevest, N.V. Zambezi, M.A. Parry (CEO)
Sponsored by
Reg. No.: 1958/001036/08 VAT Reg. No.: 4760 12 1113 PBO No.: 930010177
Test your program with the following cases: Question 3: Fighting Game
1.a 10 Introduction:
1.b. 21 In a fighting game, the buttons A, B, X, Y are used to perform
1.c. 36 different types of attacks. Pressing a button once performs a
1.d. 111 normal attack, and pressing the same button twice performs
a special attack. For example, pressing X is a punch and XX
is a special punch.
Question 2: Tree Growth
In a virtual forest, a tree’s name determines its growth speed.
The player inputs a sequence of attacks e.g. “ABXXYBB”
Each letter in the tree’s name is assigned a value as follows:
which is then sent to the game engine. The game engine
• Vowels (a, e, i, o, u) are 5 points each.
• Special consonants (b, c, d, f, g) are 3 points each. cannot directly read the players inputs. Instead, it reads an
• All other consonants are 2 points each. encoded version where special attacks are represented by
the letter S followed by the attack type. The sequence

The sum of these points determines the tree’s growth speed “ABXXYBB” is encoded as “ABSXYSB”.

as follows:
Sum Points Growth speed Player’s often spam (hit the same button repeatedly). To

Less than 25 Slow discourage spamming, if the player repeatedly hits the same

25 to 35 Medium button consecutively, it is interpreted as a single special


attack e.g. “XXXXXB” is encoded as “SXB”.
Greater than 35 Fast

Task Task:
Write a program which reads in the name of the tree and Write a program which reads in the player's sequence of
outputs the tree’s growth speed. attacks and outputs the encoded version sent to the game
engine.
Examples:
Input: baobab Examples:
Output: Slow Input: XABYYX
Output: XABSYX
Explanation: The sum points of baobab is 3 + 5 + 5 + 3 + 5 +
3 = 24. Since 24 is less than 25 the growth speed is Slow.
Input: XXXXBYYYAA
Input: pineapple Output: SXBSYSA
Output: Medium
Tests
Explanation: The sum points of pineapple is 2 + 5 + 2 + 5 + 3.a. BBBBA
5 + 2 + 2 + 2 + 5 = 30. Since 30 is in the range 25 to 35 the 3.b. XBAYYABX
growth speed is Medium.
3.c. AABBXYXYBAAABBXYXYBA
3.d.
Test your program with the following cases: AAAAABAAAXBAABBXXXXXXYBBBBYYYYAAAXXXXYXXXXX
2.a. oak BBBBAAAYBX
2.b. magnificent
2.c. sequoia
2.d. yellowwood

Directors: Ms. S.B. Goba (President), Ms. P. Pasi (VP), K.W. Matthee (Treasurer),
.Gwanzura, T. Mashegoane, R. Kisten, , J. Singh, K.F. Chipidza, Sponsored by
Prof. L.A. Futcher, Ms. J.M. Overdevest, N.V. Zambezi, M.A. Parry (CEO)
Reg. No.: 1958/001036/08 VAT Reg. No.: 4760 12 1113 PBO No.: 930010177

You might also like