Word search: Difference between revisions
Content added Content deleted
m (removed overlap checks) |
m ("give up" no longer required when overlaps allowed.) |
||
Line 589: | Line 589: | ||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
Once it gets stuck it gets really stuck; there are many ways to try cramming 24,000+ words into a hole where they simply cannot fit. <br> |
|||
So after (just) 0.1s, it gives up and starts with a clean board, any longer that that proved to be counterproductive. |
|||
<lang Phix>-- |
<lang Phix>-- |
||
-- demo\rosetta\wordsearch.exw |
-- demo\rosetta\wordsearch.exw |
||
Line 597: | Line 595: | ||
string message = "ROSETTACODE" |
string message = "ROSETTACODE" |
||
sequence words, solution="", placed |
sequence words, solution="", placed |
||
constant maxt = 0.1 |
|||
atom t1 = time()+maxt |
|||
constant grid = split(""" |
constant grid = split(""" |
||
Line 656: | Line 652: | ||
end if |
end if |
||
end if |
end if |
||
if time()>t1 then return end if |
|||
end for |
end for |
||
end if |
end if |
||
Line 686: | Line 681: | ||
printf(1,"%d words loaded\n",length(words)) |
printf(1,"%d words loaded\n",length(words)) |
||
⚫ | |||
while 1 do |
|||
t1 = time()+maxt |
|||
⚫ | |||
if length(solution) then exit end if |
|||
?"stuck, retry" |
|||
end while |
|||
for x=2 to 11 do |
for x=2 to 11 do |
||
for y=4 to 31 by 3 do |
for y=4 to 31 by 3 do |
||
Line 710: | Line 700: | ||
<pre> |
<pre> |
||
24820 words loaded |
24820 words loaded |
||
"stuck, retry" |
|||
"stuck, retry" |
|||
"stuck, retry" |
|||
0 1 2 3 4 5 6 7 8 9 |
0 1 2 3 4 5 6 7 8 9 |
||
0 l o v e s d R p u n |
0 l o v e s d R p u n |