The question is; Write a deterministic automata code for the language with ∑ = {0, 1} accepts the only input 101.
My classmate sent the following code but it doesnt seem to work. PLEASE HELP.
Code:
My classmate sent the following code but it doesnt seem to work. PLEASE HELP.
Code:
from automata.fa.dfa import DFA dfa=DFA( states={'q0','q1','q2','q3'}, inputs symbols={'0','1'}, transitions={ 'q0':{'0':'q0','1':'q1'} 'q1':{'0':'q2','1':'q1'} 'q2':{'0':'q2','1':'q3'} 'q3':{'0':'q3','1':'q3'} }, initial state='q0', final state={'q3'} ) dfa.read_input('101') #answer is '101' dfa.read_input('010') #answer is 'error' if dfa.accepts_inputs('101'): print('accepted') else: print('rejected')