Skip to content

Commit

Permalink
simplify Julia Day 4
Browse files Browse the repository at this point in the history
  • Loading branch information
Moelf committed Dec 4, 2023
1 parent 6c36f5c commit 6fa71d5
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/julia/04_moelf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ prize(n) = iszero(n) ? 0 : 2^(n - 1)
function scratch_all_count(cards)
N_cards = ones(Int, length(cards))
for (i, N_copies) in enumerate(N_cards)
score = cards[i]
for j = (i + 1):(i + score)
isassigned(N_cards, j) || continue
N_cards[j] += N_copies
end
rg = (i + 1):(i + cards[i])
N_cards[rg] .+= N_copies
end
return N_cards
end
Expand Down

0 comments on commit 6fa71d5

Please sign in to comment.