function memorygame(starting, place=2020)
    seen = Dict{Int,Int}()
    for (i, x) in enumerate(starting[1:end-1])
        seen[x] = i
    end
    count = length(starting)
    previous = starting[end]
    while count < place
        if haskey(seen, previous)
            next = count - seen[previous]
            seen[previous] = count
            previous = next
        else
            seen[previous] = count
            previous = 0
        end
        count += 1
    end
    previous
end

function main()
    starting = [9, 12, 1, 4, 17, 0, 18]
    part1 = memorygame(starting, 2020)
    part2 = memorygame(starting, 30000000)
    @info "Solution" part1 part2
end

main()
