123456789101112131415161718192021 |
- #!/usr/bin/ruby
- # Author: Trizen
- # https://github.com/trizen
- # What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9?
- # https://projecteuler.net/problem=24
- # Runtime: 5.387s (previously: 7.307s)
- var i = 0
- var arr = @(0..9)
- arr.permutations { |*p|
- if (++i == 1e6) {
- say p.join
- break
- }
- }
|