We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4be031b commit adb6e4cCopy full SHA for adb6e4c
day11.sc
@@ -2,16 +2,10 @@ import common.loadPackets
2
import scala.annotation.tailrec
3
4
case class Point(x: Int, y: Int) {
5
- def neighbors = Set(
6
- copy(x = x - 1),
7
- copy(x = x - 1, y = y - 1),
8
- copy(y = y - 1),
9
- copy(x = x + 1, y = y - 1),
10
- copy(x = x + 1),
11
- copy(x = x + 1, y = y + 1),
12
- copy(y = y + 1),
13
- copy(x = x - 1, y = y + 1)
14
- )
+ def neighbors =
+ (for (dx <- -1 to 1;
+ dy <- -1 to 1)
+ yield copy(x = x + dx, y = y + dy)).toSet - this
15
}
16
17
type State = Map[Point, Int]
0 commit comments