# Sudoku PointingPairStrategy

The next sudoku strategy is called a "pointing pair" which I'm going to start by generalizing into "pointing triple".Â  The strategy is pretty straightforward: if, for a given number in a given block, all the potential cells are in the same row or column, then that number cannot exist in any other block's cells of the same row or column.

A pointing pair is easier to see than a pointing triple, but necessitates making the definition slightly tighter: if a block contains only two potential cells for a given number and they're in the same row or column, then that number cannot exist in any other block's cells of the same row or column.

Of course, if you crank it down one more step (to a "pointing single"), you have the definition of a known cell (either a given or one already solved for).Â  But enough prose, on to the code:

```boolean play(Board board) {
board.blocks.each { b ->
(1..9).each { n ->
def cells = b.findAll {
it.hasMark(n)
}
if (cells.size() >= 2) {
if (cells*.col.unique().size() == 1) {
// all in one col
cells[0].col.each {
if (it.block != b) { // different block
}
}
}
if (cells*.row.unique().size() == 1) {
// all in one row
cells[0].row.each {
if (it.block != b) { // different block
}
}
}
}
}
}