alex1770 / wordle

Finding optimal play in the game of wordle
MIT License
54 stars 16 forks source link

Assertion error if hidden list contains a word with 4 or more equal characters #9

Open JustAnotherArchivist opened 1 month ago

JustAnotherArchivist commented 1 month ago

I was trying to run this with a word list that includes Roman numerals, some of which contain four equal letters, e.g. xxxix. This causes wordle to crash with an assertion error:

$ echo xxxix >test
$ ./wordle -h test
Commit 8fd3f1bdf884 2024-03-06 00:27:32 +0000
Initialising...
wordle: wordle.cpp:390: void inithardmodebitvectors(): Assertion `mult[a]<4' failed.
alex1770 commented 1 month ago

Yes, sorry about that unfriendly error message. It uses an internal coding of two bits per letter in order to pack the letter counts into 64 bits (26x2≤64), so it can handle letters that occur up to three times. This works for the original wordlist as that doesn't contain any words with ≥4 of the same letter, and it just rejects wordlists with ≥4 of the same letter. It wouldn't be hard to adapt this to cater for some letters (up to 12=64-26x2 of them) that occur ≥4 times and still pack this into 64 bits. Or could take a slight efficiency hit and go to 128 bits for the counts.