UOM Programming Proficiency/Competency Test

This article is to introduce what is the University of Melbourne Programming Proficiency/Competency Test, and how it was like. Information was based on my personal experience in Semester 2, 2016.

What is it?

The University of Melbourne Programming Proficiency Test (also known as the Programming Competency Test), is served as one of the prerequisites to replace the subject COMP10001 Foundation of Computing. When passing this test at a score more than 75%, you can enroll to several subject including COMP10002 Foundation of Algorithm.

The name of the test is not consistent throughout the materials provided by the university, but “Programming Proficiency Test” is used more commonly.

How is it like?

More of a general stuff

  • You will be given a several tasks to solve by writing your solution code on the question paper.
  • You can use any programming language, by naming it in the given blank in the question.
  • No additional material or calculator is allowed in the exam venue.
  • You are given 1.5 hours to finish the paper of 5 questions. (Some questions may have smaller parts)
  • Blanks are given right after each question for your code, and extra writing space are given in the end of the paper for overflow code.
  • You are recommended to write in the way you are more familiar with instead of a more speed-efficient way, since the runtime efficiency is not accounted in the marking.

From my experience

  • Most of the questions require you to write a function/method to solve a task. The other questions ask you to read a piece of code (written in both Python 3 and pseudo-code) and answer a question about it.
  • It’s better to know a bit of Python 3 before attending it, despite not necessarily, as the questions could be a bit Python-inclined.

How do you register for it?

Contact the subject coordinator and he/she will redirect you to the correct person. Please be sure to leave enough time for registration, as sometime email communication can take longer than expected. Usually it takes in the first week of the semester.

Any sample questions?

The following questions are recalled from the UOMPPT Semester 2 2016 and released here for study purpose. The sample answers provided below may not be correct. I, the writer, provide the following material ‘AS IS’, and do not incur any promise regarding it.

Question 1: Pig-Latin Generator

Write a function translate() which translates Pig-Latin from a normal English word.

Rules for Pig-Latin words:

  • If the first letter is a consonant, move the first letter to the end of the word and add “ay” in the end.
  • Otherwise, just add “ay” in the end.

Examples:

  • “vocaloid” → “ocaloidvay”
  • “android” → “androiday”

Input (Parameters)

One parameter: a string consists of only small letters.

Sample answer (Python 3.x)

def translate(word):
    if word[0] in "aeiou":
        return word + "ay"
    else:
        return word[1:] + word[0] + "ay"

Question 2: Triangle generator

Write a function triangle() that takes in a number N and prints a right-aligned triangle with height and width of N filled with *.

Input (Parameters)

One parameter: a positive integer indicating the size

Sample output (Python Interactive Console)

>>> triangle(7)
      *
     **
    ***
   ****
  *****
 ******
*******

Sample answer (Python 3.x)

def triangle(a):
    for i in range(a):
        print("*" * (i + 1).rjust(a))

Question 3: Largest n-gram

Write a function find() that returns the length of the longest common n-gram between 2 words, return 0 if there is no common n-gram.

What is n-gram?

N-gram here represents a sequence of n continuous letters in a list of words. Spaces and punctuations are ignored in this case.

Input (Parameters)

2 Parameters:

  1. First word sequence to compare
  2. Second word sequence to compare

All input strings only consist of letters and space, where spaces are to be ignored.

Examples (Python interactive shell)

>>> find("covers", "discovery")
5
>>> find("apple", "tommy")
0

Sample answer (Python 3)

def find(w1, w2):
    w1, w2 = w2, w1 if len(w2) < len(w1) else w1, w2
    minlen = len(w1)
    result = 0
    for i in range(minlen):
        grams1 = []
        for j in range(minlen - i):
            grams1.append(w1[j:j + i + 1])
        for j in range(len(w2) - i):
            if w2[j:j + i + 1] in grams1:
                result = i + 1
    return result

Question 4: Sudoku Verifier

This question is separated into 3 parts, with an introduction of sudoku. Here I assume you know what it is, and how it works. If you don’t, please head to Wikipedia.

Terms used in this question:

  • A sudoku row: a list/array consist of 9 integers between 1 and 9 inclusive, assuming all rows have 9 integers, and no integer is out of the range (1 – 9).
  • A sudoku array: a 2-dimentional array of 9 sudoku rows representing a completed sudoku table. Assuming all arrays have 9 rows, and no row is invalid.
  • A sudoku column: a column (vertical row) in the sudoku table.
  • A sub-square: the smaller squares bonded by the bold lines in the sudoku table, consist of 9 digits between 1 and 9 inclusive.

4.1 Verify a row

Write a function verify_row() that takes in a sudoku row as its parameter, return 1 if the row is valid (consist of only 9 digits from 0 to 9 with no duplicated numbers), or 0 otherwise.

Sample answer (Python 3.x)
def verify_row(row):
    return int(set(row) == set(range(1, 10)))

4.2 Verify rows and columns

Write a function verify_row_column() that takes a sudoku array as the only parameter and returns 1 if all its rows and columns are valid, or 0 otherwise. Assuming function verify_row() is prepared correctly for use.

Sample answer (Python 3.x)
def verify_row_column(array):
    verified = 1
    for i in array:
        verified &= verify_row(i)
    pivot = [[]] * 9
    for ival in array:
        for j, jval in enumerate(ival):
            pivot[j].append(ival)
    for i in pivot:
        verified &= verify_row(i)
    return verified

4.3 Verify sub-squares

Write a function verify_subsq() that takes a sudoku array as the only parameter and returns 1 if all its sub-squares are valid, or 0 otherwise. Assuming function verify_row() is prepared correctly for use.

Sample answer (Python 3.x)
def verify_subsq(array):
    verified = 1
    subsqs = coords = []
    magic_nums = [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
    for i in magic_nums:
        for j in magic_nums:
            coords.append([])
            for k in i:
                for l in j:
                    coords[-1].append[2]
                    
    for i in coords:
        subsqs.append([])
        for j in i:
          subsqs[-1].append(array[j[0]][j[1]])
        verified &= verify_row(subsq[-1])
    
    return verified

Question 5: Read code and answer the question

In this section, 2 pieces of identical code are given in each part of the question, written in Python 3 and pseudo-code. However, in the following recall, I’m going to show only the Python version.

5.1 Sum products

def MyFunction1(m, n):
    a = 0
    for i in range(1, m + 1):
        for j in range(1, n + 1):
            a += m * n
    return a

Q: How many times did the program multiplies?
A: m ⨉ n times.

def MyFunction2(word):
    if len(word) == 0:
        return 0
    elif len(word) == 1:
        if word in "AEIOUaeiou":
            return 1
        else:
            return 0
    else:
        mid = int(len(word) / 2) 
        return MyFunction2(word[:mid]) + MyFunction2(word[mid:])

Q: How many is MyFunction2() called when "rhythm" is called as a parameter?
A: 11 times, including the initial call.


Comments

2 responses to “UOM Programming Proficiency/Competency Test”

  1. Thanks a loooot for your information!!
    I’m planning to transfer to cs next semester, so hopefully I will take the test! Your blog did helped a lot!!!

    1. Glad to hear that! Wish you all the best for your transfer!

Leave a Reply

Your email address will not be published. Required fields are marked *