public async Task AddressingMode() { var intcode = new IntcodeComputer(new BigInteger[] { 1002, 4, 3, 4, 33 }); await intcode.RunAsync(); Assert.AreEqual(99, intcode.Get(4)); }
public async Task Computer(string memory, int address, int expected) { var intcode = new IntcodeComputer(memory); await intcode.RunAsync(); Assert.AreEqual(expected, intcode.Get(address)); }
public async Task <BigInteger> Part1() { var intcode = new IntcodeComputer(_input); intcode.Set(1, 12); intcode.Set(2, 2); await intcode.RunAsync(); return(intcode.Get(0)); }
public async Task <int> Part2() { for (int noun = 0; noun < 100; noun++) { for (int verb = 0; verb < 100; verb++) { var intcode = new IntcodeComputer(_input); intcode.Set(1, noun); intcode.Set(2, verb); await intcode.RunAsync(); if (intcode.Get(0) == 19690720) { return((noun * 100) + verb); } } } throw new Exception("not found"); }