Skip to content

Commit

Permalink
franklin-update
Browse files Browse the repository at this point in the history
  • Loading branch information
rdboyes committed Dec 5, 2024
1 parent 4e8c3ab commit 9949a9e
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.11.1"
julia_version = "1.11.2"
manifest_format = "2.0"
project_hash = "f77c437f26b1311cd7d55aa7512ee43438044132"
project_hash = "9ed7cdf0679c596794174d81e0da39b7ef0605c1"

[[deps.AbstractFFTs]]
deps = ["LinearAlgebra"]
Expand Down
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ Franklin = "713c75ef-9fc9-4b05-94a9-213340da978e"
FreeType = "b38be410-82b0-50bf-ab77-7b57e271db43"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
NodeJS = "2bd173c7-0d6d-553b-b6af-13a54713934c"
TidierData = "fe2206b3-d496-4ee9-a338-6a095c4ece80"
TidierPlots = "337ecbd1-5042-4e2a-ae6f-ca776f97570a"
20 changes: 20 additions & 0 deletions posts/adventofcode2024.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,24 @@ println("Part 2: $p2")

Another AoC classic, a "grid problem", and another improvement for TidierStrings to submit as a PR! Julia's eachmatch function allows for overlaps, no reason not to allow the overlap Bool to pass through from str_count.

### Day 5

One of those days where you hit Part 2 and just think ... not today. Happy enough with my part one, although it is very light on the Tidier.jl.

```julia
data = readlines("data/5.txt")
div = findall(data .== "")[1]

to_int(x) = parse.(Int, x)
rules = to_int.(split.(data[1:(div-1)], "|"))
pages = to_int.(split.(data[(div+1):end], ","))

check_rules(p, rl) = ifelse(
any([r p && !all(p r .== r) for r in rl]),
0, p[ceil(Int, end/2)])

println("Part 1: $(sum(check_rules.(pages, (rules, ))))")
```


{{ add_bsky_comments "at://did:plc:2h5e6whhbk5vnnerqqoi256k/app.bsky.feed.post/3lcbbseb55c27" }}
51 changes: 51 additions & 0 deletions posts_inprog/capybaramurderparty.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
```julia
using DataFrames
using TidierData

state_list = DataFrame[]

prizes = [14000, 10000, 7000, 5000, 5000, 5000, 5000, 5000,
2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500]

for i in 1:10000
current_state = DataFrame(
id = 1:63,
kills = vcat(
repeat([5], 1),
repeat([4], 2),
repeat([3], 2),
repeat([2], 21),
repeat([1], 18),
repeat([0], 63-44)
),
post_r3_kills = vcat(
repeat([5], 1),
repeat([4], 2),
repeat([3], 2),
repeat([2], 21),
repeat([1], 18),
repeat([0], 63-44)
),
)

for round in 1:45
killer = rand(1:nrow(current_state))
killed = rand(vcat(1:(killer-1), (killer+1):nrow(current_state)))
current_state.kills[killer] += 1
delete!(current_state, [killed])
end

sort!(current_state, :kills, rev = true)
current_state.iter .= i
current_state.prize = prizes

push!(state_list, current_state)
end

@chain vcat(state_list...) begin
@group_by(post_r3_kills, id)
@summarize(av_win = sum(prize)/10000)
@summarize(ev = mean(av_win))
@arrange(desc(ev))
end
```

0 comments on commit 9949a9e

Please sign in to comment.