Skip to content

Instantly share code, notes, and snippets.

@jezinka
Created October 17, 2018 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jezinka/024aae1c3b17347b28b48224b4420f32 to your computer and use it in GitHub Desktop.
Save jezinka/024aae1c3b17347b28b48224b4420f32 to your computer and use it in GitHub Desktop.
boolean removePairsCandidates(Cell cell, Cell[] cells) {
boolean theSameRecord = false
boolean change = false
Cell twinCell
cells.each {
if (it != cell && it.candidates == cell.candidates) {
theSameRecord = true
twinCell = it
}
}
if (theSameRecord) {
cells.findAll {
it != cell && it != twinCell && it.candidates
}.each { otherCell ->
cell.candidates.each { value ->
if (otherCell.candidates.contains(value)) {
otherCell.candidates -= value
change = true
}
}
}
}
return change
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment