human
DFA for Strings not ending with " THE " | This function is for the starting state ( zeroth ) of DFA.
On receiving ' T ' or ' t ' goto first state ( 1 ).
This function is for the first state of DFA.
On receiving ' T ' or ' t ' goto first state ( 1 ).
On receiving ' H ' or ' h ' goto second state ( 2 ).
else goto starting state ( 0 ).
This function is for the second state of DFA.
On receiving ' E ' or ' e ' goto third state ( 3 ) else goto starting state ( 0 ).
This function is for the third state of DFA.
On receiving ' T ' or ' t ' goto first state ( 1 ) else goto starting state ( 0 ).
store length of stringing.
Driver Code"
Solution in Python:
assistant
#Here is code to dFA for Strings not ending with " THE " and the other steps required.
 def start ( c ) :
	if ( c == ' t ' or c == ' T ' ) :
		dfa = 1
def state1 ( c ) :
	if ( c == ' t ' or c == ' T ' ) :
		dfa = 1
	elif ( c == ' h ' or c == ' H ' ) :
		dfa = 2
	else :
		dfa = 0
def state2 ( c ) :
	if ( c == ' e ' or c == ' E ' ) :
		dfa = 3
	else :
		dfa = 0
def state3 ( c ) :
	if ( c == ' t ' or c == ' T ' ) :
		dfa = 1
	else :
		dfa = 0
def isAccepted ( string ) :
	length = len ( string )
	for i in range ( length ) :
		if ( dfa == 0 ) :
			start ( string [ i ] )
		elif ( dfa == 1 ) :
			state1 ( string [ i ] )
		elif ( dfa == 2 ) :
			state2 ( string [ i ] )
		else :
			state3 ( string [ i ] )
	return ( dfa != 3 )
if __name__ == " _ _ main _ _ " :
	string = " forTHEgeeks "
dfa = 0
	if isAccepted ( string ) :
		print ( " ACCEPTED " )
	else :
		print ( " NOT ▁ ACCEPTED " )