MOO - the May 1999 POTM

MOO is a word-guessing game. The original form of the game was found in /usr/games on old UNIX systems - the player would guess a word and the program would tell them how many letters were in the correct position (a "BULL") and how many were in the word, but incorrectly positioned (a "COW"). Hence the name: MOO. In September of 1989, the game was turned into a POTM contest by T. Scott Kennedy (in those days it was the winner's responsibility to run the next contest). Scott won the first-ever POTM and created this one as the second-ever POTM. The current POTM doesn't use "cows" and "bulls" as defined above, but your program WILL need to guess an English word in a similar fashion.


These are the long rules for the latest POTM.  I have tried to
be as clear as possible but if there are any questions please
ask them as soon as possible so I can correct errors in the
weekly FAQ mailings.  My goal is to eliminate loopholes - if
you have a question about wording, I probably meant the statement
to have the simplest possible interpretation.

           ****** MOO - The MayDay POTM ******
      (deadline is 11:59 PM EST Saturday May 1, 1999)


==================  T H E   L O N G   R U L E S  =================

I.  YOUR PROGRAM AND YOUR TASK IN SUMMARY

    a) Your program will play a game called "MOO" which
       will try and guess an English word.  (The word
       will be "SKUNK" for this example, but you won't
       know that until your program deduces it!)

    b) On the initial execution, I'll tell you how many
       letters are in the word I'm thinking of.  Your
       program will then output a string of that length
       as your guess.  As an example, your program reads
       standard input and discovers the number 5 meaning
       that the word I'm thinking of is 5 letters long.
       Your program outputs the string "SSSSS" and exits.
       Before exiting, you may store temporary data in
       a file for use on your next execution.

    c) On subsequent executions, your program reads three
       things from standard input:  Your previous guess
       (SSSSS in this example); and the number of HITS
       and the number of MISSES.
       A "HIT" occurs when a letter in your guess
        is in the correct position with the target
       A "MISS" occurs when a letter is not in the
        target word at all.
       Your program can also read any information you
       left behind in the temporary data file in order
       to determine your next guess.  After applying
       your algrithm, your program outputs another 5
       letter string.

    d) When you guess the word (5 HITS in this case),
        you are done.  Your score is the number
        of guesses you took.

II.  A SAMPLE GAME - THE TARGET WORD IS "SKUNK"

      GUESS  HITS  MISSES  NOTE
      =====  ====  ======  ==========================
      SSSSS   1      0     since there is an S, there are no misses
                             but only the first S is a HIT
      AAAAA   0      5     no A, so all 5 are misses
      ABCDE   0      5     all misses
      KKKKK   2      0     note there are 2 Ks in SKUNK
      SKIPS   2      2     I,P are the misses, first S,K are hits
      SHARK   2      3     H,A,R are the misses
      GUPPY   0      4     The U is NOT a miss, but it's out of place
      KUSSN   0      0     no misses, but nothing in right position     
      SPUNK   4      1     all correct except for the P
      SKUNS   4      0     so close ... no misses since S is in target
      SKUNK   5      0     at last ... you got it!

III.  THE TARGET WORD

    a) will be 4 or more letters long
    b) will be less than 10 letters long
        (thus wordlength = 4,5,6,7,8, or 9 letters)
    c) will be an American English word selected at random and
        spell-checked using a standard UNIX spell-checker
    d) may contain repeated letters (or may not)
    e) may be a plural or conjugated verb form, proper name,
        or anything else that spell-checks
    f) will NOT contain apostrophes, dashes, or anything
        besides the upper case letters A through Z
    g) will be all upper-case (capitalization is not an issue)

IV.  SCORING AND WINNING - SYSTEM TESTING and THE FINALS

    a) Your score will be the number of guesses you take
        (including the final correct guess).  Low
        score is good - just in case you couldn't guess.
    b) For the finals, three different words will be used
        and your score will be the sum of the scores
        for each of the words.
    c) In the event of a tie after three words, those
        entries that are tied (and ONLY those entries)
        will be subjected to another three word playoff.
        Ties will continue to be broken in this manner until
        there is a single winner or the POTM-master gets
        tired of running tiebreakers.
    d) If an entry takes more than 10 seconds sys+user time
        to make a guess, it will receive a score of 999
        for that round and will not be allowed to continue
        on this word.  Note that this is a PER GUESS
        restriction, not a per game restriction.
    e) If an entry makes more than 100 guesses and still has
        not deduced the target word, it will receive a
        score of 999 for that word.

V.  PROGRAM DETAILS

    a) INPUT TO YOUR PROGRAM
        1) Your program must read input from standard input

        2) If only a single number is presented to your
            program, the number will be the number of
            letters in the target word.  Call it N.
            N will be presented ONLY on the initial
            execution of your program.  4 <= N <= 9

            example:  echo 6 | yourprogram

        3) On subsequent executions, your program will
            be presented with three values:

            SSSS (a string of length N which was the
                last guess made by your program)
            H (an integer 0 <= H <= N) indicating the
                number of HITS in the guess
            M (an integer 0 <= M <= N) indicating the
                number of MISSES in the guess

            example:  echo SHARK 2 3 | yourprogram

            The string will be in upper case, with
            one space separating the values.

    b) OUTPUT OF YOUR PROGRAM
        1) Your program must output one string of
            upper case letters containing your next guess
        2) The string must be N characters long, exactly.
        3) All characters must be alphabetic (A-Z)

    c) YOUR TEMP FILE
        1) It will be necessary to keep a history of
            your guesses and their results (or
            something similar) since your entry is
            re-executed with each guess.  Thus, you
            are permitted to create a file in the
            current directory/folder for such use.
        2) You are responsible for the creation, writing
            to, and reading from this file as you wish.
        3) Since many programs may be running, name your
            file something unique - your choice, but
            the name MUST begin with the characters
            TEMP.  (suggestion: TEMP.yourprogname)
        4) This file should not grow to exceed 1 Meg
        5) You need not remove the file ... I'll do that
            at the end of the target word processing
            before the next target word is started.

    d) IMPORTANT RESTRICTIONS ON YOUR PROGRAM
        1) Your program must not contain (or refer to)
           a dictionary of words
        2) Your program may not make use of the UNIX
           "spell" facility or any of its supporting
           tools or files.

