http://ruby-china.org/topics/16256
get https://github.com/mvj3/hangman/blob/master/data/words.txt
and compile the decision tree.json
ruby compile.rb
then run the test
ruby test.rb
result
tested 8000 samples, correct rate: 99.3125%
example keys in tree.json:
"c1,3"
when "c" matches in position 1 and 3""
when a char doesn't match (the char can be extracted from the first char of keys of the same wrapping hash)
leaf values in tree.json:
1
guess succeed. no repeat chars in the word0
guess succeed. there is repeat chars in the word