Skip to content

Commit

Permalink
franklin-update
Browse files Browse the repository at this point in the history
  • Loading branch information
rdboyes committed Dec 15, 2024
1 parent 80a1e94 commit c5041c6
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions posts/adventofcode2024w2.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,36 @@ println(sum(pathsp1))
print(sum(pathsp2))
```

## Day 13

Pretty clean solution for Day 13. Don't love the round/asinteger solution but floating point problems were causing headaches.

```julia
inst = readlines("data/13.txt")

A = [parse.(Int, m.captures) for m in
match.(r"A: X\+(\d+), Y\+(\d+)", inst) if !isnothing(m)]
B = [parse.(Int, m.captures) for m in
match.(r"B: X\+(\d+), Y\+(\d+)", inst) if !isnothing(m)]
P = [parse.(Int, m.captures) for m in
match.(r"Prize: X\=(\d+), Y\=(\d+)", inst) if !isnothing(m)]

function solve(adjust=0)
ans = 0
for i in eachindex(A)
sol = hcat(A[i], B[i]) \ (P[i] .+ adjust)
if all(isinteger.(round.(sol, digits=3)))
ans += sum((3, 1) .* sol)
end
end
return ans
end

println(solve())
println(solve(10000000000000))
```


## Day 14

Solution to part one runs fast, clean solution. Part two requires you to watch a nearly 17 minute long video generated by Makie.jl to find the tree. I'm sure there was a smart way to do this, but when in doubt, look at the data...
Expand Down

0 comments on commit c5041c6

Please sign in to comment.