Skip to content

Commit

Permalink
franklin-update
Browse files Browse the repository at this point in the history
  • Loading branch information
rdboyes committed Dec 2, 2024
1 parent 799b2a3 commit 67c3372
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions posts/adventofcode2024.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,19 @@ check_safe(steps) = all(steps .> 0 .&& steps .< 4) ||

p1 = @chain df begin
@transmute(list = to_int(split(Column1)))
@mutate(steps = extrema(diff(list)))
@mutate(steps = diff(list))
@mutate(safe = check_safe(steps))
@pull(safe)
sum
end

println("Part 1: $p1")

function check_sublists(list)
any(check_safe.(diff.([list[1:end .!= i] for i in 1:length(list)])))
end
check_all(l) = any(check_safe.(diff.([l[1:end .!= i] for i in 1:length(l)])))

p2 = @chain df begin
@transmute(list = to_int(split(Column1)))
@mutate(safe = check_sublists(list))
@mutate(safe = check_all(list))
@pull(safe)
sum
end
Expand Down

0 comments on commit 67c3372

Please sign in to comment.