From 1088112f043919a767daaa7a5f43e14a37054f79 Mon Sep 17 00:00:00 2001 From: Patrick Auernig Date: Thu, 15 Dec 2022 11:12:00 +0100 Subject: [PATCH] Add solution for 2022 day 14 --- 2022/Cargo.lock | 8 ++ 2022/Cargo.toml | 1 + 2022/README.md | 2 +- 2022/day-14/Cargo.toml | 14 +++ 2022/day-14/Justfile | 5 + 2022/day-14/inputs/puzzle.txt | 179 ++++++++++++++++++++++++++++++++ 2022/day-14/inputs/test.txt | 2 + 2022/day-14/src/bin/part_one.rs | 72 +++++++++++++ 2022/day-14/src/bin/part_two.rs | 75 +++++++++++++ 2022/day-14/src/lib.rs | 121 +++++++++++++++++++++ README.md | 2 +- 11 files changed, 479 insertions(+), 2 deletions(-) create mode 100644 2022/day-14/Cargo.toml create mode 100644 2022/day-14/Justfile create mode 100644 2022/day-14/inputs/puzzle.txt create mode 100644 2022/day-14/inputs/test.txt create mode 100644 2022/day-14/src/bin/part_one.rs create mode 100644 2022/day-14/src/bin/part_two.rs create mode 100644 2022/day-14/src/lib.rs diff --git a/2022/Cargo.lock b/2022/Cargo.lock index b081d2f..4162ac1 100644 --- a/2022/Cargo.lock +++ b/2022/Cargo.lock @@ -70,6 +70,14 @@ dependencies = [ "nom", ] +[[package]] +name = "aoc-2022-14" +version = "0.1.0" +dependencies = [ + "itertools", + "nom", +] + [[package]] name = "autocfg" version = "1.1.0" diff --git a/2022/Cargo.toml b/2022/Cargo.toml index 8922b6d..6fe7f72 100644 --- a/2022/Cargo.toml +++ b/2022/Cargo.toml @@ -13,6 +13,7 @@ members = [ "./day-11", "./day-12", "./day-13", + "./day-14", ] diff --git a/2022/README.md b/2022/README.md index 61e8255..2ea9946 100644 --- a/2022/README.md +++ b/2022/README.md @@ -17,7 +17,7 @@ | [11] | ✓ | | [Rust] | | [12] | ✓ | ✓ | [Rust] | | [13] | ✓ | ✓ | [Rust] | -| [14] | | | | +| [14] | ✓ | ✓ | [Rust] | | [15] | | | | | [16] | | | | | [17] | | | | diff --git a/2022/day-14/Cargo.toml b/2022/day-14/Cargo.toml new file mode 100644 index 0000000..b85fb00 --- /dev/null +++ b/2022/day-14/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "aoc-2022-14" +version = "0.1.0" +edition = "2021" + + +[lib] +test = false +doctest = false + + +[dependencies] +nom = "7.1" +itertools = "0.10" diff --git a/2022/day-14/Justfile b/2022/day-14/Justfile new file mode 100644 index 0000000..7d08527 --- /dev/null +++ b/2022/day-14/Justfile @@ -0,0 +1,5 @@ +@part PART INPUT_FILE="inputs/puzzle.txt": + cargo --quiet run --bin part_{{PART}} -- {{INPUT_FILE}} + +clean: + cargo clean diff --git a/2022/day-14/inputs/puzzle.txt b/2022/day-14/inputs/puzzle.txt new file mode 100644 index 0000000..880a895 --- /dev/null +++ b/2022/day-14/inputs/puzzle.txt @@ -0,0 +1,179 @@ +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +568,139 -> 573,139 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +534,78 -> 539,78 +513,78 -> 518,78 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98 +553,133 -> 558,133 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +511,53 -> 515,53 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +543,144 -> 543,145 -> 560,145 -> 560,144 +522,69 -> 527,69 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +560,133 -> 565,133 +561,139 -> 566,139 +518,94 -> 518,95 -> 532,95 -> 532,94 +497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13 +531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98 +553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +517,53 -> 521,53 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +518,94 -> 518,95 -> 532,95 -> 532,94 +520,78 -> 525,78 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +546,114 -> 546,115 -> 554,115 -> 554,114 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +522,63 -> 527,63 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +564,136 -> 569,136 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +534,111 -> 534,112 -> 549,112 -> 549,111 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13 +553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118 +526,72 -> 531,72 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +533,66 -> 538,66 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +527,78 -> 532,78 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81 +517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +550,136 -> 555,136 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +556,130 -> 561,130 +517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +547,139 -> 552,139 +505,57 -> 509,57 +497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +567,133 -> 572,133 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +520,55 -> 524,55 +517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81 +543,144 -> 543,145 -> 560,145 -> 560,144 +553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118 +497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13 +575,139 -> 580,139 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +511,57 -> 515,57 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +514,55 -> 518,55 +546,114 -> 546,115 -> 554,115 -> 554,114 +557,136 -> 562,136 +571,136 -> 576,136 +546,114 -> 546,115 -> 554,115 -> 554,114 +497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +525,60 -> 530,60 +559,127 -> 564,127 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +529,63 -> 534,63 +526,66 -> 531,66 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +508,55 -> 512,55 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +534,111 -> 534,112 -> 549,112 -> 549,111 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98 +516,75 -> 521,75 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +523,75 -> 528,75 +523,57 -> 527,57 +519,66 -> 524,66 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +554,139 -> 559,139 +543,144 -> 543,145 -> 560,145 -> 560,144 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +514,51 -> 518,51 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +517,57 -> 521,57 +531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +518,94 -> 518,95 -> 532,95 -> 532,94 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +530,75 -> 535,75 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +519,72 -> 524,72 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +563,130 -> 568,130 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98 +534,111 -> 534,112 -> 549,112 -> 549,111 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 \ No newline at end of file diff --git a/2022/day-14/inputs/test.txt b/2022/day-14/inputs/test.txt new file mode 100644 index 0000000..1926028 --- /dev/null +++ b/2022/day-14/inputs/test.txt @@ -0,0 +1,2 @@ +498,4 -> 498,6 -> 496,6 +503,4 -> 502,4 -> 502,9 -> 494,9 \ No newline at end of file diff --git a/2022/day-14/src/bin/part_one.rs b/2022/day-14/src/bin/part_one.rs new file mode 100644 index 0000000..7bacf36 --- /dev/null +++ b/2022/day-14/src/bin/part_one.rs @@ -0,0 +1,72 @@ +use std::{env, io}; + +use aoc_2022_14::{parse_input, CaveMap, Point, SAND_ORIGIN}; + +fn main() -> io::Result<()> { + let infile_path = env::args().nth(1).expect("input file"); + + let result = solve(&infile_path)?; + + println!("{result}"); + + Ok(()) +} + +fn solve(path: &str) -> io::Result { + let mut cave_map = parse_input(path)?; + + loop { + match simulate(&cave_map) { + Some(pos) => cave_map.put_sand(pos), + None => break, + } + } + + Ok(cave_map.count_sand()) +} + +fn simulate(cave_map: &CaveMap) -> Option { + let mut sand_pos = SAND_ORIGIN; + let checks = [(1, 0), (1, -1), (1, 1)]; + + loop { + let next_checks = checks.map(|(x, y)| (sand_pos.0 + x, sand_pos.1 + y)); + let mut next_pos = sand_pos; + + for pos in next_checks { + if !cave_map.is_obstructed(&pos) { + next_pos = pos; + break; + } + } + + if !cave_map.is_in_bounds(&next_pos) { + return None; + } + + if next_pos == sand_pos { + break; + } + + sand_pos = next_pos; + } + + Some(sand_pos) +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn sample() { + let result = solve("inputs/test.txt").unwrap(); + assert_eq!(24, result); + } + + #[test] + fn puzzle() { + let result = solve("inputs/puzzle.txt").unwrap(); + assert_eq!(1068, result); + } +} diff --git a/2022/day-14/src/bin/part_two.rs b/2022/day-14/src/bin/part_two.rs new file mode 100644 index 0000000..d703f35 --- /dev/null +++ b/2022/day-14/src/bin/part_two.rs @@ -0,0 +1,75 @@ +use std::{env, io}; + +use aoc_2022_14::{parse_input, CaveMap, Point, SAND_ORIGIN}; + +fn main() -> io::Result<()> { + let infile_path = env::args().nth(1).expect("input file"); + + let result = solve(&infile_path)?; + + println!("{result}"); + + Ok(()) +} + +fn solve(path: &str) -> io::Result { + let mut cave_map = parse_input(path)?; + + loop { + let pos = simulate(&cave_map); + + cave_map.put_sand(pos); + + if pos == SAND_ORIGIN { + break; + } + } + + Ok(cave_map.count_sand()) +} + +fn simulate(cave_map: &CaveMap) -> Point { + let mut sand_pos = SAND_ORIGIN; + let checks = [(1, 0), (1, -1), (1, 1)]; + + loop { + let next_checks = checks.map(|(x, y)| (sand_pos.0 + x, sand_pos.1 + y)); + let mut next_pos = sand_pos; + + for pos in next_checks { + if !cave_map.is_obstructed(&pos) { + next_pos = pos; + break; + } + } + + if next_pos == sand_pos { + break; + } + + sand_pos = next_pos; + + if cave_map.reached_bottom(&sand_pos) { + break; + } + } + + sand_pos +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn sample() { + let result = solve("inputs/test.txt").unwrap(); + assert_eq!(93, result); + } + + #[test] + fn puzzle() { + let result = solve("inputs/puzzle.txt").unwrap(); + assert_eq!(27936, result); + } +} diff --git a/2022/day-14/src/lib.rs b/2022/day-14/src/lib.rs new file mode 100644 index 0000000..c18ea44 --- /dev/null +++ b/2022/day-14/src/lib.rs @@ -0,0 +1,121 @@ +use std::{ + collections::HashMap, + fs::File, + io::{self, Read}, + path::Path, +}; + +use itertools::Itertools; + +pub const SAND_ORIGIN: Point = (0, 500); + +pub type Point = (i32, i32); +pub type Lines = Vec; + +pub struct CaveMap { + positions: HashMap, + height: i32, + width: i32, +} + +impl CaveMap { + fn new(lines: &[Lines]) -> Self { + let mut width = 0; + let mut height = 0; + let mut positions = HashMap::new(); + + for line in lines { + let rocks = line.windows(2).flat_map(|w| { + let (x1, y1) = w[0]; + let (x2, y2) = w[1]; + let xs = if x1 < x2 { x1..=x2 } else { x2..=x1 }; + let ys = if y1 < y2 { y1..=y2 } else { y2..=y1 }; + ys.cartesian_product(xs) + }); + + for (x, y) in rocks { + if height < x { + height = x; + } + + if width < y { + width = y; + } + + positions.insert((x, y), '#'); + } + } + + CaveMap { + positions, + height, + width, + } + } + + pub fn is_in_bounds(&self, &(x, y): &Point) -> bool { + (0..self.height).contains(&x) && (0..self.width).contains(&y) + } + + pub fn reached_bottom(&self, &(x, _): &Point) -> bool { + let floor_idx = self.height + 1; + floor_idx == x + } + + pub fn is_obstructed(&self, pos: &Point) -> bool { + self.positions.contains_key(pos) + } + + pub fn put_sand(&mut self, pos: Point) { + self.positions.insert(pos, 'o'); + } + + pub fn count_sand(&self) -> usize { + self.positions.values().filter(|&&v| v == 'o').count() + } + + pub fn print(&self) { + for x in 0..=self.height { + for y in 450..=self.width { + if (x, y) == SAND_ORIGIN { + print!("S"); + continue; + } + let val = self.positions.get(&(x, y)).unwrap_or(&'.'); + print!("{val}"); + } + println!(); + } + } +} + +pub fn parse_input

(path: P) -> io::Result +where + P: AsRef, +{ + let mut file = File::open(path)?; + let mut buf = String::new(); + file.read_to_string(&mut buf)?; + + let (_, lines) = parse::lines(&buf).expect("failed to parse lines"); + + Ok(CaveMap::new(&lines)) +} + +mod parse { + use nom::{ + bytes::complete::tag, + character::{self, complete::newline}, + multi::separated_list1, + sequence::separated_pair, + IResult, + }; + + use super::Lines; + + pub(super) fn lines(input: &str) -> IResult<&str, Vec> { + let pairs = separated_pair(character::complete::i32, tag(","), character::complete::i32); + let line = separated_list1(tag(" -> "), pairs); + separated_list1(newline, line)(input) + } +} diff --git a/README.md b/README.md index 9084cda..82817e3 100644 --- a/README.md +++ b/README.md @@ -9,4 +9,4 @@ - [2019](2019/README.md) (0% completed) - [2020](2020/README.md) (20% completed) - [2021](2021/README.md) (68% completed) -- [2022](2022/README.md) (50% completed) +- [2022](2022/README.md) (54% completed)