human
Program to construct DFA accepting odd number of 0 s and odd number of 1 s | Function to check whether the given is accepted by DFA or not.
Stores initial state of DFA.
Stores final state of DFA.
Stores previous state of DFA.
Iterate through the string.
Checking for all combinations.
Update the previous_state.
If final state is reached.
Otherwise.
Driver Code.
Given string.
Function Call"
Solution in Python:
 What is a code to program to construct DFA accepting odd number of 0 s and odd number of 1 s and the other steps required?
assistant
#Here is code to program to construct DFA accepting odd number of 0 s and odd number of 1 s and the other steps required.
 def checkValidDFA ( s ) :
	initial_state = 0
	final_state = 0
	previous_state = 0
	for i in range ( len ( s ) ) :
		if ( ( s [ i ] == '0' and previous_state == 0 ) or ( s [ i ] == '1' and previous_state == 3 ) ) :
			final_state = 1
		elif ( ( s [ i ] == '0' and previous_state == 3 ) or ( s [ i ] == '1' and previous_state == 0 ) ) :
			final_state = 2
		elif ( ( s [ i ] == '0' and previous_state == 1 ) or ( s [ i ] == '1' and previous_state == 2 ) ) :
			final_state = 0
		elif ( ( s [ i ] == '0' and previous_state == 2 ) or ( s [ i ] == '1' and previous_state == 1 ) ) :
			final_state = 3
		previous_state = final_state
	if ( final_state == 3 ) :
		print ( " Accepted " )
	else :
		print ( " Not ▁ Accepted " )
if __name__ == ' _ _ main _ _ ' :
	s = "010011"
	checkValidDFA ( s )