Senior Division 1990
Note: In all problems, except the first one, the alignment of your 
output need only approximate what is show here in the sample runs. 

1. TRIANGLES
Write a program that will print a triangle with sides of length N 
constructed of characters entered by the user. Have the program ask 
the user for the size N and a string of three characters.  Print out a 
triangle similar to the one below using one character for each side. 

Test your program with size 7 string ABC, and size 10 string XYZ.



SAMPLE RUN
ENTER A SIZE? 7
ENTER A STRING? ABC

C
AC
A C
A  C
A   C
A    C
ABBBBBB


2. WINNING/LOSING FORM
When you flip a coin you win every time it comes up heads and lose if 
it comes up tails. Begin by flipping a coin and noting whether you win 
or lose on the first toss. Now continue flipping four more times and 
note whether you are ahead (more wins than loses) or behind (more 
loses than wins). If you begin with a win and end up ahead or begin 
with a loss and end up behind you are in WINNING/LOSING FORM.

What are the chances that when you toss a coin 5 times you are in 
WINNING/LOSING FORM?

Write a program that will simulate the experiment of tossing a fair 
coin 5 times and checking if you are in  WINNING/LOSING FORM. 
To estimate your chances of this happening, repeat the experiment 100 
times and report the percentage of  times you are in 
WINNING/LOSING FORM.

The above process (100 experiments) is considered one case. Process 
10 cases and average the results to compute an estimate of the 
percentage of the time that you are in a WINNING/LOSING FORM 
when flipping a coin five times. Print out your results as shown below.

SAMPLE RUN
Case 		Percentage
 1		      74
 2		      70
 3		      70
 4		      66
 5		      71
 6		      73
 7		      60
 8		      74
 9		      67
 10		      69
===========================
Average	      69.4	

On average you will be in 
WINNING/LOSING FORM 69.4% of the time when tossing a fair 
coin 5 times.


3. MAKING CHANGE
Write a program than will compute how many ways to make change 
for a given amount of money. The money system consists of the coins 
A, B, C, and D where

		5 A = 1 B
		2 B = 1 C
		2 C = 1 D

All money is expressed in terms of A. Thus 23 in this system means 
23 A. Your job is to write a program that will compute all the ways to 
make change for any amount of A. Print your results as shown in the 
sample run.

Test your program with 23 and 36.

SAMPLE RUN
Enter an amount in A? 23

Number	A	B	C	D
1	23	0	0	0
2	18 	1	0	0
3	13	2	0	0
4	8	3	0	0
5	3	4	0	0
6	13	0	1	0
7	8	1	1	0
8	3	2	1	0
9	3	0	2	0
10	3	0	0	1

There are 10 ways to make change for 23 A using A, B, C and D.


4 FRIDAY THE 13TH
Is Friday the 13th really an unusual event?  That is, does the 13th of 
the month land on a Friday less often than on any other day of the 
week? To answer this question, write a program that will compute the 
frequency that the 13th of each month lands on Sunday, Monday, 
Tuesday, Wednesday, Thursday, Friday, and Saturday over a given 
period of N years. The time period to test will be from January 1, 1900 
to December 31, 1900+N-1 for any number of years N.

There are few facts you need to know before you can solve this 
problem:

1. January 1, 1900 was on a Monday.

2. Thirty days has September, April, June, and November, all the rest 
have 31 except for February which has 28 except in leap years when it 
has 29.

3. Every year evenly divisible by 4 is a leap year (1992 = 4*498 so 
1992 will be a leap year, but the year 1990 is not  a leap year) 

4. Rule 3 does not hold for century years. Century years divisible by 
400 are leap years, all other are not. Thus the century years 1700, 
1800, 1900 and 2100  are not leap years, but 2000 is a leap year.


Test your program for N=20 and N=400.

Note: To make it fair for everyone, you may not use any built-in date 
functions in your computer language.

SAMPLE RUN
Enter the number of years N? 20

FROM JAN 1, 1900 TO DECEMBER 31, 1919 THE 13TH OF THE 
MONTH LANDS ON 

DAY			# OF TIMES
SUNDAY			33
MONDAY			34
TUESDAY			33
WEDNESDAY			35
THURSDAY			35
FRIDAY			34
SATURDAY			36




5 WORD CHAIN
A Word Chain is a sequence of words which differ by one letter. The 
set of words {MOM, TIP, TAP, SIP, MAP, MOP} contains the word 
chain  

	MOM MOP MAP TAP TIP SIP 

where each adjacent pair of words differ by exactly one letter. If all the 
words in the set are not used the chain is said to be broken. Write a 
program that finds a word chain in a set of words beginning with the 
first word in the set. If the chain is broken, print out "This chain in 
broken." Print the word chain in a vertical column and indicate (with a 
special character such as ! ) which letter changes in the chain. Use the 
sample run as a model.

Test your program with the set  {HEAL, DEAD, DEER, HEAD, 
BEER, DEED} and the set {TWO, PAT, TOP, TOO, POP}


[You many enter your words and the number of words used in DATA 
statements or place then in an array but you must enter them in the 
same sequence they are given above. The program must find the word 
chain if one exists. You may assume that each set tested contains at 
most one word chain.]

SAMPLE RUNS

	MOM
	  !
	MOP
	 !
	MAP
	!
	TAP
	 !
	TIP
	!
	SIP
	Is a word chain.

	TWO
	 !
	TOO
	  !
	TOP
	!
	POP
	This chain is broken.


ICPSC 1990
Senior Division Problems

{page|1}


