-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday5a.cpp
37 lines (35 loc) · 808 Bytes
/
day5a.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "utils.hpp"
int main(int argc, char *argv[])
{
// Cheating because lazy
std::vector<std::string> crates = {
"",
"WRF",
"THMCDVWP",
"PMZNL",
"JCHR",
"CPGHQTB",
"GCWLFZ",
"WVLQZJGC",
"PNRFWTVC",
"JWHGRSV",
};
auto input = read_input("day5_input");
std::regex reg_exp("([0-9]+) [a-z]+ ([0-9]+) [a-z]+ ([0-9]+)");
std::smatch reg_out;
for (auto &&x : input)
{
if (std::regex_search(x, reg_out, reg_exp))
{
for (int y = 0; y < std::stoi(reg_out[1]); y++)
{
crates.at(std::stoi(reg_out[3])).push_back(crates.at(std::stoi(reg_out[2])).back());
crates.at(std::stoi(reg_out[2])).pop_back();
}
}
}
for (auto && y: crates)
{
std::cout << y << "\n";
}
}