# If piece is efficiently placed, try the next pentomino # (tend to cluster them towards origin) if (!exceeds_hole_count($index)) { solve ($index+1); } #### ($x, $y) = next_position_accross ( $x, $y ); # if the pentomino has run off the board, backup # and try again. (n_p_a returns (-1,-1) in this case if ($x < 0) { return } $SOLVE_COUNT++; # Start the piece well out onto the board if (($x+$y) < $index) { next }; #### # Optimization by which piece never starts too far out on board. if (($x+$y) > (2*$index)) { print 'b'; next }; if ($y > $index) { print 'y'; return }; last;