1999 IBM-DCU All Ireland Schools Programming Competition

Round 1 Problems

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. Frames

The diagram shows a collection of overlapping frames. The frames have been placed on top of each other. Every frame covers at least one of the frames under it.

Write a program that calculates the order in which the n (1 £ n £ 26) frames have been placed on top of each other.

The width of the frame is 1 unit, and the sides are at least 3 units in length. At least one part of each of the four sides of a frame will be visable. A corner shows two sides.

The input will be a representation of the frames. The first two values will be the height, h (3 £ h £ 30) and the width, w (3 £ w £ 30). Then follows h strings of w characters each.

The input for the example diagram is
9
8
.CCC....
ECBCBB..
DCBCDB..
DCCC.B..
D.B.ABAA
D.BBBB.A
DDDDDD.A
E...AAAA
EEEEEE..

 

The output should be the letters representing the frames in the order that they were placed on top of each other

CBDAE

(By examining the diagram you can see that frame C is obviously the last frame to have been placed, so it is the first letter.) Frame E is covered by A which is covered by D which is in turn covered by B, which is covered by C.