<jupyter_start><jupyter_text>Kaprekar Constant- all 4 digit numbers with at least two distinct digits- repeatedly applying a simpel procedure:     - given x, create two new numbers that consist of the digits in x in ascending and descending order    - subtrat the smaller number from the larger number    example: - 4321 - 1234 = 3087- 8730 - 0378 = 8352- 8532 - 2358 = 6174Write a function that returns how many steps will take for a given input.<jupyter_code>def get_digits(num): 
    digits = str(num)
    
    if len(digits) == 4: 
        return digits
    else: 
        return '0' * (4 - len(digits)) + digits
    
def kaprekar_steps(num): 
    steps = 0 
    
    while num != 6174: 
        digits = get_digits(num)
        num = int(''.join(sorted(digits, reverse=True))) - int(''.join(sorted(digits)))
        steps += 1
        
    return steps
# recursive solution

def kaprekar_steps(num, steps=0): 
    if num == 6174: 
        return steps
    
    digits = get_digits(num)
    num = int(''.join(sorted(digits, reverse=True))) - int(''.join(sorted(digits)))
    
    return kaprekar_steps(num, steps+1)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10443864229765012, 'fraction_numerical': 0.04525674499564839, 'mean_word_length': 2.8333333333333335, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '276153', 'license': 'MIT', 'n_tokens_mistral': 418, 'n_tokens_neox': 364, 'n_words': 116, 'path': 'Daily/Kaprekar Constant.ipynb', 'repo_name': 'jasonyum/python_go', 'size': '1149'}