This commit is contained in:
gbrochar 2023-03-29 16:13:24 +02:00
parent a53e1e238a
commit 6639f35c10
8 changed files with 447 additions and 0 deletions

12
aoc_14a/.gitignore vendored Normal file
View File

@ -0,0 +1,12 @@
# ---> Rust
# Generated by Cargo
# will have compiled files and executables
/target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk

8
aoc_14a/Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "aoc_14a"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

138
aoc_14a/input Normal file
View File

@ -0,0 +1,138 @@
486,40 -> 486,44 -> 482,44 -> 482,49 -> 499,49 -> 499,44 -> 491,44 -> 491,40
487,60 -> 487,61 -> 503,61 -> 503,60
495,21 -> 501,21 -> 501,20
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
499,123 -> 503,123
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
514,125 -> 518,125
485,92 -> 485,89 -> 485,92 -> 487,92 -> 487,84 -> 487,92 -> 489,92 -> 489,89 -> 489,92 -> 491,92 -> 491,88 -> 491,92 -> 493,92 -> 493,85 -> 493,92 -> 495,92 -> 495,82 -> 495,92 -> 497,92 -> 497,91 -> 497,92
508,121 -> 512,121
498,58 -> 503,58
487,60 -> 487,61 -> 503,61 -> 503,60
508,125 -> 512,125
486,40 -> 486,44 -> 482,44 -> 482,49 -> 499,49 -> 499,44 -> 491,44 -> 491,40
486,79 -> 491,79
494,55 -> 499,55
485,92 -> 485,89 -> 485,92 -> 487,92 -> 487,84 -> 487,92 -> 489,92 -> 489,89 -> 489,92 -> 491,92 -> 491,88 -> 491,92 -> 493,92 -> 493,85 -> 493,92 -> 495,92 -> 495,82 -> 495,92 -> 497,92 -> 497,91 -> 497,92
485,92 -> 485,89 -> 485,92 -> 487,92 -> 487,84 -> 487,92 -> 489,92 -> 489,89 -> 489,92 -> 491,92 -> 491,88 -> 491,92 -> 493,92 -> 493,85 -> 493,92 -> 495,92 -> 495,82 -> 495,92 -> 497,92 -> 497,91 -> 497,92
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
485,92 -> 485,89 -> 485,92 -> 487,92 -> 487,84 -> 487,92 -> 489,92 -> 489,89 -> 489,92 -> 491,92 -> 491,88 -> 491,92 -> 493,92 -> 493,85 -> 493,92 -> 495,92 -> 495,82 -> 495,92 -> 497,92 -> 497,91 -> 497,92
495,105 -> 495,99 -> 495,105 -> 497,105 -> 497,97 -> 497,105 -> 499,105 -> 499,103 -> 499,105 -> 501,105 -> 501,102 -> 501,105
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
491,58 -> 496,58
502,64 -> 506,64
500,108 -> 500,112 -> 494,112 -> 494,116 -> 506,116 -> 506,112 -> 505,112 -> 505,108
485,92 -> 485,89 -> 485,92 -> 487,92 -> 487,84 -> 487,92 -> 489,92 -> 489,89 -> 489,92 -> 491,92 -> 491,88 -> 491,92 -> 493,92 -> 493,85 -> 493,92 -> 495,92 -> 495,82 -> 495,92 -> 497,92 -> 497,91 -> 497,92
482,37 -> 482,27 -> 482,37 -> 484,37 -> 484,28 -> 484,37 -> 486,37 -> 486,27 -> 486,37 -> 488,37 -> 488,27 -> 488,37
485,92 -> 485,89 -> 485,92 -> 487,92 -> 487,84 -> 487,92 -> 489,92 -> 489,89 -> 489,92 -> 491,92 -> 491,88 -> 491,92 -> 493,92 -> 493,85 -> 493,92 -> 495,92 -> 495,82 -> 495,92 -> 497,92 -> 497,91 -> 497,92
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
495,105 -> 495,99 -> 495,105 -> 497,105 -> 497,97 -> 497,105 -> 499,105 -> 499,103 -> 499,105 -> 501,105 -> 501,102 -> 501,105
492,73 -> 497,73
511,123 -> 515,123
495,21 -> 501,21 -> 501,20
496,76 -> 501,76
485,92 -> 485,89 -> 485,92 -> 487,92 -> 487,84 -> 487,92 -> 489,92 -> 489,89 -> 489,92 -> 491,92 -> 491,88 -> 491,92 -> 493,92 -> 493,85 -> 493,92 -> 495,92 -> 495,82 -> 495,92 -> 497,92 -> 497,91 -> 497,92
485,92 -> 485,89 -> 485,92 -> 487,92 -> 487,84 -> 487,92 -> 489,92 -> 489,89 -> 489,92 -> 491,92 -> 491,88 -> 491,92 -> 493,92 -> 493,85 -> 493,92 -> 495,92 -> 495,82 -> 495,92 -> 497,92 -> 497,91 -> 497,92
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
485,92 -> 485,89 -> 485,92 -> 487,92 -> 487,84 -> 487,92 -> 489,92 -> 489,89 -> 489,92 -> 491,92 -> 491,88 -> 491,92 -> 493,92 -> 493,85 -> 493,92 -> 495,92 -> 495,82 -> 495,92 -> 497,92 -> 497,91 -> 497,92
500,79 -> 505,79
495,105 -> 495,99 -> 495,105 -> 497,105 -> 497,97 -> 497,105 -> 499,105 -> 499,103 -> 499,105 -> 501,105 -> 501,102 -> 501,105
500,108 -> 500,112 -> 494,112 -> 494,116 -> 506,116 -> 506,112 -> 505,112 -> 505,108
495,105 -> 495,99 -> 495,105 -> 497,105 -> 497,97 -> 497,105 -> 499,105 -> 499,103 -> 499,105 -> 501,105 -> 501,102 -> 501,105
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
485,92 -> 485,89 -> 485,92 -> 487,92 -> 487,84 -> 487,92 -> 489,92 -> 489,89 -> 489,92 -> 491,92 -> 491,88 -> 491,92 -> 493,92 -> 493,85 -> 493,92 -> 495,92 -> 495,82 -> 495,92 -> 497,92 -> 497,91 -> 497,92
486,40 -> 486,44 -> 482,44 -> 482,49 -> 499,49 -> 499,44 -> 491,44 -> 491,40
513,141 -> 513,145 -> 512,145 -> 512,152 -> 523,152 -> 523,145 -> 518,145 -> 518,141
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
505,119 -> 509,119
496,70 -> 500,70
482,37 -> 482,27 -> 482,37 -> 484,37 -> 484,28 -> 484,37 -> 486,37 -> 486,27 -> 486,37 -> 488,37 -> 488,27 -> 488,37
505,123 -> 509,123
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
496,125 -> 500,125
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
502,121 -> 506,121
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
505,67 -> 509,67
485,92 -> 485,89 -> 485,92 -> 487,92 -> 487,84 -> 487,92 -> 489,92 -> 489,89 -> 489,92 -> 491,92 -> 491,88 -> 491,92 -> 493,92 -> 493,85 -> 493,92 -> 495,92 -> 495,82 -> 495,92 -> 497,92 -> 497,91 -> 497,92
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
482,37 -> 482,27 -> 482,37 -> 484,37 -> 484,28 -> 484,37 -> 486,37 -> 486,27 -> 486,37 -> 488,37 -> 488,27 -> 488,37
518,128 -> 518,130 -> 516,130 -> 516,138 -> 525,138 -> 525,130 -> 522,130 -> 522,128
518,128 -> 518,130 -> 516,130 -> 516,138 -> 525,138 -> 525,130 -> 522,130 -> 522,128
482,37 -> 482,27 -> 482,37 -> 484,37 -> 484,28 -> 484,37 -> 486,37 -> 486,27 -> 486,37 -> 488,37 -> 488,27 -> 488,37
485,92 -> 485,89 -> 485,92 -> 487,92 -> 487,84 -> 487,92 -> 489,92 -> 489,89 -> 489,92 -> 491,92 -> 491,88 -> 491,92 -> 493,92 -> 493,85 -> 493,92 -> 495,92 -> 495,82 -> 495,92 -> 497,92 -> 497,91 -> 497,92
500,108 -> 500,112 -> 494,112 -> 494,116 -> 506,116 -> 506,112 -> 505,112 -> 505,108
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
489,76 -> 494,76
485,92 -> 485,89 -> 485,92 -> 487,92 -> 487,84 -> 487,92 -> 489,92 -> 489,89 -> 489,92 -> 491,92 -> 491,88 -> 491,92 -> 493,92 -> 493,85 -> 493,92 -> 495,92 -> 495,82 -> 495,92 -> 497,92 -> 497,91 -> 497,92
485,92 -> 485,89 -> 485,92 -> 487,92 -> 487,84 -> 487,92 -> 489,92 -> 489,89 -> 489,92 -> 491,92 -> 491,88 -> 491,92 -> 493,92 -> 493,85 -> 493,92 -> 495,92 -> 495,82 -> 495,92 -> 497,92 -> 497,91 -> 497,92
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
498,15 -> 498,16 -> 508,16 -> 508,15
500,108 -> 500,112 -> 494,112 -> 494,116 -> 506,116 -> 506,112 -> 505,112 -> 505,108
482,37 -> 482,27 -> 482,37 -> 484,37 -> 484,28 -> 484,37 -> 486,37 -> 486,27 -> 486,37 -> 488,37 -> 488,27 -> 488,37
486,40 -> 486,44 -> 482,44 -> 482,49 -> 499,49 -> 499,44 -> 491,44 -> 491,40
502,70 -> 506,70
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
513,141 -> 513,145 -> 512,145 -> 512,152 -> 523,152 -> 523,145 -> 518,145 -> 518,141
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
487,60 -> 487,61 -> 503,61 -> 503,60
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
518,128 -> 518,130 -> 516,130 -> 516,138 -> 525,138 -> 525,130 -> 522,130 -> 522,128
513,141 -> 513,145 -> 512,145 -> 512,152 -> 523,152 -> 523,145 -> 518,145 -> 518,141
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
482,37 -> 482,27 -> 482,37 -> 484,37 -> 484,28 -> 484,37 -> 486,37 -> 486,27 -> 486,37 -> 488,37 -> 488,27 -> 488,37
502,125 -> 506,125
495,105 -> 495,99 -> 495,105 -> 497,105 -> 497,97 -> 497,105 -> 499,105 -> 499,103 -> 499,105 -> 501,105 -> 501,102 -> 501,105
495,105 -> 495,99 -> 495,105 -> 497,105 -> 497,97 -> 497,105 -> 499,105 -> 499,103 -> 499,105 -> 501,105 -> 501,102 -> 501,105
513,141 -> 513,145 -> 512,145 -> 512,152 -> 523,152 -> 523,145 -> 518,145 -> 518,141
493,79 -> 498,79
485,92 -> 485,89 -> 485,92 -> 487,92 -> 487,84 -> 487,92 -> 489,92 -> 489,89 -> 489,92 -> 491,92 -> 491,88 -> 491,92 -> 493,92 -> 493,85 -> 493,92 -> 495,92 -> 495,82 -> 495,92 -> 497,92 -> 497,91 -> 497,92
487,23 -> 487,24 -> 496,24 -> 496,23
513,141 -> 513,145 -> 512,145 -> 512,152 -> 523,152 -> 523,145 -> 518,145 -> 518,141
487,23 -> 487,24 -> 496,24 -> 496,23
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
508,70 -> 512,70
486,40 -> 486,44 -> 482,44 -> 482,49 -> 499,49 -> 499,44 -> 491,44 -> 491,40
518,128 -> 518,130 -> 516,130 -> 516,138 -> 525,138 -> 525,130 -> 522,130 -> 522,128
513,141 -> 513,145 -> 512,145 -> 512,152 -> 523,152 -> 523,145 -> 518,145 -> 518,141
495,105 -> 495,99 -> 495,105 -> 497,105 -> 497,97 -> 497,105 -> 499,105 -> 499,103 -> 499,105 -> 501,105 -> 501,102 -> 501,105
485,92 -> 485,89 -> 485,92 -> 487,92 -> 487,84 -> 487,92 -> 489,92 -> 489,89 -> 489,92 -> 491,92 -> 491,88 -> 491,92 -> 493,92 -> 493,85 -> 493,92 -> 495,92 -> 495,82 -> 495,92 -> 497,92 -> 497,91 -> 497,92
500,108 -> 500,112 -> 494,112 -> 494,116 -> 506,116 -> 506,112 -> 505,112 -> 505,108
485,92 -> 485,89 -> 485,92 -> 487,92 -> 487,84 -> 487,92 -> 489,92 -> 489,89 -> 489,92 -> 491,92 -> 491,88 -> 491,92 -> 493,92 -> 493,85 -> 493,92 -> 495,92 -> 495,82 -> 495,92 -> 497,92 -> 497,91 -> 497,92
482,37 -> 482,27 -> 482,37 -> 484,37 -> 484,28 -> 484,37 -> 486,37 -> 486,27 -> 486,37 -> 488,37 -> 488,27 -> 488,37
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
505,58 -> 510,58
485,92 -> 485,89 -> 485,92 -> 487,92 -> 487,84 -> 487,92 -> 489,92 -> 489,89 -> 489,92 -> 491,92 -> 491,88 -> 491,92 -> 493,92 -> 493,85 -> 493,92 -> 495,92 -> 495,82 -> 495,92 -> 497,92 -> 497,91 -> 497,92
500,108 -> 500,112 -> 494,112 -> 494,116 -> 506,116 -> 506,112 -> 505,112 -> 505,108
486,40 -> 486,44 -> 482,44 -> 482,49 -> 499,49 -> 499,44 -> 491,44 -> 491,40
497,52 -> 502,52
485,92 -> 485,89 -> 485,92 -> 487,92 -> 487,84 -> 487,92 -> 489,92 -> 489,89 -> 489,92 -> 491,92 -> 491,88 -> 491,92 -> 493,92 -> 493,85 -> 493,92 -> 495,92 -> 495,82 -> 495,92 -> 497,92 -> 497,91 -> 497,92
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
495,105 -> 495,99 -> 495,105 -> 497,105 -> 497,97 -> 497,105 -> 499,105 -> 499,103 -> 499,105 -> 501,105 -> 501,102 -> 501,105
518,128 -> 518,130 -> 516,130 -> 516,138 -> 525,138 -> 525,130 -> 522,130 -> 522,128
487,23 -> 487,24 -> 496,24 -> 496,23
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
482,37 -> 482,27 -> 482,37 -> 484,37 -> 484,28 -> 484,37 -> 486,37 -> 486,27 -> 486,37 -> 488,37 -> 488,27 -> 488,37
486,40 -> 486,44 -> 482,44 -> 482,49 -> 499,49 -> 499,44 -> 491,44 -> 491,40
482,37 -> 482,27 -> 482,37 -> 484,37 -> 484,28 -> 484,37 -> 486,37 -> 486,27 -> 486,37 -> 488,37 -> 488,27 -> 488,37
499,67 -> 503,67
518,128 -> 518,130 -> 516,130 -> 516,138 -> 525,138 -> 525,130 -> 522,130 -> 522,128
500,108 -> 500,112 -> 494,112 -> 494,116 -> 506,116 -> 506,112 -> 505,112 -> 505,108
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
485,92 -> 485,89 -> 485,92 -> 487,92 -> 487,84 -> 487,92 -> 489,92 -> 489,89 -> 489,92 -> 491,92 -> 491,88 -> 491,92 -> 493,92 -> 493,85 -> 493,92 -> 495,92 -> 495,82 -> 495,92 -> 497,92 -> 497,91 -> 497,92
501,55 -> 506,55
482,37 -> 482,27 -> 482,37 -> 484,37 -> 484,28 -> 484,37 -> 486,37 -> 486,27 -> 486,37 -> 488,37 -> 488,27 -> 488,37
495,105 -> 495,99 -> 495,105 -> 497,105 -> 497,97 -> 497,105 -> 499,105 -> 499,103 -> 499,105 -> 501,105 -> 501,102 -> 501,105
495,105 -> 495,99 -> 495,105 -> 497,105 -> 497,97 -> 497,105 -> 499,105 -> 499,103 -> 499,105 -> 501,105 -> 501,102 -> 501,105
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
518,128 -> 518,130 -> 516,130 -> 516,138 -> 525,138 -> 525,130 -> 522,130 -> 522,128
498,15 -> 498,16 -> 508,16 -> 508,15
501,165 -> 501,155 -> 501,165 -> 503,165 -> 503,157 -> 503,165 -> 505,165 -> 505,160 -> 505,165 -> 507,165 -> 507,156 -> 507,165 -> 509,165 -> 509,163 -> 509,165 -> 511,165 -> 511,163 -> 511,165 -> 513,165 -> 513,158 -> 513,165 -> 515,165 -> 515,160 -> 515,165 -> 517,165 -> 517,160 -> 517,165 -> 519,165 -> 519,156 -> 519,165
482,37 -> 482,27 -> 482,37 -> 484,37 -> 484,28 -> 484,37 -> 486,37 -> 486,27 -> 486,37 -> 488,37 -> 488,27 -> 488,37
495,105 -> 495,99 -> 495,105 -> 497,105 -> 497,97 -> 497,105 -> 499,105 -> 499,103 -> 499,105 -> 501,105 -> 501,102 -> 501,105
513,141 -> 513,145 -> 512,145 -> 512,152 -> 523,152 -> 523,145 -> 518,145 -> 518,141
498,15 -> 498,16 -> 508,16 -> 508,15

