Type hints for improving performance
This commit is contained in:
parent
c3a4e0a627
commit
f5152ece96
@ -16,7 +16,7 @@ function chain_length(n, terms)
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
if n % 2 == 0
|
if n % 2 == 0
|
||||||
n = n / 2
|
n = n ÷ 2
|
||||||
else
|
else
|
||||||
n = 3n + 1
|
n = 3n + 1
|
||||||
end
|
end
|
||||||
@ -50,7 +50,8 @@ function Problem14()
|
|||||||
ans = 0
|
ans = 0
|
||||||
limit = 1_000_000
|
limit = 1_000_000
|
||||||
score = 0
|
score = 0
|
||||||
terms = Dict()
|
terms = Dict{Int, Int}()
|
||||||
|
sizehint!(terms, limit)
|
||||||
for i in 1:limit
|
for i in 1:limit
|
||||||
terms[i] = chain_length(i, terms)
|
terms[i] = chain_length(i, terms)
|
||||||
if terms[i] > score
|
if terms[i] > score
|
||||||
|
Loading…
x
Reference in New Issue
Block a user