Elementary Division 1988
1. DIAMOND
Write a program than will print the following diamond. Use as few 
PRINT statements as possible.


        $
       $-$
      $-$-$
     $-$-$-$
    $-$-$-$-$
     $-$-$-$
      $-$-$
       $-$
        $


Note: Your experiment will most likely show different results.


2. PATTERNS
Examine the pattern of numbers in the triangle of size 8 shown 
below.

1  
1  1
1  1  2
1  1  2  3
1  1  2  3  5
1  1  2  3  5  8
1  1  2  3  5  8  13
1  1  2  3  5  8  13 21


From the pattern, figure out what the next row should be. Write a 
program that will generate this triangle for any number of rows from 
1 to 10. Test your program for N=8 and N=10.

Sample Run

ENTER A VALUE FOR N: 6

1  
1  1
1  1  2
1  1  2  3
1  1  2  3  5
1  1  2  3  5  8


3. DIE TOSS
A die is a cube with six equal sides {1, 2, 3, 4, 5, 6}. The function 
INT(6*RND(1) +1)  (or similar function) picks a number from 1 to 6 
that can be used to simulate the tossing of a die. 

Write a program that uses this function to  simulate the tossing of a 
die. Have the user enter the number of times, N, the die is  tossed and 
print a list showing how many times each value from 1 to 6 appears.

Test you program for the number of trials N = 100 and 200.

Sample Run

Enter the number of trials: 100
value		count
1		14
2		13
3		18
4		19
5		20
6		16
total		100





4. REVERSE
Write a program that asks the user for a list of words and prints the 
list in reverse order. 

Test your program with the list:  WHAT YOU SEE IS WHAT YOU 
GET

Sample Run

ENTER A LIST OF WORDS:
THIS IS IT

IT IS THIS


5. FOUR SUMS
Write a program that will find and count the number of ways that any 
whole number between 3 and 15 can be written as the sum of four 
positive whole numbers.

Test your program for N= 10.

Sample Run

Enter a number BETWEEN 3 AND 15: 8

THE four SUMS ARE:
8 = 1 + 1 + 1 + 5
8 = 1 + 1 + 2 + 4
8 = 1 + 1 + 3 + 3
8 = 1 + 2 + 2 + 3
8 = 2 + 2 + 2 + 2 

total number FOUR SUMS = 5


Note:  Rearrangement of the same numbers are not counted as 
different sums.
The sum  8 = 5 + 1 + 1 +1 is not considered different from  8 = 1 + 1 
+ 1 + 5. 


	ICPSC 1988
	Elementary Division Problems


