<jupyter_start><jupyter_text>Part 2Since we already built a complete map using the robot, we can simply calculate positions based on the map in the robot's memory<jupyter_code>def calculate_oxygen_spread(space):
    space = {p: v for p, v in space.items() if v != '#'}
    
    to_check = {p: v for p, v in space.items() if v == '.'}
    while len(to_check) > 0:
        for pos in to_check.keys():
            moves = []
            for h in Robot.HEADINGS:
                m = space.get(robot.calculate_pos(pos, h))
                if m is None:
                    pass
                elif m == 'O':
                    moves.append(0)
                elif isinstance(m, int):
                    moves.append(m)
            if len(moves)>0:
                space[pos] = min(moves) + 1
        to_check = {p: v for p, v in space.items() if v == '.'}
        
        
    values = [v for v in space.values() if isinstance(v, int)]
    return max(values)


calculate_oxygen_spread(robot.space)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11208576998050682, 'fraction_numerical': 0.004873294346978557, 'mean_word_length': 1.7983651226158037, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '566354', 'license': 'MIT', 'n_tokens_mistral': 334, 'n_tokens_neox': 318, 'n_words': 100, 'path': 'solutions/2019/kws/15.ipynb', 'repo_name': 'kws/AdventOfCode', 'size': '1026'}