def isNumber(self, s):
        """
        D-FSA: Deterministic Finite State Automata
        Transition table T, which is constructed from FSA

        state = T[state, token]

        Draw the diagram for FSA
        :param s:
        :return:
        """
        INVALID = 0
        SPACE = 1
        SIGN = 2
        DIGIT = 3
        DOT = 4
        E = 5
        T = [
            [-1, 0, 3, 1, 2,-1],
            [-1, 8,-1, 1, 4, 5],
            [-1,-1,-1, 4,-1,-1],
            [-1,-1,-1, 1, 2,-1],
            [-1, 8,-1, 4,-1, 5],
            [-1,-1, 6, 7,-1,-1],
            [-1,-1,-1, 7,-1,-1],
            [-1, 8,-1, 7,-1,-1],
            [-1, 8,-1,-1,-1,-1], # 9
        ]
        state = 0
        for char in s:
            if state==-1:
                return False
            if char==" ":
                token = SPACE
            elif char in ("-", "+"):
                token = SIGN
            elif char in map(str, range(10)):
                token = DIGIT
            elif char==".":
                token = DOT
            elif ("e", "E") in char:
                token = E
            else:
                token = INVALID

            state = T[state][token]
        if state in (1, 4, 7, 8):  # accept state
            return True
        else:
            return False
dataset/ETHPy150Open algorhythms/LeetCode/066 Valid Number.py/Solution.isNumber/swapped operands of `in`