Question: # Usage: # python 3 dfa.py 0 1 1 0 0 1 0 # Write a dimulator of a deterministic finite automata import numpy as
# Usage:
# python dfa.py
# Write a dimulator of a deterministic finite automata
import numpy as np
import sys
alphabet
states qr
acceptingstates q
transition npemptylenstateslenalphabet dtypeU
transitionstatesindexqalphabet.indexr
transitionstatesindexqalphabet.indexq
transitionstatesindexralphabet.indexq
transitionstatesindexralphabet.indexr
def DFAinput:
currentstate states
for symbol in input:
currentstate transitionstatesindexcurrentstatealphabet.indexsymbol
return currentstate
def main:
inputstring input
finalstate DFAinputstring
if finalstate in acceptingstates:
printAccept
else:
printReject
if namemain:
main
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
