2021/11.py
def part_1_original_approach(lines: List[str]) -> int:
    """
    This was my original approach. I missed a few critical details that really bit me in
    the ass.

    1. Operator precedence for modulo.
    """
    ans = 0

    seq = [[int(c) for c in x] for x in lines]
    for _ in range(100):
        ns = [[(a + 1) % 10 for a in r] for r in seq]

        to_flash = {
            (r, c) for r in range(len(seq)) for c in range(len(seq[0])) if ns[r][c] == 0
        }
        flashed = set()
        while to_flash:
            f = to_flash.pop()

            if f in flashed:
                continue
            flashed.add(f)

            to_inc = set()
            for r, c in grid_adjs(
                f, ((0, len(seq)), (0, len(seq[0]))), AdjacenciesType.ALL
            ):
                to_inc.add((r, c))

            for r, c in to_inc:
                # Here was my operator precedence error. I originally had
                # ns[r][c] = 0 if ns[r][c] == 0 else ns[r][c] + 1 % 10
                # which is wrong since % binds tighter than +
                ns[r][c] = 0 if ns[r][c] == 0 else (ns[r][c] + 1) % 10
                if ns[r][c] == 0:
                    to_flash.add((r, c))

        ans += sum(1 for r in ns for c in r if c == 0)
        seq = ns

    return ans

    This was my original approach. I missed a few critical details that really bit me in
    the ass.

    1. Operator precedence for modulo.
    
This was my original approach. I missed a few critical details that really bit me in
the ass.

1. Operator precedence for modulo.
This was my original approach . I missed a few critical details that really bit me in the ass . 1 . Operator precedence for modulo .
def part_1_original_approach(lines: List[str]) -> int:
    ans = 0
    seq = [[int(c) for c in x] for x in lines]
    for _ in range(100):
        ns = [[(a + 1) % 10 for a in r] for r in seq]
        to_flash = {
            (r, c) for r in range(len(seq)) for c in range(len(seq[0])) if ns[r][c] == 0
        }
        flashed = set()
        while to_flash:
            f = to_flash.pop()
            if f in flashed:
                continue
            flashed.add(f)
            to_inc = set()
            for r, c in grid_adjs(
                f, ((0, len(seq)), (0, len(seq[0]))), AdjacenciesType.ALL
            ):
                to_inc.add((r, c))
            for r, c in to_inc:
                ns[r][c] = 0 if ns[r][c] == 0 else (ns[r][c] + 1) % 10
                if ns[r][c] == 0:
                    to_flash.add((r, c))
        ans += sum(1 for r in ns for c in r if c == 0)
        seq = ns
    return ans
def part_1_original_approach ( lines : List [ str ] ) -> int : ans = 0 seq = [ [ int ( c ) for c in x ] for x in lines ] for _ in range ( 100 ) : ns = [ [ ( a + 1 ) % 10 for a in r ] for r in seq ] to_flash = { ( r , c ) for r in range ( len ( seq ) ) for c in range ( len ( seq [ 0 ] ) ) if ns [ r ] [ c ] == 0 } flashed = set ( ) while to_flash : f = to_flash . pop ( ) if f in flashed : continue flashed . add ( f ) to_inc = set ( ) for r , c in grid_adjs ( f , ( ( 0 , len ( seq ) ) , ( 0 , len ( seq [ 0 ] ) ) ) , AdjacenciesType . ALL ) : to_inc . add ( ( r , c ) ) for r , c in to_inc : ns [ r ] [ c ] = 0 if ns [ r ] [ c ] == 0 else ( ns [ r ] [ c ] + 1 ) % 10 if ns [ r ] [ c ] == 0 : to_flash . add ( ( r , c ) ) ans += sum ( 1 for r in ns for c in r if c == 0 ) seq = ns return ans
This was my original approach.
This was my original approach .
"""
    This was my original approach. I missed a few critical details that really bit me in
    the ass.

    1. Operator precedence for modulo.
    """ # Here was my operator precedence error. I originally had # ns[r][c] = 0 if ns[r][c] == 0 else ns[r][c] + 1 % 10 # which is wrong since % binds tighter than +
lines
List[str]