01020304050607080910111213141516171819202122232425

Advent of Code

2019/21

Springdroid Adventure

in C#

by encse

You lift off from Pluto and start flying in the direction of Santa.

While experimenting further with the tractor beam, you accidentally pull an asteroid directly into your ship! It deals significant damage to your hull and causes your ship to begin tumbling violently.

Read the full puzzle.

using System.Linq;

namespace AdventOfCode.Y2019.Day21;

[ProblemName("Springdroid Adventure")]
class Solution : Solver {

    public object PartOne(string input) {
        var icm = new IntCodeMachine(input);
        
        // J = (¬A ∨ ¬B ∨ ¬C) ∧ D  
        // jump if no road ahead, but we can continue from D
        return new IntCodeMachine(input).Run(
            "OR A T",
            "AND B T",
            "AND C T",
            "NOT T J", 
            "AND D J", 
            "WALK"
        ).Last();
    }

    public object PartTwo(string input) {

         // J = (¬A ∨ ¬B ∨ ¬C) ∧ D ∧ (H ∨ E) 
         // same as part 1, but also check that D is not a dead end
        return new IntCodeMachine(input).Run(
            "OR A T",
            "AND B T",
            "AND C T",
            "NOT T J",  
            "AND D J", 
            "OR H T",
            "OR E T",
            "AND T J", 
            "RUN"
        ).Last();
    }
}

Please ☆ my repo if you like it!

© 2025 Advent of Code is a registered trademark in the US Images provided by Bing image creator