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. The above question cannot be reproduced by any means without the prior permission of NZQA.



Submission

The above is the quote from the sample exam. For this site, you can implement the algorithm described by the above pseudocode in your language of choice. However, make sure to adapt it to meet the output requirements below. When you're ready, go to the submit tab. You will need to fix the boundary case mentioned in (f) if applicable.

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.

We will measure the algorithmic efficiency of your implementation. That means if your implementation is O(N) then you should get 100%. Less than 100% indicates either a bug in your implementation or poor algorithmic efficiency. However, further improvements are possible. Feel free to make further submissions, trying to reduce the runtime of the last test case.

Warning: In many languages, concatenating two strings is a O(N) operation, which may lead to an inefficient O(N^2) implementation.

Input

A string a on a single line. We test your code with a string length N of up to 2,000,000.

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())))


  • Sample Input 1

    Scholarship
    

    Sample Output 1

    0