advent-of-code

Perserverance, or the lack thereof

git clone git://git.shimmy1996.com/advent-of-code.git
commit 8504ad38a94e6f2014f84db4bf2518a8a45ba825
parent aa20bd9fb6a9b0525ebe17297b1c6e8c92eea545
Author: Shimmy Xu <shimmy.xu@shimmy1996.com>
Date:   Wed, 14 Dec 2022 20:26:34 -0500

Add 2022 day 14

Diffstat:
A2022/day14/Cargo.toml | 8++++++++
A2022/day14/input.txt | 130+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A2022/day14/src/main.rs | 116+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 254 insertions(+), 0 deletions(-)
diff --git a/2022/day14/Cargo.toml b/2022/day14/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "day14"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
diff --git a/2022/day14/input.txt b/2022/day14/input.txt
@@ -0,0 +1,130 @@
+522,57 -> 522,59 -> 516,59 -> 516,67 -> 531,67 -> 531,59 -> 526,59 -> 526,57
+479,105 -> 479,107 -> 472,107 -> 472,113 -> 483,113 -> 483,107 -> 482,107 -> 482,105
+479,80 -> 479,78 -> 479,80 -> 481,80 -> 481,77 -> 481,80 -> 483,80 -> 483,77 -> 483,80 -> 485,80 -> 485,71 -> 485,80 -> 487,80 -> 487,74 -> 487,80 -> 489,80 -> 489,71 -> 489,80 -> 491,80 -> 491,75 -> 491,80
+479,80 -> 479,78 -> 479,80 -> 481,80 -> 481,77 -> 481,80 -> 483,80 -> 483,77 -> 483,80 -> 485,80 -> 485,71 -> 485,80 -> 487,80 -> 487,74 -> 487,80 -> 489,80 -> 489,71 -> 489,80 -> 491,80 -> 491,75 -> 491,80
+479,80 -> 479,78 -> 479,80 -> 481,80 -> 481,77 -> 481,80 -> 483,80 -> 483,77 -> 483,80 -> 485,80 -> 485,71 -> 485,80 -> 487,80 -> 487,74 -> 487,80 -> 489,80 -> 489,71 -> 489,80 -> 491,80 -> 491,75 -> 491,80
+510,43 -> 515,43
+477,141 -> 477,144 -> 469,144 -> 469,148 -> 491,148 -> 491,144 -> 483,144 -> 483,141
+525,54 -> 537,54 -> 537,53
+504,47 -> 509,47
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+489,136 -> 494,136
+479,80 -> 479,78 -> 479,80 -> 481,80 -> 481,77 -> 481,80 -> 483,80 -> 483,77 -> 483,80 -> 485,80 -> 485,71 -> 485,80 -> 487,80 -> 487,74 -> 487,80 -> 489,80 -> 489,71 -> 489,80 -> 491,80 -> 491,75 -> 491,80
+479,80 -> 479,78 -> 479,80 -> 481,80 -> 481,77 -> 481,80 -> 483,80 -> 483,77 -> 483,80 -> 485,80 -> 485,71 -> 485,80 -> 487,80 -> 487,74 -> 487,80 -> 489,80 -> 489,71 -> 489,80 -> 491,80 -> 491,75 -> 491,80
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+479,105 -> 479,107 -> 472,107 -> 472,113 -> 483,113 -> 483,107 -> 482,107 -> 482,105
+460,93 -> 464,93
+499,32 -> 499,35 -> 498,35 -> 498,40 -> 512,40 -> 512,35 -> 505,35 -> 505,32
+481,126 -> 481,121 -> 481,126 -> 483,126 -> 483,122 -> 483,126 -> 485,126 -> 485,125 -> 485,126
+481,126 -> 481,121 -> 481,126 -> 483,126 -> 483,122 -> 483,126 -> 485,126 -> 485,125 -> 485,126
+477,141 -> 477,144 -> 469,144 -> 469,148 -> 491,148 -> 491,144 -> 483,144 -> 483,141
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+465,161 -> 465,155 -> 465,161 -> 467,161 -> 467,151 -> 467,161 -> 469,161 -> 469,151 -> 469,161
+469,91 -> 473,91
+496,15 -> 496,16 -> 510,16
+500,138 -> 505,138
+499,32 -> 499,35 -> 498,35 -> 498,40 -> 512,40 -> 512,35 -> 505,35 -> 505,32
+479,105 -> 479,107 -> 472,107 -> 472,113 -> 483,113 -> 483,107 -> 482,107 -> 482,105
+469,87 -> 473,87
+465,161 -> 465,155 -> 465,161 -> 467,161 -> 467,151 -> 467,161 -> 469,161 -> 469,151 -> 469,161
+522,49 -> 527,49
+463,91 -> 467,91
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+496,136 -> 501,136
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+472,93 -> 476,93
+481,126 -> 481,121 -> 481,126 -> 483,126 -> 483,122 -> 483,126 -> 485,126 -> 485,125 -> 485,126
+499,32 -> 499,35 -> 498,35 -> 498,40 -> 512,40 -> 512,35 -> 505,35 -> 505,32
+481,126 -> 481,121 -> 481,126 -> 483,126 -> 483,122 -> 483,126 -> 485,126 -> 485,125 -> 485,126
+477,141 -> 477,144 -> 469,144 -> 469,148 -> 491,148 -> 491,144 -> 483,144 -> 483,141
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+486,138 -> 491,138
+499,32 -> 499,35 -> 498,35 -> 498,40 -> 512,40 -> 512,35 -> 505,35 -> 505,32
+481,130 -> 481,131 -> 494,131
+479,80 -> 479,78 -> 479,80 -> 481,80 -> 481,77 -> 481,80 -> 483,80 -> 483,77 -> 483,80 -> 485,80 -> 485,71 -> 485,80 -> 487,80 -> 487,74 -> 487,80 -> 489,80 -> 489,71 -> 489,80 -> 491,80 -> 491,75 -> 491,80
+479,80 -> 479,78 -> 479,80 -> 481,80 -> 481,77 -> 481,80 -> 483,80 -> 483,77 -> 483,80 -> 485,80 -> 485,71 -> 485,80 -> 487,80 -> 487,74 -> 487,80 -> 489,80 -> 489,71 -> 489,80 -> 491,80 -> 491,75 -> 491,80
+514,45 -> 519,45
+518,47 -> 523,47
+501,49 -> 506,49
+481,126 -> 481,121 -> 481,126 -> 483,126 -> 483,122 -> 483,126 -> 485,126 -> 485,125 -> 485,126
+484,100 -> 488,100
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+481,102 -> 485,102
+475,91 -> 479,91
+499,32 -> 499,35 -> 498,35 -> 498,40 -> 512,40 -> 512,35 -> 505,35 -> 505,32
+479,80 -> 479,78 -> 479,80 -> 481,80 -> 481,77 -> 481,80 -> 483,80 -> 483,77 -> 483,80 -> 485,80 -> 485,71 -> 485,80 -> 487,80 -> 487,74 -> 487,80 -> 489,80 -> 489,71 -> 489,80 -> 491,80 -> 491,75 -> 491,80
+479,80 -> 479,78 -> 479,80 -> 481,80 -> 481,77 -> 481,80 -> 483,80 -> 483,77 -> 483,80 -> 485,80 -> 485,71 -> 485,80 -> 487,80 -> 487,74 -> 487,80 -> 489,80 -> 489,71 -> 489,80 -> 491,80 -> 491,75 -> 491,80
+522,57 -> 522,59 -> 516,59 -> 516,67 -> 531,67 -> 531,59 -> 526,59 -> 526,57
+478,93 -> 482,93
+492,134 -> 497,134
+465,161 -> 465,155 -> 465,161 -> 467,161 -> 467,151 -> 467,161 -> 469,161 -> 469,151 -> 469,161
+477,141 -> 477,144 -> 469,144 -> 469,148 -> 491,148 -> 491,144 -> 483,144 -> 483,141
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+472,89 -> 476,89
+479,105 -> 479,107 -> 472,107 -> 472,113 -> 483,113 -> 483,107 -> 482,107 -> 482,105
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+479,80 -> 479,78 -> 479,80 -> 481,80 -> 481,77 -> 481,80 -> 483,80 -> 483,77 -> 483,80 -> 485,80 -> 485,71 -> 485,80 -> 487,80 -> 487,74 -> 487,80 -> 489,80 -> 489,71 -> 489,80 -> 491,80 -> 491,75 -> 491,80
+507,45 -> 512,45
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+481,126 -> 481,121 -> 481,126 -> 483,126 -> 483,122 -> 483,126 -> 485,126 -> 485,125 -> 485,126
+522,57 -> 522,59 -> 516,59 -> 516,67 -> 531,67 -> 531,59 -> 526,59 -> 526,57
+465,161 -> 465,155 -> 465,161 -> 467,161 -> 467,151 -> 467,161 -> 469,161 -> 469,151 -> 469,161
+479,80 -> 479,78 -> 479,80 -> 481,80 -> 481,77 -> 481,80 -> 483,80 -> 483,77 -> 483,80 -> 485,80 -> 485,71 -> 485,80 -> 487,80 -> 487,74 -> 487,80 -> 489,80 -> 489,71 -> 489,80 -> 491,80 -> 491,75 -> 491,80
+472,84 -> 482,84
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+479,105 -> 479,107 -> 472,107 -> 472,113 -> 483,113 -> 483,107 -> 482,107 -> 482,105
+477,141 -> 477,144 -> 469,144 -> 469,148 -> 491,148 -> 491,144 -> 483,144 -> 483,141
+479,105 -> 479,107 -> 472,107 -> 472,113 -> 483,113 -> 483,107 -> 482,107 -> 482,105
+479,105 -> 479,107 -> 472,107 -> 472,113 -> 483,113 -> 483,107 -> 482,107 -> 482,105
+508,49 -> 513,49
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+466,93 -> 470,93
+522,57 -> 522,59 -> 516,59 -> 516,67 -> 531,67 -> 531,59 -> 526,59 -> 526,57
+499,32 -> 499,35 -> 498,35 -> 498,40 -> 512,40 -> 512,35 -> 505,35 -> 505,32
+522,57 -> 522,59 -> 516,59 -> 516,67 -> 531,67 -> 531,59 -> 526,59 -> 526,57
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+465,161 -> 465,155 -> 465,161 -> 467,161 -> 467,151 -> 467,161 -> 469,161 -> 469,151 -> 469,161
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+511,47 -> 516,47
+493,138 -> 498,138
+479,80 -> 479,78 -> 479,80 -> 481,80 -> 481,77 -> 481,80 -> 483,80 -> 483,77 -> 483,80 -> 485,80 -> 485,71 -> 485,80 -> 487,80 -> 487,74 -> 487,80 -> 489,80 -> 489,71 -> 489,80 -> 491,80 -> 491,75 -> 491,80
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+479,80 -> 479,78 -> 479,80 -> 481,80 -> 481,77 -> 481,80 -> 483,80 -> 483,77 -> 483,80 -> 485,80 -> 485,71 -> 485,80 -> 487,80 -> 487,74 -> 487,80 -> 489,80 -> 489,71 -> 489,80 -> 491,80 -> 491,75 -> 491,80
+522,57 -> 522,59 -> 516,59 -> 516,67 -> 531,67 -> 531,59 -> 526,59 -> 526,57
+499,102 -> 503,102
+477,141 -> 477,144 -> 469,144 -> 469,148 -> 491,148 -> 491,144 -> 483,144 -> 483,141
+525,54 -> 537,54 -> 537,53
+479,80 -> 479,78 -> 479,80 -> 481,80 -> 481,77 -> 481,80 -> 483,80 -> 483,77 -> 483,80 -> 485,80 -> 485,71 -> 485,80 -> 487,80 -> 487,74 -> 487,80 -> 489,80 -> 489,71 -> 489,80 -> 491,80 -> 491,75 -> 491,80
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+496,15 -> 496,16 -> 510,16
+487,98 -> 491,98
+479,80 -> 479,78 -> 479,80 -> 481,80 -> 481,77 -> 481,80 -> 483,80 -> 483,77 -> 483,80 -> 485,80 -> 485,71 -> 485,80 -> 487,80 -> 487,74 -> 487,80 -> 489,80 -> 489,71 -> 489,80 -> 491,80 -> 491,75 -> 491,80
+477,141 -> 477,144 -> 469,144 -> 469,148 -> 491,148 -> 491,144 -> 483,144 -> 483,141
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+490,96 -> 494,96
+496,100 -> 500,100
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+465,161 -> 465,155 -> 465,161 -> 467,161 -> 467,151 -> 467,161 -> 469,161 -> 469,151 -> 469,161
+479,80 -> 479,78 -> 479,80 -> 481,80 -> 481,77 -> 481,80 -> 483,80 -> 483,77 -> 483,80 -> 485,80 -> 485,71 -> 485,80 -> 487,80 -> 487,74 -> 487,80 -> 489,80 -> 489,71 -> 489,80 -> 491,80 -> 491,75 -> 491,80
+493,98 -> 497,98
+466,89 -> 470,89
+479,80 -> 479,78 -> 479,80 -> 481,80 -> 481,77 -> 481,80 -> 483,80 -> 483,77 -> 483,80 -> 485,80 -> 485,71 -> 485,80 -> 487,80 -> 487,74 -> 487,80 -> 489,80 -> 489,71 -> 489,80 -> 491,80 -> 491,75 -> 491,80
+479,80 -> 479,78 -> 479,80 -> 481,80 -> 481,77 -> 481,80 -> 483,80 -> 483,77 -> 483,80 -> 485,80 -> 485,71 -> 485,80 -> 487,80 -> 487,74 -> 487,80 -> 489,80 -> 489,71 -> 489,80 -> 491,80 -> 491,75 -> 491,80
+481,126 -> 481,121 -> 481,126 -> 483,126 -> 483,122 -> 483,126 -> 485,126 -> 485,125 -> 485,126
+465,161 -> 465,155 -> 465,161 -> 467,161 -> 467,151 -> 467,161 -> 469,161 -> 469,151 -> 469,161
+481,130 -> 481,131 -> 494,131
+481,126 -> 481,121 -> 481,126 -> 483,126 -> 483,122 -> 483,126 -> 485,126 -> 485,125 -> 485,126
+499,32 -> 499,35 -> 498,35 -> 498,40 -> 512,40 -> 512,35 -> 505,35 -> 505,32
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+487,102 -> 491,102
+465,161 -> 465,155 -> 465,161 -> 467,161 -> 467,151 -> 467,161 -> 469,161 -> 469,151 -> 469,161
+522,57 -> 522,59 -> 516,59 -> 516,67 -> 531,67 -> 531,59 -> 526,59 -> 526,57
+493,102 -> 497,102
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+479,80 -> 479,78 -> 479,80 -> 481,80 -> 481,77 -> 481,80 -> 483,80 -> 483,77 -> 483,80 -> 485,80 -> 485,71 -> 485,80 -> 487,80 -> 487,74 -> 487,80 -> 489,80 -> 489,71 -> 489,80 -> 491,80 -> 491,75 -> 491,80
+479,80 -> 479,78 -> 479,80 -> 481,80 -> 481,77 -> 481,80 -> 483,80 -> 483,77 -> 483,80 -> 485,80 -> 485,71 -> 485,80 -> 487,80 -> 487,74 -> 487,80 -> 489,80 -> 489,71 -> 489,80 -> 491,80 -> 491,75 -> 491,80
+487,29 -> 487,21 -> 487,29 -> 489,29 -> 489,22 -> 489,29 -> 491,29 -> 491,22 -> 491,29 -> 493,29 -> 493,19 -> 493,29 -> 495,29 -> 495,23 -> 495,29 -> 497,29 -> 497,27 -> 497,29 -> 499,29 -> 499,23 -> 499,29 -> 501,29 -> 501,26 -> 501,29
+515,49 -> 520,49
+490,100 -> 494,100
diff --git a/2022/day14/src/main.rs b/2022/day14/src/main.rs
@@ -0,0 +1,116 @@
+use std::cmp::Ordering;
+use std::collections::HashMap;
+
+#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)]
+struct Coord(i32, i32);
+
+impl Coord {
+    fn from_str(s: &str) -> Self {
+        let tmp = s
+            .split(',')
+            .map(|x| x.parse::<i32>().unwrap())
+            .collect::<Vec<i32>>();
+        Self(tmp[0], tmp[1])
+    }
+}
+
+#[derive(Debug, Clone, Copy)]
+enum Terrain {
+    Sand,
+    Rock,
+}
+
+fn sign(a: i32) -> i32 {
+    match a.cmp(&0) {
+        Ordering::Less => -1,
+        Ordering::Equal => 0,
+        Ordering::Greater => 1,
+    }
+}
+
+fn main() {
+    let input = {
+        let mut tmp = HashMap::new();
+        for l in std::fs::read_to_string("input.txt")
+            .unwrap()
+            .trim()
+            .split('\n')
+        {
+            let points = l
+                .split(" -> ")
+                .map(|s| Coord::from_str(s))
+                .collect::<Vec<Coord>>();
+            let mut curr = points[0];
+            tmp.insert(curr, Terrain::Rock);
+            for next in &points[1..] {
+                while curr != *next {
+                    curr = Coord(
+                        curr.0 + sign(next.0 - curr.0),
+                        curr.1 + sign(next.1 - curr.1),
+                    );
+                    tmp.insert(curr, Terrain::Rock);
+                }
+            }
+        }
+        tmp
+    };
+    let source = Coord(500, 0);
+    // 1072
+    println!("Part 1: {}", part_1(&input, source));
+    // 24659
+    println!("Part 2: {}", part_2(&input, source, 2));
+}
+
+fn part_1(input: &HashMap<Coord, Terrain>, source: Coord) -> usize {
+    let y_max = input.keys().map(|c| c.1).max().unwrap();
+    let mut sim: HashMap<Coord, Terrain> = input.clone();
+    'outer: loop {
+        let mut sand_curr = source;
+        while sand_curr.1 < y_max {
+            let mut comes_to_rest = true;
+            for (dx, dy) in [(0, 1), (-1, 1), (1, 1)] {
+                let sand_next = Coord(sand_curr.0 + dx, sand_curr.1 + dy);
+                if !sim.contains_key(&sand_next) {
+                    sand_curr = sand_next;
+                    comes_to_rest = false;
+                    break;
+                }
+            }
+            if comes_to_rest {
+                sim.insert(sand_curr, Terrain::Sand);
+                continue 'outer;
+            }
+        }
+        break;
+    }
+    sim.values()
+        .filter(|x| if let Terrain::Sand = x { true } else { false })
+        .count()
+}
+
+fn part_2(input: &HashMap<Coord, Terrain>, source: Coord, floor_offset: i32) -> usize {
+    let y_max = input.keys().map(|c| c.1).max().unwrap() + floor_offset;
+    let mut sim: HashMap<Coord, Terrain> = input.clone();
+    while !sim.contains_key(&source) {
+        let mut sand_curr = source;
+        loop {
+            let mut comes_to_rest = true;
+            for (dx, dy) in [(0, 1), (-1, 1), (1, 1)] {
+                let sand_next = Coord(sand_curr.0 + dx, sand_curr.1 + dy);
+                if !sim.contains_key(&sand_next) {
+                    sand_curr = sand_next;
+                    comes_to_rest = false;
+                    break;
+                }
+            }
+            comes_to_rest = comes_to_rest || sand_curr.1 == y_max - 1;
+            if comes_to_rest {
+                sim.insert(sand_curr, Terrain::Sand);
+                break;
+            }
+        }
+    }
+    sim.values()
+        .filter(|x| if let Terrain::Sand = x { true } else { false })
+        .count()
+}