Skip to content

Commit f14ece9

Browse files
committed
Day 4: part 1 WIP
1 parent baf40cb commit f14ece9

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/main/scala/Day04.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ object Day04:
3939
....
4040
....
4141
*/
42-
def topLeftPositions(w: Word)(p: Pos): List[Pos] =
43-
List.range(start = p.col, end = p.col + w.length).map(col => Pos(p.row, col))
42+
def topLeftPositions(w: Word)(from: Pos): List[Pos] =
43+
List.range(start = from.col, end = from.col + w.length).map(col => Pos(from.row, col))
4444

4545
def wordCheckTopLeft(w: Word, store: StoreGrid): WordCheckResult = wordCheck(topLeftPositions, w, store)
4646

@@ -50,8 +50,8 @@ object Day04:
5050
.M..
5151
X...
5252
*/
53-
def ascDiagonalPositions(w: Word)(p: Pos): List[Pos] =
54-
List.range(start = 0, end = w.length).reverse.map(i => Pos(row = i + p.row, col = w.length - i - 1 + p.col))
53+
def ascDiagonalPositions(w: Word)(from: Pos): List[Pos] =
54+
List.range(start = 0, end = w.length).reverse.map(i => Pos(row = i + from.row, col = w.length - i - 1 + from.col))
5555

5656
def wordCheckAscDiagonal(w: Word, store: StoreGrid): WordCheckResult = wordCheck(ascDiagonalPositions, w, store)
5757

@@ -61,8 +61,8 @@ object Day04:
6161
..A.
6262
...S
6363
*/
64-
def descDiagonalPositions(w: Word)(p: Pos): List[Pos] =
65-
List.range(start = 0, end = w.length).map(i => Pos(row = i + p.row, col = i + p.col))
64+
def descDiagonalPositions(w: Word)(from: Pos): List[Pos] =
65+
List.range(start = 0, end = w.length).map(i => Pos(row = i + from.row, col = i + from.col))
6666

6767
def wordCheckDescDiagonal(w: Word, store: StoreGrid): WordCheckResult = wordCheck(descDiagonalPositions, w, store)
6868

src/test/scala/Day04Suite.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Day04Suite extends ScalaCheckSuite:
3434

3535
test("topLeftPositions example"):
3636
assertEquals(
37-
Grid.topLeftPositions(Word("XYZ"))(Pos(row = 2, col = 4)),
37+
Grid.topLeftPositions(Word("XYZ"))(from = Pos(row = 2, col = 4)),
3838
List(
3939
Pos(row = 2, col = 4),
4040
Pos(row = 2, col = 5),
@@ -44,7 +44,7 @@ class Day04Suite extends ScalaCheckSuite:
4444

4545
test("ascDiagonalPositions example"):
4646
assertEquals(
47-
Grid.ascDiagonalPositions(Word("XYZ"))(Pos(row = 2, col = 4)),
47+
Grid.ascDiagonalPositions(Word("XYZ"))(from = Pos(row = 2, col = 4)),
4848
List(
4949
Pos(row = 4, col = 4),
5050
Pos(row = 3, col = 5),
@@ -54,7 +54,7 @@ class Day04Suite extends ScalaCheckSuite:
5454

5555
test("descDiagonalPositions example"):
5656
assertEquals(
57-
Grid.descDiagonalPositions(Word("XYZ"))(Pos(row = 2, col = 4)),
57+
Grid.descDiagonalPositions(Word("XYZ"))(from = Pos(row = 2, col = 4)),
5858
List(
5959
Pos(row = 2, col = 4),
6060
Pos(row = 3, col = 5),

0 commit comments

Comments
 (0)