Package edu.cmu.tetrad.search.utils
Class NRooks
java.lang.Object
edu.cmu.tetrad.search.utils.NRooks
Returns row positions for placing rooks for an n x n matrix so the rooks cannot attach each other, with a given boolean[][] specification of where rooks are allowed to be placed. For this spec, spec[i][j] = true iff a rook can be placed there.
Had some help from ChatGPT for this.
- Version:
- $Id: $Id
- Author:
- josephramsey, ChatGPT
-
Method Summary
-
Method Details
-
nRooks
Solves the N-Rooks problem for the given board or allowable positions.- Parameters:
allowablePositions
- A matrix of allowable rook positions, should be true iff the position is allowable.- Returns:
- A list of row indices for where to place the rooks for each solution.
-