Computer Science, asked by ravalireddydasari11, 8 months ago

I
Find the kth digit of the ith permuted combination of n digits. nik are provided.(Al
indexing starts with 1) For 3, 123 is its first combination. ( the permutations are arranged
in ascending order for calculation. The order for n=3 is 123 132 213 231 312 321).
(0-n4=9)
Input Format
Three space separated number representing ni k.
Output Format
Print the digit alone
Sample Input:
Sample Output: write program in c++

Answers

Answered by tarunkrishnakoous9zg
2

Answer:

from itertools import permutations

n,i,k=map(int,input().split())

if(n>=1 and n<=9):

lst=[j for j in range(1,n+1)]

perm=permutations(lst)

j=0

for _ in perm:

 j+=1

 if(j==(i-1)):

  print(_[k-1])

 

Explanation:

Similar questions