Source: Leonardo’s Monorail
Part 1: Create a virtual machine that has four registers (
a
,b
,c
, andd
) and can process the following instructions:
cpy x y
- copiesx
intoy
(x
can be an integer or a register)inc x
- increases registerx
by onedec x
- decreases registerx
by onejnz x y
- jumps overy
instructions ifx
is not zero (x
can be an integer or a register)
What is the final value in register
a
?