aboutsummaryrefslogtreecommitdiff
path: root/src/2017/day24/aoc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/2017/day24/aoc.h')
-rw-r--r--src/2017/day24/aoc.h29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/2017/day24/aoc.h b/src/2017/day24/aoc.h
index d102bfa..9643b78 100644
--- a/src/2017/day24/aoc.h
+++ b/src/2017/day24/aoc.h
@@ -3,5 +3,32 @@
#include <vector>
namespace aoc2017 {
+
+struct component {
+ int pins[2] = {0};
+
+ void get_number(const char** pp, int* d) {
+ const char* p = *pp;
+ while (*p >= '0' && *p <= '9') {
+ *d = *d * 10 + *p - '0';
+ p++;
+ }
+ *pp = p;
+ }
+
+ void print() const noexcept { printf("%d/%d\n", pins[0], pins[1]); }
+
+ component(line_view lv) {
+ int i{0};
+ const char* p = lv.line;
+ while (p < lv.line + lv.length) {
+ if (*p >= '0' && *p <= '9') {
+ get_number(&p, &pins[i++]);
+ }
+ p++;
+ }
+ }
+};
+
std::pair<int64_t, int64_t> day24(line_view);
-}
+} // namespace aoc2017