You want to use the regexp machine to control the backtracking
when searching for a Hamiltonian path? That wouldn't be
something I would do, unless to as a 'proof of concept' or so.
I'd probably go for a recursive subroutine, although there's
the possibility for an iterative solution as well.
As for the N-queens problem, it basically is the recursive
subroutine, except molded to fit the regexp syntax. And the
only reason I did this exercise was "because I can". I don't
think I would easily do such a thing in production code.
Abigail