Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def peers(row: Int, col: Int): List[(Int, Int)] = {
- val rowStart = (row % 3) match {
- case 0 => row
- case 1 => row-1
- case 2 => row-2
- }
- val colStart = (col % 3) match {
- case 0 => col
- case 1 => col-1
- case 2 => col-2
- }
- val box = (for (i <- rowStart to rowStart + 2 ; j <- colStart to colStart + 2)
- yield (i, j)).toList
- val unfiltered =
- ((for (i <- 0 to 8) yield (row, i)) ++ (for (j <- 0 to 8) yield (j, col))++ box).toList
- (unfiltered filter (x => x != (row, col))).toSet.toList //removes duplicates
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement