public static async Task RunProgramAsync( long[] program, Func <CancellationToken, ValueTask <long> > read, Func <long, CancellationToken, ValueTask> write, CancellationToken cancellationToken = default) { var vm = new IntcodeMachine(program, read, write); await vm.StepUntilHalted(cancellationToken); }
static void Main(string[] args) { var code = File.ReadLines(args.FirstOrDefault() ?? "input.txt").FirstOrDefault(); var program = IntcodeMachine.ParseCode(code); // Part 1 RunPart1(program); // Part 2 RunPart2(program); }