-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
172 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Notes for Day 02 Part 2 | ||
======================= | ||
|
||
This report is unsafe with the code from Part 1. | ||
|
||
```elixir | ||
report = [1, 3, 2, 4, 5] | ||
Solution.safe?(report) | ||
false | ||
``` | ||
|
||
However if we are to remove 3, it's safe: | ||
|
||
```elixir | ||
report = [1, 2, 4, 5] | ||
Solution.safe?(report) | ||
true | ||
``` | ||
|
||
We can only remove one level. Now, how do we know which level to remove? The only way to know is to try removing all levels one by one and see if the report ever becomes safe. That's my approach. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,4 @@ | ||
defmodule Aoc2024Test.Day02 do | ||
use ExUnit.Case | ||
doctest Aoc2024 | ||
|
||
alias Aoc2024.Day02.Solution | ||
|
||
test "day 02 part 1" do | ||
reports = [ | ||
[7, 6, 4, 2, 1], | ||
[1, 2, 7, 8, 9], | ||
[9, 7, 6, 2, 1], | ||
[1, 3, 2, 4, 5], | ||
[8, 6, 4, 4, 1], | ||
[1, 3, 6, 7, 9] | ||
] | ||
|
||
assert Solution.safe_count(reports) == 2 | ||
assert Solution.solve_part1() == 421 | ||
end | ||
doctest Aoc2024.Day02.Solution | ||
end |