Elementary Division 1989

1. ARROW
Write a program that will create the following arrow using PRINT 
"*"; statements. Use no more than three such statements in your 
program.


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


2. EVEN UP
If you toss the same coin four times should you expect get two heads 
and two tails?

To investigate this problem, write a program that will simulate the 
tossing of a fair coin four times and count the number of heads and 
tails.  Repeat the experiment ten times and report the results as 
follows:

Sample Run

	 H   T
HTTT	 1	3
THHH	 3	1
HTTT	 1	3
THTT	 1	3
TTTT	 0	4
TTHH	 2 	2 
HTTH	 2	2 
HTTT	 1	3
TTHH	 2	2 
HHHH	 4	0
Heads =Tails 3 out of 10 times.



3. SECRET CODE
You have just found the secret instructions on how to code a message. 

 "Translate each letter in the message by substituting the letter 3 
characters to the right in the alphabet. Letters at the end of the 
alphabet  (XYZ), wrap around to the beginning (ABC). Blank spaces 
are left alone."

Top letters translate to the bottom letters.
ABCDEFGHIJKLMNOPQRSTUVWXYZ
||||||||||||||||||||||||||
DEFGHIJKLMNOPQRSTUVWXYZABC

For example, with this skip 3 substitution code the message :  ALL IS 
WELL	
is transformed into the message: 
DOO LV ZHOO

A secret message has just come over the wire which reads:
CSY.LEZI.GVEGOIH.XLI.WIGVIX. GSHI
(a period indicates a space)

Your mission, if you dare to accept it, is to write a program that will 
decode this message and similar coded messages. The same 
substitution code was used to code this message but with a slightly 
different value for the number of characters skipped to the right.  Try 
different skip values until the code is cracked.



4. DICTIONARY ORDER
If you translate the numbers from 1 to 9 into words, the number 1 
becomes "one",  2 becomes "two", 3 becomes "three", and so on down 
to 9 which becomes "nine". As words "eight" comes before "one" in 
the dictionary. 

Write a program that accepts three digits from 1 to 9 and prints their 
corresponding words in Dictionary Order.

Test your program with 3,4,5 and 
2,8,2

Sample Run
Enter three digits from 1 to 9
? 3,4,5

DICTIONARY ORDER
Five, Four, Three



5. SUM TO N 
Consider any three digits such as  
 9   5   2  which decrease from left to right. 
The three digits represented by 

		I    J    K

are values from 1 to 9 with  I  larger than J and J larger than K (I > J 
> K). 

Insert either a plus (+) or a minus  (-) in the space between the digits 
and SUM the numbers.
 
For Example   9 - 5 + 2 = 6
	
Write a program that will find all triples that satisfy the above 
conditions and which SUM TO N. 

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

Sample Run 

INPUT "ENTER A VALUE FOR N";6

THE SUMS TO 6 ARE:
9 - 2 - 1 = 6
9 - 4 + 1 = 6
9 - 5 + 2 = 6
9 - 6 + 3 = 6
9 - 7 + 4 = 6
9 - 8 + 5 = 6
8 - 3 + 1 = 6
8 - 4 + 2 = 6
8 - 5 + 3 = 6
8 - 6 + 4 = 6
8 - 7 + 5 = 6
7 - 2 + 1 = 6
7 - 3 + 2 = 6
7 - 4 + 3 = 6
7 - 5 + 4 = 6
7 - 6 + 5 = 6
5 + 4 - 3 = 6
5 + 3 - 2 = 6
5 + 2 - 1 = 6
4 + 3 - 1 = 6
3 + 2 + 1 = 6

ICPSC 1989
Elementary Division Problems 	


