Senior Divsion 1991
1. LETTER A
Write a program that will create the letter A for any even size N _ 20.
Test your program for N = 8, 10

Sample Run

Enter an even number: 6

       *
      ***
     **  *
    *******
   **      *
  **        *


Enter an even number: 8

        *
       ***
      **  *
     **    *
    *********
   **        *
  **          *
 **            *

	
2. BIRTHMONTH

If you asked people at random for their birthmonth (the month in which 
they were born), how many people would you expect to ask until someone 
shared your birthmonth, or until two of the people asked shared the same 
birthmonth?

For example, if you were born in JAN and you asked people at random for 
their birthmonth, you might get the following response:

MAR	JUN	APR	DEC	FEB
NOV	JAN

In this experiment it took 7 tries until someone shared your birthmonth. 

Another way the experiment could end is if two people in your list have 
the same birthmonth.

2. (continued)

MAR	JUN	APR	DEC	MAR
	
In this experiment it took 5 tries until two people had the same 
birthmonth.

Set up a random experiment that counts how many people were asked until 
someone shared your birthmonth or until two people had the same 
birthmonth.  Repeat this experiment 1,000 times and report the average 
count for all 1,000 experiments.

You may assume that each month is equally likely to be a birthmonth: 
1/12. 

Enter your birthmonth as: JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, 
OCT, NOV, DEC.

Sample Run

What is your birthmonth ? FEB

After 1000 experiments, the average number of people asked until someone 
shared your same birthmonth or two people had the same birthmonth was 
4.06



3. TEAMS

Write a program that lists all teams of size M that can be selected from 
a group of size N. (Assume N<=26.)

Use a letter of the alphabet to identify each person. Print M letters to 
represent each team of size M and compute the total number of teams that 
can be formed from a group of size N. 

Note that ABC is the same team as BAC or CAB.

Test your program for team size M, group size N  = 3, 7 and  M, N = 5, 
7.



3. (continued)

Sample Run

Team size, group size = 3,7

TEAMS OF SIZE 3 FROM A GROUP OF SIZE 7

ABC ABD ABE ABF ABG ACD ACE ACF ACG ADE ADF ADG AEF AEG  AFG BCD BCE BCF 
BCG BDE BDF  BDG BEF BEG BFG CDE CDF CDG  CEF CEG CFG DEF DEG DFG EFG

TOTAL NUMBER OF TEAMS OF SIZE 3 FROM A GROUP OF SIZE 7 IS EQUAL TO 35





4. PRIME PALINDROMES

The number 151 is a prime palindrome because it is both a prime number 
and a palindrome (it is the same number when read forward as backward). 
Write a program that finds all prime palindromes  between two numbers a 
and b. You may assume that a and b are between 1 and 32,000.

Test your program with a,b = 1, 1000 and a,b =1000, 32000

Sample Run

a,b = 1,1000

PRIME PALINDROMES BETWEEN 1 AND 1000

2	3	5	7	11	
101	131	151	181	191	
313	353	373	383	727	
757	787	797	919	929




5. SAILORS AND A MONKEY

N sailors and a monkey are on an island. One evening the sailors round 
up all the coconuts on the island and put them in one large bin. They 
decide to wait until morning to divide up the coconuts, so they go to 
bed. During the night, the first sailor gets up, separates the coconuts 
into N equal piles with one left over, which he gives to the monkey.  He 
decides to hide one of the piles for himself, and he puts the remaining 
N-1 piles back in the bin. He then returns to his hammock, content that 
at least he got his share.

But he is not alone. During the night, each sailor gets up and does 
exactly the same thing:  gives one coconut to the monkey and takes 1/Nth 
of the coconuts left for himself.

In the morning the N sailors come together again and divide the 
remaining coconuts in the bin into N equal piles with one coconut left 
over for the monkey. What is the least number of coconuts that they 
could have begun with for all this to happen? Print out the number of 
coconuts that each sailor collected, the number that went to the monkey, 
and the total number of coconuts the sailors gathered together in the 
first place.

Test your program for N=5 and N=6.

Sample Run

Number of sailors = 5

Sailor		Coconuts
 1			   4147
 2			   3522
 3			   3022
 4			   2622
 5			   2302
Monkey	           6
========================
Total		  15621


	ICPSC 1991
	Senior Division Problems 

{PAGE}


