#cm, 3 registers Start: R3=0 Clear R1=0 Move1 R2=0 Add1 End Clear / R3-1: R3=0 Clear R1=0 Move1 R2=0 Add1 End Move1 / R1-1: Move2 Move2 / R3+1: R1=0 Move1 R2=0 Add1 End Add1 / R2-1: Add2 Add2 / R3+1: R2=0 Add1 End
#cm, 3 registers Start: R3=0 Clear R1=0 Move1 R2=0 Add1 End Clear / R3-1: R3=0 Clear R1=0 Move1 R2=0 Add1 End Move1 / R1-1: Move2 Move2 / R3+1: R1=0 Move1 R2=0 Add1 End Add1 / R2-1: Add2 Add2 / R3+1: R2=0 Add1 End
R1
R2
R3
length
R1
R2
R3
Input
1
()
3
()
2
()
Output
0
()
0
()
4
()
#
State
Operation
R1
R2
R3
0
Start
1
()
3
()
2
()
1
Clear
R3-1
1
()
2
Clear
R3-1
0
()
3
Move1
R1-1
0
()
4
Move2
R3+1
1
()
5
Add1
R2-1
2
()
6
Add2
R3+1
2
()
7
Add1
R2-1
1
()
8
Add2
R3+1
3
()
9
Add1
R2-1
0
()
10
Add2
R3+1
4
()
11
End