Compare commits
No commits in common. "f5e7c2e487acf9c4b439122fbc4885389f8e2aa5" and "bbc271e001956081acb5ef3ee23e15df4730143f" have entirely different histories.
f5e7c2e487
...
bbc271e001
140
2023/.inputs/11
140
2023/.inputs/11
|
@ -1,140 +0,0 @@
|
|||
........................................#...........................#..........................................#............................
|
||||
.................................#.....................#...........................#.................#..............................#.......
|
||||
............#................................#..................#...........................................................................
|
||||
..#.........................................................................................................................................
|
||||
................#.........................................................#..............#..................#.......#.......................
|
||||
......................#....................................................................................................................#
|
||||
......................................#.........................................................#.............................#.............
|
||||
.......................................................................#................................#..........................#........
|
||||
.......#.................................................#..................................................................................
|
||||
...............#................................#...........................................................................................
|
||||
........................................#............#.........................#...........#..................#.............................
|
||||
.............................#......................................................................................#.................#.....
|
||||
......................................................................#..............#.....................................................#
|
||||
.......................#................................#.....#............................................#.............#..................
|
||||
.......#..................................#......................................................#............................#.............
|
||||
.#..........#..................#............................................................................................................
|
||||
.....................................#.................................................................................................#....
|
||||
............................................................#...........................#..........................#.............#..........
|
||||
.................#.......#...............................................#.......#..........................................................
|
||||
..........#.................................................................................................#...............................
|
||||
..#............................................................................................#......#................#..................#.
|
||||
................................#.................#..........................................................................#.......#......
|
||||
.......................................#.....#......................#.......................................................................
|
||||
................#...........................................................................................................................
|
||||
.....#....................#.............................................................................#.................#.................
|
||||
........................................................................#....................#..............................................
|
||||
.........#........................#..................................................................................#......................
|
||||
..............#..................................#................#...............#........................#...........................#....
|
||||
......................................#...............#.....................................................................................
|
||||
.......................................................................................#....................................................
|
||||
.#.....#.......................................................#..............#....................................#........................
|
||||
................#.........#...................................................................#..................................#..........
|
||||
..................................#.........#...............................................................................................
|
||||
.....................................................................................#..................#...................................
|
||||
.........................................................................#.......................#..........................................
|
||||
#........................................#.....#......#.........................................................#...........................
|
||||
..............#..............................................#...........................................................#..............#...
|
||||
..............................................................................#..........#..................................................
|
||||
..................................................................#.........................................................................
|
||||
.....#...............#............#................................................#........................#........................#......
|
||||
...........................#............................#..................#....................#...........................#...............
|
||||
..........#................................................................................#...........................#...................#
|
||||
........................................#...................................................................................................
|
||||
.....................................................................#....................................#.................................
|
||||
.............#..................#..............................................................................#..........#.................
|
||||
.....................................#..........................................#...........................................................
|
||||
..................................................#.......#.........................................................#...................#...
|
||||
....#.......................................................................................................................................
|
||||
...........#............................................................................................#...................................
|
||||
..............................................#.....................................#......#......#..................................#......
|
||||
...................................#.......................................................................................................#
|
||||
..........................#...........................................#......................................#...............#..............
|
||||
........................................................#.......#.......................#...................................................
|
||||
......#.........#...............................................................#...................#...................................#...
|
||||
.........................................#................................................................#.................................
|
||||
#......................#.....#..............................................................#...............................................
|
||||
............................................................................................................................................
|
||||
...........#.........................................................................#........................#.............................
|
||||
.......................................#.........#.................#...................................................................#....
|
||||
...#..............#.........................................#..................#...................#........................................
|
||||
..........................................................................#........................................#........................
|
||||
....................................................................................................................................#.......
|
||||
.....................#.......#.............#...................................................#............................................
|
||||
...................................#..................................................................#......#..........#..................#
|
||||
.......#.......................................#.........#...........#............#...........................................#.............
|
||||
............#...............................................................................................................................
|
||||
.........................#..............................................................#.........#.........................................
|
||||
.....................................................................................................................#......................
|
||||
................#..........................................................#............................................................#...
|
||||
#...........................#............#..................#.....#............................................#............................
|
||||
.................................#..........................................................................................................
|
||||
.......................................................#.................................#.......#......#..........#......#.................
|
||||
..............#..........#.....................#.....................#........#.....#.......................................................
|
||||
............................................................................................................................................
|
||||
....................................#...........................................................................#..............#............
|
||||
..........#..........#.......#............#...................#...........................................#..........................#......
|
||||
........................................................................#...................................................................
|
||||
...............#..............................................................................#.....................#.......................
|
||||
.........................#...........................................................................#......................................
|
||||
...................................#............#.................................................................................#.....#...
|
||||
.........................................................#....................#.......#.....................................................
|
||||
...........................................#..........................#.....................................................................
|
||||
....#......#...........#.............................................................................................#.......#..............
|
||||
..............................#..............................................................#........#.............................#.......
|
||||
.....................................................#...................................................................................#..
|
||||
.........................................................................#..............#...................................................
|
||||
............................................................................................................................................
|
||||
...................................#......#.....................................................................#................#..........
|
||||
................................................#...........................................................................................
|
||||
......#.....#......#........................................................#...............................................................
|
||||
........................#......#...........................#...........#.....................#................................#.............
|
||||
....................................................#............#......................#....................#..............................
|
||||
............................................................................................................................................
|
||||
........#......#.....#......#...........................................................................#..............................#....
|
||||
...#....................................#..............#....................................................................................
|
||||
..............................................................#..................#..............................#.................#.........
|
||||
.........................................................................................................................#.................#
|
||||
..........................................................#.....................................#...........................................
|
||||
................#..................#.......#..............................#...........................#.....................................
|
||||
.......................................................................................#...........................#........................
|
||||
...............................................#............................................................................................
|
||||
........................#....................................................................................#...........................#..
|
||||
.....#........................#.....................#..............#........................................................................
|
||||
#...................................#.....................................................................................#.................
|
||||
...........................................................#....................#....................................#......................
|
||||
...................#......#..................#......................................................................................#.......
|
||||
......................................................................................#...................#.................................
|
||||
.........#.......................................................................................#..........................................
|
||||
.....................................#.......................#......#......#.............................................#..................
|
||||
...............................#................................................................................#.......................#...
|
||||
............................................................................................................................................
|
||||
..................#.......................................#.................................................................................
|
||||
....#...................................#............#..................#...........................#...............................#.......
|
||||
......................................................................................#............................#......#.................
|
||||
......................#......................................#..............................................................................
|
||||
.............................................#................................#.........................#......................#............
|
||||
..........#........................................................#.......................#..........................#................#....
|
||||
.............................#.....#........................................................................................................
|
||||
..#..............................................#.....................................#..........#.............#...........................
|
||||
..............#....................................................................................................................#........
|
||||
....................#.....................................................................................#.................................
|
||||
................................#.......................................#...................................................................
|
||||
.........................#...................#...........#..................................................................................
|
||||
...................................................................#......................................................#.................
|
||||
.............#...............#....................................................................................................#.........
|
||||
.......................................#...............................................................#........#...........................
|
||||
.....#............................................#............#.............................#.......................#....................#.
|
||||
........................................................#...........................#.........................................#.............
|
||||
...........................................................................#................................................................
|
||||
.#...................#..............#.....................................................#................#................................
|
||||
..............#..........................#..........................#...........#...........................................................
|
||||
......#......................#.............................#..................................#........#............#.......................
|
||||
........................................................................#...................................................................
|
||||
.................................................#..........................................................................#...............
|
||||
.......................#........................................#...........................................................................
|
||||
....#......#.........................................#.............................................#..............................#.........
|
||||
....................................................................................#....................................................#..
|
||||
...........................#......#.....#...................#............#.................#.......................#........................
|
||||
........................................................................................................................#...................
|
||||
.......#...............................................................................#.................#..................................
|
1000
2023/.inputs/12
1000
2023/.inputs/12
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
300
2023/.inputs/24
300
2023/.inputs/24
|
@ -1,300 +0,0 @@
|
|||
291493672529314, 259618209733833, 379287136024123 @ -9, 119, -272
|
||||
308409248682955, 156803514643857, 424989308414284 @ -78, 236, -255
|
||||
195379943194796, 213851381371727, 355270583377422 @ 25, 14, -15
|
||||
297329579961934, 122004770593749, 344090716183747 @ -87, 185, -36
|
||||
295385164557865, 339802914312939, 293784344149228 @ 64, 10, -211
|
||||
155809034672704, 276962605708219, 308527141561896 @ 65, -70, 49
|
||||
379374976062190, 523822522311015, 436295585524315 @ -208, -433, -263
|
||||
247918644285258, 312143526467359, 112155607012071 @ 189, 75, 390
|
||||
342617287456519, 397354826185853, 200879077842813 @ 20, -132, -32
|
||||
378033289852195, 344304802155174, 277151328831253 @ -244, 249, -576
|
||||
329376422447230, 354844965599343, 218863978047367 @ -8, 17, -10
|
||||
244732151114366, 241023555875268, 299614412087890 @ 91, 151, -79
|
||||
229675166786762, 272496792240003, 403388647505619 @ -27, -68, -59
|
||||
342641695024690, 405074098532187, 192422793097927 @ -23, -198, 69
|
||||
307790269475010, 287974903224075, 133983400495495 @ 157, 448, 404
|
||||
338204078494098, 220756564653275, 207895864790871 @ -119, 198, 127
|
||||
256854809852143, 151282473118095, 430813946794295 @ -82, 22, -38
|
||||
310795589424306, 300273918793951, 561603474537271 @ -105, -69, -358
|
||||
216689910377710, 176014643762749, 302037819898693 @ 17, 89, 35
|
||||
174016187301220, 213432519760749, 356227705342783 @ 20, -17, 14
|
||||
242219599681270, 198095041632474, 234812336636788 @ 123, 291, 53
|
||||
363124893146512, 442652496410205, 252364287745435 @ -131, -484, -450
|
||||
351213223671270, 362935312834443, 228742908818179 @ -128, -74, 17
|
||||
344214173972434, 388335215576475, 186571894620823 @ 103, 14, 8
|
||||
349598760694057, 366914630609265, 194339201768647 @ 50, 264, -86
|
||||
341614994957750, 190062425474889, 303119964664158 @ -149, 100, 15
|
||||
222157711994666, 237412175293295, 408224324533627 @ -39, -51, -31
|
||||
271757703912044, 464616309219749, 332689336082035 @ -74, -295, 20
|
||||
250628766803800, 168532696620157, 208267299142314 @ 17, 192, 147
|
||||
317020112206914, 277809818286032, 407863381711725 @ 15, 281, -708
|
||||
139674271448922, 306849236561795, 263391082181071 @ 46, -123, 119
|
||||
258096215553470, 289814915480794, 288168350695608 @ 27, 5, -17
|
||||
363641445693300, 230988678372095, 207280361486617 @ -183, 14, 164
|
||||
395475230137604, 286569114155087, 286374068821828 @ -227, -58, 53
|
||||
290926236744178, 297457255748751, 294347374053647 @ -25, 7, -48
|
||||
316790682490495, 379717245881004, 409858098674218 @ -110, -183, -153
|
||||
334822390551460, 382851207647739, 198921551768833 @ 122, 10, -55
|
||||
225775609455410, 89113641823329, 422613356792828 @ -33, 124, -63
|
||||
70307326837874, 123895406185359, 143541754272355 @ 295, 235, 257
|
||||
162794878008996, 173652810519316, 495533087752947 @ 33, 27, -138
|
||||
258705632635810, 80655227230039, 157840377597263 @ 107, 651, 244
|
||||
300344409299646, 183646111251361, 110595965169963 @ -69, 168, 318
|
||||
213975778288718, 193764624265807, 340491818490139 @ -35, -12, 44
|
||||
254365196823130, 485963685578899, 125027966220903 @ -34, -333, 276
|
||||
185119816803022, 159164853646062, 332181755689210 @ 43, 89, 9
|
||||
312682991980546, 296682404141739, 277578830074327 @ -52, 45, -48
|
||||
334063201619320, 349082279167895, 224872082527799 @ -28, 44, -38
|
||||
146865332069684, 118672354368894, 388923136846080 @ 49, 85, -21
|
||||
241545018449890, 175575930639279, 238105656690763 @ 119, 336, 48
|
||||
242998473052770, 260842386471899, 353094911438503 @ -15, -22, -40
|
||||
298049374841860, 302953880934789, 280519903072663 @ -100, -93, 74
|
||||
241726047709066, 396700833512351, 470178566023441 @ -61, -216, -91
|
||||
143251881420009, 227630340282400, 400202239949349 @ 40, -43, -20
|
||||
181693698716464, 371335237710474, 279589747245676 @ 25, -185, 89
|
||||
199776083341870, 424271723369277, 330637576913863 @ 17, -247, 18
|
||||
243099685892272, 278790917182863, 307263401526238 @ 13, -18, -7
|
||||
311573992428958, 339563241504477, 421253358816085 @ -115, -137, -115
|
||||
195139968654514, 399321212524987, 273718733311575 @ 29, -216, 84
|
||||
168652905324066, 42922523093201, 136328134641529 @ 79, 264, 260
|
||||
332492502844023, 232541271110323, 268437348702505 @ -122, 98, 32
|
||||
229871163504332, 315811780311601, 273027152212607 @ -11, -108, 82
|
||||
364596076994326, 405392531793979, 169077695698471 @ -142, -190, 206
|
||||
368014471738282, 411404609914515, 359308233522031 @ -187, -232, -168
|
||||
336734676406219, 363019597051899, 200746200694471 @ 154, 250, -118
|
||||
240100311481720, 182734033187437, 419841535721491 @ -28, 57, -100
|
||||
101659208850650, 143063258042099, 354417480491543 @ 78, 39, 30
|
||||
316608300364190, 327231766296979, 349926929027083 @ -108, -100, -67
|
||||
175882437786106, 207986866149867, 48272619812743 @ 314, 296, 528
|
||||
288200702096579, 134237752092030, 431007956556798 @ -50, 247, -237
|
||||
187799273615390, 251576716767794, 225064328926248 @ -5, -67, 159
|
||||
345031129381395, 398704983119649, 192035012621928 @ -20, -152, 55
|
||||
240614617391002, 436092108670983, 319023865196143 @ 5, -269, -12
|
||||
127420991862727, 123135422678220, 57674678556796 @ 186, 217, 389
|
||||
290291345885074, 335338153703259, 336486368450743 @ -64, -110, -52
|
||||
345222677707330, 353264220909579, 228080629830103 @ -55, 76, -106
|
||||
120731315974643, 121922962460939, 352925773636740 @ 154, 170, -39
|
||||
246457027018171, 290587724108904, 299967181084042 @ 124, 75, -119
|
||||
339299631313000, 347877395943849, 291783005889913 @ -156, -157, 73
|
||||
186318069122314, 321229647672967, 378293022619411 @ 41, -117, -49
|
||||
275970025052456, 254003877380129, 60447875537872 @ 129, 300, 581
|
||||
343777030173730, 387603653627809, 190127595920333 @ 23, -49, 39
|
||||
326625954078592, 221492115488361, 224589119605135 @ 28, 711, -66
|
||||
330727351246045, 382460793638208, 258529227193591 @ 62, -53, -358
|
||||
207849930952126, 217444078290659, 375450280446241 @ -7, -10, -19
|
||||
330413601325446, 354867024118919, 215181365719423 @ -14, 15, 8
|
||||
273539593790110, 527357437168179, 200706886651201 @ -93, -350, 184
|
||||
371305621051250, 406992413205499, 294687273096023 @ -194, -219, -191
|
||||
238331445291794, 405888543233043, 282145027415895 @ -17, -224, 66
|
||||
164563908487373, 245446713465540, 386623255996042 @ 36, -47, -25
|
||||
352203648341690, 391410023508659, 182689032755383 @ -14, -49, 74
|
||||
196332283252558, 239566376209863, 435769782659827 @ -10, -51, -63
|
||||
332262603162525, 477986526034049, 423864050467268 @ -146, -312, -93
|
||||
336025171108531, 228814354002627, 246100455575479 @ -136, 66, 90
|
||||
202554996256310, 144622073487839, 323843280557063 @ 70, 185, -26
|
||||
231583793158585, 274098148570719, 431523663253009 @ 32, -10, -208
|
||||
194039870771935, 220086273278949, 348459395283913 @ 32, 12, -12
|
||||
350978977183535, 297706532696529, 401295634941628 @ -128, 136, -541
|
||||
239988722464295, 366388864576004, 306003658418008 @ 54, -147, -43
|
||||
225592715561806, 116755915783527, 495439611678523 @ -40, 79, -127
|
||||
295163518502294, 256302372227871, 354092662486808 @ -69, 22, -87
|
||||
238762928861436, 104277648663616, 429257920986946 @ 45, 321, -253
|
||||
335646527589942, 267411223903873, 319409116881496 @ -149, -52, 29
|
||||
308988592776658, 321707797031691, 264887445984871 @ -49, -24, -8
|
||||
325655810895730, 314119726351931, 285885347173367 @ -88, -7, -56
|
||||
228513865324464, 407705823788478, 98135183804964 @ -35, -227, 295
|
||||
221021819586370, 258975000763563, 6625466634103 @ 12, -23, 438
|
||||
320402078029900, 178059278800419, 383059738044013 @ -139, 18, -12
|
||||
336426609877986, 385743547933251, 217242942544247 @ 13, -83, -78
|
||||
59321749403267, 132811665802238, 377024432495280 @ 118, 47, 9
|
||||
269221169152992, 144282527780641, 105622925246739 @ -32, 191, 316
|
||||
322565467760320, 359196040673604, 209572790080603 @ 33, 9, 22
|
||||
343911256200550, 402887944644989, 174632354525853 @ 41, -165, 157
|
||||
353126168973970, 405273919582935, 172039271954023 @ -33, -184, 178
|
||||
326846182468312, 226025647156965, 371867791604191 @ -142, -17, -18
|
||||
372763417186486, 399946994118006, 284888654682571 @ -205, -159, -578
|
||||
238591627755922, 274330093596843, 314686772435383 @ 95, 66, -102
|
||||
350425162332062, 389369983875975, 179065186259203 @ 156, 127, 23
|
||||
195114071161846, 225361264742211, 333450165595939 @ 18, -8, 19
|
||||
200946455709850, 426471282348513, 438704787028177 @ -13, -247, -69
|
||||
182130635710210, 211838995770339, 366144270406063 @ 21, -5, -7
|
||||
337674626273200, 379119144804627, 124545588880084 @ 37, -14, 515
|
||||
309119233707144, 345457984349776, 176480897161028 @ 189, 171, 163
|
||||
341093069492194, 215426787755718, 543835877405731 @ -145, 83, -386
|
||||
406947563701153, 361064263636829, 506655770864396 @ -244, -160, -263
|
||||
138744154165460, 337520178393783, 264760081146471 @ 132, -128, 82
|
||||
142884697542590, 14953861507879, 301051396847183 @ 36, 167, 84
|
||||
62428000394402, 121573669531131, 285948127754263 @ 198, 136, 68
|
||||
301235858359754, 290689686950351, 264197704796073 @ -45, 24, 13
|
||||
69052754947310, 235657014607714, 418845817526938 @ 99, -61, -25
|
||||
276020997007381, 154938920738092, 289050261086728 @ -64, 117, 53
|
||||
340992490662874, 283734631397387, 247161636223296 @ -121, 74, 27
|
||||
125358983559838, 388966759539897, 442450312355365 @ 59, -208, -64
|
||||
247111468608036, 298684579131926, 247459506399721 @ 21, -37, 80
|
||||
269799925928330, 346080114851941, 192870832715433 @ -53, -141, 183
|
||||
21485022052306, 61917371383851, 14153560016647 @ 151, 113, 369
|
||||
168759694289722, 235235657051967, 394018487592739 @ 91, 16, -100
|
||||
346771701017358, 379090812136831, 195343843369543 @ -36, -27, 38
|
||||
364922844998242, 405449109473563, 193296414410007 @ -100, -154, -176
|
||||
286294122958642, 382870439083131, 153541929882391 @ -30, -177, 245
|
||||
144541456321322, 259959262174823, 159041330065209 @ 99, -36, 229
|
||||
169067477683714, 204758213310363, 221220702084535 @ 78, 46, 146
|
||||
201146928516970, 172345662796719, 265025819376463 @ 51, 112, 78
|
||||
122849126629390, 139266589388763, 133073803140829 @ 217, 218, 275
|
||||
376610203535095, 524590501174134, 540682746641333 @ -202, -413, -380
|
||||
155396067983527, 135079411201904, 346771075414519 @ 38, 65, 26
|
||||
367025720824960, 399429967429654, 200118770338033 @ -163, -147, -28
|
||||
188860323625695, 280509742808449, 228889209496588 @ 208, 56, 83
|
||||
370994826025810, 516943861319289, 277158295638088 @ -193, -544, -105
|
||||
360132758113355, 400823411389429, 179526450589128 @ -14, -72, 21
|
||||
317723494997245, 403424754416019, 123033781749148 @ -10, -206, 371
|
||||
231857064371422, 328033566747723, 258488840035627 @ 84, -66, 37
|
||||
430250735327386, 317628879447345, 463851654198943 @ -269, -111, -162
|
||||
197095573209612, 386367210346765, 255360476476089 @ 118, -187, 61
|
||||
237963736351605, 265388533967262, 253761264381393 @ 162, 157, -12
|
||||
363368985840202, 288715458856678, 222859449036721 @ -169, 153, 44
|
||||
336715322008593, 367196238729037, 205425778003914 @ 18, 36, -15
|
||||
172536009897664, 162754568611140, 345184409520034 @ 45, 67, 5
|
||||
343839846989266, 277316030970699, 191154063170167 @ -41, 515, 86
|
||||
364839061293440, 370333200866079, 202280142884213 @ -146, 76, -47
|
||||
205180494328024, 181302108773882, 352998887224071 @ -7, 27, 10
|
||||
253114332607887, 252973452511066, 373269612984083 @ -44, -31, -42
|
||||
260563693507432, 370218908840841, 227275158133861 @ 90, -127, 65
|
||||
211632379587750, 229189261429669, 267702494391083 @ 33, 27, 76
|
||||
246925439769358, 403237078327653, 341438050336159 @ 101, -213, -194
|
||||
314011896591392, 359513784621587, 220682410853239 @ 13, -46, 26
|
||||
192947734147345, 343204650565017, 232772451195853 @ 162, -96, 88
|
||||
400010012688090, 317666186832694, 389849162657458 @ -249, -51, -211
|
||||
344654321611729, 249175343587025, 521971621625971 @ -160, -28, -226
|
||||
334131140547988, 223459610704956, 530065014889646 @ -151, -17, -195
|
||||
271802467841374, 312721714818849, 474166669352047 @ -61, -100, -190
|
||||
346585589783366, 394172810646086, 185879034872896 @ 43, -73, 41
|
||||
348026275676730, 387630874942399, 214450542419923 @ -71, -109, -31
|
||||
338259203280741, 352302596311566, 118072221394886 @ 96, 283, 655
|
||||
293750362255726, 291573521915979, 78443880264043 @ 41, 130, 488
|
||||
327898963343795, 191014039376899, 482563685839609 @ -138, 50, -184
|
||||
337166009346768, 391869416398867, 241936328612339 @ 150, -42, -536
|
||||
318801805101604, 313350452906991, 260512311617500 @ -79, -18, 15
|
||||
363665586589577, 276485965150536, 560019564776630 @ -182, -29, -371
|
||||
283693315753962, 303343268529299, 260638812037467 @ 19, 30, -8
|
||||
152531270776150, 182584879439265, 364189307415757 @ 17, -11, 29
|
||||
331886310340210, 367196248652751, 203943027278671 @ 7, -9, 32
|
||||
293670081918730, 338393014464039, 238074080259283 @ 11, -40, 32
|
||||
340517885909575, 292220098034574, 263908972058479 @ 12, 565, -430
|
||||
215180009575150, 159662811481959, 432250918416853 @ 109, 256, -295
|
||||
111353526905854, 158069012352691, 414700573118491 @ 56, 12, -19
|
||||
342149249853468, 379057271341489, 449130014242836 @ -147, -180, -231
|
||||
164800679784870, 110492400316699, 384075961244050 @ 27, 90, -13
|
||||
194218348327784, 317435294782571, 377991167649959 @ 96, -78, -126
|
||||
265459439896876, 393130510464227, 448999804034887 @ -22, -202, -238
|
||||
342485301424762, 306126318497295, 448916100464563 @ -155, -91, -157
|
||||
285930806205610, 329883886388883, 254526439062823 @ 32, -17, -12
|
||||
222718267472544, 137706718628633, 419538567330529 @ -50, 33, -25
|
||||
355490264524645, 367186320360879, 230373412357398 @ -94, 46, -183
|
||||
349202081810142, 291246578412431, 223213156752343 @ -99, 284, -22
|
||||
318303996716125, 368813135346114, 214100266906048 @ -22, -95, 67
|
||||
359828018775610, 334476869183979, 315718417210383 @ -178, -128, 19
|
||||
310093135954874, 392333711576675, 96139866022847 @ 154, -127, 625
|
||||
332723387475285, 384153175982064, 182503117349788 @ 30, -77, 131
|
||||
360194406570013, 349779100748340, 127043801020300 @ -92, 337, 597
|
||||
288773776244596, 318828306006264, 110180186804176 @ 9, -5, 359
|
||||
123467355045370, 135168256391259, 212490220185583 @ 66, 58, 171
|
||||
301530401246642, 315308990894907, 147997344598679 @ 208, 319, 331
|
||||
229677118804378, 304422878069265, 134766211371802 @ -25, -104, 257
|
||||
335208657102058, 429374769368011, 181336018815583 @ -76, -292, 173
|
||||
153126745187446, 361996029410147, 361232623991831 @ 176, -148, -110
|
||||
307543544558028, 310836622716592, 261806684128363 @ 9, 87, -82
|
||||
305446483268280, 95007956275577, 26450381518969 @ -23, 588, 584
|
||||
308195050787890, 376020805378859, 151124547509703 @ 101, -69, 295
|
||||
181744775932850, 416582355770979, 374307216760003 @ -9, -236, 17
|
||||
323567364535098, 398843484951019, 184056042477469 @ -29, -190, 161
|
||||
239625227411666, 460421176139587, 263860052129839 @ -17, -297, 89
|
||||
290391850460116, 123822800918427, 390474163576439 @ -112, 58, -6
|
||||
274274367393128, 222419281142943, 357607375004572 @ -51, 46, -61
|
||||
355957759423346, 403839841977963, 174439429446519 @ 61, -119, 102
|
||||
92872979090114, 178033036374593, 184039848628045 @ 111, 24, 200
|
||||
97741768910238, 219237917005243, 481345580120351 @ 70, -46, -84
|
||||
219237852779083, 293460830478687, 286842878713720 @ 134, 22, -39
|
||||
165873248906086, 48723353419159, 391521269184095 @ 14, 135, -8
|
||||
120293816868514, 163820001937179, 368954885538727 @ 51, 10, 22
|
||||
337142332745596, 160547517607569, 190677777707717 @ -130, 235, 175
|
||||
359903966491060, 336058036164375, 214952259623515 @ -68, 608, -316
|
||||
278704085129049, 332251057343106, 274876653327010 @ 16, -53, -25
|
||||
341902521147010, 290550862384683, 187354875008647 @ -118, 79, 167
|
||||
266132989640850, 85667158930666, 151187445755913 @ 127, 761, 268
|
||||
226481708603128, 264873125336255, 125550562908581 @ -52, -88, 259
|
||||
358194067651922, 464014334175995, 240376420942551 @ -161, -364, 36
|
||||
255918918476926, 464443215434815, 151073769691223 @ 86, -361, 258
|
||||
326934575138296, 227642710359355, 187154441418847 @ -139, -6, 194
|
||||
355023487027664, 380684157575495, 166279629390635 @ -20, 92, 232
|
||||
342708878447974, 365712377127771, 208254982911037 @ -31, 26, -15
|
||||
275992353396058, 254199039060579, 312307418341759 @ -44, 15, -9
|
||||
275807125436405, 450328581313154, 241879925570534 @ -38, -295, 97
|
||||
355105298525698, 461358532374587, 174255797829999 @ -67, -634, 165
|
||||
127304870812111, 107206164704598, 387938601844705 @ 110, 147, -56
|
||||
191211556791145, 383063844291897, 383818462516984 @ 162, -176, -209
|
||||
270008506829071, 306985556216215, 270509853345710 @ 14, -18, 7
|
||||
254859649784435, 279691564762489, 252917958138213 @ 22, 12, 60
|
||||
301554869022495, 278690002932659, 270658229427943 @ -96, -46, 74
|
||||
292995486711810, 278124279008795, 299858987167607 @ -68, -18, 6
|
||||
170086256676901, 192032278758264, 399539006601156 @ 14, -5, -21
|
||||
363343862472525, 462708884039439, 206020620737318 @ -114, -770, -179
|
||||
199767932051315, 231641229533994, 324467235209543 @ 34, 7, 10
|
||||
185698250335984, 338189264810958, 295966585334407 @ 61, -131, 42
|
||||
355845863753410, 453333218257139, 189979947718988 @ -145, -366, 147
|
||||
263693411545060, 382941996378267, 552998788505917 @ -68, -198, -231
|
||||
357882206779336, 415793203698444, 221686125924646 @ -59, -285, -335
|
||||
58482797244400, 283357087767651, 380695065023959 @ 112, -106, 10
|
||||
329961895718995, 370045430297334, 264316414918513 @ -70, -109, -72
|
||||
248082141022960, 238905086388339, 221882363855113 @ 22, 70, 123
|
||||
209808257975519, 379817673897890, 358895541155856 @ 160, -163, -201
|
||||
275001200474245, 405709429886895, 479845248771052 @ 52, -218, -579
|
||||
215447048650693, 286084440368310, 308066874352459 @ 86, -7, -34
|
||||
243779481735825, 367408788584499, 186923174146441 @ 162, -110, 164
|
||||
22569070313760, 307206567552909, 336933487682743 @ 202, -113, 26
|
||||
209855802119430, 266771395093679, 336731626000023 @ 28, -33, -14
|
||||
152285478372850, 300465378313851, 147474491960791 @ 177, -44, 252
|
||||
317340728176012, 355422381584551, 214819746096109 @ 8, -24, 41
|
||||
218567618087469, 163809178763437, 274368240641493 @ -36, 24, 108
|
||||
263714419323370, 253066561988427, 236112367528733 @ -13, 34, 103
|
||||
318025834942906, 209033552746731, 422873100748303 @ -82, 192, -317
|
||||
287128402777502, 364357342250719, 245621206783419 @ 153, -40, -104
|
||||
248072289852880, 330038730987654, 167572107691063 @ 41, -77, 218
|
||||
189081821987410, 458283001653339, 444430934012663 @ 35, -290, -129
|
||||
232689117806470, 338009512571859, 347647996245103 @ -44, -152, 24
|
||||
286524941660398, 398498738895345, 392464150253677 @ 41, -197, -405
|
||||
289581406826830, 404120121547236, 281550894569635 @ 27, -213, -90
|
||||
238710152421370, 355292544483489, 351300821030563 @ 23, -140, -82
|
||||
356304901805038, 320639399358399, 251359082876207 @ -166, -65, 64
|
||||
299258143464579, 329939012733995, 241161767292621 @ 78, 74, -60
|
||||
391208392886390, 342636257835159, 562331178144743 @ -227, -116, -446
|
||||
347915406224905, 378141743469594, 140106553810348 @ 28, 79, 481
|
||||
407508472819681, 342065101666042, 327670405171882 @ -232, -157, 47
|
||||
68256701718408, 52950691008669, 156980686432495 @ 150, 175, 230
|
||||
241577764898038, 246780391542179, 295501616392079 @ -19, -10, 46
|
||||
335640266041963, 366897853889835, 320775200954400 @ -154, -182, 49
|
||||
305567299016286, 304550890065435, 234102345829961 @ -15, 58, 37
|
||||
255844102411545, 236416893288454, 223372017812513 @ 34, 113, 108
|
||||
359486749992297, 388233343083006, 180756857053962 @ -42, 61, 45
|
||||
256997657349820, 240682040678865, 191215964897935 @ -58, -29, 190
|
||||
337489509798277, 387749886514020, 191762667954925 @ 48, -67, 44
|
||||
308731611545420, 173487498189829, 444926426740073 @ -39, 356, -468
|
||||
405934168591492, 433302451890441, 495881447316868 @ -251, -268, -327
|
||||
342562531851970, 329852991659459, 146721758630247 @ -133, -60, 262
|
||||
201459697721034, 226176452581883, 409625152149327 @ -20, -42, -29
|
||||
342190286602489, 382361323151712, 199647031503058 @ 36, -7, -37
|
||||
295823889919724, 237024181773491, 238902193047203 @ -56, 86, 88
|
||||
313871022274978, 350907196244889, 236256681248611 @ -25, -55, 16
|
||||
359840463350408, 352014789184705, 312578822471289 @ -159, -52, -224
|
||||
63266051000177, 144958221562269, 401563955793621 @ 120, 40, -20
|
||||
289363911332530, 4297357886271, 201584988813263 @ 47, 964, 118
|
||||
139623875169600, 365121525551783, 489522324414385 @ 42, -184, -109
|
||||
285387003808144, 234159759801909, 194429463680919 @ -91, -20, 186
|
||||
312338296007416, 230717344302005, 321196352977333 @ -67, 156, -112
|
||||
109900900224955, 79824552813534, 271811127497488 @ 70, 103, 113
|
||||
299767049618653, 243317066662260, 262990449670462 @ -34, 143, 5
|
||||
336430697131966, 368621759709731, 209166228902299 @ -16, -16, 5
|
||||
391878841792417, 405438773779004, 446025651245823 @ -214, -225, -62
|
||||
382391688500786, 283246166659291, 375114971709047 @ -212, -18, -128
|
||||
307671490544586, 326499940532387, 232143193625119 @ 10, 39, 11
|
||||
369326492413668, 408128175647671, 194002024388681 @ -174, -204, -83
|
|
@ -28,11 +28,7 @@ library
|
|||
Day08
|
||||
Day09
|
||||
Day10
|
||||
Day11
|
||||
Day12
|
||||
Day15
|
||||
Day20
|
||||
Day24
|
||||
|
||||
other-modules:
|
||||
Misc
|
||||
|
@ -43,8 +39,7 @@ library
|
|||
base ^>=4.17.2.0,
|
||||
text ^>=2.1,
|
||||
megaparsec ^>=9.6,
|
||||
microlens ^>=0.4.13,
|
||||
hmatrix ^>=0.20.2
|
||||
microlens ^>=0.4.13
|
||||
|
||||
default-language: Haskell2010
|
||||
|
||||
|
|
|
@ -12,10 +12,7 @@ import Utils (readInput)
|
|||
--import qualified Day08
|
||||
--import qualified Day09
|
||||
--import qualified Day10
|
||||
--import qualified Day11
|
||||
--import qualified Day12
|
||||
--import qualified Day15
|
||||
import qualified Day24
|
||||
import qualified Day15
|
||||
|
||||
|
||||
run :: (Show b, Show c)
|
||||
|
@ -45,7 +42,4 @@ main = do
|
|||
--run 08 Day08.parse Day08.solveA Day08.solveB
|
||||
--run 09 Day09.parse Day09.solveA Day09.solveB
|
||||
--run 10 Day10.parse Day10.solveA Day10.solveB
|
||||
--run 11 Day11.parse Day11.solveA Day11.solveB
|
||||
--run 12 Day12.parse Day12.solveA Day12.solveB
|
||||
--run 15 Day15.parse Day15.solveA Day15.solveB
|
||||
run 24 Day24.parse Day24.solveA Day24.solveB
|
||||
run 15 Day15.parse Day15.solveA Day15.solveB
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module Day11 (parse, solveA, solveB) where
|
||||
|
||||
import Data.Void (Void)
|
||||
import Data.Text (Text)
|
||||
import Data.List (transpose, tails)
|
||||
import Data.Bifunctor (first, bimap)
|
||||
import Control.Monad (join)
|
||||
import Text.Megaparsec (Parsec, errorBundlePretty, runParser, many, choice, eof)
|
||||
import Text.Megaparsec.Char (char, newline)
|
||||
import Misc (withCoords)
|
||||
|
||||
|
||||
data Cell = E | G deriving (Show, Eq)
|
||||
|
||||
type Row = Int
|
||||
type Col = Int
|
||||
type Grid = [[Cell]]
|
||||
|
||||
type Parser = Parsec Void Text
|
||||
|
||||
|
||||
parse :: Text -> Either String Grid
|
||||
parse = first errorBundlePretty . runParser grid ""
|
||||
where
|
||||
row :: Parser [Cell]
|
||||
row = many (choice [E <$ char '.', G <$ char '#']) <* newline
|
||||
grid :: Parser Grid
|
||||
grid = many row <* eof
|
||||
|
||||
pairs :: [a] -> [(a, a)]
|
||||
pairs xs = [(x, y) | (x:ys) <- tails xs, y <- ys]
|
||||
|
||||
expanded :: Grid -> ([Row], [Col])
|
||||
expanded = bimap filterE (filterE . transpose) . join (,)
|
||||
where
|
||||
filterE :: Grid -> [Int]
|
||||
filterE = map fst . filter (all (E ==) . snd) . zip [0..]
|
||||
|
||||
galaxies :: Grid -> [(Row, Col)]
|
||||
galaxies = map fst . filter ((G ==) . snd) . withCoords
|
||||
|
||||
solve :: Int -> Grid -> Int
|
||||
solve m = do
|
||||
gs <- galaxies
|
||||
es <- expanded
|
||||
return $ sum . map (distance es) . pairs $ gs
|
||||
where
|
||||
between :: Int -> Int -> Int -> Bool
|
||||
between a b n
|
||||
| a < b = a <= n && n <= b
|
||||
| otherwise = b <= n && n <= a
|
||||
crossed :: Int -> Int -> [Int] -> Int
|
||||
crossed a b = length . filter (between a b)
|
||||
distance :: ([Row], [Col]) -> ((Row, Col), (Row, Col)) -> Int
|
||||
distance (rs, cs) ((r1, c1), (r2, c2)) =
|
||||
let dr = abs (r1 - r2)
|
||||
dc = abs (c1 - c2)
|
||||
m' = (m - 1)
|
||||
er = m' * crossed r1 r2 rs
|
||||
ec = m' * crossed c1 c2 cs
|
||||
in dr + dc + er + ec
|
||||
|
||||
solveA :: Grid -> Int
|
||||
solveA = solve 2
|
||||
|
||||
solveB :: Grid -> Int
|
||||
solveB = solve 1000000
|
|
@ -1,79 +0,0 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module Day12 where
|
||||
|
||||
import Data.Void (Void)
|
||||
import Data.Text (Text)
|
||||
import Data.List (intercalate)
|
||||
import Text.Megaparsec (Parsec, errorBundlePretty, runParser, many, eof, choice, sepBy)
|
||||
import Data.Bifunctor (first, bimap)
|
||||
import Text.Megaparsec.Char (char, space, newline)
|
||||
import Text.Megaparsec.Char.Lexer (decimal)
|
||||
|
||||
|
||||
data Cell
|
||||
= U -- ? unknown
|
||||
| O -- . operational
|
||||
| D -- # damaged
|
||||
deriving (Show, Eq)
|
||||
|
||||
type Row = ([Cell], [Int])
|
||||
|
||||
type Parser = Parsec Void Text
|
||||
|
||||
|
||||
input :: Text
|
||||
input =
|
||||
"???.### 1,1,3\n\
|
||||
\.??..??...?##. 1,1,3\n\
|
||||
\?#?#?#?#?#?#?#? 1,3,1,6\n\
|
||||
\????.#...#... 4,1,1\n\
|
||||
\????.######..#####. 1,6,5\n\
|
||||
\?###???????? 3,2,1\n"
|
||||
|
||||
parse :: Text -> Either String [Row]
|
||||
parse = first errorBundlePretty . runParser rows ""
|
||||
where
|
||||
cell :: Parser Cell
|
||||
cell = choice [U <$ char '?', O <$ char '.', D <$ char '#']
|
||||
row :: Parser Row
|
||||
row = do
|
||||
cs <- many cell <* space
|
||||
ns <- decimal `sepBy` char ',' <* newline
|
||||
return (cs, ns)
|
||||
rows :: Parser [Row]
|
||||
rows = many row <* eof
|
||||
|
||||
arrange :: [Cell] -> [Int] -> [[Cell]]
|
||||
arrange [] [] = [[]]
|
||||
arrange [] _ = []
|
||||
arrange cs []
|
||||
| D `notElem` cs = [map (const O) cs]
|
||||
| otherwise = []
|
||||
arrange cs@(c:cr) ns@(n:nr)
|
||||
| canFill && canSkip = tryFill <> trySkip
|
||||
| canFill = tryFill
|
||||
| canSkip = trySkip
|
||||
| otherwise = []
|
||||
where
|
||||
(window, rest) = splitAt n cs
|
||||
fill :: [Cell] -> [Cell]
|
||||
fill = (replicate n D ++)
|
||||
canSkip :: Bool
|
||||
canSkip = c /= D
|
||||
trySkip :: [[Cell]]
|
||||
trySkip = map (O:) (arrange cr ns)
|
||||
canFill :: Bool
|
||||
canFill = O `notElem` window && n == length window && (null rest || head rest /= D)
|
||||
tryFill :: [[Cell]]
|
||||
tryFill
|
||||
| null rest = map fill (arrange rest nr)
|
||||
| otherwise = map (fill . (O:)) (arrange (tail rest) nr)
|
||||
|
||||
solveA :: [Row] -> Int
|
||||
solveA = length . concatMap (uncurry arrange)
|
||||
|
||||
unfold :: Row -> Row
|
||||
unfold = bimap (intercalate [U] . replicate 5) (concat . replicate 5)
|
||||
|
||||
solveB :: [Row] -> Int
|
||||
solveB = solveA . map unfold . take 5
|
|
@ -5,12 +5,11 @@ import Data.Void (Void)
|
|||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import Data.Char (ord, isSpace)
|
||||
import Data.List (findIndex)
|
||||
import Data.Bifunctor (bimap)
|
||||
import Text.Megaparsec (Parsec, errorBundlePretty, runParser, sepBy, optional, eof, many, choice)
|
||||
import Text.Megaparsec.Char (newline, alphaNumChar, char)
|
||||
import Text.Megaparsec.Char.Lexer (decimal)
|
||||
import Lens.Micro (ix, (%~), (.~))
|
||||
import Lens.Micro (ix, (%~))
|
||||
|
||||
|
||||
data Op
|
||||
|
@ -51,14 +50,12 @@ del :: Text -> [[Entry]] -> [[Entry]]
|
|||
del k = ix (hash k) %~ filter ((k /=) . fst)
|
||||
|
||||
set :: Text -> Int -> [[Entry]] -> [[Entry]]
|
||||
set k v = ix (hash k) %~ upsert
|
||||
set k v = ix (hash k) %~ update
|
||||
where
|
||||
update :: Int -> [Entry] -> [Entry]
|
||||
update n = ix n .~ (k, v)
|
||||
insert :: [Entry] -> [Entry]
|
||||
insert = (<> [(k, v)])
|
||||
upsert :: [Entry] -> [Entry]
|
||||
upsert es = maybe (insert es) (`update` es) . findIndex ((k ==) . fst) $ es
|
||||
update :: [Entry] -> [Entry]
|
||||
update es
|
||||
| any ((k ==) . fst) es = map (\(k', v') -> if k == k' then (k, v) else (k', v')) es
|
||||
| otherwise = es <> [(k, v)]
|
||||
|
||||
solveB :: [(Text, Op)] -> Int
|
||||
solveB = sum . zipWith row [1..] . foldl (flip run) (replicate 256 []) . map snd
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
module Day20 where
|
||||
|
||||
import Data.Void (Void)
|
||||
import Data.Text (Text)
|
||||
import Data.Bifunctor (first)
|
||||
import Text.Megaparsec (Parsec, (<|>), errorBundlePretty, runParser, eof, many, choice, sepBy)
|
||||
import Text.Megaparsec.Char (char, alphaNumChar, space, string)
|
||||
import Text.Megaparsec.Char.Lexer ()
|
||||
|
||||
|
||||
data ModType
|
||||
= Cast -- Broadcast
|
||||
| Flip -- Flip-Flop
|
||||
| Conj -- Conjuntion
|
||||
deriving Show
|
||||
|
||||
data Mod = Mod
|
||||
{ mName :: !String
|
||||
, mType :: !ModType
|
||||
, mNext :: ![String]
|
||||
} deriving Show
|
||||
|
||||
type Parser = Parsec Void Text
|
||||
|
||||
a :: Text
|
||||
a =
|
||||
"broadcaster -> a, b, c\n\
|
||||
\%a -> b\n\
|
||||
\%b -> c\n\
|
||||
\%c -> inv\n\
|
||||
\&inv -> a\n"
|
||||
|
||||
b :: Text
|
||||
b =
|
||||
"broadcaster -> a\n\
|
||||
\%a -> inv, con\n\
|
||||
\&inv -> b\n\
|
||||
\%b -> con\n\
|
||||
\&con -> output\n"
|
||||
|
||||
parse :: Text -> Either String [Mod]
|
||||
parse = first errorBundlePretty . runParser ms ""
|
||||
where
|
||||
m :: Parser Mod
|
||||
m = do
|
||||
mType <- choice [ Flip <$ char '%', Conj <$ char '&' ] <|> pure Cast
|
||||
mName <- many alphaNumChar <* space <* string "->" <* space
|
||||
mNext <- (many alphaNumChar `sepBy` string ", ") <* space
|
||||
return $ Mod {..}
|
||||
ms :: Parser [Mod]
|
||||
ms = many m <* eof
|
||||
|
||||
-- >>> parse a
|
||||
-- Right [Mod {mName = "broadcaster", mType = Cast, mNext = ["a","b","c"]},Mod {mName = "a", mType = Flip, mNext = ["b"]},Mod {mName = "b", mType = Flip, mNext = ["c"]},Mod {mName = "c", mType = Flip, mNext = ["inv"]},Mod {mName = "inv", mType = Conj, mNext = ["a"]}]
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module Day24 (parse, solveA, solveB) where
|
||||
|
||||
import Data.Void (Void)
|
||||
import Data.Text (Text)
|
||||
import Data.Maybe (mapMaybe)
|
||||
import Data.Bifunctor (first, bimap)
|
||||
import Control.Monad ((<=<))
|
||||
import Text.Megaparsec (Parsec, errorBundlePretty, runParser, eof, many)
|
||||
import Text.Megaparsec.Char (char, space)
|
||||
import Text.Megaparsec.Char.Lexer (signed, decimal)
|
||||
import Numeric.LinearAlgebra (R, linearSolve, flatten, toList, fromLists, col)
|
||||
import Misc (paired)
|
||||
|
||||
|
||||
type R3 = (R, R, R)
|
||||
type Ray = (R3, R3)
|
||||
|
||||
type Parser = Parsec Void Text
|
||||
|
||||
|
||||
parse :: Text -> Either String [Ray]
|
||||
parse = first errorBundlePretty . runParser rays ""
|
||||
where
|
||||
r :: Parser R
|
||||
r = signed space decimal
|
||||
r3 :: Parser R3
|
||||
r3 = do
|
||||
a <- r <* char ',' <* space
|
||||
b <- r <* char ',' <* space
|
||||
c <- r
|
||||
return (a, b, c)
|
||||
ray :: Parser (R3, R3)
|
||||
ray = do
|
||||
t1 <- r3 <* space
|
||||
char '@' *> space
|
||||
t2 <- r3 <* space
|
||||
return (t1, t2)
|
||||
rays :: Parser [Ray]
|
||||
rays = many ray <* eof
|
||||
|
||||
|
||||
intersect2D :: Ray -> Ray -> Maybe ([R], (R, R))
|
||||
intersect2D r1 r2 =
|
||||
let ((sx1, sy1, _), (vx1, vy1, _)) = r1
|
||||
((sx2, sy2, _), (vx2, vy2, _)) = r2
|
||||
coeffs = fromLists
|
||||
[ [vx2, -vx1]
|
||||
, [vy2, -vy1]
|
||||
]
|
||||
rhs = col
|
||||
[ sx1 - sx2
|
||||
, sy1 - sy2
|
||||
]
|
||||
times = toList . flatten <$> linearSolve coeffs rhs
|
||||
in case times of
|
||||
Just ts@(tb:_) -> Just (ts, toPoint tb r2)
|
||||
_otherwise -> Nothing
|
||||
where
|
||||
toPoint :: R -> Ray -> (R, R)
|
||||
toPoint t ((sx, sy, _), (vx, vy, _)) = (sx + t * vx, sy + t * vy)
|
||||
|
||||
solveAFor :: R -> R -> [Ray] -> Int
|
||||
solveAFor s e = length . filter isBoth . mapMaybe (uncurry intersect2D) . paired
|
||||
where
|
||||
isFuture :: [R] -> Bool
|
||||
isFuture = all (0<=)
|
||||
isWithin :: (R, R) -> Bool
|
||||
isWithin (x, y) = s <= x && x <= e && s <= y && y <= e
|
||||
isBoth :: ([R], (R, R)) -> Bool
|
||||
isBoth = uncurry (&&) . bimap isFuture isWithin
|
||||
|
||||
solveA :: [Ray] -> Int
|
||||
solveA = solveAFor 200000000000000 400000000000000
|
||||
|
||||
findThrow :: (Ray, Ray, Ray) -> Maybe [Int]
|
||||
findThrow (r1, r2, r3) =
|
||||
let
|
||||
((sx1, sy1, sz1), (vx1, vy1, vz1)) = r1
|
||||
((sx2, sy2, sz2), (vx2, vy2, vz2)) = r2
|
||||
((sx3, sy3, sz3), (vx3, vy3, vz3)) = r3
|
||||
coeffs = fromLists
|
||||
[ [0, vz2 - vz1, vy1 - vy2, 0, sz1 - sz2, sy2 - sy1]
|
||||
, [0, vz3 - vz1, vy1 - vy3, 0, sz1 - sz3, sy3 - sy1]
|
||||
, [vz1 - vz2, 0, vx2 - vx1, sz2 - sz1, 0, sx1 - sx2]
|
||||
, [vz1 - vz3, 0, vx3 - vx1, sz3 - sz1, 0, sx1 - sx3]
|
||||
, [vy2 - vy1, vx1 - vx2, 0, sy1 - sy2, sx2 - sx1, 0]
|
||||
, [vy3 - vy1, vx1 - vx3, 0, sy1 - sy3, sx3 - sx1, 0]
|
||||
]
|
||||
rhs = col
|
||||
[ vy1 * sz1 - sy1 * vz1 + sy2 * vz2 - vy2 * sz2
|
||||
, vy1 * sz1 - sy1 * vz1 + sy3 * vz3 - vy3 * sz3
|
||||
, sx1 * vz1 - vx1 * sz1 + vx2 * sz2 - sx2 * vz2
|
||||
, sx1 * vz1 - vx1 * sz1 + vx3 * sz3 - sx3 * vz3
|
||||
, vx1 * sy1 - sx1 * vy1 + sx2 * vy2 - vx2 * sy2
|
||||
, vx1 * sy1 - sx1 * vy1 + sx3 * vy3 - vx3 * sy3
|
||||
]
|
||||
in map round . toList . flatten <$> linearSolve coeffs rhs
|
||||
|
||||
solveB :: [Ray] -> Int
|
||||
solveB = maybe 0 (sum . take 3) . findThrow'
|
||||
where
|
||||
bundle :: [Ray] -> Maybe (Ray, Ray, Ray)
|
||||
bundle rays = case rays of
|
||||
r1:r2:r3:_ -> Just (r1, r2, r3)
|
||||
_otherwise -> Nothing
|
||||
findThrow' :: [Ray] -> Maybe [Int]
|
||||
findThrow' = findThrow <=< bundle
|
|
@ -1,7 +1,5 @@
|
|||
module Misc where
|
||||
|
||||
import Data.List (tails)
|
||||
|
||||
|
||||
withCoords :: [[a]] -> [((Int, Int), a)]
|
||||
withCoords grid = [((r, c), a) | (r, row) <- zip [0..] grid, (c, a) <- zip [0..] row]
|
||||
|
@ -9,6 +7,3 @@ withCoords grid = [((r, c), a) | (r, row) <- zip [0..] grid, (c, a) <- zip [0..]
|
|||
pairs :: [a] -> [(a, a)]
|
||||
pairs [] = []
|
||||
pairs xs = zip xs $ tail xs
|
||||
|
||||
paired :: [a] -> [(a, a)]
|
||||
paired xs = [(x, y) | (x:ys) <- tails xs, y <- ys]
|
||||
|
|
|
@ -13,8 +13,6 @@ import qualified Day07
|
|||
import qualified Day08
|
||||
import qualified Day09
|
||||
import qualified Day10
|
||||
import qualified Day11
|
||||
import qualified Day12
|
||||
import qualified Day15
|
||||
|
||||
|
||||
|
@ -278,48 +276,12 @@ day10 =
|
|||
\L.L7LFJ|||||FJL7||LJ\n\
|
||||
\L7JLJL-JLJLJL--JLJ.L\n"
|
||||
|
||||
day11 :: Test
|
||||
day11 =
|
||||
let parsed = Day11.parse input
|
||||
in TestList
|
||||
[ TestCase $ assertEqual "A" (Right 374) (Day11.solveA <$> parsed)
|
||||
, TestCase $ assertEqual "B" (Right 82000210) (Day11.solveB <$> parsed)
|
||||
]
|
||||
where
|
||||
input =
|
||||
"...#......\n\
|
||||
\.......#..\n\
|
||||
\#.........\n\
|
||||
\..........\n\
|
||||
\......#...\n\
|
||||
\.#........\n\
|
||||
\.........#\n\
|
||||
\..........\n\
|
||||
\.......#..\n\
|
||||
\#...#.....\n"
|
||||
|
||||
day12 :: Test
|
||||
day12 =
|
||||
let parsed = Day12.parse input
|
||||
in TestList
|
||||
[ TestCase $ assertEqual "A" (Right 21) (Day12.solveA <$> parsed)
|
||||
, TestCase $ assertEqual "B" (Right 525152) (Day12.solveB <$> parsed)
|
||||
]
|
||||
where
|
||||
input =
|
||||
"???.### 1,1,3\n\
|
||||
\.??..??...?##. 1,1,3\n\
|
||||
\?#?#?#?#?#?#?#? 1,3,1,6\n\
|
||||
\????.#...#... 4,1,1\n\
|
||||
\????.######..#####. 1,6,5\n\
|
||||
\?###???????? 3,2,1\n"
|
||||
|
||||
day15 :: Test
|
||||
day15 =
|
||||
let parsed = Day15.parse input
|
||||
in TestList
|
||||
[ TestCase $ assertEqual "A" (Right 1320) (Day15.solveA <$> parsed)
|
||||
, TestCase $ assertEqual "B" (Right 145) (Day15.solveB <$> parsed)
|
||||
, TestCase $ assertEqual "A" (Right 145) (Day15.solveB <$> parsed)
|
||||
]
|
||||
where
|
||||
input = "rn=1,cm-,qp=3,cm=2,qp-,pc=4,ot=9,ab=5,pc-,pc=6,ot=7"
|
||||
|
@ -336,8 +298,6 @@ tests = TestList
|
|||
, TestLabel "08" day08
|
||||
, TestLabel "09" day09
|
||||
, TestLabel "10" day10
|
||||
, TestLabel "11" day11
|
||||
, TestLabel "12" day12
|
||||
, TestLabel "15" day15
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in a new issue