2022 rust day 14 part 1
This commit is contained in:
parent
00ec57dc3d
commit
31c609954e
155
2022/rust/inputs/day14.txt
Normal file
155
2022/rust/inputs/day14.txt
Normal file
|
@ -0,0 +1,155 @@
|
||||||
|
499,65 -> 499,68 -> 491,68 -> 491,74 -> 508,74 -> 508,68 -> 504,68 -> 504,65
|
||||||
|
479,42 -> 479,33 -> 479,42 -> 481,42 -> 481,32 -> 481,42 -> 483,42 -> 483,34 -> 483,42 -> 485,42 -> 485,36 -> 485,42 -> 487,42 -> 487,33 -> 487,42
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
485,24 -> 485,25 -> 496,25 -> 496,24
|
||||||
|
485,24 -> 485,25 -> 496,25 -> 496,24
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
519,149 -> 524,149
|
||||||
|
536,105 -> 536,109 -> 533,109 -> 533,115 -> 545,115 -> 545,109 -> 540,109 -> 540,105
|
||||||
|
494,16 -> 499,16
|
||||||
|
536,105 -> 536,109 -> 533,109 -> 533,115 -> 545,115 -> 545,109 -> 540,109 -> 540,105
|
||||||
|
499,65 -> 499,68 -> 491,68 -> 491,74 -> 508,74 -> 508,68 -> 504,68 -> 504,65
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
504,83 -> 508,83
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
516,83 -> 520,83
|
||||||
|
514,88 -> 514,89 -> 530,89
|
||||||
|
520,155 -> 525,155
|
||||||
|
479,42 -> 479,33 -> 479,42 -> 481,42 -> 481,32 -> 481,42 -> 483,42 -> 483,34 -> 483,42 -> 485,42 -> 485,36 -> 485,42 -> 487,42 -> 487,33 -> 487,42
|
||||||
|
479,42 -> 479,33 -> 479,42 -> 481,42 -> 481,32 -> 481,42 -> 483,42 -> 483,34 -> 483,42 -> 485,42 -> 485,36 -> 485,42 -> 487,42 -> 487,33 -> 487,42
|
||||||
|
522,140 -> 527,140
|
||||||
|
536,105 -> 536,109 -> 533,109 -> 533,115 -> 545,115 -> 545,109 -> 540,109 -> 540,105
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
502,22 -> 507,22
|
||||||
|
494,56 -> 494,59 -> 489,59 -> 489,62 -> 501,62 -> 501,59 -> 500,59 -> 500,56
|
||||||
|
525,137 -> 530,137
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
523,152 -> 528,152
|
||||||
|
529,128 -> 529,123 -> 529,128 -> 531,128 -> 531,123 -> 531,128 -> 533,128 -> 533,123 -> 533,128
|
||||||
|
507,77 -> 511,77
|
||||||
|
494,56 -> 494,59 -> 489,59 -> 489,62 -> 501,62 -> 501,59 -> 500,59 -> 500,56
|
||||||
|
536,140 -> 541,140
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
543,140 -> 548,140
|
||||||
|
479,42 -> 479,33 -> 479,42 -> 481,42 -> 481,32 -> 481,42 -> 483,42 -> 483,34 -> 483,42 -> 485,42 -> 485,36 -> 485,42 -> 487,42 -> 487,33 -> 487,42
|
||||||
|
479,42 -> 479,33 -> 479,42 -> 481,42 -> 481,32 -> 481,42 -> 483,42 -> 483,34 -> 483,42 -> 485,42 -> 485,36 -> 485,42 -> 487,42 -> 487,33 -> 487,42
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
492,28 -> 492,29 -> 509,29
|
||||||
|
485,45 -> 485,47 -> 480,47 -> 480,53 -> 496,53 -> 496,47 -> 489,47 -> 489,45
|
||||||
|
518,161 -> 527,161 -> 527,160
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
499,65 -> 499,68 -> 491,68 -> 491,74 -> 508,74 -> 508,68 -> 504,68 -> 504,65
|
||||||
|
529,128 -> 529,123 -> 529,128 -> 531,128 -> 531,123 -> 531,128 -> 533,128 -> 533,123 -> 533,128
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
536,105 -> 536,109 -> 533,109 -> 533,115 -> 545,115 -> 545,109 -> 540,109 -> 540,105
|
||||||
|
518,161 -> 527,161 -> 527,160
|
||||||
|
531,131 -> 536,131
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
501,85 -> 505,85
|
||||||
|
497,13 -> 502,13
|
||||||
|
529,128 -> 529,123 -> 529,128 -> 531,128 -> 531,123 -> 531,128 -> 533,128 -> 533,123 -> 533,128
|
||||||
|
507,85 -> 511,85
|
||||||
|
479,42 -> 479,33 -> 479,42 -> 481,42 -> 481,32 -> 481,42 -> 483,42 -> 483,34 -> 483,42 -> 485,42 -> 485,36 -> 485,42 -> 487,42 -> 487,33 -> 487,42
|
||||||
|
513,155 -> 518,155
|
||||||
|
485,45 -> 485,47 -> 480,47 -> 480,53 -> 496,53 -> 496,47 -> 489,47 -> 489,45
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
532,137 -> 537,137
|
||||||
|
485,45 -> 485,47 -> 480,47 -> 480,53 -> 496,53 -> 496,47 -> 489,47 -> 489,45
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
485,24 -> 485,25 -> 496,25 -> 496,24
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
479,42 -> 479,33 -> 479,42 -> 481,42 -> 481,32 -> 481,42 -> 483,42 -> 483,34 -> 483,42 -> 485,42 -> 485,36 -> 485,42 -> 487,42 -> 487,33 -> 487,42
|
||||||
|
495,22 -> 500,22
|
||||||
|
529,128 -> 529,123 -> 529,128 -> 531,128 -> 531,123 -> 531,128 -> 533,128 -> 533,123 -> 533,128
|
||||||
|
516,152 -> 521,152
|
||||||
|
529,128 -> 529,123 -> 529,128 -> 531,128 -> 531,123 -> 531,128 -> 533,128 -> 533,123 -> 533,128
|
||||||
|
499,65 -> 499,68 -> 491,68 -> 491,74 -> 508,74 -> 508,68 -> 504,68 -> 504,65
|
||||||
|
529,128 -> 529,123 -> 529,128 -> 531,128 -> 531,123 -> 531,128 -> 533,128 -> 533,123 -> 533,128
|
||||||
|
529,128 -> 529,123 -> 529,128 -> 531,128 -> 531,123 -> 531,128 -> 533,128 -> 533,123 -> 533,128
|
||||||
|
513,81 -> 517,81
|
||||||
|
479,42 -> 479,33 -> 479,42 -> 481,42 -> 481,32 -> 481,42 -> 483,42 -> 483,34 -> 483,42 -> 485,42 -> 485,36 -> 485,42 -> 487,42 -> 487,33 -> 487,42
|
||||||
|
536,105 -> 536,109 -> 533,109 -> 533,115 -> 545,115 -> 545,109 -> 540,109 -> 540,105
|
||||||
|
485,45 -> 485,47 -> 480,47 -> 480,53 -> 496,53 -> 496,47 -> 489,47 -> 489,45
|
||||||
|
529,128 -> 529,123 -> 529,128 -> 531,128 -> 531,123 -> 531,128 -> 533,128 -> 533,123 -> 533,128
|
||||||
|
530,152 -> 535,152
|
||||||
|
479,42 -> 479,33 -> 479,42 -> 481,42 -> 481,32 -> 481,42 -> 483,42 -> 483,34 -> 483,42 -> 485,42 -> 485,36 -> 485,42 -> 487,42 -> 487,33 -> 487,42
|
||||||
|
505,19 -> 510,19
|
||||||
|
494,56 -> 494,59 -> 489,59 -> 489,62 -> 501,62 -> 501,59 -> 500,59 -> 500,56
|
||||||
|
491,19 -> 496,19
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
499,65 -> 499,68 -> 491,68 -> 491,74 -> 508,74 -> 508,68 -> 504,68 -> 504,65
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
522,146 -> 527,146
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
499,65 -> 499,68 -> 491,68 -> 491,74 -> 508,74 -> 508,68 -> 504,68 -> 504,65
|
||||||
|
533,149 -> 538,149
|
||||||
|
541,155 -> 546,155
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
488,22 -> 493,22
|
||||||
|
539,137 -> 544,137
|
||||||
|
494,56 -> 494,59 -> 489,59 -> 489,62 -> 501,62 -> 501,59 -> 500,59 -> 500,56
|
||||||
|
510,83 -> 514,83
|
||||||
|
528,134 -> 533,134
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
537,152 -> 542,152
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
495,85 -> 499,85
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
501,16 -> 506,16
|
||||||
|
494,56 -> 494,59 -> 489,59 -> 489,62 -> 501,62 -> 501,59 -> 500,59 -> 500,56
|
||||||
|
514,88 -> 514,89 -> 530,89
|
||||||
|
485,45 -> 485,47 -> 480,47 -> 480,53 -> 496,53 -> 496,47 -> 489,47 -> 489,45
|
||||||
|
504,79 -> 508,79
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
525,143 -> 530,143
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
529,146 -> 534,146
|
||||||
|
479,42 -> 479,33 -> 479,42 -> 481,42 -> 481,32 -> 481,42 -> 483,42 -> 483,34 -> 483,42 -> 485,42 -> 485,36 -> 485,42 -> 487,42 -> 487,33 -> 487,42
|
||||||
|
494,56 -> 494,59 -> 489,59 -> 489,62 -> 501,62 -> 501,59 -> 500,59 -> 500,56
|
||||||
|
526,149 -> 531,149
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
527,155 -> 532,155
|
||||||
|
507,81 -> 511,81
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
492,28 -> 492,29 -> 509,29
|
||||||
|
535,134 -> 540,134
|
||||||
|
499,65 -> 499,68 -> 491,68 -> 491,74 -> 508,74 -> 508,68 -> 504,68 -> 504,65
|
||||||
|
479,42 -> 479,33 -> 479,42 -> 481,42 -> 481,32 -> 481,42 -> 483,42 -> 483,34 -> 483,42 -> 485,42 -> 485,36 -> 485,42 -> 487,42 -> 487,33 -> 487,42
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
536,105 -> 536,109 -> 533,109 -> 533,115 -> 545,115 -> 545,109 -> 540,109 -> 540,105
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
536,105 -> 536,109 -> 533,109 -> 533,115 -> 545,115 -> 545,109 -> 540,109 -> 540,105
|
||||||
|
485,45 -> 485,47 -> 480,47 -> 480,53 -> 496,53 -> 496,47 -> 489,47 -> 489,45
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
485,45 -> 485,47 -> 480,47 -> 480,53 -> 496,53 -> 496,47 -> 489,47 -> 489,45
|
||||||
|
510,79 -> 514,79
|
||||||
|
529,140 -> 534,140
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
498,83 -> 502,83
|
||||||
|
494,56 -> 494,59 -> 489,59 -> 489,62 -> 501,62 -> 501,59 -> 500,59 -> 500,56
|
||||||
|
479,42 -> 479,33 -> 479,42 -> 481,42 -> 481,32 -> 481,42 -> 483,42 -> 483,34 -> 483,42 -> 485,42 -> 485,36 -> 485,42 -> 487,42 -> 487,33 -> 487,42
|
||||||
|
519,85 -> 523,85
|
||||||
|
498,19 -> 503,19
|
||||||
|
501,81 -> 505,81
|
||||||
|
513,85 -> 517,85
|
||||||
|
509,22 -> 514,22
|
||||||
|
523,102 -> 523,92 -> 523,102 -> 525,102 -> 525,99 -> 525,102 -> 527,102 -> 527,95 -> 527,102 -> 529,102 -> 529,101 -> 529,102 -> 531,102 -> 531,101 -> 531,102 -> 533,102 -> 533,99 -> 533,102 -> 535,102 -> 535,94 -> 535,102 -> 537,102 -> 537,92 -> 537,102
|
||||||
|
479,42 -> 479,33 -> 479,42 -> 481,42 -> 481,32 -> 481,42 -> 483,42 -> 483,34 -> 483,42 -> 485,42 -> 485,36 -> 485,42 -> 487,42 -> 487,33 -> 487,42
|
||||||
|
509,174 -> 509,170 -> 509,174 -> 511,174 -> 511,169 -> 511,174 -> 513,174 -> 513,169 -> 513,174 -> 515,174 -> 515,167 -> 515,174 -> 517,174 -> 517,166 -> 517,174 -> 519,174 -> 519,173 -> 519,174 -> 521,174 -> 521,164 -> 521,174 -> 523,174 -> 523,172 -> 523,174
|
||||||
|
479,42 -> 479,33 -> 479,42 -> 481,42 -> 481,32 -> 481,42 -> 483,42 -> 483,34 -> 483,42 -> 485,42 -> 485,36 -> 485,42 -> 487,42 -> 487,33 -> 487,42
|
||||||
|
534,155 -> 539,155
|
|
@ -3,5 +3,5 @@ mod solutions;
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
solutions::day13::run();
|
solutions::day14::run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,9 @@ fn parse_data<T: AsRef<str>>(data: &[T]) -> Vec<Vec<i32>> {
|
||||||
let s = next.as_ref();
|
let s = next.as_ref();
|
||||||
match s.len() == 0 {
|
match s.len() == 0 {
|
||||||
true => acc.push(Vec::new()),
|
true => acc.push(Vec::new()),
|
||||||
false => acc.last_mut()
|
false => {
|
||||||
.and_then(|last| Some(last.push(s.parse().unwrap())))
|
acc.last_mut().and_then(|last| Some(last.push(s.parse().unwrap())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
acc
|
acc
|
||||||
})
|
})
|
||||||
|
|
135
2022/rust/src/solutions/day14.rs
Normal file
135
2022/rust/src/solutions/day14.rs
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
use std::fmt::{Display, Formatter};
|
||||||
|
use regex::Regex;
|
||||||
|
use crate::utils;
|
||||||
|
use crate::utils::matrix::Matrix;
|
||||||
|
|
||||||
|
|
||||||
|
pub fn run() -> () {
|
||||||
|
let data = parse_data(&utils::read_lines(utils::Source::Day(14)));
|
||||||
|
|
||||||
|
println!("Day 14");
|
||||||
|
println!("Part 1: {}", solve1(&data));
|
||||||
|
println!("Part 2: {}", solve2(&data));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[repr(u8)]
|
||||||
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
|
enum Tile { Empty, Rock, Sand }
|
||||||
|
|
||||||
|
impl Display for Tile {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
match self {
|
||||||
|
Tile::Empty => write!(f, ".")?,
|
||||||
|
Tile::Rock => write!(f, "#")?,
|
||||||
|
Tile::Sand => write!(f, "o")?,
|
||||||
|
};
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_grid(data: &[Vec<(usize, usize)>]) -> Matrix<Tile> {
|
||||||
|
let (min_c, max) = data.iter()
|
||||||
|
.flatten()
|
||||||
|
.fold((usize::MAX, (usize::MIN, usize::MIN)), |(min_c, (max_r, max_c)), &(r, c)| (
|
||||||
|
min_c.min(c), (max_r.max(r), max_c.max(c))
|
||||||
|
));
|
||||||
|
let mut grid = Matrix::with_bounds((0, min_c), max, Tile::Empty);
|
||||||
|
for path in data.iter() {
|
||||||
|
let mut path_iter = path.iter();
|
||||||
|
path_iter.next()
|
||||||
|
.map(|&start| path_iter
|
||||||
|
.fold(start, |(prev_r, prev_c), &(next_r, next_c)| {
|
||||||
|
let (min_r, max_r) = (prev_r.min(next_r), prev_r.max(next_r));
|
||||||
|
let (min_c, max_c) = (prev_c.min(next_c), prev_c.max(next_c));
|
||||||
|
match prev_r == next_r {
|
||||||
|
true => (min_c..=max_c).into_iter()
|
||||||
|
.for_each(|c| grid[(prev_r, c)] = Tile::Rock),
|
||||||
|
false => (min_r..=max_r).into_iter()
|
||||||
|
.for_each(|r| grid[(r, prev_c)] = Tile::Rock),
|
||||||
|
};
|
||||||
|
(next_r, next_c)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
};
|
||||||
|
grid
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn drop_sand(grid: &mut Matrix<Tile>, (row, col): (usize, usize)) -> Option<(usize, usize)> {
|
||||||
|
let ((_, min_c), (max_r, max_c)) = grid.bounds();
|
||||||
|
for r in row..max_r {
|
||||||
|
if grid[(r, col)] != Tile::Empty {
|
||||||
|
return if col == min_c {
|
||||||
|
None
|
||||||
|
} else if grid[(r, col - 1)] == Tile::Empty {
|
||||||
|
drop_sand(grid, (r, col - 1))
|
||||||
|
} else if col == max_c {
|
||||||
|
None
|
||||||
|
} else if grid[(r, col + 1)] == Tile::Empty {
|
||||||
|
drop_sand(grid, (r, col + 1))
|
||||||
|
} else {
|
||||||
|
let index = (r - 1, col);
|
||||||
|
grid[index] = Tile::Sand;
|
||||||
|
Some(index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn solve1(data: &[Vec<(usize, usize)>]) -> i32 {
|
||||||
|
let mut grid = create_grid(data);
|
||||||
|
|
||||||
|
let mut sand_count = 0;
|
||||||
|
while let Some(_) = drop_sand(&mut grid, (0, 500)) {
|
||||||
|
sand_count += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sand_count
|
||||||
|
}
|
||||||
|
|
||||||
|
fn solve2(data: &[Vec<(usize, usize)>]) -> i32 {
|
||||||
|
2
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn parse_data<T: AsRef<str>>(data: &[T]) -> Vec<Vec<(usize, usize)>> {
|
||||||
|
let re = Regex::new(r#"(\d+,\d+)"#).unwrap();
|
||||||
|
data.iter()
|
||||||
|
.map(|line| re
|
||||||
|
.captures_iter(line.as_ref())
|
||||||
|
.map(|s| {
|
||||||
|
let mut parts = s.get(1).unwrap().as_str().split(",");
|
||||||
|
let c: usize = parts.next().unwrap().parse().unwrap();
|
||||||
|
let r: usize = parts.next().unwrap().parse().unwrap();
|
||||||
|
(r, c)
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
)
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
static DATA: &[&str] = &[
|
||||||
|
"498,4 -> 498,6 -> 496,6",
|
||||||
|
"503,4 -> 502,4 -> 502,9 -> 494,9",
|
||||||
|
];
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn part1() {
|
||||||
|
assert_eq!(24, solve1(&parse_data(DATA)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn part2() {
|
||||||
|
let data = parse_data(DATA);
|
||||||
|
assert_eq!(2, solve2(&data));
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,3 +11,4 @@ pub mod day10;
|
||||||
pub mod day11;
|
pub mod day11;
|
||||||
pub mod day12;
|
pub mod day12;
|
||||||
pub mod day13;
|
pub mod day13;
|
||||||
|
pub mod day14;
|
||||||
|
|
|
@ -8,15 +8,26 @@ pub struct Matrix<T> {
|
||||||
array: Vec<T>,
|
array: Vec<T>,
|
||||||
rows: usize,
|
rows: usize,
|
||||||
cols: usize,
|
cols: usize,
|
||||||
|
offset_r: usize,
|
||||||
|
offset_c: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Default + Clone> Matrix<T> {
|
impl<T: Default + Clone> Matrix<T> {
|
||||||
pub fn new(rows: usize, cols: usize) -> Self {
|
pub fn new(rows: usize, cols: usize) -> Self {
|
||||||
Self { rows, cols, array: vec![Default::default(); rows * cols] }
|
Self { rows, cols, array: vec![Default::default(); rows * cols], offset_r: 0, offset_c: 0 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Clone> Matrix<T> {
|
||||||
|
pub fn with_shape((rows, cols): (usize, usize), value: T) -> Self {
|
||||||
|
Self { rows, cols, array: vec![value.clone(); rows * cols], offset_r: 0, offset_c: 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_shape((rows, cols): (usize, usize), value: T) -> Self {
|
pub fn with_bounds((min_r, min_c): (usize, usize), (max_r, max_c): (usize, usize), value: T) -> Self {
|
||||||
Self { rows, cols, array: vec![value.clone(); rows * cols] }
|
assert!(max_r > min_r && max_c > min_c, "Min bound has to be lower than max bound");
|
||||||
|
let (rows, cols) = (max_r - min_r + 1, max_c - min_c + 1);
|
||||||
|
let (offset_r, offset_c) = (min_r, min_c);
|
||||||
|
Self { rows, cols, array: vec![value.clone(); rows * cols], offset_r, offset_c }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +37,13 @@ impl<T> Matrix<T> {
|
||||||
(self.rows, self.cols)
|
(self.rows, self.cols)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn bounds(&self) -> ((usize, usize), (usize, usize)) {
|
||||||
|
(
|
||||||
|
(self.offset_r, self.offset_c),
|
||||||
|
(self.offset_r + self.rows, self.offset_c + self.cols)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn reshape(mut self, (rows, cols): (usize, usize)) -> Self {
|
pub fn reshape(mut self, (rows, cols): (usize, usize)) -> Self {
|
||||||
assert_eq!(self.rows * self.cols, rows * cols);
|
assert_eq!(self.rows * self.cols, rows * cols);
|
||||||
(self.rows, self.cols) = (rows, cols);
|
(self.rows, self.cols) = (rows, cols);
|
||||||
|
@ -51,13 +69,15 @@ impl<T> Matrix<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cell_indices(&self) -> impl Iterator<Item = (usize, usize)> + '_ {
|
pub fn cell_indices(&self) -> impl Iterator<Item = (usize, usize)> + '_ {
|
||||||
(0..self.rows).into_iter()
|
let row_range = self.offset_r..(self.rows + self.offset_r);
|
||||||
.flat_map(|row| (0..self.cols).into_iter().map(move |col| (row, col)))
|
let col_range = self.offset_c..(self.cols + self.offset_c);
|
||||||
|
row_range.into_iter()
|
||||||
|
.flat_map(move |row| col_range.clone().into_iter().map(move |col| (row, col)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn get_offset(&self, row: usize, col: usize) -> usize {
|
fn get_offset(&self, row: usize, col: usize) -> usize {
|
||||||
row * self.cols + col
|
(row - self.offset_r) * self.cols + (col - self.offset_c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +129,7 @@ impl<T> FromIterator<T> for Matrix<T> {
|
||||||
fn from_iter<I: IntoIterator<Item=T>>(iter: I) -> Self {
|
fn from_iter<I: IntoIterator<Item=T>>(iter: I) -> Self {
|
||||||
let array = iter.into_iter().collect::<Vec<_>>();
|
let array = iter.into_iter().collect::<Vec<_>>();
|
||||||
let cols = array.len();
|
let cols = array.len();
|
||||||
Matrix { array, cols, rows: 1 }
|
Matrix { array, cols, rows: 1, offset_r: 0, offset_c: 0 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,9 @@ fn parse_data<T: AsRef<str>>(data: &[T]) -> () {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
static DATA: &[&str; 1] = [""];
|
static DATA: &[&str] = &[
|
||||||
|
""
|
||||||
|
];
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn part1() {
|
fn part1() {
|
||||||
|
|
Loading…
Reference in a new issue