aboutsummaryrefslogtreecommitdiff
path: root/src/2022/day17/aoc.cpp
diff options
context:
space:
mode:
authorkaiwu <kaiwu2004@gmail.com>2023-01-09 17:51:32 +0800
committerkaiwu <kaiwu2004@gmail.com>2023-01-09 17:51:32 +0800
commit90d9dee4dacf406679585299bc2fdf0823ab3982 (patch)
treeeb220badb1753a4cebd309f7aec0dfd57a6bbbf3 /src/2022/day17/aoc.cpp
parent616c378c9855a89c92f0e1c572812a5602fac363 (diff)
downloadadvent-of-code-90d9dee4dacf406679585299bc2fdf0823ab3982.tar.gz
advent-of-code-90d9dee4dacf406679585299bc2fdf0823ab3982.zip
2022 day17 part2
Diffstat (limited to 'src/2022/day17/aoc.cpp')
-rw-r--r--src/2022/day17/aoc.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/2022/day17/aoc.cpp b/src/2022/day17/aoc.cpp
index c9d0dca..d57742b 100644
--- a/src/2022/day17/aoc.cpp
+++ b/src/2022/day17/aoc.cpp
@@ -4,6 +4,7 @@
namespace aoc2022 {
static line_view moves;
+static size_t index = 0;
static bool at(uint8_t r, int p) {
// p 0..7
@@ -14,8 +15,7 @@ static bool at(uint8_t r, int p) {
}
char next() {
- static int i{0};
- int x = i++ % (moves.length - 1);
+ int x = index++ % (moves.length - 1);
const char* p = moves.line;
// printf("%c at %d\n", *(p + x), x);
return *(p + x);
@@ -194,15 +194,21 @@ std::pair<size_t, size_t> day17(line_view file) {
rock17 floor{chamber, {0x7F}};
std::map<size_t, size_t> heights;
- // size_t n = (file.length - 1) * 5;
+ // size_t p = (file.length - 1) * 5;
size_t n = 2022;
+ // sample 17 35/35/35
+ // input 8602 8575/8575/8575
for (size_t i = 0; i < n; i++) {
rock17 r = make_rock(i);
check_three(floor.rs);
+ // auto x = check_three(floor.rs);
+ // if (x == 0) {
+ // printf("%ld, %ld\n", i, index % p);
+ // }
merge(floor, r, 0);
}
- print(floor.rs);
- printf("%ld\n", floor.rs.size() - 1);
+ // print(floor.rs);
+ printf("%ld %ld\n", floor.rs.size() - 1, index);
return {0, 0};
}
} // namespace aoc2022