chore: current WIP day 7b and 8
This commit is contained in:
1 parent
2e86795761
commit
28e400f221
6 files changed
+1278
-18
No files matched your search
@@ -11,3 +11,4 @@
|
||||
| 5 | Cafeteria | ⭐ | ⭐ |
|
||||
| 6 | Trash Compactor | ⭐ | ⭐ |
|
||||
| 7 | Laboratories | ⭐ | |
|
||||
| 8 | Playground | | |
|
||||
@@ -0,0 +1,13 @@
|
||||
import { assertEquals } from "@std/assert";
|
||||
import {
|
||||
get_three_largest_pairings_mul,
|
||||
read_junction_box_3d_positions,
|
||||
} from "../exercises/day_8.ts";
|
||||
|
||||
Deno.test("Day 8 - A", async () => {
|
||||
const junction_boxes_coords = await read_junction_box_3d_positions(
|
||||
"src/exercises/assets/day_8_test_input.txt",
|
||||
);
|
||||
const result = get_three_largest_pairings_mul(junction_boxes_coords, 10);
|
||||
assertEquals(result, 40);
|
||||
});
|
||||
@@ -0,0 +1,1000 @@
|
||||
85745,85024,49163
|
||||
49701,97021,69974
|
||||
86108,44672,12611
|
||||
97857,40198,46149
|
||||
85447,51581,23591
|
||||
49266,93396,26631
|
||||
81670,83939,13358
|
||||
84820,38718,56611
|
||||
58890,76582,41171
|
||||
34179,63666,10776
|
||||
79802,63910,6319
|
||||
31026,22961,51059
|
||||
98828,85501,19710
|
||||
84448,55650,16999
|
||||
77672,96361,37323
|
||||
17805,99487,17520
|
||||
16142,81573,83031
|
||||
80696,46143,85936
|
||||
83372,91566,71701
|
||||
75491,73510,15905
|
||||
72610,6841,71331
|
||||
85170,95694,14313
|
||||
62209,44255,48636
|
||||
56726,939,15793
|
||||
48531,88931,29192
|
||||
34368,1068,44936
|
||||
71659,74537,94611
|
||||
27101,47095,11274
|
||||
92872,24449,41518
|
||||
76713,99198,65511
|
||||
77032,18541,1643
|
||||
81804,78613,92610
|
||||
30285,78011,95649
|
||||
94118,14262,86867
|
||||
98138,20639,95733
|
||||
19717,7643,78366
|
||||
79577,98530,79284
|
||||
65885,91738,89021
|
||||
57129,62655,14528
|
||||
16341,35833,91115
|
||||
25125,79976,75983
|
||||
30026,3413,39985
|
||||
9249,14414,98996
|
||||
95986,97558,35543
|
||||
64849,48676,63732
|
||||
37866,18975,22476
|
||||
20193,23344,86471
|
||||
40697,88955,5112
|
||||
85534,10932,26468
|
||||
79778,43504,79713
|
||||
58117,2059,86884
|
||||
9669,51398,77640
|
||||
24125,78951,46432
|
||||
34711,96382,87664
|
||||
45573,75148,81845
|
||||
16889,88383,40791
|
||||
8670,37004,97701
|
||||
95183,23182,18896
|
||||
40744,17743,19467
|
||||
6735,65124,25209
|
||||
17439,58054,22868
|
||||
78674,65470,16365
|
||||
10552,46369,84731
|
||||
25386,25677,79956
|
||||
92755,20746,58602
|
||||
21460,78182,94812
|
||||
16495,99425,14836
|
||||
49765,66706,45783
|
||||
26751,61378,18085
|
||||
82543,54799,26048
|
||||
51490,92325,46246
|
||||
62642,7191,15333
|
||||
39860,71783,23981
|
||||
63276,57829,2595
|
||||
60363,27578,31242
|
||||
51810,64805,93604
|
||||
75656,85059,73027
|
||||
77505,27458,64284
|
||||
13992,39193,38320
|
||||
29262,91494,20049
|
||||
74872,82504,59103
|
||||
22021,62347,84106
|
||||
27034,14798,55844
|
||||
71916,80095,97902
|
||||
90253,79655,66123
|
||||
86884,1804,54809
|
||||
49657,58516,90518
|
||||
54415,51651,14277
|
||||
96302,71922,93730
|
||||
78763,42339,75250
|
||||
86116,78356,91352
|
||||
94940,88505,72924
|
||||
4115,23113,99754
|
||||
81154,59324,76757
|
||||
7359,28671,21384
|
||||
52207,34049,2247
|
||||
42201,87450,34089
|
||||
46669,77265,42851
|
||||
14225,41052,40185
|
||||
73051,27210,25317
|
||||
26462,58994,23092
|
||||
66186,2419,91475
|
||||
54164,95130,82507
|
||||
90198,43005,72494
|
||||
44053,25414,14046
|
||||
25317,47146,4880
|
||||
2726,28534,15914
|
||||
45479,32705,96310
|
||||
80624,66681,51598
|
||||
82532,95691,98610
|
||||
45125,56328,12156
|
||||
69088,84761,83206
|
||||
52912,26485,76488
|
||||
57450,80919,24740
|
||||
59962,63369,63839
|
||||
76614,95589,97321
|
||||
79720,5364,79099
|
||||
28830,17016,54833
|
||||
42079,76225,45761
|
||||
65848,55751,92895
|
||||
55354,82059,22466
|
||||
16121,6011,1717
|
||||
53695,97624,46440
|
||||
60458,28905,78176
|
||||
38226,83075,60867
|
||||
67013,59189,24604
|
||||
59493,58375,52952
|
||||
80121,58172,44398
|
||||
52001,51712,9131
|
||||
37002,36667,45361
|
||||
53253,76646,45277
|
||||
31721,55969,7087
|
||||
21751,45928,75548
|
||||
21043,59423,52755
|
||||
90032,9363,65033
|
||||
45749,70908,67326
|
||||
48418,40434,17828
|
||||
56845,23466,21742
|
||||
91518,86928,48563
|
||||
516,29577,40827
|
||||
12770,60869,50055
|
||||
44238,92219,53513
|
||||
34152,71908,22949
|
||||
25564,95746,30582
|
||||
7107,17245,50912
|
||||
24619,43132,93912
|
||||
74423,10628,33205
|
||||
88638,97306,22262
|
||||
17483,77927,54635
|
||||
3039,41331,99683
|
||||
26462,19784,13734
|
||||
98378,37606,52453
|
||||
30127,74069,49928
|
||||
16811,36447,47818
|
||||
20000,88266,11515
|
||||
90842,27338,60427
|
||||
58158,4856,45430
|
||||
7170,68602,69302
|
||||
16935,77827,73340
|
||||
72131,63124,61043
|
||||
84551,25429,58768
|
||||
12674,2472,98102
|
||||
10305,79552,96118
|
||||
14260,5798,25818
|
||||
86479,8440,48642
|
||||
7682,21371,64929
|
||||
27247,60963,15448
|
||||
16688,14493,92422
|
||||
47502,35518,83242
|
||||
68927,29716,5829
|
||||
87690,9995,41730
|
||||
63352,10104,30353
|
||||
16353,72465,44270
|
||||
85195,65929,63085
|
||||
61616,16033,99490
|
||||
3578,34804,17890
|
||||
33957,29670,23201
|
||||
76443,89101,12148
|
||||
21906,98120,49549
|
||||
36242,53091,57670
|
||||
9552,92432,17982
|
||||
60981,2225,77952
|
||||
7465,99581,76621
|
||||
68232,87445,5116
|
||||
78801,1981,74941
|
||||
83925,29672,98264
|
||||
16408,74616,68934
|
||||
81218,79937,64981
|
||||
54254,71566,7214
|
||||
83077,4512,34529
|
||||
14061,33437,49687
|
||||
72846,25246,40696
|
||||
74787,70028,20081
|
||||
35389,6013,22791
|
||||
11031,30568,1830
|
||||
29499,83959,92644
|
||||
55188,1544,71994
|
||||
68698,44118,41811
|
||||
87002,47961,52539
|
||||
44960,85056,73762
|
||||
20106,51164,32413
|
||||
89440,26189,62662
|
||||
73824,67270,8070
|
||||
71970,88337,91958
|
||||
4572,64567,72244
|
||||
22544,83764,36384
|
||||
82987,50338,95109
|
||||
98233,50378,81803
|
||||
3199,42755,46463
|
||||
68932,40764,93273
|
||||
57341,64650,24272
|
||||
83688,18635,15318
|
||||
25387,80995,31467
|
||||
98370,88066,30940
|
||||
32774,42021,33681
|
||||
7586,38402,10746
|
||||
48260,81041,40558
|
||||
29492,97055,87333
|
||||
24126,39410,45422
|
||||
20304,65694,6007
|
||||
72787,48756,11747
|
||||
28327,71900,50803
|
||||
60561,55715,10616
|
||||
10960,28481,1566
|
||||
62527,29945,93160
|
||||
34772,58285,90168
|
||||
22344,27332,76583
|
||||
15394,10075,77289
|
||||
45528,77071,16872
|
||||
11053,7224,74428
|
||||
5246,87789,64592
|
||||
44480,56550,85366
|
||||
66016,12184,74069
|
||||
84909,34653,41787
|
||||
15702,96954,42309
|
||||
96799,47657,82300
|
||||
97323,7775,79169
|
||||
25423,29772,11130
|
||||
83053,66975,40962
|
||||
86591,54449,7837
|
||||
45806,40469,31789
|
||||
62806,92574,63005
|
||||
41786,83977,43416
|
||||
13661,21360,47431
|
||||
47866,42585,71300
|
||||
22063,29693,50980
|
||||
62045,24529,32361
|
||||
89982,14315,32381
|
||||
60245,36342,34935
|
||||
40246,99465,4282
|
||||
89863,27216,74685
|
||||
23691,26136,72462
|
||||
75021,54176,16734
|
||||
39403,74752,7816
|
||||
46810,14709,52064
|
||||
17735,6409,69003
|
||||
23644,38369,19040
|
||||
22678,24426,71606
|
||||
52947,87845,62868
|
||||
32558,13485,90646
|
||||
23275,52745,52084
|
||||
95040,1176,46723
|
||||
96346,77506,86806
|
||||
72065,73728,83099
|
||||
29079,99946,80406
|
||||
7730,50041,93929
|
||||
19580,43906,52029
|
||||
3889,77680,31241
|
||||
89050,7965,20701
|
||||
16542,15476,42161
|
||||
19758,37994,91903
|
||||
10406,68666,54858
|
||||
15836,59881,45902
|
||||
88015,57274,81052
|
||||
28307,71670,52843
|
||||
69439,58757,35716
|
||||
40839,88857,50078
|
||||
98603,80792,52028
|
||||
12800,98473,79511
|
||||
84277,85725,85850
|
||||
58836,36195,31658
|
||||
43804,24002,39761
|
||||
12201,54499,83863
|
||||
64399,46967,46895
|
||||
1340,81054,85675
|
||||
5578,13337,16520
|
||||
13683,812,10699
|
||||
11517,79989,84598
|
||||
50070,45258,84570
|
||||
45402,28278,69212
|
||||
12076,98145,66079
|
||||
92573,20057,17745
|
||||
59914,72272,20599
|
||||
79910,88451,98532
|
||||
68719,16894,33782
|
||||
1879,43507,7603
|
||||
56593,84402,78380
|
||||
18789,69726,44183
|
||||
35165,79278,87276
|
||||
90339,88126,73347
|
||||
96660,62567,74422
|
||||
67895,51575,74667
|
||||
7509,65096,14940
|
||||
99895,41192,86263
|
||||
76084,36563,10772
|
||||
21132,16749,16737
|
||||
81072,11088,29744
|
||||
6830,61173,5775
|
||||
84252,56005,34996
|
||||
34413,47128,62518
|
||||
33272,49960,82661
|
||||
87092,84090,33537
|
||||
69263,60287,19529
|
||||
25231,53302,23255
|
||||
48670,76330,53800
|
||||
50693,91656,87146
|
||||
90455,24882,84690
|
||||
7937,17825,30994
|
||||
36832,80983,54902
|
||||
98251,41008,96903
|
||||
28628,17615,4256
|
||||
23777,37031,74461
|
||||
76434,54099,50436
|
||||
71057,78462,51112
|
||||
32814,6453,86847
|
||||
76116,88396,85825
|
||||
42399,44460,37096
|
||||
53399,59515,6379
|
||||
45037,65860,5478
|
||||
35470,90363,31193
|
||||
54292,51804,19002
|
||||
42004,49635,17288
|
||||
37528,95370,9526
|
||||
40614,30977,52181
|
||||
89919,79800,70251
|
||||
88524,84249,57766
|
||||
57593,97241,55165
|
||||
25648,27952,28127
|
||||
77640,48503,90463
|
||||
5875,69059,16903
|
||||
26863,32623,11758
|
||||
37612,14590,90482
|
||||
52209,48524,71377
|
||||
83787,24188,72273
|
||||
18048,52591,71798
|
||||
43984,77426,1534
|
||||
93534,59734,3152
|
||||
1162,36987,20938
|
||||
3704,63728,12547
|
||||
37558,68227,80066
|
||||
75418,80343,43337
|
||||
38024,31218,83813
|
||||
68683,62029,29038
|
||||
31156,75938,5338
|
||||
15341,47362,46237
|
||||
55500,75884,74518
|
||||
17968,45303,4743
|
||||
54216,35941,88204
|
||||
18568,36318,37948
|
||||
22894,9862,25010
|
||||
22121,76531,79917
|
||||
55049,22319,62374
|
||||
55303,20708,16328
|
||||
63454,11534,3113
|
||||
87570,19835,64689
|
||||
18957,73150,9331
|
||||
52017,43985,34800
|
||||
68793,82369,11850
|
||||
42960,49728,68164
|
||||
5158,33919,94691
|
||||
44459,7377,84671
|
||||
92320,74660,77288
|
||||
6514,53588,44194
|
||||
11484,26066,10944
|
||||
55630,33710,48704
|
||||
87942,84726,65386
|
||||
64463,9047,4856
|
||||
1264,98327,8116
|
||||
76270,13684,46314
|
||||
67070,60547,3351
|
||||
4407,42056,13882
|
||||
82823,50674,58707
|
||||
35283,39168,1092
|
||||
27609,67196,56575
|
||||
28639,19489,32037
|
||||
59299,23117,71991
|
||||
24076,45456,18426
|
||||
77865,93198,47123
|
||||
25322,31193,56394
|
||||
60406,64141,13676
|
||||
51038,17969,84886
|
||||
68416,18094,17518
|
||||
15163,91850,35322
|
||||
3489,71669,35129
|
||||
43137,20269,72646
|
||||
30208,46565,97434
|
||||
69406,80919,84153
|
||||
88448,79812,99370
|
||||
21903,825,18514
|
||||
39050,21342,28844
|
||||
23496,20111,4632
|
||||
19433,29846,53464
|
||||
75557,71759,25850
|
||||
18849,78168,34596
|
||||
88006,9961,79581
|
||||
29588,57151,25562
|
||||
40531,89545,22677
|
||||
9369,97166,68875
|
||||
93335,50005,76366
|
||||
7743,76886,73756
|
||||
30755,25723,75183
|
||||
51972,30183,87199
|
||||
42317,8067,25644
|
||||
35874,8,29183
|
||||
96589,95269,63402
|
||||
49043,60894,95440
|
||||
91239,82453,21243
|
||||
22135,34416,20914
|
||||
15428,16005,46505
|
||||
81962,49597,37999
|
||||
26671,83003,11533
|
||||
88700,60545,50690
|
||||
69686,38965,86611
|
||||
98316,67368,25866
|
||||
55806,1548,69835
|
||||
59609,39789,74092
|
||||
35114,6023,30539
|
||||
13229,72562,76489
|
||||
20587,25433,62012
|
||||
8152,51946,6467
|
||||
11855,26118,23046
|
||||
91321,87874,84653
|
||||
80202,87211,92625
|
||||
13381,34258,88723
|
||||
84454,88842,8109
|
||||
56082,8326,91945
|
||||
68537,24889,49665
|
||||
42503,40680,44553
|
||||
95544,56904,67914
|
||||
618,92734,1736
|
||||
19162,27443,72873
|
||||
1691,72541,27941
|
||||
85156,55245,14748
|
||||
78586,45400,56289
|
||||
93145,54546,6724
|
||||
68206,78712,81979
|
||||
55906,41769,36957
|
||||
34208,85892,66962
|
||||
37724,84194,29158
|
||||
47422,48379,7630
|
||||
19449,45095,65763
|
||||
75572,86665,61057
|
||||
26147,61294,57629
|
||||
59744,47395,17435
|
||||
5839,60470,69863
|
||||
13265,57820,78602
|
||||
71049,90495,59690
|
||||
4666,90509,34388
|
||||
42429,32602,55530
|
||||
25685,1077,47097
|
||||
91912,50891,44694
|
||||
27084,18134,92754
|
||||
48895,30007,93115
|
||||
90149,89947,65120
|
||||
38576,64309,92775
|
||||
8908,15253,25195
|
||||
39256,40646,59335
|
||||
43345,57477,99274
|
||||
716,45547,17384
|
||||
66215,90086,40879
|
||||
58560,33758,67296
|
||||
32019,57645,10418
|
||||
51566,16936,36839
|
||||
67492,25481,41403
|
||||
22526,33397,2498
|
||||
52946,80725,71570
|
||||
3159,13243,791
|
||||
25402,42173,6491
|
||||
32747,10262,28769
|
||||
95427,39368,72930
|
||||
70788,10401,29402
|
||||
6304,21267,47899
|
||||
41412,99792,19835
|
||||
17355,41918,60357
|
||||
23271,24490,50728
|
||||
56277,35645,58411
|
||||
69614,5706,92375
|
||||
51795,47131,58639
|
||||
10615,79316,87234
|
||||
47304,34854,20896
|
||||
97342,13216,8671
|
||||
41981,62963,55504
|
||||
25817,82899,41654
|
||||
94771,24236,30155
|
||||
44811,59083,10427
|
||||
92454,47875,87029
|
||||
47244,78127,59609
|
||||
9656,21816,74761
|
||||
30970,34847,80665
|
||||
49200,81081,70097
|
||||
83166,1069,19296
|
||||
2147,71594,26690
|
||||
1282,13321,83705
|
||||
45231,46528,77433
|
||||
72072,44406,83148
|
||||
4550,31422,59650
|
||||
62091,19639,41671
|
||||
75806,81007,80178
|
||||
88859,52745,82341
|
||||
91013,40253,21471
|
||||
90565,29368,92635
|
||||
72090,49748,80944
|
||||
36388,83049,30257
|
||||
30740,42171,97438
|
||||
27965,84786,74591
|
||||
88503,61778,95811
|
||||
18594,26084,36970
|
||||
65231,2822,38256
|
||||
29220,23295,60922
|
||||
89360,24315,90180
|
||||
60639,74760,33411
|
||||
73914,83353,73546
|
||||
76083,10777,67938
|
||||
39050,60915,34126
|
||||
64843,31040,94269
|
||||
15950,34382,66967
|
||||
55614,48890,80162
|
||||
58402,6074,75754
|
||||
30428,95089,54823
|
||||
68646,70222,86691
|
||||
25009,64752,22292
|
||||
91740,11672,73652
|
||||
68699,76516,53717
|
||||
38828,75233,2045
|
||||
90758,10085,11863
|
||||
35303,4054,24100
|
||||
72217,97623,55062
|
||||
96580,58969,77513
|
||||
11259,64930,78330
|
||||
51320,58687,37369
|
||||
41746,29888,35939
|
||||
69574,5211,15256
|
||||
22199,8682,43177
|
||||
43273,80081,86629
|
||||
94365,66547,95176
|
||||
68848,78201,10163
|
||||
91497,43185,43358
|
||||
99185,4023,79277
|
||||
11908,2855,94831
|
||||
76467,44703,82848
|
||||
42194,13485,4427
|
||||
40906,66688,94781
|
||||
93697,79846,84682
|
||||
74369,15948,68615
|
||||
67443,10659,48481
|
||||
9908,98954,36171
|
||||
40186,73283,52933
|
||||
99396,93299,79215
|
||||
80473,76811,60061
|
||||
3300,15525,49547
|
||||
64235,44838,62520
|
||||
68802,35511,51385
|
||||
45911,88407,45589
|
||||
68657,37270,52442
|
||||
40070,52847,64550
|
||||
85204,34686,25889
|
||||
77849,23743,60227
|
||||
11255,44764,57420
|
||||
2985,72486,69626
|
||||
31305,59544,4705
|
||||
38315,31568,52256
|
||||
42984,43008,91342
|
||||
88147,44667,18664
|
||||
38757,75939,45745
|
||||
49769,98103,87443
|
||||
56391,77109,57497
|
||||
87901,46126,40241
|
||||
28119,99747,24930
|
||||
42704,51439,73455
|
||||
79728,79670,11041
|
||||
43043,4095,48057
|
||||
88158,50827,17671
|
||||
88606,67274,52161
|
||||
16960,30058,66555
|
||||
5153,13766,4421
|
||||
93159,19450,86051
|
||||
37083,25104,71678
|
||||
99484,38873,8163
|
||||
90316,18914,12357
|
||||
50912,99969,56767
|
||||
50084,65352,82067
|
||||
40494,36949,60458
|
||||
26774,91021,56395
|
||||
66366,98043,7635
|
||||
45252,76847,21575
|
||||
47066,94257,15162
|
||||
3306,62910,70823
|
||||
85588,45961,59301
|
||||
62657,91007,12986
|
||||
85175,41106,11110
|
||||
85565,4056,2529
|
||||
20520,19897,72395
|
||||
15830,19657,71679
|
||||
26839,31190,80953
|
||||
54135,48670,55762
|
||||
20676,8534,50152
|
||||
89034,72567,24111
|
||||
21863,16032,8441
|
||||
61801,28518,58572
|
||||
56531,35829,30815
|
||||
81354,58423,44076
|
||||
6589,84325,66690
|
||||
25233,11865,99301
|
||||
68810,53829,53433
|
||||
56215,68422,67023
|
||||
83231,22105,16519
|
||||
85831,91557,18742
|
||||
55915,42603,92805
|
||||
37540,79266,33034
|
||||
12713,33625,50348
|
||||
59687,99965,55069
|
||||
60437,42606,74220
|
||||
54500,85809,16560
|
||||
65298,14679,41910
|
||||
72105,99343,68866
|
||||
47210,95130,3399
|
||||
2768,81492,15697
|
||||
63099,24694,55015
|
||||
48618,13449,91933
|
||||
66249,34896,31008
|
||||
86902,75314,22110
|
||||
39835,69674,30763
|
||||
33453,32363,62415
|
||||
70571,7199,30808
|
||||
84766,50228,61838
|
||||
91949,91544,96319
|
||||
85517,57023,19506
|
||||
22321,23185,14525
|
||||
28196,92154,60248
|
||||
23783,90987,58869
|
||||
79606,14886,21691
|
||||
11555,9510,60890
|
||||
95260,18641,25484
|
||||
13074,68976,84381
|
||||
21071,2256,34472
|
||||
25922,2612,68976
|
||||
27570,8348,83879
|
||||
73737,8974,36076
|
||||
81028,13545,66793
|
||||
21319,18705,92178
|
||||
13939,28898,18896
|
||||
44878,87684,14996
|
||||
27511,41182,53126
|
||||
33314,44968,96547
|
||||
60415,12335,29166
|
||||
29922,71235,12906
|
||||
78015,52880,12171
|
||||
46033,27750,60095
|
||||
10674,70673,8948
|
||||
81270,48091,43432
|
||||
28891,23126,18591
|
||||
63647,23486,75158
|
||||
3260,44422,79503
|
||||
24810,65643,53157
|
||||
35862,52980,4654
|
||||
53213,56709,87824
|
||||
89292,54990,37360
|
||||
38140,68558,52318
|
||||
72910,13861,41244
|
||||
95139,37411,53020
|
||||
71156,87606,95665
|
||||
96621,1232,21495
|
||||
89531,96021,7842
|
||||
67045,3406,64525
|
||||
17459,69578,49542
|
||||
34838,248,2497
|
||||
11030,97664,47772
|
||||
31287,9333,41426
|
||||
19072,63924,3001
|
||||
7431,5064,29648
|
||||
85846,14540,65502
|
||||
8412,5818,89192
|
||||
55400,59670,22005
|
||||
84247,94335,92590
|
||||
16623,58484,78018
|
||||
15682,73998,69510
|
||||
67898,76387,80142
|
||||
59426,72609,88872
|
||||
17621,64665,1407
|
||||
78448,72326,90406
|
||||
91199,85312,5309
|
||||
63593,97642,49163
|
||||
5747,26556,79460
|
||||
84303,45041,91368
|
||||
71643,85895,19213
|
||||
31125,35416,29703
|
||||
52476,2357,34558
|
||||
26853,52019,38607
|
||||
32295,22729,48475
|
||||
20998,39914,24967
|
||||
31883,61294,6666
|
||||
63756,35603,46959
|
||||
95228,21217,24839
|
||||
17929,83018,72744
|
||||
89231,19815,7258
|
||||
8027,5254,8204
|
||||
91580,3201,41573
|
||||
40137,60102,97686
|
||||
4574,60096,37453
|
||||
21989,88163,88567
|
||||
58357,96024,66434
|
||||
26850,22809,38765
|
||||
49285,94550,21969
|
||||
42161,18147,5875
|
||||
36955,99935,35913
|
||||
32415,35958,68782
|
||||
64021,58788,44844
|
||||
56581,71575,16343
|
||||
58688,14244,49159
|
||||
4798,37533,29530
|
||||
35967,47609,19604
|
||||
97307,63734,75520
|
||||
98478,70902,32774
|
||||
13191,94365,53523
|
||||
46316,58175,77031
|
||||
32444,10491,99730
|
||||
94417,77469,44026
|
||||
69523,27919,50055
|
||||
58194,47879,36240
|
||||
1595,52340,51060
|
||||
94144,75474,707
|
||||
88185,61915,84265
|
||||
73833,24908,93632
|
||||
73304,73122,6418
|
||||
67062,37183,54822
|
||||
39401,80982,54388
|
||||
63370,83577,54850
|
||||
95436,81584,63542
|
||||
94854,35000,73307
|
||||
43835,75469,22263
|
||||
43736,60285,68811
|
||||
95416,63786,22260
|
||||
29316,44954,1327
|
||||
80063,78813,61103
|
||||
17169,33424,9126
|
||||
38392,24384,67992
|
||||
24150,45121,72010
|
||||
81855,31359,8318
|
||||
8834,70874,90199
|
||||
71301,58891,5761
|
||||
60387,77720,11158
|
||||
63444,21237,44307
|
||||
39389,44919,66527
|
||||
88833,19255,78117
|
||||
52509,9618,81890
|
||||
6724,93417,16368
|
||||
76603,61404,73700
|
||||
67182,92942,73813
|
||||
94265,85598,53385
|
||||
16874,62509,50504
|
||||
98770,48218,88565
|
||||
18055,24802,37009
|
||||
9073,27440,14884
|
||||
10472,2985,50301
|
||||
99927,2433,59410
|
||||
76194,83063,37070
|
||||
26354,43415,71679
|
||||
72801,46694,18571
|
||||
12293,44508,48252
|
||||
49884,78944,28605
|
||||
36575,1667,2600
|
||||
61201,69688,61913
|
||||
79046,31798,14953
|
||||
75283,63705,65760
|
||||
79904,21814,63190
|
||||
80718,16181,51853
|
||||
1421,32964,52060
|
||||
22576,60124,57902
|
||||
62463,15863,33854
|
||||
97195,22335,64649
|
||||
64002,8150,61083
|
||||
70565,16825,77213
|
||||
38616,85092,71181
|
||||
3259,5825,29656
|
||||
22692,18087,2706
|
||||
45233,95857,34879
|
||||
73361,3504,93705
|
||||
76075,15196,46112
|
||||
48311,66179,24825
|
||||
34847,51027,84948
|
||||
47292,8030,69406
|
||||
50439,47126,45215
|
||||
93596,85044,67201
|
||||
27358,58813,75452
|
||||
45085,37054,72302
|
||||
89734,24334,43012
|
||||
72478,22685,32664
|
||||
13127,12132,16556
|
||||
23398,74293,66782
|
||||
61561,71268,98395
|
||||
96270,6076,42180
|
||||
50808,10296,55267
|
||||
52925,75959,22868
|
||||
36728,87595,67262
|
||||
28814,20465,20025
|
||||
12451,74968,57823
|
||||
50476,74094,89126
|
||||
92049,7915,99919
|
||||
21058,86375,94191
|
||||
74248,24932,27221
|
||||
15822,62263,91376
|
||||
23190,78287,74294
|
||||
68195,26341,88255
|
||||
4845,82979,74445
|
||||
73567,99985,38328
|
||||
92793,73612,93227
|
||||
73150,70240,8129
|
||||
16401,70653,38472
|
||||
78512,46261,79432
|
||||
55273,25112,41768
|
||||
49819,52757,89101
|
||||
73147,42021,62925
|
||||
83243,86788,44561
|
||||
66035,43011,61081
|
||||
64289,30634,66383
|
||||
83767,70012,23930
|
||||
97913,46083,21133
|
||||
9049,5314,52871
|
||||
1092,22006,2463
|
||||
17713,58985,85053
|
||||
16899,76126,67622
|
||||
78048,90858,62819
|
||||
54151,57810,58786
|
||||
67174,92098,3884
|
||||
10011,87582,48423
|
||||
32956,29592,34277
|
||||
13507,83336,2828
|
||||
93095,58759,33797
|
||||
66838,21657,38777
|
||||
10676,26335,43942
|
||||
1291,15134,7925
|
||||
79979,77208,94762
|
||||
79118,61466,78970
|
||||
42589,88160,49030
|
||||
93876,56922,95185
|
||||
3002,50452,52767
|
||||
57532,69130,63834
|
||||
89846,38728,90432
|
||||
63548,17076,71966
|
||||
87517,70862,71815
|
||||
29644,77037,85317
|
||||
78262,49214,15015
|
||||
30666,50362,70396
|
||||
57299,19791,67500
|
||||
66338,13576,66395
|
||||
83998,55932,44475
|
||||
26175,38546,10889
|
||||
27860,27905,25079
|
||||
52934,22736,42941
|
||||
70279,21508,42569
|
||||
4203,78454,67282
|
||||
27116,88523,65610
|
||||
42698,68974,11616
|
||||
20366,57344,11552
|
||||
96597,29151,97534
|
||||
25441,85554,61805
|
||||
68775,84558,90829
|
||||
76047,64205,78866
|
||||
77342,5849,37724
|
||||
1922,29109,10038
|
||||
27523,56567,59191
|
||||
79457,33618,6302
|
||||
50497,10050,64942
|
||||
21488,70230,16804
|
||||
90169,94742,39467
|
||||
81555,18099,27530
|
||||
94381,33409,3824
|
||||
76817,81492,61417
|
||||
95538,36312,46905
|
||||
58182,62504,58512
|
||||
21623,13118,50040
|
||||
81905,60630,83932
|
||||
4414,49936,53420
|
||||
13002,74826,15841
|
||||
5130,55995,96493
|
||||
48551,59489,7598
|
||||
66951,51133,42542
|
||||
43324,65299,93868
|
||||
96772,17067,13303
|
||||
51115,22260,26733
|
||||
9176,24405,69907
|
||||
70491,64869,76549
|
||||
43369,94927,69970
|
||||
93191,64165,84993
|
||||
78357,12787,68510
|
||||
60545,44946,14245
|
||||
15821,42536,20696
|
||||
47660,55748,95639
|
||||
75137,19123,82285
|
||||
75810,51631,60363
|
||||
86047,38867,55048
|
||||
100,36946,47750
|
||||
22345,11738,3154
|
||||
45091,70474,4419
|
||||
54342,97968,53923
|
||||
97177,49919,32211
|
||||
86092,22756,70196
|
||||
33826,88495,34815
|
||||
80563,29717,72590
|
||||
84222,97772,63848
|
||||
48813,84268,30129
|
||||
57115,6851,90838
|
||||
19147,47880,74908
|
||||
72374,89184,26981
|
||||
61424,74801,86555
|
||||
72908,29845,46866
|
||||
17968,60598,87285
|
||||
16716,7239,54595
|
||||
63462,79864,2191
|
||||
15859,32562,83174
|
||||
26478,36049,11898
|
||||
77765,36690,38167
|
||||
39185,35029,27497
|
||||
99233,3518,35764
|
||||
15022,99868,72379
|
||||
78938,91683,54584
|
||||
2422,28525,63196
|
||||
44050,49576,53328
|
||||
61593,52079,54189
|
||||
83760,46277,2450
|
||||
89148,43262,10337
|
||||
17556,38859,31710
|
||||
61482,57351,59982
|
||||
78945,38620,94712
|
||||
42106,22783,6880
|
||||
95509,89168,35995
|
||||
77018,22089,86104
|
||||
54855,27046,83330
|
||||
24509,28772,76079
|
||||
4250,30108,35461
|
||||
80237,54491,65750
|
||||
1676,14034,3771
|
||||
97033,63273,87740
|
||||
79063,61653,85252
|
||||
27730,2579,43457
|
||||
75469,54205,40734
|
||||
56470,64558,98729
|
||||
38143,74552,90839
|
||||
92204,38520,2310
|
||||
42753,30415,74635
|
||||
62050,32618,64017
|
||||
43143,54979,89726
|
||||
29197,33521,37598
|
||||
47005,81646,89523
|
||||
43352,18117,43373
|
||||
44744,45236,2571
|
||||
75037,6652,5842
|
||||
5771,84424,35402
|
||||
88734,24291,32664
|
||||
63048,13128,62557
|
||||
36853,5680,11727
|
||||
83796,2580,73413
|
||||
90112,94485,28345
|
||||
1939,2285,51662
|
||||
71063,43005,20022
|
||||
20631,26590,21361
|
||||
28775,96713,79699
|
||||
11319,76966,8560
|
||||
96298,9538,12332
|
||||
7656,37920,91474
|
||||
80101,67962,68296
|
||||
37374,27253,17034
|
||||
61445,21364,93809
|
||||
1079,39201,76908
|
||||
5785,98392,7937
|
||||
20043,83370,29160
|
||||
85845,62515,70670
|
||||
74143,62464,19160
|
||||
99915,9289,46143
|
||||
55301,77668,74574
|
||||
65724,33701,87127
|
||||
91453,48691,2345
|
||||
23044,63807,96420
|
||||
46439,59903,84818
|
||||
77174,244,53338
|
||||
20445,38347,80785
|
||||
75801,19537,26032
|
||||
87185,33859,39604
|
||||
10257,7883,56966
|
||||
18287,71328,21000
|
||||
8129,73999,79097
|
||||
54107,45217,94045
|
||||
42488,9698,18312
|
||||
22667,75682,96602
|
||||
561,55661,82745
|
||||
5609,91767,26013
|
||||
39709,30915,90168
|
||||
44491,32022,39839
|
||||
25221,24311,87573
|
||||
38792,57973,52031
|
||||
@@ -0,0 +1,20 @@
|
||||
162,817,812
|
||||
57,618,57
|
||||
906,360,560
|
||||
592,479,940
|
||||
352,342,300
|
||||
466,668,158
|
||||
542,29,236
|
||||
431,825,988
|
||||
739,650,466
|
||||
52,470,668
|
||||
216,146,977
|
||||
819,987,18
|
||||
117,168,530
|
||||
805,96,715
|
||||
346,949,466
|
||||
970,615,88
|
||||
941,993,340
|
||||
862,61,35
|
||||
984,92,344
|
||||
425,690,689
|
||||
+55
-18
@@ -44,33 +44,70 @@ export function count_bean_splits(tm: TachyonManifold): number {
|
||||
|
||||
export function count_quantum_splits(tm: TachyonManifold): number {
|
||||
const full_tree = generate_full_quantum_tree(tm);
|
||||
console.log(">> Tree\n", full_tree.map((row) => row.join("")).join("\n"));
|
||||
const init_x = tm[0].findIndex((value) => value === "S");
|
||||
console.log(
|
||||
">> Full tree\n",
|
||||
full_tree.map((row) => row.join("")).join("\n"),
|
||||
);
|
||||
let total = 0;
|
||||
|
||||
return count_quantum_paths(full_tree, init_x, 1);
|
||||
console.log("==", tm[tm.length - 2]);
|
||||
for (let i = 0; i < tm[0].length; i++) {
|
||||
if (tm[tm.length - 2][i] === "|") {
|
||||
total += count_quantum_paths_upwards(tm, i, tm.length - 2) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
export function count_quantum_paths(
|
||||
return total;
|
||||
}
|
||||
|
||||
export function count_quantum_paths_upwards(
|
||||
tm: TachyonManifold,
|
||||
initial_x: number,
|
||||
initial_y: number,
|
||||
): number {
|
||||
let total_paths = 0;
|
||||
if (initial_y === tm.length - 2) {
|
||||
console.log(">> exit on ", { initial_y, initial_x });
|
||||
return tm[initial_y][initial_x] === "|" ? 1 : 0;
|
||||
}
|
||||
while (tm[initial_y][initial_x]) {
|
||||
const point = tm[initial_y][initial_x];
|
||||
if (point === "^") {
|
||||
console.log(">> split on ", { initial_y, initial_x });
|
||||
total_paths += count_quantum_paths(tm, initial_x + 1, initial_y + 1);
|
||||
total_paths += count_quantum_paths(tm, initial_x - 1, initial_y + 1);
|
||||
}
|
||||
initial_y += 1;
|
||||
if (initial_y === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return total_paths;
|
||||
let total = 0;
|
||||
|
||||
let current_bean = tm[initial_y][initial_x];
|
||||
while (current_bean !== "." && initial_y > 2) {
|
||||
switch (current_bean) {
|
||||
case "|": {
|
||||
const left_point = tm[initial_y][initial_x - 1];
|
||||
const right_point = tm[initial_y][initial_y + 1];
|
||||
// WRONG: the splitter existing does not mean that it has a bean
|
||||
if (left_point === "^" && right_point === "^") {
|
||||
total += 1;
|
||||
}
|
||||
if (left_point === "^") {
|
||||
total += count_quantum_paths_upwards(
|
||||
tm,
|
||||
initial_x - 1,
|
||||
initial_y - 1,
|
||||
);
|
||||
}
|
||||
if (right_point === "^") {
|
||||
total += count_quantum_paths_upwards(
|
||||
tm,
|
||||
initial_x + 1,
|
||||
initial_y - 1,
|
||||
);
|
||||
}
|
||||
|
||||
if (left_point === "^" || right_point === "^") {
|
||||
const contiues_upwards = tm[initial_y - 1][initial_x] === "|";
|
||||
if (contiues_upwards) {
|
||||
total += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
initial_y--;
|
||||
current_bean = tm[initial_y][initial_x];
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
export function generate_full_quantum_tree(
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
interface Coordinate {
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
}
|
||||
|
||||
export default async function Playground() {
|
||||
const junction_boxes_coords = await read_junction_box_3d_positions(
|
||||
"src/exercises/assets/day_8_input.txt",
|
||||
);
|
||||
console.log(
|
||||
">> Three largest pairings mul: ",
|
||||
get_three_largest_pairings_mul(junction_boxes_coords, 1000),
|
||||
);
|
||||
}
|
||||
|
||||
export function get_three_largest_pairings_mul(
|
||||
box_list: Coordinate[],
|
||||
max_pairings: number,
|
||||
): number {
|
||||
const pairing_list = generate_n_shortest_pairings(box_list, max_pairings)
|
||||
.sort((a, b) => b.length - a.length);
|
||||
let total = 1;
|
||||
for (let i = 0; i < 3; i++) {
|
||||
total *= pairing_list[i].length;
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
function generate_n_shortest_distances(
|
||||
box_list: Coordinate[],
|
||||
n: number,
|
||||
): { a: number; b: number; distance: number }[] {
|
||||
const distances: { a: number; b: number; distance: number }[] = [];
|
||||
for (let i = 0; i < n; i++) {
|
||||
const shortest_distance: { distance: number; pair_index: number[] } = {
|
||||
distance: Infinity, // Dirty, but it's late
|
||||
pair_index: [],
|
||||
};
|
||||
box_list.forEach((box, box_index) => {
|
||||
for (let next_i = box_index + 1; next_i < box_list.length; next_i++) {
|
||||
const next_box = box_list[next_i];
|
||||
const next_distance = calc_distance(box, next_box);
|
||||
|
||||
if (
|
||||
next_distance < shortest_distance.distance &&
|
||||
!distances.some((d) => d.a === box_index && d.b === next_i)
|
||||
) {
|
||||
shortest_distance.distance = next_distance;
|
||||
shortest_distance.pair_index = [box_index, next_i];
|
||||
}
|
||||
}
|
||||
});
|
||||
distances.push({
|
||||
a: shortest_distance.pair_index[0],
|
||||
b: shortest_distance.pair_index[1],
|
||||
distance: shortest_distance.distance,
|
||||
});
|
||||
}
|
||||
|
||||
return distances;
|
||||
}
|
||||
|
||||
function generate_n_shortest_pairings(
|
||||
box_list: Coordinate[],
|
||||
max_pairings: number,
|
||||
): number[][] {
|
||||
const distance_list = generate_n_shortest_distances(box_list, max_pairings);
|
||||
const circuits: number[][] = [];
|
||||
|
||||
distance_list.forEach((distance) => {
|
||||
const a = circuits.find((c) => c.includes(distance.a));
|
||||
let b = circuits.find((c) => c.includes(distance.b));
|
||||
|
||||
if (a && b) {
|
||||
b.forEach((x) => a.push(x));
|
||||
b = [];
|
||||
} else if (a) {
|
||||
a.push(distance.b);
|
||||
} else if (b) {
|
||||
b.push(distance.a);
|
||||
} else {
|
||||
circuits.push([distance.a, distance.b]);
|
||||
}
|
||||
});
|
||||
|
||||
return circuits;
|
||||
}
|
||||
|
||||
function _generate_n_shortest_pairings_old(
|
||||
box_list: Coordinate[],
|
||||
max_pairings: number,
|
||||
): number[][] {
|
||||
const circuits: number[][] = [];
|
||||
|
||||
// Pair generation
|
||||
for (let i = 0; i < max_pairings; i++) {
|
||||
const shortest_distance: { distance: number; pair_index: number[] } = {
|
||||
distance: Infinity, // Dirty, but it's late
|
||||
pair_index: [],
|
||||
};
|
||||
|
||||
// Pair boxes
|
||||
box_list.forEach((box, box_index) => {
|
||||
for (let next_i = box_index + 1; next_i < box_list.length; next_i++) {
|
||||
const next_box = box_list[next_i];
|
||||
const next_distance = calc_distance(box, next_box);
|
||||
if (
|
||||
next_distance < shortest_distance.distance &&
|
||||
!circuits.some((pairing) =>
|
||||
pairing.includes(box_index) && pairing.includes(next_i)
|
||||
)
|
||||
) {
|
||||
shortest_distance.distance = next_distance;
|
||||
shortest_distance.pair_index = [box_index, next_i];
|
||||
}
|
||||
}
|
||||
});
|
||||
// Check shortest pairings and then push
|
||||
const a_circiut = circuits.find((c) =>
|
||||
c.includes(shortest_distance.pair_index[0])
|
||||
);
|
||||
const b_circiut = circuits.find((c) =>
|
||||
c.includes(shortest_distance.pair_index[1])
|
||||
);
|
||||
|
||||
console.log(">> ", {
|
||||
circuits,
|
||||
a_circiut,
|
||||
b_circiut,
|
||||
new: shortest_distance.pair_index,
|
||||
distance: shortest_distance.distance,
|
||||
});
|
||||
|
||||
if (
|
||||
a_circiut && b_circiut
|
||||
) {
|
||||
const n_index = circuits.findIndex((p) =>
|
||||
p.includes(shortest_distance.pair_index[1])
|
||||
);
|
||||
b_circiut.forEach((b) => {
|
||||
circuits.find((p) => p.includes(shortest_distance.pair_index[0]))
|
||||
?.push(b);
|
||||
});
|
||||
circuits[n_index] = [];
|
||||
} else if (
|
||||
a_circiut
|
||||
) {
|
||||
circuits.find((p) => p.includes(shortest_distance.pair_index[0]))
|
||||
?.push(shortest_distance.pair_index[1]);
|
||||
} else if (
|
||||
b_circiut
|
||||
) {
|
||||
circuits.find((p) => p.includes(shortest_distance.pair_index[1]))
|
||||
?.push(shortest_distance.pair_index[0]);
|
||||
} else {
|
||||
circuits.push(shortest_distance.pair_index);
|
||||
}
|
||||
}
|
||||
|
||||
return circuits;
|
||||
}
|
||||
|
||||
function calc_distance(a: Coordinate, b: Coordinate): number {
|
||||
return Math.sqrt(
|
||||
Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2) + Math.pow(a.z - b.z, 2),
|
||||
);
|
||||
}
|
||||
|
||||
export async function read_junction_box_3d_positions(
|
||||
path: string,
|
||||
): Promise<Coordinate[]> {
|
||||
const file_txt = await Deno.readTextFile(path);
|
||||
const coordinates: Coordinate[] = [];
|
||||
file_txt.split("\n").forEach((raw_coord) => {
|
||||
if (!raw_coord.length) {
|
||||
return;
|
||||
}
|
||||
const coord_array = raw_coord.split(",");
|
||||
coordinates.push({
|
||||
x: parseInt(coord_array[0]),
|
||||
y: parseInt(coord_array[1]),
|
||||
z: parseInt(coord_array[2]),
|
||||
});
|
||||
});
|
||||
|
||||
return coordinates;
|
||||
}
|
||||
Reference in new issue
Block a user