public void Run() { computer.LoadProgram(FileUtils.LoadDataFor(13)) .SetInput(() => joystickInput) .SetOutput(GetX) .Run(); }
private Task RunComputerWithWiredIO(long phase, BlockingCollection <long> input, BlockingCollection <long> output) => Task.Run(() => new IntComputer() .LoadProgram(FileUtils.LoadDataFor(7)) .SetInput(() => input.Take())//InputEnumerator(phase, input)) .SetOutput((o) => output.Add(o)) .Run());
public Day9() { var computer = new IntComputer(); computer.LoadProgram(FileUtils.LoadDataFor(9)).SetInput(() => 1).SetOutput((o) => _answer1 = o).Run(); computer.LoadProgram(FileUtils.LoadDataFor(9)).SetInput(() => 2).SetOutput((o) => _answer2 = o).Run(); }
public Day2() { var computer = new IntComputer(); _answer1 = computer.LoadProgram(FileUtils.LoadDataFor(2)).Using(12, 2).Run().MemoryZeroAddress; _answer2 = FindVerbAndNounForOutput(computer, 19690720); }
public PaintingRobot(long startingPointColor = 0) { panelsGridPaintStatus.Add(currentPosition, startingPointColor); computer.LoadProgram(FileUtils.LoadDataFor(11)) .SetInput(ColorInput) .SetOutput(Paint) .Run(); }
public long GetDust() { var movements = GetAsciiInput(new string[] { "A,B,A,B,C,C,B,C,B,A", "R,12,L,8,R,12", "R,8,R,6,R,6,R,8", "R,8,L,8,R,8,R,4,R,4" }); var asciiInput = new Queue <long>(movements); computer.LoadProgram(FileUtils.LoadDataFor(17)) .SetMemory(2) .SetOutput(DustCollected) .SetInput(() => asciiInput.Dequeue()) .Run(); return(dustCollected); }
private int FindVerbAndNounForOutput(IntComputer computer, int output) { for (var noun = 0; noun < 100; noun++) { for (var verb = 0; verb < 100; verb++) { if (computer .LoadProgram(FileUtils.LoadDataFor(2)) .Using(noun, verb) .Run() .MemoryZeroAddress == output) { return((100 * noun) + verb); } } } return(0); }
public Scaffold() { computer.LoadProgram(FileUtils.LoadDataFor(17)) .SetOutput(CameraOutput) .Run(); FindIntersections(); //Print(true); RobotPosition currentPosition = screen.Where(s => !(s.Value == '#' || s.Value == '.')).Select(s => new RobotPosition(s.Value, s.Key)).FirstOrDefault(); List <Point> scaffoldPath = screen.Where(s => s.Value == 35).Select(s => s.Key).ToList(); scaffoldPath.AddRange(intersections); FindScaffoldPath(scaffoldPath, currentPosition); Console.WriteLine(GetDust()); }