Skip to content

Commit

Permalink
[Day 4] Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
goggle committed Dec 4, 2023
1 parent fb66eda commit 11c8816
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/day04.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ eval_points(nwins::Int) = nwins > 0 ? 2^(nwins - 1) : 0
function part2(winning_numbers::Vector{Vector{Int}}, my_numbers::Vector{Vector{Int}})
ncards = ones(Int, length(winning_numbers))
for (i, (w, m)) enumerate(zip(winning_numbers, my_numbers))
ncommon = length(intersect(w, m))
for k = i+1:i+ncommon
ncards[k] += ncards[i]
end
ncards[i+1:i+length(intersect(w, m))] .+= ncards[i]
end
return ncards |> sum
end
Expand Down

0 comments on commit 11c8816

Please sign in to comment.