TheAlgorithms-Python

Форк
0
28 строк · 763.0 Байт
1
"""
2
A permutation is an ordered arrangement of objects. For example, 3124 is one
3
possible permutation of the digits 1, 2, 3 and 4. If all of the permutations
4
are listed numerically or alphabetically, we call it lexicographic order. The
5
lexicographic permutations of 0, 1 and 2 are:
6

7
    012   021   102   120   201   210
8

9
What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5,
10
6, 7, 8 and 9?
11
"""
12

13
from itertools import permutations
14

15

16
def solution():
17
    """Returns the millionth lexicographic permutation of the digits 0, 1, 2,
18
    3, 4, 5, 6, 7, 8 and 9.
19

20
    >>> solution()
21
    '2783915460'
22
    """
23
    result = list(map("".join, permutations("0123456789")))
24
    return result[999999]
25

26

27
if __name__ == "__main__":
28
    print(solution())
29

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.