
The Historians push the button on their strange device, but this time, you all just feel like you’re falling.
Solution in Java
Full source can be found: in GitHub
Part 1
The first thing for today is modelling Opcode and the ComputeEngine. Where the compute engine represents the machine that is executing the instruction in the input string.
1enum Opcode {
2 adv, bxl, bst, jnz, bxc, out, bdv, cdv
3}
4
5public static class ComputeEngine {
6 private final long[] registers;
7
8 int[] program;
9 int instructionPointer;
10
11 List<Integer> output = new ArrayList<>();
12
13 public ComputeEngine(long[] registers, int[] program) {
14 this.registers = registers;
15 this.program = program;
16 this.instructionPointer = 0;
17 }
18}
Using these two entities it is already possible to create the method that converts the input string.
[Read More]







