diff --git a/Day7/Question2/input b/Day7/Question2/input new file mode 100644 index 0000000..1de5cbd --- /dev/null +++ b/Day7/Question2/input @@ -0,0 +1,142 @@ +......................................................................S...................................................................... +............................................................................................................................................. +......................................................................^...................................................................... +............................................................................................................................................. +.....................................................................^.^..................................................................... +............................................................................................................................................. +....................................................................^.^.^.................................................................... +............................................................................................................................................. +...................................................................^.^.^.^................................................................... +............................................................................................................................................. +..................................................................^.^.^.^.^.................................................................. +............................................................................................................................................. +.................................................................^...^...^.^................................................................. +............................................................................................................................................. +................................................................^.^.^...^...^................................................................ +............................................................................................................................................. +...............................................................^.....^...^...^............................................................... +............................................................................................................................................. +..............................................................^...^.^.....^.^.^.............................................................. +............................................................................................................................................. +.............................................................^.^.^...^.......^.^............................................................. +............................................................................................................................................. +............................................................^...^.^.....^.^.^.^.^............................................................ +............................................................................................................................................. +...........................................................^.^.....^.^.....^.^.^.^........................................................... +............................................................................................................................................. +..........................................................^.^...^.^...^.^.^.^.^...^.......................................................... +............................................................................................................................................. +.........................................................^...^.^.....^.^.....^.^.^.^......................................................... +............................................................................................................................................. +........................................................^.^.^.......^.^.^.^.^.^.^.^.^........................................................ +............................................................................................................................................. +.......................................................^.^.^.....^...^.....^.^.^...^.^....................................................... +............................................................................................................................................. +......................................................^...^.^.^.^.^.^.^.......^.^.^.^.^...................................................... +............................................................................................................................................. +.....................................................^.^.^...^...^...^.....^.......^.^.^..................................................... +............................................................................................................................................. +....................................................^...^...^.^.^...^.^.^.^.^...^.^.^...^.................................................... +............................................................................................................................................. +...................................................^...^...^.^...^.^...^...^...........^.^................................................... +............................................................................................................................................. +..................................................^.^.^.^.^.......^.^.^.^.^...^.^...^.^.^.^.................................................. +............................................................................................................................................. +.................................................^.^.^.^.....^.^.^.......^.^.......^.^.^.^.^................................................. +............................................................................................................................................. +................................................^...^.^.^.^.^.^.^.^.^.^.^.....^...^.^.^...^.^................................................ +............................................................................................................................................. +...............................................^.^...^...^.^.^.^...^.^.^.^...^.^.^...^.^.^...^............................................... +............................................................................................................................................. +..............................................^...^.^...^.^.^.....^.^.^.^...^.^.^.^.^...^.....^.............................................. +............................................................................................................................................. +.............................................^.....^...^...^.^...^.....^.^.^.^...^.......^.^...^............................................. +............................................................................................................................................. +............................................^.^...^.^.^.^.^.^.^...^.^.^.^.^...^.....^.^.^.^...^.^............................................ +............................................................................................................................................. +...........................................^.^.^.^.^.^.......^.^...^.^.^.....^.^.^.......^...^.^.^........................................... +............................................................................................................................................. +..........................................^...^.^.^.^.^.^.^...^.^.....^.^.^.^.....^.^.^.^...^.^.^.^.......................................... +............................................................................................................................................. +.........................................^.^...^...^.....^.^...^.^.^.^...^.......^...^...^.^.....^.^......................................... +............................................................................................................................................. +........................................^.^...^.^.^.^...........^.^...^.^.....^...^.^.....^.^...^.^.^........................................ +............................................................................................................................................. +.......................................^.^...^.^.^.^.^...^.^.^...^.^.....^.......^.^.^.^.....^.^.....^....................................... +............................................................................................................................................. +......................................^...^.^.^...^.......^...^.^.^...^...^.^.^...^...^.....^...^.^.^.^...................................... +............................................................................................................................................. +.....................................^.^.^.^.......^.^...^.^.^.^.^...^.^.....^.^.^.^...^.^.^.^...^.^.^.^..................................... +............................................................................................................................................. +....................................^...^...^.^.^.^.^.....^.^.^.^...^...^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.^.................................... +............................................................................................................................................. +...................................^.....^.^...^...^.^...^.^...^.^.^.^.......^.^.^.^.^.^.^.^...^.^.^.^.^.^................................... +............................................................................................................................................. +..................................^.^.^...^.^.^...^.^.^...^.^.^.^.^.^.^.^.^.^.^...^.^.^...^...^...^.^.^.^.^.................................. +............................................................................................................................................. +.................................^.^.^.^.^.^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.^.....^.^...^...^.^...^.^.^.^...^................................. +............................................................................................................................................. +................................^.^.^.....^.^.....^...^.^.^.^.^.^...^...^.^...^.....^.^.^.^.^.^.^.^.^...^.^.^................................ +............................................................................................................................................. +...............................^.^.^.^.....^.^.....^.^.....^.^.....^.....^.^...^.^.....^.^.....^...^.^.^.^.^.^............................... +............................................................................................................................................. +..............................^.^.^.^...^.....^.^.^.........^.^.......^...^...^...^.^.^.^.......^.^.^.^.^.^.^.^.............................. +............................................................................................................................................. +.............................^.^.^.....^.^.^.....^.^.^.^...^.....^.^.^.^.^...^.^.^.^.^.^.^...^.^.^.^.......^.^.^............................. +............................................................................................................................................. +............................^...^.^.^.^.^...^.^.....^.^...^...^.^.....^.^...^.^.^.^...^.^.^.^.^.^...^.^...^.^.^.^............................ +............................................................................................................................................. +...........................^.....^.^.^.^.^...^.^.^.^.........^.^.^.^.^.^.^.^.^.^.^.^.^.^.....^.^.^.^.^.^.^.^.^.^.^........................... +............................................................................................................................................. +..........................^.^.......^.^.^...^.^.^.^.^...^.^.^...^.^...^.^.^.^...^...^...^.^...^...^.^.^.^.^.^.....^.......................... +............................................................................................................................................. +.........................^.^.^...^.^.^...^.^...^.^.^.^.^.^.^.......^.^.^.^...^.^.....^.....^.^.^.^...^.....^.^.^...^......................... +............................................................................................................................................. +........................^.^.....^.^.^.^.^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.^...^.....^...^.^.^.^.^.^.^.....^.^...^.^.^.^........................ +............................................................................................................................................. +.......................^.^.^.^...^...^...^.^.^...^.^.^.^.^.....^.^.......^.^...^.^...^.^.^...^...^.^.^...^.^.....^...^....................... +............................................................................................................................................. +......................^.^.........^.....^.^.....^...^...^...^.^.^.^.^.......^.^...^...^.^.^.^.......^.^...^.^.^...^.^.^...................... +............................................................................................................................................. +.....................^.^.^...^...^.^...^.^.^...^...^.^.^.^.^.^.^...^...^.^.^.^.....^.^.^...^.^.....^...^...^...^.^.^.^.^..................... +............................................................................................................................................. +....................^.^.^...^.^.^...^.^.^.....^.......^.^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.....^.^.^.^.^.^...^.^.^...^.^.^.^.................... +............................................................................................................................................. +...................^.....^.^...^.^...^.^...^.^.....^...^.^.^.......^.^.^.^.^.^.^.^.^...^.^.^.^.^...^.^.^.^...^.^.^.^.^...^................... +............................................................................................................................................. +..................^.^.^.^.^.^.^...^.^.^.^.....^.^.^.^.^.^.^...^.^...^...^...^.^.^.^.......^.^.^.....^.^...^.^.^...^.^...^.^.................. +............................................................................................................................................. +.................^...^.^.^.^.^...^.......^.^.^.....^.^...^...^.^.^...^.^...^...^...^...^.^.^...^...^.^...^.^.^.^.^.^.^.^.^.^................. +............................................................................................................................................. +................^.^...^...^.^...^.^.....^.^.^.^.^.^.......^.^.^...^.^.^.^.^.^.^.^.^...........^.^.^.....^.....^.^.^.^.^.^...^................ +............................................................................................................................................. +...............^.^.^...^.^.^.^.^.^.........^.^.^.^.^.......^...^.....^...^.^...^.....^...^...^...^.^.^.^.^.^.^.^.^.^.^.^.^.^.^............... +............................................................................................................................................. +..............^.^.^.^.^.^.^.^.^.^.^.^...^.^...^.^.^.^.^...^.^...^.......^.^...^.^.^...^.....^.^.^...^.^.^.^.^...^.^.^.^.^...^.^.............. +............................................................................................................................................. +.............^.^.^.^.^...^.^.^.......^.^.^...^.^.^.^...^.^.^.^...^.....^.^.......^.^.........^.^.^.^.^.....^.^.^.^.^.^.^...^.^.^............. +............................................................................................................................................. +............^...^.^...^.^.^.^.^.^...........^.^.^.^.^.^.^.^.^.^.....^.^.^.^...^.....^.^.......^...^.^...^.....^.^.^...^.^.^...^.^............ +............................................................................................................................................. +...........^.^.^.^.^.^.^.....^.^...^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.....^.^.^.^.^.^...^...^.^.^.^...^.^.^.^...^.^.^.^...^.^.^.^.^.^........... +............................................................................................................................................. +..........^...^.^.^.^.^.^...^...^.^...^.^.^.^.^.^...^.^...^.^.^.^.^.^.^.^...^.^.^...^.^.^...^.^.^.^...^...^.^.^.^.^.^...^.^.^.^.^.^.......... +............................................................................................................................................. +.........^...^.^...^.....^.^.^...^.......^.^.....^.......^...^...^...^.^.^.^.^.^.^.....^.^.^.....^.^.^.^.^...^.^.^.^.^.^.^.^.^.^.^.^......... +............................................................................................................................................. +........^.^...........^...^.......^.^...^.^.^...^.^.^.^...^.^...^.^.^.......^...^.^.^.^.^.^.^.^.^.^.....^...^...^.....^.^.^.^.^.^.^.^........ +............................................................................................................................................. +.......^...^...^.^.^...^.^.^.....^.^...^.^.^...^...^.^.^.^.^.^.^.^.^.^.^.^.^...^.^.^...^.^...^...^.^.^...^.^.^.^.^.....^...^.^.....^.^....... +............................................................................................................................................. +......^...^.^...^...^...^.^.^...^.^.^.^...^...^.^.^...^.^.....^.^.^...^.....^...^.^...^.......^.^...^.^.....^...^.^.^.^.^.^.^.^.^.^...^...... +............................................................................................................................................. +.....^.^.^.^...^.^.....^.^...^.^.......^.^.^.^.^.^.^.^.^.^...^...^.^.^.^.^...^.^.^.^.^.^.^...^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.^...^...^.^..... +............................................................................................................................................. +....^...^...^.^.^.^...^.^.^...^.^.....^.^.^...^.^.^.^...^.^.^.^.^...^.^.^.^.^...^.^.^.^.^.^.......^.^.^.^.^.....^.^.^.^...^.^.^.^.^...^.^.... +............................................................................................................................................. +...^.^...^...^.......^...^.^.^...^.^.^.^.^.^.^.^.^.^.^...^.^...^.^.^.^.^...^...^.^...^...^.^.^.^.^.^.^.^.^.....^...^.^...^.^...^.^.^.^...^... +............................................................................................................................................. +..^.^.........^.^.^.^.^.^.^.^.^.^...^.......^.^.^.^...^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^...........^.....^.^.^.^.^.^.^.^.^.^.^.^.^...^.^...^.^.. +............................................................................................................................................. +.^.^.^.^.^.....^.^.^.^.^.^.^.^.^.^.....^.^...^.^.^.^.^.^...^.^...^.^.^.^.^...^...^...^...^.^.^.^.^.^...^.^.^.^.^.^.^.^...^.^.^.^.^.^.^.....^. +............................................................................................................................................. diff --git a/Day7/Question2/inputTest b/Day7/Question2/inputTest new file mode 100644 index 0000000..57a2466 --- /dev/null +++ b/Day7/Question2/inputTest @@ -0,0 +1,16 @@ +.......S....... +............... +.......^....... +............... +......^.^...... +............... +.....^.^.^..... +............... +....^.^...^.... +............... +...^.^...^.^... +............... +..^...^.....^.. +............... +.^.^.^.^.^...^. +............... diff --git a/Day7/Question2/main.cpp b/Day7/Question2/main.cpp new file mode 100644 index 0000000..88ccd57 --- /dev/null +++ b/Day7/Question2/main.cpp @@ -0,0 +1,44 @@ +#include +#include +#include +#include +#include +#include + +int main() { + std::fstream input("input"); + std::string currentLine = ""; + uint16_t lineCount = 0, lengthOfALine = 0; + uint64_t password = 0; + + // We are skipping the first line since it only tells us + // where to start with 'S' + std::getline(input, currentLine, '\n'); + lengthOfALine = currentLine.length(); + std::vector beams(lengthOfALine, 0); + beams[currentLine.find('S')] = 1; + + // Each path the beam went now *sigh* + while (std::getline(input, currentLine, '\n')) { + // Ignore useless middle lines + if (lineCount % 2 == 1) { + for (int16_t position = 0; position < lengthOfALine; position++) { + if (currentLine[position] == '^' && beams[position]) { + // Basically idea is to pass the possible timelines to the split beams + beams[std::max(position - 1, 0)] += beams[position]; + beams[std::min(position + 1, static_cast(lengthOfALine))] += + beams[position]; + beams[position] = 0; + } + } + } + lineCount++; + } + + // Let's see how many possible timelines were able to reach at the end + for (uint64_t val : beams) { + password += val; + } + + std::cout << password << std::endl; +}