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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!