<jupyter_start><jupyter_text>Day 2<jupyter_code>count=0

with open('input_day2.txt','r') as file:
    for line in file:
        elements=line.strip().split(" ")
        num=elements[0].split("-")
        n_min=int(num[0])
        n_max=int(num[1])
        letter=elements[1][0]
        string=elements[2]
        if string.count(letter)<=n_max and string.count(letter)>=n_min:
            count+=1
count
count=0

with open('input_day2.txt','r') as file:
    for line in file:
        elements=line.strip().split(" ")
        num=elements[0].split("-")
        n_min=int(num[0])
        n_max=int(num[1])
        letter=elements[1][0]
        string=elements[2]
        if (string[n_min-1]==letter and string[n_max-1]!=letter) or (string[n_min-1]!=letter and string[n_max-1]==letter):
            count+=1 
count<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17122473246135553, 'fraction_numerical': 0.027348394768133173, 'mean_word_length': 2.9716981132075473, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '424857', 'license': 'MIT', 'n_tokens_mistral': 312, 'n_tokens_neox': 312, 'n_words': 47, 'path': '2020/paula/day2/advent_code_day2.ipynb', 'repo_name': 'bbglab/adventofcode', 'size': '841'}