def w(b,s):
    """
    Given a tic tac toe board b of arbitrary size s, determine if 1 won.

    This is a helper function for e. If I wasn't trying to reduce the
    character count, this function's name would begin with an
    underscore, and would be called _one_won.

    Board must be specified as an integer, the binary representation of
    which depicts the sequence of values, proceeding from the upper-left
    corner to the upper-right corner, with proceeding rows following.

    For example:
    101
    001
    110
    would be represented as 101001110, or decimal 334.

    The board must be a square, the length of which must be s.

    Every non-1 square must be 0.

    Returns a boolean value signifying whether 1 won.
    """
    # t is a value we'll use in each of the following calculations.
    t=2**s
    # h calculates a horizontal win. It's based on OEIS A090411. There
    # are multiple horizontal wins possible per board: one per row. The
    # i parameter represents which row will be used for this win.
    h=lambda i:(t-1)<<(s*(i+1)-s)
    # v calculates a vertical win. It's based on OEIS A033138. There
    # are multiple vertical wins possible per board: one per column. The
    # i parameter represents which column will be used for this win.
    v=lambda i:int(2**(s**2+i)/(t-1))
    # r is an iteration helper for h and v. It collects each row or
    # column of possible wins, based on the board size s.
    r=lambda f:[f(i) for i in range(s)]
    # d is a diagonal win shaped like "/". It is OEIS A119408.
    d=int((t*2**s**2-1)/(2*t-1))
    # u is a diagonal win shaped like "\". It is OEIS A244961.
    u=int((2**s**2-t)/(t-2))
    # To determine if 1 won, we bitwise And the board with each possible
    # win. If the win itself matches that value, then 1 has won.
    return any(b&w==w for w in r(h)+r(v)+[d,u])