mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
bc8df6de31
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.2.2 → v0.3.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.2...v0.3.2) - [github.com/pre-commit/mirrors-mypy: v1.8.0 → v1.9.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.8.0...v1.9.0) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
29 lines
763 B
Python
29 lines
763 B
Python
"""
|
|
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?
|
|
"""
|
|
|
|
from itertools import permutations
|
|
|
|
|
|
def solution():
|
|
"""Returns the millionth lexicographic permutation of the digits 0, 1, 2,
|
|
3, 4, 5, 6, 7, 8 and 9.
|
|
|
|
>>> solution()
|
|
'2783915460'
|
|
"""
|
|
result = list(map("".join, permutations("0123456789")))
|
|
return result[999999]
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print(solution())
|