NAME

guessnumber - a number guessing game


SYNOPSIS

guessnumber [ -r 'radix_string' ] [ -d 'n_digits' ]


DESCRIPTION

There are two players in the game of guessing numbers, one selecting a number and counting matches, the other guessing the number. This program plays the role of the former, while the user plays the role of the latter. The program first generates a 4-digit random number whose digits are all distinct. This number is kept secrete from the user. Each time the user guesses a 4-digit number, the program counts the number of digits whose positions coincide with those in the answer, and report this number as A. It also counts the number of digits which appear in the answer but have different positions, and report this number as B. For example, if the answer is ``3085'' and the guess is ``8057'', then the computer reports ``1A2B'' since ``0'' counts as an A, while ``8'' and ``5'' count as B's. The game continues until the user gets the answer correctly, namely obtaining a ``4A0B'' report from the program.

This program is a perl script. You can run it by typing perl guessnumber and read its documentation by typing perldoc guessnumber. Once inside, type :h to get help. (The html page is generated by typing pod2html guessnumber and therefore is pretty much the same as, possibly older than, the document embedded in the program.)


OPTIONS

-r 'radix_string'
Use radix_string as the radix string instead of '0123456789'. If radix_string is a one-digit or two-digit number, the first radix_string characters of '0123456789abcdef...xyz' is used.

-d 'n_digits'
Generate n_digits-digit numbers instead of 4-digit numbers.


LICENSE

This code is distributed under the GNU General Public License


AUTHOR

Chao-Kuei Hung ckhung AT cyut DOT edu DOT tw

The latest version is available at: http://www.cyut.edu.tw/~ckhung/p/toy/guessnumber