Puzzle Rules - Collisions

Synopsis

To validate if a cell value is valid within the puzzle, we have to do three checks:

  • Is the value unique within the Row
  • Is the value unique within the Column
  • Is the value unique within the Box

To begin to code this, we have to identify the steps needed to fine non-unique instances, or collisions

  • Find first cell in the current row, iterate each next-cell until we get to the last cell in the row
  • Do the same for columns, first cell in column, iterate each next cell in the column until we get to the last cell in the column
  • Finally for the box, find the first cell in the box, iterate each next cell in the box until we get to the last cell in the box.
  • Keep track of all collisions as you iterate

Code Design

  • CheckCollisionsInrow
    • getFirstCellInRow
    • getNextCellInRow
    • getLastCellInRow
  • CheckCollisionsInColumm
    • getFirstCellInColumn
    • getNextCellInColumn
    • getLastCellInColumn
  • CheckCollionsInBox
    • getFirstCellInBox
    • getNextCellInBox
    • getLastCellInBox

Take Aways

A step-by-step approach on how we recognize valid cells within the puzzle leads to an algorithm which we can code from


Complete and Continue