public function __invoke()
 {
     $grid = new LightingGridWithAdjustableBrightness();
     $parser = new InstructionsParser($grid);
     $input = file_get_contents(__DIR__ . "/../../input/Day6/Puzzle1");
     $parser->parse($input);
     echo "Cumulative brightness of lights: " . $grid->getCumulativeBrightness();
 }
 public function __invoke()
 {
     $grid = new LightingGrid();
     $parser = new InstructionsParser($grid);
     $input = file_get_contents(__DIR__ . "/../../input/Day6/Puzzle1");
     $parser->parse($input);
     echo "Number of turned on lights: " . $grid->getNumberOfTurnOnLights();
 }
 public function __invoke()
 {
     $parser = new InstructionsParser();
     $parsed = $parser->parse($this->loadInput("Day19/Puzzle1"));
     $runner = new ReplacementRunner($parsed['replacements']);
     $possibles = $runner->possibleReplacements($parsed['molecule']);
     $this->write("Number of possibles: " . count($possibles));
 }
 public function __invoke()
 {
     $elevator = new Elevator();
     $parser = new InstructionsParser($elevator);
     $input = file_get_contents(__DIR__ . "/../../input/Day1/Puzzle1");
     $parser->parseInstructions($input);
     echo "Final floor: " . $elevator->getFloor();
 }
 public function __invoke()
 {
     $santa = new Santa();
     $parser = new InstructionsParser($santa);
     $input = file_get_contents(__DIR__ . "/../../input/Day3/Puzzle3");
     $parser->parse($input);
     echo "Total number of unique houses visited: " . $santa->getNumberOfUniqueHousesDeliveredTo();
 }
 public function __invoke()
 {
     $parser = new InstructionsParser();
     $parsed = $parser->parse($this->loadInput("Day19/Puzzle1"));
     $runner = new ReplacementRunner($parsed['replacements']);
     $steps = $runner->minimumNumberStepsForBuildingMolecule($parsed['molecule']);
     $this->write("Steps: " . $steps);
 }
 public function __invoke()
 {
     $input = $this->loadInput("Day15/Puzzle1");
     $parser = new InstructionsParser();
     $larder = $parser->parse($input);
     $combinations = new Combinations();
     $planner = new RecipePlanner($larder, $combinations);
     $megaCookie = $planner->megaCookie(100);
     $this->write("Mega cookie value: " . $megaCookie->totalScoreForRecipe());
 }
 public function __invoke()
 {
     $input = $this->loadInput("Day14/Puzzle1");
     $parser = new InstructionsParser();
     $herd = $parser->parse($input);
     $race = new Race($herd);
     $duration = 2503;
     $winner = $race->pointsWinnerAfter($duration);
     $this->write("Winner: " . $winner->name() . " with " . $winner->points() . " points");
 }
 public function __invoke()
 {
     $elevator = new Elevator();
     $parser = new InstructionsParser($elevator);
     $input = file_get_contents(__DIR__ . "/../../input/Day1/Puzzle1");
     $parser->parseInstructions($input);
     $log = $parser->getInstructionsLog();
     $logEntryKey = array_search("-1", $log);
     echo "Instruction # entered for first entry to basement: " . ($logEntryKey + 1);
 }
 public function __invoke()
 {
     $input = $this->loadInput("Day14/Puzzle1");
     $parser = new InstructionsParser();
     $herd = $parser->parse($input);
     $race = new Race($herd);
     $duration = 2503;
     $winner = $race->winnerAfter($duration);
     $this->write("Winner: " . $winner->name() . ", who has flown " . $winner->distanceAfter($duration));
 }
 public function __invoke()
 {
     $circuit = new Circuit(new WiresCollection());
     $parser = new InstructionsParser($circuit);
     $input = file_get_contents(__DIR__ . "/../../input/Day7/Puzzle1");
     $instructions = explode(PHP_EOL, $input);
     while (true) {
         foreach ($instructions as $k => $instruction) {
             if ($parser->parse($instruction) !== false) {
                 unset($instructions[$k]);
             }
         }
         if (empty($instructions)) {
             break;
         }
     }
     echo "Signal provided to wire 'a':" . $circuit->getWireValue("a");
 }
 public function __invoke()
 {
     $input = $this->loadInput("Day16/Puzzle1");
     $parser = new InstructionsParser();
     $gifterProperties = ["children" => 3, "cats" => 7, "samoyeds" => 2, "pomeranians" => 3, "akitas" => 0, "vizslas" => 0, "goldfish" => 5, "trees" => 3, "cars" => 2, "perfumes" => 1];
     foreach (explode(PHP_EOL, $input) as $instruction) {
         $sue = $parser->parse($instruction);
         $couldBeThisSue = true;
         foreach ($gifterProperties as $property => $value) {
             if (!$sue->couldBe($property, $value)) {
                 $couldBeThisSue = false;
                 break;
             }
         }
         if ($couldBeThisSue) {
             break;
         }
     }
     $this->write("Sue number: " . $sue->number());
 }