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 = 100
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: 1
Attempts: 3
Number of words: 25
Number of words: 25


1 e s o d u m a h d R
0 1 2 3 4 5 6 7 8 9

2 z n o u g h t y O g
3 i b a p o s c S o r
1 p s a s l a n t o R
4 r u f m e E s e g e
2 r p a d d a O r g w
5 y t T a y r r r r i
3 e i l i e S e n o n
6 h T u r d o k o o g
4 h l r E v z i s i b
7 p A u t p l h y s e
5 t s T m f h a l b o
8 r C b s e l e a O s
6 e T i a s g u r a n
9 o o i a l e g m r D
7 A t i e g s a v C d
10 p b o b e t s E e b
8 t n l e n d i O l a
bispore [10, 2] to [4, 8] dumah [1, 4] to [1, 8]
9 t f d i m v r D a g
porphyrize [10, 1] to [1, 1] melda [9, 8] to [5, 4]
10 s n o o g E h u g e
bobet [10, 2] to [10, 6] greiges [2, 10] to [8, 10]
aslant [1, 3] to [1, 8] fleshing [9, 2] to [2, 9]
hoyman [7, 7] to [2, 2] noughty [2, 2] to [2, 8]
bondage [4, 10] to [10, 10] razed [6, 8] to [2, 4]
sorgo [7, 9] to [3, 9] tutees [5, 2] to [10, 7]
insulin [9, 4] to [3, 10] goons [10, 5] to [10, 1]
perky [3, 4] to [7, 8] osc [3, 5] to [3, 7]
ether [6, 1] to [2, 1] sagged [4, 8] to [9, 3]
tbo [7, 4] to [9, 2] tub [5, 2] to [3, 2]
viva [9, 6] to [6, 9] slips [5, 2] to [1, 2]
gela [9, 7] to [9, 4] arb [8, 8] to [10, 10]
via [4, 5] to [2, 3] faint [5, 5] to [9, 1]
ors [6, 9] to [4, 7] hll [7, 7] to [9, 5]
mitt [5, 4] to [8, 1] huge [10, 7] to [10, 10]
doko [6, 5] to [6, 8] udos [1, 5] to [1, 2]
brad [5, 9] to [8, 6] one [3, 9] to [3, 7]
tra [7, 4] to [5, 4] utp [7, 3] to [7, 5]
rid [4, 3] to [2, 5] lag [8, 9] to [10, 9]
bfa [3, 2] to [5, 4] cyd [3, 7] to [1, 9]
mid [9, 5] to [9, 3] lie [3, 3] to [3, 5]
eme [8, 7] to [10, 9]
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>