← Quiz: Mealy and Moore Machines: all 10 questions
Quiz: Mealy and Moore Machines · Question 4 of 10
What does this print? (code)
What does this print?
delta = {("r0", "0"): "r0", ("r0", "1"): "r1", ("r1", "0"): "r2",
("r1", "1"): "r0", ("r2", "0"): "r1", ("r2", "1"): "r2"}
out = {"r0": "0", "r1": "1", "r2": "2"}
state, result = "r0", out["r0"]
for ch in "100":
state = delta[(state, ch)]
result += out[state]
print(result)
- A.121
- B.0112
- C.012
- D.0121
Answer & explanation
Correct answer: 0121
Remainders of 0, 1, 2 (= 10₂) and 4 (= 100₂) mod 3 are 0, 1, 2, 1.
Can you get the rest right without peeking?
Take the timed Quiz: Mealy and Moore Machines quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →