Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 723c4c3

Browse files
committed
style: format and comments
Signed-off-by: Sgiath <[email protected]>
1 parent 09e7630 commit 723c4c3

File tree

2 files changed

+48
-41
lines changed

2 files changed

+48
-41
lines changed

lib/2024/day16.ex

Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,44 @@ defmodule AdventOfCode.Year2024.Day16 do
1212

1313
@impl AdventOfCode
1414
def test_input do
15-
"""
16-
###############
17-
#.......#....E#
18-
#.#.###.#.###.#
19-
#.....#.#...#.#
20-
#.###.#####.#.#
21-
#.#.#.......#.#
22-
#.#.#####.###.#
23-
#...........#.#
24-
###.#.#####.#.#
25-
#...#.....#.#.#
26-
#.#.#.###.#.#.#
27-
#.....#...#.#.#
28-
#.###.#.#.#.#.#
29-
#S..#.....#...#
30-
###############
31-
"""
32-
33-
# """
34-
# #################
35-
# #...#...#...#..E#
36-
# #.#.#.#.#.#.#.#.#
37-
# #.#.#.#...#...#.#
38-
# #.#.#.#.###.#.#.#
39-
# #...#.#.#.....#.#
40-
# #.#.#.#.#.#####.#
41-
# #.#...#.#.#.....#
42-
# #.#.#####.#.###.#
43-
# #.#.#.......#...#
44-
# #.#.###.#####.###
45-
# #.#.#...#.....#.#
46-
# #.#.#.#####.###.#
47-
# #.#.#.........#.#
48-
# #.#.#.#########.#
49-
# #S#.............#
50-
# #################
51-
# """
15+
[
16+
"""
17+
###############
18+
#.......#....E#
19+
#.#.###.#.###.#
20+
#.....#.#...#.#
21+
#.###.#####.#.#
22+
#.#.#.......#.#
23+
#.#.#####.###.#
24+
#...........#.#
25+
###.#.#####.#.#
26+
#...#.....#.#.#
27+
#.#.#.###.#.#.#
28+
#.....#...#.#.#
29+
#.###.#.#.#.#.#
30+
#S..#.....#...#
31+
###############
32+
""",
33+
"""
34+
#################
35+
#...#...#...#..E#
36+
#.#.#.#.#.#.#.#.#
37+
#.#.#.#...#...#.#
38+
#.#.#.#.###.#.#.#
39+
#...#.#.#.....#.#
40+
#.#.#.#.#.#####.#
41+
#.#...#.#.#.....#
42+
#.#.#####.#.###.#
43+
#.#.#.......#...#
44+
#.#.###.#####.###
45+
#.#.#...#.....#.#
46+
#.#.#.#####.###.#
47+
#.#.#.........#.#
48+
#.#.#.#########.#
49+
#S#.............#
50+
#################
51+
"""
52+
]
5253
end
5354

5455
@pallete %{
@@ -74,6 +75,10 @@ defmodule AdventOfCode.Year2024.Day16 do
7475
search(map, head)
7576
end
7677

78+
@doc """
79+
This actually works but takes a VERY long time to finish, probably all the list flatten and
80+
sorting. Don't have time to investigate further - work and stuff :)
81+
"""
7782
def search(map, [{{x, y}, {vx, vy}, score, visitied} | heads]) do
7883
new_heads =
7984
case Grid.get(map, {x, y}) do
@@ -100,11 +105,12 @@ defmodule AdventOfCode.Year2024.Day16 do
100105
if is_integer(new_heads) do
101106
new_heads
102107
else
103-
heads = [new_heads | heads]
104-
|> List.flatten()
105-
|> Enum.sort_by(&elem(&1, 2))
108+
heads =
109+
[new_heads | heads]
110+
|> List.flatten()
111+
|> Enum.sort_by(&elem(&1, 2))
106112

107-
search(map, heads)
113+
search(map, heads)
108114
end
109115
end
110116

test/2024/day16_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ defmodule AdventOfCode.Year2024.Day16.Test do
55

66
doctest AdventOfCode.Year2024.Day16
77

8+
@tag skip: "not implemented"
89
test "part 1" do
910
[input1, input2] = Day16.test_input()
1011

0 commit comments

Comments
 (0)