Simple hangman solver written in Crystal
Simple script to solve hangman.
Does the following:
Note: Syntax is nearly Ruby compatable, however tuple types need to be changed to Hash and type decleration needs to be removed from the array.
$ crystal hangman.cr
$ crystal hangman.cr --error-trace
Selecting a word from the dictionary at random...
The word is --------- (9 of 9 digits remaining)
Solving using simple algorithm...
Trying with e...
The word is ------e-- (8 of 9 digits remaining)
Trying with i...
The word is ------e-- (8 of 9 digits remaining)
Trying with a...
The word is --a---e-- (7 of 9 digits remaining)
...
Trying with y...
The word is crac-less (1 of 9 digits remaining)
Trying with g...
The word is crac-less (1 of 9 digits remaining)
Trying with b...
The word is crac-less (1 of 9 digits remaining)
Trying with f...
The word is crac-less (1 of 9 digits remaining)
Trying with v...
The word is crac-less (1 of 9 digits remaining)
Trying with k...
The word is crackless (0 of 9 digits remaining)
Solved after 22 iterations with simple algorithm
Solving using improved algorithm...
Trying with e...
The word is ------e-- (8 of 9 digits remaining)
Trying with s...
The word is ------ess (6 of 9 digits remaining)
Trying with n...
The word is ------ess (6 of 9 digits remaining)
Trying with l...
The word is -----less (5 of 9 digits remaining)
Trying with r...
The word is -r---less (4 of 9 digits remaining)
Trying with t...
The word is -r---less (4 of 9 digits remaining)
Trying with a...
The word is -ra--less (3 of 9 digits remaining)
Trying with c...
The word is crac-less (1 of 9 digits remaining)
Trying with k...
The word is crackless (0 of 9 digits remaining)
Solved after 10 iterations with improved algorithm
Crystal 0.23.1 (2017-09-08) LLVM 4.0.1
/usr/local/share/dict
as is default on macOS