示例#1
0
 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);
 }
示例#2
0
        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);
        }