=============================================================================
    The following items are standard stuff for ALL the POTMs ....
    (but they occasionally will change ... so READ 'EM!)
=============================================================================
I.  About your programming:

    a) As of 9/98 the POTM compiles and executes on and Ultra-2:

        potm potm 5.5.1 Generic_103640-17 sun4u sparc SUNW,Ultra-2
        The Ultra-2 I'm on has 128Mb physical
        memory and 350Mb virtual memory.  It runs Solaris 2.5.1.

        I must insist that your entry be contained in
        a SINGLE ASCII file, mailed in plaintext from a mailer that
        does not split long lines or insert strange characters.  
        Please help keep my life simple!!!

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

        Sun WorkShop Compiler C 4.2         (ANSI C Compiler SVID compliant)
        Sun WorkShop Compiler C++ 4.2 
        GNU compilers gcc/g++ version 2.8.1

*** C/C++ Note:  please do not use platform dependent include files
***   (like conion.h for example) since they will cause my compilation
***   to fail.  If YOU need them, consider using ifdefs so that only
***   YOUR compilation will see them ... thanks!

        PERL version 5.004
        Java, version 1.1.6 of the Java Developer Toolkit from SUN
                (as downloaded to a SPARC workstation)

        FORTRAN compilers from SUN, sorry - no PASCAL support!
        FORTRAN 90: WorkShop Compilers 4.2 10/22/96 FORTRAN 90 1.2
        FORTRAN 77: WorkShop Compilers 4.2 30 Oct 1996 FORTRAN 77 4.2

    All compilation will be done WITHOUT ANY OPTIMIZATION, and the
    standard math library will be loaded (even if not used).  While
    this might not reflect the real world, it is at least consistent.
    No makefiles are permitted, if there are special instructions
    please so indicate in your program header comments.

***      IMPORTANT:  submit early so we can resolve any
***      portability problems!!!  (Particularly if you 
***      are working in a PC environment.

       NOTE: assembly code submissions are NOT acceptable.  I must be
       the one to compile your code so I can check for cheating!

    c) if you wish to submit a shell program, Bourne, Korn, and csh
         are available ... along with any bin or /usr/bin tools that
         are available as generic Unix tools - my judgement!!!
         Also nawk, awk, dc, or whatever.
         (again - submit early in case there are version differences)

    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) Maximum size of the source code is roughly 25K characters - 
         different rules may apply for specific POTMS, and 
         comments don't count against you.

    f) Maximum size of executable is 1 Megabyte ... please!!!!

    g) sizeof(short)=2; sizeof(int)=4; sizeof(long)=4; sizeof(char)=1

    h)       a    = 0x80000000  = -2147483648
         a - 1                  =  2147483647
         a + 1                  = -2147483647
           {a} is true.  
           {a == 0} is false.

II.  The system testing ....
    
    a) mail me an entry as soon as possible - you can always submit
         another entry if you improve your solution .. but try and
         keep it down to one a week once the porting issues are 
         resolved .... please!

    b) one entry per person (or team) please.  I associate each entry
         name with an email address and a person for communication
         purposes.  Communication is fine - and encouraged - but
         everyone's code should be their own unless there is a
         stated collaboration and a single team entry.  Honor system!
         Use the POTM bulletin board at:
         http://www.messagezone.com/message.asp?BoardName=101314

    c) 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.
         (I usually will get to new mail once a night but perhaps not!)

    d) please make sure your program works on the system test problem.

    e) your program must perform the task specified within the
       specified time limit (usually 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 you can see the differences in speed between your machine 
       and mine.  All execution time measurements used for 
       tiebreakers (if any) will be measured using (sys+user) 
       time via timex (similar to time command).  
       
       ****   NOTE: A code fragment to measure elapsed time
       ****     is available from the POTM-master for the asking.

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

   Please email (not uuto, no attachments) your source code to me at:

         enter@att.com                       (preferred)
         hicinbothem@att.com                 (use only as a last resort!)

WARNING!!!  Please be sure your mailer does NOT truncate long lines
    or make any substitutions for characters.  These kinds of problems
    will prevent the program from compiling when I receive it!

    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)           */
/*  compile instructions (if other than "make entryname")    */

    NOTE:  These comments should be referenced in whatever method
    is appropriate for your programming language of choice.

    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 in a day or so)

    IMPORTANT:  If you don't hear from me within a week it may
    mean that the mail got screwed up .... please follow up with an 
    inquiry to hicinbothem@att.com ....

Thanks!  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!!!  Don't call me ... please!

WATCH THE FAQ - ESPECIALLY IN THE FIRST FEW WEEKS AS ALL THE STUPID
  ERRORS I MAKE IN THE PROBLEM STATEMENT TURN UP!!!!

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