Skip to content

Commit 5ea283b

Browse files
committed
Fix slice range for elixir v1.16 compatibility
1 parent 2dc3ac0 commit 5ea283b

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

01/sol.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ defmodule Day01 do
4545

4646
def find_first_matching_value(string, map) do
4747
case check_matching(string, map) do
48-
nil -> find_first_matching_value(String.slice(string, 1..-1), map)
48+
nil -> find_first_matching_value(String.slice(string, 1..-1//1), map)
4949
val -> val
5050
end
5151
end

02/sol.exs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ defmodule Day02 do
1717
def partB(file_path) do
1818
case File.read(file_path) do
1919
{:ok, content} ->
20-
String.split(String.slice(content, 0..-2), ~r/\n/)
20+
String.split(String.slice(content, 0..-2//1), ~r/\n/)
2121
|> Enum.map(&parse_line/1)
2222
|> Enum.map(&min_required_bag/1)
2323
|> Enum.map(&Enum.product/1)
@@ -33,7 +33,7 @@ defmodule Day02 do
3333
line
3434
|> String.split(": ")
3535
|> (fn [game_id_str, moves_str] ->
36-
{String.to_integer(String.slice(game_id_str, 5..-1)), moves_str}
36+
{String.to_integer(String.slice(game_id_str, 5..-1//1)), moves_str}
3737
end).()
3838

3939
batches =

05/sol.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ defmodule Day05 do
2323
sections
2424
|> Enum.at(n)
2525
|> String.split("\n", trim: true)
26-
|> Enum.slice(1..-1)
26+
|> Enum.slice(1..-1//1)
2727
|> Enum.map(&String.split(&1, " ", trim: true))
2828
|> Enum.map(fn x -> Enum.map(x, &String.to_integer/1) end)
2929
|> Enum.sort_by(&Enum.at(&1, 1))

21/sol.exs

+6-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ defmodule Day21 do
2020
{ax, row |> Enum.find_index(&(&1 == "S"))}
2121
end
2222

23-
def get_val({x, y}, {grid, {gridX, gridY}}) when x < 0 or y < 0 or x >= gridX or y >= gridY,
23+
def get_val({x, y}, {_, {gridX, gridY}}) when x < 0 or y < 0 or x >= gridX or y >= gridY,
2424
do: nil
2525

2626
def get_val({x, y}, {grid, _}) do
@@ -32,7 +32,7 @@ defmodule Day21 do
3232
|> Enum.filter(fn a -> get_val(a, grid) == "." end)
3333
end
3434

35-
def possible_steps_partB({ax, ay}, {grid, {gridX, gridY}} = g) do
35+
def possible_steps_partB({ax, ay}, {_, {gridX, gridY}} = g) do
3636
[{ax, ay - 1}, {ax, ay + 1}, {ax - 1, ay}, {ax + 1, ay}]
3737
|> Enum.filter(fn {x, y} ->
3838
get_val({Integer.mod(x, gridX), Integer.mod(y, gridY)}, g) == "."
@@ -56,7 +56,7 @@ defmodule Day21 do
5656

5757
@k 26_501_365
5858
def partB(file_path) do
59-
{{grid, {gridX, gridY}} = g, starting_point} = read_input(file_path)
59+
{{_, {gridX, _}} = g, starting_point} = read_input(file_path)
6060
n = Integer.mod(@k, gridX)
6161
f_n = bfs(g, n, [starting_point], &possible_steps_partB/2) |> length()
6262
f_nx = bfs(g, n + gridX, [starting_point], &possible_steps_partB/2) |> length()
@@ -75,3 +75,6 @@ defmodule Day21 do
7575
a_0 + a_1 * x + a_2 * x * x
7676
end
7777
end
78+
79+
IO.puts(Day21.partA("./input"))
80+
IO.puts(Day21.partB("./input"))

25/sol.exs

+2
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,5 @@ defmodule Day25 do
8484
file_path |> read_input() |> solve()
8585
end
8686
end
87+
88+
IO.puts(Day25.partA("./input"))

0 commit comments

Comments
 (0)