
Elementary  Division 1991
1. LETTER E
Write a program that will create the letter E of any odd size N <  20.
Test your program for N = 7, 9

Sample Run
Enter an odd number: 5

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

Enter an odd number: 7

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


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?

For example, if you were born in JAN and you started asking 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. 

Set up a random experiment that counts how many people were asked 
until someone shared your birthmonth.  Repeat this experiment 100 
times and report the average count for all 100 experiments.




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

Enter your birthmonth as a number:  
1 - JAN,  2 - FEB... 12 - DEC.

Sample Run

What is your birthmonth? 2

After 100 experiments, the average number of people asked until 
someone shared your same birthmonth was 11.81



3. PAIRS
Write a program that lists all pairs (two people) that can be selected 
from a group of size N. (Assume N<=26.)

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

Note that AB is the same pair as BA.

Test your program for group size N = 7 and N = 11.

Sample Run

Group size = 7

PAIRS FROM A GROUP OF SIZE 7

AB  AC  AD  AE  AF  AG 
BC  BD  BE  BF  BG 
CD  CE  CF  CG 
DE  DF  DG  
EF  EG  
FG  

TOTAL NUMBER OF PAIRS IN A GROUP OF SIZE 7 IS EQUAL 
TO 21




4. PALINDROMES
The number 1991 is a palindrome because it is the same number 
when read forward or backward. Write a program that  finds and 
prints all palindromes between two numbers a and b. You may 
assume that a and b are between 0 and 9,999.

Test your program with a,b = 1000, 2000 and a,b = 2000, 4000


Sample Run

a,b = 1000,2000

Palindromes between 1000 and 2000

1001	1111	1221	1331	1441
1551	1661	1771	1881	1991




5. SAILORS AND A  MONKEY
Five sailors and a monkey are on an island. One evening the sailors 
round up 15,621 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 5 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 4 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/5th of the total coconuts left for himself.

In the morning the 5 sailors come together again and divide the 
remaining coconuts in the bin into 5 equal piles with one coconut left 
over for the monkey. How many coconuts does each sailor and the 
monkey get?

Write a program that computes how many coconuts each sailor and 
the monkey got. 

(Your program should be general enough so it  could work with a 
different number of sailors and an appropriate number of coconuts.)

Sample Run

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


	ICPSC 1991
	Elementary Division Problems 

	ICPSC 1991 
	Elementary Division Problems 

{PAGE}


