This commit is contained in:
JonOfUs 2022-12-14 12:57:39 +01:00
parent 22a46d10a6
commit ae19a80e72
4 changed files with 304 additions and 1 deletions

158
res/14/input.txt Normal file
View file

@ -0,0 +1,158 @@
498,32 -> 503,32
538,63 -> 538,65 -> 534,65 -> 534,70 -> 551,70 -> 551,65 -> 544,65 -> 544,63
525,56 -> 530,56
552,86 -> 557,86
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
558,104 -> 558,94 -> 558,104 -> 560,104 -> 560,99 -> 560,104 -> 562,104 -> 562,101 -> 562,104 -> 564,104 -> 564,99 -> 564,104
594,151 -> 594,154 -> 591,154 -> 591,162 -> 602,162 -> 602,154 -> 598,154 -> 598,151
504,56 -> 509,56
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
503,52 -> 508,52
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
558,104 -> 558,94 -> 558,104 -> 560,104 -> 560,99 -> 560,104 -> 562,104 -> 562,101 -> 562,104 -> 564,104 -> 564,99 -> 564,104
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
551,90 -> 551,91 -> 561,91 -> 561,90
521,59 -> 521,60 -> 540,60 -> 540,59
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
563,107 -> 563,111 -> 556,111 -> 556,117 -> 574,117 -> 574,111 -> 566,111 -> 566,107
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
594,151 -> 594,154 -> 591,154 -> 591,162 -> 602,162 -> 602,154 -> 598,154 -> 598,151
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
558,80 -> 563,80
594,151 -> 594,154 -> 591,154 -> 591,162 -> 602,162 -> 602,154 -> 598,154 -> 598,151
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
563,107 -> 563,111 -> 556,111 -> 556,117 -> 574,117 -> 574,111 -> 566,111 -> 566,107
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
511,56 -> 516,56
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
518,56 -> 523,56
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
521,59 -> 521,60 -> 540,60 -> 540,59
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
563,107 -> 563,111 -> 556,111 -> 556,117 -> 574,117 -> 574,111 -> 566,111 -> 566,107
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
538,63 -> 538,65 -> 534,65 -> 534,70 -> 551,70 -> 551,65 -> 544,65 -> 544,63
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
594,151 -> 594,154 -> 591,154 -> 591,162 -> 602,162 -> 602,154 -> 598,154 -> 598,151
563,107 -> 563,111 -> 556,111 -> 556,117 -> 574,117 -> 574,111 -> 566,111 -> 566,107
594,151 -> 594,154 -> 591,154 -> 591,162 -> 602,162 -> 602,154 -> 598,154 -> 598,151
572,120 -> 572,123 -> 569,123 -> 569,129 -> 584,129 -> 584,123 -> 577,123 -> 577,120
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
563,107 -> 563,111 -> 556,111 -> 556,117 -> 574,117 -> 574,111 -> 566,111 -> 566,107
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
553,75 -> 557,75
559,86 -> 564,86
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
581,167 -> 581,168 -> 600,168 -> 600,167
572,120 -> 572,123 -> 569,123 -> 569,129 -> 584,129 -> 584,123 -> 577,123 -> 577,120
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
558,104 -> 558,94 -> 558,104 -> 560,104 -> 560,99 -> 560,104 -> 562,104 -> 562,101 -> 562,104 -> 564,104 -> 564,99 -> 564,104
584,135 -> 594,135 -> 594,134
558,104 -> 558,94 -> 558,104 -> 560,104 -> 560,99 -> 560,104 -> 562,104 -> 562,101 -> 562,104 -> 564,104 -> 564,99 -> 564,104
501,29 -> 506,29
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
514,54 -> 519,54
562,83 -> 567,83
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
500,54 -> 505,54
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
558,104 -> 558,94 -> 558,104 -> 560,104 -> 560,99 -> 560,104 -> 562,104 -> 562,101 -> 562,104 -> 564,104 -> 564,99 -> 564,104
551,90 -> 551,91 -> 561,91 -> 561,90
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
538,63 -> 538,65 -> 534,65 -> 534,70 -> 551,70 -> 551,65 -> 544,65 -> 544,63
544,77 -> 548,77
506,50 -> 511,50
505,32 -> 510,32
594,151 -> 594,154 -> 591,154 -> 591,162 -> 602,162 -> 602,154 -> 598,154 -> 598,151
538,63 -> 538,65 -> 534,65 -> 534,70 -> 551,70 -> 551,65 -> 544,65 -> 544,63
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
497,56 -> 502,56
566,86 -> 571,86
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
581,167 -> 581,168 -> 600,168 -> 600,167
572,120 -> 572,123 -> 569,123 -> 569,129 -> 584,129 -> 584,123 -> 577,123 -> 577,120
563,107 -> 563,111 -> 556,111 -> 556,117 -> 574,117 -> 574,111 -> 566,111 -> 566,107
558,104 -> 558,94 -> 558,104 -> 560,104 -> 560,99 -> 560,104 -> 562,104 -> 562,101 -> 562,104 -> 564,104 -> 564,99 -> 564,104
572,120 -> 572,123 -> 569,123 -> 569,129 -> 584,129 -> 584,123 -> 577,123 -> 577,120
558,104 -> 558,94 -> 558,104 -> 560,104 -> 560,99 -> 560,104 -> 562,104 -> 562,101 -> 562,104 -> 564,104 -> 564,99 -> 564,104
572,120 -> 572,123 -> 569,123 -> 569,129 -> 584,129 -> 584,123 -> 577,123 -> 577,120
584,135 -> 594,135 -> 594,134
572,120 -> 572,123 -> 569,123 -> 569,129 -> 584,129 -> 584,123 -> 577,123 -> 577,120
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
538,63 -> 538,65 -> 534,65 -> 534,70 -> 551,70 -> 551,65 -> 544,65 -> 544,63
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
513,50 -> 518,50
563,107 -> 563,111 -> 556,111 -> 556,117 -> 574,117 -> 574,111 -> 566,111 -> 566,107
508,29 -> 513,29
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
558,104 -> 558,94 -> 558,104 -> 560,104 -> 560,99 -> 560,104 -> 562,104 -> 562,101 -> 562,104 -> 564,104 -> 564,99 -> 564,104
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
521,59 -> 521,60 -> 540,60 -> 540,59
547,75 -> 551,75
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
558,104 -> 558,94 -> 558,104 -> 560,104 -> 560,99 -> 560,104 -> 562,104 -> 562,101 -> 562,104 -> 564,104 -> 564,99 -> 564,104
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
538,63 -> 538,65 -> 534,65 -> 534,70 -> 551,70 -> 551,65 -> 544,65 -> 544,63
594,151 -> 594,154 -> 591,154 -> 591,162 -> 602,162 -> 602,154 -> 598,154 -> 598,151
504,26 -> 509,26
521,54 -> 526,54
550,73 -> 554,73
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
550,77 -> 554,77
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
558,104 -> 558,94 -> 558,104 -> 560,104 -> 560,99 -> 560,104 -> 562,104 -> 562,101 -> 562,104 -> 564,104 -> 564,99 -> 564,104
558,104 -> 558,94 -> 558,104 -> 560,104 -> 560,99 -> 560,104 -> 562,104 -> 562,101 -> 562,104 -> 564,104 -> 564,99 -> 564,104
510,52 -> 515,52
492,23 -> 492,15 -> 492,23 -> 494,23 -> 494,22 -> 494,23 -> 496,23 -> 496,14 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,22 -> 502,23 -> 504,23 -> 504,18 -> 504,23 -> 506,23 -> 506,21 -> 506,23
509,48 -> 514,48
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
495,45 -> 495,37 -> 495,45 -> 497,45 -> 497,44 -> 497,45 -> 499,45 -> 499,38 -> 499,45 -> 501,45 -> 501,39 -> 501,45 -> 503,45 -> 503,36 -> 503,45 -> 505,45 -> 505,44 -> 505,45 -> 507,45 -> 507,42 -> 507,45 -> 509,45 -> 509,44 -> 509,45 -> 511,45 -> 511,35 -> 511,45
556,77 -> 560,77
572,120 -> 572,123 -> 569,123 -> 569,129 -> 584,129 -> 584,123 -> 577,123 -> 577,120
574,148 -> 574,140 -> 574,148 -> 576,148 -> 576,138 -> 576,148 -> 578,148 -> 578,139 -> 578,148 -> 580,148 -> 580,146 -> 580,148 -> 582,148 -> 582,145 -> 582,148 -> 584,148 -> 584,139 -> 584,148 -> 586,148 -> 586,138 -> 586,148 -> 588,148 -> 588,141 -> 588,148 -> 590,148 -> 590,138 -> 590,148
517,52 -> 522,52
551,90 -> 551,91 -> 561,91 -> 561,90
507,54 -> 512,54
581,167 -> 581,168 -> 600,168 -> 600,167
512,32 -> 517,32
538,63 -> 538,65 -> 534,65 -> 534,70 -> 551,70 -> 551,65 -> 544,65 -> 544,63
555,83 -> 560,83

