This commit is contained in:
David Doblas Jiménez
2021-10-27 11:27:14 +02:00
parent 846a9343ae
commit d9c96f32cf
51 changed files with 315 additions and 366 deletions

View File

@@ -5,8 +5,7 @@ Created on 08 Sep 2021
@email: daviddoji@pm.me
Solution for Problem 38 of Project Euler
https://projecteuler.net/problem=38
=#
https://projecteuler.net/problem=38 =#
using BenchmarkTools
@@ -28,8 +27,7 @@ function Problem38()
What is the largest 1 to 9 pandigital 9-digit number that can
be formed as the concatenated product of an integer with
(1,2, ... , n) where n > 1?
=#
(1,2, ... , n) where n > 1? =#
results = []
pandigital = join(['1', '2', '3', '4', '5', '6', '7', '8', '9'])
@@ -41,7 +39,7 @@ function Problem38()
while length(number) < 9
number *= string(integer * i)
if join(sort(collect(number))) == pandigital
push!(results,number)
push!(results, number)
end
integer += 1
end
@@ -50,7 +48,7 @@ function Problem38()
end
println("Time to evaluate Problem 38:")
println("Time to evaluate Problem $(lpad(38, 3, "0")):")
@btime Problem38()
println("")
println("Result for Problem 38: ", Problem38())
println("Result for Problem $(lpad(38, 3, "0")): ", Problem38())