Linting
This commit is contained in:
parent
948dfb0ff8
commit
3cf341159b
@ -1,4 +1,4 @@
|
||||
using Base:String
|
||||
using Base: String
|
||||
#=
|
||||
Created on 22 Jul 2021
|
||||
|
||||
@ -15,6 +15,7 @@ function Problem13()
|
||||
#=
|
||||
Work out the first ten digits of the sum of the following one-hundred
|
||||
50-digit numbers =#
|
||||
|
||||
return string(sum(parse.(BigInt, readlines("../files/Problem13.txt"))))[1:10]
|
||||
end
|
||||
|
||||
|
@ -9,13 +9,13 @@ https://projecteuler.net/problem=14 =#
|
||||
|
||||
using BenchmarkTools
|
||||
|
||||
function chain_length(n)# , terms)
|
||||
function chain_length(n)
|
||||
length = 0
|
||||
while n > 1
|
||||
n = iseven(n) ? n >> 1 : 3n + 1
|
||||
length += 1
|
||||
end
|
||||
return length
|
||||
return length
|
||||
end
|
||||
|
||||
function Problem14()
|
||||
@ -42,13 +42,13 @@ function Problem14()
|
||||
ans = 0
|
||||
limit = 1_000_000
|
||||
score = 0
|
||||
for i in 1:2:limit # no need to check even numbers
|
||||
for i = 1:2:limit # no need to check even numbers
|
||||
longest = chain_length(i)
|
||||
if longest > score
|
||||
score = longest
|
||||
ans = i
|
||||
end
|
||||
end
|
||||
end
|
||||
return ans
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user