aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/2017/day21/aoc.cpp4
-rw-r--r--src/2017/day21/aoc.h22
2 files changed, 25 insertions, 1 deletions
diff --git a/src/2017/day21/aoc.cpp b/src/2017/day21/aoc.cpp
index b1f315a..c077b32 100644
--- a/src/2017/day21/aoc.cpp
+++ b/src/2017/day21/aoc.cpp
@@ -5,15 +5,17 @@ namespace aoc2017 {
typedef void (*sfunc)(std::vector<square3>* vs3, std::vector<square2>* vs2,
const std::map<std::string, std::string>& rs);
+
void s3tos2(std::vector<square3>* vs3, std::vector<square2>* vs2, const std::map<std::string, std::string>& rs) {}
void s2tos3(std::vector<square3>* vs3, std::vector<square2>* vs2, const std::map<std::string, std::string>& rs) {}
static void part1(int t, int times, std::vector<square3>* vs3, std::vector<square2>* vs2,
const std::map<std::string, std::string>& rs) {
sfunc fs[2] = {s3tos2, s2tos3};
- if (t <= times) {
+ while (t <= times) {
sfunc f = fs[t % 2];
f(vs3, vs2, rs);
+ t++;
}
}
diff --git a/src/2017/day21/aoc.h b/src/2017/day21/aoc.h
index c2bae44..1f743c2 100644
--- a/src/2017/day21/aoc.h
+++ b/src/2017/day21/aoc.h
@@ -56,6 +56,17 @@ struct square2 {
return {s0, s1, s2};
}
+ std::vector<square2> combo() const noexcept {
+ std::vector<square2> c{*this};
+ for (auto&& s : rotate()) {
+ c.emplace_back(s);
+ }
+ for (auto&& s : flip()) {
+ c.emplace_back(s);
+ }
+ return c;
+ }
+
std::string to_string() {
char sx[6] = {0};
sprintf(sx, "%c%c/%c%c", s[0], s[1], s[2], s[3]);
@@ -200,6 +211,17 @@ struct square3 {
return {s0, s1, s2, s3, s4, s5, s6};
}
+ std::vector<square3> combo() const noexcept {
+ std::vector<square3> c{*this};
+ for (auto&& s : rotate()) {
+ c.emplace_back(s);
+ }
+ for (auto&& s : flip()) {
+ c.emplace_back(s);
+ }
+ return c;
+ }
+
std::string to_string() {
char sx[12] = {0};
sprintf(sx, "%c%c%c/%c%c%c/%c%c%c", s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8]);