upvote
To anyone else confused, backticks quote in python2 is alias of repr() function, removed in python3.
reply
Cool you turned this around so fast after people asked for this info in the thread. The code golf itself is incomprensible to me.
reply
I started to write an explanation myself, then I felt that human effort is overrated and just had ChatGPT generate one for me. (It did require some additional prompting to get it right, though - I should have probably asked Astra from Codex instead of whatever model they feed you on the chat UI.)

    def g(a):
        # Make p a 1-element array of a 99-character string filled with 'z'.
        p = ['z'*99]

        # Create a view of the board that combines each row with the
        # row above and below it. The padding ensures that the first
        # and last rows also have three rows to work with.
        #
        # For example, with:
        #   a = ['001', '110', '101']
        #   p = ['zzz']
        #
        # We get:
        #   a       = ['001', '110', '101']
        #   p+a     = ['zzz', '001', '110', '101']
        #   a[1:]+p = ['110', '101', 'zzz']
        #
        # zip() stops at the shortest input, producing:
        # [
        #   ('001', 'zzz', '110'),
        #   ('110', '001', '101'),
        #   ('101', '110', 'zzz')
        # ]
        #
        # Each tuple contains the current row, the previous row
        # (or padding), and the next row (or padding), in that order.
        board = zip(a, p+a, a[1:]+p)

        result = []
        for r in board:
            # If a is still in its original orientation, transpose
            # the three rows and recursively process them.
            #
            # zip(*r) turns the three rows into columns, allowing
            # the next recursive call to process the board in the
            # other orientation.
            #
            # The backticks convert the recursive result (a list
            # of integers) to its string representation: "[0, 1, 0]"
            # (`` is just shorthand for repr(), which is supposed to
            # return a machine-readable string representation of a value.)
            # [1::3] extracts every third character, effectively
            # extracting the individual cell values from the list
            # representation.
            #
            # The comparison a<p is also a clever way to distinguish
            # the original board from the transposed board: Python 2
            # compares the different element types differently.
            #
            # Boolean expressions short-circuit in Python, and they
            # return the result of the last term evaluated, not True/False;
            # for example, `0 or 1` will evaluate to 1, not True. The original
            # golfed version makes use of this to take one of two branches
            # without spending the golf budget on writing if/else.
            if a < p:
                result.append(`g(zip(*r))`[1::3])
            else:
                # We are now looking at three adjacent columns, each
                # containing three cells: a complete 3x3 neighborhood.
                #
                # r*2 duplicates the neighborhood. Converting it to
                # a string and counting '1' gives twice the number of
                # live neighbors, plus the center cell.
                #
                # Starting the count at index 4 skips the first
                # occurrence of the center cell, but its second
                # occurrence remains.
                #
                # Therefore:
                #   dead cell with 3 neighbors: 6
                #   live cell with 2 neighbors: 5
                #   live cell with 3 neighbors: 7
                #
                # All these cases satisfy 4 < count < 8.
                #
                # Unary + on a boolean (the result of the comparison)
                # converts it to an integer (0 or 1).
                # Because we are currently in the recursively called branch,
                # the caller will turn our entire return value into a string 
                # (via backticks); therefore, we do not have to bother turning the
                # converted integers back into strings.
                result.append(+(4 < `r*2`.count('1', 4) < 8))

        return result
Most of this are pretty standard Python 2 codegolf tricks that I used to use, when I was still interested in this stuff. (I like to think my much younger and more carefree self used to be decent at codegolfing in Python.) Python 2 is weirdly weakly typed, with implicit conversions all over the place - most codegolf programs of the era will make extensive use of this. The only language-level trick that stands out to me is the `listOfChars`[1::3] to convert a list of single-digit integers to a string, and I suppose that one is kind of obvious when you think about it - just rarely comes up.

The really smart part is the way it uses recursive calls with branches with an implicit test `a<p` to check whether we are in the recursively called branch or not. Most people would have probably created a second function instead of a branch to do the counting, which would have incurred the heavy golf cost of having to type `lambda` to declare it, or passed an explicit flag to the recursive call, which also incurs character penalties.

reply
TIL that whitespace around operator keywords like `and` is optional.
reply