Talk:Diophantine linear system solving: Difference between revisions

ps guessing
No edit summary
(ps guessing)
 
(One intermediate revision by the same user not shown)
Line 131:
 
--[[User:Plinio|Plinio]] ([[User talk:Plinio|talk]]) 07:33, 27 February 2022 (UTC)
 
: Oh, don't worry at all about disturbing people, there's well over 5,000 talk pages on this site and most of us only pay attention to a tiny fraction of them. Anyway, here's a quick little ditty I knocked up to show a possible alternative approach, probably much saner and certainly exponentially easier to tweak and adjust.
<pre>
constant msprob = {{1,{},{1,2,3,4,5,7}},
{3,{4,5,7},{9,10,11}},
{2,{5,10,11},{6,8,12}}}
sequence field = repeat(0,12)
 
procedure solve(integer tdx=1)
if tdx>length(msprob) then
?{field,find_all(1,field,true)}
else
{integer tgt, sequence fixed, sequence play} = msprob[tdx]
tgt -= sum(extract(field,fixed))
if tgt<0 or tgt>length(play) then return end if
field = reinstate(field,play,repeat(0,length(play)-tgt)&repeat(1,tgt))
bool found = true
while found do
solve(tdx+1)
found = false
integer nxt = play[$]
for idx=length(play)-1 to 1 by -1 do
integer prv = play[idx]
if field[prv]=0 and field[nxt]!=0 then
field[prv] = 1
field[nxt] = 0
found = true
sequence slamright = play[idx+2..$]
field = reinstate(field,slamright,sort(extract(field,slamright)))
exit
end if
nxt = prv
end for
end while
end if
end procedure
solve()
</pre>
output
<pre>
{{0,0,0,0,0,0,1,0,0,1,1,0},{7,10,11}}
{{0,0,0,0,0,0,1,0,1,0,1,1},{7,9,11,12}}
{{0,0,0,0,0,0,1,1,1,0,1,0},{7,8,9,11}}
{{0,0,0,0,0,1,1,0,1,0,1,0},{6,7,9,11}}
{{0,0,0,0,0,0,1,0,1,1,0,1},{7,9,10,12}}
{{0,0,0,0,0,0,1,1,1,1,0,0},{7,8,9,10}}
{{0,0,0,0,0,1,1,0,1,1,0,0},{6,7,9,10}}
{{0,0,0,0,1,0,0,0,1,0,1,0},{5,9,11}}
{{0,0,0,0,1,0,0,0,1,1,0,0},{5,9,10}}
{{0,0,0,1,0,0,0,0,0,1,1,0},{4,10,11}}
{{0,0,0,1,0,0,0,0,1,0,1,1},{4,9,11,12}}
{{0,0,0,1,0,0,0,1,1,0,1,0},{4,8,9,11}}
{{0,0,0,1,0,1,0,0,1,0,1,0},{4,6,9,11}}
{{0,0,0,1,0,0,0,0,1,1,0,1},{4,9,10,12}}
{{0,0,0,1,0,0,0,1,1,1,0,0},{4,8,9,10}}
{{0,0,0,1,0,1,0,0,1,1,0,0},{4,6,9,10}}
{{0,0,1,0,0,0,0,0,1,1,1,0},{3,9,10,11}}
{{0,1,0,0,0,0,0,0,1,1,1,0},{2,9,10,11}}
{{1,0,0,0,0,0,0,0,1,1,1,0},{1,9,10,11}}
</pre>
:I don't think that misses any, but I could be wrong. Enjoy. --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 12:12, 27 February 2022 (UTC)
:PS There are of course many points in the game of minesweeper where you are forced to make a guess, the start screen being one, and this example being another.<br> The results suggest 9 is the most likely to be a mine and any of {1,2,3} your best gambol. --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 12:45, 27 February 2022 (UTC)
7,795

edits