Solution to problem 24 in Julia
This commit is contained in:
parent
f33afdb5c1
commit
32d158a679
34
src/Julia/Problem024.jl
Normal file
34
src/Julia/Problem024.jl
Normal file
@ -0,0 +1,34 @@
|
||||
#=
|
||||
Created on 13 Aug 2021
|
||||
|
||||
@author: David Doblas Jiménez
|
||||
@email: daviddoji@pm.me
|
||||
|
||||
Solution for Problem 24 of Project Euler
|
||||
https://projecteuler.net/problem=24
|
||||
=#
|
||||
|
||||
using Combinatorics
|
||||
|
||||
function Problem24()
|
||||
#=
|
||||
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
|
||||
permutations are listed numerically or alphabetically, we call it
|
||||
lexicographic order. The lexicographic permutations of 0, 1 and 2 are:
|
||||
|
||||
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]
|
||||
_permutations = nthperm(digits, 1_000_000)
|
||||
return join(_permutations)
|
||||
end
|
||||
|
||||
|
||||
println("Time to evaluate Problem 24:")
|
||||
@time Problem24()
|
||||
println("")
|
||||
println("Result for Problem 24: ", Problem24())
|
Loading…
x
Reference in New Issue
Block a user