<jupyter_start><jupyter_text>Avent Of Code 2018 - DAY 5 <NAME>, 2018https://adventofcode.com/2018/day/5  strategy- brute force- string replace<jupyter_code>UNITS = 'abcdefghijklmnopqrstuvwxyz'
PAIRS = [x+y for x,y in zip(UNITS, UNITS.upper())]+[y+x for x,y in zip(UNITS, UNITS.upper())]
print(' '.join(PAIRS))

def fully_react(s):
    while True:
        ss = s
        for x in PAIRS:
            ss = ss.replace(x,'')
        if s == ss:
            break
        s = ss
    return s<jupyter_output><empty_output><jupyter_text>part 1<jupyter_code>polymer = "dabAcCaCBAcCcaDA"
print(fully_react(polymer))
with open('input.txt') as f:
    polymer = f.read().strip()
    print(len(fully_react(polymer)))<jupyter_output>10888<jupyter_text>part 2<jupyter_code>def remove_unit(polymer, unit):
    return polymer.replace(unit.lower(), '').replace(unit.upper(), '')

def shortest_size(polymer):
    return min(len(fully_react(remove_unit(polymer, unit))) for unit in UNITS)
    
polymer = "dabAcCaCBAcCcaDA"
print(shortest_size(polymer))
with open('input.txt') as f:
    polymer = f.read().strip()
    print(shortest_size(polymer))<jupyter_output>6952
{'fraction_non_alphanumeric': 0.1467248908296943, 'fraction_numerical': 0.021834061135371178, 'mean_word_length': 4.355140186915888, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 1, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '385628', 'license': 'Unlicense', 'n_tokens_mistral': 471, 'n_tokens_neox': 430, 'n_words': 83, 'path': '05/day-5.ipynb', 'repo_name': 'jdhalimi/aoc-2018', 'size': '1156'}