======================================================================
               T H E   P R I M E   T I M E   P O T M
======================================================================

  Your task is to play "connect the digits" to find prime numbers in
         a square of numbers that I provide to your program!

Find the largest prime in the square that is less than 10^9 (1,000,000,000),
and do it quickly, and you could be the next POTM winner!  (speed, rather
than program size, will be the tie-breaker this time around ....)

Primes may be up to 9 digits long ..... (less than 1,000,000,000)

Input is a 5x5 square of numbers presented at run time ... for example:

		1 9 4 0 3	legal answers:
		7 5 8 3 3	  1940339  (meanders around the edge)
		0 0 0 7 9	943485497  (re-uses several digits legally)
		0 0 0 0 0 	900000011  (many paths yield this one)
		9 0 0 1 1	       37  (hey - at least it's legal!)

but you knew all this ... you asked for the details!!!!   read on ....

===============================================================================
  DEADLINE IS 11:59PM on January 15, 1995 ... give or take a time zone!
===============================================================================

1.  Your job is to write a program that takes a single argument which is
	the PATH name to the input file containing the grid:

	progname FILENAME

    Where FILENAME is the full PATHNAME of the input file.

    Your program will read in the file, and then print a single number
    as the output of the program ... namely the largest prime number
    you could find in the grid contained in the input file.

2.  Your program will be run five times, with five different grids.
	Scoring will be as follows:

	a)  The sum of the five returns will be added, provided they are
		valid answers, and the highest sum wins.
	b)  in the event of a tie (likely), the tiebreaker is computed
		by adding the  times for the five runs (as 
		computed by timex).  Smallest total time wins.

3.  About the input grid:

	a) The input file will contain 5 lines;
	b) each line will contain 5 digits (0-9) separated by spaces;
	c) any digit may appear in any of the 25 grid positions;
	d) there will be at least one non-zero digit;
	e) there will be at least one prime number contained in the grid;

4.  About the program output:

	a) the number must be a prime number (base 10);
	b) the number must have 9 or fewer digits;
	c) the leading digit should not be zero;
	d) the number must be obtainable from the grid using the rules below;

5.  Valid numbers from the grid:

	a) you may start at any of the 25 grid positions;
	b) subsequent digits may be chosen by moving horizontally, vertically,
		or diagonally from the previous position in the grid;
	c) you may NOT "stay" on a grid position and use the same grid 
		position twice in a row;
	d) there is NO wrap-around in any direction - that is, you may not move
		from column 5 to column 1, or from row 1 to row 5, or anything
		like that. (despite the error I made in the original sample)
	e) you may reuse grid positions provided that the above rules are 
		followed in order to return to that position.
	f) you may make at most 8 "moves" resulting in a digit string no
		longer than 9 digits.  Fewer moves are acceptable.

5.  About your programming:

	a) I compile on one machine and execute on another as follows:

		compilation machine: SunOS 5.3 Generic_101318-59 sun4m sparc
		execution machine  : SunOS 5.3 Generic           sun4c sparc

	b) The compilers I have available are (at least):

		SPARCompiler C++ 4.0
		SPARCompiler C   ANSI C compiler
				 SVID compliant under SunOS 5.x

		Plus whatever else I can support on the compilation 
		machine ... just ask and I'll try to find it!!!
		(This is a NEW box - so I'm not real sure what I have yet!)

		IMPORTANT:  submit early so we can resolve any
		portability problems!!!  

	c) if you wish to submit a shell program, Bourne, Korn, and csh are
		acceptable ... along with any bin or /usr/bin I can find.

	d) Temporary files may be created in /tmp, but MUST be removed
		when you are done ... creation of files anywhere else is
		strictly prohibited.

	e) No data structures containing lists of primes are allowed
		in the pre-compiled code ... you may 'generate' lists of
		primes to your heart's content, but please don't code up
		prime tables in your source code and eat up my disk space.
		I will not accept such entries - if your source code is
		"long" it's probably illegal.  8*)

6.  The system testing ....
	
	a) ship me an entry as soon as possible - you can always submit
		another entry if you improve your solution ..
	b) on receipt of your entry, I'll run a system test to make sure
		your program works ... you'll receive the results and
		a weekly standing of how you fared against other entries!
	c) here is a sample test file - please make sure your program works 
		with a file containing these five lines before you submit:
1 9 4 0 3
7 5 8 3 3
0 0 0 7 9
0 0 0 0 0
9 0 0 1 1

	d) unlike previous contests, I'm going to try and run each week
		with a different input grid and rank order each week
		based on the new results ... we'll see how long I keep
		THIS up ....

	e) your program must finish and print the answer to this system test
		problem in no more than ten minutes (sys+user time as 
		measured by timex on MY execution system).
		Your time will be provided along with your system test run
		so that you can correlate MY measured times with yours if
		you submit early entries.

	f) HELPFUL HINT:  in order to test your program, you're going to
		want to create your own grids and put large primes into them.
		  The UNIX command "factor" 
		(usually found in /usr/bin) may prove to be of help here.
		But then, you probably knew that ....

		If you come up with any real tough grids ... send them to
		me - maybe I'll use one in the finals!

7.  SENDING ME YOUR ENTRY - PLEASE USE EMAIL!!!

	Please email me the source code to me at:

		enter@potm.att.com		(preferred)
		enter@potm.ffast.att.com
		attmail!hicinbothem		(will forward correctly)

	IMPORTANT:  Please use the following (or equivalent) lines at the
	front of the program you mail to me (this will help immeasurably!):

	/*  POTM ENTRY:  entryname (something clever please!)		*/
	/*  Your Name:   First Last					*/
	/*  Your email:  log@machine.att.com (or whatever)		*/
	/*  compilation instructions (if other than "make entryname")	*/

	NOTE:  If you submit a shell program, please include these lines
	with a leading "#" and indicate which shell to run it under!  

	IMPORTANT:  ENTER EARLY - you will receive weekly standings and
	you will resolve any portability issues early.  You may improve
	your entry at any time by simply sending me another entry - so it
	pays to enter earlier!  (I process most everything within a week.)

	IMPORTANT:  AFTER you mail me an entry, I will run a system test on
	it and ship you the results - the system test results comprise the
	weekly standings.

	IMPORTANT:  If you don't hear from me within a few days - it may mean
	that the mail got screwed up .... please follow up with an inquiry to
	attmail!hicinbothem .... hopefully all my mail-path bugs are worked out!

Thanks!  Looking forward to your entry.  If you have any questions, mail 'em
to me - if I answer them I'll include them in the Frequently Asked Questions
(FAQ) list I circulate with the weekly standings!!!

WATCH THE FAQ - ESPECIALLY IN THE FIRST FEW WEEKS AS ALL THE STUPID ERRORS
  I MADE IN THE ABOVE RULES TURN UP!!!!

Looking forward to your entry!		(remember:  enter@potm.att.com)
=Fred