static void Main(string[] args) { var input = File.ReadAllText(@"C:\git\AdventOfCode2019\input\2019 - Day 25.txt"); var vm = new IntCodeVM(input); vm.InputFunction = StartInput; var outputs = vm.Run(); Console.Write(GetOutputString(outputs)); }
private static long NextInput(IntCodeVM vm) { var result = _inputs.First(); _inputs.RemoveAt(0); if (!_inputs.Any()) { vm.InputFunction = StartInput; } return(result); }
private static long StartInput(IntCodeVM vm) { var output = GetOutputString(vm.Outputs); vm.Outputs.Clear(); Console.Write(output); var input = Console.ReadLine(); _inputs = GetInputList(input); vm.InputFunction = NextInput; return(NextInput(vm)); }