Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mdr committed Dec 2, 2024
1 parent 9bc72ba commit a6f0bd7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Aoc2024/Day02/Solve.lean
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ private def decreasingSlowly: HashSet Int := HashSet.ofList [-1, -2, -3]
private def isSubsetOf [Hashable α] [BEq α] (xs: HashSet α) (ys: HashSet α) : Bool :=
xs.all ys.contains

#guard isSubsetOf (HashSet.ofList [1, 3]) (HashSet.ofList [1, 2, 3]) == true
#guard isSubsetOf (HashSet.ofList [1, 4]) (HashSet.ofList [1, 2, 3]) == false

private def isSafe (report : Report) : Bool :=
let diffs := differences report |> HashSet.ofList
isSubsetOf diffs increasingSlowly || isSubsetOf diffs decreasingSlowly
Expand Down
1 change: 1 addition & 0 deletions notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* https://github.com/chenson2018/advent-of-code/blob/main/2024/lean/AoC/Day01.lean
* https://github.com/kiranandcode/lean-aoc/blob/main/Solutions/Day1.lean
* https://github.com/anurudhp/aoc2022/blob/main/Aoc/Day02.lean
* https://github.com/mfornet/advent-of-code-2024

## Questions
* How does this syntax work?
Expand Down

0 comments on commit a6f0bd7

Please sign in to comment.