Compare commits
No commits in common. "0d4c2a7b4e6b319887aaec6d9a5e8323b02572a3" and "c6e5343b529d735b7bdffd14aac617a583b1f177" have entirely different histories.
0d4c2a7b4e
...
c6e5343b52
@ -39,7 +39,6 @@ day17 = []
|
|||||||
day18 = []
|
day18 = []
|
||||||
day19 = []
|
day19 = []
|
||||||
day20 = []
|
day20 = []
|
||||||
visualize = []
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
173
input/14.txt
173
input/14.txt
@ -1,173 +0,0 @@
|
|||||||
480,150 -> 485,150
|
|
||||||
459,100 -> 464,100
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
458,81 -> 458,77 -> 458,81 -> 460,81 -> 460,73 -> 460,81 -> 462,81 -> 462,80 -> 462,81 -> 464,81 -> 464,77 -> 464,81 -> 466,81 -> 466,78 -> 466,81 -> 468,81 -> 468,73 -> 468,81
|
|
||||||
504,19 -> 508,19
|
|
||||||
467,59 -> 472,59
|
|
||||||
463,103 -> 468,103
|
|
||||||
472,68 -> 477,68
|
|
||||||
472,176 -> 472,175 -> 472,176 -> 474,176 -> 474,174 -> 474,176 -> 476,176 -> 476,174 -> 476,176 -> 478,176 -> 478,175 -> 478,176 -> 480,176 -> 480,166 -> 480,176 -> 482,176 -> 482,172 -> 482,176 -> 484,176 -> 484,167 -> 484,176
|
|
||||||
470,103 -> 475,103
|
|
||||||
479,36 -> 479,40 -> 477,40 -> 477,48 -> 489,48 -> 489,40 -> 483,40 -> 483,36
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
467,128 -> 467,132 -> 462,132 -> 462,138 -> 477,138 -> 477,132 -> 472,132 -> 472,128
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
452,112 -> 458,112 -> 458,111
|
|
||||||
460,115 -> 460,117 -> 456,117 -> 456,125 -> 469,125 -> 469,117 -> 464,117 -> 464,115
|
|
||||||
486,25 -> 490,25
|
|
||||||
471,109 -> 476,109
|
|
||||||
467,179 -> 467,180 -> 472,180 -> 472,179
|
|
||||||
487,150 -> 492,150
|
|
||||||
501,16 -> 505,16
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
472,176 -> 472,175 -> 472,176 -> 474,176 -> 474,174 -> 474,176 -> 476,176 -> 476,174 -> 476,176 -> 478,176 -> 478,175 -> 478,176 -> 480,176 -> 480,166 -> 480,176 -> 482,176 -> 482,172 -> 482,176 -> 484,176 -> 484,167 -> 484,176
|
|
||||||
479,36 -> 479,40 -> 477,40 -> 477,48 -> 489,48 -> 489,40 -> 483,40 -> 483,36
|
|
||||||
458,81 -> 458,77 -> 458,81 -> 460,81 -> 460,73 -> 460,81 -> 462,81 -> 462,80 -> 462,81 -> 464,81 -> 464,77 -> 464,81 -> 466,81 -> 466,78 -> 466,81 -> 468,81 -> 468,73 -> 468,81
|
|
||||||
464,109 -> 469,109
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
472,176 -> 472,175 -> 472,176 -> 474,176 -> 474,174 -> 474,176 -> 476,176 -> 476,174 -> 476,176 -> 478,176 -> 478,175 -> 478,176 -> 480,176 -> 480,166 -> 480,176 -> 482,176 -> 482,172 -> 482,176 -> 484,176 -> 484,167 -> 484,176
|
|
||||||
489,22 -> 493,22
|
|
||||||
458,81 -> 458,77 -> 458,81 -> 460,81 -> 460,73 -> 460,81 -> 462,81 -> 462,80 -> 462,81 -> 464,81 -> 464,77 -> 464,81 -> 466,81 -> 466,78 -> 466,81 -> 468,81 -> 468,73 -> 468,81
|
|
||||||
460,115 -> 460,117 -> 456,117 -> 456,125 -> 469,125 -> 469,117 -> 464,117 -> 464,115
|
|
||||||
471,55 -> 471,56 -> 479,56
|
|
||||||
458,81 -> 458,77 -> 458,81 -> 460,81 -> 460,73 -> 460,81 -> 462,81 -> 462,80 -> 462,81 -> 464,81 -> 464,77 -> 464,81 -> 466,81 -> 466,78 -> 466,81 -> 468,81 -> 468,73 -> 468,81
|
|
||||||
498,25 -> 502,25
|
|
||||||
467,128 -> 467,132 -> 462,132 -> 462,138 -> 477,138 -> 477,132 -> 472,132 -> 472,128
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
498,13 -> 502,13
|
|
||||||
472,176 -> 472,175 -> 472,176 -> 474,176 -> 474,174 -> 474,176 -> 476,176 -> 476,174 -> 476,176 -> 478,176 -> 478,175 -> 478,176 -> 480,176 -> 480,166 -> 480,176 -> 482,176 -> 482,172 -> 482,176 -> 484,176 -> 484,167 -> 484,176
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
472,144 -> 477,144
|
|
||||||
466,150 -> 471,150
|
|
||||||
479,36 -> 479,40 -> 477,40 -> 477,48 -> 489,48 -> 489,40 -> 483,40 -> 483,36
|
|
||||||
458,81 -> 458,77 -> 458,81 -> 460,81 -> 460,73 -> 460,81 -> 462,81 -> 462,80 -> 462,81 -> 464,81 -> 464,77 -> 464,81 -> 466,81 -> 466,78 -> 466,81 -> 468,81 -> 468,73 -> 468,81
|
|
||||||
507,22 -> 511,22
|
|
||||||
467,128 -> 467,132 -> 462,132 -> 462,138 -> 477,138 -> 477,132 -> 472,132 -> 472,128
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
458,81 -> 458,77 -> 458,81 -> 460,81 -> 460,73 -> 460,81 -> 462,81 -> 462,80 -> 462,81 -> 464,81 -> 464,77 -> 464,81 -> 466,81 -> 466,78 -> 466,81 -> 468,81 -> 468,73 -> 468,81
|
|
||||||
479,36 -> 479,40 -> 477,40 -> 477,48 -> 489,48 -> 489,40 -> 483,40 -> 483,36
|
|
||||||
498,19 -> 502,19
|
|
||||||
458,81 -> 458,77 -> 458,81 -> 460,81 -> 460,73 -> 460,81 -> 462,81 -> 462,80 -> 462,81 -> 464,81 -> 464,77 -> 464,81 -> 466,81 -> 466,78 -> 466,81 -> 468,81 -> 468,73 -> 468,81
|
|
||||||
472,176 -> 472,175 -> 472,176 -> 474,176 -> 474,174 -> 474,176 -> 476,176 -> 476,174 -> 476,176 -> 478,176 -> 478,175 -> 478,176 -> 480,176 -> 480,166 -> 480,176 -> 482,176 -> 482,172 -> 482,176 -> 484,176 -> 484,167 -> 484,176
|
|
||||||
458,68 -> 463,68
|
|
||||||
458,81 -> 458,77 -> 458,81 -> 460,81 -> 460,73 -> 460,81 -> 462,81 -> 462,80 -> 462,81 -> 464,81 -> 464,77 -> 464,81 -> 466,81 -> 466,78 -> 466,81 -> 468,81 -> 468,73 -> 468,81
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
472,176 -> 472,175 -> 472,176 -> 474,176 -> 474,174 -> 474,176 -> 476,176 -> 476,174 -> 476,176 -> 478,176 -> 478,175 -> 478,176 -> 480,176 -> 480,166 -> 480,176 -> 482,176 -> 482,172 -> 482,176 -> 484,176 -> 484,167 -> 484,176
|
|
||||||
475,65 -> 480,65
|
|
||||||
458,81 -> 458,77 -> 458,81 -> 460,81 -> 460,73 -> 460,81 -> 462,81 -> 462,80 -> 462,81 -> 464,81 -> 464,77 -> 464,81 -> 466,81 -> 466,78 -> 466,81 -> 468,81 -> 468,73 -> 468,81
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
492,19 -> 496,19
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
472,176 -> 472,175 -> 472,176 -> 474,176 -> 474,174 -> 474,176 -> 476,176 -> 476,174 -> 476,176 -> 478,176 -> 478,175 -> 478,176 -> 480,176 -> 480,166 -> 480,176 -> 482,176 -> 482,172 -> 482,176 -> 484,176 -> 484,167 -> 484,176
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
460,115 -> 460,117 -> 456,117 -> 456,125 -> 469,125 -> 469,117 -> 464,117 -> 464,115
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
472,176 -> 472,175 -> 472,176 -> 474,176 -> 474,174 -> 474,176 -> 476,176 -> 476,174 -> 476,176 -> 478,176 -> 478,175 -> 478,176 -> 480,176 -> 480,166 -> 480,176 -> 482,176 -> 482,172 -> 482,176 -> 484,176 -> 484,167 -> 484,176
|
|
||||||
467,128 -> 467,132 -> 462,132 -> 462,138 -> 477,138 -> 477,132 -> 472,132 -> 472,128
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
458,81 -> 458,77 -> 458,81 -> 460,81 -> 460,73 -> 460,81 -> 462,81 -> 462,80 -> 462,81 -> 464,81 -> 464,77 -> 464,81 -> 466,81 -> 466,78 -> 466,81 -> 468,81 -> 468,73 -> 468,81
|
|
||||||
466,100 -> 471,100
|
|
||||||
458,81 -> 458,77 -> 458,81 -> 460,81 -> 460,73 -> 460,81 -> 462,81 -> 462,80 -> 462,81 -> 464,81 -> 464,77 -> 464,81 -> 466,81 -> 466,78 -> 466,81 -> 468,81 -> 468,73 -> 468,81
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
464,62 -> 469,62
|
|
||||||
472,176 -> 472,175 -> 472,176 -> 474,176 -> 474,174 -> 474,176 -> 476,176 -> 476,174 -> 476,176 -> 478,176 -> 478,175 -> 478,176 -> 480,176 -> 480,166 -> 480,176 -> 482,176 -> 482,172 -> 482,176 -> 484,176 -> 484,167 -> 484,176
|
|
||||||
456,103 -> 461,103
|
|
||||||
484,28 -> 484,30 -> 481,30 -> 481,33 -> 488,33 -> 488,30 -> 487,30 -> 487,28
|
|
||||||
467,179 -> 467,180 -> 472,180 -> 472,179
|
|
||||||
467,128 -> 467,132 -> 462,132 -> 462,138 -> 477,138 -> 477,132 -> 472,132 -> 472,128
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
472,176 -> 472,175 -> 472,176 -> 474,176 -> 474,174 -> 474,176 -> 476,176 -> 476,174 -> 476,176 -> 478,176 -> 478,175 -> 478,176 -> 480,176 -> 480,166 -> 480,176 -> 482,176 -> 482,172 -> 482,176 -> 484,176 -> 484,167 -> 484,176
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
467,106 -> 472,106
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
472,176 -> 472,175 -> 472,176 -> 474,176 -> 474,174 -> 474,176 -> 476,176 -> 476,174 -> 476,176 -> 478,176 -> 478,175 -> 478,176 -> 480,176 -> 480,166 -> 480,176 -> 482,176 -> 482,172 -> 482,176 -> 484,176 -> 484,167 -> 484,176
|
|
||||||
474,50 -> 474,51 -> 486,51
|
|
||||||
468,65 -> 473,65
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
472,176 -> 472,175 -> 472,176 -> 474,176 -> 474,174 -> 474,176 -> 476,176 -> 476,174 -> 476,176 -> 478,176 -> 478,175 -> 478,176 -> 480,176 -> 480,166 -> 480,176 -> 482,176 -> 482,172 -> 482,176 -> 484,176 -> 484,167 -> 484,176
|
|
||||||
479,68 -> 484,68
|
|
||||||
476,147 -> 481,147
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
453,106 -> 458,106
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
484,28 -> 484,30 -> 481,30 -> 481,33 -> 488,33 -> 488,30 -> 487,30 -> 487,28
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
484,28 -> 484,30 -> 481,30 -> 481,33 -> 488,33 -> 488,30 -> 487,30 -> 487,28
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
483,147 -> 488,147
|
|
||||||
472,176 -> 472,175 -> 472,176 -> 474,176 -> 474,174 -> 474,176 -> 476,176 -> 476,174 -> 476,176 -> 478,176 -> 478,175 -> 478,176 -> 480,176 -> 480,166 -> 480,176 -> 482,176 -> 482,172 -> 482,176 -> 484,176 -> 484,167 -> 484,176
|
|
||||||
501,22 -> 505,22
|
|
||||||
465,68 -> 470,68
|
|
||||||
479,144 -> 484,144
|
|
||||||
484,28 -> 484,30 -> 481,30 -> 481,33 -> 488,33 -> 488,30 -> 487,30 -> 487,28
|
|
||||||
484,28 -> 484,30 -> 481,30 -> 481,33 -> 488,33 -> 488,30 -> 487,30 -> 487,28
|
|
||||||
472,176 -> 472,175 -> 472,176 -> 474,176 -> 474,174 -> 474,176 -> 476,176 -> 476,174 -> 476,176 -> 478,176 -> 478,175 -> 478,176 -> 480,176 -> 480,166 -> 480,176 -> 482,176 -> 482,172 -> 482,176 -> 484,176 -> 484,167 -> 484,176
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
472,176 -> 472,175 -> 472,176 -> 474,176 -> 474,174 -> 474,176 -> 476,176 -> 476,174 -> 476,176 -> 478,176 -> 478,175 -> 478,176 -> 480,176 -> 480,166 -> 480,176 -> 482,176 -> 482,172 -> 482,176 -> 484,176 -> 484,167 -> 484,176
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
474,106 -> 479,106
|
|
||||||
458,81 -> 458,77 -> 458,81 -> 460,81 -> 460,73 -> 460,81 -> 462,81 -> 462,80 -> 462,81 -> 464,81 -> 464,77 -> 464,81 -> 466,81 -> 466,78 -> 466,81 -> 468,81 -> 468,73 -> 468,81
|
|
||||||
471,55 -> 471,56 -> 479,56
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
475,141 -> 480,141
|
|
||||||
460,115 -> 460,117 -> 456,117 -> 456,125 -> 469,125 -> 469,117 -> 464,117 -> 464,115
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
472,176 -> 472,175 -> 472,176 -> 474,176 -> 474,174 -> 474,176 -> 476,176 -> 476,174 -> 476,176 -> 478,176 -> 478,175 -> 478,176 -> 480,176 -> 480,166 -> 480,176 -> 482,176 -> 482,172 -> 482,176 -> 484,176 -> 484,167 -> 484,176
|
|
||||||
472,176 -> 472,175 -> 472,176 -> 474,176 -> 474,174 -> 474,176 -> 476,176 -> 476,174 -> 476,176 -> 478,176 -> 478,175 -> 478,176 -> 480,176 -> 480,166 -> 480,176 -> 482,176 -> 482,172 -> 482,176 -> 484,176 -> 484,167 -> 484,176
|
|
||||||
484,28 -> 484,30 -> 481,30 -> 481,33 -> 488,33 -> 488,30 -> 487,30 -> 487,28
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
457,109 -> 462,109
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
458,81 -> 458,77 -> 458,81 -> 460,81 -> 460,73 -> 460,81 -> 462,81 -> 462,80 -> 462,81 -> 464,81 -> 464,77 -> 464,81 -> 466,81 -> 466,78 -> 466,81 -> 468,81 -> 468,73 -> 468,81
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
467,128 -> 467,132 -> 462,132 -> 462,138 -> 477,138 -> 477,132 -> 472,132 -> 472,128
|
|
||||||
504,25 -> 508,25
|
|
||||||
458,81 -> 458,77 -> 458,81 -> 460,81 -> 460,73 -> 460,81 -> 462,81 -> 462,80 -> 462,81 -> 464,81 -> 464,77 -> 464,81 -> 466,81 -> 466,78 -> 466,81 -> 468,81 -> 468,73 -> 468,81
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
495,22 -> 499,22
|
|
||||||
492,25 -> 496,25
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
472,176 -> 472,175 -> 472,176 -> 474,176 -> 474,174 -> 474,176 -> 476,176 -> 476,174 -> 476,176 -> 478,176 -> 478,175 -> 478,176 -> 480,176 -> 480,166 -> 480,176 -> 482,176 -> 482,172 -> 482,176 -> 484,176 -> 484,167 -> 484,176
|
|
||||||
467,128 -> 467,132 -> 462,132 -> 462,138 -> 477,138 -> 477,132 -> 472,132 -> 472,128
|
|
||||||
460,106 -> 465,106
|
|
||||||
469,147 -> 474,147
|
|
||||||
450,109 -> 455,109
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
452,112 -> 458,112 -> 458,111
|
|
||||||
461,65 -> 466,65
|
|
||||||
458,81 -> 458,77 -> 458,81 -> 460,81 -> 460,73 -> 460,81 -> 462,81 -> 462,80 -> 462,81 -> 464,81 -> 464,77 -> 464,81 -> 466,81 -> 466,78 -> 466,81 -> 468,81 -> 468,73 -> 468,81
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
472,176 -> 472,175 -> 472,176 -> 474,176 -> 474,174 -> 474,176 -> 476,176 -> 476,174 -> 476,176 -> 478,176 -> 478,175 -> 478,176 -> 480,176 -> 480,166 -> 480,176 -> 482,176 -> 482,172 -> 482,176 -> 484,176 -> 484,167 -> 484,176
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
467,179 -> 467,180 -> 472,180 -> 472,179
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
460,115 -> 460,117 -> 456,117 -> 456,125 -> 469,125 -> 469,117 -> 464,117 -> 464,115
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
458,81 -> 458,77 -> 458,81 -> 460,81 -> 460,73 -> 460,81 -> 462,81 -> 462,80 -> 462,81 -> 464,81 -> 464,77 -> 464,81 -> 466,81 -> 466,78 -> 466,81 -> 468,81 -> 468,73 -> 468,81
|
|
||||||
462,97 -> 467,97
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
510,25 -> 514,25
|
|
||||||
495,16 -> 499,16
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
458,81 -> 458,77 -> 458,81 -> 460,81 -> 460,73 -> 460,81 -> 462,81 -> 462,80 -> 462,81 -> 464,81 -> 464,77 -> 464,81 -> 466,81 -> 466,78 -> 466,81 -> 468,81 -> 468,73 -> 468,81
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
479,36 -> 479,40 -> 477,40 -> 477,48 -> 489,48 -> 489,40 -> 483,40 -> 483,36
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
472,176 -> 472,175 -> 472,176 -> 474,176 -> 474,174 -> 474,176 -> 476,176 -> 476,174 -> 476,176 -> 478,176 -> 478,175 -> 478,176 -> 480,176 -> 480,166 -> 480,176 -> 482,176 -> 482,172 -> 482,176 -> 484,176 -> 484,167 -> 484,176
|
|
||||||
460,115 -> 460,117 -> 456,117 -> 456,125 -> 469,125 -> 469,117 -> 464,117 -> 464,115
|
|
||||||
448,94 -> 448,87 -> 448,94 -> 450,94 -> 450,93 -> 450,94 -> 452,94 -> 452,91 -> 452,94 -> 454,94 -> 454,88 -> 454,94 -> 456,94 -> 456,91 -> 456,94 -> 458,94 -> 458,86 -> 458,94 -> 460,94 -> 460,86 -> 460,94 -> 462,94 -> 462,89 -> 462,94 -> 464,94 -> 464,90 -> 464,94
|
|
||||||
479,36 -> 479,40 -> 477,40 -> 477,48 -> 489,48 -> 489,40 -> 483,40 -> 483,36
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
464,163 -> 464,158 -> 464,163 -> 466,163 -> 466,154 -> 466,163 -> 468,163 -> 468,153 -> 468,163 -> 470,163 -> 470,160 -> 470,163 -> 472,163 -> 472,162 -> 472,163 -> 474,163 -> 474,159 -> 474,163 -> 476,163 -> 476,155 -> 476,163 -> 478,163 -> 478,159 -> 478,163
|
|
||||||
473,150 -> 478,150
|
|
||||||
471,62 -> 476,62
|
|
||||||
484,28 -> 484,30 -> 481,30 -> 481,33 -> 488,33 -> 488,30 -> 487,30 -> 487,28
|
|
||||||
479,36 -> 479,40 -> 477,40 -> 477,48 -> 489,48 -> 489,40 -> 483,40 -> 483,36
|
|
||||||
478,109 -> 483,109
|
|
||||||
474,50 -> 474,51 -> 486,51
|
|
||||||
460,115 -> 460,117 -> 456,117 -> 456,125 -> 469,125 -> 469,117 -> 464,117 -> 464,115
|
|
@ -56,7 +56,7 @@ pub fn run() {
|
|||||||
.filter(|(_, pair)| pair.in_order())
|
.filter(|(_, pair)| pair.in_order())
|
||||||
.map(|(idx, _)| idx + 1)
|
.map(|(idx, _)| idx + 1)
|
||||||
.sum::<usize>();
|
.sum::<usize>();
|
||||||
println!("Day 13, Part 01: {:?}", p1);
|
println!("Day 12, Part 01: {:?}", p1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "part2")]
|
#[cfg(feature = "part2")]
|
||||||
@ -74,7 +74,7 @@ pub fn run() {
|
|||||||
let product =
|
let product =
|
||||||
(p2.binary_search(&div1).unwrap() + 1) * (p2.binary_search(&div2).unwrap() + 1);
|
(p2.binary_search(&div1).unwrap() + 1) * (p2.binary_search(&div2).unwrap() + 1);
|
||||||
|
|
||||||
println!("Day 13, Part 02: {:?}", product);
|
println!("Day 12, Part 02: {:?}", product);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
248
src/day14/mod.rs
248
src/day14/mod.rs
@ -1,248 +0,0 @@
|
|||||||
use crate::read;
|
|
||||||
use itertools::Itertools;
|
|
||||||
|
|
||||||
use std::{
|
|
||||||
collections::*,
|
|
||||||
hash::{Hash, Hasher},
|
|
||||||
};
|
|
||||||
#[derive(Debug, Clone, Eq)]
|
|
||||||
pub struct Coord {
|
|
||||||
pub x: i32,
|
|
||||||
pub y: usize,
|
|
||||||
pub is_rock: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Hash for Coord {
|
|
||||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
|
||||||
self.x.hash(state);
|
|
||||||
self.y.hash(state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PartialEq for Coord {
|
|
||||||
fn eq(&self, other: &Self) -> bool {
|
|
||||||
self.x == other.x && self.y == other.y
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Coord {
|
|
||||||
pub fn down_left(&self) -> Self {
|
|
||||||
Coord {
|
|
||||||
x: self.x - 1,
|
|
||||||
y: self.y + 1,
|
|
||||||
is_rock: self.is_rock,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn down_right(&self) -> Self {
|
|
||||||
Coord {
|
|
||||||
x: self.x + 1,
|
|
||||||
y: self.y + 1,
|
|
||||||
is_rock: self.is_rock,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn down(&self) -> Self {
|
|
||||||
Coord {
|
|
||||||
x: self.x,
|
|
||||||
y: self.y + 1,
|
|
||||||
is_rock: self.is_rock,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn run() {
|
|
||||||
let input = read("14");
|
|
||||||
let lines = input.lines();
|
|
||||||
let mut rocks: HashSet<Coord> = lines
|
|
||||||
.flat_map(|line| {
|
|
||||||
line.split(" -> ")
|
|
||||||
.map(|c| {
|
|
||||||
let nums = c.split_once(',').unwrap();
|
|
||||||
Coord {
|
|
||||||
x: nums.0.parse().unwrap(),
|
|
||||||
y: nums.1.parse().unwrap(),
|
|
||||||
is_rock: true,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.tuple_windows()
|
|
||||||
.flat_map(|(s, e)| {
|
|
||||||
let mut path = vec![];
|
|
||||||
for nx in s.x..=e.x {
|
|
||||||
for ny in s.y..=e.y {
|
|
||||||
path.push(Coord {
|
|
||||||
x: nx,
|
|
||||||
y: ny,
|
|
||||||
is_rock: true,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for nx in e.x..=s.x {
|
|
||||||
for ny in e.y..=s.y {
|
|
||||||
path.push(Coord {
|
|
||||||
x: nx,
|
|
||||||
y: ny,
|
|
||||||
is_rock: true,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
path
|
|
||||||
})
|
|
||||||
.collect_vec()
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
// Hide cursor
|
|
||||||
print!("\x1B[?25l");
|
|
||||||
#[cfg(feature = "part1")]
|
|
||||||
{
|
|
||||||
#[cfg(feature = "visualize")]
|
|
||||||
print!("\x1B[2J\x1B[1;1H");
|
|
||||||
|
|
||||||
let _count = p1(&mut rocks.clone());
|
|
||||||
|
|
||||||
#[cfg(not(feature = "visualize"))]
|
|
||||||
println!("Day 14, Part 01: {:?}", _count);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "part2")]
|
|
||||||
{
|
|
||||||
let floor = rocks.iter().map(|r| r.y).max().unwrap() + 2;
|
|
||||||
(-1000..=1000)
|
|
||||||
.map(|x| Coord {
|
|
||||||
x,
|
|
||||||
y: floor,
|
|
||||||
is_rock: true,
|
|
||||||
})
|
|
||||||
.for_each(|coord| {
|
|
||||||
rocks.insert(coord);
|
|
||||||
});
|
|
||||||
// Clear screen
|
|
||||||
#[cfg(feature = "visualize")]
|
|
||||||
print!("\x1B[2J\x1B[1;1H");
|
|
||||||
|
|
||||||
let _count = p2(&mut rocks);
|
|
||||||
|
|
||||||
#[cfg(not(feature = "visualize"))]
|
|
||||||
println!("Day 14, Part 02: {:?}", _count);
|
|
||||||
}
|
|
||||||
// Restore cursor
|
|
||||||
print!("\x1B[?25h");
|
|
||||||
}
|
|
||||||
|
|
||||||
fn p1(rocks: &mut HashSet<Coord>) -> usize {
|
|
||||||
let bottom = rocks.iter().map(|r| r.y).max().unwrap();
|
|
||||||
let sand_start = Coord {
|
|
||||||
x: 500,
|
|
||||||
y: 0,
|
|
||||||
is_rock: false,
|
|
||||||
};
|
|
||||||
let mut count_p1 = 0;
|
|
||||||
|
|
||||||
loop {
|
|
||||||
let mut sand = sand_start.clone();
|
|
||||||
|
|
||||||
loop {
|
|
||||||
if sand.y > bottom {
|
|
||||||
#[cfg(feature = "visualize")]
|
|
||||||
print(rocks, &sand, 1, count_p1);
|
|
||||||
return count_p1;
|
|
||||||
}
|
|
||||||
let d = sand.down();
|
|
||||||
let dl = sand.down_left();
|
|
||||||
let dr = sand.down_right();
|
|
||||||
|
|
||||||
if rocks.contains(&d) {
|
|
||||||
if rocks.contains(&dl) {
|
|
||||||
if rocks.contains(&dr) {
|
|
||||||
count_p1 += 1;
|
|
||||||
rocks.insert(sand.clone());
|
|
||||||
#[cfg(feature = "visualize")]
|
|
||||||
print(rocks, &sand, 1, count_p1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
sand = dr;
|
|
||||||
} else {
|
|
||||||
sand = dl;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sand = d;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn p2(rocks: &mut HashSet<Coord>) -> usize {
|
|
||||||
let sand_start = Coord {
|
|
||||||
x: 500,
|
|
||||||
y: 0,
|
|
||||||
is_rock: false,
|
|
||||||
};
|
|
||||||
let mut count_p2 = 0;
|
|
||||||
|
|
||||||
loop {
|
|
||||||
let mut sand = sand_start.clone();
|
|
||||||
if rocks.contains(&sand) {
|
|
||||||
#[cfg(feature = "visualize")]
|
|
||||||
print(rocks, &sand, 2, count_p2);
|
|
||||||
return count_p2;
|
|
||||||
}
|
|
||||||
|
|
||||||
loop {
|
|
||||||
let d = sand.down();
|
|
||||||
let dl = sand.down_left();
|
|
||||||
let dr = sand.down_right();
|
|
||||||
|
|
||||||
if rocks.contains(&d) {
|
|
||||||
if rocks.contains(&dl) {
|
|
||||||
if rocks.contains(&dr) {
|
|
||||||
count_p2 += 1;
|
|
||||||
rocks.insert(sand.clone());
|
|
||||||
#[cfg(feature = "visualize")]
|
|
||||||
print(rocks, &sand, 2, count_p2);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
sand = dr;
|
|
||||||
} else {
|
|
||||||
sand = dl;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sand = d;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "visualize")]
|
|
||||||
fn print(rocks: &HashSet<Coord>, sand: &Coord, part: i32, count: usize) {
|
|
||||||
let (min_y, min_x, max_y, max_x) = (10, 442, 182, 514);
|
|
||||||
|
|
||||||
if sand.x < min_x || sand.x > max_x || sand.y < min_y || sand.y > max_y {
|
|
||||||
return; // Don't render if not displayed
|
|
||||||
}
|
|
||||||
|
|
||||||
let status = format!("Part: {}, Count: {}", part, count);
|
|
||||||
let bounds = " ".repeat((max_y as usize) - (min_y as usize) - status.len());
|
|
||||||
let mut out = format!("{}{}\n", status, bounds);
|
|
||||||
|
|
||||||
for x in (min_x..=max_x).rev() {
|
|
||||||
for y in min_y..=max_y {
|
|
||||||
let testing = &Coord {
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
is_rock: false,
|
|
||||||
};
|
|
||||||
let c = match (sand == testing, rocks.get(testing)) {
|
|
||||||
(true, _) => "\x1B[31mo\x1B[0m",
|
|
||||||
(_, None) => " ",
|
|
||||||
(_, Some(coord)) if coord.is_rock => "#",
|
|
||||||
_ => "\x1B[33mo\x1B[0m",
|
|
||||||
};
|
|
||||||
out += c;
|
|
||||||
}
|
|
||||||
out += "\n";
|
|
||||||
}
|
|
||||||
out += &bounds;
|
|
||||||
// Clear terminal, position cursor at (1,1)
|
|
||||||
print!("\x1B[1;1H{}", out);
|
|
||||||
let ms = if part == 1 { 34 } else { 8 }; // Go faster in part 2, takes too long otherwise
|
|
||||||
std::thread::sleep(std::time::Duration::from_millis(ms));
|
|
||||||
}
|
|
@ -14,7 +14,6 @@ mod day10;
|
|||||||
mod day11;
|
mod day11;
|
||||||
mod day12;
|
mod day12;
|
||||||
mod day13;
|
mod day13;
|
||||||
mod day14;
|
|
||||||
mod puter;
|
mod puter;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@ -59,9 +58,6 @@ fn main() {
|
|||||||
if cfg!(feature = "day13") || (cfg!(feature = "today") && today == 13) {
|
if cfg!(feature = "day13") || (cfg!(feature = "today") && today == 13) {
|
||||||
day13::run();
|
day13::run();
|
||||||
}
|
}
|
||||||
if cfg!(feature = "day14") || (cfg!(feature = "today") && today == 14) {
|
|
||||||
day14::run();
|
|
||||||
}
|
|
||||||
println!("Finished, time taken: {:?}", now.elapsed())
|
println!("Finished, time taken: {:?}", now.elapsed())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user