Elementary Division 1985

1. SQUARE DESIGN
Write a program that will generate the following Square Design. Do 
it with as few PRINT statements as possible.

+-----------+
I-X-X-X-X-X-I
I-X-X-X-X-X-I
I-X-X-X-X-X-I
I-X-X-X-X-X-I
I-X-X-X-X-X-I
+-----------+







2. ORDERED NUMBERS
A 4-digit number WXYZ is called an Ordered Number if the 
difference between the first two digits, WX, and the last two digits, 
YZ, is equal to 1 (WX-YZ=1 or YZ-WX =1). For example, 1213 and 
4645 are Ordered Numbers, while 2345 and 7685 are not Ordered 
Numbers.

Write a program that will only accept a 4-digit number and will 
determine if it is an Ordered Number. Test your program with the 
numbers: 1213, 2345, 999, and 4645.

Sample Run
ENTER A 4-DIGIT NUMBER:  1213

1213 IS AN ORDERED NUMBER.


3. WINNING COMBINATIONS
Three runners, A, B, and C, enter as a team in a 10 mile relay race.  
Two of the runners will run 3 miles each, and the best runner will 
run 4 miles. All runners have a normal time that they run for their 
first, second, third, and fourth mile. It is given by the following rule:

Time in seconds for Nth mile     
Runner A 
256+9xN+13 16xINT((9xN+13)/16)

Runner B 
256 +13xN +15 -16xINT(13xN+15)/16)

Runner C
256 + 7xN +9 -16xINT((7xN+9)/16)
( INT stands for Integer part.) 

Write a program that will determine which runner should run the 4 
mile leg in order for the team to have the best time. This is the 
Winning Combination. Also print the best time for the team.

Sample Run

RUNNER ? RUNS 4 MILES.
THE BEST TIME IS ???? SECONDS.    


4. JUNSTIFYING TEXT
Write a program that will accept a sentence of text from the keyboard 
in any convenient way and print the sentence in a column 20 
characters wide. Words at the end of a line that would lengthen the 
line beyond 20 characters must be moved to the next line.  This is 
called Justifying Text. Test your program by entering the sentence:

A great discovery solves a great problem but there is a grain of 
discovery in the solution of any problem.

Sample Run

A great discovery 
solves a great 
problem but there is 
a grain of discovery
in the solution of
any problem.

Note: Your solution need not be 
right justified.


5. PRIME CRYPTARITHM
The following multiplications problem can be solved by substituting 
only prime digits (2, 3, 5, or 7) into the positions marked *. This is 
called a Prime Cryptarithm.

    * * *
  x     *
  -------
  * * * *

Write a program that will find all solutions to this Prime 
Cryptarithm. 

Sample Run

    3 2 5
  x     7
  -------
  2 2 7 5

    5 5 5
  x     5
  -------
  2 7 7 5

..........
..........

	ICPSC 1985
	Elementary Division Problems




