#1
(This post was last modified: 24 April, 2020 - 05:52 PM by Golla8125.)
def num2dig(n: int) -> [int]: 
return [int© for c in str(n)] 
def dig2num(ds: int) -> [int]: 
return int(''.join([str(d) for d in ds])) 
def largest(n: int) -> int: 
return dig2num(sorted(num2dig(n),reverse=True)) 
def smallest(n: int) -> int: return dig2num(sorted(num2dig(n)))
 def next_kaprekar(n: int) -> int:
 return largest(n) - smallest(n)
 def kaprekar(n: int) -> [int]: 
seq = [n] n = next_kaprekar(n) 
while seq[-1] != n:
 seq.append(n)
 n= next_kaprekar(n)
 return seq