Class NRooks

java.lang.Object
edu.cmu.tetrad.search.utils.NRooks

public class NRooks extends Object

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
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static ArrayList<int[]>
    nRooks(boolean[][] allowablePositions)
    Solves the N-Rooks problem for the given board or allowable positions.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • NRooks

      public NRooks()
  • Method Details

    • nRooks

      public static ArrayList<int[]> nRooks(boolean[][] allowablePositions)
      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.