From 7ef665a545ca70bfe180ec2bfb0f7de2a58e316e Mon Sep 17 00:00:00 2001 From: Rebecca Le Date: Thu, 19 Dec 2024 00:35:06 +0800 Subject: [PATCH] 2024 day 18, part 1 It's super slow but I'll wait for optimization until I see what part 2 is... --- README.md | 4 +- lib/y2024/README.md | 3 +- lib/y2024/day18.ex | 62 ++++++++++++++++++++++++++++++ lib/y2024/input/day18.txt | Bin 0 -> 19749 bytes test/y2024/day18_test.exs | 14 +++++++ test/y2024/input/day18/sample.txt | Bin 0 -> 122 bytes 6 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 lib/y2024/day18.ex create mode 100644 lib/y2024/input/day18.txt create mode 100644 test/y2024/day18_test.exs create mode 100644 test/y2024/input/day18/sample.txt diff --git a/README.md b/README.md index 16d8f5f..312f868 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ My Elixir solutions for [Advent of Code](https://adventofcode.com/) (all years). -

451 stars

-

32 stars
+

452 stars

+

33 stars
44 stars
50 stars
46 stars
diff --git a/lib/y2024/README.md b/lib/y2024/README.md index 042693e..bc2689c 100644 --- a/lib/y2024/README.md +++ b/lib/y2024/README.md @@ -2,7 +2,7 @@ My Elixir solutions for [Advent of Code 2024](https://adventofcode.com/2024). -32 stars +33 stars ## Benchmarks @@ -46,4 +46,5 @@ day 15, part 1 5.06 197.80 ms ±0.60% 197.59 ms 201. day 16, part 1 12.91 77.43 ms ±5.49% 77.14 ms 86.71 ms day 16, part 2 13.07 76.51 ms ±5.00% 76.09 ms 85.69 ms day 17, part 1 45.64 K 21.91 μs ±15.81% 21.17 μs 37.50 μs +day 18, part 1 0.27 3.73 s ±0.03% 3.73 s 3.73 s ``` diff --git a/lib/y2024/day18.ex b/lib/y2024/day18.ex new file mode 100644 index 0000000..dcad4cc --- /dev/null +++ b/lib/y2024/day18.ex @@ -0,0 +1,62 @@ +defmodule Y2024.Day18 do + use Advent.Day, no: 18 + + alias Advent.PathGrid + + def part1(bytes, size \\ 50, byte_num \\ 1024) do + fallen = Enum.take(bytes, byte_num) + + graph = + Enum.reduce(fallen, empty_grid({0, 0}, {size, size}), fn coord, graph -> + PathGrid.add_wall(graph, coord) + end) + + length(Graph.get_shortest_path(graph, {0, 0}, {size, size})) - 1 + end + + # @doc """ + # iex> Day18.part2("update or delete me") + # "update or delete me" + # """ + # def part2(input) do + # input + # end + + @doc """ + iex> Day18.parse_input("5,4\\n4,2\\n4,5\\n3,0\\n") + [{5,4}, {4,2}, {4,5}, {3,0}] + """ + def parse_input(input) do + input + |> String.split("\n", trim: true) + |> Enum.map(fn line -> + [left, right] = String.split(line, ",", parts: 2) + {String.to_integer(left), String.to_integer(right)} + end) + end + + @doc """ + Create a completely empty path grid of a given size. + """ + def empty_grid({from_row, from_col}, {to_row, to_col}) do + Enum.reduce(from_row..to_row, Graph.new(vertex_identifier: & &1), fn row, graph -> + Enum.reduce(from_col..to_col, graph, fn col, graph -> + graph = Graph.add_vertex(graph, {row, col}, :floor) + + [{row - 1, col}, {row, col - 1}] + |> Enum.reduce(graph, fn neighbour, graph -> + if PathGrid.floor?(graph, neighbour) do + graph + |> Graph.add_edge({row, col}, neighbour) + |> Graph.add_edge(neighbour, {row, col}) + else + graph + end + end) + end) + end) + end + + def part1_verify, do: input() |> parse_input() |> part1(70, 1024) + # def part2_verify, do: input() |> parse_input() |> part2() +end diff --git a/lib/y2024/input/day18.txt b/lib/y2024/input/day18.txt new file mode 100644 index 0000000000000000000000000000000000000000..3e2a6e6c4678cfa594475aad255701457fb40135 GIT binary patch literal 19749 zcmV(jK=!`?M@dveQdv+`0CLtg3h<%Rz!AlGM1zgZgvp$!63KsBqs`yZLT zoAORuCnZ{Q{l7hwStGysB;l!RaBnB|Y3L?tP@nj7@qrQlI`#9$VZlV97XAlC7uWx* zym%?M6_(AJS>!VMv|XtX1~di1a-D@?f|@d)M^=C0lT@I-YU611gOD8%Cow^Y#i3d8 z5U@y1-z3mkCM04uf5A9kvZx}8(zOlnXLHTmez)lPJ(|`yM11yH|?Sj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2=J{ShM>$udORXthKGI2pw3NaWo;q&HS4a>cgTuC~^Z@NO}km%KZj}9EA z9d)DhMu45^4(Xb@03%zeOQ1E0FUGB$s{CL&hH(>#e2U_50G&CrJLgktU|RHZE!#Gb z*^PKWniHx~x!HsTs4tN|bd?CNt(}#E#h!o` z=a8uVkC*N+pG_ZpK|ixP*q%)QlJeOwx-0=o__`}^NY+4DR!-ld|6`KHRzR~Oz4Tt7 zxK_d)-mNz7r2V<=*3OYyqXd@ShxZ=N;Prdq)czZyMc-LmPswPwt8aCenNjRGG7(lE zV#P$A&RN!ddGpO@Kz#ScxT1fR@6_U*;aE%H=>bpaq{ena7eJCCEL7^Vy*9s^(bubF z6#%SMvfSQ6BmzeJp=;NGd~UtDN&o+GP~Rp;|v&nI@83ZSy7*fh9UkE zV@DH-uJU@AsZp->076crfab*A3Pxwx?q(UN6zdSb_^(CA(<)nc|msUvYFE3OXD&kPQ{eG9P%tWzAXtAxx+dewAW*NSqS~6!P zh$AI)RtH3n&UCZ+1uARz!|25R&lsvc88%l+$#iIn=MBnve!~=+I)v%bZ Day18.parse_input() |> Day18.part1(6, 12) == 22 + end + + test "verification, part 1", do: assert(Day18.part1_verify() == 436) + # test "verification, part 2", do: assert(Day18.part2_verify() == "update or delete me") + + def test_data(), do: File.read!("test/y2024/input/day18/sample.txt") +end diff --git a/test/y2024/input/day18/sample.txt b/test/y2024/input/day18/sample.txt new file mode 100644 index 0000000000000000000000000000000000000000..d4326b148df9e789cfe3dd0dd7d94608fb0fa376 GIT binary patch literal 122 zcmV-=0EPbmM@dveQdv+`0CVA3%TvWi!Cl>&u(Nz3cZjNPf{xr51e5Ote+Q7iNMcxd zW@vlsv{d(_c(?RgxKF0D>ITf?u{Q(^pxcs7B?|GGMh>AU%3SRiZudF}5%X%I8h5CO cNCbo1WxGJ}E`GNCmW6ZW4Y4|fqU<-AcER~O5dZ)H literal 0 HcmV?d00001