summaryrefslogtreecommitdiff
path: root/Advent-of-Code-2022/aoc-14
diff options
context:
space:
mode:
Diffstat (limited to 'Advent-of-Code-2022/aoc-14')
-rwxr-xr-xAdvent-of-Code-2022/aoc-14/build.sh5
-rw-r--r--Advent-of-Code-2022/aoc-14/input.txt129
-rw-r--r--Advent-of-Code-2022/aoc-14/main.c122
-rw-r--r--Advent-of-Code-2022/aoc-14/sample.txt2
4 files changed, 258 insertions, 0 deletions
diff --git a/Advent-of-Code-2022/aoc-14/build.sh b/Advent-of-Code-2022/aoc-14/build.sh
new file mode 100755
index 0000000..9e59ef5
--- /dev/null
+++ b/Advent-of-Code-2022/aoc-14/build.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+set -xe
+
+gcc -o main main.c -Wall -Wextra -pedantic -D_POSIX_C_SOURCE
diff --git a/Advent-of-Code-2022/aoc-14/input.txt b/Advent-of-Code-2022/aoc-14/input.txt
new file mode 100644
index 0000000..049aec7
--- /dev/null
+++ b/Advent-of-Code-2022/aoc-14/input.txt
@@ -0,0 +1,129 @@
+490,51 -> 490,54 -> 486,54 -> 486,59 -> 499,59 -> 499,54 -> 492,54 -> 492,51
+476,161 -> 476,156 -> 476,161 -> 478,161 -> 478,160 -> 478,161 -> 480,161 -> 480,154 -> 480,161 -> 482,161 -> 482,155 -> 482,161 -> 484,161 -> 484,158 -> 484,161 -> 486,161 -> 486,159 -> 486,161
+472,79 -> 472,73 -> 472,79 -> 474,79 -> 474,69 -> 474,79 -> 476,79 -> 476,77 -> 476,79
+477,148 -> 477,138 -> 477,148 -> 479,148 -> 479,144 -> 479,148 -> 481,148 -> 481,146 -> 481,148
+484,132 -> 489,132
+501,15 -> 506,15
+485,85 -> 485,88 -> 482,88 -> 482,93 -> 499,93 -> 499,88 -> 491,88 -> 491,85
+472,79 -> 472,73 -> 472,79 -> 474,79 -> 474,69 -> 474,79 -> 476,79 -> 476,77 -> 476,79
+503,43 -> 514,43 -> 514,42
+497,13 -> 502,13
+490,51 -> 490,54 -> 486,54 -> 486,59 -> 499,59 -> 499,54 -> 492,54 -> 492,51
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+498,17 -> 503,17
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+490,51 -> 490,54 -> 486,54 -> 486,59 -> 499,59 -> 499,54 -> 492,54 -> 492,51
+467,81 -> 467,82 -> 487,82 -> 487,81
+481,135 -> 486,135
+485,85 -> 485,88 -> 482,88 -> 482,93 -> 499,93 -> 499,88 -> 491,88 -> 491,85
+476,161 -> 476,156 -> 476,161 -> 478,161 -> 478,160 -> 478,161 -> 480,161 -> 480,154 -> 480,161 -> 482,161 -> 482,155 -> 482,161 -> 484,161 -> 484,158 -> 484,161 -> 486,161 -> 486,159 -> 486,161
+470,122 -> 470,123 -> 485,123 -> 485,122
+491,132 -> 496,132
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+476,161 -> 476,156 -> 476,161 -> 478,161 -> 478,160 -> 478,161 -> 480,161 -> 480,154 -> 480,161 -> 482,161 -> 482,155 -> 482,161 -> 484,161 -> 484,158 -> 484,161 -> 486,161 -> 486,159 -> 486,161
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+491,17 -> 496,17
+476,161 -> 476,156 -> 476,161 -> 478,161 -> 478,160 -> 478,161 -> 480,161 -> 480,154 -> 480,161 -> 482,161 -> 482,155 -> 482,161 -> 484,161 -> 484,158 -> 484,161 -> 486,161 -> 486,159 -> 486,161
+497,26 -> 501,26
+476,161 -> 476,156 -> 476,161 -> 478,161 -> 478,160 -> 478,161 -> 480,161 -> 480,154 -> 480,161 -> 482,161 -> 482,155 -> 482,161 -> 484,161 -> 484,158 -> 484,161 -> 486,161 -> 486,159 -> 486,161
+491,22 -> 495,22
+477,148 -> 477,138 -> 477,148 -> 479,148 -> 479,144 -> 479,148 -> 481,148 -> 481,146 -> 481,148
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+476,161 -> 476,156 -> 476,161 -> 478,161 -> 478,160 -> 478,161 -> 480,161 -> 480,154 -> 480,161 -> 482,161 -> 482,155 -> 482,161 -> 484,161 -> 484,158 -> 484,161 -> 486,161 -> 486,159 -> 486,161
+480,129 -> 485,129
+490,51 -> 490,54 -> 486,54 -> 486,59 -> 499,59 -> 499,54 -> 492,54 -> 492,51
+477,132 -> 482,132
+477,148 -> 477,138 -> 477,148 -> 479,148 -> 479,144 -> 479,148 -> 481,148 -> 481,146 -> 481,148
+476,161 -> 476,156 -> 476,161 -> 478,161 -> 478,160 -> 478,161 -> 480,161 -> 480,154 -> 480,161 -> 482,161 -> 482,155 -> 482,161 -> 484,161 -> 484,158 -> 484,161 -> 486,161 -> 486,159 -> 486,161
+488,20 -> 492,20
+492,48 -> 506,48 -> 506,47
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+477,148 -> 477,138 -> 477,148 -> 479,148 -> 479,144 -> 479,148 -> 481,148 -> 481,146 -> 481,148
+474,135 -> 479,135
+479,64 -> 484,64
+510,29 -> 510,33 -> 506,33 -> 506,39 -> 517,39 -> 517,33 -> 512,33 -> 512,29
+486,64 -> 491,64
+490,66 -> 495,66
+476,161 -> 476,156 -> 476,161 -> 478,161 -> 478,160 -> 478,161 -> 480,161 -> 480,154 -> 480,161 -> 482,161 -> 482,155 -> 482,161 -> 484,161 -> 484,158 -> 484,161 -> 486,161 -> 486,159 -> 486,161
+472,79 -> 472,73 -> 472,79 -> 474,79 -> 474,69 -> 474,79 -> 476,79 -> 476,77 -> 476,79
+494,24 -> 498,24
+476,161 -> 476,156 -> 476,161 -> 478,161 -> 478,160 -> 478,161 -> 480,161 -> 480,154 -> 480,161 -> 482,161 -> 482,155 -> 482,161 -> 484,161 -> 484,158 -> 484,161 -> 486,161 -> 486,159 -> 486,161
+471,109 -> 471,112 -> 467,112 -> 467,120 -> 477,120 -> 477,112 -> 475,112 -> 475,109
+503,43 -> 514,43 -> 514,42
+477,148 -> 477,138 -> 477,148 -> 479,148 -> 479,144 -> 479,148 -> 481,148 -> 481,146 -> 481,148
+485,85 -> 485,88 -> 482,88 -> 482,93 -> 499,93 -> 499,88 -> 491,88 -> 491,85
+476,161 -> 476,156 -> 476,161 -> 478,161 -> 478,160 -> 478,161 -> 480,161 -> 480,154 -> 480,161 -> 482,161 -> 482,155 -> 482,161 -> 484,161 -> 484,158 -> 484,161 -> 486,161 -> 486,159 -> 486,161
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+510,29 -> 510,33 -> 506,33 -> 506,39 -> 517,39 -> 517,33 -> 512,33 -> 512,29
+488,135 -> 493,135
+472,79 -> 472,73 -> 472,79 -> 474,79 -> 474,69 -> 474,79 -> 476,79 -> 476,77 -> 476,79
+467,81 -> 467,82 -> 487,82 -> 487,81
+483,126 -> 488,126
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+483,66 -> 488,66
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+477,148 -> 477,138 -> 477,148 -> 479,148 -> 479,144 -> 479,148 -> 481,148 -> 481,146 -> 481,148
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+476,161 -> 476,156 -> 476,161 -> 478,161 -> 478,160 -> 478,161 -> 480,161 -> 480,154 -> 480,161 -> 482,161 -> 482,155 -> 482,161 -> 484,161 -> 484,158 -> 484,161 -> 486,161 -> 486,159 -> 486,161
+476,66 -> 481,66
+472,79 -> 472,73 -> 472,79 -> 474,79 -> 474,69 -> 474,79 -> 476,79 -> 476,77 -> 476,79
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+476,161 -> 476,156 -> 476,161 -> 478,161 -> 478,160 -> 478,161 -> 480,161 -> 480,154 -> 480,161 -> 482,161 -> 482,155 -> 482,161 -> 484,161 -> 484,158 -> 484,161 -> 486,161 -> 486,159 -> 486,161
+494,15 -> 499,15
+476,161 -> 476,156 -> 476,161 -> 478,161 -> 478,160 -> 478,161 -> 480,161 -> 480,154 -> 480,161 -> 482,161 -> 482,155 -> 482,161 -> 484,161 -> 484,158 -> 484,161 -> 486,161 -> 486,159 -> 486,161
+476,161 -> 476,156 -> 476,161 -> 478,161 -> 478,160 -> 478,161 -> 480,161 -> 480,154 -> 480,161 -> 482,161 -> 482,155 -> 482,161 -> 484,161 -> 484,158 -> 484,161 -> 486,161 -> 486,159 -> 486,161
+485,85 -> 485,88 -> 482,88 -> 482,93 -> 499,93 -> 499,88 -> 491,88 -> 491,85
+485,22 -> 489,22
+487,129 -> 492,129
+477,148 -> 477,138 -> 477,148 -> 479,148 -> 479,144 -> 479,148 -> 481,148 -> 481,146 -> 481,148
+471,109 -> 471,112 -> 467,112 -> 467,120 -> 477,120 -> 477,112 -> 475,112 -> 475,109
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+485,85 -> 485,88 -> 482,88 -> 482,93 -> 499,93 -> 499,88 -> 491,88 -> 491,85
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+488,24 -> 492,24
+490,51 -> 490,54 -> 486,54 -> 486,59 -> 499,59 -> 499,54 -> 492,54 -> 492,51
+472,79 -> 472,73 -> 472,79 -> 474,79 -> 474,69 -> 474,79 -> 476,79 -> 476,77 -> 476,79
+476,161 -> 476,156 -> 476,161 -> 478,161 -> 478,160 -> 478,161 -> 480,161 -> 480,154 -> 480,161 -> 482,161 -> 482,155 -> 482,161 -> 484,161 -> 484,158 -> 484,161 -> 486,161 -> 486,159 -> 486,161
+485,85 -> 485,88 -> 482,88 -> 482,93 -> 499,93 -> 499,88 -> 491,88 -> 491,85
+472,79 -> 472,73 -> 472,79 -> 474,79 -> 474,69 -> 474,79 -> 476,79 -> 476,77 -> 476,79
+477,148 -> 477,138 -> 477,148 -> 479,148 -> 479,144 -> 479,148 -> 481,148 -> 481,146 -> 481,148
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+510,29 -> 510,33 -> 506,33 -> 506,39 -> 517,39 -> 517,33 -> 512,33 -> 512,29
+495,135 -> 500,135
+471,109 -> 471,112 -> 467,112 -> 467,120 -> 477,120 -> 477,112 -> 475,112 -> 475,109
+510,29 -> 510,33 -> 506,33 -> 506,39 -> 517,39 -> 517,33 -> 512,33 -> 512,29
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+471,109 -> 471,112 -> 467,112 -> 467,120 -> 477,120 -> 477,112 -> 475,112 -> 475,109
+482,24 -> 486,24
+471,109 -> 471,112 -> 467,112 -> 467,120 -> 477,120 -> 477,112 -> 475,112 -> 475,109
+510,29 -> 510,33 -> 506,33 -> 506,39 -> 517,39 -> 517,33 -> 512,33 -> 512,29
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+491,26 -> 495,26
+470,122 -> 470,123 -> 485,123 -> 485,122
+505,17 -> 510,17
+470,122 -> 470,123 -> 485,123 -> 485,122
+510,29 -> 510,33 -> 506,33 -> 506,39 -> 517,39 -> 517,33 -> 512,33 -> 512,29
+485,26 -> 489,26
+471,109 -> 471,112 -> 467,112 -> 467,120 -> 477,120 -> 477,112 -> 475,112 -> 475,109
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+471,109 -> 471,112 -> 467,112 -> 467,120 -> 477,120 -> 477,112 -> 475,112 -> 475,109
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+485,85 -> 485,88 -> 482,88 -> 482,93 -> 499,93 -> 499,88 -> 491,88 -> 491,85
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+472,79 -> 472,73 -> 472,79 -> 474,79 -> 474,69 -> 474,79 -> 476,79 -> 476,77 -> 476,79
+510,29 -> 510,33 -> 506,33 -> 506,39 -> 517,39 -> 517,33 -> 512,33 -> 512,29
+467,81 -> 467,82 -> 487,82 -> 487,81
+479,26 -> 483,26
+492,48 -> 506,48 -> 506,47
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
+476,161 -> 476,156 -> 476,161 -> 478,161 -> 478,160 -> 478,161 -> 480,161 -> 480,154 -> 480,161 -> 482,161 -> 482,155 -> 482,161 -> 484,161 -> 484,158 -> 484,161 -> 486,161 -> 486,159 -> 486,161
+490,51 -> 490,54 -> 486,54 -> 486,59 -> 499,59 -> 499,54 -> 492,54 -> 492,51
+482,62 -> 487,62
+476,161 -> 476,156 -> 476,161 -> 478,161 -> 478,160 -> 478,161 -> 480,161 -> 480,154 -> 480,161 -> 482,161 -> 482,155 -> 482,161 -> 484,161 -> 484,158 -> 484,161 -> 486,161 -> 486,159 -> 486,161
+490,51 -> 490,54 -> 486,54 -> 486,59 -> 499,59 -> 499,54 -> 492,54 -> 492,51
+457,106 -> 457,99 -> 457,106 -> 459,106 -> 459,98 -> 459,106 -> 461,106 -> 461,97 -> 461,106 -> 463,106 -> 463,105 -> 463,106 -> 465,106 -> 465,99 -> 465,106 -> 467,106 -> 467,103 -> 467,106 -> 469,106 -> 469,101 -> 469,106 -> 471,106 -> 471,103 -> 471,106 -> 473,106 -> 473,100 -> 473,106
diff --git a/Advent-of-Code-2022/aoc-14/main.c b/Advent-of-Code-2022/aoc-14/main.c
new file mode 100644
index 0000000..7fcfdfa
--- /dev/null
+++ b/Advent-of-Code-2022/aoc-14/main.c
@@ -0,0 +1,122 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+
+#if 0
+ #define PART part1
+#else
+ #define PART part2
+#endif
+
+#if 0
+ #define FILENAME "sample.txt"
+ #define WIDTH 600
+ #define HEIGHT 20
+#else
+ #define FILENAME "input.txt"
+ #define WIDTH 2000
+ #define HEIGHT 500
+#endif
+
+#define MAX(x, y) (((x) > (y)) ? (x) : (y))
+#define MIN(x, y) (((x) < (y)) ? (x) : (y))
+
+int map[WIDTH][HEIGHT] = {0};
+int max_y = INT_MIN;
+int sands = 0;
+
+int sim_sand()
+{
+ int sand_x = 500;
+ int sand_y = 0;
+ while(1) {
+ if(sand_y >= max_y)
+ return -1;
+
+ if(map[sand_x][sand_y + 1] != 1) {
+ sand_y++;
+ } else if(map[sand_x - 1][sand_y + 1] != 1) {
+ sand_x--; sand_y++;
+ } else if(map[sand_x + 1][sand_y + 1] != 1) {
+ sand_x++; sand_y++;
+ } else break;
+
+ continue;
+ }
+
+ map[sand_x][sand_y] = 1;
+ return 0;
+}
+
+void part1()
+{
+ while(sim_sand() == 0)
+ sands++;
+}
+
+void draw_line(int x1, int y1, int x2, int y2);
+
+void part2()
+{
+ draw_line(0, max_y + 2, WIDTH-1, max_y + 2);
+ max_y = INT_MAX;
+
+ while(map[500][0] != 1) {
+ sim_sand();
+ sands++;
+ }
+}
+
+void draw_line(int x1, int y1, int x2, int y2)
+{
+ if(x1 != x2 && y1 == y2)
+ for(int x = MIN(x1, x2); x <= MAX(x1, x2); x++)
+ map[x][y1] = 1;
+ else if(y1 != y2 && x1 == x2)
+ for(int y = MIN(y1, y2); y <= MAX(y1, y2); y++)
+ map[x1][y] = 1;
+}
+
+
+void parse()
+{
+ FILE *fp = fopen(FILENAME, "r");
+ if(!fp) {
+ fprintf(stderr, "ERROR: Could not open file %s\n", FILENAME);
+ exit(1);
+ }
+
+ char line[5000];
+ while(fgets(line, sizeof(line), fp))
+ {
+ int x1 = -1; int y1 = -1;
+ int x2 = -1; int y2 = -1;
+
+ char *sprt1;
+ char *tok = strtok_r(line, " -> ", &sprt1);
+ while(tok != NULL) {
+
+ char *sprt2;
+ x2 = atoi(strtok_r(tok, ",", &sprt2));
+ y2 = atoi(strtok_r(NULL, ",", &sprt2));
+ max_y = MAX(max_y, y2);
+
+ if(x1 != -1 && y1 != -1)
+ draw_line(x1, y1, x2, y2);
+ x1 = x2; y1 = y2;
+
+ tok = strtok_r(NULL, " -> ", &sprt1);
+ }
+ }
+
+ fclose(fp);
+}
+
+int main(void)
+{
+ parse();
+ PART();
+ printf("%d\n", sands);
+ return 0;
+}
diff --git a/Advent-of-Code-2022/aoc-14/sample.txt b/Advent-of-Code-2022/aoc-14/sample.txt
new file mode 100644
index 0000000..4e87bb5
--- /dev/null
+++ b/Advent-of-Code-2022/aoc-14/sample.txt
@@ -0,0 +1,2 @@
+498,4 -> 498,6 -> 496,6
+503,4 -> 502,4 -> 502,9 -> 494,9