- Home
- »
- Question Paper
- »
- Computer Programming Olympiad School Round 2 ...

*All posts from*

__olympiad.org.za__

# Computer Programming Olympiad School Round 2 Question Paper 2017

** Name of the Organization **: Computer Olympiad South Africa

**: Programming Olympiad**

__Examination Name__**: Programming Olympiad Round 2 Question Paper**

__Announcement__**: 2017**

__Year__**: Past Papers**

__Type__**: http://olympiad.org.za/programming-olympiad/past-papers/school-rounds/**

__Website__**:**

__Download Question Paper__**: https://www.southafricain.com/uploads/9866-2017POR2.pdf**

__2017 PO School Round 2__**: https://www.southafricain.com/uploads/9866-2016POR2.pdf**

__2016 PO School Round 2__**: https://www.southafricain.com/uploads/9866-2011POR2.pdf**

__2011 PO School Round 2__**: https://www.southafricain.com/uploads/9866-2010POR2.pdf**

__2010 PO School Round 2__**: https://www.southafricain.com/uploads/9866-2009POR2.pdf**

__2009 PO School Round 2__Contents

## Computer Programming Olympiad Round 2 Question Paper

** Download Programming Olympiad 2017 PO School Round 2 sample question Paper & Solution above PDF links

** Not to be used before 14 August 2017

Related: Computer Programming Olympiad Round 1 Question Paper 2017 : www.southafricain.com/9860.html

## Instructions

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 earns 10 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.

## Sample Questions

** Section 1 **: Secret Code

**: Polynacci**

__Section 2__**: Rational Order**

__Section 3__### Secret Code

You have just found secret instructions on how to encode a message. Determine the message length and round up to the nearest multiple of 5. Write out the message in rows of 5 characters each until the message is complete. Send the message a column at a time from left to right.

** For example, suppose the message is**: THIS IS A CODED MESSAGE

As it is 23 characters long, add two spaces at the end to make the message 25 characters long.

** The rows of five characters are**:

1 2 3 4 5 T H I S I S A C O D E D M E S S A G E

** The characters are sent one column at a time from left to right. The encoded message therefore becomes**:

TIC.AHSOMGI.DEESAES…DS.

** Task**: Write a program that will encode any message using the secret instructions. Make sure to output all spaces as full stop characters: ‘.‘

**:**

__Examples__**: THIS IS A CODED MESSAGE**

__Input__**: TIC.AHSOMGI.DEESAES…DS.**

__Output__**: 3 AND 7 MAKES 10!**

__Input__**: 3.K0.7E!A.S.NM..DA1.**

__Output__** Test your program with the following cases and type or paste the answers in the correct blocks on the web page**:

1a) MEET.ME.IN.THE.PARK.TONIGHT.AT.SEVEN

1b) LOREM IPSUM DOLOR SIT AMET

1c) OLEHDKL.OEA..U.YBWLI,EHDT..E.?ITRI..HE..WE.H.IRSI

1d)T.GLEHC.L.EACEM.THDAR.A.LATSATTHET!.EDE.T….HDKT.EOIH

### Polynacci

You may recall the Tribonacci numbers which you saw in Round 1. In that sequence you started with three initial terms and each term thereafter is the sum of the previous three terms.

We now further generalise this concept and consider a sequence of numbers which we call a Polynacci sequence. A Polynacci sequence begins with M given initial terms. The next term of the sequence is then generated by adding the previous M terms.

** For example, if M = 3 and we start with terms 1, 2, 3, we obtain the sequence**:

1, 2, 3, 6, 11, 20, 37, 68, 125, 230, 423, 778, …

** If we have M = 5 and we start with the terms 1, 1, 2, 2, 3, then we obtain the sequence**:

1, 1, 2, 2, 3, 9, 17, 33, 64, 126, 249, …

** Task**: Create a program that will determine the N-th term of a Polynacci sequence given the first M terms.

**: The number of initial terms must be calculated from the given input and not be provided as an input value.**

__Note 1__**: The input numbers are separated by a single space**

__Note 2__**:**

__Example cases__**: Start with: 2 3 4 N: 10**

__Input__**: 335**

__Output__**: Start with: 1 2 3 4 5 N: 10**

__Input__**: 214**

__Output__**:**

__Test your program with the following cases and type or paste the answers in the correct blocks on the web page__**: 3 1 1 N: 12**

__2a) Start with__**: 2 3 5 7 N: 15**

__2b) Start with__**: 1 4 9 7 2 2 N: 30**

__2c) Start with__**: 2 8 15 4 4 3 8 9 10 3 N: 36**

__2d) Start with__### Rational Order

** Consider the set of all reduced rational numbers between 0 and 1 inclusive with denominators less than or equal to N. Here is the set when N=5**:

0/1 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 1/1

Note that, for N = 5, there is a total of 11 reduced rational numbers found between 0 and 1 with denominators no more than 5.

** Task**: Given a positive integer N your task is to write a program that calculates all the reduced rational numbers between 0 and 1 inclusive with denominators less than or equal to ??. Output only the total number of rational numbers found.

Examples

**: N = 4 Output: 7**

__Input__**: N = 5 Output: 11**

__Input__**:**

__Test your program with the following cases and type or paste the answers in the correct blocks on the web page__3a) N = 7

3b) N = 15

3c) N = 62

3d) N = 100