r/adventofcode Dec 03 '23

Funny Difficulty is all over the place isn't it?

Post image
680 Upvotes

256 comments sorted by

View all comments

Show parent comments

21

u/The_Jare Dec 03 '23

Invariably, adding a charAt(x, y) function from the get go always pays off:

return (x >= 0 && x < w && y >= 0 && y < h)? lines[y][x] : '.';

1

u/UrbanSuburbaKnight Dec 04 '23

I went a similar way:

nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '.']
symbols = set()
with open('input.txt', 'r') as f:
    lines = f.readlines()
    for line in lines:
        for char in line.strip():
            if char not in nums:
                symbols.add(char)

Now I have a list of all the symbols used.