Documentation.
This commit is contained in:
parent
9f9a10dc40
commit
ca2f3ad63a
55
README.md
55
README.md
@ -1,11 +1,11 @@
|
|||||||
Acrostic Solver
|
Magic Word Square (aka. CrossDoku) Solver
|
||||||
===============
|
=========================================
|
||||||
|
|
||||||
Get a dictionary file (text file with one word per line) from [here](http://www.puzzlers.org/dokuwiki/doku.php?id=solving:wordlists:about:start)
|
Get a dictionary file (text file with one word per line) from [here](http://www.puzzlers.org/dokuwiki/doku.php?id=solving:wordlists:about:start)
|
||||||
and change the `WORDLIST` variable accordingly.
|
and change the `WORDLIST` variable accordingly.
|
||||||
|
|
||||||
|
|
||||||
`SQUARE` holds the square - without spaces or anything else. Just all letters one after another.
|
`SQUARE` holds the raw square - without spaces or anything else. Just all letters one after another.
|
||||||
|
|
||||||
|
|
||||||
At the bottom, the `letters` variable holds all available letters from the `SQUARE` and their amounts.
|
At the bottom, the `letters` variable holds all available letters from the `SQUARE` and their amounts.
|
||||||
@ -32,3 +32,52 @@ rem_second = check_valid("NROBE", rem_first.copy()) # get remaining letters aft
|
|||||||
result = try_solve(rem_second.copy(), ["BEACON", "ENROBE"]) # solve remaining
|
result = try_solve(rem_second.copy(), ["BEACON", "ENROBE"]) # solve remaining
|
||||||
print(result)
|
print(result)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Example
|
||||||
|
-------
|
||||||
|
|
||||||
|
For a given magic word square puzzle, i.e. letters and number of letters are given, e.g.:
|
||||||
|
|
||||||
|
```
|
||||||
|
AAACCC
|
||||||
|
CEEEEE
|
||||||
|
EEEIIL
|
||||||
|
LMRRRR
|
||||||
|
RRSSSS
|
||||||
|
TTTTUU
|
||||||
|
```
|
||||||
|
|
||||||
|
You should write it into the `SQUARE` variable like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
SQUARE="AAACCCCEEEEEEEEIILLMRRRRRRSSSSTTTTUU"
|
||||||
|
```
|
||||||
|
|
||||||
|
If you run the script, the output should look like this after a few seconds:
|
||||||
|
|
||||||
|
```
|
||||||
|
Word length: 6
|
||||||
|
{'C': 4, 'L': 2, 'R': 6, 'S': 4, 'I': 2, 'A': 3, 'E': 8, 'U': 2, 'M': 1, 'T': 4}
|
||||||
|
Diag candidate: A
|
||||||
|
Diag candidate: M
|
||||||
|
1248 candidates.
|
||||||
|
.------.
|
||||||
|
|CIRCLE|
|
||||||
|
|ICARUS|
|
||||||
|
|RAREST|
|
||||||
|
|CREATE|
|
||||||
|
|LUSTRE|
|
||||||
|
|ESTEEM|
|
||||||
|
'------'
|
||||||
|
```
|
||||||
|
|
||||||
|
First, it determines the length per word from the `SQUARE` string.
|
||||||
|
|
||||||
|
Then it lists all letters and their amount.
|
||||||
|
|
||||||
|
"Diag candidate" means, that letter has an odd amount and is on the diagonal.
|
||||||
|
|
||||||
|
"1248 candidates." means it found 1248 words in the dictionary which could fit into our square.
|
||||||
|
|
||||||
|
After a few seconds, if a solution was found, it is displayed as the solved square.
|
||||||
|
11
solve.py
11
solve.py
@ -19,7 +19,16 @@ WORDLIST="mbsingle.txt"
|
|||||||
#SQUARE="VVSETENIEDEGGEEAESPNECDINEACIDENTIDE"
|
#SQUARE="VVSETENIEDEGGEEAESPNECDINEACIDENTIDE"
|
||||||
#SQUARE="DLNDTCEGEEEGDENEAACNAALHRRTASDGRAEER"
|
#SQUARE="DLNDTCEGEEEGDENEAACNAALHRRTASDGRAEER"
|
||||||
#SQUARE="RTLOOEEOBNDNROCLOSOANELDRCEERDNSSLAE"
|
#SQUARE="RTLOOEEOBNDNROCLOSOANELDRCEERDNSSLAE"
|
||||||
SQUARE="ALOMOSLOUEREOAETEDATAGLTSCEGUERDSLTE"
|
#SQUARE="ALOMOSLOUEREOAETEDATAGLTSCEGUERDSLTE"
|
||||||
|
#SQUARE="GAREEEGULOUEEQELLMALRALSGAREECSEEGTT"
|
||||||
|
#SQUARE="ELOSSESESAANOVAPETESDEAASPERELDLTNEL"
|
||||||
|
#SQUARE="NNMESTSITANEERCSORTESELTSELESTNAIESR"
|
||||||
|
#SQUARE="OEOANERNABRMANAWENNEENIARMBELDTDRLBA"
|
||||||
|
#SQUARE="IETREAVALAEYAZRTNLEUELRIERLEDENEVADA"
|
||||||
|
#SQUARE="HEEMAHTMRICRELDORAIASPPSACASELREEDEE"
|
||||||
|
#SQUARE="ROENPTSMELTECALREESALAENCEETESTELEMO"
|
||||||
|
#SQUARE="ABLORINRALAYGNBTEANMNEEAIRNMTEEEAONR"
|
||||||
|
SQUARE="AAACCCCEEEEEEEEIILLMRRRRRRSSSSTTTTUU"
|
||||||
word_len = math.sqrt(len(SQUARE))
|
word_len = math.sqrt(len(SQUARE))
|
||||||
|
|
||||||
print("Word length: %i" % word_len)
|
print("Word length: %i" % word_len)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user