Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to implement dfa in python

dfa = {0:{'0':0, '1':1},
       1:{'0':2, '1':0},
       2:{'0':1, '1':2}}
def accepts(transitions,initial,accepting,s):
    state = initial
    for c in s:
        state = transitions[state][c]
    return state in accepting
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #implement #dfa #python
ADD COMMENT
Topic
Name
9+1 =