blob: 1a5a7d9c1f02b528a32d88ba1f06c6b6c7a38654 (
plain)
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
|
#pragma once
#include "common.h"
#include <vector>
namespace aoc2017 {
struct disc {
line_view name;
int weight;
int total = 0;
std::vector<disc*> subs;
const char* xp = nullptr;
const char* get_number(const char* p, int* d) {
*d = 0;
while (*p >= '0' && *p <= '9') {
*d = *d * 10 + *p - '0';
p++;
}
return p;
}
disc(line_view lv, const char* p) {
name = {lv.line, p - 1};
p = get_number(p + 1, &weight) + 5;
if (p < lv.line + lv.length) {
xp = p;
}
}
};
void day7(line_view, char[]);
} // namespace aoc2017
|