2018-09-30 22:01:58 +00:00
---
id: 5900f3841000cf542c50fe97
title: 'Problem 24: Lexicographic permutations'
2020-11-27 18:02:05 +00:00
challengeType: 5
2019-08-05 16:17:33 +00:00
forumTopicId: 301885
2021-01-13 02:31:00 +00:00
dashedName: problem-24-lexicographic-permutations
2018-09-30 22:01:58 +00:00
---
2020-11-27 18:02:05 +00:00
# --description--
2020-02-28 12:39:47 +00:00
2018-09-30 22:01:58 +00:00
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:
2020-02-28 12:39:47 +00:00
2018-09-30 22:01:58 +00:00
< div style = 'text-align: center;' > 012 021 102 120 201 210< / div >
2020-02-28 12:39:47 +00:00
What is the `n` th lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9?
2020-11-27 18:02:05 +00:00
# --hints--
`lexicographicPermutations(699999)` should return a number.
```js
assert(typeof lexicographicPermutations(699999) === 'number');
```
`lexicographicPermutations(699999)` should return 1938246570.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
assert(lexicographicPermutations(699999) == 1938246570);
```
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
`lexicographicPermutations(899999)` should return 2536987410.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
assert(lexicographicPermutations(899999) == 2536987410);
```
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
`lexicographicPermutations(900000)` should return 2537014689.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
assert(lexicographicPermutations(900000) == 2537014689);
2018-09-30 22:01:58 +00:00
```
2020-11-27 18:02:05 +00:00
`lexicographicPermutations(999999)` should return 2783915460.
```js
assert(lexicographicPermutations(999999) == 2783915460);
```
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
# --seed--
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
## --seed-contents--
2018-09-30 22:01:58 +00:00
```js
function lexicographicPermutations(n) {
2020-09-15 16:57:40 +00:00
2018-09-30 22:01:58 +00:00
return n;
}
lexicographicPermutations(999999);
```
2020-11-27 18:02:05 +00:00
# --solutions--
2018-09-30 22:01:58 +00:00
```js
// solution required
```