On Tue, Jun 6, 2017 at 4:09 AM, 'Mike Day' via Programming
<[email protected]> wrote:
> if I were developing a solver for solitaire,  I'd include a variable as a
> parameter for
>
> the size of problem,  eg the number of rows,  1 2 3 etc,  or the ravel-size,
> eg 1 3 6 etc.

You had not specified that previously, but note that implementing this
is a simple change.

For example:

flip=: [ ~: i.@#@[ e. ]

solitaire=:3 :0
  5 solitaire y
:
  path=. (y flip~ 1#~ 0 0.5 0.5 p. x) search i.0 3
  if. #path do. path else. 'No solution' end.
)

That said, the 'No solution' cases require a time-consuming exhaustive
search, and in the few tests I did with sizes other than 5, I was
hitting no solution cases. It's time consuming because each
permutation of moves that leads to a final board state gets tested.

Still, I hope this helps,

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to