Practice Session

From ProgSoc Wiki

Jump to: navigation, search

1. Open up a web browser and go to http://register.progsoc.org/team/. Log in with a team name and password provided by the competition staff.

2. Follow the instructions in the manual for the team interface online at DOMJudge Team Manual.

3. Try the following problems:


Problem 1: Hello UTS

This is an exercise to confirm that you understand the strict output requirements for marking by the automatic judge. It is important that you precisely follow instructions regarding whitespace, end-of-line and end-of-file delimiters.

Write a program to that prints the following two lines to standard output:

Hello, UTS!
	Goodbye, UTS.

There must be exactly two lines of output. The first line is terminated with a newline, the second line is terminated by the end-of-file (no newline). The second line starts with a tab. All other whitespace between words are single spaces. The output is case-sensitive.


Problem 2: Fizzbuzz

Write a program that takes a single integer n as input, and counts from 1 to n. The output will consist of one integer per line, terminated with a newline. All numbers that are divisible by 3 should be replaced by the word 'fizz'. All numbers that are divisible by 7 should be replaced by the word 'buzz'. If a number is divisible by both 3 and 7, it is to be replaced by 'fizzbuzz'.

You can assume that the input (provided on standard input) is an integer in the range -65536 to 65535. You will need to do some elementary input validation. If the input to the program n is less than 1, your program's output should be the single line "error".

Note: the output for this problem is case sensitive.


Sample input 1

10

Sample output 1

1
2
fizz
4
5
fizz
buzz
8
fizz
10

Sample input 2

-3

Sample output 2

error



Problem 3: Easy P-box

A P-box is an operation that is used in many encryption algorithms. It performs a permutation or transposition of input elements.

Implement a P-box that can transpose characters in a string, according to a given P-box specification. The first line of input will specify the P-box. It will consist of a list of integers from 1 to n, where n is less than 11. The list will not be in numerical order. The ith number in the list specifies which input character will appear as the ith character of the output. Subsequent lines of input will be strings the P-box operates on. For each line of input, print the output of the P-box operation on that string. You may assume that the input strings are exactly the same length as the P-box list. The input strings will consist solely of lowercase alphabetic characters, uppercase alphabetic characters, and spaces.

Sample input
4 3 2 1
abcd
frog

Sample output
dcba
gorf



Click here for tips on how to write your solutions

Personal tools