Senior Division 1985
1.  SQUARE DESIGNS
Write a program that will generate Square Designs like the one below 
for size N for the first square.and size M for the second square. 
Separate the square with 5 spaces.

Test your program for N,M = 4,7 and 9,3.

Sample Run
ENTER VALUES FOR N,M :? 5,3

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


2. ORDERED SQUARES
A number with an even number of digits, such as n1n2n3n4n5n6, is 
called an Ordered Number if the number n1n2n3 and the number 
n4n5n6 differ by 1.

i.e.  n1n2n3 - n4n5n6=+ or - 1.

A number is a Square if it is equal to the product of one whole number 
multiplied by itself. Thus 144 is a Square since 144= 12x12. An 
Ordered Square is a number that is both Ordered and a Square.

Write a program that will find all N-digit Ordered Squares for any 
even integer N.

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

Sample Run

ENTER A VALUE FOR N: 4

ALL ORDERED SQUARES OF SIZE 4:

8281



3. WINNING COMBINATIONS
Three runners, A, B, and C enter as a team in a 10 mile relay race. 
Each runner can run from 1 to 8 miles (no fractions). All runners have 
a normal time in seconds that they will run their first, second, 
third,.eighth mile. It is derived with the following function:

Time in seconds for the Nth mile
Runner A    265 + 9N +11 - 16INT((9N+11)/16)
Runner B   256 + 13N + 15 - 16INT((13N+15)/16)
Runner C...256 + 7N +10 -16INT((7N +10)/16)

Write a program that will determine how many miles each runner 
should run for the team to have the fastest time. These are called the 
Winning Combinations. Print out the top three Winning Combinations 
as shown in the sample run.

Sample Run
TOP 3 WINNING COMBINATIONS FOR RUNNERS ABC.

          MILES RUN
NUMBER    A   B   C    TIME
1         3   5   2    2622
2         1   5   4    2624
3         ?   ?   ?    ????





4. JUSTIFYING TEXT
Write a program that accepts a sentence from the keyboard and prints 
out the sentence justified into a column N characters wide. Words that 
can't fit on the line are moved to the next line. Spaces must then be 
added between words so that each line, except possibly the last one, is 
exactly N characters wide.This is called Justifying Text.

Test your program by entering the sentence below and justifying the 
text for N=20 and N=25.

Sentence to enter:
A great discovery solved a great problem but there is a grain of 
discovery in the solution of any problem. 

Sample Run
ENTER A VALUE FOR N: 20
ENTER A SENTENCE:

JUSTIFIED TEXT:

A  GREAT   DISCOVERY
SOLVES    A    GREAT
PROBLEM BUT THERE IS
A GRAIN OF DISCOVERY
IN THE  SOLUTION  OF
ANY PROBLEM.
	


5. PRIME CRYPTARITHM
The following cryptarithm is a multiplication problem that can be 
solved in substituting digits from a specified set of N digits into the 
positions marked with *. If the set of prime digits {2,3,5,7} are the 
only ones allowed, the cryptarithm is called a PRIME 
CRYPTARITHM.

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

Write a program that will find all solution(s) to the cryptarithm above 
for any subset of digits from the set {0,1,2,3,4,5,6,7,8,9}. Test your 
program with two different subsets: the prime digits {2,3,5,7} and the 
set {2,4,8}.

Sample Run
ENTER A SET OF DIGITS: 2357

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

                                     ICPSC 1985
                             Senior Division Problems



                                     ICPSC 1985
                             Senior Division Problems




