diff --git a/d14.cc b/d14.cc new file mode 100644 index 0000000..ec49dce --- /dev/null +++ b/d14.cc @@ -0,0 +1,213 @@ +#include +#include +#include + +//#define ANIMATE + +using namespace std; + +enum Tile { + EMPTY, + ROCK, + SAND +}; + +struct Input { + vector>> rocks; + vector> map; + complex start; + complex size; +}; + +void make_map(Input &input) +{ + // Figure out map extremes + unsigned min_x = 500, max_x = 500; + unsigned min_y = 0, max_y = 0; + for (auto &rock : input.rocks) { + for (auto &p : rock) { + if (p.real() < min_x) min_x = p.real(); + if (p.real() > max_x) max_x = p.real(); + if (p.imag() < min_y) min_y = p.imag(); + if (p.imag() > max_y) max_y = p.imag(); + } + } + + input.start = {min_x, min_y}; + input.size = {1 + max_x - min_x, 1 + max_y - min_y}; + + input.map = vector>(input.size.imag(), vector(input.size.real())); + + for (auto &rock : input.rocks) { + complex p = rock.at(0); + input.map[p.imag() - input.start.imag()][p.real() - input.start.real()] = ROCK; + for (unsigned i = 1; i < rock.size(); i++) { + complex &np = rock[i]; + while (p != np) { + int dx = np.real() - p.real(); + int dy = np.imag() - p.imag(); + if (dx > 1) dx = 1; + if (dx < -1) dx = -1; + if (dy > 1) dy = 1; + if (dy < -1) dy = -1; + p += complex(dx, dy); + input.map[p.imag() - input.start.imag()][p.real() - input.start.real()] = ROCK; + } + } + } +} + +Input parse() +{ + Input data; + for (string line; getline(cin, line);) { + vector> cur; + unsigned pos = 0; + for (;;) { + unsigned first = pos; + unsigned first_end = line.find(",", pos); + unsigned second = first_end + 1; + unsigned second_end = line.find(" -> ", pos); + pos = second_end + 4; + if (first == first_end || second == second_end) break; + unsigned real = stoi(line.substr(first, first_end)); + unsigned imag = stoi(line.substr(second, second_end)); + cur.push_back({real, imag}); + } + data.rocks.push_back(cur); + } + make_map(data); + return data; +} + +#ifdef ANIMATE +#include +unsigned render_frame = 0; +void render(const vector> &map) +{ + char fname[] = "img/00000.pam"; + sprintf(fname, "img/%05u.pam", render_frame++); + auto file = ofstream(fname); + file << "P7\n"; + file << "WIDTH " << map.front().size() << '\n'; + file << "HEIGHT " << map.size() << '\n'; + file << "DEPTH 3\nMAXVAL 255\nTUPLTYPE RGB\nENDHDR\n"; + + for (unsigned y = 0; y < map.size(); y++) { + for (unsigned x = 0; x < map.front().size(); x++) { + uint32_t color = 0; + switch (map[y][x]) { + case ROCK: color = 0xFF0000; break; + case SAND: color = 0x00FFFF; break; + default: break; + } + file.write((char *)&color, 3); + } + } + file.close(); +} +#endif + +complex dirs[] = { + {0, 1}, + {-1, 1}, + {1, 1} +}; + +unsigned p1(const Input &input) +{ + auto map = input.map; + + const complex sand_start(500, 0); + + unsigned count = 0; + for (;;) { + bool oob = false; + complex sand = sand_start - (complex)input.start; + for (;;) { + bool moved = false; + for (auto &d : dirs) { + complex test = sand + d; + if (test.real() < 0 || test.real() >= (int)input.size.real()) oob = true; + if (test.imag() < 0 || test.imag() >= (int)input.size.imag()) oob = true; + if (oob) break; + auto tile = map[test.imag()][test.real()]; + if (tile != EMPTY) continue; + sand = test; + moved = true; + break; + } + if (!moved) { + if (!oob) map[sand.imag()][sand.real()] = SAND; + break; + } + } +#ifdef ANIMATE + //render(map); +#endif + if (oob) break; + count++; + } + return count; +} + +unsigned p2(const Input &input) +{ + auto map = input.map; + + map.push_back(vector(input.size.real(), EMPTY)); + map.push_back(vector(input.size.real(), ROCK)); + complex start = input.start; + complex size = input.size + complex(0, 2); + + const complex sand_start(500, 0); + + unsigned count = 0; + for (;;) { + complex sand = sand_start - start; + if (map[sand.imag()][sand.real()] == SAND) break; + for (;;) { + bool moved = false; + for (auto &d : dirs) { + complex test = sand + d; + + // Widen the map + if (test.real() < 0) { + for (auto &x : map) x.insert(x.begin(), EMPTY); + map.back().front() = ROCK; + start += complex(-1, 0); + test += complex(1, 0); + size += complex(1, 0); + } else if (test.real() >= size.real()) { + for (auto &x : map) x.push_back(EMPTY); + map.back().back() = ROCK; + size += complex(1, 0); + } + if (test.imag() < 0 || test.imag() >= size.imag()) continue; + + auto tile = map[test.imag()][test.real()]; + if (tile != EMPTY) continue; + sand = test; + moved = true; + break; + } + if (!moved) { + map[sand.imag()][sand.real()] = SAND; + break; + } + } +#ifdef ANIMATE + render(map); +#endif + count++; + } + + return count; +} + +int main() +{ + auto input = parse(); + cout << p1(input) << endl; + cout << p2(input) << endl; +} diff --git a/d14_anim.webm b/d14_anim.webm new file mode 100644 index 0000000..1123fd8 Binary files /dev/null and b/d14_anim.webm differ diff --git a/d14_input.txt b/d14_input.txt new file mode 100644 index 0000000..19afc33 --- /dev/null +++ b/d14_input.txt @@ -0,0 +1,163 @@ +494,71 -> 498,71 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +472,131 -> 472,134 -> 466,134 -> 466,141 -> 484,141 -> 484,134 -> 476,134 -> 476,131 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +478,104 -> 478,103 -> 478,104 -> 480,104 -> 480,96 -> 480,104 -> 482,104 -> 482,97 -> 482,104 -> 484,104 -> 484,97 -> 484,104 +469,53 -> 474,53 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +499,38 -> 503,38 +483,107 -> 483,110 -> 476,110 -> 476,113 -> 487,113 -> 487,110 -> 486,110 -> 486,107 +485,62 -> 489,62 +493,38 -> 497,38 +494,169 -> 494,159 -> 494,169 -> 496,169 -> 496,167 -> 496,169 -> 498,169 -> 498,166 -> 498,169 -> 500,169 -> 500,167 -> 500,169 -> 502,169 -> 502,161 -> 502,169 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +482,144 -> 482,147 -> 480,147 -> 480,153 -> 489,153 -> 489,147 -> 488,147 -> 488,144 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +484,29 -> 488,29 +483,107 -> 483,110 -> 476,110 -> 476,113 -> 487,113 -> 487,110 -> 486,110 -> 486,107 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +472,41 -> 472,45 -> 469,45 -> 469,48 -> 479,48 -> 479,45 -> 477,45 -> 477,41 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +482,144 -> 482,147 -> 480,147 -> 480,153 -> 489,153 -> 489,147 -> 488,147 -> 488,144 +472,41 -> 472,45 -> 469,45 -> 469,48 -> 479,48 -> 479,45 -> 477,45 -> 477,41 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +494,169 -> 494,159 -> 494,169 -> 496,169 -> 496,167 -> 496,169 -> 498,169 -> 498,166 -> 498,169 -> 500,169 -> 500,167 -> 500,169 -> 502,169 -> 502,161 -> 502,169 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +494,169 -> 494,159 -> 494,169 -> 496,169 -> 496,167 -> 496,169 -> 498,169 -> 498,166 -> 498,169 -> 500,169 -> 500,167 -> 500,169 -> 502,169 -> 502,161 -> 502,169 +478,104 -> 478,103 -> 478,104 -> 480,104 -> 480,96 -> 480,104 -> 482,104 -> 482,97 -> 482,104 -> 484,104 -> 484,97 -> 484,104 +488,65 -> 492,65 +494,169 -> 494,159 -> 494,169 -> 496,169 -> 496,167 -> 496,169 -> 498,169 -> 498,166 -> 498,169 -> 500,169 -> 500,167 -> 500,169 -> 502,169 -> 502,161 -> 502,169 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +482,122 -> 486,122 +482,71 -> 486,71 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +491,68 -> 495,68 +476,128 -> 480,128 +494,169 -> 494,159 -> 494,169 -> 496,169 -> 496,167 -> 496,169 -> 498,169 -> 498,166 -> 498,169 -> 500,169 -> 500,167 -> 500,169 -> 502,169 -> 502,161 -> 502,169 +460,59 -> 465,59 +472,41 -> 472,45 -> 469,45 -> 469,48 -> 479,48 -> 479,45 -> 477,45 -> 477,41 +478,104 -> 478,103 -> 478,104 -> 480,104 -> 480,96 -> 480,104 -> 482,104 -> 482,97 -> 482,104 -> 484,104 -> 484,97 -> 484,104 +473,74 -> 473,75 -> 480,75 +477,57 -> 482,57 +472,41 -> 472,45 -> 469,45 -> 469,48 -> 479,48 -> 479,45 -> 477,45 -> 477,41 +493,32 -> 497,32 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +473,55 -> 478,55 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +496,35 -> 500,35 +479,125 -> 483,125 +456,57 -> 461,57 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +490,35 -> 494,35 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +474,59 -> 479,59 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +482,144 -> 482,147 -> 480,147 -> 480,153 -> 489,153 -> 489,147 -> 488,147 -> 488,144 +481,38 -> 485,38 +482,144 -> 482,147 -> 480,147 -> 480,153 -> 489,153 -> 489,147 -> 488,147 -> 488,144 +478,104 -> 478,103 -> 478,104 -> 480,104 -> 480,96 -> 480,104 -> 482,104 -> 482,97 -> 482,104 -> 484,104 -> 484,97 -> 484,104 +478,104 -> 478,103 -> 478,104 -> 480,104 -> 480,96 -> 480,104 -> 482,104 -> 482,97 -> 482,104 -> 484,104 -> 484,97 -> 484,104 +478,104 -> 478,103 -> 478,104 -> 480,104 -> 480,96 -> 480,104 -> 482,104 -> 482,97 -> 482,104 -> 484,104 -> 484,97 -> 484,104 +478,104 -> 478,103 -> 478,104 -> 480,104 -> 480,96 -> 480,104 -> 482,104 -> 482,97 -> 482,104 -> 484,104 -> 484,97 -> 484,104 +485,119 -> 491,119 -> 491,118 +494,169 -> 494,159 -> 494,169 -> 496,169 -> 496,167 -> 496,169 -> 498,169 -> 498,166 -> 498,169 -> 500,169 -> 500,167 -> 500,169 -> 502,169 -> 502,161 -> 502,169 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +482,144 -> 482,147 -> 480,147 -> 480,153 -> 489,153 -> 489,147 -> 488,147 -> 488,144 +472,131 -> 472,134 -> 466,134 -> 466,141 -> 484,141 -> 484,134 -> 476,134 -> 476,131 +483,107 -> 483,110 -> 476,110 -> 476,113 -> 487,113 -> 487,110 -> 486,110 -> 486,107 +472,131 -> 472,134 -> 466,134 -> 466,141 -> 484,141 -> 484,134 -> 476,134 -> 476,131 +494,169 -> 494,159 -> 494,169 -> 496,169 -> 496,167 -> 496,169 -> 498,169 -> 498,166 -> 498,169 -> 500,169 -> 500,167 -> 500,169 -> 502,169 -> 502,161 -> 502,169 +487,26 -> 491,26 +481,59 -> 486,59 +459,55 -> 464,55 +488,128 -> 492,128 +494,169 -> 494,159 -> 494,169 -> 496,169 -> 496,167 -> 496,169 -> 498,169 -> 498,166 -> 498,169 -> 500,169 -> 500,167 -> 500,169 -> 502,169 -> 502,161 -> 502,169 +488,71 -> 492,71 +472,131 -> 472,134 -> 466,134 -> 466,141 -> 484,141 -> 484,134 -> 476,134 -> 476,131 +494,169 -> 494,159 -> 494,169 -> 496,169 -> 496,167 -> 496,169 -> 498,169 -> 498,166 -> 498,169 -> 500,169 -> 500,167 -> 500,169 -> 502,169 -> 502,161 -> 502,169 +487,38 -> 491,38 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +483,107 -> 483,110 -> 476,110 -> 476,113 -> 487,113 -> 487,110 -> 486,110 -> 486,107 +482,65 -> 486,65 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +481,32 -> 485,32 +482,144 -> 482,147 -> 480,147 -> 480,153 -> 489,153 -> 489,147 -> 488,147 -> 488,144 +494,169 -> 494,159 -> 494,169 -> 496,169 -> 496,167 -> 496,169 -> 498,169 -> 498,166 -> 498,169 -> 500,169 -> 500,167 -> 500,169 -> 502,169 -> 502,161 -> 502,169 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +475,38 -> 479,38 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +485,68 -> 489,68 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +494,169 -> 494,159 -> 494,169 -> 496,169 -> 496,167 -> 496,169 -> 498,169 -> 498,166 -> 498,169 -> 500,169 -> 500,167 -> 500,169 -> 502,169 -> 502,161 -> 502,169 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +483,107 -> 483,110 -> 476,110 -> 476,113 -> 487,113 -> 487,110 -> 486,110 -> 486,107 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +472,131 -> 472,134 -> 466,134 -> 466,141 -> 484,141 -> 484,134 -> 476,134 -> 476,131 +494,169 -> 494,159 -> 494,169 -> 496,169 -> 496,167 -> 496,169 -> 498,169 -> 498,166 -> 498,169 -> 500,169 -> 500,167 -> 500,169 -> 502,169 -> 502,161 -> 502,169 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +482,144 -> 482,147 -> 480,147 -> 480,153 -> 489,153 -> 489,147 -> 488,147 -> 488,144 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +464,77 -> 464,78 -> 473,78 -> 473,77 +483,107 -> 483,110 -> 476,110 -> 476,113 -> 487,113 -> 487,110 -> 486,110 -> 486,107 +494,169 -> 494,159 -> 494,169 -> 496,169 -> 496,167 -> 496,169 -> 498,169 -> 498,166 -> 498,169 -> 500,169 -> 500,167 -> 500,169 -> 502,169 -> 502,161 -> 502,169 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +473,74 -> 473,75 -> 480,75 +485,119 -> 491,119 -> 491,118 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +484,35 -> 488,35 +472,41 -> 472,45 -> 469,45 -> 469,48 -> 479,48 -> 479,45 -> 477,45 -> 477,41 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +464,77 -> 464,78 -> 473,78 -> 473,77 +453,59 -> 458,59 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +467,59 -> 472,59 +485,156 -> 498,156 -> 498,155 +472,41 -> 472,45 -> 469,45 -> 469,48 -> 479,48 -> 479,45 -> 477,45 -> 477,41 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +463,57 -> 468,57 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +478,104 -> 478,103 -> 478,104 -> 480,104 -> 480,96 -> 480,104 -> 482,104 -> 482,97 -> 482,104 -> 484,104 -> 484,97 -> 484,104 +472,131 -> 472,134 -> 466,134 -> 466,141 -> 484,141 -> 484,134 -> 476,134 -> 476,131 +464,77 -> 464,78 -> 473,78 -> 473,77 +462,53 -> 467,53 +478,104 -> 478,103 -> 478,104 -> 480,104 -> 480,96 -> 480,104 -> 482,104 -> 482,97 -> 482,104 -> 484,104 -> 484,97 -> 484,104 +472,131 -> 472,134 -> 466,134 -> 466,141 -> 484,141 -> 484,134 -> 476,134 -> 476,131 +483,107 -> 483,110 -> 476,110 -> 476,113 -> 487,113 -> 487,110 -> 486,110 -> 486,107 +466,55 -> 471,55 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +482,128 -> 486,128 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +465,51 -> 470,51 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +487,32 -> 491,32 +476,71 -> 480,71 +490,29 -> 494,29 +494,169 -> 494,159 -> 494,169 -> 496,169 -> 496,167 -> 496,169 -> 498,169 -> 498,166 -> 498,169 -> 500,169 -> 500,167 -> 500,169 -> 502,169 -> 502,161 -> 502,169 +485,156 -> 498,156 -> 498,155 +478,35 -> 482,35 +478,104 -> 478,103 -> 478,104 -> 480,104 -> 480,96 -> 480,104 -> 482,104 -> 482,97 -> 482,104 -> 484,104 -> 484,97 -> 484,104 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +479,68 -> 483,68 +478,104 -> 478,103 -> 478,104 -> 480,104 -> 480,96 -> 480,104 -> 482,104 -> 482,97 -> 482,104 -> 484,104 -> 484,97 -> 484,104 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +472,41 -> 472,45 -> 469,45 -> 469,48 -> 479,48 -> 479,45 -> 477,45 -> 477,41 +490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,18 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,19 -> 498,23 -> 500,23 -> 500,16 -> 500,23 -> 502,23 -> 502,20 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,13 -> 506,23 -> 508,23 -> 508,21 -> 508,23 +470,57 -> 475,57 +465,91 -> 465,90 -> 465,91 -> 467,91 -> 467,84 -> 467,91 -> 469,91 -> 469,85 -> 469,91 -> 471,91 -> 471,88 -> 471,91 -> 473,91 -> 473,88 -> 473,91 -> 475,91 -> 475,88 -> 475,91 -> 477,91 -> 477,84 -> 477,91 -> 479,91 -> 479,90 -> 479,91 -> 481,91 -> 481,88 -> 481,91 +485,125 -> 489,125 diff --git a/d14_output.txt b/d14_output.txt new file mode 100644 index 0000000..674ad15 --- /dev/null +++ b/d14_output.txt @@ -0,0 +1,2 @@ +728 +27623 diff --git a/makeanim.sh b/makeanim.sh index 61d5afb..d0d280b 100755 --- a/makeanim.sh +++ b/makeanim.sh @@ -1,4 +1,4 @@ #!/bin/sh ffmpeg -threads 0 -pattern_type glob -i "img/*.pam" -r 60 \ - -vf "format=yuv444p,setpts=0.05*PTS,scale=iw*4:ih*4:flags=neighbor" \ + -vf "format=yuv444p,setpts=0.05*PTS,scale=iw*4:ih*4:flags=neighbor:eval=frame,pad=342*4:172*4:(ow-iw)/2:(oh-ih)/2" \ anim.webm