import machine
# -------------------------
# State definitions
# -------------------------
A = 0
B = 1
C = 2
D = 3
# -------------------------
# FSM state variable
# -------------------------
state = A # initial state
# -------------------------
# FSM function
# -------------------------
def fsm(input_bool):
global state
if state == A:
print("A", end="")
state = B if input_bool else C
elif state == B:
print("B", end="")
state = C if input_bool else D
elif state == C:
print("C", end="")
state = B if input_bool else A
elif state == D:
print("D", end="")
state = A if input_bool else C
inputs = [True, False, True, True, False, False, True]
for i in inputs:
fsm(i)
print() # newline