#!/usr/bin/env python # 2025 - Advent Of Code 4 # file = 'input_example.txt' file = 'input.txt' # pylint: disable=consider-using-with input_lines = [line.strip('\n') for line in open(file, encoding="utf-8")] MAX_X = len(input_lines[0]) MAX_Y = len(input_lines) accessible = 0 for pos_y in range(0, MAX_Y): for pos_x in range(0, MAX_X): if input_lines[pos_y][pos_x] == '@': rolls = 0 if pos_y > 0 and pos_x > 0 and input_lines[pos_y-1][pos_x-1] == '@': rolls += 1 if pos_y > 0 and input_lines[pos_y-1][pos_x] == '@': rolls += 1 if pos_y > 0 and pos_x < MAX_X - 1 and input_lines[pos_y-1][pos_x+1] == '@': rolls += 1 if pos_x > 0 and input_lines[pos_y][pos_x-1] == '@': rolls += 1 if pos_x < MAX_X - 1 and input_lines[pos_y][pos_x+1] == '@': rolls += 1 if pos_y < MAX_Y - 1 and pos_x > 0 and input_lines[pos_y+1][pos_x-1] == '@': rolls += 1 if pos_y < MAX_Y - 1 and input_lines[pos_y+1][pos_x] == '@': rolls += 1 if pos_y < MAX_Y - 1 and pos_x < MAX_X - 1 and input_lines[pos_y+1][pos_x+1] == '@': rolls += 1 if rolls < 4: accessible += 1 print('x', end='') else: print('@', end='') else: print('.', end='') print() print(accessible)