2
res/14/test-input.txt Normal file
View file

@ -0,0 +1,2 @@
498,4 -> 498,6 -> 496,6
503,4 -> 502,4 -> 502,9 -> 494,9

143
src/days/d14.rs Normal file
View file

@ -0,0 +1,143 @@
use std::fs;
const CAVE_WIDTH: u32 = 400;
const CAVE_HEIGHT: u32 = 200;
const X_OFFSET: u32 = 300;
const START_POINT: (u32,u32) = (500,0);
pub fn solve() {
let path = "res/14/input.txt";
let contents = fs::read_to_string(path).expect("I/O error, wrong path?");
// parse paths
let rock_paths: Vec<Vec<(u32, u32)>> = contents
.lines()
.filter(|line| *line != "")
.map(|line| {
line.split(" -> ")
.map(|coord| {
let coord_arr: Vec<&str> = coord.split(",").collect();
(coord_arr[0].parse::<u32>().unwrap(),
coord_arr[1].parse::<u32>().unwrap())
}).collect()
}).collect();
// cave[X][Y]
let mut cave: Vec<Vec<bool>> = (0..CAVE_WIDTH).map(|_| (0..CAVE_HEIGHT).map(|_| false).collect()).collect();
// set cave path structure
rock_paths.iter().for_each(|path| {
path.windows(2)
.for_each(|pairs| {
// draw rock lines
let x_iter = if pairs[0].0 > pairs[1].0 {
pairs[1].0..=pairs[0].0
} else {
pairs[0].0..=pairs[1].0
};
x_iter.for_each(|x| {
let y_iter = if pairs[0].1 > pairs[1].1 {
pairs[1].1..=pairs[0].1
} else {
pairs[0].1..=pairs[1].1
};
y_iter.for_each(|y| {
cave[(x-X_OFFSET) as usize][y as usize] = true;
})
});
})
});
// task 1 - normal cave
// let sand fall
let mut sand_unit_counter: u32 = 0;
let mut sand_pos = next_sand_pos(&cave);
while sand_pos.1 < CAVE_HEIGHT-1 {
cave[sand_pos.0 as usize][sand_pos.1 as usize] = true;
sand_pos = next_sand_pos(&cave);
sand_unit_counter += 1;
}
println!("Result 1: {sand_unit_counter}");
// task 2 - cave with ground
// find ground - cave height is 2 + max y value
let cave_height = 2 + rock_paths
.iter()
.map(|line|
line
.iter()
.map(|r| r.1)
.max()
.unwrap()
)
.max()
.unwrap();
// build ground
cave.iter_mut().for_each(|col| {
col[(cave_height) as usize] = true
});
// let sand fall again, until it reaches the start point
while sand_pos != (START_POINT.0-X_OFFSET, START_POINT.1) {
cave[sand_pos.0 as usize][sand_pos.1 as usize] = true;
sand_pos = next_sand_pos(&cave);
sand_unit_counter += 1;
}
println!("Result 2: {sand_unit_counter}");
}
// returns the next position a sand unit will come to rest at
fn next_sand_pos(cave: &Vec<Vec<bool>>) -> (u32, u32) {
let start_pos = (START_POINT.0-X_OFFSET, START_POINT.1);
let mut pos: (u32, u32) = start_pos;
while !is_end_pos(pos, cave) {
// first check directly below
if !cave[(pos.0) as usize][(pos.1+1) as usize] {
pos = (pos.0, pos.1+1)
} // then diagonally down-left
else if !cave[(pos.0-1) as usize][(pos.1+1) as usize] {
pos = (pos.0-1, pos.1+1)
} // then diagonally down-right
else if !cave[(pos.0+1) as usize][(pos.1+1) as usize] {
pos = (pos.0+1, pos.1+1)
}
}
pos
}
// returns whether the passed coordinates are a valid end position for a sand unit
fn is_end_pos(pos: (u32, u32), cave: &Vec<Vec<bool>>) -> bool {
if pos.1 as usize == cave[0].len()-1 {
// pos is on ground of the cave, lays still
return true
}
// don't need to check for enough space to left+right since cave is big enough
if cave[(pos.0-1) as usize][(pos.1+1) as usize]
&& cave[(pos.0) as usize][(pos.1+1) as usize]
&& cave[(pos.0+1) as usize][(pos.1+1) as usize] {
return true
}
false
}
// prints the cave to stdout
fn _print_cave(cave: &Vec<Vec<bool>>) {
let mut out: Vec<String> = (0..CAVE_HEIGHT).map(|_| "".to_string()).collect();
cave.iter().for_each(|line| {
line.iter().enumerate().for_each(|(i, cell)|
match *cell {
true => out[i] += "#",
false => out[i] += "."
}
);
});
out.iter().for_each(|s| println!("{s}"));
}

View file

@ -1,7 +1,7 @@
pub mod days; pub mod days;
fn main() { fn main() {
days::d13::solve() days::d14::solve()
//_all_days() //_all_days()
} }