Created
December 16, 2020 01:58
-
-
Save chubbc/e269f78fbdfd1dde6a0308470c1b43f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N = [19,0,5,1,10,13]; | |
function AoC2020_15(N::Vector{Int}, n::Int)::Int | |
D::Dict{Int,Int} = Dict{Int,Int}(reverse.(collect(enumerate(N)))); | |
c::Int = 0; | |
for i ∈ length(N)+1:n-1 | |
(D[c], c) = (i, i-get(D, c, i)); | |
end | |
return c; | |
end | |
p1 = AoC2020_15(N,2020); | |
p2 = AoC2020_15(N,30000000); | |
println((p1, p2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment