From 32d158a67971e675fd24530279e86ac21db34cb4 Mon Sep 17 00:00:00 2001 From: daviddoji Date: Fri, 13 Aug 2021 21:52:42 +0200 Subject: [PATCH] Solution to problem 24 in Julia --- src/Julia/Problem024.jl | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/Julia/Problem024.jl diff --git a/src/Julia/Problem024.jl b/src/Julia/Problem024.jl new file mode 100644 index 0000000..a128b83 --- /dev/null +++ b/src/Julia/Problem024.jl @@ -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())