This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package chess | |
// Everything from this line down to the cut is common to the 'unoptimised' and 'optimised' solutions | |
case class Location(row: Int, column: Int) | |
trait Piece { | |
def canAttackLocation(from: Location, to: Location): Boolean | |
} | |
case object Rook extends Piece { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sudoku | |
case class Location(row: Int, col: Int) { | |
def areValuesMutuallyExclusive(other: Location, size: Int) = | |
isInSameRow(other) || | |
isInSameColumn(other) || | |
isInSameSmallSquare(other, size) | |
private def isInSameRow(other: Location): Boolean = row == other.row |
NewerOlder