| This page contains links to all of the material needed to complete
the UNSW High Schools Programming Competition.
The detailed rules of the competition are given at http://do.cse.unsw.edu.au/progcomp/rules.html. Please read the rules carefully before commencing the competition. In order to permit a wide range of languages to be used there are no strict requirements on the method of entering the test data or the method of displaying the results. You may supply your programs with the data in whichever way you wish. Run each program on all the test data provided. Print out the results of each run and submit these together with the program listings. Clearly label each page with the question number and your team name. The supervisor must sign the cover sheet and submit this together with all your printouts by express post mail. If possible please also submit an electronic copy to progcomp@cse.unsw.edu.au immediately after the competition. There is no need to fill in an answer form on the web page this year - email submission is sufficient. Marks will be awarded for correct behavior and for programming style. Good style involves simple clear programs with brief but informative comments. 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!
|
Write a program which, given a string, prints it out backwards with the vowels removed.
| Input | Output |
|---|---|
| backwards | sdrwkcb |
| If at first you don't succeed... | ...dccs t'nd y tsrf t f |
| Aeiouuua |
backwards If at first you don't succeed... Aeiouuua Fly Fly Fly! Gwen and Edith are very VERY funny. "Halt!" cried the guard, running to the gate.
In an exciting new TV show contestants stand in a circle and every nth contestant is removed from the circle until there is only one left. This last contestant is the winner. The number n is picked by the host.
For example, one night Ann, Burt, Charlie, Dexter, Edith, Fred, and Gwen are the contestants. The host decides the number n will be 3, and starts counting from Ann. So Charlie is removed first, then Fred, then Burt, then Gwen (the counting skips over Charlie and Fred since they have already been removed), then Edith, then Ann. Leaving Dexter as the winner.
Write a program which, given a whole number (n) and a list of strings (contestant names), prints out the name of the winner. Assume the contestants are arranged in the same order as the list of names, and that counting starts from the first contestant in the list.
The format of your output should match the examples below:
| Input | Output |
|---|---|
3 Ann Burt Charlie Dexter Edith Fred Gwen | The winner is Dexter |
5 Ann Burt Charlie Dexter Edith Fred Gwen Pubert | The winner is Charlie |
4 Ernie The Cookie monster Burt | The winner is The Cookie monster |
3 Ann Burt Charlie Dexter Edith Fred Gwen |
5 Ann Burt Charlie Dexter Edith Fred Gwen Pubert |
4 Ernie The Cookie monster Burt |
1 Bruce Mila Gary Luc |
5 Claire Ann Virginnia Lisa Liz Sharon |
15 Gwen Edith Anneka Greta Ned Belinda Natasha Igor Helen Margo Finn Dr Who |
A collection of brackets is well formed if opening brackets are matched by closing brackets, and if there is no overlap.
Overlap occurs when one of the brackets in a pair of corresponding opening and closing brackets is between another pair of brackets, but the other bracket in the pair isn't.
For example ([)] overlaps, but ([]) doesn't.
Write a program which, given a string consisting of bracket characters, decides whether or not the collection is well formed.
The format of your output should match the examples below:
| Input | Output |
|---|---|
| ((())) | ((())) is well formed |
| ((([[{}[]]]))[]){} | ((([[{}[]]]))[]){} is well formed |
| ()()(] | ()()(] is NOT well formed |
(()())
((([[{}[]]]))[]){}
()()(]
[]
((()((())))
{[][([{}]])}
( ) { } [ ]
Note that this list contains the curly brackets {} as well as rounded ones
().
9 numbers arranged in a 3x3 square is said to form a Balanced Square if every row and every column has the same sum.
For example
1 8 6 10 5 0 4 2 9is a Balanced Square as every row and column add up to 15.
1 2 3 3 1 2 2 3 1is also a Balanced Square, every row and column add up to 6.
Write a program which, given a list of 9 integers, prints them out in a Balanced Square. If the integers can be arranged into a Balanced Square in more than one way you may print whichever one you wish.
If it is not possible to form a Balanced Square using the integers print out a message stating this.
The format of your output should match the examples below:
| Input | Output |
|---|---|
0 1 2 4 6 8 5 10 9 | 1 8 6 10 5 0 4 2 9 |
1 1 1 2 2 2 3 3 3 | 1 2 3 3 1 2 2 3 1 |
0 1 2 4 6 8 5 3 9 | 0 1 2 4 6 8 5 3 9 cannot be made into a Balanced Square. |
0 1 2 4 6 8 5 10 9 1 1 1 2 2 2 3 3 3 0 1 2 4 6 8 5 3 9 1 2 3 4 5 6 7 8 9 12 1 2 3 4 5 6 7 8 1 2 3 3 6 7 4 5 5 8 2 7 1 4 3 3 6 2
The base 10 decimal 140.34 represents the sum
1*100 + 4*10 + 0*1 + 3*(1/10) + 4*(1/100)
In a similar way the base-2 decimal 1101.101 represents the sum
1*8 + 1*4 + 0*2 + 1*1 + 1*(1/2) + 0*(1/4) + 1*(1/8)which is 13 + 5/8 (13.625) in base 10.
Write a program which, given two integers a and b, prints out the base-2 decimal corresponding to the fraction a/b.
If there are more than 10 digits after the decimal point print only the first 10.
The format of your output should match the examples below:
| Input | Output |
|---|---|
5 8 | 0.101 |
109 8 | 1101.101 |
1 3 | 0.0101010101 |
5 8 109 8 1 3 1000 1 1 1000 2 5
Provide separate printouts for the core part and the bonus part of this question. Use the same test data for the bonus part as for the core part.
Write a program which, given a number in digits, returns the number in words.
The format of your output should match the examples below:
| Input | Output |
|---|---|
13 | thirteen |
109 | one hundred nine |
1234567 | one million two hundred thirty four thousand five hundred sixty seven |
13 109 1234567 129 14012 907650
If you do the bonus part you need not provide output for the core part, although you may if you wish. Use the same test data for the bonus part as for the core part, plus the following additional test cases:
100000000000 12345600789 1002301045 1001327
|
The University of New South Wales School of Computer Science and Engineering UNSW High Schools Programming Competition 2001 |
| |
|
|||||||
| |
|
|||||||
| (Family names only) |
|
|||||||
| |
|
|||||||
|
||||||||
| |
|
|||||||
| |
|
|||||||
| |
|
|
| |
|
For each task, describe the team's achievement using one of these codes:
| N/A Task not attempted | U/S Attempted, but unsuccessfully |
| PART A partially successful attempt (some apparently correct output) | |
| OK Task completed | |
| Supervisor to complete |
Please leave these columns blank: UNSW assessors use only | ||
| Task | Attempt | Points | Remarks |
| Return to: | High Schools Programming Competition School of Computer Science and Engineering, The University of New South Wales, Sydney NSW 2052 to arrive by Friday 27 July 2001 |