2
aoc_14a/input2 Normal file
View File

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

130
aoc_14a/src/main.rs Normal file
View File

@ -0,0 +1,130 @@
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
use std::cmp::min;
use std::cmp::max;
#[derive(Clone, PartialEq)]
enum Cell {
Void,
Sand,
Wall,
}
fn main() {
let file_path = String::from("input2");
println!("In file {}", file_path);
let mut data: Vec<Vec<Cell>> = vec![vec![Cell::Void; 1000]; 1000];
let mut min_x = 100000;
let mut max_x = 0;
let mut min_y = 100000;
let mut max_y = 0;
if let Ok(lines) = read_lines(file_path) {
// Consumes the iterator, returns an (Optional) String
for (i, line) in lines.enumerate() {
if let Ok(ip) = line {
let items: Vec<&str> = ip.split(" -> ").collect();
let mut x = items[1].split(",").collect::<Vec<&str>>()[0].parse::<usize>().unwrap();
let mut y = items[1].split(",").collect::<Vec<&str>>()[1].parse::<usize>().unwrap();
let mut prev_x = items[0].split(",").collect::<Vec<&str>>()[0].parse::<usize>().unwrap();
let mut prev_y = items[0].split(",").collect::<Vec<&str>>()[1].parse::<usize>().unwrap();
min_x = min(min_x, prev_x);
max_x = max(max_x, prev_x);
min_y = min(min_y, prev_y);
max_y = max(max_y, prev_y);
for v in items.iter().skip(2) {
match max(x, prev_x) - min(x, prev_x) {
0 => {
println!("draw vertical");
for i in min(y, prev_y)..max(y, prev_y) + 1 {
data[x][i] = Cell::Wall;
}
},
_ => {
println!("draw horizontal");
for i in min(x, prev_x)..max(x, prev_x) + 1 {
data[i][y] = Cell::Wall;
}
}
}
prev_x = x;
prev_y = y;
x = v.split(",").collect::<Vec<&str>>()[0].parse::<usize>().unwrap();
y = v.split(",").collect::<Vec<&str>>()[1].parse::<usize>().unwrap();
min_x = min(min_x, x);
max_x = max(max_x, x);
min_y = min(min_y, y);
max_y = max(max_y, y);
println!("{}", v);
}
match max(x, prev_x) - min(x, prev_x) {
0 => {
println!("draw vertical");
for i in min(y, prev_y)..max(y, prev_y) + 1 {
data[x][i] = Cell::Wall;
}
},
_ => {
println!("draw horizontal");
for i in min(x, prev_x)..max(x, prev_x) + 1 {
data[i][y] = Cell::Wall;
}
}
}
println!("{:#?}", items);
}
}
}
let mut sand_count = 0;
'outer: loop {
let mut x = 500;
let mut y = 0;
loop {
if y > max_y {
break 'outer;
}
if data[x][y + 1] == Cell::Void {
y += 1;
}
else if data[x - 1][y + 1] == Cell::Void {
x -= 1;
y += 1;
}
else if data[x + 1][y + 1] == Cell::Void {
x += 1;
y += 1;
}
else {
sand_count += 1;
data[x][y] = Cell::Sand;
break;
}
}
}
if min_y > 1 {
min_y -= 2;
}
if min_x > 1 {
min_x -= 2;
}
for i in min_y..max_y + 2 {
for j in min_x..max_x + 2 {
match data[j][i] {
Cell::Void => print!("."),
Cell::Wall => print!("#"),
Cell::Sand => print!("o"),
}
}
println!("");
}
println!("{} {} {} {}", min_x, max_x, min_y, max_y);
println!("{}", sand_count);
}
fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
where P: AsRef<Path>, {
let file = File::open(filename)?;
Ok(io::BufReader::new(file).lines())
}

