<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># Lets the user input a number N between 1 and 10 and a number k
# at most equalt to N!, and outputs the kth permutation of {0, ..., N-1},
# using lexicographic order and counting from 1.
#
# Written by *** and Eric Martin for COMP9021

import sys
from math import factorial


provided_input = input('Enter two strictly positive integers,\n'
                       '  the first one at most equal to 10\n'
                       '  the second one at most equal to first one!: ')
provided_input = provided_input.split()
if len(provided_input) != 2:
    print('Incorrect input, giving up.')
    sys.exit()
try:
    number_range = int(provided_input[0])
    rank = int(provided_input[1])
    if number_range &lt;= 0 or rank &lt;= 0 or rank &gt; factorial(number_range):
        raise ValueError
except:
    print('Incorrect input, giving up.')
    sys.exit()

solution = ''
# REPLACE THIS COMMENT WITH YOUR CODE
print('Lexicographically, the permutation of 0, ..., {} of rank {} is: {}'.
                          format(number_range - 1, rank, solution))
</pre></body></html>