Round 1 Problems (1994)

  1. Horizontal Histogram
  2. Vertical Histogram
  3. Well Ordered Numbers
  4. Roman Numerals
  5. Hotel Keys

All Ireland Schools Programming Competition. How to enter Time Table Rules DCU Computers Guidelines Sample Problems Sample Problems IOI


1. Horizontal Histogram

Write a program that accepts a set of digits (0 to 9) as input and prints a horizontal histogram representing the occurrences of each digit.

Test your program with the set of 13 digits:
1, 7, 2 ,9 ,6, 7, 1, 3, 7, 5, 7, 9, 0

Example

Enter a Number : 12
Enter 12 digits:
1,7,2,9,6,7,1,3,7,5,7,9
 
0
1 **
2 *
3 *
4
5 *
6 *
7 ****
8
9 **

2. Vertical Histogram

Write a program that accepts a set of digits (0 to 9) as input and prints a vertical histogram representing the occurrences of each digit.

Test your program with the set of 13 digits:
1, 7, 2 ,9 ,6, 7, 1, 3, 7, 5, 7, 9, 0

Example

Enter a Number : 12
Enter 12 digits:
1,7,2,9,6,7,1,3,7,5,7,9

       *
       *
 *     * *
 *** *** *
0123456789

3. Well Ordered Numbers

The number 138 is called well-ordered because the digits in the number (1,3,8) increase from left to right (1 < 3 < 8). The number 365 is not well-ordered because 6 is larger than 5.

Write a program that will find and display all possible three digit well-ordered numbers. Report the total number of three digit well-ordered numbers.

Example

The three digit well ordered numbers are:
123 124 125 126 127 128 129 134
135 136 137 138 139 145 146 147
148 149 156 157 158 159 167 168
... ... ... ... ... ... ... ...
... ... ... ... ... ... ... ...
678 679 689 789

The total number is ??

4. Roman Numerals

Write a program that reads in a roman numeral and converts the number to normal decimal. The roman characters are :

M = 1000, D = 500, C = 100, L = 50, X = 10, V = 5, I = 1
Test your program with the following values : V (5), IV (4), VIII (8), MM (2000), MCM (1900), MCMXCIV (1994).

Example

Enter a roman numeral : VIII
VIII is 8.

5. Hotel Keys

The logo hotel gives out cards instead of keys. Each card contains a unique combination of holes, and can open one door in the hotel. The lock works by shining a beam of light through the card and detecting the pattern made by the holes. If the pattern is correct then the door opens. Each guest will be given a card, that opens only his or her door. An example card is shown here :

Each card has 4 x 6 (24) locations where a hole could go. This example has six holes. The holes of a card are not allowed to form a complete row, column or diagonal as otherwise, the card would easily bend or tear. (A diagonal can have two, three or four holes.) There must be at least five holes in each card.

No card should be able to open any door other than its own, no matter which way it is turned.

Write a program that will work out patterns for a number of cards. You don’t have to draw the card, simply print out the locations of the holes for each card. For example

The holes on this card are at B2, C2, C3, B4, D4, and B5. Note that another hole at A1 would not be allowed as then a diagonal is formed across the card. (A diagonal can consist of two holes, so holes at D5 and C6 would also be disallowed.)

Get your program to produce 20 cards.

Example

Enter the number of cards required : 2
Card 1 : Holes at A1, B1, C1, B2, C2.
Card 2 : Holes at B1, C1, D1, B2, B3, B4.