12
aoc_14b/.gitignore vendored Normal file
View File

@ -0,0 +1,12 @@
# ---> Rust
# Generated by Cargo
# will have compiled files and executables
/target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk

8
aoc_14b/Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "aoc_14b"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

137
aoc_14b/src/main.rs Normal file
View File

@ -0,0 +1,137 @@
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
use std::cmp::min;
use std::cmp::max;
#[derive(Clone, PartialEq)]
enum Cell {
Void,
Sand,
Wall,
}
fn main() {
let file_path = String::from("../aoc_14a/input");
println!("In file {}", file_path);
let mut data: Vec<Vec<Cell>> = vec![vec![Cell::Void; 1000]; 1000];
let mut min_x = 100000;
let mut max_x = 0;
let mut min_y = 100000;
let mut max_y = 0;
if let Ok(lines) = read_lines(file_path) {
// Consumes the iterator, returns an (Optional) String
for (i, line) in lines.enumerate() {
if let Ok(ip) = line {
let items: Vec<&str> = ip.split(" -> ").collect();
let mut x = items[1].split(",").collect::<Vec<&str>>()[0].parse::<usize>().unwrap();
let mut y = items[1].split(",").collect::<Vec<&str>>()[1].parse::<usize>().unwrap();
let mut prev_x = items[0].split(",").collect::<Vec<&str>>()[0].parse::<usize>().unwrap();
let mut prev_y = items[0].split(",").collect::<Vec<&str>>()[1].parse::<usize>().unwrap();
min_x = min(min_x, prev_x);
max_x = max(max_x, prev_x);
min_y = min(min_y, prev_y);
max_y = max(max_y, prev_y);
for v in items.iter().skip(2) {
match max(x, prev_x) - min(x, prev_x) {
0 => {
println!("draw vertical");
for i in min(y, prev_y)..max(y, prev_y) + 1 {
data[x][i] = Cell::Wall;
}
},
_ => {
println!("draw horizontal");
for i in min(x, prev_x)..max(x, prev_x) + 1 {
data[i][y] = Cell::Wall;
}
}
}
prev_x = x;
prev_y = y;
x = v.split(",").collect::<Vec<&str>>()[0].parse::<usize>().unwrap();
y = v.split(",").collect::<Vec<&str>>()[1].parse::<usize>().unwrap();
min_x = min(min_x, x);
max_x = max(max_x, x);
min_y = min(min_y, y);
max_y = max(max_y, y);
println!("{}", v);
}
match max(x, prev_x) - min(x, prev_x) {
0 => {
println!("draw vertical");
for i in min(y, prev_y)..max(y, prev_y) + 1 {
data[x][i] = Cell::Wall;
}
},
_ => {
println!("draw horizontal");
for i in min(x, prev_x)..max(x, prev_x) + 1 {
data[i][y] = Cell::Wall;
}
}
}
println!("{:#?}", items);
}
}
}
for i in 0..1000 {
data[i][max_y + 2] = Cell::Wall;
}
let mut sand_count = 0;
'outer: loop {
let mut x = 500;
let mut y = 0;
loop {
if data[500][0] == Cell::Sand {
break 'outer;
}
if data[x][y + 1] == Cell::Void {
y += 1;
}
else if data[x - 1][y + 1] == Cell::Void {
x -= 1;
y += 1;
}
else if data[x + 1][y + 1] == Cell::Void {
x += 1;
y += 1;
}
else {
sand_count += 1;
data[x][y] = Cell::Sand;
break;
}
}
}
if min_y > 1 {
min_y -= 2;
}
if min_x > 1 {
min_x -= 2;
}
let dx = max_x - min_x;
for i in 0..max_y + 4 {
for j in min_x - dx..max_x + dx {
match data[j][i] {
Cell::Void => print!("."),
Cell::Wall => print!("#"),
Cell::Sand => print!("o"),
}
}
println!("");
}
println!("{} {} {} {}", min_x, max_x, min_y, max_y);
println!("{}", sand_count);
}
fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
where P: AsRef<Path>, {
let file = File::open(filename)?;
Ok(io::BufReader::new(file).lines())
}