Refactor output

This commit is contained in:
David Doblas Jiménez 2023-08-28 18:47:48 +02:00
parent e2f035d386
commit 9bd496d356

View File

@ -10,7 +10,7 @@ https://projecteuler.net/problem=24 =#
using BenchmarkTools
using Combinatorics
function Problem24()
function Problem024()
#=
A permutation is an ordered arrangement of objects. For example, 3124 is
one possible permutation of the digits 1, 2, 3 and 4. If all of the
@ -20,14 +20,16 @@ function Problem24()
012 021 102 120 201 210
What is the millionth lexicographic permutation of the digits
0, 1, 2, 3, 4, 5, 6, 7, 8 and 9? =#
digits = [0,1,2,3,4,5,6,7,8,9]
0, 1, 2, 3, 4, 5, 6, 7, 8 and 9?
=#
digits = collect(0:9)
_permutations = nthperm(digits, 1_000_000)
return join(_permutations)
end
println("Time to evaluate Problem $(lpad(24, 3, "0")):")
@btime Problem24()
println("Took:")
@btime Problem024()
println("")
println("Result for Problem $(lpad(24, 3, "0")): ", Problem24())
println("Result for Problem $(lpad(24, 3, "0")): ", Problem024())