class UniqueRectangleTypeOneStrategy implements Strategy { static getTests() { [ /* * (1,1), (1,6), and (2,6) all contain [28] * (1,2) contains [248] * '4' can be */ new Test('..3179.6579.6351..615842793567314829431298657..9567...17.956...9.67835..358421976', { ! it.getCell(1, 2).hasMark(2) && ! it.getCell(1, 2).hasMark(8) } ) ] } boolean play(Board board) { def madePlay = false for (pivot in board.cells.findAll { it.markCount == 2 }) { for (pincer1 in pivot.row.findAll { it != pivot && it.marks == pivot.marks }) { for (pincer2 in pivot.col.findAll { it != pivot && it != pincer1 && it.marks == pivot.marks && ( pincer1.block == pivot.block ^ it.block == pivot.block ) }) { println "potential rectangle at $pivot, $pincer1, $pincer2" for (target in ([pincer1.row, pincer1.col].flatten().intersect([pincer2.row, pincer2.col].flatten()) - pivot)) { for (n in pivot.marks) { madePlay = target.removeMark(n, this) || madePlay } if (madePlay) { return true } } } } } false } }