Elegant Project Euler Solution
Leonhard Euler
leon at example.org
Sun Nov 3 19:51:14 UTC 2019
Hi all,
Just wanted to share a very elegant solution for Project Euler,
problem #24.
This is the problem:
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?
And my solution:
```
import std;
void main() {
iota(10).array.nthPermutation(999999).writeln();
}
```
Know thy standard library ;)
More information about the Digitalmars-d
mailing list