From f5152ece96461996e165c75ab08332564ff6a93f Mon Sep 17 00:00:00 2001 From: daviddoji Date: Sat, 24 Jul 2021 11:17:25 +0200 Subject: [PATCH] Type hints for improving performance --- src/Julia/Problem014.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Julia/Problem014.jl b/src/Julia/Problem014.jl index ae71e2a..22d2e89 100644 --- a/src/Julia/Problem014.jl +++ b/src/Julia/Problem014.jl @@ -16,7 +16,7 @@ function chain_length(n, terms) break end if n % 2 == 0 - n = n / 2 + n = n รท 2 else n = 3n + 1 end @@ -50,7 +50,8 @@ function Problem14() ans = 0 limit = 1_000_000 score = 0 - terms = Dict() + terms = Dict{Int, Int}() + sizehint!(terms, limit) for i in 1:limit terms[i] = chain_length(i, terms) if terms[i] > score