<jupyter_start><jupyter_text>Part 1<jupyter_code>start = 353096
end = 843212
def check_has_double(n):
    for i in range(len(n)-1):
        if n[i] == n[i+1]:
            return True
    return False
def check_increasing(n):
    for i in range(len(n)-1):
        if n[i] <= n[i+1]:
            pass
        else:
            return False
    return True
def check_valid(start, end):
    valids = []
    for n in range(start, end+1):
        str_n = str(n)
        if check_has_double(str_n) and check_increasing(str_n):
            valids.append(n)
    return valids
valids = check_valid(start, end)
print(len(valids))<jupyter_output>579<jupyter_text>Part 2<jupyter_code>from collections import Counter

def check_has_double_2(n):
    doubles = []
    for i in range(len(n)-1):
        if n[i] == n[i+1]:
            doubles.append(n[i])
    
    cnt = Counter()
    
    cnt.update(doubles)
    
    for _, i in cnt.items():
        if i == 1:
            return True
    
    return False
def check_valid_2(start, end):
    valids = []
    for n in range(start, end+1):
        str_n = str(n)
        if check_has_double_2(str_n) and check_increasing(str_n):
            valids.append(n)
    return valids
valids = check_valid_2(start, end)
print(len(valids))<jupyter_output>358
{'fraction_non_alphanumeric': 0.11875, 'fraction_numerical': 0.02578125, 'mean_word_length': 2.4343163538873993, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 7, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '578078', 'license': 'MIT', 'n_tokens_mistral': 497, 'n_tokens_neox': 474, 'n_words': 106, 'path': 'advent-of-code-2019/4.ipynb', 'repo_name': 'bentrevett/py-algorithms', 'size': '1280'}