Skip to content

Instantly share code, notes, and snippets.

@chubbc
Created December 16, 2020 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chubbc/e269f78fbdfd1dde6a0308470c1b43f9 to your computer and use it in GitHub Desktop.
Save chubbc/e269f78fbdfd1dde6a0308470c1b43f9 to your computer and use it in GitHub Desktop.
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