aboutsummaryrefslogtreecommitdiff
path: root/src/2015/day19/aoc.h
diff options
context:
space:
mode:
authorkaiwu <kaiwu2004@gmail.com>2022-03-24 19:50:20 +0800
committerkaiwu <kaiwu2004@gmail.com>2022-03-24 19:50:20 +0800
commit94c77ee143b8ba663d86fff3be7d42f25ee96a43 (patch)
tree81e7e30018b7a93f8383ae8aad8c29de581bed5b /src/2015/day19/aoc.h
parent5c4a35c77539e969f4c20a0702402996b8848683 (diff)
downloadadvent-of-code-94c77ee143b8ba663d86fff3be7d42f25ee96a43.tar.gz
advent-of-code-94c77ee143b8ba663d86fff3be7d42f25ee96a43.zip
Rn Y Y Ar
Diffstat (limited to 'src/2015/day19/aoc.h')
-rw-r--r--src/2015/day19/aoc.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/2015/day19/aoc.h b/src/2015/day19/aoc.h
index a8e5b2d..5c19adf 100644
--- a/src/2015/day19/aoc.h
+++ b/src/2015/day19/aoc.h
@@ -123,6 +123,7 @@ struct molecule {
}
}
+ // exponetial down
void deduct(line_view lv, int steps, int* shortest) const noexcept {
if (lv == "e") {
if (*shortest > steps) {
@@ -175,6 +176,7 @@ struct molecule {
}
}
+ // exponetial up
void transfer(line_view lv, int steps, int* shortest) {
if (lv.length > original.length) {
return;
@@ -200,8 +202,10 @@ struct molecule {
void parse(line_view lv) {
const char* p = lv.contains("=>");
if (p != nullptr) {
- replacements.push_back({{lv.line, p - 1}, {p + 3, lv.line + lv.length - 1}});
- transfers[{lv.line, p - 1}].push_back({p + 3, lv.line + lv.length - 1});
+ line_view k{lv.line, p - 1};
+ line_view v{p + 3, lv.line + lv.length - 1};
+ replacements.push_back({k, v});
+ transfers[k].push_back(v);
} else {
if (lv.length > 1) {
original = {lv.line, lv.line + lv.length - 1};