The goal of this challenge is to write a program able to guess a word in the smallest possible number of attempts. It is based on the concept of the Lingo TV show (http://en.wikipedia.org/wiki/Lingo_(U.S._game_show)).
Given a word length passed as the first argument on its command line, the player program disposes of five attempts to guess the word by writing a guess on its standard output followed by a single
After a guess is made, the program receives a string on its standard input, also followed by a single
The string has the same length as the word to guess and is comprised of a sequence of the following characters:
X: which means that the given letter is not present in the word to guess
?: which means that the given letter is present in the word to guess, but at another location
O: which means that the letter at this location has been correctly guessed
For example, if the word to guess is
dents, and the program sends the word
dozes, it will receive
s are correct,
e is misplaced, and
z are not present.
Be careful that if a letter is present more times in the guessing attempt than in the word to guess, it will not be marked as
O more times than the number of occurences of the letter in the word to guess.
For example, if the word to guess is
cozies and the program sends
tosses, it will receive
XOXXOO because there is only one
s to locate.
Words are chosen from an english word list. If the word sent by the program is not a valid word of the correct length, the attempt is considered as an automatic failure and only
X's are returned.
The player program should assume that a file named
wordlist.txt and containing one word per line is present in the current working directory, and can be read as necessary.
Guesses should only be comprised of alphabetic low-case characters (
No other network or file operations are allowed for the program.
The game ends when a string only comprised of
O is returned or after the program has made 5 attempts and was not able to guess the word.
The score of a game is given by the given formula:
score = 100 * (6 - number_of_attempts)
So if the word is correctly guessed on the first try, 500 points are given. The last try is worth 100 points.
Failure to guess the word grants zero points.
Player programs will be evaluated by trying to have them guess 100 random words for each word length between 4 and 13 characters inclusively.
Random word selection will be done by advance so all entries will have to guess the same words.
The winning program, and accepted answer, will be the one to reach the highest score.
Programs will be run in an Ubuntu virtual machine, using the code at https://github.com/noirotm/lingo. Implementations in any language are accepted as long as reasonable instructions to compile and/or run them are provided.
I'm providing a few test implementations in ruby in the git repository, feel free to take inspiration from them.
This question will be periodically updated with rankings for published answers so challengers can improve their entries.
The official final evaluation will take place on the 1st of July.
Entries can now assume the presence of
wordlistN.txt files to speed up reading the word list for the current word length for N between 4 and 13 inclusively.
For example, there is a
wordlist4.txt file containing all four letter words, and
wordlist10.txt containing all ten letter words, and so on.
First round results
At the date of 2014-07-01, three entries have been submitted, with the following results:
4 5 6 7 8 9 10 11 12 13 Total ./chinese-perl-goth.pl 8100 12400 15700 19100 22100 25800 27900 30600 31300 33600 226600 java Lingo 10600 14600 19500 22200 25500 28100 29000 31600 32700 33500 247300 ./edc65 10900 15800 22300 24300 27200 29600 31300 33900 33400 33900 262600 ** Rankings ** 1: ./edc65 (262600) 2: java Lingo (247300) 3: ./chinese-perl-goth.pl (226600)
All entries performed consistently, with a clear winner, being @edc65's C++'s entry.
All contestants are pretty awesome. I have been unable so far to even beat @chinese-perl-goth.
If more entries are submitted, another evaluation will take place. Current entries can also be improved if you feel like you can do better.