1994  ICPSC 
Elementary Division Problems




1. STOP SIGN
Write a program that will generate and print out the stop sign shown 
below.  The program must use at most five PRINT commands.


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



2. DIGIT STRING
Suppose you translate a number it into a string of digits spelled 
out, one word for each digit, followed by a single space. For 
example, the number 407 becomes the digit string: "FOUR ZERO SEVEN".
Write a program to accept a positive number and print out its DIGIT 
STRING. The program should work for decimal numbers as shown in the 
Sample Run.

Sample Run
Enter a positive number: 407.8
The Digit String = FOUR ZERO SEVEN . EIGHT

Test your program with the following numbers:  79 66.2 9786.45231


3. CIRCULAR NUMBERS
A whole number is said to be CIRCULAR if, when you multiply the 
number by its units decimal digit, the result is the number with its 
decimal digits rotated to the right, with the units digit becoming 
its high-order digit. For example, 102564 is a circular number 
because in the multiplication:

102564
    x4
--------
410256  can be formed by taking  4 at right of 102564 and moving it 
to the  left to get 410256.

Write a program to test a number from 1 to 999,999 to see if it is a 
CIRCULAR NUMBER. 

Sample Run
Enter your number less than 1,000,000 : 102564
102564 is a CIRCULAR NUMBER

Enter a number less than 1,000,000 : 123456
123456 is NOT a CIRCULAR NUMBER

Test your program with inputs  102564,  11111, 113793.


4. ORDERING FRACTIONS
A  fraction is the quotient of two integers M/N. Consider two  
fractions 1/2 and 3/8 which one is largest?  When these two fractions  
are ordered from lowest to highest they would appear as follows:    
           3 / 8   <  1 / 2
Write a program that accepts two fractions, each entered as a pair 
N,M , and prints out the fractions in ordered form as above. If the 
fractions are equal, it should say so and always put the fraction 
with the lowest denominator on the left. For example if N,M = 6,12 
and P,Q = 2,4 then the output would be:   
                   2 / 4 = 6 / 12

Sample Run
Enter a fraction M/N as M,N : 1,2
Enter a fraction P/Q as P,Q : 3,8
3 / 8   <  1 / 2

Test your program with the fractions: 
2,3  and 4,7
615, 2280  and 123, 456
12345,34567 and 34,57

5. VALID WALKS
A 3x3 square is divided into 9 unit cells and numbered from left to 
right  row by row as shown below . It is  possible to walk from cell 
1 to cell  9 by stepping from one cell to a neighboring cell ( one 
that shares a common side) until you have arrived at cell 9 never 
steping on a cell more than once. A VALID WALK is described as a list 
of nine digits beginning with 1 and ending with 9 as follows: 
123654789. Notice that no digits are repeated and all neighboring 
digits are neighboring cells. Walks that use fewer than all 9 cells 
are valid too. For example, 12369 is a VALID WALK. Walks that don't 
begin at 1 and end at 9 are not valid.

----------------
|    |    |    |
| 1*****2***3  |
|    |    | *  |
------------*---
|    |    | *  |
|  4***5****6  |
|  * |    |    |
---*------------
|  * |    |    |
|  7***8****9  |
|    |    |    |
----------------

Write a program that will tell whether a proposed walk in this 3x3 
block  is a VALID WALK.

Sample Runs
Enter a walk : 1 2 3 6 5 4 7 8 9
123654789 is a VALID WALK.

Enter a walk: 1 2 3 4 5 6 7 8 9 
123456789 is NOT a VALID WALK. 

Test your program with the following  walks: 
123654789, 12369, 123569, 2369, 1252589, 147852369

Your program may not store all the valid walks worked out my hand and 
simply look them up. But you may store the valid steps in an array 
A(I,J)  where A(I,J) = 1 means you may step from cell I to cell J 
where I =1 to 8 and J=2 to 9. 
