Day 7 Question 2
This commit is contained in:
142
Day7/Question2/input
Normal file
142
Day7/Question2/input
Normal file
@@ -0,0 +1,142 @@
|
||||
......................................................................S......................................................................
|
||||
.............................................................................................................................................
|
||||
......................................................................^......................................................................
|
||||
.............................................................................................................................................
|
||||
.....................................................................^.^.....................................................................
|
||||
.............................................................................................................................................
|
||||
....................................................................^.^.^....................................................................
|
||||
.............................................................................................................................................
|
||||
...................................................................^.^.^.^...................................................................
|
||||
.............................................................................................................................................
|
||||
..................................................................^.^.^.^.^..................................................................
|
||||
.............................................................................................................................................
|
||||
.................................................................^...^...^.^.................................................................
|
||||
.............................................................................................................................................
|
||||
................................................................^.^.^...^...^................................................................
|
||||
.............................................................................................................................................
|
||||
...............................................................^.....^...^...^...............................................................
|
||||
.............................................................................................................................................
|
||||
..............................................................^...^.^.....^.^.^..............................................................
|
||||
.............................................................................................................................................
|
||||
.............................................................^.^.^...^.......^.^.............................................................
|
||||
.............................................................................................................................................
|
||||
............................................................^...^.^.....^.^.^.^.^............................................................
|
||||
.............................................................................................................................................
|
||||
...........................................................^.^.....^.^.....^.^.^.^...........................................................
|
||||
.............................................................................................................................................
|
||||
..........................................................^.^...^.^...^.^.^.^.^...^..........................................................
|
||||
.............................................................................................................................................
|
||||
.........................................................^...^.^.....^.^.....^.^.^.^.........................................................
|
||||
.............................................................................................................................................
|
||||
........................................................^.^.^.......^.^.^.^.^.^.^.^.^........................................................
|
||||
.............................................................................................................................................
|
||||
.......................................................^.^.^.....^...^.....^.^.^...^.^.......................................................
|
||||
.............................................................................................................................................
|
||||
......................................................^...^.^.^.^.^.^.^.......^.^.^.^.^......................................................
|
||||
.............................................................................................................................................
|
||||
.....................................................^.^.^...^...^...^.....^.......^.^.^.....................................................
|
||||
.............................................................................................................................................
|
||||
....................................................^...^...^.^.^...^.^.^.^.^...^.^.^...^....................................................
|
||||
.............................................................................................................................................
|
||||
...................................................^...^...^.^...^.^...^...^...........^.^...................................................
|
||||
.............................................................................................................................................
|
||||
..................................................^.^.^.^.^.......^.^.^.^.^...^.^...^.^.^.^..................................................
|
||||
.............................................................................................................................................
|
||||
.................................................^.^.^.^.....^.^.^.......^.^.......^.^.^.^.^.................................................
|
||||
.............................................................................................................................................
|
||||
................................................^...^.^.^.^.^.^.^.^.^.^.^.....^...^.^.^...^.^................................................
|
||||
.............................................................................................................................................
|
||||
...............................................^.^...^...^.^.^.^...^.^.^.^...^.^.^...^.^.^...^...............................................
|
||||
.............................................................................................................................................
|
||||
..............................................^...^.^...^.^.^.....^.^.^.^...^.^.^.^.^...^.....^..............................................
|
||||
.............................................................................................................................................
|
||||
.............................................^.....^...^...^.^...^.....^.^.^.^...^.......^.^...^.............................................
|
||||
.............................................................................................................................................
|
||||
............................................^.^...^.^.^.^.^.^.^...^.^.^.^.^...^.....^.^.^.^...^.^............................................
|
||||
.............................................................................................................................................
|
||||
...........................................^.^.^.^.^.^.......^.^...^.^.^.....^.^.^.......^...^.^.^...........................................
|
||||
.............................................................................................................................................
|
||||
..........................................^...^.^.^.^.^.^.^...^.^.....^.^.^.^.....^.^.^.^...^.^.^.^..........................................
|
||||
.............................................................................................................................................
|
||||
.........................................^.^...^...^.....^.^...^.^.^.^...^.......^...^...^.^.....^.^.........................................
|
||||
.............................................................................................................................................
|
||||
........................................^.^...^.^.^.^...........^.^...^.^.....^...^.^.....^.^...^.^.^........................................
|
||||
.............................................................................................................................................
|
||||
.......................................^.^...^.^.^.^.^...^.^.^...^.^.....^.......^.^.^.^.....^.^.....^.......................................
|
||||
.............................................................................................................................................
|
||||
......................................^...^.^.^...^.......^...^.^.^...^...^.^.^...^...^.....^...^.^.^.^......................................
|
||||
.............................................................................................................................................
|
||||
.....................................^.^.^.^.......^.^...^.^.^.^.^...^.^.....^.^.^.^...^.^.^.^...^.^.^.^.....................................
|
||||
.............................................................................................................................................
|
||||
....................................^...^...^.^.^.^.^.....^.^.^.^...^...^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.^....................................
|
||||
.............................................................................................................................................
|
||||
...................................^.....^.^...^...^.^...^.^...^.^.^.^.......^.^.^.^.^.^.^.^...^.^.^.^.^.^...................................
|
||||
.............................................................................................................................................
|
||||
..................................^.^.^...^.^.^...^.^.^...^.^.^.^.^.^.^.^.^.^.^...^.^.^...^...^...^.^.^.^.^..................................
|
||||
.............................................................................................................................................
|
||||
.................................^.^.^.^.^.^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.^.....^.^...^...^.^...^.^.^.^...^.................................
|
||||
.............................................................................................................................................
|
||||
................................^.^.^.....^.^.....^...^.^.^.^.^.^...^...^.^...^.....^.^.^.^.^.^.^.^.^...^.^.^................................
|
||||
.............................................................................................................................................
|
||||
...............................^.^.^.^.....^.^.....^.^.....^.^.....^.....^.^...^.^.....^.^.....^...^.^.^.^.^.^...............................
|
||||
.............................................................................................................................................
|
||||
..............................^.^.^.^...^.....^.^.^.........^.^.......^...^...^...^.^.^.^.......^.^.^.^.^.^.^.^..............................
|
||||
.............................................................................................................................................
|
||||
.............................^.^.^.....^.^.^.....^.^.^.^...^.....^.^.^.^.^...^.^.^.^.^.^.^...^.^.^.^.......^.^.^.............................
|
||||
.............................................................................................................................................
|
||||
............................^...^.^.^.^.^...^.^.....^.^...^...^.^.....^.^...^.^.^.^...^.^.^.^.^.^...^.^...^.^.^.^............................
|
||||
.............................................................................................................................................
|
||||
...........................^.....^.^.^.^.^...^.^.^.^.........^.^.^.^.^.^.^.^.^.^.^.^.^.^.....^.^.^.^.^.^.^.^.^.^.^...........................
|
||||
.............................................................................................................................................
|
||||
..........................^.^.......^.^.^...^.^.^.^.^...^.^.^...^.^...^.^.^.^...^...^...^.^...^...^.^.^.^.^.^.....^..........................
|
||||
.............................................................................................................................................
|
||||
.........................^.^.^...^.^.^...^.^...^.^.^.^.^.^.^.......^.^.^.^...^.^.....^.....^.^.^.^...^.....^.^.^...^.........................
|
||||
.............................................................................................................................................
|
||||
........................^.^.....^.^.^.^.^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.^...^.....^...^.^.^.^.^.^.^.....^.^...^.^.^.^........................
|
||||
.............................................................................................................................................
|
||||
.......................^.^.^.^...^...^...^.^.^...^.^.^.^.^.....^.^.......^.^...^.^...^.^.^...^...^.^.^...^.^.....^...^.......................
|
||||
.............................................................................................................................................
|
||||
......................^.^.........^.....^.^.....^...^...^...^.^.^.^.^.......^.^...^...^.^.^.^.......^.^...^.^.^...^.^.^......................
|
||||
.............................................................................................................................................
|
||||
.....................^.^.^...^...^.^...^.^.^...^...^.^.^.^.^.^.^...^...^.^.^.^.....^.^.^...^.^.....^...^...^...^.^.^.^.^.....................
|
||||
.............................................................................................................................................
|
||||
....................^.^.^...^.^.^...^.^.^.....^.......^.^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.....^.^.^.^.^.^...^.^.^...^.^.^.^....................
|
||||
.............................................................................................................................................
|
||||
...................^.....^.^...^.^...^.^...^.^.....^...^.^.^.......^.^.^.^.^.^.^.^.^...^.^.^.^.^...^.^.^.^...^.^.^.^.^...^...................
|
||||
.............................................................................................................................................
|
||||
..................^.^.^.^.^.^.^...^.^.^.^.....^.^.^.^.^.^.^...^.^...^...^...^.^.^.^.......^.^.^.....^.^...^.^.^...^.^...^.^..................
|
||||
.............................................................................................................................................
|
||||
.................^...^.^.^.^.^...^.......^.^.^.....^.^...^...^.^.^...^.^...^...^...^...^.^.^...^...^.^...^.^.^.^.^.^.^.^.^.^.................
|
||||
.............................................................................................................................................
|
||||
................^.^...^...^.^...^.^.....^.^.^.^.^.^.......^.^.^...^.^.^.^.^.^.^.^.^...........^.^.^.....^.....^.^.^.^.^.^...^................
|
||||
.............................................................................................................................................
|
||||
...............^.^.^...^.^.^.^.^.^.........^.^.^.^.^.......^...^.....^...^.^...^.....^...^...^...^.^.^.^.^.^.^.^.^.^.^.^.^.^.^...............
|
||||
.............................................................................................................................................
|
||||
..............^.^.^.^.^.^.^.^.^.^.^.^...^.^...^.^.^.^.^...^.^...^.......^.^...^.^.^...^.....^.^.^...^.^.^.^.^...^.^.^.^.^...^.^..............
|
||||
.............................................................................................................................................
|
||||
.............^.^.^.^.^...^.^.^.......^.^.^...^.^.^.^...^.^.^.^...^.....^.^.......^.^.........^.^.^.^.^.....^.^.^.^.^.^.^...^.^.^.............
|
||||
.............................................................................................................................................
|
||||
............^...^.^...^.^.^.^.^.^...........^.^.^.^.^.^.^.^.^.^.....^.^.^.^...^.....^.^.......^...^.^...^.....^.^.^...^.^.^...^.^............
|
||||
.............................................................................................................................................
|
||||
...........^.^.^.^.^.^.^.....^.^...^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.....^.^.^.^.^.^...^...^.^.^.^...^.^.^.^...^.^.^.^...^.^.^.^.^.^...........
|
||||
.............................................................................................................................................
|
||||
..........^...^.^.^.^.^.^...^...^.^...^.^.^.^.^.^...^.^...^.^.^.^.^.^.^.^...^.^.^...^.^.^...^.^.^.^...^...^.^.^.^.^.^...^.^.^.^.^.^..........
|
||||
.............................................................................................................................................
|
||||
.........^...^.^...^.....^.^.^...^.......^.^.....^.......^...^...^...^.^.^.^.^.^.^.....^.^.^.....^.^.^.^.^...^.^.^.^.^.^.^.^.^.^.^.^.........
|
||||
.............................................................................................................................................
|
||||
........^.^...........^...^.......^.^...^.^.^...^.^.^.^...^.^...^.^.^.......^...^.^.^.^.^.^.^.^.^.^.....^...^...^.....^.^.^.^.^.^.^.^........
|
||||
.............................................................................................................................................
|
||||
.......^...^...^.^.^...^.^.^.....^.^...^.^.^...^...^.^.^.^.^.^.^.^.^.^.^.^.^...^.^.^...^.^...^...^.^.^...^.^.^.^.^.....^...^.^.....^.^.......
|
||||
.............................................................................................................................................
|
||||
......^...^.^...^...^...^.^.^...^.^.^.^...^...^.^.^...^.^.....^.^.^...^.....^...^.^...^.......^.^...^.^.....^...^.^.^.^.^.^.^.^.^.^...^......
|
||||
.............................................................................................................................................
|
||||
.....^.^.^.^...^.^.....^.^...^.^.......^.^.^.^.^.^.^.^.^.^...^...^.^.^.^.^...^.^.^.^.^.^.^...^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.^...^...^.^.....
|
||||
.............................................................................................................................................
|
||||
....^...^...^.^.^.^...^.^.^...^.^.....^.^.^...^.^.^.^...^.^.^.^.^...^.^.^.^.^...^.^.^.^.^.^.......^.^.^.^.^.....^.^.^.^...^.^.^.^.^...^.^....
|
||||
.............................................................................................................................................
|
||||
...^.^...^...^.......^...^.^.^...^.^.^.^.^.^.^.^.^.^.^...^.^...^.^.^.^.^...^...^.^...^...^.^.^.^.^.^.^.^.^.....^...^.^...^.^...^.^.^.^...^...
|
||||
.............................................................................................................................................
|
||||
..^.^.........^.^.^.^.^.^.^.^.^.^...^.......^.^.^.^...^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^...........^.....^.^.^.^.^.^.^.^.^.^.^.^.^...^.^...^.^..
|
||||
.............................................................................................................................................
|
||||
.^.^.^.^.^.....^.^.^.^.^.^.^.^.^.^.....^.^...^.^.^.^.^.^...^.^...^.^.^.^.^...^...^...^...^.^.^.^.^.^...^.^.^.^.^.^.^.^...^.^.^.^.^.^.^.....^.
|
||||
.............................................................................................................................................
|
||||
16
Day7/Question2/inputTest
Normal file
16
Day7/Question2/inputTest
Normal file
@@ -0,0 +1,16 @@
|
||||
.......S.......
|
||||
...............
|
||||
.......^.......
|
||||
...............
|
||||
......^.^......
|
||||
...............
|
||||
.....^.^.^.....
|
||||
...............
|
||||
....^.^...^....
|
||||
...............
|
||||
...^.^...^.^...
|
||||
...............
|
||||
..^...^.....^..
|
||||
...............
|
||||
.^.^.^.^.^...^.
|
||||
...............
|
||||
44
Day7/Question2/main.cpp
Normal file
44
Day7/Question2/main.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
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<uint64_t> 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<int>(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;
|
||||
}
|
||||
Reference in New Issue
Block a user