Training Site
Sideways banner

NCEA Scholarship 2025 Digital Technologies Q1 (Sample)

Input: Standard Input (stdin)
Output: Standard Output (stdout)
Memory limit: 128 megabytes
Time limit: 1.0 seconds

Consider the following pseudocode:

FUNCTION DoSomething(a):
  b = ""
  FOR i FROM (LENGTH(a) - 1) TO 0 STEP = -1
    b = b + a[i]
  ENDFOR
  answer = true
  FOR j FROM 0 to LENGTH(a):
    IF a[j] IS NOT EQUAL TO b[j]
      answer = false
    ENDIF
  ENDFOR
  return answer

PRINT DoSomething("Scholarship")


(e) Write one boundary case for this function.

(f) Write the improved pseudocode function to handle this boundary case in the box below.

(h) Assuming that improvements can be made on the efficiency of this algorithm, in the box below, write the most efficient algorithm you can think of to achieve the intended purpose of the “DoSomething” function.

Note: You are not allowed to use reverse() or sort().



This question is taken with permission from Scholarship Digital Technologies 93604 (Sample assessment 2025). However, subtasks and test data (with the exception of the sample data) are created independently by the NZOI. Your result is no indication of exam performance. These questions are unlikely to be sufficient preparation for the exam. NZQA owns the copyright in the examination material reproduced, and has consented to its reproduction, but takes no responsibility for its accuracy or fitness for purpose. The performance standard by which the scholarship assessments are assessed, varies significantly from the NZOI grading and selection process, and success in the NZOI selection process does not guarantee gaining a Scholarship in Digital Technologies. This question cannot be reproduced by any means without the prior permission of NZQA.



Submission

For this site, you can implement the algorithm described by the above pseudocode in your language of choice. When you're ready, go to the submit tab. You will need to identify the boundary case mentioned in (f) and make the required changes. After that, it might get 50%. Can you improve the algorithm to get 100%?

Please note that the above question asks you to improve on the algorithm. This means you cannot rely on language features such as sort, reverse, or string slicing. Our website cannot tell the difference but in an exam situation using them might not get you very far. These features hide the true process required to perform the task, which is still occurring at an interpreter or library level even if it is not expressed directly in code. You must be explicit. Try to write your code in a way that it can be easily translated line-by-line into another language without the same features as yours. As a starting point, try translating the above pseudocode one line at a time into your language of choice. You may need to add things around it but the core algorithm should retain a similar structure. Once you've done that, have a go at the two tasks.

Input

A string a on a single line.

Output

If DoSomething returns true then print 1. Otherwise, print 0.

For example, to print the output for our site correctly with Python, using the provided input, you could write

print(int(DoSomething(input())))


Subtasks

Where N is the length of string a.

  • Subtask 1 (50%): N=20,000. Your solution handles boundary cases correctly.
  • Subtask 2 (50%): N=2,000,000. Your solution uses a more efficient algorithm.