/** * @param InputInterface $input * @param OutputInterface $output * @return int|null|void */ protected function execute(InputInterface $input, OutputInterface $output) { if (null !== ($filename = $input->getOption('file'))) { if (file_exists($filename)) { $instructions = file_get_contents($filename); } else { $output->writeln('Unable to open file. Please check the path and make sure the file exists.'); return; } } elseif (null === ($instructions = $input->getOption('string'))) { $output->writeln('Please provide either a string or a file using --string="xxx" or --file="/path/to/file"'); return; } $output->writeln('DAY 1 - Puzzle 1'); $output->writeln('Result: ' . Day1::calculateFloor($instructions)); $output->writeln('DAY 1 - Puzzle 2'); $output->writeln('Result: ' . Day1::calculateBasementEntry($instructions)); }
/** * @dataProvider calculateBasementEntryInputProvider */ public function testCalculateBasementEntry($input, $expected) { $this->assertEquals($expected, Day1::calculateBasementEntry($input)); }