class PointingPairStrategy implements Strategy { static getTests() { [ new Test( '306000000' + '000070000' + '405000000' + '0' * 9 * 6, { for (i in 4..9) { if (it.getCell(i, 2).hasMark(7)) { return false } } true } ), new Test( '306000000' + '108000000' + '405000000' + '0' * 9 * 6, { for (i in 4..9) { if (it.getCell(i, 2).hasMark(7)) { return false } } true } ), new Test( '0' * 9 * 3 + '000906000' + '030000000' + '000405000' + '0' * 9 * 3, { for (r in [1, 2, 3, 7,8, 9]) { if (it.getCell(r, 5).hasMark(3)) { return false } } true } ), new Test( '..37...5..7..5.8..1....6..45.2......8..9.4..6......9.23..5....7..4.9..6..2...74..' ) ] } boolean play(Board board) { // This is really both pointing pair and pointing triple // since we look for 2+ cells in the same row/col def madePlay = false 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 madePlay = it.removeMark(n, this) || madePlay } } } if (cells*.row.unique().size() == 1) { // all in one row cells[0].row.each { if (it.block != b) { // different block madePlay = it.removeMark(n, this) || madePlay } } } } } } madePlay } }