Question
Create MachineOne, that has three states, A, B, and C, and accepts inputs f (for forward) and b (for back). The states transition on inputs
Create MachineOne, that has three states, A, B, and C, and accepts inputs f (for forward) and b (for back). The states transition on inputs according to:
the states are considered to be in a circular order, A then B then C then back to A, and so on. on input f, the state is advanced. I.e. from A to B, from B to C, and from C to A. on input b, the state retreats. I.e. from A to C, from B to A, and from C to B.
Replace the pass statement with code to implement MachineOne.
The machine begins in state A.
class MachineOne: def __init__(self): pass def signal(self,message): pass def get_state(self): pass return ''
Pass this test, and other tests that you can think of.
def run_tests_one(): tests = ['fffbbfbfbbffbbbf'] results = ['ABCACBCBCBABCBACA']
verdict = 'PASS' for t, r in zip(tests,results): if test_machine(MachineOne(), t) != r: verdict = 'FAIL' print(verdict) run_tests_one()
FAIL
Please either show brief code of python implementation or at least give me some ideas on how to pass the test.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started