|
This page contains links to all of the material needed to complete
the Preliminary Round of the UNSW High Schools Programming Competition.
The detailed rules of the competition are supplied in a separate page. Please read the rules carefully before commencing the competition. Each programming task is described in a separate page, and there is a separate directory for each task containing data files. Tasks may be completed in any order. You must stop working and submit your work so far after 2 hours. You can submit program listings, even if they're not working. Good Luck! |
Ths basic task is worth 10 points. The extension is worth up to 5 bonus points.
where digit positions are counted from the left, beginning with 1. Thus the odd positions are the first, third, fifth and seventh digits. A UPI is valid if and only if S is a multiple of 10. Thus 53723516 is valid because 5+7+3+1+3*(3+2+5)-6=40, which is a multiple of 10.
S = sum of digits in odd positions
+ 3 * (sum of digits in even positions except the last)
- digit in last position
The input format is one UPI per line. The program should display the UPI followed by the word "OK" or the word "REJECT".
| Input | Output |
|---|---|
53723516 00367857 12345678 28654322 19851688 99999999 00000000 |
53723516 OK 00367857 OK 12345678 REJECT 28654322 OK 19851688 OK 99999999 REJECT |
| Input | Output |
|---|---|
19851688 99999999 00000000 |
19851688 OK risk=1 99999999 REJECT |
Write a program which when given a positive integer i returns the i-th prime number. Assume that 2 is the first prime number.
This task is worth 10 points.
| Input | Output |
|---|---|
1 |
2 |
2 |
3 |
3 |
5 |
4 |
7 |
5 |
11 |
42 |
181 |
256 + 512 = 728 might be expressed as ABC +
BDA = EAF, where the encoding is A=2, B=5,
C=6, D=1, E=7, F=8.
Your task is to write a program that reads in an arbitrary "letter
maths" equation and determines an encoding that gives a valid arithmetic
equality. The program should then print out the decoded equation.
If no such encoding is possible, your program should indicate this
with the output Invalid letter maths. If there are
multiple encodings that produce a valid equality, then any of them
is acceptable.
Input is a single line consisting of a "number", a single space, an operator (one of '+', '-', '*' or '/'), a single space, another "number", an '=' character with a single space on either side, and a final "number". In this context, "numbers" are sequences of upper-case alphabetic letters.
This task is worth 15 points.
| Input | Output |
|---|---|
ABC + BDA = EAF |
256 + 512 = 728 |
ABCDDD * XYZ = JEDJZDDD |
123000 * 765 = 94095000 |
EEL / A = XY |
113 / 4 = 28 |
AAAA + B = CC |
Invalid letter maths |
The result of each game show round will be enter on single line. The line will contain the contestants name followed by their score for that round. A line containing only the word end indicates the finish of the game show. The number of rounds or contestants is not fixed.
Write a program which takes as input the results of each game show round and prints the winner of the game show.
The basic task is worth 10 points. The extension is worth up to 5 bonus points.
| Input | Output |
|---|---|
john 1 fred 3 mary 7 fred 2 john 1 john 4 mary 1 fred 4 john 1 end |
The winner is fred with a score of 9 |
A game show will last no more than 100 rounds.
Contestants' names will always be a single word containing only lower-case alphabetic charcters. Names will always be spelt correctly.
There will always be one outright winner (no ties). In other words one contestant always has a score larger than any other.
The last line of input will always contain the word end. No contestant will have the name end.
Your program can assume input is correct.
No error checking is required.
Each line of the file contains 4 fields separated by commas:
phonenumber,dd/mm/yyyy,hh:mm:ss,hh:mm:sswhere phonenumber is a 10-digit phone number (including area code, no spaces or hyphens); the date is presented as a 2-digit day (dd), 2-digit month (mm) and 4-digit year (yyyy), separated by / characters; and the times are in 24-hour format with 2 digits each for hour (hh), minute (mm) and second (ss).
The input is terminated by a line consisting of the dummy number 0000000000 and irrelevant other fields.
The basic task is worth 10 points. The extension is worth up to 5 bonus marks.
| Input | Output |
|---|---|
0291234567,02/02/1999,07:30:00,07:45:00 0293854329,02/02/1999,09:12:00,09:16:30 0293854329,02/02/1999,17:10:30,17:11:00 0296650000,02/02/1999,09:05:00,09:08:30 0296650000,02/02/1999,10:12:00,10:15:00 0296650000,02/02/1999,11:07:30,11:08:30 0296650000,02/02/1999,12:05:45,12:09:00 0000000000 |
0291234567 15:00 0293854329 05:00 0296650000 10:45 |
There is no limit on the number of input lines.
You may may assume the input is of the correct format.
The program should read the length of the first side of the spiral and then draw sides until the spiral reaches "the middle" (a point where no further characters can be drawn that are not adjacent to or that cover some existing character).
This task is worth 15 points.
| Input | Output |
|---|---|
1 |
/ |
3 |
/\ / \ / (__) |
6 |
/\ / \ / /\ \ / / \ \ / / (__) \ / (________) |
8 |
/\ / \ / /\ \ / / \ \ / / /\ \ \ / / / _) \ \ / / (______) \ / (____________) |