Compare commits
3 Commits
4efef42bc9
...
main
Author | SHA1 | Date | |
---|---|---|---|
a6c11ad68d | |||
163029eaeb | |||
cd2d6f4452 |
7
day14/Cargo.lock
generated
Normal file
7
day14/Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "day14"
|
||||||
|
version = "0.1.0"
|
164
day14/input.txt
Normal file
164
day14/input.txt
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
|
||||||
|
513,69 -> 513,71 -> 511,71 -> 511,76 -> 522,76 -> 522,71 -> 517,71 -> 517,69
|
||||||
|
520,87 -> 524,87
|
||||||
|
480,121 -> 480,122 -> 498,122 -> 498,121
|
||||||
|
520,56 -> 520,60 -> 517,60 -> 517,66 -> 528,66 -> 528,60 -> 523,60 -> 523,56
|
||||||
|
484,147 -> 484,149 -> 483,149 -> 483,153 -> 489,153 -> 489,149 -> 488,149 -> 488,147
|
||||||
|
493,24 -> 498,24
|
||||||
|
496,22 -> 501,22
|
||||||
|
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
|
||||||
|
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
|
||||||
|
508,79 -> 512,79
|
||||||
|
486,104 -> 486,105 -> 493,105 -> 493,104
|
||||||
|
497,129 -> 502,129
|
||||||
|
474,34 -> 478,34
|
||||||
|
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
508,87 -> 512,87
|
||||||
|
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
|
||||||
|
499,20 -> 504,20
|
||||||
|
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
|
||||||
|
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
|
||||||
|
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
496,125 -> 501,125
|
||||||
|
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
|
||||||
|
511,26 -> 516,26
|
||||||
|
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
|
||||||
|
520,56 -> 520,60 -> 517,60 -> 517,66 -> 528,66 -> 528,60 -> 523,60 -> 523,56
|
||||||
|
520,56 -> 520,60 -> 517,60 -> 517,66 -> 528,66 -> 528,60 -> 523,60 -> 523,56
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
502,83 -> 506,83
|
||||||
|
496,87 -> 500,87
|
||||||
|
483,26 -> 488,26
|
||||||
|
487,131 -> 492,131
|
||||||
|
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
|
||||||
|
499,85 -> 503,85
|
||||||
|
480,34 -> 484,34
|
||||||
|
474,38 -> 478,38
|
||||||
|
486,104 -> 486,105 -> 493,105 -> 493,104
|
||||||
|
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
|
||||||
|
494,90 -> 494,92 -> 489,92 -> 489,100 -> 504,100 -> 504,92 -> 497,92 -> 497,90
|
||||||
|
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
513,69 -> 513,71 -> 511,71 -> 511,76 -> 522,76 -> 522,71 -> 517,71 -> 517,69
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
520,56 -> 520,60 -> 517,60 -> 517,66 -> 528,66 -> 528,60 -> 523,60 -> 523,56
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
480,38 -> 484,38
|
||||||
|
489,40 -> 493,40
|
||||||
|
483,36 -> 487,36
|
||||||
|
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
|
||||||
|
508,131 -> 513,131
|
||||||
|
517,85 -> 521,85
|
||||||
|
494,131 -> 499,131
|
||||||
|
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
|
||||||
|
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
|
||||||
|
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
|
||||||
|
494,90 -> 494,92 -> 489,92 -> 489,100 -> 504,100 -> 504,92 -> 497,92 -> 497,90
|
||||||
|
514,87 -> 518,87
|
||||||
|
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
|
||||||
|
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
|
||||||
|
494,90 -> 494,92 -> 489,92 -> 489,100 -> 504,100 -> 504,92 -> 497,92 -> 497,90
|
||||||
|
507,24 -> 512,24
|
||||||
|
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
|
||||||
|
471,40 -> 475,40
|
||||||
|
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
|
||||||
|
511,81 -> 515,81
|
||||||
|
514,83 -> 518,83
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
|
||||||
|
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
|
||||||
|
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
|
||||||
|
465,40 -> 469,40
|
||||||
|
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
480,29 -> 490,29 -> 490,28
|
||||||
|
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
|
||||||
|
493,127 -> 498,127
|
||||||
|
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
|
||||||
|
504,26 -> 509,26
|
||||||
|
492,20 -> 497,20
|
||||||
|
477,36 -> 481,36
|
||||||
|
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
|
||||||
|
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
|
||||||
|
505,81 -> 509,81
|
||||||
|
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
|
||||||
|
513,69 -> 513,71 -> 511,71 -> 511,76 -> 522,76 -> 522,71 -> 517,71 -> 517,69
|
||||||
|
480,121 -> 480,122 -> 498,122 -> 498,121
|
||||||
|
494,90 -> 494,92 -> 489,92 -> 489,100 -> 504,100 -> 504,92 -> 497,92 -> 497,90
|
||||||
|
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
|
||||||
|
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
|
||||||
|
490,26 -> 495,26
|
||||||
|
504,129 -> 509,129
|
||||||
|
484,147 -> 484,149 -> 483,149 -> 483,153 -> 489,153 -> 489,149 -> 488,149 -> 488,147
|
||||||
|
484,147 -> 484,149 -> 483,149 -> 483,153 -> 489,153 -> 489,149 -> 488,149 -> 488,147
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
513,69 -> 513,71 -> 511,71 -> 511,76 -> 522,76 -> 522,71 -> 517,71 -> 517,69
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
503,22 -> 508,22
|
||||||
|
495,18 -> 500,18
|
||||||
|
490,129 -> 495,129
|
||||||
|
477,40 -> 481,40
|
||||||
|
520,56 -> 520,60 -> 517,60 -> 517,66 -> 528,66 -> 528,60 -> 523,60 -> 523,56
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
511,85 -> 515,85
|
||||||
|
502,87 -> 506,87
|
||||||
|
513,69 -> 513,71 -> 511,71 -> 511,76 -> 522,76 -> 522,71 -> 517,71 -> 517,69
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
500,127 -> 505,127
|
||||||
|
489,22 -> 494,22
|
||||||
|
499,14 -> 499,15 -> 508,15
|
||||||
|
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
|
||||||
|
483,40 -> 487,40
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
484,147 -> 484,149 -> 483,149 -> 483,153 -> 489,153 -> 489,149 -> 488,149 -> 488,147
|
||||||
|
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
497,26 -> 502,26
|
||||||
|
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
|
||||||
|
501,131 -> 506,131
|
||||||
|
468,38 -> 472,38
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
486,24 -> 491,24
|
||||||
|
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
|
||||||
|
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
|
||||||
|
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
|
||||||
|
471,36 -> 475,36
|
||||||
|
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
|
||||||
|
494,90 -> 494,92 -> 489,92 -> 489,100 -> 504,100 -> 504,92 -> 497,92 -> 497,90
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
|
||||||
|
484,147 -> 484,149 -> 483,149 -> 483,153 -> 489,153 -> 489,149 -> 488,149 -> 488,147
|
||||||
|
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
|
||||||
|
486,38 -> 490,38
|
||||||
|
513,69 -> 513,71 -> 511,71 -> 511,76 -> 522,76 -> 522,71 -> 517,71 -> 517,69
|
||||||
|
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
|
||||||
|
508,83 -> 512,83
|
||||||
|
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
|
||||||
|
486,104 -> 486,105 -> 493,105 -> 493,104
|
||||||
|
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
|
||||||
|
484,147 -> 484,149 -> 483,149 -> 483,153 -> 489,153 -> 489,149 -> 488,149 -> 488,147
|
||||||
|
480,29 -> 490,29 -> 490,28
|
||||||
|
484,147 -> 484,149 -> 483,149 -> 483,153 -> 489,153 -> 489,149 -> 488,149 -> 488,147
|
||||||
|
480,121 -> 480,122 -> 498,122 -> 498,121
|
||||||
|
500,24 -> 505,24
|
||||||
|
520,56 -> 520,60 -> 517,60 -> 517,66 -> 528,66 -> 528,60 -> 523,60 -> 523,56
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
494,90 -> 494,92 -> 489,92 -> 489,100 -> 504,100 -> 504,92 -> 497,92 -> 497,90
|
||||||
|
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
|
||||||
|
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
|
||||||
|
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
499,14 -> 499,15 -> 508,15
|
||||||
|
513,69 -> 513,71 -> 511,71 -> 511,76 -> 522,76 -> 522,71 -> 517,71 -> 517,69
|
||||||
|
494,90 -> 494,92 -> 489,92 -> 489,100 -> 504,100 -> 504,92 -> 497,92 -> 497,90
|
||||||
|
477,32 -> 481,32
|
||||||
|
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
|
||||||
|
505,85 -> 509,85
|
||||||
|
520,56 -> 520,60 -> 517,60 -> 517,66 -> 528,66 -> 528,60 -> 523,60 -> 523,56
|
@ -1,3 +1,191 @@
|
|||||||
fn main() {
|
use std::fs::read_to_string;
|
||||||
println!("Hello, world!");
|
|
||||||
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||||
|
struct Map {
|
||||||
|
min_x: usize,
|
||||||
|
width: usize,
|
||||||
|
height: usize,
|
||||||
|
map: Vec<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Map {
|
||||||
|
fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
min_x: 500,
|
||||||
|
width: 0,
|
||||||
|
height: 0,
|
||||||
|
map: vec![],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn print(&self) {
|
||||||
|
for y in 0..self.height {
|
||||||
|
for x in 0..self.width {
|
||||||
|
print!(
|
||||||
|
"{}",
|
||||||
|
if self.map[x + y * self.width] {
|
||||||
|
'#'
|
||||||
|
} else {
|
||||||
|
'.'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
println!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn at(&self, position: (usize, usize)) -> bool {
|
||||||
|
if !self.is_inside(position) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
let x = position.0 - self.min_x;
|
||||||
|
self.map[x + position.1 * self.width]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_inside(&self, position: (usize, usize)) -> bool {
|
||||||
|
position.0 >= self.min_x && position.0 < self.min_x + self.width && position.1 < self.height
|
||||||
|
}
|
||||||
|
|
||||||
|
fn add_obstacle(&mut self, position: (usize, usize)) {
|
||||||
|
while self.min_x > position.0 {
|
||||||
|
self.extend_left();
|
||||||
|
}
|
||||||
|
while self.min_x + self.width <= position.0 {
|
||||||
|
self.extend_right();
|
||||||
|
}
|
||||||
|
while self.height <= position.1 {
|
||||||
|
self.extend_down();
|
||||||
|
}
|
||||||
|
let x = position.0 - self.min_x;
|
||||||
|
self.map[x + position.1 * self.width] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn extend_down(&mut self) {
|
||||||
|
self.map.append(&mut vec![false; self.width]);
|
||||||
|
self.height += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn extend_left(&mut self) {
|
||||||
|
self.map.append(&mut vec![false; self.height]);
|
||||||
|
for y in (0..self.height).rev() {
|
||||||
|
for x in (0..self.width).rev() {
|
||||||
|
self.map[(x + 1) + y * (self.width + 1)] = self.map[x + y * self.width];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.width += 1;
|
||||||
|
self.min_x -= 1;
|
||||||
|
for y in 0..self.height {
|
||||||
|
self.map[y * self.width] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn extend_right(&mut self) {
|
||||||
|
self.map.append(&mut vec![false; self.height]);
|
||||||
|
for y in (0..self.height).rev() {
|
||||||
|
for x in (0..self.width).rev() {
|
||||||
|
self.map[x + y * (self.width + 1)] = self.map[x + y * self.width];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.width += 1;
|
||||||
|
for y in 0..self.height {
|
||||||
|
self.map[self.width - 1 + y * self.width] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn add_sand(map: &Map) -> Option<(usize, usize)> {
|
||||||
|
let mut sand = (500, 0);
|
||||||
|
while map.is_inside(sand) {
|
||||||
|
let x = sand.0;
|
||||||
|
let y = sand.1;
|
||||||
|
if !map.at((x, y + 1)) {
|
||||||
|
sand.1 += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if !map.at((x - 1, y + 1)) {
|
||||||
|
sand.1 += 1;
|
||||||
|
sand.0 -= 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if !map.at((x + 1, y + 1)) {
|
||||||
|
sand.1 += 1;
|
||||||
|
sand.0 += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return Some(sand);
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn add_sand_floor(map: &Map, floor: usize) -> Option<(usize, usize)> {
|
||||||
|
let mut sand = (500, 0);
|
||||||
|
while !map.at((500, 0)) {
|
||||||
|
let x = sand.0;
|
||||||
|
let y = sand.1;
|
||||||
|
if y + 1 == floor {
|
||||||
|
return Some(sand);
|
||||||
|
}
|
||||||
|
if !map.at((x, y + 1)) {
|
||||||
|
sand.1 += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if !map.at((x - 1, y + 1)) {
|
||||||
|
sand.1 += 1;
|
||||||
|
sand.0 -= 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if !map.at((x + 1, y + 1)) {
|
||||||
|
sand.1 += 1;
|
||||||
|
sand.0 += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return Some(sand);
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let input = "498,4 -> 498,6 -> 496,6
|
||||||
|
503,4 -> 502,4 -> 502,9 -> 494,9"
|
||||||
|
.to_owned();
|
||||||
|
let input = read_to_string("input.txt").unwrap_or(input);
|
||||||
|
let mut map = Map::new();
|
||||||
|
for line in input.lines() {
|
||||||
|
let points = line.split(" -> ").map(|coord| {
|
||||||
|
let [x, y] = coord.split(',').map(|n| n.parse::<usize>().unwrap()).collect::<Vec<_>>()[..] else {panic!()};
|
||||||
|
(x, y)
|
||||||
|
}).collect::<Vec<_>>();
|
||||||
|
for line in points.windows(2) {
|
||||||
|
let (x1, y1) = line[0];
|
||||||
|
let (x2, y2) = line[1];
|
||||||
|
let x_min = x1.min(x2);
|
||||||
|
let x_max = x1.max(x2);
|
||||||
|
let y_min = y1.min(y2);
|
||||||
|
let y_max = y1.max(y2);
|
||||||
|
for x in x_min..=x_max {
|
||||||
|
for y in y_min..=y_max {
|
||||||
|
map.add_obstacle((x, y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println!("printing map:");
|
||||||
|
map.print();
|
||||||
|
let mut num_sand = 0;
|
||||||
|
while let Some(sand) = add_sand(&map) {
|
||||||
|
map.add_obstacle(sand);
|
||||||
|
num_sand += 1;
|
||||||
|
}
|
||||||
|
println!();
|
||||||
|
map.print();
|
||||||
|
println!("needed {num_sand} sand particles");
|
||||||
|
let floor = map.height + 1;
|
||||||
|
println!("floor: {floor}");
|
||||||
|
while let Some(sand) = add_sand_floor(&map, floor) {
|
||||||
|
map.add_obstacle(sand);
|
||||||
|
num_sand += 1;
|
||||||
|
}
|
||||||
|
println!();
|
||||||
|
map.print();
|
||||||
|
println!("needed {num_sand} sand particles");
|
||||||
}
|
}
|
||||||
|
7
day15/Cargo.lock
generated
Normal file
7
day15/Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "day15"
|
||||||
|
version = "0.1.0"
|
32
day15/input.txt
Normal file
32
day15/input.txt
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
Sensor at x=2832148, y=322979: closest beacon is at x=3015667, y=-141020
|
||||||
|
Sensor at x=1449180, y=3883502: closest beacon is at x=2656952, y=4188971
|
||||||
|
Sensor at x=2808169, y=1194666: closest beacon is at x=3015667, y=-141020
|
||||||
|
Sensor at x=1863363, y=2435968: closest beacon is at x=2166084, y=2883057
|
||||||
|
Sensor at x=3558230, y=2190936: closest beacon is at x=3244164, y=2592191
|
||||||
|
Sensor at x=711491, y=2444705: closest beacon is at x=617239, y=2988377
|
||||||
|
Sensor at x=2727148, y=2766272: closest beacon is at x=2166084, y=2883057
|
||||||
|
Sensor at x=2857938, y=3988086: closest beacon is at x=2968511, y=4098658
|
||||||
|
Sensor at x=1242410, y=2270153: closest beacon is at x=214592, y=2000000
|
||||||
|
Sensor at x=3171784, y=2523127: closest beacon is at x=3244164, y=2592191
|
||||||
|
Sensor at x=2293378, y=71434: closest beacon is at x=3015667, y=-141020
|
||||||
|
Sensor at x=399711, y=73420: closest beacon is at x=1152251, y=-158441
|
||||||
|
Sensor at x=3677529, y=415283: closest beacon is at x=3015667, y=-141020
|
||||||
|
Sensor at x=207809, y=2348497: closest beacon is at x=214592, y=2000000
|
||||||
|
Sensor at x=60607, y=3403420: closest beacon is at x=617239, y=2988377
|
||||||
|
Sensor at x=3767729, y=3136725: closest beacon is at x=4171278, y=3348370
|
||||||
|
Sensor at x=3899632, y=3998969: closest beacon is at x=4171278, y=3348370
|
||||||
|
Sensor at x=394783, y=1541278: closest beacon is at x=214592, y=2000000
|
||||||
|
Sensor at x=1193642, y=642631: closest beacon is at x=1152251, y=-158441
|
||||||
|
Sensor at x=122867, y=2661904: closest beacon is at x=214592, y=2000000
|
||||||
|
Sensor at x=551012, y=3787568: closest beacon is at x=617239, y=2988377
|
||||||
|
Sensor at x=3175715, y=2975144: closest beacon is at x=3244164, y=2592191
|
||||||
|
Sensor at x=402217, y=2812449: closest beacon is at x=617239, y=2988377
|
||||||
|
Sensor at x=879648, y=1177329: closest beacon is at x=214592, y=2000000
|
||||||
|
Sensor at x=1317218, y=2978309: closest beacon is at x=617239, y=2988377
|
||||||
|
Sensor at x=3965126, y=1743931: closest beacon is at x=3244164, y=2592191
|
||||||
|
Sensor at x=2304348, y=3140055: closest beacon is at x=2166084, y=2883057
|
||||||
|
Sensor at x=3380135, y=3650709: closest beacon is at x=2968511, y=4098658
|
||||||
|
Sensor at x=49224, y=1914296: closest beacon is at x=214592, y=2000000
|
||||||
|
Sensor at x=3096228, y=2457233: closest beacon is at x=3244164, y=2592191
|
||||||
|
Sensor at x=1415660, y=6715: closest beacon is at x=1152251, y=-158441
|
||||||
|
Sensor at x=2616280, y=3548378: closest beacon is at x=2656952, y=4188971
|
@ -1,3 +1,95 @@
|
|||||||
fn main() {
|
use std::{collections::HashSet, fs::read_to_string, io::Write, ops::RangeInclusive};
|
||||||
println!("Hello, world!");
|
|
||||||
|
struct Sensor {
|
||||||
|
x: i64,
|
||||||
|
y: i64,
|
||||||
|
x_beacon: i64,
|
||||||
|
y_beacon: i64,
|
||||||
|
distance: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&str> for Sensor {
|
||||||
|
fn from(value: &str) -> Self {
|
||||||
|
let [x_sensor, y_sensor, x_beacon, y_beacon] = value
|
||||||
|
.chars()
|
||||||
|
.filter(|c| c.is_ascii_digit() || c.is_whitespace() || *c == '-')
|
||||||
|
.collect::<String>()
|
||||||
|
.split_whitespace()
|
||||||
|
.map(|n| n.parse::<i64>().unwrap())
|
||||||
|
.collect::<Vec<_>>()[..] else {panic!()};
|
||||||
|
Self {
|
||||||
|
x: x_sensor,
|
||||||
|
y: y_sensor,
|
||||||
|
x_beacon,
|
||||||
|
y_beacon,
|
||||||
|
distance: x_sensor.abs_diff(x_beacon) + y_sensor.abs_diff(y_beacon),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let input = (
|
||||||
|
"Sensor at x=2, y=18: closest beacon is at x=-2, y=15
|
||||||
|
Sensor at x=9, y=16: closest beacon is at x=10, y=16
|
||||||
|
Sensor at x=13, y=2: closest beacon is at x=15, y=3
|
||||||
|
Sensor at x=12, y=14: closest beacon is at x=10, y=16
|
||||||
|
Sensor at x=10, y=20: closest beacon is at x=10, y=16
|
||||||
|
Sensor at x=14, y=17: closest beacon is at x=10, y=16
|
||||||
|
Sensor at x=8, y=7: closest beacon is at x=2, y=10
|
||||||
|
Sensor at x=2, y=0: closest beacon is at x=2, y=10
|
||||||
|
Sensor at x=0, y=11: closest beacon is at x=2, y=10
|
||||||
|
Sensor at x=20, y=14: closest beacon is at x=25, y=17
|
||||||
|
Sensor at x=17, y=20: closest beacon is at x=21, y=22
|
||||||
|
Sensor at x=16, y=7: closest beacon is at x=15, y=3
|
||||||
|
Sensor at x=14, y=3: closest beacon is at x=15, y=3
|
||||||
|
Sensor at x=20, y=1: closest beacon is at x=15, y=3"
|
||||||
|
.to_owned(),
|
||||||
|
10,
|
||||||
|
20,
|
||||||
|
);
|
||||||
|
let (input, line, xy_max): (_, i64, i64) = read_to_string("input.txt")
|
||||||
|
.map(|input| (input, 2_000_000, 4_000_000))
|
||||||
|
.unwrap_or(input);
|
||||||
|
let sensors = input.lines().map(Sensor::from).collect::<Vec<_>>();
|
||||||
|
let mut covered: HashSet<_> = sensors
|
||||||
|
.iter()
|
||||||
|
.flat_map(|s| {
|
||||||
|
let diff = line.abs_diff(s.y);
|
||||||
|
if diff > s.distance {
|
||||||
|
return RangeInclusive::new(1, 0);
|
||||||
|
}
|
||||||
|
let d = s.distance - diff;
|
||||||
|
(s.x - d as i64)..=(s.x + d as i64)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
for sensor in &sensors {
|
||||||
|
if sensor.y_beacon == line {
|
||||||
|
covered.remove(&sensor.x_beacon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println!("{} positions can't contain a beacon", covered.len());
|
||||||
|
'outer: for y in 0..=xy_max {
|
||||||
|
let mut ranges = vec![];
|
||||||
|
for sensor in &sensors {
|
||||||
|
let diff = y.abs_diff(sensor.y);
|
||||||
|
if diff > sensor.distance {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let d = sensor.distance - diff;
|
||||||
|
ranges.push((sensor.x - d as i64)..=(sensor.x + d as i64));
|
||||||
|
}
|
||||||
|
ranges.sort_unstable_by(|r1, r2| r1.start().cmp(r2.start()));
|
||||||
|
let mut max_x = 0;
|
||||||
|
for range in ranges {
|
||||||
|
if max_x + 1 < *range.start() {
|
||||||
|
let x = max_x + 1;
|
||||||
|
println!(
|
||||||
|
"found beacon at {x},{y} with frequency {}",
|
||||||
|
x * 4_000_000 + y
|
||||||
|
);
|
||||||
|
break 'outer;
|
||||||
|
}
|
||||||
|
max_x = max_x.max(*range.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use std::{fs::read_to_string, iter::Peekable, str::Lines};
|
use std::{collections::HashMap, fs::read_to_string, iter::Peekable, str::Lines};
|
||||||
|
|
||||||
|
/*
|
||||||
#[derive(PartialEq, Debug)]
|
#[derive(PartialEq, Debug)]
|
||||||
struct File {
|
struct File {
|
||||||
name: String,
|
name: String,
|
||||||
@ -115,3 +116,68 @@ fn main() {
|
|||||||
let sol2 = sizes.filter(|s| s >= &additional).min().unwrap();
|
let sol2 = sizes.filter(|s| s >= &additional).min().unwrap();
|
||||||
println!("Deleting Directory with size {sol2}");
|
println!("Deleting Directory with size {sol2}");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let input = read_to_string("input.txt").unwrap();
|
||||||
|
let mut cwd = "/".to_owned();
|
||||||
|
let mut files = HashMap::new();
|
||||||
|
for line in input.lines() {
|
||||||
|
let line = line.split_whitespace().collect::<Vec<_>>();
|
||||||
|
match line.len() {
|
||||||
|
3 => match line[2] {
|
||||||
|
"/" => cwd = "/".to_owned(),
|
||||||
|
".." => {
|
||||||
|
cwd = {
|
||||||
|
if cwd == "/" {
|
||||||
|
cwd
|
||||||
|
} else {
|
||||||
|
let dirs = cwd.split_inclusive('/').collect::<Vec<_>>();
|
||||||
|
let nwd = dirs[..(dirs.len() - 1)]
|
||||||
|
.iter()
|
||||||
|
.fold(String::new(), |s, v| s + v);
|
||||||
|
nwd
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dir => cwd = cwd + dir + "/",
|
||||||
|
},
|
||||||
|
2 => {
|
||||||
|
if (line[0] != "$") && (line[0] != "dir") {
|
||||||
|
let size = line[0].parse::<usize>().unwrap();
|
||||||
|
let path = cwd.clone() + line[1];
|
||||||
|
files.insert(path, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let mut directories = HashMap::new();
|
||||||
|
for (path, size) in files {
|
||||||
|
let mut folders = path
|
||||||
|
.split_terminator('/')
|
||||||
|
.map(|s| s.to_owned())
|
||||||
|
.collect::<Vec<String>>();
|
||||||
|
folders.pop();
|
||||||
|
for (index, folder) in folders.clone().iter().enumerate() {
|
||||||
|
let previus = if index > 0 { &folders[index - 1] } else { "" };
|
||||||
|
folders[index] = previus.to_owned() + folder + "/";
|
||||||
|
}
|
||||||
|
for folder in folders {
|
||||||
|
*directories.entry(folder).or_insert(0) += size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let result1: usize = directories.values().filter(|&&size| size < 100_000).sum();
|
||||||
|
const TOTAL_SPACE: usize = 70000000;
|
||||||
|
const NEEDED_FREE: usize = 30000000;
|
||||||
|
let used = *directories.entry("/".to_owned()).or_insert(0);
|
||||||
|
let free = TOTAL_SPACE - used;
|
||||||
|
let additional = NEEDED_FREE - free;
|
||||||
|
let result2: usize = directories
|
||||||
|
.values()
|
||||||
|
.filter(|&&size| size >= additional)
|
||||||
|
.min()
|
||||||
|
.map(|size| *size)
|
||||||
|
.unwrap_or(0);
|
||||||
|
println!("{result1} bytes used by directories smaller than 100000. {result2} Bytes removed by the smallest directory");
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user