Word search: Difference between revisions
Content added Content deleted
Line 1,313: | Line 1,313: | ||
end |
end |
||
function wordmatrix(filename) |
function wordmatrix(filename, usepropernames = true) |
||
words = [lowercase(line) for line in readlines(filename) |
words = [lowercase(line) for line in readlines(filename) |
||
if match(r"^[a-zA-Z]+$", line) != nothing && |
if match(r"^[a-zA-Z]+$", line) != nothing && (usepropernames || |
||
length(line) >= minwordsize && length(line) <= ncols] |
match(r"^[a-z]", line) != nothing) && length(line) >= minwordsize && length(line) <= ncols] |
||
n = |
n = 1000 |
||
for i in 1:n |
for i in 1:n |
||
grid = LetterGrid() |
grid = LetterGrid() |
||
Line 1,336: | Line 1,336: | ||
end |
end |
||
end |
end |
||
throw("Failed to place words after n attempts") |
throw("Failed to place words after $n attempts") |
||
end |
end |
||
Line 1,410: | Line 1,410: | ||
end |
end |
||
printresult(wordmatrix("words.txt")) |
printresult(wordmatrix("words.txt", false)) |
||
</lang>{{output}}<pre> |
</lang>{{output}}<pre> |
||
Attempts: |
Attempts: 3 |
||
Number of words: 25 |
Number of words: 25 |
||
0 1 2 3 4 5 6 7 8 9 |
|||
2 z n o u g h t y O g |
|||
1 p s a s l a n t o R |
|||
2 r p a d d a O r g w |
|||
3 e i l i e S e n o n |
|||
4 h l r E v z i s i b |
|||
5 t s T m f h a l b o |
|||
6 e T i a s g u r a n |
|||
7 A t i e g s a v C d |
|||
8 t n l e n d i O l a |
|||
9 t f d i m v r D a g |
|||
10 s n o o g E h u g e |
|||
aslant [1, 3] to [1, 8] fleshing [9, 2] to [2, 9] |
|||
bondage [4, 10] to [10, 10] razed [6, 8] to [2, 4] |
|||
insulin [9, 4] to [3, 10] goons [10, 5] to [10, 1] |
|||
ether [6, 1] to [2, 1] sagged [4, 8] to [9, 3] |
|||
viva [9, 6] to [6, 9] slips [5, 2] to [1, 2] |
|||
via [4, 5] to [2, 3] faint [5, 5] to [9, 1] |
|||
mitt [5, 4] to [8, 1] huge [10, 7] to [10, 10] |
|||
brad [5, 9] to [8, 6] one [3, 9] to [3, 7] |
|||
rid [4, 3] to [2, 5] lag [8, 9] to [10, 9] |
|||
mid [9, 5] to [9, 3] lie [3, 3] to [3, 5] |
|||
sea [4, 8] to [2, 6] sow [4, 8] to [2, 10] |
|||
zero [4, 6] to [1, 9] air [7, 7] to [9, 7] |
|||
asp [1, 3] to [1, 1] |
|||
</pre> |
</pre> |
||