aboutsummaryrefslogtreecommitdiff
path: root/src/2017/day21/aoc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/2017/day21/aoc.cpp')
-rw-r--r--src/2017/day21/aoc.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/2017/day21/aoc.cpp b/src/2017/day21/aoc.cpp
index 706fa8a..716d4e6 100644
--- a/src/2017/day21/aoc.cpp
+++ b/src/2017/day21/aoc.cpp
@@ -1,6 +1,39 @@
#include "aoc.h"
+#include <map>
namespace aoc2017 {
-std::pair<int64_t, int64_t> day21(line_view) { return {0, 0}; }
+std::pair<int64_t, int64_t> day21(line_view file) {
+ std::map<std::string, std::string> rules;
+
+ per_line(file, [&rules](line_view lv) {
+ const char* p0 = lv.line;
+ const char* p1 = p0;
+ std::string k;
+ std::string v;
+ while (p1 < lv.line + lv.length) {
+ if (*p1 == '=') {
+ k = std::string{p0, (size_t)(p1 - p0 - 1)};
+ p0 = p1 + 3;
+ }
+ if (*p1 == '\n') {
+ v = std::string{p0, (size_t)(p1 - p0)};
+ }
+ p1++;
+ }
+ rules.insert({k, v});
+ return true;
+ });
+
+ // .#.
+ // ..#
+ // ###
+ square3 s3{".#./..#/###"};
+
+ // for (auto& kv : rules) {
+ // printf("%s => %s\n", kv.first.c_str(), kv.second.c_str());
+ // }
+
+ return {0, 0};
+}
} // namespace aoc2017